agent-dealer 1.4.1 → 1.4.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/bundle/server/dist/adapters/github.js +66 -3
- package/bundle/server/dist/adapters/github.test.js +90 -0
- package/bundle/server/dist/coordinator/auto-merge.js +17 -6
- package/bundle/server/dist/coordinator/commands.js +18 -2
- package/bundle/server/dist/coordinator/developer-effect.js +49 -7
- package/bundle/server/dist/coordinator/developer-effect.test.js +118 -4
- package/bundle/server/dist/coordinator/muse-developer.integration.test.js +2 -1
- package/bundle/server/dist/coordinator/operator-criteria.js +250 -17
- package/bundle/server/dist/coordinator/operator-criteria.test.js +177 -4
- package/bundle/server/dist/coordinator/operator-verification.integration.test.js +208 -0
- package/bundle/server/dist/coordinator/projection.js +5 -1
- package/bundle/server/dist/coordinator/prompts.js +77 -4
- package/bundle/server/dist/coordinator/prompts.test.js +22 -4
- package/bundle/server/dist/coordinator/reviewer-effect.js +64 -45
- package/bundle/server/dist/coordinator/reviewer-effect.test.js +63 -10
- package/bundle/server/dist/coordinator/reviewer-pr-evidence.test.js +245 -0
- package/bundle/server/dist/coordinator/reviewer-result.js +4 -3
- package/bundle/server/dist/coordinator/reviewer-result.test.js +6 -0
- package/bundle/server/dist/coordinator/routing.js +3 -0
- package/bundle/server/dist/coordinator/routing.test.js +19 -0
- package/bundle/server/dist/coordinator/usage.js +35 -2
- package/bundle/server/dist/coordinator/usage.test.js +49 -1
- package/bundle/server/dist/docs-api-reference.test.js +89 -0
- package/bundle/server/package.json +2 -2
- package/bundle/shared/package.json +1 -1
- package/package.json +1 -1
|
@@ -34,20 +34,49 @@ export const OPERATOR_VERIFICATION_RESPONSE_OPTIONS = [
|
|
|
34
34
|
export function operatorVerificationRequestId(headSha) {
|
|
35
35
|
return `operator-verification:${headSha}`;
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* NOT-575: the planner deck tags each criterion `[agent]`, `[ci]` or
|
|
39
|
+
* `[operator]` at the END of the criterion line. Only that trailing tag
|
|
40
|
+
* decides — a criterion whose prose merely mentions `[operator]` but ends in
|
|
41
|
+
* `[agent]` is an agent criterion, never a gate. Case-insensitive; trailing
|
|
42
|
+
* whitespace (including a CR from CRLF ticket text) is ignored. Strictly the
|
|
43
|
+
* last token: `[operator].` with trailing punctuation is NOT a tag.
|
|
44
|
+
*
|
|
45
|
+
* Repair round 2: Linear markdown escapes the brackets (`\[operator\]`), and
|
|
46
|
+
* neither intake nor the contract compiler unescapes them — the raw text ends
|
|
47
|
+
* in `\]`, so a plain `]`-anchored match never fires and genuine operator
|
|
48
|
+
* criteria sail through the gate (the NOT-567/569-572 missed-gate shape).
|
|
49
|
+
* Each bracket therefore accepts one optional backslash.
|
|
50
|
+
*/
|
|
51
|
+
const TRAILING_OPERATOR_TAG_RE = /\\?\[operator\\?\]\s*$/i;
|
|
52
|
+
/** True when the criterion text carries a trailing `[operator]` tag (NOT-575). */
|
|
53
|
+
export function hasTrailingOperatorTag(criterionText) {
|
|
54
|
+
return TRAILING_OPERATOR_TAG_RE.test(criterionText.trim());
|
|
55
|
+
}
|
|
38
56
|
/** An indented checkbox (a nested sub-task) — never a command, never a gate. */
|
|
39
57
|
const INDENTED_CHECKBOX_RE = /^\s+[-*]\s*\[[ xX]?\]/;
|
|
40
58
|
/** An indented plain bullet — an evidence/command sub-bullet. */
|
|
41
59
|
const INDENTED_BULLET_RE = /^\s+[-*]\s+(.*)$/;
|
|
42
60
|
/**
|
|
43
|
-
*
|
|
44
|
-
* `
|
|
45
|
-
*
|
|
61
|
+
* NOT-575: the planner contract's indented `Evidence:` line under a criterion
|
|
62
|
+
* (` Evidence: ...`, or the nested-bullet form ` * Evidence: ...` the
|
|
63
|
+
* contract compiler also accepts). Collected as the criterion's command the
|
|
64
|
+
* same way a sub-bullet is — without this every contract-ticket criterion
|
|
65
|
+
* gates with an empty command list.
|
|
66
|
+
*/
|
|
67
|
+
const INDENTED_EVIDENCE_RE = /^\s+(?:[-*+]\s+)?Evidence\s*:\s*(.*)$/i;
|
|
68
|
+
/**
|
|
69
|
+
* Returns each top-level (unindented) checkbox AC with a trailing `[operator]`
|
|
70
|
+
* tag (NOT-575: the tag at the end of the criterion line only, never a
|
|
71
|
+
* mention inside the criterion text), together with the indented evidence
|
|
72
|
+
* lines directly under it (sub-bullets and `Evidence:` lines — the commands
|
|
73
|
+
* to run).
|
|
46
74
|
*
|
|
47
75
|
* "Top-level" means the checkbox marker starts at column 0; indented
|
|
48
76
|
* checkboxes (sub-tasks) never open the gate. Collection of a criterion's
|
|
49
|
-
* commands stops at the next column-0 checkbox,
|
|
50
|
-
* blank lines inside the
|
|
77
|
+
* commands stops at the next column-0 checkbox, an indented checkbox, a
|
|
78
|
+
* non-bullet non-evidence line, or EOF — blank lines inside the block are
|
|
79
|
+
* skipped, not terminators.
|
|
51
80
|
*/
|
|
52
81
|
export function extractOperatorCriteria(acceptanceCriteria) {
|
|
53
82
|
const found = [];
|
|
@@ -56,7 +85,7 @@ export function extractOperatorCriteria(acceptanceCriteria) {
|
|
|
56
85
|
while (i < lines.length) {
|
|
57
86
|
const line = lines[i];
|
|
58
87
|
const top = line.match(/^[-*]\s*\[[ xX]?\]\s*(.*)$/);
|
|
59
|
-
if (top &&
|
|
88
|
+
if (top && hasTrailingOperatorTag(top[1] ?? "")) {
|
|
60
89
|
const criterion = { text: (top[1] ?? "").trim(), commands: [] };
|
|
61
90
|
i += 1;
|
|
62
91
|
while (i < lines.length) {
|
|
@@ -73,6 +102,12 @@ export function extractOperatorCriteria(acceptanceCriteria) {
|
|
|
73
102
|
// the block without being collected.
|
|
74
103
|
if (INDENTED_CHECKBOX_RE.test(sub))
|
|
75
104
|
break;
|
|
105
|
+
const evidence = sub.match(INDENTED_EVIDENCE_RE);
|
|
106
|
+
if (evidence) {
|
|
107
|
+
criterion.commands.push(`Evidence: ${(evidence[1] ?? "").trim()}`);
|
|
108
|
+
i += 1;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
76
111
|
const bullet = sub.match(INDENTED_BULLET_RE);
|
|
77
112
|
if (bullet) {
|
|
78
113
|
criterion.commands.push((bullet[1] ?? "").trim());
|
|
@@ -88,6 +123,49 @@ export function extractOperatorCriteria(acceptanceCriteria) {
|
|
|
88
123
|
}
|
|
89
124
|
return found;
|
|
90
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* NOT-575: the same trailing-tag detection over the frozen execution
|
|
128
|
+
* contract's structured criteria. The contract is the authoritative criterion
|
|
129
|
+
* list for contract tickets — when an explicitly-provided acceptance-criteria
|
|
130
|
+
* string diverges from it, a genuine trailing-`[operator]` contract criterion
|
|
131
|
+
* must still gate. Pure (no DB): the caller supplies the frozen contract.
|
|
132
|
+
*/
|
|
133
|
+
export function extractOperatorCriteriaFromContract(contract) {
|
|
134
|
+
if (!contract)
|
|
135
|
+
return [];
|
|
136
|
+
const found = [];
|
|
137
|
+
for (const criterion of contract.acceptanceCriteria) {
|
|
138
|
+
if (!hasTrailingOperatorTag(criterion.text))
|
|
139
|
+
continue;
|
|
140
|
+
found.push({
|
|
141
|
+
text: criterion.text.trim(),
|
|
142
|
+
commands: criterion.evidence?.trim() ? [`Evidence: ${criterion.evidence.trim()}`] : [],
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return found;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* NOT-575: union of the AC-text criteria and the structured-contract
|
|
149
|
+
* criteria, deduped by exact criterion text (contract tickets render their AC
|
|
150
|
+
* text from the contract, so the two lists normally agree — the union only
|
|
151
|
+
* matters when they diverge). Pure: the caller supplies the frozen snapshot
|
|
152
|
+
* fields, so the gate, the developer prompt, and the reviewer prompt all
|
|
153
|
+
* classify identically without each reading the DB.
|
|
154
|
+
*/
|
|
155
|
+
export function operatorCriteriaForSnapshot(snapshot) {
|
|
156
|
+
const seen = new Set();
|
|
157
|
+
const merged = [];
|
|
158
|
+
for (const criterion of [
|
|
159
|
+
...extractOperatorCriteria(snapshot.acceptanceCriteria),
|
|
160
|
+
...extractOperatorCriteriaFromContract(snapshot.executionContract),
|
|
161
|
+
]) {
|
|
162
|
+
if (seen.has(criterion.text))
|
|
163
|
+
continue;
|
|
164
|
+
seen.add(criterion.text);
|
|
165
|
+
merged.push(criterion);
|
|
166
|
+
}
|
|
167
|
+
return merged;
|
|
168
|
+
}
|
|
91
169
|
/** The frozen snapshot's acceptanceCriteria, falling back to the live issue
|
|
92
170
|
* fields for items queued before snapshots existed (same fallback as
|
|
93
171
|
* commands.ts's getTaskSnapshot). */
|
|
@@ -105,38 +183,161 @@ export function snapshotAcceptanceCriteria(issue) {
|
|
|
105
183
|
}
|
|
106
184
|
return issue.acceptanceCriteria ?? "";
|
|
107
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* NOT-575: the frozen snapshot's execution contract, falling back to the
|
|
188
|
+
* live-issue derived contract for items queued before snapshots existed (same
|
|
189
|
+
* fallback shape as snapshotAcceptanceCriteria above). The contract is the
|
|
190
|
+
* authoritative criterion list when AC text and contract diverge.
|
|
191
|
+
*/
|
|
192
|
+
export function snapshotExecutionContract(issue) {
|
|
193
|
+
try {
|
|
194
|
+
const artifact = latestIssueArtifact(issue.id, TASK_SNAPSHOT_KIND);
|
|
195
|
+
if (artifact?.contentJson) {
|
|
196
|
+
const parsed = JSON.parse(artifact.contentJson);
|
|
197
|
+
if (parsed.executionContract && typeof parsed.executionContract === "object") {
|
|
198
|
+
return parsed.executionContract;
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
// fall through to the live-field fallback below
|
|
205
|
+
}
|
|
206
|
+
return issue.executionContract ?? null;
|
|
207
|
+
}
|
|
108
208
|
/** The frozen snapshot's `[operator]` criteria for this issue ([] when none). */
|
|
109
209
|
export function getOperatorCriteriaForIssue(issue) {
|
|
110
|
-
return
|
|
210
|
+
return operatorCriteriaForSnapshot({
|
|
211
|
+
acceptanceCriteria: snapshotAcceptanceCriteria(issue),
|
|
212
|
+
executionContract: snapshotExecutionContract(issue),
|
|
213
|
+
});
|
|
111
214
|
}
|
|
112
215
|
function recordHeadSha(record) {
|
|
113
216
|
return record && typeof record.headSha === "string" && record.headSha ? record.headSha : null;
|
|
114
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* NOT-575: the criterion texts a record covers, or null when the record
|
|
220
|
+
* predates per-criterion coverage (absent/non-list `criteria`) — a legacy
|
|
221
|
+
* record covers the whole head it pins, so a verify-then-crash recovery never
|
|
222
|
+
* re-blocks behind a result the operator already recorded.
|
|
223
|
+
*/
|
|
224
|
+
function recordCoveredCriteria(record) {
|
|
225
|
+
if (!record || record.criteria === undefined)
|
|
226
|
+
return null;
|
|
227
|
+
if (!Array.isArray(record.criteria))
|
|
228
|
+
return null;
|
|
229
|
+
return record.criteria.filter((c) => typeof c === "string" && !!c);
|
|
230
|
+
}
|
|
231
|
+
/** Every recorded result (verified artifact or waiver event) for exactly `headSha`. */
|
|
232
|
+
function verificationRecordsForHead(issueId, headSha) {
|
|
233
|
+
const records = [];
|
|
234
|
+
try {
|
|
235
|
+
for (const artifact of listArtifactsForIssueByKind(issueId, OPERATOR_VERIFICATION_ARTIFACT_KIND)) {
|
|
236
|
+
if (!artifact.contentJson)
|
|
237
|
+
continue;
|
|
238
|
+
try {
|
|
239
|
+
const record = JSON.parse(artifact.contentJson);
|
|
240
|
+
if (recordHeadSha(record) === headSha)
|
|
241
|
+
records.push(record);
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
// unreadable artifact content cannot prove verification
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
// a read failure fails closed below (no verification found → gate blocks)
|
|
250
|
+
}
|
|
251
|
+
try {
|
|
252
|
+
for (const event of listWorkflowEventsForIssue(issueId)) {
|
|
253
|
+
if (event.type !== "operator_verification.waived" || !event.payloadJson)
|
|
254
|
+
continue;
|
|
255
|
+
try {
|
|
256
|
+
const record = JSON.parse(event.payloadJson);
|
|
257
|
+
if (recordHeadSha(record) === headSha)
|
|
258
|
+
records.push(record);
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
// unreadable payload cannot prove a waiver
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
// same fail-closed reasoning as above
|
|
267
|
+
}
|
|
268
|
+
return records;
|
|
269
|
+
}
|
|
115
270
|
/**
|
|
116
271
|
* True when the human already recorded a result for exactly `headSha`: either a
|
|
117
272
|
* `verified` artifact (kind `operator_verification`, author human) or a
|
|
118
273
|
* `operator_verification.waived` workflow event. A result pins the head it was
|
|
119
274
|
* recorded at — new commits re-block the gate.
|
|
275
|
+
*
|
|
276
|
+
* Head-level only: the visual-evidence hold (which has no criterion list)
|
|
277
|
+
* releases on this. Criterion gating uses missingOperatorCriteriaForHead so
|
|
278
|
+
* each trailing-`[operator]` criterion needs its own recorded result.
|
|
120
279
|
*/
|
|
121
280
|
export function hasOperatorVerificationForHead(issueId, headSha) {
|
|
122
281
|
if (!headSha)
|
|
123
282
|
return false;
|
|
283
|
+
return verificationRecordsForHead(issueId, headSha).length > 0;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* NOT-575: the subset of `criteria` with no recorded result for exactly
|
|
287
|
+
* `headSha` ([] when every criterion is covered). A `verified` artifact or a
|
|
288
|
+
* `operator_verification.waived` event covers the criterion texts it lists —
|
|
289
|
+
* the resolve path stores the gated action's exact criterion list, so a
|
|
290
|
+
* result recorded for one criterion never releases another. Legacy records
|
|
291
|
+
* without a criterion list cover the whole head (see recordCoveredCriteria).
|
|
292
|
+
*/
|
|
293
|
+
export function missingOperatorCriteriaForHead(issueId, headSha, criteria) {
|
|
294
|
+
if (criteria.length === 0 || !headSha)
|
|
295
|
+
return [];
|
|
296
|
+
const records = verificationRecordsForHead(issueId, headSha);
|
|
297
|
+
if (records.length === 0)
|
|
298
|
+
return [...criteria];
|
|
299
|
+
return criteria.filter((criterion) => {
|
|
300
|
+
for (const record of records) {
|
|
301
|
+
const covered = recordCoveredCriteria(record);
|
|
302
|
+
if (covered === null)
|
|
303
|
+
return false;
|
|
304
|
+
if (covered.includes(criterion.text))
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
return true;
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
function attestationNote(record) {
|
|
311
|
+
return typeof record.note === "string" ? record.note : "";
|
|
312
|
+
}
|
|
313
|
+
/** Every recorded operator attestation for the issue, oldest first ([] when none). */
|
|
314
|
+
export function listOperatorAttestations(issueId) {
|
|
315
|
+
const attestations = [];
|
|
124
316
|
try {
|
|
125
317
|
for (const artifact of listArtifactsForIssueByKind(issueId, OPERATOR_VERIFICATION_ARTIFACT_KIND)) {
|
|
126
318
|
if (!artifact.contentJson)
|
|
127
319
|
continue;
|
|
128
320
|
try {
|
|
129
321
|
const record = JSON.parse(artifact.contentJson);
|
|
130
|
-
|
|
131
|
-
|
|
322
|
+
const headSha = recordHeadSha(record);
|
|
323
|
+
if (!headSha)
|
|
324
|
+
continue;
|
|
325
|
+
attestations.push({
|
|
326
|
+
kind: "verified",
|
|
327
|
+
headSha,
|
|
328
|
+
note: attestationNote(record),
|
|
329
|
+
by: typeof record.verifiedBy === "string" ? record.verifiedBy : null,
|
|
330
|
+
at: typeof record.verifiedAt === "string" ? record.verifiedAt : (artifact.createdAt ?? null),
|
|
331
|
+
criteria: recordCoveredCriteria(record) ?? [],
|
|
332
|
+
});
|
|
132
333
|
}
|
|
133
334
|
catch {
|
|
134
|
-
// unreadable
|
|
335
|
+
// unreadable content is not an attestation
|
|
135
336
|
}
|
|
136
337
|
}
|
|
137
338
|
}
|
|
138
339
|
catch {
|
|
139
|
-
// a read failure
|
|
340
|
+
// a read failure yields no attestations (the reviewer judges without them)
|
|
140
341
|
}
|
|
141
342
|
try {
|
|
142
343
|
for (const event of listWorkflowEventsForIssue(issueId)) {
|
|
@@ -144,18 +345,50 @@ export function hasOperatorVerificationForHead(issueId, headSha) {
|
|
|
144
345
|
continue;
|
|
145
346
|
try {
|
|
146
347
|
const record = JSON.parse(event.payloadJson);
|
|
147
|
-
|
|
148
|
-
|
|
348
|
+
const headSha = recordHeadSha(record);
|
|
349
|
+
if (!headSha)
|
|
350
|
+
continue;
|
|
351
|
+
attestations.push({
|
|
352
|
+
kind: "waived",
|
|
353
|
+
headSha,
|
|
354
|
+
note: attestationNote(record),
|
|
355
|
+
by: typeof record.waivedBy === "string" ? record.waivedBy : null,
|
|
356
|
+
at: event.ts ?? null,
|
|
357
|
+
criteria: recordCoveredCriteria(record) ?? [],
|
|
358
|
+
});
|
|
149
359
|
}
|
|
150
360
|
catch {
|
|
151
|
-
// unreadable payload
|
|
361
|
+
// unreadable payload is not an attestation
|
|
152
362
|
}
|
|
153
363
|
}
|
|
154
364
|
}
|
|
155
365
|
catch {
|
|
156
|
-
// same
|
|
366
|
+
// same leniency as above
|
|
367
|
+
}
|
|
368
|
+
return attestations;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* NOT-575: the criterion texts an `operator_verification` action gates (its
|
|
372
|
+
* stored `evidence.operatorVerification.criteria`), or null when the action
|
|
373
|
+
* predates that evidence shape or is unreadable. The resolve path stores
|
|
374
|
+
* exactly this list on the recorded result, so the result covers the gated
|
|
375
|
+
* criteria — that exact criterion set — and nothing else.
|
|
376
|
+
*/
|
|
377
|
+
export function criteriaTextsFromActionEvidence(action) {
|
|
378
|
+
if (!action.evidenceJson)
|
|
379
|
+
return null;
|
|
380
|
+
try {
|
|
381
|
+
const evidence = JSON.parse(action.evidenceJson);
|
|
382
|
+
const criteria = evidence.operatorVerification?.criteria;
|
|
383
|
+
if (!Array.isArray(criteria))
|
|
384
|
+
return null;
|
|
385
|
+
return criteria
|
|
386
|
+
.map((c) => (c && typeof c === "object" ? c.text : null))
|
|
387
|
+
.filter((t) => typeof t === "string" && !!t);
|
|
388
|
+
}
|
|
389
|
+
catch {
|
|
390
|
+
return null;
|
|
157
391
|
}
|
|
158
|
-
return false;
|
|
159
392
|
}
|
|
160
393
|
/** One numbered criterion + its commands, for the gate's reason/question. */
|
|
161
394
|
export function formatOperatorCriteria(criteria) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// NOT-314: `[operator]` criterion parser — pure cases (no DB).
|
|
2
|
+
// NOT-575: only the trailing tag decides (never a mention in the text).
|
|
2
3
|
import { test } from "node:test";
|
|
3
4
|
import assert from "node:assert/strict";
|
|
4
|
-
import { extractOperatorCriteria } from "./operator-criteria.js";
|
|
5
|
+
import { criteriaTextsFromActionEvidence, extractOperatorCriteria, extractOperatorCriteriaFromContract, hasTrailingOperatorTag, operatorCriteriaForSnapshot, } from "./operator-criteria.js";
|
|
5
6
|
test("two [operator] ACs return both; the indented command sub-bullet is collected", () => {
|
|
6
7
|
const criteria = extractOperatorCriteria([
|
|
7
8
|
"- [ ] Agent can list sessions from the registry",
|
|
@@ -26,15 +27,51 @@ test("tag case variants match: [OPERATOR], [Operator], [oPeRaToR]", () => {
|
|
|
26
27
|
const criteria = extractOperatorCriteria(["- [ ] First [OPERATOR]", "- [ ] Second [Operator]", "- [ ] Third [oPeRaToR]"].join("\n"));
|
|
27
28
|
assert.equal(criteria.length, 3);
|
|
28
29
|
});
|
|
29
|
-
test("tag
|
|
30
|
+
test("NOT-575: only the trailing tag decides — leading, middle, and bare mention do not gate", () => {
|
|
30
31
|
const criteria = extractOperatorCriteria([
|
|
31
32
|
"- [ ] [operator] Leading tag proves login",
|
|
32
33
|
"- [ ] Middle [operator] tag proves login",
|
|
33
34
|
"- [ ] Trailing tag proves login [operator]",
|
|
34
35
|
"- [ ] [operator]",
|
|
35
36
|
].join("\n"));
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
// The bare `[operator]` line IS a trailing tag (the whole text is the tag);
|
|
38
|
+
// leading and middle mentions never open the gate.
|
|
39
|
+
assert.equal(criteria.length, 2);
|
|
40
|
+
assert.equal(criteria[0].text, "Trailing tag proves login [operator]");
|
|
41
|
+
assert.equal(criteria[1].text, "[operator]");
|
|
42
|
+
});
|
|
43
|
+
test("NOT-575: a criterion ending in [agent] whose text mentions [operator] is not flagged", () => {
|
|
44
|
+
// The NOT-568 shape: the [agent] criterion's prose merely contained the
|
|
45
|
+
// string [operator], while the real [operator] criterion gated.
|
|
46
|
+
const criteria = extractOperatorCriteria([
|
|
47
|
+
"- [ ] Verify the [operator] handoff renders for the agent review [agent]",
|
|
48
|
+
" Evidence: agent run | run the render test | green",
|
|
49
|
+
"- [ ] Operator can sign in with SSO and see the org dashboard [operator]",
|
|
50
|
+
" Evidence: operator run | `npm run probe:sso -- --env staging` | dashboard lists orgs",
|
|
51
|
+
].join("\n"));
|
|
52
|
+
assert.equal(criteria.length, 1);
|
|
53
|
+
assert.equal(criteria[0].text, "Operator can sign in with SSO and see the org dashboard [operator]");
|
|
54
|
+
assert.deepEqual(criteria[0].commands, [
|
|
55
|
+
"Evidence: operator run | `npm run probe:sso -- --env staging` | dashboard lists orgs",
|
|
56
|
+
]);
|
|
57
|
+
});
|
|
58
|
+
test("NOT-575: trailing-tag matching is case-insensitive and tolerates trailing whitespace", () => {
|
|
59
|
+
const criteria = extractOperatorCriteria(["- [ ] First [OPERATOR] ", "- [ ] Second [Operator]\t", "- [ ] Third [oPeRaToR]"].join("\n"));
|
|
60
|
+
assert.equal(criteria.length, 3);
|
|
61
|
+
});
|
|
62
|
+
test("NOT-575: hasTrailingOperatorTag — last tag wins, punctuation after the tag is not a tag", () => {
|
|
63
|
+
assert.equal(hasTrailingOperatorTag("Proves login [operator]"), true);
|
|
64
|
+
assert.equal(hasTrailingOperatorTag("Proves login [OPERATOR]"), true);
|
|
65
|
+
assert.equal(hasTrailingOperatorTag("Proves login [operator] "), true);
|
|
66
|
+
assert.equal(hasTrailingOperatorTag("[operator]"), true);
|
|
67
|
+
assert.equal(hasTrailingOperatorTag("Mentions [operator] then ends [agent]"), false);
|
|
68
|
+
assert.equal(hasTrailingOperatorTag("[operator] Leading tag proves login"), false);
|
|
69
|
+
assert.equal(hasTrailingOperatorTag("Proves login [operator]."), false);
|
|
70
|
+
assert.equal(hasTrailingOperatorTag("Proves login [operators]"), false);
|
|
71
|
+
assert.equal(hasTrailingOperatorTag("Two tags [agent] [operator]"), true);
|
|
72
|
+
assert.equal(hasTrailingOperatorTag("Two tags [operator] [agent]"), false);
|
|
73
|
+
assert.equal(hasTrailingOperatorTag("No tag at all"), false);
|
|
74
|
+
assert.equal(hasTrailingOperatorTag(""), false);
|
|
38
75
|
});
|
|
39
76
|
test("multiple indented sub-bullets all collect; blank lines inside the block are skipped", () => {
|
|
40
77
|
const criteria = extractOperatorCriteria([
|
|
@@ -76,3 +113,139 @@ test("the next top-level checkbox ends the command block; prose ends it too", ()
|
|
|
76
113
|
test("[agent] in AC text is not an operator criterion", () => {
|
|
77
114
|
assert.deepEqual(extractOperatorCriteria("- [ ] Agent lists sessions [agent]\n"), []);
|
|
78
115
|
});
|
|
116
|
+
test("NOT-575: the contract's indented Evidence: line is collected, not a block terminator", () => {
|
|
117
|
+
const criteria = extractOperatorCriteria([
|
|
118
|
+
"- [ ] Paid checkout works end to end [operator]",
|
|
119
|
+
" Evidence: operator run | `npm run probe:checkout -- --env staging` | receipt shown",
|
|
120
|
+
" - see docs/probes/checkout.md for the test card",
|
|
121
|
+
].join("\n"));
|
|
122
|
+
assert.equal(criteria.length, 1);
|
|
123
|
+
assert.deepEqual(criteria[0].commands, [
|
|
124
|
+
"Evidence: operator run | `npm run probe:checkout -- --env staging` | receipt shown",
|
|
125
|
+
"see docs/probes/checkout.md for the test card",
|
|
126
|
+
]);
|
|
127
|
+
});
|
|
128
|
+
test("NOT-575: the nested-bullet Evidence form collects the same way", () => {
|
|
129
|
+
const criteria = extractOperatorCriteria(["- [ ] Paid checkout works end to end [operator]", " * Evidence: operator run | paste the output | reviewed"].join("\n"));
|
|
130
|
+
assert.equal(criteria.length, 1);
|
|
131
|
+
assert.deepEqual(criteria[0].commands, ["Evidence: operator run | paste the output | reviewed"]);
|
|
132
|
+
});
|
|
133
|
+
test("NOT-575: contract criteria gate on the trailing tag with their evidence as the command", () => {
|
|
134
|
+
const criteria = extractOperatorCriteriaFromContract({
|
|
135
|
+
version: "v1",
|
|
136
|
+
executionMode: "bug fix",
|
|
137
|
+
nonGoals: ["x"],
|
|
138
|
+
exitPredicate: "done",
|
|
139
|
+
onePrStoppingPoint: "stop",
|
|
140
|
+
acceptanceCriteria: [
|
|
141
|
+
{ text: "Verify the [operator] handoff renders [agent]", evidence: "agent run" },
|
|
142
|
+
{ text: "Operator signs in with SSO [operator]", evidence: "operator run | paste the output" },
|
|
143
|
+
{ text: "Untagged work", evidence: null },
|
|
144
|
+
],
|
|
145
|
+
});
|
|
146
|
+
assert.equal(criteria.length, 1);
|
|
147
|
+
assert.equal(criteria[0].text, "Operator signs in with SSO [operator]");
|
|
148
|
+
assert.deepEqual(criteria[0].commands, ["Evidence: operator run | paste the output"]);
|
|
149
|
+
assert.deepEqual(extractOperatorCriteriaFromContract(null), []);
|
|
150
|
+
assert.deepEqual(extractOperatorCriteriaFromContract(undefined), []);
|
|
151
|
+
});
|
|
152
|
+
test("NOT-575: the snapshot union dedupes AC text and contract by exact criterion text", () => {
|
|
153
|
+
const merged = operatorCriteriaForSnapshot({
|
|
154
|
+
acceptanceCriteria: "- [ ] Operator signs in with SSO [operator]\n Evidence: ac text evidence",
|
|
155
|
+
executionContract: {
|
|
156
|
+
version: "v1",
|
|
157
|
+
executionMode: "bug fix",
|
|
158
|
+
nonGoals: ["x"],
|
|
159
|
+
exitPredicate: "done",
|
|
160
|
+
onePrStoppingPoint: "stop",
|
|
161
|
+
acceptanceCriteria: [
|
|
162
|
+
{ text: "Operator signs in with SSO [operator]", evidence: "contract evidence" },
|
|
163
|
+
{ text: "Operator completes a paid checkout [operator]", evidence: "checkout evidence" },
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
// The shared criterion appears once (AC-text form wins); the contract-only
|
|
168
|
+
// criterion still gates even though the AC string diverges from it.
|
|
169
|
+
assert.equal(merged.length, 2);
|
|
170
|
+
assert.equal(merged[0].text, "Operator signs in with SSO [operator]");
|
|
171
|
+
assert.deepEqual(merged[0].commands, ["Evidence: ac text evidence"]);
|
|
172
|
+
assert.equal(merged[1].text, "Operator completes a paid checkout [operator]");
|
|
173
|
+
assert.deepEqual(merged[1].commands, ["Evidence: checkout evidence"]);
|
|
174
|
+
});
|
|
175
|
+
test("NOT-575 repair 2: a Linear-escaped trailing \\[operator\\] gates with its Evidence line", () => {
|
|
176
|
+
// Linear markdown escapes the tag brackets; intake and the contract
|
|
177
|
+
// compiler keep the raw `\[operator\]` text, so the gate must accept it —
|
|
178
|
+
// the NOT-567/569-572 tickets merged with no operator action because it did not.
|
|
179
|
+
const criteria = extractOperatorCriteria([
|
|
180
|
+
"- [ ] Agent can list sessions from the registry \\[agent\\]",
|
|
181
|
+
" Evidence: unit tests | run the registry suite | green",
|
|
182
|
+
"- [ ] Operator can sign in with SSO and see the org dashboard \\[operator\\]",
|
|
183
|
+
" Evidence: operator run | `npm run probe:sso -- --env staging` | dashboard lists orgs",
|
|
184
|
+
].join("\n"));
|
|
185
|
+
assert.equal(criteria.length, 1);
|
|
186
|
+
assert.equal(criteria[0].text, "Operator can sign in with SSO and see the org dashboard \\[operator\\]");
|
|
187
|
+
assert.deepEqual(criteria[0].commands, [
|
|
188
|
+
"Evidence: operator run | `npm run probe:sso -- --env staging` | dashboard lists orgs",
|
|
189
|
+
]);
|
|
190
|
+
});
|
|
191
|
+
test("NOT-575 repair 2: an escaped \\[agent\\] line mentioning [operator] is not flagged", () => {
|
|
192
|
+
// The NOT-568 mis-flag shape under Linear escaping: the [agent]
|
|
193
|
+
// criterion's prose contains the string [operator] (backticked, unescaped)
|
|
194
|
+
// but its trailing tag is `\[agent\]` — never a gate. The genuine escaped
|
|
195
|
+
// `\[operator\]` criterion alongside it still gates.
|
|
196
|
+
const criteria = extractOperatorCriteria([
|
|
197
|
+
"- [ ] Verify the `[operator]` handoff renders for the agent review \\[agent\\]",
|
|
198
|
+
" Evidence: agent run | run the render test | green",
|
|
199
|
+
"- [ ] Operator can sign in with SSO \\[operator\\]",
|
|
200
|
+
" Evidence: operator run | `npm run probe:sso` | dashboard shown",
|
|
201
|
+
].join("\n"));
|
|
202
|
+
assert.equal(criteria.length, 1);
|
|
203
|
+
assert.equal(criteria[0].text, "Operator can sign in with SSO \\[operator\\]");
|
|
204
|
+
});
|
|
205
|
+
test("NOT-575 repair 2: hasTrailingOperatorTag accepts the escaped tag, still rejects escaped non-tags", () => {
|
|
206
|
+
assert.equal(hasTrailingOperatorTag("Proves login \\[operator\\]"), true);
|
|
207
|
+
assert.equal(hasTrailingOperatorTag("Proves login \\[OPERATOR\\]"), true);
|
|
208
|
+
assert.equal(hasTrailingOperatorTag("Proves login \\[operator\\] "), true);
|
|
209
|
+
assert.equal(hasTrailingOperatorTag("\\[operator\\]"), true);
|
|
210
|
+
assert.equal(hasTrailingOperatorTag("Mentions [operator] then ends \\[agent\\]"), false);
|
|
211
|
+
assert.equal(hasTrailingOperatorTag("Proves login \\[agent\\]"), false);
|
|
212
|
+
assert.equal(hasTrailingOperatorTag("Proves login \\[operators\\]"), false);
|
|
213
|
+
assert.equal(hasTrailingOperatorTag("Proves login \\[operator\\]."), false);
|
|
214
|
+
assert.equal(hasTrailingOperatorTag("Two tags \\[agent\\] \\[operator\\]"), true);
|
|
215
|
+
assert.equal(hasTrailingOperatorTag("Two tags [operator] \\[agent\\]"), false);
|
|
216
|
+
});
|
|
217
|
+
test("NOT-575 repair 2: contract criteria gate on the escaped trailing tag", () => {
|
|
218
|
+
const criteria = extractOperatorCriteriaFromContract({
|
|
219
|
+
version: "v1",
|
|
220
|
+
executionMode: "bug fix",
|
|
221
|
+
nonGoals: ["x"],
|
|
222
|
+
exitPredicate: "done",
|
|
223
|
+
onePrStoppingPoint: "stop",
|
|
224
|
+
acceptanceCriteria: [
|
|
225
|
+
{ text: "Verify the `[operator]` handoff renders \\[agent\\]", evidence: "agent run" },
|
|
226
|
+
{ text: "Operator signs in with SSO \\[operator\\]", evidence: "operator run | paste the output" },
|
|
227
|
+
],
|
|
228
|
+
});
|
|
229
|
+
assert.equal(criteria.length, 1);
|
|
230
|
+
assert.equal(criteria[0].text, "Operator signs in with SSO \\[operator\\]");
|
|
231
|
+
assert.deepEqual(criteria[0].commands, ["Evidence: operator run | paste the output"]);
|
|
232
|
+
});
|
|
233
|
+
test("NOT-575: criteriaTextsFromActionEvidence reads the gated list, null when unreadable", () => {
|
|
234
|
+
assert.deepEqual(criteriaTextsFromActionEvidence({
|
|
235
|
+
evidenceJson: JSON.stringify({
|
|
236
|
+
operatorVerification: {
|
|
237
|
+
headSha: "abc",
|
|
238
|
+
criteria: [
|
|
239
|
+
{ text: "First [operator]", commands: [] },
|
|
240
|
+
{ text: "Second [operator]", commands: ["Evidence: x"] },
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
}),
|
|
244
|
+
}), ["First [operator]", "Second [operator]"]);
|
|
245
|
+
assert.equal(criteriaTextsFromActionEvidence({ evidenceJson: null }), null);
|
|
246
|
+
assert.equal(criteriaTextsFromActionEvidence({ evidenceJson: "not json" }), null);
|
|
247
|
+
assert.equal(criteriaTextsFromActionEvidence({ evidenceJson: JSON.stringify({}) }), null);
|
|
248
|
+
assert.equal(criteriaTextsFromActionEvidence({
|
|
249
|
+
evidenceJson: JSON.stringify({ operatorVerification: { criteria: "nope" } }),
|
|
250
|
+
}), null);
|
|
251
|
+
});
|