Skip to content

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 into
mainfrom
claude/issue-37175-record-context-http-rig
Nov 25, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-37175-record-context-http-rig

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Part of #37175
Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:用户无感。这是测试:外接 AI 读取一条记录资料的工具,在网页通道和本地命令行通道上,用真内核、真执行器对同一个人逐字节比对回答。
  • 为什么做:属于“在一条记录上问 AI”专题,补上网页通道只测了接线、没用真执行器的缺口。
  • 出错会怎样:只增加一组测试,不改任何产品代码;有问题直接撤回即可。
  • 要你做什么:无。

What changes

  • One new top-level describe in the shared harness file packages/runtime/src/mcp-record-context-tools-bridge.test.ts: get_record_context over one real kernel, asked through both MCP doors for one caller, every answer compared byte for byte (isError and the text content), refusals included.
    • The kernel: a real ObjectQL on SqlDriver (better-sqlite3), the real SecurityPlugin (a permission set with an object refusal, a field-level refusal and a row rule), the real ObjectStackProtocolImplementation, and the real RecordContextServicePlugin registered as the record-context service. Nothing of the metadata plane, the data plane or the executor is a double.
    • The /mcp door: HttpDispatcher.handleMcp into the real MCPServerRuntime, so the call goes through this package's HTTP data bridge (packages/runtime/src/domains/mcp.ts).
    • The stdio door: the real MCPServerPlugin's long-lived session (createStdioDataBridge) over an in-process transport, principal-bound to OS_MCP_STDIO_API_KEY.
    • One caller: the /mcp request carries the context resolveAuthzContext plus assembleExecutionContext build for the same key the stdio session resolves (owner usr_member, active in org_1). A precondition case checks that the stdio door's root read carried the same userId, tenantId, permissions and positions.
  • The cases (card What 2 and 3, and amendment 4):
    • the record through its package pack: the field-level-hidden field is not carried and is stated by the not_visible note; the lookup whose target is apiEnabled: false is answered notVisible: 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;
    • a root the caller may not read: PERMISSION_DENIED 403 before any pack is looked up, equal to get_record's answer for the same object and record on both doors;
    • a related child this caller is not served: today PERMISSION_DENIED 403 for the whole call, the child unnamed (see Acceptance notes for the gap to ADR-0160 as amended);
    • a related child its API exposure refuses: PERMISSION_DENIED 403, named;
    • a related child whose package is disabled (the protocol answers OBJECT_PACKAGE_DISABLED for it, checked in the case): PERMISSION_DENIED 403, unnamed;
    • an anchor the body does not resolve: RESOURCE_NOT_FOUND 404;
    • a pack saved at run time through protocol.saveMetaItem (served from the metadata registry, not shipped by the stack, no _packageId): read on both doors.
  • The WIP probe file is removed: packages/runtime/src/domains/mcp-record-context-37175.test.ts (console output, from the resumed backup 0fa37da2) is deleted. Its rig is now the describe above.
  • No production source changes. packages/runtime/package.json, the lockfile and packages/runtime/vitest.config.ts are 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.ts under the verify lock: Tests 15 passed (15), VERDICT command-exit 0. Of the 15, 8 are this describe's; the 7 earlier ones are unchanged and still pass.
  • pnpm --filter @objectstack/runtime typecheck (tsc plus check:test-typecheck over tsconfig.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.
  • One-off fixture control, not committed: with the permission set's row rule removed, the main case answers rows ["r1","r2"] and its test goes red. So r2 is absent because of the row rule, and the case can fail. The file was restored with git checkout HEAD --; git diff HEAD is empty and the blob hash equals HEAD's.

Acceptance notes

  • Card acceptance. "For one fixture and one caller, the HTTP bridge and the stdio bridge give byte-identical answers, refusals included": every case goes through one helper that asks both doors and requires stdio to equal http (isError and text). "The registry-served pack is read": the last case.
  • Gap to ADR-0160 as amended 2026-11-25 (point 2). A related child this caller is not served should be "left out and stated, not refused". executeGetRecordContext still 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.
  • Amendment 4, the docblock half is not in this PR. The amendment asks for a sentence in 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 (the vault lookup case). That is why this PR says Part of: the sentence is the half left open.
  • The WIP's two open readings, measured again on main a182fbe37:
    • (a) The stdio door answered RECORD_NOT_FOUND for a row the HTTP door read. Cause: the WIP's key resolved to a caller with no organization, while the row is in org_1. It was the rig, not a door defect. With the key active in org_1 and the same context handed to /mcp, both doors read the row.
    • (b) A private-OWD row owned by another user came back on HTTP. Not a row-security defect. The WIP rig composed no sharing service, and the private-OWD read filter is that service's (resolveSharingReadFilter in plugin-security returns null when resolveKernelService('sharing') has no buildReadFilter). The rig now uses an authored row rule on the permission set. Both doors honour it.
  • Placement. The file is the shared harness file (AGENTS.md: a new pin for a component that already has a shared harness file goes into that file as a top-level describe). The claim named packages/runtime/src/domains/** for a new file; this is a declared change of surface, and the deleted WIP file under domains/ is the only change there.
  • The file's wall time is collection. Shared box: 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) and pnpm check:dual-build-cjs-loads (it needs every package built). dispatch-gates --ran with 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 last describe. The risky hunk is the keyedQl proxy, which stands in for the key's auth tables, and the caller assembly beside it.

Two-minute check: pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/mcp-record-context-tools-bridge.test.ts should print Tests 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's Test Core runs the suite. No changeset: the diff is a test file under src/, and packages/runtime publishes dist, README.md and CHANGELOG.md only, with tests excluded from its build tsconfig, so skip-changeset.

repo:objectstack#5 · os-bill · session_01Utp6CbeF2saT6wUBV4E9uc


Generated by Claude Code

…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
…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
@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

Nothing 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): node scripts/docs-audit/affected-docs.mjs --json ebac615f77137aa6abd7fa78955467b7527112ec → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

维护者速读

  • 改了什么:只加测试。外部 AI 读记录情境包时,网页通道和命令行通道在同一个真实内核上逐字节给出相同答案,拒绝的情况也一样;运行时保存的情境包也能读到。
  • 为什么:记录范围 AI 问答专题要求两条通道行为一致,之前只在命令行通道上验过。
  • 风险:无产品代码改动,不发版。
  • 要你做什么:无,由专题区自行落地。

席位意见:ACCEPT。

席位核对

Head-sha: 9c9d8a6349
ACCEPT — L1, seat repo:objectstack#5

  1. Shape: open draft against main; Part of #37175 is right: the card's remaining piece (the door.ts docblock sentence, fenced in service-record-context this round) rides 37178 跟进:资料包目录被截断时,没列出的章节也要能读到 #37233, and 37140 跟进:get_record_context 在运行时 HTTP 通道上用真执行器测一遍(含拒绝) #37175 closes when 37178 跟进:资料包目录被截断时,没列出的章节也要能读到 #37233 lands. 37140 跟进:get_record_context 在运行时 HTTP 通道上用真执行器测一遍(含拒绝) #37175 keeps pm:dispatched until then (landing rule B). l1-face: one flag, judged below.
  2. Premise measured: card items 1–3 are pinned in one new top-level describe: /mcp and stdio give equal payloads for one caller across the root refusal, a hidden field, an unopenable lookup, an unreadable related row, an unexposed and a disabled-package related child, an unresolved anchor, and a registry-served pack. The case titled [today; ADR-0160 as amended …] pins current behaviour where the amended ADR says otherwise; that gap is the amendment's implementation, not this card's.
  3. Gates: check-runs at 9c9d8a6349: 37 success, 21 expected skip, 0 failed, 0 pending; Lint & Repo Gates and TypeScript Type Check success; mergeable clean.
  4. Accepted deviations: the rig is a describe in the existing bridge test file instead of a new file under domains/ (declared in the PR body). skip-changeset is right: @objectstack/runtime ships dist, README.md and CHANGELOG.md only, so the one .test.ts file publishes nothing.
  5. Out of scope and where it went: the docblock sentence goes to 37178 跟进:资料包目录被截断时,没列出的章节也要能读到 #37233. A1(b) in the dev report is not a security defect (the rig has no sharing service).
  6. Landing terms: Tier default, ungoverned, Clause-②: no, so no L2 is owed. The area lands it: ready, then auto-merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 25, 2026 21:25
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 134b71d Nov 25, 2026
59 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-37175-record-context-http-rig branch November 25, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m skip-changeset PR has no user-facing published change; bypasses the changeset gate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants