Skip to content

feat(ipc): add broker_v2 module — first v2 surface (slice 10 of #488) - #781

Merged
zackees merged 1 commit into
mainfrom
feat/777-slice10-add-broker-v2-entry-point
Jun 19, 2026
Merged

zackees merged 1 commit into
mainfrom
feat/777-slice10-add-broker-v2-entry-point

Conversation

@zackees

@zackees zackees commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Slice 10. First v2 surface in zccache: new ipc::broker_v2 module + bumps running-process patch to e64f6ff (picks up slices 5-8). 1 unit test passes. Refs #777.

First zccache surface that calls the v2 broker API. New module
`zccache::ipc::broker_v2` with `connect_v2_broker(wanted_version) ->
Result<ClientSession, BrokerV2Error>` wrapping
`running_process::broker::client_v2::connect("zccache", ...)`.

Also bumps the [patch.crates-io] running-process pin to e64f6ff to
pick up running-process #492 (BackendHttpReady plumbing), #493
(GetBrokerHttpEndpoint RPC dispatch), #494 (env overrides), #495
(broker HTTP server scaffold), and #496 (aggregator page top-bar +
iframe) — all of which are in-tree but unreferenced by zccache yet.

v1 callers are deliberately untouched: v2 ships alongside v1 per the
coexistence table in upstream #470. Each subsequent slice replaces
one more of zccache's 62 v1 broker references with a v2 path.

One unit test covers the typed BrokerV2Error::Dial path with no
broker running — the same shape the rest of the migration will
pattern-match on.

Refs #777

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit 6f047f8 into main Jun 19, 2026
@zackees
zackees deleted the feat/777-slice10-add-broker-v2-entry-point branch June 19, 2026 21:31
zackees added a commit that referenced this pull request Jun 19, 2026
…socket assertion

Three more spots that didn't get updated for #763 / #761 / #762 Phase 0:

1. `.github/workflows/test-action.yml` — the cargo-registry save / clean
   steps hardcoded `$HOME/.zccache/cargo-registry/<key>.tar.gz`. After
   #763 the archive lands under `<cache>/v<VERSION>/cargo-registry/`,
   so the workflow's `test -f` check was wrong and failed on every run.
   Fix: ask the binary via `$(./target/debug/zccache cache-root)` —
   that prints the effective (version-namespaced) root, matching the
   integration-test fix from the prior commit.

2. `.github/workflows/wrapper-e2e.yml` — same shape on both Unix and
   Windows: `test -d "$ZCCACHE_CACHE_DIR/logs"` was checking the
   pre-#763 unversioned root. Replaced with `$(zccache cache-root)/logs`
   on Unix and the PowerShell equivalent on Windows.

3. `crates/zccache/src/ipc/broker_v2.rs` — the smoke test from #781
   asserted `socket_path.contains("rpb-v2-zccache-")`, which is the
   *Windows* named-pipe naming. On Unix the v2 broker hashes the
   consumer key into the filename (`<hex>.sock`) inside a shared
   `.rp-<uid>-broker-v2/` parent dir, so the substring never matches
   and `macos / Test` failed. Made the assertion platform-aware: keep
   the strong `rpb-v2-zccache-` check on Windows, fall back to the
   universal `broker-v2` directory marker on Unix.

Verified locally on Windows: broker_v2 lib test passes. Cargo-registry
behavior validated via a docker repro under `.perf-local/docker-repro/`
that shows the OLD path (`$HOME/.zccache/cargo-registry/...`) missing
and the NEW path (`$(zccache cache-root)/cargo-registry/...`) present.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 20, 2026
* chore(release): bump 1.12.8 -> 1.12.9

