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 0f7389c
Browse filesBrowse the repository at this point in the historyBrowse files
fix(runtime)!: an action the metadata does not show a caller is one that caller cannot run, on every run door (ADR-0106 D1) (#32110)
Clause-②: no (narrowing) — every door that runs an action by name in a
caller's context (`POST /api/v1/actions/...`, bare and addressed, MCP
`run_action`, a host's `dispatchAction`, and the action that admits an
MCP `resume_run`) now runs for a caller only an action the `/meta`
action projection serves that caller, and answers any other as it
answers a name nothing declares. ADR-0106 D1 already promises that a
field the caller cannot read does not exist for that caller, so no
stated contract is narrowed; what narrows is the run a caller with a
`readable: false` field holds. No answer member is added and no code
joins the registered vocabulary, but these doors now also answer `503
FIELD_VISIBILITY_UNRESOLVED`, which none of them answered before.
Metadata-protocol: none
Skills-docs: no move — `skills/**` teaches the run doors only for
actions a caller is shown; `content/docs/ai/connect-mcp.mdx` states the
rule.
## 维护者速读
- **改了什么**:按名称执行动作的每个门(REST `POST /actions` 的裸路径与带命名空间的地址、MCP
`run_action`、宿主 `dispatchAction`、`resume_run` 的准入动作,以及 `run_action`
对系统对象的预筛)在读取动作声明的任何门之前,先用 `/meta`
动作投影的同一判定该调用者能否看到这个动作(动作在任何非展示文字的位置提到调用者不可读的字段即被隐去:参数的
`field`/`name`/默认值/`visible`、动作自身的 `visible`、声明式更新 `patch`
的键等);看不到的动作,在门已解析出唯一声明之后,按该门对"不存在的名字"的回答逐字节作答。
- **为什么改**:ADR-0106 D1 要求调用者不可读的字段在任何平面上都不存在;`/meta` 与 `list_actions`
已经隐去参数绑定了不可读字段的动作,执行门按维护者裁决(记录 6755714726)采用同一判定。
- **风险与回滚**:对带 `readable: false` 字段的调用者是收窄(标题带
`!`):持有该动作但读不到它提到的某个字段的调用者不再能执行它,包括写入只写字段(例如设置密钥)的动作,不论经参数还是
`patch`;迁移方式是授予读权限,或改成处理器动作并让内联参数名不同于字段名(changeset
写明,有测试按字面执行)。字段可见性无法评估或对象定义读取失败时回答 `503
FIELD_VISIBILITY_UNRESOLVED`,什么都不执行。系统上下文、D4 豁免者、无 security
服务或关闭掩码的部署逐字节不变。回滚即 revert 本 PR。
- **先看**:`packages/runtime/src/action-dispatch.ts`(准入序列里新的可见性判定,位于 D4
能力门之前)、`packages/runtime/src/action-run-visibility.ts`(只把门手里的对象与掩码交给
`/meta` 的投影函数)、`packages/runtime/src/domains/mcp.ts`(`run_action` 预筛与
`resume_run`)。
- **两分钟验证**:`pnpm --filter @objectstack/runtime exec vitest run
src/domains/mcp-object-schema-mask.test.ts` —— 预期全部通过;其中 run-door
一组断言:被隐去的动作在 REST、MCP 与宿主门上的回答,与未知名称的回答逐字节相同。
- **需要你做的**:无,席位落地。
## What changes
- **The rule.** An action is run for a caller only where the `/meta`
action projection serves it to that caller. The judgement is
`projectMetaActionForCaller` (`@objectstack/rest`), the function the
`/meta` action reads and MCP `list_actions` already ask, asked against
the object the door runs the action under, over the `/meta` object
door's own masker. `action-run-visibility.ts` only hands it those two
inputs; it adds no rule. That projection withholds an action that
mentions, in any non-prose position, a field the caller cannot read on
that object: a param's `field` or `name`, a param's `defaultValue` or
`visible`, the action's own `visible`, a key of a declarative update's
`patch`, or any other non-prose value; a string literal equal to the
field's name counts. A param's `field` under `objectOverride` is judged
on the object it names.
- **Where.** Once, in the admitted sequence every run door shares
(`action-dispatch.ts`): right after the ADR-0110 D3 trichotomy, before
the AI-door rules, the ADR-0066 D4 capability gate, the activation
consult, the type checks and the ADR-0104 param contract. So a withheld
action discloses no gate, no switch and no param shape, and reads no
record. The MCP bridge asks the same question where it admits an action
outside that sequence: `run_action`'s scoped `sys_*` pre-screen
(`capabilityRefusal` answers nothing for a withheld action) and
`resume_run` (a withheld candidate admits nothing and is no refusal).
`list_actions` now derives the object it judges by the same function the
run doors use.
- **The answer.** Once the door has resolved one declaration for the
name, a withheld action is answered with the door's own unknown-name
answer, built by the same function. Answers given while the name is
still being resolved (a name more than one package holds is one) come
before this question and are unchanged. The unknown-name answers are the
bare `/actions` arm's undeclared `404`, the addressed arm's `404` for
its namespace or the environment (`addressedActionNotFoundError`, now
shared by the resolver and this answer), `run_action`'s not-found
refusal, and for `resume_run` the refusal a run no flow action could
have started receives.
- **Refusal.** Where the caller's field visibility cannot be evaluated,
the definition of the action's object cannot be read (a read that throws
is a fault, never "no object"), or the projection would leave that
object with no field: `503 FIELD_VISIBILITY_UNRESOLVED`, fail-closed, as
the `/meta` object door refuses the read.
- **Unchanged.** The system context, a D4-exempt caller
(`manage_metadata`), a deployment with no `security` service or with the
mask switched off, and every caller for an action that mentions no field
that caller cannot read.
## Tests
- `src/action-run-visibility.test.ts` (new): the run-door judgement
against the `/meta` object door's and action door's own verdicts, case
by case — 7 callers (a field-restricted member, staff, a caller denied
every field, a security outage, an undetermined field universe, the
system context, a D4-exempt author) × embedded, standalone and
object-less actions of 11 shapes: the param bindings, plus a `patch`
key, an action `visible` predicate, an inline param named like the
field, a literal default, and the changeset's migration rewrite; the
ruled verdicts; an object-less action run under a routed object judged
on that object; and a system-context CONTROL that never asks the
security service.
- `src/domains/mcp-object-schema-mask.test.ts`, new top-level describe
over the real security layer: REST `/actions`, MCP `run_action` and host
`dispatchAction` (both postures) answer a withheld action byte-identical
to an unknown name for every bag shape, and write nothing; a
capability-gated withheld action is answered as unknown, never as its
gate's refusal, and the scoped pre-screen names no gate; the `503` on
both doors, for a caller denied every field and for a security service
that throws; CONTROLs: an action the member is shown runs (REST and MCP,
rows written), a shown caller still gets the located param `400`, and
the system context and a D4-exempt author are answered as a deployment
with the mask switched off. The changeset's migration followed literally
(a handler action with an inline param not named like the field) runs
for the member on both doors; the same rewrite with the param named like
the field stays withheld. A params-less action whose `patch` writes the
field is withheld.
- `src/domains/actions-addressed-route.test.ts`: the addressed REST path
and a namespaced `run_action` answer a withheld action byte-identical to
a name the namespace does not declare; CONTROL runs. A run whose
action-object definition read throws is refused `503
FIELD_VISIBILITY_UNRESOLVED` and runs nothing; CONTROL: with no security
service no definition is read and nothing is refused.
- `src/mcp-resume-run.test.ts`: a run whose admitting action the caller
can no longer see is refused exactly as a run on a deployment declaring
no action for its flow, and stays parked; the `503`; CONTROL resumes.
## Acceptance notes
- An object-less action run under a routed object is judged on that
object, the one its params resolve against at run time; the `/meta`
action read judges an object-less entry by its `objectOverride` params
alone. Kept by decision and pinned in `action-run-visibility.test.ts`.
- The error-code ledger's comment listing this package's
`FIELD_VISIBILITY_UNRESOLVED` emitters names the MCP schema reads, not
the run doors; the code is registered for `@objectstack/runtime`, so no
gate reads that comment. Left for a spec-lane edit.
## Verification
Patch round readings, under the shared verify lock. The PR head is
`9688f8fb4f`.
<details><summary>Pins</summary>
At `9688f8fb4f`: `pnpm --filter @objectstack/runtime exec vitest run
--maxWorkers=2 src/action-run-visibility.test.ts
src/domains/mcp-object-schema-mask.test.ts
src/domains/actions-addressed-route.test.ts src/mcp-resume-run.test.ts`
```
Test Files 4 passed (4)
Tests 307 passed (307)
```
</details>
<details><summary>One-shot ablations</summary>
- The admission check (first round, at `a898febdf4`): the run doors'
masker made to answer a passthrough posture for every caller. 9 red,
then restored.
- A failing definition read (this round, at `0b28d8e5e3`):
`ablation-replace.mjs` made the read answer "no object" instead of a
fault (anchor hit once). `actions-addressed-route.test.ts` went red on
the `503` pin (plus the control as first written, which `9688f8fb4f`
rewrote), then restored: `git diff HEAD` empty, blob equal to HEAD.
</details>
<details><summary>Runtime suite, typecheck and dogfood battery</summary>
- `pnpm --filter @objectstack/runtime typecheck` at `0b28d8e5e3` — exit
0 (`tsc --noEmit` and `check:test-typecheck`). `9688f8fb4f` changes one
test file only.
- `pnpm --filter @objectstack/runtime test` at `0b28d8e5e3`: 576 of 577
files and 9578 tests passed, 19 skipped. The one red was the
failing-read control as first written. `9688f8fb4f` rewrites it, and the
pin files above pass at that head.
- Dogfood battery (first round, at `a898febdf4`): 446 files passed (3
skipped), 3695 tests passed (42 skipped). This round's code change is in
`action-dispatch.ts` only.
</details>
<details><summary>Derived gates</summary>
At `9688f8fb4f`, `node scripts/pm/dispatch-gates.mjs --commands` derived
101 families; all were run and reconciled with `--ran` (exit codes
recorded): 98 exit 0, 3 NOT MEASURED. `check:skill-examples` and
`check:dual-build-cjs-loads` refused on build output this tree had not
built. `check:type-check-debt` never got a turn on the shared lock. CI
builds and runs all three. `test:repo` is CI's.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYn5CmmdShCJifm6WYj)_
<!-- signed: security#2 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(runtime)!: an action the metadata does not show a caller is one that caller cannot run, on every run door (ADR-0106 D1)
6
+
7
+
Clause-②: no (narrowing) — every door that runs an action by name in a caller's context (`POST /api/v1/actions/...`, bare and addressed, MCP `run_action`, a host's `dispatchAction`, and the action that admits an MCP `resume_run`) now runs for a caller only an action the `/meta` action projection serves that caller, and answers any other as it answers a name nothing declares. ADR-0106 D1 already promises that a field the caller cannot read does not exist for that caller, so no stated contract is narrowed; what narrows is the run a caller with a `readable: false` field holds. No answer member is added and no code joins the registered vocabulary, but these doors now also answer `503 FIELD_VISIBILITY_UNRESOLVED`, which none of them answered before.
8
+
Metadata-protocol: none
9
+
Skills-docs: no move — `skills/**` teaches the run doors only for actions a caller is shown; `content/docs/ai/connect-mcp.mdx` states the rule.
10
+
11
+
<!-- adr-0087: not-required (no-migration-prescription) No key of any schema and no stored shape changes: the run doors judge a caller by the projection the metadata doors already apply. There is nothing for a migration to rewrite and no tombstone. -->
12
+
13
+
**BREAKING** for a caller with a `readable: false` field, on `POST /api/v1/actions/...`, on `dispatchAction`, and on MCP `run_action` and `resume_run` over HTTP (`/api/v1/mcp`).
14
+
15
+
-**The rule.** An action is run for a caller only where the `/meta` action projection serves it to that caller: the same judgement, asked through `projectMetaActionForCaller` (`@objectstack/rest`), against the object the door runs the action under. The projection withholds an action that mentions, in any position that is not display prose, a field the caller cannot read on that object: a param's `field` or `name`, a param's `defaultValue` or `visible` predicate, the action's own `visible` predicate, a key of a declarative update's `patch`, or any other non-prose value of the action. A string literal equal to the field's name counts as a mention. A param's `field` under `objectOverride` is judged on the object it names. Labels, descriptions and other display prose are not read.
16
+
-**The answer.** Once the door has resolved one declaration for the name, a withheld action is answered byte for byte as the same door answers a name nothing declares. Answers the door gives while it is still resolving the name (a name more than one package holds is one) come before this question and are unchanged. The unknown-name answers are the bare `/actions` arm's `404` (and `dispatchAction`'s), the addressed arm's `404` for its namespace or the environment, `run_action`'s not-found refusal, and for `resume_run` the refusal a run no flow action could have started receives. The question is asked before every gate that reads the action's declaration on the caller's behalf (its capability gate, its activation switch, its param contract), so nothing is read or run.
17
+
-**Declared narrowing.** A caller who holds the action, and its capability, but cannot read a field the action mentions can no longer run it. That includes an action that writes a field the caller may write but not read, such as one that sets a secret, whether through a param or through `patch`. To keep such a run, either grant the caller read on every field the action mentions, or rewrite the action so that no non-prose position spells that field's name as a whole word. A declarative update cannot write a field without naming it, so move the write into a handler: `type: 'script'`, a `target` handler that writes the field, and an inline param whose `name` is not the field's (`new_amount`, not `budget`). A param named like the field is a mention, and keeps the action withheld.
18
+
-**Refusal.** Where the caller's field visibility cannot be evaluated, the definition of the action's object cannot be read, or the projection would leave that object with no field, the run is refused as the `/meta` object door refuses the read: `FIELD_VISIBILITY_UNRESOLVED` / 503, fail-closed. Nothing runs.
19
+
-**Unchanged.** The system context, a D4-exempt caller (`manage_metadata`), and a deployment with no `security` service or with the mask switched off run every action as before; so does every caller for an action that mentions no field that caller cannot read.
0 commit comments