@resolveio/server-lib 22.3.157 → 22.3.159

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,7 +51,9 @@ exports.extractResolveIOAICoderJourneyContractFromMarkdown = extractResolveIOAIC
51
51
  exports.buildResolveIOAICoderWorkflowQaRowsFromJourneyContract = buildResolveIOAICoderWorkflowQaRowsFromJourneyContract;
52
52
  exports.validateResolveIOAICoderJourneyContract = validateResolveIOAICoderJourneyContract;
53
53
  exports.collectResolveIOAICoderJourneyContractIssues = collectResolveIOAICoderJourneyContractIssues;
54
+ exports.evaluateResolveIOAICoderWorkflowProofReadiness = evaluateResolveIOAICoderWorkflowProofReadiness;
54
55
  exports.fingerprintResolveIOAICoderV6Blocker = fingerprintResolveIOAICoderV6Blocker;
56
+ exports.buildResolveIOAICoderV6WorkflowReadiness = buildResolveIOAICoderV6WorkflowReadiness;
55
57
  exports.buildResolveIOAICoderV6Budget = buildResolveIOAICoderV6Budget;
56
58
  exports.initializeResolveIOAICoderV6State = initializeResolveIOAICoderV6State;
57
59
  exports.recordResolveIOAICoderV6Step = recordResolveIOAICoderV6Step;
@@ -268,6 +270,58 @@ function buildWorkflowStepId(step, index) {
268
270
  || cleanField(step, ['label', 'title', 'visible_cta'], 120).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '')
269
271
  || "step-".concat(index + 1);
270
272
  }
273
+ function normalizeWorkflowProofKind(source, fallbackText) {
274
+ if (fallbackText === void 0) { fallbackText = ''; }
275
+ var explicit = cleanField(source, ['proof_kind', 'proofKind', 'coverage', 'type', 'kind'], 120).toLowerCase().replace(/[\s-]+/g, '_');
276
+ if (explicit) {
277
+ return explicit;
278
+ }
279
+ var text = cleanText([
280
+ fallbackText,
281
+ concatFields(source, ['id', 'step_id', 'stepId', 'action', 'browser_steps', 'expected_dom_or_data_proof', 'proof', 'expected_result', 'viewport'], 700)
282
+ ].filter(Boolean).join(' '), 1800).toLowerCase();
283
+ if (/\b(mobile|390x844|viewport)\b/.test(text)) {
284
+ return 'mobile';
285
+ }
286
+ if (/\b(export|report|pdf|download)\b/.test(text)) {
287
+ return 'report_export';
288
+ }
289
+ if (/\b(complete|saved|save|result|recommendation|calculated|optimized|final)\b/.test(text)) {
290
+ return 'workflow_completion';
291
+ }
292
+ if (/\b(sample|seeded|non[-\s]?empty|kpi|table|chart|record|row)\b/.test(text)) {
293
+ return 'non_empty_data';
294
+ }
295
+ if (/\b(empty|error|recovery|invalid)\b/.test(text)) {
296
+ return 'recovery';
297
+ }
298
+ if (/\b(hub|dashboard|command center|next up|queue)\b/.test(text)) {
299
+ return 'hub_action';
300
+ }
301
+ return 'business_workflow';
302
+ }
303
+ function buildWorkflowQaRequiredArtifacts(source, proofKind) {
304
+ var explicit = cleanList(readField(source, ['required_artifacts', 'requiredArtifacts', 'proof_artifacts', 'artifact_expectation', 'artifacts_required']), 12, 180);
305
+ var defaultsByKind = {
306
+ hub_action: ['hub screenshot or DOM snapshot', 'next action state proof'],
307
+ workflow_completion: ['before/action/after trace', 'saved or calculated output proof', 'business assertion artifact'],
308
+ report_export: ['generated report/export artifact', 'export control proof', 'saved output row proof'],
309
+ non_empty_data: ['seeded data snapshot', 'non-empty KPI/table/chart proof'],
310
+ mobile: ['mobile viewport screenshot or trace', 'responsive workflow action proof'],
311
+ recovery: ['empty/error state screenshot or trace', 'recovery action proof'],
312
+ business_workflow: ['browser trace or screenshot', 'DOM/data assertion artifact']
313
+ };
314
+ return Array.from(new Set(__spreadArray(__spreadArray([], __read(explicit), false), __read((defaultsByKind[proofKind] || defaultsByKind.business_workflow)), false))).slice(0, 16);
315
+ }
316
+ function buildWorkflowQaStateTransition(source, fallback) {
317
+ if (fallback === void 0) { fallback = {}; }
318
+ return {
319
+ before: cleanField(source, ['before', 'setup_state', 'initial_state'], 700) || fallback.expectedState,
320
+ action: cleanField(source, ['action', 'browser_steps', 'visible_cta', 'cta'], 700) || fallback.action,
321
+ after: cleanField(source, ['after', 'expected_state', 'expected_result', 'expected_dom_or_data_proof', 'proof'], 700) || fallback.assertion || fallback.expectedState,
322
+ assertion: cleanField(source, ['assertion', 'expected_dom_or_data_proof', 'proof', 'expected_result'], 700) || fallback.assertion
323
+ };
324
+ }
271
325
  function buildResolveIOAICoderWorkflowQaRowsFromJourneyContract(input) {
272
326
  var contract = typeof input === 'string'
273
327
  ? extractResolveIOAICoderJourneyContractFromMarkdown(input)
@@ -289,17 +343,14 @@ function buildResolveIOAICoderWorkflowQaRowsFromJourneyContract(input) {
289
343
  if (!route && !action && !assertionText) {
290
344
  return;
291
345
  }
292
- rows.push({
293
- index: cleanNumber(readField(assertion, ['index', 'order'])) || index + 1,
294
- workflowId: cleanField(assertion, ['workflow_id', 'workflowId'], 160) || workflowId,
295
- stepId: cleanField(assertion, ['step_id', 'stepId', 'id'], 160) || "qa-".concat(index + 1),
346
+ var proofKind = normalizeWorkflowProofKind(assertion);
347
+ var rowBase = {
296
348
  route: route || undefined,
297
349
  action: action || undefined,
298
350
  assertion: assertionText || undefined,
299
- expectedState: expectedState || undefined,
300
- status: cleanField(assertion, ['status'], 120) || undefined,
301
- artifactPaths: cleanList(readField(assertion, ['artifact_paths', 'artifactPaths']), 20, 500)
302
- });
351
+ expectedState: expectedState || undefined
352
+ };
353
+ rows.push(__assign(__assign({ index: cleanNumber(readField(assertion, ['index', 'order'])) || index + 1, workflowId: cleanField(assertion, ['workflow_id', 'workflowId'], 160) || workflowId, stepId: cleanField(assertion, ['step_id', 'stepId', 'id'], 160) || "qa-".concat(index + 1) }, rowBase), { expectedOutput: cleanField(assertion, ['expected_output', 'expectedOutput', 'saved_output', 'calculated_output', 'report_output'], 700) || expectedState || assertionText || undefined, proofKind: proofKind, acceptanceGate: 'aiqa_business_assertion', requiredArtifacts: buildWorkflowQaRequiredArtifacts(assertion, proofKind), stateTransition: buildWorkflowQaStateTransition(assertion, rowBase), status: cleanField(assertion, ['status'], 120) || undefined, artifactPaths: cleanList(readField(assertion, ['artifact_paths', 'artifactPaths']), 20, 500) }));
303
354
  });
304
355
  if (rows.length) {
305
356
  return rows.slice(0, 80);
@@ -308,17 +359,14 @@ function buildResolveIOAICoderWorkflowQaRowsFromJourneyContract(input) {
308
359
  if (!step || typeof step !== 'object' || Array.isArray(step)) {
309
360
  return;
310
361
  }
311
- rows.push({
312
- index: index + 1,
313
- workflowId: workflowId,
314
- stepId: buildWorkflowStepId(step, index),
362
+ var proofKind = normalizeWorkflowProofKind(step, normalizeWorkflowStepPosition(step, index, workflow.length));
363
+ var rowBase = {
315
364
  route: cleanField(step, ['route'], 240) || undefined,
316
365
  action: cleanField(step, ['visible_cta', 'action', 'cta'], 500) || undefined,
317
366
  assertion: cleanField(step, ['success_confirmation', 'expected_state_transition', 'final_result'], 700) || undefined,
318
- expectedState: cleanField(step, ['expected_state_transition', 'success_confirmation', 'final_result'], 500) || undefined,
319
- status: undefined,
320
- artifactPaths: []
321
- });
367
+ expectedState: cleanField(step, ['expected_state_transition', 'success_confirmation', 'final_result'], 500) || undefined
368
+ };
369
+ rows.push(__assign(__assign({ index: index + 1, workflowId: workflowId, stepId: buildWorkflowStepId(step, index) }, rowBase), { expectedOutput: cleanField(step, ['final_result', 'saved_exported_reported_result', 'completion_result', 'expected_state_transition'], 700) || rowBase.expectedState || rowBase.assertion, proofKind: proofKind, acceptanceGate: 'aiqa_business_assertion', requiredArtifacts: buildWorkflowQaRequiredArtifacts(step, proofKind), stateTransition: buildWorkflowQaStateTransition(step, rowBase), status: undefined, artifactPaths: [] }));
322
370
  void workflow;
323
371
  });
324
372
  return rows.slice(0, 80);
@@ -689,6 +737,20 @@ function cleanWorkflowQaRows(values, limit) {
689
737
  action: cleanText(value.action, 500) || undefined,
690
738
  assertion: cleanText(value.assertion, 700) || undefined,
691
739
  expectedState: cleanText(value.expectedState || value.expected_state, 500) || undefined,
740
+ expectedOutput: cleanText(value.expectedOutput || value.expected_output, 700) || undefined,
741
+ proofKind: cleanText(value.proofKind || value.proof_kind, 120) || undefined,
742
+ acceptanceGate: (value.acceptanceGate || value.acceptance_gate) === 'aiqa_business_assertion'
743
+ ? 'aiqa_business_assertion'
744
+ : undefined,
745
+ requiredArtifacts: cleanList(value.requiredArtifacts || value.required_artifacts, 20, 180),
746
+ stateTransition: value.stateTransition || value.state_transition
747
+ ? {
748
+ before: cleanText((value.stateTransition || value.state_transition).before, 700) || undefined,
749
+ action: cleanText((value.stateTransition || value.state_transition).action, 700) || undefined,
750
+ after: cleanText((value.stateTransition || value.state_transition).after, 700) || undefined,
751
+ assertion: cleanText((value.stateTransition || value.state_transition).assertion, 700) || undefined
752
+ }
753
+ : undefined,
692
754
  status: cleanText(value.status, 120) || undefined,
693
755
  artifactPaths: cleanList(value.artifactPaths || value.artifact_paths, 20, 500)
694
756
  };
@@ -709,6 +771,431 @@ function cleanWorkflowQaRows(values, limit) {
709
771
  }
710
772
  return rows;
711
773
  }
774
+ function statusLooksPassed(value) {
775
+ var normalized = cleanText(value, 120).toLowerCase();
776
+ return !!normalized && /\b(pass|passed|success|succeeded|ok|done|complete|completed|ready|saved|published|deployed)\b/i.test(normalized);
777
+ }
778
+ function statusLooksFailed(value) {
779
+ var normalized = cleanText(value, 160).toLowerCase();
780
+ return !!normalized && /\b(fail|failed|error|blocked|missing|empty|stale|skipped|not ready|not_ready|cannot|could not|invalid)\b/i.test(normalized);
781
+ }
782
+ function normalizeProofKey(value) {
783
+ return cleanText(value, 500).toLowerCase().replace(/[^a-z0-9]+/g, ' ').replace(/\s+/g, ' ').trim();
784
+ }
785
+ function cleanAssertionArtifactPaths(value) {
786
+ return cleanList(value.artifactPaths
787
+ || value.artifact_paths
788
+ || value.artifacts
789
+ || value.screenshots
790
+ || (value.screenshot ? [value.screenshot] : []), 20, 500);
791
+ }
792
+ function normalizeWorkflowProofAssertion(value) {
793
+ var source = value && typeof value === 'object' && !Array.isArray(value) ? value : {};
794
+ return {
795
+ assertion: cleanText(source.assertion || source.name || source.label || source.expected, 1000),
796
+ status: cleanText(source.status || source.outcome || source.result || (source.passed === true ? 'pass' : source.passed === false ? 'fail' : ''), 120),
797
+ workflowId: cleanText(source.workflowId || source.workflow_id || source.workflow || source.workflowName || source.workflow_name, 200),
798
+ stepId: cleanText(source.stepId || source.step_id || source.id || source.key, 200),
799
+ route: cleanText(source.route || source.path || source.url, 500),
800
+ action: cleanText(source.action || source.browser_steps || source.action_under_test || source.actionUnderTest, 800),
801
+ expected: cleanText(source.expected || source.expected_state || source.expectedState || source.expected_business_state_change || source.expectedBusinessStateChange, 1000),
802
+ observed: cleanText(source.observed || source.actual || source.after || source.after_state || source.afterState, 1000),
803
+ dataProof: cleanText(source.dataProof || source.data_proof || source.domProof || source.dom_proof || source.proof || source.summary, 1400),
804
+ artifactPaths: cleanAssertionArtifactPaths(source),
805
+ metadata: source.metadata && typeof source.metadata === 'object' && !Array.isArray(source.metadata) ? source.metadata : {}
806
+ };
807
+ }
808
+ function workflowRowKey(row, index) {
809
+ return cleanText(row.stepId || row.assertion || row.action || row.route || "workflow-row-".concat(index + 1), 200);
810
+ }
811
+ function sameWorkflowRow(left, right) {
812
+ var leftStep = normalizeProofKey(left.stepId);
813
+ var rightStep = normalizeProofKey(right.stepId);
814
+ if (leftStep && rightStep && leftStep === rightStep) {
815
+ return true;
816
+ }
817
+ var leftRoute = normalizeProofKey(left.route);
818
+ var rightRoute = normalizeProofKey(right.route);
819
+ var leftAction = normalizeProofKey(left.action || left.assertion);
820
+ var rightAction = normalizeProofKey(right.action || right.assertion);
821
+ return !!leftRoute && !!rightRoute && leftRoute === rightRoute && !!leftAction && !!rightAction && (leftAction.includes(rightAction) || rightAction.includes(leftAction));
822
+ }
823
+ function mergeWorkflowQaRows(contractRows, recordedRows) {
824
+ if (!contractRows.length) {
825
+ return recordedRows;
826
+ }
827
+ return contractRows.map(function (contractRow) {
828
+ var recorded = recordedRows.find(function (row) { return sameWorkflowRow(contractRow, row); });
829
+ if (!recorded) {
830
+ return contractRow;
831
+ }
832
+ return __assign(__assign(__assign({}, contractRow), recorded), { workflowId: recorded.workflowId || contractRow.workflowId, stepId: recorded.stepId || contractRow.stepId, route: recorded.route || contractRow.route, action: recorded.action || contractRow.action, assertion: recorded.assertion || contractRow.assertion, expectedState: recorded.expectedState || contractRow.expectedState, expectedOutput: recorded.expectedOutput || contractRow.expectedOutput, proofKind: recorded.proofKind || contractRow.proofKind, acceptanceGate: recorded.acceptanceGate || contractRow.acceptanceGate, requiredArtifacts: Array.from(new Set(__spreadArray(__spreadArray([], __read(cleanList(contractRow.requiredArtifacts, 20, 180)), false), __read(cleanList(recorded.requiredArtifacts, 20, 180)), false))), stateTransition: recorded.stateTransition || contractRow.stateTransition, artifactPaths: Array.from(new Set(__spreadArray(__spreadArray([], __read(cleanList(contractRow.artifactPaths, 20, 500)), false), __read(cleanList(recorded.artifactPaths, 20, 500)), false))) });
833
+ });
834
+ }
835
+ function assertionMatchesWorkflowRow(assertion, row) {
836
+ var metadata = assertion.metadata || {};
837
+ if (metadata.workflowQaRowMatched === true || metadata.journeyContractMatched === true || metadata.aicoderWorkflowProof === true) {
838
+ return true;
839
+ }
840
+ var rowStep = normalizeProofKey(row.stepId);
841
+ var assertionStep = normalizeProofKey(assertion.stepId || metadata.stepId || metadata.step_id);
842
+ if (rowStep && assertionStep && rowStep === assertionStep) {
843
+ return true;
844
+ }
845
+ var rowRoute = normalizeProofKey(row.route);
846
+ var assertionRoute = normalizeProofKey(assertion.route);
847
+ var rowAction = normalizeProofKey(row.action || row.assertion);
848
+ var assertionAction = normalizeProofKey([
849
+ assertion.action,
850
+ assertion.assertion,
851
+ assertion.expected,
852
+ assertion.observed,
853
+ assertion.dataProof
854
+ ].filter(Boolean).join(' '));
855
+ return !!rowRoute
856
+ && !!assertionRoute
857
+ && rowRoute === assertionRoute
858
+ && !!rowAction
859
+ && !!assertionAction
860
+ && (assertionAction.includes(rowAction) || rowAction.includes(assertionAction));
861
+ }
862
+ function workflowRowPassingAssertion(row, assertions) {
863
+ return assertions.find(function (assertion) { return statusLooksPassed(assertion.status) && assertionMatchesWorkflowRow(assertion, row); });
864
+ }
865
+ function workflowAssertionHasOutputProof(assertion) {
866
+ if (!assertion) {
867
+ return false;
868
+ }
869
+ return cleanText(assertion.dataProof, 1000).length >= 8
870
+ || cleanText(assertion.observed, 1000).length >= 8
871
+ || cleanText(assertion.expected, 1000).length >= 8
872
+ || cleanList(assertion.artifactPaths, 20, 500).length > 0;
873
+ }
874
+ function workflowRowArtifactPaths(row, assertion) {
875
+ return Array.from(new Set(__spreadArray(__spreadArray([], __read(cleanList(row.artifactPaths, 20, 500)), false), __read(cleanList(assertion === null || assertion === void 0 ? void 0 : assertion.artifactPaths, 20, 500)), false)));
876
+ }
877
+ function workflowRowRequiresOutputProof(row) {
878
+ var _a, _b;
879
+ var proofKind = cleanText(row.proofKind, 120).toLowerCase();
880
+ if (/^(workflow_completion|report_export|non_empty_data|hub_action|business_workflow)$/.test(proofKind)) {
881
+ return true;
882
+ }
883
+ var text = cleanText([
884
+ row.expectedOutput,
885
+ row.expectedState,
886
+ row.assertion,
887
+ (_a = row.stateTransition) === null || _a === void 0 ? void 0 : _a.after,
888
+ (_b = row.stateTransition) === null || _b === void 0 ? void 0 : _b.assertion
889
+ ].filter(Boolean).join(' '), 1600).toLowerCase();
890
+ return /\b(save|saved|persist|calculated|optimized|recommendation|report|export|result|non[-\s]?empty|record|row|kpi|table|chart)\b/.test(text);
891
+ }
892
+ function workflowRowRequiresMappedBusinessAssertion(row) {
893
+ var _a;
894
+ var proofKind = cleanText(row.proofKind, 120).toLowerCase();
895
+ if (/^(workflow_completion|report_export)$/.test(proofKind)) {
896
+ return true;
897
+ }
898
+ if (/^(mobile|recovery|hub_action|non_empty_data)$/.test(proofKind)) {
899
+ return false;
900
+ }
901
+ var text = cleanText([
902
+ row.stepId,
903
+ row.expectedOutput,
904
+ row.expectedState,
905
+ row.assertion,
906
+ (_a = row.stateTransition) === null || _a === void 0 ? void 0 : _a.after
907
+ ].filter(Boolean).join(' '), 1600).toLowerCase();
908
+ return /\b(workflow[-_\s]?completion|save|saved|persist|calculated|optimized|recommendation|report|export|final result)\b/.test(text);
909
+ }
910
+ function workflowRowWeakProofReason(row, assertions) {
911
+ var assertion = workflowRowPassingAssertion(row, assertions);
912
+ var rowPassed = statusLooksPassed(row.status);
913
+ if (!rowPassed && !assertion) {
914
+ return '';
915
+ }
916
+ var artifactPaths = workflowRowArtifactPaths(row, assertion);
917
+ var requiredArtifacts = cleanList(row.requiredArtifacts, 20, 180);
918
+ if (requiredArtifacts.length && !artifactPaths.length) {
919
+ return "".concat(workflowRowKey(row, 0), " missing required artifact proof: ").concat(requiredArtifacts.slice(0, 3).join(', '));
920
+ }
921
+ if (row.acceptanceGate === 'aiqa_business_assertion' && workflowRowRequiresMappedBusinessAssertion(row) && !assertion) {
922
+ return "".concat(workflowRowKey(row, 0), " requires mapped AIQaBusinessAssertion proof.");
923
+ }
924
+ if (workflowRowRequiresOutputProof(row) && !workflowAssertionHasOutputProof(assertion) && !cleanText(row.expectedOutput || row.expectedState, 700)) {
925
+ return "".concat(workflowRowKey(row, 0), " missing saved/calculated/report output proof.");
926
+ }
927
+ return '';
928
+ }
929
+ function workflowRowHasProof(row, assertions) {
930
+ if (workflowRowWeakProofReason(row, assertions)) {
931
+ return false;
932
+ }
933
+ if (statusLooksPassed(row.status) && cleanList(row.artifactPaths, 20, 500).length) {
934
+ return true;
935
+ }
936
+ return !!workflowRowPassingAssertion(row, assertions);
937
+ }
938
+ function workflowRowFailed(row, assertions) {
939
+ if (statusLooksFailed(row.status)) {
940
+ return true;
941
+ }
942
+ return assertions.some(function (assertion) { return statusLooksFailed(assertion.status) && assertionMatchesWorkflowRow(assertion, row); });
943
+ }
944
+ function collectContractArtifactPaths(rows, assertions, extraPaths) {
945
+ return Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(cleanList(extraPaths, 40, 500)), false), __read(rows.flatMap(function (row) { return cleanList(row.artifactPaths, 20, 500); })), false), __read(assertions.flatMap(function (assertion) { return cleanList(assertion.artifactPaths, 20, 500); })), false))).slice(0, 80);
946
+ }
947
+ function stableProofValue(value) {
948
+ if (Array.isArray(value)) {
949
+ return value.map(stableProofValue);
950
+ }
951
+ if (value && typeof value === 'object') {
952
+ return Object.keys(value)
953
+ .sort()
954
+ .reduce(function (accumulator, key) {
955
+ var cleanKey = cleanText(key, 120);
956
+ if (!cleanKey || /^(evaluatedAt|recordedAt|createdAt|updatedAt|timestamp|durationMs)$/i.test(cleanKey)) {
957
+ return accumulator;
958
+ }
959
+ var nextValue = stableProofValue(value[key]);
960
+ if (nextValue !== undefined && nextValue !== '' && !(Array.isArray(nextValue) && !nextValue.length)) {
961
+ accumulator[cleanKey] = nextValue;
962
+ }
963
+ return accumulator;
964
+ }, {});
965
+ }
966
+ if (typeof value === 'number') {
967
+ return Number.isFinite(value) ? value : undefined;
968
+ }
969
+ if (typeof value === 'boolean') {
970
+ return value;
971
+ }
972
+ return cleanText(value, 2000);
973
+ }
974
+ function fingerprintResolveIOAICoderWorkflowProofPayload(value, prefix) {
975
+ var text = JSON.stringify(stableProofValue(value));
976
+ var hash = 0;
977
+ for (var index = 0; index < text.length; index += 1) {
978
+ hash = ((hash << 5) - hash + text.charCodeAt(index)) | 0;
979
+ }
980
+ return "".concat(prefix, "-").concat(Math.abs(hash).toString(36));
981
+ }
982
+ function normalizeWorkflowProofFingerprintList() {
983
+ var e_11, _a, e_12, _b;
984
+ var values = [];
985
+ for (var _i = 0; _i < arguments.length; _i++) {
986
+ values[_i] = arguments[_i];
987
+ }
988
+ var fingerprints = [];
989
+ try {
990
+ for (var values_3 = __values(values), values_3_1 = values_3.next(); !values_3_1.done; values_3_1 = values_3.next()) {
991
+ var value = values_3_1.value;
992
+ var list = Array.isArray(value) ? value : value ? [value] : [];
993
+ try {
994
+ for (var list_1 = (e_12 = void 0, __values(list)), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) {
995
+ var entry = list_1_1.value;
996
+ var normalized = cleanText(entry, 200);
997
+ if (normalized && !fingerprints.includes(normalized)) {
998
+ fingerprints.push(normalized);
999
+ }
1000
+ }
1001
+ }
1002
+ catch (e_12_1) { e_12 = { error: e_12_1 }; }
1003
+ finally {
1004
+ try {
1005
+ if (list_1_1 && !list_1_1.done && (_b = list_1.return)) _b.call(list_1);
1006
+ }
1007
+ finally { if (e_12) throw e_12.error; }
1008
+ }
1009
+ }
1010
+ }
1011
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
1012
+ finally {
1013
+ try {
1014
+ if (values_3_1 && !values_3_1.done && (_a = values_3.return)) _a.call(values_3);
1015
+ }
1016
+ finally { if (e_11) throw e_11.error; }
1017
+ }
1018
+ return fingerprints.slice(0, 40);
1019
+ }
1020
+ function evaluateResolveIOAICoderWorkflowProofReadiness(input) {
1021
+ var _a, _b;
1022
+ if (input === void 0) { input = {}; }
1023
+ var now = isoNow(input.now);
1024
+ var journeyInput = input.journeyContract !== undefined ? input.journeyContract : input.journeyContractMarkdown;
1025
+ var hasJourneyInput = journeyInput !== undefined && journeyInput !== null && cleanText(journeyInput, 100).length > 0;
1026
+ var journeyValidation = hasJourneyInput
1027
+ ? validateResolveIOAICoderJourneyContract(journeyInput, {
1028
+ requireMarkdownEnvelope: typeof journeyInput === 'string'
1029
+ })
1030
+ : {
1031
+ valid: false,
1032
+ contract: null,
1033
+ issues: [{
1034
+ code: 'missing_contract',
1035
+ path: 'docs/APP_JOURNEY_CONTRACT.md',
1036
+ message: 'docs/APP_JOURNEY_CONTRACT.md is required before workflow proof can accept the app.',
1037
+ severity: 'error'
1038
+ }],
1039
+ workflowQaRows: [],
1040
+ primaryWorkflowId: ''
1041
+ };
1042
+ var recordedRows = cleanWorkflowQaRows(input.workflowQaRows, 120);
1043
+ var rows = mergeWorkflowQaRows(journeyValidation.workflowQaRows, recordedRows);
1044
+ var assertions = asArray(input.businessAssertions).map(normalizeWorkflowProofAssertion).filter(function (assertion) {
1045
+ return assertion.assertion || assertion.route || assertion.action || assertion.dataProof || assertion.status;
1046
+ });
1047
+ var routeOnly = asArray(input.routeProbes).some(function (probe) { return statusLooksPassed((probe === null || probe === void 0 ? void 0 : probe.status) || ((probe === null || probe === void 0 ? void 0 : probe.passed) === true ? 'pass' : '')); })
1048
+ && !assertions.some(function (assertion) { return statusLooksPassed(assertion.status); });
1049
+ var weakProofReasons = rows.map(function (row) { return workflowRowWeakProofReason(row, assertions); }).filter(Boolean);
1050
+ var failedRows = rows.filter(function (row) { return workflowRowFailed(row, assertions); });
1051
+ var passedRows = rows.filter(function (row) { return workflowRowHasProof(row, assertions); });
1052
+ var missingRows = rows.filter(function (row) { return !workflowRowHasProof(row, assertions) && !workflowRowFailed(row, assertions); });
1053
+ var passedAssertions = assertions.filter(function (assertion) { return statusLooksPassed(assertion.status); });
1054
+ var releaseBlockers = [
1055
+ statusLooksFailed(input.deployStatus) ? "deploy=".concat(cleanText(input.deployStatus, 160)) : '',
1056
+ statusLooksFailed(input.publishStatus) ? "publish=".concat(cleanText(input.publishStatus, 160)) : '',
1057
+ statusLooksFailed(input.sampleDataStatus) ? "sample_data=".concat(cleanText(input.sampleDataStatus, 160)) : ''
1058
+ ].filter(Boolean);
1059
+ var hasDataProof = passedAssertions.some(function (assertion) { return cleanText(assertion.dataProof, 1000).length >= 8; });
1060
+ var sampleDataReady = statusLooksPassed(input.sampleDataStatus)
1061
+ || (!statusLooksFailed(input.sampleDataStatus) && hasDataProof);
1062
+ var artifactPaths = collectContractArtifactPaths(rows, assertions, input.artifactPaths);
1063
+ var workflowProofFingerprint = fingerprintResolveIOAICoderWorkflowProofPayload({
1064
+ primaryWorkflowId: journeyValidation.primaryWorkflowId || cleanText((_a = recordedRows[0]) === null || _a === void 0 ? void 0 : _a.workflowId, 160),
1065
+ passedWorkflowRows: passedRows.map(workflowRowKey),
1066
+ failedWorkflowRows: failedRows.map(workflowRowKey),
1067
+ missingWorkflowRows: missingRows.map(workflowRowKey),
1068
+ passedBusinessAssertions: passedAssertions.map(function (assertion) { return ({
1069
+ assertion: assertion.assertion,
1070
+ workflowId: assertion.workflowId,
1071
+ stepId: assertion.stepId,
1072
+ route: assertion.route,
1073
+ action: assertion.action,
1074
+ expected: assertion.expected,
1075
+ observed: assertion.observed,
1076
+ dataProof: assertion.dataProof,
1077
+ artifactPaths: assertion.artifactPaths
1078
+ }); }),
1079
+ sampleDataStatus: input.sampleDataStatus,
1080
+ sampleDataReady: sampleDataReady,
1081
+ artifactPaths: artifactPaths
1082
+ }, 'aicoder-workflow-proof');
1083
+ var artifactFingerprint = fingerprintResolveIOAICoderWorkflowProofPayload({
1084
+ artifactPaths: artifactPaths,
1085
+ businessDataProof: passedAssertions.map(function (assertion) { return ({
1086
+ stepId: assertion.stepId,
1087
+ route: assertion.route,
1088
+ dataProof: assertion.dataProof,
1089
+ observed: assertion.observed,
1090
+ artifactPaths: assertion.artifactPaths
1091
+ }); })
1092
+ }, 'aicoder-workflow-artifacts');
1093
+ var previousWorkflowFingerprints = normalizeWorkflowProofFingerprintList(input.previousWorkflowProofFingerprint, input.previousWorkflowProofFingerprints);
1094
+ var previousArtifactFingerprints = normalizeWorkflowProofFingerprintList(input.previousArtifactFingerprint, input.previousArtifactFingerprints);
1095
+ var proofFreshness = 'unknown';
1096
+ if (!passedAssertions.length && !artifactPaths.length) {
1097
+ proofFreshness = 'missing';
1098
+ }
1099
+ else if (previousWorkflowFingerprints.includes(workflowProofFingerprint)) {
1100
+ proofFreshness = 'same_as_previous';
1101
+ }
1102
+ else if (previousArtifactFingerprints.includes(artifactFingerprint)) {
1103
+ proofFreshness = 'stale_artifact';
1104
+ }
1105
+ else {
1106
+ proofFreshness = 'fresh';
1107
+ }
1108
+ var blockers = [];
1109
+ var status = 'ready';
1110
+ var reason = 'Journey contract and workflow business proof are ready.';
1111
+ var nextAction = 'Proceed to the smallest remaining release gate.';
1112
+ if (!hasJourneyInput) {
1113
+ status = 'missing_journey_contract';
1114
+ blockers.push('Generate and validate docs/APP_JOURNEY_CONTRACT.md before build/acceptance.');
1115
+ reason = 'AICoder cannot accept an app without a journey contract.';
1116
+ nextAction = 'Run journey_contract generation and validation first.';
1117
+ }
1118
+ else if (!journeyValidation.valid) {
1119
+ status = 'journey_invalid';
1120
+ blockers.push.apply(blockers, __spreadArray([], __read(journeyValidation.issues.filter(function (issue) { return issue.severity === 'error'; }).map(function (issue) { return issue.message; }).slice(0, 8)), false));
1121
+ reason = 'Journey contract validation failed.';
1122
+ nextAction = 'Repair docs/APP_JOURNEY_CONTRACT.md before product-code repair.';
1123
+ }
1124
+ else if (routeOnly) {
1125
+ status = 'route_only';
1126
+ blockers.push('Route/browser proof passed, but no workflow business assertion passed.');
1127
+ reason = 'Route-only proof cannot accept an AICoder app.';
1128
+ nextAction = 'Run workflow QA generated from the journey contract.';
1129
+ }
1130
+ else if (!rows.length) {
1131
+ status = 'workflow_qa_missing';
1132
+ blockers.push('No workflow QA rows were generated or recorded from the journey contract.');
1133
+ reason = 'Workflow QA evidence is missing.';
1134
+ nextAction = 'Generate workflow QA rows from journey_contract.qa_assertions.';
1135
+ }
1136
+ else if (weakProofReasons.length) {
1137
+ status = 'business_proof_weak';
1138
+ blockers.push.apply(blockers, __spreadArray([], __read(weakProofReasons.slice(0, 8)), false));
1139
+ reason = 'Workflow QA rows passed without the structured artifacts or mapped output proof required by the Journey Contract.';
1140
+ nextAction = 'Rerun the weak workflow QA rows and record AIQaBusinessAssertion plus required artifacts.';
1141
+ }
1142
+ else if (failedRows.length || missingRows.length) {
1143
+ status = 'workflow_qa_incomplete';
1144
+ blockers.push.apply(blockers, __spreadArray(__spreadArray([], __read(failedRows.map(function (row, index) { return "failed:".concat(workflowRowKey(row, index)); }).slice(0, 8)), false), __read(missingRows.map(function (row, index) { return "missing:".concat(workflowRowKey(row, index)); }).slice(0, 8)), false));
1145
+ reason = 'Not all journey contract workflow QA rows have passed business proof.';
1146
+ nextAction = 'Rerun or repair the incomplete workflow QA rows before publish.';
1147
+ }
1148
+ else if (!passedAssertions.length) {
1149
+ status = input.scorecardPassed === true ? 'business_proof_missing' : 'workflow_qa_incomplete';
1150
+ blockers.push('Workflow rows have no mapped AIQaBusinessAssertion business proof.');
1151
+ reason = input.scorecardPassed === true
1152
+ ? 'Scorecard-only proof is not acceptance.'
1153
+ : 'Workflow business proof is missing.';
1154
+ nextAction = 'Record AIQaBusinessAssertion rows tied to the journey contract.';
1155
+ }
1156
+ else if (releaseBlockers.length) {
1157
+ status = 'release_blocked';
1158
+ blockers.push.apply(blockers, __spreadArray([], __read(releaseBlockers), false));
1159
+ reason = 'Workflow proof passed, but release/deploy/sample-data gates block acceptance.';
1160
+ nextAction = 'Repair only the failed release gate or hotfix artifact before rerunning publish/deploy.';
1161
+ }
1162
+ else if (!sampleDataReady) {
1163
+ status = 'sample_data_missing';
1164
+ blockers.push('No non-empty seeded/sample data proof is available for the workflow.');
1165
+ reason = 'AICoder app proof must include meaningful non-empty data.';
1166
+ nextAction = 'Seed meaningful records and rerun workflow QA against that data.';
1167
+ }
1168
+ else if (proofFreshness === 'same_as_previous' || proofFreshness === 'stale_artifact') {
1169
+ status = 'stale_workflow_proof';
1170
+ blockers.push(proofFreshness === 'same_as_previous'
1171
+ ? 'Workflow business proof fingerprint is unchanged from a prior run.'
1172
+ : 'Workflow proof artifacts are unchanged from a prior run.');
1173
+ reason = 'AICoder workflow proof is stale; repeated evidence cannot advance acceptance.';
1174
+ nextAction = 'Rerun workflow QA from journey_contract.qa_assertions and record fresh AIQaBusinessAssertion artifacts.';
1175
+ }
1176
+ return {
1177
+ ready: status === 'ready',
1178
+ status: status,
1179
+ reason: reason,
1180
+ blockers: blockers,
1181
+ journeyContractValid: journeyValidation.valid,
1182
+ primaryWorkflowId: journeyValidation.primaryWorkflowId || cleanText((_b = recordedRows[0]) === null || _b === void 0 ? void 0 : _b.workflowId, 160),
1183
+ passedWorkflowRows: passedRows.map(workflowRowKey),
1184
+ missingWorkflowRows: missingRows.map(workflowRowKey),
1185
+ failedWorkflowRows: failedRows.map(workflowRowKey),
1186
+ passedBusinessAssertions: passedAssertions.map(function (assertion) { return cleanText(assertion.assertion || assertion.stepId || assertion.route, 300); }).filter(Boolean).slice(0, 40),
1187
+ routeOnly: routeOnly,
1188
+ scorecardOnly: input.scorecardPassed === true && !passedAssertions.length,
1189
+ sampleDataReady: sampleDataReady,
1190
+ releaseBlockers: releaseBlockers,
1191
+ artifactPaths: artifactPaths,
1192
+ workflowProofFingerprint: workflowProofFingerprint,
1193
+ artifactFingerprint: artifactFingerprint,
1194
+ proofFreshness: proofFreshness,
1195
+ nextAction: nextAction,
1196
+ evaluatedAt: now
1197
+ };
1198
+ }
712
1199
  function fingerprintResolveIOAICoderV6Blocker(value) {
713
1200
  var text = cleanText(value, 4000)
714
1201
  .toLowerCase()
@@ -749,6 +1236,183 @@ function classifyResolveIOAICoderV6FailureClass(step) {
749
1236
  }
750
1237
  return 'product_code';
751
1238
  }
1239
+ function aicoderWorkflowReadinessNextCommand(status) {
1240
+ switch (status) {
1241
+ case 'journey_contract_required':
1242
+ return 'Generate and validate docs/APP_JOURNEY_CONTRACT.md before product-code build work.';
1243
+ case 'journey_contract_repair_required':
1244
+ return 'Repair the journey contract until first/next/last workflow QA rows validate.';
1245
+ case 'workflow_build_ready':
1246
+ return 'Build the north-star workflow from the journey contract and seeded data story.';
1247
+ case 'workflow_qa_required':
1248
+ return 'Run workflow QA from journey_contract.qa_assertions and record AIQaBusinessAssertion proof.';
1249
+ case 'workflow_business_proof_ready':
1250
+ return 'Proceed only to release/publish gates; wow UI polish is allowed after business proof.';
1251
+ case 'release_repair_required':
1252
+ return 'Repair the failed publish/deploy/sample-data gate without rebuilding the app shell.';
1253
+ case 'infra_repair_only':
1254
+ return 'Repair Puppeteer, Chrome, Mongo, startup, port, cache, or environment evidence only.';
1255
+ case 'compile_repair_only':
1256
+ return 'Repair compile/build evidence only and rerun the same deterministic build gate.';
1257
+ case 'collect_new_evidence':
1258
+ return 'Collect new evidence for the stuck blocker before another model/code loop.';
1259
+ case 'budget_stopped':
1260
+ return 'Stop autonomous spend and request a bounded human decision.';
1261
+ case 'parked':
1262
+ return 'Park the run until a human chooses the next bounded action.';
1263
+ default:
1264
+ return 'Review workflow evidence before continuing.';
1265
+ }
1266
+ }
1267
+ function aicoderWorkflowReadinessGateFor(status) {
1268
+ switch (status) {
1269
+ case 'journey_contract_required':
1270
+ case 'journey_contract_repair_required':
1271
+ return 'journey_contract';
1272
+ case 'workflow_build_ready':
1273
+ return 'build';
1274
+ case 'workflow_qa_required':
1275
+ case 'workflow_business_proof_ready':
1276
+ return 'workflow_qa';
1277
+ case 'release_repair_required':
1278
+ return 'release';
1279
+ case 'infra_repair_only':
1280
+ return 'infra';
1281
+ case 'compile_repair_only':
1282
+ return 'compile';
1283
+ case 'collect_new_evidence':
1284
+ return 'evidence';
1285
+ case 'budget_stopped':
1286
+ case 'parked':
1287
+ return 'manual';
1288
+ default:
1289
+ return 'manual';
1290
+ }
1291
+ }
1292
+ function buildResolveIOAICoderV6WorkflowReadiness(bundle, context) {
1293
+ var _a, _b;
1294
+ if (context === void 0) { context = {}; }
1295
+ var history = Array.isArray(bundle.aiCoderV6StepHistory) ? bundle.aiCoderV6StepHistory : [];
1296
+ var last = history[history.length - 1];
1297
+ var workflowMemory = bundle.aiCoderV6WorkflowMemory || {};
1298
+ var rows = cleanWorkflowQaRows(workflowMemory.workflowQaRows, 80);
1299
+ var proofArtifacts = cleanList(workflowMemory.businessProofArtifacts, 80, 500);
1300
+ var completedSteps = cleanList(workflowMemory.completedWorkflowSteps, 80, 240);
1301
+ var primaryWorkflowId = cleanText(workflowMemory.primaryWorkflowId || ((_a = rows[0]) === null || _a === void 0 ? void 0 : _a.workflowId), 200);
1302
+ var activeWorkflowStep = cleanText(workflowMemory.activeWorkflowStep || workflowMemory.blockedWorkflowStep || ((_b = rows.find(function (row) { return !statusLooksPassed(row.status); })) === null || _b === void 0 ? void 0 : _b.stepId), 200);
1303
+ var failureClass = cleanText(last === null || last === void 0 ? void 0 : last.failureClass, 120).toLowerCase();
1304
+ var reason = cleanText(context.reason || (last === null || last === void 0 ? void 0 : last.blocker) || (last === null || last === void 0 ? void 0 : last.summary), 1000);
1305
+ var combinedText = "".concat(failureClass, "\n").concat(reason, "\n").concat((last === null || last === void 0 ? void 0 : last.stepType) || '', "\n").concat((last === null || last === void 0 ? void 0 : last.lane) || '').toLowerCase();
1306
+ var compileOnly = failureClass === 'compile'
1307
+ || /\b(compile|typescript|ts[0-9]{3,5}|ng build|cannot find name|module not found)\b/i.test(combinedText);
1308
+ var infraOnly = !compileOnly && (failureClass === 'infra'
1309
+ || /\b(puppeteer|chrome|browser executable|mongo|port|startup|settings\.json|node_modules|cache|lock)\b/i.test(combinedText));
1310
+ var releaseBlocked = failureClass === 'release'
1311
+ || context.nextLane === 'publish'
1312
+ || /\b(release|publish|deploy|cloudfront|artifact|sample data|sample_data)\b/i.test(combinedText);
1313
+ var routeOnlyBlocked = /\b(route only|route-only|route loaded|route_probe|browser route|shell only|shell-only)\b/i.test(combinedText);
1314
+ var sameFailureParked = context.action === 'park'
1315
+ || context.reason === 'aicoder_v6_repeated_no_progress'
1316
+ || context.reason === 'aicoder_v6_ping_pong_no_progress';
1317
+ var budgetStopped = context.action === 'budget_stop' || context.budgetExceeded === true;
1318
+ var workflowQaRowsReady = rows.length > 0;
1319
+ var journeyContractReady = !!cleanText(workflowMemory.journeyContractPath, 500)
1320
+ && (!!primaryWorkflowId || workflowQaRowsReady || completedSteps.length > 0);
1321
+ var passedWorkflowRows = rows.filter(function (row) { return statusLooksPassed(row.status); });
1322
+ var businessProofReady = proofArtifacts.length > 0
1323
+ || passedWorkflowRows.some(function (row) { return cleanList(row.artifactPaths, 10, 500).length > 0; })
1324
+ || completedSteps.length > 0;
1325
+ var status = 'workflow_build_ready';
1326
+ var blockers = [];
1327
+ if (budgetStopped) {
1328
+ status = 'budget_stopped';
1329
+ blockers.push('Budget guard stopped autonomous spend.');
1330
+ }
1331
+ else if (sameFailureParked) {
1332
+ status = 'collect_new_evidence';
1333
+ blockers.push('Same failure class repeated without enough new evidence.');
1334
+ }
1335
+ else if (compileOnly && context.action === 'infra_retry') {
1336
+ status = 'compile_repair_only';
1337
+ blockers.push('Compile/build gate failed; do not count this as product workflow failure.');
1338
+ }
1339
+ else if (infraOnly && context.action === 'infra_retry') {
1340
+ status = 'infra_repair_only';
1341
+ blockers.push('Infra gate failed; repair only environment/browser/startup dependencies.');
1342
+ }
1343
+ else if (failureClass === 'journey' || context.reason === 'aicoder_v6_journey_contract_repair_required') {
1344
+ status = 'journey_contract_repair_required';
1345
+ blockers.push('Journey contract failed validation.');
1346
+ }
1347
+ else if (!journeyContractReady) {
1348
+ status = 'journey_contract_required';
1349
+ blockers.push('Journey contract workflow memory is not ready.');
1350
+ }
1351
+ else if (releaseBlocked || context.reason === 'aicoder_v6_release_repair_required') {
1352
+ status = 'release_repair_required';
1353
+ blockers.push('Release/publish/deploy gate blocks acceptance.');
1354
+ }
1355
+ else if (!workflowQaRowsReady || !businessProofReady || routeOnlyBlocked) {
1356
+ status = 'workflow_qa_required';
1357
+ if (!workflowQaRowsReady) {
1358
+ blockers.push('Workflow QA rows are missing.');
1359
+ }
1360
+ if (!businessProofReady) {
1361
+ blockers.push('AIQaBusinessAssertion proof is missing.');
1362
+ }
1363
+ if (routeOnlyBlocked) {
1364
+ blockers.push('Route/browser proof is not workflow business proof.');
1365
+ }
1366
+ }
1367
+ else if (businessProofReady) {
1368
+ status = 'workflow_business_proof_ready';
1369
+ }
1370
+ var canRunWorkflowQa = journeyContractReady
1371
+ && workflowQaRowsReady
1372
+ && !infraOnly
1373
+ && !compileOnly
1374
+ && !sameFailureParked
1375
+ && !budgetStopped;
1376
+ var canPublish = status === 'workflow_business_proof_ready'
1377
+ && !releaseBlocked
1378
+ && !infraOnly
1379
+ && !compileOnly
1380
+ && !sameFailureParked
1381
+ && !budgetStopped;
1382
+ var canRunProductRepair = journeyContractReady
1383
+ && !infraOnly
1384
+ && !compileOnly
1385
+ && !sameFailureParked
1386
+ && !budgetStopped
1387
+ && status !== 'journey_contract_repair_required'
1388
+ && status !== 'release_repair_required'
1389
+ && status !== 'workflow_business_proof_ready';
1390
+ return {
1391
+ status: status,
1392
+ nextGate: aicoderWorkflowReadinessGateFor(status),
1393
+ nextLane: context.nextLane || (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane,
1394
+ nextStep: context.nextStep || (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep,
1395
+ nextCommand: aicoderWorkflowReadinessNextCommand(status),
1396
+ journeyContractReady: journeyContractReady,
1397
+ workflowQaRowsReady: workflowQaRowsReady,
1398
+ businessProofReady: businessProofReady,
1399
+ routeOnlyBlocked: routeOnlyBlocked,
1400
+ releaseBlocked: releaseBlocked,
1401
+ infraOnly: infraOnly,
1402
+ compileOnly: compileOnly,
1403
+ sameFailureParked: sameFailureParked,
1404
+ canRunProductRepair: canRunProductRepair,
1405
+ canRunWorkflowQa: canRunWorkflowQa,
1406
+ canPublish: canPublish,
1407
+ canPolishWowUi: canPublish,
1408
+ requiresHumanDecision: budgetStopped || sameFailureParked,
1409
+ reason: reason || aicoderWorkflowReadinessNextCommand(status),
1410
+ blockers: blockers.slice(0, 8),
1411
+ primaryWorkflowId: primaryWorkflowId,
1412
+ activeWorkflowStep: activeWorkflowStep,
1413
+ businessProofArtifacts: proofArtifacts
1414
+ };
1415
+ }
752
1416
  function buildResolveIOAICoderV6Budget(existing) {
753
1417
  return {
754
1418
  maxPromptTokensPerNonInitialStep: Number((existing === null || existing === void 0 ? void 0 : existing.maxPromptTokensPerNonInitialStep) || 4000),
@@ -1018,6 +1682,14 @@ function decideResolveIOAICoderV6Continuation(bundle) {
1018
1682
  };
1019
1683
  };
1020
1684
  var managerRecoveryFields = function () { return recoveryFieldsFor(managerDecision.recoveryPlan, managerDecision.recoveryCheckpoint, managerDecision.recoveryEvidenceProbe); };
1685
+ var withWorkflowReadiness = function (decision) { return (__assign(__assign({}, decision), { workflowReadiness: buildResolveIOAICoderV6WorkflowReadiness(bundle, {
1686
+ action: decision.action,
1687
+ reason: decision.reason,
1688
+ nextLane: decision.nextLane,
1689
+ nextStep: decision.nextStep,
1690
+ budgetExceeded: decision.budgetExceeded,
1691
+ repeatedNoProgressCount: decision.repeatedNoProgressCount
1692
+ }) })); };
1021
1693
  var budgetExceeded = (budget.loopCount >= budget.maxLoopsPerRun && !managerDecision.loopBudgetShouldReset)
1022
1694
  || budget.totalPromptTokenEstimate >= budget.maxTotalPromptTokens
1023
1695
  || ((last === null || last === void 0 ? void 0 : last.promptTokenEstimate) || 0) > budget.maxPromptTokensPerNonInitialStep * 2;
@@ -1025,53 +1697,53 @@ function decideResolveIOAICoderV6Continuation(bundle) {
1025
1697
  var recoveryPlan_1 = recoveryPlanFor('budget_stop', 'aicoder_v6_budget_guard', {
1026
1698
  productRepairFailure: false
1027
1699
  });
1028
- return __assign({ action: 'budget_stop', reason: 'aicoder_v6_budget_guard', nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: budgetExceeded }, recoveryFieldsFor(recoveryPlan_1));
1700
+ return withWorkflowReadiness(__assign({ action: 'budget_stop', reason: 'aicoder_v6_budget_guard', nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: budgetExceeded }, recoveryFieldsFor(recoveryPlan_1)));
1029
1701
  }
1030
1702
  if (managerDecision.action === 'park_ping_pong') {
1031
- return __assign({ action: 'park', reason: 'aicoder_v6_ping_pong_no_progress', nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep, repeatedNoProgressCount: managerDecision.pingPongCount, budgetExceeded: false }, managerRecoveryFields());
1703
+ return withWorkflowReadiness(__assign({ action: 'park', reason: 'aicoder_v6_ping_pong_no_progress', nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep, repeatedNoProgressCount: managerDecision.pingPongCount, budgetExceeded: false }, managerRecoveryFields()));
1032
1704
  }
1033
1705
  if (managerDecision.action === 'park_repeated_failure') {
1034
- return __assign({ action: 'park', reason: 'aicoder_v6_repeated_no_progress', nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep, repeatedNoProgressCount: managerDecision.sameFailureCount, budgetExceeded: false }, managerRecoveryFields());
1706
+ return withWorkflowReadiness(__assign({ action: 'park', reason: 'aicoder_v6_repeated_no_progress', nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep, repeatedNoProgressCount: managerDecision.sameFailureCount, budgetExceeded: false }, managerRecoveryFields()));
1035
1707
  }
1036
1708
  if (repeatedNoProgressCount > budget.maxRepeatedNoProgress) {
1037
1709
  var recoveryPlan_2 = recoveryPlanFor('park', 'aicoder_v6_repeated_no_progress', {
1038
1710
  action: 'park_repeated_failure',
1039
1711
  productRepairFailure: !/^(?:infra|compile|release)$/i.test(String((last === null || last === void 0 ? void 0 : last.failureClass) || ''))
1040
1712
  });
1041
- return __assign({ action: 'park', reason: 'aicoder_v6_repeated_no_progress', nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, recoveryFieldsFor(recoveryPlan_2));
1713
+ return withWorkflowReadiness(__assign({ action: 'park', reason: 'aicoder_v6_repeated_no_progress', nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, recoveryFieldsFor(recoveryPlan_2)));
1042
1714
  }
1043
1715
  if (managerDecision.action === 'retry_infra') {
1044
1716
  var compileRepair = managerDecision.recoveryPlan.recoveryClass === 'compile_repair'
1045
1717
  || managerDecision.failureClass === 'compile'
1046
1718
  || (last === null || last === void 0 ? void 0 : last.failureClass) === 'compile';
1047
- return __assign({ action: 'infra_retry', reason: compileRepair ? 'aicoder_v6_compile_repair_required' : 'aicoder_v6_infra_retry', nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, managerRecoveryFields());
1719
+ return withWorkflowReadiness(__assign({ action: 'infra_retry', reason: compileRepair ? 'aicoder_v6_compile_repair_required' : 'aicoder_v6_infra_retry', nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, managerRecoveryFields()));
1048
1720
  }
1049
1721
  if ((last === null || last === void 0 ? void 0 : last.outcome) === 'needs_repair') {
1050
1722
  if (last.failureClass === 'journey') {
1051
- return __assign({ action: 'retry_same_step', reason: 'aicoder_v6_journey_contract_repair_required', nextLane: 'plan', nextStep: last.stepType === 'journey_validation' ? 'journey_contract' : last.stepType, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, managerRecoveryFields());
1723
+ return withWorkflowReadiness(__assign({ action: 'retry_same_step', reason: 'aicoder_v6_journey_contract_repair_required', nextLane: 'plan', nextStep: last.stepType === 'journey_validation' ? 'journey_contract' : last.stepType, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, managerRecoveryFields()));
1052
1724
  }
1053
1725
  if (last.failureClass === 'release') {
1054
- return __assign({ action: 'retry_same_step', reason: 'aicoder_v6_release_repair_required', nextLane: 'publish', nextStep: last.stepType, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, managerRecoveryFields());
1726
+ return withWorkflowReadiness(__assign({ action: 'retry_same_step', reason: 'aicoder_v6_release_repair_required', nextLane: 'publish', nextStep: last.stepType, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, managerRecoveryFields()));
1055
1727
  }
1056
- return __assign({ action: last.lane === 'repair' ? 'retry_same_step' : 'switch_to_repair', reason: 'aicoder_v6_repair_required', nextLane: 'repair', nextStep: 'repair', repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, managerRecoveryFields());
1728
+ return withWorkflowReadiness(__assign({ action: last.lane === 'repair' ? 'retry_same_step' : 'switch_to_repair', reason: 'aicoder_v6_repair_required', nextLane: 'repair', nextStep: 'repair', repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, managerRecoveryFields()));
1057
1729
  }
1058
1730
  if ((last === null || last === void 0 ? void 0 : last.outcome) === 'infra_retry') {
1059
1731
  var recoveryPlan_3 = recoveryPlanFor('infra_retry', 'aicoder_v6_infra_retry', {
1060
1732
  failureClass: 'infra',
1061
1733
  productRepairFailure: false
1062
1734
  });
1063
- return __assign({ action: 'infra_retry', reason: 'aicoder_v6_infra_retry', nextLane: last.lane, nextStep: last.stepType, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, recoveryFieldsFor(recoveryPlan_3));
1735
+ return withWorkflowReadiness(__assign({ action: 'infra_retry', reason: 'aicoder_v6_infra_retry', nextLane: last.lane, nextStep: last.stepType, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, recoveryFieldsFor(recoveryPlan_3)));
1064
1736
  }
1065
1737
  if ((last === null || last === void 0 ? void 0 : last.outcome) === 'ready_to_publish') {
1066
1738
  var recoveryPlan_4 = recoveryPlanFor('ready_to_publish', 'aicoder_v6_ready_to_publish', {
1067
1739
  failureClass: 'release',
1068
1740
  productRepairFailure: false
1069
1741
  });
1070
- return __assign({ action: 'ready_to_publish', reason: 'aicoder_v6_ready_to_publish', nextLane: 'publish', nextStep: 'publish', repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, recoveryFieldsFor(recoveryPlan_4));
1742
+ return withWorkflowReadiness(__assign({ action: 'ready_to_publish', reason: 'aicoder_v6_ready_to_publish', nextLane: 'publish', nextStep: 'publish', repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, recoveryFieldsFor(recoveryPlan_4)));
1071
1743
  }
1072
1744
  var recoveryPlan = managerDecision.recoveryPlan || recoveryPlanFor('continue', 'aicoder_v6_continue');
1073
1745
  var fallbackCheckpoint = managerDecision.recoveryCheckpoint || recoveryCheckpointFor(recoveryPlan);
1074
- return __assign({ action: 'continue', reason: 'aicoder_v6_continue', nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, recoveryFieldsFor(recoveryPlan, fallbackCheckpoint, managerDecision.recoveryEvidenceProbe));
1746
+ return withWorkflowReadiness(__assign({ action: 'continue', reason: 'aicoder_v6_continue', nextLane: (last === null || last === void 0 ? void 0 : last.lane) || bundle.aiCoderV6SupervisorState.activeLane, nextStep: (last === null || last === void 0 ? void 0 : last.stepType) || bundle.aiCoderV6SupervisorState.activeStep, repeatedNoProgressCount: repeatedNoProgressCount, budgetExceeded: false }, recoveryFieldsFor(recoveryPlan, fallbackCheckpoint, managerDecision.recoveryEvidenceProbe)));
1075
1747
  }
1076
1748
  function buildResolveIOAICoderV6DiagnoseFirstPrompt(lines) {
1077
1749
  var _a, _b;