{"record":{"id":"e61fdd500af71c85","repo":"affaan-m/ECC","slug":"final-verification-failed","errorCode":"FINAL_VERIFICATION_FAILED","errorMessage":"Could not verify destination-only ${CURRENT_PLUGIN_ID} state after source cleanup.","messagePattern":"Could not verify destination-only (.+?) state after source cleanup\\.","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/claude-scope-migration.js","lineNumber":238,"sourceCode":"    } catch {\n      // Preserve the safest known two-scope state in the structured recovery.\n    }\n    throw migrationError(\n      'SOURCE_UNINSTALL_FAILED',\n      `The destination is installed, but Claude could not remove the ${migration.sourceScope} source scope.`,\n      {\n        phase: 'source-uninstall',\n        observedScopes,\n        recovery: recoveryCommands(migration.sourceScope, destinationScope),\n      }\n    );\n  }\n}\n\nfunction verifyFinalState(run, paths, destinationScope) {\n  const plugins = readPluginInventory(run, paths.projectRoot, 'final-verification');\n  return validateExpectedScopes(plugins, [destinationScope], {\n    code: 'FINAL_VERIFICATION_FAILED',\n    destinationScope,\n    message: `Could not verify destination-only ${CURRENT_PLUGIN_ID} state after source cleanup.`,\n    phase: 'final-verification',\n    recovery: recoveryCommands(null, destinationScope),\n  });\n}\n\nfunction migrateClaudePluginScope(options = {}, dependencies = {}) {\n  if (!VALID_SCOPES.has(options.scope)) {\n    throw migrationError(\n      'INVALID_SCOPE',\n      'Scope migration requires --scope user, project, or local.'\n    );\n  }\n  if (options.hooks !== undefined && !VALID_HOOK_MODES.has(options.hooks)) {\n    throw migrationError('INVALID_HOOK_MODE', `Invalid hook mode: ${options.hooks}`);\n  }\n","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/claude-scope-migration.js#L220-L256","documentation":"After a plugin scope migration removes the plugin from the source scope, verifyFinalState re-reads the plugin inventory and asserts the plugin now exists in the destination scope ONLY. If the final inventory does not match that expectation, it throws FINAL_VERIFICATION_FAILED with a message stating the destination-only state could not be verified, plus recovery commands. This prevents declaring success on a migration that left the system inconsistent.","triggerScenarios":"migrateClaudePluginScope completes source cleanup but the final plugin inventory read shows the plugin missing from the destination scope, still present in the source scope, or the inventory file is unreadable/stale at the final-verification phase.","commonSituations":"Another process (Claude Code itself) rewrote plugin state between cleanup and verification; file locks or sync delays making the freshly written destination config not yet visible to the inventory reader; concurrent migrations racing on the same project root; a partially failed cleanup step earlier in the migration.","solutions":["Run the recoveryCommands included in the error to re-register the plugin in the destination scope","Re-run migrateClaudePluginScope after closing other Claude Code sessions that may hold plugin state","Manually inspect the destination scope's plugin config and the source scope's remnants, then remove duplicates","Retry after any file-sync/lock settles, then confirm only the destination scope lists the plugin"],"exampleFix":"// before: destination config missing the plugin\n{ \"plugins\": [] }\n\n// after (or run the suggested recovery command)\n{ \"plugins\": [{ \"id\": \"everything-claude-code\", \"scope\": \"user\" }] }","handlingStrategy":"retry","validationCode":"// before migrating, confirm no other session holds plugin state:\n// lsof <projectRoot>/.claude/plugins* and ensure destination config lists no conflicting entries","typeGuard":null,"tryCatchPattern":"try { await migrateClaudePluginScope(); } catch (e) { if (e.code === 'FINAL_VERIFICATION_FAILED') { /* run e.recovery commands, then re-run migration */ } else throw e; }","preventionTips":["Close other Claude Code sessions during scope migration to avoid concurrent state writes","Run migrations on a quiescent filesystem (no active sync tools on the project root)","Re-run migration rather than manually editing plugin state when verification fails"],"tags":["migration","verification","plugin-scope"],"backgroundTag":"migration-verification-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}