Skip to content

perf(skills): avoid repeated placement scans during batch deletion - #26223

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-skill-delete-placement-index
Oct 8, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-skill-delete-placement-index

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Deleting several skills made Orca repeatedly check every discovered placement for each selected skill. Preparation now groups placements once, so it checks only the ones that can belong to each selected skill.

What Changed

The deletion planner indexes its freshly discovered candidates by the existing host-specific file or directory identity. It merges matching candidates in their original order, then runs the existing ownership, eligibility, and deduplication checks. Preview and deletion both use this planner.

Why

The old loop repeated root-containment work for unrelated candidates. Indexing this one discovery result removes that repeated work without a persistent cache or changes to filesystem freshness and deletion safeguards.

Seven alternating before/after runs of the actual complete planner on a generated local filesystem with 64 selected skills and 192 canonical/file-alias/directory-alias placements measured median preparation 65.639 ms → 14.228 ms. Classification calls dropped 12,288 → 192. The one-skill control measured 1.283 ms → 1.281 ms. These measure deletion preparation, not terminal typing latency.

Linked Issue

No existing issue; maintainer performance audit.

Visual Proof

N/A — preparation produces the same deletion preview and operation; only repeated internal work changes.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Two regressions cover a real filesystem batch with many unrelated placements, and mixed directory/file aliases with original ordering and false-identity traps. The batch regression fails on the original source.

  • Six skill-deletion suites: 63 passing tests.
  • Eight paired complete-plan controls preserve outputs and errors: candidate order, duplicate selections, duplicate root metadata, symlinked home roots, missing/stale/unowned skills, permission failures, Windows case/UNC paths, and WSL POSIX paths.
  • Every timed before/after run has identical complete-plan, placement-root, root-path, and path-semantics hashes.
  • Node typecheck, focused lint, formatting, and changed-code quality gate pass.
  • Validation ran on macOS with Node 24 and ORCA_BACKGROUND_LAUNCH=1, using private generated files. Windows/WSL path cases use filesystem seams; they are not measurements on those operating systems. No app window or user skill was touched.
  • Combined branch with all 27 audit changes: 2,291 passing browser/ACP/skill-deletion tests across 254 files, full pnpm tc, and zero new quality findings across 89 changed files. Hosted CI passed: repository guards, static analysis/typecheck, all five Node 24 test shards, relay integration, Ubuntu 22.04 persistence, and macOS/Windows packaging.

Review

Independent review confirmed that index membership exactly matches the existing classifier's file-versus-directory predicate and normalization. Original candidate ordinals preserve first-root metadata and deduplication. The index lives only for one fresh plan; host execution and all authorization checks remain in their current owners. No remote protocol or provider-specific behavior changes.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Only the planner and its existing test file change. Existing canonical content, alias handling, freshness refusals, and filesystem failure behavior are preserved.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c10a918f-3e46-4307-8dd0-6ad4c9b6feb8
📥 Commits

Reviewing files that changed from the base of the PR and between 0d82899 and 9ddd249.

📒 Files selected for processing (2)
  • src/main/skills/skill-delete/plan.test.ts
  • src/main/skills/skill-delete/plan.ts

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


📝 Walkthrough

Walkthrough

buildSkillDeletePlan now indexes placement candidates by normalized realpath and selects candidates matching each requested skill’s canonical file or directory realpath. It restores candidate enumeration order before classification. Tests cover request order, canonical placements, directory and file symlink identities, and classification call counts. Mock restoration was added to test cleanup.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 9ddd2

The deletion-planning change appears mergeable after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: avoiding repeated placement scans during batch skill deletion.
Description check ✅ Passed The description covers the required sections with a clear explanation of the change, rationale, testing, visual-proof status, and checklist. It identifies the contributor as a maintainer, which fits t…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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

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

@nwparker
nwparker merged commit c5767f0 into main Oct 8, 2026
30 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.

1 participant