Repository navigation
fix(native-chat,status-server): bound steward pump failures and absorb HTTP disconnects - #9515
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: 1595ae47bacf6161f91584e3f0ef11a5de264fcf
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 把 watch 的退避限制在 watch 提交
同一 managed Session 的 watch 连续提交失败两次,随后独立报告或日历窗口到期。 第二次失败会把 watch 退避增至 120 秒。当前外层在进入 _process_managed_session 之前直接跳过该 Session,所以健康的 weekly-progress 与 session-task 两种 frontier 都没被查询。独立成对测试中,基线在 t=1122 提交窗口;当前头直到退避结束才有机会运行。 将 watch 的校验、提交和退避放在它自己的分支,继续核对健康报告与日历;共享会话或准入故障可以保留外层退避。 用两次 watch 失败后于退避期间到期的报告和日历做回归,并核对 watch 未被提前重试。 变更位置 日历入口 报告入口
[P2] 后台警告应避免输出原异常的路径片段
报告准备阶段遇到普通文件权限错误,文件位于带空格的目录中。 新逻辑对 str(exc) 作空白切分和路径正则替换,仅遮掉第一个空格前的路径部分。生产 pump 的合成 PermissionError 测试读到后续目录名和文件名;基线仅输出固定诊断。 日志与去重使用稳定阶段、异常类型、errno 或经允许的原因码,不拼接任意异常文本。保留现有退避值与警告频率。 用带空格的常见路径验证真实 pump 的 warning 不含目录或文件片段,再核对退避和恢复。 变更位置 日志调用 现有 Chat I/O 诊断边界
动机 / Motivation
运行长时 Chat 和 Status 的操作者需要单条失败按 lane 降频,同时按时运行同会话的正常报告或日历工作。 旧 pump 给部分故障重复输出固定警告。补丁引入每类退避,并在 HTTP 边缘统一处理客户端提前断开。 定向 159 项回归和新原报告测试通过。成对生产 pump 入口验证显示,watch 连续失败会拖延同一会话的日历和报告,新增日志还保留带空格路径的私有后缀。 当前提案属于后台选择、日志及 HTTP 传输。新的调度策略、模型路径和外部投递以现有边界为准。
改动思路 / Approach
保留定期报告和日历的原准入与收敛节奏。由各自工作的调用点分类与退避,共享会话不可读的外层状态才应用会话级退避。HTTP helper 继续归拥有 socket 响应的传输层。 保留断开识别和报告失败的局部退避,把 watch 的失败限制在 watch 子步骤,并用允许列表字段代替日志中的异常文本。 当前 HTTP 响应助手可以保留,真实 socket 用例能区分提前断开和其他 I/O。独立报告窗口之后还需用修订版检查 watch 退避的作用域及日志字段,避免用统一分类重复承担该决定。 既有契约
具体改动 / Changes
9 个文件,+833/-58。复核采用 d976868f7a9db73398014ffe4a0d69c3d0383979 的产品契约。日历窗口独立保留、诊断边界、正常传输与断开 逐项对应下列关键入口。 基线契约
pump_managed_session_monitors处理当前真实会话和 watch failure hint。活动的 watch 退避挡在整个会话入口。需下沉 watch gate。 源码_sanitize_exception_summary处理来自本地失败的异常对象。正则去除部分路径后输出原异常文本。改用稳定诊断字段。 源码send_http_response处理已准备的 HTTP 响应。只吞可分类的提前断开。其他 OSError 继续上抛。 源码report_selection_recovery处理原报告探针与 journal。仅合格失败或 stopped 继续。与 #9513 的原报告修复需按共同基线核对。 源码
对主干的风险 / Risks
精确头 159 项 monitor、后台隔离、Status、Chat tests 通过,含测试使用真正 loopback socket 的断开;2 项报告回归、Ruff 及用精确 Git index 的 maintainability ratchet 均过。 仓库原 pump 入口在隔离会话与合成前沿/故障下,基线三例全通过,精确头三例失败。两次 watch 错误后的正常 frontiers 均未调用;实际报告 warning 保留空格后的目录及文件后缀。 同一时钟、真实 pump/ChatStore、注入 watch 提交失败与可成功 frontiers,分别执行基线和精确头。补充合成文件系统异常并检查真实 pump 发出的 warning。 同一生产 pump 入口和同一故障矩阵的基线/精确头对照,另验健康 JSON、Status 与 Chat 断开路径。 按 Goal 的 CI 设置未查询远端托管检查。
我的整体评价 / Verdict
watch 故障在退避增长后可能让健康报告迟到最多约一小时,且涉及两类原日历 frontiers。 健康日历窗口无需追随 watch 的故障重试,日志也不应带出原异常中的私有文件名。 保留现有 Chat 诊断中不记录原异常文本的边界,复用现有报告准入与 HTTP 传输 owner。 当前 HTTP 响应助手可以保留,真实 socket 用例能区分提前断开和其他 I/O。独立报告窗口之后还需用修订版检查 watch 退避的作用域及日志字段,避免用统一分类重复承担该决定。 改动仅涉及调度与 HTTP 传输层。健康 JSON、CORS 与实际 socket 提前关闭都进入回归;页面渲染没有变化。 未验证正式部署、真实模型或外部投递。监控回归使用真实 pump 与合成 provider 边缘;HTTP 覆盖 loopback socket。托管 CI 未查询。
English verdict: REQUEST_CHANGES. Watch-specific failures back off healthy report and calendar work in the same session, and the new warning retains private path fragments. HTTP disconnect handling passed the focused checks.
1595ae4 to
e9b2087
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
动机 / Motivation
持续运行本地 Chat 的管家操作者及同进程的其他监控和报告。 管家守护进程应保留原任务和会话,限制重复失败成本,同时让健康监控和报告继续推进。 当前候选用分 lane 的指数退避限制持续故障,并吸收正常 HTTP 对端断连。
旧版重复执行失败准入。候选抑制同一告警和暂时跳过准入,但每次跳过前仍扫全量历史。 健康 HTTP、独立报告和 watch 的定向路径通过,退避中的历史读取仍随会话长度增长。
实际长期开销、运行中的守护进程及自然到期通知仍未复验。未查询托管 CI。
改动思路 / Approach
report_selection_recovery 只接受已停止的 probe 或原有 host_result_contract 恢复情形。_exception_diagnostics 按异常类、errno 和白名单错误码记录。Chat 的 JSON、附件、SSE、重定向和 OPTIONS 复用 Status 传输收尾。 在仍处于退避时读取可定位到该 Goal/会话的廉价变更信号,按明确的修复事件或退避到期再深入读取历史。用大历史和无关注册表更新核对退避期间的访问上限及其他 lane 的进度。
维护状态仅属于 Python host;同时扫描 route 的全部 turns 与全局 registry 使开销与历史和其他 Goal 活动耦合。
具体改动 / Changes
完整核对 cc44cb7c1601af333b5f828e9f9fe4b378a2c66a 到 e9b208700978ea806f0044e036f164e67baf3ebf 的 9 个路径(+1146/-94)。管家守护进程应保留原任务和会话,限制重复失败成本,同时让健康监控和报告继续推进。 Original private steward
关键路径
- 计算共享准入失败的存储见证。_session_storage_witness
- 在真实轮询路径组织 binding 与 Managed Session。pump_steward_monitors
- 共享 HTTP 响应写入,区分客户端断连与实际 I/O 失败。send_http_response
- 保留原报告及合法恢复 probe。report_selection_recovery
对主干的风险 / Risks
[P2] 退避期间仍逐轮扫描全部历史,且无关注册表更新可重试。用实际 pump 和临时 File turns 目录注入一次同样的准入失败。退避中的三个后续轮次没有重调该准入,但每轮分别读取 32、128、512 个历史文件的 stat,数量随历史线性增长。随后只写与当前 Goal 无关的 registry 内容,模拟 t=1004 再调用 pump,原 t=1000 的同一故障在 60 秒期限前被重试。 维护状态仅属于 Python host;同时扫描 route 的全部 turns 与全局 registry 使开销与历史和其他 Goal 活动耦合。 当前代码
独立定向 152 项通过,包括 watch 与健康报告隔离、路径去敏、断连和健康 HTTP。共享 transport 保留非断连错误。 独立受控时钟与单 lane 故障注入。执行真实 pump 循环以及真实文件目录遍历,未使用现用守护进程或生产数据。 实际长期开销、运行中的守护进程及自然到期通知仍未复验。未查询托管 CI。
我的整体评价 / Verdict
REQUEST_CHANGES。在仍处于退避时读取可定位到该 Goal/会话的廉价变更信号,按明确的修复事件或退避到期再深入读取历史。用大历史和无关注册表更新核对退避期间的访问上限及其他 lane 的进度。 本次范围为已核对的宿主运行时与定向验证,界面布局未改。
English verdict: REQUEST_CHANGES — recovery backoff still scans the full session history on every suppressed poll, and an unrelated registry update can retry the unchanged fault before its deadline.
…b HTTP client disconnects Add per-lane bounded exponential backoff (60s-3600s) and state-transition deduplicated path-redacted warnings in steward_monitor_pump so foreground idle flips and monitor deadline hints never bypass active failure backoffs, while clearing failure hints on configure/reset. Fail closed in StewardTurnHost.report_selection_recovery for non-resumable completed probe journals such as task_postcondition so StewardReports.frontier retains the retry turn cleanly without looping on _admit. Extract DisconnectSafeHTTPServer, is_client_disconnect_error, and chunked send_http_response in status_server and reuse them across status_server and chat_server to absorb benign peer disconnects without stderr tracebacks while preserving status JSON formatting. Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…h backoff, and log allowlisted diagnostics Attach a lightweight stat witness for outer binding/session admission failure backoffs so repaired session or queued-turn files recover immediately without disabling backoff on unchanged failures. Scope managed-session watch backoff to the watch branch only so healthy weekly-progress and session-task frontiers still advance, and log/deduplicate only allowlisted stage, exception class, errno, and safe code fields without str(exc). Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
e9b2087 to
a5cc832
Compare
|
Updated PR #9515 at
|
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: a5cc8323cda8be1729584d92df2064649e5a691f
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 每个退避绑定反复读取整份未变的 registry
四个已绑定会话各有不可解码的会话文件,所有绑定均处于退避,连续三个空闲 tick 没有新输入。 上一头读 registry 0 次。当前头读 12 次。把无关 Goal 从 32 增至 4,096 后,读取字节从 164,844 增至 21,073,884,仍没有会话重试。读取和解码成本跟 registry 全量与失败绑定数相乘。 复用现有 registry 读取方的快照。按文件版本复用,再在快照内检查真实受影响的 Goal;主管理路径保留修复提前放行。 对同一文件运行多个退避绑定,记录无变化 tick 的文件读取上界,并验证改动目标 Goal 能触发恢复、改动无关 Goal 不提前重试。 变更位置 整份 registry 读取 退避调用
动机 / Motivation
Steward 后台 worker 会在有多个持久失败绑定时持续经过同一已启用 pump。 早期修订会在退避中遍历会话历史。新头只记录当前及出错的回合文件,监控退避期间另按绑定读取所属 Goal。 新头在历史记录改写期间维持一次坏会话尝试。四个未恢复的绑定每次空闲 tick 却读取同一 registry 四次。 继续采用原绑定、Goal 所有权、宿主循环和文件状态。现有 HTTP 处理方式与 CLI 输入范围保留。
改动思路 / Approach
Pump 拥有退避和触发,ChatSessionStore 提供用到的会话及回合,registry 已有按请求共享快照,HTTP helper 拥有传输关闭。 原失败继续在各 binding 下计时,修复正常重新放行。开放的回合、报告和 watch 保留。 仅当前三文件增量改变 witness、异常源指向和测试。复核完整十个变更文件,包含原有报告与 HTTP 边界。 既有契约
具体改动 / Changes
10 个文件,+1397/-148。复核采用 fc232e5d58699101f47729dc389f93a6d7426076 的产品契约。STEWARD-RECOVERY implemented、STEWARD-READ-BOUND not_met、HTTP-DISCONNECT implemented 逐项对应下列关键入口。 基线契约
_session_storage_witness处理失败的会话、回合和所属 Goal。每个退避内的失败绑定读取一次 Goal。来源变化允许下一次尝试。 源码pump_steward_monitors处理已有 Steward 绑定。每项独立退避。沿用原 tick 和回合所有者。 源码load_goal_from_registry处理registry 路径和 Goal id。无请求 scope 时先读取完整 registry。保留现有读取错误。 源码send_http_response处理已有 HTTP 响应。受理客户端提前断开。传播非断开错误。 源码
对主干的风险 / Risks
独立的 256 回合夹具验证原问题消失,旧记录修改期间只有初次失败,也没有历史扫描。 32 个无关 Goal 读取 164,844 字节,4,096 个无关 Goal 读取 21,073,884 字节。两者都是 12 次整文件读,绑定内容原样。 在上一头与本头运行同一个真实 store 和 pump,记录 registry 字节与坏会话尝试,并运行 monitor、报告和 HTTP 分支测试。 相同四个坏会话、三次固定时钟 pump 调用。上一评审头读 registry 0 次,新头读 12 次,两种配置下均未增加会话重试。 独立对照使用真实文件和生产 registry codec,时钟与绑定列表由夹具控制。字节统计不等同常驻 CPU 或实际磁盘读取量。 按 Goal 的 CI 设置未查询远端托管检查。
语义与 CI 对齐
32 个无关 Goal 读取 164,844 字节,4,096 个无关 Goal 读取 21,073,884 字节。两者都是 12 次整文件读,绑定内容原样。 复用现有 registry 读取方的快照。按文件版本复用,再在快照内检查真实受影响的 Goal;主管理路径保留修复提前放行。 按上述成对场景复验原入口,保留现有权限和状态词汇。
我的整体评价 / Verdict
退避期间的开销重新受整份 registry 大小与失败绑定数共同放大。目标记录不变时仍然解码整份文件。 原任务和报告不会因历史写入提前重试,常驻服务在空闲阶段仍承担重复读取与解析开销。 让已拥有 registry 的读取方提供每轮共享快照,另用文件版本复用同源 Goal 切片。用新读取替换同一来源时保留真实配置修复的提前醒来。 后台调度和 HTTP 传输代码,首屏不受影响。 独立对照使用真实文件和生产 registry codec,时钟与绑定列表由夹具控制。字节统计不等同常驻 CPU 或实际磁盘读取量。
English verdict: REQUEST_CHANGES on exact head a5cc832. Historical turn scanning is fixed. During backoff each failed binding still reads and parses the entire unchanged registry on every idle poll.
…ticks Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
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: b8a6c48aa3721ad1fe0e56ea1221a43c90578913
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
常驻 Steward 需要在有坏会话时继续处理健康绑定。上一修订在退避中每轮按失败绑定反复读取 registry。健康绑定在独立的退避窗口中继续运行,HTTP 服务在客户端断开后仍可响应。 本次沿用已有报告窗口和 HTTP 入口。 现有恢复契约
改动思路 / Approach
Pump 以文件设备、inode、修改时间和大小识别 registry 版本。它复用现有 codec,把摘要分到各 Goal。独立队列和现有窗口继续由原调用方管理。无需迁移会话文件。 共享 Goal 摘要
具体改动 / Changes
10 个文件,+1510/-153。较上一评审只有 pump 和其测试改动。会话存储的文件 witness 只看相关试次。共用 HTTP helper 保留原响应数据,分片发送时处理已断开的连接。 会话 witness HTTP 发送
- STEWARD-RECOVERY。已有会话的进度和窗口继续由其 lane 管理,报告恢复可以留在原回合。 泵入口
- STEWARD-READ-BOUND。每一文件版本共享一份缓存,Goal 摘要决定哪些绑定提前退出退避。 缓存
- HTTP-DISCONNECT。
send_http_response把短写与刷新纳入同一断开处理。非断开异常传播到既有错误处理路径。 响应写入
对主干的风险 / Risks
隔离环境里四个坏会话在三个空闲 tick 进入退避。上一头在 32 与 4,096 个无关 Goal 的场景均读取 12 次,分别读取 164,844 与 21,073,884 字节。本头两种规模均为 0 次。修改无关 Goal 共用一次读取,改动目标 Goal 后只有它的绑定提前重试。46 项监控和 Status 定向用例、118 项宿主与 HTTP 用例、2 项报告恢复用例通过。定向范围涵盖真实断开后健康响应和非断开错误传播。
语义与 CI 对齐
原报告窗口、绑定权限和 CORS 检查由原入口判定。独立对照用真实 ChatSessionStore 和 registry 文件及受控时钟。未测活跃部署的 CPU,未查询托管 CI。完整报告测试扩展运行在五分钟后停止,报告结论采用已完成的两项定向恢复测试。
我的整体评价 / Verdict
以作者自评形式给出通过结论。缓存修复覆盖前次求改的范围,实际恢复和传输用例均通过。后台调度和 transport 的变更可以通过现有服务入口观察,界面布局未改动。
English verdict: APPROVE on exact head b8a6c48.
Summary
Fixes two production service log/resource pathologies observed in continuous local daemon runs:
steward_monitor_pump.py,steward_reports.py,steward_monitor.py,steward_turn.py):60s -> 120s -> ... -> 3600scap) and state-transition deduplicated path-redactedWARNINGdiagnostics (_failure_key,_sanitize_exception_summary,_record_failure,_clear_failure) across steward report frontier, due-monitor submission, advancement submission, outer binding processing, managed-session calendar/report frontiers, and managed-session watch processing.fg_checked[binding_id] = False) or soon-due monitor timers (_schedule_soonest_monitor_backoff/ managed-sessionremaining < 60) overrode active failure backoffs or re-triggered failing report frontiers, while keeping foreground advancement dispatch unthrottled when healthy.clear_steward_monitor_check_hintsinStewardReports.configureandStewardMonitor._clear_next_check_hintso reconfiguration or recovery resets both throttle hints and failure state cleanly.StewardTurnHost.report_selection_recoveryto fail closed cleanly (return None) when a finished.admission-retryprobe journal is neither"stopped"nor an audited"host_result_contract"failure (e.g.,"task_postcondition"), soStewardReports.frontierretains the existing turn cleanly without repeatedly raising from_admit.status_server.py,chat_server.py):is_client_disconnect_error, chunkedsend_http_response(64 KiBslices +flush()+close_connection = True), andDisconnectSafeHTTPServer(handle_errorguard for benign peer-close errors only) instatus_server.py, reusing them acrossStatusRequestHandlerandChatRequestHandler(_send_json,_serve_asset, SSE stream headers/loop,/redirect,do_OPTIONS) while keepingindent=2status JSON parity and re-raising real non-disconnectOSErrors.Verification
ruff checkon all 9 modified files: passedmypy --follow-imports=silent loopx/capabilities/native_chat/steward_monitor_pump.py: passed (0issues)scripts/check_rfc_bilingual.py --base origin/main --head HEAD: passedexamples/control_plane/control-plane-maintainability-ratchet-smoke.py --format=json: passed (ok: true,steward_turn.py <= 2000LOC)npm run typecheck:control-planeandnode --test tests/control_plane_ts/steward_reports.test.ts(12/12): passed.venv/bin/python -m pytest tests/capabilities/test_steward_monitor_contract.py tests/test_steward_background_monitor_isolation.py tests/test_status_server_cors.py tests/test_status_server_fast_path.py tests/test_status_server_ssh_hosts.py tests/test_chat_server_cors.py -q: 159 passed.venv/bin/python -m pytest tests/test_native_steward_reports.py -k "task_postcondition or report_recovers_via_admission_resume_once_blocking_replan_clears_after_contract_failure" -q: 2 passed (192 deselected)change-quality(cqr_25a827bc0aa76f04df7b,scope_fingerprint:25a827bc0aa76f04df7b55d7d62271d4c0f713e20accc6c3fb8ce7c8999e5ddd): passed / validcanary premerge --from-git-diff --git-diff-base origin/main --tier standard: passed (6/6catalog canaries,0failures)