@@ -563,7 +563,8 @@ const FAILURE_PROPAGATION_CALLEES = new Map([
563563 */
564564const FAILURE_PROPAGATION_SITES = new Map ( [
565565 [
566- 'packages/metadata-protocol/src/protocol.ts::migrateStoredMetadata' ,
566+ // [#29985] The body moved to `protocol-save.ts` with the codemod split.
567+ 'packages/metadata-protocol/src/protocol-save.ts::migrateStoredMetadata' ,
567568 {
568569 callees : [ [ 'record' , 'effect' ] ] ,
569570 why :
@@ -575,7 +576,8 @@ const FAILURE_PROPAGATION_SITES = new Map([
575576 } ,
576577 ] ,
577578 [
578- 'packages/metadata-protocol/src/protocol.ts::duplicatePackage' ,
579+ // [#29985] The body moved to `protocol-package-commits.ts` with the codemod split.
580+ 'packages/metadata-protocol/src/protocol-package-commits.ts::duplicatePackage' ,
579581 {
580582 callees : [ [ 'failed.push' , 'effect' ] ] ,
581583 why :
@@ -3345,6 +3347,12 @@ function createHostSplit(load) {
33453347 return api ;
33463348}
33473349
3350+ /** [#29985] Is this call `host.x(…)` — through ruling E's host parameter (`HOST_SPLIT.hostParam`)? */
3351+ function viaHostParameter ( call ) {
3352+ const expr = call . expression ;
3353+ return ts . isPropertyAccessExpression ( expr ) && ts . isIdentifier ( expr . expression ) && expr . expression . text === HOST_SPLIT . hostParam ;
3354+ }
3355+
33483356/**
33493357 * Does this call perform a storage READ — directly, or through a same-file
33503358 * wrapper? See `MAX_READ_WRAPPER_DEPTH` for why wrappers are followed, and
@@ -3367,7 +3375,14 @@ function isReadCall(node, functionBodies, seen = new Set(), depth = 0, maxDepth
33673375 let body = functionBodies . get ( name , node ) ;
33683376 let bodies = functionBodies ;
33693377 // #25467: own-file first; only an unresolved name may be a host call.
3370- if ( ! body && functionBodies . split ) {
3378+ // [#29985] …except a call through ruling E's `host` parameter: `host.x(…)`
3379+ // reaches the class's member `x` whatever the module declares, and a
3380+ // section module routinely declares `x` itself (the moved body of that very
3381+ // member, with the extra `host` parameter, so the own-file answer failed
3382+ // the arity check and the seam left the census).
3383+ const hostHop = functionBodies . split && viaHostParameter ( node ) ? functionBodies . split . hostCall ( node , functionBodies ) : undefined ;
3384+ if ( hostHop ) ( { body, bodies } = hostHop ) ;
3385+ else if ( ! body && functionBodies . split ) {
33713386 const hop = functionBodies . split . hostCall ( node , functionBodies ) ;
33723387 if ( hop ) ( { body, bodies } = hop ) ;
33733388 }
@@ -3543,7 +3558,19 @@ function establishesBenign(expr, ctx) {
35433558 const seen = ctx . guardSeen ?? new Set ( ) ;
35443559 const depth = ctx . guardDepth ?? 0 ;
35453560 if ( seen . has ( name ) || depth >= MAX_GUARD_DEPTH ) return false ;
3546- const body = ctx . functionBodies . get ( name , call ) ;
3561+ let body = ctx . functionBodies . get ( name , call ) ;
3562+ let guardBodies = ctx . functionBodies ;
3563+ // [#29985] A body the host split moved (ruling E) reaches the guard it
3564+ // delegated to in `protocol.ts` as `host.guard(error)`: the same HOST CALL
3565+ // `isReadCall` follows, by the same precedence, answered from the host
3566+ // class's own method — the guard the call reached before the body moved,
3567+ // and nothing wider.
3568+ const hostHop = ctx . functionBodies . split && viaHostParameter ( call ) ? ctx . functionBodies . split . hostCall ( call , ctx . functionBodies ) : undefined ;
3569+ if ( hostHop ) ( { body, bodies : guardBodies } = hostHop ) ;
3570+ else if ( ! body && ctx . functionBodies . split ) {
3571+ const hop = ctx . functionBodies . split . hostCall ( call , ctx . functionBodies ) ;
3572+ if ( hop ) ( { body, bodies : guardBodies } = hop ) ;
3573+ }
35473574 if ( ! body || ! ts . isBlock ( body ) ) return false ;
35483575 const exits = [ ] ;
35493576 const consulted = new Set ( ) ;
@@ -3552,6 +3579,7 @@ function establishesBenign(expr, ctx) {
35523579 false ,
35533580 {
35543581 ...ctx ,
3582+ functionBodies : guardBodies ,
35553583 usedDiscriminators : consulted ,
35563584 guardSeen : new Set ( [ ...seen , name ] ) ,
35573585 guardDepth : depth + 1 ,
@@ -5025,6 +5053,9 @@ const SELF_TEST_BATTERIES = Object.freeze({
50255053 'passes: #25467 E1 — a stub that hands its body anything but `protocolHost(this)` is not followed' : 1 ,
50265054 'BOUND (#25467 E1): the `host.x()` hop IS a hop — a third hop through the host is still refused' : 1 ,
50275055 'BOUND (#25467 E1): the same host ladder IS a seam one hop deeper — the pin above is not vacuous' : 1 ,
5056+ 'passes: #29985 — a moved body\'s catch that delegates to a `protocol.ts` guard as `host.guard(error)` answers on the discriminated branch' : 1 ,
5057+ 'flags: #29985 — negative control: the same delegation to a host guard that asks no error type still invents the answer' : 1 ,
5058+ 'flags: #29985 — `host.x()` in a module that declares x itself (x\'s own moved body) is the class member x, through its stub' : 1 ,
50285059 'ledger (read seams): a stale entry PASSES and is reported; an unledgered seam still FAILS (#26444)' : 1 ,
50295060 'ledger (read seams): a ledgered file on disk the scan never READ is refused; a deleted one passes (#26444)' : 1 ,
50305061 } ) ,
@@ -5038,7 +5069,7 @@ const SELF_TEST_BATTERIES = Object.freeze({
50385069// `undefined` and the comparison fails loudly.
50395070const SELF_TEST_BATTERY_FLOOR = Object . freeze ( {
50405071 selfTest : 70 ,
5041- selfTestReadSeams : 67 ,
5072+ selfTestReadSeams : 70 ,
50425073} ) ;
50435074
50445075// The roster's TOTAL, checked from BOTH verdict sites. Each entry checks only
@@ -6353,6 +6384,11 @@ function selfTestReadSeams() {
63536384 private async findOverlay(t: string) { return await this.lookup(t); }
63546385 async getItem(t: string) { return await this.findOverlay(t); }
63556386 private static async readStatic(engine: any, t: string) { return await engine.find(t, {}); }
6387+ private rethrowUnlessGone(error: unknown): void {
6388+ if (isMissingTableError(error)) return;
6389+ throw error;
6390+ }
6391+ private shrugOff(error: unknown): void { void error; }
63566392 async listRowsMoved(id: string) {
63576393 return listRowsMoved(protocolHost(this), id);
63586394 }
@@ -6364,6 +6400,9 @@ function selfTestReadSeams() {
63646400 readonly tidy: ObjectStackProtocolImplementation['tidy'];
63656401 readonly getItem: ObjectStackProtocolImplementation['getItem'];
63666402 readonly readStatic: (typeof ObjectStackProtocolImplementation)['readStatic'];
6403+ readonly rethrowUnlessGone: ObjectStackProtocolImplementation['rethrowUnlessGone'];
6404+ readonly listRowsMoved: ObjectStackProtocolImplementation['listRowsMoved'];
6405+ readonly shrugOff: ObjectStackProtocolImplementation['shrugOff'];
63676406 readonly untyped: (t: string) => Promise<unknown[]>;
63686407 }` ;
63696408 const E1_MODULE_HEAD = `
@@ -7611,6 +7650,54 @@ function selfTestReadSeams() {
76117650 expectViolation : true ,
76127651 expectSeams : 1 ,
76137652 } ,
7653+ {
7654+ // [#29985] \`metaTypeNamespaceExists\` and \`listCommits\`'s shape once moved:
7655+ // the catch delegates to the host class's discriminating guard.
7656+ name : 'passes: #29985 — a moved body\'s catch that delegates to a `protocol.ts` guard as `host.guard(error)` answers on the discriminated branch' ,
7657+ files : {
7658+ [ `${ HOST_SPLIT . dir } /protocol.ts` ] : E1_HOST ,
7659+ [ `${ HOST_SPLIT . dir } /protocol-host.ts` ] : E1_HOST_MODULE ,
7660+ [ `${ HOST_SPLIT . dir } /protocol-uninstall.ts` ] : E1_MODULE_HEAD + `
7661+ export async function listRows(host: Pick<ProtocolHost, 'findRows' | 'rethrowUnlessGone'>, id: string) {
7662+ try { return await host.findRows(id); }
7663+ catch (error) { host.rethrowUnlessGone(error); return []; }
7664+ }` ,
7665+ } ,
7666+ expectViolation : false ,
7667+ expectSeams : 1 ,
7668+ expectDiscriminatorsUsed : [ 'isMissingTableError' ] ,
7669+ } ,
7670+ {
7671+ // [#29985] \`rollbackToPackageCommit\` guarding \`host.revertCommit(…)\` once
7672+ // both bodies sit in one section module: the module declares the
7673+ // moved \`revertCommit\` itself, with the extra \`host\` parameter.
7674+ name : 'flags: #29985 — `host.x()` in a module that declares x itself (x\'s own moved body) is the class member x, through its stub' ,
7675+ files : {
7676+ [ `${ HOST_SPLIT . dir } /protocol.ts` ] : E1_HOST ,
7677+ [ `${ HOST_SPLIT . dir } /protocol-host.ts` ] : E1_HOST_MODULE ,
7678+ [ `${ HOST_SPLIT . dir } /protocol-uninstall.ts` ] : E1_MODULE_HEAD + `
7679+ export async function rollBack(host: Pick<ProtocolHost, 'listRowsMoved'>, id: string) {
7680+ try { return await host.listRowsMoved(id); }
7681+ catch { return []; }
7682+ }` ,
7683+ } ,
7684+ expectViolation : true ,
7685+ expectSeams : 1 ,
7686+ } ,
7687+ {
7688+ name : 'flags: #29985 — negative control: the same delegation to a host guard that asks no error type still invents the answer' ,
7689+ files : {
7690+ [ `${ HOST_SPLIT . dir } /protocol.ts` ] : E1_HOST ,
7691+ [ `${ HOST_SPLIT . dir } /protocol-host.ts` ] : E1_HOST_MODULE ,
7692+ [ `${ HOST_SPLIT . dir } /protocol-uninstall.ts` ] : E1_MODULE_HEAD + `
7693+ export async function listRows(host: Pick<ProtocolHost, 'findRows' | 'shrugOff'>, id: string) {
7694+ try { return await host.findRows(id); }
7695+ catch (error) { host.shrugOff(error); return []; }
7696+ }` ,
7697+ } ,
7698+ expectViolation : true ,
7699+ expectSeams : 1 ,
7700+ } ,
76147701 {
76157702 name : 'passes: #25467 E1 — negative control: a moved body whose `host.x()` reaches no storage wrapper is no seam' ,
76167703 files : {
0 commit comments