Repository navigation
[Chore] Correct Turbo cache inputs and add a build cache input contract - #2324
zoomote2[bot] wants to merge 2 commits into
Conversation
- Restore default ($TURBO_DEFAULT$) build inputs; the restrictive src/** list omitted package-root entry files such as the webview index.html. - Hash shared extension source and src/package.json into the webview build, and shared source into webview typechecking, via $TURBO_ROOT$ inputs (plain ../.. globs are silently dropped by Turbo). - Declare PKG_RELEASE_CHANNEL and VSCODE_TEXTMATE_DEBUG as webview build env inputs, and PKG_RELEASE_CHANNEL and POSTHOG_API_KEY for the extension bundle; both are embedded in build output by esbuild/vite. - Hash repo-root README, CHANGELOG, LICENSE, .env, and webview audio assets into the extension bundle; vsce packages copies of these that the old dist-only vsix inputs never invalidated. - Couple check-types to @roo-code/types#build; consumers typecheck against the types package source, so its changes must invalidate.
Add src/scripts/verify-build-cache-inputs.mjs, following the existing coverage cache-input contract pattern: a detached git worktree plus turbo --dry=json probes assert that shared source, the webview entry HTML, package version, repo-root packaging files, webview audio assets, and release/debug env inputs invalidate the right tasks; identical inputs stay reusable; unrelated env stays out of every hash. Wire the contract into code-qa on both OS lanes so a stale webview or extension bundle is never restored as a cache hit.
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one): 1
Please check the settings in the CodeRabbit UI or the
|
|
3 issues outstanding. See session
Reviewed ce56479 |
| "build": { | ||
| "outputs": ["../src/webview-ui/**"] | ||
| "outputs": ["../src/webview-ui/**"], | ||
| "inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/src/shared/**", "$TURBO_ROOT$/src/package.json"], |
There was a problem hiding this comment.
The hashed inputs stop at src/shared/**, but the shared-source import closure escapes the directory:
src/shared/modes.ts:12runtime-imports../core/prompts/sections/custom-instructions, which importssrc/services/roo-config(@roo/modesis imported by 19 webview files, so thecheck-typesclosure typechecks both files, and the bundle includes them unless tree-shaking drops the function).src/shared/tools.ts:5type-imports../services/destructive-command-guard/runner, whichcheck-typesalso typechecks.
An edit to src/core/prompts/sections/custom-instructions.ts, src/services/roo-config/**, or src/services/destructive-command-guard/runner.ts changes the real typecheck/build results while the @roo-code/vscode-webview#build and #check-types hashes stay identical, so CI can restore a stale webview bundle or a stale typecheck verdict — the same false-hit class this PR exists to fix. The new contract only probes src/shared/package.ts, so it cannot catch this.
Suggested fix: hash the escape roots and pin the choice with a contract probe.
| "inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/src/shared/**", "$TURBO_ROOT$/src/package.json"], | |
| "build": { | |
| "outputs": ["../src/webview-ui/**"], | |
| "inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/src/shared/**", "$TURBO_ROOT$/src/core/**", "$TURBO_ROOT$/src/services/**", "$TURBO_ROOT$/src/package.json"], | |
| "env": ["PKG_RELEASE_CHANNEL", "VSCODE_TEXTMATE_DEBUG"] | |
| }, | |
| "check-types": { | |
| "dependsOn": ["@roo-code/types#build"], | |
| "inputs": ["$TURBO_DEFAULT$", "$TURBO_ROOT$/src/shared/**", "$TURBO_ROOT$/src/core/**", "$TURBO_ROOT$/src/services/**"] | |
| } |
Whole-directory globs trade hit rate for correctness; the narrower alternative is per-file entries for the three escape targets, but those rot when src/shared imports change. A contract case that edits custom-instructions.ts and asserts both tasks invalidate would pin whichever set you pick.
| const worktreeCommit = () => { | ||
| const result = spawnSync("git", ["stash", "create"], { cwd: root, encoding: "utf8" }) | ||
| if (result.status === 0 && result.stdout.trim()) return result.stdout.trim() | ||
| return "HEAD" | ||
| } |
There was a problem hiding this comment.
This silent HEAD fallback drops the guard the sibling contract has for the same call. git stash create can exit 1 with empty output on Windows when stale index metadata refreshes to a clean tracked tree — but if the tracked tree is actually dirty, falling back to HEAD here silently probes the last commit's committed turbo.json files instead of the working tree, so all eleven cases pass against stale config. Real git failures (lock contention, safe.directory) also land in this branch.
verify-coverage-cache-inputs.mjs:65-78 (stashCommit) handles exactly this: a quiet exit-1 is trusted only after git status --porcelain --untracked-files=no confirms a clean tracked tree, and everything else throws. Reusing that guard keeps local runs honest.
| "$TURBO_ROOT$/README.md", | ||
| "$TURBO_ROOT$/CHANGELOG.md", | ||
| "$TURBO_ROOT$/LICENSE", | ||
| "$TURBO_ROOT$/.env", |
There was a problem hiding this comment.
.env never reaches the bundle output: esbuild.mjs takes POSTHOG_API_KEY from the process environment rather than the file, copyPaths lands it at src/.env, .vscodeignore has no !.env so vsce strips it from the VSIX, and it is not a declared task output. Hashing it can only add cache misses, never prevent a stale hit.
Fine to keep as intentional hardening — but then say so in a comment next to the entry, and consider correcting the PR description, which currently says esbuild copies all of these "into dist" (the copies land in the src/ package dir).
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Review statusThis PR was opened by an automated account. A human maintainer must verify the change intent, provenance, and validation before merging. Current step: Mark the PR ready. Required CI must pass before CodeRabbit starts. Review-state labels are managed by this workflow; do not edit them manually. |
Related GitHub Issue
Closes: #2290
Description
This PR corrects the Turbo cache inputs for the build and static tasks. Identical inputs now reuse the cache. Changed inputs now invalidate the right tasks. The commits are split: the input corrections land first. The verification harness lands second.
Correctness fixes (commit 1):
turbo.json:builduses$TURBO_DEFAULT$again. The oldsrc/**list is package-relative. It missed package-root entry files such aswebview-ui/index.htmlandpublic/**.webview-ui/turbo.json: the webview build now hashes$TURBO_ROOT$/src/shared/**and$TURBO_ROOT$/src/package.json. Vite imports the shared source through the@roo/*alias. Vite reads the package version intoPKG_VERSION. The build declaresPKG_RELEASE_CHANNELandVSCODE_TEXTMATE_DEBUGas env inputs. Both are embedded in the bundle byvite.config.ts. Webviewcheck-typeshashes the shared source too. Its tsconfig includes../src/shared.src/turbo.json: the extensionbundlenow hashes$TURBO_ROOT$/README.md,CHANGELOG.md,LICENSE,.env, and$TURBO_ROOT$/webview-ui/audio/**. esbuild copies all of these intodist. The bundle declaresPKG_RELEASE_CHANNELandPOSTHOG_API_KEYas env inputs. Both are embedded byesbuild.mjsdefines.vsixnow hashes$TURBO_DEFAULT$,dist/**, and the generated packaging files. vsce reads README, CHANGELOG, LICENSE, andpackage.nls*.json; the olddist/**-only list missed them.turbo.json:check-typesdepends on@roo-code/types#build. Consumers typecheck against the types package source (see itsexportsmap). A types source change must invalidate every dependent typecheck.Key discovery: Turbo 2.11.10 drops
../..-style input globs without any warning. Only$TURBO_ROOT$-prefixed paths hash files outside a package.Reuse evaluation (issue step 3, no code change):
code-qa.ymlalready persists.turbo/cacheper OS with a lockfile and commit key. That is the simplest justified reuse. A shared Turbo remote cache would add credentials and a fork-PR write-permission boundary, and its cross-OS safety still needs proof. It stays an evaluation. No new cache service ships here. Release workflows run direct package scripts without Turbo, so release artifacts never come from a cache.Audit notes:
process.platformandPKG_SHA(git SHA) defines are unreferenced in webview source. The bundle output is OS- and SHA-independent today. Git metadata cannot cause false hits. CI cache keys already include the commit SHA.Test Procedure
pnpm --dir src run verify:build-cache-inputs. The new contract creates a detached git worktree and probesturbo --dry=jsonhashes. It checks eleven cases: shared source, entry HTML, package version, repo-root packaging files, audio assets, release and debug env inputs, unrelated env isolation, types source coupling, and reuse stability.pnpm --dir src run verify:coverage-cache-inputs. The existing contract still passes (9/9).index.html,src/shared/**,src/package.json, rootREADME.md, webview audio, andPKG_RELEASE_CHANNELchanged none of the relevant hashes. On this branch, each edit invalidates the correct tasks, and identical inputs keep hashes stable.pnpm testpasses (14/14 Turbo tasks; 12,455 tests).pnpm --dir src exec eslint --prune-suppressions --max-warnings=0 scripts/verify-build-cache-inputs.mjsadds no suppression entries. Prettier passes on all touched files.Pre-Submission Checklist
src/test-utils/,@/utils/test-utils) are used only for mechanical duplication; test intent and scenario-specific mocks remain visible.Visual Snapshots
None. This is a CI-only change. No rendered surface changes.
Videos (interaction / animation only)
None.
Documentation Updates
Additional Notes
contents: readand no new credentials.