Skip to content

fix(runtime): scope server children's transpiler cache and keep scoping idempotent - #7364

Merged
lidge-jun merged 3 commits into
devfrom
fix/transpiler-cache-scope-followup
Oct 19, 2026
Merged

lidge-jun merged 3 commits into
devfrom
fix/transpiler-cache-scope-followup

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Follow-up to #7362 (merged as 93a9016), addressing the non-blocking review findings from gemini-4-argon. Rebased onto dev; it contains only the follow-up commits.

  1. Server children on the bundled runtime still evicted the runner's cache. src/server/startup-health-cache.ts (startup-health probe behind /api/settings), src/server/startup-action-control.ts (dashboard startup install) and src/server/windows-tray-control.ts start durableBunPath() directly, without bin/ocx.mjs. Under the 1.4.3 test runner that path is the bundled 1.4.2 binary, which inherited the unscoped shard cache and rewrote the runner's entries. Settings tests such as tests/server/logs-timezone.test.ts trigger it. A new durableBunChildEnv() in src/lib/bun-runtime.ts scopes the cache to the child's version only when the durable runtime is the bundled binary and differs from the running Bun; otherwise the env is returned unchanged. All three spawn sites use it.

    Measured: a warm runner cache (378 entries, format 34), then bun test tests/server/logs-timezone.test.ts:

    runner root after the test
    before 609 × format 28 + 171 × format 34 (runner entries evicted)
    after 782 × format 34; bundled entries only under bun-1.4.2/
  2. Nested launches no longer nest the scope. A launcher started from an already launched process inherited <cache>/bun-1.4.2 and produced <cache>/bun-1.4.2/bun-1.4.2. The helper now re-scopes a trailing bun-<version> segment in place.

  3. Root-level scopes keep their root. /bun-1.4.2/, C:\bun-1.4.2\ and UNC paths re-scope to /bun-<v>, C:\bun-<v> and \\srv\share\bun-<v>. A bare C: would be drive-relative, so a drive root keeps its separator. Relative (bun-1.4.2, .) and drive-relative (C:bun-1.4.2) scopes also re-scope in place, and a drive-relative parent stays drive-relative. A name that merely ends in bun-<v> (xbun-1.4.2) stays an ordinary parent. (Found in review rounds 1–2.)

  4. Version pattern matches findPathBun. Prerelease identifiers with hyphens and +build metadata are accepted (bounded to 64 characters). The alphabet still has no separator, drive colon or NUL.

  5. Adds src/lib/bun-transpiler-cache-scope.d.mts, matching the other launcher .mjs helpers, so TypeScript callers are typed.

Verification

  • tests/cli/bun-transpiler-cache-scope.test.ts: 7 pass, including root-level, relative and boundary cases. Windows forms checked with native path.win32.
  • Independent review: gpt-6.1-sol (3 rounds) and gemini-4-argon, no blocking findings on the final head. New cases cover in-place re-scoping (POSIX and Windows separators, a non-version bun-* parent), prerelease/build/oversized versions, and durableBunChildEnv choosing scope only across a version change.
  • After the rebase onto dev: startup-action, startup-health, launcher-runtime, logs-timezone and tests/lab/core-lab-boundary.test.ts: 123 pass, 0 fail.
  • bun x tsc --noEmit, bun run structure:check and scripts/file-size-ratchet.ts pass.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (structure/ops/cross-platform-ci.md.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (The scoped directory stays under the inherited protected path; the version segment is validated.)

@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner October 19, 2026 08:01
@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: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 2b5b993e-c0b7-4f47-981e-f1f70d4cb833
📥 Commits

Reviewing files that changed from the base of the PR and between 93a9016 and 5372630.

📒 Files selected for processing: 8
  • src/lib/bun-runtime.ts
  • src/lib/bun-transpiler-cache-scope.d.mts
  • src/lib/bun-transpiler-cache-scope.mjs
  • src/server/startup-action-control.ts
  • src/server/startup-health-cache.ts
  • src/server/windows-tray-control.ts
  • structure/ops/cross-platform-ci.md
  • tests/cli/bun-transpiler-cache-scope.test.ts
+-----------------------------------------------------------------------------+
| I took both the red pill and the blue pill. Now I'm stuck in a code review. |
+-----------------------------------------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)
✨ 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T08:05:45.997062Z 0719870 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.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Oct 19, 2026
Base automatically changed from fix/windows-spawn-timeouts-2-89 to dev October 19, 2026 08:04
…ng idempotent

Server spawns of the bundled runtime (startup-health probe, dashboard startup
install, Windows tray) bypassed the launcher and still evicted the test
runner's cache. Scope them through durableBunChildEnv when the child is a
different Bun version; re-scope an already scoped path in place; accept
prerelease/build versions; type the helper.
@lidge-jun
lidge-jun force-pushed the fix/transpiler-cache-scope-followup branch from e8fc42d to aedd824 Compare October 19, 2026 08:05

@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: 071987095e

ℹ️ 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".

Comment thread src/lib/bun-transpiler-cache-scope.mjs Outdated
Comment on lines +47 to +48
const tail = SCOPED_TAIL.exec(cache);
const base = tail && validVersion(tail[2].slice(4)) ? (tail[1] || cache.slice(0, cache.length - tail[2].length)) : cache;

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 Track scoped state without parsing arbitrary cache paths

For an explicit cache root ending in a valid-looking version, such as /protected/bun-1.2.3, this heuristic treats the operator's directory as a generated scope and changes it to the sibling /protected/bun-1.4.2, potentially writing executable cache data outside the configured directory. Conversely, . first scopes to the bare path bun-1.4.2, which this separator-dependent match does not recognize on the next launch, producing bun-1.4.2/bun-1.4.2. Both valid inputs violate the documented override-preservation/idempotence contract, so scoped state needs an unambiguous marker or preserved original base rather than inference from the final directory name.

AGENTS.md reference: structure/AGENTS.md:L9-L10

Useful? React with 👍 / 👎.

@lidge-jun
lidge-jun merged commit 7dfc141 into dev Oct 19, 2026
31 of 34 checks passed
@lidge-jun
lidge-jun deleted the fix/transpiler-cache-scope-followup branch October 19, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant