✅ gremlins: portable gate test and same-second delta-note test

This commit is contained in:
2026-10-16 21:57:08 +02:00
parent 4d8af024ff
commit 2257e89537
@@ -1521,9 +1521,14 @@ class GateTests(Base):
def test_closed_gate_on_existing_registry(self):
"""A1: a registry made with the gate open; with it closed, nothing launches and no job
entry is written; the tick launches no ping (it reads nothing)."""
code, out, _ = self.init()
self.assertEqual(code, 0, out)
entry is written; the tick launches no ping (it reads nothing).
The registry is made with the override env set, so the gate is open on any host (on a
supported one the env is ignored); the env is gone again before the gate is closed."""
with mock.patch.dict(os.environ, {gremlins.UNSUPPORTED_OK_ENV: "1"}):
self.assertIsNone(gremlins.platform_gate())
code, out, _ = self.init()
self.assertEqual(code, 0, out)
self.assertNotIn(gremlins.UNSUPPORTED_OK_ENV, os.environ)
before = gremlins.read_registry(self.state)
brief = os.path.join(self.tmp, "b.md")
with open(brief, "w") as f:
@@ -3813,6 +3818,14 @@ class LaunchTests(LaunchBase):
note = os.path.join(self.tmp, "delta-1.md")
with open(note, "w", newline="\n") as f:
f.write("NOTE-MARKER\n" + "d" * 60000 + "\n")
# `trained_at` has whole seconds, so a note written in the same second as a training's or
# a rebase's end would sit on either side of it by chance: B1's training is moved a minute
# back and the note half a minute back, so B1 predates the note and the rebase below
# (ending now or later) postdates it, on any host speed.
t_note = time.time() - 30
os.utime(note, (t_note, t_note))
self.set_registry(lambda reg: reg["bases"]["B1"].__setitem__("trained_at", gremlins._iso(t_note - 30)))
self.assertLess(gremlins._ts(self.reg()["bases"]["B1"]["trained_at"]), os.path.getmtime(note))
out = self.fake_spawn("B1", "--delta-note", note, brief=named)
self.assertEqual(len(out["reasons"]), 1, out)
self.assertRegex(out["reasons"][0], r"^delta_tokens:\d+$")