/** * Test fixture: an on_restore hook in the celilo-mgmt staging shape, minus * everything the real one owns but the staging itself. Copies the artifact's * celilo.db into restore_dir/system/ so the Phase 4 wrapper's * applyStagedSystemFiles has something to swap. */ import { cpSync, existsSync, mkdirSync } from 'node:fs'; import { join } from 'node:path'; import { defineHook } from '@celilo/capabilities'; export default defineHook({ hook: 'on_restore', requires: [], optional: [], handler: async (ctx) => { const restoreDir = (ctx as unknown as { restore_dir: string }).restore_dir; const systemDir = join(restoreDir, 'system'); mkdirSync(systemDir, { recursive: true }); const artifactDb = join(restoreDir, 'celilo.db'); if (existsSync(artifactDb)) { cpSync(artifactDb, join(systemDir, 'celilo.db')); } return { restored_items: 1 }; }, });