Skip to content
Merged
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
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,31 @@ already-delivered events from starting repairs. Removing the ID re-enables
admission after a fresh observation. This does not cancel an already-running
response; settle that owner separately before changing its work.

### CI jobs that are not CI faults

Some jobs fail to say something about the change under test: a pull request
without a milestone, a title that fails the lint, a review bot's verdict. They
are not faults of the runners. List them in `remediation.ignoredCiJobs` in
`settings.json` and no case is filed when they fail; cases already filed for
them are closed.

```json
"remediation": {
"ignoredCiJobs": [
{ "workflow": "Check PR milestone", "note": "a pull request without a milestone" },
{ "repo": "dashpay/platform", "workflow": "Pull Request Linter" },
{ "repo": "dashpay/dash-evo-tool", "job": "Platform pin guard" }
]
}
```

An entry takes `repo`, `workflow`, `job`, `event` and `branch`, and needs at
least a `workflow` or a `job`. Every field given must match; `*` matches any run
of characters and case is ignored. `note` is for the reader. The failures still
appear on the CI page and in its counts: only the remediation cases go. The
console refuses to save a malformed list; a list damaged on disk ignores
nothing. How cases end in general is in `deploy/INCIDENTS.md`.

Console GitHub login sessions last seven days from sign-in (both the server session and browser cookie). Existing sessions keep their original expiry; sign in again to receive the new lifetime.

After a console deployment, verify retained capabilities as well as legacy APIs:
Expand Down
14 changes: 12 additions & 2 deletions agent/aws-health.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { join } from 'node:path';
import { createAwsHealth } from './aws-health.js';
import { writeAtomic, readJSON } from '../shared/settings.js';
import { DEFAULT_SETTINGS } from '../shared/settings.js';
import { deriveIssues, reconcile } from '../server/incidents.js';
import { deriveIssues, issueId, reconcile } from '../server/incidents.js';

