Skip to content

fix: repair CLI and host contracts, harden runtime cleanup, and prune dead code - #8985

Merged
huangruiteng merged 3 commits into
mainfrom
codex/review-fixes-20261118
Nov 18, 2026
Merged

huangruiteng merged 3 commits into
mainfrom
codex/review-fixes-20261118

Conversation

@hhyykk

@hhyykk hhyykk commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

Repair reproducible gaps found in a repository audit. Base: main at 3c03e91e6.

  • CLI, host, and packaging: register the Postgres command through the normal CLI path, fix host input and error handling, and include extension manifests in the standalone Core build. Normalize invalid inputs in content operations, workspace reads, and Lark progress.
  • Control plane: stop disposable runtimes after every Linux thread has exited, preserve direct-child reaping, and close lock and research subprocesses on failure. Remove 17 status/quota re-exports with no remaining in-tree consumers after chore(examples): prune 100 zero-reference ceremonial and parity smokes #8883. Clean up unused implementation paths.
  • Repository: align documentation and CI links with the canonical repository. Update type-check scopes, release and publication smokes, and lint.

Author Declaration

  • Written by: model_agent (Google Antigravity and OpenAI Codex).
  • Implemented against: no written specification. The repository audit and current CLI, runtime, and distribution contracts are the basis.
  • Self-check: inspected callers, checked all changed text paths and 56 canonical documentation targets, and checked the audited open PRs for file overlap.

Scope And Continuation

Existing follow-ups cover release recovery, stale canary configuration, and adjacent control-plane refactors. Publication policy, desktop rollback retention, and broader dead-code candidates require separate review. See #8703, #8737, #8890, #8898, #8908, #8936, #8965, #8972, and #8973.

Validation

  • Tested revision: c4c30344e3e4d78019e5e51d72d6886f225487d7. Earlier broad checks are marked separately.
  • Run state: finished.
  • Input classes: synthetic, public_fixture.
  • Runtime: Node 24.21.0 with SQLite 3.53.4. SQLite-backed selected tests ran without filtering. Node 25.5.0 on the earlier host path embedded SQLite 3.51.2, below the project's WAL-reset qualification threshold.
Check kind Result Public-safe evidence / limitation
Static Passed Control-plane and dashboard TypeScript, Ruff over the selected source trees, Mypy (17 configured source files), bilingual RFC diff, and Git whitespace checks. Chat bundle built and source verification passed.
Unit and integration Passed 213 Python tests for the audited code, Antigravity runtime and adapter, Explore results, and contract health. Six disposal cases passed, including a runtime locator change, live worker threads, and direct process reaping.
Unit Passed 134 TypeScript control-plane tests and 67 OpenCode tests. This includes SQLite checkpoints, authority, handler loading, and shadow drain.
Real entrypoint Passed Postgres setup help and the CLI/help, preset, doc-book, release artifact, frontstage share, and local-install smokes. The macOS and Windows installers were outside this local run.
Installed Core Passed Built the standalone 2.4.0 wheel, installed it into an isolated environment, and passed all 48 distribution and installed-context tests.
Quick premerge Passed Six direct checks and four selected checks.
Static Passed Changed-path public boundary scan covered all 143 existing changed files, with zero blockers.
Standard premerge Timed out The default 120-second budget expired for examples/install-local-smoke.py. The same smoke passed on its own with a higher limit. The other nine catalog cases, all eight risk-profile cases, direct checks, and the changed-path scan passed.
Repository hygiene Failed on baseline files Full-tree scan and repository-hygiene smoke flag existing test identifiers in unchanged files. A separate release timeline check reports the missing v2.3.0 entry. The full-tree command also includes local registry health diagnostics.
Earlier regression suite Passed with skips 208 passed and 41 skipped before the rebase. The separate Core wheel run qualifies installed-package paths.

Frontend / Visual Evidence

  • UI impact: none. The frontend changes cover build diagnostics and asset delivery. The local Frontstage Share smoke verifies published assets.

Type of Change

  • Bug fix
  • Documentation update
  • Test update

Boundary Checklist

  • PR payload and changed files were checked for private material.
  • Bilingual RFC and whitespace checks passed.
  • All three commits carry a DCO sign-off.

Signed-off-by: aihop <4408344+hhyykk@users.noreply.github.com>
Signed-off-by: aihop <4408344+hhyykk@users.noreply.github.com>
Signed-off-by: aihop <4408344+hhyykk@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T04:44:06.578885Z c4c3034 PR opened
ℹ️ 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.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · Gemini · Google (self_reported)

已针对 PR #8985 exact head c4c30344e3e4d78019e5e51d72d6886f225487d7 完成全量代码审查(按 PR 实际 merge-base 3c03e91e6736f129d78e7c895b9d4a871f132a7f 核查全部 144 个变更文件 +1350 / -1117;注:远端 baseRefOid 已推进至 0d4233f723,使用三点 diff ...HEAD 对应精确分支改动)、跨仓引用检索与本地实测验证(审查结论:APPROVE,无 P0/P1 阻断问题,附 1 项非阻断 P2 关注与主干既往 CI lint 说明)。

动机 / Motivation

受影响调用方与运维者:运行 loopx postgres、loopx explore、loopx opencode2-goal-worker、loopx content-ops、loopx preset 的 CLI 运维者,使用 OpenCode / OpenCode2 / Pi / Claude Code / Antigravity Goal 桥接与个人工作区代理(/api/goals)的 Host 运行时调用方,构建 loopx-core 独立分发包的维护者,以及阅读公开文档、Skill 链接与维护 loopx/control_plane/、loopx/status.py、loopx/quota.py 死代码边界的开发者。

修改前(3c03e91e6736f129d78e7c895b9d4a871f132a7f):审计发现多处可复现缺口,包括 loopx/cli.py 在 build_parser() 漏注册 register_postgres_commands 且 _main() 保留已由 dispatch_common_command 处理的 6 组不可达冗余分派块;opencode2_goal_worker.py 将子进程诊断打到 stdout 破坏 --format json 且掩盖 ok=False;effect_runtime.py 在 Linux 容器场景遇到孤儿僵尸进程组(leader Z 而工作线程未退出)与 explore_research_terminal.ts / shadow_drain_files.ts 子进程关闭路径缺少 rl.close() / SIGKILL 升级保护;remote_authority_policy.ts 未先校验 digest 长度即调用 timingSafeEqual;opencode_goal_mode / opencode2_goal_mode 锁文件接受 pid <= 0 且 waitPlan 未适配 cold_path_detail.local_scheduler 与 unchanged_poll.limits;claude_goal_mode 在空 file_path 时未 fail-closed 且未基于 cwd 解析相对路径;packages/loopx-core 漏打包 *.toml 清单文件;以及 status.py / quota.py / control_plane/ 遗留 17 处无消费者 re-export、已退场导出与指向旧仓库路径的文档链接。修改后(c4c30344e3e4d78019e5e51d72d6886f225487d7):系统性修复上述 CLI、Host 桥接、进程/锁清理、输入校验与打包缺口,同步将公开仓库引用对齐至 loopx-project/loopx 并清理确认无调用方的死代码路径。

可观测结果:在 c4c30344e3e4d78019e5e51d72d6886f225487d7 上实测:变更 Python 文件 ruff check 0 错误;全仓 mypy(17 个配置源码文件)0 错误;npm run typecheck:control-plane 通过;scripts/check_rfc_bilingual.py --base 3c03e91e6736f129d78e7c895b9d4a871f132a7f --head HEAD 通过;scripts/generate_turn_contract.py --check 显示 Turn contract bindings: up to date;node --test tests/opencode2_goal_worker.test.mjs tests/opencode_goal_bridge_runtime.test.mjs 通过(67 passed, 0 failed),6 组 tests/control_plane_ts/*.test.ts(含 delivery_response、effect_runtime_handler_loading、effect_runtime_handlers、usage_statistics_environment、zcode_app_server:62 passed, 2 skipped;remote_authority:16 passed)全部通过;两组 Python pytest 覆盖新增审计回归、status/quota 词表、Lark、Claude hook、Content-Ops、Core 打包与 Effect Runtime 集成共 309 passed, 42 skipped(164 passed, 42 skipped + 145 passed);examples/release-artifacts-smoke.py 与 examples/dev-book-publication-smoke.py 通过;loopx canary premerge --tier quick --from-git-diff --git-diff-base 3c03e91e6736f129d78e7c895b9d4a871f132a7f(ok=true, failures=0)与 loopx check --scan-path(143 个未删除文件,errors=0)均干净通过。

非目标边界:本 PR 不改动已合入 main(0d4233f723)的 codex_adapter / chat_runtime 上下文策略,不修改 PostgreSQL 运行时策略、桌面端回滚保留或更大范围跨模块重构,亦不替主干修复 tests/test_chat_manager_model_adoption.py:416 既往 lint 错误。

改动思路 / Approach

架构与放置判断:按各缺陷既有所有权边界就地修补——CLI 解析与帮助/手册更新留在 loopx/cli.py、help_surface.py、man/loopx.1;Host 运行时与锁/进程回收留在各自 agy_goal_mode / claude_goal_mode / opencode* / pi_goal_mode / effect_runtime.py;类型与输入边界收紧留在对应 TS/Python 模块;打包后缀修正留在 packages/loopx-core;未引入任何新抽象层或并行控制器。针对本 PR 删除的 29 个 Python 定义、7 个 TS 导出、17 个 status.py/quota.py re-export 与 shadow_drain_fault_process.ts,已同时在当前头与最新 origin/main 全仓检索确认无任何剩余调用方。

当前 PR 边界:包含 CLI/Host/打包修复(93493f5563)、控制面进程清理与死代码裁剪(7bea701365)及仓库 URL/CI/lint 对齐(c4c30344e3)共 3 个提交(144 文件,相对 merge-base 3c03e91e6736f129d78e7c895b9d4a871f132a7f);.github/workflows/full-public-smokes.yml 仅在 smoke-fleet-health 增加 github.repository == 'loopx-project/loopx' 条件以防止 fork 误跑,未触及主干权限与合并门禁逻辑。

域 / 改动类 关键修复与裁剪内容 验证证据
CLI / 帮助 / 打包 cli.py 注册 register_postgres_commands 并移除 6 组已被 dispatch_common_command 覆盖的不可达分派;opencode2_goal_worker.py 诊断转 stderr 并透传 ok=False;packages/loopx-core 纳入 *.toml test_audit_cli_and_runtime_fixes.py + test_core_distribution.py
Host 与进程/锁清理 effect_runtime.py 检查 Linux /proc/<pid>/task/*/stat 确认全线程退为 Z;explore_research_terminal.ts / shadow_drain_files.ts 释放 readline 并升级 SIGTERM→SIGKILL;goal-bridge-runtime.mjs 使用 "wx" 排他锁 + token 校验释放且更新 waitPlan opencode2_goal_worker.test.mjs + opencode_goal_bridge_runtime.test.mjs + test_effect_runtime_integration.py
输入安全与死代码清理 remote_authority_policy.ts 长度预检后再 timingSafeEqual;goal_policy.py 空路径 fail-closed 并解析相对 cwd;runtime_workspace.py unquote 路径;清理 17 项无调用 re-export 与 36 处死函数/导出 全仓调用方检索 0 残留 + remote_authority.test.ts + test_status_facade_vocabulary_owners.py
文档链接与仓库卫生 公开文档与配置从 huangruiteng/loopx 对齐为 loopx-project/loopx;.github/CODEOWNERS 与 .gitignore 移除已退场 deprecate/ / apps/dashboard/ 规则;vite.config.ts 代理 /api/goals dev-book-publication-smoke.py + canary premerge --tier quick + loopx check

具体改动 / Changes

本次有效 diff(3c03e91e6736f129d78e7c895b9d4a871f132a7f..c4c30344e3e4d78019e5e51d72d6886f225487d7)共触及 144 个文件(+1350 / -1117,无 RFC 文件变更):

  1. CLI 与扩展合约(loopx/cli.py、loopx/help_surface.py、man/loopx.1、loopx/cli_commands/explore.py、loopx/cli_commands/opencode2_goal_worker.py、loopx/presets.py、loopx/chat_attachments.py、loopx/capabilities/content_ops/*、loopx/capabilities/change_quality/cli.py、loopx/capabilities/explore/router_state.py):补齐 postgres 解析注册并移除重复分派、修正 explore 空 goal_id 默认注册表回退、隔离 opencode2 stderr、加固 content-ops 重复 stdin ('-') 检测与 Markdown 渲染、presets.py 对 cli_bin 做 shell 引用并容忍空列表、chat_attachments 严格校验 type(declared_size) is int、router_state 要求计数双非空后再转换。
  2. Host 适配器与运行时清理(loopx/agy_goal_mode/host_runtime.py、loopx/capabilities/native_chat/antigravity_adapter.py、loopx/claude_goal_mode/*、loopx/opencode2_goal_mode/opencode2-goal-worker.mjs、loopx/opencode_goal_mode/goal-bridge-runtime.mjs、loopx/pi_goal_mode/loopx-goal.ts、scripts/loopx、scripts/loopx.ps1):支持 ANTIGRAVITY_LS_URL 与 --antigravity_app/--cli-bin,校验轨迹响应字典形状;Claude hook 空写入路径 fail-closed 且 goalmode_cmd 检查退出码;OpenCode 锁文件拒收 pid <= 0、使用 "wx" 原子创建与 token 校验释放、waitPlan 对齐真实 cold_path_detail/limits;Pi 适配器解析非零退出码下的有效 JSON 决策。
  3. 控制面安全、清理与死代码裁剪(loopx/control_plane/effect_runtime.py、explore_research_terminal.ts、shadow_drain_files.ts、remote_authority_policy.ts、checkpoint_commit.ts、effect_runtime_handlers.ts、删除 shadow_drain_fault_process.ts 及 20+ 控制面模块无消费者导出、loopx/status.py、loopx/quota.py、loopx/extensions/lark/*、loopx/presentation/*):安全关闭子进程与 readline、Linux 全线程僵尸态校验、timingSafeEqual 长度前置校验、explore_results_api.py 跳过重复校验并按 original_goal_id 匹配且对 SourceScopeError 返回 404、runtime_workspace.py 对静态路径先 unquote。
  4. 打包、CI、测试与仓库引用对齐(packages/loopx-core/*、packages/loopx-codex-provider-routing/__init__.py、apps/presentation/dashboard/vite.config.ts、.github/CODEOWNERS、.github/workflows/full-public-smokes.yml、.gitignore、CONTRIBUTING.md、sonar-project.properties、docs/*、examples/*、skills/loopx-self-repair/*、新增 tests/test_audit_cli_and_runtime_fixes.py 等):修正 loopx-core 包含 *.toml、对齐 loopx-codex-provider-routing __version__(0.15.8)与 pyproject.toml、为 Vite 开发代理补全 /api/goals、对齐仓库 URL 至 loopx-project/loopx。

关键代码讲解

  1. _linux_thread_group_is_zombie 与 _stop_effect_runtime(loopx/control_plane/effect_runtime.py:640-660, 958-964):_reap_exited_runtime_child 仅在 waitpid 确认 ECHILD(非本进程直接子进程)时返回 True,随后在 Linux 检查 /proc/<pid>/task/*/stat 所有线程均为 Z 且无新增线程,才允许判定孤儿进程组已终止,防止主线程先退出而工作线程仍写盘时误判停止。
  2. createFileLockStore 与 waitPlan(loopx/opencode_goal_mode/goal-bridge-runtime.mjs:179-265, 326-360):以 fs.open(lockPath, "wx", 0o600) 取代覆盖式 rename 竞态,并在释放锁时校验 current.token === token 防止误删后续持有者锁文件;waitPlan 兼容 cold_path_detail.local_scheduler 与 unchanged_poll.limits。
  3. remoteAuthorityPolicyAdmission(loopx/control_plane/coordination/remote_authority_policy.ts:96-103):先比较 candidate.length === digest.length 再调用 timingSafeEqual,消除非法或截断 hex 凭据哈希触发 RangeError 的边界异常。

对主干的风险 / Risks

  • 无 P0/P1 阻断性问题:已核对与 origin/main(0d4233f723 / a79e781340)重合区,所有被本 PR 删除的函数、导出与重导出在 origin/main 均无新增调用方;唯一须注意合入前需要按 GitHub 正常合并/变基处理 main 在 3c03e91e6736f129d78e7c895b9d4a871f132a7f 之后推进的提交(067ad42cc4 等)。
  • 远端 CI 与非阻断关注:远端 CI kernel-static-checks 失败于主干既有 tests/test_chat_manager_model_adoption.py:416(F811),致使下游 checks/pytest/stage2c/merge-gate 失败或跳过;局部非阻断 P2 关注:loopx/presets.py:336 通过 common_setup[0].rsplit(" ", 1)[0] 反推 cli_prefix 对直接传入非标准 common_setup 的调用方略脆弱(build_beginner_preset_packet 默认生成 "{_shell(cli_bin)} doctor" 不受影响)。

我的整体评价 / Verdict

PR #8985 系统修复了 CLI 注册与流分离、Host 锁/孤儿进程回收、输入校验与 loopx-core 打包等多项审计缺陷,按既有所属边界裁剪 50 余项无调用死代码/重导出并同步将公开引用迁至 loopx-project/loopx;经本地 Ruff、17 文件 Mypy、控制面 TS 类型检查、67 项 Node MJS + 78 项 TS(2 skipped)+ 309 项 Python(42 skipped)测试与 quick premerge / 边界扫描独立验证,未见对主干行为或 origin/main 新增路径的回归风险。visual_review:not_applicable(原因:仅修改 apps/presentation/dashboard/vite.config.ts 本地开发 /api/goals 代理与后端/CLI/文档文件,未改动任何前端 UI 组件、样式或渲染视图;未验证范围:none)。审查结论为 APPROVE(合入前需待主干 lint 恢复及维护者合入授权)。

English verdict: APPROVE exact head c4c3034; across 144 files relative to merge-base 3c03e91, PR #8985 repairs CLI parser/stream handling (postgres, explore, opencode2-goal-worker, presets, content-ops), hardens runtime/lock cleanup (effect_runtime.py, explore_research_terminal.ts, shadow_drain_files.ts, goal-bridge-runtime.mjs), fixes input bounds (remote_authority_policy.ts, goal_policy.py, runtime_workspace.py), packages *.toml in loopx-core, prunes verified dead exports/re-exports (0 callers on both HEAD and origin/main), and aligns loopx-project/loopx links; verified locally via ruff, 17-file mypy, typecheck:control-plane, 67 Node MJS + 78 TS (2 skipped) + 309 Python (42 skipped) tests passing, canary premerge --tier quick (failures=0), and loopx check (errors=0); remote kernel-static-checks failure (tests/test_chat_manager_model_adoption.py:416 F811) is pre-existing on main.

@huangruiteng
huangruiteng merged commit 9ff078d into main Nov 18, 2026
43 of 48 checks passed
@huangruiteng
huangruiteng deleted the codex/review-fixes-20261118 branch November 18, 2026 06:33
gcl-coder added a commit to gcl-coder/loopx that referenced this pull request Nov 18, 2026
Main deleted the unused readGoalHeartbeatReceipts helper (loopx-project#8985). The branch's
receipt reader had grown around that helper, so the merge keeps main's removal
and carries only the scoped receipt view, the committed-successor admission
and the committed-row marker. scheduler_hint.py, quota.py, status.py and the
settlement readback test merged without overlap; the receipt reader was the
only textual conflict.

Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
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.

3 participants