diff --git a/docs/adr/0011-actions-as-ai-tools.md b/docs/adr/0011-actions-as-ai-tools.md index 0fc49e8944c..5d5c3502948 100644 --- a/docs/adr/0011-actions-as-ai-tools.md +++ b/docs/adr/0011-actions-as-ai-tools.md @@ -3,6 +3,7 @@ **Status**: Accepted — implemented (2026-06-04) **Authors**: HotCRM (objectstack-ai/hotcrm) — surfaced the requirement; design finalised in framework **Consumers**: `@objectstack/service-ai` (the bridge), `@objectstack/spec` (ui.action, contracts.ai-service), every app that ships actions +**Amended** (2026-11-15, [#33689](https://github.com/objectstack-ai/objectstack/issues/33689)): a dated note under [Confirmation](#confirmation-hitl-approval-queue) records who confirms a declared-gated action on an AI door. The status line above is left as it is. --- @@ -234,6 +235,52 @@ asking; an action the user can't invoke simply isn't offered. | `ai.requiresConfirmation: false` on a destructive action | exposed & direct-run — **author asserts safe** (bridge logs a warning) | | not destructive | direct-run | +> **Amendment note (2026-11-15, [#33689](https://github.com/objectstack-ai/objectstack/issues/33689) — PR #33725, `1e65a389`): who confirms a declared-gated action on an AI door.** +> Ruled by the account owner on objectstack-ai/cloud#3826 (「3826 照建议(征询版)」, phase 1, card 1 of its +> item-6 chain) and amended on #33689 (「我开始重新接受你说的主流方案,就是推送到客户的手机端」, +> 「比如最简单的我可以先推送到邮件」). The contract is the docblock of +> `packages/spec/src/contracts/ai-service.ts#AI_ACTION_CONFIRMATION_CAPABILITY`; it is the record, and this note +> points at it without restating every case. +> +> - **Why.** On the MCP doors the confirmation of an action declaring `ai.requiresConfirmation: true` was the +> caller's own `confirm: true`, which nothing could check. Measured on published 18.4.0, an agent sent it itself on +> an irreversible action in 2 of 6 runs. The gate made forgetting loud; it did not prove a person. +> - **Which calls.** An action whose author declared `ai.requiresConfirmation: true` (the declared flag, not the +> destructive heuristic of the table above), called through the MCP `run_action` tool, or through `resume_run` for +> the candidate action it would run, by any caller acting for a person, on an OAuth token or an API key. +> - **How the person is asked, in order, after every admission gate and before anything runs.** (1) **Elicit**: one +> MCP `elicitation/create` in form mode, when the client advertised `elicitation` at `initialize` and the door can +> carry the request. (2) **Hand off**, otherwise: the call goes to the host's pending-confirmation service +> (`packages/spec/src/contracts/ai-service.ts#IActionConfirmationService`, registered under +> `packages/spec/src/contracts/ai-service.ts#ACTION_CONFIRMATION_SERVICE`) and the caller is answered +> `status: 'pending_confirmation'` with a pending id. Only the person the call ran as approves or rejects it in the +> app; an approved action runs as that person with every gate and permission re-checked, and a handed-off +> `resume_run` resumes its parked run rather than starting one. The approve and reject doors take a person's +> signed-in session to the app and nothing else. (3) **Refuse** only when the host registers no such service: +> `428 ACTION_CONFIRMATION_REQUIRED` with `details.reason: 'no_confirmation_service'`. +> - **The caller's `confirm` never counts** on such a call, in any of the three steps. +> - **What an answer proves.** An elicited `accept` proves that the client answered, and an approved hand-off that a +> signed-in session to the app answered. Neither proves a human; each is as strong as what it takes to give it. +> - **Bounds.** The MCP `delete_record` and `delete_records` gates keep reading `confirm: true` until a decision moves +> them, and REST `/actions` stays outside the gate for a person. +> - **The in-app assistant door: the same rule, its own channel.** Ruling-ref: Leehom 2026-11-15T11:10:57Z, +> 「B 同一规则,两套流程暂留」 (record `6893484458` on #33689). The core rules bind every AI door, the in-app +> assistant included: neither the caller's nor the model's own confirmation counts; only the person the call ran +> as decides; the deciding doors take a signed-in session only; and an approved action runs as that person, with +> every gate and permission re-checked. The in-app door keeps its own channel, the pending-approval card and inbox +> this ADR describes in [Invocation flow](#4-invocation-flow) and the table above, and `IAIService`'s pending +> members stay. Merging the two seams was not ruled. The contract at `1e65a389` names the two MCP tools only; the +> in-app door's three changes (who decides, which credential may decide, and as whom the approved action runs, +> today the pre-registered bypass dispatcher) land through #33808, the cloud approve and reject routes are aligned +> through #33809, and the seam merge is #33806. +> - **When it binds.** The contract ships in `@objectstack/spec/contracts` from the release that carries `1e65a389`. +> The doors implement it in the next card of the chain. Until that change ships, every door gates on the member as +> before (`packages/runtime/src/action-execution.ts#actionConfirmationRefusal`), and the addendum's sentence below +> that a C action is refused "until the call carries `confirm: true`" stays the description of the running code. +> - **Unchanged.** The opt-in and its default-off exposure; the addendum's H, C and E buckets and its rule that a C +> action's confirmation is never relaxed (what changes is who confirms it, not whether it is asked); and the AI +> service account's refusal, ADR-0151 D3 rule 3, which its own note of the same date records. + --- ## Migration Path diff --git a/docs/adr/0151-ai-service-account-a-headless-agent-is-a-registered-principal-of-its-own.md b/docs/adr/0151-ai-service-account-a-headless-agent-is-a-registered-principal-of-its-own.md index 3f4115e86b9..d8976223751 100644 --- a/docs/adr/0151-ai-service-account-a-headless-agent-is-a-registered-principal-of-its-own.md +++ b/docs/adr/0151-ai-service-account-a-headless-agent-is-a-registered-principal-of-its-own.md @@ -8,6 +8,7 @@ - **Leaves unchanged**: the 2026-09-16 note (a person's API key is that person's credential, never an agent); rule 5 and its credential-kind × target-door table; ADR-0118 D1, D2, D5 and D6; the meaning of `ExecutionContext.performedBy` (the OAuth client that acted for a person) and the room it reserves; the OAuth agent path end to end; ADR-0073's automation principal, which stays a separate identity. - **Consumers**: `@objectstack/platform-objects` (two `sys_user` columns), `@objectstack/plugin-auth` (the registration, key and lifecycle doors; the session and credential refusal), `@objectstack/core` (key admission carries the kind; the shared assembler stamps the principal), `@objectstack/plugin-security` (the agent ceiling at evaluation and at assignment), `@objectstack/plugin-audit` and `@objectstack/spec` (the hook surface, O4), and in `objectstack-ai/cloud` the licence layer and the console (cloud ADR-0116 D7, cloud#3886, cloud#3820). - **Amended** (2026-11-10, [#32060](https://github.com/objectstack-ai/objectstack/issues/32060)): a dated note under [What builds on this](#what-builds-on-this) records what O3 and O4 shipped. The status line above is left as it is. +- **Amended** (2026-11-15, [#33689](https://github.com/objectstack-ai/objectstack/issues/33689)): a dated note under [D3](#d3--its-authority-its-own-grants-under-the-agent-ceiling) records that rule 3 holds unchanged under the amended action-confirmation contract. The status line above is left as it is. --- @@ -75,6 +76,28 @@ ADR-0118 refused a seeded "system" pseudo-user for two reasons: seeding writes t - **Rule 5 needs nothing new.** An account's `api` action forward carries the account's own key, and that key already *is* the agent, so no forward credential is minted. Its cells in the table are the `api_key` row as it stands: the identity door refuses by name, the MCP and platform doors accept. - **MCP.** On the HTTP endpoint and over stdio (ADR-0101, `OS_MCP_STDIO_API_KEY`), an account's key admits the account through the same shared chain. The OAuth tool families are a person's consent and do not apply; the account's grants bound what its tools reach. +> **Amendment note (2026-11-15, [#33689](https://github.com/objectstack-ai/objectstack/issues/33689) — PR #33725, `1e65a389`): rule 3 under the amended confirmation contract.** +> [ADR-0011](./0011-actions-as-ai-tools.md)'s note of the same date records the new contract +> (`packages/spec/src/contracts/ai-service.ts#AI_ACTION_CONFIRMATION_CAPABILITY`): a person confirms a declared-gated +> action on an AI door, elicited in the MCP client or handed off to the host's pending-confirmation service, and the +> caller's own `confirm: true` never counts. Rule 3 is unchanged by it: +> +> - **An account acting for itself is refused whatever it sends.** It is neither elicited, since no person stands +> behind the account and its own client could answer, nor handed off. From the change that implements the +> contract, the refusal carries `details.reason: 'service_account'` +> (`packages/spec/src/contracts/ai-service.ts#ACTION_CONFIRMATION_REFUSAL_REASONS`) on every door that runs an +> action, REST `/actions` and host doors included, because the one admitted sequence asks this rule at each of them. +> - **The pending-confirmation service is not the hold door rule 3 waits on.** It hands a person's own call back to +> that same person (`packages/spec/src/contracts/ai-service.ts#IActionConfirmationService`), and an account has no +> person behind it. Its approve and reject doors take a person's signed-in session and refuse an agent principal, +> with or without `onBehalfOf`. A hold that routes an account's run to its owner or an administrator remains O6's, +> through the approvals engine, and is a separate decision. +> - **An agent acting for a person** (`principalKind: 'agent'` with `onBehalfOf`, the OAuth path) is not an account: +> the contract asks the person it acts for. +> - **Until the implementing change ships**, the gate is `packages/runtime/src/action-execution.ts#actionConfirmationRefusal` +> as before, and it refuses an account through +> `packages/runtime/src/action-execution.ts#isAiServiceAccountCaller` whatever the call sends. + ### D4 — Its credentials: dedicated API keys, minted by a person - **API keys, one or many.** Each key row carries `user_id` = the account and `active_organization_id` = the account's organization. An account may hold several keys (rotation, one per deployment); they remain one identity.