From 4bdbfbfc8a68064914c482fa4eab5ed2913caa2a Mon Sep 17 00:00:00 2001 From: Andrew Peris Date: Mon, 9 Nov 2026 03:44:52 +0000 Subject: [PATCH 1/3] Add subprocess resume crash and contention proof --- docs/o08-durable-resume-decision-packet.md | 30 ++- .../resume-subprocess-worker.mjs | 104 +++++++++ .../resume-subprocess.test.js | 201 ++++++++++++++++++ 3 files changed, 328 insertions(+), 7 deletions(-) create mode 100644 tests/offline-orchestration-prototype/resume-subprocess-worker.mjs create mode 100644 tests/offline-orchestration-prototype/resume-subprocess.test.js diff --git a/docs/o08-durable-resume-decision-packet.md b/docs/o08-durable-resume-decision-packet.md index cc702f4..ef88a97 100644 --- a/docs/o08-durable-resume-decision-packet.md +++ b/docs/o08-durable-resume-decision-packet.md @@ -236,13 +236,29 @@ resume. Context-enabled recovery, live providers, production data, automatic claim takeover, and O09 remain out of scope. O08 stays open pending remaining criteria and independent review. -The slice is bounded to roughly one focused day: persist/link the stable retry -window, validate and classify read-only restart evidence, and add a finite -boundary/corruption matrix. Actual resume integration remains a separate slice -because it must reconstruct job and ledger state and compose current execution -authority, atomic one-shot claim, fresh stable-time checks, durable dispatch -marker, and uncertain-outcome quarantine at every asynchronous boundary. O09 -remains a separate dependency gate. +The implementation and subprocess acceptance evidence above cover the bounded +no-context runtime path. Broader O08 criteria, different storage backends, +context-enabled recovery, production durability guarantees, and O09 remain +separate and unaccepted. + +## Synthetic subprocess restart and crash acceptance — 2026-11-09 + +`resume-subprocess.test.js` seeds only the pinned Comic Manifest fixture in a +private temporary local store, then exercises the runner from fresh Node child +processes. It verifies: a new process completes attempt two with the original +attempt linkage; two concurrent processes contend while one is paused in +preflight and only one dispatches; process exit immediately after claim leaves +a held claim with no takeover; exit after the durable dispatch marker leaves no +mock effect and no replay; and exit after one mock effect plus a durable but +unlinked provider-outcome blob is quarantined without a second mock effect. +The test-only worker records effects in a temporary marker file and all results +are checked against the durable event history. + +These are process-crash and local-filesystem integration tests around the +existing fsync-backed prototype store. They do not simulate power loss, prove +behavior on other filesystems, add a production backend, or provide a generic +exactly-once guarantee. O08 remains open pending its remaining criteria and +review; O09 remains gated separately. ## Finite synthetic restart and crash-point fixtures diff --git a/tests/offline-orchestration-prototype/resume-subprocess-worker.mjs b/tests/offline-orchestration-prototype/resume-subprocess-worker.mjs new file mode 100644 index 0000000..288a2a5 --- /dev/null +++ b/tests/offline-orchestration-prototype/resume-subprocess-worker.mjs @@ -0,0 +1,104 @@ +import { randomUUID } from 'node:crypto'; +import { existsSync, watch, writeFileSync } from 'node:fs'; +import { createSyntheticExecutionAuthorityVerifier, SYNTHETIC_EXECUTION_PURPOSE } from '../../src/offline-orchestration-prototype/execution-authority.js'; +import { createOfflineOrchestrationPrototypeForTest, LocalFilePrototypeStore } from '../../src/offline-orchestration-prototype/testing.js'; +import { MockTextAdapter } from '../../src/prompt-sdk/index.js'; + +const root = process.env.DSS_O08_STORE_ROOT; +const jobId = process.env.DSS_O08_JOB_ID; +const mode = process.env.DSS_O08_WORKER_MODE; +const stableNow = Number(process.env.DSS_O08_STABLE_NOW); +const production = { + production_id: 'urn:uuid:10000000-0000-4000-8000-000000000001', + revision: 1, + identity_sha256: 'sha256:9250217ad23125b0356a9e7002f57a55dacf9d982f069caa403b89f8c6c234dc' +}; +const record = (action, suffix) => ({ + decision_id: `20000000-0000-4000-8000-${suffix.padStart(12, '0')}`, + decision: 'allow', + action, + purpose: SYNTHETIC_EXECUTION_PURPOSE, + production, + not_before: '2026-01-01T00:00:00Z', + review_after: '2027-01-01T00:00:00Z', + expires_at: '2027-02-01T00:00:00Z', + authority_reference: 'https://github.com/DefinitelySecureStudio/platform/issues/109' +}); +const authority = createSyntheticExecutionAuthorityVerifier([record('execute', '1'), record('retry', '2')]); +const store = new LocalFilePrototypeStore(root); + +if (mode === 'crash-after-claim') { + const claimResume = store.claimResume.bind(store); + store.claimResume = value => { + const result = claimResume(value); + if (result.status === 'acquired') process.exit(73); + return result; + }; +} + +if (mode === 'crash-after-dispatch-marker') { + const append = store.append.bind(store); + store.append = event => { + const result = append(event); + if (event.type === 'dispatch-started') process.exit(74); + return result; + }; +} + +let mockAdapterFactory; +if (mode === 'hold-preflight') { + mockAdapterFactory = configuration => new class extends MockTextAdapter { + async describe() { + const ready = process.env.DSS_O08_READY_MARKER; + const release = process.env.DSS_O08_RELEASE_MARKER; + writeFileSync(ready, 'ready\n', { flag: 'wx', mode: 0o600 }); + await new Promise(resolve => { + const watcher = watch(root, () => { + if (existsSync(release)) { watcher.close(); resolve(); } + }); + if (existsSync(release)) { watcher.close(); resolve(); } + }); + return super.describe(); + } + }(configuration); +} +if (mode === 'crash-after-outcome-blob') { + const writeImmutable = store.writeImmutable.bind(store); + store.writeImmutable = (key, bytes) => { + const result = writeImmutable(key, bytes); + if (key.startsWith('provider-outcome:')) process.exit(75); + return result; + }; + mockAdapterFactory = configuration => new class extends MockTextAdapter { + async execute(request, options) { + const result = await super.execute(request, options); + writeFileSync(process.env.DSS_O08_PROVIDER_EFFECT_MARKER, 'one synthetic mock call\n', { flag: 'wx', mode: 0o600 }); + return result; + } + }(configuration); +} + +const monotonicEpoch = `subprocess-${process.pid}`; +const runner = createOfflineOrchestrationPrototypeForTest({ + store, + runtime: { + now: () => Number(process.hrtime.bigint() / 1_000_000n), + epochId: monotonicEpoch, + wallNow: () => Date.parse('2026-11-08T02:40:00Z'), + setTimer: (callback, delay) => setTimeout(callback, delay), + clearTimer: timer => clearTimeout(timer) + }, + idFactory: randomUUID, + executionAuthorityProvider: authority.verifier, + resumeTimeAuthority: { + id: 'studio.synthetic.resume-time-v1', + mode: 'synthetic', + domain_id: 'synthetic-resume-time-v1', + epoch_id: 'subprocess-fixture-epoch', + now: () => stableNow + }, + mockAdapterFactory +}); + +const result = await runner.resume({ jobId, authorizeResume: true }); +process.stdout.write(`${JSON.stringify({ pid: process.pid, result })}\n`); diff --git a/tests/offline-orchestration-prototype/resume-subprocess.test.js b/tests/offline-orchestration-prototype/resume-subprocess.test.js new file mode 100644 index 0000000..078916b --- /dev/null +++ b/tests/offline-orchestration-prototype/resume-subprocess.test.js @@ -0,0 +1,201 @@ +import assert from 'node:assert/strict'; +import { spawn } from 'node:child_process'; +import { existsSync, mkdtempSync, readFileSync, rmSync, watch, writeFileSync } from 'node:fs'; +import { randomUUID } from 'node:crypto'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { readFile } from 'node:fs/promises'; +import test from 'node:test'; +import { createSyntheticExecutionAuthorityVerifier, SYNTHETIC_EXECUTION_PURPOSE } from '../../src/offline-orchestration-prototype/execution-authority.js'; +import { LocalFilePrototypeStore, createOfflineOrchestrationPrototypeForTest } from '../../src/offline-orchestration-prototype/testing.js'; + +const fixture = JSON.parse(await readFile(new URL('../fixtures/comic-manifest-v1.json', import.meta.url), 'utf8')); +const productionSource = JSON.stringify(fixture.production); +const stableStart = Date.parse('2026-11-08T02:40:00Z'); +const workerPath = fileURLToPath(new URL('./resume-subprocess-worker.mjs', import.meta.url)); + +function authority() { + const production = { + production_id: 'urn:uuid:10000000-0000-4000-8000-000000000001', + revision: 1, + identity_sha256: 'sha256:9250217ad23125b0356a9e7002f57a55dacf9d982f069caa403b89f8c6c234dc' + }; + const record = (action, suffix) => ({ + decision_id: `20000000-0000-4000-8000-${suffix.padStart(12, '0')}`, + decision: 'allow', action, purpose: SYNTHETIC_EXECUTION_PURPOSE, production, + not_before: '2026-01-01T00:00:00Z', review_after: '2027-01-01T00:00:00Z', + expires_at: '2027-02-01T00:00:00Z', + authority_reference: 'https://github.com/DefinitelySecureStudio/platform/issues/109' + }); + return createSyntheticExecutionAuthorityVerifier([record('execute', '1'), record('retry', '2')]); +} + +async function seedCandidate(t) { + const root = mkdtempSync(join(tmpdir(), 'dss-o08-subprocess-')); + t.after(() => rmSync(root, { recursive: true, force: true })); + const store = new LocalFilePrototypeStore(root); + const runner = createOfflineOrchestrationPrototypeForTest({ + store, + runtime: { + now: () => 10_000, + epochId: 'parent-seed-process', + wallNow: () => Date.parse('2026-11-08T02:40:00Z'), + setTimer: () => 1, + clearTimer: () => {} + }, + idFactory: randomUUID, + executionAuthorityProvider: authority().verifier, + resumeTimeAuthority: { + id: 'studio.synthetic.resume-time-v1', mode: 'synthetic', + domain_id: 'synthetic-resume-time-v1', epoch_id: 'subprocess-fixture-epoch', + now: () => stableStart + } + }); + const result = await runner.submit({ + productionSource, + noOutputResultVersion: '1.1.0', + mockOutcome: { kind: 'rate-limit', retry_after_ms: 10 } + }); + assert.equal(result.kind, 'terminal'); + assert.equal(result.retry_eligible, true); + const events = store.readEvents(result.job_id); + const window = events.find(event => event.type === 'resume-window'); + assert.equal(window.retry_not_before_at_ms, stableStart + 10); + return { root, jobId: result.job_id, store, window }; +} + +function startWorker(seed, mode = 'normal', extraEnv = {}) { + const child = spawn(process.execPath, [workerPath], { + cwd: process.cwd(), + env: { + ...process.env, + DSS_O08_STORE_ROOT: seed.root, + DSS_O08_JOB_ID: seed.jobId, + DSS_O08_STABLE_NOW: String(seed.window.retry_not_before_at_ms), + DSS_O08_WORKER_MODE: mode, + ...extraEnv + }, + stdio: ['pipe', 'pipe', 'pipe'] + }); + let allStdout = ''; + let stderr = ''; + child.stdout.setEncoding('utf8'); + child.stderr.setEncoding('utf8'); + child.stdout.on('data', chunk => { + allStdout += chunk; + }); + child.stderr.on('data', chunk => { stderr += chunk; }); + const closed = new Promise((resolve, reject) => { + const timer = setTimeout(() => { + child.kill('SIGKILL'); + reject(new Error(`Subprocess timed out. stderr=${stderr}`)); + }, 15_000); + child.once('error', error => { clearTimeout(timer); reject(error); }); + child.once('close', (code, signal) => { + clearTimeout(timer); + resolve({ code, signal, stdout: allStdout, stderr }); + }); + }); + return { + child, + closed + }; +} + +async function waitForFile(path, root, child) { + if (existsSync(path)) return; + await new Promise((resolve, reject) => { + const watcher = watch(root, () => { + if (existsSync(path)) { watcher.close(); clearTimeout(timer); resolve(); } + }); + const timer = setTimeout(() => { + watcher.close(); + child.kill('SIGKILL'); + reject(new Error(`Expected subprocess marker was not created: ${path}`)); + }, 5_000); + }); +} + +async function runWorker(seed, mode = 'normal', extraEnv = {}) { + const worker = startWorker(seed, mode, extraEnv); + const exit = await worker.closed; + let message; + if (exit.code === 0 && exit.stdout.trim()) message = JSON.parse(exit.stdout.trim().split('\n').at(-1)); + else if (exit.code === 0) throw new Error(`Resume worker exited without a result. stderr=${exit.stderr}`); + return { ...exit, pid: message?.pid, result: message?.result }; +} + +test('a separate Node process resumes the pinned synthetic candidate from the durable store', async t => { + const seeded = await seedCandidate(t); + const pidBefore = process.pid; + const child = await runWorker(seeded); + assert.equal(child.code, 0, child.stderr); + assert.notEqual(child.pid, pidBefore); + assert.equal(child.result.kind, 'terminal'); + const events = seeded.store.readEvents(seeded.jobId); + const prepared = events.filter(event => event.type === 'prepared'); + assert.equal(prepared.length, 2); + assert.equal(prepared[1].retry_of_attempt_id, prepared[0].attempt_id); + assert.equal(events.filter(event => event.type === 'dispatch-started').length, 2); +}); + +test('two Node processes contend for one durable claim and only the winner dispatches', async t => { + const seeded = await seedCandidate(t); + const ready = join(seeded.root, 'preflight.ready'); + const release = join(seeded.root, 'preflight.release'); + const winner = startWorker(seeded, 'hold-preflight', { + DSS_O08_READY_MARKER: ready, + DSS_O08_RELEASE_MARKER: release + }); + await waitForFile(ready, seeded.root, winner.child); + const contender = await runWorker(seeded); + assert.equal(contender.code, 0, contender.stderr); + assert.equal(contender.result.status, 'resume-claim-held'); + writeFileSync(release, 'release\n', { flag: 'wx', mode: 0o600 }); + const completed = await winner.closed; + assert.equal(completed.code, 0, completed.stderr); + const result = JSON.parse(completed.stdout.trim().split('\n').at(-1)).result; + assert.equal(result.kind, 'terminal'); + assert.equal(seeded.store.readEvents(seeded.jobId).filter(event => event.type === 'dispatch-started').length, 2); +}); + +test('process death after claim leaves a permanent claim and no takeover', async t => { + const seeded = await seedCandidate(t); + const crashed = await runWorker(seeded, 'crash-after-claim'); + assert.equal(crashed.code, 73); + const restarted = await runWorker(seeded); + assert.equal(restarted.code, 0, restarted.stderr); + assert.equal(restarted.result.status, 'resume-claim-held'); + assert.equal(seeded.store.readEvents(seeded.jobId).filter(event => event.type === 'dispatch-started').length, 1); +}); + +test('process death after durable dispatch marker does not replay the mock call', async t => { + const seeded = await seedCandidate(t); + const effectMarker = join(seeded.root, 'provider-effect.marker'); + const crashed = await runWorker(seeded, 'crash-after-dispatch-marker', { + DSS_O08_PROVIDER_EFFECT_MARKER: effectMarker + }); + assert.equal(crashed.code, 74); + assert.throws(() => readFileSync(effectMarker)); + const restarted = await runWorker(seeded, 'normal', { DSS_O08_PROVIDER_EFFECT_MARKER: effectMarker }); + assert.equal(restarted.code, 0, restarted.stderr); + assert.equal(restarted.result.status, 'resume-not-eligible'); + assert.equal(seeded.store.readEvents(seeded.jobId).filter(event => event.type === 'dispatch-started').length, 2); + assert.throws(() => readFileSync(effectMarker)); +}); + +test('process death after one mock effect and an unlinked outcome blob quarantines without replay', async t => { + const seeded = await seedCandidate(t); + const effectMarker = join(seeded.root, 'provider-effect.marker'); + const crashed = await runWorker(seeded, 'crash-after-outcome-blob', { + DSS_O08_PROVIDER_EFFECT_MARKER: effectMarker + }); + assert.equal(crashed.code, 75); + assert.equal(readFileSync(effectMarker, 'utf8'), 'one synthetic mock call\n'); + const restarted = await runWorker(seeded, 'normal', { DSS_O08_PROVIDER_EFFECT_MARKER: effectMarker }); + assert.equal(restarted.code, 0, restarted.stderr); + assert.equal(restarted.result.status, 'resume-not-eligible'); + assert.equal(seeded.store.readEvents(seeded.jobId).filter(event => event.type === 'dispatch-started').length, 2); + assert.equal(readFileSync(effectMarker, 'utf8'), 'one synthetic mock call\n'); +}); From d184d1bbb6fb441c2f1dfa7aba8b72e05910bdef Mon Sep 17 00:00:00 2001 From: Andrew Peris Date: Mon, 9 Nov 2026 03:46:23 +0000 Subject: [PATCH 2/3] Limit subprocess test environment --- .../resume-subprocess.test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/offline-orchestration-prototype/resume-subprocess.test.js b/tests/offline-orchestration-prototype/resume-subprocess.test.js index 078916b..aeb9eaf 100644 --- a/tests/offline-orchestration-prototype/resume-subprocess.test.js +++ b/tests/offline-orchestration-prototype/resume-subprocess.test.js @@ -66,10 +66,14 @@ async function seedCandidate(t) { } function startWorker(seed, mode = 'normal', extraEnv = {}) { + const childEnvironment = {}; + for (const key of ['PATH', 'TMPDIR', 'TEMP', 'SystemRoot', 'WINDIR', 'LANG', 'LC_ALL']) { + if (process.env[key] !== undefined) childEnvironment[key] = process.env[key]; + } const child = spawn(process.execPath, [workerPath], { cwd: process.cwd(), env: { - ...process.env, + ...childEnvironment, DSS_O08_STORE_ROOT: seed.root, DSS_O08_JOB_ID: seed.jobId, DSS_O08_STABLE_NOW: String(seed.window.retry_not_before_at_ms), From eb20d8a275c8270e5d34fd715f7154b81bd43c01 Mon Sep 17 00:00:00 2001 From: Andrew Peris Date: Mon, 9 Nov 2026 03:52:37 +0000 Subject: [PATCH 3/3] Count subprocess effects across restarts --- docs/o08-durable-resume-decision-packet.md | 5 +- .../resume-subprocess-worker.mjs | 21 ++++--- .../resume-subprocess.test.js | 61 ++++++++++++------- 3 files changed, 54 insertions(+), 33 deletions(-) diff --git a/docs/o08-durable-resume-decision-packet.md b/docs/o08-durable-resume-decision-packet.md index ef88a97..7a95142 100644 --- a/docs/o08-durable-resume-decision-packet.md +++ b/docs/o08-durable-resume-decision-packet.md @@ -251,8 +251,9 @@ preflight and only one dispatches; process exit immediately after claim leaves a held claim with no takeover; exit after the durable dispatch marker leaves no mock effect and no replay; and exit after one mock effect plus a durable but unlinked provider-outcome blob is quarantined without a second mock effect. -The test-only worker records effects in a temporary marker file and all results -are checked against the durable event history. +The test-only worker records every adapter `execute()` entry in a shared +temporary per-execution effect log, including normal restarts and both crash +points; all call counts are checked against the durable event history. These are process-crash and local-filesystem integration tests around the existing fsync-backed prototype store. They do not simulate power loss, prove diff --git a/tests/offline-orchestration-prototype/resume-subprocess-worker.mjs b/tests/offline-orchestration-prototype/resume-subprocess-worker.mjs index 288a2a5..9633659 100644 --- a/tests/offline-orchestration-prototype/resume-subprocess-worker.mjs +++ b/tests/offline-orchestration-prototype/resume-subprocess-worker.mjs @@ -1,5 +1,5 @@ import { randomUUID } from 'node:crypto'; -import { existsSync, watch, writeFileSync } from 'node:fs'; +import { appendFileSync, existsSync, watch, writeFileSync } from 'node:fs'; import { createSyntheticExecutionAuthorityVerifier, SYNTHETIC_EXECUTION_PURPOSE } from '../../src/offline-orchestration-prototype/execution-authority.js'; import { createOfflineOrchestrationPrototypeForTest, LocalFilePrototypeStore } from '../../src/offline-orchestration-prototype/testing.js'; import { MockTextAdapter } from '../../src/prompt-sdk/index.js'; @@ -26,6 +26,14 @@ const record = (action, suffix) => ({ }); const authority = createSyntheticExecutionAuthorityVerifier([record('execute', '1'), record('retry', '2')]); const store = new LocalFilePrototypeStore(root); +const effectLog = process.env.DSS_O08_EFFECT_LOG; + +class ObservedMock extends MockTextAdapter { + async execute(request, options) { + appendFileSync(effectLog, `${process.pid}\n`, { flag: 'a', mode: 0o600 }); + return super.execute(request, options); + } +} if (mode === 'crash-after-claim') { const claimResume = store.claimResume.bind(store); @@ -45,9 +53,9 @@ if (mode === 'crash-after-dispatch-marker') { }; } -let mockAdapterFactory; +let mockAdapterFactory = configuration => new ObservedMock(configuration); if (mode === 'hold-preflight') { - mockAdapterFactory = configuration => new class extends MockTextAdapter { + mockAdapterFactory = configuration => new class extends ObservedMock { async describe() { const ready = process.env.DSS_O08_READY_MARKER; const release = process.env.DSS_O08_RELEASE_MARKER; @@ -69,13 +77,6 @@ if (mode === 'crash-after-outcome-blob') { if (key.startsWith('provider-outcome:')) process.exit(75); return result; }; - mockAdapterFactory = configuration => new class extends MockTextAdapter { - async execute(request, options) { - const result = await super.execute(request, options); - writeFileSync(process.env.DSS_O08_PROVIDER_EFFECT_MARKER, 'one synthetic mock call\n', { flag: 'wx', mode: 0o600 }); - return result; - } - }(configuration); } const monotonicEpoch = `subprocess-${process.pid}`; diff --git a/tests/offline-orchestration-prototype/resume-subprocess.test.js b/tests/offline-orchestration-prototype/resume-subprocess.test.js index aeb9eaf..dce58f7 100644 --- a/tests/offline-orchestration-prototype/resume-subprocess.test.js +++ b/tests/offline-orchestration-prototype/resume-subprocess.test.js @@ -66,6 +66,7 @@ async function seedCandidate(t) { } function startWorker(seed, mode = 'normal', extraEnv = {}) { + const effectLog = extraEnv.DSS_O08_EFFECT_LOG ?? join(seed.root, 'synthetic-effects.log'); const childEnvironment = {}; for (const key of ['PATH', 'TMPDIR', 'TEMP', 'SystemRoot', 'WINDIR', 'LANG', 'LC_ALL']) { if (process.env[key] !== undefined) childEnvironment[key] = process.env[key]; @@ -78,6 +79,7 @@ function startWorker(seed, mode = 'normal', extraEnv = {}) { DSS_O08_JOB_ID: seed.jobId, DSS_O08_STABLE_NOW: String(seed.window.retry_not_before_at_ms), DSS_O08_WORKER_MODE: mode, + DSS_O08_EFFECT_LOG: effectLog, ...extraEnv }, stdio: ['pipe', 'pipe', 'pipe'] @@ -107,17 +109,31 @@ function startWorker(seed, mode = 'normal', extraEnv = {}) { }; } +function effectCount(path) { + if (!existsSync(path)) return 0; + const contents = readFileSync(path, 'utf8').trim(); + return contents ? contents.split('\n').length : 0; +} + async function waitForFile(path, root, child) { if (existsSync(path)) return; await new Promise((resolve, reject) => { - const watcher = watch(root, () => { - if (existsSync(path)) { watcher.close(); clearTimeout(timer); resolve(); } - }); - const timer = setTimeout(() => { - watcher.close(); - child.kill('SIGKILL'); - reject(new Error(`Expected subprocess marker was not created: ${path}`)); - }, 5_000); + let settled = false; + let timer; + let watcher; + const finish = error => { + if (settled) return; + settled = true; + watcher?.close(); + clearTimeout(timer); + if (error) { + child.kill('SIGKILL'); + reject(error); + } else resolve(); + }; + watcher = watch(root, () => { if (existsSync(path)) finish(); }); + timer = setTimeout(() => finish(new Error(`Expected subprocess marker was not created: ${path}`)), 5_000); + if (existsSync(path)) finish(); }); } @@ -142,6 +158,7 @@ test('a separate Node process resumes the pinned synthetic candidate from the du assert.equal(prepared.length, 2); assert.equal(prepared[1].retry_of_attempt_id, prepared[0].attempt_id); assert.equal(events.filter(event => event.type === 'dispatch-started').length, 2); + assert.equal(effectCount(join(seeded.root, 'synthetic-effects.log')), 1); }); test('two Node processes contend for one durable claim and only the winner dispatches', async t => { @@ -150,17 +167,20 @@ test('two Node processes contend for one durable claim and only the winner dispa const release = join(seeded.root, 'preflight.release'); const winner = startWorker(seeded, 'hold-preflight', { DSS_O08_READY_MARKER: ready, - DSS_O08_RELEASE_MARKER: release + DSS_O08_RELEASE_MARKER: release, + DSS_O08_EFFECT_LOG: join(seeded.root, 'synthetic-effects.log') }); await waitForFile(ready, seeded.root, winner.child); const contender = await runWorker(seeded); assert.equal(contender.code, 0, contender.stderr); assert.equal(contender.result.status, 'resume-claim-held'); + assert.equal(effectCount(join(seeded.root, 'synthetic-effects.log')), 0); writeFileSync(release, 'release\n', { flag: 'wx', mode: 0o600 }); const completed = await winner.closed; assert.equal(completed.code, 0, completed.stderr); const result = JSON.parse(completed.stdout.trim().split('\n').at(-1)).result; assert.equal(result.kind, 'terminal'); + assert.equal(effectCount(join(seeded.root, 'synthetic-effects.log')), 1); assert.equal(seeded.store.readEvents(seeded.jobId).filter(event => event.type === 'dispatch-started').length, 2); }); @@ -171,35 +191,34 @@ test('process death after claim leaves a permanent claim and no takeover', async const restarted = await runWorker(seeded); assert.equal(restarted.code, 0, restarted.stderr); assert.equal(restarted.result.status, 'resume-claim-held'); + assert.equal(effectCount(join(seeded.root, 'synthetic-effects.log')), 0); assert.equal(seeded.store.readEvents(seeded.jobId).filter(event => event.type === 'dispatch-started').length, 1); }); test('process death after durable dispatch marker does not replay the mock call', async t => { const seeded = await seedCandidate(t); - const effectMarker = join(seeded.root, 'provider-effect.marker'); - const crashed = await runWorker(seeded, 'crash-after-dispatch-marker', { - DSS_O08_PROVIDER_EFFECT_MARKER: effectMarker - }); + const effectLog = join(seeded.root, 'synthetic-effects.log'); + const crashed = await runWorker(seeded, 'crash-after-dispatch-marker', { DSS_O08_EFFECT_LOG: effectLog }); assert.equal(crashed.code, 74); - assert.throws(() => readFileSync(effectMarker)); - const restarted = await runWorker(seeded, 'normal', { DSS_O08_PROVIDER_EFFECT_MARKER: effectMarker }); + assert.equal(effectCount(effectLog), 0); + const restarted = await runWorker(seeded); assert.equal(restarted.code, 0, restarted.stderr); assert.equal(restarted.result.status, 'resume-not-eligible'); + assert.equal(effectCount(effectLog), 0); assert.equal(seeded.store.readEvents(seeded.jobId).filter(event => event.type === 'dispatch-started').length, 2); - assert.throws(() => readFileSync(effectMarker)); }); test('process death after one mock effect and an unlinked outcome blob quarantines without replay', async t => { const seeded = await seedCandidate(t); - const effectMarker = join(seeded.root, 'provider-effect.marker'); + const effectLog = join(seeded.root, 'synthetic-effects.log'); const crashed = await runWorker(seeded, 'crash-after-outcome-blob', { - DSS_O08_PROVIDER_EFFECT_MARKER: effectMarker + DSS_O08_EFFECT_LOG: effectLog }); assert.equal(crashed.code, 75); - assert.equal(readFileSync(effectMarker, 'utf8'), 'one synthetic mock call\n'); - const restarted = await runWorker(seeded, 'normal', { DSS_O08_PROVIDER_EFFECT_MARKER: effectMarker }); + assert.equal(effectCount(effectLog), 1); + const restarted = await runWorker(seeded); assert.equal(restarted.code, 0, restarted.stderr); assert.equal(restarted.result.status, 'resume-not-eligible'); + assert.equal(effectCount(effectLog), 1); assert.equal(seeded.store.readEvents(seeded.jobId).filter(event => event.type === 'dispatch-started').length, 2); - assert.equal(readFileSync(effectMarker, 'utf8'), 'one synthetic mock call\n'); });