Skip to content

test(windows): use a never-allocated PID for the pending-child recovery fixture - #7949

Merged
lidge-jun merged 1 commit into
devfrom
fix/windows-pending-dead-pid
Oct 29, 2026
Merged

lidge-jun merged 1 commit into
devfrom
fix/windows-pending-dead-pid

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

The dev lane=all batch 40824593871 failed on hosted Windows (job 123284678453): reconciliation publication failure fences: file-flush / harden / rename in tests/codex-integration/codex-cli-update-windows-pending.test.ts:124 (Expected: > 0, Received: 0). readback and flush passed in the same file, and the same cases passed in the previous batch. No source in the Codex CLI updater changed between the two batch heads.

The cause is in the fixture. beforeAll used the PID of a short-lived child as deadPid and assumed it stays dead for the whole file. Windows reuses PIDs quickly, and a busy runner can hand that PID to another process. The records use deadPid as the recovery parent, so a reused PID makes the parent look alive. Recovery then correctly fences admission before it reaches the publication step these cases inject into, injected stays 0, and the assertion fails. The product behaved correctly.

This uses 0x7ffffffc instead. It is a multiple of 4 like every Windows PID, inside the record validator's range (<= 0xffffffff), and far above anything Windows allocates, so it stays dead for the whole file. beforeAll asserts it reads as ESRCH, the same signal processGone uses. No assertion or product code changes.

Verification

Windows x64, OCX_TEST_NO_QUEUE=1:

  • Red, reproducing a reused PID by setting deadPid = process.pid: bun test tests/codex-integration/codex-cli-update-windows-pending.test.ts -t "reconciliation publication failure fences" gives 0 pass / 5 fail, each with Received: 0, the hosted symptom.
  • Green with this change: the full file passes 30 / 0.
  • bun run typecheck: exit 0. tests/ci-workflows/file-size-ratchet.test.ts: pass.
  • NOT RUN: hosted Windows. That runs only in the batched dev check after this lands.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. N/A: test fixture only.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. N/A: no product code changes.

Summary by CodeRabbit

  • Tests
    • Updated Windows x64 integration test coverage to check that probing a nonexistent process ID returns the expected not-found result. The test no longer launches a temporary process to obtain an ID for this check. These changes affect test coverage only; no end-user behavior has changed.

…ry fixture

A reused exited-child PID made the recovery parent look alive, so recovery fenced before the publication stage the failure-fence cases inject into (dev batch 40824593871).
@lidge-jun lidge-jun added the bug Something isn't working label Oct 29, 2026
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner October 29, 2026 06:23
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 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-10-29T06:24:45.467727Z e7017a9 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.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 26224ad and e7017a9.

Files selected for processing: 1
  • tests/codex-integration/codex-cli-update-windows-pending.test.ts

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

Walkthrough

The Windows pending-update test now uses a fixed PID and verifies that process.kill(pid, 0) reports ESRCH. It removes the spawnSync import and no longer starts a child process to obtain an exited PID.

Changes: Windows pending-update test

Layer / File(s) Summary
Set and verify an absent PID
tests/codex-integration/codex-cli-update-windows-pending.test.ts
The setup assigns 0x7ffffffc to deadPid and asserts that process.kill(deadPid, 0) throws with code ESRCH. It removes the spawnSync import previously used to obtain an exited child process PID.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related PRs

  • lidge-jun/opencodex#7648: Adds Windows CLI update recovery based on process and Job lifetime evidence. This test change supplies a fixed absent PID for the recovery-parent precondition.
  • lidge-jun/opencodex#7909: Adds pending-child recovery reconciliation and includes the Windows test file changed here. This test change makes the dead-parent precondition deterministic.

Suggested labels: chore

Suggested reviewers: ingwannu

Merge Risk: Minimal · up to e7017

This PR makes the Windows recovery test deterministic without changing product code or behavior.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "test(windows): use a never-allocated PID for the pending-child recovery fixture" matches the main change. The test fixture no longer uses a short-lived child's PID for deadPid. On native Wi…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "test(windows): use a never-allocated PID for the pending-child recovery fixture" matches the main change. The test fixture no longer uses a short-lived child's PID for deadPid. On native Windows x64 it now uses 0x7ffffffc, which is asserted to read as ESRCH. The objectives describe the same rationale: Windows PID reuse could make the recovery parent appear alive. The title is specific, concise, and single-sentence, and it uses the conventional type(scope) prefix.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • 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

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

@lidge-jun
lidge-jun merged commit b9fb2c7 into dev Oct 29, 2026
32 of 33 checks passed
@lidge-jun
lidge-jun deleted the fix/windows-pending-dead-pid branch October 29, 2026 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant