Skip to main content

Module completion_contract

Module completion_contract 

Source
Expand description

Completion contracts: evidence-based verification that a sub-agent’s task is actually done, instead of trusting its self-report.

A contract is a small list of machine-checkable exit criteria declared at spawn time (exit_criteria on sessions_spawn). When the sub-agent finishes, the runtime executes every criterion and annotates the result with per-criterion evidence — “done” then means verified done (v0.4.0 item C+E in docs/roadmap/competitive-intel-update-2026-07.md).

Safety model:

  • File criteria only accept RELATIVE paths and resolve inside the chat’s working directory — a contract cannot be used to probe ~/.ssh or other host paths, and evidence excerpts are capped.
  • Command criteria run through the sub-agent’s own bash tool via CommandRunner, so the sandbox router, dangerous-pattern checks, and tool_policy all apply exactly as if the agent had run the command.

Structs§

CriterionOutcome
Outcome of checking one criterion.

Enums§

ExitCriterion

Constants§

MAX_CRITERIA
Hard cap on criteria per contract — a contract is a checklist, not a test suite; anything larger belongs in an actual test the agent runs itself.

Traits§

CommandRunner
Executes Command criteria. Production wires this to the sub-agent’s bash tool; tests use a stub.

Functions§

parse_exit_criteria
Parse the exit_criteria tool-input value. None when absent/null; errors on malformed entries so bad contracts fail loudly at spawn time instead of silently verifying nothing.
render_for_prompt
Render the contract for the sub-agent’s task prompt so it knows exactly what will be checked when it declares completion.
render_report
Render the verification block prepended to the sub-agent’s result text.
verify_criteria
Check every criterion and collect evidence. Never panics; unreadable files or runner errors surface as failed criteria with the error as evidence (fail closed).