fix(release): stabilize config restart QA

This commit is contained in:
Peter Steinberger
2026-05-22 15:53:31 +01:00
parent e842869003
commit cc91ff04cc
3 changed files with 52 additions and 0 deletions

View File

@@ -66,6 +66,9 @@ steps:
- ref: env
- Capability flip
- ref: sessionKey
- set: setupStartIndex
value:
expr: state.getSnapshot().messages.length
- try:
actions:
- call: patchConfig
@@ -92,6 +95,15 @@ steps:
expr: config.setupPrompt
timeoutMs:
expr: liveTurnTimeoutMs(env, 30000)
- call: waitForOutboundMessage
args:
- ref: state
- lambda:
params: [candidate]
expr: "candidate.conversation.id === 'qa-operator' && String(candidate.text ?? '').includes('Protocol note')"
- expr: liveTurnTimeoutMs(env, 30000)
- sinceIndex:
ref: setupStartIndex
- call: readEffectiveTools
saveAs: beforeTools
args:

View File

@@ -1,3 +1,4 @@
import fsSync from "node:fs";
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
@@ -763,6 +764,35 @@ describe("acquireSessionWriteLock", () => {
}
});
it("retries when a reported stale same-process lock disappears before recovery", async () => {
await withTempSessionLockFile(async ({ sessionFile, lockPath }) => {
await fs.writeFile(
lockPath,
JSON.stringify({
pid: process.pid,
createdAt: new Date().toISOString(),
starttime: FAKE_STARTTIME,
}),
"utf8",
);
let resolverCalls = 0;
testing.setProcessStartTimeResolverForTest((pid) => {
if (pid !== process.pid) {
return null;
}
resolverCalls += 1;
if (resolverCalls === 1) {
fsSync.rmSync(lockPath, { force: true });
}
return FAKE_STARTTIME;
});
const lock = await acquireSessionWriteLock({ sessionFile, timeoutMs: 500 });
await lock.release();
expect(resolverCalls).toBeGreaterThan(0);
});
});
it("removes held locks on termination signals", async () => {
const signals = ["SIGINT", "SIGTERM", "SIGQUIT", "SIGABRT"] as const;
const originalKill = process.kill.bind(process);

View File

@@ -560,6 +560,16 @@ async function removeReportedStaleLockIfStillStale(params: {
}): Promise<boolean> {
const nowMs = Date.now();
const payload = await readLockPayload(params.lockPath);
if (payload === null) {
try {
await fs.access(params.lockPath);
} catch (error) {
if ((error as NodeJS.ErrnoException).code === "ENOENT") {
return true;
}
throw error;
}
}
const inspected = inspectLockPayloadForSession({
payload,
staleMs: params.staleMs,