ADR-0027 — Platform write-tool confirm & execute-on-approve (Quad mutating tools; seat-bound external decisions — Amendment 1, 2026-11-13)
- Status: Accepted (Principal Architect, 2026-07-25) — amended 2026-11-13 (Amendment 1,
upsquad-ai/upsquad-core#4420, founder ruling): a trigger, answer or decision recorded through a login-bound (seat) external credential is that human's decision, audited as agent + member; unbound credentials stay confirm-gated under D1–D5 and stamp the agent. See Amendment 1. Original: resolves the #2120 mechanism escalation. Extends ADR-0026 D5 ("writes get an explicit fail-closed gate; always trip requires_approval / in-thread confirm") by fixing the mechanism D5 left open. No founder product gate (the feature + the Quad-agent-clearance rule were green-lit; no stack / dependency / secret / external-egress change). - Date: 2026-07-25
- Deciders: Principal Architect (author + decision), Backend SME (implementation feasibility / escalation)
- Refs: #2120 (Quad mutating tools + this ruling), #2146 (deferred team-tool
-32001HITL fix), upsquad-client#655 (in-thread confirm card). Amendment 1:#4420(ruling; tracker#4419),#4426(X2 — login-bound seat identity,external_agent_clients.member_id), PR#4433(X1 — external platform MCP contract,internal/platformmcp/external_contract.go),#4425(X1 build),#4348(governance-filteredtools/list); ADR-0020 / ADR-0023 Amendment 1 (same ruling). Extends ADR-0026 D5. Reuses ADR-0024 (MCP tool governance), the subagent LLD 14 async-approval pattern, and thememory_review(AML LLD #2069 §5) cross-service execute-on-approve topology.
Context
ADR-0026 built the /mcp/platform dispatch surface and its read tools (#2119). D5 said mutating tools (#2120 — trigger_workflow, record_decision) must be fail-closed and "always trip requires_approval (in-thread confirm)", but did not specify the confirm→execute mechanism. Implementation of #2120 surfaced that the implied mechanism (worker requires_approval → InterruptRequiredEvent → user confirms → resume → execute) is not wired for platform MCP tools. Verified against origin/main:
- The worker skips its governance pre-check for MCP-namespaced tools (
services/agent-worker/.../graph/nodes.py:808,governance_skip_mcp_edge, ADR-0024 D2). The platform tools areupsquad__{tool}andupsquadis an allowed prefix, so the in-step interrupt (_governance_decide_tool→decision.suspend) never fires for them. - The gateway
-32001"approval-required" envelope collapses to a plain tool error inmcp/client.py::_dispatch_call(~L405-413) — a pre-existing dead-end for all MCP-tool HITL, not just platform. - The platform/agent token carries no
session_id(internal/auth/oauth/agent_token.gopayload), so a session-keyed approval dedup/resume cannot key on/mcp/platform. GovernanceService.Checkre-gates on resume —engine.go:334/377creates a new approval on everyRequiresApprovaland never consults a resolved one; there is notool_callActionTypeHandler, so a resumed re-call re-gates → confirm loop.- Cross-service split —
WorkflowServicelives in context-engine;approval.Service/RecordDecision+ theActionTypeHandlerexecute-on-approve seam live in agent-orchestrator; the orchestrator holds no WorkflowService client.
Three mechanisms were proposed: A (worker interrupt surface + session-scoped approval + resume marker — most literal, also fixes the team-tool dead-end), B (resource-scoped confirm approval + execute-on-approve ActionTypeHandler — the org_draft_publish #1585 / subagent LLD 14 / memory_review pattern), C (in-context-engine confirm_token two-call — ships today, LLM-driven confirm).
The founder constraint is non-negotiable: mutations always confirm in-thread; the user authorises, never the LLM; Quad-agent clearance (user−1, floor 1); fail-closed; no silent mutation.
Decision
D1 — Mechanism B. Reject C. Defer A.
Amendment 1, 2026-11-13 — ACCEPTED (founder approval from his own account,
#4420comment6849892608; ruling text#4419comment6776135827item 3). D1–D5 below describe the agent-stamped path: the caller is an agent (Quad, or an external client on an unboundclient_credentialsgrant), so the human must authorise through a confirm approval. For a caller on a login-bound seat credential, the human is the caller: atrigger_workflow,answer_run_promptorrecord_decisionissued through it is that human's decision, executes directly, and is audited as agent + member. The invariant D2 protects — the user authorises, never the LLM — is satisfied by the seat, not by a second approval row. Details in Amendment 1.
- C is rejected on security grounds: the LLM holds the
confirm_token, so a prompt-injection or a compliant-but-wrong model can issue both calls and self-confirm without the user — a direct violation of "no silent mutation / the user authorises." (A one-time, args-bound token may appear inside B as defence-in-depth binding the approved mutation to exact args, but it is never the authorisation.) - A is deferred to #2146 (LLD-first): it is the most literal
InterruptRequiredEvent, but it requires teaching the worker to recognise-32001, rebuilding the worker interrupt/resume lifecycle for MCP tools, breaking the resume re-gate, and addingsession_idto the token — a large multi-language blast radius that fixes a pre-existing global MCP-HITL gap platform writes do not need. - B is adopted: it reaches the same security property (the user authorises a durable approval; the mutation executes server-side; fail-closed; no re-gate) with far less surface and two proven in-tree precedents — subagent LLD 14 (async approval + execute-on-approve) and
memory_review(a context-engine resource whose approval an orchestrator-registeredActionTypeHandlerresolves on approve). The latter is exactly thetrigger_workflowtopology, so finding 5 is a solved pattern, not a new one.
D2 — The security invariant (binds every part of the implementation).
- A write tool handler NEVER mutates. Its only effects are a clearance check and creating one resource-scoped confirm approval (a
governance_approvalsrow) carrying the mutation payload + a writeActionType+ a human summary, then returningconfirmation_required{approval_id, summary}. - The mutation is performed exclusively by an orchestrator-registered
ActionTypeHandler.Approved, invoked by the existing user approve →RecordDecisionpath, only when the approval resolves approved. Denied → no-op. - No path from the LLM/worker can cause the mutation without a user-resolved approved approval; the LLM can only trigger step 1 and cannot self-approve.
- Above the Quad agent's clearance floor → friendly refusal + deep link; no approval created, no mutation.
D3 — Fail-closed gate is deterministic, not policy-dependent (PlatformGovEngine, extends the ADR-0026 ReadAllowEngine).
- read Resource (
workflow.read) → Allow (unchanged). - write Resource (
workflow.trigger,approval.decide) withAction.Clearance ≥ floor(action)→ RequiresApproval (async mode) — the deterministic confirm gate; it does not depend on a seeded per-org policy (which would default-deny and block the tool). - write Resource with
Action.Clearance < floor(action)→ Deny, reason = the friendly refusal + deep link (the/mcp/platformroute already surfaces a governance deny as anisErrortool result the LLM relays). Enforces "Quad-agent clearance (user−1); above-floor refuses" at the gate with no orphaned approval. - else →
inner.Check(fail-closed default-deny). The route injects the Quad agent's inferred clearance (InferAgentClearance, parent−1, floor 1) intomiddleware.Identity.Clearancefor write tools (reads keep 0 — UX-only projection).
D4 — Execute-on-approve is server-side, stamped as the Quad agent.
quad_workflow_trigger.Approved →WorkflowService.TriggerWorkflowvia a new orchestrator→context-engine gRPC client (the one net-new wiring piece), stamped with the Quad agent's org +agent_idfrom the approval metadata at Quad clearance — not the approving user (preserves the #2120 founder ruling: Quad-mediated mutations act at the Quad agent's clearance, not viewer-stamped).quad_record_decision.Approved → in-processapproval.Service.RecordDecisionon the target workflow approval (the confirm approval and the workflow gate are two distinct approvals).- Both
.Denied→ no-op + a "cancelled" surface; idempotent (a handler may fire more than once).
D5 — In-thread confirm surface. Under B the surface is a confirmation_required tool result (not an interrupt_required stream arm). The client renders it as an in-thread confirm card (summary + Confirm/Cancel) that resolves approval_id via the existing approve/reject API — tracked in upsquad-client#655 (the existing quad-approval-banner is subagent-bubble-scoped). Backend ships a graceful deep-link fallback (the LLM relays the summary + an approvals-surface link) so the mutation path never dead-ends if the card lands later; #2120's "in-thread confirm" acceptance is fully met once the card is live.
Consequences
- Positive: genuine user-authorised confirm with server-side execution, fail-closed by construction (the handler cannot mutate); reuses two proven patterns and adds only one net-new gRPC client; no re-gate loop; needs neither
session_idin the token nor changes to the worker interrupt lifecycle; extensible to future platform write tools (register a new write Resource +ActionTypeHandler). - Negative / cost: two approvals exist for
record_decision(the confirm approval + the target workflow gate) — deliberate and mirrors the two-step nature of the action; a new orchestrator→context-engine WorkflowService client; a client companion (upsquad-client#655) is required for the richest UX (deep-link fallback bridges the gap). - Security: internal surfaces only; tenant isolation continues on the ADR-0026 org-scoped path (cross-tenant + IDOR probes required through the tool path). The no-direct-mutation test (govengine gate removed ⇒ still zero mutation) is the fail-closed proof.
Alternatives rejected
- C — LLM-held
confirm_tokentwo-call: the LLM can self-confirm (prompt-injection double-call), violating "no silent mutation / the user authorises." Rejected as the authorisation (may survive only as defence-in-depth arg-binding). - A — worker interrupt surface + session-scoped approval: most literal
InterruptRequiredEventand it fixes the team-tool-32001dead-end, but its blast radius (worker interrupt/resume rebuild +-32001recognition +session_idtoken schema + resume re-gate break) is disproportionate for the platform write path, which B satisfies without any of it. Deferred to #2146 (the-32001fix is a pre-existing global MCP-HITL gap worth doing on its own, LLD-first). - Policy-dependent
requires_approval(rely on a seeded governance policy to gate writes): the real engine default-denies on no-match, so an unseeded org would block the tool entirely rather than confirm it. Rejected for a deterministicPlatformGovEngineverdict (D3).
Amendment 1 — 2026-11-13 — a seat-bound decision is the human's decision (core#4420)
- Status: Accepted — founder approval from his own account,
upsquad-ai/upsquad-core#4420comment6849892608(2026-11-13T10:06:39Z,user.type == "User", bodyApproved, on the issue whose body enumerates this amendment). Ruling text as relayed by the coordinator:#4419comment6776135827item 3 — "a trigger, answer or decision recorded through a login-bound (seat) external credential is that human's decision and is audited as agent + member; unbound credentials stay confirm-gated and stamp the agent." Read together with#4419comment6799098815(2026-11-11; SDLC workflow first, whose coder step is a seat-bound human's own Claude Code). Tracker#4419. - Provenance line: Founder ruling from his own account: #4420 comment 6849892608; text #4419 comments 6776135827 / 6799098815.
- Record: the seat mechanism is specified in
#4426(X2) and the external tool contract in PR#4433(X1); the governance-filteredtools/listit depends on is#4348. This amendment records the authorisation rule and the client constraints that shaped the interface; it does not restate either issue. - Supersedes: in D4, the sentence "stamped with the Quad agent's org +
agent_id… — not the approving user" for seat-bound callers only: a seat-bound mutation is stamped agent + member, at the member's clearance. In D2.1 ("a write tool handler NEVER mutates") and D3 ("write Resource with clearance ≥ floor → RequiresApproval"), the scope narrows to unbound callers; a seat-bound caller's write resolves Allow at the member's clearance and the handler executes. Everything else — mechanism B for unbound callers, the rejection of C, the deferral of A to#2146, theconfirmation_requiredsurface and upsquad-client#655 — is unchanged. The 2026-07-25 decision's founder constraint ("the user authorises, never the LLM; fail-closed; no silent mutation") is not relaxed; A1.1 says how a seat satisfies it.
A1.1 Decision
- A seat-bound decision is the human's decision. When the external credential on a platform MCP call is login-bound —
external_agent_clients.member_idset (a nullable column#4426adds; it does not exist onmain, migration 155), the token carrying the member's identity (HumanMemberID, QWP-5 claim) — atrigger_workflow,answer_run_promptorrecord_decisioncall is that member's trigger, answer or decision. It executes directly (#4433:trigger_workflowreturnstriggered+run_id+run_url;record_decisionreturnsrecorded|already_decided), is subject to the same clearance floor as the same human acting in the portal, and is audited as agent + member — both identities on the audit row, neither alone. - Unbound credentials stay confirm-gated and stamp the agent. A
client_credentialsgrant with no member bound (headless agents) keeps D1–D5 exactly: the handler never mutates, one confirm approval is created, an orchestrator-registeredActionTypeHandlerexecutes on approve, the mutation is stamped as the agent. - Seat identity = the human, obtained by login. The authorisation server adds
authorization_code+ PKCE (+ refresh) and dynamic client registration; the browser leg is a configurable OIDC upstream — hosted: Clerk; on-prem: the tenant's IdP, or Clerk-with-SSO. The callback resolves the member through the existing issuer + JWKS path (internal/gateway/claims_enrich.go) and the member's units and clearance. Seat = member × client, auto-created on first login, revocable, listed in the portal. The token'sUnitIDis the team the member chose at login; its clearance is the member's; platform and team routes resolve scope as member ∩ agent allowlist.answerable_by: requesteron a gate resolves to the human. Pilot position (proposed on#4426; founder ruling owed —#4419comment6776135827item 4, no own-account record yet): Clerk with Google SSO; a Clerk-less on-prem install to be filed as aprod-enablementitem for on-prem GA, not for the pilot. - Watching is a portal link; acting is a pull tool. Every run-scoped tool result carries
run_url(#4433:trigger_workflow'sconfirmation_requiredarm carriesdeep_linkinstead;answer_run_promptandrecord_decisioncarry none); the human watches a run in the portal. The pull tools (list_my_runs,get_run_statuswithprompt_kind/next_tool,get_run_prompt,answer_run_prompt,await_runwithsince_seqandpoll_after_seconds,trigger_workflow) are for acting, and for agents that must wait-and-continue. Nothing is pushed to the client.
A1.2 Why the seat satisfies "the user authorises, never the LLM"
The 2026-07-25 decision rejected mechanism C because the LLM held the confirm_token and could self-confirm. On a seat, the authorising fact is not held by the model: it is the human's login, bound to a credential the human can see and revoke, carried on every call, and the client (Claude Code, Codex, Claude Desktop) shows the human each tool call under its own permission model. Four controls bound the residual risk that a client-side model issues a write the human did not read:
- the external surface is ≤ 12 tools on its own route, with
tools/listfiltered by the caller's governance verdict (#4348) so a tool the seat may not use is not advertised; - every call still passes the gateway's per-call governance (
PreToolUseon^mcp__in orchestrated runs; the platform route'sPlatformGovEngineotherwise) at the member's clearance — a seat does not lift the floor; - the three seat-direct writes are trigger, answer, decide — the actions a human takes in the portal with one click; higher-consequence writes (git write, deploy, workspace) are not on this surface and keep their own gates (
#2568,#2598,#3735); - agent + member on the audit row makes a client-side mistake attributable to the client and the person, which is what "that human's decision" means operationally.
This is a founder-accepted trade: convenience for the human on their own tools against the confirm step D5 would otherwise impose. It is scoped to seat-bound callers; the moment a credential has no member, D1–D5 apply.
A1.3 Client constraints that shaped the interface (measured)
| Client | Constraint | Consequence for the contract |
|---|---|---|
| MCP clients generally (Codex default) | Tool calls ≤ 60 s; no server → client push; elicitation unreliable | await_run.wait_seconds ≤ 45; every "waiting" result returns poll_after_seconds and next_tool; the client re-polls, the server never pushes; questions are asked through get_run_prompt / answer_run_prompt, never through elicitation |
| Claude Desktop | ~240 s fixed call ceiling, no shell | Status and answer must complete within one call; Desktop cannot self-pace a long wait, so a parked run notifies out-of-band (email today; a Slack adapter is proposed in X3 #4427, pending founder approval as a new integration — #4419 item 6, offered with an email-only alternative) with run_url and the exact tool call to resume |
| Claude Code / Codex | Full shell, own permission prompts | First-class for the pull core and for the SDLC coder step (the run waits; the engineer codes; a PR is opened) |
A1.4 Consequences
- Positive: a human on their own Claude Code / Codex / Claude Desktop can trigger, watch (portal), answer and approve without a second confirm round-trip; audit rows name the person;
answerable_by: requesterhas a human to resolve to; the SDLC workflow's coder step has an identity to assign work to. - Negative / accepted: a new OIDC leg on the authorisation server and a nullable
member_idonexternal_agent_clients(#4426, reviewed bybackend-security+principal-architectas a new auth primitive); two authorisation paths through one platform route, distinguished by whether the credential is bound — the audit row's agent + member pair is how a reader tells them apart; the Clerk-on-prem position is proposed on#4426with a founder ruling owed (#4419item 4); itsprod-enablemententry is filed once ruled. - Companion records: ADR-0020 Amendment 1 (runtime) and ADR-0023 Amendment 1 (engine) — the three were ruled together on
#4420.