Skip to content
Source
Sign inSign up
TanStack/intent

perf: hoist relative package paths and reuse project context in intent stale #341

MergedLadyBluenotes(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/341/headmerged by LadyBluenotes(GitHub profile, opens in a new tab)

🎯 Changes

  • Thread the per-run fsCache through resolveStaleTargets, findWorkspaceRoot, findWorkspacePackages, scanForPolicedIntents, and filterStaleReportSkills so intent stale reuses cached project-context, workspace-pattern, and package.json reads instead of re-reading pnpm-workspace.yaml four times and root package.json twice.
  • Compile compileSkillSourcePolicy once in filterStaleReportSkills instead of calling isSourcePermitted (which recompiled the source policy) on every reported skill.
  • Hoist getRelativePackageDir(artifactRoot, packageDir) out of the per-artifact loops in buildArtifactSignals and buildWorkspaceCoverageSignals so path.relative is computed once per package instead of once per _artifacts entry, and check hasGeneratedSkill before computing uncovered-package metadata in buildWorkspaceCoverageSignals.
  • Reported staleness, coverage signals, and exit codes do not change.
  • Adds a patch changeset.
Benchmark (benchmarks/intent/stale.bench.ts, Node v24.14.1 win32 x64)Baseline (main cb45f14)Candidate (PR)Change
reports workspace drift53.45 hz (mean 18.71 ms, p75 19.46 ms, ±0.81%, N=535)58.54 hz (mean 17.08 ms, p75 17.22 ms, ±1.56%, N=586)-8.7% mean (1.10x hz)
reports workspace drift with shared artifacts46.80 hz (mean 21.37 ms, p75 22.29 ms, ±0.84%, N=469)55.52 hz (mean 18.01 ms, p75 18.36 ms, ±0.52%, N=556)-15.7% mean (1.19x hz)

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr (run pnpm build:all first).

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).
    1. 🦋 Changeset detected

      Latest commit: 16c71b9c2f9b8388911cedb07a71722cb9922349

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 1 package
      NameType
      @tanstack/intentPatch

      Not sure what this means? Click here to learn what changesets are.

      Click here if you're a maintainer who wants to add another changeset to this PR

    2. Review in Change Stack →

      Note

      Currently processing new changes in this PR. This may take a few minutes, please wait...

      ⚙️ Run configuration
      • Configuration used: defaults
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: d00df163-c19b-4521-835b-a09b825e19d5
      📥 Commits

      Reviewing files that changed from the base of the PR and between cb45f14ef6a6ba452ee85f5e2c4a3d98a90c8a05 and 447adafbe180384119c130a1bad31d509f4306fb.

      📒 Files selected for processing: 6
      • .changeset/stale-reuse-context-and-relpath.md
      • packages/intent/src/commands/stale.ts
      • packages/intent/src/commands/support.ts
      • packages/intent/src/core/source-policy.ts
      • packages/intent/src/staleness/check.ts
      • packages/intent/tests/repeated-work.test.ts
      +-----------------------------------------------------------+
      | Veni, Vidi, Codici Fixi. I came, I saw, I fixed the code. |
      +-----------------------------------------------------------+
        \
         \   (\__/)
             (•ㅅ•)
             /   づ
      ✨ Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autofix · 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.
    3. View your CI Pipeline Execution ↗ for commit 447adafbe180384119c130a1bad31d509f4306fb

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:sherif,t...✅ Succeeded41sView ↗
      nx run-many --targets=build✅ Succeeded1sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-10-19 01:06:03 UTC

    4. Open in StackBlitz

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

      commit: 447adaf

    5. Merging this PR will not alter performance

      :warning: 9 benchmarks spent significant time in system calls

      System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

      Measurement and system calls

      ✅ 12 untouched benchmarks


      Comparing perf/stale-reuse-context-and-relpath (16c71b9) with main (cb45f14) Open in CodSpeed

Sign in to join this conversation.