Skip to content

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

Merged
LadyBluenotes merged 2 commits into
mainfrom
perf/stale-reuse-context-and-relpath
Oct 19, 2026
Merged

LadyBluenotes merged 2 commits into
mainfrom
perf/stale-reuse-context-and-relpath

Conversation

@LadyBluenotes

Copy link
Copy Markdown
Member

🎯 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 drift 53.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 artifacts 46.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).

…t stale

- Pass the per-run fsCache through resolveStaleTargets, workspace package
  enumeration, scanForPolicedIntents, and filterStaleReportSkills so
  pnpm-workspace.yaml and package.json manifests are read once per stale run.
- Compile the skill source policy once in filterStaleReportSkills instead
  of once per reported skill.
- Compute getRelativePackageDir(artifactRoot, packageDir) once per package
  in buildArtifactSignals and buildWorkspaceCoverageSignals instead of on
  every artifact entry.
@changeset-bot

changeset-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 16c71b9

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

This PR includes changesets to release 1 package
Name Type
@tanstack/intent Patch

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

@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

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 cb45f14 and 447adaf.

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

@nx-cloud

nx-cloud Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 447adaf

Command Status Duration Result
nx affected --targets=test:eslint,test:sherif,t... ✅ Succeeded 41s View ↗
nx run-many --targets=build ✅ Succeeded 1s View ↗

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

@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 447adaf

@LadyBluenotes
LadyBluenotes merged commit 1ff7b0f into main Oct 19, 2026
7 checks passed
@LadyBluenotes
LadyBluenotes deleted the perf/stale-reuse-context-and-relpath branch October 19, 2026 01:05
@github-actions github-actions Bot mentioned this pull request Oct 19, 2026
@codspeed

codspeed Bot commented Oct 19, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 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 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