From 20336860eb95ecda5b8ccaa90005b79d4ee05db4 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 22 Aug 2026 23:16:29 -0700 Subject: [PATCH] fix(mantis): fence lost Telegram leases without a ten-second delay (#128122) * perf(mantis): fence lost Telegram leases without delay * test(mantis): enforce prompt lost-lease fencing --- scripts/mantis/run-with-lease-fence.sh | 9 ++------- test/scripts/run-with-lease-fence.test.ts | 8 ++++---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/scripts/mantis/run-with-lease-fence.sh b/scripts/mantis/run-with-lease-fence.sh index 6ffef72f3e8b..3f04c7ed0093 100755 --- a/scripts/mantis/run-with-lease-fence.sh +++ b/scripts/mantis/run-with-lease-fence.sh @@ -10,7 +10,7 @@ lost_marker_path="$1" shift 2 # The marker records broker-confirmed loss of the shared-account lease; continuing -# Telegram I/O would violate broker serialization. The <=10s poll window is accepted +# Telegram I/O would violate broker serialization. The <=1s poll window is accepted # against the 20-minute lease TTL. # <&0: a backgrounded command's stdin defaults to /dev/null, which silently # swallowed the piped agent prompt. The explicit redirect keeps the caller's stdin. @@ -48,10 +48,5 @@ while true; do exit 97 fi - for _ in {1..10}; do - sleep 1 - if ! kill -0 "$command_pid" 2>/dev/null; then - command_exit - fi - done + sleep 1 done diff --git a/test/scripts/run-with-lease-fence.test.ts b/test/scripts/run-with-lease-fence.test.ts index 2b47aada5ce4..1f55f9336c53 100644 --- a/test/scripts/run-with-lease-fence.test.ts +++ b/test/scripts/run-with-lease-fence.test.ts @@ -43,13 +43,13 @@ describe("run-with-lease-fence", () => { fs.writeFileSync(lostMarker, "lost\n"); try { - await expect(waitForChildClose(child, 12_000)).resolves.toEqual({ + await expect(waitForChildClose(child)).resolves.toEqual({ code: 97, signal: null, }); - const ticksAfterFence = fs.readFileSync(ticksFile, "utf8"); - await new Promise((resolve) => setTimeout(resolve, 1_200)); - expect(fs.readFileSync(ticksFile, "utf8")).toBe(ticksAfterFence); + expect(() => process.kill(-commandPid, 0)).toThrow( + expect.objectContaining({ code: "ESRCH" }), + ); expect(stderr).toContain("::error::Telegram QA lease lost mid-run; fencing proof"); } finally { if (child.exitCode === null) {