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): accept a refused uninstall in the concurrent ownership race - #8556
a registration racing uninstall is either removed or refused, never left unreported assumed uninstall always gets the ownership lock. After the gate opens, the gated children may still hold the lock when removeOwnedConfigState runs. Uninstall then fails fast with refused ("could not lock the ownership manifest ... busy") before it writes its tombstone, so every child records its path afterwards. That outcome is correct, because the home stays intact. The test still expected each recorded file to be removed, which is the expected false, received true failure at the existsSync assertion seen in #8090's CI.
The race assertions move into a helper, expectRaceOutcome, that checks both outcomes:
Uninstall got the lock: the existing checks are unchanged. A recorded child's file is removed, a refused or unrecorded child's file is reported as residual, and the lock file is gone.
Uninstall was refused:result.reason names the busy lock, residualPaths is the home only, the manifest carries no uninstallStartedAt, every child exits 0, and every racing path is listed in the manifest and still exists. A rerun then returns { status: "removed", residualPaths: [] } and the home is gone.
New test an uninstall refused for a busy lock leaves racing registrations recorded for a rerun forces the refused path. It calls uninstall while the test still holds the lock, right after opening the gate, asserts refused, and runs the same helper. Both tests share a spawnGatedChildren setup that is the existing barrier code, unchanged.
Reproduction on unchanged dev3372695: a copy of the original race test that calls uninstall before releasing the held lock fails the same way CI did:
uninstall status: refused could not lock the ownership manifest: config ownership metadata is busy in another opencodex process
Expected: false
Received: true
(fail) repro #8379 > a registration racing uninstall is either removed or refused, never left unreported
Current head e4763acc, rebased onto dev1d10758f:
bun test tests/config/config-ownership-concurrent-record.test.ts: 60 pass, 0 fail (321 assertions, including the new reason check).
bun test tests/config/config-ownership-concurrent-record.test.ts -t "racing|refused for a busy lock", repeated 15 times: 15/15 passed.
bun run typecheck && bun run structure:check && bun run privacy:scan && OCX_TEST_MAIN_TIMEOUT_MS=3600000 bun run test --parallel=3 --timeout 30000: exit 0.
One earlier full run on the same head at --parallel=4 failed only on the wall-clock budget in tests/responses/sse-untyped-credential-mask.test.ts: excerpt masking ... stays linear took 1673 ms against a 1500 ms limit, on a heavily shared host. That file passes on its own on this head (98 pass, 0 fail), and the full rerun above passed.
Checklist
Scope stays focused and avoids unrelated cleanup.
Docs or release notes were updated when needed. (none needed: test-only)
Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (none touched)
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit
Tests
Expanded coverage for concurrent configuration recording and removal, including attempts to uninstall while ownership is locked.
Verified that a blocked uninstall leaves files intact and that removal succeeds when retried after recording completes.
Added checks for child registration outcomes and remaining files across concurrent operations, helping ensure configuration state is handled consistently during these races.
all PR quality gates passed; the review readiness checklist is complete.
Review readiness checklist
✅ Required local validation passed; commands, results, and any full-suite exception are documented.
✅ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
✅ I resolved all correct Codex and CodeRabbit findings.
✅ My PR is ready for review.
✅ 4/4 boxes ticked.
This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers: @lidge-jun@Ingwannu
No actionable comments were generated in the recent review.
Walkthrough
The concurrent config ownership test now shares its gated-child setup and race assertions. It covers uninstall refusal while the ownership lock is held and verifies that a later uninstall removes the home after child registrations finish.
Changes: Config ownership race coverage
Layer / File(s)
Summary
Gate child registrations and verify uninstall outcomes tests/config/config-ownership-concurrent-record.test.ts
A shared setup starts six gated child processes, and a helper checks successful and refused uninstall outcomes. A new case holds the lock during uninstall, verifies refusal without tombstoning, then checks that a rerun removes the home.
This change only updates a concurrency test to cover both uninstall outcomes in a race. It does not alter production behavior, and no merge-blocking risk was found.
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-only change to the concurrent config-ownership race test and the refused-uninstall case, which is the main change in the changeset. It is specific, uses a conventional prefix,…
Linked Issues check
Issue #8379 asks that the concurrent config-ownership test accept a refused uninstall when the ownership lock stays busy. The whole-PR diff (merge base 1d10758 to head e4763ac) changes only tests/…
Out of Scope Changes check
The whole-PR file list for the merge-base-to-head diff shows one changed file: tests/config/config-ownership-concurrent-record.test.ts. The PR description states that src/ is untouched, and the diff…
Full details: Title check
Explanation
The title names the test-only change to the concurrent config-ownership race test and the refused-uninstall case, which is the main change in the changeset. It is specific, uses a conventional prefix, and is 73 characters long. The raw summary and objectives both describe a test-only change that accepts the refused uninstall outcome in the race test, matching the title.
Full details: Linked Issues check
Explanation
Issue #8379 asks that the concurrent config-ownership test accept a refused uninstall when the ownership lock stays busy. The whole-PR diff (merge base 1d10758 to head e4763ac) changes only tests/config/config-ownership-concurrent-record.test.ts.
Coverage of the requirement:
expectRaceOutcome handles result.status === "refused". It asserts result.reason contains "busy", residualPaths equals [dir], manifest(dir).uninstallStartedAt is undefined, every child exits 0, every racing path is listed in the manifest and still exists, and a removeOwnedConfigState(dir) rerun returns { status: "removed", residualPaths: [] } with the home removed.
The non-refused branch keeps the original checks: exit codes 0/2/3, removed files for successful children, residual paths for the others, and no lock file.
The original race test now calls the shared helper. The new test an uninstall refused for a busy lock leaves racing registrations recorded for a rerun holds the lock while it calls uninstall, asserts refused, and then runs the same helper. This forces the refused path deterministically.
The previous conclusion still holds for the head. The only change since the previous reviewed head c73242b is the added reason "busy" assertion, which is present in the diff.
Unresolved: the #8090 CI timing path is unconfirmed, as the issue states. The issue does not require that path to be reproduced, so this does not block a verdict. Test runs reported by the author were not re-executed in this review.
Full details: Out of Scope Changes check
Explanation
The whole-PR file list for the merge-base-to-head diff shows one changed file: tests/config/config-ownership-concurrent-record.test.ts. The PR description states that src/ is untouched, and the diff is consistent with that.
Each hunk supports #8379:
type ConfigRemovalResult import: types the result parameter of expectRaceOutcome and the forced-refusal test.
expectRaceOutcome: the refused and lock-acquired assertions for the race.
spawnGatedChildren: the existing barrier code moved into a helper, with no behavior change, so both tests share one setup.
New forced-refusal test: covers the refused path that #8379 requires.
No unrelated cleanup, production behavior change, documentation change, or security-sensitive change appears in the diff. The PR objectives mention #8386, but that is not part of this PR's diff and is not a scope issue here.
Finishing Touches
Generate unit tests (beta)
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; 9 remain after this review.
Rebased onto the current dev (de0914a1); there were no conflicts and the diff is unchanged. On the rebased head, bun run typecheck, bun run structure:check, bun run privacy:scan and OCX_TEST_MAIN_TIMEOUT_MS=3600000 bun run test --parallel=4 --timeout 30000 all pass (exit 0). tests/config/config-ownership-concurrent-record.test.ts alone: 60 pass, 0 fail.
Merge-manager review: the assertion is not vacuous — the refused branch requires no tombstone, all children exit 0, every path still present, and a rerun that removes the home. Optional: also assert result.reason contains "busy". Scope note: this fixes #8379; #8386 concerns a docs paragraph that neither dev nor this head has, so I'll close #8386 separately as not applicable. Ready to integrate once the readiness checklist is ticked on this head and CI is green.
…race
When the racing registrations keep the ownership lock busy, uninstall
returns refused before it writes its tombstone, and the registrations
then succeed. The race test still expected every recorded file to be
removed. It now checks the refused outcome as its own case (no
tombstone, every registration recorded, a rerun removes the home), and
a new test forces that path by running uninstall while the lock is held.
Closeslidge-jun#8379
Thanks for the review. I added the optional check: the refused branch of expectRaceOutcome now also asserts result.reason contains "busy", so both race tests cover it. I also rebased onto the current dev (1d10758f), with no conflicts.
On this head, bun test tests/config/config-ownership-concurrent-record.test.ts gives 60 pass, 0 fail, and the two race tests passed 15/15 repeated runs. bun run typecheck && bun run structure:check && bun run privacy:scan && OCX_TEST_MAIN_TIMEOUT_MS=3600000 bun run test --parallel=3 --timeout 30000 exits 0. An earlier full run at --parallel=4 failed only on the wall-clock budget in tests/responses/sse-untyped-credential-mask.test.ts (1673 ms against a 1500 ms limit, on a heavily shared host). That file passes on its own on this head (98/0).
The reason will be displayed to describe this comment to others. Learn more.
Reviewed current head e4763acc1e6d6a84d5d56d0c686cdf1822444431 and the full test-only diff. The new helper accepts the two genuine race outcomes while retaining the tombstone, registration, reported-leftover and rerun-cleanup assertions. The deterministic held-lock case exercises the busy-refusal branch; it does not turn an unexpected failure into success.
The hosted Ubuntu run 43744085574 completed successfully. I checked the actual config-ownership test output, including the concurrent uninstall/registration and busy-lock rerun cases, rather than only the aggregate status. No production contract or documentation change is needed for this test-only correction. Approval is for this source head; refresh the now-stale dev ancestry and readiness before integration. This is not native Windows/macOS evidence or merge authorization.
Closing this one: #8822, now on dev, fixes the same race by rerunning a busy-refused uninstall, and it adds a forced busy case of its own. That makes this PR redundant, and it conflicts with that test now. Thanks for the reviews.
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).review-ready
3 participants
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
a registration racing uninstall is either removed or refused, never left unreportedassumed uninstall always gets the ownership lock. After the gate opens, the gated children may still hold the lock whenremoveOwnedConfigStateruns. Uninstall then fails fast withrefused("could not lock the ownership manifest ... busy") before it writes its tombstone, so every child records its path afterwards. That outcome is correct, because the home stays intact. The test still expected each recorded file to be removed, which is theexpected false, received truefailure at theexistsSyncassertion seen in #8090's CI.expectRaceOutcome, that checks both outcomes:result.reasonnames the busy lock,residualPathsis the home only, the manifest carries nouninstallStartedAt, every child exits 0, and every racing path is listed in the manifest and still exists. A rerun then returns{ status: "removed", residualPaths: [] }and the home is gone.an uninstall refused for a busy lock leaves racing registrations recorded for a rerunforces the refused path. It calls uninstall while the test still holds the lock, right after opening the gate, assertsrefused, and runs the same helper. Both tests share aspawnGatedChildrensetup that is the existing barrier code, unchanged.src/is untouched.Closes #8379
Verification
All runs used Bun 1.4.4 on Linux (Ubuntu 24.04).
Reproduction on unchanged
dev3372695: a copy of the original race test that calls uninstall before releasing the held lock fails the same way CI did:Current head
e4763acc, rebased ontodev1d10758f:bun test tests/config/config-ownership-concurrent-record.test.ts: 60 pass, 0 fail (321 assertions, including the newreasoncheck).bun test tests/config/config-ownership-concurrent-record.test.ts -t "racing|refused for a busy lock", repeated 15 times: 15/15 passed.bun run typecheck && bun run structure:check && bun run privacy:scan && OCX_TEST_MAIN_TIMEOUT_MS=3600000 bun run test --parallel=3 --timeout 30000: exit 0.--parallel=4failed only on the wall-clock budget intests/responses/sse-untyped-credential-mask.test.ts:excerpt masking ... stays lineartook 1673 ms against a 1500 ms limit, on a heavily shared host. That file passes on its own on this head (98 pass, 0 fail), and the full rerun above passed.Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit