變更記錄 — 新手包 v17(修復 61154 P0 程序開 profile 丟失 Google 登入態 + 內置 8 條 SOCKS 隧道自動校整) 日期:2026-10-22|執行:A66(應主持 dj_host1 61154 P0 令,A65/A63 複核) ==================================================================================== 今版主題(應主持 61154 P0 令): 針對主持機 A/B 實測定位(「純 `_copy_seed_profile_to_ramdisk` + `_build_chromium_launch_args` 開 `myaccount.google.com` 100% 保持已登入;但行完整 `prompt-runner.py` / `watcher.py` 流程即刻丟失 Google 登入態變全新乾淨 profile」),逐段 5 步解剖定位出 **3 大直接破壞根因** 及 **2 項並發/分流保護加固**,並對稱修復 `scripts/watcher.py`(升至 `v10.6.4`)同 `scripts/prompt-runner.py`(升至 `v1.6.5-v10.6.4`)。 ------------------------------------------------------------------------------------ 一、5 步逐段解剖根因結論(有代碼行號與實測 SHA256/HMAC 證據,零靠估): ------------------------------------------------------------------------------------ - **破口 A(最致命主因|Step ② `_merge_ws_extension_layer` `L2310..2332` 篡改 `Preferences` 及注入殘缺 `Secure Preferences`)**: - 完整流程喺 `L10032`(`prompt-runner.py`)/`L9037`(`watcher.py`)同 `L5174` 呼叫 `_merge_ws_extension_layer(ws_src, profile_dir)`。 - 原代碼 `L2310..2332` 將外來 `ws-*`(如 `ws-11`)嘅 `extensions` 同 `protection.macs.extensions` 強行寫入席位 Google profile(如 `ai-58`)嘅 `Default/Preferences` 同 `Default/Secure Preferences`: ① 寫入外來 `protection.macs.extensions` 後**無重算 `protection.super_mac`**(實測 `expected=F62CD87EB8BF...` vs `got=673DCDD13ADA...`),直接觸發 Chromium `PrefHashFilter::VerifySuperMac()` 判定設定檔遭外部篡改; ② 當 `ai-58` 原本只有 `Preferences` 而無 `Secure Preferences` 時,`L2330` 用 `ws-11` 嘅 `Secure Preferences` 喺 `ai-58/Default/Secure Preferences` 新建咗一個只有 `299 B`(僅含 `extensions`,完全無 `account_info` / `google.services`)嘅殘缺 `Secure Preferences`!Chromium `SegregatedPrefStore` 優先讀取 `Secure Preferences`,見到 tracked identity prefs 缺失且 `super_mac` 不符,即刻執行 `ResetTrackedPref` 清空 Google 帳號綁定(`account_info`、`google.services.account_id`、`signin_scoped_device_id`),令 `AccountReconcilor` 將 `.google.com` session 視作無效而退回未登入狀態! - **破口 B(致命並發主因|Step ① `_clean_ramdisk_profiles` `L1922..1958` + `vnc-keep.sh` 跨進程抹除 `/dev/shm/watcher-profiles`)**: - 龍義機背景長期跑緊 `watcher.py`(`SEATS=A8 A9 A10`)同 `vnc-keep.sh`(每 5 秒一輪),同時前景執行 `prompt-runner.py --only 58`。 - 原版兩個程序共用同一個 `RAMDISK_PROFILES_DIR = /dev/shm/watcher-profiles`,且 `_stage_seed_profile_to_ramdisk`(`L2101`)每次切換席位都執行 `_clean_ramdisk_profiles(rroot_res, keep_profile=None)`(無條件 `shutil.rmtree` 刪除 `/dev/shm/watcher-profiles` 下所有 `ai-*` 目錄);加上 `vnc-keep.sh` 嘅 `ensure_watchers()` 只查 `run/watcher-$s.pid`(未查單一 Coordinator 嘅 `run/watcher-coordinator.pid`),每 5 秒觸發 `start-watcher.sh` 執行 `rm -rf /dev/shm/watcher-profiles`! - 當 `prompt-runner.py` 啱啱 stage 好 `/dev/shm/watcher-profiles/ai-58` 準備開 Chromium 時,背景 `watcher.py` 輪轉或 `vnc-keep.sh` 即刻將 `/dev/shm/watcher-profiles/ai-58` 連根刪走,令隨後啟動嘅 Chromium 喺空白路徑建立全新乾淨 profile("似一個全新乾淨 profile,攞唔返")! - **破口 C(次生主因|Step ① `_sanitize_profile_zoom_prefs` `L2116` + Step ③ `_stage_a_harvest_windscribe` `L2917`)**: - `_sanitize_profile_zoom_prefs` 喺開機前直接改寫 `Default/Preferences`(刪改 `partition.default_zoom_level`); - 當 `ws-*` LevelDB 直接收割 miss 時,`_stage_a_harvest_windscribe`(`L2917`)同 `_bootstrap_ws_extension_for_socks`(`L3472`)直接用 `str(profile_dir)`(即席位 Google profile)配裸 WireGuard SOCKS(`11080–11086`,繞過 `11090` `SERVER_DIRECT`)啟動 Chromium,令 Chromium 背景 Google 同步請求經非 Server IP 出口並覆寫 `Cookies`/`Preferences`。 ------------------------------------------------------------------------------------ 二、逐檔修復清單(v17): ------------------------------------------------------------------------------------ 1. `scripts/watcher.py`(`v10.6.4`,`484370 B`,`md5=1a42ae87a8f5534969c2fe8b6544b4ad`,`sha256=7e7902330121d5798dc2ee5eb51f874e9a1a6f030ba92457786d2f5329606e7b`)及 `scripts/prompt-runner.py`(`v1.6.5-v10.6.4`,`514457 B`,`md5=f56cab1e95aa199d2157051c9ec17493`,`sha256=057aa1d65975adeb2af6f44e089f8b4186ca478c7936cf5c8a554e7f9cefd7b9`): - **修復 ①**:`_merge_ws_extension_layer` 徹底移除對 `Default/Preferences` 同 `Default/Secure Preferences` 嘅讀寫(只複製 `Default/Extensions/` 同 `Default/Local Extension Settings/`),100% 保持席位 profile 原生 `Preferences`、`Secure Preferences`、`Cookies`、`Local State` 及 `PrefHashFilter` `super_mac` 零改動。 - **修復 ②**:`_stage_seed_profile_to_ramdisk` 新增 `verify_profile_google_session_integrity(ram_dir, reference_seed_dir=seed_dir)`,強制做複製後憑證檔(`Local State`、`Cookies`、`Network/Cookies`、`Preferences`、`Secure Preferences`、`Login Data`、`Web Data`)SHA-256 byte-level 對比;開機前 `_sanitize_profile_zoom_prefs` 預設 `force_write=False` 唔改寫磁碟 `Preferences`。 - **修復 ③**:`prompt-runner.py` 預設獨立使用 `/dev/shm/prompt-runner-profiles`(與 `watcher.py` 嘅 `/dev/shm/watcher-profiles` 完全物理隔離);同時 `.staged_by_watcher` 寫入 `sid:prof:pid:ts`,`_clean_ramdisk_profiles` 遇到其他在生 PID 持有嘅 profile 一律跳過保護。 - **修復 ④**:`_stage_a_harvest_windscribe` 同 `_bootstrap_ws_extension_for_socks` 若需開臨時收割 browser,強制透過 `_create_isolated_ws_stage_a_dir` 於隔離臨時目錄啟動,嚴禁觸碰席位 Google `profile_dir`;且先自動掃描本機所有可用 `ws-*` LevelDB 免開 browser 收割。 - **修復 ⑤**:`_resolve_seed_profile_dir` 優先選取含有真實憑證檔(`Cookies`/`Local State`)嘅 `PROFILES_DIR`(`local-profiles`),防空白 `workshop/profiles` 骨架目錄遮蔽;`_GOOGLE_ACCOUNT_EXACT_HOSTS` / `_GOOGLE_ACCOUNT_DOMAIN_SUFFIXES` 補齊 `play.google.com`、`id.google.com`、`consent.google.com`、`clients1..6.google.com`、`.clients6.google.com`、`.ogs.google.com` 經 `11090` `SERVER_DIRECT` 出;新增 `probe_myaccount_google_login_state` 驗證函式。 2. 更新 `vnc-keep.sh`、`start-watcher.sh`、`stack-watchdog.sh`、`update-programs.sh`、`verify-workshop.sh`: - `vnc-keep.sh` 嘅 `ensure_watchers()` 優先檢查 `run/watcher-coordinator.pid`,防止 Coordinator 在生時每 5 秒重跑 `start-watcher.sh`; - `start-watcher.sh` 以 `clean_stale_watcher_ramdisk` 取代盲目 `rm -rf /dev/shm/watcher-profiles`,保護在生 PID 並隔離 `/dev/shm/prompt-runner-profiles`。