Skip to content

test: sample one clock for both process-age readings - #31307

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
crew/bug-resolve/31067-process-age-flake
Nov 6, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
crew/bug-resolve/31067-process-age-flake

Conversation

@CrysisDeu

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: test_process_age_comes_from_the_process_start_not_the_procfs_inode stops failing at random on the Windows test shard.

The test failed once on an unrelated PR head (run 42140424097, job 127641820986, Backend Tests (Windows) (1)): AssertionError: age 875.3153457641602 disagrees with the helper 874.7974994182587, a 0.518 s gap against a 0.5 s tolerance.

Why it matters

A random red on the Windows shard blocks unrelated PRs and costs a rerun each time.

Not a goal

  • Changing process_age_secs or _pid_age_seconds product code.
  • Loosening the 0.5 s tolerance.

Intended? / Repro

Intended? No. The test comment says the two readings are "of the same clock microseconds apart". On Windows that is not true: _pid_age_seconds (src/kiro_crew/session_pid_tracking.py:88-98 on main @ 722b07e) calls platform_compat.get_process_start_id and then its own time.time(). The test calls it twice (once directly, once via rr.process_age_secs), so each reading samples the clock after its own lookup. On a loaded shard the second lookup took over 0.5 s. macOS has the same shape (line 99-104). Linux dates against /proc/uptime and is not affected.

Repro: the CI log above (PR #30951 head 30d2ea7, which does not touch this code). 27592 passed, this one failed. Not reproduced locally: this host runs no local tests, and the gap needs a loaded Windows runner.

What changed (motivation → approach → change)

Symptom: two age readings of the same process differ by more than 0.5 s. Cause: each reading takes its own time.time() sample after a lookup of variable length. Change: the test freezes session_pid.time at one real sample (the same _FrozenClock seam the Windows age-floor test below it already uses), so both readings share one "now". The tolerance stays tight, so the mutation target (reading the procfs inode's st_ctime instead of the process start) still fails it.

Alternative considered: compare the derived start instants instead of the ages. It lost because it needs a second helper or a recomputation of the FILETIME conversion in the test, which the docstring says the test avoids on purpose.

Backwards compatibility

Compatible: test-only change.

Removes nothing: only a test's clock is pinned.

Tests

test/test_runtime_reconcile.py::test_process_age_comes_from_the_process_start_not_the_procfs_inode now freezes the clock once before both readings.

Proof: not provable -- test-only change

Manual verification

N/A — test-only change; CI's Windows, macOS and Linux shards run it.

Related Issues

Fixes #31067

Sibling sweep

Swept: git grep -n "process_age_secs(mine|_pid_age_seconds(mine|process_age_secs(os.getpid|_pid_age_seconds(os.getpid" -- test/
Siblings: none -- no other test compares two live age readings of the same process

Pattern harvest

Not generalizable: one test compared two independently clocked readings; the other age tests already freeze the clock.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

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

On Windows and macOS each age reading dated the process start against its
own time.time() call, so on a loaded shard the two drifted past the 0.5s
tolerance. Freeze session_pid's clock once so both readings share it.

Fixes #31067
@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners November 6, 2026 09:08
@CrysisDeu
CrysisDeu requested a review from Zedmor November 6, 2026 09:08
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision 7209790ad67f3173de49a3a6b65a612c5bc81c07 ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Does not block merge.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 7209790ad67f3173de49a3a6b65a612c5bc81c07 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 7209790ad67f3173de49a3a6b65a612c5bc81c07 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the test now takes one clock sample for both readings and keeps the 0.5 s tolerance. session_pid's facade mirror carries the patch to session_pid_tracking.time, the same route the Windows age-floor test already relies on.

[DESIGN-REVIEWED] 7209790

Description read

[DESCRIPTION-READ] d204bc3adab9e43beb0e11ba75ee7677cb47955b5eaa8aa20d14392ded32326b

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

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 7209790ad67f3173de49a3a6b65a612c5bc81c07 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 7209790

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 7209790ad67f3173de49a3a6b65a612c5bc81c07 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 7209790ad67f3173de49a3a6b65a612c5bc81c07 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 7209790

Verdict parsed from the review's SHA-scoped output markers for commit 7209790ad67f3173de49a3a6b65a612c5bc81c07.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 7209790ad67f3173de49a3a6b65a612c5bc81c07 false-positive: <reason, 20 to 500 characters>

@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 Nov 6, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 6, 2026 12:09

@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: both process-age readings share one frozen clock sample.

@KiroCrewCaptain
KiroCrewCaptain merged commit f469bcf into main Nov 6, 2026
102 of 111 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the crew/bug-resolve/31067-process-age-flake branch November 6, 2026 12:39
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 6, 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_process_age_comes_from_the_process_start_not_the_procfs_inode on Windows

2 participants