Skip to content

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

Closed

Description

@dezren39

Problem

Codex review of PR #5349 (record copy of the live-applied session-binding migration for issue #5001, now pm-stack/opencode-claimant/migration-0023.sql) raised two P2 findings against the live-applied function bodies. The record copy must stay byte-faithful to what was applied live, so these are fixed by a new migration, not by editing the record.

Findings (chatgpt-codex-connector[bot] on PR #5349)

  1. Bind lock-order deadlock — bind_repo_task_lane_session updates the lane ledger before locking the task row, while the new binding-clearing transitions lock the task row first. A same-session bind retry overlapping park_task or another clearing transition can deadlock and abort either operation. Fix: acquire the task row FOR UPDATE before accessing the ledger in the bind function. (PR opencode-claimant: migration-0022 — clear bound session_id on requeue + bind-time claim guard (#5001) #5349 review comment 4465191796, migration file line ~425.)
  2. Unqualified task_id in the revalidate release branch — revalidate_parked_tasks() declares RETURNS TABLE(task_id bigint, outcome text), so the unqualified task_id reference in the release branch is ambiguous under PL/pgSQL's default variable-conflict handling and can error, rolling back the whole sweep. Fix: alias the ledger table and qualify its task_id column. (PR opencode-claimant: migration-0022 — clear bound session_id on requeue + bind-time claim guard (#5001) #5349 review comment 4465191807, migration file line ~387.)

Acceptance

  • A new claimant migration (next free number) fixes both findings against the current live function bodies (re-extract live defs first; do not trust the record copy alone).
  • Lock order is consistent across bind + every binding-clearing transition.
  • The revalidate release path is exercised with a parked task that still carries progress.session_id (the ambiguous branch) and completes without error.
  • Applied live with before/after verification, and the record copy lands via PR referencing this issue.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    queue/queuedHas a queued task in the Supabase agent queue
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 4, 2026
  2. added a commit that references this issue on Nov 4, 2026
  3. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    event: done
    task: task 9348 (repo-health-code-pilot; worker repo-worker-code; lane code-g)
    by: repo-worker-code (lane code-g shift)
    at: 2026-11-04T10:47:00Z
    state: done — fixed_merged
    verified: migration-0024 applied LIVE (agent schema) with pg_get_functiondef before/after diff showing only the two intended changes; the revalidate release path reproduced the 42702 ambiguity error before the fix and completed after it (rolled-back synthetic exercise, no residue); record copy PR #5399 MERGED (99b158c), closing this issue. Both Codex findings on PR #5349 replied to (4466495641, 4466494617). Codex finding on PR #5399 (recovery mode) dispositioned on its thread (4466525721): the recovery branch was dropped by migration-0023, not 0024 — restoration filed as #5400.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working (prefixed form of the classic bug label)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions