GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(id): durable replication receiver + verifier (#806 phase 3) by dezren39 · Pull Request #4634 · developing-today/code Conversation
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 39 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here are some automated review suggestions for this pull request.
Reviewed commit: e2742f8435
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| file.write_all(&bytes)?; | ||
| file.sync_all()?; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Recover interrupted tail appends before reopening the replica
If the process crashes during this append, or write_all partially writes before returning an error such as disk-full, the committed journal retains a partial batch. Poisoning the session does not undo those writes, and open rejects an unterminated entry as CorruptReplica, preventing recovery through a fresh replication session. A partial batch ending at an entry boundary is instead silently treated as fully committed on restart. Persist a recoverable committed-length boundary or equivalent transaction record so failed/interrupted appends can be rolled back to the last complete committed batch.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a805749. Tail appends are now transactional: before appending, the receiver durably records the journal pre-append length in an append-pending record (written through a scratch file + rename, so the record itself is never torn) and removes it only after the appended bytes fsync. At open, a leftover record truncates the journal back to the recorded length before validation — so a crash or partial write mid-append can neither wedge the replica with an unterminated line nor silently promote a batch that stops at an entry boundary. An append error also attempts an immediate rollback in-process. New test interrupted_tail_append_is_rolled_back_on_open covers both debris shapes (torn line and complete extra entry).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| payload_digest: crate::world::replication::payload_digest(&oversized), | ||
| payload: oversized, | ||
| }; | ||
| let error = receiver.accept_frame(&sign(envelope, &key)).unwrap_err(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Construct the oversized test frame without the bounded signer
This test always panics before reaching accept_frame: its payload exceeds MAX_REPLICATION_PAYLOAD_BYTES, so SignedReplicationEnvelope::sign returns None, which the local sign helper immediately unwraps. Consequently, the new receiver test suite fails rather than exercising oversized-frame rejection. Construct and sign the deliberately invalid envelope through a test-only path that bypasses the production signer's size guard.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a805749. The oversized test now signs through a test-only sign_unbounded helper that replicates the signing-bytes contract (domain + every envelope field + exact payload bytes) and signs directly, bypassing the production signer size guard — so the frame passes signature verification and actually reaches the payload-bound check in ReplicationTracker::accept. If the signing contract changes, the helper frames fail verification and the test fails loudly rather than silently passing.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ReplicationKind::Tail => { | ||
| match self.staged.as_mut() { | ||
| Some(staged) => staged.extend(&accepted.payload), | ||
| None => self.staged = Some(Staged::Tails(accepted.payload)), |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Enforce snapshot-first ordering in each new session
If a pinned source sends a correctly signed base-cursor tail as the first frame after reconnect, the tracker accepts it because begin_session resets verification to the chain base, but this branch stages it for append to the existing journal. A tail containing the matching Created header followed by a valid terminal therefore appends a second header, reports a committed cursor that does not describe the stored bytes, and makes the next open fail with CorruptReplica. A terminal-first session likewise overwrites the committed cursor with the base without changing the journal. Although the current writer emits a snapshot first, the receiver must enforce that ordering rather than treating these accepted frame sequences as durable commits.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a805749. The receiver now enforces snapshot-first ordering itself: on a session first frame it decodes the frame (shape only) and refuses any non-snapshot kind with the new ReceiverError::SessionMustStartWithSnapshot BEFORE the tracker sees it, so a refusal leaves tracker, staging, journal, and the committed cursor all untouched. A base-chained tail can no longer be appended to an existing journal, and a terminal-first session can no longer move the committed cursor without moving the journal. New test tail_or_terminal_first_in_a_session_is_refused covers both, and verifies the replica still opens cleanly at the prior committed cursor.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… oversized test (#806 phase 3) Codex review on PR #4634: (P1) a crashed or partial tail append could wedge the replica as CorruptReplica or silently promote an uncommitted batch - tail appends now write a durable append-pending record (pre-append length, installed by rename) before appending and remove it after fsync; open rolls a leftover record back. (P2) a session starting with a base-chained tail or a terminal could corrupt committed state - the receiver now refuses a non-snapshot first frame (SessionMustStartWithSnapshot) before the tracker sees it. (P2) the oversized-payload test panicked in the bounded signer - it now signs through a test-only unbounded path replicating the signing-bytes contract. New tests: tail/terminal-first refusal, interrupted-append rollback (torn and entry-boundary debris).
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here are some automated review suggestions for this pull request.
Reviewed commit: a8057499a5
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if let Err(error) = append_result { | ||
| // Best-effort immediate rollback; the pending | ||
| // record makes the next open roll back regardless. | ||
| let _ = self.roll_back_to(prior_len); | ||
| return Err(error); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Recover pending appends before allowing a replacement snapshot
If a tail append fails during write_all or sync_all, this path leaves the append-pending record behind even when immediate rollback succeeds. Calling begin_session on the poisoned receiver then permits a reconnect snapshot to commit successfully without clearing that record. On the next open, roll_back_interrupted_append truncates the replacement snapshot to the old pre-append length, silently dropping committed entries or corrupting a reset snapshot. Recover and clear the pending transaction before allowing a replacement snapshot to commit.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 80c8353. Two layers: (1) commit_staged's Snapshot arm now runs roll_back_interrupted_append before installing a replacement snapshot, so a stale append-pending record is recovered and cleared before the snapshot commits and can never truncate it at the next open; (2) the tail-append error path now clears the append-pending record (plus directory fsync) whenever the immediate rollback succeeds — the record is only left behind when rollback itself failed, in which case the next open or a snapshot commit's recovery performs it. Regression test: stale_append_pending_record_cannot_roll_back_a_replacement_snapshot. Replication suite on the laptop: 33 passed. (Reply posted after the merge — GitHub refused review-comment replies with 422 abuse errors during the shift.)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| world_id: WORLD.to_string(), | ||
| source, | ||
| header_version: 1, | ||
| kind: ReplicationKind::Tail, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Let the oversized-frame test reach payload validation
The unbounded signer fixes the previously reported signing panic, but the new snapshot-first guard now rejects this test's first Tail frame with SessionMustStartWithSnapshot, before the tracker checks its payload size. Consequently, the assertion expecting PayloadTooLarge still fails. Make the oversized envelope a snapshot, or establish a valid snapshot-first session before submitting the oversized tail, so this test exercises the intended size check.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 80c8353. The oversized test now builds the oversized envelope as a Snapshot frame (still signed through the test-only sign_unbounded helper), so it passes the snapshot-first guard and reaches the tracker's payload-size check: oversized_payload_is_refused passes, asserting PayloadTooLarge. The same commit also fixes three pre-existing E0618 compile errors in this test module (the receiver helper fn shadowed by local bindings named receiver, via a new reopen helper) — the module did not compile at a805749, which is why this assertion had never actually run. Replication suite on the laptop: 33 passed. (Reply posted after the merge — GitHub refused review-comment replies with 422 abuse errors during the shift.)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…oversized test + receiver test compile (#806 phase 3) Codex re-review of a805749 raised two findings: (P1) a tail append whose immediate rollback succeeded left its append-pending record behind, so a later replacement snapshot could be truncated at next open - commit_staged now recovers/clears any pending append before a snapshot commit, and a successful immediate rollback clears the record too; regression test stale_append_pending_record_cannot_roll_back_a_replacement_snapshot. (P2) the oversized-frame test used a Tail frame and was refused by the snapshot-first guard before reaching payload validation - it now sends a Snapshot frame. Also fixes three pre-existing E0618 compile errors in the receiver tests (helper fn shadowed by a local binding named receiver) via a reopen helper: the module did not compile at a805749. Tests: cargo test -p id --lib replication - 32 passed.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here are some automated review suggestions for this pull request.
Reviewed commit: 80c8353cbb
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| let accepted = tracker.accept(frame_bytes)?; | ||
| (accepted, tracker.cursor(), tracker.header_version()) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Reject version-zero snapshots before committing them
If the pinned source sends a correctly signed snapshot whose envelope and Created header both specify version 0, followed by its terminal frame, the receiver commits it successfully: ReplicationTracker::accept only rejects versions above MAX_JOURNAL_VERSION. However, validate_committed_journal explicitly rejects version 0, so the next open fails with CorruptReplica, even if this snapshot replaced a previously valid replica. Enforce the same supported-version range during frame acceptance as during reopening, before advancing the tracker or replacing committed bytes.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fixed in e768cd7. ReplicationTracker::accept now enforces the full supported journal range (header_version == 0 or > MAX_JOURNAL_VERSION both refuse with UnsupportedJournalVersion) before any tracker state advances — the same range validate_committed_journal enforces at open, so an accepted frame can no longer commit a journal the next open would reject. Regression test: version_zero_snapshot_is_refused_before_any_entry. Replication suite on the laptop: 33 passed; Codex re-review of e768cd7 reported no findings and PR #4634 merged as 844fac4. (Reply posted after the merge — GitHub refused review-comment replies with 422 abuse errors during the shift.)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…hase 3) Codex re-review of 80c8353 (P2, comment 4449166369): ReplicationTracker::accept only rejected header versions above MAX_JOURNAL_VERSION, so a correctly signed version-0 snapshot committed - then validate_committed_journal rejected it at the next open, bricking the replica and destroying any valid journal it replaced. Accept now enforces the full supported range 1..=MAX_JOURNAL_VERSION before any state advances. Regression test: version_zero_snapshot_is_refused_before_any_entry. Tests: cargo test -p id --lib replication - 33 passed.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.