Skip to content
Source
Sign inSign up
TanStack/intent

fix: refresh workspace discovery for each operation #267

MergedLadyBluenotes(GitHub profile, opens in a new tab)merged 2 commits intofix-workspace-intent-warning fromrefs/pull/267/headmerged by LadyBluenotes(GitHub profile, opens in a new tab)

🎯 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.

CaseCommands per batchBefore #267RepairedMean reduction
Direct load path101.82791.554515.0%
Direct load JSON102.31141.995213.7%
Direct load, 120-package workspace103.52351.672652.5%
Workspace list35.83795.77021.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. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      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 2578ef765e6ecf82660c2c7187cc7a55468dfcfd and 7ef4453a20d7bf4361e86c9285bac1e1d60e121f.

      📒 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

      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 nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring 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 nameStatusExplanation
      Linked Issues check✅ PassedIssue #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✅ PassedThe 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✅ PassedThe title clearly and concisely describes the primary change: refreshing workspace discovery for each operation.
      Description check✅ PassedThe 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.
    2. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit bb9c6a52d138352de2a845a249cc2033efee0d3e

      CommandStatusDurationResult
      nx run-many --targets=build✅ Succeeded2sView ↗

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

    3. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented

      Open in StackBlitz

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

      commit: bb9c6a5

    4. codspeed[bot](GitHub profile, opens in a new tab)commented

      Merging this PR will improve performance by 47.1%

      ⚡ 3 improved benchmarks ✅ 6 untouched benchmarks

      Performance Changes

      BenchmarkBASEHEADEfficiency
      ⚡loads a direct dependency from a large workspace75.1 ms41.8 ms+79.42%
      ⚡loads a direct dependency skill46.9 ms32.7 ms+43.57%
      ⚡loads direct dependency content as json55.5 ms44.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

Sign in to join this conversation.