Skip to content

fix(config): batch Windows migration ACL copies - #229

Merged
mohanagy merged 7 commits into
developmentfrom
fix/228-windows-console-cleanup
Jul 25, 2026
Merged

fix(config): batch Windows migration ACL copies#229
mohanagy merged 7 commits into
developmentfrom
fix/228-windows-console-cleanup

Conversation

@mohanagy

@mohanagy mohanagy commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #228. Windows Console native-OAuth onboarding could exceed Vitest's five-second boundary while the guarded config-replacement transaction serially launched three trusted PowerShell ACL operations.

The fix keeps private transaction-directory creation separate, exclusively creates empty backup and candidate files, then copies and verifies the held source descriptor onto both in one bounded trusted helper invocation. No configuration content is written until that verification succeeds.

Security impact

  • shell: false, trusted System32 PowerShell, minimal environment, bounded request data, and fail-closed ACL handling remain intact.
  • Both files stay exclusive and zero-byte until descriptor verification succeeds.
  • The helper verifies every target's persisted access rules before any content write.
  • Backup publication still occurs before candidate publication.
  • Cleanup waits for both prepared files before source restoration; uncertain cleanup retains the private transaction rather than risking loss.
  • Candidate and descriptor setup failures preserve bounded, phase-specific public errors.
  • A NUL in either batched target is rejected before PowerShell launches.

Validation

  • Added a focused regression proving both empty files are prepared before exactly one batched ACL verification.
  • Added a helper contract test proving one trusted PowerShell launch carries the fixed two-target request.
  • Added fault-injection coverage for candidate-versus-backup error semantics.
  • Added target NUL-byte rejection coverage.
  • npm test
  • npm run test:core
  • npm run test:coverage
  • npm run lint
  • npm run typecheck
  • npm run build
  • npm run smoke:cli
  • npm run check:pack
  • npm run test:package
  • Windows Node 20/22/24, Linux, macOS, quality, package, and verification checks were green on the preceding head; all current-head checks are rerunning after the review fixes.

Scope

Removed the temporary timing diagnostic now that the production boundary is fixed. No timeout increases, retries, skips, or weakened Windows containment are included.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 12 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3f2fe7eb-b47e-48d2-9fb3-a01b3ea89f38

📥 Commits

Reviewing files that changed from the base of the PR and between a6a1e62 and 775c114.

📒 Files selected for processing (5)
  • src/cli/migrate-config.ts
  • src/console/console-dashboard-application-service.ts
  • tests/console-dashboard-application-service.test.ts
  • tests/windows-config-acl.test.ts
  • tests/windows-config-migration-acl-failure.test.ts
📝 Walkthrough

Walkthrough

The migration flow now exclusively prepares backup and candidate files, applies verified Windows security descriptors to both in one batch, writes synchronized contents through pre-opened handles, and performs phase-aware cleanup. Tests cover candidate creation collisions and batched ACL verification.

Changes

Windows migration ACL flow

Layer / File(s) Summary
Batch ACL request and verification
src/cli/windows-config-acl.ts, tests/windows-config-acl.test.ts
Adds the batch ACL request, encoding, exported helper, PowerShell application and per-target verification, with request-level tests.
Exclusive file preparation and synchronized writes
src/cli/migrate-config.ts
Creates backup and candidate files exclusively, verifies descriptors across both targets, and writes contents through pre-opened handles.
Phase-aware failure handling and migration coverage
src/cli/migrate-config.ts, tests/config-migration.test.ts, tests/windows-config-migration-acl-failure.test.ts
Adds phase-specific preparation errors and cleanup, and tests candidate collisions, ACL failures, and batched preparation behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MigrationCommand
  participant FileSystem
  participant WindowsACL
  participant PowerShell
  MigrationCommand->>FileSystem: Create backup and candidate exclusively
  MigrationCommand->>WindowsACL: Copy descriptors to both targets
  WindowsACL->>PowerShell: Run batch ACL operation
  PowerShell-->>WindowsACL: Verify each target descriptor
  WindowsACL-->>MigrationCommand: Return verification result
  MigrationCommand->>FileSystem: Write synchronized backup and candidate contents
