fix: require minimum continuity dispatch receipt
This commit is contained in:
@@ -3,6 +3,23 @@ import fs from 'node:fs';
|
||||
|
||||
const LEGAL_TERMINAL_STATES = new Set(['waiting_user', 'blocked', 'pending_verification']);
|
||||
|
||||
function isNonEmptyString(value) {
|
||||
return typeof value === 'string' && value.trim().length > 0;
|
||||
}
|
||||
|
||||
function isObject(value) {
|
||||
return value != null && typeof value === 'object' && !Array.isArray(value);
|
||||
}
|
||||
|
||||
function hasValidDispatchReceipt(receipt) {
|
||||
if (!isObject(receipt)) return false;
|
||||
if (!isNonEmptyString(receipt.planId)) return false;
|
||||
if (!isNonEmptyString(receipt.currentTask)) return false;
|
||||
if (!isObject(receipt.nextDerivedAction)) return false;
|
||||
if (!isNonEmptyString(receipt.dispatchedAt)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function parseArgs(argv) {
|
||||
let inputPath = null;
|
||||
let compact = false;
|
||||
@@ -59,7 +76,7 @@ function evaluateContinuity(payload) {
|
||||
const taskComplete = payload?.taskState === 'complete';
|
||||
const nextAction = payload?.nextDerivedAction ?? payload?.derivedAction ?? null;
|
||||
const nextActionKnown = nextAction != null;
|
||||
const hasDispatchReceipt = payload?.dispatchReceipt != null;
|
||||
const hasDispatchReceipt = hasValidDispatchReceipt(payload?.dispatchReceipt ?? null);
|
||||
const closureState = payload?.replyClosureState ?? null;
|
||||
const isLegalTerminalState = LEGAL_TERMINAL_STATES.has(closureState);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user