Repository navigation
Commit 6739719
fix(runtime)!: an AI service account does not confirm an action for itself (#32926)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DQAjJRsJBbEW4k4W1YDZ3rq)_
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: follow-up #32936
## 维护者速读
- **改了什么**:AI 服务账号(自己行事、不代表任何人的 agent 主体)不能替自己确认动作。声明了
`ai.requiresConfirmation: true` 的动作,对这类账号在所有动作入口(MCP
`run_action`、`resume_run`、REST `/actions`、宿主 `dispatchAction`
的两种姿态)一律拒绝,无论请求里带什么;错误码、状态码与 details 不变(`428
ACTION_CONFIRMATION_REQUIRED`),提示语只陈述规则:由人来执行此动作。
- **为什么改**:ADR-0151 D3 第 3
条已裁定:需要人确认的动作,在交给人处理的挂起入口建成之前,对服务账号直接拒绝,且绝不由账号自己确认。
- **风险与回滚**:属破坏性变更(BREAKING,收窄)。受影响的只有:用 AI 服务账号的 Key
运行“需确认”动作的部署,升级后该调用被拒;处置是改由人执行,或由动作作者确认可无人值守后声明
`ai.requiresConfirmation: false`。人的调用、代人执行的 agent(带
`onBehalfOf`)、以及账号运行未声明确认的动作,全部不变。回滚即还原本 PR。
- **先看**:①
`packages/runtime/src/action-execution.ts`(`actionConfirmationRefusal`:读取调用者、账号分支与提示语);②
`packages/runtime/src/action-dispatch.ts`(准入序列:账号在两种姿态下都过确认闸);③
`packages/runtime/src/domains/mcp.ts`(`resume_run` 把调用者传给确认闸)。
- **两分钟验证**:`pnpm --filter @objectstack/runtime exec vitest run
src/action-dispatch.test.ts -t "ADR-0151 D3 rule 3"`,预期 6 条全过:账号在
REST、MCP、宿主两种姿态下都得到 428 且什么都没执行、没读记录、没写调用记录;人和代人 agent 照旧。
- **需要你做的**:无,席位落地。
Supersedes #32691 (same change, carried forward onto current `main`; the
merge conflict in a shared test harness is resolved keeping both sides).
## What changes
The rule, from ADR-0151 D3 rule 3: **an AI service account does not
confirm an action for itself.** An AI service account is an agent
principal acting for itself (`principalKind: 'agent'` with no
`onBehalfOf`).
- **The gate reads the caller.** `actionConfirmationRefusal`
(`packages/runtime/src/action-execution.ts`) takes the caller's
envelope. For an account, an action declaring `ai.requiresConfirmation:
true` is refused whatever the request carries; the confirmation member
is not read for one. `isAiServiceAccountCaller` spells the account test
as the flow-action door already does (`principalKind === 'agent'` and no
`onBehalfOf`). A missing envelope and the system context are not an
account.
- **Every door.** The one admitted sequence (`action-dispatch.ts`) asks
the gate for an account under both postures, so REST `/actions` and a
host's `dispatchAction` on `rest` refuse it too; MCP `run_action`
already runs the sequence under `ai`, and `resume_run`
(`domains/mcp.ts`) passes the caller to the gate for every candidate
action. The refusal stays the last pre-dispatch check: nothing runs, no
record is read and no invocation row is written.
- **Same envelope, a rule sentence.** The registered code, status and
`details` are unchanged (`428` `ACTION_CONFIRMATION_REQUIRED`; no new
error code). For an account the message states the rule — an AI service
account does not confirm an action for itself: a person runs this action
— and prescribes no retry.
- **Unchanged for everyone else.** A person's call is gated exactly as
before (at MCP `confirm: true` runs a gated action; REST `/actions`
stays outside the gate for a person). A delegated agent (`onBehalfOf`
present) is gated as before. An account runs every action that declares
no confirmation, or `false`.
- **Spec prose.** The `tool.requiresConfirmation` retirement
prescription (`packages/spec/src/ai/tool.zod.ts`) states the account
rule beside the REST `/actions` bound, and its pin
(`tool-confirmation-prescription-tense.pin.test.ts`) is re-anchored: the
gate reads the caller, the sequence asks it for an account under both
postures, the REST carve-out holds for a person, and the prose carries
the account rule. `check:generated` reports every spec artifact current;
no artifact changed. No schema accepts or refuses anything new.
- **The published contract.** `AIActionConfirmation` and
`ActionConfirmationRequiredDetails`
(`packages/spec/src/contracts/ai-service.ts`) state the account rule:
the confirmation member is no longer described as the only predicate,
and the retry is described as a caller acting for a person's; an AI
service account is refused a declared-gated action whatever it sends.
The gate docblock (`action-execution.ts`), the
`ACTION_CONFIRMATION_REQUIRED` ledger comment
(`error-code-ledger.zod.ts`) and the dispatcher's listing-predicate
comment (`http-dispatcher.ts`) qualify their retry sentences the same
way; the `tool.zod.ts` comment says the REST carve-out holds for every
caller but an account. Comments and JSDoc only; no schema, export or
runtime behaviour moves.
- **Docs.** One rule line each in `content/docs/ai/actions-as-tools.mdx`
and `content/docs/ai/connect-mcp.mdx`.
- **Changeset.** `.changeset/agent-account-never-confirms-alone.md`
(`@objectstack/runtime`, `@objectstack/spec`, patch): BREAKING, "Who
moves", and the ADR-0087 `not-required` marker.
## Tests
- `packages/runtime/src/action-confirmation-gate.test.ts`: the producer.
An account is refused with the confirmation member and without it, with
the registered code, status and `details`; its message states the rule
and prescribes no retry (a person's still does, as a control); a person,
a delegated agent, a missing envelope and the system context confirm as
before; an account passes an action that declares no confirmation, or
`false`.
- `packages/runtime/src/action-dispatch.test.ts` (one new top-level
`describe` in the shared harness): an account at REST `/actions`, MCP
`run_action` and a host door under `rest`, `ai` and no posture, with the
member and without it — `428` `ACTION_CONFIRMATION_REQUIRED`, nothing
run, no record read, no invocation row. Controls: a person runs with the
member at MCP and with or without it at REST (and the same call from a
person does read the record, so the read counter is live); a delegated
agent as before at both doors; an account runs an undeclared and a
`false` action at REST, MCP and a host door.
- `packages/runtime/src/mcp-resume-run.test.ts`: an account's resume of
a gated action is refused `428` with the member and without it — nothing
resumed, run still parked, no record read, no invocation row. Controls:
an account resumes an ungated action; a delegated agent is refused
without the member and completes with it.
-
`packages/qa/dogfood/test/service-account-register-key.dogfood.test.ts`:
on the real showcase stack, the registered account's real key is refused
`428` at REST `/actions` on a confirmation-gated platform action, with
the member and without it; its owner, a person, runs the same action
(`200`).
-
`packages/spec/src/ai/tool-confirmation-prescription-tense.pin.test.ts`:
re-anchored as above, and it now reads a second carrier, the
`AIActionConfirmation` / `ActionConfirmationRequiredDetails` docblocks,
which must carry the account rule and may not say "when, and only when"
or promise an always-confirming client success. Reverse-verified once:
restoring "when, and only when" turned that case red (1 failed / 8
passed), restored from `HEAD`, `git diff HEAD` empty.
- `packages/mcp/src/__tests__/stdio-agent-account.test.ts`: the case
title now says what it asserts (the data bridge stdio registers carries
no action seam).
<details><summary>Ablation (one, on the principal check)</summary>
`isAiServiceAccountCaller` mutated to answer `false`, through
`scripts/ablation-replace.mjs` (anchor 1 → 0, blob changed); the three
runtime suites ran 7 failed / 82 passed — every account refusal case
red, every control green. Restored: blob equal to `HEAD`, `git diff
HEAD` empty.
</details>
## Acceptance notes
- **stdio.** The stdio transport registers no action tools in this tree
(its data bridge carries no action seam;
`skills/objectstack-ai/SKILL.md` says the same), so the stdio case pins
that absence rather than a refusal.
- **Dogfood scope.** The showcase stack registers no `audit` service, so
the dogfood case asserts the refusal and the person control at REST;
"nothing run, no record read, no invocation row" is pinned in the
runtime harnesses above. The showcase boot here carries no MCP plugin,
so MCP and `resume_run` are pinned in the runtime harnesses.
- **Skills docs follow-up.** `skills/objectstack-ai/SKILL.md` (the
`run_action` / `resume_run` row) and `packages/mcp/src/skill-md.ts` (the
`run_action` / `resume_run` entries) teach `confirm: true` as the retry
for a gated action; they should say an AI service account is refused
whatever it sends. Both are outside this PR's surface (`skills/**` is
Tier H), filed as #32936 (blocked by this PR), which also carries
`packages/mcp/src/mcp-http-tools.ts` (the HTTP MCP `run_action`
description and the account's `list_actions` row).
- `packages/runtime/src/http-dispatcher.ts`: its listing-predicate
comment now qualifies the retry the same way (see What changes).
## Verification
Gate union head: `8e2c6ee48a` (`6729ea847c` plus one
comment/JSDoc-and-pin commit for the contract review's should-fix and
nits; `main` not re-merged, no conflict reported).
<details><summary>Derived gate families (dispatch-gates --commands,
reconciled with --ran)</summary>
- `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack
--ran` on `8e2c6ee48a`: 116 derived (the five new families are read by
the newly touched files: `check:authz-resolver`,
`check:error-code-casing`, `check:init-service-contract`,
`check:startup-registry-verdict`, `check:wildcard-fallthrough`), 116
run, every one recorded with its exit code, all exit 0; 0 NOT MEASURED,
0 unrun.
- `pnpm check:dual-build-cjs-loads` and `pnpm check:type-check-debt`
exit 0 on a full build of this head.
- `pnpm --filter @objectstack/spec check:generated`: every artifact
current; no reference page changed.
</details>
<details><summary>Tests and typecheck (on 8e2c6ee and
6729ea8)</summary>
- On `8e2c6ee48a` (full `pnpm build` green): spec pin 9 of 9;
`stdio-agent-account.test.ts` passed; `pnpm --filter` typecheck exit 0
for `@objectstack/spec`, `@objectstack/runtime`, `@objectstack/mcp`.
- On `6729ea847c` (the delta since moves comments, JSDoc and one test
title only): `@objectstack/runtime` test 588 files, 10265 passed, 19
skipped; `@objectstack/mcp` test 63 files, 1058 passed;
`service-account-register-key.dogfood.test.ts` 10 of 10; full dogfood
battery 456 files passed, 3 skipped, 3833 tests passed, 42 skipped, no
failures.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4d1MskSgQZSjfWLUqNr)_
<!-- signed: security#1 · os-elon-musk ·
session_016WV4cx5nHfga3Hm9BzikGw -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent e728d7a commit 6739719
17 files changed
Lines changed: 516 additions & 60 deletions
File tree
- .changeset
- content/docs/ai
- packages
- mcp/src/__tests__
- qa/dogfood/test
- runtime/src
- domains
- spec/src
- ai
- api
- contracts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
491 | 495 | | |
492 | 496 | | |
493 | 497 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
145 | 169 | | |
146 | 170 | | |
147 | 171 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
247 | 252 | | |
248 | 253 | | |
249 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
21 | 29 | | |
22 | 30 | | |
23 | 31 | | |
| |||
173 | 181 | | |
174 | 182 | | |
175 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
46 | 56 | | |
47 | 57 | | |
48 | 58 | | |
| |||
207 | 217 | | |
208 | 218 | | |
209 | 219 | | |
210 | | - | |
211 | | - | |
212 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
213 | 223 | | |
214 | | - | |
| 224 | + | |
215 | 225 | | |
216 | 226 | | |
217 | 227 | | |
218 | 228 | | |
219 | 229 | | |
220 | | - | |
| 230 | + | |
221 | 231 | | |
222 | 232 | | |
223 | 233 | | |
| |||
234 | 244 | | |
235 | 245 | | |
236 | 246 | | |
237 | | - | |
| 247 | + | |
238 | 248 | | |
239 | 249 | | |
240 | 250 | | |
| |||
243 | 253 | | |
244 | 254 | | |
245 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
0 commit comments