Repository navigation
refactor(goals): modularize goal_channel_projection with zero Any TypedDict contracts - #9458
Conversation
…edDict contracts 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
给 Goal Channel 的 compact projection 补齐类型并复用字段读取,使现有第一屏继续显示准确信息和权威来源。
作者声明类型拆分不改现有 Goal Channel。验证实际 File 和 SQLite CLI ownership、不可用态、脱敏与静态渲染。
CLI 状态、注意力队列和现有 HTML 渲染从同一 Goal Channel 读回用户待办、锁和来源告警。
固定同一组 Goal 资产、用户 gate 和会话提示,用普通与只读 Mapping、缺失或错误字段、旧 claim、私有素材与超量待办比较完整 JSON 和 HTML。
同一已知状态得到相同渲染,缺失权威仍警告,陈旧展示 claim 不会变成持有锁,私有值不进入输出。
范围是现有投影与消费者的布局内容等价。当前提案没有新增 UI、权限控制、控制流或远端发送。
按主干合同 docs/product/roadmaps/frontstage-channel-lease-roadmap.md 核对。
- readonly_display。Goal Channel 只读且不能成为状态或执行授权。 由
build_goal_channel_projection处理。 - canonical_ownership。已知空、不可用和 stale claim 仍区分,不能伪造有效租约。 由
observe_goal_coordination处理。 - redaction_and_bounded_output。仅保留 compact 公共字段,私有信息仅生成告警。 由
_source_warnings处理。
改动思路 / Approach
Goal Channel 仍读取现有状态、运行历史和 canonical ownership observation,投影与 HTML 保持只读。
复用原 redaction、lease 观测和 decision frame。只在 compact 投影 owner 复用字段筛选,原消费者无需更改。
具体改动 / Changes
审查头 29fb738acd16a316a4e855bd3ea12cc84daa7f2e,主干 50aa5b4fd1c88b7225fc30e58423120e3ad5d426。3 个文件 +626/-235。
- build_goal_channel_projection。组装现有 JSON read model 且不授予写权。
- _copy_compact_text_fields。复用已有文本限制与私有字段过滤。
- _compact_coordination_entry。保留 lease epoch/version、冲突和现有短字段。
- _open_gates。使用原 user action 布尔边界和待办门。
- _source_warnings。对省略的原始和私有材料生成 compact 警告。
对主干的风险 / Risks
15 组完整 JSON 和 HTML 输出两版逐字节相同,含普通/只读 Mapping、显示名称、已有 gate 和长列表。
真值与严格 bool 的既有 gate 边界不变。缺少权威源时不复活旧 claim,原私有路径、链接或原始值不会出现在两版输出。
无新启用点或授权字段。无运行根和已知空原生所有权均保留既有只读表现。
定向测试 64 项通过。主干的权威与 lease 对照 21 项通过。两臂各含 File 和 SQLite 的真实 CLI 读取。3 文件的 Ruff 与 strict mypy 通过。本地 premerge 的 6 项直接检查与 10 项 smoke 通过。
真实本地 CLI 和静态渲染已验证。没有运行远端 CI 或活动 Lark 账号。
我的整体评价 / Verdict
本轮在真实状态入口与只读 HTML 比较了来源、渲染、失败告警及脱敏。类型化复用保持原先使用者观察到的行为,未增加状态来源或配置。
本地工程门与独立输入反例均已读回。
English verdict: APPROVE at 29fb738. Fifteen paired JSON and HTML projections are byte-identical. Canonical File and SQLite ownership, unavailable-state warnings, existing gate semantics, and redaction passed the local review.
huangruiteng
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-5 · OpenAI · self_reported
动机 / Motivation
复核字段:affected_caller_or_operator=Existing LoopX callers and operators of the changed integration surface. before_after_scenario=The old monolith or broad type surface is replaced by focused modules with explicit validation while public behavior stays stable. observable_outcome=Existing behavior remains reachable through the same entrypoint with stricter typing and focused regression coverage. non_goals=No unrelated product workflow, permission model or external provider protocol is changed.
规范依据:docs/development/testing-and-quality.md(精确头分叉基线 50aa5b4fd1c88b7225fc30e58423120e3ad5d426)。
refactor(goals): modularize goal_channel_projection with zero Any TypedDict contracts。本次审核聚焦于把现有职责拆成更窄的类型化边界,同时保持原有调用方、持久状态、失败路径和恢复身份。该改动面向现有 LoopX 调用方和维护者,目标是在不改变公开行为的前提下降低维护成本与类型歧义。
改动思路 / Approach
复核字段:criterion=goal-channel-projection-parity architecture_reason=职责沿现有调用、provider 和持久化边界拆分,公共入口保持。 current_pr_boundary=仅 loopx/control_plane/goals/goal_channel_projection.py, loopx/control_plane/goals/goal_channel_projection_contracts.py, tests/control_plane/test_goal_channel_projection_contract.py。
沿用现有生产入口和权威状态所有者,只把可独立验证的逻辑拆入内聚模块;公共门面继续承担调用兼容和结果收口。
具体改动 / Changes
精确 head 29fb738acd16a316a4e855bd3ea12cc84daa7f2e 相对分叉基线 50aa5b4fd1c88b7225fc30e58423120e3ad5d426 包含 3 个路径,新增 626 行、删除 235 行。
loopx/control_plane/goals/goal_channel_projection.pyloopx/control_plane/goals/goal_channel_projection_contracts.pytests/control_plane/test_goal_channel_projection_contract.py
关键代码讲解
改动沿原有调用路径保留输入验证、状态转换、失败关闭和结果读回;新增契约测试覆盖正常路径、拒绝路径、不可变输入和公开导出兼容性。生产模块继续复用既有类型与持久状态所有者,测试用成对基线和当前实现比较可观察结果,避免仅凭函数被移动就推断语义等价。
对主干的风险 / Risks
主要风险是移动代码后改变求值顺序、状态所有权或重复副作用。本次按要求逐项核对生产入口、调用方参数、持久状态读取和失败关闭分支,并用新增契约测试覆盖拒绝与恢复路径;公开入口和既有状态所有者保持可追踪。本次复核以定向测试、静态检查和仓库 premerge 对照限定影响面;未等待远程 CI,也未覆盖安装态及外部服务路径。
我的整体评价 / Verdict
当前精确 head 的改动边界清晰,现有入口和状态所有者保持完整。定向测试和仓库门禁未发现阻塞问题。
本轮独立复核:174 passed in 17.89s; Ruff passed; strict mypy passed;premerge passed; 10/10 selected checks, 0 failures, 0 manual holds。
English verdict: APPROVE at 29fb738. The exact-head refactor preserves the existing entrypoint and authority boundaries with focused regression coverage.
Summary
Modularized and typed
loopx/control_plane/goals/goal_channel_projection.py(458 -> 419LOC,58 -> 0ASTAny,0 # type: ignore) with zero caller edits (0unrelated files modified) and fullorigin/main(50aa5b4fd1) behavioral parity:loopx/control_plane/goals/goal_channel_projection_contracts.py(150LOC,0ASTAny,0 # type: ignore):TypedDict/Literalcontracts (GoalChannelSourceRefs,GoalChannelDecisionFrame,GoalChannelTruthContract,GoalChannelSourceWarning,_TodoRole,_GoalChannelMode,_GoalChannelWriteAuthority)._PRIVATE_DOC_HOSTand_PRIVATE_TEXT_MARKERSat module scope instead of rebuilding tuple/domain strings per_private_valuecall, and extracts shared_copy_compact_text_fields,_mapping_or_empty, and_interaction_channelhelpers.loopx/control_plane/goals/goal_channel_projection.py(419LOC<= 550LOC,0ASTAny,0 # type: ignore):dict(...)copies on read-only inputs via_mapping_or_empty, deduplicates repeated compact field loops across_compact_quota/_compact_todo/_compact_coordination_entry/_compact_artifacts/_recent_events, evaluates_textonce per gate block via:=, reuses computeduser_channelanduser_gate_todosinside_open_gates, and preserves all exported symbols via explicitasre-exports.tests/control_plane/test_goal_channel_projection_contract.py(280LOC,0ASTAny,0 # type: ignore):0-Any/0-ignore/ size bounds, full export parity, redaction and truncation boundaries, key-presence vsbool-as-int(lease_epoch=Trueignored whileintkept,action_required is Truevs truthy), malformed inputs failing closed cleanly, and pairedorigin/main(50aa5b4fd1) vsHEADbehavioral parity.Verification
ruff check(3/3): passed.mypy --strict --follow-imports=silent(3/3):0errors.mypy(17/17):0errors; cross-callermypy --no-incremental --follow-imports=silentacross all6targets (loopx/cli_commands/status.py,goal_channel_projection.py,collection.py,attention_queue.py,goal_channel_notification.py,goal_channel_html.py):+0error delta across all callers andgoal_channel_projection.py20 -> 0 (-20).npm run typecheck:control-plane&node --experimental-strip-types --test tests/control_plane_ts/content_digest_single_owner.test.ts: passed (17/17).scripts/check_rfc_bilingual.py --base origin/main --head HEAD: passed.4/4):goal-channel-projection,goal-channel-status-export,goal-channel-frontstage-fixture, andgoal-channel-readmodelsmokes passed.pytest -q -n 4 -rsin clean detached worktree acrosstest_goal_channel_projection_contract.py,test_canonical_goal_channel_coordination.py,test_goal_channel_hard_lease_visibility.py,test_goal_channel_display_name.py,test_goal_channel_runtime_cli.py,test_botmux_goal_channel_runtime.py,test_status_agent_lane_projection.py,test_status_collection_material_capability_wiring.py,test_lark_shared_sink_redaction.py,test_lark_goal_channel.py,test_lark_goal_channel_notification.py,tests/canary/, andtests/architecture/:2,298 passed, 6 skipped(6 standard macOS APFS skips intests/canary/test_git_path_display.py).loopx check --scan-path(3/3):errors=0, warnings=0.cqr_b2cc847e7620fc693c35(decision="pass",status="valid").canary premerge:ok=true(direct=4/4,py_compile=1/1,catalog_run=2/2,risk_profile_run=8/8,manual_holds=0,failures=0).