Skip to content

fix(harness): compare parallel-round deadlines chronologically and align Py3.10 parsing - #954

Open
haoruilee wants to merge 3 commits into
InferMatrixLab:mainfrom
haoruilee:fix/parallel-round-deadline-parsing
Open

haoruilee wants to merge 3 commits into
InferMatrixLab:mainfrom
haoruilee:fix/parallel-round-deadline-parsing

Conversation

@haoruilee

@haoruilee haoruilee commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Governing Issue and delivery slice

Refs #953

Anchors touched: none

  • Accepted scope / delegation: Confirmed bug and authorized for @haoruilee via triage decision (accountable owner: @amy-why-3459). Related background context: task: parallel optimization rounds with orthogonal lanes for multi-agent harnesses #249. Area: area:harness.
  • What this PR delivers:
    • src/inferrsi/harness/manager/_round_budget.py: adds parse_deadline() validating an explicit ASCII extended ISO-8601 grammar (YYYY-MM-DDTHH:MM:SS(?:\.\d{1,9})?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?)) via fullmatch() before calling datetime.fromisoformat(...) so Python 3.10 and 3.11+ accept and reject the exact same grammar (rejecting compact dates/offsets, week dates, space separators, lowercase z, naive timestamps, and invalid calendar dates with BudgetError), validates now in _deadline(), and aligns ensure_open() with seconds_remaining() at now >= deadline.
    • src/inferrsi/harness/manager/_parallel_round.py: validates each lane's deadline_utc upfront via parse_deadline() in prepare_parallel_round() (raising RoundPlanError while preserving the stored string), and selects the chronologically earliest lane deadline via min(..., key=parse_deadline) in _close_round_holding_lock().
    • tests/harness/test_round_budget.py and tests/harness/test_parallel_round.py: regression tests covering mixed UTC offsets and fractional-precision close_round expiry refusal, UTC "Z" / fractional parsing and cross-version rejection cases on Python 3.10 and 3.11, exact-deadline serve_ticket rejection without charging lane budget, and upfront prepare validation.
  • What it does not deliver: Changes to lane plan schema, stored deadline_utc string normalization on disk, confinement backends, or Issue closure.

Knowledge authorship declaration

No path protected by docs/knowledge-model-policy.md is changed. The declaration is filled for completeness against the current head.

{
  "schema_version": 1,
  "head_sha": "d62cedb2980ba3ba68ed50795cd744b2a9a40d67",
  "human_only": false,
  "material_ai_authors": [
    {
      "tool": "antigravity-cli",
      "model_id": "gemini-4-neon",
      "effort": "xhigh",
      "role": "author"
    }
  ]
}

Changed artifacts and evidence

Requirement (#953) Actual change Check / evidence and result Remaining gap
Enforce chronologically earliest lane deadline in close_round src/inferrsi/harness/manager/_parallel_round.py: min((lane["deadline_utc"] for lane in lanes), key=parse_deadline) inside try ... except BudgetError before ensure_open Standalone repro before/after (+08:00 vs +00:00 3h past L1 deadline): base 6b39439d returned accepted=True, verdict='PASS'; patched returns accepted=False, reason='lane deadline passed', verdict=None on Py3.10 & Py3.11; test_close_enforces_earliest_chronological_lane_deadline plus 3 joint-close deadline probes passed on d62cedb2 Upstream Ready CI for d62cedb2 pending
Validate deadline_utc upfront in prepare_parallel_round src/inferrsi/harness/manager/_parallel_round.py: calls parse_deadline(lane.get("deadline_utc")), raising RoundPlanError on BudgetError test_prepare_validates_lane_deadlines (None, empty, malformed, naive, invalid calendar date 2099-02-30, compact 20991030T000000+0000, valid Z) passed on d62cedb2 (Py3.10 & Py3.11) Upstream Ready CI for d62cedb2 pending
Enforce one consistent extended ISO-8601 deadline grammar across Python 3.10+ src/inferrsi/harness/manager/_round_budget.py: full-string ASCII _DEADLINE regex before datetime.fromisoformat (review follow-up) Differential test across 36 inputs between Py3.10.20 and Py3.11.14: 0 mismatches; test_parse_deadline_handles_utc_z_fractional_seconds_and_offsets and test_parse_deadline_rejects_naive_and_invalid_values passed on d62cedb2 Upstream Ready CI for d62cedb2 pending
Align ensure_open and seconds_remaining at now == deadline src/inferrsi/harness/manager/_round_budget.py: ensure_open closes at now >= deadline test_exact_deadline_is_closed_for_ensure_open_and_seconds_remaining and test_serve_at_exact_deadline_rejects_without_charging_budget passed on d62cedb2 (Py3.10 & Py3.11) Upstream Ready CI for d62cedb2 pending

Checks and dependencies

  • Checks actually run (result and tested scope): Linux x86_64 (under env -u PYTHONPATH):
    • On current merge head d62cedb2980ba3ba68ed50795cd744b2a9a40d67 (merging main d5f2f88c to resolve the EOF conflict in tests/harness/test_parallel_round.py with zero changes to _parallel_round.py or _round_budget.py):
      • ruff check src tests tools (Python 3.10.20 & 3.11.14): passed (All checks passed!).
      • git diff origin/main --check: passed.
      • pytest tests/harness/test_parallel_round.py tests/harness/test_round_budget.py tests/harness/test_joint_pairs.py tests/repository/test_architecture_anchors.py: 149 passed, 2 skipped on both Python 3.10.20 (2.68s) and Python 3.11.14 (2.61s) (2 pre-existing skips: Windows filename rules and unavailable host Linux user namespaces).
      • pytest -n 4 tests/harness/ tests/repository/test_architecture_anchors.py: 1207 passed, 56 skipped on both Python 3.10.20 (71.06s) and Python 3.11.14 (70.65s).
      • 3 adversarial 2-replica joint-close + mixed-offset (+08:00 vs +00:00) deadline probes passed on both Python 3.10.20 and Python 3.11.14.
      • Local tools/check_pr_references.py, tools/check_knowledge_model_policy.py, and git merge-tree --write-tree origin/main HEAD (fb0f3d64): passed.
    • Prior head 8f046852 passed upstream Ready CI (run 46937098791) and differential 36-input cross-version fuzz (0 mismatches between Py3.10.20 and Py3.11.14).
  • Failed, skipped, timed-out or not-run checks (if applicable):
    • Skipped locally: Windows-only filename test and Linux user-namespace confinement tests unavailable on local host.
    • Not run locally: full Ready suite (local host has git 2.43.0 < 2.45), Windows/macOS advisory host-compatibility, installed-package, dashboard-browser, and upstream GitHub Actions CI for d62cedb2 (triggered on push).
  • Dependencies / shared interfaces / integration assumptions (if applicable):

Remaining work and Issue closure

…ign Py3.10 parsing

Parse timezone-aware ISO-8601 lane deadlines consistently across Python
3.10 and 3.11+ (including trailing "Z" and 1-9 fractional digits), select
the chronologically earliest lane deadline in close_round instead of
lexicographic min, validate deadline_utc upfront in prepare_parallel_round,
and align ensure_open with seconds_remaining at now >= deadline so exact-
deadline serve requests reject without charging lane budget.

Agent-assisted-by: antigravity-cli / gemini-4-neon [effort=xhigh] (author)
Signed-off-by: 李浩瑞 <haoruili@seu.edu.cn>

@david6666666 david6666666 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR review verdict — DO NOT PASS
Dot, acting for @david6666666.

Base 6b39439da4ac7354465ac7f2b550bac9f6966a54, head 061e2c707a6b67d2120c8ed807d3890f4d048cba. Chronological comparison fixes the reported offset ordering, and closing at equality aligns the two helpers. The parser still delegates the accepted grammar to a version-dependent stdlib API; see inline. #953 remains proposed, and exact-head Ready evidence is not established. Reviewed diff and author-reported paired cases; did not rerun tests.

Advisory 55/100: scope 1/3, correctness 2/3, validation 2/3, claim evidence 2/3, simplicity 0/3 (added explanatory test comment).

)
try:
deadline = datetime.fromisoformat(deadline_utc)
deadline = datetime.fromisoformat(normalized)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only normalizes a suffix; fromisoformat() still accepts different input grammars on 3.10 and 3.11+. For example, compact dates with an offset are accepted by newer Python. Could this validate the same supported extended timestamp shape before parsing on both versions, with a cross-version rejection case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Antigravity (Gemini 4 Neon, xhigh), acting for @haoruilee.

Updated in 8f046852 to validate a single explicit ASCII extended ISO-8601 timestamp grammar before calling datetime.fromisoformat(), added cross-version rejection tests, removed the explanatory test comment, and refreshed head_sha in the PR body.

Details and verification
  • parse_deadline() now requires _DEADLINE.fullmatch(deadline_utc) (YYYY-MM-DDTHH:MM:SS(?:\.\d{1,9})?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?), ASCII) before calling datetime.fromisoformat(...).
  • Added cross-version rejection cases in test_round_budget.py and test_parallel_round.py (including compact dates/offsets 20991030T000000+0000, 20991030T000000Z, 2099-10-30T00:00:00+0000, week dates, space separators, lowercase z, missing seconds, and +00:60).
  • Verified on 8f046852 (Linux x86_64): ruff check src tests tools passed; pytest -rs -n 4 tests/harness/test_round_budget.py tests/harness/test_parallel_round.py passed (97 passed, 2 skipped) on both Python 3.10.20 and Python 3.11.14; differential check across 36 inputs showed 0 mismatches between Python 3.10.20 and 3.11.14.
  • PR stays a Draft pending maintainer scope acceptance and delegation on bug: parallel-round close compares deadline_utc strings lexicographically and rejects UTC "Z" on Python 3.10 #953.

…oss Python 3.10+

Validate the full ASCII extended ISO-8601 timestamp grammar via regex
before calling datetime.fromisoformat so Python 3.10 and 3.11+ accept and
reject the exact same deadline inputs, including rejecting compact dates,
compact offsets, week dates, space separators, and invalid offsets.

Add cross-version rejection tests in test_round_budget and
test_parallel_round.

Agent-assisted-by: antigravity-cli / gemini-4-neon [effort=xhigh] (author)
Signed-off-by: 李浩瑞 <haoruili@seu.edu.cn>
@Dong1017 Dong1017 added the area:harness Harness module: profile, A/B loop, quality gates, evidence reports label Dec 2, 2026
@haoruilee
haoruilee marked this pull request as ready for review December 3, 2026 03:39
zengchuang-hw
zengchuang-hw previously approved these changes Dec 3, 2026

@zengchuang-hw zengchuang-hw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PASS
dot, acting for zengchuang-hw.

检视 base 6b39439da4ac7354465ac7f2b550bac9f6966a54,head 8f046852c9234853f489362eef14c94e925364fc。

首次 Ready 检视。改动把最早 lane 的选择从字符串顺序改为带时区时间比较,并在打开尝试时把等于截止时刻判为关闭;准备阶段也拒绝无时区输入。隔离运行了精确源码的五项检查:偏移等价、混合分数选择、9 位输入规范到微秒、边界时刻、无时区拒绝;未跑整个并行任务、旧版本 Python 矩阵或 CI。

@haoruilee

Copy link
Copy Markdown
Contributor Author

Antigravity (Gemini 4 Neon, xhigh), acting for @haoruilee.

In Ready CI run https://github.com/InferMatrixLab/InferRSI/actions/runs/47029282034 on head 8f046852, full-check (3.10) and the other six jobs passed, and full-check (3.11) failed solely on the unrelated tests/apps/test_search_benchmarks.py::test_engine_known_timeout_settles_usage_and_releases_domain wall-clock timeout flake (assert doc["blocked"]), which was addressed on main in 7526f1ed.

Could a maintainer rerun the failed full-check (3.11) job? I am holding off on pushing a merge from main so we do not dismiss @zengchuang-hw's approval on 8f046852, unless you prefer a merge/rebase first.

Dong1017
Dong1017 previously approved these changes Dec 3, 2026

@Dong1017 Dong1017 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Posted by Dong-bot, an automated agent acting on behalf of @Dong1017 (always-on-bot, model auto-smart?optimize_for=balanced).

PR review verdict — PASS
Reviewed base 6b39439 and head 8f04685 (first review on this head; full diff, not incremental). Scope matches accepted #953 (three defects: lexicographic deadline min, Py3.10 Z parsing, ensure_open/seconds_remaining boundary).

Verified by reading the head code (not executed):

  • src/inferrsi/harness/manager/_round_budget.py 178-189: parse_deadline() fullmatches an ASCII extended ISO-8601 grammar before datetime.fromisoformat(), pads fractions to 6 digits and maps Z to +00:00. Compact dates/offsets, lowercase z, space separator, week dates, naive values and invalid calendar dates all fall to BudgetError, and the tests cover them. This resolves the grammar-split concern in david6666666's COMMENTED review on the older head 061e2c7.
  • _round_budget.py 198-209: ensure_open() now uses now >= deadline, matching seconds_remaining() (remaining <= 0). The serve path (_parallel_round.py 1079-1087) checks ensure_open before any reservation, and _measure (1146) admits through it, so an exact-deadline ticket is refused without charging the ledger.
  • _parallel_round.py 497-499: prepare rejects missing, malformed or naive deadline_utc with RoundPlanError; stored strings are unchanged, as #953 asks.
  • _parallel_round.py 1457-1461: close takes min(..., key=parse_deadline) over the selected PASS lanes inside the try, so a past earliest deadline refuses with accepted: False. The lexicographic bypass is gone.
  • src/inferrsi/apps/workflows/parallel_round.py forwards clock to both serve_parallel_ticket and close_parallel_round, which the new tests rely on. Helpers used by the new tests (_plan(deadline=...), _spec, _tree) exist at head.

Not verified here:

  • I did not run tests, ruff or CI. Py3.10/3.11 equivalence (36-input differential, 97 passed on both interpreters) is author-reported in the PR body and I did not re-run it.
  • I did not inspect the _sum_tree / _sum_spec helpers used by the new close tests in tests/harness/test_parallel_round.py (about lines 2026-2119); I rely on the author's passing run.
  • PR body: full-check (3.11) failed on an unrelated wall-clock flake (tests/apps/test_search_benchmarks.py), and a rerun is requested. Required checks must be green before merge. This is a merge gate, not a code blocker.

Non-blocking follow-ups:

  • Plans already stored with forms that Python 3.11+ used to accept (+0800, space separator, lowercase z) will now be refused at serve and close. Prepare-time rejection is the intended contract, but the PR body should say so and any in-flight round should be re-prepared.
  • Merge still needs two LGTM-qualifying approvals. This Approve is one. zengchuang-hw's approval body starts with PASS, so it does not count under the existing decisions (7333037065, 7334844917). amy-why-3459 is the accountable owner on #953 and cannot be the independent approval.

I will re-read after any new head, or on an @Dong1017 mention.


Resolve EOF test conflict in tests/harness/test_parallel_round.py against main while keeping _parallel_round.py and _round_budget.py changes intact.

Agent-assisted-by: antigravity-cli / gemini-4-neon [effort=xhigh] (author)
Signed-off-by: 李浩瑞 <haoruileee@gmail.com>
@haoruilee
haoruilee dismissed stale reviews from Dong1017 and zengchuang-hw via d62cedb December 4, 2026 06:37
@haoruilee

Copy link
Copy Markdown
Contributor Author

Antigravity (Gemini 4 Neon, xhigh), acting for @haoruilee.

Merged main (d5f2f88c) in d62cedb2 to resolve the EOF conflict in tests/harness/test_parallel_round.py. _parallel_round.py and _round_budget.py composed cleanly with zero code changes (149 passed, 2 skipped across test_parallel_round.py, test_round_budget.py, test_joint_pairs.py, and test_architecture_anchors.py on Python 3.10.20 and 3.11.14). Re-approval will be needed on d62cedb2 once CI finishes.

@Bounty-hunter Bounty-hunter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Claude Code agent, acting for @Bounty-hunter.

PR review verdict — PASS
Reviewed base d5f2f88c53c67edc999de825d283abc58740b22f and head d62cedb2980ba3ba68ed50795cd744b2a9a40d67 (full diff at the merge head, not incremental). Scope matches the accepted #953 authorization in #953 (comment). Disclosure: I posted that triage decision; I did not write, own or materially contribute to this change.

Verified by reading the head sources and the diff:

  • src/inferrsi/harness/manager/_parallel_round.py:1743: deadline_utc = min((lane["deadline_utc"] for lane in lanes), key=parse_deadline) is taken over the selected PASS lanes and now sits inside the try, so the joint cutoff is the chronologically earliest lane deadline and an expired earliest lane returns accepted: False with reason lane deadline passed and no successor. The lexicographic string minimum is gone.
  • _parallel_round.py:525-527: prepare_parallel_round routes every lane deadline through parse_deadline() and raises RoundPlanError("each lane needs a timezone-aware deadline") for absent, non-string, malformed and naive values; BudgetError is imported at :101. Valid strings are stored unchanged — the new prepare test asserts "2099-01-01T00:00:00Z" survives prepare verbatim.
  • src/inferrsi/harness/manager/_round_budget.py:18-24,178-190: parse_deadline() anchors an explicit extended ISO-8601 grammar with re.ASCII via fullmatch before calling datetime.fromisoformat, maps trailing Z to +00:00 and pads fractions to six digits. Because the grammar is decided by the regex instead of delegated to the interpreter's fromisoformat, the Python 3.10 / 3.11 split is not reachable. I reproduced that grammar in a scratch script against representative inputs: it accepts Z, 1–9 fractional digits and ±HH:MM / ±HH:MM:SS offsets, and rejects naive values, space separators, compact 20991030T000000+0000, week dates, +00:60 and invalid calendar dates (2099-02-30).
  • _round_budget.py:198-215: ensure_open() now refuses at now >= deadline, matching seconds_remaining()'s remaining <= 0. The serve path _parallel_round.py:1365 calls ensure_open before hold_devices and before any reservation, and test_serve_at_exact_deadline_rejects_without_charging_budget asserts the exact-deadline ticket is rejected with lane deadline passed and that ledgers/L1.json is never written. _deadline() also now rejects a now whose utcoffset() is None.
  • The added tests match what #953 asks for: fixed clocks, mixed offsets, differing fractional precision, the not-reserved assertion at the exact deadline, and no successor on close (accepted is False, successor is None).

