Skip to content

PX-398: avoid fnm multishell paths in service launchers - #6030

Closed
andrew05060414 wants to merge 2 commits into
lidge-jun:devfrom
andrew05060414:agent/engineer-arknights/px-398-fnm-service
Closed

andrew05060414 wants to merge 2 commits into
lidge-jun:devfrom
andrew05060414:agent/engineer-arknights/px-398-fnm-service

Conversation

@andrew05060414

@andrew05060414 andrew05060414 commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Verification

  • bun run typecheck — passed (bun x tsc --noEmit, exit 0).
  • bun run structure:check — passed (structure/ SSOT checks passed).
  • bun test tests/service/service-fnm-launcher.test.ts — 4 passed, 0 failed.
  • bun test tests/service/launchd-repair.test.ts — 59 passed, 0 failed, 221 expect calls. This includes the stale launchd PATH cleanup case and asserts no launchctl/bootout calls.
  • bun test tests/service/service.test.ts — 207 passed, 3 skipped, 0 failed, 693 expect calls.
  • bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts — 18 passed, 0 failed, 553 expect calls.
  • bun test tests/cli/cli-connect-readiness.test.ts — 22 passed, 0 failed, 123 expect calls.
  • bun test tests/codex-integration/codex-shim.test.ts --test-name-pattern "fnm multishell|durable node installation" — 1 passed, 1 skipped, 0 failed.
  • bun run privacy:scan — passed (Privacy scan passed).
  • git diff --check — passed.
  • The three service files above were run separately because the existing suites mutate process environment variables globally; a single multi-file Bun invocation can interleave those fixtures and produce two environment-path assertion failures, while the isolated commands are clean.
  • Full bun test tests/codex-integration/codex-shim.test.ts — 87 passed, 9 skipped, 10 failed. The failures are Windows powershell.exe cases blocked by the host execution policy when running generated temporary scripts; the focused fnm regression test passed.
  • Linux real-machine UAT has not been run. NAS, Oracle, and Mac are currently using the already-migrated Bun-global launcher, so that state cannot prove the old fnm scenario.
  • Proposed UAT, not executed and awaiting Andrew's confirmation: use Oracle ARM Ubuntu aarch64 (the known fnm / Node v24.20.0 reproduction), back up service state, set only the recorded launcherPath to a disposable fnm_multishells/<id>/bin/ocx path, run this branch's ocx service repair, verify stale diagnosis, durable replacement/direct Bun runtime, and a systemd ExecStart without fnm_multishells; then verify reboot recovery and restore the saved state.

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.

This PR is intentionally a Draft until confirmed Linux real-machine UAT is complete; no review-ready claim is checked.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

避免将 fnm 的 shell 临时路径写入服务,并提示 Codex shim 缺失状态。
让 launchd 清理旧 plist 的临时 PATH 而不重启健康服务,并让 Windows 服务脚本复用同一过滤规则。
@coderabbitai

coderabbitai Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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
@github-actions

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

This PR stays in draft until every box above is ticked.

@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 62 / 80

이 PR은 서비스가 fnm 같은 도구의 잠깐 쓰는 폴더를 시작 경로로 기억하지 않게 한다. fnm은 터미널이 켜질 때마다 fnm_multishells/번호/bin 폴더를 PATH 맨 앞에 넣는다. 그 터미널에서 ocx service install을 하면 Linux systemd, Mac launchd, Windows 작업 스케줄러가 그 폴더를 서비스 설정에 적어 둔다. 터미널을 닫으면 폴더는 사라진다. 서비스는 없는 파일을 실행하려고 다시 시작을 반복할 수 있다.

막는 방법은 이렇다. 경로 한 칸이 asdf_multishells, fnm_multishells, mise_multishells, nvm_multishells, volta_multishells이면 오래 쓰는 실행 파일로 치지 않는다. 그런 ocx만 있으면 그 경로를 버리고, Bun으로 직접 띄운다. 세 운영체제의 서비스 설정은 PATH를 저장하기 전에 그 칸을 뺀다. Mac에서는 이미 정상인 launchd 작업을 끄지 않고, 설정 파일 안의 임시 PATH만 지운다. ocx connect로 Codex를 연결하면, shim이 없거나 깨졌을 때 OPENCODEX_API_AUTH_TOKEN이 없어 Missing environment variable이 날 수 있다고 알려 준다. Codex shim을 설치할 때는 fnm 임시 링크를 실제 Node 설치 경로까지 따라간 다음 그 파일을 감싼다.

기준 브랜치는 dev다. 같은 주제로 열려 있는 다른 PR은 없다. 작성자가 Draft로 두었고, Linux 실제 기기 확인은 아직 하지 않았다.

src/service/launchd.ts:551 - 임시 PATH를 설정 파일에서만 지운다. 지금 돌아가는 프로세스는 그대로 둔다. 그런데 화면에는 "service is already loaded from the current plist; nothing to do."라고 찍는다. 파일은 바뀌었는데 할 일이 없다고 말한다. 반환값도 reloaded: false다. 터미널을 닫은 뒤 그 프로세스는 다음 재시작 전까지 없어진 폴더를 PATH에 가진다.

src/service/repair.ts:167 - 수리를 이미 하는 중에 경고가 "ocx service repair를 실행하라"고 한다. 문장은 src/service/state.ts:100의 상태 진단 문장이다. 수리 시작 알림으로 쓰면 사용자가 같은 명령을 또 쳐야 하는 것처럼 보인다.

src/codex/shim.ts:151 - 서비스는 다섯 가지 폴더 이름을 칸 전체로 비교한다. shim은 fnm만 보고, 비교 방식도 다르다. src/codex/shim.ts:166에서 실제 경로가 임시 폴더 안에 남으면 그 경로를 그대로 쓴다. src/codex/shim.ts:985는 그 경로의 파일을 백업하고 shim으로 덮어쓴다. 그 파일이 임시 폴더 안의 복사본이면 터미널이 끝날 때 shim도 같이 사라진다.

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

Mac에서 건강한 서비스를 끄지 않는 것은 #4236을 지키려는 선택이다. 임시 PATH가 이미 죽은 폴더라면, 파일만 고쳐서 지금 프로세스가 그 경로를 계속 쓴다. 잠깐 재시작해도 되는지, 다음 부팅까지 둘지 정해야 한다.

Linux 실제 기기 확인은 작성자도 아직 안 했다고 적었다. Oracle ARM에서 fnm으로 한 번 보기 전에는 머지하지 않는 편이 맞다. Draft와 체크리스트 0/4도 그 상태다.

너의 추천

임시 폴더를 서비스 설정에 넣지 않는 방향이 이 고장의 원인과 맞다. 머지 전에 세 가지를 고치면 된다. launchd가 파일을 고쳤으면 고쳤다고 말하고, 필요하면 재시작 여부를 드러낼 것. 수리 중 경고는 "임시 경로를 빼고 다시 기록하는 중"처럼 지금 하는 일을 말할 것. shim도 서비스와 같은 폴더 이름 규칙을 쓰고, 경로가 임시 폴더 밖에 있지 않으면 그 파일을 덮어쓰지 말고 실패로 알릴 것. Linux 실제 기기 확인 전에는 Draft를 유지할 것.

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

@Ingwannu

Copy link
Copy Markdown
Owner

Early draft blocker on exact head 740b68da542c7bf98c9f9063a3c214e9d1095e93: normalizePreviousLaunchdPlist returns the entire previous plist whenever the filtered PATH values match, without proving the rest of the plist matches. Example: loaded job has old PATH=/fnm_multishells/id/bin:/usr/bin; desired plist removes that prefix and changes HTTPS_PROXY. PATH normalization matches /usr/bin, so the function adopts the whole old plist, the later byte comparison sees no change, and the non-PATH repair is silently skipped.

Compare full plist bytes after normalizing only the previous PATH field, rather than returning the whole previous plist on PATH equality. Add a regression combining fnm path cleanup with a simultaneous environment/property change. Holding approval while the PR remains draft; no functional exact-head CI is present yet.

@lidge-jun

Copy link
Copy Markdown
Owner

Thanks, @andrew05060414. The release train 4 bug-hardening lane reviewed this and is leaving it open, because it cannot land as-is.

  • The branch conflicts with current dev across 17 paths.
  • The launchd repair rewrites the plist, but nothing reloads the running job, so the fix does not reach the live service until a manual bootout/bootstrap.
  • A service-launcher change also has to preserve the package-local runtime and the non-PATH environment the current launchers carry. That needs lifecycle proof on both Linux (systemd) and macOS (launchd), and the unit tests here do not provide it.

A narrower version would be welcome: the multishell PATH filter alone in the service owner, rebased on dev, with a test that shows the live job picks up the change. That would be much easier to take.

@lidge-jun

Copy link
Copy Markdown
Owner

Thanks @andrew05060414. This change landed on dev through the carry in #6168 (merged as 2d5228e), which keeps your authorship with a Co-authored-by trailer and folds in the review fixes. Closing this PR as superseded.

@lidge-jun lidge-jun closed this Sep 28, 2026
@andrew05060414
andrew05060414 deleted the agent/engineer-arknights/px-398-fnm-service branch September 29, 2026 14:06
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.

3 participants