@aviaratech/ai-delivery 0.3.37 → 0.3.39
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 +14 -18
- package/dist/agent.d.ts +0 -4
- package/dist/agent.js +1 -8
- package/dist/agent.js.map +2 -2
- package/dist/cli.js +2 -72
- package/dist/cli.js.map +2 -2
- package/dist/cliResult.js +2 -14
- package/dist/cliResult.js.map +2 -2
- package/dist/cliResult.test.js +0 -74
- package/dist/cliResult.test.js.map +2 -2
- package/dist/config/deliveryConfig.d.ts +0 -6
- package/dist/config/deliveryConfig.js +2 -35
- package/dist/config/deliveryConfig.js.map +2 -2
- package/dist/config/deliveryConfig.test.js +1 -25
- package/dist/config/deliveryConfig.test.js.map +2 -2
- package/dist/contributorChecks.test.js +5 -3
- package/dist/contributorChecks.test.js.map +2 -2
- package/dist/delivery/common.d.ts +0 -14
- package/dist/delivery/common.js +1 -44
- package/dist/delivery/common.js.map +2 -2
- package/dist/directoryIndependent.test.js +2 -24
- package/dist/directoryIndependent.test.js.map +2 -2
- package/dist/dispatch.js +0 -46
- package/dist/dispatch.js.map +3 -3
- package/dist/fixtures/inertTarget.js +3 -5
- package/dist/fixtures/inertTarget.js.map +2 -2
- package/dist/fixtures/recordedGitHubFlows.d.ts +0 -72
- package/dist/fixtures/recordedGitHubFlows.js +1 -57
- package/dist/fixtures/recordedGitHubFlows.js.map +2 -2
- package/dist/git.d.ts +0 -6
- package/dist/git.js +0 -15
- package/dist/git.js.map +2 -2
- package/dist/github/client.js +0 -3
- package/dist/github/client.js.map +2 -2
- package/dist/github/commandIdentityPolicy.js +0 -1
- package/dist/github/commandIdentityPolicy.js.map +2 -2
- package/dist/github/issueHistory.d.ts +0 -6
- package/dist/github/issueHistory.js +0 -39
- package/dist/github/issueHistory.js.map +2 -2
- package/dist/github/nativeIssueMetadata.d.ts +0 -10
- package/dist/github/nativeIssueMetadata.js +1 -33
- package/dist/github/nativeIssueMetadata.js.map +3 -3
- package/dist/github/projectDelivery.d.ts +0 -34
- package/dist/github/projectDelivery.js +0 -211
- package/dist/github/projectDelivery.js.map +2 -2
- package/dist/github/repo.d.ts +0 -8
- package/dist/github/repo.js +0 -72
- package/dist/github/repo.js.map +2 -2
- package/dist/issue.js +22 -17
- package/dist/issue.js.map +2 -2
- package/dist/issue63Routes.test.js +1 -72
- package/dist/issue63Routes.test.js.map +2 -2
- package/dist/issueInfoReadback.test.js +59 -1
- package/dist/issueInfoReadback.test.js.map +2 -2
- package/dist/issueIntake.test.js +12 -0
- package/dist/issueIntake.test.js.map +2 -2
- package/dist/issueJournal.d.ts +0 -9
- package/dist/issueJournal.js +10 -76
- package/dist/issueJournal.js.map +2 -2
- package/dist/issueJournal.test.js +1 -108
- package/dist/issueJournal.test.js.map +2 -2
- package/dist/issueTracking.test.js +0 -48
- package/dist/issueTracking.test.js.map +2 -2
- package/dist/lifecycle.test.js +12 -48
- package/dist/lifecycle.test.js.map +2 -2
- package/dist/logger.d.ts +0 -4
- package/dist/logger.js +0 -31
- package/dist/logger.js.map +2 -2
- package/dist/mcp/tools.d.ts +2 -618
- package/dist/mcp/tools.js +8 -34
- package/dist/mcp/tools.js.map +2 -2
- package/dist/pluginAuthProbe.js +0 -3
- package/dist/pluginAuthProbe.js.map +2 -2
- package/dist/pluginDoctor.test.js +1 -1
- package/dist/pluginDoctor.test.js.map +2 -2
- package/dist/pluginInstaller.js +0 -3
- package/dist/pluginInstaller.js.map +2 -2
- package/dist/pluginInstaller.test.js +3 -19
- package/dist/pluginInstaller.test.js.map +2 -2
- package/dist/pluginPackaging.test.js +1 -118
- package/dist/pluginPackaging.test.js.map +2 -2
- package/dist/pr.d.ts +2 -73
- package/dist/pr.js +27 -220
- package/dist/pr.js.map +3 -3
- package/dist/pr.test.js +11 -304
- package/dist/pr.test.js.map +2 -2
- package/dist/prAssociation.test.js +112 -22
- package/dist/prAssociation.test.js.map +2 -2
- package/dist/prDispatch.test.js +4 -11
- package/dist/prDispatch.test.js.map +2 -2
- package/dist/releaseWorkflow.test.js +0 -1
- package/dist/releaseWorkflow.test.js.map +2 -2
- package/dist/review.d.ts +0 -82
- package/dist/review.js +3 -94
- package/dist/review.js.map +2 -2
- package/dist/review.test.js +2 -4
- package/dist/review.test.js.map +2 -2
- package/dist/services/agentReadinessService.d.ts +0 -1
- package/dist/services/agentReadinessService.js.map +2 -2
- package/dist/stdoutRegression.test.js +3 -22
- package/dist/stdoutRegression.test.js.map +2 -2
- package/dist/targetPolicyDiscovery.test.js +0 -86
- package/dist/targetPolicyDiscovery.test.js.map +2 -2
- package/dist/targetPolicyEntrypoints.test.js +1 -54
- package/dist/targetPolicyEntrypoints.test.js.map +2 -2
- package/dist/targetRepositoryExecution.test.js +1 -49
- package/dist/targetRepositoryExecution.test.js.map +2 -2
- package/dist/terminalMessages.d.ts +0 -10
- package/dist/terminalMessages.js +1 -31
- package/dist/terminalMessages.js.map +2 -2
- package/dist/toolOutput.js +0 -2
- package/dist/toolOutput.js.map +2 -2
- package/dist/toolOutput.test.js +15 -1
- package/dist/toolOutput.test.js.map +2 -2
- package/dist/verification.d.ts +1 -186
- package/dist/verification.js +29 -587
- package/dist/verification.js.map +3 -3
- package/dist/verificationGate.test.js +4 -90
- package/dist/verificationGate.test.js.map +2 -2
- package/dist/version.d.ts +0 -6
- package/dist/version.js +2 -39
- package/dist/version.js.map +2 -2
- 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 +118 -162
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/dist/boardReconcile.test.d.ts +0 -1
- package/dist/boardReconcile.test.js +0 -1746
- package/dist/boardReconcile.test.js.map +0 -7
- package/dist/delivery/delivery.test.d.ts +0 -1
- package/dist/delivery/delivery.test.js +0 -560
- package/dist/delivery/delivery.test.js.map +0 -7
- package/dist/delivery/evidence.d.ts +0 -92
- package/dist/delivery/evidence.js +0 -139
- package/dist/delivery/evidence.js.map +0 -7
- package/dist/delivery/legacy.d.ts +0 -8
- package/dist/delivery/legacy.js +0 -65
- package/dist/delivery/legacy.js.map +0 -7
- package/dist/delivery/policy.d.ts +0 -252
- package/dist/delivery/policy.js +0 -221
- package/dist/delivery/policy.js.map +0 -7
- package/dist/delivery/stage.d.ts +0 -179
- package/dist/delivery/stage.js +0 -242
- package/dist/delivery/stage.js.map +0 -7
- package/dist/deliveryBoard.d.ts +0 -74
- package/dist/deliveryBoard.js +0 -644
- package/dist/deliveryBoard.js.map +0 -7
- package/dist/deliveryBoard.test.d.ts +0 -1
- package/dist/deliveryBoard.test.js +0 -649
- package/dist/deliveryBoard.test.js.map +0 -7
- package/dist/deliveryHealth.test.d.ts +0 -1
- package/dist/deliveryHealth.test.js +0 -191
- package/dist/deliveryHealth.test.js.map +0 -7
- package/dist/fixtures/deliveryBoardReplay.d.ts +0 -56
- package/dist/fixtures/deliveryBoardReplay.js +0 -617
- package/dist/fixtures/deliveryBoardReplay.js.map +0 -7
- package/dist/genericCompatibility.test.d.ts +0 -1
- package/dist/genericCompatibility.test.js +0 -66
- package/dist/genericCompatibility.test.js.map +0 -7
- package/dist/services/boardReconcileService.d.ts +0 -1204
- package/dist/services/boardReconcileService.js +0 -1445
- package/dist/services/boardReconcileService.js.map +0 -7
- package/dist/services/deliveryHealthService.d.ts +0 -84
- package/dist/services/deliveryHealthService.js +0 -204
- package/dist/services/deliveryHealthService.js.map +0 -7
- package/dist/services/legacyIssueMigration.d.ts +0 -46
- package/dist/services/legacyIssueMigration.js +0 -299
- package/dist/services/legacyIssueMigration.js.map +0 -7
- package/dist/utils/filesystem.d.ts +0 -1
- package/dist/utils/filesystem.js +0 -5
- package/dist/utils/filesystem.js.map +0 -7
|
@@ -1,617 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import {
|
|
3
|
-
existsSync,
|
|
4
|
-
lstatSync,
|
|
5
|
-
mkdirSync,
|
|
6
|
-
mkdtempSync,
|
|
7
|
-
readFileSync,
|
|
8
|
-
realpathSync,
|
|
9
|
-
rmSync,
|
|
10
|
-
writeFileSync
|
|
11
|
-
} from "node:fs";
|
|
12
|
-
import { tmpdir } from "node:os";
|
|
13
|
-
import { join } from "node:path";
|
|
14
|
-
import { onTestFinished, vi } from "vitest";
|
|
15
|
-
import * as configuration from "../config/deliveryConfig.js";
|
|
16
|
-
import { digestBytes, digestValue } from "../delivery/common.js";
|
|
17
|
-
import * as githubClients from "../github/client.js";
|
|
18
|
-
import * as issueOwner from "../issue.js";
|
|
19
|
-
import { renderJournal } from "../issueJournal.js";
|
|
20
|
-
import * as projectOwner from "../github/projectDelivery.js";
|
|
21
|
-
import { fixtureGit } from "./inertTarget.js";
|
|
22
|
-
import { syntheticDiscoveryClients, syntheticDiscoveryConfig, syntheticOverrides } from "./discovery.js";
|
|
23
|
-
const boardReplayRepos = ["example/alpha", "example/beta"];
|
|
24
|
-
const boardReplayAsOf = "2026-10-23T12:00:00.000Z";
|
|
25
|
-
function deliveryBoardReplay(options = {}) {
|
|
26
|
-
const repos = options.longLinks ? boardReplayRepos.map((repository) => `${repository}-${"x".repeat(90)}`) : boardReplayRepos;
|
|
27
|
-
const base = realpathSync(mkdtempSync(join(tmpdir(), "ai-delivery-board-replay-")));
|
|
28
|
-
const ownership = lstatSync(base);
|
|
29
|
-
const roots = repos.map((_, i) => join(base, `repo-${i}`));
|
|
30
|
-
const trap = join(base, "target-code-executions.txt");
|
|
31
|
-
const calls = {
|
|
32
|
-
operations: {},
|
|
33
|
-
nativeWrites: 0,
|
|
34
|
-
setupCalls: 0,
|
|
35
|
-
perItemStatusReads: 0,
|
|
36
|
-
unexpectedReads: 0,
|
|
37
|
-
clientFactory: 0,
|
|
38
|
-
contexts: 0
|
|
39
|
-
};
|
|
40
|
-
const count = (name) => {
|
|
41
|
-
calls.operations[name] = (calls.operations[name] ?? 0) + 1;
|
|
42
|
-
};
|
|
43
|
-
let disposed = false;
|
|
44
|
-
const snapshot = (path) => {
|
|
45
|
-
if (!existsSync(path)) return null;
|
|
46
|
-
const stat = lstatSync(path);
|
|
47
|
-
return {
|
|
48
|
-
digest: digestBytes(readFileSync(path)),
|
|
49
|
-
mode: stat.mode,
|
|
50
|
-
dev: stat.dev,
|
|
51
|
-
ino: stat.ino,
|
|
52
|
-
mtimeMs: stat.mtimeMs
|
|
53
|
-
};
|
|
54
|
-
};
|
|
55
|
-
const configHashes = /* @__PURE__ */ new Map();
|
|
56
|
-
const dispose = () => {
|
|
57
|
-
if (disposed) return;
|
|
58
|
-
disposed = true;
|
|
59
|
-
vi.restoreAllMocks();
|
|
60
|
-
vi.useRealTimers();
|
|
61
|
-
if (existsSync(base)) {
|
|
62
|
-
const current = lstatSync(base);
|
|
63
|
-
assert.equal(current.dev, ownership.dev);
|
|
64
|
-
assert.equal(current.ino, ownership.ino);
|
|
65
|
-
assert.equal(current.uid, ownership.uid);
|
|
66
|
-
assert.equal(current.isSymbolicLink(), false);
|
|
67
|
-
assert.equal(current.isDirectory(), true);
|
|
68
|
-
rmSync(base, { recursive: true });
|
|
69
|
-
}
|
|
70
|
-
assert.equal(existsSync(base), false);
|
|
71
|
-
console.log(
|
|
72
|
-
JSON.stringify({
|
|
73
|
-
fixture: "delivery-board-synthetic",
|
|
74
|
-
root: base,
|
|
75
|
-
dev: ownership.dev,
|
|
76
|
-
ino: ownership.ino,
|
|
77
|
-
cleanupConfirmed: true,
|
|
78
|
-
...calls
|
|
79
|
-
})
|
|
80
|
-
);
|
|
81
|
-
};
|
|
82
|
-
onTestFinished(dispose);
|
|
83
|
-
vi.useFakeTimers({ toFake: ["Date"] });
|
|
84
|
-
vi.setSystemTime(new Date(options.asOf ?? boardReplayAsOf));
|
|
85
|
-
const asOf = Date.parse(options.asOf ?? boardReplayAsOf);
|
|
86
|
-
const iso = (offset) => new Date(asOf + offset).toISOString();
|
|
87
|
-
const day = 24 * 60 * 60 * 1e3;
|
|
88
|
-
const baseSha = "c".repeat(40);
|
|
89
|
-
const sha = (number) => number.toString(16).padStart(40, "0");
|
|
90
|
-
const index = (repository) => repos.indexOf(repository.toLowerCase());
|
|
91
|
-
const repoId = (repository) => `REPO-${index(repository)}`;
|
|
92
|
-
const issueId = (repository, number) => `ISSUE-${index(repository)}-${number}`;
|
|
93
|
-
const prId = (repository, number) => `PR-${index(repository)}-${number}`;
|
|
94
|
-
const native = (repository) => ({
|
|
95
|
-
...syntheticDiscoveryConfig,
|
|
96
|
-
repository,
|
|
97
|
-
native: structuredClone(syntheticDiscoveryConfig.native)
|
|
98
|
-
});
|
|
99
|
-
const { repository: _repository, ...overrides } = syntheticOverrides(syntheticDiscoveryConfig);
|
|
100
|
-
const settings = {
|
|
101
|
-
roles: {
|
|
102
|
-
author: { authSource: "personal", identity: "fixture-author", credentialEnv: { token: "SYNTHETIC_TOKEN" } },
|
|
103
|
-
reviewer: {
|
|
104
|
-
identity: "fixture-reviewer",
|
|
105
|
-
credentialEnv: {
|
|
106
|
-
appId: "SYNTHETIC_APP",
|
|
107
|
-
installationId: "SYNTHETIC_INSTALLATION",
|
|
108
|
-
privateKeyPath: "SYNTHETIC_KEY_PATH"
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
configPath: join(base, "SYNTHETIC_PRIVATE_CONFIG"),
|
|
113
|
-
overrides,
|
|
114
|
-
checkoutRoots: [base],
|
|
115
|
-
sourceDigest: digestValue({ fixture: "delivery-board-settings" })
|
|
116
|
-
};
|
|
117
|
-
const config = (repository) => ({
|
|
118
|
-
...native(repository),
|
|
119
|
-
schemaVersion: "ai-delivery.github@1",
|
|
120
|
-
roles: settings.roles
|
|
121
|
-
});
|
|
122
|
-
const configs = new Map(repos.map((repository) => [repository, config(repository)]));
|
|
123
|
-
const selected = options.selectedIssues ?? 50;
|
|
124
|
-
const selectedCount = (repository) => Math.max(0, Math.min(25, selected - index(repository) * 25));
|
|
125
|
-
const observedIssue = (repository, number) => ({
|
|
126
|
-
node_id: issueId(repository, number),
|
|
127
|
-
number,
|
|
128
|
-
title: options.combinedRetainedLimit && number === 1 ? "x".repeat(9 * 1024 * 1024) : `Synthetic issue ${number}`,
|
|
129
|
-
html_url: `https://github.com/${repository}/issues/${number}`,
|
|
130
|
-
state: "open",
|
|
131
|
-
labels: number === 5 ? [{ name: "needs-decision" }] : [],
|
|
132
|
-
updated_at: iso(
|
|
133
|
-
number >= 6 && number <= 10 ? -3 * day + (number === 6 ? 0 : options.recentBoundary && number === 7 ? 1 : -1) : -day
|
|
134
|
-
)
|
|
135
|
-
});
|
|
136
|
-
const observedPr = (repository, number) => ({
|
|
137
|
-
node_id: prId(repository, number),
|
|
138
|
-
number,
|
|
139
|
-
title: options.oversizedPr && index(repository) === 0 && number === 101 ? "x".repeat(17 * 1024 * 1024) : `Synthetic PR ${number}`,
|
|
140
|
-
html_url: `https://github.com/${repository}/pull/${number}`,
|
|
141
|
-
body: `Closes #${number - 90}
|
|
142
|
-
|
|
143
|
-
Synthetic proof.`,
|
|
144
|
-
state: "open",
|
|
145
|
-
merged: false,
|
|
146
|
-
draft: false,
|
|
147
|
-
mergeable: true,
|
|
148
|
-
mergeable_state: number <= 105 ? "clean" : "blocked",
|
|
149
|
-
head: {
|
|
150
|
-
sha: sha(number + index(repository) * 1e3),
|
|
151
|
-
ref: `issue/${number - 90}`,
|
|
152
|
-
repo: { node_id: repoId(repository), full_name: repository }
|
|
153
|
-
},
|
|
154
|
-
base: { sha: baseSha, ref: "main", repo: { node_id: repoId(repository), full_name: repository } },
|
|
155
|
-
user: { login: "fixture-author" }
|
|
156
|
-
});
|
|
157
|
-
const issueInput = (number, kind, pending = false) => {
|
|
158
|
-
const common = {
|
|
159
|
-
issueNumber: number,
|
|
160
|
-
summary: "Synthetic current work.",
|
|
161
|
-
status: "In Progress",
|
|
162
|
-
nextStep: "Continue",
|
|
163
|
-
nextDate: null,
|
|
164
|
-
keyNumbers: [],
|
|
165
|
-
evidence: ["https://github.com/example/alpha/issues/1"]
|
|
166
|
-
};
|
|
167
|
-
switch (kind) {
|
|
168
|
-
case "progress":
|
|
169
|
-
return { ...common, kind, done: ["Prepared"], decisionNeeded: pending ? "Approve synthetic design" : "None" };
|
|
170
|
-
case "decision":
|
|
171
|
-
return { ...common, kind, decision: "Selected approach", rationale: "Reviewed" };
|
|
172
|
-
case "start":
|
|
173
|
-
return { ...common, kind, outcome: "Finish work" };
|
|
174
|
-
case "blocker":
|
|
175
|
-
return { ...common, kind, blocker: "Dependency", resolution: "Wait for source" };
|
|
176
|
-
case "closeout":
|
|
177
|
-
return {
|
|
178
|
-
...common,
|
|
179
|
-
kind,
|
|
180
|
-
acceptance: [{ criterion: "Synthetic complete", evidence: "https://github.com/example/alpha/issues/1" }],
|
|
181
|
-
followUps: []
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
const journal = (repository, number, input, id, createdAt = iso(-day)) => {
|
|
186
|
-
const fullId = (BigInt(id) + BigInt(index(repository)) * 100000n).toString();
|
|
187
|
-
return {
|
|
188
|
-
id: `COMMENT-${fullId}`,
|
|
189
|
-
fullDatabaseId: BigInt(fullId) <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(fullId) : fullId,
|
|
190
|
-
createdAt,
|
|
191
|
-
lastEditedAt: null,
|
|
192
|
-
url: `https://github.com/${repository}/issues/${number}#issuecomment-${fullId}`,
|
|
193
|
-
body: renderJournal(input, `<!-- ai-delivery:journal@1:${digestValue(input)} -->`)
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
const comments = (repository, number) => {
|
|
197
|
-
if (number === 21 || number === 22) {
|
|
198
|
-
const firstId = 9007199254740992n + BigInt(number - 21) * 4n;
|
|
199
|
-
const older = journal(repository, number, issueInput(number, "progress", true), firstId.toString());
|
|
200
|
-
const newer = journal(repository, number, issueInput(number, "decision"), (firstId + 1n).toString());
|
|
201
|
-
older.id = `OPAQUE-Z-${index(repository)}-${number}`;
|
|
202
|
-
newer.id = `OPAQUE-A-${index(repository)}-${number}`;
|
|
203
|
-
older.lastEditedAt = iso(-1e3);
|
|
204
|
-
return number === 21 ? [older, newer] : [newer, older];
|
|
205
|
-
}
|
|
206
|
-
const kind = number === 5 ? "decision" : number === 23 ? "start" : number === 24 ? "blocker" : number === 25 ? "closeout" : "progress";
|
|
207
|
-
const input = issueInput(number, kind, number <= 4);
|
|
208
|
-
if (options.ambiguousJournal && index(repository) === 0 && number === 1)
|
|
209
|
-
Object.assign(input, { details: "**Decision needed:** None" });
|
|
210
|
-
return [
|
|
211
|
-
journal(repository, number, issueInput(number, "progress", true), `${1e3 + number}`, iso(-2 * day)),
|
|
212
|
-
journal(repository, number, input, `${2e3 + number}`)
|
|
213
|
-
];
|
|
214
|
-
};
|
|
215
|
-
const projectItems = Array.from({ length: 580 }, (_, i) => {
|
|
216
|
-
const repository = i < 25 ? repos[0] : i < 50 ? repos[1] : "example/unselected";
|
|
217
|
-
const number = i < 50 ? i % 25 + 1 : i + 1;
|
|
218
|
-
const active = number >= 6 && number <= 10 && i < 50;
|
|
219
|
-
return {
|
|
220
|
-
id: `ITEM-${i}`,
|
|
221
|
-
isArchived: false,
|
|
222
|
-
content: {
|
|
223
|
-
__typename: "Issue",
|
|
224
|
-
id: issueId(repository, number),
|
|
225
|
-
number,
|
|
226
|
-
repository: { nameWithOwner: repository }
|
|
227
|
-
},
|
|
228
|
-
fieldValueByName: { name: active ? "Active" : "Queued", optionId: active ? "STATUS-1" : "STATUS-0" }
|
|
229
|
-
};
|
|
230
|
-
});
|
|
231
|
-
projectItems[576] = { ...projectItems[5], id: "ARCHIVED-SELECTED-ISSUE", isArchived: true };
|
|
232
|
-
projectItems[577].content = { __typename: "DraftIssue", id: "DRAFT" };
|
|
233
|
-
projectItems[578].content = { __typename: "PullRequest", id: "PROJECT-PR" };
|
|
234
|
-
if (options.status === "missing") projectItems[5].fieldValueByName = null;
|
|
235
|
-
if (options.status === "unsupported") projectItems[5].fieldValueByName = { name: "Unknown", optionId: "OTHER" };
|
|
236
|
-
if (options.status === "duplicate") projectItems[579] = { ...projectItems[5], id: "DUPLICATE-ITEM" };
|
|
237
|
-
const writer = (name) => async () => {
|
|
238
|
-
calls.nativeWrites++;
|
|
239
|
-
throw new Error(`Forbidden synthetic native writer: ${name}`);
|
|
240
|
-
};
|
|
241
|
-
const endpoint = (methods) => new Proxy(methods, {
|
|
242
|
-
get(target, property) {
|
|
243
|
-
if (typeof property === "string" && property in target) return target[property];
|
|
244
|
-
if (typeof property !== "string") return void 0;
|
|
245
|
-
if (/^(?:create|update|delete|merge|add|remove|set|close|requestReview)/u.test(property))
|
|
246
|
-
return writer(property);
|
|
247
|
-
return async () => {
|
|
248
|
-
calls.unexpectedReads++;
|
|
249
|
-
throw new Error(`Unexpected synthetic read: ${property}`);
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
const coordinates = (input) => `${String(input.owner)}/${String(input.repo)}`.toLowerCase();
|
|
254
|
-
const rest = {
|
|
255
|
-
repos: endpoint({
|
|
256
|
-
get: async (input) => {
|
|
257
|
-
const repository = coordinates(input);
|
|
258
|
-
count(`Repo:${repository}`);
|
|
259
|
-
if (repository === repos[0]) options.abortAfterRepository?.abort();
|
|
260
|
-
if (repository === options.unreadableRepository || index(repository) < 0) throw { status: 404 };
|
|
261
|
-
return {
|
|
262
|
-
status: 200,
|
|
263
|
-
headers: {},
|
|
264
|
-
data: { node_id: repoId(repository), full_name: repository, default_branch: "main", private: false }
|
|
265
|
-
};
|
|
266
|
-
},
|
|
267
|
-
getCombinedStatusForRef: async (input) => ({
|
|
268
|
-
status: 200,
|
|
269
|
-
headers: {},
|
|
270
|
-
data: { sha: input.ref, state: "success", total_count: 0, statuses: [] }
|
|
271
|
-
})
|
|
272
|
-
}),
|
|
273
|
-
issues: endpoint({
|
|
274
|
-
listForRepo: async (input) => {
|
|
275
|
-
const repository = coordinates(input);
|
|
276
|
-
count(`Issues:${repository}`);
|
|
277
|
-
const data = Number(input.page ?? 1) === 1 ? [
|
|
278
|
-
...Array.from({ length: selectedCount(repository) }, (_, i) => observedIssue(repository, i + 1)),
|
|
279
|
-
{
|
|
280
|
-
...observedIssue(repository, 999),
|
|
281
|
-
pull_request: { url: `https://api.github.com/repos/${repository}/pulls/999` }
|
|
282
|
-
}
|
|
283
|
-
] : [];
|
|
284
|
-
return { status: 200, headers: {}, data };
|
|
285
|
-
}
|
|
286
|
-
}),
|
|
287
|
-
pulls: endpoint({
|
|
288
|
-
list: async (input) => {
|
|
289
|
-
const repository = coordinates(input);
|
|
290
|
-
count(`Prs:${repository}`);
|
|
291
|
-
return {
|
|
292
|
-
status: 200,
|
|
293
|
-
headers: {},
|
|
294
|
-
data: Number(input.page ?? 1) === 1 ? Array.from({ length: 10 }, (_, i) => observedPr(repository, 101 + i)) : []
|
|
295
|
-
};
|
|
296
|
-
},
|
|
297
|
-
get: async (input) => {
|
|
298
|
-
const repository = coordinates(input);
|
|
299
|
-
count(`Pr:${repository}`);
|
|
300
|
-
return { status: 200, headers: {}, data: observedPr(repository, Number(input.pull_number)) };
|
|
301
|
-
}
|
|
302
|
-
}),
|
|
303
|
-
checks: endpoint({
|
|
304
|
-
listForRef: async (input) => ({
|
|
305
|
-
status: 200,
|
|
306
|
-
headers: {},
|
|
307
|
-
data: {
|
|
308
|
-
total_count: 1,
|
|
309
|
-
check_runs: [
|
|
310
|
-
{
|
|
311
|
-
id: 1e4 + Number.parseInt(String(input.ref).slice(-6), 16),
|
|
312
|
-
name: "checks",
|
|
313
|
-
head_sha: input.ref,
|
|
314
|
-
app: { id: 7 },
|
|
315
|
-
status: "completed",
|
|
316
|
-
conclusion: options.prChecksFailed && coordinates(input) === repos[0] && input.ref === sha(101) ? "failure" : "success"
|
|
317
|
-
}
|
|
318
|
-
]
|
|
319
|
-
}
|
|
320
|
-
})
|
|
321
|
-
}),
|
|
322
|
-
git: endpoint({
|
|
323
|
-
getRef: async (input) => {
|
|
324
|
-
assert.equal(input.ref, "heads/main");
|
|
325
|
-
return {
|
|
326
|
-
status: 200,
|
|
327
|
-
headers: {},
|
|
328
|
-
data: {
|
|
329
|
-
ref: "refs/heads/main",
|
|
330
|
-
object: {
|
|
331
|
-
type: "commit",
|
|
332
|
-
sha: options.movedBase && coordinates(input) === repos[0] ? "d".repeat(40) : baseSha
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
}),
|
|
338
|
-
request: async (route) => {
|
|
339
|
-
if (!route.startsWith("GET ")) return writer(route)();
|
|
340
|
-
if (route.endsWith("/rules/branches/{branch}"))
|
|
341
|
-
return {
|
|
342
|
-
status: 200,
|
|
343
|
-
headers: {},
|
|
344
|
-
data: [
|
|
345
|
-
{
|
|
346
|
-
type: "required_status_checks",
|
|
347
|
-
parameters: { required_status_checks: [{ context: "checks", integration_id: 7 }] }
|
|
348
|
-
}
|
|
349
|
-
]
|
|
350
|
-
};
|
|
351
|
-
if (route.endsWith("/protection")) return { status: 200, headers: {}, data: { required_status_checks: null } };
|
|
352
|
-
calls.unexpectedReads++;
|
|
353
|
-
throw new Error("Unexpected synthetic REST route.");
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
const graphql = async (query, variables) => {
|
|
357
|
-
if (!query.trimStart().startsWith("query")) return writer("graphql")();
|
|
358
|
-
const operation = /\bquery\s+(\w+)/u.exec(query)?.[1] ?? "Unnamed";
|
|
359
|
-
count(operation);
|
|
360
|
-
const repository = `${String(variables.owner)}/${String(variables.repo ?? variables.name)}`.toLowerCase();
|
|
361
|
-
if (operation === "ProjectDeliveryConfiguration") {
|
|
362
|
-
const data = await syntheticDiscoveryClients(native(repos[0])).graphql(query, variables);
|
|
363
|
-
if (options.readOnlyProject) data.organization.projectV2.viewerCanUpdate = false;
|
|
364
|
-
return data;
|
|
365
|
-
}
|
|
366
|
-
if (operation === "ProjectDeliveryItems") {
|
|
367
|
-
const cursor = variables.cursor === null || variables.cursor === void 0 ? 0 : Number(variables.cursor);
|
|
368
|
-
const end = Math.min(cursor + 100, projectItems.length);
|
|
369
|
-
return {
|
|
370
|
-
organization: {
|
|
371
|
-
projectV2: {
|
|
372
|
-
id: "PROJECT-1",
|
|
373
|
-
number: 1,
|
|
374
|
-
items: {
|
|
375
|
-
nodes: projectItems.slice(cursor, end),
|
|
376
|
-
pageInfo: {
|
|
377
|
-
hasNextPage: end < projectItems.length,
|
|
378
|
-
endCursor: options.projectCursorRepeats ? "100" : String(end)
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
if (operation === "DeliveryBoardJournal") {
|
|
386
|
-
const number = Number(variables.number);
|
|
387
|
-
if (options.journalDenied && index(repository) === 0 && number === 1) throw { status: 403 };
|
|
388
|
-
assert.match(query, /comments\s*\(\s*last:\s*100\s*,\s*before:/u);
|
|
389
|
-
const backwards = index(repository) === 0 && number === 1 && (options.journalBackwards || options.journalCursorRepeats);
|
|
390
|
-
const skip = Boolean(
|
|
391
|
-
backwards && (options.journalCursorRepeats || variables.cursor === null || variables.cursor === void 0)
|
|
392
|
-
);
|
|
393
|
-
const nodes = skip ? [
|
|
394
|
-
{
|
|
395
|
-
...journal(repository, number, issueInput(number, "progress"), "4001", iso(-1e3)),
|
|
396
|
-
body: "Ordinary prose mentions ai-delivery:journal@1 without a comment marker."
|
|
397
|
-
}
|
|
398
|
-
] : comments(repository, number);
|
|
399
|
-
return {
|
|
400
|
-
repository: {
|
|
401
|
-
id: repoId(repository),
|
|
402
|
-
nameWithOwner: repository,
|
|
403
|
-
issue: {
|
|
404
|
-
id: options.wrongJournalParent && index(repository) === 0 && number === 1 ? "WRONG-PARENT" : issueId(repository, number),
|
|
405
|
-
number,
|
|
406
|
-
comments: { nodes, pageInfo: { hasPreviousPage: skip, startCursor: skip ? "older" : null } }
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
if (operation === "DeliveryReviewDecision") {
|
|
412
|
-
if (options.prReviewUnavailable && index(repository) === 0 && variables.number === 101) throw { status: 503 };
|
|
413
|
-
return {
|
|
414
|
-
repository: {
|
|
415
|
-
pullRequest: {
|
|
416
|
-
headRefOid: observedPr(repository, Number(variables.number)).head.sha,
|
|
417
|
-
reviewDecision: Number(variables.number) <= 105 ? null : "REVIEW_REQUIRED"
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
if (operation === "DeliveryBoardPr") {
|
|
423
|
-
if (options.prNativeUnavailable && index(repository) === 0 && variables.number === 101) throw { status: 503 };
|
|
424
|
-
const pr = observedPr(repository, Number(variables.number));
|
|
425
|
-
const issueNumber = pr.number - 90;
|
|
426
|
-
return {
|
|
427
|
-
repository: {
|
|
428
|
-
id: repoId(repository),
|
|
429
|
-
nameWithOwner: repository,
|
|
430
|
-
pullRequest: {
|
|
431
|
-
id: pr.node_id,
|
|
432
|
-
number: pr.number,
|
|
433
|
-
state: "OPEN",
|
|
434
|
-
isDraft: false,
|
|
435
|
-
headRefOid: pr.head.sha,
|
|
436
|
-
baseRefOid: baseSha,
|
|
437
|
-
headRefName: pr.head.ref,
|
|
438
|
-
baseRefName: "main",
|
|
439
|
-
baseRepository: { id: repoId(repository), nameWithOwner: repository },
|
|
440
|
-
headRepository: { id: repoId(repository), nameWithOwner: repository },
|
|
441
|
-
mergeable: "MERGEABLE",
|
|
442
|
-
mergeStateStatus: pr.number <= 105 ? "CLEAN" : "BLOCKED",
|
|
443
|
-
closingIssuesReferences: {
|
|
444
|
-
nodes: [
|
|
445
|
-
{
|
|
446
|
-
__typename: "Issue",
|
|
447
|
-
id: issueId(repository, issueNumber),
|
|
448
|
-
number: issueNumber,
|
|
449
|
-
repository: { id: repoId(repository), nameWithOwner: repository }
|
|
450
|
-
}
|
|
451
|
-
],
|
|
452
|
-
pageInfo: { hasNextPage: false, endCursor: null }
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
if (operation === "DeliveryBoardSearch") {
|
|
459
|
-
assert.equal("query" in variables, false, "Octokit reserves query; search variables use q");
|
|
460
|
-
assert.match(query, /\$q:\s*String!/u);
|
|
461
|
-
const search = String(variables.query ?? variables.q);
|
|
462
|
-
const selectedRepo = /\brepo:([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)/u.exec(search)?.[1]?.toLowerCase();
|
|
463
|
-
assert.ok(selectedRepo && index(selectedRepo) >= 0);
|
|
464
|
-
assert.match(search, /\bis:pr\b/u);
|
|
465
|
-
const merged = /\bmerged:/u.test(search);
|
|
466
|
-
assert.match(search, merged ? /merged:>=/u : /created:>=/u);
|
|
467
|
-
const qualifier = merged ? "merged" : "created";
|
|
468
|
-
const lower = new RegExp(`${qualifier}:>=([^ ]+)`, "u").exec(search)?.[1];
|
|
469
|
-
const upper = new RegExp(`${qualifier}:<([^ ]+)`, "u").exec(search)?.[1];
|
|
470
|
-
assert.ok(lower && upper, "both native timestamp bounds are explicit");
|
|
471
|
-
const from = Date.parse(lower), to = Date.parse(upper);
|
|
472
|
-
assert.ok(Number.isFinite(from) && Number.isFinite(to));
|
|
473
|
-
assert.ok(from <= asOf - 7 * day && from > asOf - 7 * day - 1e3, "query lower bound encloses the exact window");
|
|
474
|
-
assert.ok(to >= asOf && to < asOf + 1e3, "query upper bound preserves the final partial second");
|
|
475
|
-
if (options.lateMetricFailure && selectedRepo === repos[1] && merged) throw { status: 503 };
|
|
476
|
-
const marker = "<!-- ai-delivery:pr@1 -->";
|
|
477
|
-
const nodes = options.emptyMetrics ? [] : Array.from({ length: 3 }, (_, i) => ({
|
|
478
|
-
__typename: "PullRequest",
|
|
479
|
-
id: `METRIC-${selectedRepo}-${merged ? "merged" : "opened"}-${i}`,
|
|
480
|
-
number: 401 + i,
|
|
481
|
-
url: `https://github.com/${selectedRepo}/pull/${401 + i}`,
|
|
482
|
-
repository: { id: repoId(selectedRepo), nameWithOwner: selectedRepo },
|
|
483
|
-
createdAt: merged ? iso(-30 * day) : options.windowEdges && selectedRepo === repos[0] ? iso(i === 0 ? -7 * day : i === 1 ? 0 : -7 * day - 1) : iso(-day),
|
|
484
|
-
mergedAt: merged ? options.windowEdges && selectedRepo === repos[0] ? iso(i === 0 ? -7 * day : i === 1 ? 0 : -1) : iso(-day) : null,
|
|
485
|
-
body: i < 2 ? `Synthetic proof.
|
|
486
|
-
|
|
487
|
-
${marker}` : "Unmarked body.",
|
|
488
|
-
mergeCommit: merged ? options.unknownMergeCommit && selectedRepo === repos[0] && i === 0 ? null : {
|
|
489
|
-
oid: sha(401 + i),
|
|
490
|
-
message: i === 0 ? "Synthetic squash\n\nDelivered-by: ai-delivery\n" : "Historical merge, unmarked."
|
|
491
|
-
} : null
|
|
492
|
-
}));
|
|
493
|
-
if (options.duplicateSearchIds && selectedRepo === repos[0] && !merged) nodes[1] = { ...nodes[0] };
|
|
494
|
-
if (options.retainedLimit && selectedRepo === repos[0] && !merged && nodes[0])
|
|
495
|
-
nodes[0].id = "x".repeat(16 * 1024 * 1024);
|
|
496
|
-
return {
|
|
497
|
-
search: {
|
|
498
|
-
issueCount: options.searchCap && selectedRepo === repos[0] && !merged ? 1001 : nodes.length,
|
|
499
|
-
nodes,
|
|
500
|
-
pageInfo: {
|
|
501
|
-
hasNextPage: Boolean(options.searchCursorRepeats && selectedRepo === repos[0] && !merged),
|
|
502
|
-
endCursor: options.searchCursorRepeats && selectedRepo === repos[0] && !merged ? "repeated" : null
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
calls.unexpectedReads++;
|
|
508
|
-
throw new Error(`Unexpected synthetic GraphQL read ${operation}`);
|
|
509
|
-
};
|
|
510
|
-
const clients = {
|
|
511
|
-
rest,
|
|
512
|
-
graphql,
|
|
513
|
-
authSource: "personal",
|
|
514
|
-
role: "author",
|
|
515
|
-
credentialSource: "synthetic-principal",
|
|
516
|
-
authenticatedAuthor: async () => ({ actorLogin: "fixture-author", credentialIdentity: "synthetic-principal" })
|
|
517
|
-
};
|
|
518
|
-
const context = (repository) => {
|
|
519
|
-
const cfg = configs.get(repository);
|
|
520
|
-
const routing = {
|
|
521
|
-
repository,
|
|
522
|
-
repositoryId: repoId(repository),
|
|
523
|
-
projectId: "PROJECT-1",
|
|
524
|
-
projectSource: "explicit",
|
|
525
|
-
statusFieldId: "STATUS-FIELD",
|
|
526
|
-
statusOptionIds: { Todo: "STATUS-0", "In Progress": "STATUS-1", Blocked: "STATUS-2", Done: "STATUS-3" },
|
|
527
|
-
pointsFieldId: "PROJECT-FIELD-101",
|
|
528
|
-
priorityFieldId: "PROJECT-FIELD-102",
|
|
529
|
-
native: cfg.native
|
|
530
|
-
};
|
|
531
|
-
const loaded = {
|
|
532
|
-
config: cfg,
|
|
533
|
-
configDigest: digestValue({ sourceDigest: settings.sourceDigest, routing, roles: cfg.roles }),
|
|
534
|
-
configPath: settings.configPath,
|
|
535
|
-
routing
|
|
536
|
-
};
|
|
537
|
-
const selectedClients = index(repository) === 1 && options.contextPrincipal ? {
|
|
538
|
-
...clients,
|
|
539
|
-
authenticatedAuthor: async () => {
|
|
540
|
-
if (options.contextPrincipal === "unavailable") throw { status: 503 };
|
|
541
|
-
return { actorLogin: "different-author", credentialIdentity: "different-principal" };
|
|
542
|
-
}
|
|
543
|
-
} : clients;
|
|
544
|
-
if (options.contextIdentityMismatch && index(repository) === 1) loaded.routing.repositoryId = "WRONG-REPOSITORY";
|
|
545
|
-
return {
|
|
546
|
-
clients: selectedClients,
|
|
547
|
-
repo: { owner: "example", repo: repository.split("/")[1] },
|
|
548
|
-
root: "",
|
|
549
|
-
config: cfg,
|
|
550
|
-
configuration: loaded
|
|
551
|
-
};
|
|
552
|
-
};
|
|
553
|
-
for (const [i, root] of roots.entries()) {
|
|
554
|
-
mkdirSync(root, { recursive: true });
|
|
555
|
-
fixtureGit(root, "init", "-b", "main");
|
|
556
|
-
fixtureGit(root, "config", "remote.origin.url", `https://github.com/${repos[i]}.git`);
|
|
557
|
-
writeFileSync(
|
|
558
|
-
join(root, "consumer-trap.cjs"),
|
|
559
|
-
`require('node:fs').appendFileSync(${JSON.stringify(trap)}, 'executed\\n');process.exit(91);
|
|
560
|
-
`
|
|
561
|
-
);
|
|
562
|
-
writeFileSync(
|
|
563
|
-
join(root, "package.json"),
|
|
564
|
-
JSON.stringify({ scripts: { test: "node consumer-trap.cjs", preinstall: "node consumer-trap.cjs" } })
|
|
565
|
-
);
|
|
566
|
-
fixtureGit(root, "add", ".");
|
|
567
|
-
fixtureGit(root, "commit", "-m", "Synthetic inert target");
|
|
568
|
-
configHashes.set(root, snapshot(join(root, ".git", "config")));
|
|
569
|
-
}
|
|
570
|
-
vi.spyOn(configuration, "loadDeliverySettings").mockResolvedValue(settings);
|
|
571
|
-
vi.spyOn(githubClients, "createDeliveryGitHubClients").mockImplementation(async (input) => {
|
|
572
|
-
input.signal?.throwIfAborted();
|
|
573
|
-
calls.clientFactory++;
|
|
574
|
-
assert.equal(input.role, "author");
|
|
575
|
-
assert.equal(input.identity, settings.roles.author.identity);
|
|
576
|
-
assert.deepEqual(input.config.roles, settings.roles);
|
|
577
|
-
assert.equal(input.personalAuth, void 0, "no actor fallback in the configured-author replay");
|
|
578
|
-
return clients;
|
|
579
|
-
});
|
|
580
|
-
vi.spyOn(issueOwner, "loadDeliveryContext").mockImplementation(async (input) => {
|
|
581
|
-
input.signal?.throwIfAborted();
|
|
582
|
-
calls.contexts++;
|
|
583
|
-
assert.equal(input.role, "author");
|
|
584
|
-
assert.equal(input.identity, settings.roles.author.identity);
|
|
585
|
-
assert.deepEqual(input.settings?.roles, settings.roles);
|
|
586
|
-
assert.deepEqual(input.settings?.overrides, settings.overrides);
|
|
587
|
-
assert.equal(input.settings?.sourceDigest, settings.sourceDigest);
|
|
588
|
-
assert.equal(input.settings?.configPath, settings.configPath);
|
|
589
|
-
assert.notEqual(input.personalAuth, true, "no actor fallback during context discovery");
|
|
590
|
-
if (options.projectDenied) throw { status: 403 };
|
|
591
|
-
if (options.readOnlyProject)
|
|
592
|
-
assert.equal(input.requireWritableProject, false, "read-only Project discovery needs no write permission");
|
|
593
|
-
assert.ok(input.repository && index(input.repository) >= 0);
|
|
594
|
-
return context(input.repository);
|
|
595
|
-
});
|
|
596
|
-
vi.spyOn(projectOwner, "getIssueProjectStatus").mockImplementation(async () => {
|
|
597
|
-
calls.perItemStatusReads++;
|
|
598
|
-
throw new Error("Per-item Project lookup forbidden");
|
|
599
|
-
});
|
|
600
|
-
const execution = { settings, repoRoot: base };
|
|
601
|
-
const assertReadOnly = () => {
|
|
602
|
-
assert.equal(calls.nativeWrites, 0);
|
|
603
|
-
assert.equal(calls.setupCalls, 0);
|
|
604
|
-
assert.equal(calls.perItemStatusReads, 0);
|
|
605
|
-
assert.equal(calls.unexpectedReads, 0);
|
|
606
|
-
assert.equal(existsSync(trap), false);
|
|
607
|
-
for (const [root, original] of configHashes)
|
|
608
|
-
assert.deepEqual(snapshot(join(root, ".git", "config")), original, "checkout configuration remains unchanged");
|
|
609
|
-
};
|
|
610
|
-
return { base, roots, repos, calls, settings, execution, assertReadOnly, dispose };
|
|
611
|
-
}
|
|
612
|
-
export {
|
|
613
|
-
boardReplayAsOf,
|
|
614
|
-
boardReplayRepos,
|
|
615
|
-
deliveryBoardReplay
|
|
616
|
-
};
|
|
617
|
-
//# sourceMappingURL=deliveryBoardReplay.js.map
|