Skip to content

refactor(lark): slim kanban into cohesive Zero-Any modules - #9443

Merged
huangruiteng merged 3 commits into
mainfrom
codex/slim-lark-kanban-zero-any-20261126
Nov 26, 2026
Merged

huangruiteng merged 3 commits into
mainfrom
codex/slim-lark-kanban-zero-any-20261126

Conversation

@loopx-agent

@loopx-agent loopx-agent commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Modularizes loopx/extensions/lark/presentation/kanban.py (1,392 LOC, 62 AST Any, 1 # type: ignore) into focused Zero-Any submodules under loopx/extensions/lark/presentation/ (< 700 LOC each, 0 AST Any, 0 # type: ignore) while preserving canonical sink_visibility ownership, identity re-exports, runtime semantics, baseline Markdown headers, consistent Mapping runtime normalization, and cross-module caller mypy parity.

Module Breakdown & Metrics

File LOC AST Any # type: ignore Role
loopx/extensions/lark/presentation/kanban.py 450 0 0 Compatibility facade, seeding (seed_lark_kanban_*), and heartbeat orchestration (Mapping fixture normalization)
loopx/extensions/lark/presentation/kanban_config.py 605 0 0 LarkKanbanConfig, fixtures, shared/credential redaction, _coerce_mapping_tree, local config I/O, command builders
loopx/extensions/lark/presentation/kanban_records.py 352 0 0 Todo/projection block mappers and remote/local todo_records cache persistence
loopx/extensions/lark/presentation/kanban_sync.py 460 0 0 LarkKanbanTodoSyncResult TypedDict, projection reconciliation (Mapping boundary normalization), and Todo sync flows
loopx/extensions/lark/presentation/record_io.py 104 0 0 Read-only @property RecordTarget protocol (removing build_record_delete_command type: ignore) and row parsers
loopx/extensions/lark/presentation/sync_receipt.py 158 0 0 Mapping[str, object] compaction and baseline-exact Markdown receipt renderers
loopx/cli_commands/lark_kanban.py 665 0 0 CLI sync-loopx-todos dict(...) conversion over LarkKanbanTodoSyncResult
tests/extensions/test_lark_kanban_contract.py 312 0 0 Contract suite covering < 700 LOC / Zero-Any, export identity, sink_visibility defaults, MappingProxyType parity, and render_lark_kanban_markdown header parity

Architectural & Boundary Guarantees

  • Canonical sink_visibility ownership preserved: SINK_VISIBILITY_OWNER_ONLY, SINK_VISIBILITY_SHARED, and SINK_VISIBILITIES are imported strictly from .sink_visibility (no local module assignments, no "owner-only" / "shared" string constants in kanban*, and identity-preserved parameter defaults on sync_loopx_projection_to_lark_kanban and sync_loopx_todos_to_lark_kanban).
  • Static & runtime Mapping consistency: Read-only MappingProxyType inputs (including nested mappings) are normalized via _coerce_mapping_tree and handled via isinstance(..., Mapping) consistently across sync_loopx_projection_to_lark_kanban, lark_kanban_heartbeat, lark_kanban_config_from_payload, seed_lark_kanban_*, record_io, and sync_receipt, while non-Mapping projections still raise ValueError("projection must be a JSON object").
  • Baseline Markdown receipt parity: render_lark_kanban_markdown keeps exact baseline summary_keys ordering (base_token, table_id, view_id, ... without prepending execute / goal_id / source_id).
  • Identity & budget invariants: Preserves compact_lark_kanban_sync_receipt, render_lark_kanban_markdown, LarkKanbanConfig (@dataclass(frozen=True)), kanban_board, and record_io identities on kanban.py; top-level loopx/*.py count remains 112 and loopx/canary/module_metric_baseline.json is 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=silent on record_io.py, sync_receipt.py, kanban_config.py, kanban_records.py, kanban_sync.py, kanban.py, test_lark_kanban_contract.py: 0 issues in 7 source files.
  • Cross-caller mypy --follow-imports=silent across 25 loopx/ callers: 0 regressions (TOTAL: 345, unchanged from base).
  • ruff check across all 8 touched/new files: All checks passed.
  • Isolated-HOME smokes: 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-plane clean; 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/8 files, 0 errors), and loopx 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).

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@huangruiteng
huangruiteng merged commit 0823c01 into main Nov 26, 2026
8 of 10 checks passed
@huangruiteng
huangruiteng deleted the codex/slim-lark-kanban-zero-any-20261126 branch November 26, 2026 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants