Skip to content

[Bug]: Python test-shards on main exceed the session deadline every run — suite never completes #9567

Backlog

Description

@LIHUA919

Preflight

Issue origin

Observed or reproduced in a real environment (public CI run logs on this repository).

LoopX version or commit

main at 811c1a1f6 (also reproduced on PR heads based on b34f0e615).

Host or runtime surface

Not host-specific

LoopX area

Build, packaging, installer, or CI

Problem

Every recent Python Tests run on main fails: all six test-shard jobs are interrupted by the shard session deadline with most of their assigned cases never executed, so main's Python suite currently has no complete green verification. On the latest main run (46099466649, 2026-11-28T02:43Z) each shard was assigned 7307–7308 cases and the deadline hit with only 3694–6891 finished (LOOPX_PYTEST_DEADLINE, exit code 2). The two prior main runs (46092879228, 46098530667) fail the same way. PR runs inherit the same failures, which makes every open PR's Python check red for reasons unrelated to its diff.

Minimal reproduction

  1. Open any recent Python Tests run on main (e.g. 46099466649).
  2. Open test-shard (1) (job 140838830232): the step log ends with LOOPX_PYTEST_DEADLINE {"deadline_seconds":3262.992,...,"selected_cases":7308,"finished_cases":4632,...} and ##[error]Process completed with exit code 2.
  3. Shards 2–6 show the same deadline interruption with 3694–6891 of ~7308 cases finished.

Expected behavior

main's Python Tests runs complete their assigned cases inside the shard budget and pass when the code is correct (the suite's own health signal; see also the budget design in scripts/ci/shard_budget.py).

Actual behavior

