Skip to content

refactor(feedback): modularize reward rendering with zero AST Any and O(1) run observation - #9479

Merged
loopx-agent merged 1 commit into
mainfrom
codex/slim-feedback-zero-any-20261126
Nov 27, 2026
Merged

loopx-agent merged 1 commit into
mainfrom
codex/slim-feedback-zero-any-20261126

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Summary

  • Goal / Ownership: Keep loopx/feedback.py (460 <= 550 LOC) as the lazy-adapter and reward-overlay facade while extracting pure validation, compaction, coordination summary, and Markdown/Progress-Ledger rendering into loopx/control_plane/runtime/reward_rendering.py (401 < 750 LOC) — with zero top-level loopx/*.py growth (112 unchanged), 0 AST Any, 0 # type: ignore, and 0 # noqa.
  • Export & Monkeypatch Compatibility: Preserve __all__, __dir__, from loopx.feedback import *, is identity on all 15 re-exported rendering/compaction symbols, lazy loading of legacy_writer_fence and document_io (test_feedback_adapter_loading.py), and module-level patch points such as feedback.plan_active_state_update and feedback.load_index.
  • Efficiency (O(N) -> O(1) Artifact Observation): _select_reward_run now defaults to history.load_index_snapshot(index_path, include_artifact_status=False) before select_run, observing json_exists/markdown_exists only for the selected run instead of stat-ing all unselected historical artifacts in index.jsonl.
  • Contract Tests (tests/control_plane/test_feedback_contract.py, 316 <= 400 LOC, 0 AST Any): Covers LOC/zero-Any/re-export identity budgets, MappingProxyType inputs, single-run artifact observation spy proof across a 25-run index, patched-loader fallback, and negative/write-error paths.

Validation

  • ruff check (3/3), mypy --strict --no-incremental --follow-imports=silent (3/3, 0 errors), [tool.mypy] (17/17, 0 errors), 20-file caller mypy (208 -> 208, +0 regressions)
  • Paired origin/main (7f7297a790) vs HEAD (d527901dd4) counterfactual across reward compaction, dry-run/applied overlay writeback, ACTIVE.md Progress Ledger update, and Markdown rendering (100% match, 10,354 bytes)
  • npm run typecheck:control-plane clean + TS control-plane suites (public_safe_text_corpus.test.ts, content_digest_single_owner.test.ts)
  • 4/4 clean-HOME smokes (reward-gate-direct-write-contract, control-plane-maintainability-ratchet, semantic-vocabulary-drift, status-markdown)
  • Focused & broad pytest -n 6 -rs across feedback, public-safety, shadow-writer, history, status-server, project-lifecycle, change-quality, tests/architecture/, and tests/canary/: 2,534 passed, 6 skipped (plus 319 passed targeted + 14 passed maintainability ratchet)
  • scripts/check_rfc_bilingual.py, Goal loopx check (0 errors across 6 checks), and Goal canary premerge (standard: direct=4/4, py_compile=1/1, catalog=8/8, risk_profile=8/8, failures=0) with valid Goal exact-scope change-quality qualification

@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

通过 CLI 或状态服务给指定历史运行记录人工反馈的人,以及读取回执的维护者。 将摘要呈现从写入入口移出并减少查询选定运行时的无关磁盘探查,维持索引附加与原状态文件安全。 25 条运行的文件探查由 50 次降至 2 次,125 条运行由 250 次降至 2 次。索引解码仍随记录数增长。 配对运行验证最新和显式旧运行,预览的完整 JSON、Markdown、实际索引附加与 Progress Ledger 回读一致。 验证范围为本地源码与合成索引文件。线上数据、正式安装、远端 CI 和端到端耗时待验。 Refactor Real-Path Gate

改动思路 / Approach

CLI 或状态服务 → append_human_reward → 完整历史解码与原选择 → 观察目标文件 → 原索引锁、写入与读回。 保留 reward facade、history 解码和已有写入合同,将纯呈现移入 runtime owner,只把文件存在性推迟到选定运行后。 单独改变类型不会降低文件查询数。这里保持已有读写顺序、所有者和可选的状态摘要,让原历史读出选定项后再获取存在性。

具体改动 / Changes

当前基线 7f7297a790771dab08e2444700f4d76699169950,受审提交 d527901dd4b7887cb69e0d5f09b15c49a02063e5。三个文件增加 900 行、删除 421 行。纯渲染函数进入 runtime 模块,调用方仍从原 feedback 入口取得同一导出。历史 adapter 保留主路径和调用方补丁路径,写入使用已有的运行索引锁、状态检查与原写回动作。契约测试核对真实调用和文件存在性,保护显式旧运行与缺失目标。

  • _select_reward_run。完整解码和原选择之后观察两个选中路径。源码
  • append_human_reward。保持原 actor gate、索引附加和可选状态摘要事务。源码
  • render_reward_markdown。呈现原运行和回执,不触发磁盘写。源码
  • test_append_human_reward_observes_only_selected_run_artifacts。断言只观察选中项并保留原记录数。源码

对主干的风险 / Risks

指定不存在的运行时,两个版本均返回同一拒绝,索引字节保持原样。显示路径调用仍读取完整历史;缺失目标在候选头无需查任何文件。 现有观察器仍负责已有的文件回读规则。配对比较统一了临时目录根,完整结果与账本内容一致。同源定向套件在基线 57 项和候选 61 项通过。三文件 Ruff、严格 mypy 和标准预合并 6 项直接检查、16 项所选检查通过。本地 gate 单项上限设为 300 秒。

我的整体评价 / Verdict

APPROVE。 两种规模都把存在性查询缩到选定运行,正常与拒绝路径的回执保持一致。变更延用完整索引去重、原 actor 门和账本写入责任。验证范围为本地源码与合成索引文件。线上数据、正式安装、远端 CI 和端到端耗时待验。

English verdict: APPROVE at d527901. Paired real-file tests preserved selection, receipts and durability, while artifact lookups fell from 50 to 2 and 250 to 2. Index decoding still reads the full index.

… O(1) run observation

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
@loopx-agent
loopx-agent force-pushed the codex/slim-feedback-zero-any-20261126 branch from d527901 to 9788109 Compare November 27, 2026 16:27

@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 · deepseek-flash · DeepSeek · runtime_reported · high

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

通过 CLI 或状态服务给指定历史运行记录人工反馈的人,以及读取回执的维护者。 将摘要呈现从写入入口移出并减少查询选定运行时的无关磁盘探查,维持索引附加与原状态文件安全。 25 条运行的文件探查由 50 次降至 2 次,125 条运行由 250 次降至 2 次。索引解码仍随记录数增长。 配对运行验证最新和显式旧运行,预览的完整 JSON、Markdown、实际索引附加与 Progress Ledger 回读一致。 验证范围为本地源码与合成索引文件。线上数据、正式安装、远端 CI 和端到端耗时待验。 Refactor Real-Path Gate

改动思路 / Approach

CLI 或状态服务 → append_human_reward → 完整历史解码与原选择 → 观察目标文件 → 原索引锁、写入与读回。 保留 reward facade、history 解码和已有写入合同,将纯呈现移入 runtime owner,只把文件存在性推迟到选定运行后。 单独改变类型不会降低文件查询数。这里保持已有读写顺序、所有者和可选的状态摘要,让原历史读出选定项后再获取存在性。

具体改动 / Changes

当前基线 7f7297a790771dab08e2444700f4d76699169950,受审提交 9788109276422b512b70a8c1fb6d92330d17217d。三个文件增加 900 行、删除 421 行。纯渲染函数进入 runtime 模块,调用方仍从原 feedback 入口取得同一导出。历史 adapter 保留主路径和调用方补丁路径,写入使用已有的运行索引锁、状态检查与原写回动作。契约测试核对真实调用和文件存在性,保护显式旧运行与缺失目标。

  • _select_reward_run。完整解码和原选择之后观察两个选中路径。源码
  • append_human_reward。保持原 actor gate、索引附加和可选状态摘要事务。源码
  • render_reward_markdown。呈现原运行和回执,不触发磁盘写。源码
  • test_append_human_reward_observes_only_selected_run_artifacts。断言只观察选中项并保留原记录数。源码

对主干的风险 / Risks

指定不存在的运行时,两个版本均返回同一拒绝,索引字节保持原样。显示路径调用仍读取完整历史;缺失目标在候选头无需查任何文件。 现有观察器仍负责已有的文件回读规则。配对比较统一了临时目录根,完整结果与账本内容一致。同源定向套件在基线 57 项和候选 61 项通过。三文件 Ruff、严格 mypy 和标准预合并 6 项直接检查、16 项所选检查通过。本地 gate 单项上限设为 300 秒。

当前 exact head 复核 / Rebased-head validation

PR #9479 已无冲突 rebase 到 origin/main 2302e42d9cad35a8a4150e24496ffecfbfdce8cb,当前精确头为 9788109276422b512b70a8c1fb6d92330d17217d。本轮在新 base 上重新执行定向测试、静态检查和 diff 级 premerge。

最终 exact head 复核:30 项 feedback 合约、adapter loading、Goal 校验和 run selection 测试通过;核心文件严格 mypy、Ruff、diff 检查和标准 premerge 的 16 项选定检查全部通过。单次 run index 观测和所有 re-export 兼容性保持。

我的整体评价 / Verdict

APPROVE。 两种规模都把存在性查询缩到选定运行,正常与拒绝路径的回执保持一致。变更延用完整索引去重、原 actor 门和账本写入责任。验证范围为本地源码与合成索引文件。线上数据、正式安装、远端 CI 和端到端耗时待验。

English verdict: APPROVE at 9788109. Paired real-file tests preserved selection, receipts and durability, while artifact lookups fell from 50 to 2 and 250 to 2. Index decoding still reads the full index.

@loopx-agent
loopx-agent merged commit 4af92d7 into main Nov 27, 2026
18 of 22 checks passed
@loopx-agent
loopx-agent deleted the codex/slim-feedback-zero-any-20261126 branch November 27, 2026 16:33
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.

1 participant