Skip to content

fix(cache): hash every lockfile in the economics context - #107

Merged
adityankale190895 merged 3 commits into
DiffCI:mainfrom
sarankumar1325:fix/economics-context-shared-lockfiles
Nov 11, 2026
Merged

adityankale190895 merged 3 commits into
DiffCI:mainfrom
sarankumar1325:fix/economics-context-shared-lockfiles

Conversation

@sarankumar1325

Copy link
Copy Markdown
Contributor

Part of #97 (this PR covers the economics-context.ts file; the issue says one PR per file is fine)

economicsContext in src/cache/economics-context.ts builds the cache key for Vue analysis from a hand-written lockfile list. That list missed npm-shrinkwrap.json, so editing it kept the old context hash and reused a stale analysis.

  • src/repo/lockfiles.ts now exports LOCKFILE_NAMES next to LOCKFILE. It lists the same files as names, for code that needs names rather than a regex.
  • economicsContext uses ...LOCKFILE_NAMES in place of its own list, so it now includes npm-shrinkwrap.json.

impact.ts, file-references.ts and git-diff.ts (PACKAGE_LOCKFILES) are not changed here and can follow in their own PRs. CONFIG_PATTERNS is not touched, as the issue asks.

Tests

  • New tests/cache/economics-context.test.ts. For each lockfile name, it checks that creating the file changes the context, and that changing its contents changes it again. The npm-shrinkwrap.json case fails without the fix.
  • New tests/repo/lockfiles.test.ts. It checks that every name in LOCKFILE_NAMES matches LOCKFILE, that each name the pattern accepts is in the list, and that near-misses (bun.lockbb, pnpm-lock.yml, …) are rejected.
  • Results: npx tsx --test tests/repo/lockfiles.test.ts tests/cache/*.test.ts passes, and npm run typecheck is clean.

#105 also imports LOCKFILE in a test, but it touches different files, so the two PRs don't conflict.

economicsContext spelled out its own lockfile list and missed
npm-shrinkwrap.json, so editing it reused a stale Vue analysis. Export
LOCKFILE_NAMES next to the shared LOCKFILE pattern and use it here.

Part of DiffCI#97

Signed-off-by: sarankumar1325 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T05:30:33.879704Z 71994f9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71994f9b74

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

export function economicsContext(repoPath: string): string {
const scope = readRepositoryConfig(repoPath).vue;
const paths = new Set(["diffci.json", "package.json", "tsconfig.json", "go.mod", "go.sum", "go.work", "go.work.sum", "pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock", "bun.lockb", ...["ts", "js", "mts", "mjs", "cts", "cjs"].map(ext => `vitest.config.${ext}`)]);
const paths = new Set(["diffci.json", "package.json", "tsconfig.json", "go.mod", "go.sum", "go.work", "go.work.sum", ...LOCKFILE_NAMES, ...["ts", "js", "mts", "mjs", "cts", "cjs"].map(ext => `vitest.config.${ext}`)]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Hash scoped package lockfiles

When diffci.json points vue.packageRoot at a nested package whose dependencies are governed by a lockfile there (for example, packages/ui/pnpm-lock.yaml), this spread adds only root-relative lockfile names, so changes to the package's lockfile leave the cache namespace unchanged. analyzeVueCached can then reuse a Vue contribution after that package's resolved dependencies change. Include scoped lockfile paths and test them with a nested packageRoot.

Useful? React with 👍 / 👎.

sarankumar1325 and others added 2 commits November 11, 2026 11:19
A diffci.json vue.packageRoot can have its own lockfile (for example
packages/ui/pnpm-lock.yaml). Only root lockfiles were hashed, so a change
there reused a stale Vue analysis. Hash every lockfile name under the
package root as well, with a test per name.

Signed-off-by: sarankumar1325 <[email protected]>
@adityankale190895
adityankale190895 merged commit 1c1688c into DiffCI:main Nov 11, 2026
11 checks passed
@adityankale190895

Copy link
Copy Markdown
Member

Thanks @sarankumar1325, all three are merged: #105, #106 and this one. Clear write-ups, a failing test for each fix, and quick follow-ups on the review comments made these easy to land.

One thing for next time: new files under tests/ need an entry in release-files.json, or npm run audit:boundary fails in CI. I added those entries to your branches so you didn't have to.

If you'd like to try DiffCI on one of your own JavaScript or TypeScript repositories, run this from the repo root:

npx "@diffci.com/diffci@latest" check

It shows which tests your current change affects, and when it falls back to the full suite, it says why. If anything looks wrong (a missed test, an unexpected fallback), we'd really like to hear about it in a community result or a new issue. And if you find the project useful, a star on the repo helps other people find it.

The rest of #97 (impact.ts, file-references.ts and PACKAGE_LOCKFILES in git-diff.ts) is still open if you'd like to pick it up.

adityankale190895 added a commit that referenced this pull request Nov 11, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: adityankale190895 <[email protected]>
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.

2 participants