Skip to content

feat(work-driver): driver-side outcome-verification gates (executed evidence, not transcripts) - #270

Merged
randomm merged 1 commit into
mainfrom
feat/work-driver-verify-gates
Jul 24, 2026
Merged

feat(work-driver): driver-side outcome-verification gates (executed evidence, not transcripts)#270
randomm merged 1 commit into
mainfrom
feat/work-driver-verify-gates

Conversation

@randomm

@randomm randomm commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

Top-ranked item from the harness gap analysis (9-agent research workflow: codebase inventory + surveys of Claude Code/Codex/OpenHands/Aider + MAST failure-mode research, synthesized across operator-pain / competitive-gap / reliability lenses — unanimous #1 across all three).

The gap. Every quality gate before this PR is LLM judgment — adversarial + six lenses reading diffs and transcripts. Nothing driver-side ever executes anything until post-PR CI. Agents claim "done" and the driver trusts the claim; the #245/#253 silent-merge incidents were exactly this class (MAST: verification failures = 21.3% of multi-agent failures). Codex, OpenHands, and Claude Code hooks all gate on execution exit codes.

The fix. After develop (all branches claiming success) and after commit-pr (consolidation gate passed), the driver checks executed evidence — zero LLM tokens:

Step Checks
develop ≥1 worktree has a real diff (porcelain, or commits ahead of baseSha recorded at branch step); project verify command exits 0 in each changed worktree
commit-pr commits exist ahead of origin/<base>; PR number resolves via gh pr view; missing pr: marker triggers gh pr list --head repair that adopts the found number

Failure → cap verify-failed:<step> → handoff, evidence in pipelineState.verifyEvidence, rendered by explainCap.

Verify-command discovery (verifyCmdFor): .pi/verify-cmd file > package.json typecheck/test script with lockfile-detected runner (bun/pnpm/yarn/npm) > Cargo.tomlcargo check --quiet > none (diff-evidence-only, noted).

Env knobs: PI_ENSEMBLE_VERIFY=0 escape hatch; PI_ENSEMBLE_VERIFY_TIMEOUT_MS (default 10 min).

Changes

File Change
extension/src/work-driver.ts verifyStepOutcome + verifyCmdFor + wiring in runDevelop/runCommitPr + baseSha capture in runBranch + explainCap branch + DriverContext.verifyExecFn injection point
extension/src/workflow-state.ts verify-failed:<step> cap shape; baseSha, verifyEvidence optional fields (no schema bump)
extension/smoke-tests/test-work-driver.ts 21 new assertions; gate disabled globally for flow tests (fake tmp dirs), dedicated tests re-enable with injected executor
README.md, AGENTS.md, docs/troubleshooting.md Pipeline descriptor + §7 + new "Outcome-verification gates" section

Test plan

  • bunx tsc --noEmit clean
  • bun run check (biome) clean
  • All 26 offline smoke tests pass (21 new gate assertions)
  • CI green
  • Live on nessie: normal /work N passes the gates transparently (cargo check ~1-3 min per develop)
  • Live hollow-claim test: mock developer that touches nothing → verify-failed:develop handoff with evidence
  • Live pr: marker repair: cycle where ops omits the marker → gate adopts the number via gh pr list --head

Non-goals (next items from the gap analysis)

References

…vidence, not transcripts)

Every quality gate before this PR was LLM judgment — adversarial + six
lenses reading diffs and transcripts. Nothing driver-side ever EXECUTED
anything until post-PR CI. Agents claim "done" and the driver trusted
the claim; the #245/#253 silent-merge incidents were exactly this
failure class (MAST: verification failures = 21.3% of multi-agent
failures). Top-ranked item from the harness gap analysis — unanimous
across operator-pain, competitive-gap, and reliability lenses.

New machinery (all pure driver code, zero LLM tokens):

- `verifyStepOutcome(ctx, state, step)` — the gate.
  - develop (runs when every branch claims success): at least one
    worktree has a real diff (porcelain, or commits ahead of baseSha);
    the project's verify command exits 0 in each changed worktree.
  - commit-pr (runs when the consolidation gate passes): commits exist
    ahead of origin/<base>; the parsed PR number resolves via
    `gh pr view`. Missing `pr:` marker triggers a `gh pr list --head`
    repair that ADOPTS the found number into pipelineState (pre-PR17 a
    missing marker silently degraded handoff/CI targeting).
- `verifyCmdFor(repoRoot)` — verify-command discovery: `.pi/verify-cmd`
  file > package.json typecheck/test script with lockfile-detected
  runner (bun/pnpm/yarn/npm) > Cargo.toml → `cargo check --quiet` >
  none (diff-evidence-only mode, noted).
- `PipelineState.baseSha` — recorded at branch step (git rev-parse HEAD
  right after branch creation); optional, no schema bump.
- `PipelineState.verifyEvidence` — per-check failure evidence, rendered
  into the handoff body by explainCap.
- New cap shape `verify-failed:<step>` → handoff.
- `DriverContext.verifyExecFn` — test injection point (mirrors
  issueBodyFetcherFn).

Env knobs: PI_ENSEMBLE_VERIFY=0 escape hatch;
PI_ENSEMBLE_VERIFY_TIMEOUT_MS caps the verify command (default 10 min).

Tests: 21 new assertions (discovery precedence, hollow-claim detection,
verify-cmd failure evidence, PR adoption repair, explainCap rendering).
The gate is disabled globally in test-work-driver.ts flow tests (fake
tmp dirs aren't git repos); dedicated gate tests re-enable it with an
injected executor.

Verified: tsc + biome + all 26 offline smokes pass.
@randomm
randomm merged commit 003fb46 into main Jul 24, 2026
1 check passed
@randomm
randomm deleted the feat/work-driver-verify-gates branch July 24, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant