Skip to content

fix(api): release finalize claims after failed acceptance - #331

Draft
SamGu-NRX wants to merge 2 commits into
gpt-burst/1022z-bs-auditfrom
gpt-burst/1022w2-pr327-claim-release
Draft

SamGu-NRX wants to merge 2 commits into
gpt-burst/1022z-bs-auditfrom
gpt-burst/1022w2-pr327-claim-release

Conversation

@SamGu-NRX

@SamGu-NRX SamGu-NRX commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

What changed

accept_packet now stores append-only generation claims under accepted_packet:<capture>:<generation>. Each claim records the packet digest, an owner token, and its claim time. A different digest gets 409 while the current generation is committed or younger than the five-minute recovery bound. The bound has no measurement behind it; it is an explicit crash-recovery limit.

Claims are never deleted. A durable committed marker is written after packet metadata and the capture or amendment record persist. An identical retry can finish a failed request, while a different packet can claim the next generation only after an uncommitted claim is stale.

The hostile tests cover a failed owner with an identical writer still active, cancellation and crash-style interruption, stale takeover, identical retry, and committed-generation retention.

Why

PR #331 deletes an uncommitted claim when a request fails. That lets a paused identical writer race with a later different packet. The later packet can overwrite the stored packet and metadata. Retaining generations prevents the failed owner from erasing the decision record.

How it works

flowchart TD
    A[Read generation 0] --> B{Same digest?}
    B -->|yes| C[Replay or complete]
    B -->|no, fresh or committed| D[409]
    B -->|no, stale and uncommitted| E[Claim generation 1]
    E --> F[Persist packet and metadata]
    F --> G[Write committed marker]
Loading

The generation claim is the durable decision record. Full write fencing is not included in this WIP and remains below.

UI changes

N/A. This changes the finalize API and its state records.

Verification

  • env -u NODE_ENV OMP_NUM_THREADS=1 uv run --frozen --extra api pytest server/api/tests/test_finalize_hostile.py -q passed: 15 tests.
  • env -u NODE_ENV OMP_NUM_THREADS=1 uv run --frozen --extra api pytest server/api/tests -q --ignore=server/api/tests/test_events_orchestrator_wake.py passed: 223 tests.
  • env -u NODE_ENV OMP_NUM_THREADS=1 uv run --frozen --extra api ruff check server/api/finalize.py server/api/tests/test_finalize_hostile.py passed.
  • ruff format --check passes after formatting the two changed files.
  • The complete API directory cannot collect because the copied environment lacks uvicorn for server/api/tests/test_events_orchestrator_wake.py.
  • The new interruption and inflight-writer tests fail on the old head 13e0989c because that head deletes the claim or leaves no claim after interruption. They pass on this commit.

Risk

Packet bytes and shared metadata are still written to un-fenced keys. A paused generation can write after a newer generation takes over. That fencing work is left for the lead because it needs a coordinated storage-key contract. The PR is a WIP until fencing is added.

Checklist

  • The scope is focused; related changes belong together
  • I explained what changed and why
  • N/A. No visible UI changed.
  • N/A. No motion or interaction changed.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the size:M 30-99 effective changed lines. label Oct 22, 2026
@SamGu-NRX

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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 ⚠️ Failed 2026-10-22T19:40:44.507217Z
We couldn’t complete this review. Comment @codex review to try again.
13e0989 Manual request
ℹ️ 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

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

size:M 30-99 effective changed lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant