Repository navigation
fix(attention_queue): align AttentionWaitingOn with status contract and wire AttentionQueueProjection - #9464
Conversation
…nd wire AttentionQueueProjection 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
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
把注意队列的 waiting_on 和返回类型对齐到生产 Status 的已使用值。 原声明遗漏 monitor_signal,真实 Status 仍会输出它。返回 dict 的精确字段未贯穿三个消费者。 读取全局 Status 和单 Goal 状态的操作人、监控 Agent 与下游展示。
类型落后于已有 monitor 值会妨碍添加正常消费者,也容易把观察任务误解成行动待办。 双版本真实 CLI 在隔离 File 和 SQLite 上均得到 3 行,执行等待 codex、监控 monitor_signal、owner 门槛 controller 各 1 行。监控同时保留 execution_waiting_on=codex,按 Goal 过滤后只留下监控项,各来源字节保持。 Head 217 项定向测试、attention-queue-readmodel-smoke 和 git diff --check 通过。原基线契约与集成 13 项通过。双版本真实 status CLI 各检查两个 provider 的全局及过滤投影。 结论覆盖精确工作树和隔离 CLI。运行时只校验 waiting_on,其他可选属性依其既有生产者。未核验当前安装、远程 CI 或浏览器。 基线契约
改动思路 / Approach
该改动沿用 loopx status → status attention projection → build_attention_queue。以现有状态 producer 定义 Literal,队列、adapters 和 Status 消费同一 TypedDict。 按结构化 waiting_on 做桶计数,监控显示和执行等待分别保留。构造队列时验证值,再用 typed projection 交给原消费者。 让已有 registry/monitor vocab 成为类型来源,保留一份桶计数实现,同时保留 monitor 的既有测试注入点。
具体改动 / Changes
精确提交 be69f1d,分叉基线 57c4c43。7 个文件,新增 248 行、删除 51 行,包括 producer/consumer 类型、行校验、桶计数契约与测试。
关键代码讲解
-
AttentionWaitingOn。复用 registry 和 monitor 既有词汇。 源码 -
_validated_queue_items。转换边界检查 waiting_on,对应原监控注入 seam。 源码 -
build_attention_queue_projection。保持现有分桶、计数与 Goal 过滤结果。 源码 -
build_attention_queue_projection。将 typed 投影交给生产 Status 消费者。 源码 -
preserve-existing-operator-wait-projection(implemented)。状态投影保留现有来源、可执行/观察区别和只读属性,并以已有状态词汇表达。
对主干的风险 / Risks
新增契约测试拒绝未知内部 waiting_on 值,严格 mypy 覆盖键名拼错。监控条目保持 watch,不进入需执行的 codex 桶;全局和 Goal 过滤结果在两版一致。 读模型若改变监控路由或过滤计数会误导操作者。双 provider 使用真实 CLI 验证。 复用真实 monitor 词汇和独立 execution_waiting_on 投影,按合法值 fail closed。
我的整体评价 / Verdict
APPROVE。 生产只读投影保持相同字段及分桶,类型已覆盖既有监控值,并守住未支持的内部等待值。 用户门槛、可执行下一步与自动监控等待继续按其原始状态展示和计数。
English verdict: APPROVE at be69f1d. Exact-base/head File and SQLite status preserve action, monitor and owner buckets and Goal-filtered readback. The typed queue includes the existing monitor value and rejects unsupported internal waits.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
本 PR 面向状态与注意力队列(attention_queue,即按等待方分桶的活跃目标队列)调用方(attention_projection、status 与控制面测试),修复 PR #9452 遗留的队列类型合同与运行时不一致问题。
- 触发背景与前后对比(Before / After):改造前,AttentionWaitingOn 遗漏合法状态值 monitor_signal,且 build_attention_queue_projection 与 build_attention_queue 返回松散的 dict[str, object],导致拼写错误 waitng_on 可通过 mypy 检查并在运行时触发 KeyError,同时存在无调用方的冗余导出 GlobalRegistryFindingSeverity 与 AttentionQueueCounts。改造后,AttentionWaitingOn 复用状态契约全部 5 个值,AttentionQueueItem 强制约束 waiting_on,build_attention_queue 与状态门面统一返回 AttentionQueueProjection,静态检查可接受 monitor_signal 并在编译期拦截 waitng_on 拼写错误。
- 可观测收益:已移除冗余导出并复用完整 5 值 waiting_on 词表,47 个 loopx 相关调用文件保持 +0/-0 mypy 错误增量,共享 SQLite 快照下的 status CLI JSON 输出与基线 57c4c43 完全一致,2071 项架构/金丝雀测试、756 项状态与注意力测试及 18/18 premerge 检查全部通过。
- 非目标边界:非目标:不修改运行时调度决策、不改写既有 status CLI JSON 序列化结构、不改变 goal_attention_projection.py 既有 normalize_operator_question 签名,也不改造尚未迁移 TypedDict 标注的 examples/ 独立演示脚本。
改动思路 / Approach
本 PR 严格遵循单一真源原则修复 PR #9452 审查意见。[P2] 问题根源在于 attention_queue_types.py 手写了残缺词表且构造器只标注 dict[str, object]。将 RegistryWaitingOnOverride 与 MonitorSignalWaitingOn 保留在各自 status 投影模块中单点定义,并在 attention_queue_types.py 组合为 AttentionWaitingOn、接通 build_attention_queue 与 status 门面,无循环依赖且通过全部架构边界测试。当前 PR 边界仅对齐 AttentionWaitingOn、AttentionQueueItem、AttentionQueueProjection 类型定义与 3 处构造/门面签名,并增加严格静态检查和运行时校验测试,未改动调度策略或前端展示。
- 入口与复用链路:在
goal_attention_projection.py提取RegistryWaitingOnOverride(4 项覆盖值),在monitor_display_projection.py提取MonitorSignalWaitingOn("monitor_signal"),在attention_queue_types.py组合为AttentionWaitingOn与ATTENTION_WAITING_ON_VALUES,同时删去无调用方的冲突导出GlobalRegistryFindingSeverity和AttentionQueueCounts。 - 端到端类型闭环与运行时防线:将
Sequence[AttentionQueueItem]与AttentionQueueProjection返回类型统一接到attention_queue.py、attention_projection.py和loopx/status.py,并在build_attention_queue出口新增_validated_queue_items,在运行时也对非法waiting_on做到 fail closed。
具体改动 / Changes
本次共改动 7 个文件(+248/-51):goal_attention_projection.py(+4/-3)、monitor_display_projection.py(+3/-2)、attention_queue_types.py(+62/-21)、attention_queue.py(+26/-8,现 548 LOC)、attention_projection.py(+7/-4)、loopx/status.py(+4/-4,维持 1339 LOC 上限)及 test_attention_queue_contract.py(+142/-9)。
关键代码讲解
AttentionWaitingOn(loopx/control_plane/work_items/attention_queue_types.py#L12-L13):组合RegistryWaitingOnOverride与MonitorSignalWaitingOn构成全部 5 个合法waiting_on字面量,并经get_args派生ATTENTION_WAITING_ON_VALUES,同时移除零调用方的GlobalRegistryFindingSeverity与AttentionQueueCounts。build_attention_queue_projection(loopx/control_plane/work_items/attention_queue.py#L100-L144):入参收紧为Sequence[AttentionQueueItem]、返回值绑定为AttentionQueueProjection(强制available与items字段,兼容任意Sequence),并在attention_projection.py与loopx/status.py同步签名。_validated_queue_items(loopx/control_plane/work_items/attention_queue.py#L453-L465):在build_attention_queue收口处逐项核验waiting_on为字符串且属于ATTENTION_WAITING_ON_VALUES | {context.monitor_signal_waiting_on},拒绝如"bogus_wait"或"other"等未受支持值并抛出ValueError。build_attention_queue(loopx/status.py#L1035-L1065):使兼容门面与内部读模型共享同一个AttentionQueueProjection返回契约,并在不增减StatusCollectionContext调用错误的前提下保持 0 ASTAny。
规范核对(Specification Mapping)
依据已验收协议文档 docs/status-data-contract.md(审阅基线提交 c10b100c049e8298622e5bc96e6756631dd3d8b5)逐条核对:
SDC-AQ-1:implemented —AttentionWaitingOn与ATTENTION_WAITING_ON_VALUES完整涵盖user_or_controller、controller、codex、external_evidence和monitor_signal5 个活跃状态。SDC-AQ-2:implemented —build_attention_queue_projection与build_attention_queue在work_items、status/attention_projection与loopx.status全部绑定AttentionQueueItem与AttentionQueueProjection,正例monitor_signal通过且反例waitng_on被mypy --strict捕获。SDC-AQ-3:implemented — 已删除未使用的冲突类型GlobalRegistryFindingSeverity与AttentionQueueCounts,并在真实 SQLite 状态 CLI 中与基线逐字段等价。
对主干的风险 / Risks
- 反例与非阻塞跟踪点:
- 对照共享 SQLite 快照下的真实
status --format json输出与AttentionQueueItem.__annotations__,运行时条目还可能携带 3 个未写入TypedDict的可选键(goal_channel_projection、handoff_mode、long_task_cadence_hint);经核查mypy --strict下item.get(...)可正常编译(rc=0),全部47个loopx/模块调用方均无新增错误(+0/-0),仅当外部类型化代码直接下标访问item["goal_channel_projection"]时才需在后续小补丁补全可选字段。 [tool.mypy]之外的 2 个示例 smoke 脚本(attention-queue-readmodel-smoke.py、session-runtime-readonly-projection-smoke.py)因局部变量仍保留list[dict[str, Any]]/dict[str, object]标注,直跑mypy会命中类型收敛后的入参/回传不兼容提示(7 -> 10报错,而session-runtime-readonly-projection-smoke.py#L331原下标报错反而被本 PR 修复),但两套脚本运行时均 100% 通过。
- 对照共享 SQLite 快照下的真实
- 调用面、隔离与合并兼容性:本 PR 未引入 opt-in 开关(
default_off_isolation: not_applicable),无新增权限或调度语义(authority_semantics: aligned),错误提示保持领域中立,与main、#9463、#9465、#9467、#9468、#9469均无冲突风险。 - 验证矩阵(
wait_for_ci: false,ci_policy: not_consulted):ruff check(7/7 文件):PASS。mypy --strict(契约测试正例monitor_signal通过、反例waitng_on报错拦截)与47个loopx/调用方基线对比(97->97silent,4359->4359transitive,+0/-0新增错误;唯一改动文件内错误为goal_attention_projection.py:145->146既有一致性行号顺延):PASS。- 共享 SQLite 快照
python -m loopx.entrypoint status --format json基线 vs 本 PR 对比(覆盖codex/monitor_signal/external_evidence/controller全部桶计数与条目):PASS(完全一致),attention-queue-readmodel、session-runtime-readonly-projection、status-collection-readmodel3 项 smoke 均 PASS。 pytest:tests/architecture/+tests/canary/+test_attention_queue_contract.pyPASS(2071 passed, 6 skipped,6 项均为test_git_path_display.py在 APFS 上的预期跳过);21 项状态/注意力/CLI 套件 PASS(756 passed, 0 failed)。- TypeScript:
typecheck:control-plane与content_digest_single_owner(17/17)+goal_attention/steward_managed_mode(29/29):PASS。 canary premerge(standard档位:4/4direct checks、1/1py_compile、10/10catalog canaries、8/8risk profile smokes,manual_hold_count=0)与合规检查(errors=0):PASS。- 远端 GitHub Actions CI:
UNVERIFIED(按wait_for_ci=false策略未查询/等待远端 CI)。
我的整体评价 / Verdict
- 长程与用户体验影响(
outcome_impact):long_horizon: preserved,user_experience: preserved;视觉审阅visual_review: not_applicable(原因:纯 Python 控制面类型定义与运行时校验收紧,不涉及 UI 渲染),unverified_scope: none。 - 精简度与词表对齐:
code_volume: necessary且compatibility_assessment: retain,change_proportionality: proportionate(architecture_assessment: retain),semantic_alignment: aligned / reuse_existing,observable_semantics在有效负载上等价并在无效waiting_on上实现预期的静态与运行时 fail-closed 拦截。已基于精确提交be69f1d8fd978c6a405f2f3a9ce43347f18c14e8完成复核,PR #9452[P2]问题已完整闭环,无阻塞缺陷,建议通过。
English Verdict: APPROVE
Signed-off-by: huangruiteng <huangrt01@163.com>
Signed-off-by: huangruiteng <huangrt01@163.com>
huangruiteng
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-5 · OpenAI · self_reported
动机 / Motivation
受影响的是 Status CLI、attention projection wrappers、测试和消费 attention queue 的只读展示逻辑。
修复前,monitor_signal 是真实输出但不在 AttentionWaitingOn 中;修复后,同一值由 monitor display owner 提供,五种 waiting_on 通过 typed item 进入三个真实 caller,未知值在构造边界 fail closed。
合法的 codex、controller、external evidence 与 monitor_signal 分桶保持一致;未知 waiting_on 被 ValueError 拒绝;新增可选 projection 字段可在严格类型检查中使用。
本 PR 不改变 scheduler、quota、Goal activation 或 UI 渲染,也不把任意观测字段自动升级为注意力项。
改动思路 / Approach
类型合同由既有 owner 组合,运行时计数不变,新验证只对不支持的值 fail closed。
本 PR 对齐 attention queue 类型和当前 callers,不迁移未类型化的示例,也不改变调度。
入口是 status collection entering loopx.status.build_attention_queue。权威输入为 Status goal/run facts and the shared RegistryWaitingOnOverride and MonitorSignalWaitingOn literals。决定边界:attention queue builder owns routing and bucket counts; status modules own vocabulary values。结果:Pure read-only construction of AttentionQueueProjection。消费方:Status CLI JSON and attention projection wrappers。失败与重试:Unknown waiting_on raises ValueError before an invalid projection reaches callers; no retry or mutation。
具体改动 / Changes
按 docs/status-data-contract.md 的 revision 02afe89f6f59b52d0c0b7e151037c7956807fe5b 核对,attention-queue-counters / attention-queue-item / attention-queue-monitor 分别对应下面的行为与验证。
关键代码讲解
AttentionWaitingOn:Composes registry override and monitor signal literals into the complete attention vocabulary;monitor_signal moves from missing to accepted without restating producer values。AttentionQueueItem:Defines required waiting_on and optional public read-model fields, including the three runtime projection fields completed in this repair;Consumers can type optional goal_channel_projection, handoff_mode and long_task_cadence_hint directly。build_attention_queue_projection:Counts the five buckets and returns the shared AttentionQueueProjection;The runtime counter logic is preserved while the public return type becomes exact。_validated_queue_items:Fails closed on unknown waiting_on at the construction boundary;Previously loose dict items are validated and cast to AttentionQueueItem。OperatorQuestionNormalizer:Declares that operator question normalization may legitimately return None;The type now matches the existing operator_gate implementation and removes the sole strict-mypy mismatch。
变更共 8,259 additions、53 deletions。Production changes consolidate waiting_on vocabulary, type the item and projection, validate the construction boundary, and add three runtime projection fields; tests cover strict typing and bucket parity.
attention-queue-counters:item_count 以及 user/controller、controller、codex、external evidence、monitor 五个桶必须按状态原义计数;当前为 implemented。attention-queue-item:每个 item 必须有结构化 waiting_on,并保留 status、recommended_action、project_asset、handoff 与 Goal 过滤等只读字段;当前为 implemented。attention-queue-monitor:monitor-only 项保持可见并计入 watching_monitor,但不表示立即 Codex 工作;当前为 implemented。
对主干的风险 / Risks
最强回归场景:A type tightening changes bucket semantics or rejects an existing runtime item。触发状态:monitor_signal or an optional runtime projection field is present。修复边界:The builder still uses the existing runtime counts; validation accepts both producer-owned literals and preserves optional fields。影响范围:Status attention queue consumers。可观察性:Bucket mismatches fail focused assertions; unknown values fail at construction。恢复路径:Revert the type/validation commit; no persisted state or schema migration exists。
changed_invariant_positive=passed (30 passed in 15.14s at f0735e9.);material_negative_or_failure=passed (Runtime raises ValueError and mypy reports the unknown key.);strict_type_contract=passed (Success: no issues found in 7 source files.);repository_required_checks=passed (TypeScript typecheck passed; premerge passed 18/18 with 8 changed files and zero manual holds.);smoke_parity=passed (Both smokes report ok.)。
- PASSED · Typed queue, optional runtime fields and five-way bucket counting:30 passed in 15.14s at f0735e9.
- PASSED · Unknown waiting_on and misspelled typed keys fail closed:Runtime raises ValueError and mypy reports the unknown key.
- PASSED · Changed production files are strict-mypy clean:Success: no issues found in 7 source files.
- PASSED · Risk-based premerge and TypeScript typecheck:TypeScript typecheck passed; premerge passed 18/18 with 8 changed files and zero manual holds.
- PASSED · Attention queue and session runtime read-only smokes:Both smokes report ok.
我的整体评价 / Verdict
长程效果判断为 preserved:The same state produces the same queue buckets, with a typed contract that prevents future consumer drift。用户体验判断为 preserved:This is an internal read-model type correction; no rendered journey or action semantics changed。视觉检查不适用,因为本次没有改变渲染界面或布局。
The refreshed head preserves status routing while making the shared queue projection reflect the real producer vocabulary and runtime fields。
English verdict: APPROVE at f0735e9. The attention queue now composes producer-owned waiting values, preserves the five runtime buckets, types the observed optional fields, and rejects unsupported values before projection.
Summary
Follow-up to PR #9452, aligning the attention queue contract with the actual Status vocabulary and wiring the typed projection through real callers.
AttentionWaitingOnnow composesRegistryWaitingOnOverrideandMonitorSignalWaitingOn, coveringuser_or_controller,controller,codex,external_evidenceandmonitor_signal.AttentionQueueItemandAttentionQueueProjectiondescribe the actual public-safe read model. The three already-emitted optional fieldsgoal_channel_projection,handoff_modeandlong_task_cadence_hintare now typed.build_attention_queuerejects unsupportedwaiting_onvalues before projection.Verification
Tested revision:
f0735e9045b619675f961df4c99e14edc6b0ba13Current main integrated:
02afe89f6f59b52d0c0b7e151037c7956807fe5b30 passed.18/18passed with zero manual holds.