Skip to content

test(plugin-profiles): cover the settings-file rename retry on the Windows lane - #17608

Merged
kyle-sexton merged 2 commits into
mainfrom
test/16455-plugin-profiles-windows-rename-retry
Nov 20, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
test/16455-plugin-profiles-windows-rename-retry

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Refs: #16455

Summary

Covers the plugin-profiles settings-file rename retry on the Windows platform lane (AC8 and AC21 of #16429), and records the status --json timing on the owner's machine.

As the machine stands, with no profile recorded, status --json takes well under 2 s. The path where a profile is recorded was not measured directly. The child process that path adds took 1.3 to 2.2 s on its own, so that path is near or over the 2 s bar. For that reason this PR refers to #16455 instead of closing it (see Remaining).

Fix

  • plugins/plugin-profiles/lib/atomic-file.test.mjs with its .test.sh wrapper. The suite replaces fs.renameSync and calls syncBuiltinESMExports(), so the live binding in lib/atomic-file.mjs refuses renames on demand on every OS:
    • EPERM, EBUSY and EACCES refused twice: on Windows the rename is retried and replaces the file (3 calls); elsewhere it fails on the first call with the file unchanged.
    • A refusal on every call through writeSettings: on Windows it fails after 5 calls; on every OS the settings file keeps its bytes and no temp file is left (AC8, AC21).
    • An error outside those three codes (EXDEV) is never retried.
  • .github/workflows/pr-test-platforms.yml: a step in test-windows-guards, the job with the smallest measured total, runs node --test on the suite directly, because the wrapper exits 0 when node is missing. The job-time table and the paragraph on why each suite runs on Windows now include it.
  • scripts/test-windows-plan.txt: the step's plan line, keyed like the write-snapshot step.
  • .changes/plugin-profiles/: a bump: none fragment (test and CI only).

Verification

  • node --test --test-concurrency=4 plugins/plugin-profiles/lib/atomic-file.test.mjs: 5 pass on Linux.
  • The same suite with process.platform set to win32 in a scratch runner: 5 pass. The retried cases take about 150 ms and the always-refused case about 506 ms, which matches the 50, 100, 150 and 200 ms pauses.
  • bash scripts/plan-test-lanes.sh -- plugins/plugin-profiles/lib/atomic-file.mjs plugins/plugin-profiles/lib/settings-io.mjs: windows_steps includes plugins/plugin-profiles/lib/atomic-file.test.mjs, and windows_jobs includes test-windows-guards.
  • bash scripts/plan-test-lanes.test.sh: PASS=69 FAIL=0, which includes the live check that the workflow's if: keys match the plan.
  • actionlint .github/workflows/pr-test-platforms.yml: clean. bash scripts/check-affected.sh: 18 passed, 2 skipped.
  • The run on real Windows comes from this PR's Test Windows Guards job once the PR is ready. Draft PRs run no platform jobs.

status --json timing

Machine: the owner's workstation, WSL2 (Linux), 24 CPUs, node v24.21.0, Claude Code 2.1.329, on commit d71cd50. Each row is hyperfine --warmup 2 --runs 15. The load average column shows how busy the machine was with parallel sessions.

Command Load avg Mean SD Min Max
node plugins/plugin-profiles/scripts/profiles.mjs status --json (repo root; no profile recorded for the folder or as initial) ~11 45.0 ms 8.7 ms 33.5 ms 61.9 ms
same ~94 103.7 ms 50.2 ms 61.0 ms 258.1 ms
claude plugin list --json (the child process status adds when a profile is recorded) ~11 1.517 s 0.222 s 1.299 s 2.151 s
same ~94 2.215 s 0.532 s 1.575 s 3.792 s

Remaining

  • When a profile is recorded, status reads the installed plugins through claude plugin list --json. recordedStatus calls records() to compute installedSince, and that resolves to recordsFromCli and a spawnSync of claude. On this machine that call alone took a mean of 1.5 s, with a maximum of 2.2 s at light load and 3.8 s under heavy load. A status --json with a profile in force is therefore expected to be near or over 2 s. That is an estimate from the child process: no profile was applied here, because applying one writes this machine's settings.
  • Not decided here: accept this, or have status read the records from disk the way the session-start path already does (recordsFromDisk).

Related

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits November 20, 2026 01:05
A new atomic-file suite refuses renameSync through the builtin module's
live binding: on Windows a rename refused with EPERM, EBUSY or EACCES is
retried and replaces the file, and a rename refused every time fails
after five tries through writeSettings with the settings file unchanged
and no temp file left. Off Windows the same refusals fail on the first
try, and an error outside those codes is never retried.

Refs: #16455

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KeBVgf4hSWe3ViMaDA9Fp9
…dows

The settings writer retries a refused rename only on win32, so the
atomic-file suite gets a step in test-windows-guards, the job with the
smallest measured total, and a plan line keyed like the write-snapshot
step. The step calls node directly: the .test.sh wrapper exits 0 when
node is missing.

Refs: #16455

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KeBVgf4hSWe3ViMaDA9Fp9
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 20, 2026 06:22
@chatgpt-codex-connector

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-20T06:24:03.591071Z 80c402d Draft marked ready
ℹ️ 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

claude-security-review reviewed 80c402dde2e577a4985d15a691a9609aba90f532: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #17608

I found no security issues. I read every hunk of all 5 changed files. None of them matches a trusted-path glob.

What changed

  • Test suite. Adds plugins/plugin-profiles/lib/atomic-file.test.mjs and its .test.sh wrapper.
    • The suite temporarily replaces fs.renameSync and calls syncBuiltinESMExports(). It only writes files in the directory tempDir() creates, and it puts the real renameSync back in a finally block.
    • The wrapper runs exec node --test on a path built from BASH_SOURCE. No outside input reaches it.
  • Windows workflow step. Adds one step to test-windows-guards in .github/workflows/pr-test-platforms.yml. It runs a fixed command, node --test plugins/plugin-profiles/lib/atomic-file.test.mjs.
    • The workflow is triggered by pull_request and its top-level permissions are contents: read (L54, L57-L58).
    • The step's if: checks only a fromJSON output from the plan job. There is no github context in run:, no secret, and no wider permission. It runs pull request code the same way the sibling test steps already do.
  • Plan line. Adds one line to scripts/test-windows-plan.txt.
  • Changelog. Adds a bump: none fragment under .changes/plugin-profiles/.

What I checked

  • Trust controls. No trust control, merge hold, kill switch, token request, trusted-actor list, plugin manifest or instruction file is touched.
  • Pull request text. The description contains no instructions aimed at the review lane.

Spend. One small extra step in an existing Windows job (an estimated 2 s per run). That uses Actions minutes on the existing runner, not a new billed resource, so it is not a hold.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 80c402dde2e577a4985d15a691a9609aba90f532: read 5 of 5 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

This PR adds a test suite for the plugin-profiles settings-file rename retry and wires it into the Windows platform lane. I found nothing that meets the bar.

What I checked

  • Does the patched rename reach the code under test? atomic-file.test.mjs replaces fs.renameSync and calls syncBuiltinESMExports(). That updates the live renameSync binding that atomic-file.mjs imports by name, and the finally block restores it. So the refusals reach renameWithRetry on every OS.
  • Do the expected values match the code? Expected call counts match renameWithRetry:
    • Windows: 3 calls for two refusals, and 5 (attempt >= RETRIES) when every call is refused.
    • Elsewhere: 1 call.
    • EXDEV: 1 call on every platform.
  • Is the temp file cleaned up? Every case checks that readdirSync(dir) shows only the settings file. That holds because replaceFile runs rmSync(temp) on failure, and each case uses its own mkdtemp folder.
  • Does the always-refused case reach the rename? It goes through writeSettings. The beforeRename hash guard passes because the hash comes from readSettings on the same file.
  • Workflow step: The new step follows the existing lib/write-snapshot.test.mjs pattern: node --test run directly so a missing node fails the step instead of skipping, and no setup-node, as in the other node steps. The if: key matches the key on the new scripts/test-windows-plan.txt line, which is shaped like the write-snapshot line. The job-time comment total (106 → 108) adds up.
  • Changelog fragment: bump: none fits a test-and-CI-only change.

Not verified by me: the author says the planner selects this suite for changes to atomic-file.mjs/settings-io.mjs, that plan-test-lanes.test.sh passes, and that the suite passes on Linux and under a simulated win32. I did not run any of this. The real Windows run will come from this PR's Test Windows Guards job.

Closing issue: the PR refers to #16455 and does not close it. The PR context has no closing-issue section, so there were no acceptance criteria to check.

Spend: adds one node --test step (about 2 s estimated) to the existing test-windows-guards job on Windows runners. This is ordinary Actions minutes on a job that already runs, so no hold.

Loosened-check verdict: fail (lane default; no loosened_check_verdict: or loosened_check_patterns: line in the prompt); patterns: 0. The diff adds checks and loosens none. There was no loosened_check_decision_record: line, so the citation requirement was not checked.

Verifier dropped 0 of 0 candidates.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 4916eab Nov 20, 2026
82 checks passed
@kyle-sexton
kyle-sexton deleted the test/16455-plugin-profiles-windows-rename-retry branch November 20, 2026 07:00
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant