Skip to content

docs(adr): ADR-0150 addendum — ai_context joins the package-scoped bucket beside skill - #37209

Merged
os-zhuang merged 4 commits into
mainfrom
claude/issue-37180-ai-context-package-scope-adr
Nov 25, 2026
Merged

os-zhuang merged 4 commits into
mainfrom
claude/issue-37180-ai-context-package-scope-adr

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

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

Fixes #37180

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:用户无感(只改决定记录,不改代码);提议两个应用各带的同名 AI 资料包按「应用+名字」分开认,和技能现在的做法一样,AI 点名某个应用的资料包时用「应用前缀-名字」的写法。
  • 为什么做:属于「记录级 AI 问询」这项工作;现在同名的资料包在系统里只留后装的那一份,规则要先定,再由后续实现卡 37180 跟进:资料包(ai_context)进入按包分桶的四张表,get_record_context 按应用+名字选包 #37216(把资料包加进按应用区分的名单)落地,而它必须排在 记录 AI 问询 8:技能键 context,MCP 技能提示词可带记录参数 #37141(让技能写明用哪个资料包)之前。
  • 出错会怎样:规则定错的话,后面的实现会照着错的做;本次只有文档,撤回这次合并即可。
  • 要你做什么:这条只能由你本人定,合并就等于批准,其中两处超出卡面原话(AI 用「应用前缀-名字」点名资料包;同一应用前缀下不许两个应用包带同名资料包);不同意就不合并,那样只保留「同一对象上两个同名资料包不替用户挑、一律拒绝」这一条。

What changes

Two files under docs/adr/: 44 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. 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, between bucket 3 and bucket 4.
  • A new section at the end of D1, "Addendum (2026-11-25): ai_context joins bucket 3". It proposes that the context pack type of ADR-0160 is identified by (package, name), in bucket 3 beside skill.

The addendum says, in this order:

  1. The type, and what D2, D3, D6 and D8 mean for it. A package's pack is spelled NS-NAME where its name crosses the AI face.
  2. The tree today, measured on main at 0a1b69c0. The type and its pack selection are on main. The registry keeps each package's item. The metadata service keeps one copy per name, the one registered last.
  3. What changes with the bucket: the service's copy, overlays, owner stamps (unchanged) and uninstall.
  4. The readers that move. It names three and moves none.
  5. The follow-up, 37180 跟进:资料包(ai_context)进入按包分桶的四张表,get_record_context 按应用+名字选包 #37216, which lands before row 8 (记录 AI 问询 8:技能键 context,MCP 技能提示词可带记录参数 #37141).
  6. The interim rule: two parsed packs that share a name and a root are never chosen between.
  7. Past the card's words: two points that are the maintainer's decision alone, and one that is no new decision.

ADR-0160 gains one cross-reference note under D1, which also names the follow-up and its order. No sentence of it is changed.

Not in this PR, by the card's contract: PACKAGE_SCOPED_TYPES is not edited and no reader is moved. That is #37216's work, after the ruling.

Round 2

The contract review of the first head passed with two should-fix findings and four nits. This head closes them.

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. 37180 跟进:资料包(ai_context)进入按包分桶的四张表,get_record_context 按应用+名字选包 #37216 implements it and is blocked by this PR. 记录 AI 问询 8:技能键 context,MCP 技能提示词可带记录参数 #37141 (the skill key) waits for 37180 跟进:资料包(ai_context)进入按包分桶的四张表,get_record_context 按应用+名字选包 #37216, because the one rule throws for a type outside PACKAGE_SCOPED_TYPES.
  • Two decisions are the maintainer's alone.
    1. Bucket 3 and not bucket 2: a package's pack is spelled NS-NAME in the tool's context argument. This widens D6 from the names a server lists to the value of an argument. The alternative, an optional namespace input on the tool, adds a key to two shapes ADR-0160 has ruled.
    2. Child N's predicate carries the install refusal: the type joins NAMESPACE_UNIQUE_TYPES, whose header reserves a further type to the maintainer.
  • Not a new decision. The root object narrows the candidates before the one rule picks. ADR-0160 D4 already requires it: step 3 selects among the packs rooted on the requested object, and the naming bound lets no refusal name a pack beyond those.
  • The card's step 3 names one list, and the bucket takes four. They are PACKAGE_SCOPED_TYPES, PACKAGE_SCOPED_READ_TYPES, PACKAGE_SLOTTED_METADATA_TYPES and NAMESPACE_UNIQUE_TYPES. The service's one copy per name is governed by the third, not the first. skill is in the first three; its one-holder rule inside a namespace is phase 1's, which a new type never had.
  • 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.
  • Shallow checkout. No claim here is read from history dates.
  • Noted, not filed. On main the several-packs answer lists pack names only (packages/services/service-record-context/src/sentences.ts, severalPacks). ADR-0160 D4, as amended on 2026-11-25, says each candidate is listed by name with its label. This is read from source, not measured through the tool, and no first-party object has several packs. The addendum leaves what that answer carries to D4.

Verification

Read first, by risk:

  1. docs/adr/0150-…-literal-prefix.md, "Past the card's words" at the end of the addendum: the two decisions that are the maintainer's.
  2. The same file, the D1 table hunk: one row inserted into a ruled table. Check that it reads as an addition and changes no ruled row.
  3. The same file, the status line: the appended clause.

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

Measured anchors on main at 0a1b69c (file:line)
What the addendum says Where it is read
The type is on main, and a pack name holds no hyphen packages/spec/src/ai/ai-context.zod.ts:136 (AiContextSchema), :157; packages/spec/src/kernel/address-grammar.ts:68 (ROUTER_ADDRESSABLE_NAME_PATTERN)
Pack selection keeps the packs rooted on the object and matches a bare name packages/services/service-record-context/src/read-set.ts:65 (selectContextPack)
Two packs of one name on one root: 409; with another name and no context: the several-packs answer packages/services/service-record-context/src/record-context-tools.ts:266, :265
The one rule resolves only its listed types packages/core/src/package-scoped-resolution.ts:245 (PACKAGE_SCOPED_TYPES; skill at :270)
It throws for a type outside the list packages/core/src/package-scoped-resolution.ts:740, packages/objectql/src/package-scoped-resolver.ts:148
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), read by packages/objectql/src/registry-package-addressing.ts:433
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), packages/metadata/src/package-slotted-store.ts:154
Any other type is keyed by name alone packages/metadata/src/package-slotted-store.ts:797 (storeWriteKey), :820
The last registration replaces the copy packages/metadata/src/metadata-manager.ts:1499, packages/metadata-protocol/src/protocol-registry-hydration.ts:148
One package holder of a name inside a namespace packages/objectql/src/namespace-co-owner-names.ts:96 (NAMESPACE_UNIQUE_TYPES); the list is reserved to the maintainer at :27
The type opens no overlay channel, and its row is not among the served overrides packages/spec/src/kernel/metadata-plugin.zod.ts:1388, packages/metadata-protocol/src/protocol-package-bindings.ts:388 (SEALED_ROW_SERVED_OVERRIDE_TYPES)
A skill prompt's name: a face, else a bare name by the one rule packages/mcp/src/skill-prompts.ts:373 (lookupSkillPrompt)
The one face derivation packages/spec/src/ai/face-name.ts:86 (deriveAiFaceName)
The owner stamp's judge, and the pack's collection among those it judges packages/spec/src/kernel/collection-item-owner-stamp.ts:129, :107
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)
The one first-party declarer: two packs, two names, two roots examples/app-showcase/objectstack.config.ts:223, examples/app-showcase/src/ai/record-context.ai-context.ts:20, :30

