Skip to content

fix(events): reclaim provably-dead orphaned endpoint claims instead of failing permanently - #229

Merged
ScriptedAlchemy merged 1 commit into
mainfrom
fix/event-endpoint-orphan-lock-reclaim
Sep 1, 2026
Merged

fix(events): reclaim provably-dead orphaned endpoint claims instead of failing permanently#229
ScriptedAlchemy merged 1 commit into
mainfrom
fix/event-endpoint-orphan-lock-reclaim

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Summary

  • A process killed between claiming <endpoint>.lock and releasing it previously bricked the endpoint: every later startup hit EEXIST, exhausted the bounded retries, and failed until someone manually removed the undocumented lock file.
  • The claim now records owner identity (pid, plus /proc/<pid>/stat starttime on Linux) in the lockfile immediately after the exclusive open. On EEXIST with a non-live socket, a contender reclaims only when the owner is provably dead — ESRCH, or a live pid whose starttime mismatches (recycled pid, Linux) — deleting the orphan guarded by the same dev+inode identity check the release path already uses, then re-racing the wx open so exactly one contender wins.
  • Live claims are never stolen; empty/garbage/unverifiable lockfiles and non-Linux liveness ambiguity keep the existing fail-closed bounded-retry behavior. Identity and stat are read from a single file handle, so the reclamation guard can't act on a different file than the one whose contents were verified. No TOCTOU regression against the fix(events): claim the IPC endpoint atomically before removing stale sockets (#209 follow-up) #216 design.

Addresses the unresolved P2 Codex finding on #216 (packages/agent-bundle/src/events/ipc.ts claim retries).

Test plan

  • pnpm test:unit packages/agent-bundle/tests/event-ipc.test.ts — new coverage: killed-owner reclamation, live-owner fail-closed, garbage-lockfile fail-closed, recycled-pid reclamation (asserts the live child is untouched); 5 failures when the source fix is reverted
  • pnpm typecheck / pnpm lint clean

@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d02cffc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agent-bundle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 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-09-01T23:04:49.391366Z d02cffc 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.

@ScriptedAlchemy
ScriptedAlchemy merged commit 75d5c3d into main Sep 1, 2026
9 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the fix/event-endpoint-orphan-lock-reclaim branch September 1, 2026 23:02

@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: d02cffc339

ℹ️ 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 thread packages/agent-bundle/src/events/ipc.ts
Comment thread packages/agent-bundle/src/events/ipc.ts
ScriptedAlchemy added a commit that referenced this pull request Sep 1, 2026
…time endpoints (#101 stage 1) (#236)

* feat(doctor): read-only agent-bundle doctor for host installs and runtime endpoints (#101 stage 1)

* fix(doctor): report claim-owner liveness per the #229 reclaim semantics
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.

1 participant