Repository navigation
fix(distribute): read current bytes as current before a lagging files: receipt as an edit - #192
Conversation
…ng files: receipt as an edit Refs: sideshow#190
arcavenai
left a comment
There was a problem hiding this comment.
Approving. A files: artifact whose receipt lags its bytes now reads as current and takes the next pack update, instead of reading as an edit forever. A file with no receipt still stays the user's even when its bytes match the pack.
The reproducer from #191, end to end. I wrote v2's bytes into a.cfg under its v1 receipt, then installed v2, reading the registry after each run. At 3776d96 every run said modified since sideshow wrote it and the receipt stayed at the v1 sha. At 683e972:
--dry-runsaysalready currentand leaves the receipt at the v1 sha;- the real run says
already currentand moves the receipt to the v2 sha; - the next run is unchanged;
- an edit after that reads
modified ...on two runs, with the receipt and the edit kept.
No receipt, equal bytes. A user-authored a.cfg holding exactly the pack's bytes reads user-authored on a dry run, then on three real runs across a v2 bump. It gains no receipt and is never written.
Nothing else moved. My #191 files: rows (sibling recreated, edit plus sibling, edit plus bump, dry run, removed and re-added, user-authored, unedited bump) match 3776d96 line for line. The only change is the reproducer row. My #189 rules rows match 8736668 line for line.
The write path. It is reached only with a known receipt that equals the bytes on disk while those bytes differ from the pack's. An edit cannot reach it with or without a receipt; a file with no receipt never gets past the first case.
Red, and mutants. At cca9cc8, TestFiles_ALaggingReceiptWithCurrentBytesIsMovedNotReadAsAnEdit fails for the stated reason: it reads modified and keeps the old sha. The no-receipt guard passes there, as stated. Head passes the full suite and two runs of -count=20. Each of these mutants fails a test:
- the two named mutants;
- my #189 old-order mutant, applied here by moving the current-bytes case back after the modified case;
- the current case not recording;
- the current case recording under a dry run;
- the current case keeping the old receipt;
- the edited case removed.
The comment. The known-limit comment at the !known branch says a first write whose registry save fails leaves no receipt, so the file reads as user-authored from then on, and that deleting it takes the pack's version. That matches the no-receipt run above and the absent-file path, which creates.
CI on 683e972 passes.
Seat: reviewer / reviewer
A
files:artifact whose receipt lags its bytes, because a run wrote the new version and died before the registry saved or because the user applied the update by hand, was reported as "modified since sideshow wrote it" on every run and could never be updated again. This tests "bytes equal the pack's" before "bytes differ from the receipt", so that state reads as already current and the receipt moves to the new sha.The same order the #189 review asked for rules. A
files:artifact has no marker, so the order is narrower here: a file with no receipt stays user-authored even when its bytes equal the pack's, because equal bytes prove only equality and a user's own copy must never be adopted into management.Refs: sideshow#190
Order in
distributeFile: no receipt (user-authored, skip, nothing recorded); then bytes equal to the pack with a known receipt (already current, receipt recorded as the pack's sha); then bytes differ from the receipt (modified, edit kept, receipt kept).Known limit, now in a comment and not fixed here: a first write whose registry save fails leaves no receipt, so that file reads as user-authored from then on. That is safe, and deleting the file takes the pack's version.
Acceptance:
Commits: (1) tests, red; (2) the reorder and the comment.
Blast radius: the order of two branches in
distributeFile.Mutants, each compiles and fails a test:
TestFiles_ALaggingReceiptWithCurrentBytesIsMovedNotReadAsAnEditTestFiles_NoReceiptAndBytesEqualToThePackIsStillUserAuthored