Absence readings, each with a positive control:

  • ai_context in the four list files and in packages/metadata/src/package-slotted-store.ts: 0 lines each. Control: skill is in the first three lists, at the lines the table gives.
  • The skill key: packages/spec/src/ai/skill.zod.ts has 0 context: property lines. Control: 1 tools: line.
  • objectstack-ai/hotcrm at b1ea6fcc: ai_context, aiContexts or ai-context, 0 files. Control: skills:, 6 files.
Local gates at head deee29a: 21 derived, 21 run, all exit 0

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                      1222 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
0  node scripts/check-closing-keyword-parity.mjs --self-test
0  node scripts/check-comment-mask-corpus.mjs            23898 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
0  pnpm check:adr-index                                  docs/adr/README.md is current, every record parsed
0  pnpm check:adr-symbol-anchors                         4186 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, 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, so the index does not change and is not in this diff.

A dated addendum under D1 of ADR-0150 proposes that the context pack
type of ADR-0160 is identified by (package, name), as skill is. It adds
one dated row to the D1 table and an Amended clause to the status line,
and rewrites no ruled sentence. It says what the bucket changes for the
metadata service's copy, overlays, owner stamps and uninstall, names the
readers that move without moving any, names the one follow-up card, and
carries the interim rule: two parsed packs that share a name and a root
are refused with one answer.

ADR-0160 gains one cross-reference note under D1 and no changed
sentence. Docs only: no schema, no code, no changeset.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
… rest of its several-packs answer to it

Two sentences of the addendum, corrected against the tree. ADR-0160 is
on main: it merged the day before, and only its status keyword still
reads Proposed. And where the addendum says how the several-packs answer
spells a pack, it now changes the name's spelling alone and leaves what
else that answer carries to ADR-0160, so it holds whichever of the two
records is amended first.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzi13yZRqVcp2mGonWK
@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 github-actions Bot added size/s documentation Improvements or additions to documentation labels Nov 25, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract-review-claim: session_01WGufzgv2LZN1W2qSYTZvYs · head 1179369 · 2026-11-25T03:55Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 11793695f5096ad42bd1e2a192c1d0974d630cea
Local-runs: none
Scope: docs/adr/0150-behavioural-metadata-addressed-by-package-objects-keep-the-literal-prefix.md,docs/adr/0160-record-scoped-ai-inquiry.md + none
Security-touching: yes

Read for this record: card #37180 with its three comments, the PR body, the file list (two files, both hits), the net diff against main (+43 / -1), and the check-runs on the head. The cited code was read on origin/main at a33691e5. The branch was cut from 3b4f0b98; since then main gained PR #37173 (2a6f26a4) and PR #37196 (a33691e5). The head still merges cleanly into a33691e5.

