Skip to content

Commit 7d04d73

Browse files
fix: unthrottle exact review admission
1 parent 2e6bace commit 7d04d73

11 files changed

Lines changed: 324 additions & 178 deletions

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ checkpoint, and status-only commits are intentionally omitted.
99

1010
### Changed
1111

12+
- Isolated review admission, pressure, and backpressure accounting from the publication lane so stale publication work cannot throttle review throughput, made top-level queue health review-specific, and added durable shed counters by reason.
1213
- Made exact-review reservation races and mid-generation supersession successful no-ops with bounded jittered retries, surfaced provider throttling separately from content/output failures, renewed overdue canonical records ahead of unseen backlog, and based dashboard coverage on signed live open-item inventory with explicit expired, untracked, protected, and unmanaged cohorts.
1314
- Routed scheduled review through the durable exact-review queue, raised each target plan from one to 20 candidates, and added oldest-age funnel telemetry plus a fleet-wide 200-review/hour admission budget with duplicate, backlog, and lease-safe backpressure.
1415
- Scoped per-target canonical record hydration to the selected repository and skipped unused ledger/assets downloads in workflow lanes, preventing exact-item review publication from collapsing under concurrent full-fleet state setup.

‎dashboard/exact-review-health.ts‎

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ export type ExactReviewPressureSummary = {
5353
| "no_admissible_backlog"
5454
| "dispatcher_inactive"
5555
| "handoff_unknown"
56-
| "capacity_full_with_backlog"
57-
| "publication_degraded"
58-
| "publication_critical";
56+
| "capacity_full_with_backlog";
5957
capacity: number;
6058
active: number;
6159
pending: number;
@@ -67,6 +65,13 @@ export type ExactReviewPublicationHealth = {
6765
status?: "idle" | "healthy" | "degraded" | "critical";
6866
};
6967

68+
export type ExactReviewPublicationLaneSummary = {
69+
pending: number;
70+
active: number;
71+
parked: number;
72+
oldest_pending_age_seconds: number | null;
73+
};
74+
7075
const PHASES: ExactReviewPhase[] = ["pending", "dispatching", "leased"];
7176

7277
export function summarizeExactReviewHandoff({
@@ -252,17 +257,36 @@ export function summarizeExactReviewPressure({
252257
};
253258
}
254259

255-
export function elevateExactReviewPressureForPublication(
256-
pressure: ExactReviewPressureSummary,
257-
publication: ExactReviewPublicationHealth,
258-
): ExactReviewPressureSummary {
259-
if (publication.status === "critical" && pressure.status !== "saturated") {
260-
return { ...pressure, status: "saturated", reason: "publication_critical" };
260+
export function summarizeExactReviewPublicationHealth(
261+
lane: ExactReviewPublicationLaneSummary,
262+
flow: { last_15_minutes: { net_drain_rate_per_hour: number } },
263+
): ExactReviewPublicationHealth & { reason: string | null } {
264+
const pending = nonNegativeInteger(lane.pending);
265+
const active = nonNegativeInteger(lane.active);
266+
const parked = nonNegativeInteger(lane.parked);
267+
const oldestAge = nonNegativeInteger(lane.oldest_pending_age_seconds);
268+
269+
// Dead letters and retired state-writer history are reported independently.
270+
// Neither is current publication demand, so an empty lane must stay idle.
271+
if (pending === 0 && active === 0 && parked === 0) {
272+
return { status: "idle", reason: null };
261273
}
262-
if (publication.status === "degraded" && pressure.status === "idle") {
263-
return { ...pressure, status: "congested", reason: "publication_degraded" };
274+
if (parked > 0 || oldestAge >= 6 * 60 * 60) {
275+
return {
276+
status: "critical",
277+
reason: parked > 0 ? "dead_letter_capacity" : "oldest_pending_over_6h",
278+
};
279+
}
280+
if (
281+
oldestAge >= 60 * 60 ||
282+
(pending >= 100 && flow.last_15_minutes.net_drain_rate_per_hour <= 0)
283+
) {
284+
return {
285+
status: "degraded",
286+
reason: oldestAge >= 60 * 60 ? "oldest_pending_over_1h" : "not_draining",
287+
};
264288
}
265-
return pressure;
289+
return { status: "healthy", reason: null };
266290
}
267291

268292
function exactReviewPhaseStartedAt(

0 commit comments

Comments
 (0)