Enforce LinuxCNC WASM authority for XYZAC frontend

This commit is contained in:
2026-09-02 07:43:47 +08:00
parent c60e3a1e8f
commit 6b689fd69e
36 changed files with 514 additions and 210 deletions

View File

@@ -46,11 +46,18 @@ export class XyzacCommandLedger extends OperationLedger {
}
audit({ includeResponses = true, maxEntries = Number.POSITIVE_INFINITY } = {}) {
const exported = super.export();
// High-frequency SIM_STEP responses request only a small audit window.
// OperationLedger.export() clones every historical response before the
// window can be selected, which turns a long run into quadratic browser
// serialization work. The map is insertion ordered by command sequence,
// so select the tail first and clone only the returned entries.
const values = [...this.entries.values()];
const pending = this.pending();
const totalEntries = exported.entries.length;
const windowed = Number.isFinite(maxEntries) && maxEntries >= 0 ? exported.entries.slice(-Math.floor(maxEntries)) : exported.entries;
const entries = includeResponses ? windowed : windowed.map((entry) => { const { response, ...summary } = entry; return summary; });
const totalEntries = values.length;
const windowed = Number.isFinite(maxEntries) && maxEntries >= 0 ? values.slice(-Math.floor(maxEntries)) : values;
const entries = includeResponses
? windowed.map((entry) => structuredClone(entry))
: windowed.map((entry) => { const { response, ...summary } = entry; return structuredClone(summary); });
const unsigned = { schema: XYZAC_COMMAND_LEDGER_SCHEMA, operation_schema: LEDGER_SCHEMA, phases: [...LEDGER_PHASES], scope: this.scope, entries, entry_count: totalEntries, truncated: entries.length < totalEntries, pending_count: pending.length };
return { ...unsigned, state_hash: fnv1a64(unsigned) };
}