Chat policy decisions are audited and revocable #2075

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

Why: today a chat turn's security events are scattered — judgement decisions keyed by turn id, approvals in the approvals store, held actions in chat.actions, tool calls in chat.events — so answering "which person, in which conversation, made which tool do what" means joining tables by hand. And while an admin can suspend an identity, that person's already-queued or running chat turns keep acting with their access, and nobody can switch a single tool off for chat without a code change.

Today:

  • modules/judgement/judgement.go Assess records every decision — level, every guard verdict, and the connector calls with credentials redacted via internal/platform/auditjson — in judgement.decisions under (org, run, key). Chat passes the turn id as RunID and "chat" as the workflow (modules/chat/tools.go call), so decisions exist but carry no person or session columns; the owner lives in chat.sessions owner_id / chat.turns. The new binary serves no audit endpoint for them: the /api/audit the old dashboard pages call is an old-service route (internal/webui/audit.go), and capabilities reports org_audit as not served.
  • Refusals by the access check in modules/chat/tools.go allowed go through the governance access Authorize; governance RecordDenial/ListDenials exist, but nothing on the chat path records a denial.
  • Approvals: modules/approvals records who answered, how and when (AnsweredBy/AnsweredVia/AnsweredAt); chat's held actions in chat.actions keep the answer payload and final state. No taint state exists yet (#2068 owns it).
  • Revocation: suspending an identity (governance Apply with CommandSuspend, modules/governance/identity.go) deletes its account sessions, and authentication refuses any non-active identity at request time (auth.go checks CanAct), so browser sessions and personal tokens stop working. But chat turns already queued or running for that owner are still claimed and run: store.Claim has no owner-lifecycle check, and actingAs in modules/chat/tools.go builds the principal via PrincipalFor without checking the owner can still act.
  • Kill switch: governance settings have an org-wide Frozen flag (the judgement Freeze guard holds every changing action at propose_and_wait), editable through PUT /api/settings — but there is no per-tool switch: modules/chat/tools.go tools exposes every connector declaration, and turning one off for chat needs a deploy.

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. Every tool decision of every chat turn — allowed, refused (hard rule / never), held — is written to one append-only audit record carrying decision ID, org, person (the session owner), session id, turn id, connector and action, decision level and reason, agent/tool versions, grant and policy revision, obligations, idempotency key where applicable, and when; the connector calls behind the decision are part of the record with credentials redacted (already collected via connectors.WithRecorder and kept on the decision) (RFC 8 audit fields; RFC 3 stage 8). The record is readable back through the control plane.
  2. Every approval event — asked, escalated, answered (by whom, approved or denied), expired, discarded — is an audit record correlated to person, session and turn (RFC 8; RFC 6 approval protocol).
  3. Every taint state change of a session is written to the same audit record with person, session and turn (RFC 8; the taint mechanism itself is #2068).
  4. Never log bearer tokens or unrestricted prompt/PII payloads; record what context was supplied and the downstream receipt for consequential actions, not a claim that a document caused the model's decision (RFC 8 audit).
  5. Detection and response: repeated cross-object denials, approval anomalies, abnormal egress or spend raise alerts with runbooks to quarantine a version, revoke bindings and reconcile effects; refusal and held records carry enough fields (person, action, level, reason) to alert on (RFC 8 detection and response).
  6. Revocation with a measurable maximum stale-access window per source and action class: suspending a person's identity ends their chat — queued and running turns are cancelled or failed visibly, no new turn of theirs is accepted, and a turn never acts as an owner whose identity is no longer active (actingAs fails when the owner cannot act; the work loop in modules/chat/turn.go skips turns of owners who cannot act; store.Claim refuses them). Pending approvals, caches and queued work for that person are invalidated, and live state is rechecked before consequential dispatch (RFC 8 revocation; RFC 6 recheck at dispatch; RFC 3 stage 6).
  7. Kill switch per tool: an instance admin can disable a tool for chat through the control plane without a deploy — a disabled tool is omitted from the turn's tool list, and if the model calls it anyway it is hard-refused with a sanitized, non-enumerating error; the refusal is audited like any other (RFC 8 circuit breakers; RFC 5.1 unknown/stale/omitted tool IDs fail at invocation; RFC 6 prohibitions first). A confirmation click never converts this refusal into a permit (RFC 6).

Out of scope: #2067 tool discovery, #2068 taint tracking itself, #2069 memory scopes and erasure, #2070 connector credential modes, #2071 admin tools refused in chat, #2072 approval binding, #2073 image/CSP rendering, #2074 budgets/rate limits, #2078 enforcement on every entry point, #2079 chat-triggered workflow execution contracts, #2080 disclosure authorization per audience/destination. The effective-permissions simulator is in no child of #2066 and is not part of this issue.

Design notes: modules/judgement already owns decision records and modules/approvals approval records — reach them only through their API packages (Judge.ForRun, approvals ForRun); the chat-correlated audit record (person + session + turn) belongs to modules/chat, which owns sessions and turns (modules/chat/internal/store). Cheapest correct shape: write the audit records from the same places that already write (call and hold in modules/chat/tools.go, Signal/settled in modules/chat/actions.go), or serve a read API joining the three stores — see open questions. Enforce the owner-lifecycle checks through the governance API (PrincipalFor plus an identity read), never by joining governance tables from the chat store — a module never reads another module's tables. Kill switch: per AGENTS.md a setting must work end to end, so if the disabled-tool list is a setting it needs an admin API plus enforcement in tools.go tools (omit from the list) and call (hard refuse). Deny by default throughout; never trust model-supplied identity; a resumed or approved-then-rerun action (runApproved) still acts as its owner and is audited under the same turn. No migration needed for existing rows — decisions are already keyed by turn id.

Tests (security boundary — table cases, fakes, no DB, per AGENTS.md; extend the fakes in modules/chat/access_test.go: fakeStore, fakeJudge, fakeToolbox, fakePeople):

  • Audit: with fake judge/approver/store, a turn that allows, refuses and holds one action each produces one audit record per decision and approval event carrying owner, session id, turn id, level and reason, with no token material (guards the person+session+turn correlation and the no-credentials rule). Must fail before the fix.
  • Revocation, one table over a fake store: when the owner's identity is not active, actingAs errors, the work loop claims no turn of that owner, and sendTurn is refused (guards "disabling a person ends their chat" within the stale-access window).
  • Kill switch: with a fake toolbox/settings, a disabled tool is absent from tools(...) and a forced call of it is refused with the sanitized error and recorded (guards the no-deploy switch and that the refusal is a hard DENY).

Done when: task check passes, and on a running binary: suspend a person with a turn in flight → the turn ends visibly (cancelled/failed), their next API call is refused, and their queued turns never run; as admin, disable a tool for chat via the control-plane API → the next chat turn does not list it, a model-forced call is refused and shown, and the turn's audit view shows every decision (allowed/refused/held), approval event and taint change with person, session and turn, and no credentials.

Open questions for the maintainer:

  1. Shape of the audit trail: a new append-only table in the chat schema written at decision time, or a read-only control-plane API joining judgement decisions, approvals and chat events? RFC 8 wants the full field set; the single binary has Postgres only.
  2. Where the disabled-for-chat tool list lives (governance settings vs a chat-module API), and whether it names connector+action pairs or whole connectors.
  3. What maximum stale-access window is acceptable for a suspended person's in-flight turn — the RFC requires a documented measurable bound, not "instant".
  4. Does "revokes their grants" mean removing the person's memberships on suspend, or refusing them at evaluation (authentication already refuses a non-active identity)?

Part of #2066.

**Why**: today a chat turn's security events are scattered — judgement decisions keyed by turn id, approvals in the approvals store, held actions in chat.actions, tool calls in chat.events — so answering "which person, in which conversation, made which tool do what" means joining tables by hand. And while an admin can suspend an identity, that person's already-queued or running chat turns keep acting with their access, and nobody can switch a single tool off for chat without a code change. **Today**: - modules/judgement/judgement.go Assess records every decision — level, every guard verdict, and the connector calls with credentials redacted via internal/platform/auditjson — in judgement.decisions under (org, run, key). Chat passes the turn id as RunID and "chat" as the workflow (modules/chat/tools.go call), so decisions exist but carry no person or session columns; the owner lives in chat.sessions owner_id / chat.turns. The new binary serves no audit endpoint for them: the /api/audit the old dashboard pages call is an old-service route (internal/webui/audit.go), and capabilities reports org_audit as not served. - Refusals by the access check in modules/chat/tools.go allowed go through the governance access Authorize; governance RecordDenial/ListDenials exist, but nothing on the chat path records a denial. - Approvals: modules/approvals records who answered, how and when (AnsweredBy/AnsweredVia/AnsweredAt); chat's held actions in chat.actions keep the answer payload and final state. No taint state exists yet (#2068 owns it). - Revocation: suspending an identity (governance Apply with CommandSuspend, modules/governance/identity.go) deletes its account sessions, and authentication refuses any non-active identity at request time (auth.go checks CanAct), so browser sessions and personal tokens stop working. But chat turns already queued or running for that owner are still claimed and run: store.Claim has no owner-lifecycle check, and actingAs in modules/chat/tools.go builds the principal via PrincipalFor without checking the owner can still act. - Kill switch: governance settings have an org-wide Frozen flag (the judgement Freeze guard holds every changing action at propose_and_wait), editable through PUT /api/settings — but there is no per-tool switch: modules/chat/tools.go tools exposes every connector declaration, and turning one off for chat needs a deploy. **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. Every tool decision of every chat turn — allowed, refused (hard rule / never), held — is written to one append-only audit record carrying decision ID, org, person (the session owner), session id, turn id, connector and action, decision level and reason, agent/tool versions, grant and policy revision, obligations, idempotency key where applicable, and when; the connector calls behind the decision are part of the record with credentials redacted (already collected via connectors.WithRecorder and kept on the decision) (RFC 8 audit fields; RFC 3 stage 8). The record is readable back through the control plane. 2. Every approval event — asked, escalated, answered (by whom, approved or denied), expired, discarded — is an audit record correlated to person, session and turn (RFC 8; RFC 6 approval protocol). 3. Every taint state change of a session is written to the same audit record with person, session and turn (RFC 8; the taint mechanism itself is #2068). 4. Never log bearer tokens or unrestricted prompt/PII payloads; record what context was supplied and the downstream receipt for consequential actions, not a claim that a document caused the model's decision (RFC 8 audit). 5. Detection and response: repeated cross-object denials, approval anomalies, abnormal egress or spend raise alerts with runbooks to quarantine a version, revoke bindings and reconcile effects; refusal and held records carry enough fields (person, action, level, reason) to alert on (RFC 8 detection and response). 6. Revocation with a measurable maximum stale-access window per source and action class: suspending a person's identity ends their chat — queued and running turns are cancelled or failed visibly, no new turn of theirs is accepted, and a turn never acts as an owner whose identity is no longer active (actingAs fails when the owner cannot act; the work loop in modules/chat/turn.go skips turns of owners who cannot act; store.Claim refuses them). Pending approvals, caches and queued work for that person are invalidated, and live state is rechecked before consequential dispatch (RFC 8 revocation; RFC 6 recheck at dispatch; RFC 3 stage 6). 7. Kill switch per tool: an instance admin can disable a tool for chat through the control plane without a deploy — a disabled tool is omitted from the turn's tool list, and if the model calls it anyway it is hard-refused with a sanitized, non-enumerating error; the refusal is audited like any other (RFC 8 circuit breakers; RFC 5.1 unknown/stale/omitted tool IDs fail at invocation; RFC 6 prohibitions first). A confirmation click never converts this refusal into a permit (RFC 6). **Out of scope**: #2067 tool discovery, #2068 taint tracking itself, #2069 memory scopes and erasure, #2070 connector credential modes, #2071 admin tools refused in chat, #2072 approval binding, #2073 image/CSP rendering, #2074 budgets/rate limits, #2078 enforcement on every entry point, #2079 chat-triggered workflow execution contracts, #2080 disclosure authorization per audience/destination. The effective-permissions simulator is in no child of #2066 and is not part of this issue. **Design notes**: modules/judgement already owns decision records and modules/approvals approval records — reach them only through their API packages (Judge.ForRun, approvals ForRun); the chat-correlated audit record (person + session + turn) belongs to modules/chat, which owns sessions and turns (modules/chat/internal/store). Cheapest correct shape: write the audit records from the same places that already write (call and hold in modules/chat/tools.go, Signal/settled in modules/chat/actions.go), or serve a read API joining the three stores — see open questions. Enforce the owner-lifecycle checks through the governance API (PrincipalFor plus an identity read), never by joining governance tables from the chat store — a module never reads another module's tables. Kill switch: per AGENTS.md a setting must work end to end, so if the disabled-tool list is a setting it needs an admin API plus enforcement in tools.go tools (omit from the list) and call (hard refuse). Deny by default throughout; never trust model-supplied identity; a resumed or approved-then-rerun action (runApproved) still acts as its owner and is audited under the same turn. No migration needed for existing rows — decisions are already keyed by turn id. **Tests** (security boundary — table cases, fakes, no DB, per AGENTS.md; extend the fakes in modules/chat/access_test.go: fakeStore, fakeJudge, fakeToolbox, fakePeople): - Audit: with fake judge/approver/store, a turn that allows, refuses and holds one action each produces one audit record per decision and approval event carrying owner, session id, turn id, level and reason, with no token material (guards the person+session+turn correlation and the no-credentials rule). Must fail before the fix. - Revocation, one table over a fake store: when the owner's identity is not active, actingAs errors, the work loop claims no turn of that owner, and sendTurn is refused (guards "disabling a person ends their chat" within the stale-access window). - Kill switch: with a fake toolbox/settings, a disabled tool is absent from tools(...) and a forced call of it is refused with the sanitized error and recorded (guards the no-deploy switch and that the refusal is a hard DENY). **Done when**: task check passes, and on a running binary: suspend a person with a turn in flight → the turn ends visibly (cancelled/failed), their next API call is refused, and their queued turns never run; as admin, disable a tool for chat via the control-plane API → the next chat turn does not list it, a model-forced call is refused and shown, and the turn's audit view shows every decision (allowed/refused/held), approval event and taint change with person, session and turn, and no credentials. **Open questions for the maintainer**: 1. Shape of the audit trail: a new append-only table in the chat schema written at decision time, or a read-only control-plane API joining judgement decisions, approvals and chat events? RFC 8 wants the full field set; the single binary has Postgres only. 2. Where the disabled-for-chat tool list lives (governance settings vs a chat-module API), and whether it names connector+action pairs or whole connectors. 3. What maximum stale-access window is acceptable for a suspended person's in-flight turn — the RFC requires a documented measurable bound, not "instant". 4. Does "revokes their grants" mean removing the person's memberships on suspend, or refusing them at evaluation (authentication already refuses a non-active identity)? Part of #2066.
sam added a new dependency 2026-11-20 08:53:48 +00:00
sam added the featurehigh labels 2026-11-20 10:04:32 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#2075