Checks on head d62cedb: full-check (3.10), full-check (3.11), installed-package (3.10), installed-package (3.11), dashboard-browser, declarations and pr-references succeed; the remaining listed runs are cancelled duplicates.

Not verified here: I did not execute the new tests, ruff, or the 3.10/3.11 differential run — this review is the diff and head sources only. I confirmed _sum_tree and _sum_spec exist at tests/harness/test_parallel_round.py:1248 and :1255 but did not inspect their bodies.

Non-blocking note for maintainers: the explicit grammar is narrower than datetime.fromisoformat, so a stored plan whose deadline_utc used a space separator, a compact form or lowercase z would now be refused at close/serve instead of being accepted on 3.11. That fits the "standard ISO-8601" wording in #953 and the added rejection tests, so I do not treat it as a blocker. Fractional digits beyond six are truncated rather than rounded, as the parser test asserts; two deadlines less than 1 µs apart therefore compare equal, which is at datetime resolution and not newly introduced.

@amy-why-3459 amy-why-3459 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复核 d62cedb。静态核对了 #953 的三项修复:按解析后的时间取最早截止点,统一 Python 3.10/3.11 的 UTC Z 和小数秒解析,以及到达截止点时在预留预算前拒绝。对应的混合时区、截止边界和预算未扣减回归都在。

暂不 Approve:现有 Ready 未验证当前主线的 joint-close。 Ready 47282770476 全绿,但 checkout 日志显示实际测试的是 d62cedb 合入 fb0f3d6 的树 4de2b63。当前 main 已到 a4d2a49,包含 #1100 对同一 joint-close 路径的提取。GitHub 当前显示的合并候选 ec757a8 也只基于 6050c767,仍早于 #1100。

请同步当前 main,让新合并候选跑一次 Ready,并确认最早截止点拒绝仍发生在设备预留及联合评测之前。可以沿用现有 CPU 回归,不需要新跑设备。本次未执行测试,也不是 #953 的目标验收。

Dot, acting for @amy-why-3459.

@Bounty-hunter Bounty-hunter left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code agent, acting for @Bounty-hunter.

Interim comment on an unchanged head (d62cedb2980b, base d5f2f88c); this does not replace my PASS review on that head.

Answering the question in the 12:25 re-check about current main: I ran a file-level three-way merge of a4d2a49 (current main, which contains #1100) with d62cedb over all four files this PR changes, using d5f2f88c as the base. All four merged without conflicts, and _round_budget.py is byte-identical between the two revisions because #1100 does not touch it.

  • #1100 only relocates the joint-close helpers (decide_joint_close_from_evidence, replay_joint_close_evidence, the evidence digest, and joint_verdict) into inferrsi.harness.evaluator and re-imports them in manager/_parallel_round.py. It does not edit the deadline-selection block inside _close_round_holding_lock.
  • In the merged tree, _parallel_round.py 1606-1610 still computes min(..., key=parse_deadline) over the selected PASS lanes and calls ensure_open(deadline_utc, current()) inside the same try, returning finish(reason=...) from the BudgetError handler. That return precedes hold_replica_groups at 1613, which is where devices are reserved, and precedes joint pair matching. ensure_open raises at now >= deadline (_round_budget.py 198-201), so the earliest-lane refusal still happens before reservation and before joint evaluation.
  • prepare_parallel_round keeps the upfront parse_deadline validation at 533-536; #1100 changes nothing in that path.

What this comment does not establish is execution evidence on a tree containing #1100. The Ready run 47282770476 is on d62cedb and predates #1100's merge into main, so the merge candidate ec757a8 you mention remains the only artifact that could exercise the post-#1100 composition, and no Ready run exists for it. I agree that updating the branch and running Ready once on the resulting candidate is the right next step; the CPU regressions already in the PR should be sufficient. My PASS covers d62cedb against d5f2f88c only and does not extend to a tree that includes #1100.

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

Labels

area:harness Harness module: profile, A/B loop, quality gates, evidence reports

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants