Skip to content

Round-2 review fixes: fsync+unique temp in boot_guard, raw-bytes digest in verify, lock in chain.advance - #2

Merged
ascorblack merged 1 commit into
mainfrom
agent/review-fixes-round2
Sep 7, 2026
Merged

Round-2 review fixes: fsync+unique temp in boot_guard, raw-bytes digest in verify, lock in chain.advance#2
ascorblack merged 1 commit into
mainfrom
agent/review-fixes-round2

Conversation

@ascorblack

Copy link
Copy Markdown
Owner

Addresses the three points raised in the code-review thread (reply to PR #1):

  1. daedalus/host/boot_guard.py — _atomic_write now uses a per-write uuid temp suffix (two concurrent writers in one process no longer share one temp file and clobber it mid-write), and flushes + fsyncs before os.replace so a power cut right after the rename cannot leave a 0-byte state file. A failed write removes its orphaned temp.
  2. daedalus/tools/verify.py — the receipt digest now hashes the raw stdout bytes instead of the decode("replace")-re-encoded copy, so non-UTF-8 output is described faithfully by the hash.
  3. daedalus/providers/chain.py — advance() now holds an asyncio.Lock across the check-and-advance, making the transition atomic when concurrent failures race (the contract makes advance async precisely because a rung may be materialised with awaits).

Tests: new tests/unit/test_boot_guard.py (temp uniqueness, cleanup on failure, write→flush→fsync→replace order), a concurrent-advance test in test_provider_chain.py, and a raw-bytes digest test in test_checkpoints_verify_learning.py.

Checked: 189 unit tests passed, 1 skipped; 3 smoke tests passed.Verification receipts: none — nothing in this proposal was checked with Verify.

…st in verify, lock in chain.advance

- boot_guard._atomic_write: per-write uuid temp suffix (concurrent writers
  no longer share one temp file), flush+fsync before os.replace so a power
  cut cannot leave a 0-byte state file, orphaned temp removed on failure.
- tools.verify: receipt digest now hashes the raw stdout bytes instead of
  the decode('replace')-re-encoded copy, so non-UTF-8 output is described
  faithfully.
- providers.chain: advance() takes an asyncio.Lock so the check-and-advance
  transition is atomic when concurrent failures race; the contract makes
  advance async precisely because a rung may be materialised with awaits.

Tests: new test_boot_guard.py (temp uniqueness, cleanup, write->flush->
fsync->replace order), concurrent-advance test in test_provider_chain.py,
raw-bytes digest test in test_checkpoints_verify_learning.py.
189 unit passed, 1 skipped; 3 smoke passed.
@ascorblack
ascorblack merged commit 692f07a into main Sep 7, 2026
@ascorblack
ascorblack deleted the agent/review-fixes-round2 branch September 7, 2026 12:32
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