@@ -331,7 +331,9 @@ export const PROBE_FILE_CENSUS: readonly ProbeFileReading[] = [
331331 blindSpot : 61 ,
332332 populationRule :
333333 'route registration sites — `this.routeManager.register(` call sites, LESS the one inside ' +
334- '`registerPerItemRoute` (the shared forwarder, not a route), PLUS `registerPerItemRoute(` call sites; ' +
334+ '`registerPerItemRoute` (the shared forwarder, not a route; its extent is bounded by the declaration\'s own ' +
335+ 'indentation and the subtrahend is pinned at 1 by the `forwarder slice:` control, never inferred from a ' +
336+ 'terminator spelling), PLUS `registerPerItemRoute(` call sites; ' +
335337 'reachable = those inside registerMetadataEndpoints' ,
336338 // [#15542 / #15854] ⭐ THE POPULATION RULE LEARNED A SECOND SPELLING, and
337339 // the numbers it produces did NOT move: 80 / 19 / 61, exactly as before.
@@ -390,6 +392,23 @@ export const PROBE_FILE_CENSUS: readonly ProbeFileReading[] = [
390392 // the control is 73 today for the spelling reason recorded above, and the
391393 // population it feeds is still 80. Do not "correct" the paragraph — it is a
392394 // dated measurement, not a live claim.
395+ //
396+ // [#16306] ⭐ A THIRD CONTROL, AND WHAT THE OTHER TWO CANNOT SEE. The two
397+ // above were measured insufficient rather than argued insufficient. Respell
398+ // the helper's terminator ` };` as ` }` — no semicolon, nothing lints it —
399+ // and BOTH stay green (the declaration is still present and still matches;
400+ // only its terminator moved) while the rule's old unanchored
401+ // `indexOf('\n };', at)` ran the forwarder slice 5132 → 9004, 3873
402+ // lines, swallowing 21 registrations: population read 60 and reachable read
403+ // 20, one measurement LOW and one HIGH, from a single edit. Measured
404+ // 2026-09-08 against 44c849c7d6, before and after the repair.
405+ //
406+ // ⚠️ 60 is what a genuine removal of 20 routes reads too, and NOTHING in
407+ // this record separated the two. `forwarder slice:
408+ // this.routeManager.register(` is the reading that does: it is the
409+ // subtrahend itself, pinned at 1, so a low population with it at 1 is a
410+ // real drop and a low population with it off 1 is the slice eating too
411+ // much. It is deliberately the one SLICE-scoped control on this row.
393412 controls : {
394413 'private register*Endpoints(' : 17 ,
395414 'this.routeManager.register(' : 73 ,
@@ -399,6 +418,7 @@ export const PROBE_FILE_CENSUS: readonly ProbeFileReading[] = [
399418 // shape moved and force this provenance to be re-read.
400419 'registerPerItemRoute(' : 8 ,
401420 'const registerPerItemRoute =' : 1 ,
421+ 'forwarder slice: this.routeManager.register(' : 1 ,
402422 enforceAuth : 64 ,
403423 } ,
404424 note :
@@ -601,9 +621,17 @@ export function deriveProbeFileCensus(): {
601621 // Scoped to the exported array literal, exactly as the probes are: the
602622 // patterns are the ledger's own row vocabulary, so a doc-comment or a type
603623 // declaration spelling the same tokens outside the table would inflate the
604- // reading. `controls` stay WHOLE-FILE counts, like every other row here —
605- // they answer "is this still the file I think it is", which is a question
606- // about the file and not about the table.
624+ // reading. `controls` here stay WHOLE-FILE counts — they answer "is this
625+ // still the file I think it is", which is a question about the file and not
626+ // about the table.
627+ //
628+ // ⚠️ [#16306] That is the rule on every row but one. `rest-server.ts` carries
629+ // a single SLICE-scoped control (`forwarder slice:
630+ // this.routeManager.register(`) because its population rule SUBTRACTS a
631+ // slice, and no whole-file count can see that slice grow — the four
632+ // whole-file controls on that row were measured staying green while the
633+ // slice ran 3873 lines long. A subtracted slice needs a control on the
634+ // slice; the exception is exactly that wide and no wider.
607635 for ( const [ rel , marker , keyField ] of [
608636 [ 'packages/rest/src/rest-route-ledger.ts' , 'REST_ROUTE_LEDGER' , 'family' ] ,
609637 [ 'packages/runtime/src/route-ledger.ts' , 'ROUTE_LEDGER' , 'domain' ] ,
@@ -653,22 +681,86 @@ export function deriveProbeFileCensus(): {
653681 const helperDeclRe = / c o n s t \s + r e g i s t e r P e r I t e m R o u t e \s * = / ;
654682
655683 /**
656- * Registration sites in one haystack: direct call sites, LESS the helper's
657- * own forwarding call, PLUS the helper's call sites.
684+ * The helper's OWN extent, bounded by its OWN indentation.
658685 *
659- * ⛔ Fail-loud, like the ledger marker slice above: a helper declaration
660- * that moves out of this shape slices to '' and nothing is subtracted, so
661- * the reading comes out ONE HIGH (81 / 20) and this census goes RED. It
662- * never silently shrinks — a quietly narrower rule is the failure mode the
663- * whole file is built against.
686+ * ⛔ NEVER a forward search for the terminator's literal text. The rule
687+ * this replaced ended the slice at `hay.indexOf('\n };', at)` — an
688+ * unanchored forward search with no upper bound. Respell that terminator
689+ * as `}` with no semicolon (the single most ordinary way that line
690+ * changes, and nothing lints it — there is no ESLint `semi` rule in this
691+ * repo) and `indexOf` does not fail: it finds the NEXT `\n };`
692+ * anywhere later in the file. Measured 2026-09-08 against 44c849c7d6: the
693+ * slice ran from line 5132 to line 9004 — 3873 lines — and swallowed 21
694+ * direct `this.routeManager.register(` sites.
695+ *
696+ * The extent ends instead at the first non-blank line indented no deeper
697+ * than the declaration itself, whatever that line is spelled as. That is
698+ * spelling-independent, so the respelling above moves nothing.
699+ *
700+ * ⛔ It is still not TRUSTED — see `sites` below. An indentation scan can
701+ * land short (a body line dedented to the declaration's own level) or land
702+ * long (the closing line indented deeper), so the number of forwarding
703+ * calls it returns is read back as an exact control rather than assumed.
664704 */
665- const sites = ( hay : string ) : number => {
705+ const forwarderSlice = ( hay : string ) : string => {
666706 const at = hay . search ( helperDeclRe ) ;
667- const stop = at < 0 ? - 1 : hay . indexOf ( '\n };' , at ) ;
668- const forwarder = at < 0 || stop < 0 ? '' : hay . slice ( at , stop ) ;
669- return occurrences ( hay , mountRe ) - occurrences ( forwarder , mountRe ) + occurrences ( hay , helperCallRe ) ;
707+ if ( at < 0 ) return '' ;
708+ const indent = at - ( hay . lastIndexOf ( '\n' , at ) + 1 ) ;
709+ let cursor = hay . indexOf ( '\n' , at ) ;
710+ while ( cursor >= 0 ) {
711+ const nl = hay . indexOf ( '\n' , cursor + 1 ) ;
712+ const line = hay . slice ( cursor + 1 , nl < 0 ? hay . length : nl ) ;
713+ if ( line . trim ( ) !== '' && line . length - line . trimStart ( ) . length <= indent ) {
714+ return hay . slice ( at , cursor + 1 + line . length ) ;
715+ }
716+ if ( nl < 0 ) break ;
717+ cursor = nl ;
718+ }
719+ return '' ;
670720 } ;
671721
722+ /**
723+ * Registration sites in one haystack: direct call sites, LESS the helper's
724+ * own forwarding call, PLUS the helper's call sites.
725+ *
726+ * ⭐ THE SUBTRAHEND IS CHECKED, NOT TRUSTED, and that is the repair.
727+ * `occurrences(forwarderSlice(hay), mountRe)` is recorded as its own exact
728+ * control, pinned at 1 — the helper forwards exactly once. So:
729+ *
730+ * slice lands SHORT — declaration gone, or the extent scan stops early
731+ * ⇒ subtrahend 0, the reading comes out ONE HIGH, and the control
732+ * reads 0 against a recorded 1;
733+ * slice lands LONG — the extent scan overshoots the helper's own body
734+ * ⇒ subtrahend > 1, the reading comes out low, and the control reads
735+ * > 1 against a recorded 1.
736+ *
737+ * ⛔ It never silently shrinks. Not "it cannot shrink" — it can; the word
738+ * carrying the weight is SILENTLY. A low reading with the forwarder
739+ * control at 1 is a real population drop; a low reading with that control
740+ * off 1 is the slice eating too much. Before this control existed the two
741+ * were indistinguishable — the day someone genuinely removes 20 routes the
742+ * census reads 60 either way — and the two exact controls the spelling
743+ * change added (`registerPerItemRoute(` = 8,
744+ * `const registerPerItemRoute =` = 1) stay GREEN right through it, because
745+ * the declaration is still present and still matches; only its terminator
746+ * moved. Both legs measured, not argued.
747+ *
748+ * The control IS the subtrahend, which is what keeps it from being noise:
749+ * it fires exactly when an overshoot actually distorts the reading, and
750+ * stays at 1 through an overshoot over text that registers nothing — where
751+ * there is no distortion to report.
752+ *
753+ * ⚠️ The ledger marker slice above is NOT symmetric with this one, which is
754+ * why borrowing its "fail-loud" reasoning was the mistake. Its `\n];`
755+ * overshoot can only ADD rows, so it reads HIGH; this slice's overshoot
756+ * SUBTRACTS registrations, so it reads LOW — and low is the direction that
757+ * looks like an ordinary answer.
758+ */
759+ const sites = ( hay : string ) : number =>
760+ occurrences ( hay , mountRe ) -
761+ occurrences ( forwarderSlice ( hay ) , mountRe ) +
762+ occurrences ( hay , helperCallRe ) ;
763+
672764 // Slice the mintable registrar's body: from its declaration to the next one.
673765 const decls = [ ...src . matchAll ( registrarRe ) ] . map ( ( m ) => ( { at : m . index ?? 0 , text : m [ 0 ] } ) ) ;
674766 const metaIdx = decls . findIndex ( ( d ) => d . text . includes ( 'registerMetadataEndpoints' ) ) ;
@@ -682,6 +774,12 @@ export function deriveProbeFileCensus(): {
682774 'this.routeManager.register(' : occurrences ( src , / t h i s \. r o u t e M a n a g e r \. r e g i s t e r \( / g) ,
683775 'registerPerItemRoute(' : occurrences ( src , / r e g i s t e r P e r I t e m R o u t e \( / g) ,
684776 'const registerPerItemRoute =' : occurrences ( src , / c o n s t \s + r e g i s t e r P e r I t e m R o u t e \s * = / g) ,
777+ // ⭐ The one control here that is NOT a whole-file count, deliberately:
778+ // it is the SHAPE of the slice the population rule subtracts, and it is
779+ // the only reading that can tell "the slice ate too much" apart from a
780+ // real population drop. The four counts around it cannot — all four are
781+ // green while the slice is running 3873 lines long.
782+ 'forwarder slice: this.routeManager.register(' : occurrences ( forwarderSlice ( src ) , mountRe ) ,
685783 enforceAuth : occurrences ( src , / e n f o r c e A u t h / g) ,
686784 } ,
687785 } ) ;
0 commit comments