{"record":{"id":"59c6d4d3e6cb8d14","repo":"paperclipai/paperclip","slug":"run-coordinator-reproduced-a-result-before-the-run-recorded","errorCode":null,"errorMessage":"run coordinator reproduced a result before the run recorded one","messagePattern":"run coordinator reproduced a result before the run recorded one","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/adapter-utils/src/acpx-engine/execute.ts","lineNumber":5348,"sourceCode":"        recordDisposition: recordDispositionReport,\n        // The settlement sequence is the one live cleanup owner. It claims the\n        // ledger, releases every settled resource, and returns the final\n        // disposition report. The child stderr flushes after the sync-back on every\n        // settled exit path (it stays null before the run reads the warm entry).\n        settle: async (reason: SettlementReason) => {\n          const cause: SettlementCause | null =\n            reason.kind === \"pre_turn\"\n              ? reason.cause\n              : reason.completion.kind === \"finalized\"\n                ? null\n                : reason.completion.cause;\n          const report = await settleAcpRun(runResourceLedger, cause, settlementSteps);\n          recordDispositionReport(report);\n          if (childStderrState) flushChildStderr(childStderrState);\n        },\n        reproduceResult: async (): Promise<AdapterExecutionResult> => {\n          if (!capturedResult) {\n            throw new Error(\"run coordinator reproduced a result before the run recorded one\");\n          }\n          clearTimeout(stopTimer);\n          let providerExited = false;\n          const providerPid = processIdentitySink?.latest?.pid;\n          if (ctx.signal?.aborted && providerPid && !prepared.processSessionBridge) {\n            for (let attempt = 0; attempt < 40; attempt += 1) {\n              providerExited = capturedProcessExited(processIdentitySink.localProcess);\n              if (providerExited || !forcedStop) break;\n              await new Promise((resolve) => setTimeout(resolve, 25));\n            }\n          }\n          // A forced process exit can reject ACP close after the OS has already\n          // confirmed termination. Acknowledge Stop, but never grant replay.\n          if (ctx.signal?.aborted && providerExited && (runtimeStopConfirmed || forcedStop)) {\n            capturedResult = {\n              ...capturedResult,\n              ...(safeInterruptedSession && !forcedStop && !(\"workspaceRestoreFailure\" in workspaceRestoreFailureField)\n                ? { executionRecovery: { kind: \"interrupted\", providerStopped: true, sessionPreserved: true, actionOutcomes: \"settled\" },","sourceCodeStart":5330,"sourceCodeEnd":5366,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/packages/adapter-utils/src/acpx-engine/execute.ts#L5330-L5366","documentation":"Internal invariant violation in the acpx run-coordinator settlement path: the coordinator produced (reproduced) a final turn result while the run's event ledger had not yet recorded any result — results may only be reproduced from an already-recorded entry. This is a fail-fast ordering bug detector (settlement/sync-back racing ahead of the run record), not an expected operational condition; hitting it indicates coordinator state-machine corruption.","triggerScenarios":"Thrown at packages/adapter-utils/src/acpx-engine/execute.ts:5348 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the settlement sequence: the settle() path must read the warm entry only after the run recorded its result.","Check for a code path that calls result reproduction before appendRunEvent/record of the result (ordering regression).","Capture the run's heartbeat_run_events ledger to confirm no result row exists and report the ordering bug with the trace."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}