Skip to content

test(platform_compat): poll the argv fingerprint read after Popen - #21926

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
replace/21033
Oct 18, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
replace/21033

Conversation

@iamwhatever

Copy link
Copy Markdown
Contributor

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 of test/test_platform_compat.py on main, so the fork commit no longer applies). Authorship kept on the commit.

Problem / Motivation

Goal: test_argv_fingerprint_is_stable_and_tells_processes_apart stops 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 the b assertion: the second child's fingerprint, read once right after its Popen returned.

Why it matters

Unrelated PR runs go red on it, and Coverage Gate and PR Readiness fail closed on each one.

Not a goal

  • No change to 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.
  • No change to the sibling 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 Popen sometimes answers None.

Root cause: a kernel window, not leaked test state. Popen returns 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>/cmdline empty, and process_argv_fingerprint answers None for an empty argv, as documented. Measured in #21033 on a Linux host, reading /proc/<pid>/cmdline right after Popen([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_until under the file's existing _ARGV_READ_CEILING_SECS lost-run ceiling. If it never reads, the failure names the branch: the exception the /proc read raised, or how many bytes it read (darwin: what darwin_process_argv answered). 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 _spawn uses: this test deliberately spawns the plain sleep binary, 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 /proc branch (FileNotFoundError for 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.py plus the wait-discipline, flake-pattern and pid-reader ratchets: 1096 passed, 30 skipped.
  • black, isort, flake8: pass.

Manual verification

N/A — test-only change.

Related Issues

Closes #18310

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable): N/A
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

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
@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision 693dbfbaf144f1556564a31314a3e614c5f7cd52 ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Advisory — does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 693dbfbaf144f1556564a31314a3e614c5f7cd52 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 693dbfbaf144f1556564a31314a3e614c5f7cd52 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 693dbfbaf144f1556564a31314a3e614c5f7cd52 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 693dbfb

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 693dbfbaf144f1556564a31314a3e614c5f7cd52: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 693dbfbaf144f1556564a31314a3e614c5f7cd52 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 693dbfb

Verdict parsed from the review's SHA-scoped output markers for commit 693dbfbaf144f1556564a31314a3e614c5f7cd52.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 693dbfbaf144f1556564a31314a3e614c5f7cd52: <one-sentence reason>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 18, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 18, 2026 18:04

@KiroCrewCaptain KiroCrewCaptain 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.

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.

@KiroCrewCaptain
KiroCrewCaptain merged commit 9c8bd9c into main Oct 18, 2026
106 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the replace/21033 branch October 18, 2026 18:04
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky: test_argv_fingerprint_is_stable_and_tells_processes_apart returns None on Linux CI

3 participants