fix: refresh workspace discovery for each operation #267
fix-workspace-intent-warning fromrefs/pull/267/head·merged by LadyBluenotes(GitHub profile, opens in a new tab) 🎯 Changes#
Replace four process-wide workspace caches with reuse scoped to the existing filesystem cache for each core operation. Repeated list and load calls observe new workspace roots, added and removed members, changed patterns, and workspace/npm source-kind changes.
The initial implementation slowed direct loads and was rejected. Commit bb9c6a5 removes the extra work while preserving fresh state:
- Avoid building a full workspace membership index when a direct-load candidate is outside every simple workspace prefix. Literal paths, complex patterns, symlinks after wildcards, and filesystem errors retain the existing membership resolver.
- Skip unused frontmatter reads in direct resolution, which needs only a skill name and path. Normal discovery still reads metadata. Final load containment checks and live content reads remain unchanged.
- Share manifest reads with policy resolution and skip files proven absent. Existing unreadable-manifest errors, policy checks, and work-budget assertions remain intact.
No watcher, daemon, dependency, persistent invalidation mechanism, or guide changes.
Verification#
- 868 ordinary package tests passed on the repaired revision:
node ../../node_modules/vitest/vitest.mjs run --no-file-parallelism --exclude tests/integration/distribution-installers.test.tsfrompackages/intent. - Regression tests cover repeated core calls against fresh discovery, package.json and pnpm workspace changes, source-kind permissions, direct-load read budgets, recursive patterns, and symlink retargeting.
- Build, typecheck, ESLint, Knip, Prettier, and
git diff --checkpassed. Eight existing lint warnings remain. Live external installer checks were not rerun.
Performance#
Compared the unchanged list/load benchmarks in isolated worktrees using the same installed tools. Baseline: #266 at 259ce1b; repaired: bb9c6a5. Run from benchmarks/intent: ./node_modules/.bin/vitest bench list.bench.ts load.bench.ts --run --no-file-parallelism after building each revision.
Means are milliseconds per existing benchmark batch, not per command.
| Case | Commands per batch | Before #267 | Repaired | Mean reduction |
|---|---|---|---|---|
| Direct load path | 10 | 1.8279 | 1.5545 | 15.0% |
| Direct load JSON | 10 | 2.3114 | 1.9952 | 13.7% |
| Direct load, 120-package workspace | 10 | 3.5235 | 1.6726 | 52.5% |
| Workspace list | 3 | 5.8379 | 5.7702 | 1.2% |
Repaired relative margins of error: 0.35–0.55%; baseline: 0.46–1.12%. These are local fixture measurements, not a universal speed claim. List performance is comparable within measurement noise. The earlier 6.3870 ms large-workspace result is superseded; no material standalone regression remains in these checks.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm run test:pr.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Summary by CodeRabbit#
- Bug Fixes
- Workspace discovery now reflects updated roots, patterns, and members between operations.
- Changes to workspace allowlists and symlinked members are detected more reliably.
- Direct skill loading avoids unnecessary metadata reads.
- Workspace discovery avoids scanning unrelated package members, improving efficiency.
- Tests
- Added coverage for refreshed workspace configuration, member changes, skill resolution, and workspace classification.
- 1
View your CI Pipeline Execution ↗ for commit bb9c6a52d138352de2a845a249cc2033efee0d3e
Command Status Duration Result nx run-many --targets=build✅ Succeeded 2s View ↗
☁️ Nx Cloud last updated this comment at
2026-09-11 20:45:19UTCMerging this PR will improve performance by 47.1%#
⚡ 3improved benchmarks✅ 6untouched benchmarksPerformance Changes#
Benchmark BASEHEADEfficiency ⚡ loads a direct dependency from a large workspace75.1 ms 41.8 ms +79.42% ⚡ loads a direct dependency skill46.9 ms 32.7 ms +43.57% ⚡ loads direct dependency content as json55.5 ms 44.9 ms +23.56% Tip
Curious why performance improved? Comment
@codspeedbot explain why performance improvedon this PR, or directly use the CodSpeed MCP with your agent.
Comparingfix-workspace-discovery-refresh(68ad8e3) withfix-workspace-intent-warning(259ce1b)
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Advanced
Run ID:
4e57e922-ccb5-47c0-9e61-b32155029053📥 Commits
Reviewing files that changed from the base of the PR and between 2578ef765e6ecf82660c2c7187cc7a55468dfcfd and 7ef4453a20d7bf4361e86c9285bac1e1d60e121f.
📒 Files selected for processing (9)
.changeset/refresh-workspace-discovery.mdpackages/intent/src/core/intent-core.tspackages/intent/src/core/load-resolution.tspackages/intent/src/core/project-context.tspackages/intent/src/discovery/scanner.tspackages/intent/src/discovery/walk.tspackages/intent/src/setup/workspace-patterns.tspackages/intent/tests/core.test.tspackages/intent/tests/repeated-work.test.tsIncluded review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.
📝 Walkthrough
Walkthrough#
Workspace discovery now uses operation-scoped filesystem caches. Core operations refresh workspace roots, patterns, and members. Direct scans can skip unused skill metadata and unrelated workspace enumeration. Tests cover repeated workspace changes and direct resolution.
Changes#
Workspace discovery refresh
packages/intent/src/setup/workspace-patterns.tspackages/intent/src/core/...,packages/intent/src/discovery/walk.ts,packages/intent/src/discovery/scanner.tspackages/intent/src/discovery/scanner.ts,packages/intent/src/core/load-resolution.tspackages/intent/tests/core.test.ts,packages/intent/tests/repeated-work.test.ts,.changeset/refresh-workspace-discovery.mdPriority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)#
Merge Risk: ⚪ Minimal · up to
7ef44Workspace changes are refreshed between core operations while per-operation caching and direct-load safeguards remain intact. No merge-blocking risk was identified.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
#236requires refresh between core operations, an explicit cache lifetime, consistent source-kind decisions, regression tests, and benchmark checks. The PR moves workspace pattern, root, and pac…#236. Cache plumbing, direct-load metadata avoidance, workspace classification checks, symlink regression coverage, and the changeset support workspace refresh, source-ki…Full details: Docstring Coverage
Explanation
Docstring coverage is 4.76% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 8 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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