Skip to content

feat(recovery): bind database restore to journal - #357

Merged
mergify[bot] merged 11 commits into
mainfrom
codex/w3-02c-restore
Oct 4, 2026
Merged

mergify[bot] merged 11 commits into
mainfrom
codex/w3-02c-restore

Conversation

@Cuarroc

@Cuarroc Cuarroc commented Oct 4, 2026 •

Copy link
Copy Markdown
Owner

Der Merge-Konflikt von PR #357 mit dem aktuellen main ist aufgelöst und der neue Stand ist gepusht.
Die Konfliktlösung erhält sowohl die Restore- als auch die Installer-Moduldeklaration; zusätzliche Paketlogik wurde nicht eingeführt.
Der vollständige Linux-Prepush und der Push-Hook sind grün; die Windows-Prüfung bleibt für die Merge-Queue offen.

Report

What changed

  • Merged the current origin/main into codex/w3-02c-restore with merge commit ba27fcb.
  • Resolved the only textual conflict in src-tauri/src/delivery_recovery.rs by retaining both existing module declarations: installer from main and restore from PR feat(recovery): bind database restore to journal #357.
  • Recorded the generated activity entry in commit ee569df; no unrelated user work remains modified.

Evidence

  • npm run dev:start-check — exit 0; 13.2 GB free RAM and one Cargo build (within the limit of two).
  • bash scripts/ci/secret-scan.sh — exit 0; no leaks found.
  • bash scripts/ci/gates.sh lane precommit — exit 0.
  • bash scripts/ci/gates.sh lane prepush — exit 0; 485 frontend tests passed, 527 HQ tests passed, 1,784 Rust tests passed with 7 skipped, Clippy passed, and architecture drift reported no new occurrences.
  • git push -u origin codex/w3-02c-restore — exit 0; its prepush hook also completed green.
  • git ls-remote origin refs/heads/codex/w3-02c-restore — exit 0; remote SHA ba27fcb0bb55f061cd819b060d9040f2fb23bcda.

NICHT ABGEDECKT

  • Linux does not compile or run the #[cfg(windows)] tests or the Windows clippy arms (run_in_pty, npm_shim, ConPTY, DPAPI).
  • Browser smoke, frontend build, workflow gates, and external services are outside the prepush lane.
  • Windows verification is expected in the merge queue.

Architecture drift

  • No new architecture-drift findings; no allowlist change.

Review disposition

  • Review: ausstehend (Stufe A); external review is coordinated separately.

Conflict resolution

  • git merge origin/main initially stopped because the generated .pa/ACTIVITY.md entry was uncommitted (exit 2); after recording that entry in ee569df, the merge completed with one source conflict.
  • The source conflict was limited to the module declaration block; no package behavior was changed manually.

Open points

  • Required external review remains pending.
  • Mergify queue processing remains pending until checks are green and the queue is requested.

Cuarroc and others added 4 commits October 4, 2026 20:54
Test-First: src-tauri/src/delivery_recovery/restore.rs::foreign_backup_never_replaces_the_journal_database
Test-First: src-tauri/src/delivery_recovery/restore.rs::modified_backup_never_replaces_the_journal_database
Co-Authored-By: Codex (GPT-5) <noreply@openai.com>
Test-First: src-tauri/src/delivery_recovery/restore.rs::journal_bound_backup_restores_before_write_resume
Test-First: src-tauri/src/delivery_recovery/restore.rs::restore_is_refused_after_writes_resumed
Co-Authored-By: Codex (GPT-5) <noreply@openai.com>
Regression-For: df5c145
Regression-For: 5979c8e
Co-Authored-By: Codex (GPT-5) <noreply@openai.com>
No-Test: append-only activity handoff
Co-Authored-By: Codex (GPT-5) <noreply@openai.com>
@Cuarroc
Cuarroc marked this pull request as ready for review October 4, 2026 19:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T19:16:15.914234Z 2e2252e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e2252e161

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment on lines +32 to +33
let bytes = fs::read(&snapshot.path)
.map_err(|error| format!("failed to read recovery snapshot: {error}"))?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stream verified snapshots instead of buffering them

When a legitimate SQLite backup is large relative to available RAM, fs::read allocates the entire snapshot and retains it throughout the subsequent temporary-file copy. The existing restore path streamed from a file handle, so this change can make the recovery helper abort from memory exhaustion even when sufficient disk space is available. Hash while streaming from the already-open snapshot into the temporary file, then atomically replace the destination only after the digest matches.

Useful? React with 👍 / 👎.

Comment on lines +38 to +42
crate::db_restore::restore_verified_snapshot_bytes(
&snapshot.path,
&previous.database.path,
&bytes,
)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore the previous binary together with the database

When validation fails after candidate installation has replaced the executable, this function reports a successful RestorePreviousRuntime after restoring only the database and never verifies or restores previous.binary. That leaves a candidate-binary/old-database combination rather than the journaled runtime pair, so the candidate may immediately remigrate the restored database or fail again. Restore and verify the previous binary before returning success, or narrow the action so a separate mandatory step cannot be skipped.

Useful? React with 👍 / 👎.

