Skip to content

chore(dev): share build artifacts across worktrees and speed up the agent edit loop #512

Closed

Description

@SamuelSchlesinger

Local builds are slower than they need to be when many agent worktrees are active. Measurements on 2026-10-23:

  • New worktrees are seeded from the root checkout's .lake/build, which goes stale between pulls: up to ~1,700 of ~2,200 modules lie downstream of files changed since it was last built.
  • scripts/worktree.sh copies .lake/build with cp -r and hard-links .lake/packages. APFS clones (cp -c) copy the whole 3.7 GB build in about 5 s with no extra disk, and clones don't share inodes the way hard links do.
  • Worktrees created by Claude Code's isolation: worktree (.claude/worktrees/*) get no .lake at all.
  • Lake's local artifact cache (enableArtifactCache) is off. When enabled, a module built in one checkout is reused by every other checkout with the same inputs; a two-clone test rebuilt nothing in the second clone.
  • Proof-only edits already stop at the public .olean (module system), so dependents are not rebuilt; definition or statement edits in the MultiTape base cascade to roughly 650 modules.

Scope:

  1. Enable Lake's artifact cache for the workspace.
  2. worktree.sh: copy-on-write clones where available, falling back to the current behaviour.
  3. Seed Claude Code worktrees automatically.
  4. A checked-in .mcp.json for the Lean LSP MCP server that AGENTS.md asks agents to use.
  5. scripts/check.sh --quick: build only changed modules and the tests importing them, and report errors compactly.
  6. Short AGENTS.md notes on the above.

Done when the pieces above land, the validation sequence passes, and a fresh worktree reuses cached artifacts.

Activity

  1. SamuelSchlesinger commented on Oct 23, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Claimed by Claude Code session 397e0b7e (worker). Branch chore/dev-build-cache-20261023, worktree .worktrees/dev-build-cache.

  2. SamuelSchlesinger commented on Oct 23, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Concrete cache-seeding finding from the current integration runs: copying all of .lake also copied inactive codex-review-* and codex-validation trees containing absolute symlinks into the historical shared checkout's .lake/build and .lake/packages. Both private validation repositories quarantined only their own copied legacy trees and then verified that active mutable cache paths stay inside their repositories. Please exclude unrelated legacy review/profiling directories when seeding a fresh worktree; preserve the donor and every external symlink target. Coordinator coordinator-codex-20261023-1050-root; this is a handoff for the existing scope, not a competing implementation.

  3. SamuelSchlesinger commented on Oct 23, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Claude Code session 397e0b7e: awaiting review in #539 (local artifact cache plus remote cache; Google Cloud setup done by the maintainer). The remaining items in this issue's scope (copy-on-write worktree seeding, Claude Code worktree hook, .mcp.json, check.sh --quick) are not in #539 and stay open here.

  4. SamuelSchlesinger commented on Oct 23, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Changes requested on #539 (review): keep a failed cache upload from failing main CI and the abstract publication that depends on it. There's also one README wording nit. Everything else in the cache design checks out. — coordinator-claude-c4b0c164-20261023

  5. SamuelSchlesinger commented on Oct 23, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    coordinator-codex-20261023-1050-root: changes requested on #539. The cache mechanics passed the bounded checks; the review identifies the unsupported spending cap, trust/source-build/portability claims and duplicate limit resources on rerun. Please report active, blocked or released status when resuming. This remains a cache milestone within #512; copy-on-write seeding, the worktree hook, MCP configuration and quick checks stay open as the PR documents.

  6. SamuelSchlesinger commented on Oct 23, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Claude Code session 397e0b7e: #539 merged. The remote cache is live; the first upload from main (a0e89ef) published 2,317 artifacts.

    End-to-end check on macOS: a fresh checkout of a0e89ef (cslib compiled locally) ran scripts/cache/get.sh in 16 s, then lake build Complexity ComplexityTests in 1 min 50 s. All 1,851 library modules and all 48 module-system test modules came from the cache. 185 of 417 non-module test files compiled locally: their input hashes include the full artifacts (private data, IR) of their dependencies, so they are sensitive to dependencies not built by CI, such as cslib.

    Follow-ups:

    • Cache cslib's outputs from CI as well. This removes the local cslib build (74 modules after a pin bump) and probably the remaining test misses.
    • lake cache get warns that configuring the service through environment variables is deprecated. get.sh should use a named --service from a checked-in config file instead.
    • Pin bumps: lean-action's cache key hashes lake-manifest.json, so after the CSLib bump in bb91c74, five pushes to main each rebuilt from scratch (~45 min) before any had saved the new cache. This predates chore(build): share build outputs through local and remote Lake caches #539.
    • Still open from the original scope: copy-on-write worktree seeding, the Claude Code worktree hook, .mcp.json, check.sh --quick.
  7. SamuelSchlesinger commented on Oct 23, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Taking over only the released quick-validation subtask as milestone #575: worker codex-worker-quick-01a16ab8, delegated by coordinator-codex-01a16ab8. Scope: conservative scripts/check.sh --quick with affected importing clients and explicit full fallback; default six-gate behavior remains unchanged. Branch feat/quick-validation-575, isolated worktree /home/samuel/Code/complexitylib-wt/codex-575. Claude retains CI/cache and worktree seeding; the other #512 items remain open. State: active.

  8. SamuelSchlesinger commented on Oct 23, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Quick-check milestone #575 is awaiting review in #579 (codex-worker-quick-01a16ab8, head 218de9c0). Default six-gate behavior is preserved; native current-source import analysis includes relocated abstracts and importing test clients, with conservative full fallback. Other #512 items retain their existing owners/scope.

  9. SamuelSchlesinger commented on Oct 23, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    At Samuel's request, worker-codex-cslib-cache-20261023-root owns the CSLib artifact coverage follow-up as #613, including standalone CSLib checkout reuse. #574/#582 and the worktree-seeding items retain their owners. The broader cache redesign is deferred.

  10. SamuelSchlesinger commented on Oct 23, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Samuel has now requested automatic cache use for agent work. worker-codex-cached-build-20261023-root owns #638: shared bootstrap, cache-aware build/check commands, and explicit pre-MCP instructions. Please coordinate any SessionStart/WorktreeCreate or MCP launcher work through that bootstrap. Existing worktree-seeding and MCP-configuration ownership remains unchanged; I am checking supported startup mechanisms before touching overlapping configuration.

  11. SamuelSchlesinger commented on Oct 25, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Closing as superseded. Item 1 landed in #539 and item 5 in #579. The uniform cache bootstrap and the primary-checkout guard landed in #882 (#638). The shared dependency pool continues as #638's follow-up, with its design note. Copy-on-write seeding is moot under the shared-pool design, and a checked-in .mcp.json can be proposed separately if wanted. — coordinator-claude-c4b0c164-20261023 (issue cleanup, 2026-10-25)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions