{"record":{"id":"ec6c637a7c8acdf4","repo":"Yeachan-Heo/oh-my-codex","slug":"native-hook-transaction-committed-but-staged-delet","errorCode":null,"errorMessage":"Native hook transaction committed but staged deletion cleanup failed during finalization: ${error instanceof Error ? error.message : String(error)}","messagePattern":"Native hook transaction committed but staged deletion cleanup failed during finalization: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/cli/setup.ts","lineNumber":2086,"sourceCode":"\t\tawait cleanupNativeHookTransactionStagedDeletions(\n\t\t\tapplied,\n\t\t\tancestorPrecondition,\n\t\t\ttracker,\n\t\t\tpreconditions,\n\t\t);\n\t\tinjectNativeHookTransactionFailure(\n\t\t\t\"after_staged_cleanup\",\n\t\t\tartifacts[artifacts.length - 1],\n\t\t);\n\t\tawait assertUnmutatedNativeHookTransactionPreconditions(preconditions, applied);\n\t\tawait assertNativeHookTransactionAncestorPrecondition(ancestorPrecondition);\n\t\tawait assertAppliedNativeHookTransactionSnapshots(applied);\n\t} catch (error) {\n\t\tif (\n\t\t\tstagedCleanupStarted &&\n\t\t\tapplied.some((entry) => entry.stagedDeletionCleaned)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Native hook transaction committed but staged deletion cleanup failed during finalization: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\tconst rollbackFailures: string[] = [];\n\t\tconst restored: AppliedNativeHookTransactionArtifact[] = [];\n\t\ttry {\n\t\t\tawait assertNativeHookTransactionRollbackState(applied);\n\t\t} catch (rollbackError) {\n\t\t\trollbackFailures.push(\n\t\t\t\t`recovery preflight: ${rollbackError instanceof Error ? rollbackError.message : String(rollbackError)}`,\n\t\t\t);\n\t\t}\n\t\tif (rollbackFailures.length === 0) {\n\t\t\tfor (const entry of [...applied].reverse()) {\n\t\t\t\ttry {\n\t\t\t\t\tawait assertNativeHookTransactionRollbackState(applied);\n\t\t\t\t\tawait restoreNativeHookTransactionArtifact(\n\t\t\t\t\t\tentry,","sourceCodeStart":2068,"sourceCodeEnd":2104,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/setup.ts#L2068-L2104","documentation":"After a native hook transaction commits and staged-deletion cleanup has already run for at least one artifact, a later finalization failure cannot be safely rolled back (cleanup already deleted the pre-states). This error surfaces that the commit stands but finalization did not complete, wrapping the underlying error.","triggerScenarios":"assertAppliedNativeHookTransactionSnapshots (or another finalization step) throws after stagedCleanupStarted and some entries have stagedDeletionCleaned set.","commonSituations":"Post-commit verification racing external file edits, or fault injection after the no-rollback point in tests.","solutions":["Treat the transaction as committed; do NOT attempt manual rollback of already-cleaned artifacts","Read the wrapped error message to find the finalization step that failed and address it","Re-run setup to converge to the desired end state","Check that no external process modified hook files during finalization"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await tx.finalize(); } catch (e) { if (e instanceof Error && e.message.includes(\"committed but staged deletion cleanup failed\")) { /* treat as committed; fix wrapped finalization error; re-run setup */ } else throw e; }","preventionTips":["Do not kill setup mid-finalization","Keep hook files untouched until setup exits","Re-run setup to converge rather than manual rollback"],"tags":["transaction","commit","finalization","cleanup"],"backgroundTag":"transaction-commit-inconsistent","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}