Comment on lines +16 to +20
if journal.writes_resumed {
return Err("refused: writes already resumed".into());
}
if journal.next_action() != *action {
return Err("refused: restore is not bound to this journal".into());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Persist restore completion before accepting new writes

After a successful restore, the durable journal remains in RecoveryNeeded with writes_resumed == false and the same RestorePreviousRuntime action; there is no UpdateJournal transition that consumes that action or marks the restored runtime as resumed. If the previous runtime accepts new writes and the helper is then retried or restarted, this guard still passes and the adapter restores the old snapshot again, discarding those writes. Persist a restore-completed/resumed transition before writes can resume rather than relying on this unchanged flag.

Useful? React with 👍 / 👎.

Comment on lines +12 to +15
pub fn restore_previous_runtime(
journal: &UpdateJournal,
action: &RecoveryAction,
) -> Result<(), String> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Route restore execution through the bound adapter

At this commit, a repository-wide call search finds restore_previous_runtime only in this module's unit tests; RecoveryDriver::step still invokes RecoveryEffects::restore(previous, snapshot), whose signature has neither the journal nor the exact action needed for these checks. Consequently, any restore executed through the recovery driver bypasses the newly added journal binding, write-resumption guard, and snapshot rehash entirely. Wire this adapter into the driver/effect implementation so the protected path is the one production orchestration executes.

Useful? React with 👍 / 👎.

@mergify

mergify Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

…tion

The reader refactor made restore_from_reader borrow the backup file, so the
handle stayed open across replace_file. Take the reader by value and drop it
before the replace, as the comment above it promises.

Test-First: src-tauri/src/db_restore.rs::db_restore::tests::restore_closes_the_source_before_replacing_the_destination

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Cuarroc

Cuarroc commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

@Mergifyio queue

@mergify mergify Bot added the queued label Oct 4, 2026
@mergify

mergify Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-04 19:51 UTC · Rule: default · triggered by @Cuarroc with the @mergifyio queue command
  • 🚫 Left the queue — 2026-10-04 20:19 UTC · at f1b27c8178958edda824af83057c06a38a1d457b

This pull request spent 28 minutes 1 second in the queue, with no time running CI.

Reason

The pull request conflicts with the base branch

The pull request was held in the queue, conflicting with 1 pull request ahead of it. The conflict became a base branch one after #361 merged.

Hint

You should update or rebase your pull request.

If you want to requeue this pull request, you can post a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@mergify mergify Bot added dequeued and removed queued labels Oct 4, 2026
@Cuarroc

Cuarroc commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

@Mergifyio queue

@mergify mergify Bot added queued and removed dequeued labels Oct 4, 2026
@mergify

mergify Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-04 20:39 UTC · Rule: default · triggered by @Cuarroc with the @mergifyio queue command
  • 🚫 Left the queue — 2026-10-04 20:50 UTC · at 615f58f8143e359a3012841db54f4baf9fc3c925

This pull request spent 11 minutes 6 seconds in the queue, with no time running CI.

Reason

The pull request conflicts with the base branch

Hint

You should update or rebase your pull request.

If you want to requeue this pull request, you can post a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@mergify mergify Bot added dequeued and removed queued labels Oct 4, 2026
@Cuarroc

Cuarroc commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

@Mergifyio queue

@mergify mergify Bot added queued and removed dequeued labels Oct 4, 2026
@mergify

mergify Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-04 21:09 UTC · Rule: default · triggered by @Cuarroc with the @mergifyio queue command
  • 🚫 Left the queue — 2026-10-04 21:18 UTC · at 28d1d37d09a8d5ab136c7fdafb135f2406d0d7b4

This pull request spent 8 minutes 55 seconds in the queue, with no time running CI.

Reason

The pull request conflicts with the base branch

Hint

You should update or rebase your pull request.

If you want to requeue this pull request, you can post a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@mergify mergify Bot added dequeued and removed queued labels Oct 4, 2026
@mergify mergify Bot removed the dequeued label Oct 4, 2026
@Cuarroc

Cuarroc commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

@Mergifyio queue

@mergify mergify Bot added the queued label Oct 4, 2026
@mergify

mergify Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-04 21:37 UTC · Rule: default · triggered by @Cuarroc with the @mergifyio queue command
  • 🚫 Left the queue — 2026-10-04 21:39 UTC · at 6e3d5c32b99d44e6e5e27d14714c82bb2520c063

This pull request spent 2 minutes 1 second in the queue, with no time running CI.

Reason

Pull request #357 has been dequeued

Queue conditions are not satisfied:

  • -conflict [📌 queue requirement]
  • any of: [🔀 queue conditions]
    • all of: [📌 queue conditions of queue rule default]
      • -conflict

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@mergify mergify Bot added dequeued and removed queued labels Oct 4, 2026
No-Test: generated activity record
No-Test: conflict resolution only; existing coverage follows in prepush
@mergify mergify Bot removed the dequeued label Oct 4, 2026
@Cuarroc

Cuarroc commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

@Mergifyio queue

No-Test: generated activity record
@Cuarroc Cuarroc added the review-ok Pipeline: review disposition complete, no open high finding label Oct 4, 2026
@Cuarroc

Cuarroc commented Oct 4, 2026

Copy link
Copy Markdown
Owner Author

@Mergifyio queue

@mergify

mergify Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

queue

☑️ Command queue ignored because it is already running from a previous command.

@mergify mergify Bot added the queued label Oct 4, 2026
@mergify
mergify Bot merged commit b3b39c6 into main Oct 4, 2026
11 checks passed
@mergify
mergify Bot deleted the codex/w3-02c-restore branch October 4, 2026 22:14
@mergify

mergify Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 15 minutes 10 seconds in the queue, including 11 minutes 34 seconds running CI.

Required conditions to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-ok Pipeline: review disposition complete, no open high finding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant