fix(server): keep newer forced workspace scan results #19465
main fromrefs/pull/19465/head·merged by juliusmarminge View on GitHubAn older workspace scan could publish while a newer forced scan was still running, causing the newer skills inventory to be discarded. Each in-flight provider/directory scan now has an ownership token. Forced scans take ownership before refreshing; superseded scans cannot publish or remove the current claim. The existing snapshot guard still preserves intervening session updates.
Maintainer takeover of @Exotic209093's #19465, preserving the contributor commits and merging current main. Refs #16866, overlapping-scan reproduction only.
Validation: the current baseline passes 70 registry tests. Extending the existing Deferred-gated race test makes it fail on stale publication (69 pass, 1 fail), then all 70 pass with the fix. This covers both completion orders and ordinary-request deduplication while a forced scan is pending. The test extension is 38 lines, down from the original 57 insertions/6 deletions; no new test cases were added. Changed-file lint, formatting, and scoped server typecheck pass.
Proof is headless Linux service testing with injected provider dependencies. No real client/provider session, remote/tunnel flow, web, macOS, Windows, iOS, Android, or Electron desktop was exercised. Screenshots do not demonstrate this server race.
One independent full-diff review round by Claude Opus 5.5 and Codex GPT-6-Sol found no blockers.
Implemented with Codex GPT-6.1-Sol, tests by Codex GPT-6-Astra, through the Codex harness in T3 Code.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
b6b9929Macroscope's review found this PR approvable — This is a localized server bug fix that uses per-scan ownership tokens to prevent stale workspace scans from overwriting newer forced-scan results. The production change is contained to existing scan coordination, and targeted regression tests cover the overlapping-scan scenarios.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Warning
Review limit reached#
Only developers with an assigned seat can use this organization's usage-based review budget, and seats here are assigned manually. Ask an admin to assign a seat, or change the review continuation mode in Billing.
Next included review available in 12 minutes.
View limit details
-
Limit details: You’ve used all 10 included reviews currently available.
Review configuration:
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
11b67ef9-459b-4a2a-8db6-67ec1702eff6
📥 Commits
-
Reviewing files that changed from the base of the PR and between d6d5eccc5e146f6b72cdc100ca42a50f6bd6f299 and 55e3c518bbd96c502bc17025a429cd73c2b1900a.
📒 Files selected for processing: 2
-
apps/server/src/provider/ProviderRegistry.test.tsapps/server/src/provider/ProviderRegistry.ts
-
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
2fcc216d-429b-4798-80cb-c87a63367316
📥 Commits
-
Reviewing files that changed from the base of the PR and between 7ac952c630ef8a60d14ca8f6a0c7adce33db4bae and b6b9929f8d14d2f110674ba1421fd2a78e08358d.
📒 Files selected for processing: 2
-
apps/server/src/provider/ProviderRegistry.test.tsapps/server/src/provider/ProviderRegistry.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
-
📝 Walkthrough
-
Workspace scan tracking now uses per-directory ownership tokens. A forced scan can replace an active scan’s claim, and only the scan that still owns the claim can publish results or clear it. The concurrency tests verify this behavior.
Changes: Workspace scan ownership
Layer / File(s) Summary Claim and validate workspace scans
apps/server/src/provider/ProviderRegistry.ts,apps/server/src/provider/ProviderRegistry.test.tsProviderRegistryassigns ownership tokens to scans by working directory. A scan publishes results and clears its claim only if its token remains current. Tests queue scan gates and verify that an older scan cannot publish before a forced scan completes.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to
d6d5e-
Merge Risk: ⚪ Minimal · up to
d6d5eNo actionable merge-blocking issue is identified; the change is mergeable after normal checks.
Security architecture risk: 🔵 Low · up to
b6b99-
The change strengthens scan coordination without changing request inputs or expanding provider access. Existing instance and snapshot protections remain in place. Residual uncertainty is concentrated in failure and cancellation behavior, which was inspected in source but not exercised during this review.
Retained concerns No architecture-level concerns identified.
Security review details
-
Security Blast Radius
- observed — Scan ownership is isolated by provider-instance identity and directory. Separately, a forced refresh continues to invalidate that directory's snapshots on other configured instances before scanning; this broader cache effect predates the PR and is not introduced by token ownership.
Trust Boundaries and Controls
- observed — The existing request path supplies the selected instance, directory, and forced-refresh flag. Registry preconditions reject missing or disabled providers and instances without workspace-snapshot support. The PR changes which overlapping scan may publish, without adding a new caller or altering these preconditions.
Resilience and Maintainability Implications
- observed — The scan pipeline installs an ensuring finalizer that deletes only its own claim, leaving a newer token untouched. Existing failure recovery preserves cached providers for non-interruption failures and propagates interruption. Failure/interruption cleanup is supported by source inspection, but was not directly runtime-validated in this review.
-
Pre-merge checks:
4-
Check name Status Explanation Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Title check The title clearly and concisely describes the main fix: preserving results from newer forced workspace scans. It uses an appropriate conventional commit format. Description check The description covers the problem, implementation, scope, regression testing, verification results, limitations, and tool usage. It links the related issue and takeover pull request. It does not incl… Full details: Description check
-
Explanation
The description covers the problem, implementation, scope, regression testing, verification results, limitations, and tool usage. It links the related issue and takeover pull request. It does not include an explicit maintainer approval comment, but the remaining required information is substantially complete.
-
✨ Finishing Touches: 💡 1
-
🛠️ Fix failing CI checks: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
juliusmarminge assignedjuliusmarminge
Taking over this one for batch server-misc-02. I will preserve your commits, merge current main, rebuild the minimal scan-ownership fix and regression, then run independent reviews and leave the PR unmerged.
juliusmarminge merged this4513fce
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes