"""worker_lane_sample — where the sizing sweep leaves what it measured. Operator, 2026-09-23, on the System tab: *"there is a repull every time this page loads — is there a reason this info isn't being tracked in the background and stored in some way?"* `/api/system/workers` ran a full celery inspect on every call — four broadcasts on an eleven-second budget — and the page polls it every fifteen seconds. `size_worker_lanes` was already inspecting on a timer to decide pool sizes, computing exactly these numbers and discarding them. This table is where they land instead, and the endpoint becomes a plain read. ## Why a new table rather than columns on `worker_lane` `worker_lane` holds the one number an operator sets. Putting a measurement beside it is the mistake alembic 0105 undid: `slots` sat next to `slots_cap`, and a measurement next to a preference reads as a second preference. No backfill. A row appears when the sweep first runs (within its period), and until then the lane reads as not-yet-measured, which is true. Revision ID: 0107 Revises: 0106 Create Date: 2026-09-23 """ from typing import Sequence, Union import sqlalchemy as sa from alembic import op revision: str = "0107" down_revision: Union[str, None] = "0106" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.create_table( "worker_lane_sample", sa.Column("lane", sa.String(length=32), primary_key=True), # Nullable=False with no server_default: the sweep writes every column # on every upsert, so a row only ever exists complete. sa.Column("present", sa.Boolean(), nullable=False), sa.Column("replicas", sa.Integer(), nullable=False), # Nullable on purpose — unknown, never zero. A worker that answered # without reporting its pool, and a queue the broker did not answer # for, must not be summed as empty. sa.Column("pool", sa.Integer(), nullable=True), sa.Column("active", sa.Integer(), nullable=False), sa.Column("reserved", sa.Integer(), nullable=False), sa.Column("queue_depth", sa.Integer(), nullable=True), sa.Column( "measured_at", sa.DateTime(timezone=True), nullable=False, server_default=sa.func.now(), ), ) def downgrade() -> None: op.drop_table("worker_lane_sample")