Skip to content

Release review hook locks when the owner exits - #159

Merged
CNSeniorious000 merged 1 commit into
mainfrom
fix/review-hook-lock
Nov 22, 2026
Merged

CNSeniorious000 merged 1 commit into
mainfrom
fix/review-hook-lock

Conversation

@CNSeniorious000

@CNSeniorious000 CNSeniorious000 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

An interrupted delivery leaves the directory lock behind and blocks every later hook.

Use Bun's built-in SQLite writer lock, which the OS releases when its owner exits, with a five-second contention timeout. The same process owns the lock, writes hook output, and records receipts; its jq child only computes into a captured pipe. Killing the owner cannot leave a child publishing after the lock is released.

The jq event filter from the base is moved unchanged into its own file; all 73 lines match byte-for-byte after removing the shell indentation. Legacy lock directories are ignored, and a failed output or lock timeout leaves activity replayable. This avoids PID/age-based lock deletion and adds no package dependency.

Validation:

  • Eight focused regressions pass: normal/legacy-directory concurrency, SIGTERM, SIGKILL, competing recovery, orphan-child isolation, failed output, and live-owner timeout.
  • Full suite on the exact PR commit: 369 passed, zero failed on native Ubuntu. The credential-refresh timeout seen locally does not reproduce there.
  • Native Ubuntu, macOS, and Windows validation: five tests and 94 assertions pass on each runner.

Fixes #158.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-22T19:12:05.597650Z
We couldn’t complete this review. Comment @codex review to try again.
7d369c6 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Replaces the mkdir lock in the review hook with a SQLite BEGIN IMMEDIATE writer lock. The lock releases on process exit and uses a 5-second busy timeout. Adds scripts/review-hook.mjs to handle the lock, delivery, and receipts. Moves the jq event filter unchanged into scripts/review-hook.jq. Reduces scripts/review-hook.sh to a delegate. Adds tests for legacy lock directories, owner termination, and lock timeout. The author reports the new tests and the full suite pass. Native Linux, macOS, and Windows validation is not available.

The shell hook now delegates event processing to a Bun script. The script uses a SQLite transaction to serialize deliveries and invokes a jq processor that filters events, builds context, and removes duplicate deliveries. It emits hook responses and updates delivery records. Tests cover parallel hooks, terminated lock owners, and lock timeouts followed by retry.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: Minimal · up to 7d369

This change replaces the directory lock in the review hook with a SQLite writer lock that is released when its owner process dies, so an interrupted delivery should no longer block later hooks. The tests cover concurrent, killed-owner, and timeout cases. One residual uncertainty remains: how Codex behaves if a final Stop hook times out while another delivery holds the lock. It is not established as a defect and does not block merging.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Out of Scope Changes check Inconclusive The PR description says the jq event filter moved unchanged into scripts/review-hook.jq. That file is new (+74 lines). It contains logic the description does not mention: subscription-recovery instr… Provide readable base content for scripts/review-hook.sh (or its diff) to confirm that the jq filter was moved without behavior changes. If the added jq behaviors are new, the PR description should state them and their link to #158.
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: the review hook delivery lock is released when its owner exits. The changeset replaces the directory lock with a Bun SQLite writer lock that the OS releases on owner e…
Linked Issues check Passed Objective [#158]: after a killed hook, a later hook must not block indefinitely, and delivery must stay serialized. The PR summary says scripts/review-hook.mjs takes a SQLite BEGIN IMMEDIATE write…
Description check Passed The description states the PR's purpose: an interrupted review-hook delivery leaves a directory lock that blocks later hooks. It says the change uses Bun's built-in SQLite writer lock with a five-seco…
Full details: Title check

Explanation

The title names the main change: the review hook delivery lock is released when its owner exits. The changeset replaces the directory lock with a Bun SQLite writer lock that the OS releases on owner exit, which matches the title.

Full details: Linked Issues check

Explanation

Objective [#158]: after a killed hook, a later hook must not block indefinitely, and delivery must stay serialized. The PR summary says scripts/review-hook.mjs takes a SQLite BEGIN IMMEDIATE write lock with a 5-second busy timeout. SQLITE_BUSY becomes a delivery-lock timeout error. The OS releases the lock when its owner exits, so no stale-lock deletion is needed. This meets the issue's bounded-wait and serialization requirement. The legacy $RUNNER_TEMP/injected-deliveries.lock directory is ignored, so the issue repro no longer blocks. The PR reports SIGTERM, SIGKILL, competing-recovery, and live-owner-timeout regressions. I did not run these tests; this verdict relies on the summary and PR description. Stack: this PR is the only member with review evidence. No other stack objective applies. Objective status: Addressed.

Full details: Description check

Explanation

The description states the PR's purpose: an interrupted review-hook delivery leaves a directory lock that blocks later hooks. It says the change uses Bun's built-in SQLite writer lock with a five-second timeout, moves the jq filter into its own file, ignores legacy lock directories, and lists validation runs. This matches the changeset (scripts/review-hook.mjs, review-hook.jq, review-hook.sh, and events.test.ts) and the linked issue #158. The description is specific and on-topic.

Full details: Out of Scope Changes check

Explanation

The PR description says the jq event filter moved unchanged into scripts/review-hook.jq. That file is new (+74 lines). It contains logic the description does not mention: subscription-recovery instructions, workflow-run and check-suite correlation, bot and writer filtering, repository-relative URL rewriting, and 200/2,000-character clipping of edited PR titles and bodies. The diff for scripts/review-hook.sh (-96 lines) could not be read, and the base blob for that file is unavailable. So I cannot confirm that the jq content is unchanged from the removed shell logic, or that the added behavior was previously present. I found no demonstrated unrelated change. The lock, delivery, and receipt changes in review-hook.mjs and the tests match #158.

Resolution

Provide readable base content for scripts/review-hook.sh (or its diff) to confirm that the jq filter was moved without behavior changes. If the added jq behaviors are new, the PR description should state them and their link to #158.

Finishing Touches

Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c7a70868-9ad8-405b-843f-0e5ea6d14205
Commits

Reviewing files that changed from the base of the PR and between b5b38f2 and 7d369c6.

Files selected for processing: 4

  • scripts/events.test.ts
  • scripts/review-hook.jq
  • scripts/review-hook.mjs
  • scripts/review-hook.sh

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@CNSeniorious000
CNSeniorious000 merged commit 34fc7a2 into main Nov 22, 2026
8 of 11 checks passed
@CNSeniorious000
CNSeniorious000 deleted the fix/review-hook-lock branch November 22, 2026 19:44
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.

recover the review hook lock after a killed delivery

1 participant