Repository navigation
fix(steward): recover reports and monitor follow-ups after zero-write replan or pre-dispatch failures - #9513
Conversation
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Exact head: 6b392476e549bf02334618c2d3a35d9addda9dda
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 让原生监控跟进识别实际的派发前退出
已有监控跟进 Todo,真实 Codex worker 在 starting 检查点后、派发前退出。 实际运行 Codex worker,在写入 starting 后、调用派发前注入异常。ChatStore 对 native_loopx 不保存 pending 标记,随后只写入 execution_worker_exited,并保留 started_at。冷却后原生调度解析返回 None,原跟进没有 .precommit-retry。 在 Chat 的生产写入点为这类原生工作提供可核验的未派发凭证,并让重试分类按该凭证匹配带 started_at 的真实记录。保留无凭证或已派发时的拦截。如果本次只交付 worker 启动前的准备失败恢复,收窄允许列表和交付说明。 用真实 worker 和 SQLite Todo 复验,覆盖冷却期后恰好一次接续,以及已派发、凭证缺失时继续拦截。 改动位置 ChatStore 派发检查点 worker 退出恢复
[P2] 恢复 monitor 模块的仓库边界校验
运行现有 steward monitor 合约测试。 同一仓库测试在基线以 741 行通过,在当前头以 794 行失败。既有断言对该模块设限 750 行,并在这之后检查导入 DAG。 复用 Chat 的派发证据判定,精简监控模块新增分类,恢复现有行数和导入约束。 python -m pytest -q tests/capabilities/test_steward_monitor_contract.py::test_steward_monitor_module_budgets_and_import_dag 改动位置 仓库模块合约
动机 / Motivation
使用管家定期报告和监控的操作者需要拿到原窗口报告,也需要在监控信号变化时完成对应的跟进。 当宿主重规划在提交前被拒绝,报告窗口可能留下零写入记录却未继续。监控跟进也可能在准备阶段退出,之后仍留在开放队列里。 隔离 SQLite 中,清除重规划阻塞后,原窗口只恢复一次并生成报告,次日正常运行。原生监控 worker 在派发前退出后,冷却到期依然没有跟进重试。 本次范围是原 Session 内的报告和监控恢复,沿用既有订阅、Todo、校验器和权限。
改动思路 / Approach
报告接续沿用 Chat 记录、Turn journal 和 TypeScript 原会话准入。监控恢复继续使用原 Todo 版本产生确定性载体 ID,派发前证据应由持久化派发状态的 Chat owner 提供。 当前提案需要保证零写入报告能够恢复,同时让声明支持的监控失败类型可由真实写入路径产生,并保留既有未知状态拦截。 Chat 现有处理只为 Lark 外部请求写入 pending,随后会用 committed 防止把已派发工作当成安全重试。原生跟进应沿用相同的证据强度。报告重规划回执则已能在原 journal 和新 guard 都合格时继续。 既有派发恢复合同 现有 Lark 恢复所有者
具体改动 / Changes
6 个文件,+303/-10。以 b6be7f6ab836bb91b416230b8147c027adfda5ba 的定期报告合同为基线。原报告窗口经 SQLite 验证,在清除阻塞后保持同一窗口并只恢复一次。原生准入仍核对宿主、身份、零写入和当前 guard。已证实未派发在监控边缺少对应的生产凭证。 定期报告合同
validate_replan把语义预检抛出的 ValueError 写成结构化校验失败,可从原 Turn journal 回读。 校验器report_selection_recovery读取本次失败探针的 journal,TypeScript 准入在原窗口与授权成立时接纳 task_postcondition。 报告证明 准入resolve_advancement_turn_id在冷却后依据旧载体选择有界接续。worker 的 starting 检查点与新增错误分类发生在不同生产边界,测试必须连到同一份持久化记录。 跟进选择 调度调用
对主干的风险 / Risks
精确头 18 项 Python 和 31 项 TypeScript 聚焦测试通过,管理队列与监控兼容组额外 22 项通过,现有模块边界测试有 1 项失败。两条作者新增回归移植至基线均失败,验证报告恢复和既有准备阶段的改进。真实 native witness 在基线和精确头均读到相同退出形态,也均无重试,表示这项交付缺口仍未闭合。隔离环境用实际 SQLite 和 Chat worker,Codex app-server 用合成 transport,异常只注入派发前检查点。未查询托管 CI。 报告回归 既有模块校验
我的整体评价 / Verdict
报告恢复和新治理回执可以保留。缺少匹配凭证时,原信号的跟进会持续留在开放 Todo 中。相同条件下耗尽重试的判定也依赖同一分类。 补齐原生生产凭证或收窄到已验证的错误范围,并恢复 monitor 模块边界后再复核。改动涉及 Chat 本地记录、CLI 校验和原生准入,没有修改渲染代码。SQLite 回归核对报告输出和次日窗口。 实际模型及外部投递未验证。
English verdict: REQUEST_CHANGES. A real native worker exit before dispatch still leaves the follow-up without a retry, and the monitor module now fails the repository's 750-line gate. Original report-window recovery passed.
|
补充一项独立复验的现有回归,绑定 |
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEADFor a same-repository clone whose Keep the DCO |
… replan or pre-dispatch failures Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
6b39247 to
d34c384
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
注:
pr-review包在当前无绑定会话中返回reviewer_execution.status = "unavailable" (session_not_bound),因此按reviewer_declaration规则以self_reported标明审阅身份。
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
本次改动面向通过 Steward 接收定时报告和持续 PR 监控推进汇报的用户,以及负责故障自恢复与模块契约门禁的 Steward 运行时维护者。
改造前,当 autonomous_replan 触发的 .replan 治理探针因候选改写无效在提交前阶段 task_postcondition 零写入失败时,周期报告在 replan 解除后仍卡死、监控跟进 todo 不在冷却后重试、validate_replan 遇到 ValueError 会抛未处理异常,且上轮基线存在两项 [P2] 缺陷;改造后,TS 与 Python 放行 task_postcondition 零写入恢复并将负测对齐到 settlement_postcondition,监控跟进抽共用 _past_precommit_cooldown 使模块回到 746 行并将预派发错误码收窄为三项,validate_replan 输出结构化 failed 回执。
细项改进(head d34c38497748a499e338f0bf9a463967c3f61189):
- TS 控制面
admitReportSelectionRecovery与 PythonStewardTurnHost.report_selection_recovery在保留#9515stopped日志拦截的基础上,统一放行task_postcondition(completed_phases == ["host_execute", "typed_result"],writeback/quota_spend/scheduler_ack == false)零写入阻断后的单次.admission-resume恢复,并同步将#9515的非循环负向测试对齐到settlement_postcondition。 steward_monitor_turns.py抽取_past_precommit_cooldown并精简辅助判断,将文件控制回746行(<= 750通过test_steward_monitor_contract.py),并将_PRE_DISPATCH_ADVANCEMENT_ERROR_CODES收窄为确实由外层准备拒绝到达的{"resume_failed", "runtime_unavailable", "model_auth_unavailable"},移除未有生产到达证据的"execution_worker_exited_before_dispatch",同时补充execution_worker_exited(已设started_at)及execution_worker_exited_before_dispatch的 fail-closed 负向测试。validate_replan新增except ValueError分支,输出公开发布安全的"failed"/"repair_required"回执。
可观测结果:一旦 autonomous_replan 阻塞解除,卡在 task_postcondition 零写入失败上的周期报告通过一次 .admission-resume 恢复投递,监控跟进 todo 在冷却后按上限安全重试且不会越界重试已派发/不可达状态。
边界与非目标:本 PR 仅处理零写入预提交失败的受控恢复与 validate_replan 异常收敛;不放开已派发、已写入状态或未知退出码的重试,不放宽任何模块行数预算。
改动思路 / Approach
设计取舍:将是否允许 .replan 后 .admission-resume 的最终裁决权继续放在 TS 权威控制面 admitReportSelectionRecovery,监控推进重试逻辑在既有 steward_monitor_turns.py 内通过共用 _past_precommit_cooldown 完成复用并严格收敛预派发错误码,既零新增模块或外部存储,又把模块控制在 746 行符合 750 行合约。当前 PR 边界:仅涵括零写入 task_postcondition .replan 后报告恢复、内联拒单及三类未派发准备态重试、与 validate_replan 的 ValueError 收敛,不放宽模块行数上限或已派发退出码拦截。
| 维度 | 改造前 / 上轮问题 | 本次修复后(d34c38497748a499e338f0bf9a463967c3f61189) |
|---|---|---|
task_postcondition 零写入 .replan 后报告恢复 |
TS/Python 仅允许 host_result_contract,阻塞解除后仍永久无法 .admission-resume |
TS 与 Python 统一放行且要求无写/无配额消耗/无调度确认且 replan 已清除,settlement_postcondition 仍 fail-closed |
监控跟进预派发与内联 .replan 重试 |
未识别内联 .replan 拒绝与预派发准备失败;上轮 [P2] 含 execution_worker_exited_before_dispatch 且模块达 794 行 |
收窄为 resume_failed / runtime_unavailable / model_auth_unavailable 并补充负向断言;抽共用 _past_precommit_cooldown,模块回落至 746 <= 750 行 |
validate_replan 非法候选处理 |
ValueError 未捕获导致校验回执退化为异常 inconclusive |
返回确定性 status: "failed", recovery_kind: "repair_required" 回执 |
- 入口与权威状态:报告恢复准入由 TS
steward_managed_mode.ts#L301-L387的admitReportSelectionRecovery持有权威判断;监控重试与耗尽判定由steward_monitor_turns.py读取ChatStore与NativeLoopXTurn 状态;预览校验由turn_run_once.py#L366-L392承担。 - 已有能力复用:直接复用现有
admitReportSelectionRecovery、_cleared_replan_guard、_is_precommit_retryable_advancement_turn与is_exhausted_zero_write_followup_todo,无新增外部存储或状态机。
具体改动 / Changes
- 规范基准(Spec Basis):本次修复针对线上真实发生的
.replantask_postcondition零写入卡死与上轮两项[P2]缺陷(spec_basis.decision = no_spec),改动语义与正负边界均由 TS 控制面单测与 Python 单元/合约回归直接验证。
关键代码讲解
-
admitReportSelectionRecovery与StewardTurnHost.report_selection_recovery(loopx/control_plane/collaboration/steward_managed_mode.ts#L365-L387,loopx/capabilities/native_chat/steward_turn.py#L574-L586)- 职责与变更:在原有
"host_result_contract"之外把"task_postcondition"纳入合法的前置治理零写入失败阶段;保留#9515对journal_status != "stopped"的严格 fail-closed 检查,仍要求completed_phases == ["host_execute", "typed_result"]、零写回/零配额/零调度确认且当前effective_action == "normal_run"。 - 测试对齐:原
#9515在tests/test_native_steward_reports.py#L2740-L2831以"task_postcondition"作为不可恢复探针样例,已对齐为"settlement_postcondition"(与steward_reports.test.ts一致),继续验证不可恢复阶段不会循环重试。
- 职责与变更:在原有
-
预派发收窄与 750 行模块收敛(
loopx/capabilities/native_chat/steward_monitor_turns.py#L428-L502)- 职责与变更:移除
[P2]指出的"execution_worker_exited_before_dispatch",将_PRE_DISPATCH_ADVANCEMENT_ERROR_CODES限定为frozenset({"resume_failed", "runtime_unavailable", "model_auth_unavailable"});要求status == "failed"、origin == "native_loopx"、loopx_execution is True、四个关键执行字段(response/upstream_turn_id/started_at/first_event_at)全为None、delta_count == 0且通过_past_precommit_cooldown。同时在turn_todo_selection_deferred分支支持内联.replanautonomous_replan零副作用失败的冷却后重试。抽取_past_precommit_cooldown并紧凑化相关分支后模块为746行,通过750行预算检查。 - 负向覆盖:
tests/test_steward_report_recovery_and_validator.py#L1647-L1755验证已设started_at的execution_worker_exited以及execution_worker_exited_before_dispatch均 fail-closed(_is_precommit_retryable_advancement_turn返回False、耗尽判断返回False)。
- 职责与变更:移除
-
validate_replanValueError收敛(loopx/cli_commands/turn_run_once.py#L366-L392)- 职责与变更:在
except ReplanWritebackRejected之外新增except ValueError,返回明确且不泄露私有路径的"status": "failed"、"recovery_kind": "repair_required"结构化回执。
- 职责与变更:在
对主干的风险 / Risks
- 负向边界与恢复分析:若
autonomous_replan依然处于激活态、validation_stage为"settlement_postcondition"或任何非零写/已设started_at的 Turn 记录,两端均拒绝.admission-resume与自动重试;已超过重试上限的零写入跟进任务受is_exhausted_zero_write_followup_todo约束停止循环。 - 隔离性、权限语义与默认行为披露:本 PR 属于既有 Steward 故障恢复路径的缺陷修复(
default_off_isolation = not_applicable,authority_semantics = not_applicable);未更改共享枚举词表(semantic_alignment = not_applicable);已披露默认行为变化:task_postcondition零写入.replan阻断解除后允许一次.admission-resume,监控跟进在冷却后可针对内联.replan零副作用拒单与三类未派发错误重放,且validate_replan的ValueError收敛为确定性failed回执。 - 本地验证矩阵(
wait_for_ci: false,不依赖远端 CI;已包含对两项[P2]及#9515对齐测试的完整复验):node --no-warnings --experimental-sqlite --experimental-strip-types --test tests/control_plane_ts/steward_reports.test.ts tests/control_plane_ts/steward_managed_mode.test.ts-> PASS(31 passed, 0 failed)npm run typecheck:control-plane-> PASS(exit 0)uv run --extra test python -m pytest -n 4 tests/capabilities/test_steward_monitor_contract.py tests/test_steward_report_recovery_and_validator.py tests/test_native_steward_monitor.py tests/test_native_steward_reports.py -q-> PASS(408 passed in 452.87s)uv run --extra test ruff check loopx/capabilities/native_chat/steward_monitor_turns.py loopx/capabilities/native_chat/steward_turn.py loopx/cli_commands/turn_run_once.py tests/test_steward_report_recovery_and_validator.py tests/test_native_steward_reports.py-> PASS(All checks passed!)uv run --extra test python scripts/check_rfc_bilingual.py --base origin/main --head HEAD-> PASSuv run --extra test loopx canary premerge --from-git-diff --git-diff-base origin/main --tier quick-> PASS(selected=3, failures=0, warnings=0)
我的整体评价 / Verdict
- 长程与用户体验影响:
long_horizon = improved(恢复被task_postcondition零写入.replan与预派发失败长期锁死的每日定时汇报与跟进监督链路,防止人工反复兜底);user_experience = improved(监控汇报恢复准时投递;visual_review = not_applicable,原因:仅涉及 TS 控制面校验、Python 后端运行时与测试,无前端 UI 渲染改动,unverified_scope = none)。 - 代码体量、可观测语义与词表归属:全 diff 7 个文件
+316 / -63(生产改动 4 文件仅+72 / -60,steward_monitor_turns.py为746行符合<= 750契约),code_volume = necessary,change_proportionality = proportionate;observable_semantics = intentional_change_validated。 - 残余风险与最终结论:单元与合约回归使用可控替身模拟
.replan探针日志及外层准备拒绝;两项[P2]均已在 exact headd34c38497748a499e338f0bf9a463967c3f61189修复并通过全量本地门禁,可关闭未决审阅线程并完成合入。
英文简短结论
English verdict: APPROVE at exact head d34c384 — resolves both [P2] findings by narrowing _PRE_DISPATCH_ADVANCEMENT_ERROR_CODES to verified pre-dispatch errors (resume_failed, runtime_unavailable, model_auth_unavailable) with fail-closed tests for execution_worker_exited / execution_worker_exited_before_dispatch and refactoring _past_precommit_cooldown so steward_monitor_turns.py stays at 746 lines (<= 750); 31 Node TS tests, typecheck, 408 pytest regressions (including test_steward_monitor_contract.py and aligned settlement_postcondition), ruff, bilingual RFC check, and quick canary premerge all passed locally with zero findings.
…it modules to loopx-workspace, fix contract test Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Summary
.admission-resumerecovery (steward_managed_mode.ts,steward_turn.py): Admit.admission-resumeonce a blockingautonomous_replanobligation has cleared (effective_action == "normal_run"andreplan_action_packet == null) when the prior.replangovernance probe failed pre-commit validation atvalidation_stage == "task_postcondition"(in addition to"host_result_contract") with zero durable writes (completed_phases == ["host_execute", "typed_result"],writeback/quota_spend/scheduler_ack == false). Preserve#9515's stopped-journal fail-closed checks and returnNonefromreport_selection_recoverywhile replan remains active or on non-recoverable failed probes.steward_monitor_turns.py): Recognize two zero-write failure shapes in_is_precommit_retryable_advancement_turn(andis_exhausted_zero_write_followup_todo) via_past_precommit_cooldownwhile staying within the 750-line module ceiling (746lines):turn_todo_selection_deferred(reason_code == "autonomous_replan") where the inline.replanprobe invoked the host (host_invoked == true) without durable writes (state_written == false,quota_spent == false,scheduler_acknowledged == false).native_loopxChat preparation failures (resume_failed,runtime_unavailable,model_auth_unavailable) that failed strictly before worker dispatch (started_at == null,first_event_at == null,upstream_turn_id == null,response == null,delta_count == 0). Unmappedexecution_worker_exited/execution_worker_exited_before_dispatchand post-start failures fail closed.turn_run_once.py): CatchValueErroralongsideReplanWritebackRejectedinvalidate_replanso invalid candidate fields produce a structured public-safefailedvalidator receipt rather than an unhandledinconclusiveexception.tests/test_native_steward_reports.py,tests/test_steward_report_recovery_and_validator.py,tests/control_plane_ts/steward_reports.test.ts): Align the pre-commit non-looping negative test on"settlement_postcondition", add negative fail-closed tests forexecution_worker_exited/execution_worker_exited_before_dispatch/ started turns, and cover TS/Pythontask_postcondition.admission-resumerecovery and validator receipt handling.Verification
node --no-warnings --experimental-sqlite --experimental-strip-types --test tests/control_plane_ts/steward_reports.test.ts tests/control_plane_ts/steward_managed_mode.test.ts(31 passed, 0 failed)npm run typecheck:control-plane(exit 0)uv run --extra test python -m pytest -n 4 tests/capabilities/test_steward_monitor_contract.py tests/test_steward_report_recovery_and_validator.py tests/test_native_steward_monitor.py tests/test_native_steward_reports.py -q(408 passed)uv run --extra test ruff check ...,uv run --extra test python scripts/check_rfc_bilingual.py --base origin/main --head HEAD, anduv run --extra test loopx canary premerge --from-git-diff --git-diff-base origin/main --tier quick(passed, 0 failures)