Make large G-code loading and execution robust

This commit is contained in:
2026-08-30 17:42:54 +08:00
parent 1a92d3b5b8
commit c015709d26
4 changed files with 19 additions and 6 deletions

View File

@@ -45,11 +45,13 @@ export class XyzacCommandLedger extends OperationLedger {
return { status: "reconcile_required", operation_id: operationId, retry_allowed: false, reconciliation };
}
audit({ includeResponses = true } = {}) {
audit({ includeResponses = true, maxEntries = Number.POSITIVE_INFINITY } = {}) {
const exported = super.export();
const pending = this.pending();
const entries = includeResponses ? exported.entries : exported.entries.map((entry) => { const { response, ...summary } = entry; return summary; });
const unsigned = { schema: XYZAC_COMMAND_LEDGER_SCHEMA, operation_schema: LEDGER_SCHEMA, phases: [...LEDGER_PHASES], scope: this.scope, entries, pending_count: pending.length };
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 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) };
}
}