Skip to content

Commit b22be27

Browse files
fix(mcp): validate_expression gives the publish gate's verdict at validation and formula sites (#33134)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao6bxPjjxx5Q76zwSbAq6zBX)_ Fixes #32872 Clause-②: no (narrowing) — the MCP `validate_expression` tool now answers `ok: false` (or a warning) at a `validation` or `formula` site for an expression the publish gate already refuses (or warns on). The gate's acceptance set does not change, and no existing exported type or signature changes. Metadata-protocol: none Skills-docs: none — the published skills (`objectstack-formula`, `objectstack-ai`) say only that the tool runs the build's validator, which stays true; what it refuses is taught by the served `SKILL.md` line this diff corrects. ## 维护者速读 - 改了什么:MCP `validate_expression` 在 `validation` / `formula` 位点除共享校验器外,还跑发布门禁自己的那几道检查(经 lint 新导出的 `judgeAuthoredSiteExpression`,对调用者被服务的对象定义跑门禁本身的遍历),门禁拒的它也拒;跳转目标与 `describe_object` 守同一道系统对象围栏;lint 在首次需要时才懒加载;服务端 `SKILL.md` 与 Console 镜像同步改那一行。`flow_condition` 位点不在本 PR(席位另开卡)。 - 为什么改:工具承诺"给出发布门禁对这条规则的判定",却只跑共享校验器,对空值未守卫、跳到目标对象未声明字段、跳进存储元数据表、校验规则读 `parent` 这几类答 `ok: true`,到发布时才第一次被拒。 - 风险与回滚:只收窄一个建议性工具的判定,门禁的接受集不变;门禁接受的表达式答案与之前逐字相同。`@objectstack/mcp` 把 `@objectstack/lint` 从 devDependency 挪到 dependency(无环)。回滚即 revert 本 PR。 - 先看:`packages/lint/src/authored-site-expression.ts`(入口:构造门禁要判的 stack 再跑门禁自己的 walk)与 `packages/lint/src/validate-expressions.ts` 新增的 `sharedValidatorRunByCaller`(仅跳过共享校验器那一次调用)。 - 两分钟验证:`pnpm --filter @objectstack/lint exec vitest run src/authored-site-expression.test.ts` 与 `pnpm --filter @objectstack/mcp exec vitest run src/mcp-validate-expression.test.ts`。 - 需要你做的:无,席位落地。 ## What changes This closes #32872 at the two sites the card names, `validation` and `formula`. The gate's own passes at a `flow_condition` (the unprovisioned-anchor warning on an object-bound flow predicate, and the null-guard gate on a record-triggered flow's start, `decision` and edge conditions) are not run by the tool, and this PR does not change its verdict there. They are a follow-up card. The tool promises the verdict the publish gate gives the rule, but it ran the shared expression validator (`@objectstack/formula`'s `validateExpression`) and nothing else. Measured on `origin/main` before the change, it answered `ok: true` at these sites for rules the gate refuses: | site | expression (fixture) | gate verdict | tool before | tool after | |---|---|---|---|---| | both | `record.balance.nope` (hop to a field the target does not declare) | error | ok | error, gate's sentence | | both | a hop into a stored-metadata table | error | ok | error, gate's sentence | | `validation` | `record.days > 3`, `days` neither required nor defaulted (null guard) | error | ok | error, gate's sentence | | `validation` | a read of `parent` | error | ok | error, gate's sentence | | both | `record.owner_id` on an ADR-0015 `external` object | warning | none | warning, gate's sentence | - `@objectstack/lint` - New `judgeAuthoredSiteExpression` (`packages/lint/src/authored-site-expression.ts`). ⛔ It re-implements no pass. It builds the stack the gate would judge (the subject object carrying the one probe rule or probe formula field, plus the hop targets it reads through) and runs the gate's own walk `runStackExpressionPasses` over it, as the object save door does (`runtimeWriteType: 'object'`). It returns exactly the findings the gate locates on that rule or field: by key path `objects[0].validations[0].` at a validation site, and by the field's `where` at a formula site. Any pass later added to the gate at either site is carried by construction. - New `authoredExpressionHopTargets`: the reference targets the expression reads through, read with the analysis and target accessor the gate's hop passes use. - The gate gains one option, `sharedValidatorRunByCaller`, which skips only the `validateExpression` call the caller has already made. Every other pass runs unchanged. **No gate caller passes it.** Its one passer is the new entry, and a source pin in `authored-site-expression.test.ts` now holds that by test (grep at `8a5f028f`): ``` $ grep -rn "sharedValidatorRunByCaller" packages scripts ui apps (excluding node_modules, dist) packages/lint/src/validate-expressions.ts:2277: sharedValidatorRunByCaller?: boolean; packages/lint/src/validate-expressions.ts:2281: * [#32872] What {@link StackExpressionOptions.sharedValidatorRunByCaller} packages/lint/src/validate-expressions.ts:2324: // [#32872] See {@link StackExpressionOptions.sharedValidatorRunByCaller}. packages/lint/src/validate-expressions.ts:2325: const validatorRunByCaller = options.sharedValidatorRunByCaller === true; packages/lint/src/authored-site-expression.ts:22: * already made left out (`sharedValidatorRunByCaller`). What comes back is packages/lint/src/authored-site-expression.ts:131: { runtimeWriteType: 'object', sharedValidatorRunByCaller: true }, $ grep -rn "runStackExpressionPasses(" packages apps (excluding node_modules, dist, tests) packages/lint/src/validate-expressions.ts:2295: return runStackExpressionPasses(stack, {}); packages/lint/src/authoring-rules.ts:827: runStackExpressionPasses(stack, { runtimeWriteType: ctx.runtimeWriteType }).map((i) => ({ packages/lint/src/authored-site-expression.ts:129: const issues = runStackExpressionPasses( ``` - Served definitions carry the system columns the registry injects as declared fields. The gate judges the body as authored, so the entry reads each one through `stripInjectedSystemColumns` (`@objectstack/metadata-core`, the write path's own strip). Without it, the null guard would refuse `created_at`, and an external object's anchors would read as columns its author vouches for. - `@objectstack/mcp` - `McpDataBridge` gains the optional `servedObjectDefinitionOf(name)`: the object definition as the caller is served it (the read `describeObject` projects). It is handed to the gate and rendered to nobody. A bridge without it answers the shared validator's verdict alone, as before. The stdio bridge serves it from its served view. - `validate_expression` at `formula` and `validation` merges the gate's findings into `errors` / `warnings`, as `{ source, message }` in the gate's words at the gate's severity. A `flow_condition` and a `template` are not judged by this change, and no definition is read for them. - Hop targets follow the same system-object fence as `describe_object`: a target the tool's object-name guard refuses is neither read nor judged, so a hop into a system object is judged only where the server sets `allowSystemObjects`. - The tool description and the served `SKILL.md` line name what the tool now refuses, give the unprovisioned-column warning its two sites, and state the fence. - **New runtime dependency:** `@objectstack/lint` moves from `devDependencies` to `dependencies` (`packages/mcp/package.json`, with the matching six-line `pnpm-lock.yaml` move). **No cycle:** `@objectstack/lint` depends only on `@objectstack/formula`, `@objectstack/metadata-core`, `@objectstack/sdui-parser` and `@objectstack/spec`, and none of those depends on `@objectstack/mcp`. `@objectstack/runtime` and `@objectstack/cli` already depend on `@objectstack/lint` at runtime. **Loaded lazily:** `gatePassFindings` imports lint's root entry with `await import('@objectstack/lint')` on the first call that judges a rule or formula field, and the module imports only its types, so the boot path still reaches lint only through `@objectstack/lint/runtime`, as every other server-side consumer does. The full workspace build orders it cleanly (119/119 tasks). - `@objectstack/runtime`: the HTTP MCP bridge serves `servedObjectDefinitionOf` through `readObjectForCaller`, the same caller-scoped read `describeObject` uses (ADR-0106 D1), so a field masked from the caller is masked from the gate's input too. - `@object-ui/console`: the downloadable `SKILL.md` mirror carries the same line, byte for byte. - Changeset `.changeset/32872-validate-expression-gate-parity.md`: patch for the four packages, with the **BREAKING** verdict-narrowing banner and an ADR-0087 `not-required (no-migration-prescription)` disposition. Every expression the tool now refuses, the gate already refused, so neither stored metadata nor consumer code has anything to rewrite. - Registration only: `scripts/cross-package-test-inputs.mjs` (the `@objectstack/lint` entry) and `turbo.json` (`@objectstack/lint#test` inputs) declare `scripts/js-comment-mask.mjs` and its `.d.mts`, which the new lint test imports to read the gate's source without its comments. ## Tests - `packages/lint/src/authored-site-expression.test.ts` (new, 26 tests) - **Enumeration pins.** The test reads the gate's source through the shared comment mask. - Per site, inside the gate's regions for it (`check` plus the validation-rule loop for `validation`; `judgeFieldFormula` plus the span after its call site for `formula`), every call by bare name is classified as `validator`, `plumbing`, `pass` (with a refusal fixture) or `pass-silent-here`, and every member call by its method name is classified as plumbing. - Across the whole walk (`runStackExpressionPasses`), every pass handed to the walk as `issues.push(fn(` or `issues.push(...fn(`, member names included, is classified. That is the shape of the walk's whole-stack passes at its tail (`bulkConfirmTextIssues`, `actionCopyTemplateIssues`). - `formulaCycleIssues` (from main) is classified `pass-silent-here` at the formula site, with a pin that it fires on the object's own cycle and locates nothing on the probe. - Each addition reds until it is classified. Proven by ablation: a new bare call inside `judgeFieldFormula`, a `formulaCycleIssues`-shaped spread after the fields loop, a new member call there, and a new `issues.push(...)` beside `bulkConfirmTextIssues`. - **What it cannot see** (also in the test's docblock): a pass outside the regions that pushes by another shape (an inline `issues.push({ … })`, a loop over a helper's result, a helper that pushes into `issues` itself), and a pass handed by reference (`.map(fn)`). Such a pass is still carried by construction when it locates its finding on the judged rule's key path or the judged field's `where`. What no pin catches is a pass located elsewhere, or one that needs an input the tool is not handed. - **The skip option reaches no gate run.** A source scan over lint's own sources (tests aside, comments and literals masked) holds `sharedValidatorRunByCaller` to its declaration, the walk's one read, and the one passer in `authored-site-expression.ts`. A second scan holds `runStackExpressionPasses` and `StackExpressionOptions` off all three package entries. - **One refusal pin per pass.** For each pass, the entry's findings equal the gate's own findings on the same stack (the full `runStackExpressionPasses` minus the shared validator's). - **CONTROLs.** An accepted rule and an accepted formula answer `[]`. - Also: the validator is left to the caller; the subject's own rules are ignored; a served definition (with injected columns) judges as authored; an absent object answers `[]`; hop-target reads. - `packages/mcp/src/mcp-validate-expression.test.ts`: a new describe block with one tool-level pin per member (8). It also pins that an injected `created_at` is not refused, that only hop targets are read, a CONTROL equal to the definition-less bridge, that a bridge without the member answers as before, and that `flow_condition` / `template` read no definition. **Fence pin:** a hop into a served `sys_user` is refused with `allowSystemObjects` on. By default the target is not read, and the answer equals the definition-less bridge's. - The two bridge-member ledgers (`mcp-write-response-internal-fields.tripwire.test.ts`, `stdio-data-bridge.stored-metadata-body.test.ts`) classify the new member. Both went red without the entry, as their ledgers intend. - `packages/runtime/src/domains/mcp-object-schema-mask.test.ts` adds `servedObjectDefinitionOf` to the ADR-0106 case table, with a masked field-set assertion. `mcp-option-fields-read.test.ts` pins that it equals the served object, that its keys equal `describeObject`'s fields, and that it answers null when the object is absent. ## Acceptance notes - **Findings carry no `code`.** The gate's `ExprIssue` has none, so the tool's added findings are `{ source, message }` with the gate's sentence. - **The probe rule is named `this rule`.** The tool is handed the condition, not the rule it will sit on, so a gate sentence that names the rule (the null guard, `parent`) names it `this rule`. The probe formula field is spelled `__validate_expression__`, and no gate sentence at the formula site names it. - **The formula-cycle pass (#33108) is classified `pass-silent-here` at the formula site.** It landed on main and this branch merged it. Its call sits after the fields loop, inside the formula region, and both the formula enumeration pin and the whole-walk push pin went red on the merge (`+ "formulaCycleIssues"`) until it was classified. It locates each finding on a cycle member's own `expression`. The probe is named `__validate_expression__`, which no authored formula can read, so the probe is never on a cycle. A pin shows the pass does fire on the object's own cycle, and that neither the gate nor the entry locates a finding on the probe. **Limitation:** the tool cannot give the cycle verdict for the formula being authored, because it is not handed that field's own name. That belongs with the follow-up card. - **`storedExpressionInputIssues` is `pass-silent-here`.** That holds for a `formula` probe. A stored (non-`formula`) field's `expression` authored through `site: 'formula'` gets the gate's stored-input warnings and none from the tool. This goes with the follow-up card. - **Context the one-object probe stack does not share with the gate.** These are corners, written down. Only the first two are cases where the tool refuses and the gate does not. - Package closure: the object save door narrows `objects` to the written package's closure, so a target outside it is not judged there. The tool judges any target the caller is served. The tool's refusal is true (the field does not exist), and the door's silence is the gap. - A target field masked from the caller is refused as undeclared. This conforms to ADR-0106 D1 and to what the shared validator already answers for a masked subject field. - A target the caller is not served, or a system-object target behind the fence, is not judged, so the tool stays `ok` where the gate refuses. This residual runs in the pre-existing direction. - A picklist-bound field is served with resolved `options`. A default option makes it non-nullable for the tool, while the authored body the gate reads names only the picklist. - The entry finds the subject by `name === objectName`. On the bridge's no-protocol fallback, a differently spelled name answers `[]`. - A fault-tier target turns the call into a door error instead of a verdict, the same answer `describe_object` gives for that target. - **Scope of the hint lists.** The tool's `fields` / stdlib hints still come from the tool's own index. Only the verdict reads the gate. - **The shared validator runs once.** The tool keeps its own `validateExpression` call, which carries `code`s and the site options. The gate's copy is skipped, so a validator finding is never reported twice. ## Verification Head: `8a5f028f`. Round 2 is the review fixes in `e306a89d`, then `origin/main` merged for #33108 with its pass classified (`bd2b25ff`), then merged again for #33142, which touched `mcp-http-tools.ts` (`8a5f028f`, clean). Round 1 was `95b340e2`. <details><summary>Measurement on origin/main (before)</summary> A throwaway vitest file (not committed) ran the gate's walk and the tool's handler on the same fixtures at origin/main: ``` 1 null-guard | validation | `record.days > 3` | gate: error: | tool ok=true, errors=0, warnings=0 1 null-guard (formula) | formula | `record.days > 3 ? 1 : 0` | gate: none | tool ok=true, errors=0, warnings=0 2 undeclared hop | validation | `record.balance.nope > 1` | gate: error: | tool ok=true, errors=0, warnings=0 2 undeclared hop | formula | `record.balance.nope > 1 ? 1 : 0` | gate: error: | tool ok=true, errors=0, warnings=0 3 stored body hop | validation | `record.meta.name == 'x'` | gate: error: | tool ok=true, errors=0, warnings=0 3 stored body hop | formula | `record.meta.name == 'x' ? 1 : 0` | gate: error: | tool ok=true, errors=0, warnings=0 3 parent root | validation | `parent.remaining > 1` | gate: error: | tool ok=true, errors=0, warnings=0 3 parent root (formula) | formula | `parent.remaining > 1 ? 1 : 0` | gate: none | tool ok=true, errors=0, warnings=0 3 unprovisioned anchor | validation | `record.owner_id == 'u1'` | gate: warning: | tool ok=true, errors=0, warnings=0 3 unprovisioned anchor | formula | `record.owner_id == 'u1' ? 1 : 0` | gate: warning: | tool ok=true, errors=0, warnings=0 control | validation | `record.title == 'x'` | gate: none | tool ok=true, errors=0, warnings=0 ``` The formula rows for the null guard and `parent` show no gate finding: the gate runs those two passes only at a validation rule, and the entry follows it. </details> <details><summary>Ablations (each red, each restored, `git diff HEAD` empty after)</summary> ``` Ablations through scripts/ablation-replace.mjs (restores the file; git diff HEAD empty after each): A1 mcp: handler skips gatePassFindings -> mcp-validate-expression.test.ts 9 failed | 49 passed (58); CONTROL stays green A2 lint: entry runs the shared validator too -> authored-site-expression.test.ts 1 failed | 18 passed (19): "leaves the shared validator's findings to the caller" A3 lint: no stripInjectedSystemColumns -> 1 failed | 18 passed (19): "judges a served definition (injected columns declared) as the authored body" A4b lint gate: new refuseSomethingNew(...) call inside judgeFieldFormula -> 1 failed: "site formula: every call the gate makes there is classified" (+ "refuseSomethingNew") A5 lint: formula findings filter dropped -> 3 failed | 16 passed (19): the three formula refusal pins A6b lint gate: issues.push(...formulaCycleIssues(...)) after the fields loop (the #33108 shape) -> 1 failed: "site formula: every call the gate makes there is classified" (A4b and A6b were re-run after the scan moved onto maskCommentsAndLiterals.) Round 2 (review delta), through scripts/ablation-replace.mjs, each restored with git diff HEAD empty: F1 mcp: hop-target fence dropped (`|| !exposed(target)` removed) -> mcp-validate-expression.test.ts 1 failed | 58 passed (59): "a hop target follows the same system-object fence as describe_object" F3a lint gate: a new member call inside judgeFieldFormula (`Object.freeze(Object.keys(f))`) -> authored-site-expression.test.ts 1 failed | 23 passed (24): "site formula: every member call the gate makes there is classified" (+ "freeze", "keys") F3b lint gate: `issues.push(...Array.of())` beside bulkConfirmTextIssues, outside both regions -> 1 failed | 23 passed (24): "every pass the whole walk pushes as a whole is classified" (+ "Array.of") F3c lint gate: `issues.push(...lintPasses.formulaCycleIssues(stack))` at the same place (a member-named, #33108-shaped pass) -> the walk pin reds (the undefined receiver also throws at run time, so other pins red with it: 15 failed) F8a lint: authoring-rules.ts:827 also passes `sharedValidatorRunByCaller: true` -> 1 failed | 23 passed (24): "is spelled in code only where it is declared, read, and passed by this entry" F8b lint: index.ts re-exports runStackExpressionPasses -> 1 failed | 23 passed (24): "is on none of the package entries: the walk and its options type are not exported" C0 merge of origin/main carrying #33108, before classifying its pass (a real addition, not an ablation) -> 2 failed | 22 passed (24): "site formula: every call the gate makes there is classified" and "every pass the whole walk pushes as a whole is classified", each (+ "formulaCycleIssues") ``` </details> <details><summary>Suites at head</summary> ``` At 8a5f028 (after the #33142 merge), under scripts/pm/os-verify-lock.sh: pnpm --filter @objectstack/mcp run typecheck -> exit 0 pnpm --filter @objectstack/mcp exec vitest run -> Test Files 63 passed (63) · Tests 1119 passed (1119) · exit 0 pnpm --dir ui exec vitest run apps/console/src/pages/developer/objectstack-skill.test.ts -> Test Files 1 passed (1) · Tests 13 passed (13) · exit 0 (SKILL.md mirror byte-identical) At bd2b25f (review fixes + the #33108 merge), each under the lock: env -u OS_SKIP_DTS pnpm turbo run build (workspace, docs aside) -> 119 successful, 119 total pnpm --filter @objectstack/lint run typecheck -> exit 0 (source + test programs) pnpm --filter @objectstack/mcp run typecheck -> exit 0 pnpm --filter @objectstack/runtime run typecheck -> exit 0 (re-run with a 6 GB heap: the first run's test program OOMed in tsc, exit null, no diagnostics) pnpm --filter @objectstack/lint exec vitest run -> Test Files 206 passed (206) · Tests 8767 passed (8767) · exit 0 pnpm --filter @objectstack/mcp exec vitest run -> Test Files 63 passed (63) · Tests 1119 passed (1119) · exit 0 pnpm --filter @objectstack/runtime exec vitest run src/domains/mcp-object-schema-mask.test.ts src/domains/mcp-option-fields-read.test.ts -> Test Files 2 passed (2) · Tests 71 passed (71) · exit 0 pnpm --dir ui exec vitest run apps/console/src/pages/developer/objectstack-skill.test.ts -> 13 passed (13) pnpm lint -> exit 0 At 95b340e (round 1; packages/runtime unchanged since): pnpm --filter @objectstack/runtime exec vitest run src/domains/mcp-object-schema-mask.test.ts src/domains/mcp-option-fields-read.test.ts -> Test Files 2 passed (2) · Tests 71 passed (71) · exit 0 type-check runtime -> exit 0 ``` </details> <details><summary>Derived gates (dispatch-gates --commands, reconciled with --ran)</summary> ``` Round 2, at bd2b25f (after the full dts build): the derivation is the same 101 families. All 101 re-run with stdin from /dev/null, exit codes recorded, all exit 0. (At e306a89, check:dts-closure and check:dual-build-cjs-loads had gone red on tree state alone, with declaration files missing after an OS_SKIP_DTS=1 closure build; the dts build cleared both.) At 8a5f028 the derivation is unchanged (101). Re-run after that merge, all exit 0: check-changeset-no-major, check-adr-0087-registration, check-empty-changeset (each --base origin/main), check-closing-keyword-parity, check:cross-package-test-inputs, check-comment-mask-adoption, check:route-envelope, check:undeclared-dep-imports. ✓ dispatch-gates --ran: 101 derived famil(ies) accounted for — 101 run, 0 NOT-MEASURED (a DERIVED zero — all 101 recorded an exit code and none of them is 3). Round 1, at 95b340e: node scripts/pm/dispatch-gates.mjs --commands derives 101 families at head (86 before the last commit touched scripts/, 15 added by it). Every command ran with stdin from /dev/null and its exit code recorded; all 101 exit 0. Three were re-run after a fix: - check-comment-mask-adoption: red at the first head (a private comment stripper in the new lint test); the test now imports maskCommentsAndLiterals; exit 0 - check-plugin-teardown-shape --self-test: exit 3 in the shallow clone (pinned fixture 621a487 unreachable); fetched it; exit 0 - check:cross-package-test-inputs: red (the lint test now imports scripts/js-comment-mask.mjs); the pair is declared on the @objectstack/lint entry and in turbo.json; exit 0 After the last commit: the 15 new families, plus check:cross-package-test-inputs, check:type-check-coverage, check:type-check-debt, check-comment-mask-adoption, check:dispatcher-error-vocabulary and check:duration-unit-keys (turbo.json moved), all exit 0. ✓ dispatch-gates --ran: 101 derived famil(ies) accounted for — 101 run, 0 NOT-MEASURED (a DERIVED zero — all 101 recorded an exit code and none of them is 3). ``` </details> <details><summary>Dogfood battery (owed by the narrowing arm)</summary> ``` Round 2, at bd2b25f (after the full workspace dts build): pnpm --filter @objectstack/dogfood test (no OS_TEST_SHARD, no paths, under the lock) -> os-verify-lock: VERDICT command-exit 0 · Test Files 460 passed | 3 skipped (463) · Tests 3884 passed | 42 skipped (3926) · 1809s Not re-run at 8a5f028: that merge brings only #33142 (main's own upload-link change), and the mcp suite is re-run above. Round 1, at 95b340e: -> Test Files 460 passed | 3 skipped (463) · Tests 3874 passed | 42 skipped (3916) · exit 0 · 1856s ``` </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L9qibzhu4Yeph4D3KQ9Ao3 <!-- signed: domain:server#7 · os-tesla · session_01L9qibzhu4Yeph4D3KQ9Ao3 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 702c562 commit b22be27

20 files changed

Lines changed: 1057 additions & 36 deletions
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
'@objectstack/mcp': patch
3+
'@objectstack/lint': patch
4+
'@objectstack/runtime': patch
5+
'@object-ui/console': patch
6+
---
7+
8+
fix(mcp): `validate_expression` gives the publish gate's own verdict at a `validation` or `formula` site, every pass the gate runs there included
9+
10+
Clause-②: no (narrowing) — the MCP `validate_expression` tool now answers `ok: false` (or a warning) for a validation rule or formula field the publish gate already refuses (or warns on). The gate's acceptance set does not change, and no existing exported type or signature changes.
11+
Metadata-protocol: none
12+
13+
<!-- adr-0087: not-required (no-migration-prescription) the narrowing is in an advisory tool's verdict, never in what an author may write: every expression it now refuses, the publish gate already refused, so no stored metadata and no consumer code has anything to rewrite -->
14+
15+
**BREAKING** verdict narrowing of the MCP `validate_expression` tool (`@objectstack/mcp`), at `site: 'validation'` and `site: 'formula'`.
16+
17+
The tool promises the verdict the publish gate gives the rule, but it ran the shared expression validator and nothing else, so it answered `ok: true` for rules the gate then refused at publish, and the refusal first met a person there. It now also runs the gate's own passes at those two sites, through `judgeAuthoredSiteExpression` (`@objectstack/lint`), which runs the gate's walk itself over the object definitions the caller is served:
18+
19+
- at both sites: a read through a reference to a field the target object does not declare (`record.balance.nope`), and a read through a reference into a stored-metadata table;
20+
- at a `validation` site: a nullable field used without a null guard (`record.days > 3` with `days` neither required nor defaulted), and a read of `parent`, which a `validations[]` rule never binds;
21+
- a warning at both sites: a read of an injected system column an external object has no storage behind (`record.owner_id` on an ADR-0015 `external` object).
22+
23+
Each finding is the gate's sentence, at the gate's severity. A rule the gate accepts answers exactly as before. A hop target follows the same system-object fence as `describe_object`. A `flow_condition` and a `template` are not judged by this change: the tool's verdict there is unchanged. A sentence that names the rule names it `this rule`, since the tool is handed the condition and not the rule it will sit on.
24+
25+
- `@objectstack/mcp`: `McpDataBridge` gains the optional `servedObjectDefinitionOf(name)`, the object definition as the caller is served it (the read `describeObject` projects), handed to the gate and rendered to nobody. A bridge without it answers the shared validator's verdict alone, as before. The served `SKILL.md` line and the tool description name what the tool now refuses. `@objectstack/lint` moves from a development dependency to a dependency, loaded on the first call that judges a rule or formula field, never at module load.
26+
- `@objectstack/lint`: exports `judgeAuthoredSiteExpression` and `authoredExpressionHopTargets`. The gate's verdicts are unchanged: its walk gains one internal option, off its package entries, that only this entry passes.
27+
- `@objectstack/runtime`: the HTTP MCP bridge serves `servedObjectDefinitionOf`, the same caller's object `describeObject` reads (ADR-0106 D1).
28+
- `@object-ui/console`: the downloadable `SKILL.md` mirror carries the same line.

‎packages/core/src/security/second-object-read-exposure.pin.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,18 @@ const CALLERS: Record<string, Classification> = {
337337
"ADDRESSED object, whose record is `getData` behind the route's own `get` exposure gate, and the related rows " +
338338
"are the child's `findData` behind the child's `list` exposure. Pinned by `packages/rest/src/record-page-routes.test.ts`",
339339
},
340+
// [#32872] MCP `validate_expression`'s run of the publish gate's own passes.
341+
'packages/lint/src/authored-site-expression.ts': {
342+
kind: 'not-a-served-read',
343+
reason:
344+
"`authoredExpressionHopTargets` names the object each `record.REF.FIELD` hop of the caller's expression points " +
345+
"at, so the MCP tool can hand the gate that object's DEFINITION: the bridge's `servedObjectDefinitionOf`, the " +
346+
"caller's ADR-0106 view of the same declaration `describe_object` serves (an `enable.apiEnabled: false` object " +
347+
"is described on every MCP transport, `mcp-server-runtime.merged-object-resources.test.ts`). The gate then " +
348+
"judges whether FIELD is declared there. It reads no record of the target and serves none of its values. " +
349+
"Pinned by `packages/mcp/src/mcp-validate-expression.test.ts` (a target the data API does not serve is judged " +
350+
"on its described schema with no record read; a system-object target is not read at all)",
351+
},
340352
// [#30379] The package disable door's dependent-rule scan.
341353
'packages/runtime/src/domains/packages.ts': {
342354
kind: 'not-a-served-read',

0 commit comments

Comments
 (0)