@aviaratech/ai-delivery 0.3.41 → 0.3.43
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 +7 -1
- package/dist/agentReadiness.test.js +15 -0
- package/dist/agentReadiness.test.js.map +2 -2
- package/dist/callerErrors.test.js +11 -1
- package/dist/callerErrors.test.js.map +2 -2
- package/dist/contributorChecks.test.js +4 -1
- package/dist/contributorChecks.test.js.map +2 -2
- package/dist/currentConsumer.test.js +3 -2
- package/dist/currentConsumer.test.js.map +2 -2
- package/dist/currentTrackingScenario.test.js +3 -2
- package/dist/currentTrackingScenario.test.js.map +2 -2
- package/dist/fixtures/builderReady.d.ts +82 -0
- package/dist/fixtures/builderReady.js +56 -0
- package/dist/fixtures/builderReady.js.map +7 -0
- package/dist/fixtures/inertTarget.d.ts +75 -0
- package/dist/fixtures/inertTarget.js +20 -15
- package/dist/fixtures/inertTarget.js.map +2 -2
- package/dist/fixtures/issue63.d.ts +96 -0
- package/dist/fixtures/issue63.js +21 -2
- package/dist/fixtures/issue63.js.map +2 -2
- package/dist/fixtures/readView.d.ts +9 -1
- package/dist/fixtures/readView.js +4 -0
- package/dist/fixtures/readView.js.map +2 -2
- package/dist/issue.d.ts +2 -2
- package/dist/issue.js +96 -27
- package/dist/issue.js.map +2 -2
- package/dist/issue63Routes.test.js +3 -3
- package/dist/issue63Routes.test.js.map +2 -2
- package/dist/issueBlockerGuard.test.js +5 -5
- package/dist/issueBlockerGuard.test.js.map +2 -2
- package/dist/issueContract.d.ts +242 -2
- package/dist/issueContract.js +147 -28
- package/dist/issueContract.js.map +2 -2
- package/dist/issueContract.test.d.ts +20 -0
- package/dist/issueContract.test.js +210 -13
- package/dist/issueContract.test.js.map +2 -2
- package/dist/issueDates.test.js +5 -6
- package/dist/issueDates.test.js.map +2 -2
- package/dist/issueInfoReadback.test.js +144 -7
- package/dist/issueInfoReadback.test.js.map +2 -2
- package/dist/issueIntake.test.js +201 -33
- package/dist/issueIntake.test.js.map +2 -2
- package/dist/issueJournal.js +4 -2
- package/dist/issueJournal.js.map +2 -2
- package/dist/issueJournal.test.js +22 -0
- package/dist/issueJournal.test.js.map +2 -2
- package/dist/issueTracking.test.js +4 -1
- package/dist/issueTracking.test.js.map +2 -2
- package/dist/issueWriteRecovery.test.js +12 -12
- package/dist/issueWriteRecovery.test.js.map +2 -2
- package/dist/mcp/index.js +3 -3
- package/dist/mcp/index.js.map +2 -2
- package/dist/mcp/tools.d.ts +155 -5
- package/dist/mcp/tools.js +136 -103
- package/dist/mcp/tools.js.map +2 -2
- package/dist/pluginPackaging.test.js +6 -3
- package/dist/pluginPackaging.test.js.map +2 -2
- package/dist/pr.d.ts +2 -0
- package/dist/pr.js +28 -3
- package/dist/pr.js.map +2 -2
- package/dist/pr.test.js +0 -7
- package/dist/pr.test.js.map +2 -2
- package/dist/prAssociation.test.js +82 -9
- package/dist/prAssociation.test.js.map +2 -2
- package/dist/projectNumbers.test.js +1 -1
- package/dist/projectNumbers.test.js.map +1 -1
- package/dist/readView.d.ts +32 -3
- package/dist/readView.js +29 -12
- package/dist/readView.js.map +2 -2
- package/dist/readView.test.js +63 -1
- package/dist/readView.test.js.map +2 -2
- package/dist/releaseWorkflow.test.js +2 -2
- package/dist/releaseWorkflow.test.js.map +2 -2
- package/dist/review.d.ts +8 -0
- package/dist/review.js +30 -2
- package/dist/review.js.map +2 -2
- package/dist/review.test.js +64 -1
- package/dist/review.test.js.map +2 -2
- package/dist/services/agentReadinessService.d.ts +2 -1
- package/dist/services/agentReadinessService.js +6 -0
- package/dist/services/agentReadinessService.js.map +2 -2
- package/dist/stdoutRegression.test.js +27 -15
- package/dist/stdoutRegression.test.js.map +2 -2
- package/dist/targetPolicyEntrypoints.test.js +1 -1
- package/dist/targetPolicyEntrypoints.test.js.map +2 -2
- package/dist/targetPolicyRoutes.test.js +1 -1
- package/dist/targetPolicyRoutes.test.js.map +2 -2
- package/dist/targetRepositoryExecution.test.js +11 -3
- package/dist/targetRepositoryExecution.test.js.map +2 -2
- package/dist/toolOutput.test.js +14 -0
- package/dist/toolOutput.test.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 +130 -124
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/plugins/ai-delivery/skills/intake-create/SKILL.md +1 -11
- package/plugins/ai-delivery/skills/ticket-design/SKILL.md +29 -0
package/dist/review.d.ts
CHANGED
|
@@ -51,6 +51,10 @@ export declare const ReviewVerdictSchema: z.ZodObject<{
|
|
|
51
51
|
fromReviewId: z.ZodNumber;
|
|
52
52
|
verificationResultPath: z.ZodString;
|
|
53
53
|
}, z.core.$strict>>;
|
|
54
|
+
lens: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
55
|
+
name: z.ZodString;
|
|
56
|
+
blob: z.ZodString;
|
|
57
|
+
}, z.core.$strict>>>;
|
|
54
58
|
}, z.core.$strict>;
|
|
55
59
|
export type ReviewVerdict = z.infer<typeof ReviewVerdictSchema>;
|
|
56
60
|
export declare function parseReviewVerdict(raw: unknown): ReviewVerdict;
|
|
@@ -98,6 +102,10 @@ export declare const ReviewArtifactSchema: z.ZodObject<{
|
|
|
98
102
|
}, z.core.$strict>>;
|
|
99
103
|
changedPaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
100
104
|
issueNumber: z.ZodNumber;
|
|
105
|
+
lens: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
106
|
+
name: z.ZodString;
|
|
107
|
+
blob: z.ZodString;
|
|
108
|
+
}, z.core.$strict>>>;
|
|
101
109
|
prNumber: z.ZodNullable<z.ZodNumber>;
|
|
102
110
|
readOnly: z.ZodLiteral<true>;
|
|
103
111
|
requestedEffort: z.ZodString;
|
package/dist/review.js
CHANGED
|
@@ -5,11 +5,13 @@ import { assertPrivateFile, digestValue } from "./delivery/common.js";
|
|
|
5
5
|
import { DeliveryError } from "./errors.js";
|
|
6
6
|
import { git, gitExitCode } from "./git.js";
|
|
7
7
|
import { GIT_EXECUTABLE, gitEnvironment, inertGitArguments } from "./gitProcess.js";
|
|
8
|
+
import { logWarn } from "./logger.js";
|
|
8
9
|
const Sha = z.string().regex(/^[a-f0-9]{40}$/u);
|
|
9
10
|
const Digest = z.string().regex(/^sha256:[a-f0-9]{64}$/u);
|
|
10
11
|
const Text = z.string().trim().min(1);
|
|
11
12
|
const Effort = z.enum(["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra", "inherited"]);
|
|
12
13
|
const ReviewBase = z.strictObject({ baseSha: Sha, mergeBaseSha: Sha });
|
|
14
|
+
const Lens = z.array(z.strictObject({ name: z.string().regex(/^[a-z0-9-]{1,32}$/u), blob: z.string().regex(/^[a-f0-9]{40}$/u) })).min(1).max(4).refine((lens) => new Set(lens.map((entry) => entry.name)).size === lens.length, "Lens names must be unique.");
|
|
13
15
|
const Reuse = z.strictObject({ fromReviewId: z.number().int().positive(), verificationResultPath: Text });
|
|
14
16
|
const ReviewVerdictSchema = z.strictObject({
|
|
15
17
|
schemaVersion: z.literal("ai-delivery.review-verdict@1"),
|
|
@@ -32,7 +34,8 @@ const ReviewVerdictSchema = z.strictObject({
|
|
|
32
34
|
findings: z.array(Text),
|
|
33
35
|
readOnly: z.literal(true),
|
|
34
36
|
nonClosing: z.boolean().optional(),
|
|
35
|
-
reuse: Reuse.optional()
|
|
37
|
+
reuse: Reuse.optional(),
|
|
38
|
+
lens: Lens.optional()
|
|
36
39
|
});
|
|
37
40
|
function parseReviewVerdict(raw) {
|
|
38
41
|
let value;
|
|
@@ -67,6 +70,7 @@ function buildReviewArtifact(input) {
|
|
|
67
70
|
changedPaths: verdict.scope.changedPaths,
|
|
68
71
|
...input.reviewBase === void 0 ? {} : { reviewBase: input.reviewBase },
|
|
69
72
|
...verdict.reuse === void 0 ? {} : { reuse: verdict.reuse },
|
|
73
|
+
...verdict.lens === void 0 ? {} : { lens: verdict.lens },
|
|
70
74
|
checks: verdict.verificationReproduced,
|
|
71
75
|
elapsedMs: verdict.elapsedMs,
|
|
72
76
|
findings: verdict.findings,
|
|
@@ -114,6 +118,7 @@ const ReviewArtifactSchema = z.object({
|
|
|
114
118
|
z.string().min(1).refine((path) => !path.includes("\0"))
|
|
115
119
|
).optional(),
|
|
116
120
|
issueNumber: z.number().int().positive(),
|
|
121
|
+
lens: Lens.optional(),
|
|
117
122
|
prNumber: z.number().int().positive().nullable(),
|
|
118
123
|
readOnly: z.literal(true),
|
|
119
124
|
requestedEffort: z.string().min(1),
|
|
@@ -246,6 +251,8 @@ function parseGitHubReviewArtifact(body) {
|
|
|
246
251
|
}
|
|
247
252
|
function githubReviewBody(artifact) {
|
|
248
253
|
ReviewArtifactSchema.parse(artifact);
|
|
254
|
+
const lensLine = artifact.lens ? `
|
|
255
|
+
Lens: ${artifact.lens.map((entry) => `${entry.name} (blob ${entry.blob.slice(0, 7)})`).join(", ")}` : "";
|
|
249
256
|
const metadata = artifact.verdictFileSha256 === void 0 ? "" : `
|
|
250
257
|
|
|
251
258
|
Verdict: ${artifact.verdict}
|
|
@@ -253,7 +260,7 @@ Requested model/effort: ${artifact.requestedModel} / ${artifact.requestedEffort}
|
|
|
253
260
|
Effective model/effort: ${artifact.effectiveModel} / ${artifact.effectiveEffort}
|
|
254
261
|
Elapsed milliseconds: ${artifact.elapsedMs}
|
|
255
262
|
Verdict-file SHA256: ${artifact.verdictFileSha256}
|
|
256
|
-
Findings: ${artifact.findings.length ? artifact.findings.join("; ") : "none"}`;
|
|
263
|
+
Findings: ${artifact.findings.length ? artifact.findings.join("; ") : "none"}${lensLine}`;
|
|
257
264
|
const body = `${artifact.summary}${metadata}
|
|
258
265
|
|
|
259
266
|
<!-- ai-delivery-review-artifact: ${artifact.artifactId} -->
|
|
@@ -437,6 +444,26 @@ async function qualifyReviewReuse(context, artifact, prNumber, actor) {
|
|
|
437
444
|
);
|
|
438
445
|
}
|
|
439
446
|
}
|
|
447
|
+
async function addLensLabels(context, prNumber, lens) {
|
|
448
|
+
const present = [];
|
|
449
|
+
for (const { name } of lens ?? []) {
|
|
450
|
+
const label = `lens:${name}`;
|
|
451
|
+
try {
|
|
452
|
+
await context.clients.rest.issues.getLabel({ ...context.repo, name: label });
|
|
453
|
+
present.push(label);
|
|
454
|
+
} catch {
|
|
455
|
+
logWarn(
|
|
456
|
+
`Label ${label} is missing or unreadable in ${context.config.repository}; create it, then add it to PR ${prNumber}.`
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
if (present.length === 0) return;
|
|
461
|
+
try {
|
|
462
|
+
await context.clients.rest.issues.addLabels({ ...context.repo, issue_number: prNumber, labels: present });
|
|
463
|
+
} catch {
|
|
464
|
+
logWarn(`Could not add ${present.join(", ")} to PR ${prNumber}; add them manually.`);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
440
467
|
async function submitReview(input) {
|
|
441
468
|
const { context, issueNumber, prNumber } = input;
|
|
442
469
|
let artifact = input.artifact;
|
|
@@ -516,6 +543,7 @@ async function submitReview(input) {
|
|
|
516
543
|
const current = (await context.clients.rest.pulls.get({ ...context.repo, pull_number: prNumber })).data;
|
|
517
544
|
if (current.head.sha !== artifact.head.sha || current.base.sha !== pr.base.sha || current.state !== "open")
|
|
518
545
|
throw new DeliveryError("PR moved during independent review submission; approval is not current.");
|
|
546
|
+
await addLensLabels(context, prNumber, artifact.lens);
|
|
519
547
|
return receipt;
|
|
520
548
|
} catch (error) {
|
|
521
549
|
throw new ReviewSubmissionError(
|
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 } 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,GAA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Q,SACjC,0BAA0B,SAAS,IAAI,EAAE,eAAe,SAAS;AAEjE,YAAM,IAAI,cAAc,kDAAkD;AAE5E,UAAM,WAAW,MAAM,QAAQ,QAAQ,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;",
|
|
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';\nimport { logWarn } from './logger.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 Lens = z\n .array(z.strictObject({ name: z.string().regex(/^[a-z0-9-]{1,32}$/u), blob: z.string().regex(/^[a-f0-9]{40}$/u) }))\n .min(1)\n .max(4)\n .refine((lens) => new Set(lens.map((entry) => entry.name)).size === lens.length, 'Lens names must be unique.');\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 lens: Lens.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 ...(verdict.lens === undefined ? {} : { lens: verdict.lens }),\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 lens: Lens.optional(),\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 lensLine = artifact.lens\n ? `\\nLens: ${artifact.lens.map((entry) => `${entry.name} (blob ${entry.blob.slice(0, 7)})`).join(', ')}`\n : '';\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'}${lensLine}`;\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\n/** Labels are optional metadata: add only labels that already exist, and never fail a landed review. */\nasync function addLensLabels(context: DeliveryContext, prNumber: number, lens: ReviewArtifact['lens']) {\n const present: string[] = [];\n for (const { name } of lens ?? []) {\n const label = `lens:${name}`;\n try {\n await context.clients.rest.issues.getLabel({ ...context.repo, name: label });\n present.push(label);\n } catch {\n logWarn(\n `Label ${label} is missing or unreadable in ${context.config.repository}; create it, then add it to PR ${prNumber}.`,\n );\n }\n }\n if (present.length === 0) return;\n try {\n await context.clients.rest.issues.addLabels({ ...context.repo, issue_number: prNumber, labels: present });\n } catch {\n logWarn(`Could not add ${present.join(', ')} to PR ${prNumber}; add them manually.`);\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 await addLensLabels(context, prNumber, artifact.lens);\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;AAElE,SAAS,eAAe;AAExB,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,OAAO,EACV,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,oBAAoB,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,iBAAiB,EAAE,CAAC,CAAC,EACjH,IAAI,CAAC,EACL,IAAI,CAAC,EACL,OAAO,CAAC,SAAS,IAAI,IAAI,KAAK,IAAI,CAAC,UAAU,MAAM,IAAI,CAAC,EAAE,SAAS,KAAK,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AAQ,QAAQ,KAAK,MAAM,UAAU,EAAE,GAAG,QAAQ,MAAM,aAAa,UAAU,WAAW,UAAU,GAAG,CAAC,GAC9G;AACF,QACE,SAAS,OAAO,QAAQ,kBACxB,SAAS,aAAa,QAAQ,mBAC9B,SAAS,UAAU,iBACnB,SAAS,cAAc,QAAQ,WAC/B,SAAS,MAAM,UAAU,QAAQ,SACjC,0BAA0B,SAAS,IAAI,EAAE,eAAe,SAAS;AAEjE,YAAM,IAAI,cAAc,kDAAkD;AAE5E,UAAM,WAAW,MAAM,QAAQ,QAAQ,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,UAAM,cAAc,SAAS,UAAU,SAAS,IAAI;AACpD,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
|
@@ -4,7 +4,7 @@ import { generateKeyPairSync } from "node:crypto";
|
|
|
4
4
|
import { existsSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
6
|
import { join } from "node:path";
|
|
7
|
-
import { test } from "vitest";
|
|
7
|
+
import { test, vi } from "vitest";
|
|
8
8
|
import { recordedReassociation, recordedZeroApproval } from "./fixtures/recordedGitHubFlows.js";
|
|
9
9
|
import { digestValue } from "./delivery/common.js";
|
|
10
10
|
import { createDeliveryGitHubClients, withAuthorGitToken } from "./github/client.js";
|
|
@@ -1259,4 +1259,67 @@ test("recorded reassociation submits a fresh artifact and retry reuses only that
|
|
|
1259
1259
|
rmSync(state.root, { recursive: true, force: true });
|
|
1260
1260
|
}
|
|
1261
1261
|
});
|
|
1262
|
+
const lens = [
|
|
1263
|
+
{ name: "money-path", blob: "abc1234".padEnd(40, "0") },
|
|
1264
|
+
{ name: "risk", blob: "def5678".padEnd(40, "1") }
|
|
1265
|
+
];
|
|
1266
|
+
test("verdict lens is optional, validated, and copied into the artifact only when present", () => {
|
|
1267
|
+
assert.equal("lens" in parseReviewVerdict(verdictInput()), false);
|
|
1268
|
+
assert.deepEqual(parseReviewVerdict({ ...verdictInput(), lens }).lens, lens);
|
|
1269
|
+
for (const bad of [
|
|
1270
|
+
[],
|
|
1271
|
+
[...lens, ...lens, lens[0]],
|
|
1272
|
+
[{ name: "Bad Name", blob: lens[0].blob }],
|
|
1273
|
+
[{ name: "risk", blob: "abc1234" }],
|
|
1274
|
+
[lens[0], lens[0]]
|
|
1275
|
+
])
|
|
1276
|
+
assert.throws(() => parseReviewVerdict({ ...verdictInput(), lens: bad }), /lens/u);
|
|
1277
|
+
const build = (verdict) => buildReviewArtifact({
|
|
1278
|
+
verdict,
|
|
1279
|
+
verdictFileSha256: `sha256:${"d".repeat(64)}`,
|
|
1280
|
+
identity: "synthetic-reviewer",
|
|
1281
|
+
provider: "openai",
|
|
1282
|
+
expectedHead: head.sha,
|
|
1283
|
+
prNumber: 19,
|
|
1284
|
+
authorIdentity: "synthetic-author"
|
|
1285
|
+
});
|
|
1286
|
+
assert.doesNotMatch(JSON.stringify(build(parseReviewVerdict(verdictInput()))), /lens/u);
|
|
1287
|
+
assert.deepEqual(build(parseReviewVerdict({ ...verdictInput(), lens })).lens, lens);
|
|
1288
|
+
});
|
|
1289
|
+
test("submit shows the Lens line and labels the PR only with labels that exist", async () => {
|
|
1290
|
+
const state = fixture();
|
|
1291
|
+
try {
|
|
1292
|
+
const { artifactId: _id, ...base } = state.artifact;
|
|
1293
|
+
const content = { ...base, lens, verdictFileSha256: `sha256:${"d".repeat(64)}` };
|
|
1294
|
+
const withLens = ReviewArtifactSchema.parse({ ...content, artifactId: digestValue(content) });
|
|
1295
|
+
const added = [];
|
|
1296
|
+
const rest = state.context.clients.rest;
|
|
1297
|
+
rest.issues = {
|
|
1298
|
+
getLabel: async ({ name }) => {
|
|
1299
|
+
if (name === "lens:risk") throw Object.assign(new Error("Not Found"), { status: 404 });
|
|
1300
|
+
return { data: { name } };
|
|
1301
|
+
},
|
|
1302
|
+
addLabels: async ({ labels }) => {
|
|
1303
|
+
added.push(labels);
|
|
1304
|
+
return { data: [] };
|
|
1305
|
+
}
|
|
1306
|
+
};
|
|
1307
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(() => {
|
|
1308
|
+
});
|
|
1309
|
+
await submitReview({ artifact: withLens, context: state.context, issueNumber: 17, prNumber: 19 });
|
|
1310
|
+
assert.equal(warn.mock.calls.filter(([line]) => String(line).includes("lens:risk")).length, 1);
|
|
1311
|
+
warn.mockRestore();
|
|
1312
|
+
assert.match(state.reviews[0].body, /\nLens: money-path \(blob abc1234\), risk \(blob def5678\)\n/u);
|
|
1313
|
+
assert.deepEqual(added, [["lens:money-path"]]);
|
|
1314
|
+
const plain = fixture();
|
|
1315
|
+
try {
|
|
1316
|
+
await plain.submit();
|
|
1317
|
+
assert.doesNotMatch(plain.reviews[0].body, /Lens:/u);
|
|
1318
|
+
} finally {
|
|
1319
|
+
rmSync(plain.root, { recursive: true, force: true });
|
|
1320
|
+
}
|
|
1321
|
+
} finally {
|
|
1322
|
+
rmSync(state.root, { recursive: true, force: true });
|
|
1323
|
+
}
|
|
1324
|
+
});
|
|
1262
1325
|
//# sourceMappingURL=review.test.js.map
|