Allow Phase 2 memory claims after retry exhaustion (#19809)

## Why

The Phase 2 memories job row is only the global lock for the git-backed
memory workspace. Manual memory edits do not enqueue new Stage 1 work,
so a Phase 2 row with `retry_remaining = 0` could be skipped before the
worker ever claimed the lock and generated `phase2_workspace_diff.md`.

That left workspace-only changes unconsolidated after repeated failures,
even when retry backoff had elapsed and the filesystem had real diffable
work.

## What Changed

- Allow `try_claim_global_phase2_job` to claim the Phase 2 lock after
the retry budget is exhausted, while still respecting active `retry_at`
backoff and fresh running leases.
- Treat `SkippedRetryUnavailable` for Phase 2 as backoff-only, and
update the outcome docs to match.
- Clamp Phase 2 retry bookkeeping at zero when failed attempts are
recorded.

## Verification

- Added
`phase2_global_lock_can_be_claimed_after_retry_budget_is_exhausted` to
cover the exhausted-budget lock claim path.
- Ran `cargo test -p codex-state`.
This commit is contained in:
jif-oai
2026-04-27 14:58:11 +02:00
committed by GitHub
parent 01ab25dbb5
commit 5d314f324c
2 changed files with 76 additions and 13 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ pub enum Phase2JobClaimOutcome {
/// Snapshot of `input_watermark` at claim time.
input_watermark: i64,
},
/// The global job is in retry backoff or has exhausted its retry budget.
/// The global job is in retry backoff.
SkippedRetryUnavailable,
/// Another worker currently owns a fresh global consolidation lease.
SkippedRunning,