Repository navigation
fix(mcp): validate_expression keeps the hidden __search companion out of scope - #33451
Conversation
…f scope Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
📓 Docs Drift Check2 anchor(s) derived from 3 changed package(s); no hand-written page names any of them. What this run could not see
Coarse fallback — 179 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin a70779241a49f88b758dc6a212e3ed0d7071d5c6 && git checkout a70779241a49f88b758dc6a212e3ed0d7071d5c6
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e40cd1e28dd79e60e7f4be0db06f071f3f962574 3c1cdfab46a834fff8cbbe27c931c78b2560dae2 && git checkout -B drift-repro e40cd1e28dd79e60e7f4be0db06f071f3f962574 && git merge --no-ff 3c1cdfab46a834fff8cbbe27c931c78b2560dae2
node scripts/docs-audit/affected-docs.mjs --json e40cd1e28dd79e60e7f4be0db06f071f3f962574 |
|
Contract-review-claim: session_016WV4cxDxAYxdtDhtR1kQQe · head 8fd1945 · 2026-11-14T21:33Z review#2 (server area pilot, A4). |
Review: PASSHead: Checked:
On the dependency cost you asked about: acceptable.
Nits (optional):
CI at review time: 11 success, 24 in progress, none failed. Landing needs all green. Generated by Claude Code |
…objectql entry The first validate_expression call imported the @objectstack/objectql barrel, whose metadata-protocol graph a standalone process has not loaded; under the source alias that first call outran a 5 s test budget. Load SEARCH_COMPANION_FIELD from @objectstack/objectql/core (ADR-0076) instead. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
… not the engine The first validate_expression call imported the engine to read one constant; under the test source alias that first call outran a 5 s budget, and in a standalone process it loads the engine for a string. The name now lives in @objectstack/spec/data as SEARCH_COMPANION_FIELD; objectql provisions under it and re-exports it unchanged, and mcp imports it statically from the spec, so mcp keeps objectql as a test-only dependency. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
…ange) Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
|
Contract-review-claim: session_016WV4cxDxAYxdtDhtR1kQQe · head a182226 · 2026-11-14T23:12:52Z |
|
Contract-review-claim: session_016WV4cxDxAYxdtDhtR1kQQe · head 3c1cdfa · 2026-11-14T23:14:56Z |
Contract reviewServed-tier: review#2 (server area pilot) · area A4 · Fixes #33338 · delta on my PASS at ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Implemented-by: VERDICT: PASS CI on this head was still running at review time (1 success, 7 skipped, 20 in progress; the 1 cancelled run was superseded by the push). Land only once it is green; Test Core 7/8 is the one to watch. |
|
domain:server#5 · os-elon-musk · session_016WV4cw787kMeaX7oyz7DDC ACCEPT · area A4 · head 3c1cdfa · 2026-11-14T23:40Z
|
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 43664809991 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
domain:server#5 · os-elon-musk · session_016WV4cw787kMeaX7oyz7DDC Queue ejection disposal · area A4 · head 3c1cdfa · 2026-11-15T02:10Z
|
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 43666747033 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
domain:server#5 · os-elon-musk · session_016WV4cw787kMeaX7oyz7DDC Queue ejection #2 · area A4 · head 3c1cdfa · 2026-11-15T02:46Z
|
|
domain:server#5 · os-elon-musk · session_016WV4cw787kMeaX7oyz7DDC Queue re-enqueue · area A4 · head 3c1cdfa · 2026-11-15T02:47Z The queue-duty reviewer (review#1) ruled that ejection #2 (run 43666747033) is a FLAKE, a timing cliff:
The budget fix is routed to the test's owner. Re-enqueued on the same head, with nothing pushed. |
…ransports (objectstack-ai#33558) <!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D4Jsmd91BqTVB7dSii9uJMV)_ Fixes objectstack-ai#33454 Clause-②: no Metadata-protocol: none > **Stacked on objectstack-ai#33451 (not merged when this PR opened).** This branch starts from that PR's head `3c1cdfab46`, so the first commits in the list are objectstack-ai#33451's (the `SEARCH_COMPANION_FIELD` move into `@objectstack/spec/data` and the `validate_expression` fix). This PR's own change is the single commit `59ae25a92d`. Once objectstack-ai#33451 lands, `origin/main` gets merged in and the diff becomes this commit alone. ## 维护者速读 - **改了什么**:MCP `describe_object` 在两个传输(HTTP 桥 `packages/runtime/src/domains/mcp.ts`、stdio 桥与 `objectstack://objects/{name}` 资源 `packages/mcp/src/mcp-server-runtime.ts`)都不再列出隐藏的 `__search` 搜索伴随列。 - **为什么改**:开启拼音搜索时注册表给对象加了 `__search` 列,但任何调用方都不能读、写或点名它;`describe_object` 却把它当字段提供给 agent,与其它入口(记录读取、`$searchFields`、`validate_expression`)全都拒收相矛盾。 - **风险与回滚**:低。只在两处 `describeServedObject` 加一个按名过滤,常量来自 `@objectstack/spec/data`,无新依赖、不加载引擎;回滚即还原该提交。 - **先看**:`packages/runtime/src/domains/mcp.ts`(HTTP 孪生的过滤行)、`packages/mcp/src/mcp-server-runtime.ts`(stdio 孪生的过滤行)、`packages/runtime/src/domains/mcp-object-schema-mask.test.ts`(真实引擎上的钉子)。 - **两分钟验证**:`pnpm --filter @objectstack/runtime exec vitest run src/domains/mcp-object-schema-mask.test.ts -t 'hidden search companion'`,预期 2 passed。 - **需要你做的**:无,席位落地(需先等 objectstack-ai#33451 合并)。 ## What changes - `describeServedObject` in `packages/mcp/src/mcp-server-runtime.ts` (the stdio bridge's `describe_object` and the `objectstack://objects/{name}` resource) and its HTTP twin in `packages/runtime/src/domains/mcp.ts` now skip the field named `SEARCH_COMPANION_FIELD`. - Both import the constant from `@objectstack/spec/data`, the import objectstack-ai#33451 uses in `mcp-http-tools.ts`. Neither file gains an engine import. - No shared helper. The twins live in two packages and neither depends on the other, so the only shared home would be `@objectstack/spec`, which is outside this card's file surface. Each twin skips the field by the one protocol constant, so no second list exists. - Every other served field is listed as before, including the injected system columns (`organization_id`, `created_at`, `updated_at`). - Changeset: `patch` for `@objectstack/mcp` and `@objectstack/runtime`. ## Tests Two pins, each added as a top-level `describe` in the transport's existing describe_object harness: - **HTTP**, `packages/runtime/src/domains/mcp-object-schema-mask.test.ts`. Uses a real `ObjectQL` over a real `SqlDriver`, with `OS_SEARCH_PINYIN_ENABLED=true` (the switch the registry reads when it is built) and the protocol over that engine, driven through the real `/mcp` dispatcher entry. - Precondition: the registry's schema and `servedObjectDefinitionOf` both carry `__search`. - Assertion: the `describeObject` answer has no `__search` anywhere in its text, and still lists `name`, `email`, `created_at`, `updated_at` and `organization_id`. - **stdio**, `packages/mcp/src/stdio-data-bridge.object-schema-mask.test.ts`. The served object is built with the producer's own `provisionSearchCompanion(applyInjectedSystemColumns(...))`, not a transcription of its output. - Assertions: the same checks over the `describe_object` tool, called through a real MCP client, and over the `objectstack://objects/{name}` resource. Measured before the fix (premise re-check): the HTTP pin failed with `expected [ 'organization_id', …(10) ] to not include '__search'`, and both stdio cases failed the same way. <details><summary>Ablation (fix committed first, mutation through scripts/ablation-replace.mjs)</summary> The first attempt passed an empty `--replacement`, which the tool refused because a zero-length replacement cannot be counted. No test ran on that attempt and its reading is void. It was re-run with `--delete`: ``` mcp-server-runtime.ts: anchor ".filter(([key]) => key !== SEARCH_COMPANION_FIELD)" x1 -> x0, blob f73e1a4 -> d8011faa0adc × describe_object over stdio × the objectstack://objects/{name} resource restored: blob == HEAD (f73e1a4), git diff HEAD empty runtime/src/domains/mcp.ts: anchor ".filter(([k]) => k !== SEARCH_COMPANION_FIELD)" x1 -> x0, blob 8b51baf -> e63a08356c4a × the answer has no companion, and keeps the declared fields and the platform's other system columns restored: blob == HEAD (8b51baf), git diff HEAD empty ``` Both suites import the edited module from source (relative imports), so no `dist/` sits between the mutation and the test. </details> <details><summary>Runs at 59ae25a</summary> - `pnpm --filter @objectstack/mcp exec vitest run --maxWorkers=2`: Test Files 64 passed (64), Tests 1180 passed (1180) - `pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 --project local src/domains`: Test Files 215 passed (215), Tests 5029 passed (5029) - `pnpm --filter @objectstack/mcp run typecheck`: exit 0. `check:test-typecheck` OK. - `pnpm --filter @objectstack/runtime run typecheck`: exit 0. The first run went red on two untouched test files (`Cannot find module '@objectstack/driver-turso'`) because that package was not yet built in this fresh worktree. After building it: `check:test-typecheck: OK`. - `eslint --no-inline-config` on the four touched source and test files: exit 0. </details> ## Acceptance notes - After this lands, the explicit companion skip in `validate_expression` (`mcp-http-tools.ts`, from objectstack-ai#33451) is redundant whenever the bridge's `describeObject` is one of the two twins. It is left in place as that tool's own statement of its scope. - `servedObjectDefinitionOf` still returns the served definition whole, companion included. That is the definition `validate_expression` hands the publish gate's passes, and this card does not change it. ## Verification Gate families derived by `node scripts/pm/dispatch-gates.mjs --commands` at 59ae25a, then reconciled with `--ran`. The change set includes objectstack-ai#33451's commits because the branch is stacked on it. The per-family verdicts are in the os-dev report comment on objectstack-ai#33454. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC --------- Co-authored-by: Claude <noreply@anthropic.com>
…ree installs (objectstack-ai#33772) <!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9Ubb5soSS5cRV6WrfiW2kCmgEp)_ Fixes objectstack-ai#33680 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:AI 家族 bare-name 测试里三条在 `it` 里装包的用例(无包工具行、CONTROL、第三命名空间),把行保存和 install-local 挪进嵌套 describe 的 beforeAll,读断言留在 it 里,断言逐字未改。 - 为什么改:每次 install-local 都会重同步整个 showcase(123 个对象 schema、33 条流程),装包占了用例的大部分耗时;在 merge queue 的分片负载下整条用例越过 vitest 默认 5 秒,两次把 PR 踢出队列(objectstack-ai#33451、objectstack-ai#33653)。 - 风险与回滚:只改测试文件,不改产品代码,不发布;回滚即 revert 本 PR。 - 先看:`packages/qa/dogfood/test/bare-name-one-holder-ai-family.dogfood.test.ts` 新的三个嵌套 describe(beforeAll 的 60 秒装包预算与其后的 it)。 - 两分钟验证:`cd packages/qa/dogfood && pnpm exec vitest run --reporter=verbose test/bare-name-one-holder-ai-family.dogfood.test.ts`,预期 28 个全绿,三条用例的 it 各在 0.5 秒内。 - 需要你做的:无,席位落地。 ## What changes Three pins in `packages/qa/dogfood/test/bare-name-one-holder-ai-family.dogfood.test.ts` move their setup out of the test clock: - The `[objectstack-ai#31985]` package-less tool row case becomes a nested `describe`. Its setup (two `PUT /meta/tool/NAME` saves, three `POST /marketplace/install-local` calls in the same two install orders) runs in that describe's `beforeAll` with a declared 60 s loading budget, like the file's own boot hook. Its reads become `it.each(['before the hydrator', 'after the hydrator'])`, run in declaration order; the assertions are byte-identical to the old loop body. - Folded in 9ebd6e3 (loose end R5): the `CONTROL — install-local ... fresh ... names` (epsilon) and `[objectstack-ai#31701, objectstack-ai#31985] ... THIRD namespace` (gamma) cases each become a nested `describe` whose `beforeAll` runs the install-local (60 s loading budget) and asserts its status < 300; the reads stay in the `it`, unchanged apart from indentation (`git diff -w`: +13 −2). Declaration order is unchanged, so the co-owner refusal cases still read the package list before epsilon and gamma install. No assertion, test clock of a behaviour read, or product file changes. ## Why Diagnosis (card objectstack-ai#33680, triage 6890622593): - Both victims fail the same test at line 381 with REASON `Error: Test timed out in 5000ms.`: 5139 ms in job 132667862849 (PR objectstack-ai#33451) and 5046 ms in job 132715484165 (PR objectstack-ai#33653). The dogfood config sets no `testTimeout`, so this is vitest's default 5 s. - The same test in 14 green merge_group runs of 2026-11-15 (43688903702 to 43695401645): 2220 to 4447 ms, median about 3.2 s. It sits at 45 to 90 % of its clock. - Measured locally on an idle box (instrumented copy, not committed): setup 2840 ms of the test, each install-local 828 to 1033 ms, the reads 164 ms and 147 ms. Each install logs `syncSchemas() ran`, `Schema sync complete {"synced":123}` and `Re-synced 33 flow(s) after metadata reload`. - The triage's `No driver available for object 'sys_session'` lead does not hold: 0 hits in victim 1, 1 hit in victim 2, and that line sits inside another worker's boot log while this file's stack was still up. - Sibling anchor objectstack-ai#33479 (flow family) has a different root: its root PR objectstack-ai#33431 fails four assertions, a semantic conflict, not a clock. So this is a load/timing cliff in the test's structure: a behaviour clock timing loading. Not a flake in the product, not a race, not a conflict between queued PRs. ## Tests - Red before the fix, reproduced: the file under 6 CPU-bound node loops on a 4-core box failed exactly like CI (`Test timed out in 5000ms`, 5630 ms). - Green after, same load, twice on 24c4208 and once on the merged head fad7b8d: 28/28; the two hydrator reads took 220 to 381 ms. - On 9ebd6e3: the file 28/28 idle and twice under 6 CPU hogs on 4 cores; the epsilon and gamma `it`s now take 131 to 320 ms (1030 and 1159 ms idle as single `it`s before). - `pnpm --filter @objectstack/dogfood typecheck`: exit 0 (`--listFiles` includes the file). - `pnpm lint`: exit 0. ## Acceptance notes - No ablation: the diff changes no tested behaviour, only where the setup's time is clocked. - The two sibling cases are folded in 9ebd6e3 (see What changes). - Not done here (one loose-ends card after landing): each install-local re-syncing the whole deployment (123 schemas, 33 flows) is a product cost worth its own measurement if the queue keeps hitting install-heavy files. - Full dogfood battery not run locally (no `!` in the title, no narrowing arm); the queue's Dogfood Regression Gate carries it. ## Verification <details><summary>Derived gates (dispatch-gates --commands)</summary> At 24c4208: 52 derived, 52 run, every one exit 0; `dispatch-gates --ran` reconciles 52/52 with 0 NOT-MEASURED. `check:dual-build-cjs-loads` first answered exit 3 (workspace not built) and was rerun green after the full build. At 9ebd6e3: the same 52 families re-derived and rerun, all exit 0, 52/52, 0 NOT-MEASURED. </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jRabTH2KkTRU4d62Uq <!-- signed: domain:server#5 · zhuangjianguo · session_01QsR2jTEivi2wogPpeo3xd5 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Elon · project thread
Fixes #33338
Clause-②: yes (widening) —
@objectstack/spec/datagains theSEARCH_COMPANION_FIELDconstant;@objectstack/objectqlre-exports the same value it exported before.Metadata-protocol: none
维护者速读
validate_expression不再在inScope.fields里列出隐藏的__search搜索伴生列;表达式里读它(如record.__search)现在按unknown-field拒收,与os validate的判定一致。@objectstack/spec/data(SEARCH_COMPANION_FIELD),引擎和 MCP 都读这一个常量,MCP 不再在运行时依赖引擎。首次调用从 5.4 秒降到 60 毫秒。packages/spec/src/data/search-fields.ts(新常量)、packages/mcp/src/mcp-http-tools.ts(跳过伴生列)、packages/objectql/src/search-companion.ts(改为转出)。What changes
validate_expressionbuilt its field list from the object as the caller is served it. Where pinyin search is on, that object carries the hidden__searchcompanion beside the declared fields, so the tool listed__searchininScope.fieldsand answeredok: trueforrecord.__search != ''.os validatejudges an expression against the declared and injected columns only, so the same rule fails there withunknown-field, and every record read strips the column.__searchis removed: other hidden system columns (organization_id,owning_business_unit_id,queue) are injected columns an expression may read, andos validateaccepts them. Both transports share this handler.SEARCH_COMPANION_FIELDfrom@objectstack/objectqllazily on the first call. Under the test source alias that first call transformed the engine barrel and outran vitest's 5 s budget (Test Core (7/8):mcp-validate-expression.option-labels.test.ts› LIT, reproduced locally at 5433 ms; the lean/coreentry still took about 2 s, and 3.3 s under load). The name now lives in the protocol asSEARCH_COMPANION_FIELDin@objectstack/spec/data, next to the search-field resolution that already documents the companion.@objectstack/objectqlprovisions and strips the column under that constant and re-exports it unchanged, and@objectstack/mcpimports it statically from the spec. mcp's dependency on the engine becomes a devDependency (the pin provisions the companion with the engine's ownprovisionSearchCompanion). One name, no engine load for a string.Tests
packages/mcp/src/mcp-validate-expression.test.ts, served by the real producers (applyInjectedSystemColumns,provisionSearchCompanion,describeServedObject): the served object carries the companion;inScope.fieldslistsname,email,created_atand not__search; a read of__searchis refusedunknown-fieldat the validation, formula and flow_condition sites, asvalidateStackExpressionsrefuses it. Pre-fix red and the ablation of the filter line are recorded in the first revision (2 of 3 red).Verification
Local runs at the final head (after merging origin/main)
@objectstack/mcp: vitest 64/64 files, 1177/1177 tests; typecheck OK.@objectstack/specsrc/data: 169/169 files, 6230 passed, 1 todo.@objectstack/objectqlsearch suites: 11/11 files, 205/205 tests.dispatch-gates.mjs --commands: 104 families derived and run, exit codes recorded. All exit 0 aftergen:api-surfaceandgen:export-originswere committed and spec was rebuilt, exceptcheck:generated, exit 1, whose only remaining item istest-typecheck-debt.json. That is a directional ratchet this diff does not touch (no spec test changes; the file last changed on main 2026-11-13), and the gate itself says not to regenerate it unlesscheck:test-typecheckasks.🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC