@aviaratech/ai-delivery 0.3.38 → 0.3.40
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 +0 -1
- 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 +23 -18
- package/dist/issue.js.map +2 -2
- package/dist/issue63Routes.test.js +1 -72
- package/dist/issue63Routes.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/issueWriteRecovery.test.js +35 -0
- package/dist/issueWriteRecovery.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 +123 -167
- 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
package/dist/review.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type { DeliveryConfig } from './config/deliveryConfig.js';
|
|
3
|
-
import { type RepositoryApprovalBinding, type RepositoryClassificationReceipt } from './delivery/legacy.js';
|
|
4
2
|
import { DeliveryError } from './errors.js';
|
|
5
3
|
import type { DeliveryContext } from './issue.js';
|
|
6
4
|
declare const ReviewBase: z.ZodObject<{
|
|
@@ -115,66 +113,6 @@ export declare const ReviewArtifactSchema: z.ZodObject<{
|
|
|
115
113
|
}>;
|
|
116
114
|
}, z.core.$strict>;
|
|
117
115
|
export type ReviewArtifact = z.infer<typeof ReviewArtifactSchema>;
|
|
118
|
-
export declare const SubmittedReviewReceiptSchema: z.ZodObject<{
|
|
119
|
-
artifact: z.ZodObject<{
|
|
120
|
-
artifactId: z.ZodString;
|
|
121
|
-
verdictFileSha256: z.ZodOptional<z.ZodString>;
|
|
122
|
-
authorIdentity: z.ZodString;
|
|
123
|
-
checks: z.ZodArray<z.ZodString>;
|
|
124
|
-
diffScopeHash: z.ZodString;
|
|
125
|
-
deliveryMetrics: z.ZodOptional<z.ZodObject<{
|
|
126
|
-
blockerTimeMs: z.ZodNullable<z.ZodNumber>;
|
|
127
|
-
reviewRound: z.ZodNumber;
|
|
128
|
-
}, z.core.$strict>>;
|
|
129
|
-
elapsedMs: z.ZodNumber;
|
|
130
|
-
findings: z.ZodArray<z.ZodString>;
|
|
131
|
-
head: z.ZodObject<{
|
|
132
|
-
sha: z.ZodString;
|
|
133
|
-
tree: z.ZodString;
|
|
134
|
-
}, z.core.$strict>;
|
|
135
|
-
reviewBase: z.ZodOptional<z.ZodObject<{
|
|
136
|
-
baseSha: z.ZodString;
|
|
137
|
-
mergeBaseSha: z.ZodString;
|
|
138
|
-
}, z.core.$strict>>;
|
|
139
|
-
reuse: z.ZodOptional<z.ZodObject<{
|
|
140
|
-
fromReviewId: z.ZodNumber;
|
|
141
|
-
verificationResultPath: z.ZodString;
|
|
142
|
-
}, z.core.$strict>>;
|
|
143
|
-
reusedFrom: z.ZodOptional<z.ZodObject<{
|
|
144
|
-
reviewId: z.ZodNumber;
|
|
145
|
-
artifactId: z.ZodString;
|
|
146
|
-
oldHead: z.ZodString;
|
|
147
|
-
newHead: z.ZodString;
|
|
148
|
-
reason: z.ZodString;
|
|
149
|
-
}, z.core.$strict>>;
|
|
150
|
-
changedPaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
151
|
-
issueNumber: z.ZodNumber;
|
|
152
|
-
prNumber: z.ZodNullable<z.ZodNumber>;
|
|
153
|
-
readOnly: z.ZodLiteral<true>;
|
|
154
|
-
requestedEffort: z.ZodString;
|
|
155
|
-
requestedModel: z.ZodString;
|
|
156
|
-
effectiveEffort: z.ZodString;
|
|
157
|
-
effectiveModel: z.ZodString;
|
|
158
|
-
reviewerIdentity: z.ZodString;
|
|
159
|
-
schemaVersion: z.ZodLiteral<"ai-delivery.review-artifact@1">;
|
|
160
|
-
summary: z.ZodString;
|
|
161
|
-
verdict: z.ZodEnum<{
|
|
162
|
-
approve: "approve";
|
|
163
|
-
"request-changes": "request-changes";
|
|
164
|
-
}>;
|
|
165
|
-
}, z.core.$strict>;
|
|
166
|
-
completedAt: z.ZodISODateTime;
|
|
167
|
-
githubReviewId: z.ZodNumber;
|
|
168
|
-
githubReviewUrl: z.ZodURL;
|
|
169
|
-
headSha: z.ZodString;
|
|
170
|
-
login: z.ZodString;
|
|
171
|
-
prNumber: z.ZodNumber;
|
|
172
|
-
publicationEvidenceId: z.ZodString;
|
|
173
|
-
receiptId: z.ZodString;
|
|
174
|
-
schemaVersion: z.ZodLiteral<"ai-delivery.review-receipt@1">;
|
|
175
|
-
state: z.ZodLiteral<"APPROVED">;
|
|
176
|
-
}, z.core.$strict>;
|
|
177
|
-
export type SubmittedReviewReceipt = z.infer<typeof SubmittedReviewReceiptSchema>;
|
|
178
116
|
export interface RequiredReviewState {
|
|
179
117
|
observed?: boolean;
|
|
180
118
|
reviewDecision: 'APPROVED' | 'CHANGES_REQUESTED' | 'REVIEW_REQUIRED' | null;
|
|
@@ -191,34 +129,16 @@ export declare function readRequiredReviewState(context: Pick<DeliveryContext, '
|
|
|
191
129
|
export declare function parseReviewArtifact(raw: unknown): ReviewArtifact;
|
|
192
130
|
/** Preserve the original binding: GitHub can remap a review's commit_id after a rebase. */
|
|
193
131
|
export declare function parseGitHubReviewArtifact(body: string | null | undefined): ReviewArtifact;
|
|
194
|
-
export declare function readGitHubPrScopeHash(context: DeliveryContext, prNumber: number, changedFiles: number): Promise<string>;
|
|
195
132
|
export declare function readGitHubReviewBase(context: DeliveryContext, prNumber: number, expectedHead: string): Promise<{
|
|
196
133
|
baseSha: string;
|
|
197
134
|
mergeBaseSha: string;
|
|
198
135
|
}>;
|
|
199
|
-
export declare function reviewArtifactApproval(input: {
|
|
200
|
-
artifact: ReviewArtifact;
|
|
201
|
-
classification: RepositoryClassificationReceipt;
|
|
202
|
-
config: Pick<DeliveryConfig, 'roles'>;
|
|
203
|
-
issueNumber: number;
|
|
204
|
-
prNumber?: number;
|
|
205
|
-
}): RepositoryApprovalBinding;
|
|
206
|
-
export declare function savePrepublicationArtifact(input: {
|
|
207
|
-
artifact: ReviewArtifact;
|
|
208
|
-
classification: RepositoryClassificationReceipt;
|
|
209
|
-
config: Pick<DeliveryConfig, 'roles'>;
|
|
210
|
-
issueNumber: number;
|
|
211
|
-
repoRoot: string;
|
|
212
|
-
}): void;
|
|
213
|
-
export declare function loadPrepublicationArtifact(repoRoot: string, issueNumber: number, headSha: string): ReviewArtifact | null;
|
|
214
136
|
interface ReviewSubmissionInput {
|
|
215
137
|
artifact: ReviewArtifact;
|
|
216
138
|
context: DeliveryContext;
|
|
217
139
|
issueNumber: number;
|
|
218
140
|
prNumber: number;
|
|
219
141
|
dryRun?: boolean;
|
|
220
|
-
publicationEvidenceId?: string;
|
|
221
|
-
classification?: RepositoryClassificationReceipt;
|
|
222
142
|
}
|
|
223
143
|
export interface GitHubReviewReceipt {
|
|
224
144
|
artifact: ReviewArtifact;
|
|
@@ -877,6 +797,4 @@ export declare function submitReview(input: ReviewSubmissionInput & {
|
|
|
877
797
|
dryRun?: false;
|
|
878
798
|
}): Promise<GitHubReviewReceipt>;
|
|
879
799
|
export declare function submitReview(input: ReviewSubmissionInput): Promise<GitHubReviewReceipt | ReviewDryRun>;
|
|
880
|
-
export declare function loadSubmittedReview(repoRoot: string, issueNumber: number, headSha: string): SubmittedReviewReceipt | null;
|
|
881
|
-
export declare function assertSubmittedReviewCurrent(context: DeliveryContext, receipt: SubmittedReviewReceipt): Promise<void>;
|
|
882
800
|
export {};
|
package/dist/review.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import { basename
|
|
1
|
+
import { basename } from "node:path";
|
|
2
2
|
import { execFileSync } from "node:child_process";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { assertPrivateFile } from "./delivery/common.js";
|
|
5
|
-
import {
|
|
6
|
-
digestValue,
|
|
7
|
-
RepositoryApprovalBindingSchema
|
|
8
|
-
} from "./delivery/legacy.js";
|
|
4
|
+
import { assertPrivateFile, digestValue } from "./delivery/common.js";
|
|
9
5
|
import { DeliveryError } from "./errors.js";
|
|
10
|
-
import { git,
|
|
6
|
+
import { git, gitExitCode } from "./git.js";
|
|
11
7
|
import { GIT_EXECUTABLE, gitEnvironment, inertGitArguments } from "./gitProcess.js";
|
|
12
|
-
import { writePrivateJsonFileAtomically } from "./utils/atomicJson.js";
|
|
13
8
|
const Sha = z.string().regex(/^[a-f0-9]{40}$/u);
|
|
14
9
|
const Digest = z.string().regex(/^sha256:[a-f0-9]{64}$/u);
|
|
15
10
|
const Text = z.string().trim().min(1);
|
|
@@ -135,24 +130,6 @@ const ReviewArtifactSchema = z.object({
|
|
|
135
130
|
ctx.addIssue({ code: "custom", message: "Review artifact identity or role separation is invalid." });
|
|
136
131
|
}
|
|
137
132
|
});
|
|
138
|
-
const SubmittedReviewReceiptSchema = z.object({
|
|
139
|
-
artifact: ReviewArtifactSchema,
|
|
140
|
-
completedAt: z.iso.datetime(),
|
|
141
|
-
githubReviewId: z.number().int().positive(),
|
|
142
|
-
githubReviewUrl: z.url(),
|
|
143
|
-
headSha: Sha,
|
|
144
|
-
login: z.string().min(1),
|
|
145
|
-
prNumber: z.number().int().positive(),
|
|
146
|
-
publicationEvidenceId: Digest,
|
|
147
|
-
receiptId: Digest,
|
|
148
|
-
schemaVersion: z.literal("ai-delivery.review-receipt@1"),
|
|
149
|
-
state: z.literal("APPROVED")
|
|
150
|
-
}).strict().superRefine((receipt, ctx) => {
|
|
151
|
-
const { receiptId, ...content } = receipt;
|
|
152
|
-
if (receiptId !== digestValue(content) || receipt.headSha !== receipt.artifact.head.sha || receipt.artifact.prNumber !== null && receipt.artifact.prNumber !== receipt.prNumber) {
|
|
153
|
-
ctx.addIssue({ code: "custom", message: "Submitted review receipt is not bound to its artifact." });
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
133
|
async function readRequiredReviewState(context, prNumber, expectedHead, submittedReview) {
|
|
157
134
|
let response;
|
|
158
135
|
try {
|
|
@@ -303,9 +280,6 @@ async function readGitHubPrPaths(context, prNumber, changedFiles, claimed) {
|
|
|
303
280
|
throw new DeliveryError("Independent review scope differs from the canonical remote rename inventory.");
|
|
304
281
|
return files.sort();
|
|
305
282
|
}
|
|
306
|
-
async function readGitHubPrScopeHash(context, prNumber, changedFiles) {
|
|
307
|
-
return digestValue(await readGitHubPrPaths(context, prNumber, changedFiles));
|
|
308
|
-
}
|
|
309
283
|
async function readGitHubReviewBase(context, prNumber, expectedHead) {
|
|
310
284
|
const pr = (await context.clients.rest.pulls.get({ ...context.repo, pull_number: prNumber })).data;
|
|
311
285
|
if (pr.number !== prNumber || pr.state !== "open" || pr.head.sha !== expectedHead || !Sha.safeParse(pr.base.sha).success)
|
|
@@ -317,45 +291,6 @@ async function readGitHubReviewBase(context, prNumber, expectedHead) {
|
|
|
317
291
|
})).data;
|
|
318
292
|
return ReviewBase.parse({ baseSha: pr.base.sha, mergeBaseSha: comparison.merge_base_commit.sha });
|
|
319
293
|
}
|
|
320
|
-
function reviewArtifactApproval(input) {
|
|
321
|
-
const { artifact, classification, config } = input;
|
|
322
|
-
ReviewArtifactSchema.parse(artifact);
|
|
323
|
-
if (artifact.verdict !== "approve" || artifact.issueNumber !== input.issueNumber || artifact.authorIdentity !== config.roles.author.identity || artifact.reviewerIdentity !== config.roles.reviewer.identity || artifact.head.sha !== classification.head.sha || artifact.head.tree !== classification.head.tree || artifact.diffScopeHash !== digestValue(classification.changedPaths) || input.prNumber !== void 0 && artifact.prNumber !== null && artifact.prNumber !== input.prNumber) {
|
|
324
|
-
throw new DeliveryError("Independent review artifact is stale, foreign, rejected, or covers another scope.");
|
|
325
|
-
}
|
|
326
|
-
return RepositoryApprovalBindingSchema.parse({
|
|
327
|
-
authorIdentity: artifact.authorIdentity,
|
|
328
|
-
diffScopeHash: artifact.diffScopeHash,
|
|
329
|
-
head: artifact.head,
|
|
330
|
-
result: "approved",
|
|
331
|
-
reviewerIdentity: artifact.reviewerIdentity,
|
|
332
|
-
reviewReceiptId: artifact.artifactId
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
function receiptPath(repoRoot, issueNumber, headSha) {
|
|
336
|
-
return join(gitCommonDir(repoRoot), "ai-delivery", "reviews", String(issueNumber), `${headSha}.json`);
|
|
337
|
-
}
|
|
338
|
-
function prepublicationPath(repoRoot, issueNumber, headSha) {
|
|
339
|
-
return join(gitCommonDir(repoRoot), "ai-delivery", "reviews", String(issueNumber), `${headSha}.prepublication.json`);
|
|
340
|
-
}
|
|
341
|
-
function savePrepublicationArtifact(input) {
|
|
342
|
-
if (input.artifact.prNumber !== null) throw new DeliveryError("Prepublication review must have a null PR number.");
|
|
343
|
-
reviewArtifactApproval(input);
|
|
344
|
-
writePrivateJsonFileAtomically(
|
|
345
|
-
prepublicationPath(input.repoRoot, input.issueNumber, input.artifact.head.sha),
|
|
346
|
-
input.artifact
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
function loadPrepublicationArtifact(repoRoot, issueNumber, headSha) {
|
|
350
|
-
let raw;
|
|
351
|
-
try {
|
|
352
|
-
raw = JSON.parse(assertPrivateFile(prepublicationPath(repoRoot, issueNumber, headSha)).toString("utf8"));
|
|
353
|
-
} catch (error) {
|
|
354
|
-
if (error.code === "ENOENT") return null;
|
|
355
|
-
throw new DeliveryError("Stored prepublication review is unreadable.");
|
|
356
|
-
}
|
|
357
|
-
return ReviewArtifactSchema.parse(raw);
|
|
358
|
-
}
|
|
359
294
|
async function listAllReviews(context, prNumber) {
|
|
360
295
|
const reviews = [];
|
|
361
296
|
for (let page = 1; page <= 20; page += 1) {
|
|
@@ -589,43 +524,17 @@ async function submitReview(input) {
|
|
|
589
524
|
);
|
|
590
525
|
}
|
|
591
526
|
}
|
|
592
|
-
function loadSubmittedReview(repoRoot, issueNumber, headSha) {
|
|
593
|
-
let raw;
|
|
594
|
-
try {
|
|
595
|
-
raw = JSON.parse(assertPrivateFile(receiptPath(repoRoot, issueNumber, headSha)).toString("utf8"));
|
|
596
|
-
} catch (error) {
|
|
597
|
-
if (error.code === "ENOENT") return null;
|
|
598
|
-
throw new DeliveryError("Stored review receipt is unreadable.");
|
|
599
|
-
}
|
|
600
|
-
return SubmittedReviewReceiptSchema.parse(raw);
|
|
601
|
-
}
|
|
602
|
-
async function assertSubmittedReviewCurrent(context, receipt) {
|
|
603
|
-
SubmittedReviewReceiptSchema.parse(receipt);
|
|
604
|
-
const review = (await listAllReviews(context, receipt.prNumber)).find(
|
|
605
|
-
(candidate) => candidate.id === receipt.githubReviewId
|
|
606
|
-
);
|
|
607
|
-
if (!review || review.state !== "APPROVED" || review.commit_id !== receipt.headSha || review.user?.login !== receipt.login || review.html_url !== receipt.githubReviewUrl || parseGitHubReviewArtifact(review.body).artifactId !== receipt.artifact.artifactId) {
|
|
608
|
-
throw new DeliveryError("GitHub exact-head review no longer matches the stored receipt.");
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
527
|
export {
|
|
612
528
|
ReviewArtifactSchema,
|
|
613
529
|
ReviewSubmissionError,
|
|
614
530
|
ReviewVerdictSchema,
|
|
615
|
-
SubmittedReviewReceiptSchema,
|
|
616
531
|
assertReviewVerdictTarget,
|
|
617
|
-
assertSubmittedReviewCurrent,
|
|
618
532
|
buildReviewArtifact,
|
|
619
|
-
loadPrepublicationArtifact,
|
|
620
|
-
loadSubmittedReview,
|
|
621
533
|
parseGitHubReviewArtifact,
|
|
622
534
|
parseReviewArtifact,
|
|
623
535
|
parseReviewVerdict,
|
|
624
|
-
readGitHubPrScopeHash,
|
|
625
536
|
readGitHubReviewBase,
|
|
626
537
|
readRequiredReviewState,
|
|
627
|
-
reviewArtifactApproval,
|
|
628
|
-
savePrepublicationArtifact,
|
|
629
538
|
submitReview,
|
|
630
539
|
validateReviewTarget
|
|
631
540
|
};
|
package/dist/review.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/review.ts"],
|
|
4
|
-
"sourcesContent": ["import { basename, join } from 'node:path';\nimport { execFileSync } from 'node:child_process';\nimport { z } from 'zod';\n\nimport type { DeliveryConfig } from './config/deliveryConfig.js';\nimport { assertPrivateFile } from './delivery/common.js';\nimport {\n digestValue,\n RepositoryApprovalBindingSchema,\n type RepositoryApprovalBinding,\n type RepositoryClassificationReceipt,\n} from './delivery/legacy.js';\nimport { DeliveryError } from './errors.js';\nimport { git, gitCommonDir, gitExitCode } from './git.js';\nimport { GIT_EXECUTABLE, gitEnvironment, inertGitArguments } from './gitProcess.js';\nimport type { DeliveryContext } from './issue.js';\nimport { writePrivateJsonFileAtomically } from './utils/atomicJson.js';\n\nconst Sha = z.string().regex(/^[a-f0-9]{40}$/u);\nconst Digest = z.string().regex(/^sha256:[a-f0-9]{64}$/u);\nconst Text = z.string().trim().min(1);\nconst Effort = z.enum(['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra', 'inherited']);\nconst ReviewBase = z.strictObject({ baseSha: Sha, mergeBaseSha: Sha });\nconst Reuse = z.strictObject({ fromReviewId: z.number().int().positive(), verificationResultPath: Text });\nexport const ReviewVerdictSchema = z.strictObject({\n schemaVersion: z.literal('ai-delivery.review-verdict@1'),\n verdict: z.enum(['approve', 'request-changes']),\n summary: Text,\n issueNumber: z.number().int().positive(),\n scope: z.strictObject({\n headSha: Sha,\n headTree: Sha,\n changedPaths: z\n .array(\n z\n .string()\n .min(1)\n .refine((path) => !path.includes('\\0'), 'Paths cannot contain NUL.'),\n )\n .transform((paths) => [...new Set(paths)].sort()),\n }),\n verificationReproduced: z.array(Text).min(1),\n requestedModel: Text,\n requestedEffort: Effort.default('inherited'),\n effectiveModel: Text,\n effectiveEffort: Effort.default('inherited'),\n elapsedMs: z.number().int().nonnegative(),\n findings: z.array(Text),\n readOnly: z.literal(true),\n nonClosing: z.boolean().optional(),\n reuse: Reuse.optional(),\n});\nexport type ReviewVerdict = z.infer<typeof ReviewVerdictSchema>;\n\nexport function parseReviewVerdict(raw: unknown): ReviewVerdict {\n let value: unknown;\n try {\n value = typeof raw === 'string' ? (JSON.parse(raw) as unknown) : raw;\n } catch {\n throw new DeliveryError('verdict: Invalid JSON.');\n }\n const result = ReviewVerdictSchema.safeParse(value);\n if (!result.success)\n throw new DeliveryError(\n result.error.issues.map((issue) => `${issue.path.join('.') || 'verdict'}: ${issue.message}`).join('; '),\n );\n return result.data;\n}\n\nexport function buildReviewArtifact(input: {\n verdict: ReviewVerdict;\n verdictFileSha256: string;\n identity: string;\n provider: string;\n expectedHead: string;\n prNumber: number;\n authorIdentity: string;\n reviewBase?: z.infer<typeof ReviewBase>;\n}): ReviewArtifact {\n const verdict = parseReviewVerdict(input.verdict);\n if (!Digest.safeParse(input.verdictFileSha256).success)\n throw new DeliveryError('verdictFileSha256: Expected the exact verdict-file SHA256.');\n if (input.identity.toLowerCase() === input.authorIdentity.toLowerCase())\n throw new DeliveryError('identity: Reviewer and author must be distinct.');\n assertReviewVerdictTarget(verdict, input.provider, input.expectedHead);\n const content = {\n schemaVersion: 'ai-delivery.review-artifact@1' as const,\n verdictFileSha256: input.verdictFileSha256,\n authorIdentity: input.authorIdentity,\n reviewerIdentity: input.identity,\n head: { sha: verdict.scope.headSha, tree: verdict.scope.headTree },\n issueNumber: verdict.issueNumber,\n prNumber: input.prNumber,\n diffScopeHash: digestValue(verdict.scope.changedPaths),\n changedPaths: verdict.scope.changedPaths,\n ...(input.reviewBase === undefined ? {} : { reviewBase: input.reviewBase }),\n ...(verdict.reuse === undefined ? {} : { reuse: verdict.reuse }),\n checks: verdict.verificationReproduced,\n elapsedMs: verdict.elapsedMs,\n findings: verdict.findings,\n readOnly: verdict.readOnly,\n requestedModel: verdict.requestedModel,\n requestedEffort: verdict.requestedEffort,\n effectiveModel: verdict.effectiveModel,\n effectiveEffort: verdict.effectiveEffort,\n summary: verdict.summary,\n verdict: verdict.verdict,\n };\n const artifact = ReviewArtifactSchema.parse({ ...content, artifactId: digestValue(content) });\n githubReviewBody(artifact);\n return artifact;\n}\n\nexport function assertReviewVerdictTarget(\n verdict: ReviewVerdict,\n selectedProvider: string,\n expectedHead: string,\n): void {\n const provider = (model: string) =>\n /^(?:gpt-|o[134](?:-|$))/u.test(model)\n ? 'openai'\n : model.startsWith('claude-')\n ? 'anthropic'\n : model.startsWith('gemini-')\n ? 'google'\n : /^qwen[\\d.-]/iu.test(model)\n ? 'qwen'\n : null;\n if (\n provider(verdict.requestedModel) === null ||\n provider(verdict.requestedModel) !== selectedProvider ||\n provider(verdict.effectiveModel) !== selectedProvider\n )\n throw new DeliveryError(\n 'identity: Configured reviewer provider must match both requestedModel and effectiveModel families.',\n );\n if (!Sha.safeParse(expectedHead).success || expectedHead !== verdict.scope.headSha)\n throw new DeliveryError('scope.headSha: Verdict and requested exact head differ.');\n}\nexport const ReviewArtifactSchema = z\n .object({\n artifactId: Digest,\n verdictFileSha256: Digest.optional(),\n authorIdentity: z.string().min(1),\n checks: z.array(z.string().min(1)).min(1),\n diffScopeHash: Digest,\n deliveryMetrics: z\n .object({ blockerTimeMs: z.number().int().nonnegative().nullable(), reviewRound: z.number().int().positive() })\n .strict()\n .optional(),\n elapsedMs: z.number().int().nonnegative(),\n findings: z.array(z.string()),\n head: z.object({ sha: Sha, tree: Sha }).strict(),\n reviewBase: ReviewBase.optional(),\n reuse: Reuse.optional(),\n reusedFrom: z\n .strictObject({\n reviewId: z.number().int().positive(),\n artifactId: Digest,\n oldHead: Sha,\n newHead: Sha,\n reason: Text,\n })\n .optional(),\n changedPaths: z\n .array(\n z\n .string()\n .min(1)\n .refine((path) => !path.includes('\\0')),\n )\n .optional(),\n issueNumber: z.number().int().positive(),\n prNumber: z.number().int().positive().nullable(),\n readOnly: z.literal(true),\n requestedEffort: z.string().min(1),\n requestedModel: z.string().min(1),\n effectiveEffort: z.string().min(1),\n effectiveModel: z.string().min(1),\n reviewerIdentity: z.string().min(1),\n schemaVersion: z.literal('ai-delivery.review-artifact@1'),\n summary: z.string().min(1),\n verdict: z.enum(['approve', 'request-changes']),\n })\n .strict()\n .superRefine((artifact, ctx) => {\n const { artifactId, ...content } = artifact;\n if (\n artifactId !== digestValue(content) ||\n artifact.authorIdentity === artifact.reviewerIdentity ||\n (artifact.changedPaths !== undefined && artifact.diffScopeHash !== digestValue(artifact.changedPaths))\n ) {\n ctx.addIssue({ code: 'custom', message: 'Review artifact identity or role separation is invalid.' });\n }\n });\nexport type ReviewArtifact = z.infer<typeof ReviewArtifactSchema>;\n\nexport const SubmittedReviewReceiptSchema = z\n .object({\n artifact: ReviewArtifactSchema,\n completedAt: z.iso.datetime(),\n githubReviewId: z.number().int().positive(),\n githubReviewUrl: z.url(),\n headSha: Sha,\n login: z.string().min(1),\n prNumber: z.number().int().positive(),\n publicationEvidenceId: Digest,\n receiptId: Digest,\n schemaVersion: z.literal('ai-delivery.review-receipt@1'),\n state: z.literal('APPROVED'),\n })\n .strict()\n .superRefine((receipt, ctx) => {\n const { receiptId, ...content } = receipt;\n if (\n receiptId !== digestValue(content) ||\n receipt.headSha !== receipt.artifact.head.sha ||\n (receipt.artifact.prNumber !== null && receipt.artifact.prNumber !== receipt.prNumber)\n ) {\n ctx.addIssue({ code: 'custom', message: 'Submitted review receipt is not bound to its artifact.' });\n }\n });\nexport type SubmittedReviewReceipt = z.infer<typeof SubmittedReviewReceiptSchema>;\n\nexport interface RequiredReviewState {\n observed?: boolean;\n reviewDecision: 'APPROVED' | 'CHANGES_REQUESTED' | 'REVIEW_REQUIRED' | null;\n submittedReviewAuthorCanPushToRepository: boolean | null;\n status: 'satisfied' | 'changes-requested' | 'still-required' | 'unknown';\n nextAction: string;\n}\n\n/** GitHub's PR decision is the live requirement state, not the state of one submitted review. */\nexport async function readRequiredReviewState(\n context: Pick<DeliveryContext, 'clients' | 'repo'>,\n prNumber: number,\n expectedHead: string,\n submittedReview?: { id: number; login: string; state?: 'APPROVED' | 'CHANGES_REQUESTED' },\n): Promise<RequiredReviewState> {\n let response: {\n repository: {\n pullRequest: { headRefOid: string; reviewDecision: RequiredReviewState['reviewDecision'] } | null;\n } | null;\n };\n try {\n response = await context.clients.graphql<typeof response>(\n 'query DeliveryReviewDecision($owner: String!, $name: String!, $number: Int!) { repository(owner: $owner, name: $name) { pullRequest(number: $number) { headRefOid reviewDecision } } }',\n { owner: context.repo.owner, name: context.repo.repo, number: prNumber },\n );\n } catch {\n return {\n observed: false,\n reviewDecision: null,\n submittedReviewAuthorCanPushToRepository: null,\n status: 'unknown',\n nextAction: 'Inspect the PR review requirement in GitHub before merge; review decision readback is unavailable.',\n };\n }\n const pr = response.repository?.pullRequest;\n if (!pr) {\n return {\n observed: false,\n reviewDecision: null,\n submittedReviewAuthorCanPushToRepository: null,\n status: 'unknown',\n nextAction: 'Inspect the PR review requirement in GitHub before merge; PR decision readback is unavailable.',\n };\n }\n if (pr.headRefOid !== expectedHead) {\n throw new DeliveryError('GitHub review decision does not match the exact PR head.');\n }\n if (\n pr.reviewDecision !== null &&\n pr.reviewDecision !== 'APPROVED' &&\n pr.reviewDecision !== 'REVIEW_REQUIRED' &&\n pr.reviewDecision !== 'CHANGES_REQUESTED'\n ) {\n return {\n observed: false,\n reviewDecision: null,\n submittedReviewAuthorCanPushToRepository: null,\n status: 'unknown',\n nextAction: 'Inspect the PR review requirement in GitHub before merge; review decision readback is malformed.',\n };\n }\n let submittedReviewAuthorCanPushToRepository: boolean | null = null;\n if (submittedReview) {\n try {\n const access = await context.clients.graphql<{\n repository: {\n pullRequest: {\n reviews: {\n nodes: Array<{\n author: { login: string } | null;\n authorCanPushToRepository: boolean;\n commit: { oid: string } | null;\n fullDatabaseId: string | number | null;\n state: string;\n } | null>;\n };\n } | null;\n } | null;\n }>(\n 'query DeliveryReviewAccess($owner: String!, $name: String!, $number: Int!) { repository(owner: $owner, name: $name) { pullRequest(number: $number) { reviews(last: 100) { nodes { fullDatabaseId author { login } authorCanPushToRepository commit { oid } state } } } } }',\n { owner: context.repo.owner, name: context.repo.repo, number: prNumber },\n );\n // REST review receipts include [bot], while GraphQL may omit it for the same App actor.\n const submittedActor = submittedReview.login.toLowerCase().replace(/\\[bot\\]$/u, '');\n const exact = access.repository?.pullRequest?.reviews.nodes.find(\n (review) =>\n review !== null &&\n String(review.fullDatabaseId) === String(submittedReview.id) &&\n review.author?.login.toLowerCase().replace(/\\[bot\\]$/u, '') === submittedActor &&\n review.commit?.oid === expectedHead &&\n review.state === (submittedReview.state ?? 'APPROVED'),\n );\n if (typeof exact?.authorCanPushToRepository === 'boolean') {\n submittedReviewAuthorCanPushToRepository = exact.authorCanPushToRepository;\n }\n } catch {\n // A review access read failure does not erase the live PR decision.\n }\n }\n if (pr.reviewDecision === 'APPROVED') {\n return {\n observed: true,\n reviewDecision: 'APPROVED',\n submittedReviewAuthorCanPushToRepository,\n status: 'satisfied',\n nextAction: 'Continue only after required checks pass.',\n };\n }\n if (pr.reviewDecision === 'REVIEW_REQUIRED') {\n return {\n observed: true,\n reviewDecision: 'REVIEW_REQUIRED',\n submittedReviewAuthorCanPushToRepository,\n status: 'still-required',\n nextAction:\n submittedReviewAuthorCanPushToRepository === false\n ? 'GitHub still requires a qualifying approval; the submitted reviewer App review has no repository write access. Inspect the active rule and the App installation Contents grant, then obtain approval from an eligible independent reviewer.'\n : 'GitHub still requires a qualifying approval. Inspect the active rule and obtain approval from an eligible independent reviewer; do not change actors or protections automatically.',\n };\n }\n if (pr.reviewDecision === 'CHANGES_REQUESTED') {\n return {\n observed: true,\n reviewDecision: 'CHANGES_REQUESTED',\n submittedReviewAuthorCanPushToRepository,\n status: 'changes-requested',\n nextAction: 'Resolve the blocking review and obtain a fresh exact-head independent approval.',\n };\n }\n return {\n observed: true,\n reviewDecision: null,\n submittedReviewAuthorCanPushToRepository,\n status: 'unknown',\n nextAction: 'Inspect the PR review requirement in GitHub before merge; no required-review decision was exposed.',\n };\n}\n\nexport function parseReviewArtifact(raw: unknown): ReviewArtifact {\n const value = typeof raw === 'string' ? (JSON.parse(raw) as unknown) : raw;\n return ReviewArtifactSchema.parse(value);\n}\n\n/** Preserve the original binding: GitHub can remap a review's commit_id after a rebase. */\nexport function parseGitHubReviewArtifact(body: string | null | undefined): ReviewArtifact {\n try {\n if (typeof body !== 'string' || Buffer.byteLength(body, 'utf8') > 64 * 1024) throw new Error('Invalid size.');\n const markers = body.match(/<!-- ai-delivery-review-artifact:[\\s\\S]*?-->/gu) ?? [];\n const payloads = body.match(/<!-- ai-delivery-review-artifact-data:[\\s\\S]*?-->/gu) ?? [];\n if (markers.length !== 1 || payloads.length !== 1) throw new Error('Ambiguous binding.');\n const id = markers[0]!.match(/^<!-- ai-delivery-review-artifact: (sha256:[a-f0-9]{64}) -->$/u)?.[1];\n const encoded = payloads[0]!.match(/^<!-- ai-delivery-review-artifact-data: ([A-Za-z0-9_-]+) -->$/u)?.[1];\n if (!id || !encoded) throw new Error('Invalid binding.');\n const bytes = Buffer.from(encoded, 'base64url');\n const json = bytes.toString('utf8');\n if (bytes.toString('base64url') !== encoded || !Buffer.from(json, 'utf8').equals(bytes))\n throw new Error('Invalid encoding.');\n const artifact = parseReviewArtifact(json);\n if (artifact.artifactId !== id) throw new Error('Artifact identity differs.');\n return artifact;\n } catch {\n throw new DeliveryError('GitHub review artifact binding is missing, invalid or ambiguous; obtain a fresh review.');\n }\n}\n\nfunction githubReviewBody(artifact: ReviewArtifact): string {\n ReviewArtifactSchema.parse(artifact);\n const metadata =\n artifact.verdictFileSha256 === undefined\n ? ''\n : `\\n\\nVerdict: ${artifact.verdict}\\nRequested model/effort: ${artifact.requestedModel} / ${artifact.requestedEffort}\\nEffective model/effort: ${artifact.effectiveModel} / ${artifact.effectiveEffort}\\nElapsed milliseconds: ${artifact.elapsedMs}\\nVerdict-file SHA256: ${artifact.verdictFileSha256}\\nFindings: ${artifact.findings.length ? artifact.findings.join('; ') : 'none'}`;\n const body = `${artifact.summary}${metadata}\\n\\n<!-- ai-delivery-review-artifact: ${artifact.artifactId} -->\\n<!-- ai-delivery-review-artifact-data: ${Buffer.from(JSON.stringify(artifact)).toString('base64url')} -->`;\n if (Buffer.byteLength(body) > 64 * 1024)\n throw new DeliveryError('Review body exceeds the 64 KiB publication limit; provide a concise verdict.');\n parseGitHubReviewArtifact(body);\n return body;\n}\n\nasync function readGitHubPrPaths(\n context: DeliveryContext,\n prNumber: number,\n changedFiles: number,\n claimed?: string[],\n): Promise<string[]> {\n const files: string[] = [];\n const renamed = new Set<string>();\n for (let page = 1; page <= 30; page++) {\n const batch = (\n await context.clients.rest.pulls.listFiles({ ...context.repo, pull_number: prNumber, page, per_page: 100 })\n ).data;\n files.push(...batch.map((file) => file.filename));\n for (const file of batch)\n if (file.status === 'renamed' && file.previous_filename) renamed.add(file.previous_filename);\n if (batch.length < 100) break;\n }\n if (!Number.isSafeInteger(changedFiles) || files.length !== changedFiles || new Set(files).size !== files.length)\n throw new DeliveryError('Independent review scope is incomplete or differs from the remote PR diff.');\n const current = new Set(files);\n if (\n claimed &&\n digestValue([...new Set(claimed.filter((path) => current.has(path) || !renamed.has(path)))].sort()) !==\n digestValue(files.sort())\n )\n throw new DeliveryError('Independent review scope differs from the canonical remote rename inventory.');\n return files.sort();\n}\n\nexport async function readGitHubPrScopeHash(\n context: DeliveryContext,\n prNumber: number,\n changedFiles: number,\n): Promise<string> {\n return digestValue(await readGitHubPrPaths(context, prNumber, changedFiles));\n}\n\nexport async function readGitHubReviewBase(context: DeliveryContext, prNumber: number, expectedHead: string) {\n const pr = (await context.clients.rest.pulls.get({ ...context.repo, pull_number: prNumber })).data;\n if (\n pr.number !== prNumber ||\n pr.state !== 'open' ||\n pr.head.sha !== expectedHead ||\n !Sha.safeParse(pr.base.sha).success\n )\n throw new DeliveryError('Review comparison changed; obtain a fresh review.');\n const comparison = (\n await context.clients.rest.repos.compareCommitsWithBasehead({\n ...context.repo,\n basehead: `${pr.base.sha}...${expectedHead}`,\n per_page: 1,\n })\n ).data;\n return ReviewBase.parse({ baseSha: pr.base.sha, mergeBaseSha: comparison.merge_base_commit.sha });\n}\n\nexport function reviewArtifactApproval(input: {\n artifact: ReviewArtifact;\n classification: RepositoryClassificationReceipt;\n config: Pick<DeliveryConfig, 'roles'>;\n issueNumber: number;\n prNumber?: number;\n}): RepositoryApprovalBinding {\n const { artifact, classification, config } = input;\n ReviewArtifactSchema.parse(artifact);\n if (\n artifact.verdict !== 'approve' ||\n artifact.issueNumber !== input.issueNumber ||\n artifact.authorIdentity !== config.roles.author.identity ||\n artifact.reviewerIdentity !== config.roles.reviewer.identity ||\n artifact.head.sha !== classification.head.sha ||\n artifact.head.tree !== classification.head.tree ||\n artifact.diffScopeHash !== digestValue(classification.changedPaths) ||\n (input.prNumber !== undefined && artifact.prNumber !== null && artifact.prNumber !== input.prNumber)\n ) {\n throw new DeliveryError('Independent review artifact is stale, foreign, rejected, or covers another scope.');\n }\n return RepositoryApprovalBindingSchema.parse({\n authorIdentity: artifact.authorIdentity,\n diffScopeHash: artifact.diffScopeHash,\n head: artifact.head,\n result: 'approved',\n reviewerIdentity: artifact.reviewerIdentity,\n reviewReceiptId: artifact.artifactId,\n });\n}\n\nfunction receiptPath(repoRoot: string, issueNumber: number, headSha: string): string {\n return join(gitCommonDir(repoRoot), 'ai-delivery', 'reviews', String(issueNumber), `${headSha}.json`);\n}\n\nfunction prepublicationPath(repoRoot: string, issueNumber: number, headSha: string): string {\n return join(gitCommonDir(repoRoot), 'ai-delivery', 'reviews', String(issueNumber), `${headSha}.prepublication.json`);\n}\n\nexport function savePrepublicationArtifact(input: {\n artifact: ReviewArtifact;\n classification: RepositoryClassificationReceipt;\n config: Pick<DeliveryConfig, 'roles'>;\n issueNumber: number;\n repoRoot: string;\n}): void {\n if (input.artifact.prNumber !== null) throw new DeliveryError('Prepublication review must have a null PR number.');\n reviewArtifactApproval(input);\n writePrivateJsonFileAtomically(\n prepublicationPath(input.repoRoot, input.issueNumber, input.artifact.head.sha),\n input.artifact,\n );\n}\n\nexport function loadPrepublicationArtifact(\n repoRoot: string,\n issueNumber: number,\n headSha: string,\n): ReviewArtifact | null {\n let raw: unknown;\n try {\n raw = JSON.parse(assertPrivateFile(prepublicationPath(repoRoot, issueNumber, headSha)).toString('utf8')) as unknown;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return null;\n throw new DeliveryError('Stored prepublication review is unreadable.');\n }\n return ReviewArtifactSchema.parse(raw);\n}\n\nasync function listAllReviews(context: DeliveryContext, prNumber: number) {\n const reviews: Awaited<ReturnType<typeof context.clients.rest.pulls.listReviews>>['data'] = [];\n for (let page = 1; page <= 20; page += 1) {\n const result = await context.clients.rest.pulls.listReviews({\n ...context.repo,\n pull_number: prNumber,\n per_page: 100,\n page,\n });\n reviews.push(...result.data);\n if (result.data.length < 100) return reviews;\n }\n throw new DeliveryError('Review history exceeds the bounded readback window.');\n}\n\ninterface ReviewSubmissionInput {\n artifact: ReviewArtifact;\n context: DeliveryContext;\n issueNumber: number;\n prNumber: number;\n dryRun?: boolean;\n publicationEvidenceId?: string;\n classification?: RepositoryClassificationReceipt;\n}\nexport interface GitHubReviewReceipt {\n artifact: ReviewArtifact;\n repository: string;\n baseSha: string;\n headSha: string;\n githubReviewId: number;\n githubReviewUrl: string;\n login: string;\n prNumber: number;\n schemaVersion: 'ai-delivery.github-review@1';\n state: 'APPROVED' | 'CHANGES_REQUESTED';\n receiptId: string;\n}\nexport class ReviewSubmissionError extends DeliveryError {\n constructor(\n message: string,\n readonly submission: {\n artifactId: string;\n repository: string;\n headSha: string;\n prNumber: number;\n githubReviewId?: number;\n githubReviewUrl?: string;\n },\n ) {\n super(`${message} Reconcile this artifact's remote review before retrying; no automatic retry was attempted.`);\n }\n}\nexport interface ReviewDryRun {\n dryRun: true;\n artifactId: string;\n headSha: string;\n}\nexport async function validateReviewTarget(context: DeliveryContext, artifact: ReviewArtifact, prNumber: number) {\n const pr = (await context.clients.rest.pulls.get({ ...context.repo, pull_number: prNumber })).data;\n if (\n pr.number !== prNumber ||\n pr.head.sha !== artifact.head.sha ||\n pr.state !== 'open' ||\n pr.base.repo?.full_name.toLowerCase() !== context.config.repository.toLowerCase() ||\n pr.head.repo?.full_name.toLowerCase() !== context.config.repository.toLowerCase()\n )\n throw new DeliveryError('PR identity or head changed before formal review.');\n const commit = (await context.clients.rest.git.getCommit({ ...context.repo, commit_sha: artifact.head.sha })).data;\n if (commit.sha !== artifact.head.sha || commit.tree.sha !== artifact.head.tree)\n throw new DeliveryError('Independent review tree differs from the remote commit.');\n const reviewPaths = await readGitHubPrPaths(context, prNumber, pr.changed_files, artifact.changedPaths);\n if (artifact.changedPaths === undefined && artifact.diffScopeHash !== digestValue(reviewPaths))\n throw new DeliveryError('Independent review scope is incomplete or differs from the remote PR diff.');\n if (\n artifact.reviewBase &&\n digestValue(artifact.reviewBase) !== digestValue(await readGitHubReviewBase(context, prNumber, artifact.head.sha))\n )\n throw new DeliveryError('Review comparison changed; obtain a fresh review.');\n return { ...pr, reviewPaths };\n}\n\nasync function qualifyReviewReuse(context: DeliveryContext, artifact: ReviewArtifact, prNumber: number, actor: string) {\n try {\n const request = artifact.reuse!;\n if (basename(request.verificationResultPath) !== 'result.json') throw new Error('Verification is not finalized.');\n const review = (\n await context.clients.rest.pulls.getReview({\n ...context.repo,\n pull_number: prNumber,\n review_id: request.fromReviewId,\n })\n ).data;\n const original = parseGitHubReviewArtifact(review.body);\n if (\n review.id !== request.fromReviewId ||\n review.state !== 'APPROVED' ||\n review.commit_id !== original.head.sha ||\n review.user?.login.toLowerCase() !== actor.toLowerCase() ||\n original.verdict !== 'approve' ||\n artifact.verdict !== 'approve' ||\n original.prNumber !== prNumber ||\n original.issueNumber !== artifact.issueNumber ||\n original.authorIdentity !== artifact.authorIdentity ||\n original.reviewerIdentity !== artifact.reviewerIdentity ||\n !original.reviewBase ||\n !artifact.reviewBase ||\n original.head.sha === artifact.head.sha\n )\n throw new Error('Original comparison unavailable.');\n const root = context.root;\n const base = original.reviewBase;\n const next = artifact.reviewBase;\n const mergeBase = (baseSha: string, headSha: string) => {\n const sha = git(root, 'merge-base', '--all', baseSha, headSha);\n return Sha.parse(sha);\n };\n if (\n mergeBase(base.baseSha, original.head.sha) !== base.mergeBaseSha ||\n mergeBase(next.baseSha, artifact.head.sha) !== next.mergeBaseSha ||\n gitExitCode(root, 'merge-base', '--is-ancestor', base.baseSha, next.baseSha) !== 0 ||\n gitExitCode(root, 'merge-base', '--is-ancestor', base.mergeBaseSha, next.mergeBaseSha) !== 0 ||\n git(root, 'rev-parse', `${original.head.sha}^{tree}`) !== original.head.tree\n )\n throw new Error('History differs.');\n const run = (args: string[], input?: Buffer) =>\n execFileSync(GIT_EXECUTABLE, [...inertGitArguments(root), ...args], {\n cwd: root,\n env: gitEnvironment(),\n input,\n timeout: 10000,\n maxBuffer: 4 * 1024 * 1024,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n const diff = (from: string, to: string) =>\n run([\n 'diff',\n '--no-ext-diff',\n '--no-textconv',\n '--no-color',\n '--no-renames',\n '--no-relative',\n '--src-prefix=a/',\n '--dst-prefix=b/',\n '--ignore-submodules=none',\n '--binary',\n '--full-index',\n from,\n to,\n '--',\n ]);\n const before = diff(base.mergeBaseSha, original.head.sha);\n const after = diff(next.mergeBaseSha, artifact.head.sha);\n const patch = run(['patch-id', '--stable'], before);\n if (\n !before.length ||\n !before.equals(after) ||\n !patch.equals(run(['patch-id', '--stable'], after)) ||\n !Sha.safeParse(patch.toString('utf8').split(/\\s/u)[0]).success\n )\n throw new Error('Patch differs.');\n const paths = [\n ...new Set(\n [\n [base.mergeBaseSha, original.head.sha],\n [next.mergeBaseSha, artifact.head.sha],\n ].flatMap(([from, to]) =>\n run(['diff', '--no-ext-diff', '--no-textconv', '--no-renames', '--name-only', '-z', from!, to!, '--'])\n .toString('utf8')\n .split('\\0')\n .filter(Boolean),\n ),\n ),\n ];\n const touched = (from: string, to: string) =>\n run([\n '--literal-pathspecs',\n 'log',\n '--format=',\n '--name-only',\n '-z',\n '--full-history',\n '--diff-merges=separate',\n `${from}..${to}`,\n '--',\n ...paths,\n ]).length !== 0;\n if (touched(base.mergeBaseSha, next.mergeBaseSha) || touched(base.baseSha, next.baseSha))\n throw new Error('Base touched review paths.');\n const gates = ['format', 'lint', 'types', 'build', 'tests', 'inventory'];\n const report = z\n .object({\n schemaVersion: z.literal('contributor-checks@1'),\n scope: z.literal('full'),\n status: z.literal('passed'),\n exitCode: z.literal(0),\n fullSuccess: z.literal(true),\n omitted: z.array(Text).length(0),\n completedAt: z.iso.datetime(),\n verifiedHead: z.strictObject({ sha: Sha, tree: Sha }),\n gates: z.array(Text),\n commands: z.array(\n z.object({\n stage: Text,\n status: z.literal('passed'),\n exitCode: z.literal(0),\n cleanupConfirmed: z.literal(true),\n }),\n ),\n })\n .parse(\n JSON.parse(assertPrivateFile(request.verificationResultPath, { maxBytes: 4 * 1024 * 1024 }).toString('utf8')),\n );\n if (\n digestValue(report.gates) !== digestValue(gates) ||\n digestValue(report.commands.map((command) => command.stage)) !== digestValue(gates) ||\n digestValue(report.verifiedHead) !== digestValue(artifact.head) ||\n git(root, 'rev-parse', 'HEAD') !== artifact.head.sha ||\n git(root, 'rev-parse', 'HEAD^{tree}') !== artifact.head.tree ||\n git(root, 'status', '--porcelain', '--untracked-files=all') !== ''\n )\n throw new Error('Exact-head required verification unavailable.');\n return {\n reviewId: review.id,\n artifactId: original.artifactId,\n oldHead: original.head.sha,\n newHead: artifact.head.sha,\n reason: 'Exact patch, untouched base paths and successful exact-head required verification.',\n };\n } catch {\n throw new DeliveryError(\n 'Clean-rebase reuse lacks complete unchanged-content and verification proof; obtain a fresh review.',\n );\n }\n}\n\nexport function submitReview(input: ReviewSubmissionInput & { dryRun: true }): Promise<ReviewDryRun>;\nexport function submitReview(input: ReviewSubmissionInput & { dryRun?: false }): Promise<GitHubReviewReceipt>;\nexport function submitReview(input: ReviewSubmissionInput): Promise<GitHubReviewReceipt | ReviewDryRun>;\nexport async function submitReview(input: ReviewSubmissionInput): Promise<GitHubReviewReceipt | ReviewDryRun> {\n const { context, issueNumber, prNumber } = input;\n let artifact = input.artifact;\n ReviewArtifactSchema.parse(artifact);\n if (\n artifact.issueNumber !== issueNumber ||\n artifact.authorIdentity !== context.config.roles.author.identity ||\n artifact.reviewerIdentity !== context.config.roles.reviewer.identity ||\n (artifact.prNumber !== null && artifact.prNumber !== prNumber)\n )\n throw new DeliveryError('Independent review artifact is foreign or rejected.');\n if (context.clients.authSource !== 'app' || context.clients.role !== 'reviewer' || !context.clients.appActorLogin)\n throw new DeliveryError('Formal review requires the independent reviewer GitHub App role.');\n const pr = await validateReviewTarget(context, artifact, prNumber);\n const actor = await context.clients.appActorLogin();\n if (!actor || !pr.user?.login || actor.toLowerCase() === pr.user.login.toLowerCase())\n throw new DeliveryError('Reviewer GitHub actor must differ from PR author.');\n if (artifact.reusedFrom) throw new DeliveryError('Reuse requires current comparison proof; obtain a fresh review.');\n const { artifactId: _artifactId, reuse, ...content } = artifact;\n const canonical = {\n ...content,\n ...(artifact.changedPaths === undefined\n ? {}\n : { changedPaths: pr.reviewPaths, diffScopeHash: digestValue(pr.reviewPaths) }),\n ...(reuse === undefined ? {} : { reusedFrom: await qualifyReviewReuse(context, artifact, prNumber, actor) }),\n };\n artifact = ReviewArtifactSchema.parse({ ...canonical, artifactId: digestValue(canonical) });\n const body = githubReviewBody(artifact);\n const expectedState = artifact.verdict === 'approve' ? ('APPROVED' as const) : ('CHANGES_REQUESTED' as const);\n const event = artifact.verdict === 'approve' ? ('APPROVE' as const) : ('REQUEST_CHANGES' as const);\n const marker = `<!-- ai-delivery-review-artifact: ${artifact.artifactId} -->`;\n const history = await listAllReviews(context, prNumber);\n const matches = history.filter((review) => review.body?.includes(marker));\n if (matches.length > 1) throw new DeliveryError('Conflicting GitHub reviews claim the same artifact identity.');\n const prior = matches[0];\n if (\n prior &&\n (prior.state !== expectedState ||\n prior.commit_id !== artifact.head.sha ||\n prior.user?.login.toLowerCase() !== actor.toLowerCase() ||\n !prior.html_url ||\n parseGitHubReviewArtifact(prior.body).artifactId !== artifact.artifactId)\n )\n throw new DeliveryError('Prior GitHub review marker conflicts with exact-head approval.');\n const fresh = (await context.clients.rest.pulls.get({ ...context.repo, pull_number: prNumber })).data;\n if (fresh.head.sha !== artifact.head.sha || fresh.base.sha !== pr.base.sha || fresh.state !== 'open')\n throw new DeliveryError('PR moved during independent review validation.');\n if (input.dryRun) return { dryRun: true as const, artifactId: artifact.artifactId, headSha: artifact.head.sha };\n const pending = {\n artifactId: artifact.artifactId,\n repository: context.config.repository,\n headSha: artifact.head.sha,\n prNumber,\n };\n let submitted;\n try {\n submitted =\n prior ??\n (\n await context.clients.rest.pulls.createReview({\n ...context.repo,\n pull_number: prNumber,\n commit_id: artifact.head.sha,\n body,\n event,\n })\n ).data;\n } catch {\n throw new ReviewSubmissionError('Review submission acknowledgement is unknown.', pending);\n }\n const known = {\n ...pending,\n ...(submitted.id ? { githubReviewId: submitted.id } : {}),\n ...(submitted.html_url ? { githubReviewUrl: submitted.html_url } : {}),\n };\n try {\n if (\n !submitted.id ||\n submitted.state !== expectedState ||\n submitted.commit_id !== artifact.head.sha ||\n submitted.user?.login.toLowerCase() !== actor.toLowerCase() ||\n !submitted.html_url\n )\n throw new DeliveryError('GitHub did not return complete exact-head independent approval.');\n const content = {\n artifact,\n repository: context.config.repository,\n baseSha: pr.base.sha,\n headSha: artifact.head.sha,\n githubReviewId: submitted.id,\n githubReviewUrl: submitted.html_url,\n login: submitted.user.login,\n prNumber,\n schemaVersion: 'ai-delivery.github-review@1' as const,\n state: expectedState,\n };\n const receipt = { ...content, receiptId: digestValue(content) };\n const readback = (\n await context.clients.rest.pulls.getReview({ ...context.repo, pull_number: prNumber, review_id: submitted.id })\n ).data;\n if (\n readback.id !== receipt.githubReviewId ||\n readback.html_url !== receipt.githubReviewUrl ||\n readback.state !== expectedState ||\n readback.commit_id !== receipt.headSha ||\n readback.user?.login !== receipt.login ||\n parseGitHubReviewArtifact(readback.body).artifactId !== artifact.artifactId\n )\n throw new DeliveryError('GitHub exact-head App review readback disagrees.');\n\n const current = (await context.clients.rest.pulls.get({ ...context.repo, pull_number: prNumber })).data;\n if (current.head.sha !== artifact.head.sha || current.base.sha !== pr.base.sha || current.state !== 'open')\n throw new DeliveryError('PR moved during independent review submission; approval is not current.');\n return receipt;\n } catch (error) {\n throw new ReviewSubmissionError(\n error instanceof DeliveryError ? error.message : 'Review post-submission readback is unavailable.',\n known,\n );\n }\n}\n\nexport function loadSubmittedReview(\n repoRoot: string,\n issueNumber: number,\n headSha: string,\n): SubmittedReviewReceipt | null {\n let raw: unknown;\n try {\n raw = JSON.parse(assertPrivateFile(receiptPath(repoRoot, issueNumber, headSha)).toString('utf8')) as unknown;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return null;\n throw new DeliveryError('Stored review receipt is unreadable.');\n }\n return SubmittedReviewReceiptSchema.parse(raw);\n}\n\nexport async function assertSubmittedReviewCurrent(\n context: DeliveryContext,\n receipt: SubmittedReviewReceipt,\n): Promise<void> {\n SubmittedReviewReceiptSchema.parse(receipt);\n const review = (await listAllReviews(context, receipt.prNumber)).find(\n (candidate) => candidate.id === receipt.githubReviewId,\n );\n if (\n !review ||\n review.state !== 'APPROVED' ||\n review.commit_id !== receipt.headSha ||\n review.user?.login !== receipt.login ||\n review.html_url !== receipt.githubReviewUrl ||\n parseGitHubReviewArtifact(review.body).artifactId !== receipt.artifact.artifactId\n ) {\n throw new DeliveryError('GitHub exact-head review no longer matches the stored receipt.');\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,UAAU,YAAY;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAGlB,SAAS,yBAAyB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,qBAAqB;AAC9B,SAAS,KAAK,cAAc,mBAAmB;AAC/C,SAAS,gBAAgB,gBAAgB,yBAAyB;AAElE,SAAS,sCAAsC;AAE/C,MAAM,MAAM,EAAE,OAAO,EAAE,MAAM,iBAAiB;AAC9C,MAAM,SAAS,EAAE,OAAO,EAAE,MAAM,wBAAwB;AACxD,MAAM,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;AACpC,MAAM,SAAS,EAAE,KAAK,CAAC,QAAQ,WAAW,OAAO,UAAU,QAAQ,SAAS,OAAO,SAAS,WAAW,CAAC;AACxG,MAAM,aAAa,EAAE,aAAa,EAAE,SAAS,KAAK,cAAc,IAAI,CAAC;AACrE,MAAM,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,wBAAwB,KAAK,CAAC;AACjG,MAAM,sBAAsB,EAAE,aAAa;AAAA,EAChD,eAAe,EAAE,QAAQ,8BAA8B;AAAA,EACvD,SAAS,EAAE,KAAK,CAAC,WAAW,iBAAiB,CAAC;AAAA,EAC9C,SAAS;AAAA,EACT,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EACvC,OAAO,EAAE,aAAa;AAAA,IACpB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,cAAc,EACX;AAAA,MACC,EACG,OAAO,EACP,IAAI,CAAC,EACL,OAAO,CAAC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,GAAG;AACnG,QAAI,QAAQ,KAAK,QAAQ,SAAS,KAAK,OAAO,QAAQ,KAAK,QAAQ,GAAG,KAAK,OAAO,QAAQ,UAAU;AAClG,YAAM,IAAI,cAAc,yEAAyE;AACnG,WAAO;AAAA,EACT,SAAS,OAAO;AACd,UAAM,IAAI;AAAA,MACR,iBAAiB,gBAAgB,MAAM,UAAU;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,oBACd,UACA,aACA,SAC+B;AAC/B,MAAI;AACJ,MAAI;AACF,UAAM,KAAK,MAAM,kBAAkB,YAAY,UAAU,aAAa,OAAO,CAAC,EAAE,SAAS,MAAM,CAAC;AAAA,EAClG,SAAS,OAAO;AACd,QAAK,MAAgC,SAAS,SAAU,QAAO;AAC/D,UAAM,IAAI,cAAc,sCAAsC;AAAA,EAChE;AACA,SAAO,6BAA6B,MAAM,GAAG;AAC/C;AAEA,eAAsB,6BACpB,SACA,SACe;AACf,+BAA6B,MAAM,OAAO;AAC1C,QAAM,UAAU,MAAM,eAAe,SAAS,QAAQ,QAAQ,GAAG;AAAA,IAC/D,CAAC,cAAc,UAAU,OAAO,QAAQ;AAAA,EAC1C;AACA,MACE,CAAC,UACD,OAAO,UAAU,cACjB,OAAO,cAAc,QAAQ,WAC7B,OAAO,MAAM,UAAU,QAAQ,SAC/B,OAAO,aAAa,QAAQ,mBAC5B,0BAA0B,OAAO,IAAI,EAAE,eAAe,QAAQ,SAAS,YACvE;AACA,UAAM,IAAI,cAAc,gEAAgE;AAAA,EAC1F;AACF;",
|
|
4
|
+
"sourcesContent": ["import { basename } from 'node:path';\nimport { execFileSync } from 'node:child_process';\nimport { z } from 'zod';\n\nimport { assertPrivateFile, digestValue } from './delivery/common.js';\nimport { DeliveryError } from './errors.js';\nimport { git, gitExitCode } from './git.js';\nimport { GIT_EXECUTABLE, gitEnvironment, inertGitArguments } from './gitProcess.js';\nimport type { DeliveryContext } from './issue.js';\n\nconst Sha = z.string().regex(/^[a-f0-9]{40}$/u);\nconst Digest = z.string().regex(/^sha256:[a-f0-9]{64}$/u);\nconst Text = z.string().trim().min(1);\nconst Effort = z.enum(['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra', 'inherited']);\nconst ReviewBase = z.strictObject({ baseSha: Sha, mergeBaseSha: Sha });\nconst Reuse = z.strictObject({ fromReviewId: z.number().int().positive(), verificationResultPath: Text });\nexport const ReviewVerdictSchema = z.strictObject({\n schemaVersion: z.literal('ai-delivery.review-verdict@1'),\n verdict: z.enum(['approve', 'request-changes']),\n summary: Text,\n issueNumber: z.number().int().positive(),\n scope: z.strictObject({\n headSha: Sha,\n headTree: Sha,\n changedPaths: z\n .array(\n z\n .string()\n .min(1)\n .refine((path) => !path.includes('\\0'), 'Paths cannot contain NUL.'),\n )\n .transform((paths) => [...new Set(paths)].sort()),\n }),\n verificationReproduced: z.array(Text).min(1),\n requestedModel: Text,\n requestedEffort: Effort.default('inherited'),\n effectiveModel: Text,\n effectiveEffort: Effort.default('inherited'),\n elapsedMs: z.number().int().nonnegative(),\n findings: z.array(Text),\n readOnly: z.literal(true),\n nonClosing: z.boolean().optional(),\n reuse: Reuse.optional(),\n});\nexport type ReviewVerdict = z.infer<typeof ReviewVerdictSchema>;\n\nexport function parseReviewVerdict(raw: unknown): ReviewVerdict {\n let value: unknown;\n try {\n value = typeof raw === 'string' ? (JSON.parse(raw) as unknown) : raw;\n } catch {\n throw new DeliveryError('verdict: Invalid JSON.');\n }\n const result = ReviewVerdictSchema.safeParse(value);\n if (!result.success)\n throw new DeliveryError(\n result.error.issues.map((issue) => `${issue.path.join('.') || 'verdict'}: ${issue.message}`).join('; '),\n );\n return result.data;\n}\n\nexport function buildReviewArtifact(input: {\n verdict: ReviewVerdict;\n verdictFileSha256: string;\n identity: string;\n provider: string;\n expectedHead: string;\n prNumber: number;\n authorIdentity: string;\n reviewBase?: z.infer<typeof ReviewBase>;\n}): ReviewArtifact {\n const verdict = parseReviewVerdict(input.verdict);\n if (!Digest.safeParse(input.verdictFileSha256).success)\n throw new DeliveryError('verdictFileSha256: Expected the exact verdict-file SHA256.');\n if (input.identity.toLowerCase() === input.authorIdentity.toLowerCase())\n throw new DeliveryError('identity: Reviewer and author must be distinct.');\n assertReviewVerdictTarget(verdict, input.provider, input.expectedHead);\n const content = {\n schemaVersion: 'ai-delivery.review-artifact@1' as const,\n verdictFileSha256: input.verdictFileSha256,\n authorIdentity: input.authorIdentity,\n reviewerIdentity: input.identity,\n head: { sha: verdict.scope.headSha, tree: verdict.scope.headTree },\n issueNumber: verdict.issueNumber,\n prNumber: input.prNumber,\n diffScopeHash: digestValue(verdict.scope.changedPaths),\n changedPaths: verdict.scope.changedPaths,\n ...(input.reviewBase === undefined ? {} : { reviewBase: input.reviewBase }),\n ...(verdict.reuse === undefined ? {} : { reuse: verdict.reuse }),\n checks: verdict.verificationReproduced,\n elapsedMs: verdict.elapsedMs,\n findings: verdict.findings,\n readOnly: verdict.readOnly,\n requestedModel: verdict.requestedModel,\n requestedEffort: verdict.requestedEffort,\n effectiveModel: verdict.effectiveModel,\n effectiveEffort: verdict.effectiveEffort,\n summary: verdict.summary,\n verdict: verdict.verdict,\n };\n const artifact = ReviewArtifactSchema.parse({ ...content, artifactId: digestValue(content) });\n githubReviewBody(artifact);\n return artifact;\n}\n\nexport function assertReviewVerdictTarget(\n verdict: ReviewVerdict,\n selectedProvider: string,\n expectedHead: string,\n): void {\n const provider = (model: string) =>\n /^(?:gpt-|o[134](?:-|$))/u.test(model)\n ? 'openai'\n : model.startsWith('claude-')\n ? 'anthropic'\n : model.startsWith('gemini-')\n ? 'google'\n : /^qwen[\\d.-]/iu.test(model)\n ? 'qwen'\n : null;\n if (\n provider(verdict.requestedModel) === null ||\n provider(verdict.requestedModel) !== selectedProvider ||\n provider(verdict.effectiveModel) !== selectedProvider\n )\n throw new DeliveryError(\n 'identity: Configured reviewer provider must match both requestedModel and effectiveModel families.',\n );\n if (!Sha.safeParse(expectedHead).success || expectedHead !== verdict.scope.headSha)\n throw new DeliveryError('scope.headSha: Verdict and requested exact head differ.');\n}\nexport const ReviewArtifactSchema = z\n .object({\n artifactId: Digest,\n verdictFileSha256: Digest.optional(),\n authorIdentity: z.string().min(1),\n checks: z.array(z.string().min(1)).min(1),\n diffScopeHash: Digest,\n deliveryMetrics: z\n .object({ blockerTimeMs: z.number().int().nonnegative().nullable(), reviewRound: z.number().int().positive() })\n .strict()\n .optional(),\n elapsedMs: z.number().int().nonnegative(),\n findings: z.array(z.string()),\n head: z.object({ sha: Sha, tree: Sha }).strict(),\n reviewBase: ReviewBase.optional(),\n reuse: Reuse.optional(),\n reusedFrom: z\n .strictObject({\n reviewId: z.number().int().positive(),\n artifactId: Digest,\n oldHead: Sha,\n newHead: Sha,\n reason: Text,\n })\n .optional(),\n changedPaths: z\n .array(\n z\n .string()\n .min(1)\n .refine((path) => !path.includes('\\0')),\n )\n .optional(),\n issueNumber: z.number().int().positive(),\n prNumber: z.number().int().positive().nullable(),\n readOnly: z.literal(true),\n requestedEffort: z.string().min(1),\n requestedModel: z.string().min(1),\n effectiveEffort: z.string().min(1),\n effectiveModel: z.string().min(1),\n reviewerIdentity: z.string().min(1),\n schemaVersion: z.literal('ai-delivery.review-artifact@1'),\n summary: z.string().min(1),\n verdict: z.enum(['approve', 'request-changes']),\n })\n .strict()\n .superRefine((artifact, ctx) => {\n const { artifactId, ...content } = artifact;\n if (\n artifactId !== digestValue(content) ||\n artifact.authorIdentity === artifact.reviewerIdentity ||\n (artifact.changedPaths !== undefined && artifact.diffScopeHash !== digestValue(artifact.changedPaths))\n ) {\n ctx.addIssue({ code: 'custom', message: 'Review artifact identity or role separation is invalid.' });\n }\n });\nexport type ReviewArtifact = z.infer<typeof ReviewArtifactSchema>;\n\nexport interface RequiredReviewState {\n observed?: boolean;\n reviewDecision: 'APPROVED' | 'CHANGES_REQUESTED' | 'REVIEW_REQUIRED' | null;\n submittedReviewAuthorCanPushToRepository: boolean | null;\n status: 'satisfied' | 'changes-requested' | 'still-required' | 'unknown';\n nextAction: string;\n}\n\n/** GitHub's PR decision is the live requirement state, not the state of one submitted review. */\nexport async function readRequiredReviewState(\n context: Pick<DeliveryContext, 'clients' | 'repo'>,\n prNumber: number,\n expectedHead: string,\n submittedReview?: { id: number; login: string; state?: 'APPROVED' | 'CHANGES_REQUESTED' },\n): Promise<RequiredReviewState> {\n let response: {\n repository: {\n pullRequest: { headRefOid: string; reviewDecision: RequiredReviewState['reviewDecision'] } | null;\n } | null;\n };\n try {\n response = await context.clients.graphql<typeof response>(\n 'query DeliveryReviewDecision($owner: String!, $name: String!, $number: Int!) { repository(owner: $owner, name: $name) { pullRequest(number: $number) { headRefOid reviewDecision } } }',\n { owner: context.repo.owner, name: context.repo.repo, number: prNumber },\n );\n } catch {\n return {\n observed: false,\n reviewDecision: null,\n submittedReviewAuthorCanPushToRepository: null,\n status: 'unknown',\n nextAction: 'Inspect the PR review requirement in GitHub before merge; review decision readback is unavailable.',\n };\n }\n const pr = response.repository?.pullRequest;\n if (!pr) {\n return {\n observed: false,\n reviewDecision: null,\n submittedReviewAuthorCanPushToRepository: null,\n status: 'unknown',\n nextAction: 'Inspect the PR review requirement in GitHub before merge; PR decision readback is unavailable.',\n };\n }\n if (pr.headRefOid !== expectedHead) {\n throw new DeliveryError('GitHub review decision does not match the exact PR head.');\n }\n if (\n pr.reviewDecision !== null &&\n pr.reviewDecision !== 'APPROVED' &&\n pr.reviewDecision !== 'REVIEW_REQUIRED' &&\n pr.reviewDecision !== 'CHANGES_REQUESTED'\n ) {\n return {\n observed: false,\n reviewDecision: null,\n submittedReviewAuthorCanPushToRepository: null,\n status: 'unknown',\n nextAction: 'Inspect the PR review requirement in GitHub before merge; review decision readback is malformed.',\n };\n }\n let submittedReviewAuthorCanPushToRepository: boolean | null = null;\n if (submittedReview) {\n try {\n const access = await context.clients.graphql<{\n repository: {\n pullRequest: {\n reviews: {\n nodes: Array<{\n author: { login: string } | null;\n authorCanPushToRepository: boolean;\n commit: { oid: string } | null;\n fullDatabaseId: string | number | null;\n state: string;\n } | null>;\n };\n } | null;\n } | null;\n }>(\n 'query DeliveryReviewAccess($owner: String!, $name: String!, $number: Int!) { repository(owner: $owner, name: $name) { pullRequest(number: $number) { reviews(last: 100) { nodes { fullDatabaseId author { login } authorCanPushToRepository commit { oid } state } } } } }',\n { owner: context.repo.owner, name: context.repo.repo, number: prNumber },\n );\n // REST review receipts include [bot], while GraphQL may omit it for the same App actor.\n const submittedActor = submittedReview.login.toLowerCase().replace(/\\[bot\\]$/u, '');\n const exact = access.repository?.pullRequest?.reviews.nodes.find(\n (review) =>\n review !== null &&\n String(review.fullDatabaseId) === String(submittedReview.id) &&\n review.author?.login.toLowerCase().replace(/\\[bot\\]$/u, '') === submittedActor &&\n review.commit?.oid === expectedHead &&\n review.state === (submittedReview.state ?? 'APPROVED'),\n );\n if (typeof exact?.authorCanPushToRepository === 'boolean') {\n submittedReviewAuthorCanPushToRepository = exact.authorCanPushToRepository;\n }\n } catch {\n // A review access read failure does not erase the live PR decision.\n }\n }\n if (pr.reviewDecision === 'APPROVED') {\n return {\n observed: true,\n reviewDecision: 'APPROVED',\n submittedReviewAuthorCanPushToRepository,\n status: 'satisfied',\n nextAction: 'Continue only after required checks pass.',\n };\n }\n if (pr.reviewDecision === 'REVIEW_REQUIRED') {\n return {\n observed: true,\n reviewDecision: 'REVIEW_REQUIRED',\n submittedReviewAuthorCanPushToRepository,\n status: 'still-required',\n nextAction:\n submittedReviewAuthorCanPushToRepository === false\n ? 'GitHub still requires a qualifying approval; the submitted reviewer App review has no repository write access. Inspect the active rule and the App installation Contents grant, then obtain approval from an eligible independent reviewer.'\n : 'GitHub still requires a qualifying approval. Inspect the active rule and obtain approval from an eligible independent reviewer; do not change actors or protections automatically.',\n };\n }\n if (pr.reviewDecision === 'CHANGES_REQUESTED') {\n return {\n observed: true,\n reviewDecision: 'CHANGES_REQUESTED',\n submittedReviewAuthorCanPushToRepository,\n status: 'changes-requested',\n nextAction: 'Resolve the blocking review and obtain a fresh exact-head independent approval.',\n };\n }\n return {\n observed: true,\n reviewDecision: null,\n submittedReviewAuthorCanPushToRepository,\n status: 'unknown',\n nextAction: 'Inspect the PR review requirement in GitHub before merge; no required-review decision was exposed.',\n };\n}\n\nexport function parseReviewArtifact(raw: unknown): ReviewArtifact {\n const value = typeof raw === 'string' ? (JSON.parse(raw) as unknown) : raw;\n return ReviewArtifactSchema.parse(value);\n}\n\n/** Preserve the original binding: GitHub can remap a review's commit_id after a rebase. */\nexport function parseGitHubReviewArtifact(body: string | null | undefined): ReviewArtifact {\n try {\n if (typeof body !== 'string' || Buffer.byteLength(body, 'utf8') > 64 * 1024) throw new Error('Invalid size.');\n const markers = body.match(/<!-- ai-delivery-review-artifact:[\\s\\S]*?-->/gu) ?? [];\n const payloads = body.match(/<!-- ai-delivery-review-artifact-data:[\\s\\S]*?-->/gu) ?? [];\n if (markers.length !== 1 || payloads.length !== 1) throw new Error('Ambiguous binding.');\n const id = markers[0]!.match(/^<!-- ai-delivery-review-artifact: (sha256:[a-f0-9]{64}) -->$/u)?.[1];\n const encoded = payloads[0]!.match(/^<!-- ai-delivery-review-artifact-data: ([A-Za-z0-9_-]+) -->$/u)?.[1];\n if (!id || !encoded) throw new Error('Invalid binding.');\n const bytes = Buffer.from(encoded, 'base64url');\n const json = bytes.toString('utf8');\n if (bytes.toString('base64url') !== encoded || !Buffer.from(json, 'utf8').equals(bytes))\n throw new Error('Invalid encoding.');\n const artifact = parseReviewArtifact(json);\n if (artifact.artifactId !== id) throw new Error('Artifact identity differs.');\n return artifact;\n } catch {\n throw new DeliveryError('GitHub review artifact binding is missing, invalid or ambiguous; obtain a fresh review.');\n }\n}\n\nfunction githubReviewBody(artifact: ReviewArtifact): string {\n ReviewArtifactSchema.parse(artifact);\n const metadata =\n artifact.verdictFileSha256 === undefined\n ? ''\n : `\\n\\nVerdict: ${artifact.verdict}\\nRequested model/effort: ${artifact.requestedModel} / ${artifact.requestedEffort}\\nEffective model/effort: ${artifact.effectiveModel} / ${artifact.effectiveEffort}\\nElapsed milliseconds: ${artifact.elapsedMs}\\nVerdict-file SHA256: ${artifact.verdictFileSha256}\\nFindings: ${artifact.findings.length ? artifact.findings.join('; ') : 'none'}`;\n const body = `${artifact.summary}${metadata}\\n\\n<!-- ai-delivery-review-artifact: ${artifact.artifactId} -->\\n<!-- ai-delivery-review-artifact-data: ${Buffer.from(JSON.stringify(artifact)).toString('base64url')} -->`;\n if (Buffer.byteLength(body) > 64 * 1024)\n throw new DeliveryError('Review body exceeds the 64 KiB publication limit; provide a concise verdict.');\n parseGitHubReviewArtifact(body);\n return body;\n}\n\nasync function readGitHubPrPaths(\n context: DeliveryContext,\n prNumber: number,\n changedFiles: number,\n claimed?: string[],\n): Promise<string[]> {\n const files: string[] = [];\n const renamed = new Set<string>();\n for (let page = 1; page <= 30; page++) {\n const batch = (\n await context.clients.rest.pulls.listFiles({ ...context.repo, pull_number: prNumber, page, per_page: 100 })\n ).data;\n files.push(...batch.map((file) => file.filename));\n for (const file of batch)\n if (file.status === 'renamed' && file.previous_filename) renamed.add(file.previous_filename);\n if (batch.length < 100) break;\n }\n if (!Number.isSafeInteger(changedFiles) || files.length !== changedFiles || new Set(files).size !== files.length)\n throw new DeliveryError('Independent review scope is incomplete or differs from the remote PR diff.');\n const current = new Set(files);\n if (\n claimed &&\n digestValue([...new Set(claimed.filter((path) => current.has(path) || !renamed.has(path)))].sort()) !==\n digestValue(files.sort())\n )\n throw new DeliveryError('Independent review scope differs from the canonical remote rename inventory.');\n return files.sort();\n}\n\nexport async function readGitHubReviewBase(context: DeliveryContext, prNumber: number, expectedHead: string) {\n const pr = (await context.clients.rest.pulls.get({ ...context.repo, pull_number: prNumber })).data;\n if (\n pr.number !== prNumber ||\n pr.state !== 'open' ||\n pr.head.sha !== expectedHead ||\n !Sha.safeParse(pr.base.sha).success\n )\n throw new DeliveryError('Review comparison changed; obtain a fresh review.');\n const comparison = (\n await context.clients.rest.repos.compareCommitsWithBasehead({\n ...context.repo,\n basehead: `${pr.base.sha}...${expectedHead}`,\n per_page: 1,\n })\n ).data;\n return ReviewBase.parse({ baseSha: pr.base.sha, mergeBaseSha: comparison.merge_base_commit.sha });\n}\n\nasync function listAllReviews(context: DeliveryContext, prNumber: number) {\n const reviews: Awaited<ReturnType<typeof context.clients.rest.pulls.listReviews>>['data'] = [];\n for (let page = 1; page <= 20; page += 1) {\n const result = await context.clients.rest.pulls.listReviews({\n ...context.repo,\n pull_number: prNumber,\n per_page: 100,\n page,\n });\n reviews.push(...result.data);\n if (result.data.length < 100) return reviews;\n }\n throw new DeliveryError('Review history exceeds the bounded readback window.');\n}\n\ninterface ReviewSubmissionInput {\n artifact: ReviewArtifact;\n context: DeliveryContext;\n issueNumber: number;\n prNumber: number;\n dryRun?: boolean;\n}\nexport interface GitHubReviewReceipt {\n artifact: ReviewArtifact;\n repository: string;\n baseSha: string;\n headSha: string;\n githubReviewId: number;\n githubReviewUrl: string;\n login: string;\n prNumber: number;\n schemaVersion: 'ai-delivery.github-review@1';\n state: 'APPROVED' | 'CHANGES_REQUESTED';\n receiptId: string;\n}\nexport class ReviewSubmissionError extends DeliveryError {\n constructor(\n message: string,\n readonly submission: {\n artifactId: string;\n repository: string;\n headSha: string;\n prNumber: number;\n githubReviewId?: number;\n githubReviewUrl?: string;\n },\n ) {\n super(`${message} Reconcile this artifact's remote review before retrying; no automatic retry was attempted.`);\n }\n}\nexport interface ReviewDryRun {\n dryRun: true;\n artifactId: string;\n headSha: string;\n}\nexport async function validateReviewTarget(context: DeliveryContext, artifact: ReviewArtifact, prNumber: number) {\n const pr = (await context.clients.rest.pulls.get({ ...context.repo, pull_number: prNumber })).data;\n if (\n pr.number !== prNumber ||\n pr.head.sha !== artifact.head.sha ||\n pr.state !== 'open' ||\n pr.base.repo?.full_name.toLowerCase() !== context.config.repository.toLowerCase() ||\n pr.head.repo?.full_name.toLowerCase() !== context.config.repository.toLowerCase()\n )\n throw new DeliveryError('PR identity or head changed before formal review.');\n const commit = (await context.clients.rest.git.getCommit({ ...context.repo, commit_sha: artifact.head.sha })).data;\n if (commit.sha !== artifact.head.sha || commit.tree.sha !== artifact.head.tree)\n throw new DeliveryError('Independent review tree differs from the remote commit.');\n const reviewPaths = await readGitHubPrPaths(context, prNumber, pr.changed_files, artifact.changedPaths);\n if (artifact.changedPaths === undefined && artifact.diffScopeHash !== digestValue(reviewPaths))\n throw new DeliveryError('Independent review scope is incomplete or differs from the remote PR diff.');\n if (\n artifact.reviewBase &&\n digestValue(artifact.reviewBase) !== digestValue(await readGitHubReviewBase(context, prNumber, artifact.head.sha))\n )\n throw new DeliveryError('Review comparison changed; obtain a fresh review.');\n return { ...pr, reviewPaths };\n}\n\nasync function qualifyReviewReuse(context: DeliveryContext, artifact: ReviewArtifact, prNumber: number, actor: string) {\n try {\n const request = artifact.reuse!;\n if (basename(request.verificationResultPath) !== 'result.json') throw new Error('Verification is not finalized.');\n const review = (\n await context.clients.rest.pulls.getReview({\n ...context.repo,\n pull_number: prNumber,\n review_id: request.fromReviewId,\n })\n ).data;\n const original = parseGitHubReviewArtifact(review.body);\n if (\n review.id !== request.fromReviewId ||\n review.state !== 'APPROVED' ||\n review.commit_id !== original.head.sha ||\n review.user?.login.toLowerCase() !== actor.toLowerCase() ||\n original.verdict !== 'approve' ||\n artifact.verdict !== 'approve' ||\n original.prNumber !== prNumber ||\n original.issueNumber !== artifact.issueNumber ||\n original.authorIdentity !== artifact.authorIdentity ||\n original.reviewerIdentity !== artifact.reviewerIdentity ||\n !original.reviewBase ||\n !artifact.reviewBase ||\n original.head.sha === artifact.head.sha\n )\n throw new Error('Original comparison unavailable.');\n const root = context.root;\n const base = original.reviewBase;\n const next = artifact.reviewBase;\n const mergeBase = (baseSha: string, headSha: string) => {\n const sha = git(root, 'merge-base', '--all', baseSha, headSha);\n return Sha.parse(sha);\n };\n if (\n mergeBase(base.baseSha, original.head.sha) !== base.mergeBaseSha ||\n mergeBase(next.baseSha, artifact.head.sha) !== next.mergeBaseSha ||\n gitExitCode(root, 'merge-base', '--is-ancestor', base.baseSha, next.baseSha) !== 0 ||\n gitExitCode(root, 'merge-base', '--is-ancestor', base.mergeBaseSha, next.mergeBaseSha) !== 0 ||\n git(root, 'rev-parse', `${original.head.sha}^{tree}`) !== original.head.tree\n )\n throw new Error('History differs.');\n const run = (args: string[], input?: Buffer) =>\n execFileSync(GIT_EXECUTABLE, [...inertGitArguments(root), ...args], {\n cwd: root,\n env: gitEnvironment(),\n input,\n timeout: 10000,\n maxBuffer: 4 * 1024 * 1024,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n const diff = (from: string, to: string) =>\n run([\n 'diff',\n '--no-ext-diff',\n '--no-textconv',\n '--no-color',\n '--no-renames',\n '--no-relative',\n '--src-prefix=a/',\n '--dst-prefix=b/',\n '--ignore-submodules=none',\n '--binary',\n '--full-index',\n from,\n to,\n '--',\n ]);\n const before = diff(base.mergeBaseSha, original.head.sha);\n const after = diff(next.mergeBaseSha, artifact.head.sha);\n const patch = run(['patch-id', '--stable'], before);\n if (\n !before.length ||\n !before.equals(after) ||\n !patch.equals(run(['patch-id', '--stable'], after)) ||\n !Sha.safeParse(patch.toString('utf8').split(/\\s/u)[0]).success\n )\n throw new Error('Patch differs.');\n const paths = [\n ...new Set(\n [\n [base.mergeBaseSha, original.head.sha],\n [next.mergeBaseSha, artifact.head.sha],\n ].flatMap(([from, to]) =>\n run(['diff', '--no-ext-diff', '--no-textconv', '--no-renames', '--name-only', '-z', from!, to!, '--'])\n .toString('utf8')\n .split('\\0')\n .filter(Boolean),\n ),\n ),\n ];\n const touched = (from: string, to: string) =>\n run([\n '--literal-pathspecs',\n 'log',\n '--format=',\n '--name-only',\n '-z',\n '--full-history',\n '--diff-merges=separate',\n `${from}..${to}`,\n '--',\n ...paths,\n ]).length !== 0;\n if (touched(base.mergeBaseSha, next.mergeBaseSha) || touched(base.baseSha, next.baseSha))\n throw new Error('Base touched review paths.');\n const gates = ['format', 'lint', 'types', 'build', 'tests', 'inventory'];\n const report = z\n .object({\n schemaVersion: z.literal('contributor-checks@1'),\n scope: z.literal('full'),\n status: z.literal('passed'),\n exitCode: z.literal(0),\n fullSuccess: z.literal(true),\n omitted: z.array(Text).length(0),\n completedAt: z.iso.datetime(),\n verifiedHead: z.strictObject({ sha: Sha, tree: Sha }),\n gates: z.array(Text),\n commands: z.array(\n z.object({\n stage: Text,\n status: z.literal('passed'),\n exitCode: z.literal(0),\n cleanupConfirmed: z.literal(true),\n }),\n ),\n })\n .parse(\n JSON.parse(assertPrivateFile(request.verificationResultPath, { maxBytes: 4 * 1024 * 1024 }).toString('utf8')),\n );\n if (\n digestValue(report.gates) !== digestValue(gates) ||\n digestValue(report.commands.map((command) => command.stage)) !== digestValue(gates) ||\n digestValue(report.verifiedHead) !== digestValue(artifact.head) ||\n git(root, 'rev-parse', 'HEAD') !== artifact.head.sha ||\n git(root, 'rev-parse', 'HEAD^{tree}') !== artifact.head.tree ||\n git(root, 'status', '--porcelain', '--untracked-files=all') !== ''\n )\n throw new Error('Exact-head required verification unavailable.');\n return {\n reviewId: review.id,\n artifactId: original.artifactId,\n oldHead: original.head.sha,\n newHead: artifact.head.sha,\n reason: 'Exact patch, untouched base paths and successful exact-head required verification.',\n };\n } catch {\n throw new DeliveryError(\n 'Clean-rebase reuse lacks complete unchanged-content and verification proof; obtain a fresh review.',\n );\n }\n}\n\nexport function submitReview(input: ReviewSubmissionInput & { dryRun: true }): Promise<ReviewDryRun>;\nexport function submitReview(input: ReviewSubmissionInput & { dryRun?: false }): Promise<GitHubReviewReceipt>;\nexport function submitReview(input: ReviewSubmissionInput): Promise<GitHubReviewReceipt | ReviewDryRun>;\nexport async function submitReview(input: ReviewSubmissionInput): Promise<GitHubReviewReceipt | ReviewDryRun> {\n const { context, issueNumber, prNumber } = input;\n let artifact = input.artifact;\n ReviewArtifactSchema.parse(artifact);\n if (\n artifact.issueNumber !== issueNumber ||\n artifact.authorIdentity !== context.config.roles.author.identity ||\n artifact.reviewerIdentity !== context.config.roles.reviewer.identity ||\n (artifact.prNumber !== null && artifact.prNumber !== prNumber)\n )\n throw new DeliveryError('Independent review artifact is foreign or rejected.');\n if (context.clients.authSource !== 'app' || context.clients.role !== 'reviewer' || !context.clients.appActorLogin)\n throw new DeliveryError('Formal review requires the independent reviewer GitHub App role.');\n const pr = await validateReviewTarget(context, artifact, prNumber);\n const actor = await context.clients.appActorLogin();\n if (!actor || !pr.user?.login || actor.toLowerCase() === pr.user.login.toLowerCase())\n throw new DeliveryError('Reviewer GitHub actor must differ from PR author.');\n if (artifact.reusedFrom) throw new DeliveryError('Reuse requires current comparison proof; obtain a fresh review.');\n const { artifactId: _artifactId, reuse, ...content } = artifact;\n const canonical = {\n ...content,\n ...(artifact.changedPaths === undefined\n ? {}\n : { changedPaths: pr.reviewPaths, diffScopeHash: digestValue(pr.reviewPaths) }),\n ...(reuse === undefined ? {} : { reusedFrom: await qualifyReviewReuse(context, artifact, prNumber, actor) }),\n };\n artifact = ReviewArtifactSchema.parse({ ...canonical, artifactId: digestValue(canonical) });\n const body = githubReviewBody(artifact);\n const expectedState = artifact.verdict === 'approve' ? ('APPROVED' as const) : ('CHANGES_REQUESTED' as const);\n const event = artifact.verdict === 'approve' ? ('APPROVE' as const) : ('REQUEST_CHANGES' as const);\n const marker = `<!-- ai-delivery-review-artifact: ${artifact.artifactId} -->`;\n const history = await listAllReviews(context, prNumber);\n const matches = history.filter((review) => review.body?.includes(marker));\n if (matches.length > 1) throw new DeliveryError('Conflicting GitHub reviews claim the same artifact identity.');\n const prior = matches[0];\n if (\n prior &&\n (prior.state !== expectedState ||\n prior.commit_id !== artifact.head.sha ||\n prior.user?.login.toLowerCase() !== actor.toLowerCase() ||\n !prior.html_url ||\n parseGitHubReviewArtifact(prior.body).artifactId !== artifact.artifactId)\n )\n throw new DeliveryError('Prior GitHub review marker conflicts with exact-head approval.');\n const fresh = (await context.clients.rest.pulls.get({ ...context.repo, pull_number: prNumber })).data;\n if (fresh.head.sha !== artifact.head.sha || fresh.base.sha !== pr.base.sha || fresh.state !== 'open')\n throw new DeliveryError('PR moved during independent review validation.');\n if (input.dryRun) return { dryRun: true as const, artifactId: artifact.artifactId, headSha: artifact.head.sha };\n const pending = {\n artifactId: artifact.artifactId,\n repository: context.config.repository,\n headSha: artifact.head.sha,\n prNumber,\n };\n let submitted;\n try {\n submitted =\n prior ??\n (\n await context.clients.rest.pulls.createReview({\n ...context.repo,\n pull_number: prNumber,\n commit_id: artifact.head.sha,\n body,\n event,\n })\n ).data;\n } catch {\n throw new ReviewSubmissionError('Review submission acknowledgement is unknown.', pending);\n }\n const known = {\n ...pending,\n ...(submitted.id ? { githubReviewId: submitted.id } : {}),\n ...(submitted.html_url ? { githubReviewUrl: submitted.html_url } : {}),\n };\n try {\n if (\n !submitted.id ||\n submitted.state !== expectedState ||\n submitted.commit_id !== artifact.head.sha ||\n submitted.user?.login.toLowerCase() !== actor.toLowerCase() ||\n !submitted.html_url\n )\n throw new DeliveryError('GitHub did not return complete exact-head independent approval.');\n const content = {\n artifact,\n repository: context.config.repository,\n baseSha: pr.base.sha,\n headSha: artifact.head.sha,\n githubReviewId: submitted.id,\n githubReviewUrl: submitted.html_url,\n login: submitted.user.login,\n prNumber,\n schemaVersion: 'ai-delivery.github-review@1' as const,\n state: expectedState,\n };\n const receipt = { ...content, receiptId: digestValue(content) };\n const readback = (\n await context.clients.rest.pulls.getReview({ ...context.repo, pull_number: prNumber, review_id: submitted.id })\n ).data;\n if (\n readback.id !== receipt.githubReviewId ||\n readback.html_url !== receipt.githubReviewUrl ||\n readback.state !== expectedState ||\n readback.commit_id !== receipt.headSha ||\n readback.user?.login !== receipt.login ||\n parseGitHubReviewArtifact(readback.body).artifactId !== artifact.artifactId\n )\n throw new DeliveryError('GitHub exact-head App review readback disagrees.');\n\n const current = (await context.clients.rest.pulls.get({ ...context.repo, pull_number: prNumber })).data;\n if (current.head.sha !== artifact.head.sha || current.base.sha !== pr.base.sha || current.state !== 'open')\n throw new DeliveryError('PR moved during independent review submission; approval is not current.');\n return receipt;\n } catch (error) {\n throw new ReviewSubmissionError(\n error instanceof DeliveryError ? error.message : 'Review post-submission readback is unavailable.',\n known,\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAElB,SAAS,mBAAmB,mBAAmB;AAC/C,SAAS,qBAAqB;AAC9B,SAAS,KAAK,mBAAmB;AACjC,SAAS,gBAAgB,gBAAgB,yBAAyB;AAGlE,MAAM,MAAM,EAAE,OAAO,EAAE,MAAM,iBAAiB;AAC9C,MAAM,SAAS,EAAE,OAAO,EAAE,MAAM,wBAAwB;AACxD,MAAM,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC;AACpC,MAAM,SAAS,EAAE,KAAK,CAAC,QAAQ,WAAW,OAAO,UAAU,QAAQ,SAAS,OAAO,SAAS,WAAW,CAAC;AACxG,MAAM,aAAa,EAAE,aAAa,EAAE,SAAS,KAAK,cAAc,IAAI,CAAC;AACrE,MAAM,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,wBAAwB,KAAK,CAAC;AACjG,MAAM,sBAAsB,EAAE,aAAa;AAAA,EAChD,eAAe,EAAE,QAAQ,8BAA8B;AAAA,EACvD,SAAS,EAAE,KAAK,CAAC,WAAW,iBAAiB,CAAC;AAAA,EAC9C,SAAS;AAAA,EACT,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS;AAAA,EACvC,OAAO,EAAE,aAAa;AAAA,IACpB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,cAAc,EACX;AAAA,MACC,EACG,OAAO,EACP,IAAI,CAAC,EACL,OAAO,CAAC,SAAS,CAAC,KAAK,SAAS,IAAI,GAAG,2BAA2B;AAAA,IACvE,EACC,UAAU,CAAC,UAAU,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,EAAE,KAAK,CAAC;AAAA,EACpD,CAAC;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Q,KAAK,MAAM,IAAI,EAAE,GAAG,QAAQ,MAAM,aAAa,SAAS,CAAC,GAAG;AACnG,QAAI,QAAQ,KAAK,QAAQ,SAAS,KAAK,OAAO,QAAQ,KAAK,QAAQ,GAAG,KAAK,OAAO,QAAQ,UAAU;AAClG,YAAM,IAAI,cAAc,yEAAyE;AACnG,WAAO;AAAA,EACT,SAAS,OAAO;AACd,UAAM,IAAI;AAAA,MACR,iBAAiB,gBAAgB,MAAM,UAAU;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["content"]
|
|
7
7
|
}
|
package/dist/review.test.js
CHANGED
|
@@ -6,7 +6,7 @@ import { tmpdir } from "node:os";
|
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { test } from "vitest";
|
|
8
8
|
import { recordedReassociation, recordedZeroApproval } from "./fixtures/recordedGitHubFlows.js";
|
|
9
|
-
import { digestValue } from "./delivery/
|
|
9
|
+
import { digestValue } from "./delivery/common.js";
|
|
10
10
|
import { createDeliveryGitHubClients, withAuthorGitToken } from "./github/client.js";
|
|
11
11
|
import { preflightReviewRoute } from "./pr.js";
|
|
12
12
|
import {
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
submitReview
|
|
18
18
|
} from "./review.js";
|
|
19
19
|
const head = { sha: "a".repeat(40), tree: "b".repeat(40) };
|
|
20
|
-
const publicationEvidenceId = `sha256:${"c".repeat(64)}`;
|
|
21
20
|
const marker = (id) => `<!-- ai-delivery-review-artifact: ${id} -->`;
|
|
22
21
|
const verdictInput = () => ({
|
|
23
22
|
schemaVersion: "ai-delivery.review-verdict@1",
|
|
@@ -356,8 +355,7 @@ ${marker(artifact.artifactId)}
|
|
|
356
355
|
}
|
|
357
356
|
}
|
|
358
357
|
};
|
|
359
|
-
const
|
|
360
|
-
const submit = () => submitReview({ artifact, classification, context, issueNumber: 17, prNumber: 19, publicationEvidenceId });
|
|
358
|
+
const submit = () => submitReview({ artifact, context, issueNumber: 17, prNumber: 19 });
|
|
361
359
|
return {
|
|
362
360
|
root,
|
|
363
361
|
context,
|