Repository navigation
Commit cfe3563
feat(objectql)!: by-name readers of apps, pages, dashboards, reports, books, cubes, tools, skills and agents consult (package, name) (#31847)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9YGpy1NJdhGQFV6brdHkrTP)_
Fixes #31680
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill or doc teaches a bare read of a name two
packages ship, an environment item read by a package caller, or a read
of an undeclared package's item; ADR-0150 D3 already states the rule,
and the `?package=` qualifier the refusals point to is already
documented on the meta read.
Narrowing: (1) a bare name two packages ship, read with no package, is
refused naming both (first-party count 0; for agent, skill and tool only
on a deployment that booted already holding the clash); (2) a package
caller's name only the environment holds is refused, D3 (a) (count 0);
(3) a package caller's name whose one holder is outside its declared
closure is refused (count 0, same-artifact siblings 0).
## 维护者速读
- 改了什么:应用、页面、仪表盘、报表、手册、分析立方体、工具、技能和智能体这九类元数据,按名字读取时统一走 R
的那一个包内解析器(ADR-0150 D3),不再由注册表"谁先注册就给谁"。
- 为什么改:两个包发布同名页面时,不带包名的读取一直悄悄返回先注册的那个;包内调用方还能读到它没声明依赖的包或环境自有的条目。
- 收窄的三种情况一律返回 409 RESOURCE_CONFLICT
并列出全部持有者;只有一个持有者或没有持有者时,行为与之前完全一样。仓库内四个示例应用触发次数均为 0。
- 风险与回滚:只改读取路径(getApp、MetadataFacade、协议的不带包名读取),不改任何存储形状、schema 或 MCP
输入输出;回滚即 revert 本 PR。
- 先看:`packages/objectql/src/package-scoped-read.ts`,然后 `registry.ts` 的
`resolveItem`,再看 `protocol-meta-item-reads.ts` 中的
`packagelessScopedRead`。
- 需要你做的:无,席位做合同审查,史诗席位做红线审查后落地。
## What changes
Child E8 of epic #31527 wires the by-name readers of nine types (`app`,
`page`, `dashboard`, `report`, `book`, `analytics_cube`, `tool`,
`skill`, `agent`) to R's one resolver, `resolvePackageScopedName` (the
lean core R2 #31733 landed). This follows the epic seat's ruling (option
A): both arms of `getApp` and `MetadataFacade`, and no bindable reader.
- **`package-scoped-read.ts` (new).** `PACKAGE_SCOPED_READ_TYPES` lists
the nine types. `readPackageScopedItem` turns the resolver's answer into
a reader's: resolved returns the item, not-found returns `undefined`,
and a refusal throws `PackageScopedNameRefusedError`. That error carries
`code: 'RESOURCE_CONFLICT'`, `status`/`httpStatus: 409`, the resolver's
own sentence naming every candidate, and the `refusal`. It restates no
part of the rule and holds no closure walk of its own.
- **`SchemaRegistry.resolveItem(type, name, callerPackageId?, member?)`
and `readsByPackage(type)`.** A wired type is read through
`readPackageScopedItem`; every other type keeps `getItem`.
The readers, and the caller package each one passes:
| Reader | Caller package passed |
|---|---|
| `SchemaRegistry.getApp(name, currentPackageId?)` | `currentPackageId`
|
| `MetadataFacade.get(type, name, currentPackageId?)` |
`currentPackageId` |
| `MetadataFacade.getEntry(type, name)` | none |
| `MetadataFacade.exists(type, name)` | none; a refusal answers `true`
(the holders exist) |
| protocol `readMetaItem` with no `packageId` (`GET
/api/v1/meta/TYPE/NAME`, both faces, so MCP `agent_prompt` too) | `null`
(a caller with no package) |
- **Protocol read.** The package-less arm calls
`registry.resolveItem(type, name, null, member)` once, before any layer
is read, and step 3 serves that answer in place of `getItem` and its
plural retry. A read with `?package=` keeps `getItem`; that address is
G1's exact qualifier, not a caller. metadata-protocol still cannot
import objectql, so it reaches the resolver only through the registry's
`resolveItem`. No new import edge.
- **MCP.** No code change and no input or output shape change (that is
G2's). `agent_prompt` already reads through the protocol read (#31514).
One new pin: a 409 refusal travels as a protocol error naming both
holders. It is never answered as "not found" or as the outage text.
- Barrel exports: the four names and the type from
`@objectstack/objectql`.
## Tests
- `packages/objectql/src/package-scoped-e8-readers.test.ts` (new, 71
tests). It runs the real `SchemaRegistry`, the real
`ObjectStackProtocolImplementation` and the real `MetadataFacade`, and
covers:
- the type list;
- the 409 mapping through `resolveThrownHttpError`;
- narrowing (1) for each of the six types phase 1 does not cover (app,
page, dashboard, report, book, analytics cube), at both protocol faces,
`facade.get`/`getEntry` and `getApp`;
- narrowings (2) and (3) for all nine types;
- the CONTROL for all nine types: one holder, the environment's item,
zero holders not-found, the `?package=` read untouched, and getApp's nav
contributions;
- a non-wired type keeps `getItem`.
- `packages/mcp/src/mcp-server-runtime.agent-prompt-advertised.test.ts`:
one new test, the refusal travels.
- **Forced test edit, one:**
`packages/qa/dogfood/test/bare-name-one-holder-ai-family.dogfood.test.ts`
(#30803 / #31414, phase 1). Its cold boot holds an agent, skill and tool
clash between two packages (a boot warns, it does not refuse), and it
pinned that `GET /meta/agent|tool/NAME` with no package "keeps serving
the first-registered package's item". That is narrowing (1) on the wire,
and the full dogfood battery went red on exactly those 3 tests (3 failed
/ 3659 passed) on head 9e37aef. The pin now asserts `409
RESOURCE_CONFLICT` naming both packages for agent, skill and tool, and
that `?package=` serves each package's own. The boot warning, the
install refusals and the skill-prompt reading are unchanged.
**Red on main** (b126c13, the probe in the card notes): for every
uncovered type, with two holders, `/meta`, `facade.get` and `getApp`
with no package served `alpha`, the first registered. A package caller
was served an outside-closure single holder and an environment-only
item. Before the wiring, the new file ran 25 failed and 48 passed; the
25 failures were exactly the three narrowing arms.
**Ablations.** Each mutation was put in through
`scripts/ablation-replace.mjs` and its run went red. Each was then
restored, with the blob back to HEAD.
| # | Mutation | Result |
|---|---|---|
| A1 | `readsByPackage` → false (the protocol arm off) | 6 failed |
| A2 | `facade.get` → `getItem` | 24 failed |
| A3 | `getApp` → `getItem` | 3 failed |
| A4 | `resolveItem` → `getItem` | 24 failed |
| A5 | `exists` refusal → false | 1 failed |
| A6 | MCP `readAgentByName` reads `RESOURCE_CONFLICT` as a miss | 1
failed |
| A7 | protocol source arm disabled, metadata-protocol rebuilt | 6
failed; `ablation-dist-preflight` marker present in dist |
For A7, the restore leg rebuilt metadata-protocol, the preflight found
the marker absent from dist with the tree clean, and the run went back
to 71/71.
## Acceptance notes
The four readings:
- **(a) The phase-1 one-holder tests stay green.** These ran green on
the final head with no edit: `registry-bare-name-one-holder.test.ts`,
`package-scoped-resolver.test.ts`, `core-boundary.ratchet.test.ts`,
`registry-cross-package-collision.test.ts`,
`engine-cross-package-collision.test.ts`, and the full objectql suite.
The one exception is the dogfood boot-clash pin named above: its "first
registered is served" line is the behaviour E8 removes, so it is
flipped. Its boot warning and install refusals are untouched.
- **(b) One-holder bare-name behaviour is unchanged except for the
declared narrowings.** The CONTROL block pins it for all nine types at
every rewired reader. Agent, skill and tool are phase-1 covered: a new
install of a held name is refused, so narrowing (1) reaches them only on
a deployment that booted already holding the clash.
- **(c) Migration.** None. This changes only what a read answers; no
stored row, schema or shape changes (the `adr-0087: not-required
(no-migration-prescription)` marker).
- **(d)** `Clause-②: no (narrowing)`, per seat 2's ruling. The changeset
carries the BREAKING banner, with FROM→TO and the one-line fix.
Red lines:
- ONE resolver: every wired reader goes through `readPackageScopedItem`
→ `resolvePackageScopedName`. No reader walks a closure or falls back to
the first composite.
- Ambiguity refuses, naming every candidate; zero holders stays
not-found.
- `package-scoped-resolver.ts` was not edited.
- No `packages/spec/**`, `ui/**`, `docs/adr/**` or E6 readers were
touched, and `registry.ts installPackage` was not touched.
By-name reads not rewired here. Each keeps `getItem`:
- the layered read (`getMetaItemLayered`);
- `readCodeLayerForCarryForward`;
- `protocol-artifact-lookup.ts`;
- the write side (`protocol-save.ts`, `protocol-authoring-gate.ts`);
- MCP's `diagnosedGet` for a host without a protocol;
- `getAppNavContributions`;
- the `getAllApps` list.
The seat can file any of these as later cards.
ADR-0146 overrides: a pair's stored override row is hydrated into the
registry's bare slot (`protocol-registry-hydration.ts`), so a
package-less read still finds the environment's item first, and the full
ADR-0146 suites are green.
New public names, which are the seat's call:
`PACKAGE_SCOPED_READ_TYPES`, `PackageScopedReadType`,
`isPackageScopedReadType`, `readPackageScopedItem`,
`PackageScopedNameRefusedError`, `SchemaRegistry.resolveItem` and
`SchemaRegistry.readsByPackage`.
## Verification
Head `d981cf7c1ce46776fafe4b725f2a3ef9c77dec9e`, which merges
origin/main fdfcc7a. Every run below is on that head, under
`os-verify-lock`, and each VERDICT was command-exit 0.
- Full `pnpm build`: green.
- Tests: objectql 22610 passed (29 skipped), metadata-protocol 980
passed, mcp 11887 passed.
- typecheck: clean for all three packages.
- Lint: eslint is clean on the three packages' `src` and on the edited
dogfood file.
- Gates: `dispatch-gates.mjs --commands` listed 75 commands. All 75
exited 0, and `--ran` reconciles 75 derived, 75 run, 0 NOT-MEASURED.
- Dogfood battery (`pnpm --filter @objectstack/dogfood test`): Test
Files 441 passed, 3 skipped (444). Tests 3662 passed, 42 skipped (3704).
0 failed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmTH1oAwgDMigQ9pj37
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 31ae944 commit cfe3563
9 files changed
Lines changed: 567 additions & 25 deletions
File tree
- .changeset
- packages
- mcp/src
- metadata-protocol/src
- objectql/src
- qa/dogfood/test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
412 | 436 | | |
413 | 437 | | |
414 | 438 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
95 | 111 | | |
96 | 112 | | |
97 | 113 | | |
| |||
566 | 582 | | |
567 | 583 | | |
568 | 584 | | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
573 | 596 | | |
574 | 597 | | |
575 | 598 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
143 | 154 | | |
144 | 155 | | |
145 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
225 | 226 | | |
226 | 227 | | |
227 | 228 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
233 | 239 | | |
234 | 240 | | |
235 | 241 | | |
236 | | - | |
| 242 | + | |
237 | 243 | | |
238 | 244 | | |
239 | 245 | | |
240 | 246 | | |
241 | 247 | | |
242 | 248 | | |
243 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
244 | 256 | | |
245 | 257 | | |
246 | | - | |
| 258 | + | |
247 | 259 | | |
248 | 260 | | |
249 | 261 | | |
| |||
285 | 297 | | |
286 | 298 | | |
287 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
288 | 304 | | |
289 | 305 | | |
290 | | - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
291 | 313 | | |
292 | 314 | | |
293 | 315 | | |
| |||
0 commit comments