Codex/agc browser orphan cleanup #461

Merged
lhk229 merged 11 commits from codex/agc-browser-orphan-cleanup into master 2026-09-22 19:05:21 +08:00

11 Commits

Author SHA1 Message Date
lhk229 260727c77a Merge branch 'master' into codex/agc-browser-orphan-cleanup
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
2026-09-22 19:04:55 +08:00
lhk229 9f152e353d Merge branch 'codex/agc-browser-orphan-cleanup' of https://git.genarrative.world/git/GenarrativeAI/Genarrative into codex/agc-browser-orphan-cleanup
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 1m13s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m0s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 6m28s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 8m28s
Project CI / Backend tests (pull_request) Successful in 7m17s
Project CI / Native shell tests (pull_request) Successful in 7m49s
Project CI / Frontend tests (pull_request) Successful in 4m57s
Project CI / Repository checks (pull_request) Successful in 4m19s
Project CI / AI game creator shell web tests (pull_request) Successful in 3m57s
2026-09-22 18:29:38 +08:00
lhk229 17fb0d8444 Merge branch 'master' into codex/agc-browser-orphan-cleanup
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
2026-09-22 18:29:30 +08:00
lhk229 19ed2f2c2f 清扫与收束再加固:Linux 命令行绑定、快照 fail-closed、收割未确认保留目录
sweep.rs:Linux 杀前要求 /proc/pid/cmdline 含 --user-data-dir=<本目录>/profile,把 PID 绑到配置目录;Windows/macOS 注释标明已知残余风险
sweep.rs:进程快照枚举错误一律报错(仅 ERROR_NO_MORE_FILES 为正常结束),残缺快照不再误报收割完成
sweep.rs:追踪列表记录每个成员的启动身份并在终止前复核,排除 PID 复用误杀;root 死后按旧父 PID 继续发现孤儿(PID 已复用则不发现)
process.rs:修正注释——Windows 没有 root 死亡级联退出,spawn 与 Job 绑定的逸出窗口为毫秒级
process.rs:launch_owned_browser 持有 TempDir,启动失败或收束未确认时保留目录与 owner.json,交跨会话清扫收割
2026-09-22 17:57:09 +08:00
lhk229 6b215d30e5 Merge branch 'master' into codex/agc-browser-orphan-cleanup
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
2026-09-22 17:29:29 +08:00
lhk229 b280521bdc Merge remote-tracking branch 'origin/master' into codex/agc-browser-orphan-cleanup
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m14s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 1m46s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 7m4s
Project CI / Backend tests (pull_request) Successful in 5m57s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 8m12s
Project CI / Native shell tests (pull_request) Successful in 7m22s
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
2026-09-22 17:07:55 +08:00
lhk229 2b24da2557 加固浏览器清扫与收束:杀前镜像复核、收割结果确认、镜像默认视口
sweep.rs:杀前新增活进程镜像路径复核(Windows QueryFullProcessImageNameW / Linux /proc/pid/exe),打开失败 fail-closed 拒绝
sweep.rs:Unix 新增属主目录 euid 检查,拒绝他人在 /tmp 伪造的 ga-browser-* 目录
sweep.rs:Windows 杀树改为追踪制,全部成员从快照消失才报成功,root 先死子进程残留不再误报
sweep.rs:Unix 检查 kill 返回值并以 kill(pid,0) 确认进程消失后才报成功
process.rs:reap 返回 root 退出确认,非 Windows confirm_reaped 用 try_wait 兜底,挂起/杀失败暴露为 browser-cleanup-unconfirmed
process.rs:handler_config 镜像 BrowserConfigBuilder 默认 viewport(Some 800x600),与旧 Browser::launch 行为一致
测试:杀树两个用例断言整树成员真实消失,新增镜像复核测试
2026-09-22 17:06:09 +08:00
lhk229 bce465429d Merge branch 'master' into codex/agc-browser-orphan-cleanup
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 1m42s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m11s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 7m57s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 7m9s
Project CI / Backend tests (pull_request) Successful in 5m54s
Project CI / Native shell tests (pull_request) Successful in 7m50s
Project CI / Frontend tests (pull_request) Successful in 4m31s
Project CI / Repository checks (pull_request) Successful in 4m15s
Project CI / AI game creator shell web tests (pull_request) Successful in 4m37s
2026-09-22 15:35:34 +08:00
lhk229 225bf18239 Merge remote-tracking branch 'origin/master' into codex/agc-browser-orphan-cleanup
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
2026-09-22 12:45:45 +08:00
lhk229 feb2e100c4 新增跨会话清扫陈旧无头浏览器,避免残留进程放大预检超时
- browser/sweep.rs:新增清扫模块,launch 时向 ga-browser-* 目录写入 owner.json 身份锚点(浏览器 root PID 与启动身份、可信 exe 路径、App 属主 PID 与身份)
- browser/sweep.rs:清扫按属主存活跳过、进程已退出或 PID 复用只删目录、root 存活且身份一致才杀整树分级处置,杀树前要求 exe canonical 匹配系统标准浏览器候选路径,防止伪造 owner.json 借刀杀进程
- browser/sweep.rs:Windows 用 ToolHelp 快照走树终止 root 及全部后代并逐轮复核 root 身份,Unix 只杀 root 由子进程级联退出;无 owner.json 的旧版本残留只删目录不按猜测杀进程,五分钟内的目录一律跳过防止误伤进行中的预检
- main.rs:App 启动时后台异步清扫并把处置记录写入应用日志,不阻塞窗口
- environment_check/web_creation.rs:每次 Web 预检前顺手清扫一遍,防同会话残留放大超时
- browser/process.rs:launch 时写 owner.json,暴露临时目录前缀常量
- process_session/tests.rs:Job 杀树测试的 timeout fixture 在 stdio 重定向下会立即退出导致空转通过,改用 ping fixture 并补杀前树非空断言
- browser/sweep.rs:新增年龄门禁、活实例跳过、死进程只删不杀、坏 owner 按旧残留、可信 exe 匹配与 Windows 快照走树收割的定向测试
2026-09-22 12:38:18 +08:00
lhk229 2596be6afc 修复 Web 预检浏览器启动失败时泄漏无头浏览器进程树
- browser/process.rs:改用公开的 BrowserConfig::launch() 自持 spawn,root 进程从启动起归调用方所有,不再经 Browser::launch 黑盒启动
- browser/process.rs:Windows 下 spawn 后立即把 root 挂进 KILL_ON_JOB_CLOSE 的 WindowsProcessJob,失败、超时或宿主被杀时整棵进程树由 Job 保证回收,堵住无父进程无头浏览器的累积泄漏
- browser/process.rs:自行解析 stderr 的 DevTools ws 地址并做 loopback 严格校验与输出上限,给原先无超时的 CDP 连接补上 30 秒超时
- browser/process.rs:新增 OwnedBrowser/BrowserProcessGuard 统一收尾,close-wait 失败时 TerminateJobObject 杀整树并确认树空,stderr 持续 drain 防止浏览器因管道写满卡死
- browser/process.rs:check_browser_health 与 validate_local_preview_in_browser_with_cancellation 两个调用点改走新路径,对外错误文案与语义不变
- process_session/tests.rs:新增 Windows Job terminate 收割进程树的定向测试
- browser/process.rs:新增 ws URL 只接受 loopback、HandlerConfig 镜像 BrowserConfig builder 的单元测试
2026-09-22 12:06:42 +08:00