Skip to content

Realm mirrors are used: transport, never authority — first contact needs the primary (REQ-MIRROR-002, #301) - #315

Merged
avrabe merged 14 commits into
mainfrom
feat/mirror-002
Nov 5, 2026
Merged

avrabe merged 14 commits into
mainfrom
feat/mirror-002

Conversation

@avrabe

@avrabe avrabe commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #301, implementing REQ-MIRROR-002. A realm's declared mirrors are now actually used. Before this, they were parsed and never read, so a down primary failed even with mirrors configured.

What a mirror may and may not do

A mirror is transport, never authority. Every byte from any source must verify against the realm's one trust root. Beyond that:

primary mirror
fetch order first in the order written
first contact with a line (no high-water mark, no cached status) ✅ ❌ FirstContactNeedsPrimary, refused before the mirror is contacted
install with local history ✅ ✅ bounded by the local mark (or the cached floor when there is no mark); the notice names the mirror and what bounds it
rollback consent for a digest pin ✅ ❌ never, and a mirror-sourced status is never cached, so it can't become consent later
support-horizon baseline and correction ✅ ❌ primary only; a mirror supplies layer bytes
verified refusal (rollback, below floor, channel demotion, platform) terminal not retried on a mirror
inauthentic or unavailable bytes → next source → next source
$VARVE_REGISTRY_AUTH / docker-config credentials ✅ its own origin ❌ different origin (scheme+host+port): nothing; cleartext mirror: nothing at all

First contact needs the primary. That was your decision of 2026-11-05. varve is offline and clockless, so a lagging mirror's older, genuinely signed state can't be told apart from the current one. Only this machine's own history can bound it. concept-config-reference.md states what remains at risk: with the primary down, a machine that has installed before can be served a state no older than what it recorded. A fresh machine cannot install from a mirror at all.

Review

Evidence

  • cargo test --workspace after merging current main: 1903 passed, 0 failed.
  • clippy -D warnings and fmt: clean.
  • rivet validate: pass. REQ-MIRROR-002 is amended with D1–D5.
  • Mutation runs, CI form, all 0 missed:
    • install.rs: 62 mutants tested in 13m: 53 caught, 9 unviable;
    • mirror.rs and support.rs: 159 mutants tested in 20m: 139 caught, 20 unviable;
    • linestatus.rs: 131 mutants tested in 14m: 93 caught, 38 unviable;
    • registry.rs and lineindex.rs (--in-diff): 27 mutants tested in 5m: 21 caught, 6 unviable.
  • System tests (crates/varve/tests/mirror_failover.rs): they run against loopback registries. Most failed before their fix. The tests that were already green, or written alongside the code, are named as such in the commit messages.
  • Fetch-site guard (crates/varve/tests/realm_fetch_sites.rs): fails on any primary-only fetch site outside a reasoned allowlist. It was negative-controlled.

🤖 Generated with Claude Code

https://claude.ai/code/session_019TNtfRjLNhEz82G2ggeeNu

avrabe and others added 13 commits November 4, 2026 20:57
Every realm fetch (install, composed-include fetch, outdated's signed line
index, baseline line-status, support/RealmAccess reads) now goes through
Mirrors built from Realm::sources, primary first then mirrors as written.
Install, include fetch, outdated and line-status run fetch AND verify per
source (Mirrors::attempt), so bytes failing the realm's one trust root are
refused and the next source is tried. A non-primary answer is announced on
stderr. Mirrors gained a served_layers delegate (the trait default would
have silently disabled the omission check). A source-scanning test refuses
realm.registry / hand-parsed RegistrySource outside an allowlist with stated
reasons (producer/publishing sites go to the primary).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…inauthentic bytes fail over

Mirrors::attempt took every error as a reason to ask the next source, so a
genuine layer refused as a rollback/below-floor by the primary got a second
chance against a stale mirror: failover itself mounted the freeze/rollback
attack. attempt now takes a classifier; an error it rejects is returned at
once and no later source is asked or announced.

InstallError, IndexError and LineStatusError gain fails_over(), exhaustive
matches with no wildcard arm so a new variant forces a decision. Rollback,
RollbackConsentRefused, BelowFloor, NoPlatformEntry, UnnamedEntry, Store,
State, index Stale/Io and line-status Stale and local errors are terminal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… per-source walks, absent is not the end

- A mirror on a host other than the realm primary's gets no environment
  credential, and a credential it does hold goes only to a token endpoint on
  its own host. The primary keeps its established behaviour.
- support-horizon (DefinedRealms) walks each layer from one source at a time
  via Mirrors::attempt, so bytes failing the root move on to the next source;
  per-fetch failover no longer reports "none published" after an earlier
  source was unreachable. A bad mirror spec breaks only its own realm.
- IndexError::Stale and LineStatusError::Stale fail over (same local cache
  judges every source). RollbackConsentRefused carries source_fault: a
  missing/unverifiable status fails over, a verified yank/expiry is terminal.
- Mirrors::attempt_some: an absent answer does not end the search (baseline
  line-status, outdated's index).
- Notices give each skipped source's reason; unknown URL schemes and relative
  paths in a realm are refused; the retired-roots diagnosis asks the source
  that produced the failing verdict.
- Scan test blanks #[cfg(test)] items by brace matching, recognises more
  shapes, and narrows its allowlist to specific lines.
- Tests: real blob failover, different layer for a pinned digest, the
  mirror's own refusal reason, credential leak, forged primary on the walk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fails closed; consent is terminal

- support-horizon walk: once any earlier source failed to answer, a later
  source's "no correction published" is an error ("could not be established"),
  not absence (Published::MustBePresent). A correction actually found still
  settles it; a primary that answered None establishes absence for itself.
- Credential binding fails closed: every source after the first is a mirror,
  restricted unless provably the primary's ORIGIN; a directory/OCI-layout
  primary unlocks nothing. Origin is scheme + lowercased host:port with
  default ports normalised, so an oci+http mirror on an oci:// primary's host
  is restricted.
- RollbackConsentRefused is terminal in every case again (source_fault
  removed): consent lifts a protection and must not be obtainable by asking
  another source; availability for a digest-pinned rollback install is the
  chosen cost, recorded on consent_why_not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ify and be selected

Under Published::MustBePresent (an earlier source could not be asked), a
published envelope that is present but does not verify, covers another line,
or is outranked by the baseline no longer lets the baseline answer: it is an
error ("could not be established"). Only the published document itself
settles absence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Rollback consent (digest pin below the mark) is refused on any non-primary
  source: a lagging mirror may predate a yank. install_from/install_by_digest_from
  carry the source's role; Mirrors::attempt tells the closure which source is
  the primary.
- First contact: a mirror with no verifiable line-status cannot state the
  realm's floor; new terminal InstallError::FloorNotEstablished.
- Mirrors::attempt_some: None is returned only if every source answered none;
  after any failed source absence is unknown (an error). Call sites say so.
- A restricted cleartext (oci+http) mirror sends no credential of any kind,
  including docker-config entries, which ignore the scheme.
- ChannelMismatch is terminal (a realm-signed demotion); LayerMismatch still
  fails over.
- Notice no longer prints an empty reason when an earlier source merely had
  none; a verdict produced by a later source is labelled with that source.
- Per-fetch failover (impl LayerSource for Mirrors) is test-only; RealmView
  carries RealmSource::{Single, Failover} so production cannot combine
  answers across sources by accident.
- Scan test: a gated item on the attribute's own line, braces in literals,
  Realm destructuring, Mirrors::single/new outside the allowlist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…launder consent

The post-install baseline cache step took its status from whichever source
answered, and a later digest-pinned install reads that cache as rollback
consent, so a status from a lagging mirror became consent it could not give
directly. Only the realm's primary may supply the cached baseline; a mirror
is not asked, and if the primary cannot answer no baseline is cached and a
note says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…from the primary

Maintainer decision (2026-11-05):

- First contact (no high-water mark and no cached line-status for the line) is
  answered only by the realm's primary: a mirror is refused, terminal, before
  anything is fetched from it (InstallError::FirstContactNeedsPrimary replaces
  the "mirror needs a verified status" floor rule, which an old genuine status
  with min_counter None defeated).
- With local history a mirror answers, bounded by marks and the cached status,
  and the notice says what bounds it. A pre-demotion manifest from a lagging
  mirror is inside that documented risk.
- support-horizon takes published corrections only from the primary
  (current_line_status_with_correction); a mirror may supply the layer bytes
  and baseline. Published::MustBePresent is removed.
- A mirror with no line index leaves the omission check unable to run, which is
  reported (InstallOutcome::omission_check_skipped), not silently skipped.
- Docs: concept-config-reference gains a "mirrors" section stating the residual.

Bugs: attempt_some keeps a later failure from undoing an authoritative none
(B2); the credential test resolves against a test-controlled config (B3); the
scan forbids the public install wrappers, source_from_spec and
sources.iter().next() outside allowlisted sites (B4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ary's; first-contact refusals before contact

- F1: with no mark, the first-contact floor is the min_counter of the
  HIGHER-counter verified status among the cached one and the one the source
  serves, so a source (primary or mirror) can only raise the bar.
- F2: support-horizon takes every status document that decides a window (the
  baseline and any correction) only from the primary; a mirror supplies layer
  bytes only (current_line_status_from_documents).
- F3: install_by_digest_from takes a DigestRole; a mirror is refused a first
  contact before it is contacted, using the line from the include that named
  the digest (an include naming no layer cannot be taken from a mirror).
- F5: `outdated` with no cached index treats a mirror's answer as a first
  contact (could not be established), not "nothing newer".
- F6: a mirror that carries an index but cannot enumerate its served layers
  leaves the omission check unrun, and that is reported.
- F4/F7: docs state the --from and --from-file operator acts and the F2 rule;
  REQ-MIRROR-002 amended via rivet with the maintainer's decision and a
  restated clause 4. install_from's stale doc comment is fixed.
- F8: the registry test asserts the docker-config credential, not the env one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lled-include test

- Docs and the REQ-MIRROR-002 amendment say exactly what bounds a mirror: the
  high-water mark when there is one (the cached status's floor is not
  consulted), the cached status's floor only when there is NO mark, and a
  cached yank only on the rollback-consent path.
- Messages: the omission notice says whether the mirror has no index or cannot
  enumerate (OmissionSkipped); `outdated` refuses with "no cached line index"
  (IndexFirstContactNeedsPrimary); an include whose line cannot be known says
  so, absent and unparseable apart (LineUnknownForMirror); BelowFloor no longer
  claims the machine never installed when only its marks were reset.
- A primary status that does not verify is terminal in the support walk.
- Tests: outdated refuses a mirror's genuine OLD index; the mirror is named in
  the include walk; a mislabelled include (named line has history, digest is a
  line without) is refused terminally and installs nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@temper-pulseengine

Copy link
Copy Markdown

Automated review for PR #315

pulseengine/varve:feat/mirror-002 → pulseengine/varve:main

Verdict: 💬 Comment

Summary: The patch introduces new methods and error handling for selecting the correct line status from documents, including baseline and published correction. It also verifies that these methods adhere to the REQ-MIRROR-002 requirement by ensuring that they can handle failures gracefully.

Findings: 0 mechanical (rivet) · 2 from local AI model.

Findings (2):

  1. src/verify.rs:176

    impl LineStatusError {
    

    The LineStatusError struct now includes a fails_over method that determines if another source can be asked after this failure.

  2. src/verify.rs:2702

    mod tests {
    

    The patch includes several test cases to verify the correctness of the current_line_status_from_documents and select_current methods.


Generated by a local AI model and post-validated against a strict JSON contract. Each finding includes the verbatim line being criticised — verify by reading the file at the cited location.

Reviewed at 6999991

… 90:00 on #315

varve-core (trust) and varve-core (lines) reported no summary on #315: each
was cancelled at the 90-minute cap, after 70 and 81 minutes on #314. The
mirror work grew install.rs, mirror.rs and support.rs. As every earlier
split in this job did, move files rather than drop one or raise the cap:
install.rs, selfverify.rs and reverify.rs go to varve-core (install);
mirror.rs and support.rs go to varve-core (mirror). Every gated file stays
gated: mutation_scope_is_decided_not_drifted passes, and fails naming
mirror.rs when that line is removed. Only the aggregate gate is a required
check, so the new shard names change no ruleset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019TNtfRjLNhEz82G2ggeeNu
@avrabe
avrabe merged commit 7eb9958 into main Nov 5, 2026
46 checks passed
@avrabe
avrabe deleted the feat/mirror-002 branch November 5, 2026 16:38
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.

Realm mirrors are parsed and never used: every fetch goes to the primary registry, so a down primary fails even with mirrors declared

1 participant