From 8047596419593260ba721cd5d55d49774a9777e5 Mon Sep 17 00:00:00 2001 From: Jason McCartney Date: Wed, 4 Nov 2026 21:59:05 -0700 Subject: [PATCH] Use production leadership timing in Accord integration fixtures --- scripts/accord-proof-fixture.mjs | 13 +++++++++++-- test/accord-install.test.mjs | 21 ++++++++++++++++++++- test/schedule-integration.test.mjs | 2 +- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/scripts/accord-proof-fixture.mjs b/scripts/accord-proof-fixture.mjs index e61f05d8..ab7ac863 100644 --- a/scripts/accord-proof-fixture.mjs +++ b/scripts/accord-proof-fixture.mjs @@ -34,7 +34,9 @@ export async function accordFixture() { mkdirSync(home); initialize(data, { fixtures: true }); install({ home, data, clients: [] }); - const h = { dir, home, data, profile: join(home, '.config/accord/connection.json'), children: [] }; + // Use Accord's production leadership window: a 500ms test-only lease can expire + // while a shared CI runner is busy, correctly terminating the coordinator. + const h = { dir, home, data, profile: join(home, '.config/accord/connection.json'), children: [], leaderMs: 5000 }; const launch = async (command, args) => { const p = fork( fileURLToPath(new URL('../vendor/accord/src/cli.mjs', import.meta.url)), @@ -58,7 +60,14 @@ export async function accordFixture() { h.driver = d.p; h.driverUrl = d.url; h.start = async (port = 0) => { - const s = await launch('serve', ['--port', String(port), '--driver-url', h.driverUrl, '--leader-ms', '500']); + const s = await launch('serve', [ + '--port', + String(port), + '--driver-url', + h.driverUrl, + '--leader-ms', + String(h.leaderMs) + ]); h.server = s.p; h.url = s.url; }; diff --git a/test/accord-install.test.mjs b/test/accord-install.test.mjs index 40b538fb..cdd7e80f 100644 --- a/test/accord-install.test.mjs +++ b/test/accord-install.test.mjs @@ -2,7 +2,7 @@ import test from 'node:test'; import assert from 'node:assert/strict'; import fs from 'node:fs/promises'; import path from 'node:path'; -import { accordFixture } from './accord-fixture.mjs'; +import { accordFixture, delay } from './accord-fixture.mjs'; import { ensureLloomAccord } from '../src/accord-install.mjs'; test('LLooM reuses an installed authority and retires its duplicate skill without losing edits', async (t) => { const h = await accordFixture(); @@ -28,3 +28,22 @@ test('LLooM reuses an installed authority and retires its duplicate skill withou await ensureLloomAccord({ home: h.home, profilePath: h.profile }); assert.equal((await fs.readdir(archive)).length, 1); }); + +test( + 'authority reuse tolerates a scheduling pause within the production leadership window', + { skip: process.platform === 'win32' }, + async (t) => { + const h = await accordFixture(); + t.after(() => h.close()); + h.server.kill('SIGSTOP'); + try { + await delay(800); + } finally { + h.server.kill('SIGCONT'); + } + await delay(200); + const result = await ensureLloomAccord({ home: h.home, profilePath: h.profile }); + assert(result.reused); + assert.equal(h.server.exitCode, null); + } +); diff --git a/test/schedule-integration.test.mjs b/test/schedule-integration.test.mjs index dab19a75..de517f9e 100644 --- a/test/schedule-integration.test.mjs +++ b/test/schedule-integration.test.mjs @@ -153,7 +153,7 @@ for (const crash of ['coordinator', 'gateway']) if (crash === 'coordinator') { await stop(h.server, 'SIGKILL'); await assert.rejects(readHostMemory(), 'unavailable telemetry must fail admission closed'); - await delay(650); + await delay(h.leaderMs + 150); await h.start(accordPort); } else { await stop(gateway, 'SIGKILL');