Skip to content

Offload: ship only what changed; stop failing (and re-shipping) the same folders daily - #7

Merged
BlizzHacker merged 1 commit into
mainfrom
claude/offload-change-detection
Nov 1, 2026
Merged

BlizzHacker merged 1 commit into
mainfrom
claude/offload-change-detection

Conversation

@BlizzHacker

Copy link
Copy Markdown
Owner

Why

On 2026-10-26, /opt/repos (728 GB) on the server filled to 0 bytes. mwm-offload/5050rtx/ held up to 19 dated copies of the same folders. moveweight-ui alone was about 12 GB per copy, and consecutive days were byte-identical.

The guard log shows the cause. The data rarely changed, but every shipment of these folders failed. Each failure kept the local folder, so the next day the guard shipped the whole thing again into a new YYYYMMDD-<name> folder. It left a full or partial copy behind every time and never wrote a RESTORE.md:

Folder Daily failure Root cause
moveweight-ui 52185 untracked files packed, 52175 arrived 10 untracked files under .pytest_cache/. tar's --exclude .pytest_cache matches any path component, but MWM listed and counted them.
cryptic-realm-mobile-color-fix 26473 … packed, 26460 arrived Same bug: 13 files under node_modules.partial/stream-buffers/coverage/.
cryptic-realm-infernal-arcforge tar.exe: Error exit delayed from previous errors public/cr-realms is a junction to D:\codex-build-spill\…, which no longer exists. See below.
cr-parent fatal: gitfile does not point to a valid repository A pruned worktree (its .git/worktrees/<name> is gone) was still treated as a worktree.
RommForXbox delete C:\MoveWeight\romm\RommForXbox The shipment succeeded but the delete failed. The real error was hidden, and the next day it shipped everything again.

The ".part that stalls at 1,802,373,000 bytes"

It was not a stall. That file is the complete archive: the gzip stream is intact (gzip -t passes, and the tar inside ends cleanly), and 3.08 GB of tar compresses to 1.80 GB. Windows tar.exe wrote the whole archive, then exited 1 because it could not stat the dangling junction public/cr-realms. MWM bailed before the checksum and rename, so untracked.tar.gz.part stayed behind. Its size was the same each day because the content was the same. MWM only reported tar's last stderr line, so the cause never showed. Reproduced locally (output piped to wc -c):

tar.exe: public/cr-realms: Cannot stat: No such file or directory
tar.exe: Error exit delayed from previous errors

What changes

  • Change detection. Before anything travels, every part is fingerprinted locally:

    • git-state.json: its bytes.
    • unpushed.bundle: the refs it starts at and the remote refs it stops at.
    • uncommitted.patch: the diff, hashed as it streams.
    • untracked.tar.gz / folder.tar.gz: every path, size and mtime.

    If a folder is exactly as it was at its last verified shipment, nothing is shipped. If only some parts changed, the changed parts ship and the unchanged ones are pointed at in PARTS.json and RESTORE.md, which give each part's real server path. State lives in %LOCALAPPDATA%\MoveWeight\MWM\offload-sent.json. Before a part is reused, its file is checked on the server by size, and a part that has gone missing is shipped again.

  • Count fix. is_rebuildable now matches any path component, as tar does. Untracked files inside a rebuildable folder are dropped, and the new manifest() counts exactly what tar keeps.

  • Dangling links (symlinks or junctions whose target is gone) are left out of the tar list and listed in RESTORE.md as path -> target.

  • Readable errors. Tool errors report the real stderr lines; tar's "Error exit delayed" line is dropped. The guard log shows the whole error chain ({e:#}), so a failed delete now says why.

  • Pruned worktrees ship as plain folders.

  • No more .part litter. A failed shipment removes the folder it created on the server and says so in the log. The local folder is untouched, so nothing is lost. A second run on the same day gets its own YYYYMMDD-<name>-HHMMSS folder and never writes into the first one.

  • Shipped but the delete failed is reported as that. The shipment stays recorded, so the next run only retries the delete instead of shipping again.

Tests

  • 11 new unit tests:

    • rebuildable matching
    • the manifest's count and fingerprint
    • dangling links
    • pruned worktrees
    • reuse and unchanged decisions, including the empty-bundle marker
    • stat parsing
    • artifact and restore lines
    • tar error summary
  • 1 end-to-end test (#[ignore], opt-in) that ships a scratch repo over real SSH four times: a full ship; an unchanged ship (nothing travels, same folder); one changed part (only untracked.tar.gz and git-state.json travel, and RESTORE points at the earlier bundle and patch); and a part deleted on the server (it is shipped again). Run it with MWM_TEST_SERVER=root@127.0.0.1 cargo test -p mwm-core offload -- --ignored on a box that can SSH to itself.

  • Results:

    • cargo test -p mwm-core --lib offload: 13/13 passed.
    • End-to-end test: passed against root@127.0.0.1 on .6.
    • Full cargo test -p mwm-core --lib on CT 190: 48 passed, 1 ignored.
    • Windows cross-build on CT 190 (cargo tauri build --runner cargo-xwin --target x86_64-pc-windows-msvc --no-bundle): succeeded, MoveWeightManager.exe (7.8 MB), with no warnings from offload.rs.

    The installed guard was not updated: deploying is a separate step.

Before deploying, note

The count, junction and worktree fixes will let the guard's next run actually move moveweight-ui, cryptic-realm-mobile-color-fix, cryptic-realm-infernal-arcforge and cr-parent off C: and delete them locally, after a verified shipment, as the policy says (idleDays: 2). The files that are left out are rebuildable caches (.pytest_cache, coverage) and the dangling public/cr-realms junction, whose target is already gone; RESTORE.md records it.

Server side, outside this repo: mwm-offload/dedupe-identical.sh now skips any snapshot that a newer PARTS.json points into. The previous version is kept as dedupe-identical.sh.bak-20261026.

🤖 Generated with Claude Code

…ery day

The guard re-shipped the same folders every day because their shipments
failed, so they were never deleted, and each retry wrote a full new dated
snapshot (about 12 GB a day for moveweight-ui). That filled /opt/repos.

* Change detection: every part (git-state, bundle, patch, untracked or
  folder tar) is fingerprinted locally before anything travels: refs for
  the bundle, the diff for the patch, path+size+mtime for tars. A folder
  exactly as it was at its last verified shipment ships nothing. An
  unchanged part of a changed folder is pointed at (PARTS.json, RESTORE.md)
  instead of sent again. State lives in offload-sent.json, and a part
  missing from the server is shipped again.
* Count mismatch ("52185 untracked files packed, 52175 arrived"): tar
  --exclude drops any path with a rebuildable component
  (.pytest_cache/README.md, node_modules.partial/x/coverage/...), but MWM
  listed and counted them.
* "tar.exe: Error exit delayed from previous errors" (infernal-arcforge): a
  junction into a drive that is gone made tar fail after writing the whole
  archive, every day, leaving untracked.tar.gz.part at the same size.
  Dangling links are now left out and listed in RESTORE.md, and tool
  errors report the real lines instead of the last one.
* A pruned worktree (gitdir gone) ships as a plain folder instead of
  failing every git command.
* A failed shipment removes its own folder from the server, so no .part
  files are left behind. A second run on the same day gets its own folder.
* "Shipped but the delete failed" is reported as that, with the cause, and
  the next run only retries the delete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BlizzHacker
BlizzHacker merged commit 2c0bd5a into main Nov 1, 2026
2 checks passed
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.

1 participant