Make machine configuration authoritative and restore native checkpoints exactly

This commit is contained in:
2026-09-18 09:09:41 +08:00
parent 6a69511276
commit 4a568f1f4c
94 changed files with 10882 additions and 301 deletions

View File

@@ -46,6 +46,20 @@ await handleWorkerMessage(session, { ...base, kind: "LOAD_WORKSPACE", seq: 2, op
assert.deepEqual(lastAccepted.payload.recovery_checkpoint, checkpoint);
assert.equal(accepted, 2);
assert.equal((await loadUiState({ contextId, key: "xyzac-trt-power-off" })).status, "verified");
session.machineDefinition = { id: "xyzbc-trt" };
const bcCheckpoint = { ...checkpoint, state_hash: "bc-test" };
await handleWorkerMessage(session, { ...base, kind: "POWER", seq: 3, operation_id: "bc-off", payload: { active: false, checkpoint: bcCheckpoint } });
assert.equal((await loadUiState({ contextId, key: "xyzbc-trt-power-off" })).state.checkpoint.state_hash, "bc-test");
assert.equal((await loadUiState({ contextId, key: "xyzac-trt-power-off" })).state.checkpoint.state_hash, "test");
await handleWorkerMessage(session, { ...base, kind: "LOAD_WORKSPACE", seq: 4, operation_id: "reload", payload: { root_path: "/workspace" } });
assert.equal(lastAccepted.payload.recovery_checkpoint, undefined, "active-session configuration reload must not inject old cached state");
delete session.machineDefinition;
session.core = {};
session.validateRecoveryGeometry = () => { throw new Error("sim_program_checkpoint_build_mismatch"); };
const incompatible = await handleWorkerMessage(session, { ...base, kind: "LOAD_WORKSPACE", seq: 5, operation_id: "incompatible", payload: { root_path: "/workspace", configuration: { entrypoint: "linuxcnc/configs/sim/axis/vismach/5axis/table-rotary-tilting/xyzac-trt.ini" } } });
assert.equal(lastAccepted.payload.recovery_checkpoint, undefined);
assert.equal(incompatible.payload.recovery_persistence.status, "ignored");
assert.equal(incompatible.payload.recovery_persistence.code, "sim_program_checkpoint_build_mismatch");
if (previousNavigator === undefined) delete globalThis.navigator;
else Object.defineProperty(globalThis, "navigator", { configurable: true, value: previousNavigator });