Skip to content
Open
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
133 changes: 133 additions & 0 deletions v5/client/src/api/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,30 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/projects/{project}/suites/{suite}/regressions/resolve": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
/**
* Resolve regressions in bulk
* @description Look up many regressions by UUID in a single request, for example all the regressions that
* an indicator lookup returned. This is a POST only because the list can be too long for a URL;
* it doesn't change anything.
*
* **Authorization:** no API key needed.
*/
post: operations["resolve_regressions"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/projects/{project}/suites/{suite}/regressions/indicators/query": {
parameters: {
query?: never;
Expand Down Expand Up @@ -2824,6 +2848,17 @@ export interface components {
items: components["schemas"]["RegressionIndicator"][];
cursor: components["schemas"]["PageCursor"];
};
/**
* RegressionResolveRequest
* @description The regressions to look up.
*/
RegressionResolveRequest: {
/**
* Regressions
* @description The UUIDs of the regressions to look up, from 1 to 10000 of them (not case-sensitive). Duplicates are ignored. UUIDs that don't match any regression are listed in `not_found`.
*/
regressions: string[];
};
/**
* RegressionStateName
* @description The state of a regression. `detected` and `confirmed` mean it is still being worked on;
Expand Down Expand Up @@ -2984,6 +3019,39 @@ export interface components {
*/
not_found: string[];
};
/**
* ResolvedRegressions
* @description The regressions that were found, and the UUIDs that weren't.
*/
ResolvedRegressions: {
/**
* Results
* @description The regressions that were found, as the list returns them, keyed by UUID (in lowercase).
* @example {
* "c4e1b7a2-9d3f-4a6e-8b5c-2f7e1d9a0b34": {
* "bug": "https://github.com/llvm/llvm-project/issues/160237",
* "commit": "45c41247f82e5691425542de829d568cdc2fb580",
* "created_at": "2026-08-14T02:41:12Z",
* "machine_count": 1,
* "state": "confirmed",
* "test_count": 2,
* "title": "std::find_if slowdown on x86-64",
* "uuid": "c4e1b7a2-9d3f-4a6e-8b5c-2f7e1d9a0b34"
* }
* }
*/
results: {
[key: string]: components["schemas"]["Regression"];
};
/**
* Not Found
* @description The UUIDs, in lowercase, that don't match any regression.
* @example [
* "6a2f1c3e-9d4b-4e8a-8f55-0c1b7d2e9a10"
* ]
*/
not_found: string[];
};
/**
* RestrictionEntry
* @description Something a restricted API key is restricted to: a whole project, named by its name with a
Expand Down Expand Up @@ -6961,6 +7029,71 @@ export interface operations {
};
};
};
resolve_regressions: {
parameters: {
query?: never;
header?: never;
path: {
/** @description The name of the project. */
project: string;
/** @description The name of the test suite. */
suite: string;
};
cookie?: never;
};
requestBody: {
content: {
"application/json": components["schemas"]["RegressionResolveRequest"];
};
};
responses: {
/** @description Successful Response */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ResolvedRegressions"];
};
};
/** @description The request is invalid. This includes query parameters the operation doesn't accept, and single-valued parameters given more than once. */
400: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ErrorEnvelope"];
};
};
/** @description This operation needs an API key and none was sent, or the key is malformed, unknown or revoked. */
401: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ErrorEnvelope"];
};
};
/** @description The project or the test suite doesn't exist. */
404: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ErrorEnvelope"];
};
};
/** @description `retry`: the suite's schema changed while the request was being handled. Send it again. */
409: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["ErrorEnvelope"];
};
};
};
};
query_indicators: {
parameters: {
query?: never;
Expand Down
25 changes: 24 additions & 1 deletion v5/docs/design/server/endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,14 @@ DELETE /api/projects/{project}/suites/{suite}/regressions/{uuid}
POST /api/projects/{project}/suites/{suite}/regressions/{uuid}/indicators -- Add indicator(s) (batch)
DELETE /api/projects/{project}/suites/{suite}/regressions/{uuid}/indicators -- Remove indicator(s) (batch, UUIDs in body)
POST /api/projects/{project}/suites/{suite}/regressions/indicators/query -- Look up indicators across regressions (cursor-paginated, filterable by machine, test, metric, state, commit)
POST /api/projects/{project}/suites/{suite}/regressions/resolve -- Batch resolve regression UUIDs to regressions
```

Regressions and their indicators are identified by UUIDs. A regression's UUID
may be supplied by the client at creation (see below); an indicator's is always
generated by the server.

**Auth scope:** `read` for GET and for the indicator lookup; `triage` for POST,
**Auth scope:** `read` for GET, the indicator lookup and the batch resolve; `triage` for POST,
PATCH, DELETE and indicator management.

**States** (string enum): `detected`, `confirmed`, `not_to_be_fixed`, `fixed`,
Expand Down Expand Up @@ -621,6 +622,28 @@ be long and whose names may contain any character, do not fit in a query string.
- Sort: none. Results come in an arbitrary but deterministic order suitable for
pagination (see I2 and O5).

### Resolving regressions in bulk

`POST /api/projects/{project}/suites/{suite}/regressions/resolve` looks up many
regressions by UUID at once, modelled on the commits' batch resolve (E3). The
indicator lookup returns only the UUID of each indicator's regression; this is
how a client reads the title, state and commit of the regressions it found
without one request per regression, or a walk of the whole list. It is a
`read`-scoped POST because the list of UUIDs may be too long for a query string.

- The body is `{"regressions": ["...", "..."]}`, with at least one UUID and no
more than I2's maximum page size. UUIDs are matched case-insensitively, and
duplicates are ignored: each regression appears at most once in the response.
- Returns 200 with `{"results": {...}, "not_found": [...]}`. `results` maps each
UUID that was found, in lowercase, to the regression as the list returns it
(`{uuid, title, bug, state, commit, created_at, machine_count, test_count}`,
without `notes` or the indicators). UUIDs that match no regression are listed
in `not_found`, including strings that no regression could ever have, rather
than being a 404: a client resolving the results of an earlier lookup may race
a deletion, and should simply drop those. A string containing a NUL character
is the exception: it is rejected with 400 (see D5).
- Not paginated: the response is bounded by the size of the request.


## E9: Time Series

Expand Down
6 changes: 5 additions & 1 deletion v5/server/src/lnt_v5/routes/llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ DELETE /api/projects/{project}/suites/{suite}/regressions/{uuid} tri
POST /api/projects/{project}/suites/{suite}/regressions/{uuid}/indicators triage Add indicators
DELETE /api/projects/{project}/suites/{suite}/regressions/{uuid}/indicators triage Remove indicators, by UUID
POST /api/projects/{project}/suites/{suite}/regressions/indicators/query read Indicators across regressions (machine, test, metric, state, commit)
POST /api/projects/{project}/suites/{suite}/regressions/resolve read Look up many regressions by UUID at once

GET /api/admin/api-keys admin List API keys
POST /api/admin/api-keys admin Create an API key
Expand Down Expand Up @@ -353,7 +354,10 @@ Every key is optional; `machine`, `test` and `state` are lists. It returns the
matching indicators across all regressions, each as `{uuid, regression_uuid,
machine, test, metric}`, cursor-paginated with `cursor` and `limit` in the body:
a (machine, test, metric) it returns is already tracked at that commit. Read a
regression itself with `GET /regressions/{uuid}`.
regression itself with `GET /regressions/{uuid}`, or many at once with
`POST /regressions/resolve` and `{"regressions": ["<uuid>", ...]}`: it returns
`{"results": {"<uuid>": {...}}, "not_found": [...]}`, each result a regression
as `GET /regressions` lists it.

**Record a regression** with `POST /regressions`:

Expand Down
105 changes: 105 additions & 0 deletions v5/server/src/lnt_v5/routes/regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
Row,
Select,
Table,
Text,
any_,
bindparam,
delete,
func,
insert,
Expand All @@ -49,6 +52,7 @@
true,
update,
)
from sqlalchemy.dialects.postgresql import ARRAY
from sqlalchemy.dialects.postgresql import insert as upsert

from lnt_v5 import examples
Expand Down Expand Up @@ -185,6 +189,26 @@
}
}

# What a regression looks like in a list-shaped response, for the example of the response that
# carries several.
_REGRESSION = {
"uuid": examples.REGRESSION_UUID,
"title": examples.REGRESSION_TITLE,
"bug": examples.BUG,
"state": "confirmed",
"commit": examples.COMMIT,
"created_at": examples.MEASURED_AT,
"machine_count": 1,
"test_count": 2,
}

_RESOLVE_EXAMPLES = {
"regressions": {
"summary": "Resolve the regressions an indicator lookup returned",
"value": {"regressions": [examples.REGRESSION_UUID]},
}
}

_QUERY_EXAMPLES = {
"tracked": {
"summary": "Which of these are already part of an open regression?",
Expand Down Expand Up @@ -450,6 +474,45 @@ class RegressionIndicator(Indicator):
)


class RegressionResolveRequest(BaseModel):
"""The regressions to look up."""

model_config = ConfigDict(extra="forbid")

# Bounded in length but not in what each entry may say, as `POST /commits/resolve` does: a
# value that is no UUID at all is still one this suite holds no regression under, and the
# contract is to report that under `not_found` rather than fail the whole lookup. A NUL is the
# exception, as it is everywhere (D5).
regressions: list[UuidKey] = Field(
min_length=1,
max_length=MAX_LIMIT,
description=(
f"The UUIDs of the regressions to look up, from 1 to {MAX_LIMIT} of them (not "
"case-sensitive). Duplicates are ignored. UUIDs that don't match any regression are "
"listed in `not_found`."
),
)


# A lookup table keyed by UUID rather than one of I2's envelopes, for the reason `ResolvedCommits`
# is: a client resolving the results of an indicator lookup reads each regression by the UUID it
# already holds.
class ResolvedRegressions(BaseModel):
"""The regressions that were found, and the UUIDs that weren't."""

results: dict[str, Regression] = Field(
description=(
"The regressions that were found, as the list returns them, keyed by UUID (in "
"lowercase)."
),
examples=[{examples.REGRESSION_UUID: _REGRESSION}],
)
not_found: list[str] = Field(
description="The UUIDs, in lowercase, that don't match any regression.",
examples=[["6a2f1c3e-9d4b-4e8a-8f55-0c1b7d2e9a10"]],
)


# A body rather than query parameters, because a list of test names, which may be long and whose
# names may contain any character, does not fit a query string. The lists are bounded at I2's page
# ceiling: each expands into one statement, and an unbounded one would carry more bind parameters
Expand Down Expand Up @@ -564,6 +627,16 @@ def listed(self) -> Select[Any]:
.join(self._counts, true())
)

def find(self, connection: Connection, uuids: Sequence[str]) -> list[Regression]:
"""The regressions among these UUIDs, as the list reads them, in no particular order.

One array parameter rather than `IN`, for the reason `POST /commits/resolve` gives: the
statement text is the same whatever the request size.
"""
values = bindparam("values", list(uuids), type_=ARRAY(Text))
rows = connection.execute(self.listed().where(self.table.c.uuid == any_(values))).all()
return [self.read(row) for row in rows]

def keyset(self, sort: RegressionSort | None) -> Keyset:
"""O5's ordering for this list: the caller's sort, then the internal tiebreaker.

Expand Down Expand Up @@ -1274,6 +1347,38 @@ def remove_indicators(
)


# `read`-scoped despite being a POST, and unpaginated, for the reasons `POST /commits/resolve` is.
@router.post(
"/resolve",
dependencies=[require_scope(Scope.READ)],
summary="Resolve regressions in bulk",
responses=suite_responses(),
)
def resolve_regressions(
project: ProjectName,
testsuite: SuiteName,
body: Annotated[RegressionResolveRequest, Body(openapi_examples=_RESOLVE_EXAMPLES)],
engine: EngineDep,
registry: RegistryDep,
) -> ResolvedRegressions:
"""Look up many regressions by UUID in a single request, for example all the regressions that
an indicator lookup returned. This is a POST only because the list can be too long for a URL;
it doesn't change anything.
"""
with (
engine.connect() as connection,
suite_scope(registry, connection, project, testsuite) as suite,
):
# Deduplicated, keeping the order the request gave, so that a client can read the response
# back in the order it asked.
requested = list(dict.fromkeys(body.regressions))
found = {item.uuid: item for item in Regressions(suite).find(connection, requested)}
return ResolvedRegressions(
results={uuid: found[uuid] for uuid in requested if uuid in found},
not_found=[uuid for uuid in requested if uuid not in found],
)


# The metric is resolved first, so an undeclared one is a 400 even if the body also names an absent
# machine or test, an order the spec leaves open.
@router.post(
Expand Down
Loading