diff --git a/.changes/pr-pipeline/work-resolve-issue-issue-13222-41836321545-1-2b72a09a.md b/.changes/pr-pipeline/work-resolve-issue-issue-13222-41836321545-1-2b72a09a.md new file mode 100644 index 00000000000..1d2176b3d18 --- /dev/null +++ b/.changes/pr-pipeline/work-resolve-issue-issue-13222-41836321545-1-2b72a09a.md @@ -0,0 +1,13 @@ +--- +bump: minor +--- + +### Added + +- The monitoring lane's signal 13, `lane holds`, counts the green runs that held on a fault with + only a notice: work-resolve-issue's fault stops whose retries were all faults, work-unblock's + unreadable listings, and pr-refine's failed `fix-docs` reads. A lane with + `monitor.lane-holds.threshold` held runs or more (default 4) in the last + `monitor.lane-holds.window-hours` (default 24) raises the signal's rolling issue, which only + notifies. The new optional `monitor` section of `pr-pipeline.yaml` holds both values, and the + lane carries its held runs from one hourly run to the next in its job reads artifact. diff --git a/.github/scripts/maintenance-monitor-signals/collect.mjs b/.github/scripts/maintenance-monitor-signals/collect.mjs index 46deaafbd94..719c7ef0122 100644 --- a/.github/scripts/maintenance-monitor-signals/collect.mjs +++ b/.github/scripts/maintenance-monitor-signals/collect.mjs @@ -4,7 +4,7 @@ // list is bounded, and `get` spends the run's call budget. import { parseOutcomeMarker } from "../work-resolve-issue/report-outcome.mjs"; import { escalationActivity, escalationRoute, STOP_RESOLVED } from "../pr-unblock/escalation-routes.mjs"; -import { parseBudget, POST_MERGE_UNREADABLE_SWEEPS, STALLED_HOURS, SWEEP_MAX_AGE_MINUTES } from "./signals.mjs"; +import { HOLD_LANES, parseBudget, parseHold, POST_MERGE_UNREADABLE_SWEEPS, STALLED_HOURS, SWEEP_MAX_AGE_MINUTES } from "./signals.mjs"; import { stepsKnown } from "../maintenance-reconcile-lost-runs/infra-failure.mjs"; export const LIMITS = { @@ -38,6 +38,13 @@ export const LIMITS = { stalledPulls: 40, stalledCommentRounds: 2, stalledChecks: 20, + // Uncarried green runs per hold lane read in one window, oldest completion + // first: one run list, then a jobs read and one annotation read per job that + // prints a hold, so at most 3 + 6 × 3 × 2 calls while each run has one such + // job. Past it, the span stops at the last run read and the window is a gap. + holdRuns: 6, + // Held runs the carry keeps, newest first. + holdsKept: 300, }; // report-escalation.sh's comment for a stop routed to a failing status, one // per activity, edited at each stop (gate-source.mjs LANE_STOPPED). @@ -128,14 +135,39 @@ export function parseJobsCarry(text, repo) { return new Map(data.runs.map((e) => [jobsKey(e.id, e.attempt), e])); } -export const jobsCarryFile = (repo, runs) => JSON.stringify({ version: JOBS_VERSION, repository: repo, runs }); +const NO_HELD = { runs: [], from: null, through: null }; +export const jobsCarryFile = (repo, runs, held = NO_HELD) => JSON.stringify({ version: JOBS_VERSION, repository: repo, runs, held }); + +// The held runs the same file carries, {runs, from, through}: the runs, and +// the unbroken span of completion times the lane read them over (null when +// not known, as in a file written before it carried them), or an error for +// any other shape. +export function parseHeldCarry(text, repo) { + const data = JSON.parse(text); + const held = data?.held ?? NO_HELD; + const time = (value) => value === null || (typeof value === "string" && !Number.isNaN(Date.parse(value))); + const entry = (h) => + HOLD_LANES.some((l) => l.lane === h?.lane) && + Number.isSafeInteger(h.runId) && h.runId > 0 && + typeof h.url === "string" && + (h.item === null || typeof h.item === "string") && + typeof h.reason === "string" && + typeof h.at === "string" && time(h.at); + if (data?.repository !== repo || !Array.isArray(held?.runs) || !held.runs.every(entry) || !time(held.from) || !time(held.through)) { + throw new Error("the carried held runs have an unexpected shape"); + } + return { runs: held.runs, from: held.from, through: held.through }; +} // `carriedJobs` is the last run's job reads (parseJobsCarry). A completed // run's carried read is used while its listing shows the same attempt and // updated_at, and a whole read of a completed run whose every job finished and // listed its steps in full is kept; data.jobsCarry holds what the next run -// carries: this run's reads and hits, nothing else. -export async function collect({ get, graphql, getStatus, readArtifact, repo, now, windowStart, agentIdentity, ownRate = null, carriedJobs = new Map() }) { +// carries: this run's reads and hits, nothing else. `holds`, when set, is +// {rule, carried}: signals.mjs holdRule's result or the error reading it, and +// the last run's held runs (parseHeldCarry), or null when there were none or +// they were not read; data.heldCarry holds what the next run carries. +export async function collect({ get, graphql, getStatus, readArtifact, repo, now, windowStart, agentIdentity, ownRate = null, carriedJobs = new Map(), holds = null }) { const gaps = []; const jobsMemo = new Map(); const annotationsMemo = new Map(); @@ -464,6 +496,85 @@ export async function collect({ get, graphql, getStatus, readArtifact, repo, now if (unread) gaps.push(`lane stops: over ${LIMITS.commentPages * 100} comments in the window; the oldest were not read`); }); + // Held runs of the HOLD_LANES: green runs of this repository's head on the + // default branch's code that completed in the window, whose hold job + // succeeded with a hold notice (signals.mjs parseHold), one entry per run, + // added to the carried ones still inside the rule's window. A run already + // carried is not read again, nor counted against LIMITS.holdRuns. The carry + // also records the span it was read over, which ends at the last run read + // when a lane had more than the cap. It stays unbroken when the last run + // read through a time inside the run list's lookback: runs that completed + // since then are read, so a late cron loses none. Otherwise (no carry, a + // stale one, a failed read) it starts again at this window. An unread rule, + // a lane over the cap, or a span shorter than the rule's window, is a gap, + // so signal 13's issue neither clears nor files from part of its window; + // the carried runs still go on to the next run. + const heldRuns = new Map(); + let heldFrom = null; + let heldThrough = null; + if (holds) { + const { carried } = holds; + for (const h of carried?.runs ?? []) heldRuns.set(`${h.lane}:${h.runId}`, h); + const through = Date.parse(carried?.through); + const unbroken = carried?.from && through >= windowStart.getTime() - RUN_LOOKBACK_HOURS * 3600_000 && through <= now.getTime(); + heldFrom = unbroken ? carried.from : iso(windowStart); + const readFrom = unbroken ? Math.min(through, windowStart.getTime()) : windowStart.getTime(); + const completedSince = (run) => { + const at = Date.parse(run.updated_at); + return at >= readFrom && at <= now.getTime(); + }; + await source("lane holds", async () => { + // The span is read through now unless a lane has more unread runs than + // the cap: then only its oldest are read, and the span stops at the last + // of them, so the next run reads the rest and this one reports a gap. + let readThrough = now.getTime(); + const cut = []; + for (const { lane, workflow, jobs } of HOLD_LANES) { + const runs = (await get(`/repos/${repo}/actions/workflows/${workflow}/runs?status=success&created=${created}&per_page=100`)).workflow_runs; + const unread = runs + .filter((r) => defaultBranchCode(r) && ownHead(r) && completedSince(r) && !heldRuns.has(`${lane}:${r.id}`)) + .sort((a, b) => Date.parse(a.updated_at) - Date.parse(b.updated_at)); + if (unread.length > LIMITS.holdRuns) { + readThrough = Math.min(readThrough, Date.parse(unread[LIMITS.holdRuns - 1].updated_at)); + cut.push(lane); + } + for (const run of unread.slice(0, LIMITS.holdRuns)) { + const key = `${lane}:${run.id}`; + const found = []; + for (const job of (await jobsOf(run)).filter((j) => j.conclusion === "success" && jobs.includes(j.name))) { + for (const a of await annotationsOf(job.id)) { + const hold = a.annotation_level === "notice" ? parseHold(a.title, a.message) : null; + if (hold) found.push(hold); + } + } + if (found.length === 0) continue; + heldRuns.set(key, { + lane, + runId: run.id, + url: run.html_url, + item: found.find((h) => h.item)?.item ?? null, + reason: [...new Set(found.map((h) => h.reason))].sort().join("; "), + at: run.updated_at, + }); + } + } + heldThrough = iso(new Date(readThrough)); + if (holds.rule instanceof Error) throw holds.rule; + const since = now.getTime() - holds.rule.windowHours * 3600_000; + for (const [key, h] of heldRuns) { + const at = Date.parse(h.at); + if (at < since || at > now.getTime()) heldRuns.delete(key); + } + data.holdRule = holds.rule; + if (cut.length > 0) { + throw new Error(`over ${LIMITS.holdRuns} unread green runs of ${cut.join(", ")}; held runs read only through ${heldThrough}`); + } + if (Date.parse(heldFrom) > since) throw new Error(`held runs read only since ${heldFrom}, short of the ${holds.rule.windowHours}-hour window`); + }); + } + data.laneHolds = [...heldRuns.values()].sort((a, b) => Date.parse(b.at) - Date.parse(a.at)).slice(0, LIMITS.holdsKept); + data.heldCarry = { runs: data.laneHolds, from: heldThrough ? heldFrom : null, through: heldThrough }; + // Open pull requests whose head carries a stop the pr-unblock lane routed to // a failing status (its lane-stopped comment, by the lanes App, names the // PR's current head) with no attempt of that activity started on the head diff --git a/.github/scripts/maintenance-monitor-signals/collect.test.mjs b/.github/scripts/maintenance-monitor-signals/collect.test.mjs index 9d914d77cec..6f719894ae6 100644 --- a/.github/scripts/maintenance-monitor-signals/collect.test.mjs +++ b/.github/scripts/maintenance-monitor-signals/collect.test.mjs @@ -4,7 +4,7 @@ import assert from "node:assert/strict"; import { test } from "node:test"; -import { collect, jobsCarryFile, JOBS_VERSION, LIMITS, listFiled, parseJobsCarry } from "./collect.mjs"; +import { collect, jobsCarryFile, JOBS_VERSION, LIMITS, listFiled, parseHeldCarry, parseJobsCarry } from "./collect.mjs"; import { ceilingFindings } from "./signals.mjs"; const repo = "o/r"; @@ -1028,3 +1028,152 @@ test("a carried job reads file of another version or repository, or a malformed assert.throws(() => parseJobsCarry(text, repo), /unexpected shape/); } }); + +// Green runs of the three hold lanes: 81 a work-unblock sweep that held twice, +// 82 a pull_request run, never read, and 83 a hold that completed at 15:20, +// before the window, read only when the carry stops short of it; 84 already +// carried; 85 a fault hold; 86 a skipped report job; 87 a pr-refine run with +// no hold notice. +const notice = (title, message) => ({ annotation_level: "notice", title, message }); +const holdRoutes = () => [ + [/workflows\/work-resolve-issue\.yml\/runs/, { workflow_runs: [run(84, { event: "issues" }), run(85, { event: "issues" }), run(86, { event: "issues" })] }], + [/workflows\/work-unblock\.yml\/runs/, { workflow_runs: [run(81), run(82, { event: "pull_request" }), run(83, { updated_at: "2026-10-19T15:20:00Z" })] }], + [/runs\/83\/jobs/, { jobs: [{ id: 830, name: "label-unblocked", conclusion: "success" }] }], + [/check-runs\/830\/annotations/, [notice("label-unblocked", "the agent-ready listing failed (HTTP 502); holding, and the next sweep reads it again")]], + [/workflows\/pr-refine\.yml\/runs/, { workflow_runs: [run(87, { event: "workflow_dispatch" })] }], + [/runs\/84\/jobs/, { jobs: [] }], + [/runs\/81\/jobs/, { jobs: [{ id: 810, name: "label-unblocked", conclusion: "success" }, { id: 811, name: "wip-state", conclusion: "success" }] }], + [/check-runs\/810\/annotations/, [ + notice("label-unblocked", "the open listing failed (HTTP 502); holding, and the next sweep reads it again"), + notice("label-unblocked", "the closed-issue listing failed (HTTP 502); holding, and the next sweep reads it again"), + ]], + [/runs\/85\/jobs/, { jobs: [{ id: 850, name: "report-outcome / run", conclusion: "success" }, { id: 851, name: "report-outcome / report", conclusion: "success" }] }], + [/check-runs\/850\/annotations/, [notice("report-outcome", "issue #812 stopped on a fault (outcome-unread), and every retry since a person last added agent-ready was one too; it keeps agent-ready and a later run tries again")]], + [/runs\/86\/jobs/, { jobs: [{ id: 860, name: "report-outcome / run", conclusion: "skipped" }] }], + [/runs\/87\/jobs/, { jobs: [{ id: 870, name: "fix-docs-handoff", conclusion: "success" }] }], + [/check-runs\/870\/annotations/, [notice("api-budget", "end github-token core remaining=1 used=1 limit=2 reset=x")]], + ...routes(), +]; +const carriedHold = (lane, runId, at) => ({ lane, runId, url: `https://github.com/o/r/actions/runs/${runId}`, item: null, reason: "closed-issue listing failed", at }); +// Read without a break since a day and a half ago, through 15:40, after this +// window opened at 15:36. +const CARRIED = { + runs: [ + carriedHold("work-resolve-issue", 84, "2026-10-19T15:50:00Z"), + carriedHold("work-unblock", 70, "2026-10-19T09:00:00Z"), + carriedHold("work-unblock", 71, "2026-10-18T10:00:00Z"), + ], + from: "2026-10-18T04:00:00Z", + through: "2026-10-19T15:40:00Z", +}; +const RULE = { threshold: 4, windowHours: 24 }; +const SHORT = "lane holds: held runs read only since 2026-10-19T15:36:00Z, short of the 24-hour window"; + +test("lane holds: green runs in the window add their holds to the carried ones inside the rule's window", async () => { + const api = fakeApi(holdRoutes()); + const data = await collect(input(api, { holds: { rule: RULE, carried: CARRIED } })); + assert.deepEqual(data.gaps, []); + assert.deepEqual( + data.laneHolds.map((h) => [h.lane, h.runId, h.item, h.reason]), + [ + ["work-resolve-issue", 85, "#812", "fault outcome-unread"], + ["work-unblock", 81, null, "closed-issue listing failed; open listing failed"], + ["work-resolve-issue", 84, null, "closed-issue listing failed"], + ["work-unblock", 70, null, "closed-issue listing failed"], + ], + ); + assert.equal(data.laneHolds[0].at, "2026-10-19T16:00:00Z"); + assert.deepEqual(data.heldCarry, { runs: data.laneHolds, from: CARRIED.from, through: "2026-10-19T16:41:00Z" }); + assert.deepEqual(data.holdRule, RULE); + for (const path of ["runs/82/jobs", "runs/83/jobs", "runs/84/jobs", "check-runs/811/", "check-runs/851/", "check-runs/860/"]) { + assert.ok(!api.calls.some((c) => c.includes(path)), path); + } + assert.ok(api.calls.some((c) => c.includes("workflows/pr-refine.yml/runs?status=success"))); + assert.deepEqual(parseHeldCarry(jobsCarryFile(repo, data.jobsCarry, data.heldCarry), repo), data.heldCarry); +}); + +test("lane holds: no carry, a stale one or an unread rule is a gap, and the carried runs still go on", async () => { + // No carry: this window starts the span, which falls short of 24 hours. + const uncarried = await collect(input(fakeApi(holdRoutes()), { holds: { rule: RULE, carried: null } })); + assert.deepEqual(uncarried.gaps, [SHORT]); + assert.deepEqual(uncarried.laneHolds.map((h) => h.runId), [85, 81]); + assert.deepEqual([uncarried.heldCarry.from, uncarried.heldCarry.through], ["2026-10-19T15:36:00Z", "2026-10-19T16:41:00Z"]); + // A late cron: the carry read through 15:00, so runs completed since then are read and the span holds. + const late = await collect(input(fakeApi(holdRoutes()), { holds: { rule: RULE, carried: { ...CARRIED, through: "2026-10-19T15:00:00Z" } } })); + assert.deepEqual(late.gaps, []); + assert.deepEqual(late.laneHolds.map((h) => [h.runId, h.reason]).slice(0, 4), [ + [85, "fault outcome-unread"], + [81, "closed-issue listing failed; open listing failed"], + [84, "closed-issue listing failed"], + [83, "agent-ready listing failed"], + ]); + assert.equal(late.heldCarry.from, CARRIED.from); + // A carry read through 09:00, past the run list's 6-hour lookback: the span starts again. + const stale = await collect(input(fakeApi(holdRoutes()), { holds: { rule: RULE, carried: { ...CARRIED, through: "2026-10-19T09:00:00Z" } } })); + assert.deepEqual(stale.gaps, [SHORT]); + assert.deepEqual(stale.laneHolds.map((h) => h.runId), [85, 81, 84, 70]); + // An unread rule: this window is still read and carried, unpruned, over the same span. + const unruled = await collect(input(fakeApi(holdRoutes()), { holds: { rule: new Error("the monitor.lane-holds rule was not read: yq failed"), carried: CARRIED } })); + assert.deepEqual(unruled.gaps, ["lane holds: the monitor.lane-holds rule was not read: yq failed"]); + assert.deepEqual(unruled.heldCarry.runs.map((h) => h.runId), [85, 81, 84, 70, 71]); + assert.equal(unruled.heldCarry.from, CARRIED.from); + assert.equal(unruled.holdRule, undefined); + // A failed read keeps the carried runs and marks the span unknown, so the next run starts it again. + const failed = await collect(input(fakeApi([[/workflows\/work-unblock\.yml\/runs/, new Error("GET runs: HTTP 502")], ...holdRoutes()]), { holds: { rule: RULE, carried: CARRIED } })); + assert.deepEqual(failed.gaps, ["lane holds: GET runs: HTTP 502"]); + assert.deepEqual([failed.heldCarry.runs.map((h) => h.runId), failed.heldCarry.from, failed.heldCarry.through], [[85, 84, 70, 71], null, null]); + const off = await collect(input(fakeApi(routes()))); + assert.deepEqual([off.gaps, off.laneHolds], [[], []]); +}); + +// Eight green pr-refine runs completed 15:40 to 16:15, listed newest first, +// the two oldest held, after 908, already carried, at 15:38. +const REFINE_AT = ["15:40", "15:45", "15:50", "15:55", "16:00", "16:05", "16:10", "16:15"]; +const refineRoutes = () => [ + [/workflows\/pr-refine\.yml\/runs/, { + workflow_runs: [...REFINE_AT.map((t, i) => run(900 + i, { event: "workflow_dispatch", updated_at: `2026-10-19T${t}:00Z` })), run(908, { event: "workflow_dispatch", updated_at: "2026-10-19T15:38:00Z" })].reverse(), + }], + [/runs\/90[01]\/jobs/, (path) => ({ jobs: [{ id: Number(/runs\/(\d+)/.exec(path)[1]) * 10, name: "fix-docs-handoff", conclusion: "success" }] })], + [/check-runs\/90[01]0\/annotations/, [notice("Handoff evidence hold", "handoff evidence for fix-docs still missing after the read")]], + [/runs\/90\d\/jobs/, { jobs: [] }], + ...holdRoutes(), +]; + +test("lane holds: past the cap the oldest unread runs are read, a carried one takes no slot, and the span stops at the last read", async () => { + const carried = { ...CARRIED, runs: [...CARRIED.runs, carriedHold("pr-refine", 908, "2026-10-19T15:38:00Z")] }; + const api = fakeApi(refineRoutes()); + const data = await collect(input(api, { holds: { rule: RULE, carried } })); + assert.deepEqual(data.gaps, [`lane holds: over ${LIMITS.holdRuns} unread green runs of pr-refine; held runs read only through 2026-10-19T16:05:00Z`]); + assert.deepEqual(data.laneHolds.filter((h) => h.lane === "pr-refine").map((h) => [h.runId, h.reason]), [ + [901, "fix-docs handoff evidence missing"], + [900, "fix-docs handoff evidence missing"], + [908, "closed-issue listing failed"], + ]); + assert.deepEqual([data.heldCarry.from, data.heldCarry.through], [CARRIED.from, "2026-10-19T16:05:00Z"]); + for (const id of [906, 907, 908]) assert.ok(!api.calls.some((c) => c.includes(`runs/${id}/jobs`)), id); + // The next run, an hour on, reads the rest from where this one stopped, and the span holds. + const later = fakeApi(refineRoutes()); + const next = await collect(input(later, { + now: new Date("2026-10-19T17:41:00Z"), + windowStart: new Date("2026-10-19T16:36:00Z"), + holds: { rule: RULE, carried: data.heldCarry }, + })); + assert.deepEqual(next.gaps.filter((g) => g.startsWith("lane holds")), []); + for (const id of [906, 907]) assert.ok(later.calls.some((c) => c.includes(`runs/${id}/jobs`)), id); + assert.equal(next.heldCarry.through, "2026-10-19T17:41:00Z"); +}); + +test("a carried held run of another repository or an unknown lane, or a bad span, is refused", () => { + assert.deepEqual(parseHeldCarry(JSON.stringify({ version: JOBS_VERSION, repository: repo, runs: [] }), repo), { runs: [], from: null, through: null }); + const [first] = CARRIED.runs; + for (const text of [ + jobsCarryFile("other/repo", [], CARRIED), + jobsCarryFile(repo, [], { ...CARRIED, runs: [{ ...first, lane: "pr-merge" }] }), + jobsCarryFile(repo, [], { ...CARRIED, runs: [{ ...first, at: "never" }] }), + jobsCarryFile(repo, [], { ...CARRIED, runs: [{ ...first, item: 812 }] }), + jobsCarryFile(repo, [], { ...CARRIED, from: "never" }), + jobsCarryFile(repo, [], { ...CARRIED, runs: null }), + ]) { + assert.throws(() => parseHeldCarry(text, repo), /unexpected shape/); + } +}); diff --git a/.github/scripts/maintenance-monitor-signals/issues.mjs b/.github/scripts/maintenance-monitor-signals/issues.mjs index febb08b0420..2b91d31b16a 100644 --- a/.github/scripts/maintenance-monitor-signals/issues.mjs +++ b/.github/scripts/maintenance-monitor-signals/issues.mjs @@ -18,6 +18,7 @@ export const SIGNALS = [ "10 stalled lane stop", "11 post-merge unreadable", "12 listing held", + "13 lane holds", ]; export const LOG_ONLY = new Set(["7 platform incident"]); const MUTED = new Set(["not_planned", "duplicate"]); @@ -125,6 +126,7 @@ const SOURCES = { "lane stops": ["9 lane stop"], "stalled stops": ["10 stalled lane stop"], "post-merge reports": ["11 post-merge unreadable"], + "lane holds": ["13 lane holds"], audits: ["6 report-only audit"], "githubstatus.com": [], }; diff --git a/.github/scripts/maintenance-monitor-signals/issues.test.mjs b/.github/scripts/maintenance-monitor-signals/issues.test.mjs index ce11883c696..05d3302a8da 100644 --- a/.github/scripts/maintenance-monitor-signals/issues.test.mjs +++ b/.github/scripts/maintenance-monitor-signals/issues.test.mjs @@ -112,6 +112,7 @@ test("each collect source maps to the signals it feeds, and an unknown gap leave assert.deepEqual([...unreadSignals(["post-merge reports: x"])], ["11 post-merge unreadable"]); assert.deepEqual([...unreadSignals(["pr-merge sweep: x"])], ["3 throttling", "5 held PRs", "8 throughput", "12 listing held"]); assert.deepEqual([...unreadSignals(["pr-merge listed sweep: x"])], ["5 held PRs", "8 throughput"]); + assert.deepEqual([...unreadSignals(["lane holds: x"])], ["13 lane holds"]); assert.deepEqual(new Set(unreadSignals(["new source: x"])), new Set(SIGNALS)); assert.equal(unreadSignals([]).size, 0); }); @@ -215,6 +216,8 @@ test("every detector's signal is a rolling family or logged only, and an unknown stalledStops: [{ pr: 5, head: "a", activity: "fix-ci", reason: "ci-fix-invalid", stoppedAt: "t", url: "u" }], postMergeReports: [4, 3, 2, 1].map((runId) => ({ runId, url: "u", code: "3", reason: "r", createdAt: "t" })), heldSweeps: [4, 3, 2, 1].map((runId) => ({ runId, url: "u", reason: "r", createdAt: "t" })), + laneHolds: [1, 2].map((runId) => ({ lane: "work-unblock", runId, url: "u", item: null, reason: "r", at: "2026-10-19T16:00:00Z" })), + holdRule: { threshold: 2, windowHours: 24 }, }); assert.deepEqual(new Set(all.map((f) => f.signal)), new Set([...SIGNALS, ...LOG_ONLY])); const plan = planIssues({ findings: [{ ...findingFor([1]), signal: "10 renamed" }], existing: [] }); diff --git a/.github/scripts/maintenance-monitor-signals/monitor.mjs b/.github/scripts/maintenance-monitor-signals/monitor.mjs index 2a7a129e5aa..2f48fe1ebbc 100644 --- a/.github/scripts/maintenance-monitor-signals/monitor.mjs +++ b/.github/scripts/maintenance-monitor-signals/monitor.mjs @@ -17,31 +17,60 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import process from "node:process"; import { setTimeout as delay } from "node:timers/promises"; -import { pathToFileURL } from "node:url"; +import { fileURLToPath, pathToFileURL } from "node:url"; -import { collect, JOBS_ARTIFACT, JOBS_FILE, jobsCarryFile, listFiled, parseJobsCarry } from "./collect.mjs"; +import { collect, JOBS_ARTIFACT, JOBS_FILE, jobsCarryFile, listFiled, parseHeldCarry, parseJobsCarry } from "./collect.mjs"; import { planIssues, readMarker, renderBody, renderComment, renderSupersede, titleOf, unreadSignals } from "./issues.mjs"; -import { detect } from "./signals.mjs"; +import { detect, holdRule } from "./signals.mjs"; import { rateLimitLatch } from "../../actions/log-api-budget/rate-guard.mjs"; import { ghDownload, newestTrustedRun } from "../pr-merge/rotation.mjs"; const WORKFLOW_PATH = ".github/workflows/maintenance-monitor-signals.yml"; +// The checkout's pipeline config, three levels above this file. +const CONFIG = fileURLToPath(new URL("../../../docs/conventions/pr-pipeline.yaml", import.meta.url)); -// The last run's completed job reads (collect.mjs parseJobsCarry), from the -// newest scheduled or hand-started run of main's copy of this workflow that -// holds the JOBS_ARTIFACT, this run aside: only a run's own steps upload its -// artifacts. Empty, with a warning, when there is none or it cannot be read, -// so every run's jobs are read as before. Off unless JOBS_CARRY_PATH is set. +// The last run's carry, from the newest scheduled or hand-started run of +// main's copy of this workflow that holds the JOBS_ARTIFACT, this run aside: +// only a run's own steps upload its artifacts. `jobs` is its completed job +// reads (collect.mjs parseJobsCarry), empty with a warning when there is none +// or it cannot be read, so every run's jobs are read as before. `held` is its +// held runs (parseHeldCarry), null when there is none or, with a warning, when +// it cannot be read. Off unless JOBS_CARRY_PATH is set. export async function readJobsCarry({ env, repo, actions, download }) { - if (!env.JOBS_CARRY_PATH) return new Map(); + const none = { jobs: new Map(), held: null }; + if (!env.JOBS_CARRY_PATH) return none; + const warn = (what, error) => console.log(`::warning::monitoring lane: ${what}: ${error?.message ?? error}`); + let text; try { const id = await newestTrustedRun({ repo, runId: String(env.GITHUB_RUN_ID), actions, name: JOBS_ARTIFACT, workflow: WORKFLOW_PATH }); - if (id === undefined) return new Map(); + if (id === undefined) return none; download ??= ghDownload({ repo, token: env.GITHUB_TOKEN, dir: env.RUNNER_TEMP ?? tmpdir(), name: JOBS_ARTIFACT, file: JOBS_FILE }); - return parseJobsCarry(download(id), repo); + text = download(id); } catch (error) { - console.log(`::warning::monitoring lane: no job reads carried, so every run's jobs are read: ${error?.message ?? error}`); - return new Map(); + warn("nothing carried, so every run's jobs are read", error); + return none; + } + const carry = { jobs: new Map(), held: null }; + try { + carry.jobs = parseJobsCarry(text, repo); + } catch (error) { + warn("no job reads carried, so every run's jobs are read", error); + } + try { + carry.held = parseHeldCarry(text, repo); + } catch (error) { + warn("no held runs carried", error); + } + return carry; +} + +// pr-pipeline.yaml's monitor.lane-holds rule (signals.mjs holdRule), read with +// yq as the workflow reads merge.agent-identity, or the error that stopped it. +export function readHoldRule({ path = CONFIG, run = execFileSync } = {}) { + try { + return holdRule(JSON.parse(run("yq", ["-o=json", '.monitor."lane-holds" // {}', path], { encoding: "utf8" }))); + } catch (error) { + return new Error(`the monitor.lane-holds rule was not read: ${error?.message ?? error}`); } } @@ -173,10 +202,11 @@ async function main(env = process.env) { }; // GET /rate_limit does not count against the limit. const ownRate = replay ? null : ((await get("/rate_limit").catch(() => null))?.resources?.core ?? null); - const carriedJobs = await readJobsCarry({ env, repo, actions: call }); + const carry = await readJobsCarry({ env, repo, actions: call }); const data = await collect({ - carriedJobs, + carriedJobs: carry.jobs, + holds: { rule: readHoldRule(), carried: carry.held }, get, graphql, getStatus, @@ -189,7 +219,7 @@ async function main(env = process.env) { }); if (env.JOBS_CARRY_PATH) { try { - writeFileSync(env.JOBS_CARRY_PATH, jobsCarryFile(repo, data.jobsCarry)); + writeFileSync(env.JOBS_CARRY_PATH, jobsCarryFile(repo, data.jobsCarry, data.heldCarry)); } catch (error) { console.log(`::warning::monitoring lane: the job reads were not carried: ${error.message}`); } diff --git a/.github/scripts/maintenance-monitor-signals/monitor.test.mjs b/.github/scripts/maintenance-monitor-signals/monitor.test.mjs index 09a84a7fcab..e7257d752ed 100644 --- a/.github/scripts/maintenance-monitor-signals/monitor.test.mjs +++ b/.github/scripts/maintenance-monitor-signals/monitor.test.mjs @@ -5,10 +5,11 @@ // the same issue instead of filing a second. Every rewrite takes agent-ready // off. import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; import { test } from "node:test"; import { SIGNALS, planIssues, readMarker } from "./issues.mjs"; -import { errorLines, readJobsCarry, writePlan } from "./monitor.mjs"; +import { errorLines, readHoldRule, readJobsCarry, writePlan } from "./monitor.mjs"; import { JOBS_ARTIFACT, jobsCarryFile } from "./collect.mjs"; import { detect } from "./signals.mjs"; @@ -270,6 +271,8 @@ const carryActions = (runs) => { return { actions, calls }; }; const ENTRY = { id: 50, attempt: 1, updated_at: "2026-10-19T15:20:00Z", jobs: [] }; +const HOLD = { lane: "work-unblock", runId: 60, url: "https://github.com/o/r/actions/runs/60", item: null, reason: "closed-issue listing failed", at: "2026-10-19T15:10:00Z" }; +const HELD = { runs: [HOLD], from: "2026-10-18T09:00:00Z", through: "2026-10-19T15:20:00Z" }; test("the job reads carry is read from the newest trusted run, past a pull_request run and this run", async () => { const { actions, calls } = carryActions([ @@ -278,20 +281,21 @@ test("the job reads carry is read from the newest trusted run, past a pull_reque { id: 901, path: LANE, event: "workflow_dispatch", head_branch: "main" }, ]); const downloaded = []; - const map = await readJobsCarry({ + const { jobs, held } = await readJobsCarry({ env: { JOBS_CARRY_PATH: "/x", GITHUB_RUN_ID: "903" }, repo: "o/r", actions, - download: (id) => (downloaded.push(id), jobsCarryFile("o/r", [ENTRY])), + download: (id) => (downloaded.push(id), jobsCarryFile("o/r", [ENTRY], HELD)), }); assert.deepEqual(downloaded, [901]); - assert.deepEqual([...map.keys()], ["50:1"]); + assert.deepEqual([...jobs.keys()], ["50:1"]); + assert.deepEqual(held, HELD); assert.ok(!calls.some((p) => /runs\/90[23]\/artifacts/.test(p))); }); test("no JOBS_CARRY_PATH reads nothing, and a carry that cannot be read carries nothing", async (t) => { const { actions, calls } = carryActions([{ id: 901, path: LANE, event: "schedule", head_branch: "main" }]); - assert.equal((await readJobsCarry({ env: {}, repo: "o/r", actions })).size, 0); + assert.deepEqual(await readJobsCarry({ env: {}, repo: "o/r", actions }), { jobs: new Map(), held: null }); assert.deepEqual(calls, []); t.mock.method(console, "log", () => {}); for (const download of [ @@ -300,6 +304,34 @@ test("no JOBS_CARRY_PATH reads nothing, and a carry that cannot be read carries }, () => jobsCarryFile("other/repo", [ENTRY]), ]) { - assert.equal((await readJobsCarry({ env: { JOBS_CARRY_PATH: "/x", GITHUB_RUN_ID: "999" }, repo: "o/r", actions, download })).size, 0); + assert.deepEqual(await readJobsCarry({ env: { JOBS_CARRY_PATH: "/x", GITHUB_RUN_ID: "999" }, repo: "o/r", actions, download }), { jobs: new Map(), held: null }); } + // A file from before the carry held runs carries none over no span; a bad held run drops only the held runs. + const old = JSON.stringify({ version: 1, repository: "o/r", runs: [ENTRY] }); + assert.deepEqual((await readJobsCarry({ env: { JOBS_CARRY_PATH: "/x", GITHUB_RUN_ID: "999" }, repo: "o/r", actions, download: () => old })).held, { runs: [], from: null, through: null }); + const bad = await readJobsCarry({ env: { JOBS_CARRY_PATH: "/x", GITHUB_RUN_ID: "999" }, repo: "o/r", actions, download: () => jobsCarryFile("o/r", [ENTRY], { ...HELD, runs: [{ ...HOLD, lane: "other" }] }) }); + assert.deepEqual([[...bad.jobs.keys()], bad.held], [["50:1"], null]); +}); + +test("the hold rule is read from pr-pipeline.yaml with its defaults, and a bad one is an error", () => { + const rule = (text) => readHoldRule({ path: "p.yaml", run: () => text }); + assert.deepEqual(rule("{}"), { threshold: 4, windowHours: 24 }); + assert.deepEqual(rule('{"threshold": 2, "window-hours": 6}'), { threshold: 2, windowHours: 6 }); + for (const text of ['{"threshold": 1}', '{"window-hours": 0}', "not json"]) assert.match(rule(text).message, /monitor\.lane-holds rule was not read/); + const failing = readHoldRule({ + run: () => { + throw new Error("yq: not found"); + }, + }); + assert.match(failing.message, /yq: not found/); +}); + +test("the checkout's pr-pipeline.yaml sets a hold rule the schema and holdRule take", () => { + const text = readFileSync(new URL("../../../docs/conventions/pr-pipeline.yaml", import.meta.url), "utf8"); + const leaf = /^monitor:\n {2}lane-holds:\n {4}threshold: (\d+)\n(?: {4}#.*\n)* {4}window-hours: (\d+)$/m.exec(text); + assert.ok(leaf, "pr-pipeline.yaml has a monitor.lane-holds leaf"); + assert.ok(Number(leaf[1]) >= 2); + const schema = JSON.parse(readFileSync(new URL("../../../docs/conventions/pr-pipeline/pr-pipeline.schema.json", import.meta.url), "utf8")); + const props = schema.properties.monitor.properties["lane-holds"].properties; + assert.deepEqual([props.threshold.default, props["window-hours"].default], [4, 24]); }); diff --git a/.github/scripts/maintenance-monitor-signals/signals.mjs b/.github/scripts/maintenance-monitor-signals/signals.mjs index 02ebdb610ac..7bd22f55d2f 100644 --- a/.github/scripts/maintenance-monitor-signals/signals.mjs +++ b/.github/scripts/maintenance-monitor-signals/signals.mjs @@ -402,6 +402,77 @@ export function listingHeldFindings({ heldSweeps = [] }) { ]; } +// The lanes whose read faults hold green with only a notice (outage posture +// element 2), the jobs that print each hold notice, and that notice. A lane +// that passes the threshold of docs/conventions/pr-pipeline.yaml +// monitor.lane-holds raises signal 13; the leaf's defaults have this one copy. +export const LANE_HOLDS = { threshold: 4, "window-hours": 24 }; +export const HOLD_LANES = [ + { lane: "work-resolve-issue", workflow: "work-resolve-issue.yml", jobs: ["report-outcome / run"], area: "Issue lane (work-resolve-issue)" }, + { lane: "work-unblock", workflow: "work-unblock.yml", jobs: ["label-unblocked"], area: "Unblock lane (work-unblock)" }, + { lane: "pr-refine", workflow: "pr-refine.yml", jobs: ["fix-docs-handoff", "fix-docs-subscription-handoff"], area: "PR refine lane (pr-refine fix-docs)" }, +]; +const NAME = "[a-z]+(?:-[a-z]+)*"; +const HOLD_NOTICES = [ + // report-outcome.mjs: a fault stop whose counted retries were all faults. + { title: "report-outcome", pattern: new RegExp(`^issue #(\\d+) stopped on a fault \\((${NAME})\\), and every retry`), hold: (m) => ({ item: `#${m[1]}`, reason: `fault ${m[2]}` }) }, + // label-unblocked.mjs reportHold: a listing the sweep could not read. + { title: "label-unblocked", pattern: new RegExp(`^the (${NAME}) listing failed \\(`), hold: (m) => ({ item: null, reason: `${m[1]} listing failed` }) }, + // handoff-evidence.sh: a fix-docs read that failed. + { title: "Handoff evidence hold", pattern: new RegExp(`^handoff evidence for (${NAME}) still missing`), hold: (m) => ({ item: null, reason: `${m[1]} handoff evidence missing` }) }, +]; + +// One notice annotation's hold, {item, reason}, or null. +export function parseHold(title, message) { + for (const { title: t, pattern, hold } of HOLD_NOTICES) { + const m = t === title ? pattern.exec(String(message)) : null; + if (m) return hold(m); + } + return null; +} + +// The monitor.lane-holds leaf as set ({} when absent), with its defaults, or a +// throw for a value the schema refuses. +export function holdRule(leaf) { + const rule = { ...LANE_HOLDS, ...(leaf ?? {}) }; + const whole = (value, min, max) => Number.isInteger(value) && value >= min && value <= max; + if (!whole(rule.threshold, 2, 100) || !whole(rule["window-hours"], 1, 168)) { + throw new Error("monitor.lane-holds needs a threshold of 2 to 100 and window-hours of 1 to 168"); + } + return { threshold: rule.threshold, windowHours: rule["window-hours"] }; +} + +// A held run ends green with only a notice, so a fault that holds every run +// shows nowhere else. One finding per lane whose held runs over the rule's +// window reach its threshold; an issue held that often is one of them. It only +// notifies, adds no stop and clears once the count drops below the threshold. +// The fingerprint is the set of hold reasons with counts masked, so a fault +// that keeps holding is written once. +export function laneHoldFindings({ laneHolds = [], holdRule: rule = null }) { + if (!rule) return []; + const out = []; + for (const { lane, area } of HOLD_LANES) { + const holds = laneHolds.filter((h) => h.lane === lane).sort((a, b) => Date.parse(b.at) - Date.parse(a.at)); + if (holds.length < rule.threshold) continue; + const perItem = new Map(); + for (const { item } of holds) if (item) perItem.set(item, (perItem.get(item) ?? 0) + 1); + const repeated = [...perItem].filter(([, n]) => n > 1).map(([item, n]) => `${item} ${n} times`); + out.push( + finding({ + key: `lane-hold:${lane}`, + signal: "13 lane holds", + title: `Lane holds: ${lane} held ${holds.length} runs in the last ${rule.windowHours} hours`, + area, + summary: `${holds.length} green ${lane} runs held on a fault in the last ${rule.windowHours} hours, at or over the threshold of ${rule.threshold}; each ended with only a notice and is retried later.${repeated.length > 0 ? ` Held more than once: ${repeated.join(", ")}.` : ""}`, + facts: holds.map((h) => `${h.at}${h.item ? ` ${h.item}` : ""} ${h.url}: ${h.reason}`), + evidence: [`lane-hold:${lane}`, [...new Set(holds.map((h) => h.reason.replace(/\d+/g, "N")))].sort()], + observedAt: holds[0].at, + }), + ); + } + return out; +} + const DETECTORS = [ mainRedFindings, ceilingFindings, @@ -415,6 +486,7 @@ const DETECTORS = [ stalledFindings, postMergeUnreadableFindings, listingHeldFindings, + laneHoldFindings, ]; export function detect(data) { diff --git a/.github/scripts/maintenance-monitor-signals/signals.test.mjs b/.github/scripts/maintenance-monitor-signals/signals.test.mjs index 7e136d712ad..c0b376fa801 100644 --- a/.github/scripts/maintenance-monitor-signals/signals.test.mjs +++ b/.github/scripts/maintenance-monitor-signals/signals.test.mjs @@ -11,8 +11,11 @@ import { detect, ejectionFindings, heldFindings, + holdRule, + laneHoldFindings, mainRedFindings, parseBudget, + parseHold, platformFindings, POST_MERGE_UNREADABLE_SWEEPS, LISTING_HELD_SWEEPS, @@ -546,6 +549,71 @@ test("signal 11: the fingerprint holds while the cause holds, through new runs a assert.notEqual(fp(later), fp([report(5, "3", "pull requests: HTTP 502"), report(4), report(3), report(2)])); }); +// The three hold notices as their scripts print them (report-outcome.mjs, +// label-unblocked.mjs reportHold, handoff-evidence.sh), title and message. +const FAULT = ["report-outcome", "issue #812 stopped on a fault (outcome-unread), and every retry since a person last added agent-ready was one too; it keeps agent-ready and a later run tries again"]; +const LISTING = ["label-unblocked", "the closed-issue listing failed (GET /repos/o/r/issues: HTTP 502); holding, and the next sweep reads it again"]; +const HANDOFF = ["Handoff evidence hold", "handoff evidence for fix-docs still missing after 3 reads: read-failed; no fallback starts, and the next dispatcher tick sends the PR again"]; + +test("signal 13: each lane's hold notice parses, and other notices do not", () => { + assert.deepEqual(parseHold(...FAULT), { item: "#812", reason: "fault outcome-unread" }); + assert.deepEqual(parseHold(...LISTING), { item: null, reason: "closed-issue listing failed" }); + assert.deepEqual(parseHold(...HANDOFF), { item: null, reason: "fix-docs handoff evidence missing" }); + assert.equal(parseHold("api-budget", LISTING[1]), null); + assert.equal(parseHold("report-outcome", "could not read this issue's earlier work (HTTP 502); the model is skipped, and a later run reads it again"), null); + assert.equal(parseHold(undefined, "handoff evidence for fix-docs still missing after 3 reads: x; the outputs stay empty"), null); +}); + +const held = (lane, runId, { item = null, reason = "closed-issue listing failed", hour = 10 } = {}) => ({ + lane, + runId, + url: `https://github.com/o/r/actions/runs/${runId}`, + item, + reason, + at: `2026-10-19T${String(hour).padStart(2, "0")}:47:00Z`, +}); + +test("signal 13: a repeated hold raises it and a single hold does not", () => { + const rule = holdRule({ threshold: 2 }); + const once = held("work-resolve-issue", 1, { item: "#812", reason: "fault outcome-unread" }); + assert.deepEqual(laneHoldFindings({ laneHolds: [once], holdRule: rule }), []); + const again = { ...once, runId: 2, url: "https://github.com/o/r/actions/runs/2", at: "2026-10-19T14:47:00Z" }; + const found = detect({ ...base, laneHolds: [once, again], holdRule: rule }); + assert.equal(found.length, 1); + const [f] = found; + assert.equal(f.key, "lane-hold:work-resolve-issue"); + assert.equal(f.signal, "13 lane holds"); + assert.equal(f.area, "Issue lane (work-resolve-issue)"); + assert.match(f.summary, /^2 green work-resolve-issue runs held on a fault in the last 24 hours, at or over the threshold of 2/); + assert.match(f.summary, /Held more than once: #812 2 times\./); + assert.deepEqual(f.facts, [ + "2026-10-19T14:47:00Z #812 https://github.com/o/r/actions/runs/2: fault outcome-unread", + "2026-10-19T10:47:00Z #812 https://github.com/o/r/actions/runs/1: fault outcome-unread", + ]); + assert.equal(f.observedAt, again.at); +}); + +test("signal 13: the default threshold counts each lane on its own, and no rule fires nothing", () => { + const rule = holdRule({}); + assert.deepEqual(rule, { threshold: 4, windowHours: 24 }); + const three = [1, 2, 3].map((id) => held("work-unblock", id, { hour: 9 + id })); + const others = [4, 5].map((id) => held("pr-refine", id, { reason: "fix-docs handoff evidence missing" })); + assert.deepEqual(laneHoldFindings({ laneHolds: [...three, ...others], holdRule: rule }), []); + const four = [...three, held("work-unblock", 9, { hour: 15 })]; + assert.deepEqual(laneHoldFindings({ laneHolds: [...four, ...others], holdRule: rule }).map((f) => [f.key, f.facts.length]), [["lane-hold:work-unblock", 4]]); + assert.deepEqual(laneHoldFindings({ laneHolds: four }), []); + assert.throws(() => holdRule({ threshold: 1 }), /threshold of 2 to 100/); + assert.throws(() => holdRule({ "window-hours": 1.5 }), /window-hours of 1 to 168/); +}); + +test("signal 13: the fingerprint holds while the reasons hold, through new runs", () => { + const rule = holdRule({ threshold: 2 }); + const fp = (holds) => laneHoldFindings({ laneHolds: holds, holdRule: rule })[0].fingerprint; + const two = [held("work-unblock", 1), held("work-unblock", 2, { hour: 11 })]; + assert.equal(fp(two), fp([...two, held("work-unblock", 3, { hour: 12 })])); + assert.notEqual(fp(two), fp([...two, held("work-unblock", 3, { reason: "open listing failed" })])); +}); + test("signal 11: a reason from the report reaches the issue inert", () => { const [f] = postMergeUnreadableFindings({ postMergeReports: [report(4, "3", "bad ```\n@someone [x](http://e)"), report(3), report(2), report(1)], diff --git a/docs/conventions/pr-pipeline.yaml b/docs/conventions/pr-pipeline.yaml index 572b9f40e41..461ed9d6576 100644 --- a/docs/conventions/pr-pipeline.yaml +++ b/docs/conventions/pr-pipeline.yaml @@ -1216,6 +1216,20 @@ branch-cleanup: # A run deletes at most this many; the rest wait for the next run. max-deletes-per-run: 25 +# The monitoring lane (maintenance-monitor-signals.yml). Its signal 13 counts +# the held runs of work-resolve-issue (a fault stop whose retries were all +# faults), work-unblock (a listing the sweep could not read) and pr-refine (a +# fix-docs read that failed): each ends green with only a notice, so a fault +# that keeps holding shows nowhere else. A lane with `threshold` held runs or +# more in the last `window-hours` raises the signal's issue, which only +# notifies; it adds no stop and no cap. 4 matches the pr-merge sweeps in a row +# that raise signal 12. 24 is the longest wait of work-unblock's stranded +# backoff, so one issue's repeated holds can fall in one window. +monitor: + lane-holds: + threshold: 4 + window-hours: 24 + merge: # The rung is a pacing cap: off merges nothing without a human; merge lets # the merge authority merge; merge-reviewed also needs AI review to be diff --git a/docs/conventions/pr-pipeline/README.md b/docs/conventions/pr-pipeline/README.md index 37c0c54db29..5d141646dd9 100644 --- a/docs/conventions/pr-pipeline/README.md +++ b/docs/conventions/pr-pipeline/README.md @@ -3239,6 +3239,7 @@ findings listed by key. Its scripts and tests are in | 10 stalled lane stop | an open pull request into main, of any author, carries a pr-unblock lane-stopped comment by `merge.agent-identity` naming its current head, or a `needs-human-cleared` comment for that head whose reason now routes to a failing status, older than 2 hours (four `pr-unblock-dispatch.yml` ticks), with no `pr-unblock / ` check run but a skip started on that head since, and no `stop-resolved` skip since: its same-head retries are spent; one issue lists each such stop | `stalled-lane-stop` | | 11 post-merge unreadable | each of the newest 4 post-merge reports (`pr-merge-post-merge-report`, kept by `post-merge-dispatch` in a trusted scheduled or manual `pr-merge` run on `main`) has exit code 3: the post-merge check could not read lane merges, so merges hold with only a warning; the issue names the newest report's reason, each monitoring run prints it as an `::error` while it holds, and it only notifies and clears on a readable report. A run that kept no report neither counts nor resets; no report within 70 minutes leaves the signal unread | `post-merge-unreadable` | | 12 listing held | each of the newest 4 `pr-merge-summary` artifacts of trusted scheduled or manual `pr-merge` runs on `main` has `listing_held: true`: the merge job could not list the open pull requests, so it gated nothing while its runs stayed green; the issue names the newest summary's `listing_held_reason`, and it only notifies and clears on a sweep that listed. A run that kept no summary neither counts nor resets. The 4 must be unbroken: a fault that lets one sweep in 4 list never fires, and that sweep does gate. A 4-of-8 rule would read 8 summaries on every monitoring run in place of 1 | `listing-held` | +| 13 lane holds | one lane has `monitor.lane-holds.threshold` held runs or more (default 4) over the last `monitor.lane-holds.window-hours` (default 24). A held run is a green run of this repository's head, on an event that runs the default branch's code, whose hold job succeeded with a hold notice: work-resolve-issue's `report-outcome / run` job naming a fault stop whose retries were all faults, work-unblock's `label-unblocked` job naming a listing it could not read, and pr-refine's `fix-docs-handoff` or `fix-docs-subscription-handoff` job naming a `fix-docs` read that failed. Each monitoring run reads the newest 6 green runs per lane that completed in its window, or since the time the last run read through when that is earlier, and carries the held runs it has found to the next run in its `monitor-signals-jobs` artifact, with the span it read them over. An issue held that often is one of its lane's held runs, and the finding names each issue held more than once. It only notifies, adds no stop and no cap, and clears once the count drops below the threshold. A rule that was not read leaves the signal unread, and so does a span shorter than the window: the span starts again when a monitoring run finds no carry, or one that read through a time more than 6 hours before its window, and after a failed read | `lane-hold:work-resolve-issue`, `lane-hold:work-unblock`, `lane-hold:pr-refine` | A rolling issue, titled `Monitoring: `, has the first body line ``; the body names the signal and its state diff --git a/docs/conventions/pr-pipeline/pr-pipeline.schema.json b/docs/conventions/pr-pipeline/pr-pipeline.schema.json index 8ea2803e185..105d4329850 100644 --- a/docs/conventions/pr-pipeline/pr-pipeline.schema.json +++ b/docs/conventions/pr-pipeline/pr-pipeline.schema.json @@ -370,6 +370,34 @@ } } }, + "monitor": { + "type": "object", + "additionalProperties": false, + "description": "The monitoring lane's thresholds. Contract: README.md, The monitoring lane.", + "properties": { + "lane-holds": { + "type": "object", + "additionalProperties": false, + "description": "Signal 13: a lane whose runs held green on a fault, with only a notice, this often raises the signal's issue. It only notifies, and adds no stop and no cap.", + "properties": { + "threshold": { + "type": "integer", + "minimum": 2, + "maximum": 100, + "default": 4, + "description": "Held runs of one lane in the window that raise the signal. At least 2, so a single hold never does." + }, + "window-hours": { + "type": "integer", + "minimum": 1, + "maximum": 168, + "default": 24, + "description": "Hours back from the monitoring run whose held runs count. The lane carries them from one run to the next in its job reads artifact." + } + } + } + } + }, "merge": { "$ref": "#/$defs/merge" }, "models": { "$ref": "#/$defs/models" } }, diff --git a/docs/outage-posture-audit.md b/docs/outage-posture-audit.md index e85880dbe9b..843b54e7f82 100644 --- a/docs/outage-posture-audit.md +++ b/docs/outage-posture-audit.md @@ -395,6 +395,13 @@ A ninth part 2 change fixed pr-refine's script gaps but one, with tests: that handed off, whose handoff job succeeded, with no next leg held. That is two more REST reads for each green run a candidate head has, until one ends the PR. An outage past that many runs still ends the PR. +The holds above end green with only a notice, so the monitoring lane's signal 13 counts them: the +`retry-spent` fault hold, work-unblock's held listings and pr-refine's held `fix-docs` reads. A +lane with `monitor.lane-holds.threshold` held runs over `monitor.lane-holds.window-hours` in +`docs/conventions/pr-pipeline.yaml` raises the signal's issue, as signal 12 does for pr-merge +(`.github/scripts/maintenance-monitor-signals/signals.mjs` `laneHoldFindings`). It adds no stop +and no cap. + Element 4 stays open: `decide.mjs` needs a kind that posts nothing, and the posting code in `report-check-run.mjs` needs to honor it (the Remaining row). A neutral check is not the fix, since babysit counts neutral as passing. A broker failure on pr-refine does not reach `decide.mjs`: off