Skip to content

feat(benchmark): add opt-in stop-hook checklist baseline and control-tax telemetry - #9497

Merged
huangruiteng merged 1 commit into
mainfrom
codex/s4-strong-stop-hook-todo-baseline-20261127
Nov 27, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/s4-strong-stop-hook-todo-baseline-20261127

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Goal and delivered behavior

To measure LoopX's net-of-tax effectiveness honestly against a strong non-LoopX counterfactual baseline, this PR adds an opt-in, default-off todo_checklist Stop-hook mode alongside verified monotonic control-plane overhead and tax telemetry across both Stop-hook and LoopX arms:

  • Opt-in strong counterfactual baseline (benchmark/runtime/codex.py, benchmark/runtime/native_hooks.py, benchmark/runtime/worker.py, benchmark/runtime/harbor.py, benchmark/runtime/RUNTIME.md):
    • Adds official_stop_hook_mode: "simple" | "todo_checklist" (default None, strictly requiring mode="plain" and official_stop_hook=True; rejects invalid modes, mismatched pairings, and ambient LOOPX_OFFICIAL_STOP_HOOK_MODE overrides before host setup).
    • Stages a physical, trial-local baseline-todo/TODO.md (0o700 dir, 0o600 file, symlink checks) inside LOOPX_CODEX_HOME rather than inside the workspace repository so workspace git diff / git status remain completely unpolluted, and limits workspace-write sandbox grants strictly to baseline-todo/ when enabled.
    • Preserves agent checklist edits across phase/retry re-entry without changing hooks.json trust hashes, appends deterministic checklist and regression-verification guidance to the initial plain prompt, and evaluates TODO.md on native Stop under LC_ALL=C awk (scrubbing C0 control chars \001-\037\177 and extending preview truncation up to byte 163 across UTF-8 continuation bytes so non-ASCII items never slice mid-codepoint or fail BSD awk locale checks).
    • Preserves full default-off parity: omitting official_stop_hook_mode leaves plain and existing official_stop_hook=True prompts, hooks.json, config.toml, loopx-install.json, and empty-wake Harbor metadata unchanged.
  • Verified monotonic control-plane overhead & unknown-preserving telemetry (benchmark/runtime/codex.py, benchmark/runtime/worker.py, benchmark/runtime/harbor.py, benchmark/runtime/RUNTIME.md):
    • Uses one shared owner (summarize_control_telemetry / aggregate_control_telemetry) measuring local monotonic timings with zero extra RPCs: hook_prepare_seconds, control_overhead_seconds, work_wall_seconds, control_tax_ratio, control_telemetry_verified, and control_telemetry_status ("verified", "missing_receipt", "untimed_receipt").
    • Tracks current-phase wake coverage by started wake directories (BenchmarkCodex._wake_dirs() excluded against pre-phase wakes in run(), and returned alongside missing/corrupt wake counts by BenchmarkCodex._read_wake_receipts() -> aggregate_control_telemetry(..., missing_receipts=...)) rather than scanning only readable wakes/*/receipt.json files. When a multi-wake phase (in plain + todo_checklist or heartbeat) starts a wake whose receipt.json is missing, a symlink, unreadable, truncated/corrupt JSON, or a non-mapping JSON value, observed valid hook_prepare_seconds and control_overhead_seconds are preserved while work_wall_seconds=None, control_tax_ratio=None, control_telemetry_verified=False, and control_telemetry_status="missing_receipt".
    • Distinguishes observed zero-work runs (work_wall_seconds == 0.0 with complete timing receipts -> control_telemetry_verified=True, control_telemetry_status="verified", control_tax_ratio=1.0) from missing/corrupt receipts ("missing_receipt") and untimed/legacy wake dicts ("untimed_receipt").
    • Unconditionally sets self._last_phase_telemetry per phase in BenchmarkCodex.run() (even when new_wakes == [] and prep_elapsed == 0.0) so prior-phase wakes never leak into subsequent phases, while keeping populate_context_post_run empty-wake metadata parity intact.
  • Tests (benchmark/tests/test_stop_hook_baseline_telemetry.py):
    • Covers strict validation of invalid modes/pairings/ambient env isolation, default-off parity, real git init workspace isolation + multi-locale (C, en_US.UTF-8) LC_ALL=C awk Stop hook execution across C0-control/UTF-8 boundaries/open/empty/missing/symlink/all-checked states, deterministic monotonic control_tax_ratio accounting (todo_checklist, LoopX SQLite heartbeat context_delivery="on", early budget exhaustion 1.0), partial-missing aggregate_control_telemetry, observed_zero vs untimed_receipt vs missing_receipt differentiation, and BenchmarkCodex.run + populate_context_post_run multi-wake phase coverage across plain + todo_checklist and heartbeat (missing, corrupt_json, non_dict_json, symlink_receipt, untimed, complete, excluding prior-phase wakes) in both real-harbor (when installed) and uninstalled-harbor stub paths.

Verification (at exact head 143e95a2543fe92950115dd75d8d2ea7d91492d6, rebased onto origin/main 6915df67db6a8836df344a661f295006873a3ba8)

  • pytest (benchmark/tests/test_stop_hook_baseline_telemetry.py): 17 passed, 18 skipped in 3.56s (the 18 skips require the optional harbor package; test_harbor_adapter_executes_mode_isolation_and_telemetry_with_stub_if_uninstalled executed all 5 single-wake counterfactuals plus all 12 multi-wake plain + heartbeat partial-coverage cases live via stub).
  • pytest (benchmark/tests/test_stop_hook_baseline_telemetry.py, benchmark/tests/test_worker_phase_budget.py, benchmark/tests/test_harbor_usage_completeness.py, benchmark/tests/test_native_child_parity.py, benchmark/tests/test_causal_attribution.py, benchmark/tests/test_five_arm_causal_attribution.py): 62 passed, 28 skipped in 50.77s (0 failures; optional harbor skips).
  • pytest -n 4 (benchmark/tests/test_shared_codex_runtime.py, benchmark/tests/test_task_entry.py, benchmark/tests/test_sforge_runtime.py, benchmark/tests/test_native_checkpoint_handoff.py, benchmark/tests/test_interruption_recovery.py): 240 passed, 426 skipped in 237.83s (0 failures; native binary / optional harbor skips).
  • ruff check (0 issues on all 5 Python files), git diff --check, git merge-tree origin/main HEAD, scripts/check_rfc_bilingual.py, npm run typecheck:control-plane (0 errors), examples/semantic-vocabulary-drift-smoke.py, examples/control_plane/control-plane-maintainability-ratchet-smoke.py (0 unreviewed), and loopx check (6 files, 0 errors, 0 warnings) passed.
  • Goal-bound Change Quality Receipt cqr_d7e40a14e3164b742c63 (decision: "pass", receipt_valid: true, scope d7e40a14e3164b742c634b1f72c174b757cd567fdc31e898a8e68664ffffeb66).
  • Goal-bound canary premerge --tier standard: 4/4 direct checks + 1/1 py_compile + 9/9 catalog canaries passed (0 failures; gate.status="manual_review_required" solely due to benchmark_sensitive manual hold — PR left OPEN for review).

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

[P2] 缺失计时的阶段应保留未知。使用实际 BenchmarkCodex.run,隔离远端执行边界并启动确定性的合成工作。阶段准备耗时 1 秒,工作夹具有实际输出。缺少当前 receipt.json 或回执存在但无计时字段时,两种情况都被写成 work_wall_seconds=0、control_tax_ratio=1.0。完整回执对照得到 3 秒控制、6 秒工作、比值 0.333333,并正确排除上一阶段。 区分已观测的零执行、缺失回执和不含计时的旧回执。保留已观测的准备耗时,只有当前阶段的工作窗覆盖完整时才提供可比较的比值,并为缺失或旧回执显式标注未验证。 源码

动机 / Motivation

提供一个明确选用的 Stop-hook checklist 对照组,并在相同窗口比较控制开销与工作耗时。 基线采用普通 plain 或 prompt-less Stop hook,Harbor 阶段没有发布这组比值。 比较 plain、Stop-hook checklist 和 LoopX heartbeat 的 benchmark 运行者与结果分析者。

含旧回执、超时中断或远端日志缺件的阶段可进入成本比较并误报为 100% 控制开销。 匹配完整回执时,阶段按时长聚合。隔离自动化验证默认不启用 checklist,选用后在 workspace 外保存 checklist,真实 POSIX hook 对未勾选项继续阻拦。 独立 base/head 阶段探针覆盖完整、当前缺件及旧回执三种输入。四组仓库定向测试 48 通过、12 项环境或可选依赖跳过,git diff --check 与 merge-tree 通过。 阶段验证使用 Harbor transport 替身和合成工作,无付费模型调用、生产评测或托管 CI 结果。比值应仅用于实际计时覆盖明确的比较。 基线契约

改动思路 / Approach

该改动沿用 BenchmarkCodex.run → worker 阶段回执 → Harbor context.metadata。保留官方 Checklist opt-in 与同一 Worker 计时所有者,聚合只应使用当前阶段的经验证观测。 当前阶段准备耗时单独累加,聚合把缺失或无字段的工作回执隐式当零;具体阶段仍报告实数比值。 改现有聚合成功条件或返回类型,在发布比值前确认计时覆盖。保留已有计时与正式执行路径。

具体改动 / Changes

精确提交 9645562,本次对照目标 ddcfca5。6 个文件,+1,166/−35。803 行为新测试,生产变更聚焦 mode、native hook、Worker 与 Harbor 的计时。

关键代码讲解

  • BenchmarkCodex.run 阶段收尾。在准备耗时大于零时,即使当前阶段没有可用的工作计时也调用聚合。 源码

  • aggregate_control_telemetry。对已提供的数值求和,缺少字段时没有累加或未知标记。 源码

  • run_once 的回执计时。写入该 worker 实际计时窗口的组成数据。 源码

  • prepare_baseline_todo_checklist。明确选用 checklist 时在 trial home 持有检查文件。 源码

  • benchmark-missing-coverage-unknown(partial)。缺失的完整成本覆盖保留未知。阶段准备有数据时,缺失 worker 的时间仍无法推出实际工作为零。

对主干的风险 / Risks

使用实际 BenchmarkCodex.run,隔离远端执行边界并启动确定性的合成工作。阶段准备耗时 1 秒,工作夹具有实际输出。缺少当前 receipt.json 或回执存在但无计时字段时,两种情况都被写成 work_wall_seconds=0、control_tax_ratio=1.0。完整回执对照得到 3 秒控制、6 秒工作、比值 0.333333,并正确排除上一阶段。 一个真实启动后无计时的阶段会获得与真正零工作不同的证据却不可区分。 区分已观测的零执行、缺失回执和不含计时的旧回执。保留已观测的准备耗时,只有当前阶段的工作窗覆盖完整时才提供可比较的比值,并为缺失或旧回执显式标注未验证。

语义与 CI 对齐

使用实际 BenchmarkCodex.run,隔离远端执行边界并启动确定性的合成工作。阶段准备耗时 1 秒,工作夹具有实际输出。缺少当前 receipt.json 或回执存在但无计时字段时,两种情况都被写成 work_wall_seconds=0、control_tax_ratio=1.0。完整回执对照得到 3 秒控制、6 秒工作、比值 0.333333,并正确排除上一阶段。 区分已观测的零执行、缺失回执和不含计时的旧回执。保留已观测的准备耗时,只有当前阶段的工作窗覆盖完整时才提供可比较的比值,并为缺失或旧回执显式标注未验证。

我的整体评价 / Verdict

REQUEST_CHANGES。 保留完整成本的未知语义并重跑缺件和旧回执反例后再复审。 保留缺失观测的可见性,避免自动聚合把未测到的工作时间当成零并误导对照组选择。

English verdict: REQUEST_CHANGES at 9645562. Request changes. A phase that ran work but has a missing or untimed worker receipt is published with zero work time and 100% control tax.

Comment thread benchmark/runtime/harbor.py Resolved
@loopx-agent
loopx-agent force-pushed the codex/s4-strong-stop-hook-todo-baseline-20261127 branch from 9645562 to 9d4c17c Compare November 26, 2026 18:56

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer: model_agent · gemini-3.1-pro · Google · self_reported · effort_unavailable

Approval conclusion (author-owned PR; GitHub blocks formal self-approval): APPROVE for 9497@9d4c17c0e715cadbd2b228d3c9660d4752fd0dc1 — verified [P2] finding PRRT_kwDOStEbEs68fRHU resolved cleanly across missing/untimed/observed-zero counterfactuals with 0 remaining blocking findings.

动机 / Motivation

在评估 LoopX 相对纯宿主反事实基线的“扣除控制面税率后”净收益(net-of-tax effectiveness)时,现有基准缺少两点基础能力:其一,plain + official_stop_hook=True 仅在 Stop 钩子输出固定单句提醒,没有对照侧可自行维护的非工作区任务清单;其二,worker 与 Harbor 阶段汇总缺少统一、无额外 RPC 的单调控制面计时与 control_tax_ratio 字段,且上一版评审指出缺失/无计时字段的 phase receipt 会被错误合成为 work_wall_seconds=0.0 与 control_tax_ratio=1.0(PRRT_kwDOStEbEs68fRHU)。

  • 受影响调用方(Affected callers):启用 counterfactual Stop-hook 对照组的 Benchmark 调度器(BenchmarkCodex、worker.py)、采集 control_tax_ratio 做净收益对比的 heartbeat / context_delivery 评测臂,以及沿用默认 plain 与原始 official_stop_hook=True 的现有基线消费者。
  • 前后场景对比(Before/After):改动前,启用 official_stop_hook=True 仅在 Stop 时返回固定 ``"Do not stop. Continue working on the implementation."提示、缺少与 LoopX Todo 等价的对照清单机制,且 wake receipt 与 Harbor phase metadata 不记录单调控制的准备与工作耗时分解。改动后,仅在显式 opt-inofficial_stop_hook_mode="todo_checklist"`(且严格锁定 `mode="plain"` 与 `official_stop_hook=True`)时,在 `LOOPX_CODEX_HOME/baseline-todo/TODO.md` 生成受沙箱写根白名单隔离的私有对照清单并在 `Stop` 时以 `LC_ALL=C awk` 验证完成度,同时在所有 worker wake receipt 与 Harbor 阶段汇总`hook_prepare_seconds`、`control_overhead_seconds`、`work_wall_seconds`、`control_tax_ratio`、`control_telemetry_verified` 与 `control_telemetry_status`;实测默认 `plain_off` 与 `stop_simple` 在无 checklist 产物、提示词长度(`16 B` vs `todo_checklist` `507 B`)和 `hooks.json` 哈希(`040c05565145828b`)上与基线等价。
  • 可观测收益与边界(Observable outcome & non-goals):精确候选闭环交付了 opt-in todo_checklist 反事实对照组(工作区 git status 零污染、多字节 UTF-8/控制字符与符号链接安全校验)以及未知保全(verified / missing_receipt / untimed_receipt)单调耗时统计,并已验证修复先前的 [P2] 缺陷 PRRT_kwDOStEbEs68fRHU。本 PR 不改动任何核心 LoopX 控制面决策、不引入额外 RPC 轮询、不更改 plain/默认 official_stop_hook=True 的既有工作流与沙箱权限,也不修改远端 CI 与 Harbor 评分器契约。

改动思路 / Approach

plain + official_stop_hook=True + official_stop_hook_mode (None | "simple" | "todo_checklist")
   │
   ├─ worker.py (Execution 校验 + 单调计时)
   │    ├─ mode == "todo_checklist" ──► native_hooks.prepare_baseline_todo_checklist(CODEX_HOME) [0o700/0o600, 防符号链接]
   │    │                                  └─ Stop: LC_ALL=C awk 校验 checklist,全 [x] 输出 {} 放行,否则 JSON block
   │    │                                  └─ workspace-write: 仅授权 writable_roots=[baseline-todo/]
   │    └─ 所有模式 finally: 汇总 hook_prepare / control_overhead / work_wall -> receipt.json
   │
   └─ harbor.py BenchmarkCodex.run()
        ├─ before_wakes = _wake_receipt_files()
        ├─ prep_elapsed 计入 extra_control_seconds
        └─ new_wakes = diff ──► aggregate_control_telemetry()
                                   ├─ new_wakes=[] ──► "missing_receipt" (work=None, ratio=None, verified=False)
                                   ├─ 缺/非法计时  ──► "untimed_receipt" (work=None, ratio=None, verified=False)
                                   └─ 完整有效计时 ──► "verified" (含 observed work=0.0 -> ratio=1.0)

图示说明(Illustrative, verified against 9d4c17c0e7):benchmark/runtime/codex.py:aggregate_control_telemetry 与 harbor.py:BenchmarkCodex.run 构成唯一阶段遥测结算通道,无条件覆盖 self._last_phase_telemetry 避免跨阶段污染。

  • 职责分层与架构边界(architecture_assessment):核心计数与汇总规则集中沉淀在 benchmark/runtime/codex.py(OFFICIAL_STOP_HOOK_MODES、summarize_control_telemetry、aggregate_control_telemetry)与 benchmark/runtime/native_hooks.py(prepare_baseline_todo_checklist、_todo_checklist_stop_hook_command),保持纯标准库闭环且完全满足 NATIVE_GOAL_SOURCE_PATHS 最小挂载边界;worker.py 仅做环境变量校验、单调计时采样与受限沙箱 root 透传,harbor.py 仅做阶段级 wake diff 与 metadata 写入,没有建立第二套状态机或重用 LoopX 生产控制面来污染非 LoopX 对照组。
  • 当前 PR 边界(current_pr_boundary):仅限 benchmark/runtime/ 下的显式 opt-in Stop-hook todo_checklist 模式与单调控制面开销遥测,不改变 loopx/control_plane/ 语义、不新增持久化注册表、也不扩展 loopx CLI 对外参数面。
  • 历史 [P2] 缺陷核验(PRRT_kwDOStEbEs68fRHU):已在 9d4c17c0e7 验证完全关闭。codex.py:aggregate_control_telemetry 通过 _finite_nonneg() 严格校验非负有限浮点数(拒绝 bool、NaN、Inf、负数与字符串),并显式区分无当前阶段回执(missing_receipt)、缺省或非法字段(untimed_receipt)与完整观测到的零工作窗口(verified, work_wall_seconds=0.0, control_tax_ratio=1.0);同时 harbor.py:BenchmarkCodex.run() 的 finally 无条件将当轮 self._last_phase_telemetry 赋值为 aggregate_control_telemetry(new_wakes, extra_control_seconds=prep_elapsed) 后清零,彻底阻断 empty new_wakes 场景回退读取旧阶段 wake 的泄漏路径。

具体改动 / Changes

变更分类(Base 379b9ea3e9 -> Head 9d4c17c0e7,共 6 个文件,+1417/-35 行)

  • 运行时与文档(5 files, +402/-35):
    • benchmark/runtime/codex.py(+93/-3):新增 OFFICIAL_STOP_HOOK_MODES = ("simple", "todo_checklist")、_finite_nonneg、summarize_control_telemetry、aggregate_control_telemetry,以及 Execution.official_stop_hook_mode 的严格校验(仅限 plain 且 official_stop_hook=True,拒收非字符串、布尔与未知模式)。
    • benchmark/runtime/native_hooks.py(+138/-3):新增 baseline_todo_path、prepare_baseline_todo_checklist(0o700 私有目录、O_CREAT|O_EXCL 0o600 文件、符号链接与属主校验)、baseline_todo_instructions 与 _todo_checklist_stop_hook_command(LC_ALL=C awk、[�-��] 控制字符清洗与 160–163 字节 UTF-8 续字节对齐截断),并在 prepare_official_stop_hook(..., mode=...) 按模式路由。
    • benchmark/runtime/worker.py(+88/-7):透传 LOOPX_OFFICIAL_STOP_HOOK_MODE、workspace-write 下为 baseline-todo/ 追加唯一 writable_roots、追加 baseline_todo_instructions,并以 time.monotonic() 包裹 prepare_official_stop_hook / prepare_context_delivery 与实际子进程/CheckpointWake/run_native_goal 工作耗时后无条件在 finally 写入 receipt.json。
    • benchmark/runtime/harbor.py(+67/-5):透传 official_stop_hook_mode 至执行环境与安装/阶段 metadata;记录 before_wakes、Phase prepare 耗时与 new_wakes 差集并通过 aggregate_control_telemetry 写入当前阶段 context.metadata。
    • benchmark/runtime/RUNTIME.md(+31/-2):补齐 opt-in todo_checklist 契约与单调控制税率遥测字段语义说明。
  • 测试套件(1 file, +1015):
    • benchmark/tests/test_stop_hook_baseline_telemetry.py:完整覆盖非法参数与环境隔离、默认关闭等价、git init 工作区零污染、C/en_US.UTF-8 双 locale 控制字符与 UTF-8 边界、空/缺失/符号链接 checklist、单调 control_tax_ratio、aggregate_control_telemetry 三态区分及真实/桩 BenchmarkCodex.run 五场景反事实隔离。

关键代码讲解

  1. benchmark/runtime/codex.py:80-125 (aggregate_control_telemetry)
    • 职责与边界:对单次/多轮 wake receipt 列表求算总准备时间、总控制面开销与总工作时长;仅当 record_list 非空且每条记录均具备有效 work_wall_seconds 与 control_overhead_seconds 时输出 "verified" 与比值,否则保留已观测到的 hook_prepare_seconds / control_overhead_seconds 并显式返回 None 与对应未验证状态(避免平均每个 wake 的比值造成加权偏差)。
  2. benchmark/runtime/native_hooks.py:79-139 (_todo_checklist_stop_hook_command)
    • 职责与安全边界:执行前检查 checklist 是否缺失或为符号链接;随后使用 LC_ALL=C awk(兼容 macOS BSD awk 与容器 GNU awk)清洗 C0 控制字符,当遇到多字节 UTF-8 跨越第 160 字节时最多向前放宽 3 字节延续位([�-¿])以防半个字符破坏 JSON UTF-8 合法性。当仅存在已勾选 - [x]/- [X] 且零未勾选项时输出 {} 允许退出,其余场景输出结构化 block 提示。
  3. benchmark/runtime/harbor.py:900-1002 (BenchmarkCodex.run & _populate_context)
    • 职责与不变量:无论主任务规划是否提前 blocked 返回或发生超限异常,finally 均只用 before_wakes 之后新增的 wake receipts 与 prep_elapsed 更新 _last_phase_telemetry 并立即清空,避免 populate_context 落入全量扫描而混入上一阶段(如 prior-phase-wake)的耗时。
  4. benchmark/runtime/worker.py:520-538, 956-965 (native_command & run_once)
    • 职责与资源隔离:仅在 official_stop_hook_mode == "todo_checklist" 且 sandbox == "workspace-write" 时追加 baseline-todo/ 目录至 sandbox_workspace_write.writable_roots,避免放开整个 LOOPX_CODEX_HOME(保护 config.toml、hooks.json 与 sessions/);所有 try 内早退或超时异常都仍经 finally 记录精确控制耗时与 work_wall_seconds=0.0。

规范对齐(benchmark/runtime/RUNTIME.md @ 379b9ea3e9dab2b5671129bdd0c52b3e47479ed0)

  • C-COUNTERFACTUAL-OPTOUT(未传 official_stop_hook_mode 时默认 plain 与原始 official_stop_hook=True 提示词、hooks 宣言与沙箱策略保持完全一致):implemented — codex.py:156-171、native_hooks.py:142-161、worker.py:521-528,780-783;由 test_default_off_parity_keeps_plain_and_simple_stop_hook_unchanged 与双臂探针验证。
  • C-ISOLATED-CHECKLIST(todo_checklist 仅落盘在私有 LOOPX_CODEX_HOME/baseline-todo/TODO.md,绝不写入工作区仓库):implemented — native_hooks.py:38-64,79-139;由 test_todo_checklist_isolates_from_git_workspace_and_evaluates_stop_hook 与独立 4-byte emoji/CRLF 探针验证。
  • C-MONOTONIC-TAX-TRUTH(无额外 RPC 的单调耗时采样、分母求和而非比率平均、未知或未计时回执不得伪造 0.0/1.0):implemented — codex.py:60-125、worker.py:956-965、harbor.py:995-1002;由 test_worker_control_tax_telemetry_accounts_stop_hook_and_heartbeat_arms 与 BenchmarkCodex.run 五场景反事实测试验证。

对主干的风险 / Risks

  • 无阻塞缺陷(0 blocking findings)。
  • 反例与边缘核验:
    • 在 C 与 en_US.UTF-8 两种 locale 下独立构造 4 字节 UTF-8 emoji(🚀)准确跨过第 160 字节(padding 156..160)以及 CRLF 与 - [x]/* [X] 混合条目的测试,确认 _todo_checklist_stop_hook_command 始终输出合法 UTF-8 JSON(未出现截断异常或 BSD awk 报错)。
    • 独立检查 aggregate_control_telemetry 对布尔值(True)、NaN、Inf、负数及缺省键的拒绝逻辑(均严格归入 untimed_receipt、work_wall_seconds=None、control_tax_ratio=None、control_telemetry_verified=False),以及加权求和不被单轮高税率拉偏。
    • 验证了早期预算耗尽(LOOPX_PHASE_DEADLINE_EPOCH=1.0)时 worker.py finally 正确写入 work_wall_seconds=0.0、control_tax_ratio=1.0。
  • 默认关闭与基线对比(default_off_isolation & observable_semantics):在基准提交 379b9ea3e9 与候选 9d4c17c0e7 上运行独立 plain_off 与 stop_simple_default(未配置 official_stop_hook_mode)对比:两边在 plain_off 与 stop_simple 下的输入 prompt 均保持 "Synthetic task.\n"(16 B),baseline-todo 均未创建,生成的 hooks.json SHA-256(040c05565145828b)完全一致,且 official_stop_hook_mode 字段在未 opt-in 时不出现;仅当显式 todo_checklist 时 prompt 追加 TODO.md 指导(507 B)并记录 official_stop_hook_mode="todo_checklist"。
  • 残余风险与未测边界(residual_risk):本机环境未安装可选外部包 harbor 与 sforge(相关真实包测试按标记 skipped;test_harbor_adapter_executes_mode_isolation_and_telemetry_with_stub_if_uninstalled 通过桩模块完整实测了 BenchmarkCodex 构造、populate_context 空 wake 兼容与全部 5 类 BenchmarkCodex.run 场景);真实 Docker 容器与在线模型评测、以及依 Goal 策略 wait_for_ci: false 不等待的远端 GitHub Actions CI 未在本机运行。另外 benchmark/runtime/ 本身在全文件 mypy 下存在 74 条既有历史注解告警(harbor 缺失桩与既有未标注函数),本次 PR 新增函数路径未引入新的类型错误;独立审核 worktree 运行 canary premerge 显示本机无审核侧 CQR(PR 作者侧已提交 cqr_976eb9a844f3ab3fc1e0 且 benchmark_sensitive 表面需维护者显式合入授权)。

验证矩阵(Local Verification on 9d4c17c0e7)

检查项 状态 结果与说明
目标新增与回归测试 (test_stop_hook_baseline_telemetry.py) PASS 17 passed, 6 skipped in 4.64s(6 skipped 需外部 harbor;stub 覆盖全 5 类 BenchmarkCodex.run 场景)
基准顺序 6 套件(telemetry, phase_budget, harbor_usage, native_child, causal x2) PASS 62 passed, 16 skipped in 47.72s(0 failed)
基准并发 5 套件(pytest -n 4: shared_codex, task_entry, sforge, checkpoint_handoff, recovery) PASS 240 passed, 426 skipped in 222.03s(0 failed;skips 为可选原生/外部包用例)
维护率套件 + Smokes (test_maintainability_ratchet.py, vocab-drift, ratchet-smoke) PASS ratchet pytest 14 passed (8.94s);ratchet-smoke 0 (unreviewed=0, stale=0);vocab-drift 0
ruff / npm run typecheck:control-plane / RFC 双语 / loopx check / git diff --check PASS ruff 0(5 .py);TS typecheck 0;RFC 0;loopx check 6 文件 0 errors / 0 warnings;diff --check 0
独立反事实探针(UTF-8 4-byte emoji/CRLF + 379b9ea vs 9d4c17c 3-arm parity) PASS COUNTERFACTUAL_PROBE_OK + 3 臂等价与 opt-in 分流验证通过
Goal canary premerge --tier standard --from-git-diff --git-diff-base 379b9ea3e9dab2b5671129bdd0c52b3e47479ed0 PASS (checks) 5/5 direct + 9/9 catalog passed (failures=0, failed_commands=[]);manual_hold=1(benchmark_sensitive)及审核工作树未自签 CQR
远端 GitHub Actions CI UNVERIFIED (not_consulted) 依 Goal 策略 wait_for_ci: false 不轮询或等待远端 CI

我的整体评价 / Verdict

Verdict: APPROVE (9497@9d4c17c0e715cadbd2b228d3c9660d4752fd0dc1, author-owned COMMENTED conclusion)

  • 长程收益(long_horizon: improved):为多轮基准对照补齐了不污染待测工作区仓库的 todo_checklist 强对照臂,并用单一、可区分 verified/missing_receipt/untimed_receipt 的单调计时遥测(无额外 RPC 开销)支撑净收益归因。
  • 用户体验(user_experience: preserved;visual_review: not_applicable):改动仅涉及基准运行时配置与内部 receipt/metadata(unverified_scope: none;检查路径 benchmark/runtime/codex.py, benchmark/runtime/harbor.py, benchmark/runtime/native_hooks.py, benchmark/runtime/worker.py),默认关闭场景零行为漂移。
  • 语义词表、体量与默认隔离综合裁定:严格沿用既有 Execution、Execution.sandbox、wake receipt 与 Harbor metadata 契约,无未审核维护率或词表漂移(semantic_alignment: aligned / reuse_existing;code_volume: necessary,compatibility_assessment: retain;change_proportionality: proportionate;authority_semantics: aligned;default_off_isolation: isolated)。

English verdict: APPROVE at 9d4c17c. The opt-in todo_checklist Stop-hook baseline keeps workspace repos clean and handles UTF-8/control boundaries under C locale awk, while aggregate_control_telemetry resolves PRRT_kwDOStEbEs68fRHU by distinguishing verified (including observed zero) runs from missing or untimed receipts without cross-phase wake leakage.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

[P2] 阶段中部分回执缺失时仍报告成本已验证。 一个阶段已启动多个 wake,其中至少一个回执完整,另一个回执缺失或无法解析。 完整时工作 14 秒、控制成本比例 0.30。旧格式仍正确报告未知。在 plain + checklist 和 heartbeat 两臂,第二个新回执缺失或截断时都只累加第一个,并把工作 9 秒、比例 0.10 标为 verified。 用当前阶段已启动的 wake 身份作为覆盖分母。缺失或坏回执保留缺测标记,汇总只展示已观测的控制成本,工作时间和比例保持 null。继续排除前一阶段。

动机 / Motivation

依赖 control_telemetry_verified 比较 Stop-hook 和 LoopX 净成本的 benchmark 使用者。 Harbor 0.20.0 走实际 BenchmarkCodex.run。每阶段有两个新 wake 和一个已存在的旧 wake。让第二个新 wake 的回执完整、旧格式、缺失或截断。使用确定性本地传输。 完整时工作 14 秒、控制成本比例 0.30。旧格式仍正确报告未知。在 plain + checklist 和 heartbeat 两臂,第二个新回执缺失或截断时都只累加第一个,并把工作 9 秒、比例 0.10 标为 verified。 使用本地确定性任务传输。正式模型对照、验证器得分、费用和完整实验采用未运行。 可选对照基线和真实成本需要区别运行零工作与真正缺测。阶段可包含多个 wake,残存一份正常观测无法证明完整。 Stop-hook 对照和 LoopX 共享同一成本定义。当前阶段有应计回执不可用时,真实工作时间和比例保持未知。 对照契约 对照修订 ff55255012b7b192ed7fb92d64b91ae40ecce801。

  • B1 对照基线要显式启用,并保留关闭时已有提示约束。 通过。
  • B2 完整计时与可观测零工作可提供有效比率。 通过。
  • B3 阶段任何回执缺失或未计时都必须保留未知。 当前反例成立。

改动思路 / Approach

Worker 生成每次 wake 计时,Harbor 拥有当前阶段成员及文件读取。现有汇总 helper 保留未知,由 Harbor 传递真实覆盖。 原汇总 helper 已能保留不完整输入的未知值。补齐阶段覆盖即可,继续复用同一 owner 和已有状态。 主干的比较契约要求保留未知成本。该变更新增验证字段,之前没有对阶段报告完整性作出该认证。 本轮查验普通与 checklist 模式后,增加了混合完整和缺测的实际 Harbor 反例。 按仓库经验,在局部规则与包装变更之间检查首次使用及失败读回,从同一真实入口取证。

具体改动 / Changes

精确提交 9d4c17c0e715cadbd2b228d3c9660d4752fd0dc1,6 个文件 +1417/−35。6 个文件的增加主要是验证套件。生产变化集中于可选配置、实际 Stop-hook 与阶段归集。修复宜落在已有阶段读取。

  • _read_wake_receipts。只读取成功解析的 receipt,缺失或坏记录不进入当前集合。 代码
  • BenchmarkCodex.run。从目录扫描得出的剩余记录直接参与阶段汇总。 代码
  • aggregate_control_telemetry。对实际传入的每个元素检查完整计时。上游过滤缺测后,剩余完整记录会返回 verified。 代码
  • run_once。先建立每个 wake 的实体目录,回执在执行尾部写出。 代码

62 项普通隔离测试通过,16 项跳过。安装实际 Harbor 0.20.0 后执行相关套件,63 项通过、1 项只适用无 Harbor 的夹具跳过。另 8 组实际适配器观察得到反例。 定向回归测试

对主干的风险 / Risks

旧格式 JSON 作为一个可见元素正确保留未知。同一个 wake 缺文件或 JSON 截断会被跳过,已有完整记录使阶段错误获得 verified。 标准本地预检 9 项执行检查均通过。Benchmark 敏感变更仍有独立的合入资格人工项。 针对 PR 基线的只读 merge-tree 和签署检查通过。首次本地预检因缺少根目录 TypeScript 开发依赖中断,完成 npm ci 后以同一提交复跑。未跑真实模型或对外基准。远端 CI 未查询。

语义与 CI 对齐

在真实 Harbor 适配器的 plain + checklist 和 heartbeat 重放两个新 wake,分别缺失和截断第二份回执。覆盖两份完整与旧格式对照。 同一入口的变体先验证作用域,再从原捕获校验关键事实。

我的整体评价 / Verdict

REQUEST_CHANGES。 用当前阶段已启动的 wake 身份作为覆盖分母。缺失或坏回执保留缺测标记,汇总只展示已观测的控制成本,工作时间和比例保持 null。继续排除前一阶段。 保留对照臂开关。修复 phase 对缺测 wake 的可观测覆盖后重跑本地对照,再进入正式实验资格。 保留已有 worker 日志、原始 benchmark 结果和 output format,可沿用 missing_receipt/untimed_receipt。 基准敏感表面仍有独立合入人工项。当前要求修改由已验证的统计语义反例触发。

English verdict: REQUEST_CHANGES at 9d4c17c. In an actual Harbor 0.20.0 adapter run with two current wakes, one valid receipt plus one missing or truncated receipt is reported as verified (9 seconds, tax ratio 0.10) in both checklist and heartbeat modes. Retain known missing wake membership so phase work and ratio stay unknown.

Comment thread benchmark/runtime/harbor.py Resolved
…tax telemetry

Adds an opt-in, default-off todo_checklist Stop-hook counterfactual mode alongside verified monotonic control-plane overhead and tax telemetry across both Stop-hook and LoopX worker wakes. Distinguishes verified timed telemetry (including observed zero execution) from missing_receipt and untimed_receipt phases without fabricating 0.0/1.0 ratios, and runs the POSIX stop-hook checklist check under LC_ALL=C awk with C0-control scrubbing and UTF-8 boundary protection.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@loopx-agent
loopx-agent force-pushed the codex/s4-strong-stop-hook-todo-baseline-20261127 branch from 9d4c17c to 143e95a Compare November 26, 2026 19:49

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

提供独立的 Stop hook 清单对照,按阶段记录控制面开销和工作时间,使成本比较能区分实际零工作与证据缺失。 上一评审头按可读回执聚合,混合缺件被误标 verified。当前按阶段开始前后的 wake 目录识别预期覆盖。 配置 plain Stop hook 或 LoopX heartbeat 对照、使用 Harbor 回执比较成本的研究人员。

部分阶段从成本分母消失会偏离完整成本比较,直接影响研究判断。 原阶段的一份完整加一份缺失或损坏回执,在当前 head 均得到 missing_receipt,工作时间与比例保持 null。完整计时保留 phase 合计和原始除法;已测零工作、旧回执与缺失的区分仍通过。 真实 Harbor 0.20.0 的两个套件 75 通过、1 跳过(仅用于无 Harbor 环境的替代用例);额外非挂载回传矩阵 12/12。无 Harbor 时,两项原负例复验通过。普通运行时套件 143 通过,93 个环境或依赖相关用例跳过。 本轮覆盖实际本机 Stop hook、Harbor 0.20.0 及生产阶段聚合。外部模型和远端环境执行由隔离夹具替代,未测真实模型、远端回传服务或跨任务净收益。托管 CI 未查询。 验收契约

改动思路 / Approach

该改动沿用 BenchmarkCodex.run 启动 worker/scheduler → wake 回执 → Harbor phase context.metadata,另有本地生成 Stop 命令。清单保存在 trial home,主机 Stop 命令复用 native hook 注册和信任。汇总只读回执,并增加 typed 缺件状态。 同一阶段的已启动 wake 与可用回执分别跟踪。即使仍有有效统计,缺件会显式从聚合输入阻断 verified。缺件与旧回执使用已存在的状态语义。 复用现有 worker wake 目录、汇总函数及状态值。当前修复增加缺件计数,不额外启动 RPC 或探测。

具体改动 / Changes

精确提交 143e95a,本次对照目标 6915df6。6 文件 +1667/−35。相较上一评审头,生产增量集中于 Harbor wake 覆盖计数、汇总对部分缺件的降级与同一操作说明。其他差异是双模式及坏件测试。

关键代码讲解

  • BenchmarkCodex._wake_dirs。阶段开始前记录既有 wake,后续读取排除它们。 源码

  • BenchmarkCodex._read_wake_receipts。把目录存在、回执不可用分开计数,再交给汇总。 源码

  • aggregate_control_telemetry。只有完整的阶段计时覆盖才发布工作时间和成本比例。 源码

  • BenchmarkCodex.run。下载日志后生成阶段汇总。 源码

  • prepare_official_stop_hook。仅在显式 opt-in 的清单基线生成新 Stop 行为。 源码

  • complete-current-phase-control-tax(implemented)。研究成本按实际可比窗口计量。阶段回执覆盖不全时保留未知比值,完整覆盖才验收成本。

对主干的风险 / Risks

在 Harbor 0.20.0 的真实 adapter 实现上隔离外部执行及下载,模拟非挂载环境的日志回传。plain + checklist 和 heartbeat 都排除前一阶段回执;缺失、损坏、非字典和符号链接回执都保持未知,untimed 单独处理,完整计时才 verified。干净 base/head 的旧 plain 与 simple prompt、Stop 结果逐项一致。 对照组与 LoopX 若具有不同中止或日志缺失概率,遗漏会使二者的总成本不可直接比较。 保持对当前阶段目录与正式回执分别计数,完整缺口优先传播。

我的整体评价 / Verdict

APPROVE。 本次关闭混合回执覆盖的阻断发现。显式清单模式和已观察控制成本可用于后续独立资格验证。 只发布覆盖完整的占比,才能用对照研究比较改进的完整成本。

English verdict: APPROVE at 143e95a. The exact head fixes partial wake coverage in both modes. Real Harbor 0.20.0 adapter tests and a separate non-mounted download fixture pass; default plain and simple behavior matches the base. No live model or cost claim is made.

@huangruiteng
huangruiteng merged commit 75ddb0c into main Nov 27, 2026
23 of 29 checks passed
@huangruiteng
huangruiteng deleted the codex/s4-strong-stop-hook-todo-baseline-20261127 branch November 27, 2026 05:24
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.

2 participants