Skip to content

perf(test): move the repo-wide inventory specs off the per-edit path - #304

Merged
sydevs-bot merged 6 commits into
mainfrom
claude/perf-293-per-edit-walkers
Oct 16, 2026
Merged

sydevs-bot merged 6 commits into
mainfrom
claude/perf-293-per-edit-walkers

Conversation

@sydevs-bot

Copy link
Copy Markdown
Contributor

Summary

  • The twelve tree-walking inventories left the per-edit selection. An edit with no spec of its own goes from 3.8s to 0.12s, the slowest edit from 9.0s to 6.6s.
  • docs/testing.md carries the re-measured figures and what the inner loop gives up: the inventory signal on every edit, which the lean gate and CI still catch.

Change outline

Flow — what one lane edit pays

 PostToolUse Edit|Write                          .claude/hooks/unit-test.mjs
   selectSpecs(rel)                              scripts/select-unit-specs.mjs
     isLaneSource(rel) → else []
     readLane(root)                              # 143 spec texts, once
       referenceIndex: resolve every quoted specifier → module it addresses
-      treeWalkingSpecs: the twelve that enumerate the tree   # selected below
+      treeWalkingSpecs: still reported, for the closed-list pin only
     co-located    Foo.tsx → Foo.test.tsx, Foo.mount.test.tsx
     referencing   index lookup: @/config/api/client · ./client · 'src/App.tsx'
-    tree-walking  always, since nothing in them references the edit
-  spawn vitest run <10–24 specs>                # ≥12 for every lane source
+  specs.length === 0 → exit 0                   # 117 of 417 lane sources
+  spawn vitest run <1–14 specs>
   non-zero exit → additionalContext, continue: true

Behaviour — what the spec now pins

 scripts/select-unit-specs.test.ts
-  selectFrom(fixture source) contains walker.test.tsx and shared.test.tsx
+  selectFrom(fixture source) contains neither      # either route fails it
+  selectFrom(a lane source no spec names) === []   # the no-spawn case
   lane.walkers === WALKERS                         # unchanged closed list
-  widest selection ≤ 26                            # 24, src/config/i18n.ts
+  widest selection ≤ 16                            # 14, src/lib/shape/index.ts

Preview

Nothing deployed changes: the diff touches scripts/ and docs/ only, so neither entry graph moves and pnpm size reads the same bundle. There is no page to open.

Test results

  • Lean gate: ✓ lint + typecheck + test:run (143 files, 1752 tests, 76s)
  • Targeted specs: 14 passed (scripts/select-unit-specs.test.ts), each new assertion watched failing first — with ...lane.walkers restored in selectFrom (3 red), and with one name dropped from WALKERS (1 red)
  • Build: N/A — no file in either entry graph is touched

Manual verification

  1. Edit a lane source with no spec of its own (src/config/embed.ts) in a session with the hook enabled, and confirm the feedback is immediate and silent — no vitest run at all.
  2. Break a spec's subject (src/lib/geo.ts) and confirm the failure still arrives as non-blocking context.

Notes for reviewer

The ticket's 1751-test count is now 1752. The new selectFrom case is the extra one; the 143 files and the twelve inventories are unchanged.

Two findings dismissed, both measured.

  • readLane still computes walkers on the hook's path, for a field only the closed-list pin reads. Measured at 1.1–1.2ms against a 130ms no-spawn floor, about 1%. The ticket's approach keeps the field deliberately, so a lazy getter is a follow-up rather than this PR's.
  • The width ceiling bounds the slice, not the time: src/config/i18n.ts selects 12 with four jsdom specs and takes 6.6s, while the widest selection (14, three jsdom) takes 5.5s. jsdom count tracks the clock better than width does. Pre-existing, and the ticket chose to state it rather than add a second guard — docs/testing.md and the ceiling's comment now both say width never bounds time.

Three figures the review pass corrected, in the second commit: 117 of 417 lane sources select nothing (not 137, which the ticket carried); i18n.ts boots four jsdom specs of twelve (not two); and the lost inventory signal applies to every edit, not only to the 117 — src/config/translations.test.ts, for one, is now selected for 6 of 417 sources, by reference alone.

Fixture pre-mortem. The new fixture source src/lib/unspoken.ts assumes no other fixture file names it, so the selection is genuinely empty rather than empty by resolution failure — checked against the same beforeAll's other write() calls, which name thing, thing-other and the shared walk only. The tree's wider assumption, that the lane collects src/** and scripts/** specs named *.test.ts(x), is asserted in the same file against vitest.config.ts's own include.

Detail

Measured on this branch, 4 cores, median of three, wall clock of the whole hook command. Baselines are the same machine at 2ac15db.

Edited file specs before hook before specs after hook after
src/config/embed.ts (no spec of its own) 12 3.8s 0 0.12s
src/config/i18n.ts (slowest) 24 9.0s 12 6.6s
src/lib/shape/index.ts (widest) 24 7.2s 14 5.5s

Selection width across all 417 lane sources: 117 select nothing, max 14.

Why the one-line change and not a vitest projects split, which the ticket was first filed with: the hook already exits before spawning vitest on an empty selection, so the split buys the identical saving for a config split, a hook flag and CI wiring — and the hook lives under .claude/, a protected path no unattended run can write. docs/testing.md keeps that as a breadcrumb so the alternative is not re-derived.

What was kept on purpose. treeWalkingSpecs, the ENUMERATES detector and the SHARED_WALK constant stay in the selector: the closed-list pin is their reader, and it is now the only thing that notices an inventory joining or leaving the set. Both files say which guard catches which failure — the fixture equality catches the set returning to the selection, the closed list catches a detector that stops matching.

Rejected for #285 and not revisited: a node-vs-jsdom project split (~20s and ~15s, neither half fits a budget), isolate: false (20s and flaky), and vitest related (26s on one leaf module).

Closes #293

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


Generated by Claude Code

The twelve inventory specs hold no reference to the file that breaks them,
so the selector ran all twelve on every edit. That floor was 3.8s of each
edit, and 117 of 417 lane sources selected nothing else.

`selectFrom` no longer takes `lane.walkers`. `readLane` still reports the
set, because the closed-list pin is what notices one joining or leaving it,
and the hook needs no edit: it exits before spawning vitest on an empty
selection — which also keeps the change out of `.claude/`, a protected path
no unattended run can write.

Measured on 4 cores, median of three: an edit with no spec of its own goes
from 3.8s to 0.12s, `src/config/i18n.ts` from 9.0s to 6.6s, and
`src/lib/shape/index.ts` from 7.2s to 5.5s. What it costs is the inner
loop's inventory signal, on every edit rather than on a subset: the twelve
still run in `pnpm test:run`, the lean gate and CI, so a break surfaces in
the same session.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UCFy62tDxRMU5NtPHrNYVM
The review pass found the new prose claiming more than the assertions hold.
The fixture equality fails when `selectFrom` takes the walkers back, by
either route, but not when a detector stops matching — that is the closed
list's job, and both files now say which guard catches which.

Three measured corrections: 117 of 417 lane sources select nothing, not
137; `src/config/i18n.ts` boots four jsdom specs of its twelve, not two,
against three of the widest selection's fourteen; and the per-edit
inventory signal is lost on every edit, not only on the 117 — the lane is
what still covers it. `docs/testing.md` also keeps a breadcrumb for the
vitest `projects` split this ticket was filed with, and why it was dropped.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UCFy62tDxRMU5NtPHrNYVM
@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: b1f26ab
Status: ✅  Deploy successful!
Preview URL: https://dfeef6cf.sahajatlas.pages.dev
Branch Preview URL: https://claude-perf-293-per-edit-wal.sahajatlas.pages.dev

View logs

@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
  • 17:15Z resolve-conflicts · attempt 1 · session · done
  • 17:15Z resolve-conflicts · attempt 1 · session
  • 08:18Z address-review · attempt 1 · session · done
  • 08:18Z address-review · attempt 1 · session
  • 08:10Z review-pr · attempt 1 · session · done

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 and nothing else: one five-line deletion in selectFrom, the two spec changes the acceptance criteria name, and the docs rewrite. I re-derived every figure it claims from the branch tree and all of them hold. No contract surface is touched, so there is no consumer side to follow.

What stands against it is prose. One measured figure in the rewritten section is now wrong and contradicts one above it. The section also states the superseded behaviour three times, in a file AGENTS.md loads into every session here. One question is left open: what the walker detector guards, now that only its own pin reads it.

Findings

  • should-fix — docs/testing.md:441 keeps a scripts/ edit at "~3.6s" and "six specs". This change invalidates the first, and the second was already wrong. (file thread)
  • consider — the before-figures are restated three times, and both code files narrate "until #293" (docs/testing.md:422).
  • consider — lane.walkers has one reader, so what does the closed list protect now? (scripts/select-unit-specs.mjs:166)

What was checked

  • Read docs/testing.md:410-488, both scripts/select-unit-specs* files and .claude/hooks/unit-test.mjs whole, on the branch. The hook exits at :33 on an empty selection, so the no-hook-edit claim and the protected-path argument hold.
  • Ran readLane and selectFrom over all 417 lane sources of the branch tree: 143 specs, 12 walkers, 117 selecting nothing, widest 14 on src/lib/shape/index.ts, i18n.ts at 12 with four jsdom. Every stated figure matched. readLane measures ~21ms against the stated 130ms floor, so the walkers cost dismissal stands.
  • Nothing outside the three files names the dropped source. ## Preview claims no deployable change; the diff touches scripts/ and docs/ only. Reviewer profile read.

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


Generated by Claude Code

Comment thread docs/testing.md Resolved
Comment thread docs/testing.md Resolved
Comment thread scripts/select-unit-specs.mjs 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
`listSpecs` returns eight `scripts/` specs, not six, and the ~3.6s was the
walker floor this branch removes: a `scripts/` edit now selects at most two
specs, and six of the 21 `scripts/` sources select none. Re-measured on 4
cores, median of three.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RMZoR6cFqLarLRu1LW1qMa
The before-figures were stated at three sites in a file AGENTS.md loads into
every session, and both spec comments echoed them. docs/rules/code-comments.md
says never narrate the change. The trade paragraph and the #293 breadcrumbs
stay; the 3.8s / 9.0s / 7.2s / 24-of-26 restatements go.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RMZoR6cFqLarLRu1LW1qMa
The list gates nothing now that no edit selects a walker. Its job is to be the
register of which specs carry no per-edit signal — the set the trade paragraph
in docs/testing.md is scoped by — so say that where its one reader is, rather
than leave "notices one joining or leaving" to be read as a gate.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RMZoR6cFqLarLRu1LW1qMa
@sydevs-bot

sydevs-bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Three threads adopted, pushed as 0dd782b. No rebuttals, nothing asked.

Lean gate re-run green: 143 files, 1752 tests, 70s. All three commits are prose, so the body needed no refresh.

🤖 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 08:29
@sydevs-bot
sydevs-bot requested a review from Ardnived October 16, 2026 08:29
@sydevs-bot
sydevs-bot enabled auto-merge October 16, 2026 08:29
@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
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 16, 2026
@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
#303 moved this selector's repo root off `new URL(…, import.meta.url)` and
lifted the spec's header comment above its imports, where this branch had
rewritten that comment in place. Kept #303's structure and this branch's
wording, since the sentence about walkers staying out of the selection is
what #293 changes.

`repo-source.ts`'s rationale in docs/testing.md rested on walkers running on
every edit, which this branch ends. Restated against the new behaviour: a
reader importing the walk would now take its callers off the inner loop
instead of onto every edit. The module split stands either way.

Re-measured the two totals the merge moved: 420 lane sources, not 417, and
`translations.test.ts` reaches 7 of them. 117 selecting nothing and the
widest at 14 are unchanged.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GSuT7wgPRVBUbR9bRgHwEP
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged main (#303) in. One conflict, in scripts/select-unit-specs.test.ts: #303 lifted the header comment above the imports and took ROOT from the selector's export, while this branch had rewritten that comment in place. Kept #303's structure and this branch's wording — the sentence about walkers staying out of the selection is what #293 changes.

Two things the auto-merge could not see:

  • repo-source.ts's rationale in docs/testing.md rested on walkers running on every edit, which this branch ends. Restated: a reader importing the walk would now take its callers off the inner loop. The module split stands either way.
  • test(build): a repo-root reader, so the new URL(…, import.meta.url) trap can be linted #303's three new files widened the lane, so two totals moved — 420 lane sources, and translations.test.ts reaching 7 of them. 117 selecting nothing and the widest at 14 are unchanged.

Lean gate green on the merge: 145 files, 1755 tests, 71s.

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


Generated by Claude Code

@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels 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 1b26e8c Oct 16, 2026
17 checks passed
@sydevs-bot
sydevs-bot deleted the claude/perf-293-per-edit-walkers branch October 16, 2026 17:27
@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.

perf(test): move the repo-wide inventory specs off the per-edit path

3 participants