Repository navigation
refactor(lark): slim kanban into cohesive Zero-Any modules - #9443
Conversation
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
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
动机 / Motivation
维护 Lark Kanban 的调用方通过 CLI 预览、同步 Todo 和投影,也可从公开门面直接调用同步函数。一个有效投影字典与其只读 MappingProxyType 使用完全相同的条目,调用门面导出的 sync_loopx_projection_to_lark_kanban,execute 保持默认关闭。两版相同 JSON 投影在 owner-only 和 shared 均可预览。扩展未安装时同样拒绝,缺少完整来源的 reconcile 同样拒绝。来源清理 smoke 在两版均通过。
公开投影同步的输入类型与运行校验。同一 Python 调用在基线的 strict mypy 被拒绝。在本提交的 strict mypy 通过,但运行仍抛出 ValueError: projection must be a JSON object。将同一只读投影转换为 dict 后,两版均能生成预览。 本机精确源码、真实 CLI dry-run、临时扩展运行时和模拟记录传输覆盖本地行为。未验证在线 Lark Base 写入、远端分页服务和生产安装。 验收依据
改动思路 / Approach
投影行读取由 projection_rows 持有,kanban_sync 编排验证、upsert 和清理,kanban_records 持久化远端行映射。现有扩展激活和 sink_visibility 继续决定可用性与投影边界。lark-kanban sync-projection、sync-loopx-todos 和 kanban 门面。如果当前 PR 只拆分模块,就在公开入口保留 dict 输入类型。如果有明确调用方需要通用 Mapping,就在入口接收并归一化到既有 dict owner,然后用同一只读 Mapping 验证静态和运行行为一致。
具体改动 / Changes
精确 head e587dd832a12571bfebdc0de5e94a417ff8f0e8b,目标分支快照与实际分叉基线均为 50aa5b4fd1c88b7225fc30e58423120e3ad5d426。8 个文件增加 1,829 行、删除 1,189 行。旧的 Kanban 模块拆为配置、记录和同步三部分,并调整 CLI、行适配器、回执渲染及测试。
关键代码讲解
sync_loopx_projection_to_lark_kanban。输入注解拓宽,仍由 dict guard 判定。实现复用既有投影与来源回收。 源码sync_loopx_todos_to_lark_kanban。同一个公开入口从 Goal 读取 Todo 和派生 outcome,再授权同步和保存映射。 源码read_lark_kanban_local_config。负责解析和保留本机看板配置,映射键统一为字符串。 源码_load_lark_todo_record_map。从已配置的看板读取远端记录,标出分页是否完整并保留来源范围。 源码lark_kanban_heartbeat。保留 worker 前缀约束和显式运行开关,向现有 transport 提交读写调用。 源码todo_record_list_is_authoritative。只有完备字段和标识列表可作为远端对账证据。 源码render_lark_kanban_markdown。默认文本回执新增 execute、goal_id、source_id 三行。相同输入的 JSON 字段不变。 源码handle_lark_kanban_command。将 TypedDict 复制成普通字典后追加已有下游投影及 compact receipt。 源码test_kanban_split_modules_stay_under_budget_with_zero_any。覆盖结构预算与导出身份,但没有对照声明可接受的新类型和实际入口。 源码
对主干的风险 / Risks
[P2] 公开函数的 Mapping 参数仍在运行时被拒绝
同一 Python 调用在基线的 strict mypy 被拒绝。在本提交的 strict mypy 通过,但运行仍抛出 ValueError: projection must be a JSON object。将同一只读投影转换为 dict 后,两版均能生成预览。
按新签名传入只读 Mapping 的调用方会在生成任何同步预览前失败。新注解扩大接受面,实际验证条件仍停留在原边界。影响公开 Python 调用,CLI 的 JSON 解析仍产生 dict。 相关源码
语义与验证
9 项定向测试及两侧 projection reconciliation smoke 通过。通过真实 CLI 配对验证扩展关闭、不同 sink 的预览、来源不完整拒绝。标准 premerge 未独立运行。Kanban control-plane smoke 在两侧都被现有双默认 runtime 根目录的路由拒绝,已读到同一错误,不能当成该 PR 引入的失败。同步到实际 Lark Base 尚未独立验证。
同一 sync-projection dry-run 的 Markdown 从 7 行变为 10 行,在 owner-only 与 shared 均新增 execute、goal_id、source_id。对应 JSON 字段原已存在。若保留这三行,请披露输出变化并在本地 CLI 覆盖其格式。 渲染代码
我的整体评价 / Verdict
REQUEST_CHANGES。 如果当前 PR 只拆分模块,就在公开入口保留 dict 输入类型。如果有明确调用方需要通用 Mapping,就在入口接收并归一化到既有 dict owner,然后用同一只读 Mapping 验证静态和运行行为一致。 同一只读投影应当静态与运行行为一致。复验正常 dict、扩展开关和既有收据格式。
English verdict: REQUEST_CHANGES at e587dd8. The public projection sync now type-checks read-only Mapping inputs that it rejects at runtime. Keep the dict contract or normalize Mapping inputs at the boundary. Also disclose the Markdown receipt delta.
…eaders 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
拆分 Lark Kanban 的配置、记录和同步代码,保留既有扩展门控、投影同步和调用者可读回执。当前头同时修复上一轮的公开 Mapping 合同及 Markdown 格式回归。分叉基线只接受 dict。上一提交扩展签名后仍拒绝只读 Mapping,CLI 回执也增加三行。通过独立 Lark 扩展预览或同步 Goal 投影,以及调用 Kanban Python 门面的维护者。
Kanban 公开入口、来源对账与回执相容。两版在扩展关闭及不完整来源对账时均退出 1,同样保留按源命名空间清理、分页不全阻断与幂等重放。两次 dry-run 均未创建配置或执行记录指令。当前 Python 入口接受顶层及行内嵌套的 MappingProxyType,普通 dict 仍通过。相同 JSON 走真实 CLI 时,owner-only 与 shared 的完整 Markdown 文本在两版相同。共享视图保留既有 ID 脱敏。
验证覆盖精确源码的本机 CLI、隔离扩展与真实源对账处理,Lark 记录端使用替身。在线 Lark Base、已安装发行版和远端 CI 留在各自验收。 基线运行时合同 本次变更范围
改动思路 / Approach
公开门面继续承接旧调用者并使用 sink_visibility。投影输入归一化交给配置侧 helper,记录边界继续调用既有 projection_rows 和分页权威检查。统一在输入边界接收 Mapping,保留下游 JSON dict 行转换和既有 reconcile owner。回执用原 Markdown 字段及顺序,避免在 caller 复制渲染规则。
lark-kanban sync-projection → sync_loopx_projection_to_lark_kanban → projection_rows → render_lark_kanban_markdown。
具体改动 / Changes
精确提交 909390a69dab41320eab41b6ec4f77ac2de439e2,目标分叉点 50aa5b4fd1c88b7225fc30e58423120e3ad5d426。8 个文件,增加 2010 行、删除 1203 行。三个 Kanban 子模块和既有行、回执适配器承接原门面的职责。
sync_loopx_projection_to_lark_kanban。接收合法 Mapping,按既有契约匹配来源与执行选择。 源码_coerce_mapping_tree。遍历 Mapping、列表和元组,保留现有字典行处理所需结构。 源码_load_lark_todo_record_map。从权威分页记录读取与本地回执关联的映射。 源码todo_record_list_is_authoritative。仅在完整行和必需字段的响应上授权来源对账。 源码render_lark_kanban_markdown。保留基线摘要字段、顺序及命令详情。 源码
对主干的风险 / Risks
本轮未发现阻塞问题。本地 85 项定向测试、两侧来源对账 smoke 及当前头标准 premerge 均通过。扩展改动文件、合同测试和 Mapping 调用点的 strict mypy 无新诊断。CLI adapter 保留与基线相同的 19 项 strict 诊断。
验证覆盖精确源码的本机 CLI、隔离扩展与真实源对账处理,Lark 记录端使用替身。在线 Lark Base、已安装发行版和远端 CI 留在各自验收。
我的整体评价 / Verdict
APPROVE。 当前头修复上轮两处问题。只读 Mapping 可用,普通 CLI preview、扩展门控和来源对账保持已验证语义。继续由完整快照和分页读回决定能否清理。
English verdict: APPROVE at 909390a. Nested read-only mappings now work through the declared API, and verified CLI receipt and source-reconciliation behavior matches the baseline.
Summary
Modularizes
loopx/extensions/lark/presentation/kanban.py(1,392LOC,62ASTAny,1 # type: ignore) into focused Zero-Anysubmodules underloopx/extensions/lark/presentation/(< 700LOC each,0ASTAny,0 # type: ignore) while preserving canonicalsink_visibilityownership, identity re-exports, runtime semantics, baseline Markdown headers, consistentMappingruntime normalization, and cross-module callermypyparity.Module Breakdown & Metrics
Any# type: ignoreloopx/extensions/lark/presentation/kanban.pyseed_lark_kanban_*), and heartbeat orchestration (Mappingfixture normalization)loopx/extensions/lark/presentation/kanban_config.pyLarkKanbanConfig, fixtures, shared/credential redaction,_coerce_mapping_tree, local config I/O, command buildersloopx/extensions/lark/presentation/kanban_records.pytodo_recordscache persistenceloopx/extensions/lark/presentation/kanban_sync.pyLarkKanbanTodoSyncResultTypedDict, projection reconciliation (Mappingboundary normalization), and Todo sync flowsloopx/extensions/lark/presentation/record_io.py@propertyRecordTargetprotocol (removingbuild_record_delete_commandtype: ignore) and row parsersloopx/extensions/lark/presentation/sync_receipt.pyMapping[str, object]compaction and baseline-exact Markdown receipt renderersloopx/cli_commands/lark_kanban.pysync-loopx-todosdict(...)conversion overLarkKanbanTodoSyncResulttests/extensions/test_lark_kanban_contract.py< 700LOC / Zero-Any, export identity,sink_visibilitydefaults,MappingProxyTypeparity, andrender_lark_kanban_markdownheader parityArchitectural & Boundary Guarantees
sink_visibilityownership preserved:SINK_VISIBILITY_OWNER_ONLY,SINK_VISIBILITY_SHARED, andSINK_VISIBILITIESare imported strictly from.sink_visibility(no local module assignments, no"owner-only"/"shared"string constants inkanban*, and identity-preserved parameter defaults onsync_loopx_projection_to_lark_kanbanandsync_loopx_todos_to_lark_kanban).Mappingconsistency: Read-onlyMappingProxyTypeinputs (including nested mappings) are normalized via_coerce_mapping_treeand handled viaisinstance(..., Mapping)consistently acrosssync_loopx_projection_to_lark_kanban,lark_kanban_heartbeat,lark_kanban_config_from_payload,seed_lark_kanban_*,record_io, andsync_receipt, while non-Mappingprojections still raiseValueError("projection must be a JSON object").render_lark_kanban_markdownkeeps exact baselinesummary_keysordering (base_token,table_id,view_id, ... without prependingexecute/goal_id/source_id).compact_lark_kanban_sync_receipt,render_lark_kanban_markdown,LarkKanbanConfig(@dataclass(frozen=True)),kanban_board, andrecord_ioidentities onkanban.py; top-levelloopx/*.pycount remains112andloopx/canary/module_metric_baseline.jsonis unmodified.Validation (
909390a69d/ PR head)pytest -n 6 -rs tests/extensions/ tests/architecture/ tests/canary/ tests/test_explore_presentation_views.py tests/control_plane/test_contract_quality.py tests/control_plane/test_final_outcome_diagnostics.py(clean detached HEAD):4,176 passed, 7 skipped(macOS APFS/Windows platform skips).pytest -q tests/control_plane/test_todo_consumer_host_retirement.py(exact HEAD with built web chat bundle):16 passed.pytest -q tests/extensions/test_lark_kanban_contract.py tests/architecture/test_lark_sink_visibility_owner.py tests/extensions/test_lark_kanban_schema_preflight.py tests/extensions/test_lark_shared_sink_redaction.py tests/control_plane/test_contract_quality.py:90 passed.mypy --strict --no-incremental --follow-imports=silentonrecord_io.py,sync_receipt.py,kanban_config.py,kanban_records.py,kanban_sync.py,kanban.py,test_lark_kanban_contract.py:0issues in7source files.mypy --follow-imports=silentacross25loopx/callers:0regressions (TOTAL: 345, unchanged from base).ruff checkacross all8touched/new files: All checks passed.HOMEsmokes:examples/lark-kanban-control-plane-smoke.py,examples/lark-projection-source-reconcile-smoke.py,examples/issue-fix-outcome-projection-smoke.py,examples/issue-fix-metrics-projection-smoke.py,examples/semantic-vocabulary-drift-smoke.py,examples/control_plane/control-plane-maintainability-ratchet-smoke.py: all passed.npm run typecheck:control-planeclean;node --test tests/control_plane_ts/content_digest_single_owner.test.ts:17 passed, 0 failed.scripts/check_rfc_bilingual.py --base origin/main --head HEAD,loopx check(8/8files,0errors), andloopx canary premerge --from-git-diff --git-diff-base origin/main: passed (gate.status="passed",merge_gate_passed=true,catalog_run=5/5,risk_profile_run=8/8,failures=0,manual_hold_count=0).