Skip to content

fix: refresh workspace discovery for each operation - #267

Merged
LadyBluenotes merged 2 commits into
fix-workspace-intent-warningfrom
fix-workspace-discovery-refresh
Sep 11, 2026
Merged

fix: refresh workspace discovery for each operation#267
LadyBluenotes merged 2 commits into
fix-workspace-intent-warningfrom
fix-workspace-discovery-refresh

Conversation

@LadyBluenotes

@LadyBluenotes LadyBluenotes commented Sep 11, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Stacked on #266. Fixes #236.

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.ts from packages/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 --check passed. 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.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

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 2578ef7 and 7ef4453.

📒 Files selected for processing (9)
  • .changeset/refresh-workspace-discovery.md
  • packages/intent/src/core/intent-core.ts
  • packages/intent/src/core/load-resolution.ts
  • packages/intent/src/core/project-context.ts
  • packages/intent/src/discovery/scanner.ts
  • packages/intent/src/discovery/walk.ts
  • packages/intent/src/setup/workspace-patterns.ts
  • packages/intent/tests/core.test.ts
  • packages/intent/tests/repeated-work.test.ts

Included 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

Layer / File(s) Summary
Filesystem-backed workspace cache
packages/intent/src/setup/workspace-patterns.ts
Workspace patterns, roots, and package directories now use cache instances instead of process-global caches.
Operation cache propagation
packages/intent/src/core/..., packages/intent/src/discovery/walk.ts, packages/intent/src/discovery/scanner.ts
Core operations pass the shared filesystem cache through project context, workspace package discovery, and workspace walking.
Selective workspace and skill scanning
packages/intent/src/discovery/scanner.ts, packages/intent/src/core/load-resolution.ts
Scanning filters candidate workspace roots and can omit skill metadata reads during direct resolution.
Workspace refresh and read-behavior tests
packages/intent/tests/core.test.ts, packages/intent/tests/repeated-work.test.ts, .changeset/refresh-workspace-discovery.md
Tests cover changed workspace members, patterns, allowlists, wildcard matching, symlink replacement, and skipped metadata reads. The changeset declares a patch release.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant listIntentSkills
  participant resolveProjectContext
  participant workspaceDiscovery
  participant skillScanner
  listIntentSkills->>resolveProjectContext: pass operation fsCache
  resolveProjectContext->>workspaceDiscovery: refresh roots and patterns
  workspaceDiscovery-->>resolveProjectContext: return workspace context
  listIntentSkills->>skillScanner: scan candidate package roots
  skillScanner-->>listIntentSkills: return matching skills without unused metadata
Loading

Merge Risk: ⚪ Minimal · up to 7ef44

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

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #236 requires 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…
Out of Scope Changes check ✅ Passed The changes stay within issue #236. Cache plumbing, direct-load metadata avoidance, workspace classification checks, symlink regression coverage, and the changeset support workspace refresh, source-ki…
Title check ✅ Passed The title clearly and concisely describes the primary change: refreshing workspace discovery for each operation.
Description check ✅ Passed The description is complete and relevant. It explains the motivation, implementation, verification, performance results, release impact, and changeset. The required test checklist item remains uncheck…
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.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-workspace-discovery-refresh

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.

@nx-cloud

nx-cloud Bot commented Sep 11, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit bb9c6a5

Command Status Duration Result
nx run-many --targets=build ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-11 20:45:19 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@tanstack/intent@267

commit: bb9c6a5

@codspeed-hq

codspeed-hq Bot commented Sep 11, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 47.1%

⚡ 3 improved benchmarks
✅ 6 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
loads a direct dependency from a large workspace 75.1 ms 41.8 ms +79.42%
loads a direct dependency skill 46.9 ms 32.7 ms +43.57%
loads direct dependency content as json 55.5 ms 44.9 ms +23.56%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix-workspace-discovery-refresh (68ad8e3) with fix-workspace-intent-warning (259ce1b)

Open in CodSpeed

@LadyBluenotes
LadyBluenotes force-pushed the fix-workspace-discovery-refresh branch from ea6b9d6 to 68ad8e3 Compare September 11, 2026 22:30
@LadyBluenotes
LadyBluenotes merged commit 54f7d97 into main Sep 11, 2026
8 of 9 checks passed
@LadyBluenotes
LadyBluenotes deleted the fix-workspace-discovery-refresh branch September 11, 2026 22:32
@github-actions github-actions Bot mentioned this pull request Sep 12, 2026
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.

Refresh workspace discovery between core API operations

1 participant