fix(workflow): address ready review findings

This commit is contained in:
pku-xht
2026-08-10 20:56:31 +08:00
parent fff7dfac8e
commit a7ddded2ef
11 changed files with 80 additions and 62 deletions
+7 -2
View File
@@ -289,6 +289,8 @@ export function apply(ctx: Context, config: Config): void {
signal: exec.signal,
})
const recordsRun = exec.parent === undefined
// The shipped worker-thread engine publishes member events from later
// worker messages, after start() returns and this run record is active.
if (recordsRun) recorder.start(parent.session, run)
// Bridge the tool's abort signal to the run: if the parent step is aborted while the
@@ -317,8 +319,11 @@ export function apply(ctx: Context, config: Config): void {
// Keep member listeners alive through disposal: an engine may
// synthesize cancelled member endings while reaching quiescence.
await run.dispose()
/* v8 ignore next -- WorkflowRun.result never rejects by contract, so result is assigned before finally. */
if (recordsRun && result !== undefined) recorder.finish(run.id, result.stopReason)
if (recordsRun) {
/* v8 ignore next -- WorkflowRun.result never rejects by contract, so result is assigned before finally. */
if (result === undefined) throw new Error('workflow run settled without a result')
recorder.finish(run.id, result.stopReason)
}
} finally {
if (recordsRun) recorder.abandon(run.id)
}