From 4475d379132b4fb7237750f8cb7008fb4e005415 Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Wed, 18 Nov 2026 08:37:16 -0800 Subject: [PATCH] test(protocol): the agent clock test's earlier status predates the config 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 --- .../agentenv-protocol/tests/test_a2a_agent_clock.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/agentenv-protocol/tests/test_a2a_agent_clock.py b/packages/agentenv-protocol/tests/test_a2a_agent_clock.py index b23e5192f..f59285e2b 100644 --- a/packages/agentenv-protocol/tests/test_a2a_agent_clock.py +++ b/packages/agentenv-protocol/tests/test_a2a_agent_clock.py @@ -45,6 +45,14 @@ def _status(image, **status) -> None: (image / "status.json").write_text(json.dumps(status)) +def _status_from_before(image, **status) -> None: + """A status the follower wrote for an earlier config, a second before this one: a file's mtime on Linux moves in + ticks of a few milliseconds, so a config written right after a status can share its mtime.""" + _status(image, **status) + before = time.time_ns() - 1_000_000_000 + os.utime(image / "status.json", ns=(before, before)) + + def _follows_the_next_config(image, **status) -> threading.Thread: """A follower that, as the real one, writes its status once it reads a config other than the one it had.""" config = image / "follower.json" @@ -140,7 +148,7 @@ def test_a_zone_that_isnt_one_is_refused(image): {"url": "http://gw/clock/watch", "name": "agent-solver"}, # this one, under the token the config replaced ]) def test_what_the_follower_showed_of_its_config_before_never_passes_for_the_new_one(image, before): - _status(image, connected=True, version="b:3", armed=True, **before) + _status_from_before(image, connected=True, version="b:3", armed=True, **before) with _app() as client: answer = client.post("/ext/clock/sync-time", json=REQUEST)