Skip to content

Commit 24b6ae5

Browse files
docs(skills, client): deciding an in-app AI pending action is the person's own act, on their signed-in session (#34230)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9MdVWiH4D1vGNt7peGkinYV)_ Fixes #34189 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:技能 `objectstack-ai`、`client-sdk.mdx`、`actions-as-tools.mdx` 的 ObjectOS 提示框和 `client.ai.pendingActions` 的注释改成:批准或拒绝应用内 AI 待批动作,只能由发起那次调用的本人,在应用里用自己的登录会话来做;令牌(哪怕是本人的)和 AI 身份都会被拒,只能列出,不能决定;模型自己的确认不算数。加了一个 eval 用例。 - 为什么改:ADR-0087 `in-app-pending-action-decided-by-person` 的规则由 cloud#4607 在应用内的门落地后,这四处还在教「用令牌或 SDK 调 POST 去决定」,照做会被拒。 - 风险与回滚:只改文档和注释文本,无代码行为、导出或类型变化;回滚就是 revert 本 PR。⚠ 落地时机:必须与带 cloud#4607 的 cloud 版本钉位升级同一发布窗口或之后合并,不能更早,否则文档会先于门的行为。 - 先看:`skills/objectstack-ai/SKILL.md` 的 Human-in-the-loop 段;`content/docs/api/client-sdk.mdx` 的 Pending actions 注释;`packages/client/src/index.ts` 的 `pendingActions` 注释。 - 两分钟验证:`node scripts/check-skills-token-ratchet.mjs | grep objectstack-ai/SKILL` 预期 6068 / 6801,全绿。 - 需要你做的:批准本 PR(在 cloud#4607 的钉位升级同窗或之后合并)。 ## What changes Four teaching sites now say what the in-app door's confirmation rule says: deciding (approve or reject) an in-app AI pending action is the person's own act, on their signed-in session to the app. Listing stays as written. 1. `skills/objectstack-ai/SKILL.md`, **Human-in-the-loop** paragraph: drops "an operator approves or rejects … (or via `GET/POST /api/v1/ai/pending-actions/...`)". The queue is listed in the inbox or via `GET /api/v1/ai/pending-actions`. Only the person the call ran as decides, in the app on their signed-in session. Another user's `ai:approve` does not decide it. An API key or token (even the person's own) is refused, and so is an AI identity and any call that arrives through an AI door. "The model's own confirmation does not decide the item, and neither does a `confirm` on the call: the item waits for the person." A second approver goes through the approvals engine (`held`). The next sentence now reads "Whether *your* action is queued". Frontmatter untouched. 2. `content/docs/api/client-sdk.mdx`: the "Listing takes `ai:read`, deciding takes `ai:approve`" comment moves above `approve`. It keeps the `ai:read` listing sentence and now says, as the skill does, that only the person the call ran as decides, on their signed-in session. Another user's `ai:approve` does not decide it. A client on an API key or token (even the person's own) lists and does not decide, and an AI identity is refused too. The block's closing "These methods are for … server code, jobs, CLIs, tests" now excepts approve and reject. 3. `packages/client/src/index.ts`: the `pendingActions` namespace docblock and the `approve` / `reject` docblocks say the same, AI identity included. The existing "`ai:read` vs `ai:approve`, handle the 403" paragraph is unchanged. Docblock text only, no code change. 4. `content/docs/ai/actions-as-tools.mdx`, ObjectOS callout (about line 236): one sentence. "an operator resolves it from the **AI Pending Actions** Studio inbox (approve re-runs the same dispatcher; reject records a reason)" now says only the person the call ran as decides it in the inbox, on their own signed-in session. Another user's `ai:approve` does not decide it, and an API key, a token or an AI identity is refused. Approve runs the action as that person with every gate re-checked; reject records a reason. Sources: the spec contract's in-app door section, points 1-3 (**Who decides**, **Which credential**, **As whom it runs**: "never as a synthetic AI principal, through the same admitted sequence as any action call, every gate and permission re-checked"). The seat widened the claimed surface to this sentence (card comment 6905036822). Review N1 also changed "operators expect single-click yes/no" to "people expect". Nothing else in the callout changes. 5. `skills/objectstack-ai/evals/skills-tools-knowledge.json`: case 6. An operator script on an API token is asked to approve the queue. Expected: list via the token, decide in the app on the person's session. An AI identity is refused too, and the model's own confirmation does not count. `must_contain` is `pendingActions.list`, `signed-in session` and `refused`. `must_not_contain` is `pendingActions.approve(`. Self-consistent: no `must_contain` string is in `must_not_contain`, and `expected_output` contains every `must_contain` string and neither `must_not_contain` string. 6. `.changeset/34189-pending-action-decide-session.md`: `@objectstack/skills` patch, `@objectstack/client` patch (the docblock ships in its `.d.ts`). It says the door enforces this from the runtime release that carries the in-app door, not from this package release. ## Premise check (on `origin/main` dfb8ed3) - **The door.** No package in this repository serves `/api/v1/ai/pending-actions/:id/approve|reject`. `git grep pending-actions` over `packages/services/**` and `packages/plugins/**` has no hits. The only hits are the client (`packages/client/src/index.ts`) and the protocol schemas (`packages/spec/src/api/protocol.zod.ts` 4386 and 4403). The door is served by the AI service in cloud, and its refusal is cloud#4607, which this container cannot read. So no refusal code is quoted here. The text says "refused" and names no code. The client's existing `ai:approve` 403 note is kept as written. - **What main states**, and the source of each sentence in this PR: - "only the person the call ran as decides; another user's `ai:approve` does not" comes from `packages/spec/src/contracts/ai-service.ts`, "The in-app assistant door: the same rule, its own channel", point 1 (**Who decides**). - "a signed-in session to the app; an API key or token is refused, even the person's own" comes from the same section, point 2 (**Which credential**): "an API key, a delegated or OAuth token and any other service credential are refused, whoever it resolves to". Rule 4 adds "a person's own API key resolves as that person, and is refused there all the same". - "a second approver goes through `held`" comes from point 1: "A host that wants a second person to approve the write uses the existing `held` outcome". - The ADR-0087 entry `packages/spec/src/migrations/entries/semantic/18.in-app-pending-action-decided-by-person.ts` (`replacement`) says the same, from the release whose in-app door enforces it. - "Listing takes `ai:read`" is the client's existing text. The spec pin `ai-service.test.ts` holds that `listPendingActions` carries none of the deciding points. - **What each place taught before:** SKILL.md:164-166 "an operator approves or rejects in Studio's **AI Pending Actions** inbox (or via `GET/POST /api/v1/ai/pending-actions/...`)". client-sdk.mdx:426-427 "Listing takes `ai:read`, deciding takes `ai:approve` — a caller that can see the queue may still be refused on approve. Handle the 403." The client docblock taught only the `ai:read` vs `ai:approve` split. - Because the rule binds only once the cloud door ships, this PR waits for that release (card item 4). ## Tests - No behaviour change. `pnpm --filter @objectstack/client test`: Test Files 58 passed (58), Tests 812 passed (812). `pnpm --filter @objectstack/client typecheck`: exit 0, under `os-verify-lock`. - No forced test edits. ## Acceptance notes - **Tier.** `skills/**` mandates CONTRACT_REVIEW_TIER (`dispatch-gates --tier`: MANDATORY, no one-line exit). Measured quota exemption, on the maintainer's 2026-11-15 21:53Z 「fable 不多了,后续契约复审找review 席位」: this PR was authored at the thread's default tier, never lower. The at-tier L2 review is review#2's. Tier H: stays draft. - **Skill size** (after review round 1). `skills/objectstack-ai/SKILL.md` went from 23736 to 24291 bytes, 427 to 434 lines and 5929 to 6068 tokens (+139; review round 2 added 14). The ceiling is 6801, so the ratchet row does not move. Whole package (sum of every `skills/*/SKILL.md`): 4593 to 4600 lines, 59219 to 59358 tokens. Bundle total: 248073 at the round-2 head. The eval file went from 1081 to 1343 tokens; eval fixtures are measured, not ratcheted. - **Same family:** `content/docs/ai/actions-as-tools.mdx` taught the same superseded route. Round 1 reported it to the seat. The seat widened the surface (6905036822), and round 2 fixes that one sentence. ## Review round 1 (review#2 record 6905434558, PASS on 3690b8e; seat fix order r1) - **S1** chose the cheaper fix: "Whether *your* action is held" now reads "is queued" (+2 bytes). The second-approver clause stays where it was. - **S2:** the skill now names the other refused class, an AI identity and any call that arrives through an AI door (contract point 2), and rule 5: neither the model's own confirmation nor the caller's `confirm` counts. Eval 6's expected output names both. The client docblocks, `client-sdk.mdx` and `actions-as-tools.mdx` add "an AI identity" in their existing clause. - **S3:** the `ai:approve` precondition is dropped from `client-sdk.mdx`, which now uses the skill's wording. The class-level client docblock had no precondition. Its new paragraph now says "another user's `ai:approve` does not decide it", and its old `ai:read` vs `ai:approve` 403 paragraph stays. - **N1:** `actions-as-tools.mdx` "operators expect" now reads "people expect". Only that word changed. - **N2:** `client-sdk.mdx`'s closing comment adds "(approve and reject excepted: those are the person's own act in the app)". - **N3:** eval 6 `must_contain` "list" is now "pendingActions.list", and "/approve" is dropped from `must_not_contain`. The expected output contains every `must_contain` string and no `must_not_contain` string. A script asserted this. - **N4:** the changeset adds "The door enforces this from the runtime release that carries the in-app door, not from this package release." ## Review round 2 (review#2 record 6905889120, PASS on f407440; seat fix order r2) - **S1:** the skill's rule-5 sentence is now scoped to the queue item, in the reviewer's wording: "The model's own confirmation does not decide the item, and neither does a `confirm` on the call: the item waits for the person." The MCP table rows (`delete_record`, `delete_records`, `run_action`) are untouched. Eval 6 is unchanged. - **N1:** the client class docblock and `client-sdk.mdx` were reordered so that the list/get clause speaks only of the API-key/token client: "a client on an API key or token (even the person's own) can list and get, never decide; an AI identity is refused too". The two places are kept consistent. - **Body:** the 两分钟验证 line now expects the measured 6068 / 6801. - **N2:** no change; the reviewer noted it only. ## Verification Round 4 head 769aad7. `dispatch-gates` reported no STALE TREE, so there was no merge this round; the round 3 merge of `origin/main` 7be32d3 stands. `@objectstack/client` was rebuilt first, and its `typecheck` and `test` ran in the same lock (`os-verify-lock` VERDICT command-exit 0; Test Files 58 passed (58), Tests 812 passed (812)). `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` gave 102 commands, and all of them plus `check:skill-refs` were run on 769aad7. The earlier rounds ran the same set at cf09e9f (after a full `pnpm build`), at 3690b8e and at f407440. All of them were green. `node scripts/pm/dispatch-gates.mjs --ran` at 769aad7 reported: "102 derived famil(ies) accounted for — 102 run, 0 NOT-MEASURED (a DERIVED zero)". All 103 recorded commands exited 0, including `check:skill-docs`, `check:skill-refs` and `check:skill-examples`. <details><summary>Notes on the run</summary> - `node scripts/check-plugin-teardown-shape.mjs --self-test` needs its pinned fixture commit 621a487 in a shallow clone (`git fetch --no-tags origin 621a487`). With it, the self-test exits 0 with 48 cases. - `node scripts/check-skills-token-ratchet.mjs` reads `skills/objectstack-ai/SKILL.md is 6068 tokens (ceiling 6801; headroom 733)`. - Every check-run of the PR is CI's to report. </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. (no names added) - [x] 3. No formatter ran; `pnpm lint` is a CI-owned repo scan, not run locally (the diff is prose and docblock text). - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: n/a. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmSoMtbbwL3w3kwCmky <!-- signed: domain:skills#2 · os-steve · session_01ADHkmSoMtbbwL3w3kwCmky --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent f806608 commit 24b6ae5

6 files changed

Lines changed: 58 additions & 11 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@objectstack/skills': patch
3+
'@objectstack/client': patch
4+
---
5+
6+
docs: deciding an in-app AI pending action is the person's own act, on their signed-in session
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The `objectstack-ai` skill, the client SDK page, the actions-as-tools page and the `client.ai.pendingActions` docblock now say what the confirmation rule says for the in-app assistant door (`in-app-pending-action-decided-by-person`): only the person the assistant call ran as approves or rejects their item, in the app on their signed-in session. Another user's `ai:approve` does not decide it, and an API key or token is refused, even the person's own, and so is an AI identity. A client on a token can still list and get the queue. The door enforces this from the runtime release that carries the in-app door, not from this package release. Docs and docblock text only: no export, type, route or behaviour changes in these packages. The skill gains one eval case (an operator script on an API token asked to approve the queue).

‎content/docs/ai/actions-as-tools.mdx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,14 @@ with the app's own authority.
249249
**ObjectOS** — the in-product chat runtime adds a *server-side*
250250
approval queue for its own `action_<name>` tools: a gated tool call is
251251
persisted as pending and returned to the model as
252-
`{ status: 'pending_approval', … }` instead of executing, and an operator
253-
resolves it from the **AI Pending Actions** Studio inbox (approve re-runs the
254-
same dispatcher; reject records a reason).
252+
`{ status: 'pending_approval', … }` instead of executing, and only the person
253+
the call ran as decides it in the **AI Pending Actions** inbox, on their own
254+
signed-in session to the app (another user's `ai:approve` does not decide it,
255+
and an API key, a token or an AI identity is refused); approve runs the action
256+
as that person with every gate re-checked, reject records a reason.
255257
A dedicated queue (rather than the multi-step `IApprovalService`) fits AI
256258
tool-call HITL: the subject is the proposed *call*, there is no predefined
257-
process, and operators expect single-click yes/no. See the
259+
process, and people expect single-click yes/no. See the
258260
[ObjectOS docs](https://docs.objectos.app/docs/ai) for configuration and the
259261
queue API.
260262
</Callout>

‎content/docs/api/client-sdk.mdx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,18 +417,22 @@ for await (const frame of await client.ai.agents.chatStream('build', { messages
417417
// decision parks here instead of executing.
418418
await client.ai.pendingActions.list({ status: 'pending', limit: 20 });
419419
await client.ai.pendingActions.get('pa_1');
420+
// Listing takes `ai:read`. Deciding (approve or reject) is the person's own
421+
// act: only the person the call ran as decides their item, on their signed-in
422+
// session to the app. Another user's `ai:approve` does not decide it; a client
423+
// on an API key or token (even the person's own) lists, it does not decide; an
424+
// AI identity is refused too. Handle the refusal.
420425
const outcome = await client.ai.pendingActions.approve('pa_1');
421426
// CHECK `outcome.status`: approve runs the tool, and a tool that fails comes
422427
// back { status: 'failed', error } on HTTP 200 — the approval succeeded, the
423428
// execution did not. Code that reads only `res.ok` calls that a success.
424429
if (outcome.status === 'failed') console.error(outcome.error);
425430
await client.ai.pendingActions.reject('pa_1', 'wrong account');
426-
// Listing takes `ai:read`, deciding takes `ai:approve` — a caller that can see
427-
// the queue may still be refused on approve. Handle the 403.
428431

429432
// In a React chat UI prefer `useChat()` (`@ai-sdk/react`) over `ai.chatStream`:
430433
// it speaks the same protocol and owns message state. These methods are for
431-
// everything that is not a component — server code, jobs, CLIs, tests.
434+
// everything that is not a component — server code, jobs, CLIs, tests
435+
// (approve and reject excepted: those are the person's own act in the app).
432436
//
433437
// #3718 history: `client.ai` used to hold `nlq`, `suggest` and `insights`,
434438
// building /api/v1/ai/{nlq,suggest,insights}. No server in any repo ever

‎packages/client/src/index.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7714,6 +7714,12 @@ export class ObjectStackClient {
77147714
* Reads and decisions are separately permissioned server-side (`ai:read`
77157715
* vs `ai:approve`), so a caller that can list the queue may still be
77167716
* refused on approve — handle the 403, do not assume one implies the other.
7717+
*
7718+
* Deciding (approve or reject) is the person's own act: only the person
7719+
* the call ran as decides their item, and only on their signed-in session
7720+
* to the app. Another user's `ai:approve` does not decide it; a client on
7721+
* an API key or token (even the person's own) can list and get, never
7722+
* decide; an AI identity is refused too.
77177723
*/
77187724
pendingActions: {
77197725
/** Queued actions, newest first. */
@@ -7743,6 +7749,9 @@ export class ObjectStackClient {
77437749
* back `{ status: 'failed', error }` with HTTP 200, because the approval
77447750
* succeeded even though the execution did not. Treating 2xx as "the write
77457751
* happened" reports a failed write as a success.
7752+
*
7753+
* Only the person the call ran as approves, on their own signed-in
7754+
* session; an API key, a token or an AI identity is refused.
77467755
*/
77477756
approve: async (id: string): Promise<ApproveAiPendingActionResponse> => {
77487757
const route = this.getRoute('ai');
@@ -7753,7 +7762,11 @@ export class ObjectStackClient {
77537762
return this.unwrapResponse<ApproveAiPendingActionResponse>(res);
77547763
},
77557764

7756-
/** Reject with an optional reason. Executes nothing. */
7765+
/**
7766+
* Reject with an optional reason. Executes nothing. Only the person the
7767+
* call ran as rejects, on their own signed-in session; an API key, a
7768+
* token or an AI identity is refused.
7769+
*/
77577770
reject: async (id: string, reason?: string): Promise<RejectAiPendingActionResponse> => {
77587771
const route = this.getRoute('ai');
77597772
const res = await this.fetch(`${this.baseUrl}${route}/pending-actions/${encodeURIComponent(id)}/reject`, {

‎skills/objectstack-ai/SKILL.md‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,16 @@ nests user params under `data` while keeping `recordIdParam` flat.
161161

162162
**Human-in-the-loop.** `AIServicePlugin({ enableActionApproval: true })` (default
163163
`false`) persists an `ai_pending_actions` row instead of running a dangerous
164-
action and returns `{ status: 'pending_approval', pendingActionId }`; an operator
165-
approves or rejects in Studio's **AI Pending Actions** inbox (or via
166-
`GET/POST /api/v1/ai/pending-actions/...`). Whether *your* action is held is
164+
action and returns `{ status: 'pending_approval', pendingActionId }`. The queue
165+
is listed in Studio's **AI Pending Actions** inbox (or via
166+
`GET /api/v1/ai/pending-actions`), but deciding is the person's own act: only the
167+
person the call ran as approves or rejects the item, in the app on their
168+
signed-in session. Another user's `ai:approve` does not decide it; an API key
169+
or token (even the person's own) is refused, and so is an AI identity and any
170+
call that arrives through an AI door. The model's own confirmation does not
171+
decide the item, and neither does a `confirm` on the call: the item waits for
172+
the person. So an operator script lists items and never decides them; a second approver goes through the approvals engine (the `held`
173+
outcome). Whether *your* action is queued is
167174
decided entirely by the skip rule above — `actionSkipReason(action, ctx)` and
168175
`actionRequiresApproval(action)` (from `@objectstack/service-ai`) answer both
169176
questions, and Studio's "AI exposure" diagnostics use the same predicates.

‎skills/objectstack-ai/evals/skills-tools-knowledge.json‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@
5050
"must_contain": ["defineSkill", "skills", "surface", "aiExposed"],
5151
"must_not_contain": ["defineAgent(", "knowledge:"]
5252
}
53+
},
54+
{
55+
"id": 6,
56+
"prompt": "Write a nightly operator script that uses `@objectstack/client` with our API token to go through the AI pending-actions queue and approve every pending item older than a day.",
57+
"expected_output": "Does not decide on the token: the script may list the queue (`client.ai.pendingActions.list({ status: 'pending' })`), but approving or rejecting an item is the person's own act, done in the app on their signed-in session by the person the assistant call ran as. An API key or token is refused on the decide door, even the person's own, and so is an AI identity; another user's `ai:approve` does not decide the item, and the model's own confirmation does not count. The script reports or notifies the stale items instead; where a second person must approve the write, that is the approvals engine's `held` outcome.",
58+
"files": [],
59+
"assertions": {
60+
"must_contain": ["pendingActions.list", "signed-in session", "refused"],
61+
"must_not_contain": ["pendingActions.approve("]
62+
}
5363
}
5464
]
5565
}

0 commit comments

Comments
 (0)