From 761128865fe9c1886b7e849e38c1ae323f2a6fed Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 03:32:31 +0000 Subject: [PATCH 1/2] docs(skills): a gated action guards its door only; lock the field an irreversible transition changes objectstack-ai Common Pitfalls teaches the gated script action plus a readonly or field-permission lock on the state field, and why readonlyWhen and a state_machine rule cannot be the door. The tool-name ladder names MCP_FILE_TOOL_NAMES as its fourth source (here and in content/docs/ai/tools.mdx), and the MCP prompts paragraph names mcpPrompt and the stdio exception. state-machines-and-approvals.md points to the pitfall; restatement cut in both files to pay for it. Claude-Session: https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7 Co-authored-by: Claude --- .changeset/35068-gated-action-field-lock.md | 14 ++++++ content/docs/ai/tools.mdx | 4 +- skills/objectstack-ai/SKILL.md | 47 +++++++++++++------ .../state-machines-and-approvals.md | 10 ++-- 4 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 .changeset/35068-gated-action-field-lock.md diff --git a/.changeset/35068-gated-action-field-lock.md b/.changeset/35068-gated-action-field-lock.md new file mode 100644 index 00000000000..8bddfb66e40 --- /dev/null +++ b/.changeset/35068-gated-action-field-lock.md @@ -0,0 +1,14 @@ +--- +'@objectstack/skills': patch +--- + +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` + +Clause-②: no +Metadata-protocol: none + +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` (the value is stripped) or field permissions that leave the caller no `editable` on it (refused `403`). 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. + +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`). + +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. diff --git a/content/docs/ai/tools.mdx b/content/docs/ai/tools.mdx index 3f7cfbf9534..7543cef2b0a 100644 --- a/content/docs/ai/tools.mdx +++ b/content/docs/ai/tools.mdx @@ -190,7 +190,9 @@ export const CaseHandoverSkill = defineSkill({ ## How the name is resolved -A `skill.tools[]` entry resolves against three sources, in order: +A `skill.tools[]` entry resolves against three sources, in order, and a skill +MCP can offer (`mcpPrompt` not `false`) against a fourth, the MCP door's file +tools (`MCP_FILE_TOOL_NAMES` in `@objectstack/spec/system`): 1. the stack's own `tools[]` names — the refinement records on this page; 2. the curated registry of tools the platform runtime registers at boot; diff --git a/skills/objectstack-ai/SKILL.md b/skills/objectstack-ai/SKILL.md index 89967fa24be..9f99c2946f6 100644 --- a/skills/objectstack-ai/SKILL.md +++ b/skills/objectstack-ai/SKILL.md @@ -67,11 +67,11 @@ conditions. ### Naming the tools: the resolution ladder -A `skill.tools[]` entry resolves against the union of three sources -(`collectToolUniverse` in `packages/lint/src/validate-ai-tool-references.ts`): +A `skill.tools[]` entry resolves against the union of four sources +(`packages/lint/src/validate-ai-tool-references.ts`): -1. **`stack.tools[].name`** — records your own stack declares. ADR-0109: the - default third-party path declares **none** (see *Tool metadata* below). +1. **`stack.tools[].name`** — records your own stack declares (none by + default: *Tool metadata* below). 2. **`PLATFORM_PROVIDED_TOOL_NAMES`** — the statically-registered platform tools, flattened from `PLATFORM_TOOLS_BY_PACKAGE` in `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 3. **`action_`** — one tool per AI-exposed Action of your own stack (`PLATFORM_TOOL_FAMILY_PREFIXES`). **The default path** for anything your app does. +4. **`MCP_FILE_TOOL_NAMES`** (same file) — the MCP door's file tools, resolved + only for a skill MCP can offer (`mcpPrompt` not `false`): no in-product turn + registers them. -A name in none of the three raises **`ai-skill-tool-unresolved`** (warning, +A name none of them resolves raises **`ai-skill-tool-unresolved`** (warning, ADR-0078 advisory-first). The rule exists because one audited app shipped 10 fictional tools across 6 skills through `validate` / `lint` clean, and became a copilot claiming abilities it did not have. @@ -332,11 +335,27 @@ there is **no top-level `temperature` / `maxTokens`** on an agent there is no storage backend to choose — and neither is a gate. For a gate that is **enforced**, use `enableActionApproval: true` (approval queue ☁️), `ai.requiresConfirmation` on - the **action**, or `approval: 'always'` on an MCP tool binding. AI metadata - edits are already gated: they land as drafts a human must publish (ADR-0033). + the **action** (its door only, pitfall 2), or `approval: 'always'` on an MCP + tool binding. AI metadata edits are already gated: they land as drafts a + human must publish (ADR-0033). ⚠️ `requiresConfirmation` on the **tool** was REMOVED (ADR-0033 §2; retired above). There is no `requireApprovalFor` field. -2. **Indexing everything.** A knowledge source without a `where` filter and +2. **Gating the action, not the state.** `ai.requiresConfirmation` guards the + action's own door only: an agent can still write the field it changes with + `update_record` or any data write, and the write lands. An irreversible + transition is a gated action **plus a lock on that field**: a `script` + action, whose body writes elevated (`isSystem`), over a field a non-system + write cannot set — `readonly: true` (the value is stripped, + **objectstack-data** → `readonly`) or field permissions leaving the caller + no `editable` on it (refused `403`; any set granting it wins, + **objectstack-data** `rules/security.md`). 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 (`closed: []`) still makes the reached + state final for every writer (**objectstack-automation** + `references/state-machines-and-approvals.md`). +3. **Indexing everything.** A knowledge source without a `where` filter and curated `contentFields` fills the index with drafts and boilerplate that pollute retrieval. Source hygiene is the metadata's job; relevance tuning belongs to the adapter. @@ -351,10 +370,6 @@ there is **no top-level `temperature` / `maxTokens`** on an agent | Knowledge source | `src/knowledge/sales-kb.ts` | `KnowledgeSourceSchema` metadata, registered at boot via `KnowledgeServicePlugin({ sources })` | | 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 | -Default for metadata apps: push business capability into **skills**, expose -business logic as **AI-exposed Actions**, wire domain knowledge through -**knowledge sources**. - --- ## Platform agents — reference only ☁️ @@ -400,8 +415,12 @@ there but is read: `registerSkillPrompts` offers a skill on `prompts/list` / `prompts/get` only when its server lists every tool the skill binds — a plain name by that tool, a wildcard by any match, an `action_*` entry also by `run_action`. That covers the HTTP door and any host server that calls it; the -plugin's own stdio transport lists every skill. Bind a tool no MCP family -serves (the MCP table above) and no filtering server offers the skill. +plugin's own stdio transport lists every skill except one with +`mcpPrompt: false`. That optional key is the owner's opt-out: `false` = written +for the in-product agents only, never offered over MCP on any connection, +whatever the binding; absent or `true` = the binding rule above. Bind a tool no +MCP family serves (the MCP table above) and no filtering server offers the +skill. `visualize_data` is the only built-in that draws a chart (an inline `data-chart` part), auto-registered **only** when an analytics service (`IAnalyticsService`) is wired — `query_data` / `aggregate_data` return numbers, not charts. diff --git a/skills/objectstack-automation/references/state-machines-and-approvals.md b/skills/objectstack-automation/references/state-machines-and-approvals.md index 4395a266bac..709a08014be 100644 --- a/skills/objectstack-automation/references/state-machines-and-approvals.md +++ b/skills/objectstack-automation/references/state-machines-and-approvals.md @@ -11,8 +11,7 @@ Since **ADR-0020** there is **no `workflow` metadata type** and no validation rule** in the object's `validations` array: a flat `field` + `{ from: [allowedTo] }` transition table. It is **enforced on the write path** — an update whose `field` moves to a state not listed for the current state is -rejected with the rule's `message`. A `from` state mapped to `[]` is a declared -dead-end. +rejected with the rule's `message`. ```typescript @@ -36,7 +35,7 @@ const rule: StateMachineValidation = { Notes: - **One rule per field.** Parallel lifecycles (e.g. `status` + `payment_status`) - are N separate `state_machine` rules, one per field. + are N separate `state_machine` rules. - **`initialStates`** (optional) gates INSERT: a record created with its state field outside this list is rejected. `transitions` only governs updates, so without it a record can be born mid-flow (e.g. created already @@ -55,6 +54,8 @@ Notes: you want guarded rather than relying on an implicit "any → any". - Predicate conditions in sibling rules evaluate against the merged record in the **`record.`** CEL scope (bare field names do not resolve). +- **An AI-gated irreversible transition** pairs this rule with a lock on + `field`: **objectstack-ai** → Common Pitfalls. ### Approvals (Flow Nodes) @@ -260,8 +261,7 @@ entered. Its CEL source sees exactly **three roots** — nothing else: **`record` and bare field names are NOT available and fail the node loudly.** Everywhere else on this platform `record` means "the record at event time" — at an approval node that phrase is ambiguous between two different times, so you must -say which one: `current.x` or `trigger.x`. Do not carry the `record.x` habit -over from conditions. +say which one: `current.x` or `trigger.x`. Result contract: a user-id string, a CSV string, or an array of ids. An **empty** result (present-but-empty field/variable) triggers `onEmptyApprovers`. A From af46d3bb112023906010034d8e84222f09274f6c Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 04:31:44 +0000 Subject: [PATCH 2/2] docs(skills): pitfall 2 names Modify All as a field-permission grant and asks for requiredPermissions on the gated action readonly: true is the arm that binds every non-system caller; a field permission without editable binds only a caller no held set grants it, and Modify All grants it. The elevated body skips the caller's edit right, so the gated action declares requiredPermissions. Paid down in the same file: pitfall 1's retired-tool sentence (taught under Tool metadata) and the duplicated agents-are-internal lead. Claude-Session: https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7 Co-authored-by: Claude --- .changeset/35068-gated-action-field-lock.md | 2 +- skills/objectstack-ai/SKILL.md | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.changeset/35068-gated-action-field-lock.md b/.changeset/35068-gated-action-field-lock.md index 8bddfb66e40..73a156c82be 100644 --- a/.changeset/35068-gated-action-field-lock.md +++ b/.changeset/35068-gated-action-field-lock.md @@ -7,7 +7,7 @@ docs(skills): objectstack-ai teaches that an AI-gated action guards its own door Clause-②: no Metadata-protocol: none -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` (the value is stripped) or field permissions that leave the caller no `editable` on it (refused `403`). 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. +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. 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`). diff --git a/skills/objectstack-ai/SKILL.md b/skills/objectstack-ai/SKILL.md index 9f99c2946f6..23462ac27b9 100644 --- a/skills/objectstack-ai/SKILL.md +++ b/skills/objectstack-ai/SKILL.md @@ -36,9 +36,9 @@ Agent → Skill → Tool └─ Autonomous actor with role, instructions, and guardrails ``` -Agents are platform-internal (☁️ `ask` / `build`; reference section at the -bottom). **Skills are your entry point** — you extend the platform by authoring -skills, and a skill reaches tools by naming them. +**Skills are your entry point** — agents are platform-internal (reference +section at the bottom), so you extend the platform by authoring skills, and a +skill reaches tools by naming them. --- @@ -337,18 +337,18 @@ there is **no top-level `temperature` / `maxTokens`** on an agent `enableActionApproval: true` (approval queue ☁️), `ai.requiresConfirmation` on the **action** (its door only, pitfall 2), or `approval: 'always'` on an MCP tool binding. AI metadata edits are already gated: they land as drafts a - human must publish (ADR-0033). - ⚠️ `requiresConfirmation` on the **tool** was REMOVED (ADR-0033 §2; retired - above). There is no `requireApprovalFor` field. + human must publish (ADR-0033). There is no `requireApprovalFor` field. 2. **Gating the action, not the state.** `ai.requiresConfirmation` guards the action's own door only: an agent can still write the field it changes with `update_record` or any data write, and the write lands. An irreversible transition is a gated action **plus a lock on that field**: a `script` action, whose body writes elevated (`isSystem`), over a field a non-system - write cannot set — `readonly: true` (the value is stripped, - **objectstack-data** → `readonly`) or field permissions leaving the caller - no `editable` on it (refused `403`; any set granting it wins, - **objectstack-data** `rules/security.md`). A declarative + write cannot set. `readonly: true` binds every non-system caller (the value + is stripped, **objectstack-data** → `readonly`); a field permission without + `editable` (refused `403`) binds only a caller no held set grants it, and + Modify All grants it, so an admin's agent still writes the field. The body + skips the caller's edit right: declare who may run the action in its + `requiredPermissions` (ADR-0066). 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