Repository navigation
approvals: implement the lifecycle that outlives the run (ADR-0029) - #12
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements ADR-0029 (#11). Six commits, one per layer.
The invariant, tested first: a
deferredpolicy raises before_run_toolon every path, including the parallel one. The run endspending_approvalwithRunResult.pendingcarrying the id, and the tool has not run —test_a_deferred_approval_stops_before_the_tool_runsasserts the side-effect counter is empty.How resume works:
resume_run(spec, run_id, approved=…, approver=…)refuses an unknown run, a subagent, a run that is not suspended, an already-answered approval, and one whose stored arguments no longer match their SHA-256 digest (an edited request cannot become a different approval). It then records the verdict once underBEGIN IMMEDIATE, rebuilds the transcript fromlog.messages()+ the system prompt, re-runson_tool_call— the post-transform arguments are deliberately never logged (ADR-0025), so this is how resume recovers what would have executed — executes only the calls with notool_result, and re-enters the same step engine atfirst_step = model calls + 1.That last part is the riskiest edit: the step loop moved out of
run_agentinto_drive(...), which bothrun_agentandresume_runcall. It was lifted verbatim by script, and the 379 pre-existing tests still pass unchanged.Surfaces:
harness approvals/harness approve <manifest> <id> [--deny] [--as NAME](a suspended run exits 3), andGET /api/approvals/POST /api/approvals/{id}behind the existing bearer token.Honest limits, all in the ADR and the threat model:
approveris a self-declared label. Authority is possession of the channel (token or terminal); the harness has no accounts and no doc claims an identity.RIGGING_APPROVAL_TTL_S(24h default), even if the caller says yes.run_idafter resume — OTLP cannot hold a span across processes.17 tests added (11 lifecycle, 2 CLI, 1 service, plus the route-list update).
ruff+mypy --strictclean; 390 offline tests green.