@promptdriven/runtime-client 1.1.1 → 1.1.3
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.
- package/package.json +1 -1
- package/src/runtime/adaptive-concurrency.mjs +53 -0
- package/src/runtime/agent-guide.mjs +3 -0
- package/src/runtime/agent-judge.mjs +73 -2
- package/src/runtime/contract-refs.mjs +4 -0
- package/src/runtime/index.mjs +37 -0
- package/src/runtime/product-composition.mjs +6 -4
- package/src/runtime/prompt-clauses.mjs +290 -0
- package/src/runtime/run-program.mjs +13 -8
- package/src/runtime/runtime-binding-plan.mjs +116 -15
- package/src/runtime/runtime-bindings.mjs +11 -8
- package/src/runtime/runtime-check-plan.mjs +47 -17
- package/src/runtime/runtime-client.mjs +2033 -282
- package/src/runtime/runtime-markdown.mjs +95 -41
- package/src/runtime/runtime-outcome.mjs +156 -5
- package/src/runtime/runtime-output.mjs +115 -13
- package/src/runtime/runtime-preflight.mjs +1186 -41
- package/src/runtime/try-doors.mjs +105 -23
- package/src/runtime/try-http.mjs +232 -10
- package/src/runtime/try-mcp.mjs +15 -2
|
@@ -74,6 +74,49 @@ function markdownContainerLine(line, containers) {
|
|
|
74
74
|
return { line, matched };
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
const THEMATIC_RE = /^ {0,3}(?:(?:\* *){3,}|(?:- *){3,}|(?:_ *){3,})$/;
|
|
78
|
+
const ITEM_RE = /^ {0,3}([-+*]|[0-9]{1,9}[.)]) +(\S.*)$/;
|
|
79
|
+
const FENCE_START_RE = /^ {0,3}(`{3,}|~{3,})(.*)$/;
|
|
80
|
+
const HTML_START_1_RE = /^ {0,3}<(?:!--|\?|![A-Z]|!\[CDATA\[|(?:pre|script|style|textarea)(?=[\t >]|$))/i;
|
|
81
|
+
const HTML_START_2_RE = /^ {0,3}<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?=[\t >]|\/>|$)/i;
|
|
82
|
+
const QUOTE_OR_HEADING_RE = /^ {0,3}(?:>|#{1,6}(?: |$))/;
|
|
83
|
+
const SETEXT_RE = /^ {0,3}(?:=+|-+) *$/;
|
|
84
|
+
const FENCE_CLOSE_RE = /^ {0,3}(`{3,}|~{3,}) *$/;
|
|
85
|
+
const QUOTE_PREFIX_RE = /^ {0,3}> ?/;
|
|
86
|
+
const LIST_PREFIX_RE = /^( {0,3})([-+*]|[0-9]{1,9}[.)])( +|$)/;
|
|
87
|
+
const COMMENT_START_RE = /^ {0,3}<!--/;
|
|
88
|
+
const DEF_START_RE = /^ {0,3}\[[^\]]+\]:/;
|
|
89
|
+
const HEADING_OR_SETEXT_EQ_RE = /^ {0,3}(?:#{1,6}(?: |$)|=+ *$)/;
|
|
90
|
+
const INDENT_4_RE = /^ {4}/;
|
|
91
|
+
const DIGIT_START_RE = /^[0-9]/;
|
|
92
|
+
const ONE_MARKER_RE = /^1[.)]$/;
|
|
93
|
+
|
|
94
|
+
function expandTabs(line) {
|
|
95
|
+
if (!line.includes('\t')) return line;
|
|
96
|
+
let out = '', column = 0, from = 0;
|
|
97
|
+
for (let idx = line.indexOf('\t'); idx >= 0; idx = line.indexOf('\t', from)) {
|
|
98
|
+
const seg = line.slice(from, idx);
|
|
99
|
+
out += seg;
|
|
100
|
+
column += seg.length;
|
|
101
|
+
const width = 4 - (column % 4);
|
|
102
|
+
out += ' '.repeat(width);
|
|
103
|
+
column += width;
|
|
104
|
+
from = idx + 1;
|
|
105
|
+
}
|
|
106
|
+
return out + line.slice(from);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function findClosingBackticks(text, from, scopeEnd, count) {
|
|
110
|
+
let idx = text.indexOf('`', from);
|
|
111
|
+
while (idx >= 0 && idx < scopeEnd) {
|
|
112
|
+
let runEnd = idx + 1;
|
|
113
|
+
while (runEnd < text.length && text.charCodeAt(runEnd) === 96) runEnd++;
|
|
114
|
+
if (runEnd - idx === count) return runEnd <= scopeEnd ? runEnd : -1;
|
|
115
|
+
idx = text.indexOf('`', runEnd);
|
|
116
|
+
}
|
|
117
|
+
return -1;
|
|
118
|
+
}
|
|
119
|
+
|
|
77
120
|
// Discovery sees prose only; preserve offsets and newlines without changing captured bytes.
|
|
78
121
|
export function markdownSectionText(text) {
|
|
79
122
|
const parts = [], inline = /`+|<!--|</g;
|
|
@@ -81,13 +124,22 @@ export function markdownSectionText(text) {
|
|
|
81
124
|
let containers = [], fence = null, comment = false, indented = false, copied = 0, paragraph = false;
|
|
82
125
|
let scopeStart = null, scopeEnd = 0;
|
|
83
126
|
const mask = (start, end) => {
|
|
84
|
-
|
|
127
|
+
if (end <= start) return;
|
|
128
|
+
parts.push(text.slice(copied, start));
|
|
129
|
+
const slice = text.slice(start, end);
|
|
130
|
+
parts.push(!slice.includes('\n') && !slice.includes('\r') ? ' '.repeat(end - start) : slice.replace(/[^\r\n]/g, ' '));
|
|
85
131
|
copied = end;
|
|
86
132
|
};
|
|
87
133
|
// Inline parsing belongs to one leaf block. A matching run in a later
|
|
88
134
|
// paragraph, heading or container cannot turn intervening prose into code.
|
|
89
135
|
const flush = () => {
|
|
90
136
|
if (scopeStart === null) return;
|
|
137
|
+
const firstTick = text.indexOf('`', scopeStart);
|
|
138
|
+
const firstComment = text.indexOf('<!--', scopeStart);
|
|
139
|
+
if ((firstTick < 0 || firstTick >= scopeEnd) && (firstComment < 0 || firstComment >= scopeEnd)) {
|
|
140
|
+
scopeStart = null;
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
91
143
|
inline.lastIndex = scopeStart;
|
|
92
144
|
for (let match; (match = inline.exec(text)) && match.index < scopeEnd;) {
|
|
93
145
|
let tokenStart = match.index, token = match[0], slashes = 0;
|
|
@@ -110,53 +162,55 @@ export function markdownSectionText(text) {
|
|
|
110
162
|
if (close < 0 || close + 3 > scopeEnd) continue;
|
|
111
163
|
closeEnd = close + 3;
|
|
112
164
|
} else {
|
|
113
|
-
const closing = new RegExp('(?<!`)`{' + token.length + '}(?!`)', 'g');
|
|
114
|
-
closing.lastIndex = inline.lastIndex;
|
|
115
|
-
const close = closing.exec(text);
|
|
116
|
-
if (!close || close.index + close[0].length > scopeEnd) continue;
|
|
117
165
|
// Backslashes have no escape meaning inside an actual code span.
|
|
118
|
-
closeEnd =
|
|
166
|
+
closeEnd = findClosingBackticks(text, inline.lastIndex, scopeEnd, token.length);
|
|
167
|
+
if (closeEnd < 0) continue;
|
|
119
168
|
}
|
|
120
169
|
mask(tokenStart, closeEnd);
|
|
121
170
|
inline.lastIndex = closeEnd;
|
|
122
171
|
}
|
|
123
172
|
scopeStart = null;
|
|
124
173
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
174
|
+
const len = text.length;
|
|
175
|
+
for (let pos = 0; pos < len;) {
|
|
176
|
+
let end = pos;
|
|
177
|
+
while (end < len) {
|
|
178
|
+
const ch = text.charCodeAt(end);
|
|
179
|
+
if (ch === 10 || ch === 13) break;
|
|
180
|
+
end++;
|
|
181
|
+
}
|
|
182
|
+
const start = pos;
|
|
183
|
+
const original = text.slice(start, end);
|
|
184
|
+
if (end < len) {
|
|
185
|
+
pos = (text.charCodeAt(end) === 13 && end + 1 < len && text.charCodeAt(end + 1) === 10) ? end + 2 : end + 1;
|
|
186
|
+
} else {
|
|
187
|
+
pos = len;
|
|
188
|
+
}
|
|
129
189
|
{
|
|
130
190
|
// Tabs affect Markdown indentation only. This view is never captured.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
});
|
|
137
|
-
let { line, matched } = markdownContainerLine(expanded, containers);
|
|
138
|
-
const thematic = /^ {0,3}(?:(?:\* *){3,}|(?:- *){3,}|(?:_ *){3,})$/;
|
|
139
|
-
const item = /^ {0,3}([-+*]|[0-9]{1,9}[.)]) +(\S.*)$/.exec(line);
|
|
140
|
-
const fenceStart = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(line);
|
|
191
|
+
const expanded = expandTabs(original);
|
|
192
|
+
let { line, matched } = containers.length ? markdownContainerLine(expanded, containers) : { line: expanded, matched: 0 };
|
|
193
|
+
const trimmed = line.trim();
|
|
194
|
+
const item = ITEM_RE.exec(line);
|
|
195
|
+
const fenceStart = FENCE_START_RE.exec(line);
|
|
141
196
|
const validFence = fenceStart && !(fenceStart[1][0] === '`' && fenceStart[2].includes('`'));
|
|
142
197
|
// Only HTML block types that can interrupt a paragraph split its inline
|
|
143
198
|
// scope; ordinary angle prose and custom inline tags do not.
|
|
144
|
-
const htmlStart =
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|| (item && (!paragraph || !/^[0-9]/.test(item[1]) || /^1[.)]$/.test(item[1])
|
|
199
|
+
const htmlStart = line.includes('<') && (HTML_START_1_RE.test(line) || HTML_START_2_RE.test(line));
|
|
200
|
+
const startsBlock = QUOTE_OR_HEADING_RE.test(line) || validFence || htmlStart || THEMATIC_RE.test(line)
|
|
201
|
+
|| (item && (!paragraph || !DIGIT_START_RE.test(item[1]) || ONE_MARKER_RE.test(item[1])
|
|
148
202
|
|| (matched < containers.length && containers[matched] !== '>')));
|
|
149
203
|
// Lazy paragraph continuation keeps its parent containers available for a
|
|
150
204
|
// later indented fence. Code itself never permits lazy continuation.
|
|
151
|
-
const lazy = matched < containers.length && !fence && !comment && !indented && paragraph &&
|
|
152
|
-
const boundary = !
|
|
205
|
+
const lazy = matched < containers.length && !fence && !comment && !indented && paragraph && trimmed && !startsBlock;
|
|
206
|
+
const boundary = !trimmed || startsBlock || SETEXT_RE.test(line)
|
|
153
207
|
|| (!lazy && matched < containers.length);
|
|
154
208
|
if (boundary) flush();
|
|
155
209
|
if (!lazy && matched < containers.length) { fence = null; comment = false; indented = false; paragraph = false; }
|
|
156
210
|
if (!lazy) containers = containers.slice(0, matched);
|
|
157
211
|
if (fence) {
|
|
158
212
|
mask(start, end);
|
|
159
|
-
const close =
|
|
213
|
+
const close = FENCE_CLOSE_RE.exec(line);
|
|
160
214
|
if (close && close[1][0] === fence[0] && close[1].length >= fence.length) fence = null;
|
|
161
215
|
continue;
|
|
162
216
|
}
|
|
@@ -171,45 +225,45 @@ export function markdownSectionText(text) {
|
|
|
171
225
|
}
|
|
172
226
|
// Code starts only at a leaf boundary. Its indentation belongs to the
|
|
173
227
|
// existing container; markup inside it cannot open another container.
|
|
174
|
-
if ((indented && !
|
|
228
|
+
if ((indented && !trimmed) || (!paragraph && INDENT_4_RE.test(line))) {
|
|
175
229
|
indented = true; mask(start, end); continue;
|
|
176
230
|
}
|
|
177
231
|
indented = false;
|
|
178
232
|
// Start containers only outside code; a list's continuation width belongs
|
|
179
233
|
// to its item, so a sibling marker or dedent ends an unclosed example.
|
|
180
234
|
for (; !lazy;) {
|
|
181
|
-
const quote =
|
|
235
|
+
const quote = QUOTE_PREFIX_RE.exec(line);
|
|
182
236
|
if (quote) { containers.push('>'); line = line.slice(quote[0].length); paragraph = false; continue; }
|
|
183
|
-
const list =
|
|
184
|
-
if (!list ||
|
|
237
|
+
const list = LIST_PREFIX_RE.exec(line);
|
|
238
|
+
if (!list || THEMATIC_RE.test(line)) break;
|
|
185
239
|
const rest = line.slice(list[0].length);
|
|
186
|
-
if (paragraph && (!rest.trim() || (
|
|
240
|
+
if (paragraph && (!rest.trim() || (DIGIT_START_RE.test(list[2]) && !ONE_MARKER_RE.test(list[2])))) break;
|
|
187
241
|
const padding = rest.trim() && list[3].length <= 4 ? list[3].length : 1;
|
|
188
242
|
const indent = list[1].length + list[2].length + padding;
|
|
189
243
|
containers.push(indent); line = line.slice(indent); paragraph = false;
|
|
190
244
|
}
|
|
191
|
-
if (!paragraph &&
|
|
245
|
+
if (!paragraph && INDENT_4_RE.test(line)) {
|
|
192
246
|
indented = true; mask(start, end); continue;
|
|
193
247
|
}
|
|
194
|
-
const opening =
|
|
248
|
+
const opening = FENCE_START_RE.exec(line);
|
|
195
249
|
if (!lazy && opening && !(opening[1][0] === '`' && opening[2].includes('`'))) {
|
|
196
250
|
fence = opening[1]; paragraph = false; mask(start, end); continue;
|
|
197
251
|
}
|
|
198
|
-
if (
|
|
199
|
-
const
|
|
200
|
-
mask(start +
|
|
252
|
+
if (line.includes('<!--') && COMMENT_START_RE.test(line)) {
|
|
253
|
+
const openingIdx = original.indexOf('<!--'), close = original.indexOf('-->', openingIdx + 4);
|
|
254
|
+
mask(start + openingIdx, close < 0 ? end : start + close + 3);
|
|
201
255
|
comment = close < 0; paragraph = false;
|
|
202
256
|
if (!comment) { scopeStart = start + close + 3; scopeEnd = end; flush(); }
|
|
203
257
|
continue;
|
|
204
258
|
}
|
|
205
|
-
const definition = !paragraph &&
|
|
206
|
-
paragraph = Boolean(line.trim()) && !
|
|
207
|
-
&&
|
|
259
|
+
const definition = !paragraph && DEF_START_RE.test(line);
|
|
260
|
+
paragraph = Boolean(line.trim()) && !THEMATIC_RE.test(line) && !definition && !htmlStart
|
|
261
|
+
&& !HEADING_OR_SETEXT_EQ_RE.test(line);
|
|
208
262
|
}
|
|
209
263
|
if (scopeStart === null) scopeStart = start;
|
|
210
264
|
scopeEnd = end;
|
|
211
265
|
if (!paragraph) flush();
|
|
212
266
|
}
|
|
213
267
|
flush();
|
|
214
|
-
return parts.join('') + text.slice(copied);
|
|
268
|
+
return parts.length ? parts.join('') + text.slice(copied) : text;
|
|
215
269
|
}
|
|
@@ -167,12 +167,149 @@ function normalizeMapProblem(item, mapPath) {
|
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
//
|
|
170
|
+
// Cold lazy-interfaces lint legitimately defers capability analysis until check/try
|
|
171
|
+
// synthesis; only accept capabilities_complete: false when lint itself completed cleanly
|
|
172
|
+
// and every incomplete capability report is an unknown placeholder backed by
|
|
173
|
+
// lazy_interface_pending prompts.
|
|
174
|
+
export function isLazyPendingOnlyCapabilities(answer) {
|
|
175
|
+
const result = answer?.result, report = result?.report;
|
|
176
|
+
const prompts = objects(report?.program?.prompts);
|
|
177
|
+
const hasLazyPending = prompts.some(p => (p.admission_state ?? p.state) === 'missing' && p.lazy_interface_pending === true);
|
|
178
|
+
if (!hasLazyPending) return false;
|
|
179
|
+
const topCaps = objects(result?.capabilities).map(item => item.report).filter(object);
|
|
180
|
+
const legacyCaps = objects(report?.lint?.tests).map(item => item.capabilities).filter(object);
|
|
181
|
+
const caps = topCaps.length ? topCaps : legacyCaps;
|
|
182
|
+
if (!caps.length) return objects(report?.lint?.tests).length === 0 && objects(result?.tests).length === 0;
|
|
183
|
+
return caps.every(cap => cap.complete === true || (cap.complete === false && cap.verdict === 'unknown'));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Fail-closed assessment of a remote lint response: a refusal, blocking error problem,
|
|
187
|
+
// lint-incomplete marker, lint.complete === false, or non-lazy capabilities_complete === false
|
|
188
|
+
// never collapses to a pass even if the payload also reports passed: true or passing rows.
|
|
189
|
+
// When `scope` ({ test, applicableMaps, testPassed, reachedChecked }) is supplied for an
|
|
190
|
+
// individual selected test, refusals/problems strictly targeting an unrelated test or
|
|
191
|
+
// non-applicable app map do not fail closed on this passing test.
|
|
192
|
+
export function lintFailClosed(answer, extraProblems = [], scope = null) {
|
|
193
|
+
if (!object(answer)) return null;
|
|
194
|
+
const result = answer.result, report = result?.report;
|
|
195
|
+
const rawRefusals = objects(result?.refusals);
|
|
196
|
+
if (object(report?.refusal) && !rawRefusals.some(item => item.code === report.refusal.code
|
|
197
|
+
&& (item.file ?? item.path ?? null) === (report.refusal.file ?? report.refusal.path ?? null))) {
|
|
198
|
+
rawRefusals.push(report.refusal);
|
|
199
|
+
}
|
|
200
|
+
const canonicalProblems = objects(result?.problems).length ? objects(result.problems) : objects(report?.problems);
|
|
201
|
+
const allProblems = [...canonicalProblems, ...objects(extraProblems)];
|
|
202
|
+
const refusedPrompts = objects(report?.program?.refused_prompts);
|
|
203
|
+
|
|
204
|
+
const targetOf = item => nonEmpty(item?.file, item?.path);
|
|
205
|
+
let refusals = rawRefusals;
|
|
206
|
+
let scopedProblems = allProblems;
|
|
207
|
+
let scopedRefusedPrompts = refusedPrompts;
|
|
208
|
+
let hasUnrelatedRefusal = false;
|
|
209
|
+
|
|
210
|
+
if (scope && typeof scope.test === 'string') {
|
|
211
|
+
const testPath = scope.test;
|
|
212
|
+
const applicableSet = new Set(Array.isArray(scope.applicableMaps) ? scope.applicableMaps : []);
|
|
213
|
+
const otherListedTests = new Set([
|
|
214
|
+
...objects(result?.tests),
|
|
215
|
+
...objects(report?.lint?.tests),
|
|
216
|
+
].map(item => item.path).filter(p => typeof p === 'string' && p !== testPath));
|
|
217
|
+
const otherAppMaps = new Set([
|
|
218
|
+
...objects(result?.app_maps),
|
|
219
|
+
...objects(report?.lint?.app_maps),
|
|
220
|
+
].map(item => item.path).filter(p => typeof p === 'string' && !applicableSet.has(p)));
|
|
221
|
+
const isUnrelatedTarget = item => {
|
|
222
|
+
if (item?.code === 'lint-incomplete') return false;
|
|
223
|
+
const target = targetOf(item);
|
|
224
|
+
if (!target || target === testPath || applicableSet.has(target)) return false;
|
|
225
|
+
return otherListedTests.has(target)
|
|
226
|
+
|| otherAppMaps.has(target)
|
|
227
|
+
|| /(?:^|\/)tests?\/[^/].*\.json$/.test(target)
|
|
228
|
+
|| /(?:^|\/)(?:app-map|[^/]*-map)\.json$/.test(target)
|
|
229
|
+
|| /(?:^|\/)maps\/[^/].*\.json$/.test(target);
|
|
230
|
+
};
|
|
231
|
+
refusals = rawRefusals.filter(item => !isUnrelatedTarget(item));
|
|
232
|
+
scopedProblems = allProblems.filter(item => !isUnrelatedTarget(item));
|
|
233
|
+
if (scope.reachedChecked) scopedRefusedPrompts = [];
|
|
234
|
+
hasUnrelatedRefusal = refusals.length < rawRefusals.length
|
|
235
|
+
|| scopedProblems.length < allProblems.length
|
|
236
|
+
|| (scope.reachedChecked && refusedPrompts.length > 0)
|
|
237
|
+
|| objects(result?.tests).some(t => t.path !== testPath && t.verdict === 'refused')
|
|
238
|
+
|| objects(report?.lint?.tests).some(t => t.path !== testPath && t.verdict === 'refused')
|
|
239
|
+
|| [...objects(result?.app_maps), ...objects(report?.lint?.app_maps)].some(m => !applicableSet.has(m.path) && m.verdict === 'refused');
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const errorProblems = scopedProblems.filter(item => item.severity !== 'warning');
|
|
243
|
+
const lintIncompleteProblem = allProblems.find(item => item.code === 'lint-incomplete') ?? null;
|
|
244
|
+
const lintIncompleteRefusal = rawRefusals.find(item => item.code === 'lint-incomplete') ?? null;
|
|
245
|
+
|
|
246
|
+
const envelopeRefused = scope
|
|
247
|
+
? (answer.state === 'refused'
|
|
248
|
+
&& !(scope.testPassed && !hasUnrelatedRefusal && !report?.verdict && !report?.refusal && !rawRefusals.length && !allProblems.some(item => item.severity !== 'warning')))
|
|
249
|
+
: (answer.state === 'refused' || answer.state === 'failed');
|
|
250
|
+
const reportRefused = report?.verdict === 'refused' || report?.verdict === 'failed';
|
|
251
|
+
const answerRefused = (scope ? ((envelopeRefused || reportRefused) && !hasUnrelatedRefusal) : (answer.state === 'refused' || answer.state === 'failed' || reportRefused))
|
|
252
|
+
|| refusals.length > 0;
|
|
253
|
+
const hasErrorProblems = errorProblems.length > 0 || scopedRefusedPrompts.length > 0;
|
|
254
|
+
const lintCompleteFalse = report?.lint?.complete === false || result?.problems_complete === false;
|
|
255
|
+
const anyCapabilitiesFalse = result?.capabilities_complete === false || report?.lint?.capabilities_complete === false;
|
|
256
|
+
const capabilitiesIncomplete = anyCapabilitiesFalse && !isLazyPendingOnlyCapabilities(answer);
|
|
257
|
+
|
|
258
|
+
if (answerRefused || hasErrorProblems) {
|
|
259
|
+
const blockingRefusals = [...refusals, ...errorProblems, ...scopedRefusedPrompts];
|
|
260
|
+
const primary = lintIncompleteRefusal ?? refusals[0] ?? lintIncompleteProblem ?? errorProblems[0] ?? scopedRefusedPrompts[0] ?? null;
|
|
261
|
+
const code = nonEmpty(primary?.code)
|
|
262
|
+
?? (lintCompleteFalse ? 'lint-incomplete' : capabilitiesIncomplete ? 'capabilities-incomplete' : 'lint-refused');
|
|
263
|
+
const message = nonEmpty(
|
|
264
|
+
primary?.message,
|
|
265
|
+
[primary?.reason, primary?.fix].filter(Boolean).join(' '),
|
|
266
|
+
primary?.engine_message,
|
|
267
|
+
lintCompleteFalse ? 'Lint checking did not finish. No pass was established.' : null,
|
|
268
|
+
capabilitiesIncomplete ? 'Capability analysis did not complete.' : null,
|
|
269
|
+
'The interpreter refused lint.',
|
|
270
|
+
);
|
|
271
|
+
return {
|
|
272
|
+
kind: 'refused',
|
|
273
|
+
code,
|
|
274
|
+
message,
|
|
275
|
+
answerRefused,
|
|
276
|
+
lintIncomplete: lintCompleteFalse || !!lintIncompleteProblem || !!lintIncompleteRefusal,
|
|
277
|
+
capabilitiesIncomplete,
|
|
278
|
+
refusals: blockingRefusals.length ? blockingRefusals : [{ code, message }],
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
if (lintCompleteFalse || capabilitiesIncomplete || lintIncompleteProblem) {
|
|
282
|
+
const code = lintIncompleteProblem
|
|
283
|
+
? 'lint-incomplete'
|
|
284
|
+
: lintCompleteFalse
|
|
285
|
+
? 'lint-incomplete'
|
|
286
|
+
: 'capabilities-incomplete';
|
|
287
|
+
const message = nonEmpty(
|
|
288
|
+
lintIncompleteProblem?.message,
|
|
289
|
+
[lintIncompleteProblem?.reason, lintIncompleteProblem?.fix].filter(Boolean).join(' '),
|
|
290
|
+
lintCompleteFalse ? 'Lint did not finish. No pass was established.' : 'Capability analysis did not complete.',
|
|
291
|
+
);
|
|
292
|
+
return {
|
|
293
|
+
kind: 'incomplete',
|
|
294
|
+
code,
|
|
295
|
+
message,
|
|
296
|
+
answerRefused: false,
|
|
297
|
+
lintIncomplete: lintCompleteFalse || !!lintIncompleteProblem,
|
|
298
|
+
capabilitiesIncomplete,
|
|
299
|
+
refusals: [],
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// A selected test passes lint on its own evidence: a passing per-test verdict and passing applicable app maps,
|
|
306
|
+
// and the lint response itself must not be refused, incomplete, or carrying blocking error problems.
|
|
171
307
|
// An ended lint that gives a test or applicable app map no verdict leaves it not run; only a lint that has not ended is unknown.
|
|
172
308
|
function lintOutcome(answer, refusals, test, steps, appMaps, sourceFiles) {
|
|
173
309
|
const result = answer?.result, report = result?.report, program = report?.program;
|
|
174
310
|
if (!['passed', 'failed', 'refused'].includes(answer?.state)) return { state: 'unknown', reason: 'no lint verdict' };
|
|
175
|
-
const complete = report?.lint && typeof report.lint === 'object' ? report.lint.complete === true : result?.problems_complete === true
|
|
311
|
+
const complete = (report?.lint && typeof report.lint === 'object' ? report.lint.complete === true : result?.problems_complete === true)
|
|
312
|
+
&& result?.problems_complete !== false;
|
|
176
313
|
const entries = list => objects(list).filter(item => item.path === test);
|
|
177
314
|
const listed = entries(result?.tests).length ? entries(result.tests) : entries(report?.lint?.tests);
|
|
178
315
|
const verdict = listed.length && listed.every(item => item.verdict === listed[0].verdict) ? listed[0].verdict : null;
|
|
@@ -285,6 +422,12 @@ function lintOutcome(answer, refusals, test, steps, appMaps, sourceFiles) {
|
|
|
285
422
|
}
|
|
286
423
|
}
|
|
287
424
|
const notRun = (reason, code = !complete || notChecked ? 'deadline' : 'no-server-verdict') => ({ state: 'not_run', code, retryable: false, reason, draft });
|
|
425
|
+
const failClosed = lintFailClosed(answer, [], {
|
|
426
|
+
test,
|
|
427
|
+
applicableMaps,
|
|
428
|
+
testPassed: verdict === 'passed',
|
|
429
|
+
reachedChecked: Array.isArray(program?.prompts) || Array.isArray(program?.refused_prompts),
|
|
430
|
+
});
|
|
288
431
|
if (own.some(item => refusals.includes(item))) return refused(own, { draft });
|
|
289
432
|
if (reachedProblem) return refused([reachedProblem], { draft });
|
|
290
433
|
if (appMapRefusals.length) return appMapRefused(appMapRefusals, { draft });
|
|
@@ -299,14 +442,22 @@ function lintOutcome(answer, refusals, test, steps, appMaps, sourceFiles) {
|
|
|
299
442
|
section: row.selection.step_id, message: `${row.verdict}: ${row.reason_code}` }))
|
|
300
443
|
: [{ code: compatibility.state, message: compatibility.state }], { draft });
|
|
301
444
|
}
|
|
302
|
-
if (
|
|
445
|
+
if (failClosed?.kind === 'refused') return refused(failClosed.refusals, { draft });
|
|
446
|
+
if (compatibility.state === 'supported' && compatibility.reported.complete) {
|
|
447
|
+
if (failClosed?.kind === 'incomplete') return notRun(failClosed.message, failClosed.code);
|
|
448
|
+
return { state: 'passed', draft };
|
|
449
|
+
}
|
|
303
450
|
if (lazyPending && complete && !own.length && compatibility.state === 'unknown' && compatibility.reported?.complete === false) {
|
|
451
|
+
if (failClosed?.kind === 'incomplete') return notRun(failClosed.message, failClosed.code);
|
|
304
452
|
return { state: 'passed', draft };
|
|
305
453
|
}
|
|
454
|
+
} else if (failClosed?.kind === 'refused') {
|
|
455
|
+
return refused(failClosed.refusals, { draft });
|
|
306
456
|
}
|
|
307
|
-
return notRun(compatibility.issue ?? 'selected compatibility is unknown or incomplete', compatibility.issue ?? 'no-server-verdict');
|
|
457
|
+
return notRun(compatibility.issue ?? failClosed?.message ?? 'selected compatibility is unknown or incomplete', compatibility.issue ?? failClosed?.code ?? 'no-server-verdict');
|
|
308
458
|
}
|
|
309
|
-
// A job refusal refuses a selected test that has no verdict of its own.
|
|
459
|
+
// A job refusal or blocking lint error refuses a selected test that has no verdict of its own.
|
|
460
|
+
if (failClosed?.kind === 'refused') return refused(failClosed.refusals, { draft });
|
|
310
461
|
if (!listed.length && (answer.state === 'refused' || report?.verdict === 'refused' || refusals.length))
|
|
311
462
|
return refused(refusals.length ? refusals : [{ code: 'lint-refused', message: 'The interpreter refused lint.' }], { draft });
|
|
312
463
|
return notRun(!complete || unlisted || notChecked ? 'lint did not finish' : !appMapsPassed ? 'lint gave no verdict for this app map' : 'lint gave no verdict for this test');
|