Skip to content

fix(vz): helper self-terminates on stdin EOF; surface clipboard .waiting#124

Merged
TimLai666 merged 2 commits into
mainfrom
claude/inspiring-chaum-208d84
Jul 11, 2026
Merged

fix(vz): helper self-terminates on stdin EOF; surface clipboard .waiting#124
TimLai666 merged 2 commits into
mainfrom
claude/inspiring-chaum-208d84

Conversation

@TimLai666

Copy link
Copy Markdown
Owner

Summary

實機(Apple Silicon)發現的兩個 vz 問題的修復,均已於同一台實機驗證:

  1. helper/VM 殘留:對 chefer-runtime 單發 SIGINT/SIGTERM(非終端 Ctrl+C 的整組 process group 訊號)時,helper 收不到訊號、VM 殘留繼續吃 CPU(vz-smoke.shkill -INT 即觸發)。
    • vz.rs 改以 Stdio::piped() spawn helper,stdin 寫端 fd 隨 runtime 行程存亡(mem::forget);
    • helper(main.swift)由專屬執行緒代讀 stdin、轉發進 VZ serial(hvc0 輸入路徑不變),讀到 EOF 即自我了結(VM 在行程內,exit 即拆 VM);
    • stdin 泵送只在 manifest 有 terminal/both 服務時才做(vz_util::needs_console_stdin_pump,含單元測試),其他 app 不讀使用者終端輸入。
  2. 剪貼簿連線卡 .waiting 完全靜默:NWConnection 連 guest:55381 偶發卡 .waiting 數十秒或永不成功(同時 nc 可秒連;疑為 macOS 區域網路隱私權對 ad-hoc 簽章 helper 的閘門)。
    • .waiting 現在有 tracef + 一次性 stderr 提示(引導到 系統設定 → 隱私權與安全性 → 區域網路 放行);
    • 3 秒未 ready 即棄連重連(帶 generation 防抖;reconnect() 加去重 guard);
    • build-vz-helper.sh 支援 CHEFER_CODESIGN_IDENTITY(預設仍 ad-hoc),穩定簽章身分讓 TCC 記得授權。

DESIGN.md §6 已補「Helper 生命週期(stdin liveness 契約)」與剪貼簿 .waiting 可見性兩段。

Verification

  • 全 workspace cargo test(21 suites, 0 failed)、cargo fmt --checkcargo clippy 乾淨;helper 以 swiftc 編譯 + entitlement 簽章成功。
  • 實機真 VM E2Ekill -INT <runtime pid> → runtime 5 秒寬限後 exit 130 → helper 立即印 stdin closed 收攤,+10s 無殘留(修前永久殘留);guest exit 7 → 單檔 exit 7 傳播不變;runtime </dev/null 執行不會誤殺 app。
  • helper 行為煙霧測試:stdin 立即 EOF → exit 0;stdin 開啟 + 假 kernel → 照舊 exit 5。

Notes

  • .waiting 提示/重連路徑為編譯級 + 邏輯驗證;TCC 閘門情境需下次實機 GUI run 觀察(CHEFER_CLIP_TRACE=1)。
  • packed 單檔的端到端還需要 extract.rs「解壓還原 tar mode」修復(主 checkout 未 commit 的實機驗證批次內)——origin/main 上解壓後 agents/ 無執行位、spawn helper 直接 EACCES。
  • 行為變更:非 terminal app 的終端按鍵不再被吞進 guest console;手動跑 helper 時 < /dev/null 會立即結束(檔頭已註明)。
  • 合併後可把 vz-smoke.sh 收尾的 pkill 治標改成「斷言無 helper 殘留」(AGENTS.md Follow-ups)。

🤖 Generated with Claude Code

TimLai666 and others added 2 commits July 11, 2026 19:51
實機發現的兩個問題(詳見 DESIGN §6):

1. 對 chefer-runtime 單發 SIGINT/SIGTERM(非終端 Ctrl+C 的整組訊號)時
   helper/VM 殘留繼續吃 CPU。修法:vz.rs 以 piped stdin spawn helper 並讓
   寫端 fd 隨行程存亡;helper 專屬執行緒代讀 stdin 轉發進 VZ serial
   (hvc0 輸入路徑不變),EOF 即自我了結。stdin 泵送只在有 terminal/both
   服務時才做(vz_util::needs_console_stdin_pump,含單元測試)。
   實機 E2E:kill -INT 後 ~6s helper 收攤、無殘留;exit code 傳播不變。

2. ClipboardHost 連 guest:55381 偶發卡在 NWConnection .waiting(原本落在
   default 分支完全靜默)。現在印一次性 stderr 提示(引導區域網路隱私權
   放行)、3 秒未 ready 棄連重連;build-vz-helper.sh 支援
   CHEFER_CODESIGN_IDENTITY 取得穩定簽章身分讓 TCC 記住授權。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…dth char into var name

CI 的 swiftc compile-check 以 C locale 跑 bash 3.2,`$identity)` 的全形括號
位元組被吃進變數名 → set -u 報 unbound variable(UTF-8 locale 下不會踩到)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@TimLai666
TimLai666 merged commit 0e26125 into main Jul 11, 2026
10 checks passed
@TimLai666
TimLai666 deleted the claude/inspiring-chaum-208d84 branch July 11, 2026 12:07
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.

1 participant