Repository navigation
fix(system-agent): apply approved proposal exactly once - #119389
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 10:22 PM ET / August 5, 2026, 02:22 UTC. ClawSweeper reviewWhat this changesThe PR makes system-agent operator approval consume and directly execute the hash-verified stored persistent operation once instead of starting another model turn to recreate it. Merge readinessKeep open: current main still reconstructs an agent-loop-approved operation through a second model turn, while this exact head replaces that path with the shared guarded executor and has no blocking review finding. Priority: P1 Review scores
Verification
How this fits togetherA system-agent turn can retain a hash-bound persistent operation while an operator approves it through the Gateway. The resolver validates and consumes that proposal, then the chat engine applies it through the persistent-operation executor, audit, and post-write verification flow. flowchart LR
A[System-agent turn] --> B[Stored hash-bound operation]
B --> C[Gateway operator approval]
C --> D{Hash matches?}
D -->|No| E[No-op]
D -->|Yes| F[Consume proposal]
F --> G[Guarded persistent executor]
G --> H[Audit and verified outcome]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +3, Tests +14. Total +17 across 3 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one authoritative hash-bound operation path for both agent-loop and host-seeded approvals, and land this repair after the exact-head gate passes. Do we have a high-confidence way to reproduce the issue? Yes. Current source gives a direct path: an agent-loop proposal supplies a stored operation and matching hash, then operator approval invokes a second model turn; the submitted isolated production-path canary demonstrates the repaired path with a persisted write and duplicate no-op. Is this the best way to solve the issue? Yes. Applying the already hash-verified operation at the approval owner removes probabilistic reconstruction while retaining the shared executor's inference revalidation, audit, and post-write checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 50c7444edf4b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
1ef8982 to
b7bb45e
Compare
|
Addressed both review moves at
The PR body now contains the command and redacted canary result. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
b7bb45e to
7c1df91
Compare
|
Final exact-head refresh: @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merge-ready at HEAD |
|
Merged via squash.
|
) Co-authored-by: Chris Davidson <[email protected]>
What Problem This Solves
Fixes #119387.
A delegated system-agent can freeze a persistent operation in
agentSession.proposalRef.operation, bind it to a stable hash, and publish that proposal for human approval. On currentmain, approving that hash does not execute the frozen operation. The approval helper discardsproposal.operation, emits a synthetic approval chat message, and starts a second model turn withapprovalArmed: true.That makes the operator-visible approval non-authoritative: the post-approval model can return a different directive, return no directive, or fail before applying anything. The operation that runs is reconstructed by inference rather than being the immutable operation the human approved.
Why This Change Was Made
The approval boundary already owns the authoritative
{ operation, hash }pair. The canonical fix is to preserve that object through the decision helper and apply the exact operation at the existing approved-operation executor.This change:
proposal.operationthroughresolveOperatorApprovalDecision;applyApprovedPersistentOperation(operation)directly;[proposal-resolved]marker for the next conversational turn.Rejected alternative: keeping the synthetic message and strengthening its prompt still delegates an operator-owned security decision back to probabilistic inference. The exact operation is already available, so another model round trip is neither necessary nor the approved action.
Adjacent work is unaffected: #117432 addresses delegated messaging handoff/copy, while #118960 addresses gateway approval-bus routing. Neither changes this post-approval execution boundary.
Production delta:
+17/-14across the approval helper and chat engine. Test delta:+25/-11.User Impact
System-agent approvals now apply exactly the persistent operation shown to and approved by the operator. They no longer depend on a provider/model response after approval.
A wrong hash remains a no-op. A duplicate approval callback remains a no-op. Delivery, approval UI, proposal hashing, operation validation, inference binding checks, post-write verification, and audit behavior are unchanged.
Evidence
Verified after rebasing onto fetched
upstream/main50c7444edf4be40a075d3689bec8fd5b676c2843; exact PR head7c1df916dd9beba99655525d77c673fb406143a1.Isolated real-write approval canary
The after-fix canary used a fresh temporary
OPENCLAW_STATE_DIRandOPENCLAW_CONFIG_PATH, the productionSystemAgentChatEngine, production approval resolver, production operation executor, and production config writer. It queued one delegatedconfig-set, resolved a wrong hash, approved the exact hash, retried the same callback, and read the persisted config back from disk.It did not start a Gateway, use the household config, or touch
~/.openclaw.{ "liveStateUntouched": true, "queuedForOperator": true, "wrongHashNoOp": true, "appliedExactlyOnce": true, "duplicateNoOp": true, "modelTurns": 1, "persistedGatewayPort": 19001 }The temporary config began with
gateway.port = 18789. The exact approved operation persisted19001. No second model turn ran, and the temp state directory was removed after verification.Focused tests
The regression coverage proves the initial proposal capture, wrong-hash no-op, exact operation/value delivery, one-shot consumption, duplicate no-op, source-neutral next-turn marker, and gateway session notification.
Static checks
All passed.
Independent review
AI-assisted by Codex. The source path, authorization invariant, callers, sibling paths, focused tests, isolated real-write behavior, and final diff were reviewed before submission.