Repository navigation
Commit 85f77e9
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9UmbUGPtw5rdRcd3UpYXs5N)_
Part of #25467
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:把 `protocol.ts` 里“元数据读取”一节的前半(列表读取 `getMetaItems` 及其两种变体、共享的
`readFlattenedMetaItems`,外加 `auditMetaItem`、`getUiView`)的方法体,经 E1
的宿主机制原样搬进两个新模块;6 个方法仍留在类上(签名与文档不变),方法体变成一行转发。
- **为什么改**:#25467 裁决 E 的 E2 第 1 节(按席位裁定拆成 1a/1b,每个 PR 1,000–3,000
行),在声明的 `protocol.ts` 冻结日落地;1b(单项读取、分层读取)随后另开。
- **风险与回滚**:低。只做搬移:工具逐个证明 6 个方法体与原方法体在“`this.` 读作 `host.`”之外 AST
与文本全同;对外 `index.d.ts`(ESM 与 CJS)与 main 构建出的逐字节相同,`getMetaTypes()`
的推断类型块也逐字节相同。回滚即整体 revert。
- **先看**:`packages/metadata-protocol/src/protocol-meta-list-reads.ts`
文件头;`protocol.ts` 里 6 个方法的转发体与类 `static {}`
块新增的宿主条目;`protocol.lookup-artifact-item-call-sites.test.ts` 的改动。
- **两分钟验证**:`cd packages/metadata-protocol && node
scripts/host-split.mjs check origin/main readFlattenedMetaItems
protocol-meta-list-reads.ts`,预期 `"ok":true,"textIdentical":true`。
- **需要你做的**:无(约 2,500 行,低于 3,000 行线,席位自审)。
## What changes
Step **E2, section 1 "metadata reads", part 1a** of ruling E
(6537939895), on the `protocol.ts` freeze day seat 5 declared (#28677).
Seat 5 split section 1 into 1a and 1b to keep each PR within ruling E's
band of 1,000 to 3,000 lines. This is a pure application of the E1 host
pattern: no logic changes, and no new rewrite kind.
| member | moved to | rewrite sites (all `this.x` to `host.x`) |
|---|---|---:|
| `getMetaItems` | `protocol-meta-list-reads.ts` | 1 |
| `getMetaItemsForExecution` | `protocol-meta-list-reads.ts` | 1 |
| `getMetaItemsPerPackage` | `protocol-meta-list-reads.ts` | 1 |
| `readFlattenedMetaItems` (809 lines) | `protocol-meta-list-reads.ts` |
44 |
| `auditMetaItem` | `protocol-meta-audit-ui-view.ts` | 3 |
| `getUiView` | `protocol-meta-audit-ui-view.ts` | 1 |
Each method keeps its docblock, modifiers and signature on the class;
its body becomes `return fn(protocolHost(this), …)`. `ProtocolHost` and
the class's static block gain 26 entries (the members those bodies read;
`engine`, `environmentId` and `getServicesRegistry` are read-only
getters, the rest are call-time closures). `node scripts/host-split.mjs
check origin/main MEMBER MODULE` reads `ok: true, textIdentical: true`
for all six. Negative control, with `layer === 'effective'` changed to
`!==` in `readFlattenedMetaItems`'s moved body, then restored:
```
PROBLEM protocol-meta-list-reads.ts:85: ExclamationEqualsEqualsToken where the base has EqualsEqualsEqualsToken (`===`)
PROBLEM protocol-meta-list-reads.ts: readFlattenedMetaItems's body text differs from the base body rewritten and re-indented, first at body line 3
```
`protocol.ts` drops seven import names only the moved bodies used
(`ITEM_KEY_DISCRIMINATORS`, `decorateMetadataItems`,
`soleShippingPackage`, `isActionWithheldByDisabledPackage`,
`viewIdentityPatch`, `perPackageLayerEnvelope`, `storedEntryRow`); each
module imports what its bodies read from where `protocol.ts` imports it.
No import comment was dropped: the one attached comment (`[#7774]`) also
covers `itemDiscriminator`, which stays.
**The tool (`scripts/host-split.mjs`).** Measuring this section showed
the survey misread two stub shapes, so its E1 note of "9 local named
hosts" was wrong. `stubKindOf` now recognises:
- the per-member series' generic spelling, a parenthesised `fn` with an
explicit type argument, then `.call(host, …)`;
- a plain `return fn(…)` passing exactly its own parameters, which is a
body that read no member and moved earlier.
`move` now refuses a member that is already a stub. Before this, it
would have "moved" `throwMetadataServiceUnavailable` and
`namesWithOwnStoredRow`, which are already plain stubs. The survey now
reads 174 stubs and 4 refusals. Two of the refusals are mixed stubs
(`packagelessOverlayWriteRefusal`, `namedBaseOverlayWriteRefusal`), and
the other two are `reconcileViewExpansions` (a private static field) and
`publishPackageDrafts` (a bare `this`); none of the four is in section
1. Three new tests cover this, and `host-split.test.mjs` reads 38 tests.
Ablation, deleting the instantiation-expression unwrap, then restored: 2
failed (`expected undefined to be 'call'`; `refuses to move
stubbedGeneric again`).
## Forced test edits
Two by-path pins now read through the split. What each asserts is
unchanged.
`src/protocol.lookup-artifact-item-call-sites.test.ts`:
- The `readFlattenedMetaItems` site row carries `file:
'protocol-meta-list-reads.ts'`, where its body now stands.
- The member scanner names the class's `static {}` block, and a row
records the host factory's `lookupArtifactItem` closure there. It has
disposition `no`, because it forwards the moved bodies' calls unchanged.
This is the same reasoning as cut 15's `shippedArtifactsOf` `...a` row.
- "Both read doors take their envelope from one rule" reads the list
read's `const itemPackageId = envelopePackageId(packageId, it);` in
`protocol-meta-list-reads.ts`. It also requires that module to import
`envelopePackageId` from `protocol-package-bindings.ts` and to define no
copy.
Ablation, with that line changed to `const itemPackageId = packageId;`
in the module, then restored: `Tests 1 failed | 5 passed (6)`, `expected
'// Copyright …' to contain 'const itemPackageId = envelopePackage…'`.
`src/protocol.hydrate-overlay-canonical-type.test.ts` (#9111's closed
caller set of `hydrateOverlayIntoRegistry`): the full suite found it red
after the move (`expected [ …(2) ] to have a length of 3 but got 2`),
because one of the three calls now stands in `readFlattenedMetaItems`'s
moved body as `host.hydrateOverlayIntoRegistry(`. The pin now counts
`this.` calls in protocol.ts plus `host.` calls in every `protocol-*.ts`
module, still exactly 3, and requires that at least one is read in a
module. Ablation, planting a fourth `host.hydrateOverlayIntoRegistry(`
call in `protocol-meta-audit-ui-view.ts`, then restored: `Tests 1 failed
| 10 passed (11)`, `expected [ …(4) ] to have a length of 3 but got 4`.
A bare reference that is not a call (`void
host.hydrateOverlayIntoRegistry`) does not count: 11 passed.
The read-verb pin (`protocol.read-verb-canonical-fold.test.ts`) and the
read-seam census needed no edit: E1's resolution follows the new stubs.
Read-verb ablation, dropping the fold from `getMetaItemsForExecution`'s
moved body, then restored: `Tests 1 failed | 17 passed (18)`, `expected
[ 'getMetaItemsForExecution' ] to deeply equal []`. The census reads 100
seams, the same as main 399df5b (read in a scratch worktree of main).
## The published `.d.ts`
Built from main 399df5b (this branch's merge of main) and from this
head. `index.d.ts` is byte-identical: raw sha256 `450c9334…5d744e` on
both sides, ESM equal to CJS, normaliser 2 `8d160c2b…78065` on both. The
raw diff of `getMetaTypes()`'s emitted block (793 lines, its return type
still inferred per the seat's E1 ruling) is empty.
The declaration-emit comment leak into that inferred type struck once
after the cut: the `[#23316]` docblock printed inside `key?`. It was
cleared the way E0 and E1 cleared it, by the length of the new import
comment above the leaking offset. A probe of +1 to +8 characters read
raw-equal at +3 to +6; the comment carries +5 (the word "also").
## Serial
Re-read just before opening against main 390bd2a (6 commits past this
branch's merge of main, none in `packages/metadata-protocol`; `git
merge-tree` with main is clean). Open PRs whose own diff touches
`protocol.ts` or a `protocol-*.ts` module:
- #29456 (`protocol.ts` and `protocol-credential-carry-forward.ts`): its
hunks sit at main lines 355 (the import list), 3739 to 3742
(`carryForwardRedactedCredentials`) and 17167 onward (`saveMetaItem`),
all outside the moved section (main lines about 3851 to 7057). `git
merge-tree` with this head is clean.
- #29437 (`protocol-save-door-refusals.ts` only): `git merge-tree` with
this head is clean.
Seat 3's #29390 work (branch `claude/project-thread-gvqm55`, head
d776e25, no PR yet): its hunks sit at main lines 22104 and 22457 (the
restore limb), outside the moved section. `git merge-tree` with this
head is clean.
## Gates
On ec53149: `node scripts/pm/dispatch-gates.mjs --commands` derived
62 commands, and each records `exit 0`. `--ran` reports 62 derived, 62
run, 0 NOT-MEASURED, 0 UNRUN. The package's typecheck and test, through
os-verify-lock, read Test Files 307 passed, 4 skipped; Tests 22232
passed, 26 skipped. The 11 direct dependents' typecheck exits 0. Lint
(`eslint packages/metadata-protocol --no-inline-config`) exits 0. CI is
not read.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmR4MjTzeUv5x6tNkbk)_
<!-- signed: domain:server#5 · os-steve ·
session_01ADHkmR4MjTzeUv5x6tNkbk -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent ebbb5b8 commit 85f77e9
9 files changed
Lines changed: 1385 additions & 1126 deletions
File tree
- .changeset
- packages/metadata-protocol
- scripts
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| 307 | + | |
| 308 | + | |
307 | 309 | | |
308 | 310 | | |
309 | 311 | | |
| |||
526 | 528 | | |
527 | 529 | | |
528 | 530 | | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
529 | 566 | | |
530 | 567 | | |
531 | 568 | | |
| |||
536 | 573 | | |
537 | 574 | | |
538 | 575 | | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
| 576 | + | |
547 | 577 | | |
548 | 578 | | |
549 | 579 | | |
| |||
593 | 623 | | |
594 | 624 | | |
595 | 625 | | |
596 | | - | |
| 626 | + | |
597 | 627 | | |
598 | 628 | | |
599 | 629 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
| |||
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
153 | 160 | | |
154 | 161 | | |
155 | 162 | | |
| |||
159 | 166 | | |
160 | 167 | | |
161 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
162 | 174 | | |
163 | 175 | | |
164 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
57 | 76 | | |
58 | 77 | | |
59 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
60 | 85 | | |
| 86 | + | |
61 | 87 | | |
62 | 88 | | |
63 | 89 | | |
| |||
0 commit comments