{"record":{"id":"525d783912df466e","repo":"paperclipai/paperclip","slug":"acquirelease-occurred-after-release-for-environmen","errorCode":null,"errorMessage":"acquireLease occurred after release for environment ${environmentId}","messagePattern":"acquireLease occurred after release for environment (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/plugins/sdk/src/testing.ts","lineNumber":275,"sourceCode":"  }\n  if (matched.length !== expectedOrder.length) {\n    throw new Error(\n      `Environment event order mismatch.\\nExpected: ${JSON.stringify(expectedOrder)}\\nActual:   ${JSON.stringify(actual)}`,\n    );\n  }\n}\n\n/** Assert that a full lease lifecycle (acquire → release) occurred for an environment. */\nexport function assertLeaseLifecycle(\n  events: EnvironmentEventRecord[],\n  environmentId: string,\n): { acquire: EnvironmentEventRecord; release: EnvironmentEventRecord } {\n  const acquire = events.find((e) => e.type === \"acquireLease\" && e.environmentId === environmentId);\n  const release = events.find((e) => (e.type === \"releaseLease\" || e.type === \"destroyLease\") && e.environmentId === environmentId);\n  if (!acquire) throw new Error(`No acquireLease event found for environment ${environmentId}`);\n  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) {","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/packages/plugins/sdk/src/testing.ts#L257-L293","documentation":"Test-helper assertion in assertLeaseLifecycle: the acquireLease event's timestamp is later than the release/destroy event's timestamp for the same environmentId. The recorded event stream violates the required acquire-before-release ordering, indicating the plugin (or the test clock/events) recorded events out of lifecycle order.","triggerScenarios":"Thrown at packages/plugins/sdk/src/testing.ts:275 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix lifecycle ordering so acquireLease happens before release."],"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"}