Avoid rewriting Phase 2 selection on clean workspace#19812
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2fc7a2bfb4
ℹ️ 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".
| job::succeed_preserving_selection( | ||
| session, | ||
| db, | ||
| &claim, | ||
| new_watermark, | ||
| &raw_memories, | ||
| "succeeded_no_workspace_changes", | ||
| ) | ||
| .await; |
There was a problem hiding this comment.
Rebuild selection snapshot before clean-phase2 finalize
This clean-workspace path now skips rewriting stage1_outputs.selected_for_phase2. After migrations 0017/0018, existing rows default to 0/NULL; if Phase 2 is clean, the snapshot never gets repaired. Code that depends on this flag (mark_thread_memory_mode_polluted enqueue and retention pruning) can then treat baseline rows as unselected, causing missed forgetting runs or pruning of active baseline memories.
Useful? React with 👍 / 👎.
Why
Phase 2 can now claim the global consolidation lock on startup even when the git-backed memory workspace is already clean. The clean-workspace path still finalized through the normal Phase 2 success path, which clears and re-marks
selected_for_phase2rows. That made no-op startups perform avoidable writes tostage1_outputs, creating unnecessary DB I/O and contention when no memory files changed.What Changed
codex-statethat only marks the global job row as succeeded.mark_global_phase2_job_succeededbehavior for real consolidation runs, where the selected Phase 2 snapshot must be rewritten.succeeded_no_workspace_changesbranch incore/src/memories/phase2.rsto use the preserving-selection finalizer.stage1_outputsand verifies the clean finalizer performs zero updates there.Testing
cargo test -p codex-statecargo test -p codex-core memories::tests::phase2