Skip to content

Add --offline flag covering source-tarball + git fetches - #202

Merged
bryan-minimal merged 5 commits into
mainfrom
no-fetch-covers-sources-and-vcs
May 27, 2026
Merged

bryan-minimal merged 5 commits into
mainfrom
no-fetch-covers-sources-and-vcs

Conversation

@bryan-minimal

@bryan-minimal bryan-minimal commented May 8, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds a new --offline global flag for running minimal in network-isolated environments where every input is pre-staged in the local cache. On cache miss, surfaces a clear error rather than attempting any network call.

--no-fetch semantics unchanged — keeps its existing meaning of "skip the remote artifact cache, build from source instead", which composes naturally with --rebuild for the laptop-rebuild-the-world use case.

Motivation

Running minimal package <pkg> inside a network-isolated build VM (Confidential Space, no internet egress) where source bytes are pre-staged in a sha-pinned mirror. There was no flag combination that meant "use cache only — if anything's missing, fail loud" — --no-fetch only affected the remote artifact cache, while source URL fetches and git clones quietly hit the network on cache miss.

After this patch, the same invocation surfaces:

Error: failed to fetch upstream layer: offline cache miss for git remote
https://github.com/gominimal/pkgs — --no-fetch is set; pre-populate the
vcs/ cache or remove the flag

Design

Per review feedback (thanks @msample, @twitchyliquid64) — extending --no-fetch would have conflated two distinct semantics. Cleaner shape:

  • --no-fetch (existing): skip the remote artifact cache. Source/VCS fetches still happen on cache miss. Useful for laptop rebuild-the-world flows alongside --rebuild.
  • --offline (new): treat every cache as authoritative. Source / VCS / artifact-cache misses all error rather than fetch. Implies the artifact-cache-skip half of --no-fetch (you can't reach the artifact cache when offline anyway), so --offline alone is sufficient.
  • Orthogonal to --no-cache and --rebuild: --offline doesn't force a rebuild, it just gates the network.

Changes

crates/common/src/file_cache.rs

  • FileCache gains offline: bool + new_with_offline(dir, offline) ctor + is_offline() accessor. Existing new(dir) preserved (defaults to offline=false).
  • CachingDownloader::download checks cache.offline after read_cached returns None; returns FileCacheError::OfflineCacheMiss { sha256, filename } instead of falling through to the network fetcher.

crates/common/src/remote_storage.rs

  • RemoteStorage::new_with_offline(dir, with_gcloud_auth, offline) forwards offline into FileCache. Default new unchanged.

crates/checkouts/src/lib.rs

  • Manager gains offline: bool + new_in_dir_with_offline. Existing new_in_dir preserved.
  • update(): no-op when offline (caller intent is "use what's there"; refresh-of-known-remote is non-destructive to skip).
  • checkout_of() known-remote path: skip repo.fetch() when offline.
  • checkout_of() unknown-remote path: return Error::OfflineCacheMiss { remote }.

crates/checkouts/src/error.rs: new OfflineCacheMiss variant + Display.

crates/mctx/src/config.rs

  • Config gains offline: bool field. New with_offline() builder + is_offline() accessor.
  • use_remote_cache() becomes !no_fetch && !is_offline() so --offline strictly implies the artifact-cache-skip behavior.

crates/mctx/src/lib.rs: VcsManager + RemoteStorage initializers pass config.is_offline() through to the new _with_offline constructors.

crates/mctx/src/error.rs: maps checkouts::Error::OfflineCacheMiss to a clear top-level message.

crates/minimal/src/main.rs: new --offline global CLI flag wired to ConfigBuilder::with_offline.

What this is not

  • Not a cache-population mechanism. Operators are expected to pre-stage ~/.cache/minimal/downloads/<sha256>/<filename> and the vcs/ directory themselves.
  • Not a --trusted-source-domains-style allowlist (per @msample's prompt). For the offline use case the URL doesn't matter — minimal looks up bytes by sha — but a trusted-domains flag for semi-online flows would be a reasonable separate addition.

Test plan

  • cargo fmt --check clean
  • cargo clippy --all-targets -- -D warnings clean
  • cargo test — full test suite passes
  • Six new unit tests cover the offline path:
    • file_cache::tests::offline_cache_miss_errors_without_fetching — PanickingBackend asserts the network path is never invoked
    • file_cache::tests::offline_cache_hit_returns_path_without_fetching — same assertion under cache-hit
    • file_cache::tests::online_cache_miss_invokes_backend — sanity check that default behavior is unchanged
    • checkouts::tests::offline_unknown_remote_errors
    • checkouts::tests::offline_update_is_noop
    • checkouts::tests::default_manager_is_online
  • Manual smoke: with the sed source cache wiped, minimal --offline package -v --rebuild sed errors with OfflineCacheMiss instead of silently re-fetching.

Future work (out of scope here)

  • proptest-style invariant tests across the cache surfaces (minimal doesn't currently use proptest; would be a structural addition worth its own PR)
  • cargo-fuzz harness for parser surfaces (Nickel decode, URL parsing, statefile JSON)
  • the trusted-source-domains framing @msample raised, for semi-online flows where some hosts are reachable and others aren't

Summary by CodeRabbit

  • New Features
    • Global --offline flag and config option; offline-capable managers and cache constructors to run without network access.
  • Behavior
    • When offline, network/VCS/cache fetches are suppressed and operations return clear offline-cache-miss errors advising cache pre-population or removing --offline.
  • Tests
    • Added tests for offline vs online cache behavior, checkout/update offline handling, and default online behavior.

Review Change Stack

…ct cache

Today `--no-fetch` only suppresses the remote build-artifact cache
(`gs://minimal-staging-cache`). Source-tarball downloads (op::SourceLoad)
and git clones / fetches (checkouts::Manager) ignore the flag — they
silently hit the network on cache miss.

This is a correctness gap for any consumer running `minimal package`
in a network-isolated environment (e.g., a Confidential Space VM
that pre-stages all inputs in a sha-pinned mirror, then expects
`--no-fetch` to mean "I'm offline; fail clean if anything's missing").
Today such a consumer can't tell whether minimal is using the cached
bytes or attempting a doomed network call.

Changes:

  crates/common/src/file_cache.rs:
    - FileCache gains an `offline: bool` field + `new_with_offline`
      ctor + `is_offline()` accessor. Existing `new(dir)` preserved
      for the default (online) path.
    - CachingDownloader::download checks `cache.offline` after
      read_cached miss; returns FileCacheError::OfflineCacheMiss
      instead of falling through to network.
    - New error variant carries (sha256, filename) for diagnostics.

  crates/common/src/remote_storage.rs:
    - RemoteStorage gains `new_with_offline(dir, auth, offline)`
      that forwards `offline` into FileCache. Default `new` unchanged.

  crates/checkouts/src/lib.rs:
    - Manager gains `offline: bool` field + `new_in_dir_with_offline`.
      Existing `new_in_dir` preserved.
    - update(): no-op when offline (caller intent is "use what's
      cached"; refresh-of-known-remote is non-destructive to skip).
    - checkout_of() known-remote path: skip `repo.fetch()` when offline.
    - checkout_of() unknown-remote path: return Error::OfflineCacheMiss
      (cannot clone without network).

  crates/checkouts/src/error.rs:
    - New OfflineCacheMiss { remote } variant + Display.

  crates/mctx/src/lib.rs:
    - VcsManager init: pass `!use_remote_cache()` through to
      `new_in_dir_with_offline`.
    - RemoteStorage init: same shape via `new_with_offline`.

  crates/mctx/src/error.rs:
    - Map checkouts::Error::OfflineCacheMiss to a clear message.

After the patch, `--no-fetch` is a true "offline mode" flag: cache
miss = fail with a helpful error (pointing operators at cache
pre-population) rather than a silent-then-failing network call.

Smoke test (manual, on the dev branch): `minimal --no-fetch package
sed --rebuild` with a wiped cache surfaces:

  Error: failed to fetch upstream layer: offline cache miss for
  git remote https://github.com/gominimal/pkgs — --no-fetch is set;
  pre-populate the vcs/ cache or remove the flag

Existing test suite (cargo test -p common -p checkouts) passes
without modification — change is purely additive on the cache path.
@coderabbitai

coderabbitai Bot commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds an offline mode flag propagated through Manager, FileCache, RemoteStorage, Config, Context, and CLI. In offline mode, cache or VCS misses return OfflineCacheMiss errors and network fetches are skipped; constructors, error mappings, and tests were updated.

Changes

Offline Mode Support for VCS and File Caching

Layer / File(s) Summary
Error Definitions
crates/checkouts/src/error.rs, crates/common/src/file_cache.rs, crates/mctx/src/error.rs
New OfflineCacheMiss variants and Display messages added to checkouts::Error and FileCacheError; mctx error conversion handles checkouts::OfflineCacheMiss.
Offline Fields & Constructors
crates/checkouts/src/lib.rs, crates/common/src/file_cache.rs, crates/common/src/remote_storage.rs
Manager, FileCache, and RemoteStorage gain offline: bool fields; new new_in_dir_with_offline / new_with_offline constructors added and original constructors delegate to them.
Offline Behavior Implementation
crates/checkouts/src/lib.rs, crates/common/src/file_cache.rs
When offline: Manager::update() returns OfflineCacheMiss; checkout_of() skips fetch for known remotes and returns OfflineCacheMiss for unknown remotes; CachingDownloader::download returns OfflineCacheMiss on cache miss instead of fetching.
Tests
crates/checkouts/src/lib.rs (tests), crates/common/src/file_cache.rs (tests)
Tests added to validate offline unknown-remote error, offline update() returns OfflineCacheMiss, offline cache-miss returns OfflineCacheMiss without invoking network, offline cache-hit returns cached path without network, and online cache-miss invokes backend and writes to cache.
Config, Context & CLI Wiring
crates/mctx/src/config.rs, crates/mctx/src/lib.rs, crates/minimal/src/main.rs
ConfigBuilder/Config gain offline flag and builder method; Context constructs VcsManager and RemoteStorage with the offline flag; CLI adds global --offline and run_cli applies it.

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant Context
  participant VcsManager
  participant RemoteStorage
  participant FileCache

  CLI->>Context: run with --offline
  Context->>VcsManager: new_in_dir_with_offline(true)
  Context->>RemoteStorage: new_with_offline(..., true)
  VcsManager->>FileCache: read existing bare repo or return OfflineCacheMiss
  RemoteStorage->>FileCache: request cached artifact -> hit or OfflineCacheMiss
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped in with no network near,

No fetch allowed — the rule is clear.
Cache your bits or face the miss,
Offline makes builds strictly hiss.
A rabbit guards the bytes with cheer.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a --offline flag that prevents network calls for source tarballs and git fetches, which is the primary objective of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands and usage tips.

@msample

msample commented May 8, 2026 •

Copy link
Copy Markdown
Member

This change seem like it's still allowlisting source downloads from our internal GCS? So it feels like this should be some form of --trusted-source-domains [list,..] style of option.

The original --no-fetch behaviour was nice for rebuilding the world locally on your laptop in a package repo (whether they came from GCS, github, or some mirror). It's useful for any pkg repo (well, if/when the bin cache source can be overridden)

@twitchyliquid64

Copy link
Copy Markdown
Contributor

For rebuilds, we now have the minimal package --rebuild flag. Need to double check that rebuilds everything when no package is provided, but that should be the goto for the 'rebuild the world' use-case.

Can discuss separate to this PR, but ive been thinking about turning down the --no-cache flag, its too confusing + --rebuild should cover its intended use.

impl Manager {
/// Initializes the checkouts manager in the given directory, returning a
/// thread-safe, cloneable handle to the manager instance.
pub fn new_in_dir<P: Into<PathBuf>>(base_dir: P) -> Result<ManagerHandle, Error> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future nit: when this grows more configurations we should create an Options struct and take that for a new method, ala Builder pattern.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged — agreed, will reach for an Options struct + builder when this constructor accumulates more flags. Tracking as future work; left the current shape as-is since it's only one new param.

/// In offline mode, returns [Error::OfflineCacheMiss] for the first remote we'd
/// have to fetch.
pub fn update(&mut self) -> Result<(), Error> {
if self.offline {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is called from things that really want to be fresh like minimal update - so prefer returning an error rather than silently lameducking; noop'ing here could lead to some hard-to-debug bugs.

Fwiw, update() shouldnt get called willy-nilly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call — fixed in 048c6b1. update() now returns Error::OfflineCacheMiss in offline mode (using the first known remote, or "<no remotes>" placeholder if state is empty). Test updated to assert the new behavior.

@msample

msample commented May 9, 2026

Copy link
Copy Markdown
Member

it seems cleaner to have --no-fetch-srcs for this. The srcs are not diff levels of the binary/outputs cache or a caches at all - misses aren't tolerated.

@bryan-minimal

Copy link
Copy Markdown
Member Author

Thanks both — agreed on the separation. The conflation here was wrong: "rebuild from source locally" and "I'm fully offline" are distinct semantics that shouldn't share a flag, especially with --rebuild already covering the laptop-rebuild use case independently.

Refactor plan:

  • Keep all the lower-level plumbing (FileCache::offline, Manager::offline, OfflineCacheMiss errors). Existing --no-fetch semantics restored exactly as before.
  • Introduce a new --offline CLI flag with its own Config::is_offline() accessor. The trigger for FileCache/Manager's offline mode moves from !use_remote_cache() to the new is_offline().
  • use_remote_cache() becomes !no_fetch && !is_offline() so --offline is a strict superset of --no-fetch (offline implies no artifact cache fetch either, since by definition we can't reach it).
  • Add tests on the new offline path: FileCache::download returns OfflineCacheMiss on cache miss when offline; Manager::checkout_of returns OfflineCacheMiss for an unknown remote and skips repo.fetch() for a known one.

@msample re: the GCS-allowlist question — for the offline use case the URL doesn't matter because the cache is sha-keyed: pre-populate ~/.cache/minimal/downloads/<sha>/<filename> and minimal finds bytes by hash without consulting the URL. So gs://internal-bucket/... vs https://github.com/... vs your own mirror all behave the same in offline mode. The --trusted-source-domains framing makes sense for a separate semi-online use case (allowlisted networks, blocklisted ones), but I'll keep that scope out of this PR.

Will push the updated branch shortly.

Per @msample / @twitchyliquid64 feedback on #202: extending --no-fetch
conflated two distinct semantics ("rebuild from source locally" vs
"I'm fully offline"). With --rebuild now covering the laptop-rebuild
use case independently, --no-fetch's existing meaning is restored
exactly and a new --offline flag carries the offline-mode semantics.

Behavior changes:

- New `--offline` global CLI flag (`crates/minimal/src/main.rs`).
- `Config` gains `offline: bool` field, `with_offline()` builder,
  `is_offline()` accessor (`crates/mctx/src/config.rs`).
- `use_remote_cache()` returns `!no_fetch && !is_offline()` — the
  artifact-cache-skip half of --no-fetch is implied by --offline,
  so callers who say --offline don't also need --no-fetch.
- mctx `RemoteStorage` + `VcsManager` initializers now pass
  `config.is_offline()` into the underlying offline mode (was
  `!use_remote_cache()` in the previous patch revision). With this,
  --no-fetch's existing semantic is unchanged: artifact-cache off,
  source/VCS fetches still happen.

Tests:
- 3 new tests in `crates/common/src/file_cache.rs`:
    - offline_cache_miss_errors_without_fetching
    - offline_cache_hit_returns_path_without_fetching
    - online_cache_miss_invokes_backend
  All three use a `PanickingBackend` for offline cases that asserts
  the network code path is never reached (the property that matters
  for hermeticity).
- 3 new tests in `crates/checkouts/src/lib.rs`:
    - offline_unknown_remote_errors
    - offline_update_is_noop
    - default_manager_is_online

CI: cargo fmt --check + cargo clippy --all-targets -- -D warnings
+ cargo test all clean.

Future-work suggestions noted on the PR (proptest infrastructure,
fuzz harness for parser surfaces) — both are valuable but
structurally separate from this change and out of scope here.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bryan-minimal bryan-minimal changed the title --no-fetch: cover source-tarball + git fetches, not just artifact cache Add --offline flag covering source-tarball + git fetches May 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/mctx/src/config.rs (1)

222-228: ⚡ Quick win

Add explicit tests for the offline × no_fetch behavior matrix.

This method now defines core cache semantics; a small matrix test prevents subtle regressions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/mctx/src/config.rs` around lines 222 - 228, Add unit tests covering
all four combinations of the Config flags to lock in cache semantics:
instantiate Config (or builder) with (offline, no_fetch) = (false,false),
(false,true), (true,false), (true,true) and assert the expected outcomes for
both the derived network-fetch predicate (!self.no_fetch && !self.offline) and
the is_offline() method; reference the is_offline() method and the no_fetch
field (and the function or method that computes the fetch-allowed boolean if
present) when adding these tests in the config test module so any future changes
to is_offline or no_fetch behavior will be caught.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/mctx/src/lib.rs`:
- Around line 412-418: The call to common::RemoteStorage::new_with_offline(...)
uses .unwrap(), which can panic; replace the unwrap with proper error
propagation (e.g., use ? or map_err to convert the error into your crate's Error
type) and return a contextual Error from the surrounding function (include
context such as "failed to initialize RemoteStorage with downloads_dir:
{self.config.downloads_dir()}"). Update the surrounding function signature to
return Result if needed and ensure the initialization uses the returned Err
instead of crashing.

---

Nitpick comments:
In `@crates/mctx/src/config.rs`:
- Around line 222-228: Add unit tests covering all four combinations of the
Config flags to lock in cache semantics: instantiate Config (or builder) with
(offline, no_fetch) = (false,false), (false,true), (true,false), (true,true) and
assert the expected outcomes for both the derived network-fetch predicate
(!self.no_fetch && !self.offline) and the is_offline() method; reference the
is_offline() method and the no_fetch field (and the function or method that
computes the fetch-allowed boolean if present) when adding these tests in the
config test module so any future changes to is_offline or no_fetch behavior will
be caught.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c94a0ae4-7af4-4344-b941-f772a3133a93

📥 Commits

Reviewing files that changed from the base of the PR and between b511f53 and 1054571.

📒 Files selected for processing (5)
  • crates/checkouts/src/lib.rs
  • crates/common/src/file_cache.rs
  • crates/mctx/src/config.rs
  • crates/mctx/src/lib.rs
  • crates/minimal/src/main.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • crates/common/src/file_cache.rs
  • crates/checkouts/src/lib.rs

Comment thread crates/mctx/src/lib.rs Resolved
…rage init

@twitchyliquid64 (#202 review): `Manager::update` should not silently
no-op in offline mode. It's called by callers like `minimal update`
that explicitly want fresh state, so silently lameducking would mask
hard-to-debug bugs. Now returns Error::OfflineCacheMiss with the
first known remote (or "<no remotes>" placeholder if state is empty).
Test updated to assert the new behavior.

@coderabbitai (#202 review): mctx::Context::remote_storage() unwrap'd
on RemoteStorage init failure, which can panic on recoverable startup
errors. Replaced with .map_err(|e| Error::Other(anyhow!(...)))? to
propagate via the existing error type. Drive-by — was pre-existing in
the line we already touched, fixing while close.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 423a39a5-2e68-4458-88d3-7ed0b6457535

📥 Commits

Reviewing files that changed from the base of the PR and between 1054571 and 048c6b1.

📒 Files selected for processing (2)
  • crates/checkouts/src/lib.rs
  • crates/mctx/src/lib.rs

Comment on lines +326 to 334
// Offline: skip the fetch and try the worktree checkout against
// what's already in the bare repo. If the requested ref isn't
// there, `new_worktree` will surface a git error from below
// — which is the right outcome (caller gets to know the ref
// wasn't pre-populated).
if !self.offline {
repo.fetch()?;
}
let checkout = repo.new_worktree(checkout_dir.clone(), at.clone())?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Return OfflineCacheMiss for known-remote ref misses in offline mode.

In offline mode, Line 334 can return a raw git error when the requested ref is not already present locally. That is still an offline cache miss and should surface as Error::OfflineCacheMiss { remote } for consistent UX/error mapping.

This currently creates two different error shapes for the same offline-miss class (unknown remote → OfflineCacheMiss, known remote but missing ref → git error).

The patch introduced --offline as a separate flag (per review), but
the OfflineCacheMiss error messages still pointed at --no-fetch.
Found during a local smoke test where the error pointed operators
at the wrong flag.

Fixes three sites:
- crates/common/src/file_cache.rs:FileCacheError::OfflineCacheMiss
- crates/checkouts/src/error.rs:Error::OfflineCacheMiss
- crates/mctx/src/error.rs (the From impl for checkouts::Error)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bryan-minimal

Copy link
Copy Markdown
Member Author

Stacked one more commit (9e6668b): fixes a wording bug in the OfflineCacheMiss error messages. They were still saying --no-fetch is set instead of --offline is set — caught during a local smoke test where I would have pointed an operator at the wrong flag. Three sites updated (file_cache.rs + checkouts/error.rs + mctx/error.rs).

Also independently smoke-tested the end-to-end offline flow: minimal --offline package <pkg> correctly errors on any transitive prebuilt-dep cache miss, walking the full graph (not just the leaf source). Architecturally sound for the hermetic-builder use case — staging just needs to walk the same transitive graph.

@gominimal-aw-bot

Copy link
Copy Markdown
Contributor

This PR has been waiting for review for 11 days. A maintainer probably
just needs a quick look — even a "needs more changes" comment helps it
move forward.

If the PR is intentionally on hold, consider converting it to a draft
or adding the needs-human label so this nudge stops firing.

@bryan-minimal, anything blocking from your side?

Generated by PR nudge (side-repo-ops operator) · ● 4.5M · ◷

@gominimal-aw-bot gominimal-aw-bot Bot added the agent:pr-nudge Applied by the pr-nudge agent label May 22, 2026
…line mode)

The remote artifact cache is sha-verified on hydrate, so cached pulls
are hermetically clean even when offline mode forbids source-tarball or
VCS fetches. Drop the offline check from use_remote_cache (now
!no_fetch only).

Motivating use case: minimalmertic hermetic-builder-rs sets
with_offline(true) to surface mirror-source gaps as clear errors. It
also wants to read from a signer-attested build cache for expensive
deps like llvm. Previously these were mutually exclusive; now they
compose. Set with_no_fetch explicitly to disable the artifact cache in
fully air-gapped builds.

Non-breaking for callers that rely on offline implying no_fetch — those
callers should now set both flags explicitly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/mctx/src/config.rs (1)

189-191: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix stale offline/no_fetch docs and rustdoc intra-link targets

  • Config::offline docs still say it “Implies” [Self::no_fetch], but offline is independent of no_fetch (and use_remote_cache is gated only on no_fetch).
  • Config::use_remote_cache docs reference an invalid rustdoc target ([Self::with_no_fetch]); with_no_fetch is on ConfigBuilder.
Suggested doc fixes
-    /// any network call. Implies the artifact-cache-skip half of [Self::no_fetch].
+    /// any network call. Independent from [Self::no_fetch].

@@
-    /// allowed in offline mode. Set [Self::with_no_fetch] explicitly to
+    /// allowed in offline mode. Set [ConfigBuilder::with_no_fetch] explicitly to
     /// disable the artifact cache in fully air-gapped configurations.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/mctx/src/config.rs` around lines 189 - 191, Update the field docs so
they are accurate: for Config::offline, remove the phrase that says it "Implies
the artifact-cache-skip half of [Self::no_fetch]" and state that offline is
independent from no_fetch (it errors on cache/VCS misses without changing
no_fetch/use_remote_cache behavior); for the Config::use_remote_cache docs fix
the broken rustdoc intra-link by referencing the builder method correctly
(ConfigBuilder::with_no_fetch or with_no_fetch on ConfigBuilder) instead of the
invalid [Self::with_no_fetch] target so the link points to the actual
ConfigBuilder method.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@crates/mctx/src/config.rs`:
- Around line 189-191: Update the field docs so they are accurate: for
Config::offline, remove the phrase that says it "Implies the artifact-cache-skip
half of [Self::no_fetch]" and state that offline is independent from no_fetch
(it errors on cache/VCS misses without changing no_fetch/use_remote_cache
behavior); for the Config::use_remote_cache docs fix the broken rustdoc
intra-link by referencing the builder method correctly
(ConfigBuilder::with_no_fetch or with_no_fetch on ConfigBuilder) instead of the
invalid [Self::with_no_fetch] target so the link points to the actual
ConfigBuilder method.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f703b964-b444-42d8-b91a-72df12e3198e

📥 Commits

Reviewing files that changed from the base of the PR and between 9e6668b and deb19a4.

📒 Files selected for processing (1)
  • crates/mctx/src/config.rs

@bryan-minimal

Copy link
Copy Markdown
Member Author

Pushed one more commit on top: deb19a4e mctx: split offline from no_fetch (artifact cache stays usable in offline mode).

This refines the design from earlier review: the remote artifact cache is sha-verified on hydrate (rcache::RemoteCache::materialize), so cached pulls are hermetically clean even when --offline is set. Dropping the offline-implies-no_fetch coupling lets callers compose them independently:

  • --offline alone: source/VCS fetches gate on cache; artifact cache still readable.
  • --no-fetch alone: artifact cache off; source/VCS fetches still happen (existing meaning).
  • --offline --no-fetch: both off, fully air-gapped (was the previous default of --offline alone).

Motivating use case (concrete): the minimalmertic hermetic-builder-rs sets with_offline(true) to surface mirror-source gaps as clear errors, but ALSO wants to read from a signer-attested build cache for expensive deps like llvm (3+ hour rebuild otherwise). Previously these were mutually exclusive; now they compose.

Non-breaking for callers that relied on the old coupling — they should set both flags explicitly. Default behavior preserved for --offline alone (still the safe choice).

Diff: crates/mctx/src/config.rs only (18 insertions, 5 deletions). No new tests because the existing offline-mode tests already cover the cache layers; this is purely a config-flag-semantics adjustment.

Sibling PR #228 carries the related sandbox2 + op changes that the hermetic-builder-rs use case needs alongside this — kept separate because that's CS-sandbox plumbing rather than offline-mode work.

@bryan-minimal
bryan-minimal merged commit ed6a299 into main May 27, 2026
8 checks passed
@bryan-minimal
bryan-minimal deleted the no-fetch-covers-sources-and-vcs branch May 27, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:pr-nudge Applied by the pr-nudge agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants