feat: require auto-chain action evidence
This commit is contained in:
@@ -98,6 +98,23 @@ function buildProgressEvidence(wrapperResult: any): Record<string, unknown> | nu
|
|||||||
return Object.keys(progressEvidence).length > 0 ? progressEvidence : null;
|
return Object.keys(progressEvidence).length > 0 ? progressEvidence : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildAutoChainDispatchEvidence(wrapperResult: any, progressEvidence: Record<string, unknown> | null): Record<string, unknown> | null {
|
||||||
|
const taskName = typeof progressEvidence?.sessionKey === "string"
|
||||||
|
? progressEvidence.sessionKey.trim()
|
||||||
|
: "";
|
||||||
|
const requiredNextAction = typeof wrapperResult?.requiredNextAction === "string"
|
||||||
|
? wrapperResult.requiredNextAction.trim()
|
||||||
|
: "";
|
||||||
|
|
||||||
|
if (!requiredNextAction || !taskName) return null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
action: requiredNextAction,
|
||||||
|
sessionKey: taskName,
|
||||||
|
dispatched: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function shouldClaimProgression(wrapperResult: any, progressEvidence: Record<string, unknown> | null): boolean {
|
function shouldClaimProgression(wrapperResult: any, progressEvidence: Record<string, unknown> | null): boolean {
|
||||||
if (!wrapperResult || wrapperResult.classification !== "long_task") return false;
|
if (!wrapperResult || wrapperResult.classification !== "long_task") return false;
|
||||||
if (progressEvidence && Object.keys(progressEvidence).length > 0) return true;
|
if (progressEvidence && Object.keys(progressEvidence).length > 0) return true;
|
||||||
@@ -152,11 +169,8 @@ function buildGateLockInput(wrapperResult: any): Record<string, unknown> {
|
|||||||
concreteNextAction: requiredNextAction,
|
concreteNextAction: requiredNextAction,
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
const autoChainDispatchEvidence = progressEvidence && hasConcreteExecutionEvidence
|
const autoChainDispatchEvidence = hasConcreteExecutionEvidence
|
||||||
? {
|
? buildAutoChainDispatchEvidence(wrapperResult, progressEvidence)
|
||||||
sessionKey: typeof progressEvidence.sessionKey === "string" ? progressEvidence.sessionKey : "",
|
|
||||||
concreteNextAction: requiredNextAction,
|
|
||||||
}
|
|
||||||
: null;
|
: null;
|
||||||
const claimedProgression = shouldClaimProgression(wrapperResult, progressEvidence)
|
const claimedProgression = shouldClaimProgression(wrapperResult, progressEvidence)
|
||||||
? "already progressing to the next step in background"
|
? "already progressing to the next step in background"
|
||||||
@@ -184,6 +198,9 @@ function buildGateLockInput(wrapperResult: any): Record<string, unknown> {
|
|||||||
statusSummary: claimedProgression,
|
statusSummary: claimedProgression,
|
||||||
executionEvidence,
|
executionEvidence,
|
||||||
progressEvidence,
|
progressEvidence,
|
||||||
|
autoChainDispatchEvidenceReason: hasConcreteExecutionEvidence && !autoChainDispatchEvidence
|
||||||
|
? "explicit auto-chain next action requires dispatched-action evidence"
|
||||||
|
: "",
|
||||||
progressEvidenceReason,
|
progressEvidenceReason,
|
||||||
sessionKey: typeof progressEvidence?.sessionKey === "string" ? progressEvidence.sessionKey : "",
|
sessionKey: typeof progressEvidence?.sessionKey === "string" ? progressEvidence.sessionKey : "",
|
||||||
runId: typeof progressEvidence?.runId === "string" ? progressEvidence.runId : "",
|
runId: typeof progressEvidence?.runId === "string" ? progressEvidence.runId : "",
|
||||||
|
|||||||
@@ -202,7 +202,12 @@ function hasAutoChainDispatchEvidence(input) {
|
|||||||
const value = getPathValue(input, fieldPath);
|
const value = getPathValue(input, fieldPath);
|
||||||
if (hasNonEmptyString(value)) return true;
|
if (hasNonEmptyString(value)) return true;
|
||||||
if (Array.isArray(value)) return value.length > 0;
|
if (Array.isArray(value)) return value.length > 0;
|
||||||
if (value && typeof value === 'object') return Object.keys(value).length > 0;
|
if (value && typeof value === 'object') {
|
||||||
|
if (typeof value.action === 'string' && value.action.trim().length > 0) return true;
|
||||||
|
if (typeof value.concreteNextAction === 'string' && value.concreteNextAction.trim().length > 0) return true;
|
||||||
|
if (typeof value.dispatched === 'boolean') return value.dispatched;
|
||||||
|
return Object.keys(value).length > 0;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user