Maintenance API
These endpoints read the patterns of
corrections on a team's lines, and file or dismiss them, as the
Patterns tab does. They answer JSON,
and errors are application/problem+json as on the
resource API. See
How maintenance works.
| Method and path | Returns |
|---|---|
GET /api/teams/{teamId}/lines/{lineId}/maintenance/patterns | The line's maintenance settings, measures and patterns. See Line. |
GET /api/teams/{teamId}/maintenance/patterns/{patternId} | A pattern and the corrections behind it. See Pattern. |
POST /api/teams/{teamId}/maintenance/patterns/{patternId}/file | 200, with the pattern: files it. See File and dismiss. |
POST /api/teams/{teamId}/maintenance/patterns/{patternId}/dismiss | 200, with the pattern: dismisses it. See File and dismiss. |
GET /api/teams/{teamId}/tasks/{taskId}/maintenance | { fixes }: the pattern a maintenance task was filed to fix, with its corrections, or null. |
They take a person's session. A person outside the team's workspace is
answered 404. Workspace tokens are not taken.
Line
| Field | Type | Description |
|---|---|---|
lineId | string | |
enabled | boolean | Whether patterns surface on the line: maintenance.enabled. Without the block, true only for a line with exactly one work station. |
automatic | boolean | Whether codebase patterns are filed without asking: maintenance.file is automatic. |
maxOpen | number | maintenance.max_open. |
open | number | Maintenance tasks open now. |
station | string or null | The station maintenance tasks are filed at. |
needsStation | boolean | Whether maintenance is off because the line has more than one work station and no maintenance block names one. |
spend | object | { month, spentUsd, capUsd, unpriced, estimated }: what grouping corrections spent this calendar month, in UTC, against the cap of 5 USD. unpriced counts the sessions that reported no price in dollars, and estimated the sessions that never reported their cost. Each of them is charged 0.25 USD. |
correctionRate | object | { before, after, verdict }: corrections per run on the line's stations in the last 30 days, and in the 30 days before. verdict is better, worse, unchanged, or insufficient while either side has fewer than 5 runs. |
measures | object | { filed, dismissed, merged, closed, caught, checked }: patterns people filed and dismissed, maintenance tasks whose pull request merged and that closed or completed without a merge, and corrections a history check caught, of those it could check. |
patterns[] | object | The line's patterns, ranked. See Pattern. |
Pattern
| Field | Type | Description |
|---|---|---|
id, lineId | string | |
key | string | A short key for the mistake. |
summary | string | What was wrong, in one line. |
type | string | codebase, station or process. |
state | string | watching, surfaced, filed, fixing, resolved or dismissed. |
rank | number | Its corrections times its tasks within the last 14 days. |
corrections, tasks | number | All its corrections, and the tasks they are on. |
recentCorrections, recentTasks | number | The same within the last 14 days. |
lastCorrectedAt | string | When its newest correction was made. |
surfacedAt, fixingSince, dismissedUntil | string or null | When it last surfaced, when its fix merged, and until when it stays dismissed. |
route | object or null | { kind, taskId, memoryId }: where filing sent it. kind is task, search or memory. |
historyCheck | object or null | { command, at, caught, missed, tooWide, notCheckable }: the newest result of spotlight maintenance check. |
fix | object or null | { before, after, verdict }: corrections per run like correctionRate, 30 days before and after its fix merged. |
The pattern endpoint and a task's fixes give
{ pattern, corrections, filingBlock }. filingBlock is null when the
pattern can be filed now, else why it cannot:
filingBlock | Cause |
|---|---|
not-waiting | The pattern does not wait for the team. |
search-asked | A station search for the pattern is being asked for. |
no-station | A codebase pattern, and the line has no maintenance.station. |
slots-full | A codebase pattern, and the line has max_open open maintenance tasks. |
Each correction:
| Field | Type | Description |
|---|---|---|
id, taskId | string | |
source | string | message, sent-back, held, review-comment, push or revert. |
text | string or null | What the person wrote, at most 4,000 characters. |
repository, path | string or null | Where the correction is, when known. |
lineStart, lineEnd | number or null | The lines of path it is about. |
before, after | string or null | For a push: the agent's commit the person pushed over, and the person's commit. |
at | string | When it was made. |
checked | string or null | What the newest history check found for it: caught, missed, too-wide or not-checkable. |
File and dismiss
Both take no body, and act only on a pattern in the surfaced state.
Pattern type | Filing |
|---|---|
codebase | Files a maintenance task at the line's maintenance station. The pattern becomes filed. |
station | Starts a search of the station with the most of its corrections, requested by the caller. The pattern becomes fixing. |
process | Proposes a team memory from its newest correction that cites a person's message, for review in the inbox. The pattern becomes fixing. |
Dismissing sets the pattern to dismissed for 90 days. It surfaces again
after that once it is ready, or sooner when it gets twice the corrections that
make it ready.
| Status | Message | Cause |
|---|---|---|
404 | No team <teamId> for this caller. | The caller cannot see the team. |
404 | No correction pattern <patternId> on this team. | No such pattern on the team. |
409 | The line already has <n> open maintenance tasks. Finish one first, or raise maintenance.max_open. | Every slot on the line is taken. |
409 | The pattern cannot be filed: <reason>. | The pattern cannot be routed, as in the line has no work station to file it at or a memory cites a person’s message, and none of its corrections is one, or the station search was refused. |
422 | A correction pattern is filed only once it surfaced, and this one is <state>. | Filing a pattern that does not wait for the team. |
422 | A correction pattern is filed only once, and a station search for this one is being asked for. | Filing a pattern while someone else's filing asks for its station search. |
422 | A correction pattern is dismissed only while it waits for the team, and this one is <state>. | Dismissing a pattern that does not wait for the team. |
From a maintenance task's run
A run on a maintenance task calls two endpoints, through
spotlight maintenance check.
Only the runner with the lease on the run may call them, with its runner
token.
| Method and path | Returns |
|---|---|
GET /api/runs/{runId}/maintenance/corrections | { patternId, summary, setups, corrections }: the corrections behind the task's pattern, and each repository's setup command, by owner/name. |
POST /api/runs/{runId}/maintenance/checks | Takes { command, results }, each result { correctionId, outcome, paths, pathsOmitted }, with at most 100 paths of at most 1,000 characters each. pathsOmitted is how many more paths the check flagged and left out. Answers { caught, missed, tooWide, notCheckable }. |
A run whose task fixes no pattern is answered 404:
No run <runId> held by this runner, or it fixes no correction pattern. A
body with no command, no results, or a result about another pattern is
answered 422.