Skip to content

refactor(lark): type explore_results with zero Any - #9582

Open
Duang777 wants to merge 1 commit into
loopx-project:mainfrom
Duang777:codex/lark-explore-results-zero-any-20261129
Open

Duang777 wants to merge 1 commit into
loopx-project:mainfrom
Duang777:codex/lark-explore-results-zero-any-20261129

Conversation

@Duang777

Copy link
Copy Markdown
Collaborator

Goal And Delivered Outcome

Author Declaration

  • Written by: model_agent (Claude Opus, Anthropic), operated by @Duang777

Implemented against

  • Specification and revision: no written specification; behavior of explore_results.py at 811c1a1f6 is the basis.
  • Criteria:
Criterion (spec clause) Disposition Symbol / path Test or command
Zero AST Any, no cast(Any) escapes implemented explore_results.py module_metrics() → 0
Public and test-patched names stay on this module implemented run_command, default_subprocess_runner, all exports tests/test_explore_presentation_views.py
Baseline ceiling lowered, line ceilings untouched implemented module_metric_baseline.json tests/canary/test_maintainability_ratchet.py
  • Self-check before submission: no module split (nothing moved, so monkeypatch targets keep resolving here). Repeated x if isinstance(x, dict) else {} narrowing is folded into _as_dict / _as_mapping / _as_list.
  • Known narrowing, disclosed: _as_list accepts only list/tuple for projection nodes/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. Likewise x or {} → _as_dict(x) only differs for a non-dict truthy Mapping, which no caller passes.

Scope And Continuation

  • Completed scope and remaining work: explore_results.py only. lark/cli_transport.py still returns dict[str, Any]; left for a separate pass.
  • Slice boundary / successor: complete within this scope. Touches the same baseline file as chore(canary): ratchet Any ceilings to retired module debt #9581 (adjacent entries); whichever merges second needs a trivial rebase.

Validation

  • Tested revision: 51a9b2241
  • Run state: finished
  • Input classes: synthetic
Check kind Result Public-safe evidence / limitation
static passed mypy --strict --follow-imports=silent on the file: 28 errors at base → 0.
unit passed Explore presentation, chat explore results, audit CLI, extensions, explore/issue-fix capability, CLI entrypoint, ratchet suites: 2570 passed, 1 skipped.
real_entrypoint passed loopx explore schema --format json with the bundled Lark extension under a throwaway runtime root: identical output at base and head. No network or Lark account.
regression_parity passed Base vs head outputs identical for lark_explore_schema_payload, build_explore_card_markdown, dry-run setup_lark_explore_board, lark_explore_config_from_payload on synthetic inputs.
static passed loopx canary premerge --from-git-diff --git-diff-base origin/main: 8/8, 0 failures.

Frontend / Visual Evidence

  • UI impact: none

Type of Change

  • Refactoring (no functional changes)

LoopX Area

  • Capability or extension (providers, adapters, skills)

Shared-authority RFC fixture impact

N/A

Boundary Checklist

  • Neither the diff nor this PR body/comments/attachments disclose private state, credentials, raw traces or verifier output, internal links, or local machine paths.
  • I did not duplicate maintainer-owned benchmark work unless a maintainer split out a public issue for it.
  • I kept the change scoped to the linked issue/task.
  • No paired RFC changed.
  • I completed the visual evidence section for UI changes, or marked UI impact none.
  • Every commit includes a DCO Signed-off-by trailer (git commit -s).

🤖 Generated with Claude Code

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

Copy link
Copy Markdown
Collaborator

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

动机 / 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 项标准预合并。 验收契约

关键代码讲解

对主干的风险 / 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.

This branch has not been deployed

No deployments
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