Skip to content

test(windows): cover the snapshot refresh-read owner cutoff - #8967

Merged
lidge-jun merged 1 commit into
devfrom
test/snapshot-refresh-cutoff
Nov 19, 2026
Merged

lidge-jun merged 1 commit into
devfrom
test/snapshot-refresh-cutoff

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Follow-up to #8965, covering the gap its review found (P3). #8965 stops owner reads in the Windows process snapshot once the helper reaches the enumeration cap's owner cutoff. It checks that cutoff before each GetOwnerSid call and again before the refresh read that follows it. The existing cap-reached case only tests the first check: removing the cutoff from the refresh check left every test green.

This adds a cap-during-owner case to the real-PowerShell owner-enrichment test. The mocked Invoke-CimMethod moves the cutoff into the past while the first owner read is in flight. The snapshot must keep all 40 rows, make exactly one owner read, and make no refresh read. The case is deterministic, with no sleeps or timing assumptions. Test-only; no runtime change.

Verification

  • With portable PowerShell 7.7.0 on macOS, bun test tests/windows/windows-process-evidence.test.ts: 13 pass, 3 skip (native-Windows cases), 0 fail.
  • Mutation: removing -or [DateTime]::UtcNow -ge $ownerBudget.Until from the refresh check in src/service/windows-process-evidence.ts fails the new case (budget=cap-during-owner, expected 0 refresh reads, received 1).
  • Also re-confirmed fix(windows): keep snapshot owner reads inside the enumeration cap #8965's own regression on this host: the pre-fix(windows): keep snapshot owner reads inside the enumeration cap #8965 source fails cap-reached with 32 owner reads instead of 0.
  • bun run typecheck, structure:check, the file-size ratchet and test-layout pass.
  • NOT RUN: Windows PowerShell 5.1 and native Windows (Windows shards run in the dev batch); the full local suite.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (Test-only; none needed.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (Test-only.)

Summary by CodeRabbit

  • Tests
    • Expanded Windows process evidence test coverage for budget cutoffs that expire during owner reads. The tests now verify that the read count reflects when the cutoff occurs and that no additional refresh read starts after the budget is exhausted.

Follow-up to #8965: the cap-reached case only exercised the cutoff before each owner read. The new cap-during-owner case moves the cutoff into the past during the first owner read and requires no refresh read.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 19, 2026 17:36
@lidge-jun lidge-jun added the ci:full Run the four full Ubuntu test shards on this pull request label Nov 19, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T17:37:47.713215Z 972912f 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.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Windows process evidence test adds the cap-during-owner budget case. It verifies that the first owner read occurs and no refresh read starts after the cutoff expires.

Changes: Owner cutoff test coverage

Layer / File(s) Summary
Test cutoff during owner read
tests/windows/windows-process-evidence.test.ts
Lines 243–257 add cap-during-owner to the shared scenarios and budget type. Line 273 moves the cutoff into the past during the first owner read. Line 292 expects one owner read for this case, matching expires-during-owner.

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

Change: Other

Possibly related PRs

Merge Risk: Minimal · up to 97291

This adds a test for the owner cutoff expiring during the first owner read. It does not change runtime behavior, so the production impact is negligible and the change is ready to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "test(windows): cover the snapshot refresh-read owner cutoff" matches the main change. The PR adds a cap-during-owner test case to the Windows process owner-enrichment test. That case checks…
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): cover the snapshot refresh-read owner cutoff" matches the main change. The PR adds a cap-during-owner test case to the Windows process owner-enrichment test. That case checks that the owner cutoff expiring during the first owner read stops the refresh read. The title names the Windows scope, the test-only nature, and the refresh-read cutoff behavior. It is concise, specific, and uses a conventional commit prefix. It does not mention the single owner read or the 40-row retention, which is acceptable because the title need not cover every detail.

Finishing Touches

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6a4ae9d and 972912f.

Files selected for processing: 1

  • tests/windows/windows-process-evidence.test.ts

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

@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer integration (lidge-jun, dev only) at head 972912f5c2. Test-only follow-up to #8965, covering its review's P3. A deterministic cap-during-owner case in the real-PowerShell owner-enrichment test moves the owner cutoff into the past during the first owner read and requires no refresh read, so it guards the refresh-read cutoff at windows-process-evidence.ts:133. Same-reviewer MERGE-OK via continueFrom, run with portable PowerShell 7.7.0: head 13 pass, 3 skip; removing the refresh cutoff fails cap-during-owner; removing the owner-read cutoff fails cap-reached; pre-#8965 source fails cap-reached with 32 owner reads. Held until the 2.100.6 release from 6a4ae9d6e1 was published, per coordinator. Union guards: dev is still at 6a4ae9d6e1, this PR's base, so the merge result is this head. Typecheck (2,666 files), structure:check, file-size ratchet and test-layout pass. Exact-head PR CI green (ci:full). NOT RUN: Windows PowerShell 5.1 and native Windows (next dev batch).

@lidge-jun
lidge-jun merged commit bee796f into dev Nov 19, 2026
37 of 39 checks passed
@lidge-jun
lidge-jun deleted the test/snapshot-refresh-cutoff branch November 19, 2026 21:13
luvs01 added a commit to luvs01/opencodex that referenced this pull request Nov 20, 2026
Combine the process-start reserve from lidge-jun#8965 and its lidge-jun#8967 refresh regression with the early snapshot and the enumeration-inclusive owner budget. Check both cutoffs after the refresh before accepting owner evidence.

Verified on Windows x64 with Bun 1.4.4: 74 Windows stop tests, two related service tests and 29 layout tests passed. Typecheck covered 2,681 files. The structure check and diff check passed. The full suite was omitted for this scoped conflict resolution during shared Windows validation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). ci:full Run the four full Ubuntu test shards on this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant