feat: one number per lane — the cap — and the autoscaler is the mechanism (4295)
CI and images / lint (push) Successful in 4s
CI and images / extension-version (push) Successful in 4s
CI and images / frontend-build (push) Successful in 24s
CI and images / integration (push) Failing after 24s
CI and images / backend-lint-and-test (push) Failing after 34s
CI and images / sign-extension (push) Skipped
CI and images / build-web (push) Skipped
CI and images / smoke-web (push) Skipped
CI and images / promote (push) Skipped
CI and images / build-agent (push) Skipped

Operator, 2026-09-23: *"auto should be always on, not a setting, so that idle
instances quiet down when not running. the number that is visible and
something the user can tweak and manage should be the cap itself the number of
running workers is handled by the autoscaling function which is always on."*

They are right, and the reason it was not built this way is worth stating: the
manual dial came first (steps 2-4) and the autoscaler came last (step 7), as
an opt-in BESIDE a control that already existed. Nothing ever asked whether
the dial should still exist once something could move it automatically. Each
step was defensible; the result was three operator settings over one number.

## `slots`, `enabled` and `autoscale` are gone

`slots` was a MEASUREMENT wearing a preference's clothes. How many workers a
lane runs is read live and moved every minute; storing it meant the operator
had to keep two numbers in agreement and the autoscaler had to be told it was
allowed to touch one of them.

`autoscale` gated the mechanism behind a choice, so a lane nobody opted in
never gave its workers back — which is why an idle instance never quieted
down.

`enabled` is derived: a cap of zero means no consumers. "Off" and "may use no
workers" were two spellings of one fact, stored separately, free to disagree.

## Two sweeps become one

`reconcile_lanes_sync` drove the pool to the stored `slots`; `autoscale_lanes_
sync` moved it away from that same number; and most of step 7's hardest
reasoning — a stored value that is a FLOOR, a target of `max(stored, current)`
— existed only to stop them fighting. Delete the stored number and the problem
is not solved, it is absent.

`size_lanes_sync` runs every minute and owns both consumers and pool size. It
also subsumes what the reconcile was for: a worker restarted at its ENV
concurrency is corrected on the next tick rather than after five.

Growth is immediate, shrink is one worker per tick. Deliberately asymmetric —
"always on" is only pleasant if the ramp keeps up, and +1/minute would take
four minutes to answer a burst. Being one worker too large for a minute costs
a sleeping process; being too small costs work not happening. For ML the
asymmetry matters most: every new slot reloads a multi-GB model, so the slow
shrink is what stops a quiet patch from paying that cost again a minute later.

## The caps ship at one, and zero for ML

Per the operator. Conservative on purpose — and a conservative default nobody
knows how to raise is just a slow product, which is the other half of what
they asked for:

    "there needs to be something that tells the user to bump those numbers to
     improve processing rate or they'd never know the controls exist."

So a lane running everything its cap allows while work piles up says so, in
its own row, with the headroom named: *"4,060 waiting and all 1 worker busy.
Raise the cap to run more at once — this machine allows up to 7."*

It fires only when raising the cap would actually help. Not when the lane is
keeping up, not when the sizing pass has room it has not taken, and not at the
machine ceiling — where "raise the cap" is advice nobody can take.

## Migration 0105 rewrites the caps rather than carrying them

The old defaults (4/2/2/1) bounded a manual control and were loose because
moving within them was the ordinary act. The number now means "the most
workers this lane may use", which is a different promise; carrying the old
figure over would quadruple the worker lane on every existing install at the
moment this deploys.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LVjrnpQjRgHdvq95rASoiR
This commit is contained in:
2026-09-23 12:48:22 -04:00
co-authored by Claude Opus 5
parent abe16aa382
commit 445164c852
16 changed files with 1110 additions and 1271 deletions
+71 -7
View File
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest'
import { mergeParts, queueKey } from '../src/utils/systemParts.js'
import { laneAdvice, mergeParts, queueKey } from '../src/utils/systemParts.js'
// The System tab's one table (operator 2026-09-23: "combine the two sections
// into a single table"). What is pinned here is the JOIN, because its failure
@@ -25,9 +25,8 @@ const LANE = {
// sorted. If the join ever compares these two lists directly rather than as
// sets, this fixture is what catches it.
queues: ['default', 'import', 'thumbnail', 'download'],
slots: 2,
slots_cap: 4,
autoscale: false,
ceiling: 8,
live: { present: true, replicas: 1, pool: 2, active: 0 },
pending: 0,
}
@@ -71,7 +70,7 @@ describe('mergeParts', () => {
// is exactly the one with no roster entry.
const ml = {
...LANE, name: 'ml', display_name: 'ML tagging', queues: ['ml'],
slots: 0, optional: true,
slots_cap: 0, optional: true,
live: { present: false, replicas: 0, pool: null, active: 0 },
}
const rows = mergeParts([POSTGRES], [ml])
@@ -81,15 +80,15 @@ describe('mergeParts', () => {
expect(row.kindLabel).toBe('optional lane')
})
it('does not call a lane at zero slots broken', () => {
it('does not call a lane capped at zero broken', () => {
// The roster only knows a heartbeat age, so it goes on saying "is running"
// for a lane the operator deliberately dialled to nothing. The lane knows
// the difference; reporting the operator's own choice as a fault is how an
// indicator stops being read.
const off = { ...LANE, slots: 0 }
const off = { ...LANE, slots_cap: 0 }
const row = mergeParts([PART], [off])[0]
expect(row.detail).toBe('off — no slots')
expect(row.detail).toBe('off — cap is zero')
})
it('puts the broken thing first, whatever it is', () => {
@@ -126,3 +125,68 @@ describe('mergeParts', () => {
expect(mergeParts(undefined, undefined)).toEqual([])
})
})
// The nudge. Operator, 2026-09-23: *"there needs to be something that tells
// you user to bump those numbers to improve processing rate or they'd never
// know the controls exist."*
//
// The caps ship at one of each, so on a busy instance the SHIPPED
// CONFIGURATION is the bottleneck. What is pinned here is that it fires only
// when raising the cap would actually help — a notice on a lane that is
// keeping up, or one already at the machine's limit, is a notice people learn
// to scroll past, and at that point it is worse than not having it.
describe('laneAdvice', () => {
const busyAtCap = {
slots_cap: 1, ceiling: 7, pending: 4060,
live: { present: true, pool: 1, active: 1 },
}
it('speaks when the cap is the limiting factor', () => {
const advice = laneAdvice(busyAtCap)
expect(advice).toContain('4,060 waiting')
expect(advice).toContain('Raise the cap')
// The headroom, so it is an instruction rather than a complaint.
expect(advice).toContain('7')
})
it('says something different about a lane that is switched off', () => {
const advice = laneAdvice({ ...busyAtCap, slots_cap: 0 })
expect(advice).toContain('this lane is off')
})
it('stays quiet when the lane is keeping up', () => {
expect(laneAdvice({ ...busyAtCap, pending: 2 })).toBeNull()
})
it('stays quiet when the cap is not the thing holding it back', () => {
// Four allowed, two running — the sizing pass has room it has not taken,
// so the queue is not the cap's fault.
expect(laneAdvice({
...busyAtCap, slots_cap: 4, live: { present: true, pool: 2, active: 2 },
})).toBeNull()
})
it('stays quiet at the machine ceiling, where the advice is untakeable', () => {
// The one case where saying "raise the cap" would send someone to a
// control that will refuse them.
expect(laneAdvice({ ...busyAtCap, ceiling: 1 })).toBeNull()
})
it('stays quiet about a lane that is not answering', () => {
// An unswept read is not a verdict: nothing replied, so "all workers
// busy" is a claim nobody made.
expect(laneAdvice({
...busyAtCap, live: { present: false, pool: null, active: 0 },
})).toBeNull()
})
it('stays quiet when the backlog is unknown rather than reading it as huge', () => {
expect(laneAdvice({ ...busyAtCap, pending: null })).toBeNull()
})
it('says nothing about a row that is not a lane at all', () => {
expect(laneAdvice(undefined)).toBeNull()
})
})