Repository navigation
test(build): read every single-file spec through readRepoSource - #306
Conversation
Five specs resolved a private repo root with `dirname(fileURLToPath(import.meta.url))` — the form #303's lint rule leaves alone, because `repo-source.ts` itself and six `scripts/*.mjs` legitimately write it. All five worked. The cost was that the pattern a tenth spec author copies was still the hand-rolled one. `src/lib/brand.test.ts` was the third shape: cwd-relative paths, working only because vitest runs from the repo root. `COPY_FILES` and `copySnapshot()` stay quoted repo-relative literals, which is how `select-unit-specs.mjs` reaches this spec from an edit to one of the seven copy files. A second eslint block bans `fileURLToPath(import.meta.url)` in specs alone, and restates #302's `new URL` selector inside it: flat config replaces a rule's options rather than merging them. `Widget.standalone.test.ts` keeps its root under a disable — `importGraph` resolves specifiers on disk, so it needs a directory, not text. The widest per-edit selection moves to `repo-source.ts` at 15 of a ceiling of 16, measured at 4.5s against the 12s budget. Both figures and the pin's comment are updated. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015WiFYX8KYs67v12sFLstz4
…o bans Review of the first commit found the spec glob restated #302's selector by hand, with nothing holding the two copies in sync, and shadowing block one's spec coverage for `no-restricted-syntax` at the same time — flat config replaces a rule's options. One hoisted constant and an `ignores` entry remove both: the scopes are now disjoint, and the selector has one home. Corrections the same pass turned up: - `repo-source.jsdom.test.ts` claimed no other spec could hold the WEB-transform property. Two of the rewired readers are jsdom, so it cannot say that. - `docs/testing.md` said #293 excludes a walker from the per-edit selection. `selectFrom` has no walker filter: it stopped ADDING them to every edit, and still selects one that names the edited module. What importing the walk costs is `source-tree.ts`'s module-scope `readdirSync`, which is the right reason for `repo-source.ts` to be its own module. - The widest edit's time was relabelled onto `repo-source.ts` without re-timing, so the doc carried 5.5s and 4.5s for one selection. Hook-timed, median of three on 4 cores: 4.5s. - `src/views/FullInterface.tsx` left the 0.12s class, since `MapFrame.test.tsx` now names it as a quoted path. 2.2s per edit, for a wiring pin that had no per-edit coverage before. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015WiFYX8KYs67v12sFLstz4
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is the ticket's size. Five specs lose their private roots, one disable stays where #289 said it would, and both bans land as specified — including the selector the ticket got wrong (arguments.0.type would never match; arguments.0.object.type does). Nothing is smuggled in: the docs/testing.md budget paragraph is named as joined, and its correction holds — source-tree.ts:16 really does readdirSync the tree at module scope, so the new rationale for repo-source.ts being its own module is sound where the walker-mark one was not. No contract surface is touched.
One thing the change creates rather than fixes: the ban makes readRepoSource the only legal way for a spec to read a repo file, so the width pin it leaves at 15 of 16 is now a ratchet that trips once per adopter.
Findings
- should-fix —
docs/testing.md:513still says 117 sources select nothing; this diff made it 116. - consider —
eslint.config.js:170'signoresis a no-op; verified both ways. - consider — the width ceiling measures adoption of a now-mandatory reader.
What was checked
Read: eslint.config.js, scripts/select-unit-specs.mjs, src/test-support/{repo-source,source-tree}.ts, the five migrated specs, Widget.standalone.test.ts, both docs/testing.md sections. Ran pnpm lint (clean) and select-unit-specs.test.ts (14 pass). Measured the selection through readLane/selectFrom: widest 15 on repo-source.ts, walkers 12, zero-selection 116 of 420, FullInterface.tsx → MapFrame.test.tsx — confirming the PR's figures and contradicting the 117. git grep fileURLToPath(import.meta.url) over specs returns only Widget.standalone.test.ts:52. Tested the ignores entry by deleting it and re-running both banned forms in a test-support/ spec. No preview to open, correctly.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The zero-selection class shrank with this branch's own change. Measured at the merge base and at this head through `readLane`/`selectFrom`: 420 lane sources either side, 117 selecting nothing before and 116 after, the one mover being `src/views/FullInterface.tsx` — the file the warning two paragraphs up already names. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NkiL26BZ1FHRg3udNBJeqi
A `test-support/` spec matched both `no-restricted-syntax` blocks, and flat config replaces a rule's options rather than merging them, so the spec block already decided which bans applied there. The `ignores` entry changed nothing, and it cost the fallback: with it, dropping the spec block would leave a `test-support/` spec with no ban at all. Watched all four ways on a throwaway `test-support/` spec carrying both banned forms: with the entry and without it, both bans error identically; with the spec block removed, the #302 URL ban errors only once the entry is gone. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NkiL26BZ1FHRg3udNBJeqi
Deploying sahajatlas with
|
| Latest commit: |
5907a93
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9b4c9837.sahajatlas.pages.dev |
| Branch Preview URL: | https://claude-test-289-repo-source.sahajatlas.pages.dev |
|
Addressed the adversarial review: two adopted, one rebutted. Head is now 5907a93.
Lean gate green after both commits — 145 files, 1755 tests. Body refreshed: the 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
readRepoSource; two eslint bans now make the reader the only way a spec reads a repo file.docs/testing.mdstated two different times for one selection, and claimed perf(test): move the repo-wide inventory specs off the per-edit path #293 excludes a walker from the per-edit selection. Neither held. The review pass found a third: the zero-selection class is 116, not 117, and this branch is what moved the one source out of it.Change outline
Contract — what a spec may write to reach a file on disk
no-restricted-syntaxcarries both bans, over two scopes sharing one selector constant. Flat config replaces a rule's options, so the spec block has to list every selector that applies there. That replacement is also why the non-spec block needs noignoresfor specs: the two can never stack, and leaving specs in its scope is what still bans the URL form in atest-support/spec if the spec block ever goes.The second ban is shape-specific, not a ban on
import.meta.url:src/lib/shadow-patches.test.tsresolves intonode_moduleswithcreateRequire(import.meta.url), which no repo-relative reader can serve.Flow — how a spec gets a repo file's text
DynamicEventsList.test.tskeeps its local comment strip andWidget.translate.test.tsits ownts.createSourceFile:readSourceWithoutCommentsandparseSourceboth import the walk, which walkssrc/at module scope.Preview
Nothing in this diff is observable in a preview — it changes specs, a lint config and two docs. No alias is read, so none is linked.
Test results
pnpm lint && pnpm typecheck && pnpm test:run— 145 files, 1755 tests, re-run after the review commitsscripts/select-unit-specs.test.tsgreen, walker set still the pinned 12test-support/module, atest-support/spec, and ascripts/*.mjsignoresentry watched four ways on a throwawaytest-support/spec carrying both banned forms: with it and without it, both bans error identically; with the spec block removed, the test(build): a repo-root reader, so thenew URL(…, import.meta.url)trap can be linted #302 URL ban errors there only once the entry is gonereadLane/selectFromat the merge base (1b26e8c) and at this head: 420 lane sources either side, 117 → 116, the one moversrc/views/FullInterface.tsxFullInterface.tsx's<MapFrame contained>,globals.css's--sy-frame-h,Widget.tsx'sref={adoptThemeRoot}and its scope root'stranslate="no",DynamicEventsList.tsx'ssortEventsargument, and a brand string in bothCompactEmbedView.tsxandtranslations.en.jsonManual verification
Nothing. Every criterion is a lint rule or a spec, and both were watched failing.
Notes for reviewer
repo-source.tsat 15, one under the ceiling of 16. A spec can read a repo file no other way, so this grows by one per adopter and the second new source-reading spec tripsselect-unit-specs.test.ts. I left the ceiling alone rather than ratchet it on this PR, and put the response in the pin's comment: time the hook and raise it, never drop a spec from the selection. Hook-timed, 15 specs cost 4.5s of a 12s budget. The review pass asked whether a time pin or a reader-excluding ceiling would hold the budget better; both answers are on that thread.Widget.standalone.test.ts's disable is rule-wide, so it lifts test(build): a repo-root reader, so thenew URL(…, import.meta.url)trap can be linted #302'snew URLban on that line too. That ban guards an at-import crash under the WEB transform and the spec is node-only, so there is nothing there to catch — stated in the comment, with what changes if the file ever takes a jsdom docblock.the private spec readers readRepoSource supersedes; this one names what the change does.Detail
Rejected: ban
import.meta.urloutright in specs (MemberExpression[object.type="MetaProperty"][property.name="url"]). It catches four spellings the shipped pair does not, includingurl.fileURLToPath(import.meta.url)and a root laundered through a local variable. It also failssrc/lib/shadow-patches.test.ts'screateRequire(import.meta.url), which is not a hand-rolled repo root and has no reader to move to — so the broader rule buys a second standing exemption for a legitimate use. Every repo-root call site in the tree importsfileURLToPathby name, so the escapes are routes a deliberate author takes, not ones the next author copies.Rejected:
src/Widget.standalone.test.tsshould usejoin(REPO_ROOT, 'src'), whichsource-tree.tsitself does. It is byte-identical to the root that spec computes, butselectFromis text-based: namingrepo-sourcethere takes the widest selection from 15 to 16, flush against the ceiling. Measured, not assumed. The ticket scopes the spec out for theimportGraphreason as well.Rejected:
ignores: ['src/Widget.standalone.test.ts']in place of the line disable. It is wider, not narrower — the spec block is the onlyno-restricted-syntaxblock that matches the file, so anignoresentry lifts both bans for the whole file where the disable lifts them for one line.Rejected: renaming
selectFrom'sleaves the tree-walking specs out of the selectioncase. The name is loose —selectFromhas no walker filter — but the comment under it states the mechanism exactly, and the name describes what #293 changed. Pre-existing, and outside this diff.Rejected: a time pin, or a ceiling that excludes the shared reader, in place of the width pin the new ban ratchets. The budget is 12s on 4 cores and
docs/testing.md:535records every time figure in it as unchecked, so a timed assertion flakes with the runner's core count. Excluding the reader would stop the pin bounding what the hook actually spawns — editingrepo-source.tsreally does run those 15 specs. Width is a declared proxy for the slice (line 528), and a trip is the designed signal to re-time and raise.Corrections the review pass found, all committed:
docs/testing.mdsaid 117 of 420 lane sources select nothing. This branch made it 116:src/views/FullInterface.tsxis the one source that left the class, which the warning two paragraphs up already named. Measured at the merge base and at this head.eslint.config.js'signores: ['**/*.{test,spec}.{ts,tsx}']on the non-spec block was a no-op, because flat config hands a doubly-matched file the spec block's options whole. Dropped, which also restores the fallback: with the entry, dropping the spec block would have left atest-support/spec with no ban at all.repo-source.jsdom.test.tssaid no other spec could hold the WEB-transform property.MapFrame.test.tsxandWidget.theme-root.test.tsxare both jsdom and both now read through the reader.docs/testing.mdsaid perf(test): move the repo-wide inventory specs off the per-edit path #293 excludes a walker from the per-edit selection.selectFromiscoLocated ∪ referencingwith no walker filter: perf(test): move the repo-wide inventory specs off the per-edit path #293 stopped adding the walkers to every edit, and a walker that names the edited module still runs. Measured — editingsrc/config/responsive.tsselects its walker spec, and editingrepo-source.tsselects two. What importing the walk actually costs issource-tree.ts's module-scopereaddirSyncof the tree, which is the sound reason forrepo-source.tsto be its own module.repo-source.tswithout re-timing, leaving 5.5s and 4.5s in the tree for one selection. Hook-timed, median of three on 4 cores: 4.5s.src/views/FullInterface.tsxleft the 0.12s class.MapFrame.test.tsxread it asviews/FullInterface.tsx, whichresolveSpecifierreturnsnullfor, so the pin had no per-edit coverage at all; assrc/views/FullInterface.tsxit resolves, and the edit now costs 2.2s. Recorded beside the budget, since it is the price a quoted literal is paid with.Measurements, all on 4 cores, hook-timed, median of three:
repo-source.ts4.48 / 4.47 / 4.36s;FullInterface.tsx2.55 / 2.16 / 2.21s.i18n.tsmeasured 5.9s here against the 6.6s on record; I left the recorded figure alone, since it was taken with the same method on another box and the comparison it supports — widest is not slowest — holds under both.Not re-litigated:
src/lib/shadow-patches.test.tskeepscreateRequire(import.meta.url), per the ticket's out-of-scope list.Closes #289
🤖 Written by the sydevs autonomous loop — see what this is
🤖 Generated with Claude Code
https://claude.ai/code/session_015WiFYX8KYs67v12sFLstz4
Generated by Claude Code