Skip to content

Commit b05ce97

Browse files
fix(check-doc-anchors): spell the heading-ids remedy so it cannot be read as a watch-hint declaration (#13775)
The remedy line printed for a broken anchor is a command for a human to paste at the repo root, and it carried the module specifier as a quoted relative literal `'./scripts/check-doc-anchors.mjs'`. The dispatch watch-hint extractor reads quoted path-shaped literals in a gate's module body and resolves the relative ones against the writer's own directory, so this gate — which lives in scripts/ — declared a path that has never existed on this tree, and that lead was pasted into every dispatch prompt the family matched. Neither half was wrong on its own; the fabrication came from prose being read as a declaration. Tightening the reader was measured and refused upstream, so the producer spells the path absolutely instead: process.cwd() + a leading-slash literal, which the extractor's admission test refuses outright while the command stays runnable verbatim from the repo root. Claude-Session: https://claude.ai/code/session_01Pk26oZ12t5N1hwGW1m1MgC Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4301f78 commit b05ce97

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

scripts/check-doc-anchors.mjs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,30 @@ function runCheck() {
456456
'\n\n The heading id is computed with `github-slugger`, the same package\n' +
457457
' fumadocs-core uses to render the page, so what this gate says the anchor is\n' +
458458
' is what the site says it is. Print a page\'s real ids with:\n' +
459-
" node -e \"import('./scripts/check-doc-anchors.mjs').then(m=>console.log(m.headingIds(require('node:fs').readFileSync('<file>','utf8')).join('\\n')))\"\n" +
459+
// ⚠️ The specifier below is spelled ABSOLUTE — `process.cwd()+'/scripts/…'` — and that is
460+
// load-bearing rather than style. This line is a REMEDY: prose for a human, to be pasted
461+
// into a shell already sitting at the repo root. Spelled the natural way, as a quoted
462+
// `./scripts/…` literal, it is ALSO a well-formed watch-hint DECLARATION to the dispatch
463+
// derivation, which scans a gate's module body for quoted path-shaped literals and
464+
// resolves the relative ones against the directory of the file that WROTE them. This gate
465+
// lives in `scripts/`, so a literal written in the ROOT frame came back with its own
466+
// directory prepended — a lead naming a path that has never existed on this tree, pasted
467+
// into every dispatch prompt whose file surface brushes this family, and indistinguishable
468+
// there from a real one.
469+
//
470+
// Neither half was wrong on its own: the remedy is correct for its reader and the extractor
471+
// is correct about a declaration — the fabrication came from one being read as the other.
472+
// Tightening the reader was measured and REFUSED (#13312: the sanctioned declaration idiom
473+
// is structurally indistinguishable from an incidental module-scope constant, priced at 8.6
474+
// real populations deleted per fabrication removed), so the repair belongs to the PRODUCER:
475+
// spell the path so it cannot be read as a declaration. The leading `/` inside the quotes is
476+
// the whole mechanism — the extractor's admission test requires a literal to begin with a
477+
// word character, `.` or `@`, so an absolute path is refused outright — and `process.cwd()`
478+
// is what keeps the command runnable verbatim from the repo root, which is the only reason a
479+
// remedy line exists. ⛔ Do not "tidy" it back to a quoted relative specifier. What this gate
480+
// really reads is declared above and deliberately, in `CONTENT_GLOB` and
481+
// `ROOT_FILE_WATCH_HINTS` (#13449).
482+
" node -e \"import(process.cwd()+'/scripts/check-doc-anchors.mjs').then(m=>console.log(m.headingIds(require('node:fs').readFileSync('<file>','utf8')).join('\\n')))\"\n" +
460483
' Fix the link, or fix the heading. Do not add an exemption — an anchor that\n' +
461484
' nobody may check is the defect this gate exists to remove (#7484).',
462485
);

0 commit comments

Comments
 (0)