Repository navigation
test(scripts): hoist the doc-links corpus walk out of the timed window - #8419
Conversation
`check-doc-links.test.ts` has two whole-corpus tests that each walked every `SCAN_ROOTS` entry and handed all 273 files (2.5 MB of markdown) to fumadocs' `getTableOfContents`. Both timed out at vitest's 15 s default under container load. Measured on this tree, under the shared verify lock: the remark parse is 2.7-3.1 s per pass and everything the two tests actually assert adds up to 27 ms. The unbounded corpus walk was inside the bounded assertion window, and paid twice over identical inputs. Hoist the parse to module scope as `ANCHOR_CORPUS`, where the cost lands in the import phase that no `testTimeout` governs — and not in a `beforeAll`, which would trade the 15 s budget for the narrower 10 s `hookTimeout`. Each test now times its own assertion and asserts exactly what it asserted before. agrees with the real renderers ... 3964 ms -> 25 ms has no setext headings ... 3659 ms -> 35 ms whole file (121 tests) 10.32 s -> 6.10 s No timeout was raised and no assertion was weakened. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
|
ACCEPT — The dispatch forbade the reflex; the dev didn't just avoid it, it proved the reflex would have been wrongThe brief said don't raise a number because a number was exceeded, and demanded the dev name which of two shapes this defect is. The answer is shape 2 — unbounded shared work that had drifted into a bounded window — and it is settled by a standalone profile rather than by argument: ⇒ ~99 % of each 15 s window was fumadocs' remark parse of the whole corpus, and both tests parsed the same 273 files — the walk was paid twice over identical inputs. Everything the two tests actually assert totals 27 ms. A raised timeout would have bought nothing and hidden that. ⭐ And the obvious "clean" alternative is actively worse, which the dev caught. Verified independently: The premise was re-derived, and it held within 10 %
Result, and the proof that nothing was bought by weakening anything
The vitest summary shows the cost moving rather than vanishing: Checked here, not taken on trust: the diff is one file, ⭐ The ablation is the right one and it fires on both legs. A setext H2 was appended to And the corpus itself was measured rather than assumed: ScopeOne file. ⛔ Not the corpus, ⛔ not
Next: CI convergence → flip ready → post-flip guard → auto-merge SQUASH → queue confirmation → landing probe ( Generated by Claude Code |
|
Armed: PR #8419 flipped ready at 2026-09-07T21:43:04Z on head Landing probe on merge, on re-fetched Control: the file's own non-vacuity floors — ⭐ Recorded for the next reader: the fix removed a whole corpus parse rather than moving a deadline. The two tests spent ~99 % of their windows on fumadocs' remark parse of 273 files (3138 ms + 2746 ms) against 27 ms of actual assertion work, and both parsed the same files — the walk was paid twice over identical inputs. Raising the timeout would have bought nothing and hidden that; Then LANDED here and on #8062, which closes via Generated by Claude Code |
|
LANDED — merged into Content probe on re-fetched
⭐ What landed is the removal of a whole corpus parse, not a moved deadline. The two tests spent ~99 % of their windows on fumadocs' remark parse of 273 files — 3138 ms + 2746 ms — against 27 ms of actual assertion work, and both parsed the same files, so the walk was paid twice over identical inputs. Result: 3964 ms → 25 ms and 3659 ms → 35 ms, whole file 10.32 s → 6.10 s, with the cost visibly moving into the import phase (225 ms → 4.22 s) rather than vanishing. ⛔ Raising the timeout would have bought nothing and hidden all of that. Generated by Claude Code |
Fixes #8062
What was measured, and on what box
Every run below went through the shared heavy-verify lock
(
../objectstack/scripts/pm/os-verify-lock.sh, the convention recorded as objectui#8403),and each one printed its own
VERDICT command-exit 0line. The lock was held for everynumber in this PR. The lock excludes other locked runs, not unlocked sibling work, so
treat the absolutes as shared-box seconds and the ratios as the durable part.
Re-derived first, before changing anything —
pnpm exec vitest run scripts/__tests__/check-doc-links.test.ts --reporter=verbose:agrees with the real renderers on every heading in the scan surfacehas no setext headings, which the ATX-only scan would not seeThe card's idle figures (4429 ms / 3792 ms) reproduced, so the premise still holds. Against
vitest's 15000 ms default the headroom goes from 3.8x and 4.1x to 600x and 428x, and
the file as a whole gets 4.2 s faster because the walk is now paid once instead of twice.
Which of the two shapes this is: shape 2, with the split measured
The work had drifted into a bounded window; it does not belong there. A standalone profile of
the identical walk (plain node, no vitest, under the lock) splits the cost:
So ~99% of each test's window was fumadocs' remark parse of the whole corpus, and both
tests parsed the same 273 files — the hint in the card is right: it was shared work paid
twice over identical inputs. Everything the two tests actually assert adds up to 27 ms.
No timeout was raised. Nothing was skipped, quarantined or narrowed.
The repair
ANCHOR_CORPUSis now built once at module scope: collect theSCAN_ROOTSfiles, readeach one, strip frontmatter with the existing
documentBody(), and hand it to fumadocs'getTableOfContentswithremark-mdxfor.mdx— byte for byte the same call the two testseach used to make. Each
it()then measures only its own assertion.Module scope is the only home that qualifies, and AGENTS.md's test-discipline rule is the
reason for both halves of that:
testTimeoutgoverns (vitest's own summarymoves it there:
import 225msbefore,import 4.22safter);beforeAll, which would trade the 15 stestTimeoutfor thenarrower 10 s
hookTimeout— moving the problem, not fixing it.The two
loadToc/loadSlugger/loadMdxhelpers anddocumentBody()moved out of thedescribe body to module scope unchanged (a describe callback is synchronous, so the top-level
await could not live inside it).
loadSlugger()is still awaited inside the tests that use it;the github-slugger parity tests are untouched.
Proof that nothing asserted changed
git diff origin/main..HEAD -- scripts/__tests__/check-doc-links.test.ts | grep -E '^[-+].*expect\('prints nothing — noexpect(line was added, removed or edited anywhere in the diff.ROADMAP.md(a genuinely scanned file), proven on disk bygit hash-objectmovinge022b5d1toec9e1df5and by agrep -cof the injected text. Result — both corpus tests FAIL (Tests 2 failed | 119 passed (121)), in 36 ms and 37 ms, so the fixture really does feed both assertions. Restore leg proven by state: hash back toe022b5d1,git diff HEADempty.ANCHOR_CORPUS.length 273 · docsFiles 184 · diskFiles 89, identical to an independent walk ofSCAN_ROOTSoutside the test ({"total":273,"docs":184,"disk":89}). The file's own lit-instrument assertions (docsFilesover 150,diskFilesover 50) are unchanged and still pass. That mutation was restored the same way, hash and emptygit diff HEAD.Checks run, with real verdicts
pnpm exec vitest run scripts/__tests__/check-doc-links.test.ts --reporter=verboseTest Files 1 passed (1)·Tests 121 passed (121)pnpm exec vitest run scripts/Test Files 121 passed (121)·Tests 3615 passed (3615)· 93.34 spnpm lintTasks: 47 successful, 47 total, exit 0 (0 errors; the warning counts are pre-existing)pnpm type-check:scriptstsc --listFilesconfirms it really includes this test file, so that green is a measurementnode scripts/check-changeset-presence.mjspnpm check:control-bytespnpm check:lint-rule-coverage·check:vi-mock-specifiers·check:vi-mock-inherit·check:pre-install-import-graphScope fences respected: the corpus,
SCAN_ROOTS, the renderers and the github-slugger paritytest are all untouched. One file changed.
Drafted by an agent seat, session
session_01FhBNJcLRZLe8M87VcUgpKr; stays in draft.🤖 Generated with Claude Code
https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
Generated by Claude Code