You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(config): hold a racing uninstall to its guarantee whatever its outcome (#8379) - #8876
tests/config/config-ownership-concurrent-record.test.ts failed intermittently ("a registration racing uninstall ... with its first run finding the lock still held", Windows dev batch run 44072572278, job "windows 7/14"): a child exited 0 after recording its path, yet the path still existed. The test asserted that every recorded path was removed before it looked at the uninstall's status, so any first run that did not reach removal failed at that line. Besides the busy-lock refusal that #8822 already retries, two such outcomes exist:
A refusal for another reason, before the tombstone. On Windows, opening a file while another process renames over it can fail with EPERM, so uninstall's unlocked metadata check (src/lib/config-ownership.ts:881) can refuse a valid home as "missing or invalid" while a child is replacing the manifest under the lock. The child's registration then succeeds.
A partial run that stopped while removing its snapshot (src/lib/config-ownership.ts:943), which names only the entry it failed on.
Neither loses a registration. The refused run writes nothing, the partial run leaves its tombstoned manifest, and in both the recorded path stays listed, so the next run removes it. The product keeps its guarantee; the test's outcome model was incomplete. There is no src/ change.
settleRacingUninstall checks the guarantee for every outcome. A recorded path is either removed, or the run was refused (no tombstone, whole home reported) or partial and the manifest still lists the path. In that case the test reruns uninstall after the race, as a user would, and the rerun must remove it. A path that was never recorded must be a residual path of the run that retired the metadata. Failure messages now carry the uninstall result and the child exit codes, which the failing CI log did not have.
Four forced cases pin each outcome in order using the file's existing hooks: registrations before, during (step hook inside the lock hold) and after the run; a registration after a refusal by a busy lock; one after a refusal by unreadable metadata (stand-in for the Windows open failure; POSIX non-root only); and one behind a removal stopped by an unwritable directory (POSIX non-root only).
structure/config-ownership.md lists the new coverage.
Which of the two outcomes the Windows job hit is inferred: the failed job logged no uninstall result. If it fails again, the message will name it. A possible follow-up, outside this PR: on Windows a concurrent registration can make ocx uninstall print a transient, misleading "missing or invalid" refusal for a valid home (nothing is lost; a rerun works).
Regression proof: with the old assertions put back into a temporary copy of the file, the three refused/partial forced cases fail with the CI symptom (expect(existsSync(path)).toBe(false), Expected: false, Received: true). The before/during/after case and both racing cases pass.
Non-vacuity: making the manifest write for the racing paths a no-op fails both racing cases and all three regression cases.
Loops of 50 runs of the file on Linux, 4 vCPU: origin/dev version 50/0 idle and 50/0 under load (nproc+2 busy loops, load average about 8); this branch 50/0 idle and 50/0 under load. The origin/dev version does not fail on Linux, consistent with a Windows-only trigger.
bun test tests/config/config-ownership-concurrent-record.test.ts on the rebased head: 64 pass, 0 fail.
bun test tests/config/config-ownership-removal.test.ts tests/config/config-ownership-uninstall.test.ts tests/config/config-ownership-concurrent-record.test.ts tests/cli/uninstall.test.ts with a private TMPDIR: 189 pass, 7 skip, 0 fail. (The agent host's default TMPDIR is group-writable, which makes 10 elevated-run cases in the untouched config-ownership-removal file fail the ancestor trust check; environmental.)
bun run test:changed: 1 file, 64 pass, 0 fail.
bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/file-size-ratchet.test.ts tests/ci-workflows/structure-ssot.test.ts tests/ci-workflows/repo-hygiene.test.ts: 105 pass, 0 fail.
bun run typecheck, bun run structure:check, bun run privacy:scan: pass.
NOT RUN: real Windows (no Windows host available; the next dev batch run covers it). Full bun run test: this is a test-only change to one file whose import graph reaches only itself, so the focused runs above cover it.
Checklist
Scope stays focused and avoids unrelated cleanup.
Docs or release notes were updated when needed.
Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.
Summary by CodeRabbit
Documentation
Clarified the documented outcomes when a registration overlaps an uninstall, including cases where it is removed, rejected, reported afterward, or retained for a rerun.
Tests
Expanded coverage of concurrent registrations across successful, refused, and interrupted uninstall outcomes, including reruns and reporting of paths that remain.
…utcome (#8379)
The racing-uninstall test asserted that every child that recorded its path saw that path removed,
before it checked the uninstall's status. Any first run that did not reach removal therefore failed
with "expected false, received true": a refusal for a reason other than a busy lock (on Windows, the
unlocked check can fail to open a manifest a registration is renaming over) or a partial run that
stopped in its snapshot. Neither loses a registration: the path stays listed in the untouched or
tombstoned manifest, and a rerun removes it.
settleRacingUninstall now checks exactly that, reruns such a run once the race is over, and puts the
uninstall result and child exit codes in every failure message. Four forced cases pin each outcome
in order; the refused and partial ones fail against the old assertions.
Closes#8379
No actionable comments were generated in the recent review.
Walkthrough
The concurrent config-ownership tests now cover racing registrations across refused, partial, and completed uninstall outcomes. They check that remaining registrations stay listed for a rerun. The coverage documentation records the tested outcomes.
Changes: Concurrent uninstall race coverage
Layer / File(s)
Summary
Settle racing uninstall outcomes tests/config/config-ownership-concurrent-record.test.ts:178-219, 250-252, 279-280
A shared helper checks refused and tombstoned outcomes, reruns uninstall when needed, and verifies removed and residual paths. The existing race test delegates its final checks to this helper and includes result and child exit codes in assertion failures.
Tests cover registrations before, during, and after uninstall, refusal due to a busy lock or unreadable metadata, and a partial run caused by an unwritable directory. The documentation lists the covered outcomes.
lidge-jun/opencodex#8121: Establishes the cross-process lock contract that the concurrent uninstall tests exercise.
Merge Risk: Minimal · up to 8bf48
This updates tests and documentation so concurrent config-ownership uninstall races account for refused and partial outcomes. It does not change production behavior, so the merge risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the test file's scope (config uninstall racing with registration) and states the change: a racing uninstall is held to its guarantee whatever its outcome. The raw summary and objective…
Linked Issues check
Issue #8379 asks that the concurrent config-ownership test stop treating a refused uninstall as a failure when a registration succeeds after the refusal. At head 8bf488f, tests/config/config-ownership…
Out of Scope Changes check
All changes are test-only plus one documentation file, structure/config-ownership.md, which the summary describes as listing the new coverage. No src/ change is reported. The extra forced cases (befor…
Full details: Title check
Explanation
The title names the test file's scope (config uninstall racing with registration) and states the change: a racing uninstall is held to its guarantee whatever its outcome. The raw summary and objectives confirm the PR extends the concurrent config-ownership test to cover refused and partial uninstall outcomes, with a rerun when a recorded path remains. The title is specific and relevant. Minor nit: 'hold ... to its guarantee' is somewhat abstract, and the title is 83 characters, slightly above a typical concise length, but it still conveys the primary change to a reader scanning history.
Full details: Linked Issues check
Explanation
Issue #8379 asks that the concurrent config-ownership test stop treating a refused uninstall as a failure when a registration succeeds after the refusal. At head 8bf488f, tests/config/config-ownership-concurrent-record.test.ts adds settleRacingUninstall. For a refused first run, it asserts residualPaths equals [dir] and that no tombstone (uninstallStartedAt) exists. For a partial or retained-manifest run, it asserts each recorded path that still exists is still listed in the manifest, reruns removeOwnedConfigState, and requires the rerun to remove every recorded path. Unrecorded paths must be reported as residual. The racing test.each cases use this helper for the busy-lock outcome, which matches the issue's reproduction. The file's header comment and the settle helper's doc comment both reference #8379. The structure/config-ownership.md update, which the raw summary describes, was not read directly. Evidence for the remaining forced cases comes from the truncated diff of the test file (read at head, 16000-byte limit), so those cases were confirmed only from the PR description and summary. The requirement itself is met by code I read directly.
Full details: Out of Scope Changes check
Explanation
All changes are test-only plus one documentation file, structure/config-ownership.md, which the summary describes as listing the new coverage. No src/ change is reported. The extra forced cases (before/during/after registration, registration after an unreadable-metadata refusal, registration after a partial removal stopped by an unwritable directory) all test the outcome model that #8379 requires: refused or partial uninstall must not be treated as a failure when registrations remain listed for a rerun. The Windows-motivated EPERM refusal case is a refusal outcome of the same kind as the busy-lock refusal named in the issue, so it is a related extension, not unrelated work. The summary states that the file's import graph reaches only itself, so the change does not touch shared code paths. Limit: the truncated diff did not allow line-by-line review of the forced cases, so this verdict relies on the consistent structure of the visible helper and on the PR's stated scope.
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
Required PR checks at that head: gates SUCCESS; test jobs SUCCESS: test changed; no failing or pending checks.
Fixes the flaky ownership race test (Cover refused uninstall in concurrent config ownership test #8379): no product bug; the test now holds a racing uninstall to its guarantee for every legal outcome (removed, refused, partial + rerun). Old assertions fail three forced cases with the CI symptom; a lost-write mutation fails five; 50x loops idle and loaded pass.
Test-only change to one file plus its structure doc; test changed ran that file on this head; Windows coverage comes from the next dev batch.
scripts/ci/assert-mergeable-review.sh --maintainer-integration passed for this head.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
choreMaintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature).
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/config/config-ownership-concurrent-record.test.tsfailed intermittently ("a registration racing uninstall ... with its first run finding the lock still held", Windows dev batch run 44072572278, job "windows 7/14"): a child exited 0 after recording its path, yet the path still existed. The test asserted that every recorded path was removed before it looked at the uninstall's status, so any first run that did not reach removal failed at that line. Besides the busy-lock refusal that #8822 already retries, two such outcomes exist:src/lib/config-ownership.ts:881) can refuse a valid home as "missing or invalid" while a child is replacing the manifest under the lock. The child's registration then succeeds.src/lib/config-ownership.ts:943), which names only the entry it failed on.Neither loses a registration. The refused run writes nothing, the partial run leaves its tombstoned manifest, and in both the recorded path stays listed, so the next run removes it. The product keeps its guarantee; the test's outcome model was incomplete. There is no
src/change.settleRacingUninstallchecks the guarantee for every outcome. A recorded path is either removed, or the run was refused (no tombstone, whole home reported) or partial and the manifest still lists the path. In that case the test reruns uninstall after the race, as a user would, and the rerun must remove it. A path that was never recorded must be a residual path of the run that retired the metadata. Failure messages now carry the uninstall result and the child exit codes, which the failing CI log did not have.structure/config-ownership.mdlists the new coverage.Which of the two outcomes the Windows job hit is inferred: the failed job logged no uninstall result. If it fails again, the message will name it. A possible follow-up, outside this PR: on Windows a concurrent registration can make
ocx uninstallprint a transient, misleading "missing or invalid" refusal for a valid home (nothing is lost; a rerun works).Closes #8379
Verification
expect(existsSync(path)).toBe(false), Expected: false, Received: true). The before/during/after case and both racing cases pass.bun test tests/config/config-ownership-concurrent-record.test.tson the rebased head: 64 pass, 0 fail.bun test tests/config/config-ownership-removal.test.ts tests/config/config-ownership-uninstall.test.ts tests/config/config-ownership-concurrent-record.test.ts tests/cli/uninstall.test.tswith a private TMPDIR: 189 pass, 7 skip, 0 fail. (The agent host's default TMPDIR is group-writable, which makes 10 elevated-run cases in the untouched config-ownership-removal file fail the ancestor trust check; environmental.)bun run test:changed: 1 file, 64 pass, 0 fail.bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/file-size-ratchet.test.ts tests/ci-workflows/structure-ssot.test.ts tests/ci-workflows/repo-hygiene.test.ts: 105 pass, 0 fail.bun run typecheck,bun run structure:check,bun run privacy:scan: pass.bun run test: this is a test-only change to one file whose import graph reaches only itself, so the focused runs above cover it.Checklist
Summary by CodeRabbit