{"record":{"id":"411c5ae02a067db3","repo":"stablyai/orca","slug":"artifact-create-recovery-record-does-not-match-its","errorCode":null,"errorMessage":"Artifact create recovery record does not match its storage identity.","messagePattern":"Artifact create recovery record does not match its storage identity\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/artifacts/artifact-create-intent-store.ts","lineNumber":183,"sourceCode":"  ) {\n    throw new Error('Artifact create recovery record has an unsupported format.')\n  }\n  return intent as ArtifactCreateIntent\n}\n\nexport function getArtifactCreateIntent(\n  profileId: string,\n  userDataPath: string,\n  sourceKey: string,\n  scope: ArtifactShareScope\n): ArtifactCreateIntent | null {\n  const path = intentPath(profileId, userDataPath, sourceKey, scope)\n  if (!existsSync(path)) {\n    return null\n  }\n  const intent = readIntent(path)\n  if (intent.sourceKey !== sourceKey || !scopeMatches(intent.scope, scope)) {\n    throw new Error('Artifact create recovery record does not match its storage identity.')\n  }\n  return intent\n}\n\nexport function getOrCreateArtifactCreateIntent(\n  profileId: string,\n  userDataPath: string,\n  sourceKey: string,\n  scope: ArtifactShareScope,\n  idempotencyKey: string,\n  body: ArtifactWriteBody\n): ArtifactCreateIntent {\n  const existing = getArtifactCreateIntent(profileId, userDataPath, sourceKey, scope)\n  if (existing) {\n    return existing\n  }\n  const directory = ensureIntentDirectory(profileId, userDataPath)\n  removeTemporaryIntents(directory)","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/artifacts/artifact-create-intent-store.ts#L165-L201","documentation":"Thrown by getArtifactCreateIntent() after successfully reading an intent: the record's internal sourceKey/scope do not match the (sourceKey, scope) derived from the storage path. This is an integrity guard — an intent file must describe the same artifact it is filed under. A mismatch implies the file was moved, misnamed, or corrupted.","triggerScenarios":"The intent file was copied/renamed to another sourceKey's path; scope was changed in the filename/path layout but the content was not updated; two sourceKeys collided onto the same path; a manual edit changed sourceKey inside the JSON.","commonSituations":"A path-layout migration rewrote intentPath() but did not migrate file contents; a backup restore placed files under wrong keys; a user copied intent files between profiles.","solutions":["Delete the mismatched intent file — it cannot be safely recovered to a different sourceKey/scope.","Re-trigger the share create for the correct (sourceKey, scope) to mint a fresh matching intent.","If migrating path layout, write a one-time migration that re-keys intent contents alongside file renames."],"exampleFix":"// before\n// file at sourceKey='A' path contains sourceKey='B' -> throws on recovery\n\n// after\n// delete the mismatched file; recovery for 'A' returns null and the share is re-created cleanly","handlingStrategy":"validation","validationCode":"import { getArtifactCreateIntent } from '...'\n\ntry {\n  const intent = getArtifactCreateIntent(profileId, userDataPath, sourceKey, scope)\n} catch (e) {\n  if ((e as Error).message === 'Artifact create recovery record does not match its storage identity.') {\n    // file mislabeled — cannot safely re-key; abandon + re-share\n    await quarantineIntentFile(intentPath(profileId, userDataPath, sourceKey, scope))\n    return null\n  }\n  throw e\n}","typeGuard":"function intentMatchesIdentity(intent: { sourceKey: string; scope: unknown }, sourceKey: string, scope: unknown): boolean {\n  return intent.sourceKey === sourceKey && scopeMatches(intent.scope as any, scope as any)\n}","tryCatchPattern":"try {\n  return getArtifactCreateIntent(profileId, userDataPath, sourceKey, scope)\n} catch (e) {\n  if ((e as Error).message === 'Artifact create recovery record does not match its storage identity.') {\n    await quarantineIntentFile(intentPath(profileId, userDataPath, sourceKey, scope))\n    return null\n  }\n  throw e\n}","preventionTips":["When changing the intentPath() layout, migrate file contents' sourceKey/scope in lockstep.","Never copy/move intent files between sourceKey paths.","Add an integrity unit test that writes then reads intents across the path-mapping surface."],"tags":["artifacts","recovery","integrity","intent-store"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}