Skip to content

test(protocol): the agent clock test's earlier status predates the config it's checked against - #774

Closed
earakely-scale wants to merge 1 commit into
mainfrom
edgararakelyan/clock-test-before-status-predates-config
Closed

earakely-scale wants to merge 1 commit into
mainfrom
edgararakelyan/clock-test-before-status-predates-config

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

What

test_a2a_agent_clock.py::test_what_the_follower_showed_of_its_config_before_never_passes_for_the_new_one[before1] failed CodeBuild's Integration Tests on #761 (assert 200 == 404), unrelated to that PR. It's a timing flake in the test.

Cause. sync_time takes a follower status as this config's only when the status file's st_mtime_ns postdates the config it just wrote (written < since_ns is stale). The test wrote the follower's earlier status and then, a client startup later, had sync_time write the config. On a kernel whose file timestamps advance in coarse ticks (a few milliseconds), the two writes can share an mtime; the [before1] case (same gateway and name, so only the time tells them apart) then took the earlier status for the new config and answered 200. [before0] names another gateway, so it's always stale and never flaked.

Fix. The earlier status is written a second before the config (_status_from_before, os.utime), as a follower's earlier status is. The product code is unchanged.

Verified

  • With the test's earlier status made no older than the config (os.utime to now + 1 s), the unchanged test fails exactly as CodeBuild did, [before1] assert 200 == 404, and [before0] passes: the failure is a status mtime that doesn't predate the config.
  • The fixed file passes (16 tests), and 200 runs of the case on a Linux test host pass. That host's kernel (7.0) stamps files at sub-millisecond resolution (0 of 2000 back-to-back writes shared an mtime), which is why the flake didn't show there; CodeBuild's kernel stamps coarser.
  • Frequency: 1 of the last 200 CodeBuild builds (since 2026-11-16) failed on it.

Not changed

A real follower's status written within one timestamp tick of core's new config, for the same gateway and name, would also count as this config's; it only matters when the follower writes its status in that same tick, and it then reads the new config within a quarter second anyway. Using <= instead would refuse a status the follower writes in the same tick after reading the new config, and sync_time would wait it out, which is worse. Left as is; a config id the follower echoes in its status would settle it, if it ever matters.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

This PR appears safe to merge.

Summary

This PR fixes a timing flake by making the test's earlier follower status clearly older than the new config. Product behavior is unchanged.

  • The agent clock test marks old statuses as older than new configs.

Reviews (1) · Last reviewed commit: "test(protocol): the agent clock test's e..." · Reviewed by Greptile

…nfig it's checked against

The test wrote the follower's earlier status and then had sync_time write the new config, which a status must
postdate (by st_mtime_ns) to count. On a kernel whose file timestamps advance in coarse ticks, the two writes can share
an mtime, and the earlier status of the same gateway and name then passed for the new config: once in CodeBuild's
last 200 runs. The earlier status is now a second older, as a follower's earlier status is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale requested a review from a team as a code owner November 18, 2026 16:37
@earakely-scale

Copy link
Copy Markdown
Collaborator Author

Folded into #761 as bca01e0, since #761's CI is where this flake showed up.

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.

1 participant