Security-touching reads yes on purpose. The addendum decides which pack names a refusal of get_record_context may show a caller (its point 2, on ADR-0160 D4's naming bound). That is permission behaviour, though both paths are ADR files.

① Derived judgments

  • Accept-sets and published surface: none move. The diff is two files under docs/adr/. No schema, no code, no generated file, no changeset. PACKAGE_SCOPED_TYPES, PACKAGE_SCOPED_READ_TYPES, PACKAGE_SLOTTED_METADATA_TYPES and NAMESPACE_UNIQUE_TYPES are unchanged on the head, and none of them lists ai_context on main. Right: the card says docs and ADR only.
  • "No ruled sentence is rewritten": right. In ADR-0150 the one changed line is the status line, and the change is an appended clause. The D1 table gains one row, marked with its date; no ruled row is edited. In ADR-0160 two lines are added (one blockquote under D1) and none is changed.
  • The readers are named and not moved: right. The card names two readers: the context argument of get_record_context, and the skill key context (记录 AI 问询 8:技能键 context,MCP 技能提示词可带记录参数 #37141). The addendum names both and adds a third (the /meta doors and the service's store). The diff moves none.
  • What the addendum proposes for later is a narrowing, and it says so. D2's install refusal and the /meta by-name refusal for a name two packages hold are both assigned to the follow-up card, each with a measured count. Right as a declaration; nothing narrows in this PR.
  • Gate verdicts. Check-runs on the head: 27 success, 23 skipped, 0 failed, 0 pending. Check Documentation Links, Lint · docs & code guards, Check Changeset and Governed Surface Queue Guard are among the successes. The two runs that were still in progress when the dev reported have finished green.

② Semver level

No changeset, and none is owed: docs/adr/ ships in no package. The PR carries skip-changeset, and Check Changeset is green on the head.

Clause-②: no is right. Nothing published moves. Metadata-protocol: none is right for the same reason.

③ Boundary flags

The dev report carries three open_questions. Each is answered here, and each is judged in ④.

  1. How a model names a package's pack (dev recommends A: the NS-NAME face in context, no new key). Answer: A is sound. It is the maintainer's to accept, see S2.
  2. Which rule refuses a second holder in one namespace (dev recommends A: NAMESPACE_UNIQUE_TYPES). Answer: A is sound. It is the maintainer's to accept, see S2.
  3. Whether the root narrows the candidates before D3 picks (dev recommends A: yes). Answer: A is right, and ADR-0160 D4 already requires it. An approver may accept it.

Dev deviations that touch the hits files:

SQL push-down. No code is in the diff, so there is no new id materialisation and no in-app join.

Escalated to the seat. main moved under this PR after the dev measured it (S1). The follow-up card is named but not filed, and #37141 has no Blocked-by for it (nit N3).

④ Design judgment

docs/adr/0150 — the addendum, sentence by sentence against the tree.

These hold on a33691e5:

  • The metadata service keeps one copy per name for a type outside PACKAGE_SLOTTED_METADATA_TYPES. storeWriteKey answers { key: name } for such a type. skill is in the list and ai_context is not.
  • The one rule throws for a type outside PACKAGE_SCOPED_TYPES, in both resolvePackageScopedHolders and resolvePackageScopedName. skill is in that list and in PACKAGE_SCOPED_READ_TYPES.
  • unregisterPackage removes by slot only for a slotted type. For any other type it removes the one copy only when that copy is the package's.
  • The owner-stamp judge now lists aiContexts among its collections.
  • lookupSkillPrompt reads a face first, then a bare name as a caller with no package, and refuses with 409 RESOURCE_CONFLICT naming each candidate by its face. Reader 1 copies that order correctly.
  • D8 gains no row. ADR-0160 D6's focus holds an object and an id, and no pack name.
  • The interim rule is on main: packages/services/service-record-context/src/read-set.ts#selectContextPack never takes a first match.

(a) The NS-NAME face in context, with no new key. Sound.

  • It breaks no grammar. A pack name is ROUTER_ADDRESSABLE_NAME_PATTERN, which admits no -, and a namespace admits none. So a face never equals a bare pack name, and an uncut face splits at its only -.
  • It adds no member to ADR-0160 D4's strict input or to D8's argument object. The bucket-2 alternative (an optional namespace input, ADR-0150 D5's run_action form) would add one to each.
  • A model can learn the face without guessing. The several-packs refusal lists it, the 409 lists it, and a skill prompt hands it on.
  • A duplicate face is still possible in the shareable namespaces and past 64 characters. The addendum refuses it at the call, which is the only place left, since no list registers a pack's face.
  • It does extend D6. D6 was ruled for names a server lists (tool, skill, agent, object-less action). Here the face is the value of an argument. It also changes what context holds in ADR-0160 D4 and D8, from a pack's name to a face or a bare name. The addendum lists the point for the approver, which is the right place. See S2 for who may accept it.

(b) The second holder in one namespace, through NAMESPACE_UNIQUE_TYPES. Sound, and in scope for the addendum.

  • D2 as ruled already covers buckets 2 and 3: one package holder of a (type, name) inside a namespace. Once the type is in bucket 3, the rule applies by the ruled text. The face needs it too: NS-NAME names one pack only if the namespace holds the name once.
  • Child N's predicate is the right carrier. The type never had a phase-1 one-holder rule, so D9 has nothing to narrow, and N's rule refuses at every install and in os validate.
  • The alternative (phase 1's lists, as skill is carried) would refuse a second holder anywhere in the deployment. That is the opposite of what bucket 3 is for.
  • The header of packages/objectql/src/namespace-co-owner-names.ts reserves a new type to the maintainer. An ADR addendum is a fit place to ask, but only the maintainer's own hand answers it. See S2.

(c) The root narrows before D3 picks. Right, and it needs no decision of its own.

  • ADR-0160 D4 step 3 already selects among packs whose object is objectName, and gives one answer for a name no pack has and for a pack on another root. Judging over every holder of the name would break that sentence and the naming bound: a 409 would name a pack on an object the caller was never shown to be served.
  • ADR-0150 has the precedent in its own text. The cross-reference to ADR-0149 D2 under D5 limits the D3 candidates of the dataset arm to the holders the caller is admitted to.
  • It also keeps bare names working in the common case. Object names carry the package prefix (ADR-0129), so two packages' packs of one name are usually rooted on different objects, and each call reaches its own.
  • Reader 2 does not narrow by root, and should not: a skill names no object. It resolves by D3 from the skill's package and hands on the face. The two readers agree.

docs/adr/0160 — the cross-reference. Consistent with ADR-0160's own decisions on a33691e5, PR #37196's amendments included. D4's strict input gains no member. D4's step order is kept, since the root's gates still run before any pack is looked up. The #d4 and #d8 anchors exist, and the link into ADR-0150 resolves. The note says no sentence of ADR-0160 is changed, and none is.

Findings.

S1 (should-fix) — Six sentences of the addendum are false on the tree this PR merges into. They were true at 3b4f0b98; main is now a33691e5.

The first two sit under a heading pinned to 3b4f0b98, so they are an honest reading of an old tree. The others are not pinned. Fix: re-measure on current main and reword. It is prose only.

S2 (should-fix) — The addendum lets "an authorized approval" be the ruling for all three of its extra points. Two of them are the maintainer's alone.

  • Point 3 admits a type into NAMESPACE_UNIQUE_TYPES. That list's header says a narrowing beyond its twelve types is the maintainer's to rule.
  • Point 1 changes what a model types in context, and extends D6, which the maintainer ruled (Q1 = A). ADR-0160 held its own user-visible points for the maintainer's explicit acceptance.

Fix: say in the addendum that points 1 and 3 take the maintainer's own merge or word, and that point 2 follows from ADR-0160 D4. The PR is draft and is to be merged by the maintainer, so the landing path is already right. The record's text should not be wider than that path.

Nit N1 — The interim rule says "refused with one answer, whether context names them or is omitted". With context omitted and a third pack of another name on the root, selectContextPack answers several (400), listing the shared name once. The 409 is given only when the shared name is the only name. No first match is taken in either case, so the guarantee holds; the words "one answer" are too strong.

Nit N2 — "Overlays" says a package-less row under a name one package holds "is that holder's customization", one sentence after saying a pack takes no environment overlay. It does not say whether that row is served. On main, a sealed type's package-less row over a managed package's name stays unserved unless the type is in SEALED_ROW_SERVED_OVERRIDE_TYPES (packages/metadata-protocol/src/protocol-package-bindings.ts), and ai_context is not. The rule is also read at (type, name), while selection narrows by root. So an environment pack on another root stops being a pack when a package that holds its name installs. That is ruled D4, as for skill. The follow-up card should state it and measure it.

Nit N3 — The follow-up card is named and not filed. Row 8 (#37141) must wait for it, because the resolver throws for a type outside PACKAGE_SCOPED_TYPES. ADR-0160's split still shows row 8 blocked by row 5 alone, and #37141 has no Blocked-by for the follow-up. The seat files the card and adds the relation.

Nit N4 — The D6 bullet rests on a pack name holding no -. D6's own grammar check does not list the pack schema. One anchor to packages/spec/src/kernel/address-grammar.ts#ROUTER_ADDRESSABLE_NAME_PATTERN would close it.

No must-fix. Two should-fix, S1 and S2, both prose in docs/adr/0150. They earn a delta review of their fix.

Implemented-by: claude/issue-37180-ai-context-package-scope-adr
Reviewed-by: session_01WGufzgv2LZN1W2qSYTZvYs

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

席位核对 — REWORK · repo:objectstack#3 · head 1179369 · 2026-11-25T04:04Z

L1: REWORK (L1-w, zone ai-A)
Head-sha: 11793695f5096ad42bd1e2a192c1d0974d630cea

The L2 at CONTRACT_REVIEW_TIER on this head is PASS with two should-fix findings open: comment 7152486548, claim 7152378467. Under the merge standard both are fixed and re-read before the hand-over, so this head is REWORK. Tier H (governed docs/adr/**). After a final ACCEPT plus a same-head L2 PASS, it goes to the seat for the maintainer. Never ready, queue or arm it here.

Should-fix (from the L2, adopted)

Nits (prose face; fix any in the same push, else each is an accepted deviation or a follow-up card)

L2 N1–N4 are in the record:

The seat's three questions (answered from the L2, which I adopt)

  • (a) NS-NAME via the face derivation, no new key. Sound: a pack name admits no -, so a face never equals a bare name, and nothing is added to D4's input or D8's arguments. It is in scope for an addendum, but it widens D6, so it is the maintainer's to accept (S2).
  • (b) A second holder refused through NAMESPACE_UNIQUE_TYPES. Sound, and in scope, since D2 as ruled already covers bucket 3. The list header reserves new types to the maintainer, so it needs the maintainer's own hand (S2).
  • (c) The root narrows before D3 picks. Right, and it needs no decision of its own. ADR-0160 D4 step 3 and its naming bound already require it.

Read and found right (head 1179369)

  • l1-face --pr 37209: 13 items clean or not yet measured. Draft, base main. Fixes #37180 binds only this card. skip-changeset is right: no published package is touched. The declarations are Clause-②: no · Metadata-protocol: none. At my read, CI had 24 success, 0 failed and 2 pending. The L2 later read 27 success, 23 skipped and 0 failed. mergeable_state was not yet computed at my read; the L2 reports the head merges cleanly into current main.
  • Fixes is right, once the findings close. The card asks for an ADR-0150 addendum putting ai_context in the package-scoped bucket beside skill, docs and ADR only, naming the readers that must move without moving them. The diff touches only the two ADRs, adds one dated D1 row and an addendum, rewrites no ruled sentence, and names readers 1–3 with "⛔ This addendum moves none."
  • Citations. All ten code paths and symbols the addendum cites exist in the tree. The anchors #d4 and #d8 resolve to ADR-0160's {#d4} / {#d8} headings. #addendum-2026-11-25-ai_context-joins-bucket-3 matches the new heading's slug.
  • The ADR-0160 cross-reference changes no sentence of that record, and the L2 finds it consistent with ADR-0160 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.

Path to final ACCEPT

  1. Card thread: one prose push for S1 and S2, plus any nits.
  2. Zone: file the follow-up card (N3) and add Blocked-by on 记录 AI 问询 8:技能键 context,MCP 技能提示词可带记录参数 #37141.
  3. L1-w: a new claim, the same L2 reviewer reads the delta, and I read the L1 delta.
  4. Then the seat hands it to the maintainer as Tier H.

…re the maintainer's alone

The addendum's reading of the tree was taken before the context pack
type, its tool and the ADR-0160 amendment landed. Every "today" sentence
is re-measured on current main and reworded: the type and the pack
selection are cited as merged code, the showcase app's two packs are the
one first-party declarer and are not refused, and the follow-up card is
named with its order before the skill key.

The record now says who rules what. The face spelling in the context
argument widens D6, and admitting the type to the namespace-unique list
is reserved to the maintainer, so the addendum is ruled by the
maintainer's own merge or word. That the root narrows the candidates is
stated as following from ADR-0160 D4, not as a new decision.

Review nits folded in: the interim rule no longer says "one answer"
where an omitted context with a third pack gets the several-packs
answer; the overlays bullet says a package-less row under a shipped name
is not served; the no-hyphen premise of the face is anchored.

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

Contract-review-claim: session_01WGufzgv2LZN1W2qSYTZvYs · head deee29a · 2026-11-25T05:53Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: deee29af32843420324bd0fa974337161838ba5f
Local-runs: none
Scope: docs/adr/0150-behavioural-metadata-addressed-by-package-objects-keep-the-literal-prefix.md,docs/adr/0160-record-scoped-ai-inquiry.md + none
Security-touching: yes

Delta review of 11793695..deee29af, under claim comment 7154249113. It follows my record on 11793695 (comment 7152486548), which left S1 and S2 open and four nits, N1 to N4. The delta is a merge of main (0a1b69c0, as 783de611) and one prose commit over the two hits files. Against main the PR is still those two files, +44 / -1.

Read for this record: card #37180 and its thread, the PR body, the file list, the delta and the net diff, card #37216, and the check-runs on the head. The cited code was read on origin/main at a03c3d4e. That is one commit past the 0a1b69c0 the addendum is measured on, and that commit touches none of the cited paths.

Security-touching stays yes. The addendum still decides which pack names a refusal of get_record_context may show a caller.

① Derived judgments

  • Accept-sets and published surface: none move. The diff is two files under docs/adr/. ai_context is in none of the four lists on main, and the head changes no list. Right.
  • "No ruled sentence is rewritten": still right. In ADR-0150 the one changed line is the status line, and the change is one appended clause. The D1 table gains one dated row. In ADR-0160 one blockquote is added and no line is changed.
  • The readers are named and not moved: still right. The delta moves none.
  • Gate verdicts. Check-runs on the head: 27 success, 22 skipped, 0 failed, 0 pending. Check Documentation Links, Lint · docs & code guards, Check Changeset and Governed Surface Queue Guard are among the successes, so the two new symbol anchors resolve.

② Semver level

No changeset, and none is owed: docs/adr/ ships in no package. The PR carries skip-changeset, and Check Changeset is green on the head. Clause-②: no and Metadata-protocol: none are right.

③ Boundary flags

④ Design judgment

Closures, each read against origin/main.

S1: closed. The addendum is re-measured on main at 0a1b69c0, and every reworded sentence holds:

  • ADR-0160's status line reads Accepted.
  • The type and the pack selection are on main under the anchors cited: packages/spec/src/ai/ai-context.zod.ts#AiContextSchema and packages/services/service-record-context/src/read-set.ts#selectContextPack.
  • The skill key context is not in packages/spec/src/ai/skill.zod.ts.
  • ai_context is in none of the four lists.
  • The owner-stamp judge lists aiContexts.
  • The first-party count is right. examples/app-showcase is the one declarer: one package, two packs (showcase_project_brief on showcase_project, showcase_task_notes on showcase_task). objectstack-ai/hotcrm at b1ea6fcc holds no aiContexts.
  • No sentence still speaks of PR feat(ai): ai_context context packs and the get_record_context tool over MCP (ADR-0160 row 5) #37173 as open, or of 3b4f0b98.

S2: closed. The status clause and the addendum's opening both say the ruling is the maintainer's alone, by the maintainer's own merge or word. The D2 bullet and point 3 say that admitting a type to NAMESPACE_UNIQUE_TYPES is the maintainer's decision; that list's header still reserves it. The D6 bullet and point 1 say that a face as the value of an argument widens D6, and that context in ADR-0160 D4 and D8 then holds a face or a bare name. Point 2 is stated as no new decision, with ADR-0160 D4's step 3 and naming bound as its source. That matches D4's text on main.

N1: closed. The interim rule now matches selectContextPack case by case. A context that names the shared name answers duplicate (409). An omitted context answers duplicate when that is the only name on the root. It answers several, with the name listed once, when the root has another name. No branch takes a first match.

N2: closed. "Overlays" now says a package-less row under a name a package ships is not served. That is true on main: isSealedManagedItem holds for an item a package ships whose type opens no overlay channel, declinesStoredRow then declines the stored row, and the only exceptions are action and SEALED_ROW_SERVED_OVERRIDE_TYPES, which does not list ai_context. It also says the rule is read at (type, name) whatever the root, and gives #37216 the measurement.

N3: closed. Card #37216 exists and is open. It is what the text says: it adds ai_context to the four lists, moves the pack selection, declares the narrowings with counts, carries the overlay consequence, is blocked by #37209, and is to land before #37141. The addendum and the ADR-0160 note both name it.

N4: closed. The D6 bullet cites packages/spec/src/kernel/address-grammar.ts#ROUTER_ADDRESSABLE_NAME_PATTERN. The pack schema's name uses that pattern, and it admits no -.

New sentences in the delta. Each was read against the tree, and none is false.

The three points beyond the card. My judgment of the first round stands, and the delta changes none of the three designs. The face in context is sound. NAMESPACE_UNIQUE_TYPES is the right carrier for D2's refusal. The root narrowing follows from ADR-0160 D4. The addendum now puts the first two before the maintainer by name, which is where they belong.

No must-fix, no should-fix.

Implemented-by: claude/issue-37180-ai-context-package-scope-adr
Reviewed-by: session_01WGufzgv2LZN1W2qSYTZvYs

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

席位核对 — ACCEPT · repo:objectstack#3 · head deee29a · 2026-11-25T05:57Z

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

No must-fix, no should-fix. The L2 at CONTRACT_REVIEW_TIER on this head is PASS with nothing open: comment 7154290067, claim 7154249113. It closes S1, S2 and N1–N4 of 7152486548. This PR is Tier H, because it touches governed docs/adr/**. It goes to the seat for the maintainer. ⛔ Never ready, queue or arm it here.

Delta 11793695..deee29af

The delta is a merge of main (783de611), then one prose commit. The net diff against main is still the two ADRs, +44/−1.

  • L2 S1 closed. "The tree today" is re-measured on 0a1b69c0:
    • ADR-0160 is Accepted;
    • row 5 has landed, with AiContextSchema and selectContextPack cited;
    • the skill key context has not landed (row 8);
    • ai_context is in none of the four lists;
    • the first-party count is restated against the showcase's two packs on two roots, and none in hotcrm b1ea6fcc.
  • L2 S2 closed. The opening paragraph and the status clause now make the addendum "the maintainer's alone to rule". Points 1 (the NS-NAME face as an argument value, widening D6) and 3 (admitting a type to NAMESPACE_UNIQUE_TYPES) are each marked "the maintainer's decision". Point 2 is stated as following from ADR-0160 D4, with D4's own step 3 and naming bound quoted.
  • Nits closed:
  • l1-face --pr 37209: 13 items clean. 27 success, 22 expected skips, 0 failed, 0 pending. mergeable_state clean. skip-changeset is right: no published package is touched.

Round 1's reads still stand: Fixes #37180, the citations and anchors, and an ADR-0160 note that changes no sentence of that record.

For the seat at hand-over

The maintainer's merge rules on the whole addendum. Points 1 and 3 under "Past the card's words" are the two decisions it asks of the maintainer by name. Row 8 (#37141) is blocked by #37216, and #37216 is blocked by this PR.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

维护者速读

Request: approval · Tier H by governed path (docs/adr/** ×2) · 2026-11-25T05:58Z

Seat's view: land. This is the ADR-0150 addendum that #37180 asks for. It puts ai_context in the package-scoped bucket beside skill, with a cross-reference note under ADR-0160 D1. It edits no code and moves no reader.


Generated by Claude Code

@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 06:08
@os-zhuang
os-zhuang enabled auto-merge November 25, 2026 06:08
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 6211ddf Nov 25, 2026
55 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-37180-ai-context-package-scope-adr branch November 25, 2026 06:29
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…mit (row 11 contract) (objectstack-ai#37240)

<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBEaJzgBWzjWCNjBjkVoeRto)_

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

Fixes objectstack-ai#37202

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 用户能看到什么变化:现在用户无感(只改决定记录,不改代码);规则是给 AI
的记录资料包里,关联列表可以只带挑出来的行、按指定顺序排、限定条数(例如只带当前生效的那一版),筛选不增加任何权限,筛选或排序用到提问人不能据以查询的字段(看不到的、值被收起的、只显示掩码的)时整段省略并说明有资料不可见、不点名字段;要等后续实现卡
objectstack-ai#37203(把这三个写法和读取它们的服务一起做出来)合并后才真正生效。
- 为什么做:属于「按记录向 AI 提问」这一大项,你 11 月 25 日已同意关联列表的筛选和排序,这里把它写成成文规则,后面的实现照着做。
- 出错会怎样:规则写错的话,后面的实现会照着错的做,碰到的是写资料包的人和用它提问的人;这次只有文档,撤回这次合并即可。
-
要你做什么:审后由你本人合并(合并即批准);你的原话只说了筛选和排序,其余十处是记录自己补全的决定,已在记录的「超出卡面原话的几点」一节逐条编号列出(第
13 到 22 点,下文英文部分也有一份),不同意哪条可以先划掉再合并。

## What changes

One file under `docs/adr/`: `0160-record-scoped-ai-inquiry.md`, 55 lines
added and 13 removed against `main`. No schema, no code, no changeset.

This is ADR-0160's second amendment. It records the maintainer's word of
2026-11-25, verbatim: 「related 的筛选和排序 同意」 (the thread of epic objectstack-ai#36996,
card objectstack-ai#37202). The first amendment (PR objectstack-ai#37196) had left filter and order
on `related` as a separate protocol decision.

- **Header.** A second `Amended:` bullet quotes the maintainer and lists
what the amendment records. It says the maintainer's word names filter
and order and no more, and it names each of the ten additions with its
point number. The `Status:` line is byte-identical, so the generated
`docs/adr/README.md` does not change and is not in the diff.
- **D1.** A `related` entry gains `where`, `orderBy` and `limit`, on the
child's own fields only.
- `where` uses the platform's object filter form with ten operators
(`$eq`, `$ne`, `$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$null`,
`$exists`), joined by `$and` / `$or`. A bare value is read as `$eq`. It
follows no relation and takes no field-to-field comparand, no `$now`
anchor, no formula and no whole `{token}` placeholder. Anything else is
refused at parse.
  - `orderBy` is `{ field, order }[]`.
- `limit` is a positive integer, at most the service's row cap for one
related list.
- The three keys leave "Later work". Placeholders resolved at call time
join it.
- The keys are declared here and land with their reader in row 11. Until
then the schema on `main` refuses them.
- **D3.** The filter and the order run inside the caller's one capped
child query and grant nothing. A `related` entry whose `where` or
`orderBy` names a field the caller cannot query on is dropped whole,
with the statement that some material is not visible, and the field is
never named.
- **D4.** The read set is unchanged: the three keys add no object to it.
- **Points that go past the card's words.** Points 5 and 11 are updated.
Points 13–22 are new and list every place where the amendment goes past
the maintainer's word and the card.
- **Implementation split, Consequences.** The split gains row 11 (card
objectstack-ai#37203). Consequences counts a fourth protocol addition.

### Round 2, at `1cd00b0d`

The contract review of the first head passed with three should-fix
findings (comment 7154648352, adopted by the seat in 7154665327). This
head answers them.

- **S1.** D3 said "a field this caller cannot read". It now says "a
field this caller cannot query on" and defines it as every field outside
the security service's `getQueryableFields` answer. That takes in the
field served masked and the field an agent's ceiling withholds, which
the engine's guard also refuses. Both symbols are anchored.
- **S2, by the seat's ruling for this text.** A bare value such as `{
is_current: true }` is admitted and read as `$eq`. A comparand that is
one whole `{token}` placeholder is refused at parse in v1, beside the
`$now` anchor, and placeholders resolved at call time are later work.
- **S3.** The `Amended:` bullet no longer says that one sentence goes
past the maintainer's word. The record's own section now carries points
13–22, and point 11 covers `where` and `orderBy`.
- **Nits applied where they touch this text.**
- The refusal that the rule avoids is named as the security plugin's
engine middleware, not the data engine.
- "The body" says an outline is cut by the body bound or by the entry
cap. PR objectstack-ai#37222 has merged, so the entry cap is now anchored on `main`.
- A door whose own page cap is lower than a `limit` that parsed cuts the
list there, and the cut is stated.
- Row 11 may bound the size of a `where` at parse; this record sets no
number.
- **Not changed, by the review's own word.** The link-field sentence
beside the new one still says "that caller's schema hides". The review
asks for a follow-up card to carry it.

The branch also merged `main` at `6211ddf4`, with no conflict. That
brought the note PR objectstack-ai#37209 added to D1 and the outline cap of PR objectstack-ai#37222.

## Tests

This PR changes a record only. No test is added or changed, and nothing
is ablated. The readings the text rests on were re-taken on `main` at
`6211ddf4`. The branch head is `1cd00b0d`, and every local gate below
ran on that head.

<details><summary>What the schema on main does with the three keys and
with the sort direction</summary>

A probe parsed a pack through `AiContextSchema` and a sort node through
`SortNodeSchema`. It ran with `tsx` from the scratchpad and is not
committed.

```text
CONTROL (no new key) success = true
related[].where: success = false | unrecognized_keys @ related.0: Unrecognized key(s) on a context pack `related` entry: `where`.
related[].orderBy: success = false | unrecognized_keys @ related.0: Unrecognized key(s) on a context pack `related` entry: `orderBy`.
related[].limit: success = false | unrecognized_keys @ related.0: Unrecognized key(s) on a context pack `related` entry: `limit`.
SortNode { field, order }: success = true
SortNode { field, direction }: success = false | unrecognized_keys: Unrecognized key(s) on this sort node: `direction`. Did you mean `direction` → `order`?
```

Each message is cut after its first sentence. The control row shows that
the probe pack parses without the new keys, so each refusal is the key's
own.

</details>

<details><summary>The anchors this round adds, resolved one by
one</summary>

`symbolResolutionClass` from `scripts/symbol-anchors.mjs`, asked for
each new anchor and for one name that does not exist:

```text
declaration  packages/spec/src/contracts/security-service.ts#getQueryableFields
declaration  packages/plugins/plugin-security/src/security-plugin-object-inputs.ts#computeQueryGuardFieldPerms
declaration  packages/plugins/plugin-security/src/predicate-guard.ts#assertReadableQueryFields
declaration  packages/spec/src/data/context-tokens.zod.ts#FILTER_TOKEN_WRAPPED_RE
declaration  packages/core/src/utils/filter-tokens.ts#resolveFilterTokens
declaration  packages/services/service-record-context/src/body-outline.ts#RECORD_CONTEXT_OUTLINE_MAX_ENTRIES
null         packages/spec/src/contracts/security-service.ts#noSuchSymbolControl
```

</details>

<details><summary>Local gates at 1cd00b0: 21 derived, 21 run, all exit
0</summary>

`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived the same 21 commands as on the first
head. Each exit code was captured before any pipe, and `--ran`
reconciled the list:

```text
✓ 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).
```

The gates that read this file printed:

```text
✅ check-adr-links: 1222 relative link destination(s) under docs/adr/ resolve
✅ check-adr-symbol-anchors: 4199 anchors across 163 records resolve — 1416 symbol (1387 declaration, 29 literal), 2731 file-level, 52 cross-repo, 6 exempt, 96 continuation.
adr-index --report: OK — docs/adr/README.md is current, every record parsed, self-test 60 assertions green.
check-nul-bytes: OK (scanned 27783 text file(s) -- 27783 tracked, 0 untracked-not-ignored; skipped 101 binary; no raw ASCII control bytes).
```

The other 17 are `check-adr-links --self-test`, `check:adr-anchors`,
`check:doc-authoring`, `check:pm-governed-merges`,
`check:pm-prior-rulings`, `check:closed-ceremony-text`,
`check-closing-keyword-parity` and its self-test,
`check-comment-mask-corpus`, `check:cross-package-test-inputs`,
`check:ci-filter-parity`, `check:driver-memory-census`,
`check:gitlink-declared`, `check:refd-timer-probe`,
`check:watch-hint-literal`, `plan-test-core-shards --self-test` and
`check:doc-formula-expressions`.

`check:doc-formula-expressions` reads the compiled output of
`@objectstack/formula` and `@objectstack/lint`. Both were built first
under the shared verify lock (`VERDICT command-exit 0`).

`node scripts/adr-index.mjs` answered `unchanged docs/adr/README.md (250
lines)`.

`node scripts/pm/overlap-check.mjs` answered `VERDICT clean exit 0`
before each push.

</details>

Every family that CI runs is read from this PR's check-runs. None of
them is re-run locally.

## Acceptance notes

**Governed surface (Tier H).** `docs/adr/**` is governed. The
maintainer's merge is the record. No seat readies, queues or arms this
PR.

**These decisions are listed for the maintainer.** The maintainer's word
names filter and order on `related`. Everything below is the record's
own settlement, accepted or struck by the merge. Each is a numbered
point in the record's "Points that go past the card's words" section,
and any one can be struck without touching the rest.

| Point | Decision | Where it comes from |
|:--|:--|:--|
| 13 | `related` takes `limit` as well as filter and order. | The card
names it; `get_record`'s `related` already takes one. |
| 14 | A `limit` over the row cap is refused at parse. Row 11 declares
one number that the schema and the service both read. | The pack's other
bounds, and `get_record`'s own `related` limit. |
| 15 | `where` admits ten operators, joined by `$and` / `$or`. `$not`,
`$between`, `$empty`, the string-match operators, relation conditions,
`{ $field }` and `$now` are refused. | The card says "a small operator
set" and names none. |
| 16 | A bare value is read as `$eq`. | The seat's ruling on review
finding S2. |
| 17 | A whole `{token}` comparand is refused at parse. Placeholders
resolved at call time are later work. | The seat's ruling on review
finding S2. |
| 18 | `orderBy` is `{ field, order }[]`. | `SortNodeSchema` on `main`
refuses `direction` by name. |
| 19 | A `where` or `orderBy` field the caller cannot query on drops the
section, stated and never named. | Review finding S1. The card says
"hidden". |
| 20 | A `where` or `orderBy` field the published definition lacks
leaves the section out, and the answer states nothing. | The record's
rule for author defects. |
| 21 | A list cut at its own `limit` is a stated cut. | The record's
rule that every cut is stated. |
| 22 | D3, "The body", names the cap on an outline's entries. | Not
about `related`: carried from the review of PR objectstack-ai#37222, nit N5. |

**Sections touched beyond the card's list, all in the one claimed
file:** the author-defects paragraph and "Later work" in D1, "The body"
in D3, the "Points" section, the intro and the two paragraphs under the
Implementation split table, and one line of Consequences.

**Seen and not changed here** (read on `main`, not exercised through a
public door, so not filed):

- Row 5's service still refuses the whole call when a `related` child is
not served to this caller. The first amendment says that child is left
out and the answer says so.
- The link-field rule in D3 still says "that caller's schema hides". A
link field that the schema shows and the caller cannot query on would
reach the engine's guard, which refuses the whole call. The review asks
for a follow-up card.
- Card objectstack-ai#37203's example spells the sort direction `direction`, and its
item 3 says "hidden". Both now differ from the record.
- The `ai_context` schema's guidance text for a stray `filter` key says
a related list reads every child row the caller may read. Row 11 has to
reword it.

## Verification

Read first, by risk. All three are in
`docs/adr/0160-record-scoped-ai-inquiry.md`:

1. **D3, "Field level", the bullet "The hidden field is one the pack
uses structurally".** This is the disclosure rule: which callers lose
the section, and what the answer may say. Round 2 rewrote its middle.
2. **D1, the `where` bullet under "Filter, order and limit on a related
list".** This is the contract row 11 implements: the operator set, the
bare value, and the comparands refused at parse.
3. **"Points that go past the card's words", points 13–22, and the
header's second `Amended:` bullet.** They say which parts are the
maintainer's word and which are the record's own.

Two-minute check: run `pnpm check:adr-symbol-anchors`. It should exit 0
and print a line that starts `✅ check-adr-symbol-anchors:`. That line
means every symbol the text cites is declared at the path the text
names. At this head it counts 4199 anchors across 163 records.

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

<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzi13yZRqVcp2mGonWK -->

---------

Co-authored-by: Claude <noreply@anthropic.com>
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
…xt pack is identified by its package and its name; get_record_context selects a pack by its face on both MCP doors (objectstack-ai#37291)

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

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

## What changes
ADR-0150's addendum (PR objectstack-ai#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
objectstack-ai#37255's `stripReadDecorations` listing, unchanged.
- **The several-packs answer** (triage row 7154571964, ADR-0160 D4 step
3 as amended by objectstack-ai#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` (objectstack-ai#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
- **Owed item 3 of the hand-off is folded into this PR.** Both doors'
`packageNamespace` (`packages/runtime/src/domains/mcp.ts`,
`packages/mcp/src/stdio-data-bridge.ts`) waited for PR objectstack-ai#37255 (objectstack-ai#37243),
which edits the same `listContextPacks` regions. It landed after objectstack-ai#37255
merged: `main` was merged in at `057cedfa` (no rebase), and the doors
were built on its `stripReadDecorations` listing (commit `1deea31f`).
- `record-context-tools.zod.ts`'s `context` describe still says "by
name"; the addendum makes it a face or a bare name. Noted for objectstack-ai#37141,
which owns that key.
- The contract review at CONTRACT_REVIEW_TIER
(`packages/spec/src/api/protocol.zod.ts`) is run by the zone, not here.

## Verification
<details><summary>Local readings</summary>

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 objectstack-ai#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 objectstack-ai#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.
</details>

<details><summary>Gate sweep (dispatch-gates --commands)</summary>

`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)`.
</details>

<details><summary>Dogfood battery</summary>

Head `74085439` (the current head; the os-dev-report is objectstack-ai#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.)
</details>

**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 (「objectstack-ai#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.com/claude-code)

https://claude.ai/code/session_01QSeKYpEsWWE9Y5YtSsDgqZ

---------

Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…nd a related-lists block scoped to each child (objectstack-ai#37315)

<!-- claude-projects-attribution: {"github_login":"os-alice"} -->
_Requested by **Alice** · [project
thread](https://claude.ai/code/project/chan_01NoziMoftaSPmzgKNjJGePH?thread=cmsg_01NoziMoftaSPmzgKNjJGePH8HwrkPJDQVtqCcoED6n6og)_

Fixes objectstack-ai#37143

Clause-②: yes (widening) — one new public export, `aiContextForm` from
`@objectstack/spec/ai`, and `/meta/types` now serves a form for
`ai_context`; no key is added to what a pack may hold
Metadata-protocol: none

## 维护者速读

- 用户能看到什么变化:应用作者在 Studio
里可以新建、编辑资料包:选根对象和它的字段,选指向它的关联列表并为每个列表选列,选正文字段,再保存发布。
- 为什么做:记录 AI 问询专题的第 7 步,让资料包不必写在代码包里(运行时可编辑)。
- 出错会怎样:最坏是编辑界面选项不对或保存被拒;已有的资料包和对象的关联列表编辑不受影响,可以直接撤回。
- 要你做的:无。

## What changes

ADR-0160 D1, clause 2 (runtime authoring). The type was already
registered with `allowRuntimeCreate: true` and its author defects are
already reported at save (`validateAiContext` on the runtime publish
door); what was missing was a form, so Studio's generic metadata editor
had nothing to lay a pack out with.

- **`aiContextForm`** (`packages/spec/src/ai/ai-context.form.ts`,
exported from `@objectstack/spec/ai`, registered as `ai_context` in
`METADATA_FORM_REGISTRY`), by the `skill.form.ts` precedent. Two
sections: Basics (`name`, `label`, the root `object` through
`ref:object`) and Material (`fields` as `field-multi` with `dependsOn:
'object'`, the `page.form.ts` precedent; `related` as
`related-list-entries` with `dependsOn: 'object'`, the `object.form.ts`
precedent; `body` as a composite whose `field` is a `field-ref` over the
root). The form names every top-level key `AiContextSchema` accepts and
no other (the registry-wide reconciliation test).
- **The `related-list-entries` block learns the pack's entry shape**
(`ui/packages/app-shell/src/views/metadata-admin/ContextPackRelatedEntries.tsx`).
A pack entry is `{ object, field?, fields? }`, not the object form's
bare name or `{ list, label?, columns? }`, so the block now tells the
two apart by the entry schema it is handed (`items.properties.object`),
never by the type's name:
- the add picker offers every reference field of a served object whose
target is the root, resolved with the spec's own `REFERENCE_VALUE_TYPES`
and `referenceTargetOf`, the link `validateAiContext` resolves (a
self-reference and each of a child's several links included); a pick is
written `{ object, field }`;
- each entry's columns are picked from THAT child object's fields
(`useObjectFields`, draft-overlaid), never the root's;
- it stops at the schema's `maxItems` (3 lists, 10 columns), and an
emptied list or column set removes its key (both arrays are `minItems:
1`);
- a stored entry the catalog shows no link for is kept and marked; the
save-time report is its judge.
- The object form's `relatedLists` keeps its chip face, unchanged
(`RelatedListNameEntries`, the old body).
- while the object list is loading, or after it failed
(`getTypeStatus('object')`), no stored entry is marked unlinked and the
add picker says loading / could not load, never "no reference field".
- **An emptied picker removes its key** (L2 review on this PR, S1).
Removing the last chip of a `field-multi` whose schema has `minItems >=
1` (the pack's `fields`) removes the key instead of writing `[]`; in a
composite, a cleared sub-field drops its key (as `setField` already does
at the top level), and a composite left empty while its schema requires
a key that has no default is removed (the pack's `body` after "None")
instead of written as `{ field: '' }`. A composite whose required keys
all carry a default keeps `{}` (S3: `/meta/types` serves the output
derivation, which lists a defaulted key as required; a view's
`pagination: {}` and `selection: {}` are read by their presence). Both
were drafts the save door refuses with no way back in the form.
`SchemaForm.tsx` (`compositeWith`) and `widgets.tsx`
(`emptyArrayRefused`).
- **Words**: eleven `engine.form.contextPack.*` keys in the studio
namespace (en, zh); the platform's `metadataForms.ai_context` bundles
regenerated (`node scripts/check-i18n-bundles.mjs --write`), with the
zh-CN leaves translated by hand, and the console's zh-CN overlay rows
(`metadata-form-zh-cn.ts`) copied from them.
- `api-surface/ai.json` and `export-origins/ai.json` regenerated for the
one new export.

objectstack-ai#37180's outcome, read for the soft dependency: PR objectstack-ai#37209 (merged by the
maintainer) puts `ai_context` in ADR-0150's package-scoped bucket beside
`skill`. A pack created in Studio is therefore saved the way a skill
created in Studio is, into the package the editor is working in; nothing
in this PR picks a package for it, and the reader move is objectstack-ai#37216.

## Tests

- `packages/spec/src/ai/ai-context.form.test.ts`: the registry entry,
the identity rows, and every picker scoped by `object`.
-
`ui/packages/app-shell/src/views/metadata-admin/ContextPackRelatedEntries-37143.test.tsx`
(12): the four rework pins (loading / idle / error catalog marks
nothing; the pack's last root field removed writes no key; an array
without `minItems` still writes `[]`; "None" for the body removes
`body`, a composite requiring nothing keeps `{}`), and the original
eight: the schema discriminator; the links offered (four, the
self-reference and both links of one child, an unrelated object absent);
a pick written as `{ object, field }`; columns offered from the child,
not the root; column and list removal dropping their keys; an unlinked
stored entry kept and marked and a listed link not offered again; the
bound and the no-root state; the host id on the add picker. Every value
the block writes is parsed with `AiContextSchema`.
- `RelatedListEntriesWidget-35923.test.tsx` (the object form's face)
still passes unchanged.
- `openPathObjectReaders-12811.test.ts` (app-shell console): one row,
`ContextPackRelatedEntries.tsx` classified `off` among the readers of
`useMetadata().objects` (the block reads the served object list for its
link catalog and is mounted only in the metadata admin, never on an
app's object-list open).
- `bare-type-display-echo-decisions.test.ts` and
`object-lifecycle-panel-echo-decisions.test.ts` (platform-objects):
literal counts and a dated comment row only, because `ai_context` now
has a form and its eighteen leaves are authored in zh-CN, ja-JP and
es-ES (surface widened by the seat, claim amendment 1).

<details><summary>Local runs (head 4b6929e)</summary>

- `pnpm --filter @objectstack/spec test`: exit 0. `pnpm --filter
@objectstack/spec typecheck`: exit 0.
- `pnpm --filter @objectstack/platform-objects test`: Test Files 126
passed (126), Tests 2161 passed (2161). typecheck: exit 0.
- `ui`: `pnpm exec vitest run
packages/app-shell/src/views/metadata-admin/
packages/app-shell/src/__tests__/`: Test Files 824 passed (824), Tests
9036 passed, 1 skipped. `packages/i18n/`: Test Files 111 passed (111).
The rest of app-shell's suite is left to `Test UI` (a full local run did
not finish in 54 minutes on the shared box and was stopped).
- Ablation, once: the pack branch of `RelatedListEntriesWidget` disabled
(`if (false && isContextPackEntrySchema(schema))`, written and restored
by `scripts/ablation-replace.mjs`, blob equal to HEAD after restore)
turns the new file red, 7 failed of 8; the one that stays green is the
helper-only case.
- `node scripts/check-i18n-bundles.mjs`: exit 0, every bundle in sync.
`pnpm --filter @objectstack/spec check:generated`: api-surface and
export-origins regenerated with `--fix`, then clean.
- After the merge of `main` and the reader-table row:
`packages/app-shell/src/console/__tests__/openPathObjectReaders-12811.test.ts`
3/3 (it was the one red file of `Test UI (15/16)` at 7d37a1d); spec 894
files and platform-objects 126/2161 green again after the merge.
- `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack
--ran`: at 4b6929e, 93 derived, 92 run, 1 NOT-MEASURED (exit 3,
prerequisite not met here: `check-plugin-teardown-shape.mjs
--self-test`), 0 UNRUN.
- CI at 3a215ad: 59 success, 10 expected skip, 0 failed. At 6ada5fd:
57 success, 10 expected skip, 2 failed (`Test UI (5/16)` and its
aggregator), the one failure
`packages/auth/src/__tests__/AuthProvider.test.tsx` (objectstack#36972
pin, `mounts` 2 vs 1), in a package this PR does not touch; it passed 3
of 3 runs locally at 6ada5fd. At 4b6929e: 59 success, 10 expected
skip, 0 failed.
- Rework (6ada5fd): `ui` `pnpm exec vitest run
packages/app-shell/src/views/metadata-admin/
packages/app-shell/src/console/__tests__/openPathObjectReaders-12811.test.ts`:
Test Files 800 passed (800), Tests 8588 passed, 1 skipped. Ablation, one
at a time with `scripts/ablation-replace.mjs` (blob equal to HEAD after
each restore): the `field-multi` prune off, the composite's
empty-required prune deleted, the catalog state forced `ready`; each
turns exactly its own pin red (1 failed of 12).
- Rework 2 (4b6929e): `ui` `pnpm exec vitest run
packages/app-shell/src/views/metadata-admin/`: Test Files 799 passed
(799), Tests 8589 passed, 1 skipped;
`ContextPackRelatedEntries-37143.test.tsx` 16/16, its new pins built on
the SERVED derivation (`z.toJSONSchema(getMetadataTypeSchema(type), {
unrepresentable: 'any' })`): view `pagination`, `selection`, `gallery`
keep `{}`, view `kanban` and the pack's `body` are removed. Ablation:
the default check removed (every required key counts) turns those three
red (3 failed of 16), restored to HEAD. Swept every composite row of the
registered forms against the served derivation: the rows whose required
keys all carry defaults (view `selection`, `pagination`, `gallery`,
`userFilters`, `appearance`, `userActions`, `navigation`, `sharing`;
object `enable`, `access`, `publicSharing`; field `currencyConfig`; hook
`retryPolicy`; report and dashboard `dateRange`, dashboard `header`;
page `interfaceConfig.appearance`, `interfaceConfig.userActions`; agent
`planning`; flow `errorHandling`) keep `{}`; the rest have a required
key with no default and are removed when emptied.
- NOT MEASURED locally: `@object-ui/app-shell` and `@object-ui/i18n`
type-check (the ui workspace's own packages have no `dist/` in this
container, so tsc stops on module resolution); `Type Check UI` is the
reading.

</details>

## Acceptance notes

- The card's end-to-end clause (an author creates a pack in Studio and
`get_record_context` serves it) is covered here in pieces, not by one
booted host: the block's every write parses as a pack; the metadata API
save of an `ai_context` row is `protocol.runtime-authoring-gate.test.ts`
(metadata-protocol); the record-context door reads the protocol's merged
`ai_context` listing (`mcp-record-context-tools-bridge.test.ts`,
runtime). Measured once live as well (showcase booted with `objectstack
dev --seed-admin`, the `ui/` console served by Vite against it, Chromium
via Playwright, at the rework's source): Studio → AI → AI Context Pack →
create `project_brief` on `showcase_project` saved and published (`PUT
…/meta/ai_context/project_brief?mode=draft` 200, `POST …/publish` 200);
edit: root fields `name`, `status`; the add picker offered the four
links to the root (`showcase_client_brief.project`,
`showcase_field_zoo.f_master_detail`,
`showcase_project_membership.project`, `showcase_task.project`); the
columns offered were `showcase_task`'s fields; body chosen then set to
"None"; saved body `{"name":"project_brief","label":"Project
brief","object":"showcase_project","fields":["name","status"],"related":[{"object":"showcase_task","field":"project","fields":["title","status"]}]}`
(no `body` key), 200 and published. A second edit removed both root
fields: saved without `fields`, 200. Then MCP `get_record_context`
(`objectName: showcase_project`, `context: project_brief`) on a seeded
project answered the pack, with the task rows' `title` and `status`.
- The body picker offers every root field, not only the long-text ones:
`field-ref` has no type filter, and a non-long-text pick is reported at
save (`ai-context-body-not-long-text`).
- The link catalog is the console's served object list
(`useMetadata().objects`); an object it does not serve is not offered,
and a stored entry naming one is kept and marked.

## Verification

Two minutes: open Studio, pick a package, open AI → AI Context Pack
(advanced fold), create one; choose a root object with a child list
(showcase: an object another object looks up), add the related list and
pick a column. Expected: the column picker lists the child object's
fields, and the Source tab shows `related: [{ object, field, fields }]`.

Read first, by risk: `ContextPackRelatedEntries.tsx`
(`contextPackLinks`, `ContextPackRelatedEntries`), the dispatch at the
top of `RelatedListEntriesWidget` in `widgets.tsx`,
`ai-context.form.ts`.

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

<!-- signed: repo:objectstack#7 · os-alice ·
session_011y7As6JrAPNfuwC2RLXXGu -->

---------

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/s skip-changeset PR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

37140 跟进:资料包(ai_context)按包区分同名,补进 ADR-0150 的分桶表

3 participants