Skip to content

opencode-claimant: migration-0024 — fix Codex P2s in live session-binding functions (#5393) - #5399

Merged
dezren39 merged 1 commit into
mainfrom
queue/9348-5393-claimant-codex-p2s
Nov 4, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/9348-5393-claimant-codex-p2s

Conversation

@dezren39

@dezren39 dezren39 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Fixes #5393

Record copy of migration-0024, already applied live to the fleet Supabase project (agent schema) with before/after verification, fixing the two Codex P2 findings raised on PR #5349 against the live session-binding functions:

  1. Bind lock order (PR opencode-claimant: migration-0022 — clear bound session_id on requeue + bind-time claim guard (#5001) #5349 comment 4465191796): bind_repo_task_lane_session now locks the task row FOR UPDATE in its first statement, before accessing the lane ledger — consistent with every binding-clearing transition in migration-0023 (expire_leases, fail_repo_task, park_task, claim_repo_task, revalidate_parked_tasks all take the task row before the ledger; verified by inspection of migration-0023.sql).
  2. Unqualified task_id (PR opencode-claimant: migration-0022 — clear bound session_id on requeue + bind-time claim guard (#5001) #5349 comment 4465191807): the release branch of revalidate_parked_tasks now aliases agent.repo_task_lane_ledger as l and qualifies l.task_id.

Verification (2026-11-04, task 9348)

  • Bodies built from the live definitions re-extracted with pg_get_functiondef (they matched the migration-0023 record copy exactly).
  • Before: the release path reproduced live in a rolled-back transaction with a synthetic parked task carrying progress.session_id — ERROR 42702: column reference "task_id" is ambiguous at the ledger update, aborting the whole sweep. No residue after rollback.
  • After: pg_get_functiondef diff before/after shows only the two intended statement changes; the same rolled-back exercise now completes — the synthetic task is released to queued and its ledger session_id is cleared. No residue after rollback.
  • migration-0023.sql record copy untouched, per the packet exclusion.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 4, 2026 10:41
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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 32 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6f802e79-2926-4c54-8db4-7af50a2a1856
Commits

Reviewing files that changed from the base of the PR and between a133165 and a355040.

Files selected for processing: 1
  • pm-stack/opencode-claimant/migration-0024.sql
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 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-11-04T10:44:16.806731Z a355040 PR opened
ℹ️ 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: a355040c99

ℹ️ 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 +145 to +148
if t.status <> 'claimed' or t.lease_until is null or t.lease_until <= now() then
raise exception 'bind_repo_task_lane_session: task % is not claimed with a live lease (status %, lease_until %)',
p_task_id, t.status, t.lease_until;
end if;

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 Preserve the guarded recovery mode from migration 0022

Applying this migration after the repository's migration-0022.sql replaces its guarded recovery implementation with a function that rejects expired leases and no longer handles either reserved recovery launched_by value. The claimant's prompt.md steps 1c–1d explicitly invoke those recovery operations after lease expiration, so both now raise instead of atomically clearing the bindings and recording the recovery attempt. This leaves deleted or vanished sessions bound and prevents the documented relaunch flow. Preserve migration 0022's recovery branch while applying the lock-order fix.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Disposition: real defect, wrong migration — not fixed in this PR, filed as #5400 with the evidence.

Verified live during task 9348: the recovery branch was dropped by migration-0023, not by this migration. The migration-0023 record copy (PR #5349) contains zero recovery references, and the live pg_get_functiondef extracted before migration-0024 was applied matched the 0023 body exactly (live probe: has_recovery=false; single 4-arg overload). Migration-0024 was built byte-faithfully from that live body per #5393's acceptance ("fixes both findings against the current live function bodies") and changes only the lock order — restoring recovery inside 0024 after it was already applied live would make this record copy unfaithful to what is running.

The underlying problem is real: prompt.md steps 1c-1d recovery calls raise against the current live function. It is filed as #5400 with a fix shape (new migration merging the 0022 recovery branch + 0023 claim guard + 0024 lock order, exercised in a rolled-back transaction).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode-claimant: fix Codex P2s in the live session-binding functions (bind lock order, revalidate task_id qualification)

1 participant