#!/usr/bin/env node /** * Maintainer utility: emit a mirror-drive experiment plan/hints JSON. * Non-destructive: this script does not mutate Corestores. * * Usage: * node scripts/mirror-drive-experiment.mjs --source-key [--mirror-key ] [--aux 2] */ import process from 'node:process' function arg(name, def = '') { const i = process.argv.indexOf(name) if (i === -1 || i + 1 >= process.argv.length) return def return String(process.argv[i + 1] || '') } const sourceKey = arg('--source-key', '').trim() const mirrorKey = arg('--mirror-key', '').trim() const aux = Math.max(0, Number.parseInt(arg('--aux', '0'), 10) || 0) if (!/^[a-f0-9]{64}$/i.test(sourceKey)) { console.error( 'mirror-drive-experiment: --source-key must be a 64-hex Hyperdrive key' ) process.exit(2) } const out = { schema: 1, tool: 'mirror-drive-experiment', sourceKeyHex: sourceKey.toLowerCase(), mirrorKeyHex: /^[a-f0-9]{64}$/i.test(mirrorKey) ? mirrorKey.toLowerCase() : '', auxiliaryCountHint: aux, envHints: { BARE_OS_MIRROR_READ_KEY: /^[a-f0-9]{64}$/i.test(mirrorKey) ? mirrorKey.toLowerCase() : sourceKey.toLowerCase(), BARE_OS_MIRROR_DRIVE_COMPOSITION_HINT_JSON: JSON.stringify({ schema: 1, mirrorDrivePattern: 'single-primary-plus-aux', auxiliaryCountHint: aux, sourceKeyHex: sourceKey.toLowerCase() }) }, note: 'Local experiment hints only; apply env vars manually when launching booter/seeder.' } process.stdout.write(JSON.stringify(out, null, 2) + '\n')