Skip to content

refactor(chat_action_store): modularize into Zero-Any store modules under 650 LOC - #9440

Merged
huangruiteng merged 2 commits into
mainfrom
codex/slim-chat-action-store-zero-any-20261126
Nov 26, 2026
Merged

huangruiteng merged 2 commits into
mainfrom
codex/slim-chat-action-store-zero-any-20261126

Conversation

@loopx-agent

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

Copy link
Copy Markdown
Collaborator

Summary

Modularizes loopx/chat_action_store.py (previously 1,667 LOC with 68 Any references and 19 mypy errors) into four cohesive, strictly Zero-Any modules while preserving the pinned 112 top-level loopx/*.py module budget and all exported symbols, lock ordering, schema versions, error contracts, and monkeypatch compatibility:

  • loopx/chat/action_store_common.py (655 LOC, 0 Any, 0 # type: ignore): defines public-safe JSON type aliases (JsonPrimitive, JsonValue, JsonDict, ObjectDict), schema/state constants, ActionConflictError, _utc_now, _opaque_id (reusing OPAQUE_ID_PATTERN from loopx/public_safe_text.py), normalize_idempotency_key, _bounded_text, _safe_json_value, _canonical_digest, shared validation/lock/commit helpers (store_lock, current_utc_now, validate_safe_object, validate_human_confirmation), and preview/lifecycle operations (replay_or_reuse_preview, list_proposals, cancel_proposal, save_proposal_checkpoint, transition_proposal, apply_proposal).
  • loopx/chat/action_store_review_cards.py (305 LOC, 0 Any, 0 # type: ignore): review-card delivery, audience freeze, cross-audience confirmation consumption, and result-card readback (record_review_card_delivery, prepare_review_card_delivery, decide_review_card, record_review_card_result_delivery).
  • loopx/chat/action_store_operations.py (597 LOC, 0 Any, 0 # type: ignore): operation confirmation arming, delivery/snapshot binding, operator callback decisions, agent handoff planning/reservation/host-start/consumption (_apply_agent_operation_plan), and outcome/result delivery (arm_operation, record_operation_delivery, record_operation_delivery_snapshot, decide_operation, observe_operation_outcome, agent_operation_plan, reserve_agent_operation_turn, record_agent_operation_host_start, consume_agent_operation, record_operation_result_delivery).
  • loopx/chat_action_store.py (567 LOC, 0 Any, 0 # type: ignore): preserves ownership of ACTION_KINDS and _OPAQUE_ID, re-exports shared helpers and atomic_write_json / exclusive_file_lock hooks, and exposes ChatActionStore as a typed facade preserving dynamic monkeypatching on loopx.chat_action_store.*.
  • Direct caller narrowing (minimal Mapping/str runtime checks eliminating mypy regressions without changing runtime semantics): loopx/chat/session_open.py, loopx/chat_actions.py, loopx/control_plane/collaboration/operation_handoff.py, loopx/control_plane/goals/acceptance_actions.py, loopx/control_plane/goals/goal_objective_actions.py, loopx/control_plane/turn_driver/managed_operation_host.py, loopx/extensions/lark/goal_channel_operation.py.
  • tests/test_chat_action_store_contract.py: contract tests guarding Zero-Any/Zero-ignore/<650/<700 LOC budgets, monkeypatch propagation across submodules, and preview/review-card/operation/stale transitions.

Verification

  • mypy --strict --follow-imports=silent --no-incremental on all four chat_action_store / action_store modules + tests/test_chat_action_store_contract.py: 0 issues.
  • Bare mypy --no-incremental across chat_action_store.py + loopx/chat/action_store_*.py and repository strict set (pyproject.toml): 0 issues.
  • Cross-file mypy --no-incremental --follow-imports=silent across all 17 loopx/ callers of chat_action_store: 0 regressions vs baseline (goal_objective_actions.py improved 4 -> 1; all zero-baseline callers remain at 0).
  • ruff check on all 12 touched Python files: all checks passed.
  • pytest across full tests/architecture/ (including test_top_level_module_budget.py at 112 top-level loopx/*.py modules), tests/canary/test_maintainability_ratchet.py, tests/test_chat_action_store_contract.py, and caller suites: 2,341 passed, 10 skipped + 321 passed = 2,662 passed, 0 failed on a84a62f492 (plus 1,198 passed, 12 skipped across tests/control_plane/ caller suites prior to subpackage move; skips are only optional deepseek_harness, clean-installed-core env, and Linux setuid/live-host cases).
  • npm run typecheck:control-plane: passed (0 errors); content_digest_single_owner.test.ts: 17/17 passed.
  • scripts/check_rfc_bilingual.py, control-plane-maintainability-ratchet-smoke.py, semantic-vocabulary-drift-smoke.py, loopx check (0 errors on store + test files), and loopx canary premerge --from-git-diff --git-diff-base origin/main: passed (direct=5/5, catalog_canaries=9/9, risk_profile_smokes=8/8, failures=0, manual_holds=0).

…nder 650 LOC

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

拆分 Chat Action Store 的共享持久化、审核卡和 operation 生命周期,保留可恢复的旧记录与业务授权和读回。基线的 ChatActionStore 集中持有预览、确认、checkpoint 和落盘,同一已接受操作的重放沿用原提案和回执。拆分需要保留调用方及旧文件行为。Chat 预览和 Goal 修订、Acceptance、Lark 卡回调、原生 operation handoff 调用方。

旧 Chat Action 持久记录与确认及回执相容。两版均拒绝相同幂等键绑定不同动作,拒绝后文件内容保持原样。指纹漂移返回 stale,不发应用回执。相同已应用请求重放不产生第二次写回。直接用基线写出 actions.json,复制给各自的真实 store。两版同样读回原预览并保持文件,走复用、apply checkpoint、一份回执、再次加载和 failed 取消。最终可观测投影逐字节相同。

验证覆盖两版隔离本机真实 actions.json,已合成的旧盘数据和失败回放,Lark 测试替换外部传输。真实 Lark 服务、已安装发行版和远端 CI 留在对应验收。 基线运行时合同 本次变更范围

改动思路 / Approach

ChatActionStore 继续持有文件和外部调用门面,common 持有共享校验锁和提交,cards 与 operations 承接各自既有状态机。保留唯一持久层和一次加锁写入,也保留公开门面供既有调用方及测试替换。只在单模块消除 Any 会继续混合审批事实、缓存和操作调度。

ChatActionStore.create_preview / decide_review_card / decide_operation → 本机动作文件与文件锁 → store.load / Lark 读回。

具体改动 / Changes

精确提交 0115b4601292741a29144a4cacf1482e1b5938eb,目标分叉点 50aa5b4fd1c88b7225fc30e58423120e3ad5d426。12 个文件,+2130 / −1372。门面 567 行,common 664 行,review cards 305 行,operations 597 行。common 按合同测试的 700 行上限验收。

  • ChatActionStore.create_preview。把预览和 request digest 原子绑定。 源码
  • replay_or_reuse_preview。从已有幂等绑定或同输入待处理记录恢复。 源码
  • apply_proposal。校验指纹、幂等回执和过期状态,并在原锁内写入。 源码
  • decide_review_card。继续验证记录的送达、受众身份及回调绑定。 源码
  • decide_operation。推进同一确认 envelope 的原生命周期。 源码

对主干的风险 / Risks

本轮未发现阻塞问题。当前 231 项定向回归与基线 207 项共同调用方测试通过。四个 store 模块和合同测试 strict mypy 无诊断,标准 premerge 通过。 真实磁盘基线记录覆盖了普通完成、失败恢复、重复调用、冲突和指纹变化。

测试执行了隔离本机真实文件读写,外部 Lark 接口使用本地替身。

我的整体评价 / Verdict

APPROVE。 既有 schema、操作锁、回调验真及发送后读回仍由原 caller 模块和 store 验证。类型收窄避免在业务调用读取非对象字段。

English verdict: APPROVE at 0115b46. The split preserves legacy persisted action records, idempotent receipts, stale-preview rejection, and the exercised Chat and Lark action paths.

@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 · Gemini · Google · self_reported

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

本次对 PR #9440(codex/slim-chat-action-store-zero-any-20261126 -> main,精确提交 0115b4601292741a29144a4cacf1482e1b5938eb,基线 50aa5b4fd1c88b7225fc30e58423120e3ad5d426)完成了完整代码、导出/签名/调用方静态类型等价性、43 组 3,275 项 pytest 回归与架构全套核查。拆分本身对零 Any 化(4 个文件全 0 AST Any / 0 # type: ignore)、31 个方法签名/默认值兼容、monkeypatch 代理(current_utc_now/store_lock)、17 调用方零新增 mypy 错误以及 TS/canary premerge(17/17)均验证通过;但在 tests/architecture/ 全量实测中发现一项直接由本 PR 引入的 [P2] 阻塞缺陷:新增 3 个文件直接放在顶层 loopx/ 下,导致 loopx/*.py 数量由 112 涨至 115,直接击穿 tests/architecture/test_top_level_module_budget.py::test_top_level_module_count_stays_at_the_pinned_budget。暂不批准合入精确提交 0115b4601292741a29144a4cacf1482e1b5938eb(REQUEST_CHANGES)。

动机 / Motivation

维护 loopx/ 顶层模块数量约束的架构门禁(tests/architecture/test_top_level_module_budget.py),以及所有通过 loopx.chat_action_store 读写 Chat 操作提案、评审卡与 Agent 托管接力信封的控制面、Lark 与 HTTP 会话调用方需要模块化重构既消除 loopx/chat_action_store.py 原本 1,667 LOC / 68 Any 的可维护性债务,又严格遵守仓库已锁定的顶层模块包分布约束(只允许减或迁入子包,不允许顶层 .py 膨胀)。

  • **问题与修前/修后对比:**本次独立对照审计确认功能拆分与兼容性保留均准确到位,但新增模块放置位置触发了一项真实阻断回归:1) 正向保留:origin/main(50aa5b4fd1)下 loopx/chat_action_store.py 为 1,667 行(含 68 处 Any);0115b4601292741a29144a4cacf1482e1b5938eb 将其拆分为 loopx/chat_action_store.py(567 LOC)、chat_action_store_common.py(664 LOC)、chat_action_store_operations.py(597 LOC)与 chat_action_store_review_cards.py(305 LOC),4 个文件均 0 AST Any、0 # type: ignore、0 实漏、全部 31 个方法签名/默认值(含 __init__)与公开导出无缺失,current_utc_now()/store_lock() 正确透过门面支持 monkeypatch,17 个上游调用方跨文件 mypy 无回归(goal_objective_actions.py 由 4 降至 1),其余 3,255 项调用方/架构/棘轮测试及 canary premerge 17/17 全部通过;2) 阻塞回归([P2] 违反顶层模块数量预算):origin/main(50aa5b4fd1c88b7225fc30e58423120e3ad5d426)在 tests/architecture/test_top_level_module_budget.py::test_top_level_module_count_stays_at_the_pinned_budget 上通过(loopx/*.py 共 112 个,与 tests/architecture/top_level_module_budget.json 锁定的 max_top_level_modules: 112 一致);而 0115b4601292741a29144a4cacf1482e1b5938eb 将 3 个新内部子模块直接放在顶层 loopx/ 下,导致 loopx/*.py 由 112 增至 115,直接触发架构套件失败(FAILED test_top_level_module_count_stays_at_the_pinned_budget)。
  • **可观测效果:**在干净 detached worktree 实测精确提交 0115b4601292741a29144a4cacf1482e1b5938eb:pytest -v tests/architecture/ 1 failed, 1,913 passed in 198.52s——唯一失败项即 tests/architecture/test_top_level_module_budget.py::test_top_level_module_count_stays_at_the_pinned_budget(loopx/ grew from 112 to 115 top-level modules);同检查在 origin/main(50aa5b4fd1)6/6 全绿;全部 43 组调用方/契约/架构/棘轮套件(3,275 项)21 failed, 3,235 passed, 19 skipped in 355.19s,其中另外 20 项 GET /chat -> 404 失败经基线同测(test_reviewed_terminal_actions.py 在 50aa5b4fd1 同样 4 failed, 26 passed)与引入只读 loopx/web 后复测(5 套 HTTP/操作套件 210 passed in 53.68s)确认为裸 detached worktree 缺少未跟踪前端静态产物所致,非本 PR 回归;test_chat_action_store_contract.py 3/3(1.33s)、test_maintainability_ratchet.py + test_chat_action_kind_owner.py + test_compact_identifier_shape_owner.py 58/58(8.79s)、ruff 12/12、严格 mypy 5/5、裸 mypy 17/17、17 调用方跨文件 mypy(0 新增错)、TS typecheck + content_digest_single_owner 17/17、loopx check 0 错与 canary premerge 17/17 均通过。
  • **非目标与边界:**不放宽 top_level_module_budget.json 的 112 上限或修改 module_metric_baseline.json,不破坏现有 loopx.chat_action_store 公开导入、ACTION_KINDS 唯一所有权或 monkeypatch 接缝;请求将 3 个新内部模块下沉至子包后重审。
  • **规范对齐:**对应 docs/architecture/rfcs/monorepo-distribution-split-v0.md(基线 50aa5b4fd1c88b7225fc30e58423120e3ad5d426)下的顶层模块预算条款 M0、Chat 模块子包迁移规范 M1 与旧路径兼容约束 I3。

改动思路 / Approach

  1. 阻塞项根因定位(loopx/chat_action_store.py:11-13 vs tests/architecture/test_top_level_module_budget.py:59-71):
    • loopx/chat_action_store.py 保留了 ChatActionStore(567 LOC、0 Any)、ACTION_KINDS 唯一所有权(test_chat_action_kind_owner.py 通过)与全部 24 项 __all__ 导出,并通过 chat_action_store_common.current_utc_now() / store_lock() 正确透传门面 monkeypatch。
    • 然而 chat_action_store_common.py(664 LOC)、chat_action_store_operations.py(597 LOC)和 chat_action_store_review_cards.py(305 LOC)直接建在 loopx/ 根目录,使 _top_level_modules() 从 112 涨到 115。作者本地只跑了单个 test_chat_action_kind_owner.py(且 canary premerge 未包含 test_top_level_module_budget.py),漏检了该架构门禁。
  2. 最小修复方向(同时清理 1 处未调用函数):
    • 迁入子包(零公共破坏、不动预算 JSON): 依据 docs/architecture/rfcs/monorepo-distribution-split-v0.md 将 loopx/chat_action_store_common.py、loopx/chat_action_store_operations.py、loopx/chat_action_store_review_cards.py 移至 loopx/chat/(例如 loopx/chat/action_store_common.py、loopx/chat/action_store_operations.py、loopx/chat/action_store_review_cards.py,或专用子包 loopx/chat_action_store_runtime/),保留顶层 loopx/chat_action_store.py 作为 I3 兼容门面,loopx/*.py 即回归 112;子包内通过 from .. import chat_action_store as facade 维持同等 monkeypatch 传播语义,并同步更新 tests/test_chat_action_store_contract.py:30-48 的文件清单。
    • 顺带清理(非阻塞): loopx/chat_action_store_common.py:267-273 的 write_store_json() 在全仓 loopx/ 与 tests/ 均无调用者(ChatActionStore._write 直接调 atomic_write_json),可在移动时移除或统一让 _write 复用。
  3. **架构归属与当前 PR 边界:**按已接受规范 docs/architecture/rfcs/monorepo-distribution-split-v0.md(M0 / I3),顶层 loopx/*.py 文件总数只能持平或递减,且规范明确规定 loopx/chat_* 应迁移至 loopx/chat/ 并在旧路径保留兼容性重导出。本 PR 虽然保住了 loopx.chat_action_store 门面(567 LOC、0 Any)和全部 31 个方法契约,但把 3 个内部辅助模块留在顶层 loopx/ 违背了子包归置边界。需将 chat_action_store_{common,operations,review_cards}.py 迁入 loopx/chat/(如 loopx/chat/action_store_{common,operations,review_cards}.py)或专用子包并保持 loopx/chat_action_store.py 为顶层兼容门面后推送新 HEAD。

具体改动 / Changes

全部 12 个文件(+2,130/-1,372,1/1 DCO 提交,git merge-tree 无冲突;module_metric_baseline.json 未修改);依据 docs/architecture/rfcs/monorepo-distribution-split-v0.md(基线 50aa5b4fd1c88b7225fc30e58423120e3ad5d426)逐项核对:M0 为 not_met(顶层 .py 从 112 增至 115),I3 为 implemented(loopx.chat_action_store 公共导入、导出与方法签名等价保留):

  1. 核心模块拆分(0 AST Any、0 # type: ignore): loopx/chat_action_store.py(567 LOC)、loopx/chat_action_store_common.py(664 LOC)、loopx/chat_action_store_operations.py(597 LOC)、loopx/chat_action_store_review_cards.py(305 LOC)。
  2. 7 个调用方与 1 份契约测试: 仅做 Mapping / isinstance 类型收窄,17 个调用方零新增 mypy 错误(goal_objective_actions.py 降为 1)。

关键代码讲解

  • loopx/chat_action_store.py 门面与导入:保留 ACTION_KINDS 与 24 项 __all__ 导出及 ChatActionStore 全部 31 个方法签名,但 L11-13 引入的三个同级顶层文件推高了 loopx/*.py 数量触发预算门禁。
  • current_utc_now & store_lock:通过延迟读取 loopx.chat_action_store 门面属性使旧 monkeypatch 测试继续生效(迁移至 loopx/chat/ 后改为 from .. import chat_action_store as facade 即可完整保留)。
  • operation_handoff.py 等 7 处调用方收窄:用 isinstance(..., Mapping) 显式收窄存储载荷并保持 0 回归与 0 运行时变化。

对主干的风险 / Risks

  • 阻断合并的 1 项已复现 [P2] 缺陷(精确提交 0115b4601292741a29144a4cacf1482e1b5938eb):
    1. [P2] 拆分文件落盘于顶层 loopx/ 突破 top_level_module_budget(loopx/chat_action_store.py:11-13,tests/architecture/test_top_level_module_budget.py:59-71):
      • 触发证据: origin/main(50aa5b4fd1c88b7225fc30e58423120e3ad5d426)运行 test_top_level_module_budget.py 6/6 通过(max_top_level_modules=112);0115b4601292741a29144a4cacf1482e1b5938eb 将 chat_action_store_common.py、chat_action_store_operations.py、chat_action_store_review_cards.py 建在顶层 loopx/,导致 pytest tests/architecture/ 在 test_top_level_module_count_stays_at_the_pinned_budget 失败(112 -> 115,1 failed, 1,913 passed in 198.52s)。
      • 最小修复与复验命令: 将该 3 个内部模块移入 loopx/chat/(或独立子包)并更新 tests/test_chat_action_store_contract.py 路径,保留顶层 loopx/chat_action_store.py 门面,确保 uv run --extra test python -m pytest -q tests/architecture/ tests/test_chat_action_store_contract.py 全数通过且 0 失败。
  • 非 PR 回归的环境失败归因与其余通过验证(精确提交 0115b4601292741a29144a4cacf1482e1b5938eb):
    • 初次在裸 detached worktree 运行 43 组 chat_action_store 套件(3,275 项)出现 21 failed, 3,235 passed, 19 skipped in 355.19s;除上述 test_top_level_module_count_stays_at_the_pinned_budget(1 项)外,其余 20 项(test_chat_completion_execution_proof.py 4、test_reviewed_terminal_actions.py 4、test_native_user_completion_update.py 12,均为 GET /chat -> 404)经在 origin/main(50aa5b4fd1)同测复现相同失败(4 failed, 26 passed),且挂入只读内置前端资源 loopx/web 后 5 组 HTTP/操作套件在 0115b4601292741a29144a4cacf1482e1b5938eb 实测 210 passed in 53.68s,证明该 20 项确属无构建产物的独立工作树环境差异,非 PR #9440 引入。
    • test_chat_action_store_contract.py 3 passed、ruff 12/12、严格 mypy 5/5、裸 mypy 17/17、17 调用方 mypy 0 回归、TS typecheck + content_digest_single_owner 17/17、Goal loopx check 0 错、Goal canary premerge 17/17(direct=6/6, failures=0) 均通过;0 真实泄漏(diff 命中项均为搬迁后的 _LOCAL_PATH 正则与 O_NOFOLLOW 禁止断言)。

语义与 CI 对齐

控制面语义词表(test_chat_action_kind_owner.py 与 semantic-vocabulary-drift-smoke)未受破坏,但顶层包布局违反 docs/architecture/rfcs/monorepo-distribution-split-v0.md M0 预算门禁;遵循 wait_for_ci: false 未查询远端 CI,保持 PR OPEN。

我的整体评价 / Verdict

  • 长程与体验评估: long_horizon=not_yet_proven(功能兼容性、零 Any 与调用方测试扎实,但因顶层模块数超限 112 -> 115 导致仓库架构全套红灯,合入将阻断所有后续 PR 的架构测试),user_experience=preserved(外部调用、31 个方法签名、monkeypatch 钩子与 HTTP/操作行为完全等价);visual_review=not_applicable(原因:仅涉及 chat_action_store 内部模块拆分与调用方类型收窄,无前端界面修改;unverified_scope:上述 [P2] 顶层模块数超预算(112 -> 115)阻塞项待迁入子包后重测;遵循 wait_for_ci=false 未查询远端 GitHub Actions CI)。
  • 结论: 请将 chat_action_store_common.py、chat_action_store_operations.py 与 chat_action_store_review_cards.py 移入 loopx/chat/(或专用子包),保持顶层 loopx/chat_action_store.py 兼容门面使 loopx/*.py == 112(并顺便移除无调用者的 write_store_json),复跑 tests/architecture/ 与契约/调用方测试后推送新 HEAD 复审。

English verdict: REQUEST_CHANGES at 0115b46. While the Zero-Any modularization (567/664/597/305 LOC, 0 AST Any, 0 # type: ignore), 31-method signature/export parity, monkeypatch facade forwarding (current_utc_now/store_lock), 17-caller mypy (0 regressions; goal_objective_actions.py reduced 4 -> 1), content_digest_single_owner.test.ts (17/17), Goal canary premerge (17/17), and all 3,255 non-budget tests (with 20 bare-worktree GET /chat 404 failures confirmed identically pre-existing on origin/main 50aa5b4fd1 and passing 210/210 in 53.68s once built loopx/web assets are present) are solid, adding three new .py files directly under top-level loopx/ grows loopx/*.py from 112 to 115, deterministically failing tests/architecture/test_top_level_module_budget.py::test_top_level_module_count_stays_at_the_pinned_budget (1 failed, 1,913 passed in 198.52s, vs 6/6 pass on origin/main 50aa5b4fd1c88b7225fc30e58423120e3ad5d426, violating docs/architecture/rfcs/monorepo-distribution-split-v0.md M0/M1). Please move the 3 internal helper modules under loopx/chat/ (or a subpackage) while retaining loopx/chat_action_store.py as the I3 facade (and optionally removing the unused write_store_json helper in chat_action_store_common.py:267-273), update tests/test_chat_action_store_contract.py, re-run tests/architecture/, and push a new head for re-verification.

Comment thread loopx/chat_action_store.py Resolved
…r top-level budget

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

拆分 Chat Action Store 的共享持久化、审核卡和 operation 生命周期,保留可恢复的旧记录与业务授权和读回。基线的 ChatActionStore 集中持有预览、确认、checkpoint 和落盘。上一版在顶层新增三个模块超过仓库预算,本轮收进现有 chat 命名空间,需要验证旧调用方和 wheel 装载。Chat 预览和 Goal 修订、Acceptance、Lark 卡回调、原生 operation handoff 调用方。

旧 Chat Action 持久记录与确认及回执相容。两版均拒绝相同幂等键绑定不同动作,拒绝后文件内容保持原样。指纹漂移返回 stale,不发应用回执。相同已应用请求重放不产生第二次写回。直接用基线写出 actions.json,复制给各自的真实 store。两版同样读回原预览并保持文件,走复用、apply checkpoint、一份回执、再次加载和 failed 取消。基线、上一提交、当前源码和在隔离目录安装的当前 wheel 输出逐字节相同。

验证覆盖两版隔离本机真实 actions.json,已合成的旧盘数据和失败回放,Lark 测试替换外部传输。当前候选 wheel 已独立安装到隔离目录。已发行版本升级、真实 Lark 服务与远端 CI 留在其验收。 基线运行时合同 本次变更范围

改动思路 / Approach

ChatActionStore 继续持有文件和外部调用门面,common 持有共享校验锁和提交,cards 与 operations 承接各自既有状态机。保留唯一持久层和一次加锁写入,也保留公开门面供既有调用方及测试替换。只在单模块消除 Any 会继续混合审批事实、缓存和操作调度。

ChatActionStore.create_preview / decide_review_card / decide_operation → 本机动作文件与文件锁 → store.load / Lark 读回。

具体改动 / Changes

精确提交 a84a62f4927ee051a9c2768425c05aae86b234f5,目标分叉点 50aa5b4fd1c88b7225fc30e58423120e3ad5d426。12 个文件,+2121 / −1372。相对 0115b46 移动三个私有模块,更新 import 和合同测试路径,删除无调用的 write_store_json wrapper。门面继续导出相同 store 入口,top-level 模块预算保持 112。

  • ChatActionStore.create_preview。把预览和 request digest 原子绑定。 源码
  • replay_or_reuse_preview。从已有幂等绑定或同输入待处理记录恢复。 源码
  • apply_proposal。校验指纹、幂等回执和过期状态,并在原锁内写入。 源码
  • decide_review_card。继续验证记录的送达、受众身份及回调绑定。 源码
  • decide_operation。推进同一确认 envelope 的原生命周期。 源码

对主干的风险 / Risks

本轮未发现阻塞问题。当前头 52 项 store contract、顶层预算和 Chat operation 测试通过,五文件 strict mypy 通过,标准 premerge 通过。wheel 的三个私有模块均打包,并在独立目录用旧盘 fixture 成功续跑。 真实磁盘基线记录覆盖了普通完成、失败恢复、重复调用、冲突和指纹变化。

首次在空 checkout 构建 wheel 时缺前端 bundle,按打包流程在当前提交构建 Dashboard 后重试成功。候选 wheel 的四个 store 入口均从隔离安装目录加载,重放未依赖源码参照路径。外部 Lark 接口使用本地替身。

我的整体评价 / Verdict

APPROVE。 既有 schema、操作锁、回调验真及发送后读回仍由原 caller 模块和 store 验证。类型收窄避免在业务调用读取非对象字段。

English verdict: APPROVE at a84a62f. The relocated modules load from the built wheel. Legacy disk replay, idempotent receipts, stale-preview rejection and the top-level module budget are preserved.

@huangruiteng
huangruiteng merged commit 31cd1f5 into main Nov 26, 2026
40 of 54 checks passed
@huangruiteng
huangruiteng deleted the codex/slim-chat-action-store-zero-any-20261126 branch November 26, 2026 01:44
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