All six shards are terminated at the deadline (session_deadline ≈ 3243–3268s of a 3600s job budget) with thousands of cases unexecuted, and the run is red. Additionally, a handful of genuine test failures are currently mixed into the interruption noise on main (latest run: test_checkpoint_provider_fence, test_quota_authority_settlement_journey, test_delegation_turn_context, test_distribution_runtime_identity, test_stride_comparison_followthrough_cli, test_connected_adapter_status_vocabulary_owner, test_research_execution_loop, test_long_chain_projected_closeout, and tests/test_runtime_subprocess_utf8.py flags loopx/hosts/agy/__init__.py:581 — a text=True subprocess read without encoding="utf-8", which reopens the #4155 locale bug the guard exists for). #8787 already observed shards at ~59.5 minutes on 11-13/14; since 2026-11-26 they exceed it every run.

Sanitized diagnostics

# main run 46099466649, test-shard (1), step tail
LOOPX_PYTEST_DEADLINE {"version":1,"deadline_seconds":3262.992,"deadline_elapsed_seconds":3262.9995,"selected_cases":7308,"finished_cases":4632,...}
##[error]Process completed with exit code 2.
# shards 2-6: selected 7307-7308, finished 3694 / 4708 / 3993 / 6275 / 6891

Additional context

Related: #8787 (CI-speed suggestions; its 11-13/14 measurements already showed ~59.5-minute shard steps), #7389 (browser lanes, different workflow). The per-case timing telemetry (LOOPX_PYTEST_TIMING) and the diagnostics file the harness already emits should make the slowest contributors identifiable without new instrumentation.

Activity

  1. LIHUA919 commented on Nov 29, 2026

    @LIHUA919
    ContributorAuthor

    Addition — a second gate is red on main, and it is upstream of the shards. While attributing the red Python Tests on PR #9435 I found that the kernel-contracts job now fails on main by itself, and because test-shard and windows-powershell list it under needs, pull-request runs skip the Python shards entirely instead of running them into the deadline:

    Run Head kernel-contracts test-shard
    PR run 45609043562 (2026-11-25) 83bbed022 on base b34f0e615 success ran, deadline-interrupted
    main run 46210676811 (2026-11-29T01:20Z) 811c1a1f6 failure ran, deadline-interrupted
    PR run 46156393438 (2026-11-29) 89b2ee479 on base 811c1a1f6 failure skipped

    The failing step is Type-check kernel contracts (python -m mypy). On main it ends with:

    loopx/cli_commands/update_artifact.py:270: error: Module has no attribute "locking"  [attr-defined]
    loopx/cli_commands/update_artifact.py:270: error: Module has no attribute "LK_UNLCK"  [attr-defined]
    loopx/cli_commands/update_operation.py:117: error: Module has no attribute "CREATE_NEW_PROCESS_GROUP"  [attr-defined]
    loopx/cli_commands/update_operation.py:117: error: Module has no attribute "DETACHED_PROCESS"  [attr-defined]
    Found 3834 errors in 395 files (checked 17 source files)
    ##[error]Process completed with exit code 1.
    

    I reproduce the same count locally on a pristine 811c1a1f6 with python -m mypy --platform linux --no-incremental (3834 errors), so it is the tree, not the runner. Every main run in the window that actually executed this job (five, from 2026-11-27T16:34Z on 509360fb0 onward) shows failure; the later ones on main were cancelled by concurrency before the job started. The last success I can find is the 2026-11-25 pull-request run above, so the regression is somewhere between b34f0e615 and 509360fb0; I did not bisect it.

    Consequence for contributors: a PR based on current main gets no Python shard result at all, whatever its own diff does, so "the Python suite passed on this head" cannot be shown from CI until this is fixed or the step is given a main-relative baseline.

  2. LIHUA919 commented on Nov 29, 2026

    @LIHUA919
    ContributorAuthor

    A more complete report of the same regression is now tracked in #9586 (per-shard failure counts, attribution to the zero-Any modularization wave, PR-side skip history back to 2026-11-21, and a merged-without-suite precedent #9304). Keeping this issue open only for the two data points it adds — the run-record regression window (b34f0e615..509360fb0, last success 2026-11-25, first failure 2026-11-27T16:34Z) and the note that later "green-looking" main runs were concurrency-cancelled before the job started. Maintainers: feel free to close this as a duplicate of #9586 once those are noted there (they are, in my cross-reference comment).

  3. gcl-coder commented on Nov 30, 2026

    @gcl-coder
    Contributor

    量化复核:超时由「等数量分配 + 容量不足」两件独立的事叠加而成

    我在 811c1a1f6 上把 #9567 的数字重新算了一遍,结论是这里有两个彼此独立的问题,
    只修其中一个都不会让分片跑完。

    一、分片是按「数量」而不是「耗时」均分的

    --splitting-algorithm least_duration 需要一份耗时基线(pytest-split 默认读
    .test_durations)。这个仓库里没有该文件,git log --all -- .test_durations 也
    查不到任何历史提交,因此该算法退化为「等数量轮转」。

    两条独立证据:

    1. 你报告里 6 个分片分到的用例数是 7307–7308,几乎完全相同。按耗时均分恰恰会产生
      不相等的用例数——相等恰恰说明只按数量分。
    2. python-tests.yml 第 686–688 行的注释本身就写着:
      Without timing history least_duration alternates equal-weight tests.

    代价是把重文件整块塞进同一个分片:同一段 3263s 里,各分片完成数为
    3694 / 3993 / 4632 / 4708 / 6275 / 6891,相差 1.86 倍。
    换算成单用例成本:最轻的 0.947 s,最重的 1.766 s。

    二、总容量已经不敷使用(即使完美均衡)

    用你报告的 deadline ≈ 3263s、2 worker、6 分片:

    • 可用算力 ≈ 6 × 2 × 3263 = 39,156 CPU-秒
    • 分配 43,845 个用例,实际完成 28,593 个(65%)
    • 已完成的平均成本 ≈ 39,156 / 28,593 = 1.369 s/用例
    • 剩余 15,252 个即使按平均成本也要 ≥ 20,880 CPU-秒
    • 合计需求 ≥ 60,036 CPU-秒 ≈ 当前容量的 1.53 倍

    按分片成本区间给一个边界:

    假设 需求 相对容量
    全部按最轻分片(0.947 s) 41,522 CPU-秒 1.06×(勉强)
    全部按平均(1.369 s) 60,036 CPU-秒 1.53×
    全部按最重分片(1.766 s) 77,423 CPU-秒 1.98×

    也就是说:即使分片完全按耗时均衡,这套用例也只是「勉强塞得进」到「差一倍」之间,
    现实值大约 1.5 倍。
    单靠修正分片算法无法转绿。

    三、我没拿到的证据

    python-diagnostics-* 产物下载返回 401(当前凭据没有 artifact 读取权限),所以
    longest_cases 的精确排名我拿不到。上面的需求估算是从你报告里的
    selected_cases / finished_cases 推出的下界,不是逐用例实测。

    如果维护者能贴出任一 python-diagnostics-N 里的 longest_cases 与
    phase_seconds,就能定位到具体用例,把「削减成本」这条路径变成可执行的。

    四、可选的三个方向(互不替代)

    1. 补耗时基线:用 actions/cache + --store-durations / --durations-path
      让分片按真实耗时均衡。修的是失衡,预计挽回 30–40%,单独不足以转绿。
    2. 加容量:--splits 6 → 8/10,或提高 worker 数。立刻有效,直接增加 CI 分钟消耗。
    3. 削减重用例成本:需要第三节那份 profile。收益最大,成本也最高。

    五、一个前置依赖

    在 kernel-contracts 修复之前(#9602),PR 运行的 test-shard 仍因 needs
    不满足而被 skip,本 issue 的修复在 PR 路径上无法被验证。两者需要一起看。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions