Skip to content

sync: native mirror layout for local and sftp on one shared planner - #217

Merged
mbertschler merged 61 commits into
mainfrom
native-mirror
Sep 25, 2026
Merged

mbertschler merged 61 commits into
mainfrom
native-mirror

Conversation

@mbertschler

@mbertschler mbertschler commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Replaces rclone for local mirrors and plain sftp mirrors, following the design in design/native-mirror.md. Three layers do the work:

  • Planner. Computes the index changes since the destination's last confirmed run. Every layout shares it.
  • Layouts. Each one turns those changes into operations.
  • Transport. Moves the bytes, with local and sftp implementations.

This is step 2 of the rclone replacement, following #211 / #216. S3 comes afterwards, on its own branch. Crypt mirrors (cloudbox) stay on rclone until the crypt byte-compatibility question is settled.

The design also records a live bug, which section 1 fixes. When a root is wiped but its upload records remain, squirrel treats it as a fresh start. The next content-addressed push then skips everything and still reports success.

Working on this branch

Four sessions work through this branch one after another, one session each.

  • Starting a session:
    • git switch native-mirror && git pull --no-rebase.
    • Read AGENTS.md and design/native-mirror.md.
    • Take the first unticked session below.
  • Git: commit small and push often. Never rebase or force-push.
  • Checks: every push keeps go vet ./..., go test ./... and golangci-lint run green. That includes the docs golden tests for any flag, config key or run kind you add.
  • Design drift: when the code proves the design wrong, amend design/native-mirror.md in the same commit.
  • Finishing a session:
    • Tick its box here.
    • Add a short note under it covering deviations, follow-ups and anything the next session needs.
    • Never mark this PR ready, and never merge it.

Sessions

  • 1. Planner, store, local transport, local mirror.

    • Planner:
      • Extract pushPlan, the layout interface and the single push driver from sync/content_addressed.go and sync/packed.go.
      • The dry-run preview becomes the summary of translate.
      • Apply the shared watermark rule, including the wiped-root fix.
    • Store:
      • A forward migration adding remote_paths, which is STRICT and has the states committing, live, displacing, displaced and lost.
      • Store functions for each state transition.
      • ContentPresentOnDestination gains remote_paths as a third source.
      • destination reset clears the table.
      • .squirrel-staging joins the reserved names.
      • Regenerate store/schema.sql.
    • Transport:
      • The transport interface and the name guard.
      • The local implementation on os.Root: exclusive create, no-replace rename with its exFAT fallback, and parent-directory sync.
      • A fault-injecting wrapper, and a contract suite that any implementation can run.
    • Mirror layout on local:
      • Translate, and execute: stage while hashing, displace or mark lost, commit.
      • Reconcile at push start.
      • The receipt at .squirrel-index/run-<id>.
      • Dispatch, refusing --shallow, progress events and a no-progress timeout per operation.
    • Done when:
      • The planner refactor leaves the existing tests unchanged.
      • A wiped-root test fails on main and passes here.
      • A local mirror pushes without rclone.
      • The design's translation and crash tables each have a test.
    • Session 1 note:
      • Done: everything above. The content-layout tests are unchanged. TestPushRefusesWipedRootWithUploadRecords fails on main and passes here. TestMirrorPushWithoutRclone pushes with no rclone wrapper. The tables are covered by TestMirrorTranslationRules, TestMirrorWriteDisplacesWhatThePathHolds and TestMirrorCrashTable.
      • Deviations (each amended in design/native-mirror.md):
        • ContentPresentOnDestination does not gain remote_paths. Its only callers are the content layouts' upload-once checks, and a mirror copy isn't at objects/<hash>. Mirror records left behind by a switch to a content layout would skip those objects and still seal the run. DestinationHasUploadRecords does count remote_paths. Maintainer: please confirm.
        • layout is generic over its operations and gains markers, rootEmpty, foreignHistory and reconcile. seal and advanceMethod take the report.
        • A packed run whose vector advance fails now closes as failed, like content-addressed.
        • A failed probe of the landing evidence or of the root now fails the run instead of refusing it.
        • Staging names are run-<id>/<hex BLAKE3 of the path>, because the row doesn't exist yet at staging time.
        • A drifted file's staged copy stays until the next reconcile. The guard removes only finished runs' staging.
        • A withdrawn commit becomes lost.
        • os.Root follows symlinks that stay inside the root, so the local transport also checks each name's parent chain with Lstat. Windows always uses the check-then-rename fallback.
        • already_correct counts every in-sync live path, which keeps friction item F7 (the CLI test pins it).
        • New Report.Layout keys the CLI summary.
        • The agent's receiver also reserves .squirrel-staging.
      • For session 2:
        • Pair.DrivesRclone is still true for local mirrors, because the ride-along, restore and recover still use rclone. Flip it once they run on the transport.
        • Snapshot rotation's removals should go through the name guard, which already permits .squirrel-index/index-*.db.
        • The sftp transport can run runTransportContract in sync/transport_contract_test.go. Its harness must plant symlinks.
        • mirrorHandler.openTransport is the opener seam, and HandlerFor dispatches on Type == "local".
      • Open items:
        • Case and normalization collisions (decision 6) are not handled. There is no probe and no refusal. A reviewer confirmed it on case-insensitive APFS: after a case-only rename, a push moves squirrel's own bytes to history as unrecorded, and the old row stays live over the other spelling's bytes. That breaks invariant 1 and loses no data. Session 4's suite lists it; it needs fixing before merge.
        • As designed, the fresh-start rule checks the whole destination root and destination-wide records. A second volume with an old tree on a shared disk can't start fresh without a reset, and the reset also clears the first volume's records.
        • reference-setup.md (the usb arrow and the kopia leg) is left to session 4, per its checklist.
        • Pre-existing, outside this branch: after destination reset, a packed destination never re-uploads content that is already in a pack. HasPackMember ignores the destination, so a second packed destination never gets that content either. Worth its own issue.
  • 2. sftp, and every mirror command without rclone.

    • sftp transport:
      • Build on x/crypto/ssh and pkg/sftp.
      • Authentication by key file, password or ssh-agent.
      • Host keys checked against known_hosts, with unknown hosts refused.
      • Concurrent writes, and fsync@openssh.com when the server offers it.
      • Lstat before every rename.
      • Plain sftp mirrors dispatch to the native handler.
      • Reject checkers on native destinations, and hash_algo on native sftp mirrors.
    • Restore, ride-along, recover and marker on the transport:
      • Mirror restore with an index, and without one against the receipts.
      • Placing goes through temp file, sync and rename, which also fixes archive restore's in-place O_TRUNC write.
      • The snapshot ride-along and its rotation, recover --from discovery, and the remote marker gate.
    • Done when:
      • The contract suite passes against an in-process pkg/sftp server and against the testbed's server, with rename onto an existing target pinned as failing.
      • local and plain sftp mirrors need no rclone for any command.
      • configuration.md and testbed.md are updated.
    • Session 2 note:
      • Done: everything above.
        • The contract suite passes against an in-process pkg/sftp server and against rclone serve sftp (TestSFTPTransportContractAgainstRcloneServe, which runs wherever rclone is on PATH, CI included). RenameNeverReplaces pins the transport's rename onto an existing target failing on both; TestSFTPServersRenameOverAnExistingName pins that both servers' raw rename replaces it.
        • The crash table runs on both transports.
        • The sync, restore, recover and status CLI tests on a local mirror run with rclone hidden from PATH.
      • Deviations (each amended in design/native-mirror.md):
        • Put also checks its target with Lstat first: protocol version 3 has no "already exists" status.
        • The handshake asks for the host key types known_hosts pins for the server (unless host_key_algorithms is set). Otherwise a server that prefers ed25519 is refused when only its RSA key is pinned.
        • sftp concurrency is per file (pkg/sftp's 64 requests in flight); paths are still written one at a time. Session 4's benchmark decides whether parallel paths are worth it.
        • The layout gains shelf(runID) snapshotShelf, and Snapshotter holds no rclone wrapper.
        • The marker and the ride-along snapshot are staged and renamed, like every path, so a failed write never leaves a marker that does not parse or a truncated snapshot for recover to pick. The name guard gains two rules for that: this run's staging onto a snapshot name, and — under --init only, before a run exists — .squirrel-staging/volume-marker onto .squirrel-volume.
        • The filesystem marker gate is gone; native mirrors check and write the marker through the transport. --init still creates a missing local root. The rclone marker gate's refusals now wrap ErrRefused.
        • Get and each of its reads are bounded by the stall timeout (marker, receipts, restore, recover). sftp's Close drops the ssh connection first, so a hung server cannot wedge a push.
        • Restore: "without an index" means the index holds no present file for the volume — a fresh database, or one whose rows all went missing after a rescan of an emptied disk. Maintainer: please confirm.
        • Restore: a walked file that contradicts the newest receipt naming it is refused, like an index mismatch. A file no receipt names is restored unchecked and counted in a warning. An unparseable receipt is skipped whole.
        • Restore: a path that already holds its indexed bytes is left alone (already correct), so --in-place preserves only what it replaces. --shallow changes nothing on a native mirror restore, as on archive restores.
      • For session 3:
        • openReadOnly(ctx, dest) gives a stall-bounded transport whose guard refuses every move; dialSFTP and hostKeys are ready for the content layouts on sftp.
        • Pair.DrivesRclone and rcloneFor (cmd/squirrel/sync.go) key on Destination.NativeMirror(). Widen both when the content layouts leave rclone.
        • CanEverGateOffload names every native mirror (local and sftp) as presence+size; flip local there.
        • rclone serve sftp offers no fsync@openssh.com, so the testbed never exercises the flush; pkg/sftp's server doesn't either.
      • Open items:
        • Host keys on rclone's sftp paths. Decision 2 holds only for native mirrors so far. The encrypted cloudbox, and the content layouts until session 3, still accept any host key when known_hosts_file is unset. Rendering ~/.ssh/known_hosts into rclone.conf would close that; configuration.md states what each path does today. Maintainer's call.
        • Migration: a plain sftp mirror rclone wrote is refused by the watermark rule (decision 4), and its host key must be pinned (decision 2).
  • 3. Evidence, and the content layouts on the transport.

    • Evidence:
      • BLAKE3 read-back before commit, on local disks only.
      • Fingerprint queries consult remote_paths.
      • verify_every becomes valid on native mirrors. The pass checks live and displaced rows with Lstat, and on local mirrors it re-hashes a rotating slice.
      • Findings mark rows lost, and those rows feed the planner as repairs.
      • Native local mirrors can gate offload. sftp mirrors keep refusing, and the refusal names the reason.
      • This reverses sync: record a mirror's rclone compare as checksum, and stop gating offload on it #216: amend reference-setup.md, offloading.md, mirror.md, friction-log F21 and SAFETY-AUDIT.md.
    • Content-addressed and packed on local and sftp:
      • Uploads go through the transport.
      • Fingerprints come from read-back on local disks.
      • On sftp they come from the optional server hash command: probed once per push, with a command line built only from the root and hex artifact names.
    • Done when:
      • A native local mirror gates offload, and the offload tests cover it.
      • rclone is used only for crypt destinations and for s3, b2 and gcs.
    • Session 3 note:
      • Done: everything above.
        • A native local mirror gates offload: TestOffloadGatesOnNativeLocalMirror covers it with and without a verify cadence, and TestLoadAcceptsLocalMirrorOffloadRequires covers config load. An sftp mirror is refused at load and before the offload walk, and the refusal names the reason.
        • local and plain sftp destinations need no rclone in any layout, for sync, verify, restore and recover. The TestNativeContent* tests run on both transports, and TestCLIContentLayoutsOnLocalWithoutRclone runs with rclone hidden. Pair.DrivesRclone keys on Destination.Native.
        • The content layouts land each artifact through artifactStore: staged, confirmed (a local read-back, or the sftp server's hash), then renamed. An artifact already at its name is confirmed and adopted, never replaced.
      • Deviations (each amended in design/native-mirror.md):
        • Config used to refuse the content layouts on local ("addressed by filesystem path"). That rule is gone, and native content destinations, local ones included, are gated on .squirrel-volume like a native mirror.
        • A missing local root is now refused with a message naming --init, for mirrors too. Before, it failed with a raw open error.
        • Repairs live in the mirror's translate, not in the shared planner. The content layouts still only raise the alarm: remote_objects has no lost state, and a changed object can't be replaced in place.
        • A mirror verify finding also demotes the volume's locally advanced fingerprint-verified components to presence+size (DemoteFingerprintVerifiedVector). Without the demotion, a gate with a verify cadence still offloaded a file whose only mirror copy verify had found gone; the review reproduced this. The next push that leaves nothing pending upgrades the components again.
        • A mirror verify pass re-reads a tenth of the stored bytes (mirrorRereadShare). Maintainer: change the share if another suits better.
        • Every verify over a native root checks the volume markers first, and fails without touching any record when one is missing.
        • On native sftp, hash_algo accepts md5, sha1, sha256 or blake3, because squirrel computes the same hash to check the server's answer. crc32, xxh3 and xxh128 stay valid behind crypt only. The sha256 default now also applies to native packed destinations.
        • The server hash also runs on the staged copy, <volume>/.squirrel-staging/run-<id>/<hex>, so a mismatch never reaches the artifact's name. The probe runs once per session and is remembered only once the server has answered.
        • An artifact the sftp server can't hash in this pass counts as unchecked, a new counter in squirrel verify. It is no longer reported as mismatched.
        • Migration v33 indexes remote_paths by content, and adds a partial index on its lost rows.
        • On macOS both the write and the read-back use F_NOCACHE, because a read there is served from pages the write left cached.
      • For session 4:
        • The adversarial suite should cover the content layouts on the transport too: a crash at each call (nativeContentFixture.pushCrashing), the adopt path, a server without a hash command, and symlinks at artifact names.
        • The benchmark should include native content-addressed and packed destinations on local and sftp.
        • sftpSettings(t, dst, commands) builds an sftp destination whose test server runs sum commands.
      • Open items:
        • The same gate gap on the content layouts (pre-existing). A verify pass that finds an object missing or changed raises the alarm but neither marks nor demotes anything, so a gate with a cadence still counts that content. Calling DemoteFingerprintVerifiedVector on a dirty content pass would close it. Maintainer's call.
        • Session 2's host-key item is closed for plain sftp content destinations, which squirrel now dials itself. It remains for crypt destinations.
        • remoteSubpathURI's local branch, and Sync onto a local destination, are now reached only by tests.
        • The content-addressed and packed pages still say --dry-run isn't supported on the push. That was already stale and is untouched here.
        • Case and normalization collisions are still open, for session 4.
  • 4. Hardening and wrap-up.

    • Session: one that wrote none of session 1's mirror code, so the tests don't share the implementer's assumptions.
    • Adversarial suite:
      • Crash injection at every transport call, followed by a clean push.
      • A model-based test over random index histories.
      • File↔directory swaps, and symlinks along a target's parent chain.
      • Names that collide by case or by Unicode normalization.
      • Disk full, source drift, and foreign files at targets and in staging.
      • The design's three invariants, checked on both transports.
    • Docs and design:
      • Framing review of every guide touched.
      • Amend reference-setup.md: the kopia leg's independence and the topology arrows.
      • Set the design doc's status.
    • Testbed: walk the lifecycle, and benchmark native against rclone on local and sftp.
    • Final self-review against AGENTS.md.
    • Done when:
      • Every case under "What the tests must cover" has a test, and any bug found is fixed.
      • The benchmark numbers are in this PR.
      • CI is green.
    • Session 4 note:
      • Done: everything above.

        • Every case under "What the tests must cover" has a test. Design section 4 now maps each case to its tests.
        • Crash injection runs at every transport call of a mirror push, on both transports, and on destinations that fold names and ones that don't. It also runs at every call of a content-addressed and a packed push. That is 428 crash points, each followed by a clean push. Invariant 1 is also checked right after each crash, because it holds at every point of a push.
        • TestMirrorModel runs random histories with random crashes on both transports and compares them against a reference model. The histories cover adds, changes, deletes, re-adds, nested file↔directory swaps, case-only renames and colliding spellings.
        • A test transport makes any disk fold names, so the collision tests also run on Linux CI.
        • The docs framing review is done: 15 pages and the README had stale rclone-era framing, all fixed.
        • reference-setup.md now shows usb as native and explains what the kopia leg alone still covers.
        • The design status is "Implemented in sync: native mirror layout for local and sftp on one shared planner #217".
        • The walk's findings are logged as F36 to F40 in the friction log.
      • Bugs found and fixed:

        • Case and normalization collisions (decision 6, session 1's open item). Each push that writes now probes the destination inside staging.
          • On a destination that folds names, a present path whose name, or a parent's name, collides with another present path's is refused. Nothing is staged or displaced for it.
          • A case-only rename displaces the old spelling as its record.
        • A recorded directory replaced by a file or symlink, or deleted. The rows under it stayed live. They now become lost and are repaired.
        • A fresh index took over a tree it had not written (F36). Pointed at a tree rclone wrote, it moved all 4690 files into history and wrote them again, doubling what the disk holds. A volume's first push now refuses such a tree and points at recover --from. The content layouts still adopt artifacts they find at their names.
        • macOS ._ files on exFAT (F37). Every push reported one as foreign staging, and an index-less restore brought back 619 of them.
        • Unplugged disk (F38). The refusal told the user to re-run with --init, even for a disk the volume had synced to before.
        • Offload refusal (F39). The refusal of an unsatisfiable gate did not list the local mirror as an alternative.
        • Staging of unknown runs. A staging directory for a run the index does not know was skipped silently. It is now reported.
      • Deviations (each amended in design/native-mirror.md):

        • A collision fails the run before its receipt, as drift does, so the watermark holds until one of the two names is renamed. Sealing with a warning instead would advance the vector over a path the destination does not hold. Maintainer: please confirm.
        • Watermark rule 1 gains a first-push gate for mirrors. It checks only the volume's own directory, so a second volume beside the first still starts fresh. Maintainer: please confirm.
        • The name probe runs on every push that writes, not only on the first push. Its file, .squirrel-staging/fold-probe-é, is removed within the push, and the name guard gains that one Remove.
        • A directory keeps the spelling it was created with. After a rename from Photos/ to photos/, files land in the existing Photos/, and an index-less restore puts them there too.
        • A dry run does not probe, so its preview does not show collisions.
      • Benchmark (2026-09-24, macOS arm64). Each run used a fresh index and a fresh destination. usb is an exFAT disk image. box is rclone serve sftp on loopback. wan is the same server behind a proxy that adds a 20 ms round trip. pics is 4540 files, 724 MB; trip is 608 files, 114 MB. "Changed" rewrites 150 files and adds 150 (30 and 30 on trip). Times are seconds:

        Push usb rclone usb native box rclone box native wan rclone wan native
        first 12.6 115.8 3.7 13.7 45.4 431.9
        unchanged 0.63 0.13 2.11 0.09 7.72 1.80
        changed 1.51 9.96 2.41 1.46 8.85 51.06
        • A native first push to APFS on the internal SSD took 86.4 s.
        • On local disks the cost is durability: every file is synced (a full flush on macOS), read back, and its parent directories synced.
        • On sftp the cost is about 30 sequential round trips per path.
        • Unchanged pushes are faster natively.
      • Open items:

        • Throughput (design open question 2, F40). Native pushes that write are 3.7× to 9.5× slower than rclone. The candidates are several paths in flight, one parent-chain check per push, and batched syncs before the renames. Whether local and plain sftp switch before any of them lands is the maintainer's call. None of them is on this branch.
        • Carried over, unchanged:
          • Rule 3 still checks the whole root and destination-wide records (session 1).
          • Crypt sftp destinations accept any host key when known_hosts_file is unset (session 2).
          • The content layouts' gate gap on a verify pass that finds a problem (session 3).
        • By design: a copy corrupted in place with its size and mtime kept stays counted by the offload gate until the 10% re-read reaches it. On the walk it passed two verify passes, and the restore's BLAKE3 check refused it.
  • 5. Throughput of pushes that write (decision 8, agreed with the maintainer on 2026-09-24).

    • Where the time went (measured with an instrumented push, design section 8):

      • Local disks: three full flushes of the drive's cache per file, not the read-back.
      • sftp: 27 requests per path, each waiting for the one before.
    • Done:

      • Put and Rename no longer flush; a new Transport.Flush makes a batch durable (one F_FULLFSYNC per batch on macOS, the batch's fsyncs together on Linux).
      • Mirror and content-addressed pushes land batches of at most 64 files or 256 MB: stage, flush, read back in full, displace, flush, record displaced, commit, flush, record live. No record claims bytes before the flush that covers them.
      • Several paths in flight on both transports, set by the new concurrency key (default 4 on local disks, 8 on sftp; rclone's --transfers on destinations rclone writes). Every per-call symlink check stays.
      • The marker, the ride-along snapshot and the receipt flush before they are relied on.
      • Tests: the fault transport gains power cuts (take back what no Flush covered, or keep the names without the bytes). The crash suites run one path at a time and gain power cuts at every call; a first push is cut at every call too; the model test runs with paths in flight and random power cuts. Each new check was confirmed to fail when its flush is removed.
    • Review fixes: a stalled content batch recorded artifacts it never landed (now failed, and the push stops); reconcile now flushes the directories an unfinished push's moves touched before recording them.

    • Benchmark (2026-09-25, same laptop, three binaries):

      First push rclone before after
      usb, exFAT image (pics) 19.0–24.2 116.1–127.4 41.4–43.6
      box, sftp loopback (pics) 3.1 16.6 5.7
      wan, sftp at 20 ms (trip) 46.9 409.4 49.7
      • Unchanged pushes stay faster than rclone everywhere. Changed pushes are faster everywhere except the exFAT image (about 1.4 times rclone's time).
      • The exFAT "after" column overstates native: those runs followed the old build's, while the host disk was still working off its flushes. Settled and broken into steps, the read-back costs about 2 s of the push, the symlink checks nothing measurable, and a quadratic scan 2.3 s (fixed below). With the fix a first push to the exFAT image takes 15–29 s against rclone's 19–25 s. Full tables in design section 8.
    • Quadratic scan fixed: for every new path the writer scanned every live record under the shared lock; it now counts live records per directory (sync/mirror_live.go). At 30,000 files the displace step fell from 62 s to 0.6 s, the first push from 81 s to 17 s.

    • Open items:

      • Linux flush batching is covered by CI but not benchmarked on a real disk.
      • concurrency defaults to 8 on sftp; 16 measured about 40% faster at a 20 ms round trip. Maintainer's call whether to raise it.

Decisions

The decisions are recorded in section 10 of the design doc (2026-09-23):

  • Content-addressed and packed sftp destinations gate through an optional server hash command. sftp mirrors don't gate.
  • Host keys are checked against known_hosts, and unknown hosts are refused.
  • Read-back runs on local disks only.
  • Existing mirror trees are refused rather than adopted, so a native mirror needs a fresh or emptied root.
  • Mirror receipts live in .squirrel-index/.
  • A case-folding collision refuses only the colliding path.
  • There is no source-completeness audit on this branch.

Decided on 2026-09-24 (decision 8): throughput. One flush per batch instead of several per file, several paths in flight set by concurrency, and every per-call check stays.

Still open: crypt byte-compatibility with rclone. It blocks only cloudbox, which is outside this branch.

One planner computes the index changes since a destination's last
confirmed run for every layout; layouts turn them into operations; a small
transport (local, sftp) carries the bytes. The mirror on local and plain
sftp moves off rclone, with every displaced version kept in history and
every move recorded before it happens.

Also records a live bug the planner fixes: a wiped root with upload
records still on file is treated as a fresh start, so the next
content-addressed push skips everything and reports success.
sftp gating goes through an optional server hash for content-addressed
and packed artifacts only; host keys are always checked against
known_hosts; read-back runs on local disks only; rclone-era mirror trees
are refused rather than adopted. Crypt stays the one open question.
The content-addressed and packed handlers each carried the same push
sequence. sync/push.go now holds it once: pushPlan, a layout interface
generic over each layout's operations, and the pushThrough driver that
runs requireIndexedVolume, markers, run allocation, the watermark rule,
translate, execute, seal and the durability advance for every layout.

A dry run is translate plus the operations' preview, replacing each
handler's previewDryRun. A packed run whose vector advance fails now
closes as failed, like content-addressed. The layout-evidence probe
uses statRemoteExists, so an unreachable destination fails the run
instead of being read as a foreign history.
The watermark rule read an empty destination root as a fresh start even
when squirrel still recorded uploads to it. A root wiped without
`squirrel destination reset` and re-marked therefore skipped every
recorded object, wrote a manifest segment mapping paths onto bytes that
were gone, and closed the run as success.

A fresh start now also requires that the destination has no upload
records (store.DestinationHasUploadRecords). Otherwise the push refuses
and points at a fresh root or destination reset.
Schema v32 adds remote_paths: one STRICT row per version squirrel wrote
at a mirror path, keyed on its files row, in one of the states
committing, live, displacing, displaced and lost. A partial unique index
keeps at most one committing-or-live row per path, and a partial index
serves the reconcile, which reads only unsettled rows.

Each move has its own transition function, which applies only to rows in
the move's source state. ContentPresentOnDestination counts live and
displaced mirror copies, DestinationHasUploadRecords counts every row,
and destination reset clears the table and reports it. PathDelta carries
the files row's folder id so a push can key its rows.
The name joins the other reserved directories everywhere they are
listed: the store's destination-facing reads, the peer-sync filters on
both ends, the rclone mirror's transfer and restore filters, and the
source-tree warning.
transport is byte-level access to one destination root: Stat, List,
Get, Put, Rename and Remove, where Put creates exclusively and Rename
never replaces its target, so no call can overwrite bytes.

The local implementation sits on os.Root and refuses a symlink anywhere
along a name's parent chain, because os.Root follows symlinks that stay
inside the root. Rename uses renameat2 RENAME_NOREPLACE on Linux and
renamex_np RENAME_EXCL on macOS, falling back to Lstat then rename on
filesystems without them (exFAT) and elsewhere; parent directories are
synced after every change.

The name guard is the one function deciding what may move or disappear:
removal of finished runs' staging and of ride-along snapshots, commits
from this run's staging, and displacement into this run's history. A
contract suite pins the behaviour any transport must show.
HandlerFor sends every local destination that is not content-addressed
or packed to a native mirror handler, which runs on the shared planner
and needs no rclone:

- translate decides from squirrel's records alone: a present path whose
  live record holds its content is confirmed, any other present path is
  written;
- execute stages each path under .squirrel-staging/run-<id>/, hashing
  the bytes it sends, moves whatever the path and its parents hold into
  .squirrel-history/run-<id>/ (as the recorded version when size and
  mtime match its record, as unrecorded bytes with a warning and an
  audit note otherwise), then commits with a no-replace rename;
- every move is recorded in remote_paths before it happens, and the next
  push's reconcile settles it from where the bytes are, then removes the
  staging finished runs left;
- seal writes the receipt, the run's manifest segment, at
  <volume>/.squirrel-index/run-<id>, and the vector advances as
  presence+size.

--shallow is refused. Every transport call is bounded by a no-progress
timeout, and a push refuses while a call an earlier push gave up on is
still inside the system. Progress events report paths and bytes.

The rclone local-mirror vector tests give way to the native ones; the
CLI summary keys its layout formatting on the new Report.Layout.
Local mirrors are now written by squirrel itself. The mirror layout
page, the syncing guide, the CLI reference, the on-disk layout and
formats references and the README describe how a local push stages,
displaces and commits, the receipt it leaves, why it starts on a fresh
or emptied root, and that --shallow is refused there. The offload
refusal names the local mirror's actual gap.

The design doc records what the implementation settled: the staging
key, a drifted file's staging left for the next reconcile, parent
displacement, directory displacement, withdrawn commits becoming lost,
the per-call no-progress bound, and the parent-chain symlink check on
top of os.Root.
RemotePath drops the fields no reader uses, and the transport, guard and
planner comments state what the code does.
ContentPresentOnDestination's only callers are the content-addressed and
packed upload-once checks, and a mirror copy is not where those layouts
read their bytes. Counting it would let a destination whose mirror
records outlived a switch to a content layout skip the objects and still
seal the run; it also scanned remote_paths on every call. The check
stays with objects and packs, and the design records why.

A native mirror now notes each move of unrecorded bytes in the run's
audit trail before making it, including a replaced directory, and its
refusal for a root without receipts names both causes: a tree it did
not write, or a root emptied while records remain.
A plain sftp mirror is about to be written by squirrel itself, like a
local one. checkers tunes rclone and hash_algo names the hash command
rclone runs on the server; neither applies there, so both are refused.
Destination.NativeMirror names the destinations squirrel writes itself.
Built on x/crypto/ssh and pkg/sftp. It logs in with a key file, a
password, or ssh-agent when neither is set, and accepts only a host key
known_hosts pins; an unknown host is refused with its fingerprint and the
line that would trust it. The handshake asks for the key types known_hosts
pins, so a server offering another type first is still checked.

Put writes concurrently and flushes through fsync@openssh.com where the
server offers it. Put and Rename Lstat their target first: pkg/sftp's own
server replaces on rename, and protocol version 3 cannot say that an
exclusive create failed because the name exists. The name checks the local
transport does move into transport.go and both implementations share them.

The contract suite gains a large-body case and runs against an in-process
pkg/sftp server and against rclone serve sftp, the testbed's server.
HandlerFor sends every native mirror — local, or sftp without crypt — to
the mirror handler, which opens its root through the local or the sftp
transport. The marker gate runs through that transport too: an existing
marker is read and checked, and a missing one is written under --init
with an exclusive Put, so the filesystem-only gate goes. A local root that
does not exist yet is still created under --init.

The rclone marker gate now wraps ErrRefused on its refusals, as the
native one does. The crash table runs on both transports, and a push to
an sftp server whose host key known_hosts does not pin is recorded as a
refused run.

Ride-along, restore and recover still reach the destination through
rclone, so Pair.DrivesRclone stays true for native mirrors until they
move.
The Snapshotter no longer holds an rclone wrapper. Each push hands over
the shelf its ride-along lands on — the destination's
<volume>/.squirrel-index/ — and a new layout method opens it: through
rclone for the content layouts, through the guarded transport for a
native mirror, whose name guard permits removing a snapshot there and
nothing else. Rotation lists and removes through the same shelf, so it
never touches a mirror's receipts.

Syncing a native mirror now runs no rclone at all, so Pair.DrivesRclone
is false for it, and the agent schedules such syncs on a host without
rclone.
…sport

recover --from a native mirror lists its <volume>/.squirrel-index/ and
fetches the chosen snapshot through a read-only transport — the name
guard, held by no run, refuses every move and removal — so it needs no
rclone and the CLI no longer looks for it.

The marker gate and restore read through Get, so the stall bound now
covers it: the open, and every Read of the file it returns. A Read runs
into the reader's own buffer, so one given up on can finish later
without touching the caller's.
Archive restore wrote each file with O_TRUNC in place: a crash or a
broken stream left a truncated file at the path. The new restorePlacer
streams the bytes into a temporary file in the target directory while it
hashes them, checks them, stamps the mtime, flushes, and only then
renames the file over the path, moving the old one into the run's
restore history first on an in-place restore. Bytes that fail their
check never reach a path, and no temporary file stays behind.

The native mirror restore will place through the same code.
A restore from a local mirror or a plain sftp mirror no longer runs
rclone. With an index that holds present files for the volume, each
present path is fetched by its path and placed only once its bytes hash
to the indexed BLAKE3; a path that already holds them is left alone and
counted as already correct, so an in-place restore preserves only what
it really replaces. Without one — a fresh machine — the restore walks
the mirrored tree, leaving out squirrel's reserved entries, and checks
each file against the content the newest receipt naming it recorded; a
file no receipt names is restored unchecked and counted in a warning.

Restore splits its target gates out into checkRestoreTarget, and the
restore, sync and status CLI tests on a local mirror now run with rclone
hidden from PATH.
rclone serve sftp, the testbed's server, replaces an existing name on a
raw protocol rename just as pkg/sftp's own server does; the test now runs
against both. testbed.md describes how the contract suite uses that
server, what it lacks next to OpenSSH, and how to walk a native sftp
mirror beside the encrypted cloudbox. The design notes that sftp
concurrency is per file for now, with paths written one at a time.
A snapshot upload to a native mirror that fails halfway left a truncated
index-*.db behind, which recover would offer as the newest snapshot. The
shelf now removes it again (the name guard permits exactly that).

The shelf opens its transport lazily, so a layout hands afterSync a shelf
instead of a function returning one, and recover shares the snapshot
listing with it. The snapshot tests that run on both backends move to
their own file, and nativeMirror spells out the layouts it excludes.
pkg/sftp's Close waits for the server to end the session, which a hung
server never does, so the push that gave up on a stalled call blocked
for good in its deferred close. The transport now drops the ssh
connection first. The connect deadline also stays in force until the
sftp session has started, so a server whose subsystem never answers
fails the dial instead of hanging it.

List refuses a name the server returns that is not a single path
element, so a hostile server cannot steer a restore out of its target.
Both were written straight to their final name, so a write that failed
halfway left a marker that does not parse — refused on every later
push, --init included — or a truncated snapshot that recover offered as
the newest. Cleaning up after the failure cannot work when the link is
what failed.

Both are now staged and renamed onto their name, as every mirrored path
is. The name guard gains the two rules that takes: from this run's
staging onto a snapshot name, and, under --init only, the marker's own
staging name onto .squirrel-volume. A partial copy stays in staging,
where reconcile clears a finished run's and the next --init the
marker's.
A receipt that failed to parse still contributed the lines before the
error; it now contributes nothing, as its warning says. The restore walk
refuses a listed name that is not a single path element.

Copies out of a transport read in 1 MiB blocks: io.Copy's 32 KiB reads
through the stall reader cost one sftp round trip each, while pkg/sftp
splits a large read into concurrent requests. A few comments lose
overlong lines and a reference to the removed local gate.
… count it

remote_paths rows carry the BLAKE3 a read of the stored bytes confirmed.
The pending-fingerprint tally and the per-content gate check count a live
or displaced copy that records one. New reads serve the mirror verify pass
(every stored row, least recently verified first) and the planner's
repairs (present paths whose current content the destination lost).
Migration v33 indexes remote_paths by content and its lost rows.
A local mirror's staged version is re-read past the page cache and hashed
with BLAKE3 before it is committed; a match records the fingerprint on its
remote_paths row, a mismatch fails the path. The local transport keeps
Put's and Get's pages out of the cache for that (F_NOCACHE on macOS,
dropping the synced pages on Linux). A mirror push then advances as
fingerprint-verified once no present content is pending; an sftp mirror
reads nothing back and stays presence+size.
squirrel verify and the agent's verify cadence now cover native mirrors,
through the transport and without rclone. A pass checks every live and
displaced copy's size and mtime; on a local disk it also re-reads the
least recently verified tenth of the stored bytes through BLAKE3. A copy
found gone or changed is marked lost and latches the destination's alarm,
and the next push writes the path again when the index still holds that
content there. verify_every is valid on native mirrors, a native local
mirror may gate offload, and an sftp mirror's refusal says why it cannot.
The mirror layout, offloading, verification, syncing and agent guides, the
CLI and configuration references and the README describe the read-back
fingerprint, the mirror verify pass and repairs, and which mirrors may be
named in offload_requires. reference-setup.md's offload-gate paragraph,
friction-log F21 and SAFETY-AUDIT.md M1 record the partial reversal of
#211/#216.
A guard held by a content-addressed or packed push commits this run's
staging onto objects/<hex>, packs/<hex>, this run's placement map and this
run's manifest segment, and never displaces anything; a mirror's guard
still commits onto the mirrored tree alone.
ServerHash runs the hash_algo's sum command on the server over an artifact,
built from the root and a hex artifact name alone and only when both hold
safe characters. The command is probed once per session by hashing a known
input; a server that runs no programs, or computes something else, offers
no server hash. The local transport offers none: its bytes are read back.
The test sftp server runs sum commands on request.
A native content verify checks every synced volume's marker first, so an
unmounted root fails the pass instead of reporting every object missing.
Over sftp, an artifact the server cannot hash this pass — no trusted
command, or a row recorded under another hash_algo — counts as unchecked
rather than mismatched, and squirrel verify prints the count. The server
hash refuses a leaf that is no regular file, and only a probe the server
answered is remembered for the session.
…sitively

Comments that described the native root, the staging directory, restore
and the scheduler's verify phase as a mirror's alone now cover the
content layouts too, and the ones phrased as what code does not do say
what it does. The verification guide names the unchecked count, the
marker check and the demotion a finding causes.
…e-only renames

A mirror push now probes, inside staging, whether the destination folds
case or Unicode normalization before its first write. On one that does,
a present path whose name, or a parent's, folds onto another present
path's where one is a file is refused: nothing is staged or displaced
for it, and the run fails before its receipt, as drift does. A version
recorded under another spelling whose path left the source moves aside
as its record first, so a case-only rename no longer leaves the old row
live over the new spelling's bytes. Directory displacement takes every
live row under any spelling of the directory along.

The guard lets a mirror push remove its own name probe. The invariant
check now also fails when two live rows name one folded entry.
A mirror push that exercises every kind of step, and a content-addressed
and a packed push, each die at every call they make, in every way that
call can die. Right after the crash every record still vouches for its
bytes and no byte left the destination; after the next clean push the
three invariants hold, staging is empty, and the content layouts verify
clean and restore the volume. The mirror runs it on a destination that
tells names apart and on one that folds them.

The invariant check splits into its three parts so the first can run
after a crash, and the content fixture's crashing push takes a mode.
…tories

Random histories of adds, changes, deletes, re-adds, nested
file↔directory swaps, case-only renames of files and directories, and on
a folding destination a second spelling of a file it holds, run through
a native mirror on both transports. A third of the pushes are preceded
by one that crashes at a random transport call. After every clean push
the live records and the destination's tree match the model, which keeps
what the source deleted until a present path needs its name, and the
three invariants hold.
…nknown runs

A recorded directory that the destination replaced with a file or a
symlink, or lost, left the rows under it live although their bytes could
no longer be at their paths. The push that finds it now marks them lost,
so the next push repairs them while the index holds their content. A
staging directory named for a run the index does not know was skipped
silently; it is reported as foreign now, and still never removed.

Tests pin both, and cover the rest of the hostile cases the design lists
on both transports: symlinks at a target, along its parent chain and in
place of the volume, history, staging and index directories; nested
file↔directory swaps with changed and foreign entries inside; foreign
files, directories and symlinks in staging; a disk that fills up or a
quota that runs out mid-write; a history directory that can't be
written; and a source that drifts while it streams, for the content
layouts too, with symlinks at an artifact's name.
…ave AppleDouble files to macOS

The testbed walk found two gaps on a real exFAT disk.

A fresh index pushing to a native mirror took the watermark rule's first
branch and started from 0 over whatever the volume's directory held: it
moved a whole tree rclone wrote into history and wrote it again, doubling
what the disk holds, where decision 4 refuses existing trees. The first
push of a volume now refuses a volume directory that holds files outside
staging while squirrel has no row of the volume there, and points at
recover for a native mirror whose index is gone. A crashed first push
left rows, so its retry passes; a second volume beside the first starts
fresh. The content layouts keep adopting artifacts at their names.

macOS keeps every file's attributes in a ._ companion on exFAT, so each
push reported the previous run's ._run-<id> as foreign staging, and an
index-less restore brought back hundreds of ._ files, those of the
reserved directories included, as unchecked. A ._X beside X is now X's:
skipped by the staging report and the emptiness checks, and left out of
an index-less restore, counted once, unless a receipt names it.
…al mirror as a gate

A native destination that lost its root or its marker told the operator
to re-run with --init, even when the volume had synced there before; on
an unplugged disk --init would bootstrap an empty destination on the
mountpoint instead. A volume that synced there before is now refused as a
disk that is most likely not mounted or a root that moved, and --init is
named only for a new, empty destination. Verify, restore and recover over
a missing local root say the same instead of a raw open error.

The refusal of an offload_requires target that can never gate listed
every gating shape but the local mirror; it names it now.
… usb no longer covers

The destinations page, the configuration reference and the README still
said rclone writes local and sftp destinations and checks their host
keys; squirrel writes every local destination and every sftp one without
crypt, in any layout, and always checks the key. The content-addressed
and packed pages said --dry-run is not supported on the push; it
previews it.

reference-setup.md: the usb arrow is native now, and the kopia leg says
what the mirrors no longer cover — a native mirror plans from the index,
so a file the indexer misses never reaches usb, and only cloudbox keeps
rclone's own walk until crypt moves.
… tests, and record the benchmark

The status is implemented in #217. "What the tests must cover" names
the tests behind each case. Section 8 records the testbed benchmark
against rclone: native pushes that write are several times slower —
local disks pay for syncing every file and reading it back, sftp for
about 30 sequential round trips per path — and unchanged pushes are
faster. What to change is a new open question.
F36 to F39 are the walk's findings this branch fixed; F40, the throughput
of pushes that write, stays open with the design's open question 2.
…present

A store error while the plan checked whether an old spelling's path was
still present skipped its displacement silently, so the write that
followed would move the old version aside as unrecorded bytes and leave
its row live. The error now fails the push. Two comments read better.
…ve destinations

A framing review of the pages this branch touched found them describing
native destinations the rclone way:

- an encrypted content-addressed or packed restore re-hashes to BLAKE3;
  only an encrypted mirror falls back to size+mtime;
- a push whose objects all got a fingerprint as they landed advances
  content-verified by itself, so sync → verify → offloadable holds only
  where fingerprints stay pending;
- every native mirror writes receipts, sftp included, and staging holds
  every native layout's in-flight writes;
- the layout guard covers a native mirror's receipt, and a native mirror
  restore checks BLAKE3 against the index or the receipts;
- index snapshots ride to every destination, not only buckets;
- verify re-hashes a destination squirrel writes itself in full, and is
  metadata-only on buckets alone;
- the marker goes through squirrel's transport on every native layout, a
  native mirror refuses a first push onto a tree it did not record, and
  native sftp has its own connect bound.

Smaller slips: encrypted packed sftp has no hash_algo default, checkers
is for rclone destinations only, a local destination takes no crypt, and
crypt moves an sftp destination's host key check to rclone.
SAFETY-AUDIT.md notes where #217 changed the marker (H7) and the
upload-correctness gap (D2).
…n 8)

Measured where a native push that writes spends its time: on local disks
the three full flushes per file, not the read-back; over sftp 27 requests
per path, one after another. Agreed with the maintainer: Put and Rename
stop flushing and a new Transport.Flush makes a batch of at most 64 files
or 256 MB durable before any record claims them, the full read-back runs
after the batch's flush, several paths go in flight per the new
concurrency key, and every per-call check stays.
A positive integer on every destination but kopia. On a destination
rclone writes it becomes rclone's --transfers, next to --checkers from
the checkers key; the native writers take it up in the next commit.
Put and Rename no longer flush; Transport.Flush makes everything before
it durable. On macOS each file gets a plain fsync and one F_FULLFSYNC
covers the batch; on Linux the batch's fsyncs run together at the flush.

A mirror push and a content-addressed push now land batches of at most
64 files or 256 MB, concurrency paths at a time: stage, flush, read back
in full, displace, flush, record displaced, commit, flush, record live.
No record claims bytes before the flush that covers them, and a staged
file's bytes are flushed before it is renamed onto its name. The marker,
the ride-along snapshot and the receipt flush the same way.

The fault transport gains a power-cut mode that takes back what no Flush
covered, or keeps every name without its bytes. The crash suites run one
path at a time and gain power cuts at every call, a first push is cut at
every call too, and the model test runs with paths in flight and random
power cuts.
… relies on

A content batch that stalled or was cancelled returned the artifacts it
never reached as landed, and the push recorded them: the next push then
skipped content the destination does not hold. putAll now fails every
artifact short of its final flush, and the push stops after a batch that
stalled.

A push that stops before its flush leaves moves the disk may still take
back. Reconcile now flushes every directory along both places of each
unsettled row before recording any settlement; Flush takes those
directories. A rename that finds its target taken also flushes that
directory, so an adopted artifact's name is durable when it is recorded.

Unrecorded moves into history are flushed before the batch's commits,
like recorded ones, and a Put that returns after the transport closed
releases its file.
Rerun on the testbed against main's rclone mirrors and the branch before
the change: sftp at a 20 ms round trip is at rclone's speed with the
default concurrency, and the exFAT image is 2-3 times faster than before,
about twice rclone's time, the rest being the read-back. F40 is fixed.
For every path with nothing at it, the mirror writer scanned every live
record for records below it, under the lock the paths in flight share: a
first push was quadratic in its file count. At 30,000 files the displace
step took 62 s. The writer now keeps a count of the live records below
each directory, as the destination resolves names, and asks it first;
the same push's displace step takes 0.6 s.
The first rerun's exFAT column followed the old build's runs while the
host disk was still working off their flushes. Settled, and broken into
steps: the read-back costs about 2 s of the push, the symlink checks
nothing measurable, and a quadratic scan 2.3 s, now fixed. With the fix
a first push to the exFAT image takes 15-29 s against rclone's 19-25 s.
@mbertschler
mbertschler marked this pull request as ready for review September 25, 2026 22:13
Copilot AI lite review requested due to automatic review settings September 25, 2026 22:13
@mbertschler
mbertschler merged commit 18d8055 into main Sep 25, 2026
4 checks passed
@mbertschler
mbertschler deleted the native-mirror branch September 25, 2026 22:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Critical marker-validation gaps and additional moderate findings remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 4 High severity · 1 Low severity

Open (5)
What changed in this PR

This PR replaces rclone with native local and plain-SFTP transports, adding durable mirror planning, verification, restore, recovery, batching, and concurrency support.

Changes:

  • Adds native local/SFTP transports, staging, receipts, flushing, and host-key validation.
  • Adds mirror evidence persistence, verification, restore/recovery, and offload integration.
  • Updates CLI behavior, configuration, documentation, design notes, and tests.

Review findings: unresolved critical marker-validation gaps remain in mirror restore and verification, with additional moderate concurrency and dry-run issues plus a documentation omission.

File Reviewed changes
sync/​verify_remote_test.go Remote verification coverage
sync/​verify_native.go Native artifact verification
sync/​vector_wiring_test.go Evidence and vector wiring tests
sync/​transport.go Transport abstraction and durability operations
sync/​transport_stall_test.go Stall-timeout coverage
sync/​transport_sftp_hostkey.go SFTP host-key validation
sync/​transport_sftp_hash_test.go SFTP hash behavior tests
sync/​transport_local_other.go Fallback local transport operations
sync/​transport_local_linux.go Linux local transport implementation
sync/​transport_local_dirs.go Local directory operations
sync/​transport_local_darwin.go macOS local transport implementation
sync/​snapshot_test.go Snapshot behavior tests
sync/​scanback.go Scan-back behavior
sync/​restore_place_test.go Atomic restore placement tests
sync/​recover.go Native snapshot recovery
sync/​readback.go Local read-back verification
sync/​rclone.go Remaining rclone integration
sync/​push_test.go Push behavior and safety tests
sync/​node.go Reserved paths and node handling
sync/​naming.go Artifact naming and collision handling
sync/​naming_test.go Naming tests
sync/​mirror_translate.go Mirror delta translation
sync/​mirror_sftp_test.go Native SFTP mirror tests
sync/​mirror_live.go Live-record tracking
sync/​mirror_live_test.go Live-record tests
sync/​kopia.go Snapshot integration
sync/​handler.go Native handler dispatch
sync/​handler_test.go Handler tests
sync/​fingerprint.go Fingerprint operations
sync/​fingerprint_test.go Fingerprint tests
sync/​content_addressed_test.go Content-addressed layout tests
sync/​batch.go Batching and concurrency
sync/​batch_test.go Batch behavior tests
sync/​artifacts.go Artifact storage abstraction
sync/​artifacts_rclone.go Rclone artifact handling
sync/​appledouble.go AppleDouble handling
store/​schema.sql Updated schema snapshot
store/​runs_audit.go Run and foreign-data auditing
store/​remote_paths_evidence.go Mirror path evidence persistence
store/​path_delta.go Path delta tracking
store/​path_delta_test.go Path delta tests
store/​migrations.go Database migrations
store/​migrate_v27_test.go Migration tests
store/​destination_run_ids.go Destination run evidence
store/​destination_reset.go Destination reset handling
store/​content_presence.go Destination content presence
SAFETY-AUDIT.md Native transport safety audit
offload/​native_mirror_test.go Native mirror offload coverage
go.mod SFTP and transport dependencies
docs/​src/​content/​docs/​reference/​on-disk-layout.md On-disk layout documentation
docs/​src/​content/​docs/​reference/​formats.md Format documentation
docs/​src/​content/​docs/​reference/​cli.md CLI reference updates
docs/​src/​content/​docs/​layouts/​packed.md Packed layout documentation
docs/​src/​content/​docs/​layouts/​encrypted.md Encrypted layout documentation
docs/​src/​content/​docs/​layouts/​content-addressed.md Content-addressed layout documentation
docs/​src/​content/​docs/​guides/​syncing.md Syncing guide updates
docs/​src/​content/​docs/​guides/​restore.md Restore guide updates
docs/​src/​content/​docs/​guides/​recovery.md Recovery guide updates
docs/​src/​content/​docs/​guides/​offloading.md Offloading guide updates
docs/​src/​content/​docs/​guides/​agent.md Agent guide updates
docs/​src/​content/​docs/​configuration/​destinations.md Destination configuration documentation
design/​testbed.md Native testbed documentation
design/​reference-setup.md Reference setup documentation
design/​README.md Design documentation index
design/​friction-log.md Friction-log updates
config/​pack_test.go Packed configuration tests
config/​offload_capability_test.go Offload capability tests
config/​layout_test.go Layout configuration tests
config/​config.go Configuration and concurrency settings
config/​config_test.go Configuration tests
cmd/​squirrel/​verify.go Verification command integration
cmd/​squirrel/​verify_test.go Verification CLI tests
cmd/​squirrel/​sync.go Sync command dispatch
cmd/​squirrel/​sync_test.go Sync CLI tests
cmd/​squirrel/​status_test.go Status command tests
cmd/​squirrel/​restore.go Restore command integration
cmd/​squirrel/​restore_test.go Restore CLI tests
cmd/​squirrel/​recover.go Recovery command integration
cmd/​squirrel/​recover_test.go Recovery CLI tests
cmd/​squirrel/​main_test.go Main command tests
cmd/​squirrel/​destination_reset.go Destination reset command
cmd/​squirrel/​content_native_test.go Native content-layout tests
cmd/​squirrel/​agent_scheduler.go Scheduler integration
cmd/​squirrel/​agent_scheduler_test.go Scheduler CLI tests
agent/​sync.go Agent reserved-path handling
agent/​sync_test.go Agent sync tests
agent/​scheduler.go Native scheduling

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread sync/mirror.go
if err != nil || !empty {
return false, err
}
case e.kind == kindFile && e.name == volmark.MarkerName:
Comment thread sync/restore_mirror.go
Comment on lines +57 to +61
func (mr *mirrorRestore) run(ctx context.Context, rep *Report, includeFile string) error {
rows, err := mr.store.ListPresentContent(ctx, mr.volID)
if err != nil {
return fmt.Errorf("list present content for %q: %w", mr.vol.Name, err)
}
Comment thread sync/verify_mirror.go
Comment on lines +34 to +35
if len(rows) == 0 {
return nil
Comment thread sync/verify_remote.go
Comment on lines +135 to +136
if dest.NativeMirror() {
return rep, verifyMirror(ctx, s, dest, &rep)
Comment on lines +84 to +93
Four directory names are reserved and **filtered out** of all sync and restore
transfers (and from peer-sync), so squirrel's own bookkeeping is never mistaken
for user content:

| Directory | Purpose |
|---|---|
| `.squirrel-history/run-<id>/` | rclone's `--backup-dir` target — prior bytes of overwritten files ([mirror](/squirrel/layouts/mirror/)). |
| `.squirrel-index/` | Ride-along [index snapshots](/squirrel/configuration/index-snapshots/). |
| `.squirrel-history/run-<id>/` | Prior bytes of the files a sync run replaced on a [mirror](/squirrel/layouts/mirror/). |
| `.squirrel-index/` | Ride-along [index snapshots](/squirrel/configuration/index-snapshots/), and a native mirror's receipts. |
| `.squirrel-restore-history/run-<id>/` | Files displaced by an [`--in-place` restore](/squirrel/guides/restore/). |
| `.squirrel-staging/run-<id>/` | In-flight writes on a destination squirrel writes itself, in any layout, renamed onto their names once confirmed. |
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.

2 participants