Repository navigation
test(runtime): get_record_context answers one caller with the same bytes on the /mcp and stdio doors over a real kernel - #37350
Merged
objectstack-fleet[bot] merged 5 commits intoNov 25, 2026
Conversation
…io plugin from runtime tests Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
…ot a deliverable) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
…cord-context-http-rig
…cp and stdio answer one caller with the same bytes Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc
…th doors Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc
Contributor
📓 Docs Drift CheckNothing in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 0 changed package(s)), so this run has no opinion about the docs. What this run could not see
Coarse fallback — 0 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): |
Contributor
Author
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 维护者速读
席位意见:ACCEPT。 席位核对Head-sha:
|
objectstack-fleet
Bot
deleted the
claude/issue-37175-record-context-http-rig
branch
November 25, 2026 21:48
This was referenced Nov 25, 2026
Merged
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
… (ADR-0160 row 11) (objectstack-ai#37354) Fixes objectstack-ai#37203 Clause-②: yes Metadata-protocol: added Skills-docs: follow-up objectstack-ai#37177 ## 维护者速读 - 用户能看到什么变化:AI 读取记录资料包时,关联列表可以按作者写的条件筛选、排序并限制条数;条件或排序用到提问人不能查询的字段时,这一段被省略并附一句「部分资料对你不可见」,不再整次报错。 - 为什么做:记录范围 AI 问询专题的第 11 行(关联列表的筛选和排序),按维护者已同意的设计修订实现。 - 出错会怎样:最坏是某个关联段落被省略或条数不对,AI 回答少了资料;不会多给提问人无权看的数据;撤回此 PR 即恢复原行为。 - 要你做什么:无。 ## What changes **Spec (`packages/spec/src/ai/ai-context.zod.ts`).** A `related` entry gains three optional keys, per ADR-0160 D1 (second amendment): - `where`: the object filter form on the child's own fields, held to `AI_CONTEXT_WHERE_OPERATORS` (`$eq $ne $in $nin $gt $gte $lt $lte $null $exists`) joined by `$and` / `$or`. A bare value is `$eq`. Refused at parse: any other operator, a dotted path, a condition on a lookup's target, `{ $field }`, a `$now` anchor, a formula/object comparand, and a comparand that is one whole brace placeholder (matched by `FILTER_TOKEN_WRAPPED_RE`). Built as `FilterConditionSchema` plus one refinement walk, so the base form's own comparand refusals still apply. - `orderBy`: `SortNodeSchema[]` (`{ field, order }`, `direction` refused by name), with the field held to a snake_case own-field name. - `limit`: positive integer up to `AI_CONTEXT_MAX_RELATED_ROWS` (20). This is the one number. `RECORD_CONTEXT_RELATED_MAX_ROWS` in the service now reads it (ADR-0160 row 11: "the schema that bounds `limit` and the service that cuts the list read one number"). - `aiContextWhereFields(where)`: lists the fields a `where` names. The service and the lint rule both use it. - Near-miss aliases: `filter` → `where`, `sort` / `sortBy` → `orderBy`. The schema-level `guidance.filter` now points at the entry's `where`. **Render service (`packages/services/service-record-context`).** - The one capped child query is `where: { $and: [linkFilter, entry.where] }`, with `orderBy` and `limit: (entry.limit ?? cap) + 1`. A cut at `limit` is marked `truncated` and stated (`related_truncated`). Still one query. - Before that query, each `where` / `orderBy` field is judged. A field the child's published definition lacks leaves the section out with nothing stated (ADR point 20). A field the caller cannot query on drops the section with the one `not_visible` statement, and the field is never named (D3, point 19). Neither case refuses the call. - "Cannot query on" is the door's new optional `queryableFieldsOf` (the security service's `getQueryableFields`). Without that answer, the contract's fallback applies (`ISecurityService.getQueryableFields`): the field must be served, must not be withheld (`fieldVisibilityOf`), and must declare no `maskingRule`. A probe that throws drops the section with the statement. - Triage row 7154563681 on the card (a related child that *this caller* is not served is left out, not refused) is **not** in this PR. It was implemented and then reverted in `aa76b901b`, because turning it on flips the real-kernel parity pin in `packages/runtime` (landed in objectstack-ai#37350, case titled "[today; ADR-0160 as amended says left out and stated]"), and `packages/runtime` is fenced here. Today's behaviour (the whole call is refused) is unchanged. It moves to a follow-up card. - The read set (`recordContextReadSet` / `planObjectsOf`) does not change (D4), and a test pins it with and without the keys. **Author surfaces (`packages/lint/src/validate-ai-context.ts`).** This extends the objectstack-ai#37176 rule rather than adding a validator. A `where` or `orderBy` field the child does not define is reported as `ai-context-field-unknown` (warning) at save and by `os validate`, and the message says the list is left out. **Review delta S1/S2 (contract record 7177225249, on bb0107c).** - S1: `AI_CONTEXT_WHERE_MAX_DEPTH` (32) bounds `$and` / `$or` nesting in `where` at parse, refused at the list that would carry a condition past it. `aiContextWhereFields` walks to that same constant, so every field of a `where` that parsed is judged by the service and the lint rule. A test pins the bound: 32 parses and names the innermost field, 33 is refused once. - S2: an `orderBy` field the child's sortability projection calls unsortable (`resolveObjectSortability`: a formula, or `sortable: false`) is an author defect. The executor leaves the section out and states nothing, matching the "field the definition lacks" arm and ADR D1, instead of letting the door refuse the whole call with `INVALID_SORT`. `validateAiContext` reports it at save and by `os validate` as the new warning `ai-context-sort-field-unsortable`, with an `os explain` entry. HTTP door, read only (runtime is fenced): `recordContextMembers` → `bridge.query` → `callData('query')` → `protocol.findData` → `assertSortFieldsExist` refuses it with `400 INVALID_SORT` too (formula by the unmaterialized-type verdict, `sortable: false` by `assertSortFieldsAreOffered`), so before this fix both transports refused the call. After it, neither door is asked. **Liveness, example, generated.** `liveness/ai_context.json` gains `related.where`, `related.orderBy.{field,order}` and `related.limit`. The showcase `KIND_COVERAGE` pack `showcase_project_brief` now carries open tasks filtered by `status $ne done`, ordered by `due_date`, `limit: 10`. Regenerated: `dropped-refinements.baseline.json` (the `where` walk and the `orderBy` field check are refinements JSON Schema cannot carry; the build printed these rows), authorable-surface, api-surface, export-origins, declaration-map, reference docs, state-counts. ## Tests <details><summary>Local runs (final head bb0107c; the derived gate sweep re-run on bb0107c)</summary> - `pnpm --filter @objectstack/service-record-context test`: 2 files, 99 tests passed. The new describe block "a related list's where, orderBy and limit" has 18 cases. - `pnpm --filter @objectstack/spec exec vitest run src/ai/ai-context.zod.test.ts`: 23 passed (parse admits and refuses every bullet of What 1, and the nesting bound). - `pnpm --filter @objectstack/lint exec vitest run src/validate-ai-context.test.ts`: 18 passed. Whole package `pnpm --filter @objectstack/lint test`: 235 files, 9633 tests passed. - `pnpm --filter @objectstack/mcp exec vitest run src/mcp-record-context-tools.test.ts` (read-only run of the objectstack-ai#37140 parity harness against the rebuilt service, at 16b86ef): 14 passed. CI Test Core at bb0107c runs it and the runtime real-kernel harness: green. - Typecheck: `@objectstack/spec`, `@objectstack/service-record-context` and `@objectstack/lint` all exit 0. - `pnpm --filter @objectstack/spec check:generated`: all 14 artifacts up to date. Ablations: five, each through `scripts/ablation-replace.mjs` with the blob restored to HEAD. Each suite imports `src`, so there is no dist step. 1. Skip `queryableAmong`: 6 cases red (the four unqueryable cases, the masking fallback, the throwing probe). 2. Drop the `$and` join: 4 cases red, including "no where reaches another root's rows". 3. S2, skip the executor's sortability check: 2 cases red (`sortable: false`, formula), the door's `INVALID_SORT` reached. 4. S1, drop the parse depth bound: 1 case red (the bound test). 5. S2, skip the lint verdict: 2 cases red (the rule test and its save-door family). A first attempt was refused by the tool as a no-op (ambiguous replacement) and re-run with a unique one. </details> ## Acceptance notes - **Parity on both transports with a `where` pack is not pinned here.** The objectstack-ai#37140 harness is `packages/mcp/src/mcp-record-context-tools.test.ts`, which was fenced for this PR while sibling objectstack-ai#37175 was in flight in `packages/runtime/**` and `packages/mcp/**`. Both doors hand the one executor a door whose `query` passes the options through (`recordContextMembers`, the stdio bridge's `query` already takes `orderBy`), and the existing harness runs green against this build. The pin is a follow-up for the report. - **Neither MCP door hands `queryableFieldsOf` yet**, so on real doors the contract fallback decides (masking-declared, hidden and withheld fields count as not queryable). A field that the security service's answer would exclude but the fallback admits (an agent acting on someone's behalf, or a computed field reading a hidden one) still reaches the engine guard, and the guard refuses the call. This is reported as a finding for the door lane. - Studio's `ContextPackRelatedEntries` does not offer the three keys yet; it preserves them on edit (note 7168171718). That goes to objectstack-ai#37143. - `RecordContextNoteKind`'s doc line still says `related_truncated` is "cut at the row cap". It now also fires at `limit`. This is spec prose outside the claim's one spec file and is left as is. - A door whose own page cap is below `limit + 1` cuts silently. That is pre-existing for the cap too, and left as is. - `where` nesting is bounded (S1). No bound on the number of conditions or `$in` members was set; ADR row 11 allows one, but none was needed. ## Verification Two-minute check: `pnpm --filter @objectstack/service-record-context exec vitest run src/__tests__/record-context-tools.test.ts`. Expect it green, with the "a related list's where, orderBy and limit" block green. Read first: (1) `record-context-tools.ts`, the 4b block that judges `queried` fields before `relatedPlans.push`, and the `$and` query; (2) `ai-context.zod.ts`, `checkRelatedWhere`. --- _Generated by [Claude Code](https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc)_ <!-- signed: repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
…d related child; both MCP doors supply queryableFieldsOf and their page cap (objectstack-ai#37412) Fixes objectstack-ai#37361 Fixes objectstack-ai#37175 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:外接 AI 读一条记录的资料包时,提问人无权看的关联子对象改为省略并说明,其余部分照常返回;筛选或排序用到提问人不能查询的字段时同样省略并说明,不再整次报错。 - 为什么做:记录级 AI 问答专题,按已同意的设计(无权的关联对象省略而非拒绝)补齐真实通道的行为。 - 出错会怎样:最坏是资料包少一段或多一段说明,提问人仍只能读到自己有权读的数据;可以直接撤回本次改动。 - 要你做的:无。 ## What changes ADR-0160 D3 "Object level" as amended, and its second amendment; triage row 7154563681 on objectstack-ai#37203. - **A related child this caller is not served is left out** (`executeGetRecordContext`, step 4a). The answer carries the root and every served section with the one `not_visible` note, and names the child nowhere (D3 wins over the triage row's "names the child"). Nothing of the child is read after its object-level judgement, its published definition included: the plan reads a left-out child as having no definition, so a lookup target reached only through it is never judged either. - **Order inside 4a is now: read guard, then API exposure, then the served definition.** Measured on the real kernel (assumption A2 holds): a disabled-package child answers `servedObjectDefinitionOf` as `null`, so judging exposure first is what keeps its refusal. API-exposure and `OBJECT_PACKAGE_DISABLED` refusals still refuse the whole call with `PERMISSION_DENIED`, the one code ADR-0160 point 12 gives an object-level refusal. An API-exposure refusal names the child only when the caller's served schema shows it (the naming bound, unchanged). A served-definition read that throws refuses the call, unnamed; it is never read as this caller's narrowing. - **Both real doors supply `queryableFieldsOf`** from the security service's `getQueryableFields`, for the caller each already resolves (assumption A1 holds: no new service dependency on either door). `/mcp`: `recordContextMembers` reads it from this request's `security` service with the request's execution context. stdio: `createStdioDataBridge` reads it from the `security` service it already holds for the object-schema mask, with the per-call principal; its dependency type now declares the optional method. - **N2, the smaller design: the door reports its cap, and the executor asks for at most it.** A new optional door member `pageCap()` answers the most rows one `query` may ask for. The executor cuts a list at `min(limit or row cap, pageCap - 1)`, reads with the probe row, and states the cut, so no door cuts or refuses a list the answer does not say was cut. Both doors answer the deployment's smaller read limit (`OS_DATA_MAX_PAGE_SIZE`, `OS_DATA_QUERY_ROW_BUDGET`), which the data door refuses past. Before, under a max page size below 21, the `/mcp` door refused the whole call `MAX_RECORDS_EXCEEDED` and the stdio door read the full list (the ablation below shows both). - **N1:** the `RecordContextNoteKind` doc line now says `related_truncated` fires at the entry's `limit`, at the row cap, or at the door's page cap. - **Rework N3:** the `.describe()` texts of `RecordContextRelatedListSchema.rows` and `.truncated` (what a model reads in the tool's output schema) now name the entry's `limit` and the door's page cap, not the row cap alone. Generated reference docs regenerated with `check:generated --fix` (`content/docs/references/ai/record-context-tools.mdx`, 2 rows twice). - **Rework N4:** one page cap. `@objectstack/types` exports `resolveQueryReadPageCap()`, the smaller of `OS_DATA_MAX_PAGE_SIZE` and `OS_DATA_QUERY_ROW_BUDGET`, `undefined` when neither is set; both doors answer `pageCap` from it, and their two local copies are gone. `deleteRecordsCap` is not changed. - **Rework S1, the declaration:** `Clause-②: yes (widening)`. The published surface widens by optional members only: `RecordContextDoor.pageCap?()`, `StdioDataBridgeDeps.security` may carry `getQueryableFields`, and the new `resolveQueryReadPageCap` export. Precedent objectstack-ai#35137. The level stays `patch` (now also on `@objectstack/types`); `Metadata-protocol: none` stands. - **N5:** an `orderBy` on a registry-injected field (`created_at`) is pinned on the service and on both doors: the executor's own-field check (the child's published definition) and both doors accept it. See the acceptance notes for the authoring lint, which does not. - **Carried from objectstack-ai#37175 (item 4 of its card amendment, comment 7151678330):** `door.ts` `query`'s docblock now says the door decides each expansion target's API exposure. Rework S3: the sentence, which ships in the `.d.ts`, cites ADR-0160 D3 "Object level" (its last paragraph: a lookup whose target the caller may not read is left unexpanded); the earlier "(ADR-0160 D3, amendment 4)" named an ADR amendment that does not exist. ## Tests Whole suites of every touched package, at head `88a1447c9` (local, under the shared verify lock; per-package exit captured before any pipe): | package | command | result | |:--|:--|:--| | `@objectstack/types` | `pnpm --filter @objectstack/types test` | exit 0 · Test Files 41/41 · Tests 934/934 | | `@objectstack/service-record-context` | `pnpm --filter @objectstack/service-record-context test` | exit 0 · Test Files 2/2 · Tests 106/106 | | `@objectstack/mcp` | `pnpm --filter @objectstack/mcp test` | exit 0 · Test Files 85/85 · Tests 1515/1515 | | `@objectstack/runtime` | `pnpm --filter @objectstack/runtime test` (`--project local`) | exit 0 · Test Files 649/649 · Tests 12041 passed, 25 skipped | | `@objectstack/spec` | `pnpm --filter @objectstack/spec test` | exit 0 · Test Files 896/896 · Tests 28442 passed, 1 todo | `pnpm --filter X typecheck` for the same five packages: exit 0 each. `pnpm --filter @objectstack/spec check:generated --fix` after a spec build: 1 of 14 artifacts stale (`content/docs/references/**`, the N3 texts), regenerated, re-checked green. Real-kernel harness (`packages/runtime/src/mcp-record-context-tools-bridge.test.ts`), every case through `both()` (same bytes on `/mcp` and stdio for one caller), 22 cases: - rework S2, new: a second caller, `usr_plain`, the same key's door but without `rc_unmask` (the baseline set no longer carries it; `usr_member` holds it through its own grant of `rc_unmasker`, resolved by the real `resolveAuthzContext`). For `usr_plain` an `orderBy` on the masked `serial` drops the section with the one `not_visible` note on both doors: no refusal, no `related` key, nothing of `rc_step` in the text, `getQueryableFields` lacks `serial` for it. Control leg in the same case: the same pack as `usr_member` reads `[s4, s2, s3, s1]`. The stdio door re-resolves the key's owner per call, and the case asserts it read as `usr_plain`; - flipped: the case titled "[today; ADR-0160 as amended says left out and stated]" now pins left out and stated, with a served control child (`rc_revision`) in the same answer; - unchanged and green: the API-exposure child (named) and the disabled-package child (`OBJECT_PACKAGE_DISABLED`, unnamed) still refuse; - new: the where/orderBy/limit parity case (filtered, ordered, cut at `limit`, stated); - new: a `where` field outside the security service's answer drops the section with the note, never refuses, with a served control; the field is served, readable and declares no masking rule, so the fallback would admit it; - new: an `orderBy` on a masked field whose unmask capability the caller holds is read (the service lists it as queryable, the fallback never would); - new: `orderBy: created_at` reads in that order on both doors; - new: under `OS_DATA_MAX_PAGE_SIZE=3` both doors cut the list at 2 and state it; - the door-member unit case now lists `pageCap` and `queryableFieldsOf`, and a new case pins that the door's queryable fields are the security service's answer for the caller and its cap the smaller read limit. Service (`record-context-tools.test.ts`): left out with a served control and no further read of the child; a lookup target reached only through a left-out child refuses nothing; unexposed and unserved child refused unnamed; disabled-package child refused before its served definition is asked; a throwing served-definition read refuses; the door cap cuts one row under it and states it, and a cap at or above the probe, absent, zero or fractional changes nothing; `orderBy: created_at` reads. <details><summary>Ablations (each committed first, mutated with scripts/ablation-replace.mjs, dist-preflighted where the subject resolves through dist, restored to the HEAD blob)</summary> - **A** (left-out child refused instead, the old behaviour; service rebuilt, dist preflight `--absent` on `leftOut.add(entry.object)`): service suite 3 red (the left-out case, the lookup-through-left-out case, the gate-order case); runtime harness 1 red (the flipped left-out case). Restored to blob `c4cd29690aa1`, rebuilt, marker present again. - **E** (no API-exposure gate on a related child, `if (false) try`; dist preflight hit): runtime harness red on the API-exposure child and on the disabled-package child, which then answers left out instead of refused. This is the measurement behind A2: on the real kernel a disabled-package child reaches `servedObjectDefinitionOf` as `null`, so only judging exposure first keeps its refusal. Service suite 6 red. - **B** (`/mcp` door hands over no `queryableFieldsOf`; runtime source, no build): 4 red, among them the narrowed-answer case and the unmasked-serial case (the two doors' bytes differ). - **C** (stdio door hands over no `queryableFieldsOf`; mcp rebuilt, dist preflight hit): 2 red, the same two parity cases. - **D** (executor never asks the door's cap; service rebuilt, dist preflight hit): service N2 case red; runtime page-cap case red with the `/mcp` door answering `MAX_RECORDS_EXCEEDED` for the whole call where stdio read the list. The first attempt at D (replacing the cut expression) left `doorCap` unused and did not build, so it ran no test; it was redone with a mutation that builds. - **F** (rework, for the S2 pin: the executor admits a field served OR queryable, `served.has(n) || queryable.has(n)`; committed first at `88a1447c9`, service rebuilt, anchor counts 1/0 on disk, dist preflight hit): runtime harness 2 red. The new second-caller case turns red with the whole call refused (`isError` true: the engine guard refuses the masked sort), and the spy-narrowed `where` case answers the dropped section. Restored to blob `c4cd29690aa1`, `git diff HEAD` empty, rebuilt, preflight `--absent` green. - Every leg restored with `git checkout HEAD -- ABSOLUTE_PATH`, proven by blob equal to HEAD and an empty `git status --porcelain`. </details> ## Acceptance notes - **Premise, measured:** the card's example of the fallback admitting a field the security service excludes is not reachable with plugin-security on these doors. Its read projection (`getReadableFields`) already leaves out every computed field the read mask deletes, so the fallback and `getQueryableFields` agree except for masked fields. There the fallback is the stricter one: it dropped a section ordered by a masked field whose unmask capability the caller holds, which this PR fixes and pins. The "excluded" direction is pinned by narrowing the real service's answer by one field with a spy. - **N5, half outside this card's surface (now objectstack-ai#37415):** the authoring lint's own-field check (`validateAiContext` in `packages/lint`, run by `os validate` and the save door) warns `ai-context-field-unknown` for `orderBy: created_at` on an object that does not declare it, saying "the list is left out of every answer", while the executor and both doors read the list (pinned here). `packages/lint` is not in this claim's file surface, so it is reported to the seat, not changed. - The stdio door's own query path plans no deployment read window (it calls the engine directly), so `OS_DATA_MAX_PAGE_SIZE` does not refuse there as the data door does. For `get_record_context` both doors now cut at the same row; for other stdio reads this is an observation, not measured here. - A disabled-package child keeps the `PERMISSION_DENIED` code (unnamed), the one code ADR-0160 point 12 gives an object-level refusal; the card's acceptance line "refuses with OBJECT_PACKAGE_DISABLED" is read as naming the case, and the existing pin is kept. ## Verification Two-minute check: `pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/mcp-record-context-tools-bridge.test.ts` (after building the runtime's dependency closure) shows 22 passed, including "a related child this caller is not served is left out" and "an orderBy on a masked field whose rule is NOT lifted for the caller drops the section". Read first, by risk: 1. `packages/services/service-record-context/src/record-context-tools.ts`, step 4a: the reordered gates and the `leftOut` set feeding `publishedOf`. 2. `packages/runtime/src/domains/mcp.ts` and `packages/mcp/src/stdio-data-bridge.ts`: the two `queryableFieldsOf` / `pageCap` members. 3. `packages/runtime/src/mcp-record-context-tools-bridge.test.ts`: the second caller (`keyOwner`, `plainCaller`, `bothAsPlain`) and the narrowed-answer case (a spy on the real security service). <details><summary>Local gates</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 117 commands for this diff (tree `objectstack-ai/objectstack` at `88a1447c9`); all 117 run, each exit captured before any pipe; `--ran` reconciliation: "117 derived, 115 run, 2 NOT-MEASURED, 0 UNRUN". - `pnpm --filter @objectstack/spec run check:skill-examples` first answered exit 3 (client-react not built); after building `@objectstack/client-react` and its closure it answered exit 0 ("351 prose examples type-check across 3 surface(s)"). - NOT MEASURED: `node scripts/check-plugin-teardown-shape.mjs --self-test` (exit 3, its pinned fixture commit is outside this shallow checkout); `pnpm check:dual-build-cjs-loads` (exit 3, reads every package's dist, and this worktree built only the runtime and mcp closures). Both are CI's. - Local-only `node scripts/check-dev-prereqs.mjs`: exit 1, "the workspace is not built" (35 of 110 packages, `ui/**` among them, unbuilt in this worktree); a reading about this checkout, not the diff. - `node scripts/pm/overlap-check.mjs --branch=HEAD` before each push: VERDICT clean (origin/main merges cleanly); not merged, as ordered. </details> _Seat note: the governing Claim on objectstack-ai#37175 now names this branch (re-claim 7181502252), since the round-2 rig branch landed as PR objectstack-ai#37350. Final-head readings (a50181d) are in the os-dev report 7181466841 on objectstack-ai#37361._ --- _Generated by [Claude Code](https://claude.ai/code/session_01Utp6CbeF2saT6wUBV4E9uc)_ <!-- signed: repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc --> --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #37175
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
describein the shared harness filepackages/runtime/src/mcp-record-context-tools-bridge.test.ts:get_record_contextover one real kernel, asked through both MCP doors for one caller, every answer compared byte for byte (isErrorand the text content), refusals included.ObjectQLonSqlDriver(better-sqlite3), the realSecurityPlugin(a permission set with an object refusal, a field-level refusal and a row rule), the realObjectStackProtocolImplementation, and the realRecordContextServicePluginregistered as therecord-contextservice. Nothing of the metadata plane, the data plane or the executor is a double./mcpdoor:HttpDispatcher.handleMcpinto the realMCPServerRuntime, so the call goes through this package's HTTP data bridge (packages/runtime/src/domains/mcp.ts).MCPServerPlugin's long-lived session (createStdioDataBridge) over an in-process transport, principal-bound toOS_MCP_STDIO_API_KEY./mcprequest carries the contextresolveAuthzContextplusassembleExecutionContextbuild for the same key the stdio session resolves (ownerusr_member, active inorg_1). A precondition case checks that the stdio door's root read carried the sameuserId,tenantId,permissionsandpositions.not_visiblenote; the lookup whose target isapiEnabled: falseis answerednotVisible: true, never expanded or named (amendment 4: the door decides an expansion target's API exposure); the related row the caller's row rule refuses is absent; the body is carried whole;PERMISSION_DENIED403 before any pack is looked up, equal toget_record's answer for the same object and record on both doors;PERMISSION_DENIED403 for the whole call, the child unnamed (see Acceptance notes for the gap to ADR-0160 as amended);PERMISSION_DENIED403, named;OBJECT_PACKAGE_DISABLEDfor it, checked in the case):PERMISSION_DENIED403, unnamed;RESOURCE_NOT_FOUND404;protocol.saveMetaItem(served from the metadata registry, not shipped by the stack, no_packageId): read on both doors.packages/runtime/src/domains/mcp-record-context-37175.test.ts(console output, from the resumed backup0fa37da2) is deleted. Its rig is now thedescribeabove.packages/runtime/package.json, the lockfile andpackages/runtime/vitest.config.tsare unchanged: PR fix(mcp,runtime): get_record_context reads a package's context packs on both MCP doors #37255 already landed the two devDependencies and the two alias rows this rig needs.Tests
Final head
9c9d8a634.pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/mcp-record-context-tools-bridge.test.tsunder the verify lock:Tests 15 passed (15), VERDICT command-exit 0. Of the 15, 8 are thisdescribe's; the 7 earlier ones are unchanged and still pass.pnpm --filter @objectstack/runtime typecheck(tsc pluscheck:test-typecheckovertsconfig.test.json, which compiles this file, counted with--listFiles): exit 0, "test layer compiles … 27 file(s) / 183 error(s) … held in test-typecheck-debt.json", the ledger unchanged.["r1","r2"]and its test goes red. Sor2is absent because of the row rule, and the case can fail. The file was restored withgit checkout HEAD --;git diff HEADis empty and the blob hash equals HEAD's.Acceptance notes
stdioto equalhttp(isErrorand text). "The registry-served pack is read": the last case.executeGetRecordContextstill refuses the whole call (refuseObject(entry.object, false), step 4a). The case pins today's answer and says so in its title. When the executor changes, this case goes red on purpose. Routed by the seat, not fixed here:packages/services/service-record-context/**is outside this card's fence.packages/services/service-record-context/src/door.ts(query): a door decides each expansion target's API exposure. That file is fenced off for this card, because sibling work is in flight there. The behaviour half is pinned here (thevaultlookup case). That is why this PR saysPart of: the sentence is the half left open.maina182fbe37:RECORD_NOT_FOUNDfor a row the HTTP door read. Cause: the WIP's key resolved to a caller with no organization, while the row is inorg_1. It was the rig, not a door defect. With the key active inorg_1and the same context handed to/mcp, both doors read the row.sharingservice, and the private-OWD read filter is that service's (resolveSharingReadFilterinplugin-securityreturnsnullwhenresolveKernelService('sharing')has nobuildReadFilter). The rig now uses an authored row rule on the permission set. Both doors honour it.describe). The claim namedpackages/runtime/src/domains/**for a new file; this is a declared change of surface, and the deleted WIP file underdomains/is the only change there.Duration 18.59s (… import 17.77s, tests 655ms). The 8 new cases take under a second.Verification
Derived gates (dispatch-gates --commands, 50 families) — local
48 exit 0. Two are NOT MEASURED, each exit 3 PREREQUISITE NOT MET, so they belong to CI:
node scripts/check-plugin-teardown-shape.mjs --self-test(its positive control is pinned to a commit this shallow clone does not hold) andpnpm check:dual-build-cjs-loads(it needs every package built).dispatch-gates --ranwith recorded exit codes: "50 derived famil(ies) accounted for — 48 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)".node scripts/pm/overlap-check.mjs --branch=HEAD: VERDICT clean exit 0 before each push.Read first (by risk):
packages/runtime/src/mcp-record-context-tools-bridge.test.ts, the lastdescribe. The risky hunk is thekeyedQlproxy, which stands in for the key's auth tables, and thecallerassembly beside it.Two-minute check:
pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/mcp-record-context-tools-bridge.test.tsshould printTests 15 passed (15).Not run locally (declared): the runtime package's full
pnpm test(653 files). The diff is this one test file, and CI'sTest Coreruns the suite. No changeset: the diff is a test file undersrc/, andpackages/runtimepublishesdist,README.mdandCHANGELOG.mdonly, with tests excluded from its build tsconfig, soskip-changeset.repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc
Generated by Claude Code