Skip to content

test(config): accept a refused uninstall in the concurrent ownership race - #8556

Closed
shu-chen-dot-ca wants to merge 2 commits into
lidge-jun:devfrom
shu-chen-dot-ca:fix-8379-refused-uninstall-race
Closed

shu-chen-dot-ca wants to merge 2 commits into
lidge-jun:devfrom
shu-chen-dot-ca:fix-8379-refused-uninstall-race

Conversation

@shu-chen-dot-ca

@shu-chen-dot-ca shu-chen-dot-ca commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

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.
  • Test-only change. src/ is untouched.

Closes #8379

Verification

All runs used Bun 1.4.4 on Linux (Ubuntu 24.04).

  • Reproduction on unchanged dev 3372695: 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 dev 1d10758f:

    • 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.

@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 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ READY

  • 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

Hygiene

✅ Deterministic PR hygiene checks passed.

@github-actions
github-actions Bot marked this pull request as draft November 11, 2026 15:18
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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.

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

Change: Other · Severity of issue fixed: Low

Merge Risk: Minimal · up to e4763

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: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 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 Passed 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 Passed 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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c73242b and e4763ac.

Files selected for processing: 1

  • tests/config/config-ownership-concurrent-record.test.ts

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

@shu-chen-dot-ca

Copy link
Copy Markdown
Contributor Author

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.

@lidge-jun

Copy link
Copy Markdown
Owner

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.

Closes lidge-jun#8379
@shu-chen-dot-ca

Copy link
Copy Markdown
Contributor Author

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).

@shu-chen-dot-ca
shu-chen-dot-ca force-pushed the fix-8379-refused-uninstall-race branch from 3d09ccc to e4763ac Compare November 15, 2026 17:58
@github-actions
github-actions Bot marked this pull request as ready for review November 15, 2026 17:59

@Ingwannu Ingwannu left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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.

@shu-chen-dot-ca

Copy link
Copy Markdown
Contributor Author

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.

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). review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cover refused uninstall in concurrent config ownership test

3 participants