Skip to content

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

Closed

Description

@sydevs-bot

Summary

The per-edit hook (.claude/hooks/unit-test.mjs) runs the specs one edit can break, under the 12-second budget docs/testing.md:417 states. Twelve of those specs enumerate the source tree instead of importing from it, so nothing in them references the edited file and the selector runs all twelve on every edit. That floor is 4.0s, and 137 of 417 lane sources select nothing else — the floor, not the selection, is most of what each edit pays.

Dropping the walkers from the per-edit selection takes an edit with no spec of its own from 4.0s to 0.09s, and the slowest edit in the tree from 9.1s to 5.8s. The inventories keep running in pnpm test:run, the lean gate and CI, so what this trades is per-edit immediacy, not coverage.

Approach

No vitest projects split, and no hook edit. The hook passes explicit spec paths and already exits before spawning vitest on an empty selection (.claude/hooks/unit-test.mjs:32), so removing the walker source from selectFrom is the whole mechanism. That matters beyond simplicity: .claude/ is a protected path, so the projects-and-hook approach this ticket was filed with could not have been built by an unattended run at all.

  1. Delete ...lane.walkers from selectFrom (scripts/select-unit-specs.mjs:190). Keep treeWalkingSpecs and readLane's walkers (:163, :176) and both detectors — ENUMERATES (:48) and SHARED_WALK (:55) — since the closed-list pin reads them.
  2. Invert the one fixture expectation that asserts the opposite (scripts/select-unit-specs.test.ts:133): the walker specs must be absent from selectFrom's result, by both routes. It goes red on step 1 as written, which is the guard working rather than a problem to route around.
  3. Leave the closed-list pin at :178 alone. WALKERS is what stops a walker silently leaving the set, and it must keep biting once the hook no longer runs them.
  4. Restate the width ceiling at :223 against the new widest selection — 14, on src/lib/shape/index.ts, down from 24 on src/config/i18n.ts. ⚠ The widest is no longer the slowest: src/config/i18n.ts selects 12 and measures 5.8s, because two of them boot jsdom. The ceiling pins width, so say in the comment there that time is measured separately.
  5. Rewrite docs/testing.md's budget section (:417): the three figures, the tree-walking bullet (:446), and the "lever left here" paragraph (:453) that this ticket closes. State what per-edit coverage is given up and where it is still caught.

Acceptance criteria

  • The hook spawns no vitest run for a lane source with no co-located and no referencing spec.
  • The twelve inventory specs still run in pnpm test:run and in CI — the lane's counts are unchanged at 143 files and 1751 tests.
  • A spec fails when an inventory spec is added to, or drops out of, the walker set.
  • A spec fails if the walkers are put back into selectFrom.
  • docs/testing.md's budget section carries the re-measured figures and names the per-edit coverage traded. The "lever left here" paragraph is gone, not reworded.

Verification checklist

All timings are the hook's own wall clock, on 4 cores, median of three. Baselines are main at f4da303, measured 2026-10-15.

  • echo "{\"tool_input\":{\"file_path\":\"$PWD/src/config/embed.ts\"}}" > /tmp/edit.json && time CLAUDE_PROJECT_DIR=$PWD node .claude/hooks/unit-test.mjs < /tmp/edit.json — a lane source with no spec of its own. Under 0.5s, against 4.0s.
  • Same command for src/config/i18n.ts — the slowest edit. Under 6.5s, against 9.1s.
  • Same command for src/lib/shape/index.ts — the widest selection after the change, 14 specs.
  • pnpm test:run — 143 files, 1751 tests.
  • pnpm vitest run scripts/select-unit-specs.test.ts — green. Then re-add ...lane.walkers to selectFrom and confirm it goes red.
  • Delete one entry from WALKERS and confirm the same spec goes red.

Notes

Measured on main at f4da303, 4 cores, median of three, 2026-10-15. The second column is the one-line selectFrom change applied locally and reverted.

Edited file specs on main hook on main specs after hook after
src/config/embed.ts (no spec of its own) 12 4.0s 0 0.09s
src/config/i18n.ts 24 9.1s 12 5.8s
src/lib/shape/index.ts 24 — 14 4.8s
the 12 walkers alone, as one vitest run 12 3.9s — —

#286 and #290 both landed, and the WALKERS reconciliation landed with them. The detector finds a walker two ways now — an ENUMERATES call, or an import of the shared walk — so the ten specs this ticket was filed against are twelve: the nine src/ inventories, source-tree.test.ts, and two scripts/ specs. scripts/select-unit-specs.test.ts and the lean gate are both green on f4da303, so nothing is outstanding from that merge. The ⚠ this ticket carried about doing the work after #286 is spent.

Per-edit coverage is the real cost, and it is bounded. After the change, 117 of 417 lane sources run nothing per edit, so adding an unregistered viewport read or JSX anchor to one of them gets no immediate signal. The lean gate (.claude/skills/pr-prep/check.sh, 77s whole) runs the full lane before every PR, and CI runs it again, so the break still surfaces in the same session. That is the answer to the coverage question raised on 2026-10-13: it is a latency-versus-immediacy trade with a gate behind it, not an uncovered path.

Rejected, measured: a vitest projects split, which this ticket was filed with. It buys nothing the one-line selectFrom change does not, needs an edit to a protected path under .claude/, and has to keep scripts/select-unit-specs.test.ts:203's regex parse of vitest.config.ts's top-level include and exclude arrays working.

Rejected for #285 and not revisited here: 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).

Activity

  1. added theissue type on Oct 13, 2026
  2. added
    proposal
    on Oct 13, 2026
  3. Ardnived commented on Oct 13, 2026

    @Ardnived
    Contributor

    @sydevs-bot implement

  4. removed
    proposal
    on Oct 13, 2026
  5. moved this from Proposed to Approved in SYDevelopers Technical Roadmapon Oct 13, 2026
  6. added
    bot:working
    on Oct 13, 2026
  7. sydevs-bot commented on Oct 13, 2026

    @sydevs-bot
    ContributorAuthor

    🤖 no session running

    recent dispatches
    • 07:46Z implement · attempt 2 · session · done
    • 07:46Z implement · attempt 2 · session
    • 05:14Z implement · attempt 1 · session · timed out
    • 05:14Z implement · attempt 1 · session
    • 00:52Z implement · attempt 2 · session · done

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

  8. sydevs-bot commented on Oct 13, 2026

    @sydevs-bot
    ContributorAuthor

    Stopped. This ticket's premise is gone from main, and its mechanism now buys nothing.

    Measured on main (a5565b6, #288 landed) with #290's own selector:

    The per-edit floor this ticket removes is already gone, because the detector silently stopped matching. A projects split now buys nothing.

    Nothing here exists on main either: select-unit-specs.mjs, selectFrom, the WALKERS list and the 12s budget all live only in #290, approved and unmerged.

    #290's WALKERS list fails once main merges into it, 1 of 10 — the handoff its body predicted.

    The open question is coverage, not speed: should the ten inventories still run on every edit? That is a decision, so I did not guess it.

    Recommend landing #290 with its WALKERS list reconciled, then @sydevs-bot revise here against the new numbers.

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


    Generated by Claude Code

  9. removed
    bot:working
    on Oct 13, 2026
  10. 11 remaining items

  11. added
    bot:working
    and removed
    bot:working
    on Oct 15, 2026
  12. sydevs-bot commented on Oct 16, 2026

    @sydevs-bot
    ContributorAuthor

    The session for this item did not finish after 3 attempts. I have stopped retrying. A @sydevs-bot verb or mention from you starts me again.

    🤖 sydevs dispatcher

  13. added
    bot:working
    and removed
    bot:working
    on Oct 16, 2026
  14. removed
    bot:working
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    Low

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions