Chat approvals bind the exact action and re-check both people #2072
Notifications
Due Date
No due date set.
Blocks
Reference: sam/archie#2072
Reference in new issue
Block a user
Why: A held chat action is approved by a person and executed later, and between approval and execution the world can change: the owner's role can be revoked, the action's target can move, or the same approval can be replayed. Without the approval bound to one exact, fully resolved action and re-checked at dispatch, a prompt-injected or raced turn could get a different action run, or the same action run twice (time-of-check to time-of-use).
Today: modules/chat/tools.go hold stores a store.Action (modules/chat/internal/store/store.go) with the turn id, key, full judged Decision, request id, escalation path and step deadline. The decision's Digest (connectors.Digest in modules/connectors/connector.go) is a SHA-256 over only the action name and canonical input — not org, session, turn, connector version, target, effect or destination. modules/approvals/approvals.go Ask stores the request with that digest, decision id and deadlines (idempotent on run+key); Settle verifies a channel identity (people.Verify) and mayAnswer (approver, on the escalation path, authority at Escalate level) and records refusals; Answer.Approval binds decision id + digest. The dashboard answer endpoint records the answer as the bootstrap admin without the mayAnswer check the channel path has. modules/chat/actions.go Signal stores the answer only while the action is waiting (store.Answer updates only where state = 'waiting'); settleActions → runApproved re-reads the owner's current principal (actingAs in tools.go), re-checks allowed(ActionRun, KindConnector), re-assesses a fresh decision and invalidated discards it if the target, effect or level changed or it is now Never; store.Move from approved to running is the run-once guard; judgement.ExecuteApproved runs only when Approval.Covers (decision id + digest) and the input digest equals the judged digest, running the frozen held action's input with the idempotency key. connectors.Connector.Invoke reports the executed digest and a mismatch is refused (ErrDigestMismatch); an unknown outcome is reported and never retried blindly (ErrOutcomeUnknown).
Source: the revised RFC exported at transcripts/2026-11-20-chat-authorization-rfc-3fa43269.md in sam/archie-product; citations below are RFC section numbers.
Required behaviour:
Out of scope: #2067 tool discovery and admission filtering; #2068 taint tracking; #2069 memory scopes; #2070 connector credential modes; #2071 admin actions refused in chat; #2073 image/CSP rendering; #2074 budgets and rate limits; #2075 audit, revocation and kill-switch; #2078 enforcement on every entry point; #2079 chat-triggered workflow execution contracts; #2080 disclosure authorization per audience and destination; plus anything else this issue does not cover.
Design notes: modules/chat owns the held-action record and the binding digest stored alongside the decision in store.Action; modules/approvals owns the request, answer verification (Settle and the dashboard answer endpoint) and idempotent Ask; modules/judgement owns Approval.Covers and ExecuteApproved. Keep connectors.Digest as the wire contract the connector SDK reports back as the executed digest; compute a separate binding digest over the wider tuple on top of connectors.Canonical output — and after any reserved-context injection from #2070, so the judged action is the run action. Reuse the existing state guards: store.Answer's waiting-only update and store.Move's from-state check are the exactly-once seams; waitKey routes the answer. The answer must never travel through the LLM prompt: the card posts to the control-plane API and runApproved executes from the stored decision. Pitfalls: a resumed turn must still act as its owner (actingAs reads the owner's current memberships); deny by default if any binding field is missing. Migration: held actions stored before this change carry only the narrow digest — discard them on upgrade (they can be asked again) rather than re-binding them.
Tests (security-seam table tests with fakes, no DB, per AGENTS.md):
Done when: approving a held chat action from the card runs it once with exactly the approved arguments; answering again returns already-answered; revoking the owner's access while pending discards the approval and nothing runs; changing the target while pending discards it; letting the deadline pass expires it unrun; an answer arriving as chat text is not accepted. Manual check on a running binary: trigger a held action in chat, approve on the card, watch it run once in the turn's tool calls; replay the answer through the API and get a conflict; wait out the deadline and see the action expire unrun.
Open questions for the maintainer:
Part of #2066.