Files
Dune/tools/start-prototype.ts
T
Quintine 8e1cd7b75b Connect Emperor Nexus extra revival with private saved continuation
Add the absent-Emperor Secret Ally alternative returning exactly three eligible forces free in Basic/Advanced base-faction Nexus games. Preserve ordinary force/free-revival allowances and the shared Advanced Fedaykin cap. Keep the action optional and private, consume the physical Nexus once, and validate durable source receipts through later ordinary revival and Ghola. Purchase timing remains pending the earlier uniform winner-payment UX question; partial returns and combined-module interactions remain guarded. No mode or publication gate opens.

Connect private controls, explicit physical elite selection, all four legal AI profiles and a dedicated rules checklist entry. Extend the reusable local prototype writer with genuine twelve-card Nexus setup. Independent review covers rules timing, private projection, physical custody, JSON and production SQLite restore, lost-response replay and competing requests. Seventeen focused effect cases and four prototype-writer cases pass.

Validation: typecheck, lint, 4649 offline tests, production build and 43 HTTP tests passed with unchanged source. Genuine-start Basic and Advanced samples completed in 715 and 263 actions with 19 and 7 periodic JSON restores, respectively, and no Emperor uses. Two explicitly staged continuations completed in 18 and 17 actions with one normal-force Emperor return each. All four had zero rejections and preserved exact Treachery, force, elite and Nexus custody; all fourteen final seat views restored unchanged. They are bounded continuation evidence, not natural full-game acceptance of the effect or AI calibration.

In the conserved staged browser scenario, Advanced Fremen returned three forces including one Fedaykin using the Nexus, then three normal forces using the ordinary allowance. Reserves rose from three to nine, Tanks fell from seven to one, spice stayed three and the physical Nexus was spent once. The inspector was readable, the action notice displayed, and pending/resolved refresh restoration, physical custody and private projection passed.

After the reported power outage, all 733 opening games and original seat/recovery records were preserved (767 after HTTP checks); database integrity and foreign keys passed. All 734 rooms immediately before broad verification remained unchanged. Reused the healthy server without restart, reset or recurring automation.

Verified source tree: fd09a4bc71018cb7ef98c7e25c25dacc495ffed304dbd0cdfa223e539e8fa5e1
2026-09-14 01:05:11 +10:00

77 lines
2.7 KiB
TypeScript

import { DatabaseSync } from 'node:sqlite';
import { writeFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { parseArgs } from 'node:util';
import { captureSavedGames } from './saved-game-verification';
import { isPrototypeProfile, startPrototypeRoom } from './prototype-room';
import { sourceSnapshot } from './verification';
async function main() {
const { values } = parseArgs({
options: {
db: { type: 'string' },
profile: { type: 'string', default: 'ix' },
room: { type: 'string' },
version: { type: 'string' },
out: { type: 'string' },
help: { type: 'boolean' },
},
});
if (values.help) {
console.log(
'Usage: node --import tsx tools/start-prototype.ts --profile ix|discovery|leader-skills|factions|nexus --db PATH --room CODE --version NUMBER --out /private/new-directory\nStarts only a fresh ready lobby for the selected development prototype. Nexus enables the existing private Nexus setup. Factions supports selected expansion factions without optional modules; the separate Ecaz Treachery variant stays disabled. Backs up all rooms first, preserves sessions and existing games, and rejects stale versions. Normal game-start and publication gates remain closed.',
);
return;
}
if (
!isPrototypeProfile(values.profile) ||
!values.db ||
!values.room ||
!values.out ||
!/^\d+$/.test(values.version ?? '')
)
throw new Error(
'Provide --db, --room, --version and a new private --out directory.',
);
const root = fileURLToPath(new URL('../', import.meta.url));
const version = Number(values.version),
source = sourceSnapshot(root);
const snapshot = await captureSavedGames(root, values.db, values.out, true);
if (
!snapshot.rooms.some(
(room) => room.code === values.room && room.version === version,
)
)
throw new Error('The requested lobby version is absent from the backup.');
const db = new DatabaseSync(values.db);
try {
const result = startPrototypeRoom(db, values.room, version, values.profile);
writeFileSync(
resolve(values.out, 'prototype.json'),
JSON.stringify(
{
format: 1,
startedAt: new Date().toISOString(),
profile: values.profile,
source,
beforeVersion: version,
...result,
},
null,
2,
) + '\n',
{ flag: 'wx', mode: 0o600 },
);
console.log(JSON.stringify(result));
} finally {
db.close();
}
}
main().catch((error: unknown) => {
console.error(
error instanceof Error ? error.message : 'Prototype start failed.',
);
process.exitCode = 1;
});