Skip to content

fix(cache): correct the default store-directory table and adopt the effected sweep surfaces - #209

Merged
C. Spencer Beggs (spencerbeggs) merged 1 commit into
mainfrom
dev
Aug 3, 2026
Merged

C. Spencer Beggs (spencerbeggs) merged 1 commit into
mainfrom
dev

Conversation

@spencerbeggs

@spencerbeggs C. Spencer Beggs (spencerbeggs) commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Adopts the effected post-loop-sweep surfaces (round-7 tail) and fixes the cache-directory correctness bug that came with them.

The cache-dir fix

Three cells of the default store-directory table were wrong, so a macOS or Windows job archived directories its package manager never writes to — a cold cache rather than a failure, which is why it survived a release. The table now comes from @effected/npm's PackageManagerCache, which cites an authority per row.

Manager Platform Was Now
pnpm macOS ~/.local/share/pnpm/store ~/Library/pnpm/store
yarn Classic macOS — ~/Library/Caches/Yarn
yarn Classic Linux ~/.yarn/cache ~/.cache/yarn
yarn Berry Linux/macOS ~/.cache/yarn ~/.yarn/berry/cache
yarn Berry Windows — %LocalAppData%\Yarn\Berry\cache
bun Windows %LocalAppData%\bun\install\cache ~/.bun/install/cache

~/.yarn/cache was never either yarn's global cache. deno stays local policy — it is out of the kit's vocabulary by scoping.

The five adoptions

Each deletes a hand-roll, with no change to the cache keys a run produces:

  • GitHubContext.headRef + branch replaces the raw GITHUB_HEAD_REF/GITHUB_REF fallback chain in restore-cache.ts, folded into the single env.github read that already supplied the workspace. The kit encodes the trap that the runner writes GITHUB_HEAD_REF as the empty string on non-PR events.
  • CacheKey.digest replaces both hand-rolled sha256(…).slice(0, 8) sites. Concatenating before hashing keeps the segments byte-identical.
  • ChildEnv.prependPath / needsShell replace pathKeyOf, childEnv and needsShell in install-dependencies.ts. The child's PATH is now joined with the target platform's delimiter rather than the host's.
  • filenamesFor supplies the lockfile names. The workspace-config extras (pnpm-workspace.yaml, .pnpmfile.cjs, .pnp.cjs, .yarn/install-state.gz) and deno's row stay local, per the round-7 ruling. The resulting pattern set is unchanged — this action's table already carried npm-shrinkwrap.json and bun.lockb.
  • PackageManagerCache.defaultDirectory — the table above.

One behavior change

A tag push now keys its cache under the tag name. The chain this replaces saw a ref that was not refs/heads/* and answered "", so every tag in the repository shared the one branchless bucket. Depth 3 of RESTORE_DEPTHS drops the branch segment, so a cold tag still restores what the branch it was cut from saved. Pinned by a new test.

On the EADDRINUSE item

Already fixed in the released code, not carried here. Both listeners in turbo-cache.test.ts bind port 0 and read the assigned port back under Effect.acquireUseRelease, and no test binds 41230 — the remaining literals are formatting and state-schema fixtures with no listener behind them. That landed in #206, so 1.3.0 contains it; no test failure appears in the last 60 CI runs.

Verification

  • 456 unit tests pass (up 1 — the new tag-push case)
  • pnpm typecheck and pnpm build clean; dist/ and .github/actions/local/ committed
  • Store-path coverage now pins Linux, macOS and Windows separately; macOS was previously untested, which is how the pnpm cell stayed wrong

Closes #207

Signed-off-by: C. Spencer Beggs spencer@savvyweb.systems

Correct package-manager cache paths and use shared cache helpers.

  • Correct pnpm, Yarn, and Bun cache defaults across macOS, Linux, and Windows.
  • Use shared cache keys, GitHub context, environment, and shell helpers.
  • Preserve existing cache-key inputs and local workspace and Deno policies.
  • Use tag-specific cache keys with cross-branch fallback restore behavior.
fix(cache): correct package-manager cache directories

- Correct pnpm, Yarn, and Bun cache defaults across supported platforms.
- Use shared cache, GitHub context, environment, and shell helpers.
- Preserve existing cache-key inputs and local workspace and Deno policies.
- Restore tag caches by tag name with cross-branch fallback.

Closes `#207`
Signed-off-by: C. Spencer Beggs <spencer@savvyweb.systems>

…ffected sweep surfaces

The default cache-directory table had three wrong cells, so a macOS or Windows job archived directories its package manager never writes to. That is a cold cache rather than a failure, which is why it survived a release.

It now comes from PackageManagerCache, which cites an authority per row: pnpm's macOS store, both yarn rows, and bun on Windows all move.

Four hand-rolled helpers give way to the upstream surfaces that replace them, with no change to the cache keys a run produces.

GitHubContext.branch takes the branch fallback chain, CacheKey.digest both short-digest sites, ChildEnv the child PATH and the Windows shell rule, and filenamesFor the lockfile names.

The workspace-config patterns and deno's rows stay local, since neither is in the kit's vocabulary.

One behavior change falls out of GitHubContext.branch: a tag push now keys under the tag rather than sharing the branchless bucket with every other tag. The cross-branch restore rung means a cold tag still restores what its branch saved.

Closes #207
Signed-off-by: C. Spencer Beggs <spencer@savvyweb.systems>
Copilot AI review requested due to automatic review settings August 3, 2026 02:09
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1334a1dc-b206-4640-8533-1437e13d0080

📥 Commits

Reviewing files that changed from the base of the PR and between fb13424 and 310dd48.

⛔ Files ignored due to path filters (9)
  • .changeset/olive-parrots-swim.md is excluded by !.changeset/**
  • .github/actions/local/dist/main.js is excluded by !**/dist/**
  • .github/actions/local/dist/post.js is excluded by !**/dist/**
  • .github/actions/local/dist/turbo-server.js is excluded by !**/dist/**
  • CLAUDE.md is excluded by !**/CLAUDE.md
  • dist/main.js is excluded by !**/dist/**, !dist/**
  • dist/post.js is excluded by !**/dist/**, !dist/**
  • dist/turbo-server.js is excluded by !**/dist/**, !dist/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • __test__/unit/steps/cache-config.test.ts
  • __test__/unit/steps/install-dependencies.test.ts
  • __test__/unit/steps/restore-cache.test.ts
  • package.json
  • src/steps/cache-config.ts
  • src/steps/install-dependencies.ts
  • src/steps/restore-cache.ts

📝 Walkthrough

Walkthrough

Changes

Cache and runtime alignment

Layer / File(s) Summary
Shared cache configuration
src/steps/cache-config.ts, package.json, __test__/unit/steps/cache-config.test.ts
Cache configuration now uses shared lockfile, package-manager, and cache-key utilities. Tests cover platform-specific cache paths.
Platform-aware child environments
src/steps/install-dependencies.ts, __test__/unit/steps/install-dependencies.test.ts
Dependency installation delegates PATH construction and shell selection to ChildEnv. Windows PATH behavior is tested explicitly.
Combined GitHub cache context
src/steps/restore-cache.ts, __test__/unit/steps/restore-cache.test.ts
Cache restoration reads workspace and branch values together. Tests cover pull requests, branches, and tags.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the cache-directory corrections and adoption of the upstream @effected surfaces.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch dev

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.

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​effected/​github-actions@​0.4.07810010090100

View full report

Copilot AI 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.

Pull request overview

This pull request updates the action’s dependency-caching behavior and internal “kit” integrations by adopting newer @effected/* surfaces, while fixing incorrect default package-manager cache-directory paths that previously caused cold caches on some platforms.

Changes:

  • Fix default package-manager cache directory detection by delegating to @effected/npm’s PackageManagerCache.defaultDirectory and expanding platform-specific test coverage.
  • Adopt new upstream helpers (GitHubContext.branch, CacheKey.digest, ChildEnv.*, filenamesFor) to replace local hand-rolled logic.
  • Update dependencies and document the new adopted surfaces, including a changeset entry.

Reviewed changes

Copilot reviewed 9 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/steps/restore-cache.ts Switches GitHub context reads to a single env.github decode (workspace + branch), including tag-keying behavior.
src/steps/install-dependencies.ts Replaces local PATH/shell logic with ChildEnv.prependPath and ChildEnv.needsShell.
src/steps/cache-config.ts Uses PackageManagerCache.defaultDirectory, filenamesFor, and CacheKey.digest to build cache paths and key segments.
test/unit/steps/restore-cache.test.ts Updates env fixtures for GITHUB_REF_NAME and adds a tag-push cache-keying test.
test/unit/steps/install-dependencies.test.ts Adjusts assertions to validate target-platform PATH delimiter behavior.
test/unit/steps/cache-config.test.ts Splits cache-path assertions across Linux/macOS/Windows and validates corrected directories.
package.json Bumps @effected/* and @vitest-agent/plugin versions to adopt post-sweep surfaces.
pnpm-lock.yaml Updates lockfile to reflect the dependency bumps.
CLAUDE.md Updates repository documentation to reflect new imported surfaces and versions.
.changeset/olive-parrots-swim.md Adds a patch changeset documenting the cache-dir fix and refactors.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

Comment on lines +132 to +134
* `ChildEnv.needsShell` decides the launch, and all four managers take its
* `true` on win32 — bun included, which is this call site's own ruling rather
* than the kit's. bun is the exception that shows the shape of the rule:
@savvy-web-bot

savvy-web-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Code Review

Current Commit: 310dd48

Summary

A tight, correctness-focused change that swaps five hand-rolled surfaces for @effected/* kit equivalents and — in doing so — fixes a real caching bug. The three wrong cells in the default store-directory table (pnpm on macOS, yarn Classic/Berry swap, bun on Windows) meant those jobs archived directories the manager never writes to: a silent cold cache, which is exactly why it survived to a release. Sourcing the table from PackageManagerCache.defaultDirectory with a cited authority per row is the right fix.

What I verified

  • keySegments byte-identity — the streaming digest (update(a).update(b).update(c)) is equivalent to concatenating with an empty separator and hashing once, so CacheKey.digest produces the same segment. cacheBust/tool-sort/pm ordering is preserved. ✅
  • context() merge in restore-cache.ts — folding branch + workspace into one env.github read (with a shared process.cwd()/"" fallback) is sound; the two can no longer disagree about whether a context exists. The GitHubContext.branch fallback (headRef → refName) correctly sidesteps the refs/pull/N/merge trap and the empty-string GITHUB_HEAD_REF gotcha. ✅
  • Tag-push behavior change — genuinely an improvement, and well-pinned: the new test asserts a tag gets its own segment and that depth 3 of RESTORE_DEPTHS still restores across from the cutting branch, so no cold-tag regression. ✅
  • ChildEnv.prependPath / needsShell — the empty-prepends guard is retained locally (kit signature refuses it), and the child PATH now joins with the target platform's delimiter. The test update catching the host-vs-target :-vs-; divergence is a nice latent-bug catch. ✅

Test coverage

Excellent. macOS was previously untested for store paths — which is precisely how the pnpm cell stayed wrong — and it's now pinned separately alongside Linux and Windows. The tag-push case is new and meaningful.

One minor note (non-blocking)

Copilot flagged the docstring at src/steps/install-dependencies.ts:132-134 — that calling the bun-on-win32 shelling "this call site's own ruling rather than the kit's" reads oddly now that ChildEnv.needsShell(platform) owns the decision and is platform-only. I read the comment as defensible: the call site's actual ruling is the choice not to special-case bun out of the shell path, applying needsShell uniformly. It documents a real design intent rather than phantom code, so I don't consider it actionable — but a one-line tightening ("we apply needsShell uniformly rather than exempting bun") would remove the ambiguity if you're touching the file again. I've left Copilot's thread as-is.

Validation

All checks green: Tests, Code Quality, Markdown, Conventional Commits, PR Title Validation. dist/ and .github/actions/local/ are committed alongside source, per the build contract.

Clean, correct, and well-tested — the docstrings-as-rationale style makes the intent easy to audit. Approving.

@savvy-web-bot savvy-web-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All validation checks green; correctness fix and kit adoptions verified. Approving.

@spencerbeggs
C. Spencer Beggs (spencerbeggs) merged commit d5c8c68 into main Aug 3, 2026
70 checks passed
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.

Cleanup round: adopt the effected post-loop-sweep surfaces (round-7 tail) — includes a cache-dir correctness fix

2 participants