Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions apps/loopover-ui/public/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -14856,6 +14856,75 @@
"recommendation",
"summary"
]
},
"PullRequestAiReviewFindings": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"ready",
"not_found",
"ai_review_off"
]
},
"repoFullName": {
"type": "string"
},
"pullNumber": {
"type": "number"
},
"login": {
"type": "string"
},
"headSha": {
"type": "string",
"nullable": true
},
"findings": {
"type": "array",
"items": {
"type": "object",
"properties": {
"category": {
"type": "string"
},
"path": {
"type": "string"
},
"severity": {
"type": "string",
"enum": [
"blocker",
"nit"
]
},
"line": {
"type": "number"
},
"body": {
"type": "string"
}
},
"required": [
"category",
"path",
"severity",
"line",
"body"
]
}
},
"categoryCounts": {
"type": "object",
"additionalProperties": {
"type": "number"
}
}
},
"required": [
"status"
]
}
},
"parameters": {},
Expand Down Expand Up @@ -19336,6 +19405,75 @@
}
]
}
},
"/v1/repos/{owner}/{repo}/pulls/{number}/ai-review-findings": {
"get": {
"summary": "Contributor-owned AI review findings for a pull request",
"parameters": [
{
"schema": {
"type": "string"
},
"required": true,
"name": "owner",
"in": "path"
},
{
"schema": {
"type": "string"
},
"required": true,
"name": "repo",
"in": "path"
},
{
"schema": {
"type": "string"
},
"required": true,
"name": "number",
"in": "path"
},
{
"schema": {
"type": "string",
"minLength": 1
},
"required": true,
"name": "login",
"in": "query"
}
],
"responses": {
"200": {
"description": "Structured AI-review findings for the authenticated contributor's own PR (mirrors loopover_get_pr_ai_review_findings)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PullRequestAiReviewFindings"
}
}
}
},
"400": {
"description": "Invalid pull number or missing login query"
},
"403": {
"description": "Caller is not the PR author"
},
"404": {
"description": "Pull request not found"
}
},
"security": [
{
"LoopOverBearer": []
},
{
"LoopOverSessionCookie": []
}
]
}
}
},
"servers": [
Expand Down
23 changes: 23 additions & 0 deletions src/openapi/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2822,6 +2822,29 @@ export const PullRequestReviewabilitySchema = z
})
.openapi("PullRequestReviewability");

// Field-level parity with `prAiReviewFindingsOutputSchema` in src/mcp/server.ts (#9305).
export const PullRequestAiReviewFindingsSchema = z
.object({
status: z.enum(["ready", "not_found", "ai_review_off"]),
repoFullName: z.string().optional(),
pullNumber: z.number().optional(),
login: z.string().optional(),
headSha: z.string().nullable().optional(),
findings: z
.array(
z.object({
category: z.string(),
path: z.string(),
severity: z.enum(["blocker", "nit"]),
line: z.number(),
body: z.string(),
}),
)
.optional(),
categoryCounts: z.record(z.string(), z.number()).optional(),
})
.openapi("PullRequestAiReviewFindings");

export const RegistryChangeReportSchema = z
.object({
generatedAt: z.string(),
Expand Down
20 changes: 20 additions & 0 deletions src/openapi/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
MaintainerNoiseReportSchema,
AmsMinerCohortComparisonSchema,
McpCompatibilitySchema,
PullRequestAiReviewFindingsSchema,
PullRequestMaintainerPacketSchema,
PullRequestReviewIntelligenceSchema,
PullRequestReviewabilitySchema,
Expand Down Expand Up @@ -173,6 +174,7 @@ export function buildOpenApiSpec() {
registry.register("MaintainerNoiseReport", MaintainerNoiseReportSchema);
registry.register("AmsMinerCohortComparison", AmsMinerCohortComparisonSchema);
registry.register("PullRequestReviewability", PullRequestReviewabilitySchema);
registry.register("PullRequestAiReviewFindings", PullRequestAiReviewFindingsSchema);

registry.registerPath({
method: "get",
Expand Down Expand Up @@ -758,6 +760,24 @@ export function buildOpenApiSpec() {
200: { description: "Private PR reviewability score and maintainer action", content: { "application/json": { schema: PullRequestReviewabilitySchema } } },
},
});
registry.registerPath({
method: "get",
path: "/v1/repos/{owner}/{repo}/pulls/{number}/ai-review-findings",
summary: "Contributor-owned AI review findings for a pull request",
request: {
params: z.object({ owner: z.string(), repo: z.string(), number: z.string() }),
query: z.object({ login: z.string().min(1) }),
},
responses: {
200: {
description: "Structured AI-review findings for the authenticated contributor's own PR (mirrors loopover_get_pr_ai_review_findings)",
content: { "application/json": { schema: PullRequestAiReviewFindingsSchema } },
},
400: { description: "Invalid pull number or missing login query" },
403: { description: "Caller is not the PR author" },
404: { description: "Pull request not found" },
},
});
registry.registerPath({
method: "get",
path: "/v1/contributors/{login}/profile",
Expand Down
8 changes: 8 additions & 0 deletions test/unit/openapi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ describe("OpenAPI contract", () => {
expect(spec.paths["/v1/repos/{owner}/{repo}/gittensor-config-recommendation"]).toBeDefined();
expect(spec.paths["/v1/repos/{owner}/{repo}/pulls/{number}/maintainer-packet"]).toBeDefined();
expect(spec.paths["/v1/repos/{owner}/{repo}/pulls/{number}/reviewability"]).toBeDefined();
expect(spec.paths["/v1/repos/{owner}/{repo}/pulls/{number}/ai-review-findings"]).toBeDefined();
expect(spec.paths["/v1/repos/{owner}/{repo}/pulls/{number}/ai-review-findings"]?.get).toBeDefined();
expect(spec.paths["/v1/contributors/{login}/profile"]).toBeDefined();
expect(spec.paths["/v1/contributors/{login}/decision-pack"]).toBeDefined();
expect(spec.paths["/v1/contributors/{login}/open-pr-monitor"]).toBeDefined();
Expand Down Expand Up @@ -100,6 +102,12 @@ describe("OpenAPI contract", () => {
expect(spec.components?.schemas?.GittensorConfigRecommendation).toBeDefined();
expect(spec.components?.schemas?.PullRequestMaintainerPacket).toBeDefined();
expect(spec.components?.schemas?.PullRequestReviewability).toBeDefined();
expect(spec.components?.schemas?.PullRequestAiReviewFindings).toBeDefined();
// #9305: response schema keys must match prAiReviewFindingsOutputSchema in src/mcp/server.ts
expect(JSON.stringify(spec.components?.schemas?.PullRequestAiReviewFindings)).toContain("status");
expect(JSON.stringify(spec.components?.schemas?.PullRequestAiReviewFindings)).toContain("findings");
expect(JSON.stringify(spec.components?.schemas?.PullRequestAiReviewFindings)).toContain("categoryCounts");
expect(JSON.stringify(spec.components?.schemas?.PullRequestAiReviewFindings)).toContain("ai_review_off");
expect(spec.components?.schemas?.LocalBranchAnalysis).toBeDefined();
expect(spec.components?.schemas?.RepoSettingsPreview).toBeDefined();
expect(spec.components?.schemas?.InstallationRepair).toBeDefined();
Expand Down