Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/35068-gated-action-field-lock.md
Original file line number Diff line number Diff line change
@@ -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` 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`).

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.
4 changes: 3 additions & 1 deletion content/docs/ai/tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
57 changes: 38 additions & 19 deletions skills/objectstack-ai/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---

Expand Down Expand Up @@ -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 /
Expand All @@ -81,8 +81,11 @@ A `skill.tools[]` entry resolves against the union of three sources
3. **`action_<name>`** — 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.
Expand Down Expand Up @@ -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).
⚠️ `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
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). 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` 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
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.
Expand All @@ -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 ☁️
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

<!-- os:check -->
```typescript
Expand All @@ -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
Expand All @@ -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.<field>`** 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)

Expand Down Expand Up @@ -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
Expand Down
Loading