Skip to content

feat(core,objectql,spec,service-record-context,mcp,runtime)!: a context pack is identified by its package and its name; get_record_context selects a pack by its face on both MCP doors - #37291

Merged
os-zhuang merged 13 commits into
mainfrom
claude/issue-37216-ai-context-package-scope
Nov 25, 2026
Merged

os-zhuang merged 13 commits into
mainfrom
claude/issue-37216-ai-context-package-scope

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ
Fixes #37216
Clause-②: yes (narrowing)
Metadata-protocol: narrowed
Skills-docs: follow-up #37177

维护者速读

  • 用户能看到什么变化:两个应用各自带了同名的资料包时,外部 AI 通过 MCP 读取记录资料能按“应用+名字”分别选到各自的包;只给名字且有两个应用都带这个名字时,会被明确拒绝并列出每个可选的写法。
  • 为什么做:属于“在一条记录上问 AI”专题,落实已合并的资料包身份裁决(资料包按应用+名字认),也为后续“技能指定资料包”那张卡扫清前提。
  • 出错会怎样:只影响资料包的选取与同名校验;第一方应用里没有任何同名资料包,现有部署读到的结果不变,可直接撤回。
  • 要你做什么:这是收窄改动,请你批准;批准后由席位合入。契约审核通过记录是 PR comment 7168612536,Head-sha 7408543965b4dbbc8e51cf8033e51106d2e2f79d。

What changes

