Repository navigation
test: sample one clock for both process-age readings - #31307
Conversation
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
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 blocks: the test now takes one clock sample for both readings and keeps the 0.5 s tolerance. [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 |
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: both process-age readings share one frozen clock sample.
Problem / Motivation
Goal:
test_process_age_comes_from_the_process_start_not_the_procfs_inodestops 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
process_age_secsor_pid_age_secondsproduct code.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-98on main @ 722b07e) callsplatform_compat.get_process_start_idand then its owntime.time(). The test calls it twice (once directly, once viarr.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/uptimeand 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 freezessession_pid.timeat one real sample (the same_FrozenClockseam 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'sst_ctimeinstead 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_inodenow 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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.