[codex] Add runtime lifecycle recovery and live issue visibility (#4419)

This commit is contained in:
Dotta 2026-04-24 15:50:32 -05:00 committed by GitHub
parent 9a8d219949
commit 5a0c1979cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
121 changed files with 9625 additions and 2044 deletions

View file

@ -0,0 +1,30 @@
import { randomUUID } from "node:crypto";
import { afterEach, describe, expect, it, vi } from "vitest";
import { withAgentStartLock } from "../services/agent-start-lock.ts";
describe("heartbeat agent start lock", () => {
afterEach(() => {
vi.useRealTimers();
});
it("does not let a stale start lock freeze later queued-run starts", async () => {
vi.useFakeTimers();
const agentId = randomUUID();
const firstStart = vi.fn(() => new Promise<void>(() => undefined));
const secondStart = vi.fn(async () => "started");
void withAgentStartLock(agentId, firstStart);
await Promise.resolve();
expect(firstStart).toHaveBeenCalledTimes(1);
const secondStartResult = withAgentStartLock(agentId, secondStart);
await Promise.resolve();
expect(secondStart).not.toHaveBeenCalled();
await vi.advanceTimersByTimeAsync(30_000);
await expect(secondStartResult).resolves.toBe("started");
expect(secondStart).toHaveBeenCalledTimes(1);
});
});