Chat approvals bind the exact action and re-check both people #2072

Open
opened 2026-11-20 08:41:09 +00:00 by sam · 0 comments
Owner

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:

  1. Each held chat action persists an immutable PendingAction carrying tenant, initiator, authorized-approver predicate, session/turn, agent/tool/workflow versions, connector account (binding mode), resolved target ids and versions, canonical arguments, destination, payload or attachment digest, effect, expiry and a single-use id — and the approval is bound to an unambiguous (canonical) encoding of that whole record, not just action name and input. (RFC 6)
  2. Approval is accepted only through an authenticated, CSRF-protected control-plane endpoint — never a chat message — and the answering person must satisfy the approver predicate; the dashboard answer path runs the same verified-person check as the channel path instead of recording the bootstrap admin. Fresh authentication or transaction-bound signing is required at the risk levels that need it. (RFC 6, RFC 3 stage 5)
  3. The approver sees a deterministic trusted-UI preview of the material effects — actual recipients, body and attachments for a message; account, charge, amount and currency for a refund — and the approver must be allowed to see that preview. (RFC 6; the corrected refund decision table is the worked example)
  4. At dispatch, recheck current authority (a fresh principal from current memberships), kill switches, object state and limits; material changes — target, effect, level, approver predicate, connector account, destination — require a new proposal, and the old approval is discarded, not stretched. (RFC 6, RFC 3 stage 6)
  5. Consume approvals atomically and run exactly once: the approved → running transition succeeds at most once, the input must digest to the bound digest, the approval must cover that exact decision, and the connector idempotency key is passed through; on an unknown downstream outcome, reconcile against the receipt before any retry. (RFC 6)
  6. A confirmation never converts a prohibition: approving a DENY is invalid and runs nothing (enforced per #2071). (RFC 6)
  7. Replayed answers, expired actions and unavailable policy, ACL or account lookup all fail closed: nothing runs. (RFC 6, RFC 1)

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):

  • Binding digest table test: it changes when any of org, session, turn, connector, action, target, effect or canonical arguments changes, and is stable across key reordering — guards TOCTOU coverage of the full record.
  • modules/approvals with a fake People: an identity no person holds is refused and recorded; an off-path person is refused; an on-path approver is accepted — guards the approver check.
  • modules/approvals: the dashboard answer path refuses a signed-in person who may not answer this request — guards closing the bootstrap-admin bypass.
  • chat store semantics with fakes: answering a held action twice, the second is not accepted; moving approved → running twice, the second fails — guards replay and double execution.
  • modules/judgement: ExecuteApproved with an approval naming another decision or another digest returns ErrUnapproved; canonically respelled arguments still run; different arguments return ErrAltered — guards frozen-argument binding.
  • chat runApproved with fakes: the owner's access revoked while pending discards the approval and nothing runs; the target or effect changed while pending discards it — guards the dispatch-time recheck.

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:

  • At which risk levels must the control-plane answer endpoint require fresh authentication or transaction-bound signing rather than an ordinary session click? RFC 6 leaves the risk levels to policy.

Part of #2066.

**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**: 1. Each held chat action persists an immutable PendingAction carrying tenant, initiator, authorized-approver predicate, session/turn, agent/tool/workflow versions, connector account (binding mode), resolved target ids and versions, canonical arguments, destination, payload or attachment digest, effect, expiry and a single-use id — and the approval is bound to an unambiguous (canonical) encoding of that whole record, not just action name and input. (RFC 6) 2. Approval is accepted only through an authenticated, CSRF-protected control-plane endpoint — never a chat message — and the answering person must satisfy the approver predicate; the dashboard answer path runs the same verified-person check as the channel path instead of recording the bootstrap admin. Fresh authentication or transaction-bound signing is required at the risk levels that need it. (RFC 6, RFC 3 stage 5) 3. The approver sees a deterministic trusted-UI preview of the material effects — actual recipients, body and attachments for a message; account, charge, amount and currency for a refund — and the approver must be allowed to see that preview. (RFC 6; the corrected refund decision table is the worked example) 4. At dispatch, recheck current authority (a fresh principal from current memberships), kill switches, object state and limits; material changes — target, effect, level, approver predicate, connector account, destination — require a new proposal, and the old approval is discarded, not stretched. (RFC 6, RFC 3 stage 6) 5. Consume approvals atomically and run exactly once: the approved → running transition succeeds at most once, the input must digest to the bound digest, the approval must cover that exact decision, and the connector idempotency key is passed through; on an unknown downstream outcome, reconcile against the receipt before any retry. (RFC 6) 6. A confirmation never converts a prohibition: approving a DENY is invalid and runs nothing (enforced per #2071). (RFC 6) 7. Replayed answers, expired actions and unavailable policy, ACL or account lookup all fail closed: nothing runs. (RFC 6, RFC 1) **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): - Binding digest table test: it changes when any of org, session, turn, connector, action, target, effect or canonical arguments changes, and is stable across key reordering — guards TOCTOU coverage of the full record. - modules/approvals with a fake People: an identity no person holds is refused and recorded; an off-path person is refused; an on-path approver is accepted — guards the approver check. - modules/approvals: the dashboard answer path refuses a signed-in person who may not answer this request — guards closing the bootstrap-admin bypass. - chat store semantics with fakes: answering a held action twice, the second is not accepted; moving approved → running twice, the second fails — guards replay and double execution. - modules/judgement: ExecuteApproved with an approval naming another decision or another digest returns ErrUnapproved; canonically respelled arguments still run; different arguments return ErrAltered — guards frozen-argument binding. - chat runApproved with fakes: the owner's access revoked while pending discards the approval and nothing runs; the target or effect changed while pending discards it — guards the dispatch-time recheck. **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**: - At which risk levels must the control-plane answer endpoint require fresh authentication or transaction-bound signing rather than an ordinary session click? RFC 6 leaves the risk levels to policy. Part of #2066.
sam added a new dependency 2026-11-20 08:53:11 +00:00
sam added the featurehigh labels 2026-11-20 10:04:31 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#2072