Skip to main content

Module verify_gate

Module verify_gate 

Source
Expand description

Verify-before-finish gate (#2279): rejects a premature finish_task with a recoverable retry when a named test command was never run.

Why: (bake-off L2 diagnosis) An engineer that never runs the visible, prompt-named test suite can still call finish_task successfully today; this module gives both the delegated engineer’s loop and the delegating PM’s loop a turn-boundary hook to reject that specific case. What: agent_loop::FinishGate constructors default_finish_gate (own transcript) and pm_finish_gate (externally shared engineer transcript), plus the pure names_test_command/is_test_command regex predicates they share. Test: verify_gate::tests::*. Verify-before-finish gate (#2279): a recoverable retry, not a hard block, that keeps a coding agent from calling finish_task before it has run a test suite it was explicitly told about.

Why: (bake-off L2 diagnosis) tcode’s delegated engineer authored 81 tests validating the wrong contract and never ran the visible, prompt-named test suite the L2 challenge instructed it to run before submitting. The task prompt and challenges/README.md (folded into project context) named a runnable test command (pytest challenges/level-2-git-analyzer/ test_suite/ -v); the transcript never shows it being invoked. This module is the structural fix: at the finish_task turn boundary (agent_loop::AgentLoop::dispatch_all), if the task/project-context text names a runnable test command AND no matching bash invocation appears in the relevant transcript, finish_task is rejected with a recoverable error — the SAME ToolResult::err retry path every other tool failure uses — instead of terminating the loop. If no test command is named at all, the gate is INERT: #2279 explicitly defers general polyglot test-suite discovery (the “(b2)” follow-up) rather than inventing one here. What: names_test_command and is_test_command are pure, independently unit-testable regex predicates — Improvement 2’s own testability principle applied to its sibling Improvement 1. Two agent_loop::FinishGate constructors build on them: default_finish_gate scans a single loop’s OWN Transcript — what a delegated engineer’s sub-agent loop attaches (runner::in_process::InProcessAgentRunner), since its own bash calls land directly in that transcript. pm_finish_gate is for the delegating PM’s loop, which never calls bash itself — it scans the externally shared run_task::SharedTranscript of TurnRecords the delegated engineer’s turns are recorded into instead, via each record’s ran_test_command flag (set by run_task::recorder::RecordingLlmClient using the SAME is_test_command predicate this module owns, so the two paths can never independently drift on what counts as a matching invocation). What (#8206): naming a test command is necessary but no longer sufficient. Both gates additionally require that a test command be DETECTABLE for the bound project (detect::detect_test_command) and — for the engineer gate — that the agent’s own registry carry bash to run it with. When either fails, finish_task is ACCEPTED and the completion report records that no test command ran and why; only a detectable, runnable, unrun suite still produces a refusal, and that refusal names the manifest or command it detected. Test: verify_gate::tests::*.

Modules§

detect
#8206: project-side detection of a runnable test command, the precondition the #2279 verify-before-finish trigger was missing.

Structs§

VerifyGateContext
The project/tooling facts the engineer gate needs beyond the prompt text.

Enums§

FinishGateOutcome
What a FinishGate decided about a successful finish_task call.

Functions§

bash_command_from_call
Extract the shell command from a bash tool call’s arguments, if call names the bash tool at all.
default_finish_gate
Build the default verify-before-finish gate: scans the SAME loop’s own transcript for both the trigger and the verification.
is_test_command
Whether command (a bash tool call’s shell command) IS a matching test invocation (the gate’s VERIFY half).
named_test_command
The test command text names, as the matched substring (#8206).
names_test_command
Whether text textually names a runnable test command (the gate’s TRIGGER half).
pm_finish_gate
Build the delegating PM’s verify-before-finish gate: the trigger comes from the PM’s own transcript, but the verification scans the externally shared engineer transcript instead.