Skip to content

Commit bd81a7a

Browse files
refactor(metadata-protocol): move getDiscovery's body into its facet, and settle the card's last facade-gate rows (#31177)
<!-- claude-projects-attribution: {"github_login":"marchtian"} --> _Requested by **田騏** · [project thread](https://claude.ai/code/project/chan_01VmuUhXU9SSUzqJYyXSmYSi?thread=cmsg_01VmuUhXU9SSUzqJYyXSmYSiNjyvCdXYygFqntMNR7S2dW)_ Fixes #30147 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:把 `getDiscovery` 的方法体从 `protocol.ts` 搬进所在分区的 facet(`ProtocolDiscoveryAndBasesFacet`),类上只留签名和一行委托;并按裁决 6687801899 收尾 facade 门禁登记表里这张卡名下剩下的行。 - 为什么改:这是本卡最后一个 PR。`getDiscovery` 靠 `typeof this.searchAll === 'function'` 决定是否对外宣告"支持搜索",codemod 的 host 转发会让这个判断恒为真,所以手工搬:类上读实例自己的 `searchAll` 再交给 facet 判断。 - 风险与回滚:纯搬移,方法体除搜索探针改读参数外不变(撤销证明可逐字节重建中间态 X);公开 `index.d.ts` / `index.d.cts` 与 main 逐字节相同;回滚即 revert 本 PR。 - 先看:`packages/metadata-protocol/src/protocol.ts` 中 `getDiscovery` 的存根(传 `this.searchAll` 那一行);`protocol-discovery-and-bases.ts` 中 facet 的 `search: typeof searchAllOnInstance === 'function'`;`scripts/facade-delegation-registry.json` 的 8 处改动。 - 两分钟验证:`pnpm check:facade-delegation-only`,预期末行 `5 facade class(es) in 3 file(s) hold delegations only, 15 named exception(s).`,退出码 0。 - 需要你做的:无,席位落地。 ## What changes **`getDiscovery`, a hand move in three commits.** The codemod's members pass refuses this member on `main`: its body reads the instance method `searchAll` as a value to set `capabilities.search`, and a host entry forwards a method through a closure that is always a function, so a moved probe would advertise search on every host. The route the card records (dev report 6686885545, `phase_3b`): 1. `43df6766ff` is the intermediate X: the probe reads a parameter, `searchAllOnInstance`, instead of `this.searchAll`. Not a landing state on its own (the public signature carries the parameter there). 2. `4a2e27e428` is `node scripts/codemod-split-protocol.mjs --members getDiscovery --write` run on X, unedited: the body goes to `ProtocolDiscoveryAndBasesFacet` by the E1 form (460 body lines), and the stub forwards `protocolHost(this)` and the parameter. 3. `e87a512b0e` is the hand edit: `getDiscovery()` takes no parameter again, so its signature is `main`'s byte for byte, and the stub hands the facet `this.searchAll`, read on the instance. The facet keeps `typeof searchAllOnInstance === 'function'`. The stub also gains a two-line comment that says why. `host-split.mjs`'s refusal of a method read as a value is unchanged. **The registry** (`scripts/facade-delegation-registry.json`), per ruling 6687801899: - the `getDiscovery` row is deleted (16 to 15 exceptions, on `main` after #31151); - `triggerAutomation`, sql-driver `get supports` and `static DIALECT_CONNECT_TIMEOUT` keep `card: "#30147"` (the gate requires a card number) and each reason is prefixed with `accepted terminal exception (ruling 6687801899):`, the reason already written kept after it; - the four `engine.ts` rows (`homeAmountServing`, `projectHomeAmountsOntoPatch`, `ScopedContext#derive`, `[APP_AUTHORED_HOOK_API]`) point at #30975. `engine.ts` and `sql-driver.ts` are not touched. **A patch changeset** for `@objectstack/metadata-protocol`: the package's built JavaScript changes (the body now runs from the facet module) while its public `.d.ts` does not, and `Metadata-protocol: none` takes `patch`. ## Tests No test file changes. Measured on the final head `56dbba9841` (this branch merged with `main` `56baf78e0c`; the merge touched neither package): - `@objectstack/metadata-protocol` vitest: 321 files passed, 4 skipped; 22,525 tests passed, 26 skipped. `typecheck` exit 0, `build` exit 0. - `packages/rest` vitest (it loads `@objectstack/metadata-protocol` through the built `dist/`, rebuilt from this head): 398 files, 7,782 tests passed, 354 skipped. `discovery-search-capability-agreement.test.ts` 4/4. - The same two suites on `e87a512b0e` (before the merge) gave the same counts. - **Negative control**: the stub handed a host-style forwarding closure instead of `this.searchAll`; the package rebuilt and the closure confirmed in `dist/index.js` and `dist/index.cjs` (`ablation-dist-preflight.mjs`); `discovery-search-capability-agreement.test.ts` failed 2 of 4 ("agrees on a protocol that cannot search" and the anti-vacuity case). Restored from `HEAD` (blob hash equal, `git diff HEAD` empty), rebuilt, the closure absent from `dist/`: 4/4 again. ## Acceptance notes - **The `.d.ts` bar.** `dist/index.d.ts` and `dist/index.d.cts` built from `main` `af3451b08b`'s two source files and from this branch's are byte-equal (sha256 `1b94b057e16e19b5…` on all four). `getDiscovery` is public with a written return type and no docblock, so nothing moved out of the printed declaration. - **Reproducing the generated commit.** `git checkout 4a2e27e` and `node scripts/codemod-split-protocol.mjs --members --verify --base 43df676` exits 0. On the head the same command exits 1, naming exactly the hand-edited stub and signature (expected; that is the third commit). - **`triggerAutomation`'s reason** now reads "accepted terminal exception (ruling 6687801899): accepted exception (#30147 phase 3): …": the order was to prefix and keep the reason already written, and that reason already opened with its own label. A one-word tidy is the seat's call. - No open pull request touches `packages/metadata-protocol/src/protocol*.ts` or the registry that this branch could collide with; #30747 (engine.ts) is untouched here. ## Verification <details><summary>Suites on the final head</summary> One locked run at `56dbba9841`: `pnpm --filter @objectstack/metadata-protocol build` exit 0, `typecheck` exit 0, `exec vitest run --maxWorkers=2` exit 0 (Test Files 321 passed, 4 skipped; Tests 22,525 passed, 26 skipped); `pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2` exit 0 (Test Files 398 passed; Tests 7,782 passed, 354 skipped); `discovery-search-capability-agreement.test.ts` verbose: 4 passed (the ordinary host, a host that does not mount the route, a protocol that cannot search, anti-vacuity). </details> <details><summary>Undo proof against X</summary> `node scripts/codemod-split-protocol.mjs --members --verify --base 43df676` on the tree of `4a2e27e428`: exit 0. ```text undo proof (#30518, #30147): 1 moved member(s) (getDiscovery); forms: e1 1; host-split check: 1/1 E1 move(s) pass (the receiver forms move bodies unedited, proved byte-equal); protocol.ts 12606 -> 12147 lines; undoing the moves does rebuild the base protocol.ts, protocol-host.ts and section modules byte-for-byte once the 15 import binding(s) only moved bodies read are pruned from the base (ApiRoutes, CHANNEL_SURFACE_SLOTS, CORE_SERVICE_PROVIDER, CapabilityDescriptor, SERVICE_CONFIG, ServiceInfo, WellKnownCapabilities, engineCanRollBack, isSubscribableChannel, readAuthFamilies, readChannelRoute, readServiceSelfInfo, resolveDiscoveryEnvironment, resolveDiscoveryVersion, serviceUnavailableMessage) ``` </details> <details><summary>Facade gate</summary> `pnpm check:facade-delegation-only` at `1a84657c25`: exit 0, `5 facade class(es) in 3 file(s) hold delegations only, 15 named exception(s).` </details> <details><summary>dispatch-gates</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` at `56dbba9841`: 65 families derived, all 65 run after a full `pnpm build` (plus a rebuild of the packages the `main` merge touched), every one `exit 0`, codes captured before any pipe. `--ran`: 65 derived, 65 run, 0 NOT-MEASURED (a derived zero: all 65 recorded an exit code), 0 UNRUN. `pnpm --filter @objectstack/spec check:generated`: all 14 artifacts up to date (a first run reported `check:test-typecheck` as `tsc failed without diagnostics` on a contended box; the gate alone and the re-run both pass). eslint on the two changed source files: exit 0. </details> <details><summary>Changed lines</summary> 1,033 changed lines (+554 / -479, 4 files, changeset included), under the 3,000 budget. </details> Session: https://claude.ai/code/session_017ihL2ebbZkr2QAEG1x7UC8 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: domain:devx#2 · marchtian · session_017ihL2ebbZkr2QAEG1x7UC8 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 658d84f commit bd81a7a

5 files changed

Lines changed: 560 additions & 482 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@objectstack/metadata-protocol': patch
3+
---
4+
5+
refactor(metadata-protocol): `getDiscovery` hands its body to its facet
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
- `ObjectStackProtocolImplementation#getDiscovery` keeps its signature and return type on the class and delegates in one line to `ProtocolDiscoveryAndBasesFacet.getDiscovery`, which holds the body, moved unchanged except for the search probe: the class reads `this.searchAll` on the instance and hands it in, so `capabilities.search` still answers whether this protocol instance serves search. No behaviour changes and nothing to do on upgrade.
11+
- The published `index.d.ts` and `index.d.cts` carry the same public surface.

0 commit comments

Comments
 (0)