From b6c0f874774f577142c1f9185eacd6236e438a18 Mon Sep 17 00:00:00 2001 From: khaliqgant Date: Wed, 30 Sep 2026 03:26:49 -0700 Subject: [PATCH 1/2] fix(sdk): accept a suspended known status in readCompletedStepOutput #590 and #441 merged in the same window: #441 widened RunReport.status to include 'suspended', and #590's reader took the caller's known status as a bare RunStatus, so main no longer typechecks (authored-worker-step.ts:143). A suspended child is not terminal and is judged like one still in flight. Co-Authored-By: Claude Opus 5.5 (1M context) --- packages/sdk/src/authored-step-output.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/sdk/src/authored-step-output.ts b/packages/sdk/src/authored-step-output.ts index e879d2894..7cc5bdb53 100644 --- a/packages/sdk/src/authored-step-output.ts +++ b/packages/sdk/src/authored-step-output.ts @@ -74,7 +74,9 @@ export async function readCompletedStepOutput( stepId: string, journalSteps: AuthoredFlowJournalStep[], context: AuthoredStepContext = {}, - knownStatus?: RunStatus, + // `suspended` (an Event Await boundary, `RunReport.status`) is not terminal: + // it is judged exactly like a run still in flight. + knownStatus?: RunStatus | 'suspended', ): Promise { let entries = await readChildJournal(journal, runId); let completed = terminalCompletion(entries, stepId); From 75afea02be388c5433c290270ead81de185b0ee8 Mon Sep 17 00:00:00 2001 From: khaliqgant Date: Wed, 30 Sep 2026 03:30:21 -0700 Subject: [PATCH 2/2] test(sdk): a suspended known status never short-circuits the terminal check Co-Authored-By: Claude Opus 5.5 (1M context) --- .../authored-step-terminal-completion.test.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/packages/sdk/tests/authored-step-terminal-completion.test.ts b/packages/sdk/tests/authored-step-terminal-completion.test.ts index b74613d72..0bb4a4850 100644 --- a/packages/sdk/tests/authored-step-terminal-completion.test.ts +++ b/packages/sdk/tests/authored-step-terminal-completion.test.ts @@ -252,6 +252,36 @@ describe('readCompletedStepOutput on an adopted gated child whose gate has not s }); }); +describe('readCompletedStepOutput given a suspended known status (#441)', () => { + // `suspended` is the authored root's Event Await boundary (exit 4). It is + // never a terminal verdict: a caller that hands it through must not have a + // producer success read as final. + it('keeps waiting and resolves only once the child run is terminal', async () => { + let polls = 0; + const child = childJournal([started(1), completed(1, 'success', 'step_done', ok)], () => { + polls += 1; + if (polls === 2) { + child.append(runCompleted('success')); + return snapshotOf('completed', { type: 'deterministic', state: 'done' }); + } + return snapshotOf('running', { type: 'deterministic', state: 'runnable' }); + }); + await expect(readCompletedStepOutput(child.journal, 'child-1', 'run-2', [], {}, 'suspended')) + .resolves.toEqual(ok); + expect(polls).toBeGreaterThanOrEqual(2); + expect(child.resumes()).toBe(0); + }); + + it('refuses a producer success while the child is still not terminal', async () => { + const child = childJournal([started(1), completed(1, 'success', 'step_done', ok)], + () => snapshotOf('running', { type: 'deterministic', state: 'runnable' })); + const failure = await readCompletedStepOutput(child.journal, 'child-1', 'run-2', [], {}, 'suspended') + .then(() => undefined, (error: Error & { code?: string }) => error); + expect(failure?.code).toBe('journal_protocol_violation'); + expect(child.resumes()).toBe(0); + }); +}); + describe('waiting on a retry backoff whose wake passes mid-poll', () => { afterEach(() => { vi.restoreAllMocks(); });