Skip to content

fix(mcp,runtime): get_record_context reads a package's context packs on both MCP doors - #37255

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-37243-context-pack-undecorated-read
Nov 25, 2026
Merged

objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-37243-context-pack-undecorated-read

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

repo:objectstack#3 · os-support-ai · session_01WGufzi13yZRqVcp2mGonWK

Fixes #37243
Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:部署了资料包的应用里,AI 助手读取一条记录的资料时(网页通道和本地命令行通道都一样),终于能读到资料包,不再一律回答“找不到资料包”。
  • 为什么做:属于“AI 读取记录资料”这条能力(资料包设计)的缺陷修复,替所有提供资料包的部署(含演示应用)解决读不到的问题,另外两张卡也在等它。
  • 出错会怎样:只影响 AI 读取记录资料这一个工具;若有问题,表现仍是读不到资料包,与修复前相同,可直接撤回。
  • 要你做什么:无

What changes

  • Both record-context doors hand the executor the authored packs, not the serving envelope. The HTTP door (packages/runtime/src/domains/mcp.ts, listContextPacks in the bridge's record-context members) and the stdio door (packages/mcp/src/stdio-data-bridge.ts, listContextPacks) read the protocol's served ai_context listing, which decorateMetadataItem stamps with _diagnostics; the executor's closed AiContextSchema parse (parsedContextPacks) dropped every row. Each door now maps its listing through stripReadDecorations (@objectstack/spec/kernel), the metadata-fallback branch included.
  • Which keys the strip removes, and why. Exactly METADATA_READ_DECORATIONS (_diagnostics, _draft, _withheldFields, _relatedListsArrangement), the read path's derived keys that are no part of a document. The ADR-0010 protection envelope (_packageId, _packageVersion, _provenance, _lock, _lockReason, _lockSource) stays: AiContextSchema declares it through MetadataProtectionFields, so it parses, and the pin asserts the served pack still carries _packageId. A blanket underscore strip would remove declared keys; stripping only _diagnostics would leave the next listed decoration to fail the same way.
  • No new helper. The shared helper already exists where producer and consumers meet: spec/kernel/metadata-read-decorations.ts, whose module docblock names this exact failure class ("any re-parse of a served document"). Both doors already depend on @objectstack/spec, so neither takes a new runtime dependency, and the protocol's served read (with its per-type redaction) is still the one a door reads — getMetaItemsForExecution would have dropped the _diagnostics too, but its docblock forbids reading it from a door that answers a caller.
  • The door's contract is stated on RecordContextDoor.listContextPacks (packages/services/service-record-context/src/door.ts). The executor's strict parse is unchanged.

Tests

  • packages/mcp/src/mcp-record-context-tools.test.ts: new top-level describe — a real ObjectStackProtocolImplementation over a real ObjectQL (an in-memory SQLite SqlDriver store) with a package carrying the pack; the metadata service lists no pack, so the protocol's listing is the only one. Precondition asserts the served pack carries _packageId and _diagnostics; then get_record_context answers through the pack, identically on MCP-over-HTTP and stdio.
  • packages/runtime/src/mcp-record-context-tools-bridge.test.ts: new top-level describe — the /mcp route end to end (HttpDispatcher.handleMcp, the real MCPServerRuntime, the real executor, SecurityPlugin, the real protocol over ObjectQL + SqlDriver); same precondition, then the call answers the pack's fields.
  • Ablation (once each, then restored; restore proven by git diff HEAD empty and blob == HEAD): removing the strip at either door turns its pin red with the defect's own answer, RESOURCE_NOT_FOUND "No context pack named … reads object …".
  • Test deps: @objectstack/mcp gains devDeps @objectstack/metadata-protocol and @objectstack/driver-sql; @objectstack/runtime gains devDeps @objectstack/mcp and @objectstack/service-record-context; each new value import has an anchored source alias row in that package's vitest.config.ts (check:test-source-alias).

Acceptance notes

  • Placement differs from the dataset tools on purpose: service-analytics' dataset executor strips decorations inside the executor; this card's ruling puts the strip at the doors and keeps AiContextSchema's consumer strict. Noted, not changed.
  • Wall time, single-file cold runs on a shared box: the runtime harness file was 16.7 s before this PR and 18.3 s after (import-dominated, cases ~0.2 s); the mcp harness file 5.8 s before and 10.8–14.1 s after, nearly all of it transforming metadata-protocol source through the new alias. These readings come from single-file runs. A full-package run shares the transform cost across files.

Verification

Local readings (final head in the report)

See the report comment on #37243 for the exact commands, exit codes and the head sha they were read on.

Read first: packages/mcp/src/stdio-data-bridge.ts (listContextPacks, the strip on both branches), packages/runtime/src/domains/mcp.ts (same), packages/mcp/src/mcp-record-context-tools.test.ts (the precondition that makes the pin non-vacuous).

Two-minute check: pnpm --filter @objectstack/mcp exec vitest run src/mcp-record-context-tools.test.ts → 11 passed; delete .map(stripReadDecorations) from the stdio listContextPacks and the last case fails with RESOURCE_NOT_FOUND.


Generated by Claude Code

…hored packs

The protocol's served ai_context listing stamps every item with the read
path's _diagnostics; the executor parses each row with the closed
AiContextSchema, so every pack was dropped and get_record_context answered
RESOURCE_NOT_FOUND on the HTTP and stdio doors alike. Both doors now pass
their listing through stripReadDecorations (METADATA_READ_DECORATIONS),
which keeps the ADR-0010 protection envelope the schema declares.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
…d on both record-context doors

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
…t the frozen memory driver

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
@github-actions github-actions Bot added size/m dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/mcp, @objectstack/runtime, @objectstack/service-record-context, touching 4 documentable anchor(s). ⚠️ 2 changed file(s) yielded no anchor (packages/mcp/vitest.config.ts, packages/runtime/vitest.config.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/permissions/authorization.mdx (via buildMcpBridge (symbol, a top-level function))
What this run could not see
  • 2 changed file(s) yielded no anchor (packages/mcp/vitest.config.ts, packages/runtime/vitest.config.ts) — pages documenting those are invisible to this run
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 37 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 9171bed0a65ab242567f243969368ead786cd830 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 935f9dc055eb783623e3bd7f2315753071bca5c0 — the merge of head 1176335e4863e31f3446cbe8b06f79e1f0344bbf into base 9171bed0a65ab242567f243969368ead786cd830, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 935f9dc055eb783623e3bd7f2315753071bca5c0 && git checkout 935f9dc055eb783623e3bd7f2315753071bca5c0
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 9171bed0a65ab242567f243969368ead786cd830 1176335e4863e31f3446cbe8b06f79e1f0344bbf && git checkout -B drift-repro 9171bed0a65ab242567f243969368ead786cd830 && git merge --no-ff 1176335e4863e31f3446cbe8b06f79e1f0344bbf

node scripts/docs-audit/affected-docs.mjs --json 9171bed0a65ab242567f243969368ead786cd830

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 9171bed0a65ab242567f243969368ead786cd830 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs

席位核对 — REWORK · repo:objectstack#3 · head 083ab1b · 2026-11-25T08:45Z

L1: REWORK (L1-w, zone ai-A)
Head-sha: 083ab1bf477cd0110c7b486bcee1cea6fb775a2d

There is one should-fix, which is a changeset push. The code is right. This is Tier S: no governed path, 249 changed lines on this card's only PR. No L2 is owed:

  • nothing under packages/spec/src/** moves;
  • no governed path is touched;
  • it declares Clause-②: no with no narrowing arm.

Should-fix

  • S1. The changeset leaves out @objectstack/service-record-context.
    • l1-face flags it: the package is published and touched, with no entry and no skip-changeset.
    • The file is src/door.ts, and the change is not inert. The RecordContextDoor.listContextPacks contract now obliges every door to hand over the authored pack, with the read decorations removed (stripReadDecorations), "because the executor parses every row with the closed AiContextSchema".
    • That sentence ships in the package's .d.ts, and it is the instruction a third-party door implementer reads.
    • AGENTS.md (Post-Task Checklist step 3): "Add a changeset for anything that publishes … never none". The gate reads no hunk content, by design (check-changeset-no-major.mjs, "not 'skip if the diff is comment-only'"). This is the same shape as feat(service-automation)!: a sync-in pull marks the rows the source deleted (ADR-0153 D3, #32062 slice 6) #37179's objectql must-fix.
    • Fix:
      • add '@objectstack/service-record-context': patch;
      • add one sentence to the body for door implementers: a RecordContextDoor hands listContextPacks the authored packs, read decorations removed, or the executor drops them.

Read and found right (head 083ab1b)

  • l1-face --pr 37255: 12 items clean and one flag (S1). 60 success, 9 expected skips, 0 failed, 0 pending. mergeable_state is clean.
  • Fixes #37243 is right. The card's acceptance asks for two things, and both are in the diff:
    • "A valid package pack is served on the HTTP door and on stdio through the real protocol, with no protocol double". The stdio pin builds a real ObjectQL + SqlDriver (in-memory SQLite) + ObjectStackProtocolImplementation, and asserts the precondition that the served item carries _diagnostics, so a non-stripping door is told apart. The runtime pin drives /mcp.
    • "A pin fails when the listing is decorated again". The reported ablation is red on each door.
    • It follows the card's fix direction: at the doors, with the executor's parse unchanged.
  • The fix.
    • Both doors' listContextPacks, protocol path and metadata fallback alike, map through stripReadDecorations.
    • That is @objectstack/spec/kernel's helper over METADATA_READ_DECORATIONS (_diagnostics, _draft, _withheldFields, _relatedListsArrangement). It returns the same reference when there is nothing to strip.
    • AiContextSchema spreads MetadataProtectionFields, so the ADR-0010 envelope survives the strict parse. This is the precedent object.zod.ts states ("stripReadDecorations removes _diagnostics / _draft before any strict re-parse (cloud#971)").
  • Clause-②: no is right. It is a defect fix: no accepted set moves, and no response member is added.
  • The new dev dependencies make no workspace cycle.
    • mcp now has metadata-protocol and driver-sql as dev dependencies; runtime has mcp and service-record-context.
    • None of those four depends back on mcp or runtime.
    • The vitest aliases are anchored root-entry rows, and the lockfile matches.
  • The changeset, sentence by sentence.
    • The symptom (RESOURCE_NOT_FOUND, "No context pack named … reads object …", on both doors), the cause (_diagnostics on the served listing, the closed parse) and the fix (strip exactly the read decorations, keep the declared envelope) are all true against the diff and the card's measurements.
    • "Nothing to do on upgrade" is true for a deployment. For a door implementer it is S1's missing sentence.
  • The tests are top-level describes in the two existing harness files, per the shared-harness rule.

Path to ACCEPT

  1. Card thread: one changeset push.
  2. L1-w: a delta read on green.
  3. ai-A lands it. It unblocks 37140 跟进:get_record_context 在运行时 HTTP 通道上用真执行器测一遍(含拒绝) #37175 and Open runtime: requires: ['record-context'] mounts the record-context service, so get_record_context exists without hand wiring #37189.

…ips in its types

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgv2LZN1W2qSYTZvYs

席位核对 — ACCEPT · repo:objectstack#3 · head 1176335 · 2026-11-25T09:12Z

L1: ACCEPT (L1-w, delta read, zone ai-A)
Head-sha: 1176335e4863e31f3446cbe8b06f79e1f0344bbf

No must-fix and no should-fix. No L2 is owed: nothing under packages/spec/src/** moves, no governed path is touched, and the PR declares Clause-②: no. Tier S. ai-A lands it.

Delta 083ab1bf..1176335e

The delta is a fast-forward of one commit that touches only the changeset.

  • S1 (7157454064) is closed.
    • The changeset now names '@objectstack/service-record-context': patch.
    • It adds the door implementer's sentence: "For anyone implementing a RecordContextDoor: listContextPacks hands over the authored packs with the read decorations removed (stripReadDecorations), or the executor drops them". That sentence matches the door.ts contract comment.
  • l1-face --pr 37255: 13 items clean. 60 success, 9 expected skips, 0 failed, 0 pending. mergeable_state is clean.

Round 1's reads still stand: the fix at both doors, the real-protocol pins with their decorated-listing precondition, the ablation, Clause-②: no, the dev dependencies with no cycle, and Fixes #37243.

Landing to-do

Fixes #37243 closes the card on merge. That unblocks #37175 and #37189.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzi13yZRqVcp2mGonWK

Landing · 2026-11-25T09:14Z · ACCEPT 7158044850 at head 1176335 (no L2 owed: no packages/spec/src/** move, Clause-②: no)

reading value
check-governed-merges.mjs --pr 37255 NOT governed · 258 changed lines
landing-k.mjs --pr 37255 K = 0 < 15 · ok
check-runs at 1176335 60 success · 9 skipped · 0 failed · mergeable clean

State: ready + auto-merge (Tier S). On MERGED, #37243 closes by Fixes; zone ai-A removes pm:dispatched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_record_context finds no context pack a real protocol serves: getMetaItems adds _diagnostics, the strict AiContextSchema parse drops every pack

2 participants