Loading

Possibly related issues

  • Issue 214: The PR changes the Windows ACL batch copy and verification path covered by the issue’s related migration probe behavior.

Poem

I’m a bunny with files in a row,
Two fresh little targets now grow.
ACLs hop in a batch,
Cleanup guards the scratch,
Safe migrations go—hop, hop, ho!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The batching, exclusive file prep, and cleanup/error handling address #228 without weakening ACL or rollback guarantees.
Out of Scope Changes check ✅ Passed The code and tests stay focused on the Windows ACL batching fix, with no obvious unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly captures the main change: batching Windows migration ACL copies.
Description check ✅ Passed The description covers Summary, Security impact, and Validation with commands and results, so it mostly matches the template.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/228-windows-console-cleanup

Comment @coderabbitai help to get the list of available commands.

@mohanagy mohanagy changed the title test: diagnose slow Windows Console OAuth setup fix(config): batch Windows migration ACL copies Jul 25, 2026
@mohanagy
mohanagy marked this pull request as ready for review July 25, 2026 06:05
@mohanagy

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/cli/migrate-config.ts (1)

477-503: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Handle descriptor-phase failures explicitly
MigrationFilePreparationError.phase === "descriptor" still falls through to the generic backup-creation message, which obscures the ACL verification failure. Add a dedicated branch here so Windows descriptor errors report the right cause.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli/migrate-config.ts` around lines 477 - 503, Update the catch handling
around MigrationFilePreparationError to add a dedicated branch for phase ===
"descriptor" before the generic restoredError path. Restore the held source
through restoreAndEscalate and report a migrationWriteError describing the
Windows descriptor or ACL verification failure, while preserving the existing
candidate-phase and generic error behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/windows-config-acl.test.ts`:
- Line 21: Add a test covering NUL-byte rejection in the batch path of
copyWindowsConfigSecurityDescriptors, verifying that a NUL in either target is
rejected while preserving the existing happy-path coverage.

---

Outside diff comments:
In `@src/cli/migrate-config.ts`:
- Around line 477-503: Update the catch handling around
MigrationFilePreparationError to add a dedicated branch for phase ===
"descriptor" before the generic restoredError path. Restore the held source
through restoreAndEscalate and report a migrationWriteError describing the
Windows descriptor or ACL verification failure, while preserving the existing
candidate-phase and generic error behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 07069b31-b0a0-4069-9486-f3f9ce1b7d1e

📥 Commits

Reviewing files that changed from the base of the PR and between 065ed70 and a6a1e62.

📒 Files selected for processing (5)
  • src/cli/migrate-config.ts
  • src/cli/windows-config-acl.ts
  • tests/config-migration.test.ts
  • tests/windows-config-acl.test.ts
  • tests/windows-config-migration-acl-failure.test.ts

Comment thread tests/windows-config-acl.test.ts
@mohanagy

Copy link
Copy Markdown
Owner Author

Addressed CodeRabbit's review in fd7b06a:

  • Descriptor-phase batch failures now restore the held source and return a bounded Windows descriptor verification error.
  • Added test coverage that rejects a NUL in either batch target before the trusted helper is launched.
  • Updated the PR description to the requested Summary, Security impact, and Validation structure.

Focused ACL/migration tests, typecheck, lint, and diff validation pass; full current-head CI is rerunning.

@mohanagy

Copy link
Copy Markdown
Owner Author

Final validation on current head 775c114: all Linux, macOS, Windows Node 20/22/24, quality, Verify, package, and CodeRabbit status checks are green. Windows OAuth/Console target timings are 3.339s (Node 20), 2.785s (Node 22), and 3.308s (Node 24); no retries were used. CodeRabbit's newest status reports Review rate limited, so it did not produce a fresh review on the final two commits. Its prior review is approved, its only thread is resolved, and an independent local read-only review found no blockers. I also attempted a local Claude Code review, but its noninteractive process produced no response and was stopped rather than treated as approval. This documents the rate-limit exception before merge.

@mohanagy
mohanagy merged commit c7eb54e into development Jul 25, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: stabilize Windows cleanup after Console native OAuth account onboarding

1 participant