Skip to content

Verification efficiency: shared build cache across worktrees + affected-scope test selection #390

Closed

Description

@currentbits

From the monorepo research: N parallel worktrees each running full builds/tests waste the machine. (1) Point all of a repo's worktrees at a shared local build cache (Turborepo/Nx/sccache/Bazel depending on the repo) so thread B reuses thread A's task results. (2) Affected-scoped verification: run only the tests the diff touches (affected graph or changed-path mapping) instead of the full suite. Big latency win when 5 agents verify simultaneously on one laptop.

Activity

  1. added
    enhancement
    plan:todo
    on Aug 17, 2026
  2. currentbits commented on Aug 19, 2026

    @currentbits
    OwnerAuthor

    Price tag from a read-only scan of the maintainer's machine (2026-08-19), for sizing this against #559: 166 worktrees, 96.0 GB, median 709 MB each — solenta alone is 119 directories and 57.3 GB. Nearly all of that is per-worktree node_modules and build output duplicated from the checkout.

    Two different fixes for the same bill and they compose: #559 deletes the directories of settled threads (bounded history), this issue stops each new one from costing 709 MB in the first place (bounded per-thread cost). On this data the second matters more over time — the reclaim is one-off, the 709 MB is charged on every new thread. Worth noting APFS cp -c cloning already gets most of the way there for a same-volume copy and is what the repo's own nightly-build instructions use.

  3. added
    plan:doing
    and removed
    plan:todo
    on Aug 22, 2026
  4. currentbits commented on Aug 22, 2026

    @currentbits
    OwnerAuthor

    Implementing both halves in this thread:

    1. Shared local build cache — detect turbo.json / nx.json / Cargo.toml in the worktree and inject TURBO_CACHE_DIR, NX_CACHE_DIRECTORY (+ NX_DAEMON=false), CARGO_TARGET_DIR, SCCACHE_DIR pointing at ~/.solenta/build-cache/<repo>. Same project path → same cache, so thread B reuses thread A's task results. Wired into the verify spawn and agent CLI spawn (agentSpawnOptions) so agent-run tests hit it too. Never overrides an env var the user already set.

    2. Affected-scope verify — before the gate / Verify now runs, list paths vs the project default branch (listChangedPaths). Rewrite well-known runners (turbo --filter=...[base], nx affected, jest --findRelatedTests, vitest related, node --test file list, pytest, go test) when the mapping is confident. Wide files (lockfile, tsconfig, CI) or unknown runners stay full-suite. Docs-only diffs skip the suite (exit 0). Post-merge verify stays full-suite.

    Fail closed: git trouble → original command. Evidence records the command that actually ran.

  5. currentbits commented on Aug 22, 2026

    @currentbits
    OwnerAuthor

    Implementation is in this worktree (thread 572176a4):

    • electron/verifyEfficiency.js — shared ~/.solenta/build-cache/<repo> env (turbo/nx/cargo/sccache) plus affected-scope rewrites for turbo/nx/jest/vitest/node --test/pytest/go test
    • Wired into verify spawn, agent CLI spawn (agentSpawnOptions), the runner gate, and Verify now
    • Post-merge verify stays full-suite
    • Fail closed: unknown runner, lockfile/tsconfig/CI, or git trouble → original command
    • Tests: electron/test/verify-efficiency.test.js plus existing verify/gate/services/proc suites green

    Not in this change: per-worktree node_modules sharing (the 709 MB disk comment). Cache sharing is task results, not install trees.

  6. currentbits commented on Aug 22, 2026

    @currentbits
    OwnerAuthor

    Implemented and split into a three-PR stack, land in order:

    1. Verify efficiency 1/3: shared build cache across worktrees (#390) #664 — shared build cache across worktrees (TURBO_CACHE_DIR / NX_CACHE_DIRECTORY / CARGO_TARGET_DIR / CCACHE_DIR keyed on the main checkout). Self-contained, does not touch the verify command.
    2. Verify efficiency 2/3: affected-scope verify, node --test (#390) #665 — affected-scope framework + the node --test matcher, with the bail-out rules that keep the gate honest.
    3. Verify efficiency 3/3: turbo, nx, jest, vitest, pytest, go matchers (#390) #666 — the remaining matchers (turbo, nx, jest, vitest, pytest, go).

    Each measures under 400 changed lines against its base and passes npm run test:electron on its own, so the stack can stop after 1 or 2 if the scoping half is not wanted.

    Open question for review, raised on #665: scoping rewrites the user's verify command and there is currently no setting to turn it off.

  7. added
    plan:done
    and removed
    plan:doing
    on Sep 6, 2026
  8. currentbits commented on Sep 6, 2026

    @currentbits
    OwnerAuthor

    Shipped on origin/main in electron/verifyEfficiency.js: shared build cache across worktrees plus affected-scope rewrites for turbo/nx/jest/vitest/node --test/pytest/go. Stack comments on this issue (#664/#665/#666) match the code that is live.

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

    enhancementplan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions