{"record":{"id":"9de14af8cb5564f2","repo":"paperclipai/paperclip","slug":"realizeworkspace-occurred-before-acquirelease-for","errorCode":null,"errorMessage":"realizeWorkspace occurred before acquireLease for environment ${environmentId}","messagePattern":"realizeWorkspace occurred before acquireLease for environment (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/sdk/src/testing.ts","lineNumber":291,"sourceCode":"  if (!release) throw new Error(`No releaseLease/destroyLease event found for environment ${environmentId}`);\n  if (acquire.timestamp > release.timestamp) {\n    throw new Error(`acquireLease occurred after release for environment ${environmentId}`);\n  }\n  return { acquire, release };\n}\n\n/** Assert that workspace realization occurred between lease acquire and release. */\nexport function assertWorkspaceRealizationLifecycle(\n  events: EnvironmentEventRecord[],\n  environmentId: string,\n): EnvironmentEventRecord {\n  const lifecycle = assertLeaseLifecycle(events, environmentId);\n  const realize = events.find(\n    (e) => e.type === \"realizeWorkspace\" && e.environmentId === environmentId,\n  );\n  if (!realize) throw new Error(`No realizeWorkspace event found for environment ${environmentId}`);\n  if (realize.timestamp < lifecycle.acquire.timestamp) {\n    throw new Error(`realizeWorkspace occurred before acquireLease for environment ${environmentId}`);\n  }\n  if (realize.timestamp > lifecycle.release.timestamp) {\n    throw new Error(`realizeWorkspace occurred after release for environment ${environmentId}`);\n  }\n  return realize;\n}\n\n/** Assert that an execute call occurred within the lease lifecycle. */\nexport function assertExecutionLifecycle(\n  events: EnvironmentEventRecord[],\n  environmentId: string,\n): EnvironmentEventRecord[] {\n  const lifecycle = assertLeaseLifecycle(events, environmentId);\n  const execEvents = events.filter(\n    (e) => e.type === \"execute\" && e.environmentId === environmentId,\n  );\n  if (execEvents.length === 0) {\n    throw new Error(`No execute events found for environment ${environmentId}`);","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/plugins/sdk/src/testing.ts#L273-L309","documentation":"Test-helper assertion in assertWorkspaceRealizationLifecycle: a realizeWorkspace event exists for the environmentId, but its timestamp precedes the acquireLease event's. The recorded events show workspace realization happening before the lease was acquired, violating the acquire-then-realize ordering the assertion enforces.","triggerScenarios":"Thrown at packages/plugins/sdk/src/testing.ts:291 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix lifecycle ordering so realizeWorkspace happens after acquireLease."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}