import { IS_MAINNET } from '../shared/network.ts'; import { ADDITIONAL_MARKET_FEE } from '../shared/market.ts'; import { assertLaunchAllowed, launchManifest } from './launch.ts'; import { marketConfig } from './market/store.ts'; export type LaunchCheck = { id: string; status: 'pass' | 'blocked' | 'unverified'; detail: string }; /** Read-only local assessment. Never opens a ledger, starts PoW, contacts peers, or sets approvals. * Configured approvals cannot resolve findings that require new code or independent evidence. */ export function launchPreflight(env: NodeJS.ProcessEnv = process.env, now = Date.now()) { const checks: LaunchCheck[] = [{ id: 'network-selection', status: IS_MAINNET ? 'pass' : 'blocked', detail: IS_MAINNET ? 'Separate mainnet candidate selected.' : 'Testnet selected; this is not a production profile.' }]; try { marketConfig(env); checks.push({ id: 'mock-payment-boundary', status: 'pass', detail: 'Only mock payments are supported; market configuration is valid.' }); } catch { checks.push({ id: 'mock-payment-boundary', status: 'blocked', detail: 'Invalid market configuration or unsupported live payment mode. No secret values are included in this report.' }); } if (IS_MAINNET) { try { assertLaunchAllowed(env, now); checks.push({ id: 'operator-startup-gates', status: 'pass', detail: 'Local startup gates satisfied; this does not establish production readiness or peer independence.' }); } catch (error) { checks.push({ id: 'operator-startup-gates', status: 'blocked', detail: error instanceof Error ? error.message : 'Startup gate failed.' }); } } checks.push( { id: 'public-node-resource-controls', status: 'blocked', detail: 'Stage-1 global RPC budgets, bounded pages/client history and read caching exist. In-memory DAG growth, full-history UI/reconciliation and production-scale load/capacity evidence remain unresolved.' }, { id: 'consensus-launch-calibration', status: 'blocked', detail: 'Initial RandomX difficulty, retarget behavior, final genesis and economic security have not been calibrated and independently reviewed for production.' }, { id: 'wallet-key-protection', status: 'blocked', detail: 'Browser signing keys remain extractable and persist unencrypted in IndexedDB; production wallet policy and recovery review are required.' }, { id: 'live-market-settlement', status: 'blocked', detail: 'No live SHKeeper adapter or reviewed payout/refund/reorg system exists. Mock payment cannot constitute real payment for valuable cards.' }, { id: 'release-security-review', status: 'unverified', detail: 'Independent consensus/application review and release-specific dependency/native/container scans require external evidence; an operator environment flag is not evidence.' }, { id: 'deployment-rehearsal', status: 'unverified', detail: 'Verify real HTTPS endpoints, proxy/IP limits, independent peers and miners, alerts, incident response and backup/restore on the intended hosts.' }, { id: 'fee-recipient-control', status: 'unverified', detail: 'Confirm the fixed public XMR fee address, checksum and recipient control out of band before any future live payout. No keys or proof are requested here.' }, ); return { ...launchManifest(), assessedAt: new Date(now).toISOString(), productionReady: false, decision: 'NO-GO', scope: 'Local code/configuration preflight; not an independent audit or launch approval.', additionalFee: { ...ADDITIONAL_MARKET_FEE }, checks }; }