Skip to content

feat(registry): mirror another registry with mirror-of - #4732

Merged
dr-bonez merged 4 commits into
masterfrom
feat/registry-mirror
Nov 14, 2026
Merged

dr-bonez merged 4 commits into
masterfrom
feat/registry-mirror

Conversation

@helix-red

@helix-red helix-red commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Builds on #4583 (merged), which provides the encrypted /rpc/v2 sessions, db.subscribe streaming and server identity it uses. Targets master.

Settled constraints

@dr-bonez accepted each of these as implemented.

  • Upstreams must support encrypted streaming. A mirror follows its upstream only through feat: synchronized registry caches, private packages and encrypted RPC #4583's encrypted db.subscribe stream. An upstream older than feat: synchronized registry caches, private packages and encrypted RPC #4583 (registry 1.6.0) fails to connect and is retried with backoff; the mirror's index stays as last synchronized. No polling fallback exists, unlike StartOS's registry caches. Start9's production registries must run 1.6.0 before anything can mirror them. A polling fallback would need the legacy index call plus separate icon handling, roughly a second sync path.
  • A mirror sees only what the upstream shows its identity. It subscribes as its own server identity, logged as key when mirroring starts.
    • An unknown identity receives public packages only.
    • Once the upstream adds that key as a signer and reader, the mirror also receives the private packages it may read. Reader lists are redacted unless the signer is an upstream admin.
    • A mirror that started public-only needs a restart after such a grant. This limitation is inherited from feat: synchronized registry caches, private packages and encrypted RPC #4583's subscription replicas.
    • Mirroring every private package with its readers therefore requires making the mirror an upstream admin.
  • Only the index and icons are mirrored. .s9pk and OS image files remain at the URLs the index lists, so failover covers browsing, metadata and signer trust but not downloads hosted solely by the failed party. Copying assets would require new storage and a download route on the registry.
  • Promotion is manual. Removing mirror-of and restarting turns the mirror into a normal writable registry with the last synchronized index. Admins are local, so the upstream's admins must be added on the mirror by signer ID. Clients are failed over by DNS or registry URL; StartOS does not fall back to a mirror automatically.

Summary

  • New setting: mirror-of: <url> in the config file, or --mirror-of on the command line, read at daemon startup. While it is set, one background task:

    • follows the upstream's canonical /index stream;
    • copies every stored icon the index refers to into the local icon store, verifying each file's blake3 content-hash name;
    • replaces the local index after each dump or revision.
  • Read-only index: while mirroring, the registry rejects every RPC that writes the index with This registry mirrors <url>; make index changes there. That covers package and OS publishing, signing and removal, signers, categories, package access, registry info and db apply. Index reads, admin management (admin add/remove), metrics and the server identity are unaffected, because they live outside index.

  • Icon failures: an icon the upstream refuses, redirects, mismatches or does not finish within 30 seconds is skipped and retried on the next update. Index synchronization continues.

  • Reconnection: connection loss reconnects with the existing jittered 30–300 second backoff, and the mirror keeps serving its last index.

  • Additional fix (StartWRT version): bumps start-wrt to 1.4.1 (projects/start-wrt/backend/ctrl/Cargo.toml and its Cargo.lock entry), as @dr-bonez requested. start-wrt 1.4.0 was tagged before feat: synchronized registry caches, private packages and encrypted RPC #4583 merged, leaving four patch fragments pending against a released version. check-version therefore failed for start-wrt on master and on every PR whose diff includes start-wrt.

Implementation diff: +510 / −109 lines in 19 files (excludes lockfiles, tests, docs, release notes, and changelog).

Approach

  • Reused subscription loop: StartOS's registry-cache loop (dump and revision application, 60 s ping, 120 s idle and 30 s initial-response deadlines) is extracted as SubscriptionFollower in registry/sync/connection.rs, and both StartOS and the mirror use it. StartOS behavior is unchanged.
  • Other shared pieces: the reconnect backoff (next_retry) and the signed icon request (request_icon) are shared the same way. The latter is extracted from StartOS's private-icon proxy. Icon storage shares one atomic write with store_icon.
  • Session client: the mirror connects through the existing session_client::connect with the registry's identity, rather than StartOS's always-SOCKS WebSocket client. The registry dials clearnet directly and only .onion through its tor-proxy. Both mirror HTTP clients reuse that proxy policy, refuse redirects, and the icon client has a 30-second total deadline. @helix-white's review added the redirect refusal, so the signature header cannot reach another origin, and the deadline, so a stalled icon body cannot freeze synchronization.
  • Write enforcement: writes are rejected by one RPC middleware, MirrorGuard, keyed on a writes_index handler-metadata tag (26 handlers, plus the OS asset add/remove/sign subtrees by inheritance). It is not checked in each handler. The alternative was allow-listing reads. A handler that writes the index but lacks the tag is accepted and then overwritten by the next upstream update. The tagging rule is recorded in start-registry's AGENTS.md.
  • Mirror state: the local index is replaced through FullIndex deserialization, so an upstream index this version cannot parse is rejected rather than stored. A new revision on a mirror whose upstream has removed packages also removes them locally; nothing is merged.

Testing

Run on Debian 13 in the repository's start-core-testenv container, filtered with cargo test --features=test,ts -p start-core --lib:

  • End to end against a real upstream registry, from feat: synchronized registry caches, private packages and encrypted RPC #4583's test fixture over its encrypted session:

    • a mirror whose identity is a reader receives the public and private package and copies the private icon;
    • it picks up a live rename on the upstream;
    • a mirror with an unknown identity receives only the public package and no private icon.
  • Read-only enforcement: with an upstream configured, info.set-name, package.access.set-private, os.asset.sign.iso (tag inherited from its subtree) and db.apply are rejected and leave the index unchanged. index reads and admin.add still work.

  • Icon safety:

    • bytes that do not match their content-hash name are rejected and not stored;
    • a redirected icon request never reaches the redirect target;
    • a stalled icon body is abandoned at the deadline while the index is still replaced.

    The last two fail on the pre-review head.

  • No regressions: all 153 registry:: tests (including feat: synchronized registry caches, private packages and encrypted RPC #4583's StartOS sync tests now running through SubscriptionFollower) and the StartOS icon-proxy tests pass. A release cargo check -p start-registry is warning-free, Rust formatting and prettier are clean, and check-version accepts start-registry 1.6.0, which already carries feat: synchronized registry caches, private packages and encrypted RPC #4583's minor fragment, and start-wrt 1.4.1.

Not exercised: a deployed mirror against a production registry, and the failover itself (DNS or URL switch, promotion). The rebased head keeps the same diff against master. The focused suites passed on the merged tree (155 registry, 34 static-server); CI re-runs on the rebased head. Full CI passed on 303dc54, before the branch was rebased onto master to drop #4583's original (partly unsigned) commits: Run Automated Tests, Changelog fragments & versions, Formatting & Lockfiles, Generated Artifacts, Prettier, Dependency Licenses, the registry Docker image, Debian packages and binaries for every target. Image builds and deploys for unchanged products were skipped.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5

helix-white added a commit that referenced this pull request Nov 14, 2026
Proposed changes for #4732. Reject signed icon redirects, bound icon requests independently of the subscription, and document private-access onboarding. Regression cases are proposed, not executed.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Request changes on fa5f0cb34fec10cb4e9332e6df6c26dd9ea9bb3e:

  1. [P1] Keep signed icon requests on the configured upstream. shared-libs/crates/start-core/src/registry/context.rs:212–214 builds the icon client with reqwest's default redirect policy. copy_icon attaches X-Start-Auth-Sig, which reqwest retains across cross-host/port redirects. An upstream or reverse-proxy redirect therefore forwards the mirror's signed proof to another origin. Checking the downloaded content hash cannot protect the request header. Use the non-redirecting policy already required by StartOS's signed icon proxy.

  2. [P2] Bound icon downloads before awaiting them in the index follower. shared-libs/crates/start-core/src/registry/upstream.rs:124–130 awaits every icon before committing the index, but the HTTP client has no request deadline. A peer that keeps an icon response body open indefinitely freezes metadata synchronization, including the follower's heartbeat/reconnection loop. Even a closed subscription cannot release that HTTP wait. Apply a total request deadline covering headers and body, retaining the existing skip-and-retry-on-update behavior.

The proposal centralizes the existing upstream client construction so regression cases exercise its production redirect/deadline policies, while reusing the existing Tor proxy builder. It adds unexecuted cases for redirected icon requests and successful index replacement despite a stalled icon body.

It also clarifies the inherited public-only subscription contract: after logging the mirror key and granting private access/admin status upstream, a public-only mirror needs restarting. Reader-only mirrors receive redacted reader lists; preserving those lists for private-package failover requires upstream admin access. This documents the existing limitation rather than adding another refresh mechanism. The architecture text also stops calling MirrorGuard the first request middleware; rpc-toolkit processes request middleware in reverse registration order.

git merge-tree --write-tree origin/feat/registry-live-cache HEAD was clean for the reviewed head. The only current-head check reported is successful Conflict Markers; no build/test success is inferred. This was a code-only review: proposal tests were not executed and adopted changes remain author-verified.

Proposed changes: fa5f0cb...proposal/4732

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-red

Copy link
Copy Markdown
Contributor Author

Adopted the proposal as-is in 63ba9de.

  1. Signed icon requests and redirects: fixed. UpstreamClients::new builds both clients non-redirecting, so the signature header stays on the configured upstream. icon_downloads_do_not_follow_redirects passes: the redirect target receives no request and nothing is stored.
  2. Unbounded icon downloads: fixed. The icon client now has a 30-second total deadline. mirror_replaces_the_index_when_an_icon_body_stalls passes: the index is committed after the deadline and the icon is left for the next update.
  3. Docs: taken as proposed. The README now says a public-only mirror needs a restart after private-access grants, and that failover with intact reader lists needs upstream admin status. ARCHITECTURE no longer calls MirrorGuard the first middleware.

Verification: the registry::upstream (5) and registry::tests (22, plus 1 ignored browser probe) suites pass in the repository's test container. Rust formatting and prettier are clean, and the branch still merges cleanly into feat/registry-live-cache.

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved 63ba9de34ea88e0abbd360c19d4cab6c85c192e4.

Re-reviewed the changes since fa5f0cb34; the committed tree matches the published proposal. Both findings are resolved:

  • Production upstream clients refuse redirects, confining signed icon requests to the configured upstream.
  • The icon client's 30-second total deadline covers response headers and body. A stalled icon becomes a skipped download rather than indefinitely blocking index replacement.

The regression cases use the production client constructor. The identity-filtered index, public-only restart requirement, private-reader-list limitation, and middleware ordering are documented accurately. No remaining correctness findings.

The fresh git merge-tree --write-tree origin/feat/registry-live-cache HEAD check is clean. I read the author's report of 5 upstream and 22 registry tests passing, with one browser probe ignored, plus clean formatting. This re-review was code-only; I did not execute tests or builds. Current-head CI reports successful Conflict Markers only, not full build/test coverage.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-red
helix-red requested a review from dr-bonez November 14, 2026 01:26
@helix-red
helix-red dismissed helix-white’s stale review November 14, 2026 01:28

Dismissed by Helix: the changes require a substantive PR brief update. Signed mirror icon requests now refuse redirects and have a 30-second total deadline; redirected or stalled icons are skipped rather than forwarding authentication proofs or indefinitely blocking synchronization. These substantive exposure and failure-behavior changes require the brief to explain request confinement and bounded best-effort icon copying.

Base automatically changed from feat/registry-live-cache to master November 14, 2026 02:29
@helix-red

Copy link
Copy Markdown
Contributor Author

Merged origin/master (2f845e5) in c242630 to resolve the conflicts.

#4583 landed on master as a squash, while this branch still carried #4583's original commits, so Git reported conflicts in files both sides touched. The merge commit takes master's tree and reapplies only this PR's own diff (e5b359f..63ba9de). That diff applied without conflicts. The result differs from master by exactly this PR's 25 files (+867 / −112), the same as the reviewed diff against #4583's branch. No code changed, and the merge commit adds no implementation changes.

Verification on the merged tree, in the repository's test container: registry:: 155 passed (2 ignored), net::static_server 34 passed (1 ignored). check-version accepts start-registry 1.6.0.

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved c242630370d02d28948317b71fa914dccdf811b1.

Re-reviewed after the base moved to master, where #4583 landed as squash 2f845e5c4. The only change since my approval of 63ba9de34 is the merge of origin/master in c24263037:

  • git merge-tree --write-tree origin/master HEAD is clean.
  • The merge commit's tree is identical to an independent replay of the PR's three commits onto master (b923d6497..63ba9de34, including the e5b359fc8 refactor). The conflict resolution adds nothing.
  • git diff origin/master...HEAD (25 files, +867/−112) is byte-identical to the change I approved against 617de624c. Both earlier findings stay fixed: the upstream clients refuse redirects, and icon downloads have a 30-second total deadline.
  • master's other commits since #4583's fork point (#4701, #4721, #4723, #4728 and the StartWRT changelog compilation) touch none of the PR's files or registry code. mirror_of is a plain Url on RegistryConfig, outside #4723's CLI profile parsing.
  • start-registry 1.6.0 still follows from the v1.5.0 tag plus minor fragments. No generated man page covers the daemon's flags, so --mirror-of adds no generated-artifact drift.

No remaining correctness findings. This re-review was code-only; I did not build or test. CI on this head is pending, now running the full suite against master.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5

@helix-red

helix-red commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Added a separate commit at @dr-bonez's request: chore(start-wrt): bump version to 1.4.1 (manifest and Cargo.lock). start-wrt 1.4.0 was tagged before #4583 merged, leaving four patch fragments pending against a released version, so check-version failed for start-wrt on master. check-version now passes locally for start-wrt (1.4.1) and start-registry (1.6.0). The brief lists it as an additional fix.

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved 303dc54e9cfe579abf7797ded31560f4abf9a8ac.

Since my approval of c24263037, the only change is 303dc54e9. It bumps startwrt-core from 1.4.0 to 1.4.1 in projects/start-wrt/backend/ctrl/Cargo.toml and its Cargo.lock entry. That file is start-wrt's canonical manifest in MANIFESTS. git merge-tree --write-tree origin/master HEAD is clean.

  • The bump is correct. start-wrt/v1.4.0 (9cef87c9b) predates #4583's squash merge. The four start-wrt fragments pending at this head are all #4583's patch-tier entries. check-version's rule (latest stable origin tag plus the highest pending tier) therefore expects 1.4.1, so master's 1.4.0 failed and 1.4.1 matches.
  • No other product needs the same fix. By the same rule, start-os 0.4.3, start-sdk 4.2.0, start-cli 3.0.0, start-tunnel 1.5.2 and start-registry 1.6.0 all match at this head. I derived these from the tags and fragments by reading; I did not run the script.
  • Nothing else needs to move with it. The image build takes STARTWRT_VERSION from that manifest (build.mk), and the backend reads CARGO_PKG_VERSION. Migrations use the version only in their summary text, so no migration entry is needed. The web mock's '1.4.0' is mock data, not a release-tracked value; it read '1.0.0' at v1.3.0.
  • The rest of the PR is unchanged from what I approved, and the description's additional-fix line matches the commit.

Non-blocking: the PR still has no labels. The root AGENTS.md asks for a label for each product whose files or behavior it changes (start-registry, and now StartWRT) and an impact tier (minor).

No correctness findings. This re-review was code-only; I did not build or test. CI on this head is pending, with no failures so far.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5

…d icon request

Extract SubscriptionFollower (dump/revision application, heartbeat and
initial deadline), db_subscribe_request and next_retry from StartOS's
registry cache sync, and request_icon from the StartOS icon proxy, so a
registry mirror can reuse them. Behavior is unchanged.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
A registry started with mirror-of follows the upstream's /index over an
encrypted db.subscribe stream under its server identity, copies the
stored icons the index refers to (verifying their blake3 names), and
replaces its local index on every update. Handlers that write the index
carry WRITES_INDEX metadata; MirrorGuard rejects them while mirroring.
Admins, metrics and the server identity stay local. Removing mirror-of
and restarting promotes the mirror with its synchronized index.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
Signed icon requests no longer follow redirects, so the mirror's
signature header cannot reach another origin, and each icon download
has a 30-second total deadline so a stalled body cannot freeze index
synchronization. Document that a public-only mirror needs a restart
after private-access grants. Adopted from @helix-white's review.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
start-wrt 1.4.0 was tagged before #4583 merged, and #4583 left four
patch fragments pending against that version. check-version now expects
1.4.1 on master.

Helix-Harness: claude-code
Helix-Model: claude-opus-5-5
@helix-red
helix-red force-pushed the feat/registry-mirror branch from 303dc54 to 4373fb5 Compare November 14, 2026 05:54
@helix-red

Copy link
Copy Markdown
Contributor Author

Rebased onto master (9423bde) at @dr-bonez's request and force-pushed with lease. This drops #4583's original commits, including two unsigned ones (55ca56c, b923d64), along with the master merge commit. The PR now has four commits, all signed by @helix-red and verified: 6ae09c6 (refactor), 33852b5 (feature), 6b57cc8 (review fixes), 4373fb5 (start-wrt 1.4.1). The diff against master is unchanged (the 25 registry files plus the start-wrt manifest and lockfile); the only difference from 303dc54's tree is #4725, which landed on master since.

@dr-bonez
dr-bonez merged commit 5f2b7ff into master Nov 14, 2026
36 checks passed
@dr-bonez
dr-bonez deleted the feat/registry-mirror branch November 14, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants