You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 475ae46
Browse filesBrowse the repository at this point in the historyBrowse files
docs(skills): a gated action guards its door only; lock the field an irreversible transition changes (#35310)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg1XdbbGasMNVx41tq3hZKV4)_Fixes#35068Fixes#35041Fixes#34237
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:objectstack-ai 技能新增一条常见陷阱「只给动作加了闸,没锁状态字段」,教作者把不可逆状态迁移写成「需确认的
script 动作 + 状态字段锁(`readonly: true` 约束所有非系统写;字段权限不给 `editable` 不约束 Modify
All 持有者),并在动作上声明 `requiredPermissions`」;工具名解析阶梯补上第四个来源
`MCP_FILE_TOOL_NAMES`(docs 的 tools.mdx 同步);MCP prompts 段落写明 `mcpPrompt:
false` 及 stdio 例外。
- 为什么改:`ai.requiresConfirmation` 只守动作这一扇门,场景卡上代理被 428 拒后改用
`update_record` 直接把工单关了;按「三个问题 同意」不扩大闸门,改为教作者锁字段。另两张 p3 卡是同文件的过期文字。
- 风险与回滚:纯技能文字与一行文档,不动任何代码与契约;回滚即 revert 本 PR。
- 先看:`skills/objectstack-ai/SKILL.md` 的 Common Pitfalls 第 2
条(锁选项是否与实测一致);其次同文件 MCP prompts 段落;`state-machines-and-approvals.md`
只多一行指针。
- 两分钟验证:`node scripts/check-skills-token-ratchet.mjs`,预期
objectstack-ai/SKILL.md 6693 / 6801、state-machines-and-approvals.md 5936
/ 5936,全绿。
- 需要你做的:审阅后合并(`skills/**` 为 Tier H 受管面)。
## What changes
**#35068 — gated action plus a field lock.** Scope 1 was measured before
any text was written (below). `skills/objectstack-ai/SKILL.md` Common
Pitfalls gains item 2, "Gating the action, not the state":
`ai.requiresConfirmation` guards the action's own door only; an
irreversible transition is a gated `script` action over a field a
non-system write cannot set: `readonly: true` binds every non-system
caller, while a field permission without `editable` binds only a caller
no held set grants it (Modify All grants it); the body skips the
caller's edit right, so the action declares `requiredPermissions`; a
declarative `operation: 'update'` action and a `flow` action under
`runAs: 'user'` write as the caller, so the lock stops them too;
`readonlyWhen` and a `state_machine` rule bind the elevated body as
well, so neither is the door, while a `state_machine` dead-end still
makes the reached state final. Pitfall 1 now says the confirmation gate
guards its door only.
`skills/objectstack-automation/references/state-machines-and-approvals.md`
carries one pointer line to it (taught once, in objectstack-ai, where
the gate is taught; no restatement).
**#35041 — the ladder's fourth source.** The resolution ladder names
four sources; item 4 is `MCP_FILE_TOOL_NAMES` (the pinned export in the
same constants file, so the list cannot drift), resolved only for a
skill MCP can offer (`mcpPrompt` not `false`).
`content/docs/ai/tools.mdx` (the one ladder sentence, scope addition
6964629901) says the same.
**#34237 — `mcpPrompt` in the MCP prompts paragraph.** The paragraph
names the optional key (`false` = in-product only, never offered over
MCP on any connection, whatever the binding; absent or `true` = the
binding rule), and the stdio sentence states the exception.
### Scope 1 measurement (tree 3fb7025 + this branch, no code changed)
| Writer | static `readonly: true` | `readonlyWhen` (TRUE) | field
permission without `editable` | `state_machine` |
|:--|:--|:--|:--|:--|
| `script` action body (`ctx.api`, elevated) | LANDS | STRIPPED |
bypassed | enforced |
| raw data write as the caller (MCP `update_record`, REST, form) |
STRIPPED | STRIPPED | refused 403 unless a held set grants `editable`
(Modify All does) | enforced |
| declarative `operation: 'update'` action | STRIPPED (writes as the
caller) | STRIPPED | refused 403 | enforced |
Anchors:
- The body runs elevated:
`packages/runtime/src/action-execution.ts:3901`
(`buildActionExecutionContext` returns `{ ...ec, isSystem: true }` with
the `'action'` mark).
- The static strip is gated on the context:
`packages/objectql/src/engine-update.ts:1411` (`staticReadonlyStripRuns
= !opCtx.context?.isSystem`) and `:1494`.
- The conditional strip runs for every caller, `isSystem` included:
`packages/objectql/src/engine-update.ts:1476`; the comment at
`:1460-1467` says `isSystem` "is still NOT an exemption here".
- Field-permission writes: the bypass is
`packages/plugins/plugin-security/src/security-plugin-authz-middleware.ts:695`
and the 403 is `:1662`.
- The declarative update writes as the caller:
`packages/runtime/src/action-execution.ts:4883` (`callData('update', …,
ec)`, the comment above it reads "⛔ `ec`, never
`buildActionExecutionContext(ec)`").
- The state machine is skipped only on seed replay or an explicit flag:
`packages/objectql/src/engine-top-level.ts:4274-4275`
(`shouldSkipStateMachine`).
- The same table is already measured in the header of
`packages/lint/src/validate-readonly-action-writes.ts`.
Result: the action body's own write to a `readonly: true` field is KEPT
and its write to a `readonlyWhen`-locked field is STRIPPED. So the lock
that binds every non-system caller is `readonly: true`; a field
permission without `editable` does not bind a Modify All holder;
`readonlyWhen` is not the door. A `state_machine` rule binds every
writer: it makes the state final, and it cannot be the door.
## Tests
Text-only change; no committed test (the measurement used existing pins,
run here).
<details><summary>Scope 1 pins — objectql, 3 files, 25 tests
passed</summary>
`pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2
src/engine-readonly-update-strip-system-gate.test.ts
src/engine-readonly-when-derived-writes.test.ts
src/engine-repo-execute-elevation.test.ts`, after building the objectql
dependency closure. Output: `Test Files 3 passed (3)`, `Tests 25 passed
(25)`, `os-verify-lock: VERDICT command-exit 0`.
- `engine-readonly-update-strip-system-gate.test.ts`: a caller-supplied
`readonly` value lands exactly when `isSystem` is set.
- `engine-readonly-when-derived-writes.test.ts`, "LOCK 2 — isSystem does
NOT exempt a caller-supplied value".
- `engine-repo-execute-elevation.test.ts`, "a readonly-field write
through ctx.api LANDS, matching REST/MCP".
</details>
## Acceptance notes
- Line budget, PAID DOWN FIRST in the same files.
`skills/objectstack-ai/SKILL.md`: the "Default for metadata apps"
paragraph is cut, because it restated the App AI Blueprint table above
it. The ladder item 1's ADR-0109 sentence is cut, because it restated
*Tool metadata*. `state-machines-and-approvals.md`: three restatements
are cut. The `[]` dead-end sentence restated the code comment `final —
no outgoing transitions`; ", one per field" restated **One rule per
field**; and "Do not carry the `record.x` habit…" restated the sentence
before it. Fix round (af46d3b, review 6999708959 S1/S2): +42 tokens,
paid first by cutting pitfall 1's retired-tool sentence (taught under
Tool metadata) and folding the agents-are-internal lead into the
skills-entry sentence; net 6680 -> 6693 / 6801.
- Neither ratchet row moves, so no ceiling is raised and the standing
ruling 「A:先削重复,余额按实测提高」 (ruling record 6513306068, letter B) is not
invoked for a raise. The remainder fits under the existing ceilings.
- Scope 3 items (the 428 refusal text; the scenario build prompt) are
other cards and are not touched here.
- `pnpm check:dual-build-cjs-loads` NOT MEASURED locally (exit 3,
PREREQUISITE NOT MET: reads every package's `dist/`); CI runs it.
## Verification
Readings at head 7611288 (tree objectstack-ai/objectstack).
<details><summary>Skills size, before (origin/main 3fb7025) and
after</summary>
| File | lines | tokens / ceiling |
|:--|:--|:--|
| `skills/objectstack-ai/SKILL.md` | 443 → 462 | 6365 → 6693 / 6801 |
|
`skills/objectstack-automation/references/state-machines-and-approvals.md`
| 392 → 392 | 5936 → 5936 / 5936 (23744 → 23743 bytes) |
| all `skills/*/SKILL.md` (lines) | 4835 → 4854 | |
| bundle total (whole shipped tree, tokens) | | 270968 → 271283 |
</details>
<details><summary>Local gate subset — 74 derived families, 73 exit 0, 1
NOT MEASURED</summary>
The list was derived with `node scripts/pm/dispatch-gates.mjs --commands
--repo objectstack-ai/objectstack` against merge base 3fb7025, which
gave 74 families. Every family ran, and the exit code was captured
before any pipe.
- 73 families exit 0. Among them: `check:skills-token-ratchet`,
`check:skill-links`, `check:skill-refs`, `check:skill-docs`,
`check:skill-served-sections`, `check:skill-examples` (345 prose
examples type-check), `check:doc-authoring`, `check:nul-bytes`,
`check:pm-skill-id-lint`, `check:skill-identifier-liveness`,
`check:docs` and `check:docs-spec-enumerations`.
- `check:skill-examples` and `check:lean-entry-closure` exited 3 on the
first pass, because their built inputs were missing. Both exited 0 after
`client-react` and `objectql` were built.
- `check:dual-build-cjs-loads` exited 3, PREREQUISITE NOT MET.
- The reconciliation `dispatch-gates --ran` printed: `74 derived
famil(ies) accounted for — 73 run, 1 NOT-MEASURED (1 DERIVED from a
recorded exit 3)`.
- `node scripts/pm/overlap-check.mjs --branch=HEAD` printed `VERDICT
clean exit 0`. It merges cleanly with origin/main, with #35129 (which
shares the ai SKILL.md) and with #35002 (which shares the state-machines
file).
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7
<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CazXu8zyYD5PC6J2u7 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
docs(skills): objectstack-ai teaches that an AI-gated action guards its own door only, and pairs an irreversible transition with a lock on the field it changes; the tool-name ladder names its fourth source and the MCP prompts paragraph names `mcpPrompt`
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
objectstack-ai's Common Pitfalls gains "Gating the action, not the state". `ai.requiresConfirmation` guards the action's door, and an agent can still write the same field with `update_record` or any data write. An irreversible transition is a gated `script` action, whose body writes elevated, over a field a non-system write cannot set. `readonly: true` binds every non-system caller (the value is stripped); a field permission without `editable` (refused `403`) binds only a caller no held set grants it, and Modify All grants it. The body skips the caller's edit right, so the action declares who may run it in `requiredPermissions`. A declarative `operation: 'update'` action and a `flow` action under `runAs: 'user'` write as the caller, so the lock stops them too. `readonlyWhen` and a `state_machine` rule bind the elevated body as well, so neither is the door; a `state_machine` dead-end still makes the reached state final for every writer. objectstack-automation's `references/state-machines-and-approvals.md` points to it.
11
+
12
+
The resolution ladder for `skill.tools[]` names four sources: the fourth is `MCP_FILE_TOOL_NAMES`, the MCP door's file tools, resolved only for a skill MCP can offer (`mcpPrompt` not `false`).
13
+
14
+
The paragraph on which skills MCP offers as prompts names `mcpPrompt`: `false` keeps a skill for the in-product agents only, never offered over MCP on any connection whatever its binding, and the stdio transport withholds it too; absent or `true` keeps the binding rule.
1.**`stack.tools[].name`** — records your own stack declares (none by
74
+
default:*Tool metadata* below).
75
75
2.**`PLATFORM_PROVIDED_TOOL_NAMES`** — the statically-registered platform
76
76
tools, flattened from `PLATFORM_TOOLS_BY_PACKAGE` in
77
77
`packages/spec/src/system/constants/platform-tool-names.ts`: data /
@@ -81,8 +81,11 @@ A `skill.tools[]` entry resolves against the union of three sources
81
81
3.**`action_<name>`** — one tool per AI-exposed Action of your own stack
82
82
(`PLATFORM_TOOL_FAMILY_PREFIXES`). **The default path** for anything your app
83
83
does.
84
+
4.**`MCP_FILE_TOOL_NAMES`** (same file) — the MCP door's file tools, resolved
85
+
only for a skill MCP can offer (`mcpPrompt` not `false`): no in-product turn
86
+
registers them.
84
87
85
-
A name in none of the three raises **`ai-skill-tool-unresolved`** (warning,
88
+
A name none of them resolves raises **`ai-skill-tool-unresolved`** (warning,
86
89
ADR-0078 advisory-first). The rule exists because one audited app shipped 10
87
90
fictional tools across 6 skills through `validate` / `lint` clean, and became a
88
91
copilot claiming abilities it did not have.
@@ -332,11 +335,27 @@ there is **no top-level `temperature` / `maxTokens`** on an agent
332
335
there is no storage backend to choose — and neither is a gate. For a gate
333
336
that is **enforced**, use
334
337
`enableActionApproval: true` (approval queue ☁️), `ai.requiresConfirmation` on
335
-
the **action**, or `approval: 'always'` on an MCP tool binding. AI metadata
336
-
edits are already gated: they land as drafts a human must publish (ADR-0033).
337
-
⚠️ `requiresConfirmation` on the **tool** was REMOVED (ADR-0033 §2; retired
338
-
above). There is no `requireApprovalFor` field.
339
-
2.**Indexing everything.** A knowledge source without a `where` filter and
338
+
the **action** (its door only, pitfall 2), or `approval: 'always'` on an MCP
339
+
tool binding. AI metadata edits are already gated: they land as drafts a
340
+
human must publish (ADR-0033). There is no `requireApprovalFor` field.
341
+
2.**Gating the action, not the state.**`ai.requiresConfirmation` guards the
342
+
action's own door only: an agent can still write the field it changes with
343
+
`update_record` or any data write, and the write lands. An irreversible
344
+
transition is a gated action **plus a lock on that field**: a `script`
345
+
action, whose body writes elevated (`isSystem`), over a field a non-system
346
+
write cannot set. `readonly: true` binds every non-system caller (the value
347
+
is stripped, **objectstack-data** → `readonly`); a field permission without
348
+
`editable` (refused `403`) binds only a caller no held set grants it, and
349
+
Modify All grants it, so an admin's agent still writes the field. The body
350
+
skips the caller's edit right: declare who may run the action in its
351
+
`requiredPermissions` (ADR-0066). A declarative
352
+
`operation: 'update'` action, and a `flow` action under `runAs: 'user'`,
353
+
write as the caller, so the lock stops them too. `readonlyWhen` and a
354
+
`state_machine` rule bind the elevated body as well, so neither is the
355
+
door; a `state_machine` dead-end (`closed: []`) still makes the reached
356
+
state final for every writer (**objectstack-automation**
357
+
`references/state-machines-and-approvals.md`).
358
+
3.**Indexing everything.** A knowledge source without a `where` filter and
340
359
curated `contentFields` fills the index with drafts and boilerplate that
341
360
pollute retrieval. Source hygiene is the metadata's job; relevance tuning
342
361
belongs to the adapter.
@@ -351,10 +370,6 @@ there is **no top-level `temperature` / `maxTokens`** on an agent
351
370
| Knowledge source |`src/knowledge/sales-kb.ts`|`KnowledgeSourceSchema` metadata, registered at boot via `KnowledgeServicePlugin({ sources })`|
352
371
| Central registration |`defineStack({ skills: [...] })`|`agents` / `tools` / `skills` are the only AI stack collections — knowledge sources have none, agents are platform-supplied, and `tools` is not the default path |
353
372
354
-
Default for metadata apps: push business capability into **skills**, expose
355
-
business logic as **AI-exposed Actions**, wire domain knowledge through
356
-
**knowledge sources**.
357
-
358
373
---
359
374
360
375
## Platform agents — reference only ☁️
@@ -400,8 +415,12 @@ there but is read: `registerSkillPrompts` offers a skill on `prompts/list` /
400
415
`prompts/get` only when its server lists every tool the skill binds — a plain
401
416
name by that tool, a wildcard by any match, an `action_*` entry also by
402
417
`run_action`. That covers the HTTP door and any host server that calls it; the
403
-
plugin's own stdio transport lists every skill. Bind a tool no MCP family
404
-
serves (the MCP table above) and no filtering server offers the skill.
418
+
plugin's own stdio transport lists every skill except one with
419
+
`mcpPrompt: false`. That optional key is the owner's opt-out: `false` = written
420
+
for the in-product agents only, never offered over MCP on any connection,
421
+
whatever the binding; absent or `true` = the binding rule above. Bind a tool no
422
+
MCP family serves (the MCP table above) and no filtering server offers the
423
+
skill.
405
424
`visualize_data` is the only built-in that draws a chart (an inline `data-chart`
406
425
part), auto-registered **only** when an analytics service (`IAnalyticsService`)
407
426
is wired — `query_data` / `aggregate_data` return numbers, not charts.
0 commit comments