apply dropped the visibility column, and add did too
Reported from use in another repository, reproduced before diagnosing, and the report was right and understated: two staging sites built a lock record without visibility, not one, and one of them was in add where the value was already computed three lines above. Fixed twice over, because the two fixes answer different questions. A staged copy is new bytes, so its visibility is evaluated afresh rather than inherited — a source that has gone private since adoption is a new exposure created at the moment of applying, and inheriting the old value would record a fact about bytes nobody holds any more. And apply now never lets an absent value overwrite a known one, which covers polads staged by an older build, the state the reporter is in. Pinned by a regression test. No test we had would have caught it: both sites round-trip correctly in isolation, and the field only vanishes across the handoff between them. The lock header says visibility is recorded because access is checked once and the copy is durable. A field that documents its own reason for existing, and is then dropped by the one operation that updates it, reads as verified and is blank. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018UTxuSizozEA8yDitPuris
This commit is contained in:
Vendored
+6
-2
@@ -135,7 +135,7 @@ func Add(root, raw, override string, out io.Writer) error {
|
||||
return fmt.Errorf("%s differs from what %s serves, and no cart is open to stage it in — "+
|
||||
"the local copy is the only evidence of that and will not be touched", rel, body.url)
|
||||
}
|
||||
if err := stage(root, rel, body.data, lock.Record{Path: rel, URL: body.url, ETag: etag}); err != nil {
|
||||
if err := stage(root, rel, body.data, lock.Record{Path: rel, URL: body.url, ETag: etag, Visibility: vis}); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(out, "staged %s\n", rel)
|
||||
@@ -387,7 +387,11 @@ func checkLocked(cfg *config.Config, root string, rec lock.Record, open bool) (S
|
||||
if !open {
|
||||
return Status{rec.Path, "CHANGED", "upstream moved — no cart open, so nothing was staged"}, 0
|
||||
}
|
||||
if err := stage(root, rec.Path, body.data, lock.Record{Path: rec.Path, URL: body.url, ETag: etag}); err != nil {
|
||||
// A staged copy is new bytes, so its visibility is evaluated afresh rather
|
||||
// than inherited: a source that has gone private since adoption is a new
|
||||
// exposure, created now.
|
||||
staged := lock.Record{Path: rec.Path, URL: body.url, ETag: etag, Visibility: sourceVisibility(cfg, body.url)}
|
||||
if err := stage(root, rec.Path, body.data, staged); err != nil {
|
||||
return Status{rec.Path, "error", err.Error()}, 0
|
||||
}
|
||||
return Status{rec.Path, "CHANGED", "staged as a polad" + usagesNote(root, rec.Path)}, 1
|
||||
|
||||
Reference in New Issue
Block a user