refactor: move matrix tooling into infx / 将矩阵工具迁移到 infx 包 - #2911
Conversation
Use infx.matrix as the canonical home for generation and validation. Keep legacy scripts and imports compatible, materialize package code from each historical revision, and cover import and replay boundaries with behavior tests. 将矩阵生成和校验迁移到 infx.matrix,统一模块导入。保留旧脚本和导入路径, 从每个历史修订提取对应的包代码,并通过行为测试验证导入兼容性和历史重放。
退出草稿状态后,通过空提交触发 infx 包的 CI 检查;源码不变。
|
Claude finished @adibarra's task in 4m 42s —— View job Review of PR #2911 / PR #2911 审查
LGTM - no blocking issues found. Independently verified the PR's core claims: 独立验证了核心声明:校验器逐字节一致,生成器仅改动导入;兼容模块通过 Note: I could not run the pytest suites in this environment (command approval not granted for 注:本环境无法执行 pytest(命令未获批准),运行时验证依赖 PR 报告的结果和 CI;以上结论基于静态差异分析。 --- · Branch |
| import json | ||
| import math | ||
| import re | ||
| """Compatibility entrypoint for :mod:`infx.matrix.generate`.""" |
There was a problem hiding this comment.
📊 Line Count Report
- Total Lines: 14
- Base Lines: 1574
- Change: 📉 -1560 lines
(Implementation moved to infx/matrix/generate.py; this file is now a compatibility shim.)
将 Claude 行数报告改为检查 infx/matrix/generate.py;若基准修订尚未迁移,则回退到旧生成器路径。生成和校验源码不变。
Description / 说明
Matrix tooling currently loads its schemas as both
validationandmatrix_logic.validation, creating distinct Python classes. Move the shared implementation into the repository-rootinfxpackage so callers share one implementation and one set of schema types.矩阵工具目前分别通过
validation和matrix_logic.validation加载模式,导致 Python 创建不同的类。将共享实现迁移到仓库根目录的infx包,让调用方共用同一套实现和模式类型。infx.matrix.generateowns generation;infx.matrix.validationowns schemas. The validator is byte-identical to the original, and the generator only changes its imports.Existing script paths, CLI flags, defaults, relative input paths, recipes, and dependencies remain unchanged. Thin compatibility modules preserve old imports, including shared class identity and monkeypatch behavior. No package installation is required to run existing commands from a checkout.
Historical changelog comparisons extract
infxfrom the requested Git revision when present; older revisions retain their standalone generator. Tests run extracted code with poisoned working-tree source and inputs to catch accidental fallback.Update matrix/changelog CI path filters, point the Claude line-count report at the canonical generator (with a legacy base-path fallback), and synchronize English/Chinese architecture documentation. Net production growth is 30 lines for package setup and compatibility; generation algorithms are unchanged.
infx.matrix.generate负责生成,infx.matrix.validation负责模式校验。校验器与原文件逐字节一致,生成器仅调整导入。现有脚本路径、CLI 参数、默认值、相对输入路径、配方和依赖保持不变。轻量兼容模块保留旧导入路径,包括类身份和 monkeypatch 行为。从检出目录运行现有命令无需安装包。
历史变更日志比较从指定 Git 修订提取
infx(若存在);更早的修订继续运行独立生成器。测试故意破坏工作区源码和输入,再运行提取的代码,以发现错误回退。更新矩阵和变更日志 CI 路径过滤器,将 Claude 行数报告指向规范生成器路径(对旧基准修订保留路径回退),并同步中英文架构文档。生产代码净增 30 行,用于包初始化和兼容;生成算法不变。
Related Issue / 关联事项
Next internal-cleanup PR after #2897, #2901, and #2903.
继 #2897、#2901 和 #2903 之后的下一项内部清理。
Validation / 验证
Full CPU suite: 1,140 tests + 219 subtests passed in 52.81s.
The exact same 403 behavior tests pass on frozen main (
5056e9415, 2.41s) and the refactor (2.46s). Two additional tests verify schema interoperability across old/new import paths in either import order.457 real CLI comparisons: 379 successful cases have byte-identical stdout/stderr; 78 rejected cases have equivalent exit codes and diagnostics, ignoring traceback source locations. Includes controlled topologies and filters plus current-catalog generation.
9 additional help/error comparisons across the generator, changelog processor, and changelog validator match exactly when run outside the checkout.
Negative controls: omitting historical package extraction and restoring duplicate schema definitions each cause two regression tests to fail.
actionlint -shellcheck= -pyflakes=passes for all three changed workflows. Copy-awaregit diff --checkpasses; existing whitespace in relocated implementation files is preserved.完整 CPU 测试集:1,140 项测试和 219 项子测试全部通过,用时 52.81 秒。
完全相同的 403 项行为测试在冻结的 main(
5056e9415,2.41 秒)和重构后(2.46 秒)均通过。另有两项测试验证不同导入顺序下新旧路径的模式互操作性。457 组真实 CLI 对比:379 组成功输出的 stdout/stderr 逐字节一致;78 组拒绝用例的退出码和诊断等价,仅忽略 traceback 源码位置。覆盖受控拓扑、筛选条件和当前配置目录。
在检出目录外执行生成器、变更日志处理器和校验器的 9 组帮助/错误输出对比,结果完全一致。
负向验证:遗漏历史包提取和恢复重复模式定义,分别使两项回归测试失败。
三个工作流均通过
actionlint -shellcheck= -pyflakes=;识别文件复制后的git diff --check通过,迁移文件保留原有空白。Type of Change / 变更类型
Checklist / 检查清单
Note
Medium Risk
Refactors central sweep matrix generation and validation used by changelog gating and CI; behavior is intended to be unchanged but any import or historical-revision extraction bug could alter generated benchmark matrices.
Overview
Moves benchmark matrix generation and Pydantic validation from
utils/matrix_logic/into a new repository-rootinfxpackage (infx.matrix.generate,infx.matrix.validation).process_changelog.pyandvalidate_perf_changelog.pynow import the canonical modules directly.utils/matrix_logic/generate_sweep_configs.pyandvalidation.pybecome thin compatibility shims: they add the repo root tosys.path, delegate toinfx, and register themselves insys.modulesso legacy import paths and monkeypatches still hit the same module objects (avoiding duplicate schema classes).CI path filters and synchronized English/Chinese architecture docs point at the new locations. The Claude PR review workflow’s matrix generator line-count rule targets
infx/matrix/generate.py, with a fallback to the old path for pre-migration diffs. Append-only changelog handling is documented to extractinfxfrom the requested Git revision when present.Tests add coverage for running the legacy script from another working directory and for schema/type identity across mixed legacy and package import orders.
Reviewed by Cursor Bugbot for commit 6536a90. Bugbot is set up for automated code reviews on this repo. Configure here.