Patch release shipping the Windows daemon unstick fix from #775 and
the v2 IPC scaffolding (#778-#781). v2 ships alongside v1 and no v1
caller is replaced yet (see broker_v2.rs:12-14), so this is a pure
patch release with no user-visible behavior change beyond the #775
fix and the broker_v2 surface being available for downstream slices.

Also adds .extern-repos/ to .gitignore for the clud-extern-repos
workflow used to coordinate the fbuild pin bump for this release.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style: rustfmt v2_pipe_naming_smoke_test (pre-existing drift)

Pre-existing rustfmt drift from #779 that slipped past CI on that PR.
Collapses two .expect() callsites back onto one line each — pure
formatting, no behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(tests): align integration tests with #763 version-namespaced cache root

PR #763 (issues #761 / #762 Phase 0) moved every persistent daemon
and CLI state file under `<cache>/v<VERSION>/` so a single env-pinned
cache root can host multiple sibling daemon versions without one
overwriting the other's state. The unit tests in
`crates/zccache/src/core/config/tests.rs` were updated in lockstep,
but four integration tests still expected the pre-#763 unversioned
layout — they've been red on `main` for the last three releases.

Each fix is a one-line shim that prepends `versioned_subdir()` to the
joined path so the test looks where the daemon and CLI actually
read/write:

* `cli_cache_root.rs` (3 tests): assert that `zccache cache-root` and
  the JSON `cache_root` field equal `<env>/v<VERSION>`, and that the
  relative-override case ends with the version subdir component while
  its parent component is the override stem.
* `cli_cli_crash_test.rs` (2 tests): the CLI crash handler now writes
  dumps under `<cache>/v<VERSION>/crashes/`.
* `daemon_crash_minidump_test.rs` (4 tests): same change for the
  daemon-side fixture.
* `daemon_rustc_restore_test.rs` (1 test): `index.bin` lives under
  `<cache>/v<VERSION>/index.bin` now, so `index_path_from_cache_dir`
  needs the versioned root, not the env-var top level.

Verified locally on Windows: all 10 previously-failing tests pass.
The unrelated Windows-only line 325 issue in `daemon_rustc_restore`
predates this PR and is not exercised on Windows CI.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ci,test): version-namespace remaining CI paths + relax broker_v2 socket assertion

Three more spots that didn't get updated for #763 / #761 / #762 Phase 0:

1. `.github/workflows/test-action.yml` — the cargo-registry save / clean
   steps hardcoded `$HOME/.zccache/cargo-registry/<key>.tar.gz`. After
   #763 the archive lands under `<cache>/v<VERSION>/cargo-registry/`,
   so the workflow's `test -f` check was wrong and failed on every run.
   Fix: ask the binary via `$(./target/debug/zccache cache-root)` —
   that prints the effective (version-namespaced) root, matching the
   integration-test fix from the prior commit.

2. `.github/workflows/wrapper-e2e.yml` — same shape on both Unix and
   Windows: `test -d "$ZCCACHE_CACHE_DIR/logs"` was checking the
   pre-#763 unversioned root. Replaced with `$(zccache cache-root)/logs`
   on Unix and the PowerShell equivalent on Windows.

3. `crates/zccache/src/ipc/broker_v2.rs` — the smoke test from #781
   asserted `socket_path.contains("rpb-v2-zccache-")`, which is the
   *Windows* named-pipe naming. On Unix the v2 broker hashes the
   consumer key into the filename (`<hex>.sock`) inside a shared
   `.rp-<uid>-broker-v2/` parent dir, so the substring never matches
   and `macos / Test` failed. Made the assertion platform-aware: keep
   the strong `rpb-v2-zccache-` check on Windows, fall back to the
   universal `broker-v2` directory marker on Unix.

Verified locally on Windows: broker_v2 lib test passes. Cargo-registry
behavior validated via a docker repro under `.perf-local/docker-repro/`
that shows the OLD path (`$HOME/.zccache/cargo-registry/...`) missing
and the NEW path (`$(zccache cache-root)/cargo-registry/...`) present.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 20, 2026
…socket assertion

Three more spots that didn't get updated for #763 / #761 / #762 Phase 0:

1. `.github/workflows/test-action.yml` — the cargo-registry save / clean
   steps hardcoded `$HOME/.zccache/cargo-registry/<key>.tar.gz`. After
   #763 the archive lands under `<cache>/v<VERSION>/cargo-registry/`,
   so the workflow's `test -f` check was wrong and failed on every run.
   Fix: ask the binary via `$(./target/debug/zccache cache-root)` —
   that prints the effective (version-namespaced) root, matching the
   integration-test fix from the prior commit.

2. `.github/workflows/wrapper-e2e.yml` — same shape on both Unix and
   Windows: `test -d "$ZCCACHE_CACHE_DIR/logs"` was checking the
   pre-#763 unversioned root. Replaced with `$(zccache cache-root)/logs`
   on Unix and the PowerShell equivalent on Windows.

3. `crates/zccache/src/ipc/broker_v2.rs` — the smoke test from #781
   asserted `socket_path.contains("rpb-v2-zccache-")`, which is the
   *Windows* named-pipe naming. On Unix the v2 broker hashes the
   consumer key into the filename (`<hex>.sock`) inside a shared
   `.rp-<uid>-broker-v2/` parent dir, so the substring never matches
   and `macos / Test` failed. Made the assertion platform-aware: keep
   the strong `rpb-v2-zccache-` check on Windows, fall back to the
   universal `broker-v2` directory marker on Unix.

Verified locally on Windows: broker_v2 lib test passes. Cargo-registry
behavior validated via a docker repro under `.perf-local/docker-repro/`
that shows the OLD path (`$HOME/.zccache/cargo-registry/...`) missing
and the NEW path (`$(zccache cache-root)/cargo-registry/...`) present.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 20, 2026
…784 phase 2a) (#786)

* perf(daemon): defer compiler-hash-cache load off spawn→lockfile path (#784)

The four cache snapshots loaded synchronously by `DaemonServer::bind_with_cache_dir`
(metadata, compiler-hash, system-includes, artifact-index) all push the readiness
lockfile write later than it needs to be. Issue #784 asks to move them all using
the `spawn_blocking` + atomic-install pattern that #640 established for the
depgraph load.

This commit ships Phase 2a — the smallest, lowest-blast-radius of the four:
compiler-hash-cache. Pattern is now in place for the remaining three to follow
in sibling PRs.

Approach (mirrors #640's depgraph deferral):

* `CompilerHashCache::merge_from` drains a freshly-loaded cache into the live
  one using `DashMap::insert` (which is `&self`), so no Arc/Mutex type changes
  are needed at the SharedState field level.
* New `CompilerHashCacheLoader` handle captures `Arc<SharedState>` + the
  snapshot path; survives `spawn_blocking` boundary; logs at WARN on disk
  failure and leaves the cache empty (stat-verify in `get_or_hash_with` keeps
  cache-key correctness either way).
* `bind_with_cache_dir` now constructs an empty `CompilerHashCache` instead of
  calling `load_from_disk` inline. New `compiler_hash_cache_loaded: AtomicBool`
  on SharedState; the daemon binary fires the load post-lockfile and the
  loader sets the flag on completion.
* Shutdown save path (`run.rs`) gates on the flag — if shutdown fires before
  the background load finishes, the on-disk snapshot is preserved (the
  in-memory cache would be partial). `save_to_disk` already short-circuits on
  empty caches, so the flag is belt + suspenders.

Tests (in `daemon::server::tests::compiler_hash`):

* `bind_does_not_load_compiler_hash_cache_from_disk` — bind with a populated
  snapshot leaves the live cache empty and the loaded flag false.
* `compiler_hash_cache_loader_merges_snapshot_into_live_cache` — loader
  populates the cache + flips the flag + entries are usable (cache-hit on
  next lookup, no re-hash).
* `compiler_hash_cache_loader_tolerates_missing_snapshot` — no on-disk file
  is not an error; flag still flips.
* `compiler_hash_cache_merge_from_drains_other` — documents the
  `merge_from` contract the loader relies on.

Pre-existing `cargo fmt` drift in `v2_pipe_naming_smoke_test.rs` swept in to
keep `cargo fmt --all --check` green in CI.

Phase 2b/2c/2d follow-ups (metadata, system-includes, artifact-store) tracked
separately; each will reuse this pattern.

Closes-via-phase #784

* fix(tests): align integration tests with #763 version-namespaced cache root

PR #763 (issues #761 / #762 Phase 0) moved every persistent daemon
and CLI state file under `<cache>/v<VERSION>/` so a single env-pinned
cache root can host multiple sibling daemon versions without one
overwriting the other's state. The unit tests in
`crates/zccache/src/core/config/tests.rs` were updated in lockstep,
but four integration tests still expected the pre-#763 unversioned
layout — they've been red on `main` for the last three releases.

Each fix is a one-line shim that prepends `versioned_subdir()` to the
joined path so the test looks where the daemon and CLI actually
read/write:

* `cli_cache_root.rs` (3 tests): assert that `zccache cache-root` and
  the JSON `cache_root` field equal `<env>/v<VERSION>`, and that the
  relative-override case ends with the version subdir component while
  its parent component is the override stem.
* `cli_cli_crash_test.rs` (2 tests): the CLI crash handler now writes
  dumps under `<cache>/v<VERSION>/crashes/`.
* `daemon_crash_minidump_test.rs` (4 tests): same change for the
  daemon-side fixture.
* `daemon_rustc_restore_test.rs` (1 test): `index.bin` lives under
  `<cache>/v<VERSION>/index.bin` now, so `index_path_from_cache_dir`
  needs the versioned root, not the env-var top level.

Verified locally on Windows: all 10 previously-failing tests pass.
The unrelated Windows-only line 325 issue in `daemon_rustc_restore`
predates this PR and is not exercised on Windows CI.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(ci,test): version-namespace remaining CI paths + relax broker_v2 socket assertion

Three more spots that didn't get updated for #763 / #761 / #762 Phase 0:

1. `.github/workflows/test-action.yml` — the cargo-registry save / clean
   steps hardcoded `$HOME/.zccache/cargo-registry/<key>.tar.gz`. After
   #763 the archive lands under `<cache>/v<VERSION>/cargo-registry/`,
   so the workflow's `test -f` check was wrong and failed on every run.
   Fix: ask the binary via `$(./target/debug/zccache cache-root)` —
   that prints the effective (version-namespaced) root, matching the
   integration-test fix from the prior commit.

2. `.github/workflows/wrapper-e2e.yml` — same shape on both Unix and
   Windows: `test -d "$ZCCACHE_CACHE_DIR/logs"` was checking the
   pre-#763 unversioned root. Replaced with `$(zccache cache-root)/logs`
   on Unix and the PowerShell equivalent on Windows.

3. `crates/zccache/src/ipc/broker_v2.rs` — the smoke test from #781
   asserted `socket_path.contains("rpb-v2-zccache-")`, which is the
   *Windows* named-pipe naming. On Unix the v2 broker hashes the
   consumer key into the filename (`<hex>.sock`) inside a shared
   `.rp-<uid>-broker-v2/` parent dir, so the substring never matches
   and `macos / Test` failed. Made the assertion platform-aware: keep
   the strong `rpb-v2-zccache-` check on Windows, fall back to the
   universal `broker-v2` directory marker on Unix.

Verified locally on Windows: broker_v2 lib test passes. Cargo-registry
behavior validated via a docker repro under `.perf-local/docker-repro/`
that shows the OLD path (`$HOME/.zccache/cargo-registry/...`) missing
and the NEW path (`$(zccache cache-root)/cargo-registry/...`) present.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant