test(eval): harden relay descendant cleanup against process-group timing - #3996
Conversation
2e0925d to
b178592
Compare
|
This is a synthesis of the independent blind review by @Sol-404ARE at exact head What I checked myself:
Findings from Sol's review (file:line anchored): Standards — NO-GO (2×P2 + 2×P3, worst P2)
The code change itself is focused and localized with no meaningful duplication; a provisional concern about the one-second negative observation was withdrawn as too low confidence. Spec — GO (0 P0–P3)
Verification: What I did not judge:
Gate: two P2 template findings (AI declaration and Checklist) remain; no P0/P1 code defect was found,
|
Astro-Han
left a comment
There was a problem hiding this comment.
This replaces a timing assertion with a causal one, which is the right fix for #3770. The old test slept 0.4s and asserted the file was absent — it could pass because cleanup worked or because the descendant simply hadn't got there yet, and those are indistinguishable.
The new shape makes them distinguishable: the descendant blocks on a FIFO the test holds open O_RDWR (so its own open never blocks and there's always a writer), publishes its PID through a tmp-then-os.replace so the marker is never read half-written, and is released only after settlement returns. A missed process-group cleanup therefore shows up as a real late-write instead of being raced against. Asserting os.getpgid(child_pid) == pid before any of that pins the premise the whole test rests on.
The failure paths are covered too — releasing again, SIGKILLing the descendant, killing the leader through _signal, closing the fd, unlinking the PID file — so a mid-test failure doesn't leak a blocked process.
AI-assisted review: I traced the FIFO handshake, the release ordering against _settle, and the cleanup paths at head b178592e9. No tests run. AI review is not independent human review.
Summary
Closes #3770.
The Eval relay lifecycle regression now exercises the real leader-exits-first boundary instead of relying on a fixed delay:
late-write;This is test-only hardening; production relay behavior is unchanged.
Verification
python3 harbor/test_relay_lifecycle.py: 14 passedpython3 harbor/test_eval_framework.py: 3 passedpython3 harbor/test_relay_contract.py: 30 passedpython3 harbor/test_egress_filter.py: 18 passedpython3 harbor/test_run_trial_policy.py: 4 passedpython3 harbor/test_relay_artifacts.py: 1 passedpython3 -m py_compile harbor/test_relay_lifecycle.py: passedgit diff --check: passedsetsid; all runs passed.中文摘要
本 PR 仅强化 Eval relay 生命周期回归测试,不修改生产逻辑。测试会先确认 descendant 已经和 scope 处于同一进程组,并等待 leader 退出;settlement 完成后才释放 descendant。如果进程组清理失效,descendant 会写入
late-write,测试将明确失败。同时补充失败路径清理,避免遗留进程。