ADR-0150's addendum (PR #37209, merged by the maintainer) puts the context pack in bucket 3 beside skill: a pack is identified by its package and its name.

  • The four lists. ai_context joins PACKAGE_SCOPED_TYPES (packages/core/src/package-scoped-resolution.ts, the one ADR-0150 D3 rule), PACKAGE_SCOPED_READ_TYPES (packages/objectql/src/package-scoped-read.ts, the /meta by-name read and its ?package= qualifier), PACKAGE_SLOTTED_METADATA_TYPES (packages/spec/src/api/protocol.zod.ts, the metadata service's per-(package, name) slot; uninstall drops one package's pack and keeps another's) and NAMESPACE_UNIQUE_TYPES (packages/objectql/src/namespace-co-owner-names.ts, D2's refusal of a second holder inside one namespace, at install and in os validate).
  • Reader 1, pack selection (packages/services/service-record-context/src/read-set.ts). Candidates are still the packs rooted on objectName. context is read as a skill prompt's name is: a face (NS-NAME, deriveAiFaceName) answers its one pack; a bare name resolves by D3 as a caller with no package (the environment's pack, else the one package holder, else 409 RESOURCE_CONFLICT naming each candidate by its face). RecordContextDoor gains an optional packageNamespace(packageId); the tool description teaches NAMESPACE-NAME.
  • Both MCP doors place a pack's package. The /mcp route (packages/runtime/src/domains/mcp.ts) implements packageNamespace through packageNamespaceOf, on the engine resolved beside the listContextPacks read, as listSkills does. The stdio bridge (packages/mcp/src/stdio-data-bridge.ts) implements it from its engine's registry (the objectql service, the same record installedPackageNamespace reads for skill prompts). Both sit on top of fix(mcp,runtime): get_record_context reads a package's context packs on both MCP doors #37255's stripReadDecorations listing, unchanged.
  • The several-packs answer (triage row 7154571964, ADR-0160 D4 step 3 as amended by docs(adr): ADR-0160 amended — a related child this caller is not served is left out; pack selection conditions; carried-text bound #37196): each pack is listed by its face with its label, in en and zh-Hans; a pack with a blank label is listed by its face alone.
  • The overlay consequence (card What 4, ADR-0150 D4 as ruled for skill): a package-less ai_context row under a name a package ships is that holder's customization and is not served, read at (type, name) whatever the row's root. Measured by a §5 pin with a control in packages/metadata-protocol/src/protocol.reads-environment-only.test.ts.
  • ADR-0087 semantic entry packages/spec/src/migrations/entries/semantic/18.ai-context-package-scoped-name.ts, registered by the changeset's registered ai-context-package-scoped-name marker.

Narrowings, each measured on first-party trees (objectstack at d7f299c0, re-read at this head; hotcrm at 9b735103): the one declarer of packs, examples/app-showcase (src/ai/record-context.ai-context.ts), ships two packs of different names (showcase_project_brief, showcase_task_notes) in one package; hotcrm declares none.

Narrowing First-party count
A second holder of a pack name inside one namespace: refused at install (422 NAMESPACE_CONFLICT) and by os validate 0
GET /api/v1/meta/ai_context/NAME with no package, for a name two packages hold: first match becomes 409 RESOURCE_CONFLICT 0
A package-less pack row under a name a package ships: not served (the holder's customization) 0

Tests

  • packages/mcp/src/mcp-record-context-tools.test.ts: a new top-level describe on the stdio bridge whose engine's registry places two packages: each same-name pack reached by its face, alike over MCP-over-HTTP and stdio; the bare name refused 409 naming both faces; a control engine with no registry spells each pack bare, so no face reaches one (404).
  • packages/runtime/src/mcp-record-context-tools-bridge.test.ts: in the real-protocol /mcp harness, two packages of two namespaces ship rcd_brief on one root: each is reached by its face, and the bare name is refused 409 naming both. The door's member pin lists packageNamespace.
  • packages/services/service-record-context/src/__tests__/record-context-tools.test.ts: a new top-level describe for selection by (package, name): each of two packages' same-name packs reached by its face; the bare name refused 409 naming both faces with nothing read; uninstalling one holder keeps the other; environment pack first under D3; the root narrows before D3 picks; the several answer by face and label in en and zh-Hans, with the blank-label fallback; a door without packageNamespace.
  • packages/metadata/src/metadata-manager-keyed-plural-read.test.ts: the pinned slotted set gains ai_context, so every plural-read case runs for it.
  • packages/metadata/src/loaders/database-loader.test.ts (metadata: the boot priming pass primes one holder per name for unbundled slotted types, so a bare read of a two-holder name answers the last row saved instead of 409 (epic red line 2) #32521 priming): the two host-file cases spelt the host's file helper.TYPE.yml, which the pass never reads for ai_context (the registry declares **/*.ai-context.yml). They now spell the file from the type's registry pattern. Every assertion is unchanged, and the ai_context cases assert the slotted behaviour every other type already had.
  • objectql and CLI enumeration pins (registry-namespace-co-owner-names, package-scoped-exact-qualifier, package-scoped-e8-readers, manifest-service-residual-namespace-name, the CLI's namespace-co-owner-names) list ai_context where it moved.

Acceptance notes

Verification

Local readings

Each run under scripts/pm/os-verify-lock.sh, exit taken from its VERDICT command-exit line. Readings taken at 6cb32813 (main merged at 057cedfa, which carries #37255). The head is now 74085439: the two commits since change only the changeset's Clause-② line and the semantic entry's reason plus the first BREAKING bullet (422 NAMESPACE_CONFLICT). The dogfood battery was re-run on 74085439 (see below). The suites the door commits touch were re-run there; the rest were read at c61fb9f7, and the merge brought no change to their packages (packages/spec, core, objectql, metadata, metadata-protocol untouched by it).

Command Head Result
pnpm --filter @objectstack/mcp test 6cb32813 85 files, 1507 tests passed · exit 0
pnpm --filter @objectstack/runtime test 6cb32813 647 files; 11997 passed, 25 skipped · exit 0
pnpm --filter @objectstack/service-record-context test 6cb32813 2 files, 82 tests passed · exit 0
typecheck mcp, runtime 6cb32813 exit 0 each
pnpm --filter @objectstack/core test c61fb9f7 157 files, 3761 tests passed · exit 0
pnpm --filter @objectstack/objectql test c61fb9f7 638 files, 14423 tests passed · exit 0
pnpm --filter @objectstack/metadata test c61fb9f7 83 files, 2798 tests passed · exit 0
pnpm --filter @objectstack/metadata-protocol test c61fb9f7 370 files passed, 9 skipped; 23419 tests passed · exit 0 (§5 pin and its control both ran and passed)
pnpm --filter @objectstack/spec exec vitest run src/migrations src/api c61fb9f7 69 files, 2339 tests passed · exit 0
pnpm --filter @objectstack/cli exec vitest run --project unit src/utils/namespace-co-owner-names.test.ts c61fb9f7 31 tests passed · exit 0
typecheck service-record-context, metadata, core, objectql, metadata-protocol, spec, cli c61fb9f7 exit 0 each

The #32521 host-file pins before the fixture fix: 2 failed / 539 passed (the two ai_context host-file cases; the pass read no file). After: 541 passed, 23 of them ai_context cases.

Ablations (once each, after committing; restore proven by blob equal to HEAD): deleting the stdio bridge's packageNamespace member turns both face cases of the new mcp describe red (2 failed, the control passes). Deleting the /mcp door's member turns the runtime face case and the member pin red (2 failed).

The CLI integration layer and test:repo were not run locally; CI runs them.

Gate sweep (dispatch-gates --commands)

node scripts/pm/dispatch-gates.mjs --commands at 6cb32813: 105 derived commands, each run with its exit code recorded. --ran: 105 derived, 105 run, 0 NOT MEASURED (a derived zero: every line carries its exit code).

  • 104 exit 0 on the first run.
  • pnpm check:type-check-debt: exit 3 on the first run (lock queue-timeout behind the dogfood run, nothing measured). Re-run under the lock: exit 0.
  • check:adr-0087-registration: registered ai-context-package-scoped-name (new here: ai-context-package-scoped-name).
Dogfood battery

Head 74085439 (the current head; the os-dev-report is #37216 comment 7169906867): the full battery under the lock gave VERDICT command-exit 0 · Test Files 487 passed, 3 skipped (490) · Tests 4128 passed, 68 skipped (4196) · no failures. Earlier reading, head 6cb32813, pnpm turbo run build --filter='@objectstack/dogfood^...' (exit 0), then pnpm --filter @objectstack/dogfood test under the lock: VERDICT command-exit 0 · Test Files 487 passed, 3 skipped (490) · Tests 4128 passed, 68 skipped (4196) · no failures. (Also run at c61fb9f7, before the door commits: the same counts.)

Read first: packages/services/service-record-context/src/read-set.ts (selectContextPack, the face / D3 order), packages/spec/src/api/protocol.zod.ts (the slot list, a contract surface), packages/mcp/src/stdio-data-bridge.ts (installedPackageNamespaceOf, the stdio door's new member).

Two-minute check: pnpm --filter @objectstack/service-record-context exec vitest run src/__tests__/record-context-tools.test.ts → 65 passed, including "the bare name two packages hold is refused 409, naming both faces".

Provenance

Opened by seat repo:objectstack#4 on the maintainer's authorization in the seat session (「#37216 开 PR 放行」). The dev session's (session_01QSeKYohZLmQ1Ug9FKcQtVu, zone a4-A) own relay pr_create was refused by its permission check and not retried; the dev sent the prepared body. The seat changed the dev's Clause-②: no (narrowing) to Clause-②: yes (narrowing). A narrowing arm is legal with either value; yes is right here because the diff also widens published surface: ?package= on the history and rollback doors for ai_context, a face in get_record_context's context, and new service-record-context exports. Branch claude/issue-37216-ai-context-package-scope @ 74085439.


🤖 Generated with Claude Code

https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ

… four package-scoped lists; pack selection reads faces

ADR-0150 addendum 2026-11-25: ai_context joins PACKAGE_SCOPED_TYPES,
PACKAGE_SCOPED_READ_TYPES, PACKAGE_SLOTTED_METADATA_TYPES and
NAMESPACE_UNIQUE_TYPES. get_record_context reads context as a skill
prompt's name is read: a face answers its one pack, a bare name resolves
by D3 for a caller with no package; the several answer lists each pack by
its face with its label.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
…s, D3 for a bare name, the several answer with labels

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
…name is not served, whatever its root; changeset

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
…he keyed plural-read pin's slotted set gains ai_context

Claude-Session: https://claude.ai/code/session_01QSeKYohZLmQ1Ug9FKcQtVu
Co-authored-by: Claude <noreply@anthropic.com>
…'s registry pattern, so ai_context's hyphenated suffix is read as slotted

Claude-Session: https://claude.ai/code/session_01QSeKYohZLmQ1Ug9FKcQtVu
Co-authored-by: Claude <noreply@anthropic.com>
…so get_record_context reaches each package's pack by its face

Claude-Session: https://claude.ai/code/session_01QSeKYohZLmQ1Ug9FKcQtVu
Co-authored-by: Claude <noreply@anthropic.com>
…y its face; the door's member pin lists packageNamespace

Claude-Session: https://claude.ai/code/session_01QSeKYohZLmQ1Ug9FKcQtVu
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l 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 7 package(s): @objectstack/cli, @objectstack/core, @objectstack/mcp, @objectstack/objectql, @objectstack/runtime, @objectstack/service-record-context, @objectstack/spec, touching 48 documentable anchor(s). ⚠️ 2 changed file(s) yielded no anchor (packages/cli/src/utils/namespace-co-owner-names.ts, packages/services/service-record-context/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

57 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 4fb03ebbfa5a7bb6771a04bc3f41cb370c440a52.

⛔ 19 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 2 changed file(s) yielded no anchor (packages/cli/src/utils/namespace-co-owner-names.ts, packages/services/service-record-context/src/index.ts) — pages documenting those are invisible to this run
  • 10 name(s) were too generic to anchor anything (single lowercase words)
  • 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 — 197 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 4fb03ebbfa5a7bb6771a04bc3f41cb370c440a52 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 64e40c65818e290efb011da8369d1eacf87cb2cb — the merge of head 7408543965b4dbbc8e51cf8033e51106d2e2f79d into base 4fb03ebbfa5a7bb6771a04bc3f41cb370c440a52, 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 64e40c65818e290efb011da8369d1eacf87cb2cb && git checkout 64e40c65818e290efb011da8369d1eacf87cb2cb
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 4fb03ebbfa5a7bb6771a04bc3f41cb370c440a52 7408543965b4dbbc8e51cf8033e51106d2e2f79d && git checkout -B drift-repro 4fb03ebbfa5a7bb6771a04bc3f41cb370c440a52 && git merge --no-ff 7408543965b4dbbc8e51cf8033e51106d2e2f79d

node scripts/docs-audit/affected-docs.mjs --json 4fb03ebbfa5a7bb6771a04bc3f41cb370c440a52

⚠️ 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 4fb03ebbfa5a7bb6771a04bc3f41cb370c440a52 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

…mespace is 422 NAMESPACE_CONFLICT, in the semantic entry and the changeset

Claude-Session: https://claude.ai/code/session_01QSeKYohZLmQ1Ug9FKcQtVu
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYo86w1wqy2z2fMrryr

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 7408543965b4dbbc8e51cf8033e51106d2e2f79d
Local-runs: none
Scope: packages/spec/src/api/protocol.zod.ts, packages/spec/src/migrations/entries/semantic/18.ai-context-package-scoped-name.ts + packages/core/src/package-scoped-resolution.ts, packages/objectql/src/package-scoped-read.ts, packages/objectql/src/namespace-co-owner-names.ts, packages/cli/src/utils/namespace-co-owner-names.ts, packages/services/service-record-context/src/read-set.ts, packages/services/service-record-context/src/sentences.ts, packages/services/service-record-context/src/record-context-tools.ts, packages/services/service-record-context/src/door.ts, packages/services/service-record-context/src/index.ts, packages/runtime/src/domains/mcp.ts, packages/mcp/src/stdio-data-bridge.ts
Security-touching: no
Rule-change-verified: none

What this record is. A delta over my full review of head db7b2e23, by the same reviewer. That full record was written but never posted (the write was refused by the reviewing session's permission check), so its judgments are restated here and this record stands alone on this head. The full review read card #37216 and every comment, the ADR-0150 addendum of 2026-11-25 with D2 to D6 and D9, ADR-0160 D4 as amended, the PR body, the 26-file list and the net diff against main at merge base 057cedfa. The delta is one commit, 74085439, over db7b2e23: two files, 4 lines added and 3 removed (.changeset/37216-ai-context-package-scoped.md and the semantic entry). No other file moved, so every judgment below that is not about those two files is carried from db7b2e23 unchanged.

① Derived judgments

Carried from db7b2e23; the delta changes no accept set and no public surface.

  1. PACKAGE_SLOTTED_METADATA_TYPES gains ai_context (published constant). Right: the metadata service's store, its removal and unregisterPackageWithReport are generic over the set, so each package's pack keeps its own slot and an uninstall drops one and keeps the other. It also follows that the history and rollback doors take ?package= for the type (refused 400 before), a widening the PR body does not name, and that an in-process read or removal by name with no package is refused 409 for a name two packages hold.
  2. PACKAGE_SCOPED_TYPES gains it. Right, and required by item 1: the store's read with no package asks the one rule, which throws for a type outside the list. A by-name read on a registry that cannot read by package answers 501, as for every listed type; SchemaRegistry can.
  3. PACKAGE_SCOPED_READ_TYPES gains it. Right: GET /api/v1/meta/ai_context/NAME with no package, for a name two packages hold, goes from the first match to 409 RESOURCE_CONFLICT. No reader passes a package caller for this type yet, so D3 (a) and (c) narrow nothing today.
  4. NAMESPACE_UNIQUE_TYPES gains it. Right and real at both doors: the predicate reads the aiContexts collection, installPackage throws NamespaceNameConflictError (422 NAMESPACE_CONFLICT), and os validate prints the same sentence.
  5. get_record_context: context accepts a face, a bare name resolves by D3 for a caller with no package, the several answer lists face and label, a two-holder refusal names each candidate. Right against the addendum's reader 1 and point 2.
  6. @objectstack/service-record-context: new exports, a changed selectContextPack signature and outcome members, recordContextReadSet().pack as the face, an optional RecordContextDoor.packageNamespace. No importer outside the package in this repository; the changeset states each.

② Semver level

  • Six packages at minor for Metadata-protocol: narrowed: met. The changeset carries both declaration lines, the BREAKING banner with a count per narrowing, the one-line fix and one ADR-0087 marker matching the entry's id. The delta leaves all of that as it was.
  • Clause-②: yes (narrowing) holds on the tree: yes for the widenings in items 1, 5 and 6, the arm for items 1, 3 and 4. The claim comments on the card (7155305628, 7157432984) still read no (narrowing); the seat reconciles that line. A card that only narrows is no (narrowing); this one is yes because it also widens.
  • The first BREAKING bullet now reads 422 NAMESPACE_CONFLICT, as the tree answers.

③ Boundary flags

④ Design judgment

The delta, packages/spec/src/migrations/entries/semantic/18.ai-context-package-scoped-name.ts. Holds. The entry's reason now reads "refused at install (422 NAMESPACE_CONFLICT, naming every holder) and by os validate". That is the envelope NamespaceNameConflictError carries (code NAMESPACE_CONFLICT, status and httpStatus 422), the one the pins assert for the type, and the spelling the sibling entries use. "Naming every holder" is true of the refusal: each conflict lists every other package of the namespace that holds the name. The rewrap of the following sentence changes no word. The changeset's first BREAKING bullet carries the same words, and the PR body's narrowing table was corrected to 422 NAMESPACE_CONFLICT as well. The three 409 that remain in the entry and the changeset are the by-name read and the get_record_context refusals, which do answer 409 RESOURCE_CONFLICT.

S1: closed

Carried from db7b2e23, unchanged by the delta.

  • packages/spec/src/api/protocol.zod.ts: holds. One row in the list the addendum names, read by its first consumer as item 1 says.
  • The entry's disposition (a semantic entry with no conversion and no relevance question), its surface, replacement and acceptance criteria: hold.
  • read-set.ts: holds. The root narrows first; a face answers its one pack; a face two packs derive is refused naming each holder; a bare name goes to the one rule with no caller package. It is lookupSkillPrompt's order, with one stricter step (two rows of one holder are refused). No arrangement I tried picks silently: an environment pack beside a package pack, a door that cannot place a package, two packages of a shareable namespace, a shared face among several with context omitted.
  • sentences.ts: holds against ADR-0160 D4 step 3 as amended, in en and zh-Hans, with the blank-label fallback pinned.
  • record-context-tools.ts, door.ts, index.ts, both MCP doors, and the three list files with the cli header: hold.

Nits, accepted as they stand (no effect on correctness or the contract). N1: in packages/mcp/src/stdio-data-bridge.ts the new helper sits between createStdioDataBridge's docblock and the function, so the exported function lost its doc comment. N2: two comments outside the diff still count the lists without the pack (package-slotted-store.ts, registry.ts). N3: the context describe, with #37141. N4: the entry's "at once" for migrateDatabaseLoaderRowPackages leaves out the stamp-only rows that migration does not bind, as the sibling tool-names-per-namespace entry does. Each is a follow-up, not a commit on this PR.

No must-fix, no should-fix.

Implemented-by: claude/issue-37216-ai-context-package-scope
Reviewed-by: session_01QSeKYpRe9nAK9bihJTbn9Q

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — REWORK · L1 · head 7408543965b4dbbc8e51cf8033e51106d2e2f79d · 2026-11-25T16:57Z

Read. I read card #37216 and every comment, the ADR-0150 addendum of 2026-11-25 (reader 1, D2, D3, D6 and the overlay paragraph), the dev's two closing reports, the PR body, the contract-review PASS 7168612536, and the full net diff against merge base 057cedfa (26 files, +668/−60).

Checklist.

  • Shape (from l1-face.mjs --pr 37291): draft, base main, first line Fixes #37216, and no closing keyword binds any other card. Fixes is right: the card's four lists, reader 1, the several-packs label row (triage 7154571964) and the narrowing counts are all delivered.
  • Fix against the card and the addendum: it holds.
    • ai_context joins all four lists: PACKAGE_SCOPED_TYPES, PACKAGE_SCOPED_READ_TYPES, PACKAGE_SLOTTED_METADATA_TYPES and NAMESPACE_UNIQUE_TYPES. The last one also gains its type union and its header.
    • selectContextPack filters by root first. A face then answers its one pack. A bare name goes to resolvePackageScopedHolders with no caller package. A face that two packs derive is refused, naming each holder. This is reader 1 as ruled.
    • Both MCP doors implement packageNamespace. /mcp resolves its engine beside the listContextPacks read. The stdio door reads engine.registry.getPackage.
  • Tests:
  • Narrowing declared fully:
    • The PR body and changeset both read Clause-②: yes (narrowing) and Metadata-protocol: narrowed.
    • Six packages are at minor.
    • The changeset carries the BREAKING (narrowing) banner with a first-party count per narrowing, and the one-line fix.
    • The ADR-0087 marker registered ai-context-package-scoped-name equals the entry's id.
    • I re-measured the first-party counts on origin/main at 829a45e9. examples/app-showcase is still the one declarer and has two distinct names (showcase_project_brief, showcase_task_notes), so every arm counts 0.
  • Changeset, read sentence by sentence against the diff:
    • The four-lists bullet holds.
    • The get_record_context bullet holds: 400 VALIDATION_ERROR for several packs, face plus label, the face-alone fallback, and NAMESPACE-NAME in the description.
    • The new-door-member bullet holds.
    • The new-exports bullet holds. index.ts exports exactly contextPackCandidates, ContextPackCandidate, ContextPackCandidateName and PackageNamespaceOf.
    • BREAKING 1 holds: NamespaceNameConflictError is 422 with code NAMESPACE_CONFLICT (registry.ts:1638).
    • BREAKING 2 holds: the by-name read gives 409 RESOURCE_CONFLICT.
    • BREAKING 3 holds: it matches the addendum's overlay paragraph.
  • Check-runs at head: 73 in total, 60 success and 13 skipped. l1-face reads all 13 skips as expected and 0 as unexpected, with 0 failed and 0 pending. Lint & Repo Gates and TypeScript Type Check are both success. The Dogfood Regression Gate shards are skipped on the PR by design, so CI does not stand in for the battery.
  • Merge state: git merge-tree --write-tree origin/main 74085439 with origin/main at 829a45e9 merges clean (exit 0), and mergeable_state reads clean.
  • K: landing-k.mjs --pr 37291 gives K = 9 against PRBASE 4fb03ebb, the last green Test Core, run 45627122732 on this head. The locale leg has no new pack, and the shared-budget leg has no book under this PR. Result: OK, under 15.
  • Claim reading:
    • latestMarkedComment over the Claim: marker picks 7157432984 as the newest claim (created 2026-11-25T08:45Z, edited 2026-11-25T13:51Z). It now reads Clause-②: yes (narrowing).
    • Seat 3's 7155305628 reads no (narrowing) and is answered by its Release: 7156321844.
    • 7164215174 carries the line but has no Claim: marker, so the tooling does not read it as a claim.
    • The landing readers take the line from the PR body, which reads yes (narrowing): --land's dogfood gate, l1-face and check-owed-reviews.

Open items.

M1 (must-fix, owed by the zone) — The dogfood battery does not cover the head.

  • The dev ran the full battery at 6cb32813 (VERDICT command-exit 0, Test Files 487 passed, 3 skipped; Tests 4128 passed, 68 skipped). The head is two single-parent commits above it:
    • db7b2e23 changes the changeset's declaration line;
    • 74085439 changes the semantic entry's reason and the changeset's first BREAKING bullet.
  • landDogfoodGate's first-parent walk accepts only merges of the base, so the dev's "text only, results still apply" is no pass.
  • The os-dev-report was never posted on 37180 跟进:资料包(ai_context)进入按包分桶的四张表,get_record_context 按应用+名字选包 #37216: post-stamped was refused in the dev container. That is the dev's open question.
  • I ran the gate function read-only (label-write.mjs's landDogfoodGate, with gh api -X GET as its only reader). It answers: --land REFUSED … why: card #37216 carries no os-dev-report by objectstack-fleet[bot] / os-zhuang (8 comment(s) read). If that report were posted as written, the walk would still refuse at 74085439 (1 parent).
  • Clears when the full battery runs on 74085439, or on a later head reached from it only by base merges, and an os-dev-report goes on 37180 跟进:资料包(ai_context)进入按包分桶的四张表,get_record_context 按应用+名字选包 #37216 by the relay identity with dogfood_battery opening with that sha. That also answers the dev's open question (option A, posted by the zone).

M2 (must-fix, owed by the seat) — Skills-docs: follow-up #37177 is not true yet.

S1 (should-fix, seat, with the re-pin after M1) — The PR body is stale or wrong in three places.

  • (a) ## Verification says "Final head 6cb32813", the dogfood block reads 6cb32813, and ## Provenance ends "@ 6cb32813". Restate them at the head that M1 runs on.

  • (b) ## Provenance says the dev's no (narrowing) was malformed because "the narrowing arm goes with yes". clause2-line.mjs reads no (narrowing) as a legal declaration, and only no (widening) is malformed. The reason for yes is this PR's widenings:

    • the history and rollback doors' ?package= for ai_context;
    • a face accepted in context;
    • the new service-record-context exports.

    ## What changes should name the first of those, which the contract review also noted.

  • (c) The ## 维护者速读 last line reads 「要你做什么:无」. A narrowing hands off for approval, so the seat record's speed-read replaces it with the approval request, naming PASS 7168612536 and Head-sha. The body's line should match.

N1 — In packages/mcp/src/stdio-data-bridge.ts, installedPackageNamespaceOf sits between createStdioDataBridge's docblock and the function. This is confirmed at the head and matches the contract review's N1. It is a follow-up, not a commit here.

N2 — l1-face flags the changeset for @objectstack/cli, @objectstack/metadata and @objectstack/metadata-protocol. None is owed:

  • metadata and metadata-protocol are touched in test files only, and those packages ship dist;
  • cli's edit is a docblock in src/utils/namespace-co-owner-names.ts. os validate's new refusal arrives through @objectstack/objectql's minor, which is a workspace dependency, not bundled.

N3 — Seat comment 7164215174 on the card is wrong on two points:

  • it calls no (narrowing) malformed;
  • it says 7157432984 reads that line, which stopped being true with the 2026-11-25T13:51Z edit.

An append-only correction is optional. No reader depends on it.

N4 — record-context-tools.zod.ts's context describe still says "by name". It is routed to #37141 and accepted.

Next. After M1 and M2 clear, the seat re-reads the delta. If the head is still 74085439, PASS 7168612536 stands. A head that moved owes a delta contract review before the hand-off. The PR then goes to the maintainer as a narrowing. After approval, the seat lands it, merging main first if K ≥ 15.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — ACCEPT · L1 · head 7408543965b4dbbc8e51cf8033e51106d2e2f79d · 2026-11-25T17:45Z

  • Same-head delta over the L1 REWORK 7168795400. The head is unchanged, so the contract review PASS 7168612536 stands.
  • M1: closed. A full dogfood battery ran on 74085439 (VERDICT command-exit 0; Test Files 487 passed, 3 skipped; Tests 4128 passed, 68 skipped; 0 failures). It is posted as os-dev-report 7169906867 on 37180 跟进:资料包(ai_context)进入按包分桶的四张表,get_record_context 按应用+名字选包 #37216, with dogfood_battery opening with the head sha. Read-only, the landing gate's dogfood check finds the report and reads 0 hops from the head.
  • M2: closed. The seat's scope note 7168812660 on 37140 跟进:技能文档教作者写资料包(ai_context) #37177 names the four author-facing changes, so Skills-docs: follow-up #37177 is now true.
  • S1: closed. The PR body is re-pinned. Verification and Dogfood name 74085439 and the new report. Provenance states why the value is yes: the diff widens too (history/rollback ?package=, the face in context, the new exports). The 维护者速读 asks for approval and names the PASS and the head.
  • N1–N4 stand as recorded (follow-ups, no head change).
  • No must-fix, no should-fix.
  • Landing: narrowing, handed to the maintainer. After approval the seat lands it; K = 9 (below 15), so no main merge is owed.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

维护者速读

  • 用户能看到什么变化:两个应用各自带同名资料包时,外部 AI 通过 MCP 读记录资料,可以按「应用前缀-名字」分别选中各自的包;只给名字而两个应用都有这个名字时,会被明确拒绝,并列出每个可选写法。同一个应用里出现第二个同名资料包,安装和 os validate 都会拒绝。
  • 为什么做:落实已合并的 ADR-0150 补充裁决,资料包和技能一样按「应用+名字」识别;属于「在一条记录上问 AI」专题,也为后续「技能指定资料包」扫清前提。
  • 出错会怎样:只影响资料包的选取和同名校验;第一方应用里没有任何同名资料包(三项收窄实测都是 0),现有部署读到的结果不变,可直接撤回。作者文档的配套更新在 37140 跟进:技能文档教作者写资料包(ai_context) #37177。
  • 要你做什么:这是收窄改动,请你批准;批准后由席位合入。契约审核通过记录是 PR comment 7168612536,Head-sha 7408543965b4dbbc8e51cf8033e51106d2e2f79d。

Approval request at 2026-11-25T17:46Z. Seat opinion: approve. Seat L1 is ACCEPT (7169974561) and the CONTRACT_REVIEW_TIER review is PASS (7168612536), both on this head. The full dogfood battery passed on this head (os-dev-report 7169906867), and the landing gate reads it at 0 hops. Each of the three narrowings measures 0 on first-party trees. K = 9 and merge-tree is clean. Four nits remain as follow-ups; none needs a head change.

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 25, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 25, 2026 18:03
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 7e9c50c Nov 25, 2026
83 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-37216-ai-context-package-scope branch November 25, 2026 18:35
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…ped bucket beside skill and ai_context (objectstack-ai#37330)

<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8ThLXnc2MYoAdJHGZxSsdaA)_

repo:cloud#1 · os-warren · session_01JQwxbZjKjZ947xtTvgJuHX

Fixes objectstack-ai#37325

Clause-②: no
Metadata-protocol: none

## 维护者速读

-
用户能看到什么变化:用户无感(只改决定记录,不改代码);把你今天定的「按应用+名字区分,都保留」写进记录:两个应用各带的同名知识源都保留、各建各的索引,AI
用「应用前缀-名字」指明是哪一个。
- 为什么做:属于「知识检索平台化」专题;哪些类型按应用区分要先写进记录,后面的实现卡
objectstack-ai#37304(让知识源成为应用包里的一份配置)才能照着做。
- 出错会怎样:记录写偏的话,后面的实现会照着偏的做;这次只有文档,撤回这次合并即可。
- 要你做什么:合并这个
PR,合并就是这条裁定的记录;其中一处超出你的原话、只能由你定:同一个应用前缀下不允许两个应用包带同名知识源(前缀不同的同名知识源照样都保留),不同意就先划掉这一条再合并。

## What changes

Two files under `docs/adr/`: 58 lines added, 1 line changed. No schema,
no code, no changeset.

**ADR-0150** (Accepted) gains a dated addendum. No ruled sentence is
rewritten.

- The status line gains one **Amended** clause, dated 2026-11-25, after
the `ai_context` one. This is the one changed line: the clause is
appended, and nothing before it is edited.
- The D1 table gains one row, marked with the date, after the
`ai_context` row and before bucket 4.
- A new section after the `ai_context` addendum and before D2, "Addendum
(2026-11-25): `knowledge_source` joins bucket 3". It writes the
maintainer's ruling of that day into the record: the knowledge source
type of ADR-0161 K4 is identified by `(package, name)`, in bucket 3
beside `skill` and `ai_context`.

The ruling is quoted with its record id in the status clause, at the
head of the addendum and in the ADR-0161 note: seat record `7168239918`
on the code card, decision card tapped **B 「按应用+名字区分,都保留」** at
2026-11-25T16:34:09Z, against the card's recommendation.

The addendum says, in this order:

1. **The type**, and what D2, D3, D4, D5, D6 and D8 mean for it. A
package's source is spelled `NS-NAME` where its name crosses the AI
face, which is inside `search_knowledge`: the `sources` list of an
answer and the `sourceIds` argument.
2. **The principle, read for this type.** The recommendation read a
source's name under D1's storage half. The ruling did not, so the keys
of a source's index are derived from its identity, as its face is. Three
things that reading does not hide are listed.
3. **The tree today**, measured on `main` at `fbb62e1c`. The type is not
registered and is in none of the four lists. A source reaches the
service through code only. The keys of an index are the bare `id`.
4. **What changes with the bucket**: the service's copy, overlays, owner
stamps, uninstall and the keys of an index.
5. **The readers that move.** It names five and moves none.
6. **The follow-up**, the code card objectstack-ai#37304, after this merge.
7. **Past the ruling's words**: seven points, none decided here. One is
the maintainer's, two follow from text already ruled, and four are left
open for the code card.

**ADR-0161** gains one cross-reference note after point 3 of K4 and
before K5. No sentence of it is changed.

**Not in this PR**, by the card's contract: none of the four lists is
edited, no reader is moved and no store is re-keyed. That is the code
card's work, after this merge.

## Tests

No package is touched, so no package build or test is owed. The checks
that read these two files are the docs gates under Verification.

## Acceptance notes

- **The chain.** This PR is the ruling's record and step 1 of its
execution. The code card objectstack-ai#37304 comes after it and stays open: it takes
the four lists, the readers and the store keying in memory, pgvector and
turso.
- **One decision is the maintainer's alone** (point 1 of "Past the
ruling's words"). The ruling record counts "the `domain:server` four
lists and readers (precedent PR objectstack-ai#37291)" and names none of them. In that
PR the fourth list is `NAMESPACE_UNIQUE_TYPES`: one package holder of a
name inside one namespace, refused at install and in `os validate`. So
"Two packages shipping one source name both work" holds for two
namespaces, and inside one namespace the second is refused. The list's
header reserves a further type to the maintainer. The merge accepts this
point. Struck, two co-owners of a namespace may ship one name, and the
one face they derive is refused at the call.
- **Two points follow from text already ruled** and are no new decision.
A source name takes the name grammar of buckets 2 and 3, which refuses a
`_`-led name that today's `id` pattern admits. And a `409` names only
the sources the tool may search (ADR-0161 K9).
- **Four points are left open for the code card.** Each is stated in the
addendum and decided nowhere in it: what each shape carries (a hit's
`sourceId` and `documentId`, a stored document's `sourceId`, the by-name
members of the service contract); which coordinate a key carries, the
package id or the namespace, and what removes an index left under the
old key; which holder a source registered in code is; and an environment
source under a name a package later ships.
- **The acceptance line of the card**, "The addendum quotes the ruling
comment id and the maintainer's words; earlier text of the record
unchanged". The id and the words are in all three places named above.
ADR-0150's diff has one changed line, the status line, and its old text
is a strict prefix of the new text. Every other old line of both files
survives, in order.
- **The tree moved once during the work.** `main` gained the knowledge
splitter (PR objectstack-ai#37287) under six of the files the addendum anchors. `main`
is merged into the branch (a merge commit, no rebase and no force-push).
Every "today" sentence and every anchor was read again at `fbb62e1c`,
and all hold. The two dated readings name that commit.
- **Overlap.** PR objectstack-ai#37329 adds a dated note under K8 of the same ADR-0161
file. `node scripts/pm/overlap-check.mjs
--branch=claude/project-thread-4uapwf` answered `VERDICT clean exit 0`
at this head, against `origin/main` and that PR's head. Whichever of the
two lands second merges `main`.
- **Line budget.** 58 added and 1 changed; the precedent PR objectstack-ai#37209 was
44 and 1. The difference is the "principle" paragraph, which the
precedent did not need because its ruling followed the recommendation,
and the seven-point list.
- **Citation form.** `check:adr-symbol-anchors` refuses a line anchor
under `docs/adr/`, so the record cites `path#Symbol`, and the line
numbers are in the table under Verification.
- **No changeset.** `docs/adr/` ships in no package, so this PR carries
`skip-changeset`.
- **Tier H.** This PR stays draft. The merge is the maintainer's, and it
is the ruling's record.
- **Shallow checkout.** No claim here is read from history dates.
- **Attribution lines.** The dispatch asked for a commit trailer that
names a model and for the harness's two-line block at the end of this
body. The repository's rules ask for the model-free trailer pair and for
one footer line under a rule, and those are what the commits and this
body carry.
- **Noted, not filed.** ADR-0161's status keyword still reads Proposed
on `main`, and its own status line says the record is in force from the
merge of the PR that carried it. This PR adds one note to that record
and does not touch its status line.

## Verification

**Read first**, by risk:

1. `docs/adr/0150-…-literal-prefix.md`, "Past the ruling's words" at the
end of the addendum (lines 191 to 199). Point 1 is the one decision that
is the maintainer's.
2. The same file, "The principle, read for this type" (line 160): how
D1's storage half reads for a type the ruling placed against the
recommendation.
3. The same file, the D1 table hunk (line 95) and the status line (line
3): one row inserted into a ruled table and one appended clause. Check
that both read as additions and change no ruled text.

**Two-minute check**: run `node scripts/check-adr-symbol-anchors.mjs`.
Expect `4220 anchors across 163 records resolve` and exit 0. Twenty-one
of them are this diff's `path#Symbol` anchors.

<details>
<summary>Measured anchors on main at fbb62e1 (file:line)</summary>

| What the addendum says | Where it is read |
|---|---|
| The type is in no row of the registry; `skill` and `ai_context` open
no environment overlay |
`packages/spec/src/kernel/metadata-plugin.zod.ts:798`
(`DEFAULT_METADATA_TYPE_REGISTRY`), `:1384`, `:1388` |
| The service keeps one slot per (package, name) for listed types |
`packages/spec/src/api/protocol.zod.ts:2753`
(`PACKAGE_SLOTTED_METADATA_TYPES`; `skill` at `:2754`) |
| Any other type is keyed by name alone |
`packages/metadata/src/package-slotted-store.ts:797` (`storeWriteKey`),
`:820` |
| The one rule resolves only its listed types, and throws for a type
outside the list | `packages/core/src/package-scoped-resolution.ts:245`
(`PACKAGE_SCOPED_TYPES`; `skill` at `:270`), `:740`;
`packages/objectql/src/package-scoped-resolver.ts:149` |
| A by-name read consults (package, name) for listed types |
`packages/objectql/src/package-scoped-read.ts:88`
(`PACKAGE_SCOPED_READ_TYPES`; `skill` at `:96`) |
| One package holder of a name inside a namespace; the list is reserved
to the maintainer |
`packages/objectql/src/namespace-co-owner-names.ts:96`
(`NAMESPACE_UNIQUE_TYPES`), `:27` |
| A source reaches the service through code only |
`packages/services/service-knowledge/src/knowledge-service-plugin.ts:91`
(`KnowledgeServicePlugin`), `:44`, `:220` |
| One map by `id`; a second registration replaces the first with a
warning |
`packages/services/service-knowledge/src/knowledge-service.ts:121`
(`KnowledgeService`), `:123`, `:166`, `:168` |
| A document id is the source's `id`, a `:` and the record id |
`packages/services/service-knowledge/src/knowledge-service.ts:1570`
(`documentIdFor`), `:1571` |
| An adapter is handed the whole source |
`packages/spec/src/contracts/knowledge-adapter.ts:33`
(`AdapterContext`), `:35` |
| The one in-tree store keyed by the bare `id` |
`packages/plugins/knowledge-memory/src/index.ts:44`
(`KnowledgeMemoryAdapter`), `:48`, `:55` |
| The push door that takes a document id from a caller |
`packages/spec/src/contracts/knowledge-service.ts:107`
(`IKnowledgeService`), `:127` |
| The tool lists each source by its `id`; a hit shows `sourceId` and
`documentId` |
`packages/services/service-knowledge/src/knowledge-tools.ts:61`
(`SearchKnowledgeSourceSummary`), `:70`, `:72`, `:222` |
| An unknown `sourceIds` entry is refused `NOT_FOUND` |
`packages/services/service-knowledge/src/knowledge-tools.ts:246`
(`createKnowledgeTools`), `:257`, `:260` |
| Today's `id` pattern admits a `_`-led name; the bucket's pattern does
not | `packages/spec/src/ai/knowledge-source.zod.ts:174`
(`KnowledgeSourceSchema`), `:176`;
`packages/spec/src/kernel/address-grammar.ts:68`
(`ROUTER_ADDRESSABLE_NAME_PATTERN`) |
| The one face derivation | `packages/spec/src/ai/face-name.ts:86`
(`deriveAiFaceName`) |
| A skill prompt's name: a face, else a bare name by the one rule |
`packages/mcp/src/skill-prompts.ts:373` (`lookupSkillPrompt`) |
| The owner stamp's judge, and the collections it judges |
`packages/spec/src/kernel/collection-item-owner-stamp.ts:129`
(`judgeCollectionItemOwnerStamp`), `:100` |
| The type's row is not among the served overrides |
`packages/metadata-protocol/src/protocol-package-bindings.ts:388`
(`SEALED_ROW_SERVED_OVERRIDE_TYPES`) |
| Uninstall, the registry's half |
`packages/objectql/src/registry.ts:5328` (`uninstallPackage`) |
| Uninstall, the service's half |
`packages/metadata/src/metadata-manager.ts:2880` (`unregisterPackage`) |

Absence readings at the same commit, each with a positive control:

- `knowledge_source` in the four list files, in
`packages/metadata/src/package-slotted-store.ts` and in the registry's
rows: 0 lines each. Control: `skill` is in the first three lists and in
the registry, at the lines the table gives.
- A stack collection: `knowledgeSources` in
`packages/spec/src/stack.zod.ts`, 0 lines. Control: `aiContexts`, 3
lines.
- `knowledge_source` under `packages/`, `examples/`, `ui/`, `skills/`
and `content/`: 0 files. Control: `ai_context`, 60 files.
- `KnowledgeServicePlugin` or `registerSource` under `examples/`: 0
files. Control: 25 files under `packages/`.
- Tracked paths under `knowledge-pgvector` or `knowledge-turso`: 0.
Control: `packages/plugins/knowledge-memory`, 10 files.
- Before this diff, ADR-0161 named ADR-0150 on 0 lines (control:
ADR-0088, 7 lines), and ADR-0150 held the word "knowledge" on 0 lines
(control: `ai_context`, 6 lines).

</details>

<details>
<summary>Local gates at head 05f35b6: 21 derived, 21 run, all exit
0</summary>

Derived with `node scripts/pm/dispatch-gates.mjs --repo
objectstack-ai/objectstack --commands`, and reconciled with `--ran`:

```
Run reconciliation — 21 derived, 21 run, 0 NOT-MEASURED, 0 UNRUN.
✓ dispatch-gates --ran: 21 derived famil(ies) accounted for — 21 run, 0 NOT-MEASURED (a DERIVED zero — all 21 recorded an exit code and none of them is 3).
```

Each exit code was captured before any pipe:

```
0  node scripts/check-adr-links.mjs                      1225 relative link destination(s) under docs/adr/ resolve
0  node scripts/check-adr-links.mjs --self-test
0  node scripts/check-closing-keyword-parity.mjs         3 parsers agree on all 9 keywords
0  node scripts/check-closing-keyword-parity.mjs --self-test
0  node scripts/check-comment-mask-corpus.mjs            23929 files, 0 disagree, 0 unparseable
0  node scripts/ci/plan-test-core-shards.mjs --self-test
0  pnpm --filter @objectstack/lint run check:doc-formula-expressions
0  pnpm check:adr-anchors                                132 anchored file(s), every governing ADR still referenced
0  pnpm check:adr-index                                  docs/adr/README.md is current, every record parsed
0  pnpm check:adr-symbol-anchors                         4220 anchors across 163 records resolve
0  pnpm check:ci-filter-parity
0  pnpm check:closed-ceremony-text
0  pnpm check:cross-package-test-inputs
0  pnpm check:doc-authoring
0  pnpm check:driver-memory-census
0  pnpm check:gitlink-declared
0  pnpm check:nul-bytes                                  no raw ASCII control bytes
0  pnpm check:pm-governed-merges
0  pnpm check:pm-prior-rulings
0  pnpm check:refd-timer-probe
0  pnpm check:watch-hint-literal
```

`check:doc-formula-expressions` reads the compiled output of
`@objectstack/formula` and `@objectstack/lint`. Those two and their
dependencies were built first on the merged tree, under the shared
verify lock (`VERDICT command-exit 0`).

`docs/adr/README.md` is generated from each record's status keyword.
ADR-0150's keyword stays Accepted and ADR-0161's stays Proposed, so the
index does not change and is not in this diff.

Also at this head: `node scripts/check-commit-card-trailers.mjs --range
origin/main..HEAD` exits 0 over the 3 commits of the branch.

Not measured locally, and CI's to run: the type-check lanes, the `Plan
Test Core shards` job and the governed-merges audit, which take values
only a CI run has.

</details>

---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbZjKjZ947xtTvgJuHX)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…he record-context docs name both mounts (objectstack-ai#37409)

<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgXTK3Lp9k96oinCGTRnfrNo)_

Fixes objectstack-ai#37177

Clause-②: no
Metadata-protocol: none

## 维护者速读
- 用户能看到什么变化:替客户写应用的 AI
助手,现在能从随产品发布的技能文档里学会怎样写「资料包」,也就是挑出一条记录的哪些字段、关联列表和正文交给 AI;产品本身的行为没有变化。
- 为什么做:属于「在一条记录上问 AI」专题;资料包这个新的元数据类型此前在技能文档里只有一个名字,作者无从下笔。
- 出错会怎样:最坏是技能文档某句话教错,AI 写出的资料包被校验拒收或读到的内容比预期少;已有应用不受影响,撤回即可恢复。
- 要你做什么:批准这次技能文件改动(受管文件,需要你批准后才能合入)。

## What changes

**New reference `skills/objectstack-ai/references/context-packs.md`**
(111 lines, 1454 tokens). It teaches authoring an `ai_context` pack from
what `main` at `9ffe37153` enforces:
- the six pack keys and the six keys of a `related` entry, with their
bounds (30 fields, 3 related lists, 10 columns, `limit` 1 to 20), and
that an unknown key or a pack over a bound is refused at parse;
- a related list's `where` / `orderBy` / `limit` (objectstack-ai#37354): the admitted
operators, literal comparands only, `order` not `direction`;
- when to use fields, a related list or the body, and how the body is
carried (whole up to 8,000 characters, else an outline with anchors,
else cut and marked);
- serving and calling: `requires: ['record-context']` or a `plugins`
mount (objectstack-ai#37303), the call's four arguments, the answer's three parts;
- pack identity (objectstack-ai#37291): package and name, one pack per name in a
namespace (`422 NAMESPACE_CONFLICT`), `context` takes the face
`NAMESPACE-NAME`, a bare name two packages hold is refused `409
RESOURCE_CONFLICT`, and the `/meta/ai_context/NAME` read needs
`?package=` for such a name;
- what the caller is not shown, and the five `os validate` rules that
report an author's mistake the tool keeps silent about.

**Pointers in the two SKILL.md files, paid by deleting restatement in
the same file.** Neither SKILL.md ceiling row moves.
- `skills/objectstack-ai/SKILL.md`: a five-line "Context packs" section,
a `get_record_context` row in the MCP tools table, and the frontmatter
description and tags name the context pack.
- `skills/objectstack-platform/SKILL.md`: the `requires` token row says
what `record-context` serves and links the reference; the ADR-0150 list
of names "identified by package and name" gains context packs.

**N1 and N2 of scope note 7166997849 (prose only).**
- N1: the `aiContexts` `.describe()` and its TSDoc in
`packages/spec/src/stack.zod.ts` no longer read the token as the only
serving condition. They name both mounts: the CLI mounts the service
where `requires` includes `record-context`, and a host that composes its
own kernel lists `RecordContextServicePlugin` in `plugins`. Regenerated
mirror: `content/docs/references/api/package-api-assembled.mdx`.
- N2: `packages/services/service-record-context/README.md` and the
`RecordContextServicePlugin` docblock teach the token beside the
`plugins[]` mount.
- Patch changeset for `@objectstack/spec` and
`@objectstack/service-record-context`.

**Eval case 11** in
`skills/objectstack-ai/evals/skills-tools-knowledge.json`: the card's
prompt ("give the AI a customer's open opportunities and notes").

**One new ratchet row** in `scripts/check-skills-token-ratchet.mjs` for
the new reference, pinned at the measurement (5813 bytes, `ceil(5813 /
4) = 1454`, zero headroom). It is the seat's claim amendment 2 on the
card, comment 7179788843: "one new row in check-skills-token-ratchet.mjs
for the new references/context-packs.md, pinned at the measured size".

Container & model: `M`, `mode:thread`, `model: CONTRACT_REVIEW_TIER
(MANDATORY for skills/**, served at tier; claim amendment 7179771295)`,
`effort: high`

### Skills readings (base `9ffe37153`, head `e9b2056f`)

| File | Lines | Tokens (`ceil(bytes / 4)`, the ratchet's count) |
|:--|:--|:--|
| `skills/objectstack-ai/SKILL.md` | 485 to 487 | 6787 to 6798 (ceiling
6801, unchanged) |
| `skills/objectstack-platform/SKILL.md` | 422 to 422 | 6149 to 6149
(ceiling 6149, unchanged) |
| `skills/objectstack-ai/references/context-packs.md` | 0 to 111 | 0 to
1454 (new row 1454) |
| `skills/objectstack-ai/evals/skills-tools-knowledge.json` | 105 to 115
| 2668 to 2997 (eval fixture, not ratcheted) |
| All `SKILL.md` files together | 4959 to 4961 | |
| Whole `skills/` tree | 23130 to 23253 | ratcheted authored 198131 to
199596; bundle total 297515 to 299309 |

### What was deleted to pay for the pointers, and where each fact still
lives

The discipline is the standing ruling of record 6513306068, quoted
verbatim: 「A:先削重复,余额按实测提高」. Only its first half is used here:
restatement is cut, and no SKILL.md row is raised.

`skills/objectstack-ai/SKILL.md` (+11 tokens net, inside the 14 of
headroom it had):
1. The `Agent → Skill → Tool` diagram. Still taught: a skill's `tools`
row ("Tool names this skill grants"), "An agent's tool set is the union
of its surface-compatible skills' tools" (Platform agents), and the
three captions by the Skill Configuration table, the Actions dispatch
table and the Platform agents section.
2. "You usually don't author tool definitions by hand for action
invocation." Still taught by that section's own heading ("the default
path"), ladder rung 3, and "Default: declare no tool records" (Tool
metadata).
3. The Verify block's `# or: os build` comment line. Still taught in
`skills/objectstack-platform/references/operations.md` ("os build # the
same three gates, plus emits dist/objectstack.json"), which the section
points to. This home is in another file.
4. The Knowledge example's `// or 'memory' for dev/test` comment. Still
taught by the Wiring paragraph above it.

`skills/objectstack-platform/SKILL.md` (net 0):
1. "Embed any domain prefix directly in the name (e.g. `name:
'crm_account'`)". Still taught by the next two paragraphs
(`manifest.namespace`: every `object.name` must start with `crm_`;
"Which names carry the namespace").
2. "(one `task.object.ts` per object)". Still taught by the Naming
Conventions row (`{name}.{type}.ts`, `task.object.ts`).
3. "handed to the stack key of its name" on the barrel sentence. Still
taught by The Template's barrel bullet.

## Tests

<details><summary>Example validity (card What 3)</summary>

- The reference's `os:check` block parsed with the built
`AiContextSchema`: `parse success: true`. Seven controls on the same
pack were each refused: `limit: 21`, a `description` key, a `$contains`
operator, 4 related lists, 31 fields, 11 related columns, `direction` in
`orderBy`.
- `os validate` on a scratch stack (objects `account` and `opportunity`,
the block's pack, `requires: ['record-context']`): `Validation passed`,
exit 0, no `ai-context-*` warning. Control on the same stack with a
`where` field the child lacks and a `body.field` that is not long text:
`ai-context-field-unknown` at `aiContexts[0].related[0].where` and
`ai-context-body-not-long-text` at `aiContexts[0].body.field`. The
scratch stack was deleted.
- `pnpm --filter @objectstack/spec run check:skill-examples`: `352 prose
examples type-check across 3 surface(s)`, exit 0.
</details>

<details><summary>Eval case 11, graded with `gradeAnswer`
(packages/qa/scenarios/src/skill-evals/grade.ts)</summary>

- A reference answer (an `aiContexts` entry with the related
`opportunity` list filtered by `stage`, `body: { field: 'notes' }`,
`requires: ['record-context']`):
`{"pass":true,"missing":[],"forbidden":[]}`.
- Control, the wrong shape (an object-level `aiReadable`, a top-level
`filter:`, `direction:`):
`{"pass":false,"missing":["opportunity","related","where","body","notes","record-context"],"forbidden":["filter:","direction:","aiReadable"]}`.
</details>

<details open><summary>Eval case 11, run against a model (seat L1 item
S1, record 7181297604)</summary>

One round of the repository's runner on head `e9b2056f`: `pnpm --filter
@objectstack/scenarios skill-evals --skills objectstack-ai --concurrency
4` (the runner selects by bundle, not by case, so all 11 cases ran; 22
of 22 turns, each case once with the bundle installed and once without;
subscription login, no API key; the served model is in the round's run
records and is not written here, repository rule).

- **Case 11, with the skill: `pass`**, `missing: []`, `forbidden: []`.
The turn launched `objectstack-ai` and read
`objectstack-ai/references/context-packs.md`.
- **Case 11, without the skill: `fail`**, `missing:
["related","where","body"]`, `forbidden: ["filter:"]`. The no-skill
answer reached for a top-level `filter:`, which is the mistake the case
forbids.
- The pack in the with-skill answer, as the model wrote it:

```typescript
export const AccountBrief: AiContext = {
  name: 'account_brief',
  label: 'Customer brief: open opportunities and notes',
  object: 'account',
  fields: ['name'],
  related: [
    {
      object: 'opportunity',
      field: 'account',
      fields: ['name', 'stage'],
      where: { stage: { $nin: ['closed_won', 'closed_lost'] } },
      limit: 20,
    },
  ],
  body: { field: 'notes' },
};
```

- The same answer adds `requires: ['record-context']` on the stack and
says that without it nothing serves `get_record_context`.
- That literal through `AiContextSchema.safeParse` on this head: `model
answer pack parse success: true`. Not measured: `os validate` on it (the
answer names no object definitions to validate against).
- **The other ten cases, same round:** with the skill 9 of 11 pass,
without it 0 of 11. Cases 5 and 6 fail with the skill (missing
`aiExposed`; missing `signed-in session`). The same round on the base
text (`skills/objectstack-ai` as of `9ffe37153`, 10 cases, 20 of 20
turns): 8 of 10 with the skill, and the same two cases fail (5 missing
`skills`, `aiExposed`; 6 missing `signed-in session`, `refused`). Both
cases are red before this diff, on sentences this diff does not touch;
they are not fixed here.
- One repeat per arm, so each figure is one draw, not a rate.
</details>

<details><summary>Packages and gates (local, head `e9b2056f` unless a
line says otherwise)</summary>

- `pnpm --filter @objectstack/spec test`: `Test Files 896 passed (896)`,
`Tests 28442 passed | 1 todo`; the lock's line `VERDICT command-exit 0`.
- `pnpm --filter @objectstack/service-record-context typecheck`, its
`test` (`Test Files 2 passed`, `Tests 99 passed`) and `pnpm --filter
@objectstack/spec typecheck`: one locked run, `VERDICT command-exit 0`.
- `pnpm --filter @objectstack/spec check:generated`: 2 of 14 stale
(skill docs, `content/docs/references/**`); `--fix` regenerated those
two and both then checked clean.
- `node scripts/check-skills-token-ratchet.mjs`: exit 0, `61 authored
bundle file(s) within their ceilings`; its `--self-test`: `104 cases
pass`.
- Derived families (`node scripts/pm/dispatch-gates.mjs --commands`):
138. Reconciliation at `e9b2056f`: `138 derived, 137 run`, and the
138th, `pnpm check:pm-dispatch-gates`, was run on its own afterwards:
exit 0.
- 133 commands exited 0 on `f3cbf52a`. The last commit changed only
`skills/objectstack-platform/SKILL.md`, and the eleven gates that read
the skills were re-run on `e9b2056f`: all exit 0.
- `pnpm check:skill-top-level-keys` exited 1 on `f3cbf52a`: its
self-test pins the sentence "the top level refuses it and the stack
fails to load" in the platform skill, which I had cut as restatement.
`e9b2056f` restores the sentence and pays with a different cut. Exit 0
on `e9b2056f`.
- `pnpm --filter @objectstack/spec run check:skill-examples` exited 3
first (`PREREQUISITE NOT MET`, `packages/client-react/dist` not built),
and 0 after that package was built.
- NOT MEASURED: `node scripts/check-plugin-teardown-shape.mjs
--self-test`, reason: exit 3, the shallow clone cannot reach the commit
its fixture is pinned to. NOT MEASURED: `pnpm
check:dual-build-cjs-loads`, reason: exit 3, some packages have no
`dist/` here (only the CLI and client closures were built). CI runs
both.
- `test:repo` and the repo-wide lint were not run locally; they are CI's
(`Test Core`, `Lint & Repo Gates`).
</details>

No ablation: the diff changes documentation, one ratchet row and one
eval fixture, and no behaviour a test pins.

## Acceptance notes
- **Size.** The reference is 1454 tokens. My estimate to the seat before
writing was 600 to 800. The file holds a whole metadata kind (two key
tables, the body, serving, pack identity, the validate rules), and I did
not find a smaller form that keeps every item the card and its three
scope notes ask for.
- **N1 and the hosted kernel.** Scope note N1 says the hosted kernel
does not serve the tool yet. That lives in another repository, which I
cannot read from here, so no sentence states it. The new text says what
`main` does: a host without the service serves no such tool.
- **A related object the caller cannot read.** The reference teaches
what `main` does today: the whole call is refused `403
PERMISSION_DENIED` (`record-context-tools.ts`, step 4a). ADR-0160 D3 as
amended says such a child is left out and stated. The PR that lands the
amendment owes this reference one sentence.
- **Not taught, because `main` does not have it:** a skill's `context`
key (ADR-0160 D8; `SkillSchema` has no such key, though the pack `name`
description in `ai-context.zod.ts` already mentions it), and the total
bound on long-text cells of a related list (ADR-0160 D3, amended
2026-11-25; the service bounds only the body).
- **Possible defect, not fixed here.** `os validate` reported
`ai-context-field-unknown` for `owner_id` in a pack's `fields` on an
object that does not declare `owner_id` itself (the platform adds it).
Measured: the warning, on the scratch stack above. Not measured: whether
`get_record_context` carries the field at run time. The example avoids
the field. Reported to the seat in the dev report.
- `content/docs/ai/skills-reference.mdx` is regenerated from the changed
frontmatter (`gen:skill-docs`), not hand-edited.
- The model identifier is not written in this body (repository rule);
the tier is named by its word.

## Verification
Two-minute check: `node scripts/check-skills-token-ratchet.mjs`. Expect
`61 authored bundle file(s) within their ceilings`, with
`context-packs.md 1454 / 1454`, `objectstack-ai/SKILL.md 6798 / 6801`
and `objectstack-platform/SKILL.md 6149 / 6149`.

Read first: (1) `skills/objectstack-ai/references/context-packs.md`
against `packages/spec/src/ai/ai-context.zod.ts` and
`packages/services/service-record-context/src/record-context-tools.ts`;
the risky part is the section "What the caller is not shown". (2) The
deletions listed above, in the two SKILL.md diffs. (3)
`packages/spec/src/stack.zod.ts`, the `aiContexts` description.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CaWzgwG1QYaiBidBCK)_

<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CaWzgwG1QYaiBidBCK -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue size/l 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.

37180 跟进:资料包(ai_context)进入按包分桶的四张表,get_record_context 按应用+名字选包

3 participants