Skip to content

docs-drift's registrar window swallows the NEXT route whole when that route's path: is a variable — a foreign handler's code identifiers bridge to the previous route #9503

Description

@os-steve

Filed unassigned by the os-dev seat working #9432 (session session_01XqDQYVU5smx29ts9pAErja). Out of that card's scope — recording rather than fixing. Same file as #9432 / #9331, different defect, and it survives both of them.

What

parseRegistrarSource in scripts/docs-audit/affected-docs.mjs finds registration sites with

constm=lines[i].match(/(?:^|[\s{,(])path\s*:\s*([`'"])(.*?)\1/);

— a path: whose value is a string or template literal. A registration whose path is a
plain variable (path: publishedPath) matches nothing, so it is not a site. It therefore does
not end the previous site's window either, and the previous route's window runs its full
REGISTRAR_HANDLER_WINDOW (150 lines) straight through the invisible registration and into
another route's handler body. Every identifier in that foreign handler is then credited to the
previous route.

Measured — on origin/main at 017c27e73, and still true with #9432's fix applied

Counting only sites the scan can see, packages/** registrar files carry 86 literal path:
sites and 33 path: lines that are not literals
. Several of the latter are genuine
registrations: rest-server.ts alone has path: basePath (3121), path: metaPath (3528) and
path: publishedPath (5747); package-routes.ts:473 has path: packagesPath;
metadata/src/routes/hmr-routes.ts:107 has path: evt.path.

The concrete swallow, read off the comment-masked source so it is not #9432's defect:

/:name/state/:field site at rest-server.ts:5661
window ends 5811 (150 lines; next LITERAL site is 5916)
path: publishedPath at 5747 is inside it and invisible
-> `publishedPath` and every other code identifier of that
handler counts as an implementation of /:name/state/:field

So a diff touching a symbol the published door implements can put the state-machine page on
the advisory, with a via that says the page names something the diff touched. It also works
the other way as a recall miss: the variable-path route has no window of its own at all, so
nothing ever bridges to it.

Why it is worth a card rather than a shrug

Same reasoning as #9294 and #9432: the per-row via promise is a claim about implementation,
and here it is false for a whole handler at a time rather than one prose line. Unlike those
two, this one has a recall half as well — the invisible routes are unreachable.

Direction, not a prescription

Cheapest correct-looking move is to treat anypath: line as a site boundary while only
literal ones produce a tail, which closes the swallow without pretending to resolve the
variable. Whether the variable-path routes should also be resolved (a one-hop const lookup in
the same file) is a separate, larger question and should be measured before it is attempted —
#9432 measured that this scan's precision work is only worth doing with before/after numbers on
real commits, and the same standard applies here.

Note the file is contended: #9331 is queued on it and #9432 just landed on it. Sequence
accordingly.

Refs: #9432 (the prose half of the input side, fixed in #9502), #9294 (the container half),
#9331 (output side, different hop), #9192 (the precision rework all of these regress against).


Generated by Claude Code

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions