Skip to content

test(build): read every single-file spec through readRepoSource - #306

Merged
sydevs-bot merged 4 commits into
mainfrom
claude/test-289-repo-source-readers
Oct 16, 2026
Merged

sydevs-bot merged 4 commits into
mainfrom
claude/test-289-repo-source-readers

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Five specs hand-rolled a repo root instead of calling readRepoSource; two eslint bans now make the reader the only way a spec reads a repo file.
  • Joined: the budget paragraph in docs/testing.md stated 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-syntax carries 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 no ignores for specs: the two can never stack, and leaving specs in its scope is what still bans the URL form in a test-support/ spec if the spec block ever goes.

 eslint.config.js
+const NO_URL_FROM_IMPORT_META = { selector: 'new URL(…, import.meta.url)', message: '…(#302)' }
 
-files: ['**/*.{test,spec}.{ts,tsx}', 'src/test-support/**/*.ts', 'scripts/**/*.mjs']
+files: ['src/test-support/**/*.ts', 'scripts/**/*.mjs']   # the non-spec half of the graph
   no-restricted-syntax: [NO_URL_FROM_IMPORT_META]
+
+files: ['**/*.{test,spec}.{ts,tsx}']
+  no-restricted-syntax: [
+    NO_URL_FROM_IMPORT_META,                               # same object, not a second copy
+    fileURLToPath(import.meta.url) → readRepoSource (#289) # the SAFE form, banned in specs
+  ]

The second ban is shape-specific, not a ban on import.meta.url: src/lib/shadow-patches.test.ts resolves into node_modules with createRequire(import.meta.url), which no repo-relative reader can serve.

Flow — how a spec gets a repo file's text

 a spec needs one file's text
-  dirname(fileURLToPath(import.meta.url))        # its own root, 4 shapes across 5 specs
-  readFileSync(join(SRC, <src-relative path>))
-  readFileSync(<cwd-relative path>)              # brand.test.ts — works only from the repo root
+  readRepoSource(<repo-relative path>)           # src/test-support/repo-source.ts
 
 a spec needs the source TREE
   sourceFiles() / readSource()                   src/test-support/source-tree.ts — unchanged
 
 a spec needs a DIRECTORY, not text
   src/Widget.standalone.test.ts                  # importGraph resolves specifiers on disk
     keeps its own root, under one eslint-disable-next-line

DynamicEventsList.test.ts keeps its local comment strip and Widget.translate.test.ts its own ts.createSourceFile: readSourceWithoutComments and parseSource both import the walk, which walks src/ 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

  • Lean gate: ✓ pnpm lint && pnpm typecheck && pnpm test:run — 145 files, 1755 tests, re-run after the review commits
  • Targeted specs: the 6 touched specs pass (39 tests); scripts/select-unit-specs.test.ts green, walker set still the pinned 12
  • Both lint bans watched going red, in all four scopes they cover — a spec, a test-support/ module, a test-support/ spec, and a scripts/*.mjs
  • The dropped ignores entry watched four ways on a throwaway test-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 the new URL(…, import.meta.url) trap can be linted #302 URL ban errors there only once the entry is gone
  • The zero-selection figure measured through readLane/selectFrom at the merge base (1b26e8c) and at this head: 420 lane sources either side, 117 → 116, the one mover src/views/FullInterface.tsx
  • Each migrated spec watched going red with its own defect reintroduced at the causing site: FullInterface.tsx's <MapFrame contained>, globals.css's --sy-frame-h, Widget.tsx's ref={adoptThemeRoot} and its scope root's translate="no", DynamicEventsList.tsx's sortEvents argument, and a brand string in both CompactEmbedView.tsx and translations.en.json
  • Build: N/A — CI runs it

Manual verification

Nothing. Every criterion is a lint rule or a spec, and both were watched failing.

Notes for reviewer

  • The widest per-edit selection is now repo-source.ts at 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 trips select-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 the new URL(…, import.meta.url) trap can be linted #302's new URL ban 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.
  • Title differs from the issue's. The issue's reads the private spec readers readRepoSource supersedes; this one names what the change does.
  • Dismissed findings are in the Detail block, with reasons.
Detail

Rejected: ban import.meta.url outright in specs (MemberExpression[object.type="MetaProperty"][property.name="url"]). It catches four spellings the shipped pair does not, including url.fileURLToPath(import.meta.url) and a root laundered through a local variable. It also fails src/lib/shadow-patches.test.ts's createRequire(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 imports fileURLToPath by name, so the escapes are routes a deliberate author takes, not ones the next author copies.

Rejected: src/Widget.standalone.test.ts should use join(REPO_ROOT, 'src'), which source-tree.ts itself does. It is byte-identical to the root that spec computes, but selectFrom is text-based: naming repo-source there takes the widest selection from 15 to 16, flush against the ceiling. Measured, not assumed. The ticket scopes the spec out for the importGraph reason 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 only no-restricted-syntax block that matches the file, so an ignores entry lifts both bans for the whole file where the disable lifts them for one line.

Rejected: renaming selectFrom's leaves the tree-walking specs out of the selection case. The name is loose — selectFrom has 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:535 records 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 — editing repo-source.ts really 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.md said 117 of 420 lane sources select nothing. This branch made it 116: src/views/FullInterface.tsx is 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's ignores: ['**/*.{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 a test-support/ spec with no ban at all.
  • repo-source.jsdom.test.ts said no other spec could hold the WEB-transform property. MapFrame.test.tsx and Widget.theme-root.test.tsx are both jsdom and both now read through the reader.
  • docs/testing.md said perf(test): move the repo-wide inventory specs off the per-edit path #293 excludes a walker from the per-edit selection. selectFrom is coLocated ∪ referencing with 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 — editing src/config/responsive.ts selects its walker spec, and editing repo-source.ts selects two. What importing the walk actually costs is source-tree.ts's module-scope readdirSync of the tree, which is the sound reason for repo-source.ts to be its own module.
  • The widest edit's figure was relabelled onto repo-source.ts without 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.tsx left the 0.12s class. MapFrame.test.tsx read it as views/FullInterface.tsx, which resolveSpecifier returns null for, so the pin had no per-edit coverage at all; as src/views/FullInterface.tsx it 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.ts 4.48 / 4.47 / 4.36s; FullInterface.tsx 2.55 / 2.16 / 2.21s. i18n.ts measured 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.ts keeps createRequire(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

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 sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 16, 2026
@sydevs-bot

sydevs-bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 18:12Z address-review · attempt 1 · session · done
  • 18:12Z address-review · attempt 1 · session
  • 18:03Z review-pr · attempt 1 · session · done
  • 18:03Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 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:513 still says 117 sources select nothing; this diff made it 116.
  • consider — eslint.config.js:170's ignores is 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

Comment thread docs/testing.md Resolved
Comment thread eslint.config.js Resolved
Comment thread scripts/select-unit-specs.test.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 16, 2026
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
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Deploying sahajatlas with  Cloudflare Pages  Cloudflare Pages

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

View logs

@sydevs-bot

Copy link
Copy Markdown
Contributor Author

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 Change outline diff no longer shows the dropped line.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 16, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review October 16, 2026 18:24
@sydevs-bot
sydevs-bot requested a review from Ardnived October 16, 2026 18:24
@sydevs-bot
sydevs-bot enabled auto-merge October 16, 2026 18:24
@sydevs-bot sydevs-bot moved this from Revising to Approved in SYDevelopers Technical Roadmap Oct 16, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Oct 16, 2026
Merged via the queue into main with commit bfa67ed Oct 16, 2026
63 of 66 checks passed
@sydevs-bot
sydevs-bot deleted the claude/test-289-repo-source-readers branch October 16, 2026 19:40
@sydevs-bot sydevs-bot moved this from Approved to Done in SYDevelopers Technical Roadmap Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

test(build): the private spec readers readRepoSource supersedes

3 participants