Repository navigation
test(platform_compat): poll the argv fingerprint read after Popen - #21926
Conversation
Popen returns once the child's close-on-exec pipe closes, which Linux does before it publishes the new image's argv, so /proc/<pid>/cmdline can still read empty right after it and process_argv_fingerprint correctly answers None. The live fingerprint test read each child once, so it failed whenever that window was hit. Read each child's fingerprint through wait_until under the existing lost-run ceiling, and name in the failure which branch answered None: the exception the /proc read raised, or how many bytes it read. Ported from #21033: the test moved from test/test_platform_compat.py to test/test_platform_compat_process_identity.py on main, so the original commit no longer applies; the change is the same. (hand-ported from commit 31b9495) Closes #18310
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 693dbfb Description read[DESCRIPTION-READ] 9a33323c40276bb926fd0643515d8921df412520cd17bd97df4d6ada68ce3d10 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (1 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: test-only change that polls the argv fingerprint read after Popen instead of reading it once, with two tests that pin the retry and the named failure.
Replaces #21033 (by @jeeshofone, idle 48h+). Same change, ported to where the test lives now:
test/test_platform_compat_process_identity.py(it moved out oftest/test_platform_compat.pyon main, so the fork commit no longer applies). Authorship kept on the commit.Problem / Motivation
Goal:
test_argv_fingerprint_is_stable_and_tells_processes_apartstops failing at random on Linux CI, and a real failure says which read answered None.The test fails with
assert (None is not None)on unrelated PRs. The failing runs read in #21033 (38520843428, 38581781524) both fail at thebassertion: the second child's fingerprint, read once right after itsPopenreturned.Why it matters
Unrelated PR runs go red on it, and Coverage Gate and PR Readiness fail closed on each one.
Not a goal
process_argv_fingerprint. Answering None for an empty argv is correct for its callers, which compare a recorded fingerprint and must never record a fingerprint of nothing.test_exact_argv_matches_and_near_misses_do_not, which test(platform_compat): poll the Windows exact-argv read #19197 already polls.What changed (motivation → approach → change)
Symptom: the first fingerprint read after
Popensometimes answers None.Root cause: a kernel window, not leaked test state.
Popenreturns once the child's close-on-exec pipe closes, and Linux closes it during exec before it publishes the new image's argv. A read in that window finds/proc/<pid>/cmdlineempty, andprocess_argv_fingerprintanswers None for an empty argv, as documented. Measured in #21033 on a Linux host, reading/proc/<pid>/cmdlineright afterPopen([sleep, "300"])returns: 1 empty read in 3000 on an idle host, 250 in 12000 with 8 such loops at once, zero exceptions.Change, test only: the POSIX branch reads each child's fingerprint through
kiro_crew.testing.wait.wait_untilunder the file's existing_ARGV_READ_CEILING_SECSlost-run ceiling. If it never reads, the failure names the branch: the exception the/procread raised, or how many bytes it read (darwin: whatdarwin_process_argvanswered). The stability (== a) and distinctness (b != a) assertions are unchanged. The Windows branch is unchanged apart from inlining the two reads.Why not a readiness byte, as
_spawnuses: this test deliberately spawns the plainsleepbinary, which cannot signal, so that the argv the kernel reports is exactly the spawn argv on Linux and macOS.Backwards compatibility
Compatible: test-only change; no source file is touched. Removes nothing.
Tests
test_the_fingerprint_read_retries_an_argv_that_is_not_published_yet: two None reads, then a value, give the value after exactly 3 reads.test_a_fingerprint_that_never_reads_fails_naming_the_branch(Linux): at a 0 s ceiling the failure names the pid and the/procbranch (FileNotFoundErrorfor an unallocatable pid).pytest test/test_platform_compat_process_identity.py: 68 passed, 3 skipped.pytest -n 8 test/test_platform_compat*.py test/test_process_identity_structural.pyplus the wait-discipline, flake-pattern and pid-reader ratchets: 1096 passed, 30 skipped.Manual verification
N/A — test-only change.
Related Issues
Closes #18310
Checklist
Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.