@aviaratech/ai-delivery 0.3.32 → 0.3.33
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/README.md +116 -3
- package/dist/cli.js +28 -3
- package/dist/cli.js.map +1 -1
- package/dist/cliResult.js +10 -0
- package/dist/cliResult.js.map +1 -1
- package/dist/cliResult.test.js +61 -0
- package/dist/cliResult.test.js.map +1 -1
- package/dist/config/deliveryConfig.d.ts +36 -0
- package/dist/config/deliveryConfig.js +27 -2
- package/dist/config/deliveryConfig.js.map +1 -1
- package/dist/config/deliveryConfig.test.js +39 -2
- package/dist/config/deliveryConfig.test.js.map +1 -1
- package/dist/currentTrackingScenario.test.js +5 -1
- package/dist/currentTrackingScenario.test.js.map +1 -1
- package/dist/dispatch.d.ts +2 -0
- package/dist/dispatch.js +15 -4
- package/dist/dispatch.js.map +1 -1
- package/dist/errors.d.ts +11 -0
- package/dist/errors.js +35 -0
- package/dist/errors.js.map +1 -1
- package/dist/fixtures/discovery.d.ts +11 -0
- package/dist/fixtures/inertTarget.d.ts +5 -0
- package/dist/fixtures/issue63.d.ts +11 -0
- package/dist/fixtures/issue63.js +16 -9
- package/dist/fixtures/issue63.js.map +1 -1
- package/dist/github/client.d.ts +3 -0
- package/dist/github/client.js +21 -10
- package/dist/github/client.js.map +1 -1
- package/dist/github/commandIdentityPolicy.js +1 -0
- package/dist/github/commandIdentityPolicy.js.map +1 -1
- package/dist/github/machineAuth.test.js +20 -0
- package/dist/github/machineAuth.test.js.map +1 -1
- package/dist/github/projectDelivery.d.ts +3 -0
- package/dist/github/projectDelivery.js +44 -12
- package/dist/github/projectDelivery.js.map +1 -1
- package/dist/issue.d.ts +53 -6
- package/dist/issue.js +696 -58
- package/dist/issue.js.map +1 -1
- package/dist/issueBatchUpdate.test.d.ts +1 -0
- package/dist/issueBatchUpdate.test.js +730 -0
- package/dist/issueBatchUpdate.test.js.map +1 -0
- package/dist/issueBlockerGuard.test.js +78 -0
- package/dist/issueBlockerGuard.test.js.map +1 -1
- package/dist/issueContract.d.ts +68 -2
- package/dist/issueContract.js +101 -9
- package/dist/issueContract.js.map +1 -1
- package/dist/issueContract.test.d.ts +5 -0
- package/dist/issueContract.test.js +28 -1
- package/dist/issueContract.test.js.map +1 -1
- package/dist/issueIntake.test.js +972 -19
- package/dist/issueIntake.test.js.map +1 -1
- package/dist/issueJournal.js +12 -8
- package/dist/issueJournal.js.map +1 -1
- package/dist/issueJournal.test.js +138 -0
- package/dist/issueJournal.test.js.map +1 -1
- package/dist/mcp/index.js +20 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/tools.d.ts +104 -12
- package/dist/mcp/tools.js +50 -34
- package/dist/mcp/tools.js.map +1 -1
- package/dist/services/agentReadinessService.js +2 -0
- package/dist/services/agentReadinessService.js.map +1 -1
- package/package.json +1 -1
- package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
- package/plugins/ai-delivery/plugin.json +1 -1
- package/plugins/ai-delivery/runtime/dist/cli.js +67 -55
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/plugins/ai-delivery/skills/intake-create/SKILL.md +22 -2
|
@@ -0,0 +1,730 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { afterEach, test, vi } from 'vitest';
|
|
3
|
+
import * as issue from './issue.js';
|
|
4
|
+
import * as configuration from './config/deliveryConfig.js';
|
|
5
|
+
import { executeTool } from './dispatch.js';
|
|
6
|
+
import { getAiDeliveryMcpTool } from './mcp/tools.js';
|
|
7
|
+
import { DeliveryError, getRateLimitDiagnostics } from './errors.js';
|
|
8
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
9
|
+
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
|
|
10
|
+
import { createAiDeliveryMcpServer } from './mcp/index.js';
|
|
11
|
+
import { syntheticDiscoveryConfig } from './fixtures/discovery.js';
|
|
12
|
+
import { IssueFields, renderIssueBody } from './issueContract.js';
|
|
13
|
+
function batchFixture() {
|
|
14
|
+
const rows = new Map(Array.from({ length: 5 }, (_, index) => {
|
|
15
|
+
const number = index + 1;
|
|
16
|
+
return [
|
|
17
|
+
number,
|
|
18
|
+
{
|
|
19
|
+
number,
|
|
20
|
+
id: number + 100,
|
|
21
|
+
node_id: `ISSUE${number}`,
|
|
22
|
+
title: `Synthetic item ${number}`,
|
|
23
|
+
body: renderIssueBody(IssueFields.parse({ title: `Synthetic item ${number}`, draft: true })),
|
|
24
|
+
state: 'open',
|
|
25
|
+
type: { name: 'Task' },
|
|
26
|
+
labels: [],
|
|
27
|
+
milestone: null,
|
|
28
|
+
html_url: `https://github.com/example/widget/issues/${number}`,
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
}));
|
|
32
|
+
const writes = [];
|
|
33
|
+
const controls = {
|
|
34
|
+
failAfterWrite: 0,
|
|
35
|
+
failReadback: 0,
|
|
36
|
+
driftOnRead: 0,
|
|
37
|
+
rateLimited: 0,
|
|
38
|
+
ignoreLabels: false,
|
|
39
|
+
parentRepository: 'example/widget',
|
|
40
|
+
parentNodeId: '',
|
|
41
|
+
};
|
|
42
|
+
const reads = new Map();
|
|
43
|
+
const metadata = new Map();
|
|
44
|
+
const parents = new Map();
|
|
45
|
+
const blockers = new Map();
|
|
46
|
+
const reasons = new Map();
|
|
47
|
+
const duplicates = new Map();
|
|
48
|
+
const fieldValues = (number) => Object.entries(metadata.get(number) ?? {}).map(([id, value]) => ({
|
|
49
|
+
data_type: 'single_select',
|
|
50
|
+
issue_field_id: Number(id),
|
|
51
|
+
issue_field_name: id === '101' ? 'Estimate' : 'Urgency',
|
|
52
|
+
value,
|
|
53
|
+
}));
|
|
54
|
+
const comments = [];
|
|
55
|
+
const statuses = new Map(Array.from(rows.keys(), (number) => [number, 'Active']));
|
|
56
|
+
const context = {
|
|
57
|
+
root: '/synthetic',
|
|
58
|
+
repo: { owner: 'example', repo: 'widget' },
|
|
59
|
+
config: syntheticDiscoveryConfig,
|
|
60
|
+
projectConfiguration: {
|
|
61
|
+
projectId: 'PROJECT',
|
|
62
|
+
projectNumber: 1,
|
|
63
|
+
title: 'Delivery',
|
|
64
|
+
writable: true,
|
|
65
|
+
pointsFieldId: 'POINTS',
|
|
66
|
+
priorityFieldId: 'PRIORITY',
|
|
67
|
+
statusFieldId: 'STATUS',
|
|
68
|
+
statusOptionIds: { Todo: 'TODO', 'In Progress': 'ACTIVE', Blocked: 'BLOCKED', Done: 'DONE' },
|
|
69
|
+
settings: {
|
|
70
|
+
number: 1,
|
|
71
|
+
title: 'Delivery',
|
|
72
|
+
statusField: 'Flow',
|
|
73
|
+
statuses: { Todo: 'Queued', 'In Progress': 'Active', Blocked: 'Waiting', Done: 'Shipped' },
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
clients: {
|
|
77
|
+
role: 'author',
|
|
78
|
+
authenticatedAuthor: async () => ({ actorLogin: 'operator', credentialIdentity: 'user:1' }),
|
|
79
|
+
rest: {
|
|
80
|
+
issues: {
|
|
81
|
+
get: async ({ issue_number }) => {
|
|
82
|
+
reads.set(issue_number, (reads.get(issue_number) ?? 0) + 1);
|
|
83
|
+
if (controls.failReadback === issue_number && writes.includes(`update:${issue_number}`))
|
|
84
|
+
throw new Error('Synthetic readback transport failure');
|
|
85
|
+
const row = rows.get(issue_number);
|
|
86
|
+
if (row && controls.driftOnRead === issue_number && reads.get(issue_number) === 2)
|
|
87
|
+
row.body = 'Concurrent operator edit';
|
|
88
|
+
if (!row)
|
|
89
|
+
throw new Error('Synthetic issue unavailable');
|
|
90
|
+
return { data: structuredClone(row) };
|
|
91
|
+
},
|
|
92
|
+
listComments: async ({ issue_number }) => ({
|
|
93
|
+
data: comments.filter((comment) => comment.issue_url.endsWith('/' + String(issue_number))),
|
|
94
|
+
}),
|
|
95
|
+
listLabelsForRepo: async () => ({ data: [{ name: 'enhancement' }] }),
|
|
96
|
+
listSubIssues: async () => ({ data: [] }),
|
|
97
|
+
addSubIssue: async ({ issue_number, sub_issue_id }) => {
|
|
98
|
+
writes.push('parent');
|
|
99
|
+
parents.set(sub_issue_id - 100, issue_number);
|
|
100
|
+
return { data: {} };
|
|
101
|
+
},
|
|
102
|
+
removeSubIssue: async ({ sub_issue_id }) => {
|
|
103
|
+
writes.push('parent');
|
|
104
|
+
parents.delete(sub_issue_id - 100);
|
|
105
|
+
return { data: {} };
|
|
106
|
+
},
|
|
107
|
+
createComment: async ({ issue_number, body }) => {
|
|
108
|
+
writes.push('comment');
|
|
109
|
+
const comment = {
|
|
110
|
+
id: comments.length + 1000,
|
|
111
|
+
body,
|
|
112
|
+
html_url: `https://github.com/example/widget/issues/${issue_number}#issuecomment-${comments.length + 1000}`,
|
|
113
|
+
user: { login: 'operator' },
|
|
114
|
+
issue_url: `https://api.github.com/repos/example/widget/issues/${issue_number}`,
|
|
115
|
+
};
|
|
116
|
+
comments.push(comment);
|
|
117
|
+
return { data: comment };
|
|
118
|
+
},
|
|
119
|
+
getComment: async ({ comment_id }) => ({
|
|
120
|
+
data: comments.find((comment) => comment.id === comment_id),
|
|
121
|
+
}),
|
|
122
|
+
update: async ({ issue_number, ...patch }) => {
|
|
123
|
+
writes.push(`update:${issue_number}`);
|
|
124
|
+
if (controls.rateLimited === issue_number)
|
|
125
|
+
throw Object.assign(new Error('PRIVATE_REMOTE_CONTENT'), {
|
|
126
|
+
status: 429,
|
|
127
|
+
response: {
|
|
128
|
+
headers: {
|
|
129
|
+
'retry-after': '60',
|
|
130
|
+
'x-ratelimit-remaining': '0',
|
|
131
|
+
'x-ratelimit-reset': '1900000000',
|
|
132
|
+
authorization: 'PRIVATE_TOKEN',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
const row = rows.get(issue_number);
|
|
137
|
+
if (typeof patch.title === 'string')
|
|
138
|
+
row.title = patch.title;
|
|
139
|
+
if (typeof patch.body === 'string')
|
|
140
|
+
row.body = patch.body;
|
|
141
|
+
if (typeof patch.type === 'string')
|
|
142
|
+
row.type = { name: patch.type };
|
|
143
|
+
if (Array.isArray(patch.labels) && !controls.ignoreLabels)
|
|
144
|
+
row.labels = patch.labels.map((label) => label.toLowerCase());
|
|
145
|
+
if (patch.milestone !== undefined)
|
|
146
|
+
Object.assign(row, { milestone: patch.milestone === null ? null : { number: patch.milestone } });
|
|
147
|
+
if (typeof patch.state === 'string') {
|
|
148
|
+
row.state = patch.state;
|
|
149
|
+
reasons.set(issue_number, patch.state === 'closed'
|
|
150
|
+
? (typeof patch.state_reason === 'string' ? patch.state_reason : 'completed').toUpperCase()
|
|
151
|
+
: 'REOPENED');
|
|
152
|
+
}
|
|
153
|
+
if (typeof patch.duplicate_issue_id === 'number')
|
|
154
|
+
duplicates.set(issue_number, patch.duplicate_issue_id - 100);
|
|
155
|
+
if (controls.failAfterWrite === issue_number) {
|
|
156
|
+
controls.failAfterWrite = 0;
|
|
157
|
+
throw new Error('Synthetic acknowledgement lost');
|
|
158
|
+
}
|
|
159
|
+
return { data: rows.get(issue_number) };
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
paginate: async (_method, { issue_number }) => [...parents].filter(([, parent]) => parent === issue_number).map(([number]) => rows.get(number)),
|
|
163
|
+
request: async (route, params) => {
|
|
164
|
+
if (route.startsWith('GET /orgs'))
|
|
165
|
+
return {
|
|
166
|
+
data: Object.values(syntheticDiscoveryConfig.native)
|
|
167
|
+
.filter((field) => typeof field === 'object' && field !== null && 'databaseId' in field)
|
|
168
|
+
.map((field) => ({
|
|
169
|
+
id: Number(field.databaseId),
|
|
170
|
+
name: field.name,
|
|
171
|
+
data_type: 'single_select',
|
|
172
|
+
options: field.values.map((name) => ({ name })),
|
|
173
|
+
})),
|
|
174
|
+
};
|
|
175
|
+
if (route.startsWith('POST ')) {
|
|
176
|
+
writes.push('metadata');
|
|
177
|
+
metadata.set(params.issue_number, {
|
|
178
|
+
...metadata.get(params.issue_number),
|
|
179
|
+
...Object.fromEntries(params.issue_field_values.map((value) => [String(value.field_id), value.value])),
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (route.startsWith('DELETE ')) {
|
|
183
|
+
writes.push('metadata');
|
|
184
|
+
delete metadata.get(params.issue_number)[String(params.issue_field_id)];
|
|
185
|
+
}
|
|
186
|
+
return { data: fieldValues(params.issue_number) };
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
graphql: async (query, variables) => {
|
|
190
|
+
const numeric = variables.number ?? variables.issueNumber;
|
|
191
|
+
const nodeId = variables.issueNodeId ?? variables.itemId ?? '1';
|
|
192
|
+
const number = typeof numeric === 'number' ? numeric : typeof nodeId === 'string' ? Number(nodeId.replace(/\D/gu, '')) : NaN;
|
|
193
|
+
if (query.includes('IssueClosureReadback'))
|
|
194
|
+
return {
|
|
195
|
+
repository: {
|
|
196
|
+
issue: {
|
|
197
|
+
number,
|
|
198
|
+
repository: { nameWithOwner: 'example/widget' },
|
|
199
|
+
state: rows.get(number).state.toUpperCase(),
|
|
200
|
+
stateReason: reasons.get(number) ?? null,
|
|
201
|
+
duplicateOf: duplicates.has(number)
|
|
202
|
+
? { number: duplicates.get(number), repository: { nameWithOwner: 'example/widget' } }
|
|
203
|
+
: null,
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
if (query.includes('blockedBy(first:'))
|
|
208
|
+
return {
|
|
209
|
+
repository: {
|
|
210
|
+
issue: {
|
|
211
|
+
parent: parents.has(number)
|
|
212
|
+
? {
|
|
213
|
+
id: controls.parentNodeId || `ISSUE${parents.get(number)}`,
|
|
214
|
+
number: parents.get(number),
|
|
215
|
+
repository: { nameWithOwner: controls.parentRepository },
|
|
216
|
+
}
|
|
217
|
+
: null,
|
|
218
|
+
blockedBy: {
|
|
219
|
+
nodes: (blockers.get(number) ?? []).map((n) => ({
|
|
220
|
+
id: `ISSUE${n}`,
|
|
221
|
+
number: n,
|
|
222
|
+
state: rows.get(n).state.toUpperCase(),
|
|
223
|
+
title: rows.get(n).title,
|
|
224
|
+
repository: { nameWithOwner: 'example/widget' },
|
|
225
|
+
})),
|
|
226
|
+
pageInfo: { hasNextPage: false, endCursor: null },
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
if (query.includes('mutation') && (query.includes('addBlockedBy') || query.includes('removeBlockedBy'))) {
|
|
232
|
+
writes.push('dependency');
|
|
233
|
+
const dependent = Number(String(variables.issue).replace(/\D/gu, ''));
|
|
234
|
+
const blocker = Number(String(variables.blocking).replace(/\D/gu, ''));
|
|
235
|
+
blockers.set(dependent, query.includes('addBlockedBy')
|
|
236
|
+
? [...new Set([...(blockers.get(dependent) ?? []), blocker])]
|
|
237
|
+
: (blockers.get(dependent) ?? []).filter((n) => n !== blocker));
|
|
238
|
+
return {};
|
|
239
|
+
}
|
|
240
|
+
if (query.includes('ProjectDeliveryItems'))
|
|
241
|
+
return {
|
|
242
|
+
organization: {
|
|
243
|
+
projectV2: {
|
|
244
|
+
items: {
|
|
245
|
+
nodes: [...rows.keys()].map((n) => ({
|
|
246
|
+
id: `ITEM${n}`,
|
|
247
|
+
isArchived: false,
|
|
248
|
+
content: { id: `ISSUE${n}` },
|
|
249
|
+
fieldValueByName: {
|
|
250
|
+
name: statuses.get(n),
|
|
251
|
+
optionId: statuses.get(n) === 'Active'
|
|
252
|
+
? 'ACTIVE'
|
|
253
|
+
: statuses.get(n) === 'Shipped'
|
|
254
|
+
? 'DONE'
|
|
255
|
+
: statuses.get(n) === 'Waiting'
|
|
256
|
+
? 'BLOCKED'
|
|
257
|
+
: 'TODO',
|
|
258
|
+
},
|
|
259
|
+
})),
|
|
260
|
+
pageInfo: { hasNextPage: false, endCursor: null },
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
if (query.includes('UpdateProjectDeliveryStatus')) {
|
|
266
|
+
writes.push('project');
|
|
267
|
+
statuses.set(number, variables.optionId === 'DONE'
|
|
268
|
+
? 'Shipped'
|
|
269
|
+
: variables.optionId === 'BLOCKED'
|
|
270
|
+
? 'Waiting'
|
|
271
|
+
: variables.optionId === 'ACTIVE'
|
|
272
|
+
? 'Active'
|
|
273
|
+
: 'Queued');
|
|
274
|
+
return { updateProjectV2ItemFieldValue: { projectV2Item: { id: `ITEM${number}` } } };
|
|
275
|
+
}
|
|
276
|
+
if (query.includes('ProjectDeliveryItemReadback'))
|
|
277
|
+
return {
|
|
278
|
+
node: {
|
|
279
|
+
id: `ITEM${number}`,
|
|
280
|
+
isArchived: false,
|
|
281
|
+
project: { id: 'PROJECT', number: 1 },
|
|
282
|
+
content: { id: `ISSUE${number}` },
|
|
283
|
+
fieldValueByName: {
|
|
284
|
+
name: statuses.get(number),
|
|
285
|
+
optionId: statuses.get(number) === 'Active'
|
|
286
|
+
? 'ACTIVE'
|
|
287
|
+
: statuses.get(number) === 'Shipped'
|
|
288
|
+
? 'DONE'
|
|
289
|
+
: statuses.get(number) === 'Waiting'
|
|
290
|
+
? 'BLOCKED'
|
|
291
|
+
: 'TODO',
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
throw new Error('Unexpected synthetic native query');
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
vi.spyOn(configuration, 'loadDeliverySettings').mockResolvedValue({
|
|
300
|
+
roles: { author: { identity: 'host-author', authSource: 'personal' }, reviewer: { identity: 'app-reviewer' } },
|
|
301
|
+
});
|
|
302
|
+
vi.spyOn(issue, 'loadDeliveryContext').mockResolvedValue(context);
|
|
303
|
+
return { context, rows, writes, comments, controls, metadata, parents, blockers, statuses };
|
|
304
|
+
}
|
|
305
|
+
afterEach(() => vi.restoreAllMocks());
|
|
306
|
+
test('batch dry run returns each planned title change without native writes', async () => {
|
|
307
|
+
const f = batchFixture();
|
|
308
|
+
const result = (await executeTool('issue_batch_update', {
|
|
309
|
+
repo: 'example/widget',
|
|
310
|
+
dryRun: true,
|
|
311
|
+
items: [
|
|
312
|
+
{ issueNumber: 1, title: 'First requested title' },
|
|
313
|
+
{ issueNumber: 2, title: 'Second requested title' },
|
|
314
|
+
],
|
|
315
|
+
}, { repoRoot: '/synthetic', identity: 'host-author' }));
|
|
316
|
+
assert.equal(result.dryRun, true);
|
|
317
|
+
assert.deepEqual(result.results.map((item) => [item.issueNumber, item.changes.title, item.readback.title]), [
|
|
318
|
+
[1, 'First requested title', 'Synthetic item 1'],
|
|
319
|
+
[2, 'Second requested title', 'Synthetic item 2'],
|
|
320
|
+
]);
|
|
321
|
+
assert.deepEqual(f.writes, []);
|
|
322
|
+
assert.equal(f.rows.get(1).title, 'Synthetic item 1');
|
|
323
|
+
});
|
|
324
|
+
async function runBatch(input) {
|
|
325
|
+
return executeTool('issue_batch_update', { repo: 'example/widget', ...input }, { repoRoot: '/synthetic', identity: 'host-author' });
|
|
326
|
+
}
|
|
327
|
+
test.each([{}, { status: { nextMilestone: 'Run checks' } }, { blockedBy: [2] }])('canonical-body retries with overrides %j preserve generated timestamps and history', async (overrides) => {
|
|
328
|
+
const clock = vi.spyOn(Date, 'now').mockReturnValue(Date.parse('2026-10-17T00:00:00.000Z'));
|
|
329
|
+
const f = batchFixture();
|
|
330
|
+
const body = renderIssueBody(IssueFields.parse({ title: 'Synthetic item 1', draft: true, problem: 'Changed contract' }), {
|
|
331
|
+
state: 'Draft',
|
|
332
|
+
lastUpdated: '2026-01-01T00:00:00.000Z',
|
|
333
|
+
nextMilestone: 'Not started',
|
|
334
|
+
blockers: 'None',
|
|
335
|
+
latestJournal: 'None yet',
|
|
336
|
+
});
|
|
337
|
+
f.statuses.set(1, 'Queued');
|
|
338
|
+
const input = { items: [{ issueNumber: 1, body, preserveHistory: true, ...overrides }] };
|
|
339
|
+
const first = await runBatch(input);
|
|
340
|
+
assert.equal(first.results[0].status, 'applied', JSON.stringify(first));
|
|
341
|
+
const writtenBody = f.rows.get(1).body;
|
|
342
|
+
const writes = [...f.writes];
|
|
343
|
+
const comments = [...f.comments];
|
|
344
|
+
clock.mockReturnValue(Date.parse('2026-10-17T00:01:00.000Z'));
|
|
345
|
+
const retry = await runBatch(input);
|
|
346
|
+
assert.equal(retry.results[0].status, 'unchanged', JSON.stringify(retry));
|
|
347
|
+
assert.equal(f.rows.get(1).body, writtenBody);
|
|
348
|
+
assert.deepEqual(f.writes, writes);
|
|
349
|
+
assert.deepEqual(f.comments, comments);
|
|
350
|
+
clock.mockReturnValue(Date.parse('2026-10-17T00:02:00.000Z'));
|
|
351
|
+
assert.equal((await runBatch(input)).results[0].status, 'unchanged');
|
|
352
|
+
assert.deepEqual(f.writes, writes);
|
|
353
|
+
assert.deepEqual(f.comments, comments);
|
|
354
|
+
});
|
|
355
|
+
test.each([
|
|
356
|
+
['foreign/repository', 'FOREIGN5'],
|
|
357
|
+
['example/widget', 'DIFFERENT5'],
|
|
358
|
+
])('same-number parent in %s with node %s cannot satisfy a batch retry', async (repository, nodeId) => {
|
|
359
|
+
const f = batchFixture();
|
|
360
|
+
const input = { items: [{ issueNumber: 1, parentIssueNumber: 5 }] };
|
|
361
|
+
assert.equal((await runBatch(input)).results[0].status, 'applied');
|
|
362
|
+
const writes = [...f.writes];
|
|
363
|
+
f.controls.parentRepository = repository;
|
|
364
|
+
f.controls.parentNodeId = nodeId;
|
|
365
|
+
const result = await runBatch(input);
|
|
366
|
+
assert.equal(result.results[0].status, 'failed', JSON.stringify(result));
|
|
367
|
+
assert.deepEqual(f.writes, writes);
|
|
368
|
+
});
|
|
369
|
+
test('correctable local batch refusals retain distinct bounded reasons', async () => {
|
|
370
|
+
const f = batchFixture();
|
|
371
|
+
const result = await runBatch({
|
|
372
|
+
items: [
|
|
373
|
+
{ issueNumber: 1, priority: 'Unsupported' },
|
|
374
|
+
{ issueNumber: 2, labels: ['unknown-label-private-content'] },
|
|
375
|
+
{ issueNumber: 3, blocks: [4] },
|
|
376
|
+
],
|
|
377
|
+
});
|
|
378
|
+
assert.deepEqual(result.results.map((item) => item.status), ['failed', 'failed', 'failed']);
|
|
379
|
+
assert.match(result.results[0].reason, /configured Priority/u);
|
|
380
|
+
assert.match(result.results[1].reason, /labels.*selected repository/u);
|
|
381
|
+
assert.match(result.results[2].reason, /overrideReason/u);
|
|
382
|
+
assert.equal(JSON.stringify(result).includes('unknown-label-private-content'), false);
|
|
383
|
+
assert.deepEqual(f.writes, []);
|
|
384
|
+
});
|
|
385
|
+
test('a conflicting closure reason explains the required explicit reopen without more writes', async () => {
|
|
386
|
+
const f = batchFixture();
|
|
387
|
+
assert.equal((await runBatch({ items: [{ issueNumber: 1, state: 'closed', closeReason: 'not_planned' }] })).results[0].status, 'applied');
|
|
388
|
+
const writes = [...f.writes];
|
|
389
|
+
const comments = [...f.comments];
|
|
390
|
+
const result = await runBatch({ items: [{ issueNumber: 1, state: 'closed', closeReason: 'completed' }] });
|
|
391
|
+
assert.equal(result.results[0].status, 'failed');
|
|
392
|
+
assert.match(result.results[0].reason, /different closure evidence; reopen it explicitly/u);
|
|
393
|
+
assert.deepEqual(f.writes, writes);
|
|
394
|
+
assert.deepEqual(f.comments, comments);
|
|
395
|
+
});
|
|
396
|
+
test('unknown remote errors, message getters and proxies retain the generic safe batch failure', async () => {
|
|
397
|
+
const f = batchFixture();
|
|
398
|
+
let inspected = 0;
|
|
399
|
+
const getter = Object.defineProperty(new DeliveryError(''), 'message', {
|
|
400
|
+
get() {
|
|
401
|
+
inspected++;
|
|
402
|
+
throw new Error('PRIVATE_GETTER_CONTENT');
|
|
403
|
+
},
|
|
404
|
+
});
|
|
405
|
+
const proxy = new Proxy(new DeliveryError('PRIVATE_PROXY_CONTENT'), {
|
|
406
|
+
get() {
|
|
407
|
+
inspected++;
|
|
408
|
+
throw new Error('PRIVATE_PROXY_CONTENT');
|
|
409
|
+
},
|
|
410
|
+
getPrototypeOf() {
|
|
411
|
+
inspected++;
|
|
412
|
+
throw new Error('PRIVATE_PROXY_CONTENT');
|
|
413
|
+
},
|
|
414
|
+
});
|
|
415
|
+
const get = vi.spyOn(f.context.clients.rest.issues, 'get');
|
|
416
|
+
for (const error of [new DeliveryError('PRIVATE_REMOTE_CONTENT'), getter, proxy]) {
|
|
417
|
+
get.mockRejectedValue(error);
|
|
418
|
+
const result = await runBatch({ items: [{ issueNumber: 1, title: 'Requested update' }] });
|
|
419
|
+
assert.equal(result.results[0].status, 'failed');
|
|
420
|
+
assert.match(result.results[0].reason, /preparation failed/u);
|
|
421
|
+
assert.equal(JSON.stringify(result).includes('PRIVATE_'), false);
|
|
422
|
+
}
|
|
423
|
+
assert.equal(inspected, 0);
|
|
424
|
+
assert.deepEqual(f.writes, []);
|
|
425
|
+
});
|
|
426
|
+
test('mixed failures retain later results and a rerun reports unchanged native outcomes', async () => {
|
|
427
|
+
const f = batchFixture();
|
|
428
|
+
const input = {
|
|
429
|
+
items: [
|
|
430
|
+
{ issueNumber: 1, title: 'Changed title' },
|
|
431
|
+
{ issueNumber: 99, title: 'Missing target' },
|
|
432
|
+
{ issueNumber: 2, defer: { trigger: 'Review next sprint' } },
|
|
433
|
+
],
|
|
434
|
+
};
|
|
435
|
+
const first = await runBatch(input);
|
|
436
|
+
assert.deepEqual(first.results.map((item) => item.status), ['applied', 'failed', 'applied']);
|
|
437
|
+
assert.equal(first.results[0].readback.title, 'Changed title');
|
|
438
|
+
assert.match(first.results[1].reason, /preparation failed/u);
|
|
439
|
+
assert.match(first.results[1].readbackError, /unavailable/u);
|
|
440
|
+
assert.deepEqual(first.results[2].readback.deferred, { trigger: 'Review next sprint' });
|
|
441
|
+
const writes = f.writes.length;
|
|
442
|
+
const second = await runBatch(input);
|
|
443
|
+
assert.deepEqual(second.results.map((item) => item.status), ['unchanged', 'failed', 'unchanged']);
|
|
444
|
+
assert.equal(f.writes.length, writes);
|
|
445
|
+
});
|
|
446
|
+
test('lost acknowledgement exposes partial state and a rerun completes remaining Project work', async () => {
|
|
447
|
+
const f = batchFixture();
|
|
448
|
+
f.controls.failAfterWrite = 1;
|
|
449
|
+
const input = {
|
|
450
|
+
items: [
|
|
451
|
+
{ issueNumber: 1, title: 'Acknowledgement lost', preserveHistory: true },
|
|
452
|
+
{ issueNumber: 2, title: 'Later item proceeds' },
|
|
453
|
+
],
|
|
454
|
+
};
|
|
455
|
+
const first = await runBatch(input);
|
|
456
|
+
assert.deepEqual(first.results.map((item) => item.status), ['failed', 'applied']);
|
|
457
|
+
assert.equal(first.results[0].readback.title, 'Acknowledgement lost');
|
|
458
|
+
assert.equal(first.results[0].readback.projectStatus, 'In Progress');
|
|
459
|
+
const historyCount = f.comments.length;
|
|
460
|
+
const second = await runBatch(input);
|
|
461
|
+
assert.deepEqual(second.results.map((item) => item.status), ['applied', 'unchanged']);
|
|
462
|
+
assert.equal(second.results[0].readback.projectStatus, 'Todo');
|
|
463
|
+
assert.equal(f.comments.length, historyCount);
|
|
464
|
+
assert.deepEqual((await runBatch(input)).results.map((item) => item.status), ['unchanged', 'unchanged']);
|
|
465
|
+
});
|
|
466
|
+
test('dry run plans close, defer, metadata, parent Points and dependency side effects without writes', async () => {
|
|
467
|
+
const f = batchFixture();
|
|
468
|
+
f.metadata.set(5, { '101': '4' });
|
|
469
|
+
f.statuses.set(4, 'Queued');
|
|
470
|
+
const result = await runBatch({
|
|
471
|
+
dryRun: true,
|
|
472
|
+
items: [
|
|
473
|
+
{ issueNumber: 1, state: 'closed', closeReason: 'duplicate', supersededBy: 5 },
|
|
474
|
+
{ issueNumber: 2, defer: { until: '2026-12-01' }, preserveHistory: true },
|
|
475
|
+
{ issueNumber: 3, labels: ['enhancement'], milestone: 1, points: 2, priority: 'High', parentIssueNumber: 5 },
|
|
476
|
+
{ issueNumber: 4, blockedBy: [2] },
|
|
477
|
+
],
|
|
478
|
+
});
|
|
479
|
+
assert.deepEqual(result.results.map((item) => item.status), ['planned', 'planned', 'planned', 'planned']);
|
|
480
|
+
assert.deepEqual(result.results[2].changes.parentPoints, { issueNumber: 5, points: null });
|
|
481
|
+
assert.deepEqual(result.results[3].changes.blockedBy, [2]);
|
|
482
|
+
assert.equal(result.results[0].changes.closureComment, true);
|
|
483
|
+
assert.deepEqual(f.writes, []);
|
|
484
|
+
assert.deepEqual(f.metadata.get(5), { '101': '4' });
|
|
485
|
+
assert.equal(f.rows.get(1).state, 'open');
|
|
486
|
+
});
|
|
487
|
+
test('unchanged includes labels, metadata, native parent Points and blocker relationships', async () => {
|
|
488
|
+
const f = batchFixture();
|
|
489
|
+
f.metadata.set(5, { '101': '4' });
|
|
490
|
+
f.statuses.set(3, 'Queued');
|
|
491
|
+
const input = {
|
|
492
|
+
items: [
|
|
493
|
+
{
|
|
494
|
+
issueNumber: 3,
|
|
495
|
+
labels: ['enhancement'],
|
|
496
|
+
milestone: 1,
|
|
497
|
+
points: 2,
|
|
498
|
+
priority: 'High',
|
|
499
|
+
parentIssueNumber: 5,
|
|
500
|
+
blockedBy: [2],
|
|
501
|
+
},
|
|
502
|
+
],
|
|
503
|
+
};
|
|
504
|
+
const first = await runBatch(input);
|
|
505
|
+
assert.equal(first.results[0].status, 'applied', JSON.stringify(first));
|
|
506
|
+
assert.deepEqual(first.results[0].readback.labels, ['enhancement']);
|
|
507
|
+
assert.equal(first.results[0].readback.milestone, 1);
|
|
508
|
+
assert.equal(first.results[0].readback.points, 2);
|
|
509
|
+
assert.equal(first.results[0].readback.priority, 'High');
|
|
510
|
+
assert.equal(f.parents.get(3), 5);
|
|
511
|
+
assert.equal(f.metadata.get(5)['101'], undefined);
|
|
512
|
+
assert.deepEqual(f.blockers.get(3), [2]);
|
|
513
|
+
assert.equal((await runBatch(input)).results[0].status, 'unchanged');
|
|
514
|
+
f.metadata.set(5, { '101': '4' });
|
|
515
|
+
assert.equal((await runBatch(input)).results[0].status, 'applied', 'Parent Points repair cannot be classified unchanged');
|
|
516
|
+
});
|
|
517
|
+
test('readback disagreement and unavailable readback remain failures while later items proceed', async () => {
|
|
518
|
+
const f = batchFixture();
|
|
519
|
+
f.controls.ignoreLabels = true;
|
|
520
|
+
const result = await runBatch({
|
|
521
|
+
items: [
|
|
522
|
+
{ issueNumber: 1, labels: ['enhancement'] },
|
|
523
|
+
{ issueNumber: 2, title: 'Later title' },
|
|
524
|
+
],
|
|
525
|
+
});
|
|
526
|
+
assert.deepEqual(result.results.map((item) => item.status), ['failed', 'applied']);
|
|
527
|
+
assert.deepEqual(result.results[0].readback.labels, []);
|
|
528
|
+
f.controls.failReadback = 3;
|
|
529
|
+
const unavailable = await runBatch({
|
|
530
|
+
items: [
|
|
531
|
+
{ issueNumber: 3, title: 'Written before transport failure' },
|
|
532
|
+
{ issueNumber: 4, title: 'Still executed' },
|
|
533
|
+
],
|
|
534
|
+
});
|
|
535
|
+
assert.deepEqual(unavailable.results.map((item) => item.status), ['failed', 'applied']);
|
|
536
|
+
assert.equal(unavailable.results[0].readback, null);
|
|
537
|
+
assert.match(unavailable.results[0].readbackError, /unavailable/u);
|
|
538
|
+
});
|
|
539
|
+
test('content drift after preparation refuses the stale write and preserves the operator edit', async () => {
|
|
540
|
+
const f = batchFixture();
|
|
541
|
+
f.controls.driftOnRead = 1;
|
|
542
|
+
const result = await runBatch({
|
|
543
|
+
items: [
|
|
544
|
+
{ issueNumber: 1, title: 'Stale prepared update' },
|
|
545
|
+
{ issueNumber: 2, title: 'Independent update' },
|
|
546
|
+
],
|
|
547
|
+
});
|
|
548
|
+
assert.deepEqual(result.results.map((item) => item.status), ['failed', 'applied']);
|
|
549
|
+
assert.equal(f.rows.get(1).body, 'Concurrent operator edit');
|
|
550
|
+
assert.equal(f.rows.get(1).title, 'Synthetic item 1');
|
|
551
|
+
});
|
|
552
|
+
test('positive rate exhaustion suppresses remaining calls and exposes only numeric rate diagnostics', async () => {
|
|
553
|
+
const f = batchFixture();
|
|
554
|
+
f.controls.rateLimited = 1;
|
|
555
|
+
const result = await runBatch({
|
|
556
|
+
items: [
|
|
557
|
+
{ issueNumber: 1, title: 'Rate limited' },
|
|
558
|
+
{ issueNumber: 2, title: 'Not attempted' },
|
|
559
|
+
],
|
|
560
|
+
});
|
|
561
|
+
assert.deepEqual(result.results.map((item) => item.status), ['failed', 'failed']);
|
|
562
|
+
assert.deepEqual(result.summary.rateLimits, [{ retryAfterSeconds: 60, resetAtSeconds: 1900000000, remaining: 0 }]);
|
|
563
|
+
assert.match(result.results[1].reason, /Not attempted/u);
|
|
564
|
+
assert.equal(f.rows.get(2).title, 'Synthetic item 2');
|
|
565
|
+
assert.doesNotMatch(JSON.stringify(result), /PRIVATE_REMOTE_CONTENT|PRIVATE_TOKEN|authorization/u);
|
|
566
|
+
assert.equal(getRateLimitDiagnostics({ status: 403, response: { headers: { 'x-ratelimit-remaining': '2' } } }), undefined);
|
|
567
|
+
let getterRead = false;
|
|
568
|
+
assert.equal(getRateLimitDiagnostics({
|
|
569
|
+
get status() {
|
|
570
|
+
getterRead = true;
|
|
571
|
+
return 429;
|
|
572
|
+
},
|
|
573
|
+
}), undefined);
|
|
574
|
+
assert.equal(getterRead, false);
|
|
575
|
+
});
|
|
576
|
+
test('a wrapped native rate error still suppresses later batch writes', async () => {
|
|
577
|
+
const f = batchFixture();
|
|
578
|
+
let observation;
|
|
579
|
+
Object.assign(f.context.clients, { rateLimitObservation: () => observation });
|
|
580
|
+
f.context.clients.rest.issues.update = (async () => {
|
|
581
|
+
observation = { remaining: 0 };
|
|
582
|
+
throw new Error('Dependency helper wrapped the original failure');
|
|
583
|
+
});
|
|
584
|
+
const result = await runBatch({
|
|
585
|
+
items: [
|
|
586
|
+
{ issueNumber: 1, title: 'Wrapped rate failure' },
|
|
587
|
+
{ issueNumber: 2, title: 'Must stay unchanged' },
|
|
588
|
+
],
|
|
589
|
+
});
|
|
590
|
+
assert.equal(result.results[1].reason, 'Not attempted: GitHub rate limit exhausted.');
|
|
591
|
+
assert.deepEqual(result.summary.rateLimits, [{ remaining: 0 }]);
|
|
592
|
+
assert.equal(f.rows.get(2).title, 'Synthetic item 2');
|
|
593
|
+
});
|
|
594
|
+
test('schema, selected repository and author refusals perform no writes; cancellation returns every item', async () => {
|
|
595
|
+
const f = batchFixture();
|
|
596
|
+
for (const input of [
|
|
597
|
+
{ items: [] },
|
|
598
|
+
{ items: Array.from({ length: 51 }, () => ({ issueNumber: 1 })) },
|
|
599
|
+
{ items: [{ issueNumber: 1, undefer: true, defer: {} }] },
|
|
600
|
+
{ items: [{ issueNumber: 1, closeReason: 'completed' }] },
|
|
601
|
+
{ items: [{ issueNumber: 1, privateUnknown: 'HIDDEN_PROPERTY' }] },
|
|
602
|
+
{ items: [{ issueNumber: 1, repo: 'other/repository' }] },
|
|
603
|
+
])
|
|
604
|
+
await assert.rejects(runBatch(input));
|
|
605
|
+
await assert.rejects(executeTool('issue_batch_update', { repo: 'example/widget', items: [{ issueNumber: 1 }] }, { repoRoot: '/synthetic', identity: 'app-reviewer' }), /author/u);
|
|
606
|
+
const abort = new AbortController();
|
|
607
|
+
abort.abort();
|
|
608
|
+
const cancelled = await issue.batchUpdateIssues(f.context, { items: [{ issueNumber: 1 }, { issueNumber: 2 }] }, abort.signal);
|
|
609
|
+
assert.deepEqual(cancelled.results.map((item) => item.status), ['failed', 'failed']);
|
|
610
|
+
assert.deepEqual(f.writes, []);
|
|
611
|
+
const shape = getAiDeliveryMcpTool('issue_update').inputSchema;
|
|
612
|
+
const complete = {
|
|
613
|
+
issueNumber: 1,
|
|
614
|
+
draft: true,
|
|
615
|
+
retainLegacyBody: true,
|
|
616
|
+
status: { latestJournal: 'Checked' },
|
|
617
|
+
labels: [],
|
|
618
|
+
milestone: null,
|
|
619
|
+
parentIssueNumber: null,
|
|
620
|
+
blocks: [],
|
|
621
|
+
blockedBy: [],
|
|
622
|
+
undefer: true,
|
|
623
|
+
preserveHistory: false,
|
|
624
|
+
};
|
|
625
|
+
assert.equal(shape.safeParse(complete).success, true);
|
|
626
|
+
assert.equal(getAiDeliveryMcpTool('issue_batch_update').inputSchema.safeParse({ items: [complete] }).success, true);
|
|
627
|
+
});
|
|
628
|
+
test('close journals, duplicate reason and explicit undefer are idempotent through the batch path', async () => {
|
|
629
|
+
const f = batchFixture();
|
|
630
|
+
const input = {
|
|
631
|
+
items: [
|
|
632
|
+
{ issueNumber: 1, state: 'closed', closeReason: 'duplicate', supersededBy: 5 },
|
|
633
|
+
{ issueNumber: 2, defer: { trigger: 'Quarterly review' } },
|
|
634
|
+
],
|
|
635
|
+
};
|
|
636
|
+
const first = await runBatch(input);
|
|
637
|
+
assert.deepEqual(first.results.map((item) => item.status), ['applied', 'applied']);
|
|
638
|
+
assert.equal(first.results[0].readback.state, 'closed');
|
|
639
|
+
assert.equal(first.results[0].relatedReadback.closeReason, 'duplicate');
|
|
640
|
+
const count = f.comments.length;
|
|
641
|
+
assert.deepEqual((await runBatch(input)).results.map((item) => item.status), ['unchanged', 'unchanged']);
|
|
642
|
+
assert.equal(f.comments.length, count);
|
|
643
|
+
const resumed = await runBatch({ items: [{ issueNumber: 2, undefer: true }] });
|
|
644
|
+
assert.equal(resumed.results[0].status, 'applied');
|
|
645
|
+
assert.equal(resumed.results[0].readback.deferred, null);
|
|
646
|
+
assert.equal((await runBatch({ items: [{ issueNumber: 2, undefer: true }] })).results[0].status, 'unchanged');
|
|
647
|
+
});
|
|
648
|
+
test('public MCP and dispatch expose the same read-only per-item plan contract', async () => {
|
|
649
|
+
const f = batchFixture();
|
|
650
|
+
const server = createAiDeliveryMcpServer({ repoRoot: '/synthetic', identity: 'host-author' });
|
|
651
|
+
const client = new Client({ name: 'batch-synthetic', version: '1' });
|
|
652
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
653
|
+
try {
|
|
654
|
+
await server.connect(serverTransport);
|
|
655
|
+
await client.connect(clientTransport);
|
|
656
|
+
const input = { repo: 'example/widget', dryRun: true, items: [{ issueNumber: 1, title: 'MCP planned title' }] };
|
|
657
|
+
const result = await client.callTool({ name: 'issue_batch_update', arguments: input });
|
|
658
|
+
assert.notEqual(result.isError, true);
|
|
659
|
+
const content = result.content;
|
|
660
|
+
const parsed = JSON.parse(content[0].text);
|
|
661
|
+
assert.equal(parsed.results[0].changes.title, 'MCP planned title');
|
|
662
|
+
assert.equal(parsed.results[0].status, 'planned');
|
|
663
|
+
assert.equal(parsed.summary.planned, 1);
|
|
664
|
+
assert.equal(parsed.results[0].readback.title, 'Synthetic item 1');
|
|
665
|
+
const direct = await runBatch(input);
|
|
666
|
+
assert.deepEqual(direct.summary, parsed.summary);
|
|
667
|
+
assert.equal(direct.results[0].changes.title, parsed.results[0].changes.title);
|
|
668
|
+
assert.deepEqual(f.writes, []);
|
|
669
|
+
}
|
|
670
|
+
finally {
|
|
671
|
+
await client.close();
|
|
672
|
+
await server.close();
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
test('the documented fifty-item boundary returns every read-only plan', async () => {
|
|
676
|
+
const f = batchFixture();
|
|
677
|
+
const result = await runBatch({
|
|
678
|
+
dryRun: true,
|
|
679
|
+
items: Array.from({ length: 50 }, () => ({ issueNumber: 1, title: 'Planned repeated item' })),
|
|
680
|
+
});
|
|
681
|
+
assert.equal(result.results.length, 50);
|
|
682
|
+
assert.equal(result.summary.planned, 50);
|
|
683
|
+
assert.deepEqual(f.writes, []);
|
|
684
|
+
});
|
|
685
|
+
test('native label casing preserves the existing case-insensitive update intent', async () => {
|
|
686
|
+
const f = batchFixture();
|
|
687
|
+
const input = { items: [{ issueNumber: 1, labels: ['ENHANCEMENT'] }] };
|
|
688
|
+
const first = await runBatch(input);
|
|
689
|
+
assert.equal(first.results[0].status, 'applied');
|
|
690
|
+
assert.deepEqual(f.rows.get(1).labels, ['enhancement']);
|
|
691
|
+
assert.equal((await runBatch(input)).results[0].status, 'unchanged');
|
|
692
|
+
});
|
|
693
|
+
test('rate exhaustion during fallback readback stops later writes and appears in the summary', async () => {
|
|
694
|
+
const f = batchFixture();
|
|
695
|
+
f.controls.failAfterWrite = 1;
|
|
696
|
+
const get = f.context.clients.rest.issues.get;
|
|
697
|
+
f.context.clients.rest.issues.get = (async (params) => {
|
|
698
|
+
if (params.issue_number === 1 && f.writes.includes('update:1'))
|
|
699
|
+
throw Object.assign(new Error('Private readback error'), { status: 429, headers: { 'retry-after': '10' } });
|
|
700
|
+
return get({ ...f.context.repo, ...params });
|
|
701
|
+
});
|
|
702
|
+
const result = await runBatch({
|
|
703
|
+
items: [
|
|
704
|
+
{ issueNumber: 1, title: 'Partial item' },
|
|
705
|
+
{ issueNumber: 2, title: 'No later write' },
|
|
706
|
+
],
|
|
707
|
+
});
|
|
708
|
+
assert.deepEqual(result.results.map((item) => item.status), ['failed', 'failed']);
|
|
709
|
+
assert.match(result.results[1].reason, /Not attempted/u);
|
|
710
|
+
assert.deepEqual(result.summary.rateLimits, [{ retryAfterSeconds: 10 }]);
|
|
711
|
+
assert.equal(f.rows.get(2).title, 'Synthetic item 2');
|
|
712
|
+
});
|
|
713
|
+
test('closure reuse refuses duplicate authored journals and corrupted authoritative comment readback', async () => {
|
|
714
|
+
for (const mode of ['duplicate', 'corrupt']) {
|
|
715
|
+
const f = batchFixture();
|
|
716
|
+
const input = { items: [{ issueNumber: 1, state: 'closed', closeReason: 'completed' }] };
|
|
717
|
+
assert.equal((await runBatch(input)).results[0].status, 'applied');
|
|
718
|
+
const existing = f.comments.find((comment) => comment.body === 'Requested closure reason: completed.');
|
|
719
|
+
if (mode === 'duplicate')
|
|
720
|
+
f.comments.push({ ...existing, id: 9999 });
|
|
721
|
+
else
|
|
722
|
+
f.context.clients.rest.issues.getComment = (async () => ({
|
|
723
|
+
data: { ...existing, body: 'Corrupted journal readback' },
|
|
724
|
+
}));
|
|
725
|
+
const writes = f.writes.length;
|
|
726
|
+
assert.equal((await runBatch(input)).results[0].status, 'failed', mode);
|
|
727
|
+
assert.equal(f.writes.length, writes);
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
//# sourceMappingURL=issueBatchUpdate.test.js.map
|