Repository navigation
fix(opencode-claimant): migration-0026 restores guarded lane-session recovery (#5400) - #8384
Conversation
…recovery (#5400) migration-0023/0024 record copies dropped the migration-0022 recovery modes from bind_repo_task_lane_session, so the claimant recovery operation in prompt.md (invoked only after lease expiry) was rejected by the live-lease guard. migration-0026 merges the two reserved recovery modes back into the migration-0024 definition: task-row-first locking preserved, normal bind unchanged, recovery compare-and-clears the prior session id against both stores, consumes one attempt, and requires an expired lease. Focused tests: test/test_migration_0026.sh (scratch Postgres, 8 scenarios).
|
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 17 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. |
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e02e786759
ℹ️ 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".
| update agent.tasks | ||
| set attempts = coalesce(attempts, 0) + 1, | ||
| progress = coalesce(progress, '{}'::jsonb) |
There was a problem hiding this comment.
Restore launch eligibility when clearing a recovered binding
For tasks recovered through this PostgreSQL function, recovery requires an expired lease but this update leaves that lease unchanged. The recovered task therefore becomes an unbound launch_failed candidate that cannot pass the normal-bind live-lease guard at lines 127–129. In claimant.py, launch_step does not renew or reclaim these claimed candidates before binding; it creates a replacement session, encounters the bind failure, and deletes the replacement without prompting it. Restore a valid claim/lease transition as part of recovery or before relaunch, and cover recovery followed by a normal bind in the tests; the current isolated recovery assertions miss this failure.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Disposition: not a defect in this migration — launch eligibility is restored by the broker's expiry/collection transition, not by the bind call, and the sequence is now covered by a test (scenario S9, head 892b99a).
Evidence from the live system this record mirrors:
- The recovered row (claimed, expired lease, progress lane opencode + stage launch_failed) is exactly the broker's handoff shape. expire_leases in pkgs/fleet/crates/fleet-queue/src/turso_queue.rs returns such rows to the handoff sink on expiry, and the claimant collects sink candidates with claim --handoff — a fresh claim with a new live lease — before launch_step launches and binds. launch_step binds claimed candidates directly only when they were just collected that way; a resting launch_failed row reaches it via the sink, never with the expired lease still attached.
- poll.py documents the same contract: stage launch_failed is a launch-safe yield precisely because recovery atomically cleared both bindings; relaunch happens after collection.
- The live verb_bind renews nothing: it has the same live-lease guard and no lease mutation, so adding lease renewal inside the PostgreSQL recovery branch would make this record diverge from the live contract it copies.
What changed in response to the finding: the migration-0026 header now documents this eligibility path explicitly, and test/migration-0026.test.sql gains scenario S9 — recovery, then the expiry/collection transition under a fresh claim lease, then a normal bind of the replacement session succeeds against both stores. All 9 scenarios pass (test/test_migration_0026.sh, scratch Postgres).
… eligibility path (Codex P2 on #8384)
|
🤖 Agent note · shepherd review — merging (task 10895, issue #5400)
|
Fixes #5400. Queue task 10895.
What
Adds pm-stack/opencode-claimant/migration-0026.sql: migration-0024's bind_repo_task_lane_session definition with the migration-0022 guarded recovery modes restored ahead of the normal-bind guard. The 0023/0024 record copies had dropped the recovery branches, so the claimant recovery operation documented in prompt.md — invoked only after lease expiry — was rejected by the function's own claimed + live-lease guard.
Note on numbering: the packet for task 10895 named this migration 0025, but 0025 was taken on main by the #5444 claim-payload fix after the packet was written, so the fix lands as 0026.
Decisions
Tests
test/test_migration_0026.sh spins up a scratch Postgres (socket-only, removed on exit), applies a minimal agent schema, migration-0026, and 8 asserted scenarios in test/migration-0026.test.sql: both recovery reasons clear both stores and consume an attempt; mismatch refusal leaves both stores unchanged; live-lease recovery refused; non-claimant recovery refused; attempts-exhausted refused; normal live-lease bind binds both stores; normal expired-lease bind refused. Result: all 8 scenarios passed on the laptop.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.