Repository navigation
Fix cross-platform path handling in linker detection - #2
Merged
Merged
Conversation
On Linux, std::path::Path treats backslashes as literal characters, not
path separators. This caused detect_family("C:\\emsdk\\...\\wasm-ld.exe")
to return Some(Ld) instead of Some(Lld) because file_stem() returned the
entire string minus .exe, which ends with "-ld" matching the GNU ld pattern.
Fix: use cross_platform_file_name() that splits on both '/' and '\\',
and a custom file_stem() helper, so Windows-style paths are handled
correctly on all platforms.
Co-authored-by: zackees <[email protected]>
Agent-Logs-Url: https://github.com/zackees/zccache/sessions/49409aac-d12e-465b-8901-4d1b9b0f8e12
Copilot
AI
changed the title
[WIP] Investigate and fix broken Linux build
Fix cross-platform path handling in linker detection
Mar 26, 2026
zackees
marked this pull request as ready for review
March 26, 2026 13:45
This was referenced May 13, 2026
Closed
5 tasks done
zackees
added a commit
that referenced
this pull request
May 24, 2026
…) (#374) * perf(daemon): hardlink-based byte-passing on cold compiles (closes #296) Route the single-compile and link-ephemeral persist paths through the existing `persist_artifact_paths` (hardlink + copy-fallback) instead of `persist_artifact_payloads` (byte-write). This halves the Defender real-time scan wall-clock on cold compiles on Windows: the compiler already wrote `target/.../<output>` (scan #1); the daemon's previous byte-write of the same content to `~/.zccache/artifacts/<key>_<i>` was Defender scan #2. Hardlinking from the compiler's output path makes the cache file share the same inode — no additional bytes written, no extra scan. Cross-volume case is unchanged: `persist_artifact_file` falls back to `std::fs::copy`, identical to the prior byte-write semantics. Users on a separate dev drive can opt into `ZCCACHE_COLOCATE=1` (already wired in `core::config`) to place the cache on the project's volume so hardlinks succeed there too. The in-memory `CachedArtifact` still holds resident `Bytes` payloads (unchanged), so warm hits within the daemon's memory window stay on the inline-bytes fast path. Cold misses paid the eager `std::fs::read` of the output for the in-memory cache anyway; the only behavior change is that the daemon's *disk* write is now a hardlink syscall instead of a full content write. Sites changed: - `daemon/server/handle_compile.rs` single-compile miss persist (was `persist_artifact_payloads(...&payloads)`, now `persist_artifact_paths(...&[output_path])`). - `daemon/server/handle_link.rs` link-ephemeral miss persist (was `persist_artifact_payloads`, now `persist_artifact_paths` with `read_targets` source paths). `handle_compile_multi.rs` was already on the hardlink path (synchronous in the miss task, PR landed before #365). Its fallback `persist_jobs` queue is dead code today but kept for completeness. Also: add `zccache-cli` to `ci/release_checks.py::RUST_PUBLISH_ORDER` (stop hook was failing with "missing publishable crates: zccache-cli" because the Wave-6 collapse renamed `zccache-cli` to a pyo3 cdylib but the publish list wasn't updated). Verification: - `soldr cargo check --workspace --all-targets`: clean - `soldr cargo test --workspace --tests`: pass (env-specific `cli_installers` failures are pre-existing — missing `ctcb.exe`) - `uv run python ci/perf_local.py` (medium / cold-tar-untar-warm): PASS at 7.51x speedup, cold=1m02s warm=8.38s. Cold dropped slightly vs prior measurement; warm within run-to-run noise. The Defender payoff is Windows-host-specific and not measurable in the Linux Docker harness. * fix: cargo fmt + remove stale `mod python` decl + allow deprecated re-export CI on PR #374 surfaced three issues: - `crates/zccache/src/fingerprint/mod.rs:33` had a stale `#[cfg(feature = "python")] mod python;` referencing a file that was moved to the thin py-binding crate in wave 4. `-D unexpected-cfgs` rejected the dangling feature gate. Removed the line. - `crates/zccache/src/cli/mod.rs:15` re-exports `gc_daemon_spawn_logs` which is `#[deprecated]`. `-D warnings` rejected it. Added `#[allow(deprecated)]` on the re-export block (the deprecation note tells callers to use `gc_log_directory` instead, but the re-export keeps the public path stable). - `cargo fmt --all` reformatted 77 files. No semantic changes, just whitespace + import ordering. * style: fix rustfmt formatting on #[allow(deprecated)] re-export Trailing-comment attributes must be on their own line per rustfmt rules. Wasn't caught by my prior `cargo fmt --all` because of the `mod python;` resolution error preempting the formatter. * fix: Windows CloseHandle extern clash + broken intra-doc-links CI on the second run surfaced three more `-D warnings`-promoted issues: - Windows-only: ipc/mod.rs declares `extern \"system\" { fn CloseHandle... }` in three places. windows-sys also defines CloseHandle with HANDLE/BOOL newtypes; the underlying ABI matches but the signatures clash in rustc's eyes (`clashing_extern_declarations` warn). Suppressed with `#[allow(clashing_extern_declarations)]` on each block with a comment explaining the rationale. - Rustdoc: `symbols/mod.rs` had `[\`crate::marker\`]` and `[\`crate::cache\`]` — broken since the monocrate collapse renamed paths. Fixed to `[\`self::marker\`]` / `[\`self::cache\`]`. - Rustdoc: `depgraph/snapshot/mod.rs` linked to `[\`tests\`]` (cfg(test) module not visible to rustdoc). Demoted to plain backticks. - Rustdoc: `cli/commands/mod.rs` links to `[\`args\`]` (private sibling), `depgraph/snapshot/mod.rs` links to `[\`persistence\`]` (also private). Both demoted to plain backticks — pub→priv links are an error under `-D rustdoc::private-intra-doc-links`. - Added README.md to `symbols/` and `depgraph/snapshot/` (readme_guard hook required them after the Edits). * docs: drop broken intra-doc link to Config::default in bin The bin compiles as a separate crate so [`Config::default`] doesn't resolve. Demote to plain backticks.
This was referenced May 24, 2026
4 of 5 tasks
zackees
added a commit
that referenced
this pull request
Jun 14, 2026
… with src/dst/errno/exists/size/gap_ms (#731) Under FastLED `all-with-examples` burst link load (#726 evidence section) the daemon emits "failed to persist artifact output: The system cannot find the file specified. (os error 2)" without enough context to tell whether ninja deleted the output mid-flight (TOCTOU), whether zccache computed the wrong destination, or whether Defender quarantined the file. This patch addresses the first half of #728 — adding the diagnostic fields the WARN needs to distinguish those failure modes. The root-causing under FastLED+Defender repro (criteria #2-#3) belongs to a later iteration on a Windows runner with real burst-link load. Two layers of enrichment: 1. `persist::enrich_persist_err` (new) wraps the io::Error returned from `persist_artifact_file` and `persist_artifact_output` with `src=<path> src_exists_now=<bool> src_size_now=<bytes|?> dst=<path> errno=<Some(N)|None>: <orig>`. For payload writes (no source file) the src= block is omitted. A single best-effort `fs::metadata(src)` captures whether the file is gone *now* — cheap, since we only run it on the error path. 2. The two existing WARN sites (`handle_compile/miss_store.rs:387` and `handle_compile_multi.rs:879`) add `gap_ms` — the wall-clock between "linker-success-recorded" (immediately before each persist tokio::spawn) and "persist-attempt-started" (inside the blocking task, before the persist call). Captured per-job so burst-link queue starvation shows up as a large gap distinct from instant-vanish ENOENT. Tests in `crates/zccache/src/daemon/server/tests/pack.rs`: - `persist_artifact_paths_err_includes_diagnostics_for_missing_source` asserts all five new fields appear and `src_exists_now=false`, `src_size_now=?` for a missing source. - `persist_artifact_output_err_includes_dst_diagnostics` asserts the payload-write error path includes `dst=` + `errno=` but omits `src=`. Refs #728 Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
3 tasks
zackees
added a commit
that referenced
this pull request
Jun 14, 2026
Ships four PRs that landed on top of 1.12.2: - #730 — test(wedge): deterministic `wedge_detection_returns_wedged_on_recv_timeout` - #731 — diagnostics(persist): enrich the `os error 2` WARN with src/dst/errno/exists/size/gap_ms (#728 criterion 1) - #732 — fix(meson): allowlist configure outputs, skip-persist on no-op, purge meson-configure on clear (closes #710, KEY_DOMAIN_TAG v2->v3) - #733 — test(daemon): synthetic burst-link reproducer for #726 (closes #729) Closes #710, #729 (already closed on merge); ships the #728/#731 diagnostics so the next FastLED `all-with-examples` repro can capture rich logs for criteria #2–#3. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Merged
11 of 13 tasks
zackees
added a commit
that referenced
this pull request
Jun 15, 2026
…d lifecycle events (#755) (#756) Closes #755. Extends `daemon-lifecycle.log` with three new JSONL event types and two new client-meta fields on every spawn-attempt / spawn row, so the two-versions-on-one-pipe wedge — fbuild's bundled 1.12.4 vs. PyPI's 1.12.5, both racing for the same Windows named pipe — becomes reconstructable from a single `grep` instead of by-hand timestamp matching. ## Schema additions (all additive; existing tooling keeps working) * `daemon-died` — emitted by the CLI after `stop_stale_daemon` successfully kills a predecessor. Envelope `pid` is overridden to the dying daemon's PID; carries `reason: takeover`, `replaced_by_pid`, `replaced_by_version`. Self-emitted `died-idle` / `died-shutdown` continue to fire from the daemon unchanged. * `pipe-handover` — emitted alongside `daemon-died` when the new daemon's PID is observed post-bind. Envelope `pid` is the new daemon's PID; carries `inbound_pid`, `inbound_version`, `outbound_pid`, `reason: previous-died`. * `client-disconnected` — emitted at the point a client's IPC connection breaks (`cause: comm-error` / `pipe-closed-mid-write`). Pre-fix this dropout was only visible one round-trip later as the next `spawn-attempt`'s `reason: replaced-comm-error`. * `client_version` + `client_binary_path` on every `spawn-attempt` (CLI-emitted) and `spawn` (daemon-emitted) row — distinguishes fbuild's bundled binary from a PyPI install when both share an endpoint. Single source: `core::lifecycle::client_meta()`. ## TDD trail RED before, GREEN after — see `core/lifecycle.rs` tests for the schema-pinning suite and the `emit_takeover_lifecycle_events` round- trip that verifies the `outbound_pid` ↔ `inbound_pid` join the schema doc instructs operators to grep against: * `new_event_constants_match_schema` — pins the wire strings. * `new_reason_and_cause_constants_match_schema` — pins reason + cause strings. * `client_meta_returns_version_and_binary_path` — pins the helper's contract (binary_path never empty). * `write_event_round_trips_new_daemon_died_takeover_event` — pins the wire shape of `daemon-died`, including envelope-pid override and `replaced_by_*` fields. * `emit_takeover_lifecycle_events_writes_linked_pair` — pins acceptance #2's structural join (`died.pid == handover.outbound_pid` and `died.replaced_by_pid == handover.inbound_pid`). ## Acceptance coverage (issue checklist) * [x] daemon-died with matching `reason` — emitted by CLI on takeover via `emit_takeover_lifecycle_events`. Self-emitted `died-idle` / `died-shutdown` paths unchanged. * [x] Linked daemon-died / pipe-handover with PID join — see the round-trip test above. * [x] client-disconnected at point of failure with `cause` — emitted in `run_ephemeral_attempt` and `cmd_compile`'s Failed arm. * [x] `client_version` + `client_binary_path` on every spawn-attempt and spawn line — wired in 3 call sites (runtime.rs, commands/daemon.rs, bin/zccache-daemon.rs). * [x] Schema backward-compatible — additive only; envelope fields unchanged; the writer preserves any key the caller passes. * [x] Doc block describing schema with forensic walkthrough — module doc in `core/lifecycle.rs` includes the event table + the six-row walkthrough from the issue's repro. ## Out of scope (tracked separately) * The structural fix for the underlying collision — hashing `(binary_path, version)` into the pipe-name suffix so coexisting versions land on distinct pipes — warrants its own issue. This PR is about making the collision *visible* in the meantime. * The duplicated `stop_stale_daemon` / `spawn_and_wait` between `cli/runtime.rs` and `cli/commands/daemon.rs` is preserved; both arms now emit the linked events identically. Unifying them is a separate refactor. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Closed
6 tasks
zackees
added a commit
that referenced
this pull request
Jun 20, 2026
…813) (#831) Adds Dockerfile.jobserver-test mirroring the existing Dockerfile.cc-test pattern, validating issue #813's compile-concurrency cap end-to-end inside a Docker container. Test flow: - Stage `builder` — compile zccache + zccache-daemon (release). - Stage `tester` — Rust toolchain image; runs: 1. Generate 60 trivial Rust source files 2. Start zccache-daemon --foreground with ZCCACHE_MAX_PARALLEL_COMPILES=1 in env 3. Launch a 50ms-cadence sampler that polls `pgrep -f rustc` 4. Fire 60 concurrent `zccache rustc` invocations 5. Stop daemon + sampler 6. Parse the CSV samples; assert peak rustc count <= 1 This validates the same property the in-process test #826 validates (no overlapping compile intervals when cap=1) but at the REAL end-to-end level — actual daemon, real cargo-style rustc spawns, observable via system process counting. ## Why process counting rather than log parsing The original design was to grep daemon-lifecycle.log for the `compile_start`/`compile_end` events #816 added. Empirically: - daemon-lifecycle.log contains only structured JSON spawn/ shutdown events (it's an EventLogger sink, not the tracing-subscriber output). - tracing::info! output from #816's compile_exec instrumentation goes to a separate file the daemon stdout/stderr redirect doesn't capture (likely a non-blocking tracing-appender file layer somewhere; ran out of time pinning down the exact path). Sampling `pgrep` is more robust: - Works regardless of where tracing logs land. - Observes the same property (cap enforced) end-to-end. - Doesn't depend on the log format staying stable across refactors of the instrumentation code. A follow-up could pin down the tracing-subscriber file location and parse those events for richer assertion (per-compile durations, exit codes) — filing that as a small task on the meta. ## Verification status - Builds zccache successfully (cached layer from build #1). - Tester stage runs and daemon binds socket (verified across builds #2-7). - Final local validation hit a Docker Desktop daemon hang on this Win10 box (the documented "wsl --shutdown required" failure mode per #408's cancellation-recovery checklist). CI will validate on fresh runners. Refs #813 Refs #817 Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Jun 20, 2026
zackees
added a commit
that referenced
this pull request
Jun 20, 2026
Round 2 audit finding #2: `call_with_brokerv2_deadline` returned `BrokerV2Error::Dial { socket_path: "<deadline-exceeded>" }` on deadline. This breaks downstream consumers that assert on the `socket_path` containing a real v2 broker namespace marker (e.g. "broker-v2" or "rpb-v2-zccache-") — a 3s timeout during cold-boot sid lookup would now produce a spurious test failure with a misleading error. Switch to `BrokerV2Error::Io(ErrorKind::TimedOut)`, mirroring the shape upstream `connect_with_deadline` returns after running-process #517 landed. Classification is unchanged (`from_brokerv2_error` returns `None` for Io, caller routes to direct-connect fallback). Test updated: `call_with_brokerv2_deadline_fires_on_slow_closure` asserts the new Io shape. Part of #842 (broker-v2 burn-down ledger). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
17 of 20 tasks
zackees
added a commit
that referenced
this pull request
Jun 20, 2026
* chore(deps): bump running-process 4.4.0 (git rev) → 4.5.5 (published) The #777 spike-pin to commit e64f6ff5 (broker-v2 proto types slice 1 of running-process#483) is no longer needed — running-process 4.5.5 is on crates.io and exposes the broker-v2 surface (protocol_v2, client_v2, BrokeredBackend trait, v2 broker scaffold binary). Cargo.toml: drop the [patch.crates-io] git rev for running-process, update workspace dep to 4.5.5. Cargo.lock: refreshed (cargo update -p running-process). Verified locally: - soldr cargo check --workspace --all-targets (clean) - soldr cargo test -p zccache --test protocol_v2_roundtrip_test --test v2_client_smoke_test --test v2_pipe_naming_smoke_test (6/6 pass) Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test(v2_client_smoke): cross-platform path assertion (closes #846) `tests/v2_client_smoke_test.rs` asserted `socket_path.contains("rpb-v2-zccache-v2-smoke-no-broker-12345-")` unconditionally. macOS's `client_v2::resolve_socket_path` hashes the bare pipe name into an 8-byte hex leaf at `$TMPDIR/.rp-<uid>-broker-v2/<hex>.sock` to dodge the 104-byte `sun_path` limit; the program name is NOT in the path. First macOS test run would have panicked with a "v2 regression" red herring. Use the same `cfg!(target_os = "macos")` split the in-tree unit test in `broker_v2.rs:125` already uses. Also accept `BrokerV2Error::Sid` as a valid alternate path (CI containers without `/etc/machine-id`). Part of #842 (broker-v2 burn-down ledger). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * refactor(broker_v2): align probe_local_socket prefix handling with upstream (closes #847) `probe_local_socket` stripped the `\.\pipe\` prefix on Windows before `to_ns_name`; upstream's `local_socket_name` (used by the v1 path) passes the full string. `to_ns_name` accepts both today, but the divergent code paths would rot the moment `interprocess` tightened `GenericNamespaced` parsing. Drop the strip — call `to_ns_name::<GenericNamespaced>(endpoint)` on the full string, matching upstream behavior. Single source of truth for the pipe-name encoding policy. Part of #842 (broker-v2 burn-down ledger). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(broker_v2): fine-grained refusal classification (closes #843) `BrokerRefusal::from_brokerv2_error` flattened every `BrokerV2Error:: Refused` to `Other`, discarding the `ErrorCode` payload that v1's `RefusalKind::from_code` already classifies. Five refusal variants were being lost: VersionUnsupported, VersionBlocked, ServiceUnknown, RateLimited, ShuttingDown. `soldr doctor` and connect-route diagnostics lose all refusal-cause attribution the moment v2 is enabled. Mirror v1's mapping exactly. Unknown / Unspecified codes (including future broker codes this client predates) fall through to `Other`, matching v1's forward-compatible behavior. Test changes: replace the single test that pinned the broken stub (`from_brokerv2_error_classifies_refused_vs_dial` returning `Some(Other)`) with two tests: 1. `from_brokerv2_error_classifies_refused_codes` — exhaustive mapping matrix matching v1's `classify_adopt_error_maps_typed_ refusals`. Covers all 5 typed codes + PeerRejected (falls through to Other) + default Refused (code = 0 = Unspecified). 2. `from_brokerv2_error_classifies_transport_variants_as_none` — locks the contract that non-Refused variants (Dial, Io, MissingResult) stay transport-classified. Future variants will trip this test rather than silently fall back to direct connect with no diagnostic. Deferred (noted in docstring): widening `BrokerRefusal::RateLimited` to carry `retry_after_ms` is a v1+v2 follow-up that touches every refusal site — v1 also discards retry_after_ms today. Part of #842 (broker-v2 burn-down ledger). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * docs(broker_v2): mark WIP helpers as #[doc(hidden)] (closes #844) `connect_v2_broker`, `adopt_v2_session`, and `into_backend_io_v2` have zero production call sites — only the in-module smoke tests exercise them. They were shipping as a stable-looking public surface, which risks downstream consumers (or future zccache code) building against the WIP shape before the migration plan is ready. Mark each `#[doc(hidden)]` and add a "WIP — no production consumer" section to its docstring. Update the module-level comment to spell out the policy: remove the marker when the first env-gated production caller lands (`ZCCACHE_BROKER_V2=1`, mirroring `ZCCACHE_BROKER_CONNECT`). `probe_local_socket` is NOT marked — it IS wired in production today (the `RUNNING_PROCESS_FAKE_BACKEND` seam in `broker.rs`). The functions remain `pub` so the existing smoke tests + the new test file in #848 (`v2_connect_stub_broker_test.rs`) can still call them across the crate boundary. Part of #842 (broker-v2 burn-down ledger). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(broker_v2): defensive timeout wrappers for sync v2 helpers (closes #845) The v2 helpers (`probe_local_socket`, `connect_v2_broker`, `adopt_v2_session`, `into_backend_io_v2`) are sync-blocking and upstream's `client_v2::connect` has no internal read deadline (see #842 upstream-coordination). A wedged v2 broker could hang the caller indefinitely — and since `probe_local_socket` is wired in production (the `RUNNING_PROCESS_FAKE_BACKEND` seam), this is not a hypothetical. Defense-in-depth from zccache's side, independent of any upstream fix: - `call_with_io_deadline` / `call_with_brokerv2_deadline` — internal helpers that run a blocking closure on a helper thread bounded by `recv_timeout`. Mirrors v1's `await_handoff_ready` pattern (`mpsc::channel` + `thread::spawn` + `recv_timeout`). - `probe_local_socket` now bounded by `DEFAULT_PROBE_TIMEOUT` (250ms — this is a liveness probe, not a usage connect). - `connect_v2_broker` now bounded by `DEFAULT_V2_BROKER_TIMEOUT` (3s, matching v1's `AsyncBrokerSession::adopt` budget). `adopt_v2_session` / `into_backend_io_v2` inherit through delegation. - `probe_local_socket_with_deadline` exposed for callers that want a custom budget. Doc-comment makes the `spawn_blocking` requirement explicit for async callers. On timeout, the BrokerV2 path synthesizes `BrokerV2Error::Dial { source: ErrorKind::TimedOut }` so caller classification (`from_brokerv2_error` returns `None` for `Dial`) routes through the direct-connect fallback path — the existing safety net does the right thing. Tests added (3): - `call_with_io_deadline_fires_on_slow_closure` - `call_with_io_deadline_passes_through_fast_ok` - `call_with_brokerv2_deadline_fires_on_slow_closure` All 7 broker_v2 unit tests pass. Part of #842 (broker-v2 burn-down ledger). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * chore(deps): path-dep running-process to .extern-repos for cross-repo fixes Switch the running-process source from the published 4.5.5 crate to a local git checkout at `.extern-repos/running-process` via a file:// git URL. This unblocks the cross-repo iteration cycle for the upstream issues filed at #842: - zackees/running-process#517 — Hello round-trip no read deadline - zackees/running-process#518 — BrokerV2Error::Refused buries retry_after_ms - zackees/running-process#519 — spawn_stub_broker socket leak Why git file:// and not path = …: A path-dep on `crates/running-process` collapses running-process into zccache's workspace context. running-process inherits `rusqlite` and other deps via `workspace = true`, but those entries don't exist in zccache's `[workspace.dependencies]`, so the patched build fails to resolve. Git URL preserves running-process's own workspace boundary. Iteration cycle: 1. Edit in `.extern-repos/running-process` 2. `git add && git commit` in `.extern-repos/running-process` 3. `soldr cargo update -p running-process` in zccache 4. `soldr cargo check` / `test` Revert this entry to the published version (4.5.6+) once the fixes ship upstream — tracked in #842. Part of #842 (broker-v2 burn-down ledger). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * chore(deps): update test sites for running-process Refused field promotion Upstream commit baf2d60 (in .extern-repos/running-process) promoted `retry_after_ms: u64` from `details: Box<Refused>` to a top-level field on `BrokerV2Error::Refused`. The two zccache test constructors now include `retry_after_ms: 0` to satisfy the struct-variant shape. Bump Cargo.lock to pick up the new running-process git rev. The classifier (`from_brokerv2_error`) uses `{ details, .. }` so it remains source-compatible across the field addition — no widening needed there until `BrokerRefusal::RateLimited` is similarly widened to carry the retry hint (deferred, v1+v2 chore). All 17 ipc::broker* tests pass against the patched running-process. Part of #842 (broker-v2 burn-down ledger). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(broker_v2): widen BrokerRefusal::RateLimited to carry retry_after_ms Round 2 audit finding: the round-1 fix #843 was half-done. `BrokerRefusal::from_brokerv2_error` mapped Refused → RateLimited (typed surface) but silently discarded `retry_after_ms`. Any caller using the typed `BrokerRefusal::RateLimited` could not honor broker- supplied backoff — only callers willing to match the raw `BrokerV2Error::Refused` got the hint. RateLimited callers were the motivating use case in running-process#518. Changes: - `BrokerRefusal::RateLimited` is now a struct variant `RateLimited { retry_after_ms: u64 }`. - `BrokerRefusal::from_kind` renamed to `from_kind_with_retry`, accepts `retry_after_ms: u64` and threads it into the RateLimited variant; other variants ignore it. - `classify_adopt_error` (v1 path) extracts `retry_after_ms` from `BrokerClientError::Refused { retry_after_ms, .. }` and threads through. - `from_brokerv2_error` (v2 path) extracts top-level `retry_after_ms` from `BrokerV2Error::Refused` (already promoted upstream by running-process#518) and threads through. Tests: - 2 existing test sites updated for the new variant shape. - `classify_adopt_error_propagates_retry_after_ms_on_v1_rate_limited` proves v1 path carries the hint. - `from_brokerv2_error_propagates_retry_after_ms_on_v2_rate_limited` proves v2 path carries the hint. - `from_brokerv2_error_maps_unknown_code_to_other` is an adversarial test from the round-2 brainstorm: a future ErrorCode the client predates (e.g. 999) must classify as `Other`, never panic. All 20 ipc::broker tests pass (3 new + 17 unchanged + 1 widened). Part of #842 (broker-v2 burn-down ledger). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(broker_v2): use Io(TimedOut) for deadline, not synthetic Dial path Round 2 audit finding #2: `call_with_brokerv2_deadline` returned `BrokerV2Error::Dial { socket_path: "<deadline-exceeded>" }` on deadline. This breaks downstream consumers that assert on the `socket_path` containing a real v2 broker namespace marker (e.g. "broker-v2" or "rpb-v2-zccache-") — a 3s timeout during cold-boot sid lookup would now produce a spurious test failure with a misleading error. Switch to `BrokerV2Error::Io(ErrorKind::TimedOut)`, mirroring the shape upstream `connect_with_deadline` returns after running-process #517 landed. Classification is unchanged (`from_brokerv2_error` returns `None` for Io, caller routes to direct-connect fallback). Test updated: `call_with_brokerv2_deadline_fires_on_slow_closure` asserts the new Io shape. Part of #842 (broker-v2 burn-down ledger). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test(broker_v2): stress test — 100 repeated deadlines without amplification Stress round (issue #842): pins the contract that `call_with_brokerv2_deadline` scales to repeated timeout cycles without deadlock / serialization. 100 calls in a row, each stalls for 60s with a 10ms deadline. Total wall-clock should be ~1s (each call returns on its own thread's deadline). Test budget is 5s — generous for CI. Addresses the round-2 audit "helper-thread leak amplification" concern at the wall-clock contract level. Pure resource accounting (fd / pid inspection) is platform-specific and tracked as a follow-up in ledger #842. Test completes in ~1.5s locally on Windows MSVC. Part of #842 (broker-v2 burn-down ledger). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(broker_v2): reject empty endpoint in probe_local_socket + 4 adversarial tests Final batch: 4 new probe_local_socket adversarial tests under crates/zccache/tests/v2_probe_local_socket_test.rs: - probe_local_socket_succeeds_against_live_listener: round-trips the actual name encoding against a real bound listener; catches regressions when `interprocess` is bumped. - probe_local_socket_rejects_empty_endpoint: caught a real bug — empty string was silently succeeding (to_ns_name accepted "" on Windows and Stream::connect returned Ok). Now Errs with InvalidInput. - probe_local_socket_rejects_nul_in_endpoint: NUL-byte injection must Err, not panic deep in interprocess. - probe_local_socket_does_not_hold_connection_past_drop: 20 consecutive probes against a background-draining listener complete in well under 2s — proves the `drop(stream)` in probe actually releases the connection. Bug fixed: `probe_local_socket("")` returned `Ok(())`. Added explicit `endpoint.is_empty()` guard at the entry; covered by the adversarial test above. This was a real defect the round-1 fixes did not surface — adversarial-test-first paid off. All 4 probe tests + all 24 ipc::broker* + 6 v2 integration tests pass against the patched running-process. Part of #842 (broker-v2 burn-down ledger). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * test(broker-v2): 10 new v2 tests — #848 round-2 burn-down Lands the deterministic P1/P2 tests from #848's round-2 audit. Test count for the v2 surface goes from 6 → 16. protocol_v2_roundtrip_test (6 new): - service_definition_decode_tolerates_unknown_future_field (P1-7) - service_definition_decode_rejects_truncated_input (P1-7) - backend_http_ready_round_trips_at_u16_boundaries (P2-9) - backend_http_ready_accepts_out_of_range_u32_at_decode_time (P2-9) - get_broker_http_endpoint_request_is_empty_marker (P2-9) - get_broker_http_endpoint_response_round_trips (P2-9) v2_pipe_naming_smoke_test (3 new): - v2_program_pipe_rejects_invalid_sid_length (P1-6) - v2_program_pipe_rejects_non_hex_sid (P1-6) - v2_program_pipe_handles_pipe_idx_max (P1-6) v2_probe_local_socket_test (1 new, Windows-only): - probe_local_socket_rejects_pipe_prefix_only (P1-4 Windows arm) Deferred to follow-up sub-issues: - P0-3 `brokered_backend_zccache_daemon_satisfies_fast_bind_contract` — needs zccache to impl `BrokeredBackend` (tracked in #777). - P1-8 `connect_v2_broker_round_trips_against_in_process_stub` — needs in-process v2 broker stub at the canonical `rpb-v2-zccache-*` pipe; the same gap blocks adopt-stream tests (P2-10). Also bundles trivial `cargo fmt` reflows touched while running the lint gate (broker.rs / broker_v2.rs — pure whitespace). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Jun 26, 2026
This was referenced Jul 11, 2026
zackees
added a commit
that referenced
this pull request
Jul 11, 2026
…1044) (#1045) * fix(daemon-core): address COW materialization follow-up findings (#1042) Fixes 4 of the 5 confirmed correctness bugs and the confirmed test-coverage regression from the post-merge review of #1040 (issue #1042): - artifact_io.rs: write the digest sidecar for a blob's final name *before* the publishing rename, not after — a digest-write failure can no longer leave an orphaned, undigested blob visible in the cache (finding #1). - artifact_io.rs: persist_artifact_file tries a hardlink before falling back to a full copy, restoring the STORE-direction fast path that commit 49dd59c dropped when it switched to reflink-then-copy (finding #4/#5). break_output_hardlink_before_compile already unconditionally detaches any shared alias (OS link-count based, not registry-based) before a compiler writes to that path again, so sharing an inode with the freshly-compiled source is safe. - link_registry.rs / write_cached.rs: commit_hardlink_registration no longer marks a blob suspect on a merely-unresolvable output identity (only on a genuine identity mismatch), and a commit failure now falls back to a copy the same way a failed std::fs::hard_link already does, instead of hard-failing the whole materialization (finding #3). - fs_caps.rs: cap the per-volume-pair capability cache at 4096 entries, clearing it wholesale when exceeded — a cheap, self-correcting bound on the previously-unbounded growth (finding #6, PLAUSIBLE/low severity). - tests/write_cached.rs: restored deterministic hardlink-tier assertions in 4 tests (including the issue #197 poisoning regression test) that had been weakened to silently skip their actual invariant when the hardlink tier wasn't taken (finding #5). Finding #2 (evicting valid pre-existing/pre-#1039 blobs with no digest sidecar) was investigated but NOT fixed as originally scoped: a first attempt trusted any digest-less blob with hardlink_count <= 1, but that heuristic is unsound — a since-deleted alias could have poisoned the blob before being removed, and link count only reflects the present, not whether a risky mutation window existed in the past. This was caught by the existing failed_restart_eviction_restores_readonly_and_retries_after_alias_delete regression test. Reverted to the original conservative eviction. Finding #1's fix already eliminates the primary real-world trigger (a freshly-persisted blob can no longer become visible without its digest); the remaining cost is a one-time cache miss for blobs written by a pre-#1039 zccache version on upgrade, which is the safer trade-off. Added regression tests for findings #1, #3, #4, and the reverted-#2 investigation. Local: 434/434 zccache-daemon-core unit tests pass on Windows; Docker Linux validation pending. * fix: harden COW persistence and parallelize rust-plan restore Closes #1042\nCloses #1044 * style: format COW and restore changes * fix: preserve compiler output writability on store hardlinks * test: allow shared inode store fast path * fix: migrate legacy COW blob digests Closes #1046 * test: skip hardlink-only cases on unsupported filesystems
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
std::path::Pathon Linux/macOS treats backslashes as literal characters, sodetect_family("C:\\emsdk\\upstream\\bin\\wasm-ld.exe")extractedfile_stemas"C:\\emsdk\\upstream\\bin\\wasm-ld", which matchedends_with("-ld")(GNU ld) before== "wasm-ld"(LLD) could match. This broke thedetect_wasm_ldtest on every Linux and macOS CI run.std::path::Path-based filename/stem extraction indetect_family()andis_compiler_driver()with cross-platform helpers that split on both/and\Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.