Skip to content

refactor(hotblocks): consolidate head/finalized-head into one owner#95

Open
mo4islona wants to merge 1 commit into
masterfrom
refactor/hotblocks-head-state-consolidation
Open

refactor(hotblocks): consolidate head/finalized-head into one owner#95
mo4islona wants to merge 1 commit into
masterfrom
refactor/hotblocks-head-state-consolidation

Conversation

@mo4islona

Copy link
Copy Markdown
Contributor

Head and finalized-head were held twice in memory — as WriteController
fields and as the DatasetController watch channels — kept in sync by hand
through WriteCtx.notify_*, so a write that forgot a notify would silently
stall wait_for_block. Give the writer the watch senders and route every
mutation through set_head/set_finalized_head, which update the field and
publish together, after the commit: a write can no longer forget to
publish, and a published watermark is always already durable (INV-31/CN-4).

The senders live on the controller and are cloned into each rebuilt writer,
so seeding moves into WriteController::new and restart re-seed becomes
automatic (INV-40/CN-9). The plain head field stays as the writer's
committed-state mirror (WP-1) — reading it back from the channel would pin a
watch read-lock across the RocksDB transaction in finalize(). WriteCtx
dissolves into WriteController, removing the write.write. indirection.

New unit tests cover the two properties the conformance matrix flags as
untested: a committed transition publishes exactly the durable watermark
(INV-30/31) and a rebuilt writer re-seeds from storage (INV-40/CN-9), plus
the head-only-progress dedup that keeps finalized waiters from waking.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

Head and finalized-head were held twice in memory — as WriteController
fields and as the DatasetController watch channels — kept in sync by hand
through WriteCtx.notify_*, so a write that forgot a notify would silently
stall wait_for_block. Give the writer the watch senders and route every
mutation through set_head/set_finalized_head, which update the field and
publish together, after the commit: a write can no longer forget to
publish, and a published watermark is always already durable (INV-31/CN-4).

The senders live on the controller and are cloned into each rebuilt writer,
so seeding moves into WriteController::new and restart re-seed becomes
automatic (INV-40/CN-9). The plain head field stays as the writer's
committed-state mirror (WP-1) — reading it back from the channel would pin a
watch read-lock across the RocksDB transaction in finalize(). WriteCtx
dissolves into WriteController, removing the write.write. indirection.

New unit tests cover the two properties the conformance matrix flags as
untested: a committed transition publishes exactly the durable watermark
(INV-30/31) and a rebuilt writer re-seeds from storage (INV-40/CN-9), plus
the head-only-progress dedup that keeps finalized waiters from waking.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mo4islona mo4islona force-pushed the refactor/hotblocks-head-state-consolidation branch from 36e693c to c2b67e8 Compare July 15, 2026 16:53
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