Repository navigation
Conversation
Replace every `Any` in explore_results with `object` and narrow Lark CLI
payloads through three small typed helpers (`_as_dict`, `_as_mapping`,
`_as_list`) instead of `x if isinstance(x, dict) else {}` ternaries over
untyped values. Two `cast(...)` calls keep the persisted record map and the
projection passthrough typed without changing values.
No module split: the module keeps every public and monkeypatched name
(run_command etc.) resolving through itself. Lower the module's any_count
baseline from 45 to 0 (measured).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: duang777 <duangjl007@gmail.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
动机 / Motivation
维护 Explore Lark 投影,以及从 CLI 查看卡片和同步预览的操作者。 原投影模块有 45 处 Any,单文件严格 mypy 报 28 个问题。 同一隔离日志提供 question、experiment、edge 和 finding。原生 CLI 的 schema、setup preview 和四行 sync preview 逐字节相同,卡片仅渲染时戳不同,仍显示阻塞原因和发现。 两文件 +92/-86。改动集中在 Explore 的 Lark 投影及其度量线,维持同一个 provider、local config 和 CLI。 实测使用合成数据、已显式启用的本地 Lark 扩展和真实 CLI dry run。使用已有传输夹具覆盖写入与读回,未向真实 Lark 租户写入。 源码确认 _as_list 收紧非 JSON 任意迭代对象的处理,_as_dict 对异常嵌套视图降为空字典。当前 CLI、文件和投影构造器供给 list 或 JSON object,未找到生产代码依赖任意 Python iterable 的路径。
改动思路 / Approach
复用运行时窄化的小函数,收紧工作流内部 Mapping 和 dict 的类型,将模块 Any 上限降为 0。 Explore 事件日志持有研究结果,Lark 投影负责 row 值与 card,transport 和接收端继续负责真正的写入和读回。 两文件 +92/-86。改动集中在 Explore 的 Lark 投影及其度量线,维持同一个 provider、local config 和 CLI。
具体改动 / Changes
精确提交 51a9b22418bb5d2e2800e576643886ddb3a0bbed,基线 811c1a1f66652d3fc3b9830d467e14b45b7423c1。两文件 +92/-86。改动集中在 Explore 的 Lark 投影及其度量线,维持同一个 provider、local config 和 CLI。
- EXPLORE-LARK-PARITY。同一隔离日志提供 question、experiment、edge 和 finding。原生 CLI 的 schema、setup preview 和四行 sync preview 逐字节相同,卡片仅渲染时戳不同,仍显示阻塞原因和发现。 验收契约
- LARK-SINK-BOUNDARY。无合法 board 的配置在两头同样拒绝。共享 sink 的脱敏、完整来源对照及执行失败读回由两头相同定向套件验证。 验收契约
- TYPE-CEILING。两头各 122 项定向测试通过。严格 mypy 28→0,AST Any 45→0。候选通过 Ruff、Git diff 和 13 项标准预合并。 验收契约
关键代码讲解
- 按现有 JSON 数组契约读取节点、边、发现和卡片条目。兼容 tuple。 _as_list
- 复用原 Lark records、发现项过滤与读回校对。 sync_explore_results_to_lark
- 按既有 reconciliation 和 digest 决定投影视图同步。 sync_issue_fix_explore_on_material_change
- 从同一个 Explore projection 生成卡片 Markdown 与元素。 build_explore_result_card
对主干的风险 / Risks
两头各 122 项定向测试通过。严格 mypy 28→0,AST Any 45→0。候选通过 Ruff、Git diff 和 13 项标准预合并。 源码确认 _as_list 收紧非 JSON 任意迭代对象的处理,_as_dict 对异常嵌套视图降为空字典。当前 CLI、文件和投影构造器供给 list 或 JSON object,未找到生产代码依赖任意 Python iterable 的路径。 实测使用合成数据、已显式启用的本地 Lark 扩展和真实 CLI dry run。使用已有传输夹具覆盖写入与读回,未向真实 Lark 租户写入。
无合法 board 的配置在两头同样拒绝。共享 sink 的脱敏、完整来源对照及执行失败读回由两头相同定向套件验证。
我的整体评价 / Verdict
APPROVE。 通过。收紧类型后,当前 JSON 投影、Lark 卡片和同步预览保持原语义。 允许提案通过独立评审。 实测使用合成数据、已显式启用的本地 Lark 扩展和真实 CLI dry run。使用已有传输夹具覆盖写入与读回,未向真实 Lark 租户写入。
English verdict: APPROVE at 51a9b22. The same isolated Explore log produced equivalent Lark CLI output at base and head, and malformed board configuration was rejected on both. All 122 focused tests passed on each revision. The candidate has zero measured Any and no strict mypy errors.
Goal And Delivered Outcome
loopx/extensions/lark/presentation/explore_results.pycarried 45 ASTAny(baseline ceiling 45) and failedmypy --strictwith 28 errors.module_metricsany_count 45 → 0;mypy --strict --follow-imports=silenton the file 28 errors → 0.loopx explore schema --format jsonoutput is byte-identical to base.mainat811c1a1f6.Author Declaration
Implemented against
explore_results.pyat811c1a1f6is the basis.Any, nocast(Any)escapesexplore_results.pymodule_metrics()→ 0run_command,default_subprocess_runner, all exportstests/test_explore_presentation_views.pymodule_metric_baseline.jsontests/canary/test_maintainability_ratchet.pyx if isinstance(x, dict) else {}narrowing is folded into_as_dict/_as_mapping/_as_list._as_listaccepts onlylist/tuplefor projectionnodes/edges/findings/stuck/frontier; previously any truthy iterable was iterated (and a truthy non-iterable raised). Projections are JSON-shaped lists, so no producer is affected. Likewisex or {}→_as_dict(x)only differs for a non-dict truthy Mapping, which no caller passes.Scope And Continuation
explore_results.pyonly.lark/cli_transport.pystill returnsdict[str, Any]; left for a separate pass.Validation
51a9b2241staticpassedmypy --strict --follow-imports=silenton the file: 28 errors at base → 0.unitpassedreal_entrypointpassedloopx explore schema --format jsonwith the bundled Lark extension under a throwaway runtime root: identical output at base and head. No network or Lark account.regression_paritypassedlark_explore_schema_payload,build_explore_card_markdown, dry-runsetup_lark_explore_board,lark_explore_config_from_payloadon synthetic inputs.staticpassedloopx canary premerge --from-git-diff --git-diff-base origin/main: 8/8, 0 failures.sync_explore_results_to_larkagainst a real Base) are covered only by the existing mocked tests; not run against a real tenant. RemotePython Testsis red on main for unrelated shard deadlines ([Bug]: Python test-shards on main exceed the session deadline every run — suite never completes #9567).Frontend / Visual Evidence
Type of Change
LoopX Area
Shared-authority RFC fixture impact
N/A
Boundary Checklist
none.Signed-off-bytrailer (git commit -s).🤖 Generated with Claude Code