Repository navigation
Conversation
`Type-check kernel contracts` runs `python -m mypy`, which follows every import the 17 declared files reach. Those imports pull in legacy modules that were never meant to satisfy `strict`, so the job reported thousands of findings in files it never claimed to qualify and never reached a green state on `main`. This is the upstream cause of the skipped Python shards in loopx-project#9567: `test-shard` needs `kernel-contracts`, so a red gate silently removes the suite that would otherwise run into its deadline. Measured on `811c1a1f6`: python -m mypy -> 3852 errors in 396 files python -m mypy --follow-imports=silent -> Success, 17 source files `--follow-imports=silent` still resolves types through imports, but reports only on the files the gate declares, so the contract set keeps its `strict` enforcement. Verified by injecting a bad return type into a contract file (`loopx/control_plane/work_items/lifecycle.py`): the silent run still failed with exactly that one error, then the injection was reverted. The same workflow already uses this flag for the Todo CLI adapter boundary. Also fix `update_operation.py` to resolve the Windows-only creation flags through `getattr`, matching the other platform-specific callers in this package. The POSIX analyzer types those two attributes out of `subprocess`. The runtime branch is already guarded by `os.name != "nt"`, so behavior is unchanged. Refs loopx-project#9567 Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.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
受影响的是查看后端资格结果的 PR 作者、维护工作流的审查者,以及使用后台更新的操作员。 基线裸 mypy 报告 395 个文件的 3834 个问题,显式检查 17 个入口文件。 在同一 Python 3.11.17 和 mypy 1.20.2 下执行基线与候选命令,另外在声明文件及导入模块注入独立类型错误。 候选命令在 17 个目标通过。目标文件内的返回类型错误和依赖签名误用各检出一次,目标集外的函数体诊断被过滤。 验证使用 macOS 的 Python 3.11.17,另以 mypy 的 Linux 目标类型分析复核。Windows 创建参数为受控分支对照,远程 CI 与完整分片时长未验证。 Python 分片的执行时间问题仍由 #9567 跟踪。
改动思路 / Approach
恢复 CI 的 17 文件 strict mypy 契约门,保留导入签名和既有工作流依赖。 在声明的检查步骤使用 follow-imports=silent,保留 strict 和导入类型。后台更新仍用同一工人启动命令,Windows 分支取得同一两个创建标志。 mypy 配置拥有目标集合,工作流 needs 决定作业和汇总的顺序。更新 CLI 的原工人锁、PID 记录与结果通道继续负责执行边界。 后端适用时 kernel-contracts 在 chat-bundle 后检查,checks 汇总结果。分片与 Windows 作业从 changes 和 chat-bundle 独立取得准入。 仓库历史经验讨论分阶段恢复 RFC。这里已有独立可用的契约门和既有工人路径。
具体改动 / Changes
精确提交 bd2828a28f696feef12d6b619fafa46308ea43b9。基线 811c1a1f66652d3fc3b9830d467e14b45b7423c1。整个 PR 2 个文件,+11/-2。YAML 的可执行变化只有现有 mypy 命令。Python 运行时变化限于获取 Windows 常量的写法。 对照「保留后端契约检查」「保持独立作业准入」「继续同等后台更新参数」。候选命令在 17 个目标通过。目标文件内的返回类型错误和依赖签名误用各检出一次,目标集外的函数体诊断被过滤。 结果证明仅工作流选项就足以恢复本地类型检查。真实 POSIX 工人仍脱离观察者继续运行,Windows 参数的两个常量组合为原值。 仓库验收规范
关键代码讲解
Type-check kernel contracts。保留 17 文件的严格检查,并继续分析导入签名。 源码test-shard。由 changes、chat-bundle 与已有条件准入,Windows 作业使用同一依赖关系。 源码start_or_observe。根据 POSIX 或 Windows 选定原 Popen 参数,继续使用原锁和结果文件。 源码
对主干的风险 / Risks
[P3] 更正 Python 作业依赖说明。 PR 说明将分片和 Windows 作业误写成 kernel-contracts 的下游。两版传递依赖均只有 changes、chat-bundle、kernel-static-checks。实际依赖 kernel-contracts 的是 checks 汇总。 请在 PR 说明把成果限定为恢复 kernel-contracts 的类型检查和后端资格汇总,保留 #9567 的分片时长问题。 汇总 Windows 条件 分片超时
1063 项工作流测试、24 项更新测试、6 项直接检查和其余 8 项预合并选检通过。标准预合并首次有一项安装 smoke 超时。同一提交与基线独立运行该 smoke 均通过。 远程 CI 未查。
语义与 CI 对齐
保持类型范围;Windows 常量取值经分支配对,真实 POSIX 工人测试通过。 目标模块读取导入签名,错误收敛到明确责任范围。旧分片门槛仍由 changes 与 chat-bundle 决定。
我的整体评价 / Verdict
APPROVE。收敛 mypy 是成立的独立增量。请在 PR 说明把成果限定为恢复 kernel-contracts 的类型检查和后端资格汇总,保留 #9567 的分片时长问题。 Python 分片的执行时间问题仍由 #9567 跟踪。 已在同一提交重新运行唯一未完成的 smoke 并通过。
English verdict: APPROVE at bd2828a. The 17-file strict type gate passes and still detects local and imported-signature errors. The Python shards and Windows job already run independently, so this addresses the contract gate and leaves #9567 open.
…ission Review follow-up for loopx-project#9604. **P1 — divergent weights duplicated and dropped cases.** Every shard restored `.test_durations` on its own. A cache saved mid-run, or branch-scoped visibility, lets one shard split with measured weights while another splits with equal weights. Different weights produce different partitions, so some cases run twice and others never run, while all six shards still exit 0. Now `test-durations-snapshot` materializes the baseline once, before the matrix exists, and publishes it as `python-durations-baseline`. All six shards download that one artifact, so the input is identical for every shard or absent for every shard. With no history the snapshot pins `{}`, which pytest-split reads as equal weights — a first run therefore splits exactly as it does today. The download is `continue-on-error` so a snapshot failure degrades to that same equal-weight behaviour instead of turning the suite red. **P2 — the merge ran with no shards.** `if: !cancelled()` let it start when `test-shard` was skipped, download nothing, and exit 1. It now reuses the shard admission (`python_tests == 'true'`), and `merge_test_durations` separates the three cases: no subsets produced and all-empty subsets are skips that write nothing, while malformed input still raises. Its tests assert exactly that, including that a skip leaves no baseline file behind. **P2 — the type gate leaked into this branch.** The workflow copy carried the `kernel-contracts` `--follow-imports=silent` change, which belongs to loopx-project#9602. Reverted to `python -m mypy`; this branch now touches only the split baseline. Per-shard subsets are published as `python-durations-shard-<n>` so the merge pattern cannot pick up the snapshot artifact and would not resurrect entries for deleted tests. `scripts/ci/test_review_gate.py` asserted `needs == ["changes", "chat-bundle"]` for every heavy lane. That invariant is about admission, and it still holds: the shard's `if` never reads the snapshot. The assertion now allows a data-only prerequisite as long as it stays out of the predicate, and the ancestor set includes it explicitly. Verification: `python3 -m unittest discover -s scripts/ci -p 'test_*.py'` -> 34 tests OK. Workflow parses to 22 jobs; shard `needs` includes the snapshot, merge `if` requires `python_tests == 'true'`, merge pattern is `python-durations-shard-*`, and `kernel-contracts` runs bare `python -m mypy`. Refs loopx-project#9604 Signed-off-by: ChengLong GU <88359731+gcl-coder@users.noreply.github.com>
Motivation
kernel-contractshas not been green onmainfor at least two days. It is theupstream blocker behind #9567:
test-shardandwindows-powershelllist itunder
needs, so a red gate silently removes the Python suite from every PR runinstead of letting it run into the deadline.
The cause is not a type defect in the contract set. It is the gate's own
invocation:
[tool.mypy]declares 17 files understrict = true, but barepython -m mypyfollows every import those files reach. That pulls in 379 legacy modules which
were never meant to satisfy
strict, so the job reports thousands of findingsin files it never claimed to qualify and the declared contract set is never
reached cleanly.
Measured on
811c1a1f6(currentmain), so this is not caused by the diff.Changes
.github/workflows/python-tests.yml—kernel-contractsnow runspython -m mypy --follow-imports=silent, with an inline comment recording why.--follow-imports=silentstill resolves types through imports; it only stopsreporting on modules outside the declared set. The 17 contract files keep
their full
strictenforcement. The same workflow already uses this flag forthe adjacent
Type-check Todo CLI adaptersboundary.loopx/cli_commands/update_operation.py— the two Windows-only creationflags are resolved through
getattr.subprocess.CREATE_NEW_PROCESS_GROUPandsubprocess.DETACHED_PROCESSdo not exist in a POSIX analyzer'ssubprocessstub. The runtime branch is already guarded by
os.name != "nt", so behavior isunchanged. Every other platform-specific caller in the package already uses this
form (
registry.py:161,usage_ping.py:276,extensions/process_runtime.py:652); this was the one remaining bare access.Verification
The gate still catches real errors. I injected a deliberate type error into
a declared contract file:
Exactly one error, correctly located, while the 3850+ cross-module findings are
gone. The injection was reverted with
git checkoutbefore committing; thediff contains no test-only edits.
Baseline vs. head, same commit, local mypy 1.20.2 / Python 3.11:
python -m mypy(before)python -m mypy --follow-imports=silent(after)Behavior of the touched runtime file:
Workflow file still parses and the step resolves to the intended command:
Scope and limits
kernel-contracts, and therefore restores the Python shards toPR runs. It does not claim the shard deadline overrun in [Bug]: Python test-shards on main exceed the session deadline every run — suite never completes #9567 is fixed —
once the shards run again they may still exceed their budget. That is the
separate half of that issue.
edit is a
getattrresolution on an already-guarded Windows branch.mainshould eventually type-check all 379 imported modules is alarger decision than this fix and is deliberately not taken here.
Refs #9567
🤖 Generated with Claude Code