Skip to content

fix(standalone): recognize encoded Bun virtual module URLs - #6098

Merged
lidge-jun merged 1 commit into
devfrom
codex/t4-issue-triage-standalone
Sep 27, 2026
Merged

lidge-jun merged 1 commit into
devfrom
codex/t4-issue-triage-standalone

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

On Windows, a compiled ocx.exe can report its bundled module URL with an encoded tilde (file:///B:/%7EBUN/root/...). isStandaloneModuleUrl only matched the literal ~BUN form, so the binary believed it was running from source: service commands, GUI asset lookup, package-integrity checks and runtime selection then took the source-tree path.

The helper now parses the URL, accepts only hostless file: URLs, decodes the pathname exactly once, and matches the Bun virtual root at the start of the path (/$bunfs/ or /<drive>:/~BUN/). Encoded tildes are recognized. Network-host file://server/... URLs, other schemes, double-encoded markers, malformed encoding and source paths that merely contain $bunfs deeper in the tree stay on the source path.

This is a narrow reimplementation of the standalone URL fix from #6079 by @luvs01. The rest of #6079 (Windows Desktop compatibility) stays under review in that PR. The structure map now lists src/lib/ under ops/service-and-sidecars.md, which already documents this helper.

Co-authored-by: luvs01 27862058+luvs01@users.noreply.github.com

Verification

  • bun test tests/lib/standalone.test.ts: red before the change (encoded Windows and network-host cases), then 5 pass / 0 fail.
  • bun run typecheck, bun run structure:check, bun run privacy:scan, git diff --check origin/dev...HEAD: exit 0 on this head.
  • Compiled binary probe on macOS (Bun 1.4.0, bun build --compile): import.meta.url was file:///$bunfs/root/probe and the new helper returned true, so the POSIX compiled path is unchanged.
  • bun run test:changed in a detached checkout of this exact commit (1297 files selected): 26181 pass / 47 skip / 20 fail. None of the failures is caused by this change. Rerun in isolation on this head, 16 of them pass (service SQLite-home, ownership state, service diagnostics, Codex and Grok toggle). The other four fail identically on unchanged origin/dev 24b2f39b on this machine: the retargeted-shim launchd case times out at 5 s, and the three launcher graceful-shutdown cases time out at 20 s. That points to machine load from parallel lanes.
  • Rebased onto dev 6d64ea26 (two Swift tray files), then onto 468b954c (fix(images): use managed Pool with proxy admission bearer, scope first #6097, image Pool admission). Neither touches this diff. Windows shards dispatched with lane=all passed on the 6d64ea26 head 9366801b (run 36333848482); the carry diff is identical on the current head. The test:changed numbers above come from the pre-rebase commit 08271bdf, whose TypeScript tree is identical. After the rebase, bun test tests/lib/standalone.test.ts (5 pass) and bun run structure:check were rerun.
  • Full local suite not run: seven release lanes are sharing this machine, so broad coverage is left to CI. Windows shards are dispatched with lane=all, since they run only on workflow_dispatch. No compiled Windows binary was run locally; the Windows URL shape is covered by the unit cases above.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration

Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: af607ab2-1b91-42f7-9017-3dc209de70a3

📥 Commits

Reviewing files that changed from the base of the PR and between 82f73a3 and c72b88c.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 057f8915-f44b-4bb4-adcc-b73994bcc113

📥 Commits

Reviewing files that changed from the base of the PR and between 24b2f39 and 08271bd.

📒 Files selected for processing (5)
  • src/lib/standalone.ts
  • structure/INDEX.md
  • structure/manifest.json
  • structure/ops/service-and-sidecars.md
  • tests/lib/standalone.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.


📝 Walkthrough

Walkthrough

isStandaloneModuleUrl now parses URLs and recognizes hostless file: URLs whose once-decoded pathname starts with a Bun virtual root. Tests cover accepted and rejected URL forms. Repository documentation describes the detection rules.

Changes

Standalone URL detection

Layer / File(s) Summary
URL detection and supporting updates
src/lib/standalone.ts:10-18, tests/lib/standalone.test.ts:20-31, structure/ops/service-and-sidecars.md:236-241, structure/INDEX.md:135, structure/manifest.json:453
The predicate requires the file: protocol and an empty host. It checks the once-decoded pathname for the $bunfs or Windows ~BUN virtual root, and returns false if parsing or decoding fails. Tests cover encoded Windows markers, double encoding, network-host URLs, nested markers, HTTPS URLs, and malformed encoding. The operations documentation and structure index and manifest describe the updated rules.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 08271

The code, tests, and documentation agree on which Bun virtual-root URLs are recognized, and no concrete user-facing failure is established. Windows standalone runtime behavior has not been directly exercised and remains a platform-validation item.

Architecture Summary

Architecture risk: 🔵 Low · up to 08271

The change affects 3 systems.

Changed systems: src, structure, tests

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 1 changed file maps to changed impact.
  • observed — structure (service) was modified; 3 changed files map to changed impact.
  • observed — tests (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/lib/standalone.ts: isStandaloneModuleUrl now validates the parsed URL’s file: protocol and empty host, checks the once-decoded pathname against the bundled-module and Windows virtual-root forms, and returns false on parsing or decoding errors. This replaces raw-URL substring and regex checks.
  • observed — Modified behavior in structure/INDEX.md: The src/lib/ row adds ops/service-and-sidecars.md to its described-by documents; the previous row did not include it.
  • observed — Modified behavior in structure/manifest.json: Added src/lib/ to the source paths documented by ops/service-and-sidecars.md.
  • observed — Modified behavior in structure/ops/service-and-sidecars.md: The standalone description changes from detecting the Bun $bunfs runtime to recognizing hostless file: module URLs whose once-decoded pathname begins at $bunfs or Windows ~BUN; network-host and nested source paths do not qualify. The service command and GUI directory descriptions remain.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (3 skipped: 3… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: recognizing encoded Bun virtual module URLs in standalone detection.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (3 skipped: 3 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@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 Sep 27, 2026
@lidge-jun
lidge-jun marked this pull request as ready for review September 27, 2026 15:49
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 27, 2026 15:49
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 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-09-27T15:52:36.058791Z 08271bd Draft marked ready
ℹ️ 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.

@lidge-jun

Copy link
Copy Markdown
Owner Author

리뷰 · 우선순위 40 / 80

윈도우에서 컴파일한 ocx.exe는 자기 파일 주소를 file:///B:/%7EBUN/root/...처럼 적을 수 있어요. 물결표 ~가 %7E라는 글자로 바뀌어 있어요. 예전 검사는 물결표가 그대로 있는 ~BUN만 찾았어요. 그래서 이 주소를 소스 폴더에서 실행 중인 것으로 봤어요. 서비스 명령, 화면 파일 위치, 패키지가 온전한지 보는 검사, 실행 방식 선택이 소스 폴더 기준으로 돌아가요.

이제는 주소를 읽어서 판단해요. file:이고, 다른 컴퓨터 이름이 붙어 있지 않을 때만 봐요. 경로의 인코딩은 한 번만 풀어요. 풀린 경로가 /$bunfs/로 시작하거나, /B:/~BUN/처럼 드라이브 글자 다음에 ~BUN이 있으면 컴파일된 프로그램으로 봐요. %7E와 소문자 %7e는 여기 들어가요. %257E처럼 두 번 감싼 주소, file://server/..., https://, 폴더 한가운데에만 $bunfs가 있는 주소는 소스 쪽으로 남아요. 테스트가 이 경우를 잠가 두었어요. 베이스는 dev예요.

이 조각은 #6079에 있던 주소 판별만 따로 가져온 거예요. #6079의 나머지 윈도우 데스크톱 작업은 그 PR에 있어요.

라인 - src/lib/standalone.ts isStandaloneModuleUrl. 이 리눅스 Bun에서 같은 조건으로 돌리면 테스트와 같아요. %7E는 컴파일된 것으로 보고, %257E와 file://server/$bunfs/...는 소스로 봐요. 어긋나는 결과는 없었어요. 윈도우에서 빌드한 exe의 실제 주소는 이 커밋에서 확인하지 않았어요.

메인테이너의 판단이 필요한 지점

#6079 헤드의 같은 함수는 다른 컴퓨터 이름을 거르지 않아요. 그 PR이 나중에 머지되면 file://server/$bunfs/...를 다시 컴파일된 프로그램으로 볼 수 있어요. 이 PR을 먼저 넣을지, #6079의 standalone.ts를 이 버전으로 맞출지 정해 주세요.

윈도우 exe를 한 번 실행해 보는 일을 머지 조건으로 둘지도 정해 주세요. 지금 테스트는 주소 문자열만 봐요.

너의 추천

이 PR을 머지하세요. 거절해야 하는 주소가 테스트에 있어요. #6079를 머지할 때는 parsed.host !== "" 검사를 지우지 마세요. 다음 윈도우 빌드에서 import.meta.url이 file:///B:/%7EBUN/...인지 한 번 보면 충분해요.

이 댓글은 grok-bot이 작성했습니다

@lidge-jun
lidge-jun force-pushed the codex/t4-issue-triage-standalone branch 2 times, most recently from 9366801 to 82f73a3 Compare September 27, 2026 18:19
Reimplements the isolated standalone URL detection fix from #6079 on dev.
Hostless file URLs can decode one layer to recognize Windows ~BUN while
source and network-host URLs remain outside the compiled-binary path.

Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com>
@lidge-jun
lidge-jun force-pushed the codex/t4-issue-triage-standalone branch from 82f73a3 to c72b88c Compare September 27, 2026 18:45
@lidge-jun
lidge-jun merged commit ef4e994 into dev Sep 27, 2026
31 checks passed
@lidge-jun
lidge-jun deleted the codex/t4-issue-triage-standalone branch September 27, 2026 19:39
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