import { Store } from '../../src/server/store.mjs'; import { ChangeSetManager } from '../../src/core/workspaces/change-sets.mjs'; const [data, sessionId, setId, phase, direction, ids] = process.argv.slice(2); const store = new Store(data), manager = new ChangeSetManager(store, { faultInjector: (actual, set) => { if (actual !== phase) return; process.stdout.write(JSON.stringify({ phase, setId: set.id, direction }) + '\n'); process.exit(73); } }); const session = store.session(sessionId); if (direction === 'prepare') await manager.prepare(session, JSON.parse(ids)); else { const set = store.owned('change_set', setId, sessionId); if (direction === 'rollback') await manager.rollback(session, setId, set.fingerprint); else await (await manager.start(session, setId, set.fingerprint)).promise; } process.stderr.write('Did not reach crash phase: ' + phase + '\n'); store.close(); process.exit(74);