From a3baf4688cea572087286841d70966892873ec2f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 20:33:57 +0000 Subject: [PATCH 1/8] test(mcp): pin validate_expression keeping the search companion out of scope Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC --- packages/mcp/package.json | 1 + .../mcp/src/mcp-validate-expression.test.ts | 61 ++++++++++++++++++- pnpm-lock.yaml | 3 + 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/packages/mcp/package.json b/packages/mcp/package.json index 71714fad20b..13ad24be6c8 100644 --- a/packages/mcp/package.json +++ b/packages/mcp/package.json @@ -32,6 +32,7 @@ "@objectstack/formula": "workspace:*", "@objectstack/lint": "workspace:*", "@objectstack/metadata-core": "workspace:*", + "@objectstack/objectql": "workspace:*", "@objectstack/spec": "workspace:*", "@objectstack/types": "workspace:*", "unpdf": "1.9.1", diff --git a/packages/mcp/src/mcp-validate-expression.test.ts b/packages/mcp/src/mcp-validate-expression.test.ts index 8d741036e50..d6e90d3b6a4 100644 --- a/packages/mcp/src/mcp-validate-expression.test.ts +++ b/packages/mcp/src/mcp-validate-expression.test.ts @@ -16,8 +16,9 @@ import { } from '@objectstack/lint'; import { applyInjectedSystemColumns } from '@objectstack/metadata-core'; +import { provisionSearchCompanion, SEARCH_COMPANION_FIELD } from '@objectstack/objectql'; -import { MCPServerRuntime } from './mcp-server-runtime.js'; +import { MCPServerRuntime, describeServedObject } from './mcp-server-runtime.js'; import type { McpDataBridge } from './mcp-http-tools.js'; /** @@ -919,3 +920,61 @@ describe('validate_expression judges the field being authored at the formula sit expect((json as { result: { isError?: boolean } }).result.isError).toBe(true); }); }); + +describe('validate_expression keeps the hidden search companion out of scope', () => { + // A field-scoped search object as the registry serves it with pinyin search + // on: the companion stamped beside the declared fields, then projected the + // way the transports project it. + const authored = { + name: 'sc_contact', + label: 'Contact', + fields: { + name: { type: 'text', label: 'Name', required: true }, + email: { type: 'email', label: 'Email' }, + }, + }; + const served = provisionSearchCompanion(applyInjectedSystemColumns(authored)); + const bridge = (): McpDataBridge => ({ + ...makeBridge(), + async listObjects() { + return [{ name: 'sc_contact', label: 'Contact', fieldCount: Object.keys(served.fields).length }]; + }, + async describeObject(name: string) { + return name === 'sc_contact' ? describeServedObject(served as never) : null; + }, + }); + + let runtime: MCPServerRuntime; + beforeEach(() => { + runtime = new MCPServerRuntime({ name: 'objectstack-test', version: '9.9.9' }); + }); + + it('the served object really carries the companion (precondition)', () => { + expect(Object.keys(served.fields)).toContain(SEARCH_COMPANION_FIELD); + }); + + it('inScope.fields lists the ordinary fields and no companion', async () => { + const r = await validate(runtime, bridge(), { objectName: 'sc_contact', expression: "record.name != ''", site: 'validation' }); + expect(r.ok).toBe(true); + expect(r.inScope.fields).toContain('name'); + expect(r.inScope.fields).toContain('email'); + expect(r.inScope.fields).toContain('created_at'); + expect(r.inScope.fields).not.toContain(SEARCH_COMPANION_FIELD); + }); + + it('a read of the companion is refused as a field the object does not have, as os validate refuses it', async () => { + const expression = `record.${SEARCH_COMPANION_FIELD} != ''`; + const gate = validateStackExpressions({ + objects: [{ ...authored, validations: [{ name: AUTHORED_RULE_NAME, type: 'script', condition: expression, message: 'm' }] }], + }).filter((i) => i.where.includes(`'${AUTHORED_RULE_NAME}'`)); + expect(gate.map((i) => i.severity ?? 'error')).toEqual(['error']); + expect(gate[0]!.message).toContain(SEARCH_COMPANION_FIELD); + + for (const site of ['validation', 'formula', 'flow_condition'] as const) { + const r = await validate(runtime, bridge(), { objectName: 'sc_contact', expression, site }); + expect(r.ok, site).toBe(false); + const refused = r.errors.filter((e: { code?: string }) => e.code === 'unknown-field'); + expect(refused.map((e: { params?: { field?: string } }) => e.params?.field), site).toEqual([SEARCH_COMPANION_FIELD]); + } + }); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index caee2b8d3a8..b2528064279 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1427,6 +1427,9 @@ importers: '@objectstack/metadata-core': specifier: workspace:* version: link:../metadata-core + '@objectstack/objectql': + specifier: workspace:* + version: link:../objectql '@objectstack/spec': specifier: workspace:* version: link:../spec From 9cfc99e13aeb7d344e9c31657bcdd1530d20edbe Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 20:37:36 +0000 Subject: [PATCH 2/8] fix(mcp): validate_expression keeps the search companion out of scope Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC --- packages/mcp/src/mcp-http-tools.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/mcp/src/mcp-http-tools.ts b/packages/mcp/src/mcp-http-tools.ts index 218e9312312..53858a178b6 100644 --- a/packages/mcp/src/mcp-http-tools.ts +++ b/packages/mcp/src/mcp-http-tools.ts @@ -2632,8 +2632,17 @@ export function registerObjectTools( const fieldDefs = Array.isArray(def.fields) ? (def.fields as Array>) : []; const fields: string[] = []; const fieldTypes: Record = {}; + // The hidden search companion is served beside the declared fields + // (the registry stamps it where pinyin search is on), but no + // expression may read it: every read strips it, and `os validate` + // judges against the declared and injected columns, which never + // include it. Left in, it is listed in `inScope.fields` and a read + // of it answers ok here while the gate refuses it. The name is the + // engine's own constant, loaded on the first call like `@objectstack/lint`. + const { SEARCH_COMPANION_FIELD } = await import('@objectstack/objectql'); for (const f of fieldDefs) { if (typeof f?.name !== 'string') continue; + if (f.name === SEARCH_COMPANION_FIELD) continue; fields.push(f.name); if (typeof f?.type === 'string') fieldTypes[f.name] = f.type; } From 7f24b188e554d00938386b21bcbf69d9b8136962 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 20:38:28 +0000 Subject: [PATCH 3/8] chore(changeset): mcp validate_expression search companion Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC --- .../mcp-validate-expression-search-companion.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .changeset/mcp-validate-expression-search-companion.md diff --git a/.changeset/mcp-validate-expression-search-companion.md b/.changeset/mcp-validate-expression-search-companion.md new file mode 100644 index 00000000000..b6934c30be0 --- /dev/null +++ b/.changeset/mcp-validate-expression-search-companion.md @@ -0,0 +1,12 @@ +--- +'@objectstack/mcp': patch +--- + +fix(mcp): `validate_expression` no longer lists the hidden `__search` search companion in `inScope.fields`, and a read of it is refused as `os validate` refuses it + +Clause-②: no +Metadata-protocol: none + +Where pinyin search is on, the object an MCP caller is served carries the hidden `__search` companion column beside its declared fields. `validate_expression` took its field list from that object, so it named `__search` in `inScope.fields` and answered `ok` for an expression such as `record.__search != ''`. Every record read strips that column, and `os validate` judges an expression against the declared and injected columns only, so the same rule failed there with `unknown-field`. + +The tool now leaves the companion out of the fields it judges and lists. The name comes from the engine's own constant (`SEARCH_COMPANION_FIELD`, `@objectstack/objectql`), so `@objectstack/mcp` now depends on `@objectstack/objectql`. It is loaded on the first `validate_expression` call, the way `@objectstack/lint` is, and not when the package loads. Every other field, injected system columns such as `organization_id` among them, is listed and judged as before. From 8fd19455fb69d60ef3eb2a02cda85c590634bc7a Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 21:11:49 +0000 Subject: [PATCH 4/8] test(mcp): judge the engine's companion constant from source Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC --- packages/mcp/vitest.config.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/mcp/vitest.config.ts b/packages/mcp/vitest.config.ts index 42c891e4e27..5bd59bfed59 100644 --- a/packages/mcp/vitest.config.ts +++ b/packages/mcp/vitest.config.ts @@ -57,10 +57,18 @@ export default defineConfig({ // which drives the stdio exit through the shared ADR-0106 case table: the // table is a VALUE import too, and judging this transport against a stale // build of it would be the same silent wrong-tree verdict. + // + // The `@objectstack/objectql` entry is for `mcp-validate-expression.test.ts`, + // which provisions the search companion with the engine's own + // `provisionSearchCompanion` and reads its name from `SEARCH_COMPANION_FIELD`, + // the constant `validate_expression` leaves out of scope: both VALUE imports, + // judged against the source in the checkout, not a build of it. Anchored + // because `@objectstack/objectql` exports a `./core` subpath. alias: [ { find: /^@objectstack\/metadata-core$/, replacement: path.resolve(__dirname, '../metadata-core/src/index.ts') }, { find: /^@objectstack\/metadata-core\/testing$/, replacement: path.resolve(__dirname, '../metadata-core/src/testing.ts') }, { find: /^@objectstack\/lint$/, replacement: path.resolve(__dirname, '../lint/src/index.ts') }, + { find: /^@objectstack\/objectql$/, replacement: path.resolve(__dirname, '../objectql/src/index.ts') }, ], }, }); From f6bb127575bab0be7f66f36c576ddc3a761d74bd Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 21:43:53 +0000 Subject: [PATCH 5/8] fix(mcp): validate_expression loads the companion name from the lean 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 Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC --- packages/mcp/src/mcp-http-tools.ts | 2 +- packages/mcp/src/mcp-validate-expression.test.ts | 2 +- packages/mcp/vitest.config.ts | 16 +++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/mcp/src/mcp-http-tools.ts b/packages/mcp/src/mcp-http-tools.ts index 53858a178b6..7a3ee4ac425 100644 --- a/packages/mcp/src/mcp-http-tools.ts +++ b/packages/mcp/src/mcp-http-tools.ts @@ -2639,7 +2639,7 @@ export function registerObjectTools( // include it. Left in, it is listed in `inScope.fields` and a read // of it answers ok here while the gate refuses it. The name is the // engine's own constant, loaded on the first call like `@objectstack/lint`. - const { SEARCH_COMPANION_FIELD } = await import('@objectstack/objectql'); + const { SEARCH_COMPANION_FIELD } = await import('@objectstack/objectql/core'); for (const f of fieldDefs) { if (typeof f?.name !== 'string') continue; if (f.name === SEARCH_COMPANION_FIELD) continue; diff --git a/packages/mcp/src/mcp-validate-expression.test.ts b/packages/mcp/src/mcp-validate-expression.test.ts index d6e90d3b6a4..65dcb2200c4 100644 --- a/packages/mcp/src/mcp-validate-expression.test.ts +++ b/packages/mcp/src/mcp-validate-expression.test.ts @@ -16,7 +16,7 @@ import { } from '@objectstack/lint'; import { applyInjectedSystemColumns } from '@objectstack/metadata-core'; -import { provisionSearchCompanion, SEARCH_COMPANION_FIELD } from '@objectstack/objectql'; +import { provisionSearchCompanion, SEARCH_COMPANION_FIELD } from '@objectstack/objectql/core'; import { MCPServerRuntime, describeServedObject } from './mcp-server-runtime.js'; import type { McpDataBridge } from './mcp-http-tools.js'; diff --git a/packages/mcp/vitest.config.ts b/packages/mcp/vitest.config.ts index 5bd59bfed59..232c207412d 100644 --- a/packages/mcp/vitest.config.ts +++ b/packages/mcp/vitest.config.ts @@ -58,17 +58,19 @@ export default defineConfig({ // table is a VALUE import too, and judging this transport against a stale // build of it would be the same silent wrong-tree verdict. // - // The `@objectstack/objectql` entry is for `mcp-validate-expression.test.ts`, - // which provisions the search companion with the engine's own - // `provisionSearchCompanion` and reads its name from `SEARCH_COMPANION_FIELD`, - // the constant `validate_expression` leaves out of scope: both VALUE imports, - // judged against the source in the checkout, not a build of it. Anchored - // because `@objectstack/objectql` exports a `./core` subpath. + // The `@objectstack/objectql/core` entry (the lean engine entry, ADR-0076) + // serves `validate_expression`, which loads `SEARCH_COMPANION_FIELD` from it + // on the first call, and `mcp-validate-expression.test.ts`, which provisions + // the search companion with the engine's own `provisionSearchCompanion`: + // both VALUE imports, judged against the source in the checkout, not a + // build of it. The lean entry, not the barrel: transforming the barrel's + // `@objectstack/metadata-protocol` graph on that first call outran a test's + // 5 s budget. alias: [ { find: /^@objectstack\/metadata-core$/, replacement: path.resolve(__dirname, '../metadata-core/src/index.ts') }, { find: /^@objectstack\/metadata-core\/testing$/, replacement: path.resolve(__dirname, '../metadata-core/src/testing.ts') }, { find: /^@objectstack\/lint$/, replacement: path.resolve(__dirname, '../lint/src/index.ts') }, - { find: /^@objectstack\/objectql$/, replacement: path.resolve(__dirname, '../objectql/src/index.ts') }, + { find: /^@objectstack\/objectql\/core$/, replacement: path.resolve(__dirname, '../objectql/src/core.ts') }, ], }, }); From 1ffa893bd01a85188fba76350149d77c68efacb7 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 22:06:21 +0000 Subject: [PATCH 6/8] fix(mcp): validate_expression reads the companion name from the spec, 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 Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC --- .../mcp-validate-expression-search-companion.md | 8 ++++++-- packages/mcp/package.json | 2 +- packages/mcp/src/mcp-http-tools.ts | 5 ++--- packages/mcp/vitest.config.ts | 12 +++++------- packages/objectql/src/search-companion.ts | 11 ++++++----- packages/spec/api-surface/data.json | 1 + packages/spec/src/data/search-fields.ts | 17 +++++++++++++++++ pnpm-lock.yaml | 6 +++--- 8 files changed, 41 insertions(+), 21 deletions(-) diff --git a/.changeset/mcp-validate-expression-search-companion.md b/.changeset/mcp-validate-expression-search-companion.md index b6934c30be0..81a3fc5f77b 100644 --- a/.changeset/mcp-validate-expression-search-companion.md +++ b/.changeset/mcp-validate-expression-search-companion.md @@ -1,12 +1,16 @@ --- '@objectstack/mcp': patch +'@objectstack/spec': minor +'@objectstack/objectql': patch --- fix(mcp): `validate_expression` no longer lists the hidden `__search` search companion in `inScope.fields`, and a read of it is refused as `os validate` refuses it -Clause-②: no +Clause-②: yes (widening) — `@objectstack/spec/data` gains the `SEARCH_COMPANION_FIELD` constant (`'__search'`); `@objectstack/objectql` re-exports the same value it exported before. Metadata-protocol: none Where pinyin search is on, the object an MCP caller is served carries the hidden `__search` companion column beside its declared fields. `validate_expression` took its field list from that object, so it named `__search` in `inScope.fields` and answered `ok` for an expression such as `record.__search != ''`. Every record read strips that column, and `os validate` judges an expression against the declared and injected columns only, so the same rule failed there with `unknown-field`. -The tool now leaves the companion out of the fields it judges and lists. The name comes from the engine's own constant (`SEARCH_COMPANION_FIELD`, `@objectstack/objectql`), so `@objectstack/mcp` now depends on `@objectstack/objectql`. It is loaded on the first `validate_expression` call, the way `@objectstack/lint` is, and not when the package loads. Every other field, injected system columns such as `organization_id` among them, is listed and judged as before. +The tool now leaves the companion out of the fields it judges and lists. Every other field, injected system columns such as `organization_id` among them, is listed and judged as before. + +The companion's name now lives in the protocol, as `SEARCH_COMPANION_FIELD` in `@objectstack/spec/data`, so a layer that only needs the name does not have to load the engine to read it. `@objectstack/objectql` provisions and strips the column under that same constant and still exports it under the same name, so engine callers change nothing. `@objectstack/mcp` reads it from the spec and gains no runtime dependency on the engine. diff --git a/packages/mcp/package.json b/packages/mcp/package.json index 13ad24be6c8..20479ff2a2e 100644 --- a/packages/mcp/package.json +++ b/packages/mcp/package.json @@ -32,13 +32,13 @@ "@objectstack/formula": "workspace:*", "@objectstack/lint": "workspace:*", "@objectstack/metadata-core": "workspace:*", - "@objectstack/objectql": "workspace:*", "@objectstack/spec": "workspace:*", "@objectstack/types": "workspace:*", "unpdf": "1.9.1", "zod": "^4.6.6" }, "devDependencies": { + "@objectstack/objectql": "workspace:*", "@types/node": "^26.6.5", "typescript": "^6.0.3", "vitest": "^4.1.11" diff --git a/packages/mcp/src/mcp-http-tools.ts b/packages/mcp/src/mcp-http-tools.ts index 7a3ee4ac425..9f5fb2f02b7 100644 --- a/packages/mcp/src/mcp-http-tools.ts +++ b/packages/mcp/src/mcp-http-tools.ts @@ -48,7 +48,7 @@ import type { EngineAggregateOptions } from '@objectstack/spec/data'; // entry IS this node, so this door and the REST query door (which parses // `FindDataRequestSchema`, whose `aggregations` are this node) judge one shape // with one refusal. -import { AggregationNodeSchema } from '@objectstack/spec/data'; +import { AggregationNodeSchema, SEARCH_COMPANION_FIELD } from '@objectstack/spec/data'; // [#23529] The catalogue's spelling of `PERMISSION_DENIED`, the code whose // `details` `errorResultFromThrown` withholds. Imported, never hand-spelled. import { StandardErrorCode, type ErrorCode } from '@objectstack/spec/api'; @@ -2638,8 +2638,7 @@ export function registerObjectTools( // judges against the declared and injected columns, which never // include it. Left in, it is listed in `inScope.fields` and a read // of it answers ok here while the gate refuses it. The name is the - // engine's own constant, loaded on the first call like `@objectstack/lint`. - const { SEARCH_COMPANION_FIELD } = await import('@objectstack/objectql/core'); + // protocol's one constant, the same one the engine provisions under. for (const f of fieldDefs) { if (typeof f?.name !== 'string') continue; if (f.name === SEARCH_COMPANION_FIELD) continue; diff --git a/packages/mcp/vitest.config.ts b/packages/mcp/vitest.config.ts index 232c207412d..c2b90be2860 100644 --- a/packages/mcp/vitest.config.ts +++ b/packages/mcp/vitest.config.ts @@ -59,13 +59,11 @@ export default defineConfig({ // build of it would be the same silent wrong-tree verdict. // // The `@objectstack/objectql/core` entry (the lean engine entry, ADR-0076) - // serves `validate_expression`, which loads `SEARCH_COMPANION_FIELD` from it - // on the first call, and `mcp-validate-expression.test.ts`, which provisions - // the search companion with the engine's own `provisionSearchCompanion`: - // both VALUE imports, judged against the source in the checkout, not a - // build of it. The lean entry, not the barrel: transforming the barrel's - // `@objectstack/metadata-protocol` graph on that first call outran a test's - // 5 s budget. + // is for `mcp-validate-expression.test.ts`, which provisions the search + // companion with the engine's own `provisionSearchCompanion` and reads its + // name from `SEARCH_COMPANION_FIELD`: VALUE imports, judged against the + // source in the checkout, not a build of it. Only the test loads the + // engine; the tool reads the name from `@objectstack/spec/data`. alias: [ { find: /^@objectstack\/metadata-core$/, replacement: path.resolve(__dirname, '../metadata-core/src/index.ts') }, { find: /^@objectstack\/metadata-core\/testing$/, replacement: path.resolve(__dirname, '../metadata-core/src/testing.ts') }, diff --git a/packages/objectql/src/search-companion.ts b/packages/objectql/src/search-companion.ts index 85e580c35b3..c3af9ddfb54 100644 --- a/packages/objectql/src/search-companion.ts +++ b/packages/objectql/src/search-companion.ts @@ -40,16 +40,17 @@ * the same column. */ -import { resolveDisplayField, TITLE_ELIGIBLE_TYPES } from '@objectstack/spec/data'; +import { resolveDisplayField, SEARCH_COMPANION_FIELD, TITLE_ELIGIBLE_TYPES } from '@objectstack/spec/data'; import { SystemFieldName } from '@objectstack/spec/system'; import { isFederatedObject } from './federated-object.js'; /** - * Name of the hidden companion column. Double-underscore prefixed so it can - * never collide with an author-declared field (machine names are snake_case - * words) and reads as platform plumbing in raw rows. + * Name of the hidden companion column. The name is the protocol's + * (`@objectstack/spec/data`), re-exported here so engine callers keep + * importing it from the engine; see the declaration there for why it lives in + * the spec. */ -export const SEARCH_COMPANION_FIELD = '__search'; +export { SEARCH_COMPANION_FIELD }; /** * Normalizers applied to the companion column. Generalization seam: pinyin is diff --git a/packages/spec/api-surface/data.json b/packages/spec/api-surface/data.json index 3dd6a05f3f6..3113cd53203 100644 --- a/packages/spec/api-surface/data.json +++ b/packages/spec/api-surface/data.json @@ -725,6 +725,7 @@ "SEARCHABLE_TEXTUAL_TYPES (const)", "SEARCH_AUTO_EXCLUDED_FIELDS (const)", "SEARCH_AUTO_EXCLUDED_TYPES (const)", + "SEARCH_COMPANION_FIELD (const)", "SEARCH_FLAG_EXCLUDED_TYPES (const)", "SEARCH_VIRTUAL_TYPES (const)", "SECRET_MASK (const)", diff --git a/packages/spec/src/data/search-fields.ts b/packages/spec/src/data/search-fields.ts index cf5226ff43a..19397bb5d19 100644 --- a/packages/spec/src/data/search-fields.ts +++ b/packages/spec/src/data/search-fields.ts @@ -359,3 +359,20 @@ export function resolveSearchFields(opts: SearchFieldResolutionOptions): string[ } return allowed; } + +/** + * Name of the hidden search companion column (#2486): the lowercase, + * normalised copy of an object's searchable text that the engine provisions + * where pinyin search is on, and the one extra `$contains` clause above scans. + * It is platform plumbing: every record read strips it, `resolveSearchFields` + * never returns it, and no expression may read it. + * + * ONE name for every layer that must recognise the column: the engine + * (`@objectstack/objectql` provisions and strips it under this name and + * re-exports it) and the MCP `validate_expression` tool (which leaves it out + * of the fields an expression may name). It lives here, not in the engine, so + * a layer that only needs the name does not have to load the engine to read it. + * Double-underscore prefixed so it can never collide with an author-declared + * field (machine names are snake_case words). + */ +export const SEARCH_COMPANION_FIELD = '__search'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b2528064279..3b7a0e39ed6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1427,9 +1427,6 @@ importers: '@objectstack/metadata-core': specifier: workspace:* version: link:../metadata-core - '@objectstack/objectql': - specifier: workspace:* - version: link:../objectql '@objectstack/spec': specifier: workspace:* version: link:../spec @@ -1443,6 +1440,9 @@ importers: specifier: ^4.6.6 version: 4.6.7 devDependencies: + '@objectstack/objectql': + specifier: workspace:* + version: link:../objectql '@types/node': specifier: ^26.6.5 version: 26.6.5 From a182226e1eb93d3fad64542faaec597b68d140cb Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 23:07:18 +0000 Subject: [PATCH 7/8] chore(spec): record SEARCH_COMPANION_FIELD's export origin Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC --- packages/spec/export-origins/data.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/spec/export-origins/data.json b/packages/spec/export-origins/data.json index 24f322456c9..43682052021 100644 --- a/packages/spec/export-origins/data.json +++ b/packages/spec/export-origins/data.json @@ -713,6 +713,7 @@ "SEARCHABLE_TEXTUAL_TYPES": "src/data/search-fields.ts#SEARCHABLE_TEXTUAL_TYPES (const)", "SEARCH_AUTO_EXCLUDED_FIELDS": "src/data/search-fields.ts#SEARCH_AUTO_EXCLUDED_FIELDS (const)", "SEARCH_AUTO_EXCLUDED_TYPES": "src/data/search-fields.ts#SEARCH_AUTO_EXCLUDED_TYPES (const)", + "SEARCH_COMPANION_FIELD": "src/data/search-fields.ts#SEARCH_COMPANION_FIELD (const)", "SEARCH_FLAG_EXCLUDED_TYPES": "src/data/search-fields.ts#SEARCH_FLAG_EXCLUDED_TYPES (const)", "SEARCH_VIRTUAL_TYPES": "src/data/search-fields.ts#SEARCH_VIRTUAL_TYPES (const)", "SECRET_MASK": "src/data/secret-mask.ts#SECRET_MASK (const)", From 3c1cdfab46a834fff8cbbe27c931c78b2560dae2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 23:14:09 +0000 Subject: [PATCH 8/8] chore(changeset): grade the spec entry patch (no metadata-protocol change) Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC --- .changeset/mcp-validate-expression-search-companion.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/mcp-validate-expression-search-companion.md b/.changeset/mcp-validate-expression-search-companion.md index 81a3fc5f77b..af8564fab39 100644 --- a/.changeset/mcp-validate-expression-search-companion.md +++ b/.changeset/mcp-validate-expression-search-companion.md @@ -1,6 +1,6 @@ --- '@objectstack/mcp': patch -'@objectstack/spec': minor +'@objectstack/spec': patch '@objectstack/objectql': patch ---