const fixture = JSON.parse(readFileSync(new URL('../shared/fixtures/dynamodb-scale-in.json', import.meta.url)));
const now = Date.parse('2026-10-02T18:00:00Z');
Expand Down Expand Up @@ -60,7 +60,17 @@ test('exact read/write alarms replay as verified informational controls and posi
assert.equal(prior.issues.filter((i) => i.code === 'aws_alarm').length, 2);
const current = derive(health);
assert.equal(current.issues.filter((i) => i.code === 'aws_alarm').length, 0);
assert.equal(current.issues.filter((i) => i.code === 'aws_scaling_control' && i.severity === 'info').length, 2);
assert.equal(current.issues.filter((i) => i.code === 'aws_scaling_control').length, 0, 'a verified control alarms by design: it is not a case');
// Cases an earlier release filed for these controls end; none is filed again.
const legacy = health.alarms.map((a) => ({ id: issueId('aws', a.region, a.name, 'aws_scaling_control'), domain: 'aws', scope: a.region, target: a.name,
code: 'aws_scaling_control', severity: 'info', status: 'open', sourceKey: 'aws:health', revision: 203,
observedAt: oldHealth.at, firstSeen: oldHealth.at, lastSeen: oldHealth.at, lastFaultAt: oldHealth.at, lastEventAt: oldHealth.at }));
const controls = (state) => state.issues.filter((i) => i.code === 'aws_scaling_control');
const ended = reconcile({ schemaVersion: 1, issues: legacy, outbox: [] }, current, now);
assert.equal(controls(ended).length, 2);
for (const issue of controls(ended)) assert.deepEqual([issue.status, issue.resolutionEvidence.reason, issue.revision], ['resolved', 'verified_control_signal', 204]);
const later = { ...health, at: new Date(now + 60_000).toISOString(), alarms: health.alarms.map((a) => ({ ...a, scalingControl: { ...a.scalingControl, verifiedAt: new Date(now + 60_000).toISOString() } })) };
assert.deepEqual(controls(reconcile(ended, derive(later, now + 60_000), now + 60_000)).map((i) => i.status), ['resolved', 'resolved'], 'still in ALARM, and not filed again');
const next = reconcile(prior, current, now);
for (const issue of next.issues.filter((i) => i.code === 'aws_alarm')) {
assert.equal(issue.status, 'resolved');
Expand Down
67 changes: 65 additions & 2 deletions deploy/INCIDENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,58 @@ Admins, or a dedicated read-only bearer token loaded through
state. Never put tokens in query strings or reuse the OAuth/agent credential.

Records carry stable fingerprints, revisions, first/last observation, severity,
source identity, and open/resolved state. Resolution requires positive fresh
source identity, and open/resolved state. Recovery requires positive fresh
rule-specific evidence. Missing observations, maintenance suppression and failed
collection never count as recovery. Evidence is untrusted data, not executable
instructions. Incident history is separate from operation history.

### How a case ends

A case that could only end by a proof that can never arrive (a job that already
left the queue, a host that no longer exists) used to stay open for good, and
the queue filled with them. The rules below end them. A resolved case records
why in `resolutionEvidence.reason`, and the board shows two kinds of ending
apart.

Three kinds of case still wait for their own proof and can stay open: an
`aws_collection_failed` for a scan that is not refreshed with every inventory
(it has no completeness clock of its own), an `aws_alarm` that moved from
`ALARM` to `INSUFFICIENT_DATA`, and every case of a CI host listed in
`remediation.excludedCiHosts`, which is left exactly as it is while excluded.

**Recovered**: monitoring saw the fault end.

| Reason | Rule |
|---|---|
| (none) | The rule's own check passed on a fresh, complete observation taken after the last fault. |
| `left_queue` | `queue_wait`: GitHub recorded the job starting on one of our runners; or the job is not among the queued jobs of a current listing that is whole for its repository (every page answered, none cut short, not cut for display, every queued job counted whatever its labels), for a run the poller still follows, in two listings in a row (one listing can miss a run that changes status between its two requests). Then it started, finished or was cancelled. A case that does not record when its run began cannot use the listing. |
| `later_attempt_passed`, `later_run_passed` | `job_failed`: a later attempt of the same run, or a later run (a higher run id) of the same workflow job on the same refs, passed after the failure. An older run that was slow to pass does not count. The refs are the head branch and the run's own ref, so pull requests from two forks with the same branch name stay apart, except under `pull_request_target`, where the ref is the base branch. Such a failure is not filed at all when the pass is already on record, and a pass still on record wins over expiry. |
| `quiet` | `host_health`: every fault is either proven healthy by its own rule or has gone unreported through `QUIET_SAMPLES` (10) consecutive valid probes of the host. A fault such as a task container that was removed has no state that could prove it healthy. On a host that stays faulty the same count drops such a fault from the evidence. |
| `verified_control_signal` | A verified scale-in control alarm (below). |

**Closed**: the case is over without a recovery. No repair is implied.

| Reason | Rule |
|---|---|
| `network_removed` | The network is no longer configured. |
| `target_removed` | The host, endpoint, disk, runner, reporter, volume, address, instance or alarm has been absent for 10 minutes (`GONE_AFTER_MS`), judged only by complete, current inventories of its kind. The 10 minutes are measured between the inventories' own times, so it takes a later inventory to end a case; the same one read again counts once. The collector and discovery cases of a network generation that a reset replaced end the same way. An inventory with an error, a failed discovery, a stale report, or a host report that lists only the first six of more disks is not evidence of absence, and does not restart the clock. A replaced instance is a new identity: its predecessor's case closes this way, never because the successor is healthy. |
| `expired` | `job_failed`: 24 hours after the failure with no later pass on record (the producer sees finished jobs for a day). `queue_wait`: not seen waiting for 24 hours while the queue was being observed. |
| `ignored_job` | `job_failed` for a job listed in `remediation.ignoredCiJobs` (see the README). |
| `superseded` | A release compatibility task whose release has a newer one in the same `major.minor` line. A release is superseded only by a newer release; a prerelease by any newer version. A superseded release is never opened as a task. |

A maintenance hold does not keep a closed case open: an operation on a network
does not preserve the cases of the hosts it replaced.

### Backlog

When more than one delivery batch (50 events) is waiting, the receiver is away
or behind. The producer then keeps only the newest waiting event of each issue.
A receiver that returns is told the current state of each issue, not the
history it missed. The newest event is kept even when it is the ending of an
issue the receiver may never have heard of: an earlier event can have been
accepted with its acknowledgement lost, and only the ending closes it there.
Events are never rewritten, so a redelivered one still matches by ID and bytes.

## Data and delivery

The unprivileged `STATUS_MODE=incidents` sidecar is the **single writer** of
Expand Down Expand Up @@ -386,7 +433,21 @@ Not covered: images with no GitHub release (nightlies, forks, patched tags).

## Remediation board

`/remediation` shows unique issues, queued event revisions, active work, waiting
`/remediation` opens on the faults monitoring reports now: counts by severity,
then each open case with what is wrong (the failing reasons of a host, the job
and branch of a CI failure with a link to its run, disk use, and so on; details
for administrators only). Cases of the same job are folded into one line.
Recovered and closed cases are a separate view, listed for 24 hours and at most
200 at a time; the counts are complete.

With dispatch switched off in the console and no repair worker reporting, the
board says exactly that: automatic repair is off. It does not call the missing
worker a stall, and it does not present what the worker last said about a case
(queued, working) as its current state; the last blocker and summary remain as
history. If the worker never acknowledged the switch-off, the board says so.
With dispatch switched on, a missing worker is a gap again and is shown as one.

It also shows queued event revisions, active work, waiting
reasons, blockers and recovery. `GET /api/remediation` is read-only; the existing
incident API bearer token or administrator session enables curated repair notes.
Public responses omit target identities, session keys, resource locks and notes,
Expand Down Expand Up @@ -426,6 +487,8 @@ in the checked-in status IAM policy. Names alone never suppress alarms; denied,
partial, stale or mismatched evidence keeps the warning actionable. Correction
of an old generic warning records explicit classification evidence and is shown
as **Monitoring corrected**, not table recovery. No scaling policy is modified.
A verified control is in `ALARM` whenever its table is idle, so no case is filed
for it; an alarm that fails verification is filed as `aws_alarm` as before.

Each readmission has a distinct attempt ID derived from its persisted admission
time. Earlier receipts/results are retained, not overwritten by retrying the
Expand Down
27 changes: 27 additions & 0 deletions scripts/browser-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ try {
lastResponse: outcome ? { outcome, summary: `Private ${id} response`, blocker: id === 'blocked' ? 'Root cause still open' : null,
nextAction: 'Existing owner retains follow-up', changes: ['Verified supporting-service correction'] } : null });
}
// The same job failing twice is one line that opens into its two cases, each
// saying what failed. An ended case says why it ended.
for (const n of [1, 2]) board.issues.push({ id: `job-${n}`, domain: 'ci', scope: 'private-ci-host', target: `dashpay/platform/${n}/private-ci-host`,
code: 'job_failed', severity: 'warning', status: 'open', firstSeen: at, lastSeen: at,
evidence: { repo: 'dashpay/platform', runId: 100 + n, attempt: 1, jobName: 'Swift SDK build', workflow: 'Tests', branch: 'private-branch', runner: 'private-ci-host' } });
board.issues.push({ id: 'gone', domain: 'network', scope: 'testnet', target: 'private-gone-host', code: 'host_health', severity: 'critical', status: 'resolved',
firstSeen: at, lastSeen: at, resolvedAt: at, resolutionEvidence: { reason: 'target_removed' } });
const boardFile = join(dataDir, 'incidents', 'state.json');
writeFileSync(boardFile, JSON.stringify(board));
const boardErrors = [];
Expand All @@ -230,6 +237,15 @@ try {
await page.setViewportSize(viewport);
await page.getByRole('link', { name: 'Remediation', exact: true }).click();
await page.getByText('Autonomous dispatch enabled').waitFor();
// The page opens on what is wrong now: six open faults, the ended ones a click away.
assert.match(await page.locator('[data-fault-summary]').innerText(), /OPEN FAULTS\s*6/i);
assert.equal(await page.locator('[data-issue-id="followup"]').count(), 0, 'a recovered case is not listed among open faults');
assert.equal(await page.locator('[data-issue-group]').count(), 1);
await page.locator('[data-issue-group] > summary').click();
assert.match(await page.locator('[data-issue-id="job-1"] [data-issue-detail]').innerText(), /dashpay\/platform · Tests · Swift SDK build · private-branch/);
await page.getByLabel('Remediation state').selectOption('history');
assert.match(await page.locator('[data-issue-id="gone"]').innerText(), /Closed[\s\S]*no longer exists/);
await page.getByLabel('Remediation state').selectOption('all');
await page.locator('[data-issue-id="blocked"] summary').click();
await page.getByText('Root cause still open').waitFor();
assert.ok((await page.locator('[data-issue-id="blocked"]').innerText()).includes('Blocked'));
Expand Down Expand Up @@ -259,8 +275,19 @@ try {
board.delivery.receiver.remediation.enabled = false;
writeFileSync(boardFile, JSON.stringify(board));
await anon.getByText('New dispatch paused', { exact: true }).waitFor({ timeout: 10_000 });
// The worker stops reporting while dispatch is switched off in the console
// (no control file means off): the page is a list of faults, not a stalled queue.
board.delivery.receiver.remediation.generatedAt = '2020-01-01T00:00:00Z';
writeFileSync(boardFile, JSON.stringify(board));
await anon.getByText('Automatic repair is switched off', { exact: true }).waitFor({ timeout: 10_000 });
assert.equal(await anon.locator('[data-repair-summary]').count(), 0);
assert.equal(await anon.getByText('Remediation cannot make progress').count(), 0);
await anon.setViewportSize({ width: 390, height: 844 });
await anon.screenshot({ path: 'artifacts/remediation-off-mobile.png', fullPage: true });
assert.ok(await anon.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), 'faults list fits a phone');
// Switched on in the console with the worker still silent: that is a gap.
writeFileSync(join(dataDir, 'remediation-control.json'), JSON.stringify({ schemaVersion: 1, seq: 1, dispatch: 'on', clearSeq: 0 }));
writeFileSync(boardFile, JSON.stringify(board));
await anon.getByText('Remediation status is stale or unavailable').waitFor({ timeout: 10_000 });
assert.deepEqual(boardErrors, []);
await anon.close();
Expand Down
Loading
Loading