fix(dispatch): Tier-3 pool sort oldest -> hybrid — honour P-level for fresh work (vc-zv4y) - #96
Merged
Conversation
bourgois
approved these changes
Jul 17, 2026
bourgois
left a comment
Collaborator
There was a problem hiding this comment.
Architect validation gate — APPROVE (vc-zv4y / ADR-0035 Fix 1)
Validated independently against the live source + CI, not against the PR summary (va-6sx discipline).
Code — CORRECT and exactly scoped
internal/config/workquery.goroutedReadyTierCommand: single-token--sort oldest→--sort hybridat the sole canonical Tier-3 site (was :133). This is ADR-0035 Fix 1 verbatim.--limit=20preserved (anti-self-block lookahead, not a priority window).- The retiring migration probe (
bdReadyPoolDemandMigrationShell, :54) and the legacygc.run_target/gc.kind=workflowfallback branch are left onoldest— correct; only the primary routed pool-demand probe flips. Verified in the golden files. - Reconciler parity held: the count-form (
poolDemandCountShell) still passes no--sort(order-irrelevant to a length), so spawn decisions are unperturbed. Documented in the new comment and unchanged in the count-form goldens.
Tests — sound and honest
internal/configpackage PASSES in CI (ok github.com/gastownhall/gascity/internal/config 3.731s).- The FIFO-pinning test
...UsesOldestBeforePriorityis correctly replaced by...UsesHybridSortHonoringPriority, and...UsesNativeHybridSortAcrossReadyTierspins the native-sort composition + first-row-only contract. - The test comment correctly scopes gascity's contract to selecting
hybrid; bd owns the ORDER BY, and the end-to-end rank re-measure (P1 49→1) is deferred to ADR-0035 AC3 (live, post-deploy) — a mock bd cannot reproduce bd 1.1.0's comparator. Right seam.
Red CI is PRE-EXISTING and UNRELATED — not a blocker here
- All
cmd/gc processshards fail only onTestClassifyProductMetricsCommandCanonicalMatrix/*;packages-core-4-of-4fails only onTestRepositoryLedgerMatchesCensusAndDocumentation. Both are command-census/ledger drift tests, untouched by this PR. - Identical failure signature appears on sibling PRs #95 and #97 (neither touches
workquery.go) ⇒ fleet-wide onVoxist/main. PR #98 ("regenerate command census") is the dedicated remedy. Voxist/gascitymain protection hasrequired_status_checks: none, so this red does not gate merge.
Branch hygiene
- head
97ceb06ais exactly 1 commit atop currentVoxist/main(behind_by=0, ahead_by=1) — no rebase, no upstream-lineage drag (the vp-zq8h trap avoided; base is the fork'smain).
Merge note (NOT deploy)
gc is self-built: merge does not reach the fleet until gc is rebuilt/redeployed (va-urb0). Per ADR-0035 AC3, do not close vc-zv4y at merge — it stays open until the live P1-rank re-measure on a rebuilt gc.
Verdict: APPROVE on merits. gascity main requires 1 review, require_last_push_approval=false — this satisfies the gate.
… fresh work (vc-zv4y) Pool dispatch (work_query Tier 3) ordered routed work strictly by created_at ASC (FIFO) and never read priority: a fresh P1 starved behind every older P2/P3 until they closed. Switch the sole canonical Tier-3 sort site (routedReadyTierCommand) from --sort oldest to --sort hybrid. bd's hybrid policy orders fresh work (<48h) by priority while draining aged work (>=48h) oldest-first, so a fresh P1 jumps ahead AND the age-based anti-starvation property that --sort oldest was chosen for is preserved. Reconciler parity held: the shared pool-demand predicate (poolDemandCountShell) passes no --sort (order-irrelevant to a length), so the reconciler spawn decision is unaffected. The retiring migration probe (workquery.go:54, ga-dhf44) deliberately stays --sort oldest. Tests: replace TestEffectiveWorkQueryRoutedQueueUsesOldestBeforePriority (which pinned the priority-blind FIFO this removes) with ...UsesHybridSortHonouringPriority; rename the native-sort composition test; regenerate the 12 workquery goldens. Verified: full internal/config package passes; bd 1.1.0 accepts --sort hybrid (negative control: invalid sort errors). ADR-0035 (docs/decisions/ADR-0035-pool-dispatch-priority-blind-fifo.md). Refs vc-zv4y.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The generic pool-worker
work_queryTier 3 (routedReadyTierCommand,internal/config/workquery.go) ordered routed pool work strictly bycreated_at ASC(--sort oldest) and never read a bead's priority, so a freshly-routed P1 starved behind every older P2/P3 until they closed — priority was decorative for the pool tier. Measured live on the city store (2026-07-17): a P1 sat at rank 49/51, outside the 20-rowgc hookwindow, sogc hook --claimdeterministically claimed a P3 filed 2026-07-01 while the P1 waited.Switch the sole canonical Tier-3 sort site to bd's
hybridpolicy: recent work (< 48h) is ordered by priority, older work (>= 48h) drains by age. This honors priority for fresh work and preserves the age-based anti-starvation drain that--sort oldestwas chosen for. Live effect: the P1 moves rank 49 → 1.Decision: ADR-0035 (
docs/decisions/ADR-0035-pool-dispatch-priority-blind-fifo.md, in voxist-city). Track 1 (fork-local); resync-debt stamps onto the bead when Track 2 (vc-ivi3, upstream PR) opens.Scope (deliberately narrow)
routedReadyTierCommandflips to--sort hybrid.workquery.go:54, ga-dhf44) intentionally stays--sort oldest.poolDemandCountShell(reconciler count-form) passes no--sortand is byte-identical ⇒ spawn-decision parity preserved (the 6*_PoolDemand_*goldens are unchanged).--limit=20(anti-self-block lookahead, not a priority window) preserved.Tests & docs
hybrid; the 12Work+RoutedPoolgoldens regenerated (PoolDemandgoldens untouched — parity).--sort oldestmust be ABSENT on the canonical tier):...UsesHybridSortHonoringPriority,...UsesNativeHybridSortAcrossReadyTiers. Migration-probe assertions left asoldest.engdocs/architecture/dispatch.mdupdated: its pool-tier description said "FIFO before priority" (the exact opposite of the shipped behavior) and is linked directly from the changed code; also corrected a pre-existing--limit=1→--limit=20drift. (ADR-0035 AC 4.)go build ./...,go vet, fullinternal/configpackage: green. TheConvoy|WorkflowServe|ControlReady|WorkQuerytests incmd/gc: green.Not in this PR (filed separately)
va-urb0), not a unit test: a mockbdcannot reproduce bd'sORDER BY; gascity's contract here is selecting the flag, which the unit tests pin.cmd/gc/dispatch_runtime.go:768-769(control-dispatcher / workflow-serve) — a genuinely distinct consumer (differentbd --readonly --sandboxinvocation, control-plane only). Filed asvc-8potofor an explicit hybrid-vs-FIFO decision rather than silently widening this diff.gcis a self-built binary; this fix reaches the fleet only aftergcis rebuilt/redeployed (va-urb0). Do not treat merge as deploy — the tracking beadvc-zv4ystays open until the live re-measure.