Skip to content

fix(showcase): cold-load gray chip was masking genuinely-red cells - #6156

Merged
jpr5 merged 14 commits into
mainfrom
fix/cold-load-gray-masks-red
Jul 26, 2026
Merged

jpr5 merged 14 commits into
mainfrom
fix/cold-load-gray-masks-red

Conversation

@jpr5

@jpr5 jpr5 commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Scope, stated up front. This PR fixes one of the ways a genuinely-red
showcase cell can render as something other than red: the cold-load signal
polarity. It does not eliminate the symptom. Nine further masking
mechanisms remain
and are enumerated, with measured counts, under
What this PR does NOT fix. Please read that
section before treating a green dashboard as evidence of a green fleet.

The bug

Absence of evidence about why a cell failed was erasing the fact that it failed.

classifyRung opened its red branch with:

if (!raw.signalKnown) {
  return { ...base, contribution: "NO_DATA", rawStatus: null };
}

signalKnown is false when the dashboard's bulk fetch projected the signal
blob away. So a genuinely RED rung whose infra-vs-product attribution was merely
PENDING got classified NO_DATA and painted gray
— the muted "no live probe
data" treatment — while the depth strip beside it, built from the raw fold,
correctly rendered 1P ✗. One model object simultaneously said d5.status === "red" and chipColor === "gray".

Two things make that polarity wrong:

  1. signalKnown === false never meant "known to have no signal." PocketBase
    omits the signal key only under a fields= projection; a row that
    genuinely has no signal arrives as null, and null !== undefined. The flag
    is pure provenance: "this row came from a projected fetch." It was never
    evidence the failure was infra.
  2. The guess was wrong on the overwhelming majority. Of the non-green rows in
    production, 94.2% are product-class and 5.8% infra-class (measured today
    against prod PocketBase using the classifier's own imported
    signalHasInfraErrorClass predicate: 3082 rows, 359 red, 21 infra-class —
    driver-error 11, abort 10 — 338 product-class). Graying every unattributed
    red lost 338 real failures to suppress 21 false alarms. A masked red is never
    investigated; a false alarm is looked at once and closed.

This was not a first-paint race. The gray state is a fully-rendered,
confident-looking wrong answer that persists until the probe's next sweep rewrites
that specific row and the SSE delta redelivers it with signal, and it recurs on
every reload, because the projection strips signal unconditionally.

Worst case for the routine per-cell dimensions is ~60 min, from the hourly
e2e-demos / starter_smoke / d6-all-pills-e2e crons in
harness/config/probes/*.yml; drift dimensions are effectively unbounded. (An
earlier revision of this body claimed "~29 min observed, ~14 min mean". Both were
withdrawn during review: "~29 min" was derived from the */30 tier and missed the
hourly tier entirely, and "~14 min mean" had no derivable basis. Do not cite them.)

Measured effect

PR #6169's exhaustive sweep — 279,936 rung combinations (7 status rows × 6 row
variants), the same map fed to the pre-fix and post-fix engines and diffed
field-by-field — puts the direction of this change beyond argument:

  • 74,256 cells change, and every one moves toward more red.
  • Zero flips toward less red: no red→gray, no red→green, no amber→green
    anywhere in the diff.
  • INV2–INV6 hold across the full sweep on the branch engine (0 violations).

Red-green on live production data (local next dev wired to prod PocketBase,
driven with Playwright, screenshots visually inspected — DOM measurements alone are
not trusted for visual verification; both captures back-to-back on the same
underlying rows, only the code changing):

Band before after
green 632 632 — unchanged, no green regression
amber 0 0
red 0 51
no data 76 25

0 red → 51 red, 76 → 25 no data — 51 recovered, arithmetic closes. Red on
first paint, no gray plateau.

The fix — two parts

(a) Flip the fail-safe polarity — cell-model.contribution.ts

A red rung with unknown infra-ness now classifies FAIL_FRESH. Graying a red
requires positive infra evidence: hasNonInfraRed is false only when every
contributing red row's blob actually carries an INFRA_ERROR_CLASSES attribution,
and signal-provenance is retained as an explicit second precondition so a missing
blob can never be read as an infra attribution even if signalHasInfraErrorClass
is loosened later.

if (fold.redSignalKnown && !fold.hasNonInfraRed) {
  return { ...base, contribution: "INFRA_RED_FRESH", rawStatus };
}

redSignalKnown is derived inside foldFamily's red-row bookkeeping, not
family-wide, so a projected-away GREEN sibling cannot suppress a legitimate infra
gray. (The original family-wide flag made INFRA_RED_FRESH effectively
unreachable in the browser for every multi-row family — D4, any multi-pill
D5/D6; only single-key D3 was unaffected, which is why every pre-existing fixture
missed it. Fixed by round-1 unit G1.)

This is the durable fail-safe: any future projection or fetch regression now
degrades toward over-reporting failure rather than silently hiding it.

(b) Make first paint correct — useLiveStatus.ts

The supplemental signal fetch is widened from the comm-error aggregates to a
union: the existing clause OR state != "green".

before: filter=(dimension = "d6" || … || dimension = "d5-single-pill-e2e") && key !~ "%/%"
after:  filter=((dimension = "d6" || … || dimension = "d5-single-pill-e2e") && key !~ "%/%") || (state != "green")

The existing fetch was not a viable vehicle as-is: it excluded these rows twice
over — dimension d5 is absent from FLEET_COMM_AGGREGATE_DIMENSIONS entirely,
and its key !~ "%/%" predicate excludes every per-cell ladder-rung key.
Relaxing only the %/% predicate would still have missed them.

Why widen the existing fetch rather than add a second one: it reuses the
freshness guard (supplementalRowIsOlder) and the chimera-avoidance merge
verbatim — that merge already reasons carefully about a newer bulk row vs an older
signal-bearing twin, and duplicating it would be the risky part. It also keeps
first paint at one extra request instead of two.

Why scope by STATE, not by key: signal-provenance is consulted only in
classifyRung's red branch — green and degraded paths never touch it — so only
non-green rows can change a chip verdict. != "green" rather than an explicit
red/degraded list is deliberate: it also catches an out-of-vocabulary state, which
rankOfState ranks worst — so the rows that matter most can never fall outside
the fetch. The comm-error clause is kept as an independent disjunct, not replaced:
a green aggregate row can still carry an active comm-error blob.

The fetch is page-capped at MAX_INITIAL_FETCH_PAGES = 20, projected to
STATUS_LIST_FIELDS,signal, and non-fatal at the fetch site — truncation is handled
asymmetrically: supplemental truncation degrades (warn, use what arrived), bulk
truncation throws. (Round-1 unit FETCH; the fetch was originally unbounded, and its
rejection propagated to setRows([]), so an enrichment failure blanked the whole
matrix.)

Rejected: suppressing the chip while pending. A blank or spinning chip for up
to an hour on a large slice of the matrix hides reds exactly as effectively as a
gray one, while additionally looking broken.

What each part buys

Real engine over all 3082 production rows, three wires built from the identical
row set (green / amber / red / gray over the 708 catalog cells the band counts):

Wire pre-fix engine post-fix engine
FULL (server / /api/matrix) 596 / 37 / 51 / 24 596 / 37 / 51 / 24
COLD, pre-fix projection 596 / 0 / 0 / 112 596 / 37 / 51 / 24
COLD, post-fix projection 596 / 0 / 49 / 63 596 / 37 / 51 / 24
  • The pre-fix browser wire collapsed 88 cells (51 red + 37 amber) into gray.
    The entire red and amber population was zeroed, because the !signalKnown
    early return preempted FAIL_FRESH, FIRST_STRIKE_FRESH and
    INFRA_RED_FRESH alike.
  • (b) alone is not sufficient: it recovers 49 of 51 reds and zero of the
    37 ambers, leaving 39 cells still mis-painted.
  • (a) is what delivers correctness — with it, all three wires equal server
    truth exactly.
  • (b) is what keeps (a) from having to guess. Today (a)-alone happens to cost 0
    false-positive cells, because no cell's verdict-determining rung is currently a
    pure infra red. That is luck, not a guarantee: prod holds 21 infra-classed red
    rows. (b) supplies the actual evidence so those stay correctly gray, and it also
    feeds decodeCellCommError for non-green per-cell rows.

Value test — per cell, all 6 (≥3 required)

Every affected cell verified individually, not inferred from a shared symptom.
Live DOM on the real surface, plus the real engine driven offline over all 3082
production rows through faithful replicas of the pre- and post-fix browser wire:

Cell (d5:<slug>/multimodal) PB row Server truth Cold PRE Cold POST Live chip PRE Live chip POST Flipped
agno red, fc 1817 red gray red gray D4 + 1P ✗ red D4 ✅
crewai-crews red, fc 1716 red gray red gray D4 + 1P ✗ red D4 ✅
llamaindex red, fc 2005 red gray red gray D4 + 1P ✗ red D4 ✅
mastra red, fc 1806 red gray red gray D4 + 1P ✗ red D4 ✅
ms-agent-python red, fc 1710 red gray red gray D4 + 1P ✗ red D4 ✅
built-in-agent red, fc 1803 red gray red gray D4 + 1P ✗ red D4 ✅

6/6 flip. All six are errorClass: conversation-error — a real probe conversation
failure, not in INFRA_ERROR_CLASSES, so FAIL_FRESH is the correct
classification. (Prod figures; built-in-agent is green on staging, so staging
shows 5.)

Depth distribution is byte-identical across the pair (D6:632 D5:0 D4:71 D3:0 D0:5 both times). The fix changes only the colour, never the depth — the D4
label on these chips was always correct, so this must not be mis-validated by
looking for a depth change.

Tally-site audit

Every tally is downstream of chipColor, so all self-correct — none needed
refactoring. All verified on the live surface post-fix:

Site Mechanism Pre-fix Post-fix Verified
feature-grid.tsx computeColumnTally gray-skip ✗ 0 ✗ 8 (Agno) ✅ header DOM
feature-grid.tsx computeColumnTallyDetail gray-skip empty list 8 features incl. Attachments ✅ panel opened via tally-trigger-red
page-stats.ts computeHealthStats case "gray": noData++ 0 red / 76 no data 51 red / 25 no data ✅ band DOM + screenshot
page-stats.ts computeDepthDistribution — (no gray gating at all) D4:71 D4:71 ✅ unaffected
page-stats.ts computeD6Stats d6Effective null → gray "red" → red ✅ golden fixture

No other chipColor consumer changes behaviour. d0-gone-predicate.ts gates
the outage alerter on chipColor === "red", but d0-gone-monitor reads full rows
with signal
, so provenance is always known there — as it is for /api/matrix.
The polarity flip is reachable only where rows are projected, i.e. exclusively
the browser cold-load path.

A test asserted the buggy behaviour

api-matrix-equivalence.test.ts asserted:

expect(serverChip).toBe("red");
expect(coldLoadChip).toBe("gray");
expect(serverChip).not.toBe(coldLoadChip);

commented as "the state the browser converges to after its supplemental signal
fetch … the more accurate answer." That comment is factually wrong — the
supplemental fetch resolved in ~1 s and structurally excluded those rows twice over
— and the assertion pinned the defect as intended behaviour. This is why CI never
caught it.
Read in full, it is asserting the defect, not an adjacent legitimate
case: the fixture is a genuine product red (errorDesc: "assertion failed: wrong answer", no infra class) with signal: undefined on the red rung.

Inverted to assert red on both paths, with the fail-safe direction explained
inline. Same for the harness's §7 I5 case (cell-model-v2.test.ts) and
classifyRung's unit case. Four golden-master fixtures
(pos-d{3,4,5,6}-red-signal-unknown) re-frozen.

Negative controls added so the flip can't over-reach: an infra-classed red still
grays (positive evidence present), and §7 I4 (infra-only red → gray,
isRegression false) still passes untouched.

The structural lever: coherence invariant INV7

cell-model.coherence.test.ts asserted INV1–INV6, all of which relate chipColor
only to the other chip-side outputs. None inspected the d3/d4/d5/d6
depth pills.
So the engine could return one object saying both d5.status === "red" and chipColor === "gray" with every invariant intact — which is exactly
what happened, on every cold load.

INV7: a gray chip above a red depth pill requires positive infra evidence on
every contributing red row.
Red-greened against the old polarity — it fails on 3
fixtures with a legible message:

pos-d5-red-signal-unknown: INV7 gray chip over a red pill requires POSITIVE infra
evidence on every red row — d5:acme/agentic-chat has none (signal STRIPPED (pending)).
A red whose cause is merely unknown must render red, not gray.

It closes the gap in the only safe direction: by fixing the chip upward, never
by muting the strip. Deriving the pills from the classified contributions — the
superficially cleaner unification — would render 1P ✗ as 1P ? on cold load and
destroy the only on-page element that was telling the truth, converting a visible
inconsistency into an invisible failure.

INV7's own limitations are disclosed under
Known limitations of the guards themselves.


Review-round fixes folded in

Three full 12-reviewer review rounds were run against this branch. Round 1
contributed five units plus an integration fix; round 2 contributed four more. The
loop was deliberately stopped after round 3 by explicit decision rather than
running a fourth; round 3's findings are catalogued (132 items in
DEFERRED-r3.md) and routed to the follow-up epic, not silently dropped.

Round 1 — five units

# Commit Concern Surface
G1 2a68282d Signal-provenance was derived family-wide but gated a red-row-scoped predicate. Precondition moved into foldFamily as redSignalKnown; RawRung.signalKnown removed entirely with all its plumbing. production + tests
A5 ebd7ac68 The autocancel fake servers ignored filter/fields, so the supplemental fetch's leftover-append silently repaired a dropped bulk page — three pagination guards passed under every mutation. Servers rebuilt to evaluate the query. test-only
FETCH f5178765 The supplemental fetch was unbounded (for(;;)), unprojected, and its rejection propagated to setRows([]). Now capped, projected, and non-fatal at the fetch site. production + tests
INV7 3dea9f64 INV7 was quantified over the whole live map rather than the cell's contributing keys, and had no isStaleCell carve-out — it failed two classes of legitimate rendering. Scoped, exempted, plus an anti-vacuity guard. test-only
DOCS 2797618c Stale/unanchored numeric claims (row counts, byte estimates, re-delivery window) corrected against production and given their source queries. comments only
— 938be2ac Integration fix. A5 and FETCH disagreed about how a supplemental request is identified; all three fake servers misclassified it as a bulk page and the whole autocancel suite failed 3/3. Both dashboard suites now key on signal being IN the projection. test-only

Round 2 — the four integrated units

Integrated in order Q2 → Q1 → Q3 → Q4. Every guard was re-mutated after
integration and reproduced its pre-integration result; no guard was disarmed by
the merge.

# Commit(s) Concern What it proved Surface
Q2 b8b75b7d The dashboard's useLiveStatus test doubles carried three divergent implementations of the same PocketBase query evaluator, and the nominally-shared one was the weakest. Collapsed to exactly one, every semantic a measured observation from a real PocketBase v0.22.21 server. Deleted autocancel's 380-line private copy. evaluatePbList cannot throw, so a parse error can no longer send NO response and hang the hook to a 20 s waitFor death. Six mutations (short page dropped in wave merge, boundary logic removed, merge order reversed, supplemental filter broken, supplemental filter widened to "", bulk filter selects nothing) each reproduced their pre-integration RED count exactly — 3/1/2/6/5/6 failures. The consolidated evaluator is strictly stronger, not merely shorter. test-only (−488 lines net in the doubles)
Q1 75fdfb3a + ed10b61f truncated meant "cap exhausted", so a complete read that happened to end exactly on the cap page was reported as truncated — the bulk caller threw, burned its reconnects and landed on a blank dashboard behind an offline banner, on every retry and every reload. truncated now means exactly "there are rows we did not read", proven by ONE lookahead read of page cap+1 whose rows are discarded and only whose emptiness is load-bearing. Algorithm hoisted to an exported paginateStatusPages(readPage). Lowering the cap 20→10 and 20→5 each produces 10 failed / 6 passed, where the pre-fix code was 6/6 GREEN — i.e. the guard was previously disarmed. A complete 10,000-row dataset renders live, truncated === false, seeded red cell still chipColor: "red", page set exactly [1..21]; 10,001 rows still throws with status: "error" and "exceeded" in the message. production + tests
Q3 49dea099 INV7 false-failed on the ordinary I1 ladder-gap shape ("no e2e: row + red chat:<slug>"). Added a carve-out keyed on ladderGapDepth, one-directional (a gap above the red excuses nothing) and never firing without a witness rung — plus a two-sided canary that fails loudly the moment the underlying gap-break is fixed. Deleting the isStaleCell exemption fails exactly the U8 force-gray case (the exemption is load-bearing, not decorative). Changing the engine's gap-break break → continue fires the two-sided canary with its intended message (expected 'red' to be 'gray') — so the allowance cannot go on silently excusing a shape the engine no longer produces. Gapless and gap-above-red incoherence still FAIL; the legitimate gap shape still PASSES. test-only
Q4 b04330ab Three explicitly load-bearing family folds were invisible at golden-master level — maxNonInfraRedFailCount's MAX, allRedSoftClass's EVERY quantifier, and redSignalKnown's RED-ROW scope — because no fixture anywhere carried two differing red rows. 5 new fixtures, baseline 56→61, 140 insertions / 0 deletions. Each of three mutations now fails via exactly one fixture: Math.max→Math.min ⇒ hetero-d4-red-failcount-max; every→any ⇒ hetero-starter-mixed-soft-hard; redSignalKnown red-row→family scope ⇒ hetero-d4-green-stripped-infra-red. Precise attribution, not a shotgun. test-only

One merge conflict, in useLiveStatus.supplemental-bounds.test.tsx: Q2 deleted the
file-local classifyRequest helper on the same lines where Q1 added its new
PAGES_THROUGH_LOOKAHEAD constant. Resolved by keeping both intents rather than
taking a side.

Baseline golden-master key count is 61, and the completeness check (has exactly one baseline entry per fixture (no stale/missing)) runs, so a fixture added without
a baseline entry fails rather than being skipped.


What this PR does NOT fix

This PR does not fully eliminate the original symptom. It fixes the
signal-polarity masking mechanism and makes the cold load correct. A genuinely-red
cell can still render gray, green, or amber by nine other routes. All nine were
found by review of this branch and are catalogued, not speculative.

Quantified by the #6169 sweep (279,936 combinations)

Mechanism Rung combinations
M1 — ladder gap-break: scanWorst folds the FIRST ABSENT/STUB rung as ABSENT and breaks, so a fresh non-infra RED on a rung above the gap is never folded and paints gray 17,088
M2 — D6 outside the scanWorst walk: a red D6 never reaches the chip 2,048
M3 — gap not below the red: the remaining gray-over-red shapes 192
19,328 total, 0 unexplained

M1 is highly reachable in practice: chat:<slug> / tools:<slug> are
integration-scoped, so one red chat: row plus an unemitted e2e:<slug>/<featureId>
row (new feature, rotation slot, D3 driver never ran) is a gray chip over a red D4
pill. combine.ts is deliberately untouched here — fixing any of M1–M3 re-verdicts
cells across the matrix and therefore needs its own PR with a golden-master
baseline re-freeze and a live value test. Q3's INV7 carve-out is silent about
M1 on purpose and only about that, and its two-sided canary is the tripwire that
forces the carve-out to be deleted the moment M1 is actually fixed.

Found in round 3, not quantified by the sweep

  1. Prototype-chain property lookups invert the anti-masking guard.
    STATE_RANK / rankOfState, WORST_STATE_RANK / worstStateRank,
    firstStrikeConfig[kind] and CATALOG_TO_D5_KEY are plain object literals read
    without an own-property guard, so a runtime value colliding with an
    Object.prototype member (constructor, toString, valueOf, …) resolves to an
    inherited function that the ?? fallback then never replaces. For rankOfState
    the out-of-vocabulary guard inverts — an unknown state, which the code
    deliberately ranks worst, instead classifies as an infra red and grays;
    worstStateRank silently swallows the row entirely. CATALOG_TO_D5_KEY is
    unguarded at four further sites in cell-model.ts, where the consequence is a
    whole-matrix render crash. Fix is Object.prototype.hasOwnProperty.call (or
    a prototype-free table) at each site.

  2. Wave truncation bypasses the fail-loud throw entirely. In the fan-out merge,
    a short page inside a wave causes every page issued after it in the same wave
    to be discarded — sound for a stable collection, but the pages resolve
    concurrently against a table the harness writes continuously. The discard
    produces no log, no warning, no counter, no degraded flip, and truncated
    stays false
    because it is only ever set by the cap lookahead. So the bulk
    caller's deliberate "a truncated BULK read cannot degrade gracefully … throw"
    posture fires only for cap exhaustion, never for this class of loss. The missing
    rows render as absent, which buildCellModel resolves to ABSENT / NO_DATA
    and paints gray — the exact polarity this PR exists to remove. INITIAL_FANOUT_BATCH
    is documented as "purely a WIRE-EFFICIENCY knob" but is load-bearing for
    correctness: at a larger batch the loss is INITIAL_FANOUT_BATCH - 1 pages.

  3. INITIAL_PAGE_SIZE above the server clamp grays ~6/7 of the matrix.
    Termination is the client-side comparison first.length === INITIAL_PAGE_SIZE,
    correct only because PocketBase clamps perPage to 500 server-side. Raise the
    constant — the obvious "fewer round-trips" tuning, which the surrounding comment
    invites — and every page returns 500, i.e. short, so the loop stops after page
    1 and returns ~500 of ~3100 rows with truncated: false. The bulk caller sees a
    complete read, never throws, and ~6/7 of the matrix renders no-data gray with no
    warning and no banner. The truncated contract cannot catch it because the read
    genuinely never hit the cap.

  4. An empty bulk page 1 publishes live with 0 rows. paginateStatusPages
    returns {rows: [], truncated: false} for an empty collection and connect()
    then does setRows([]) + setStatus("live") + setError(null) with no
    empty-collection guard. Every cell renders no-data gray behind a healthy "live"
    indicator. Untested — the smallest fixture anywhere in these files is 3 rows.
    The server-side analogue is already a known deferred item.

  5. First-strike de-amplification fires at fail_count === 0, painting a genuine
    red AMBER.
    The gate is maxNonInfraRedFailCount < threshold with threshold
    2, so fail_count of 0 de-amplifies exactly like 1 → FIRST_STRIKE_FRESH →
    amber, i.e. "transient, not yet actionable". The threshold's semantics are valid
    only if a red row's fail_count is always ≥ 1, which is asserted as a producer
    property and enforced nowhere on the read side; out-of-vocabulary states (the
    harness can persist "error" as a no-data marker, which rankOfState ranks above
    red) and back-filled or externally-written rows both reach the classifier at 0. A
    fail_count of 0 on a red row is not positive evidence of a first strike. The
    golden master cannot see it: every red-bearing fixture uses
    fail_count: opts.failCount ?? (isRed ? 1 : 0), so no fixture puts a red row at 0.

  6. An infra-red or degraded D1/D2 over a green ladder paints chip=green,
    achieved=6.
    combine.ts's §F gate fires only on contribution === "FAIL_FRESH"
    in both the achieved-depth walk and computeChip step 1; INFRA_RED_FRESH and
    DEGRADED fall through as non-gating, so the cell keeps its green ladder verdict
    with d6Effective: "green". Measured on the branch engine: D1 infra-red (driver-error) + green D2 → chip=green ach=6 reg=false d6Eff=green, and the same
    for D1 degraded. Mutation-proven invisible to the golden master: patching
    both §F gate sites to also fire on INFRA_RED_FRESH and DEGRADED — a
    materially different verdict for every column whose health probe is failing —
    leaves all 61 baseline entries byte-identical. health:<slug> / agent:<slug>
    are integration-scoped, so this is whole-column. The polarity flip closed the
    signal: undefined hole here and left the driver-error / abort hole wide open
    — and driver-error / abort on a health probe is precisely what an unreachable
    container or a cancelled sweep produces.

Known limitations of the guards themselves

Disclosed rather than omitted. These are properties of this PR's own tests.

  • INV7's Q3 carve-out does not cover the M2 shape. It is keyed on
    ladderGapDepth and excuses only a gap strictly below the shallowest red pill,
    which is M1. The D6-outside-the-walk shape (M2, 2,048 combos) is a different
    mechanism and is not addressed by the carve-out.
  • The starter-axis INV7 canary short-circuits and proves nothing.
    assertChipStripCoherent returns immediately on m.chipColor !== "gray" || redDepth === null. The hard-red starter cell the test builds has chipColor === "red", so the function returns on the first disjunct — not on the
    strip condition the comments claim. The call would pass identically if a starter
    cell did expose a red depth strip. The canary role is actually carried by the
    four lvl.exists === false / lvl.status === null assertions beside it; the
    assertChipStripCoherent call adds nothing. Compounding it, stripReadsRed — the
    identifier the comments reason about — does not exist anywhere in the repo.
  • The five INV7 "teeth" assert /INV7/, which the drift-guard message also
    matches.
    assertChipStripCoherent raises two structurally different failures
    and both messages contain the literal INV7: the keyspace-drift guard, and the
    real coherence failure. Every teeth test asserts only .toThrow(/INV7/). So if
    contributingKeys ever drifts from the engine keyspace — collectAgentLadder
    gains a rung, CATALOG_TO_D5_KEY fan-out changes shape, a keyFor segment changes
    — redRows goes empty, the drift guard fires, and all five teeth still pass
    while INV7 has gone vacuous over the entire fixture matrix. That is precisely the
    state the drift guard was written to make impossible; it is silenced inside the
    only tests that reach it. The fix is to assert the specific message
    (/requires POSITIVE infra evidence/) and pin the drift message in its own case.
  • The test double cannot express absent-vs-null projection provenance.
    applyPbFields silently drops projection tokens it does not model, so the fake
    cannot distinguish a key omitted by a fields= projection from a key present
    with value null — which is the single distinction redSignalKnown rests on.
    Fixtures therefore cannot validate the provenance semantics the fix is built on;
    that validation lives only in the live red-green capture above.

Follow-ups

Quality gate

Re-run at head b04330ab in a clean detached worktree.

  • [email protected] --check: clean — "All matched files use the correct format" (16
    changed TS/TSX files)

  • [email protected] (repo .oxlintrc.json): 5 warnings, 0 errors. 4 of the 5
    reproduce verbatim on the origin/main versions of the same files
    (unicorn(consistent-function-scoping) on c, eslint(no-shadow) on rows,
    unicorn(no-array-reverse), typescript-eslint(consistent-type-imports)). The one
    net-new against origin/main is a second
    unicorn(consistent-function-scoping) warning, on the test-local helper lvl in
    cell-model.coherence.test.ts. Zero errors; the repo's oxlint CI job is green.

  • tsc --noEmit: 0 errors in shell-dashboard; harness clean under
    tsconfig.build.json. harness's tsc --noEmit reports one pre-existing error,
    frontend-matrix.test.ts resolving ../../../shell/src/data/frontend-catalog.json
    — a stale path in a file byte-unchanged from origin/main.

  • shell-dashboard tests (measured locally at b04330ab): 71 files / 1407
    passed / 1 skipped / 0 failed.
    Scoped to src/;
    tests/runtime-env-switch.spike.test.ts was deliberately not run (it spawns
    next build plus two next start invocations and is not a unit test).

  • harness tests (measured locally at b04330ab): 3659 passed / 18 skipped /
    3 failed
    — the same three pre-existing D5 fixture-registry-drift failures, in
    files byte-unchanged from origin/main and driven entirely by inputs none of
    this PR's 17 files touch:

    • frontend showcase matrix > plans every runnable catalog cell without loss or duplication — expected 664 to have a length of 660
    • d5-mapping-drift > dashboard CATALOG_TO_D5_KEY structurally mirrors harness REGISTRY_TO_D5 — the drift regex cannot locate CATALOG_TO_D5_KEY in shell-dashboard/src/lib/live-status.ts (a 675-byte re-export shim on main, not modified here)
    • D5_REPRESENTATIVES > covers every D5FeatureType that has a registered script — missing browser-use-smoke

    Those three are now explicitly quarantined by the test / unit-showcase
    workflow that landed on main in 7282ecddfb
    (showcase/harness/vitest.quarantine.json), and that workflow's quarantine
    ratchet
    re-runs each one to confirm it still fails — so they neither hide nor
    block. At this PR's head the ratchet passes: Quarantine ratchet OK: all 3 quarantined file(s) still fail.

  • Diff hygiene: no lockfiles, no generated src/data/*.json.

CI provenance — this is the PR's first honest CI

main has been merged in at 7282ecddfb (merge commit 12ea621a, textually
clean, zero conflicts; the 13 commits above are unrewritten). This matters for more
than being up to date: the harness unit suite and shell-dashboard unit suite
jobs did not exist at b04330ab, because the workflow that enables them landed
on main afterwards and GitHub runs pull_request workflows from the PR head. The
earlier "17 pass" therefore ran none of the ~5,000 tests covering this PR's own
subject matter (cell-model/* and useLiveStatus*).

  • CI at this head (12ea621a): 21 pass / 0 pending / 0 fail across 24 registered
    rows.
  • Both new jobs run and both pass — shell-dashboard unit suite 70 files / 1404
    passed / 1 skipped
    , harness unit suite green, quarantine ratchet OK.
  • The Q1–Q4 guard battery (16 re-proofs) was re-run at the merge head and
    reproduced its pre-merge numbers exactly, so nothing was disarmed by the merge:
    Q1 cap→10 and cap→5 each 10 failed / 6 passed (unmutated 16/16 green);
    Q2 M1–M6 = 3 / 1 / 2 / 6 / 5 / 6 (M4 flips the supplemental cap test, M6 the
    bulk cap test, M5 red in both worlds by design); Q3 isStaleCell deletion = 1
    failure
    (the U8 force-gray case) and the engine break→continue fires the
    two-sided canary with expected 'red' to be 'gray'; Q4 each of the three fold
    mutations = 1 failed / 61 passed via exactly one fixture
    (hetero-d4-red-failcount-max, hetero-starter-mixed-soft-hard,
    hetero-d4-green-stripped-infra-red), baseline key count 61, completeness
    check present.

Review guidance

Surface: 17 files, +4880 / −382. Most of that volume is tests, fixtures, and the
regenerated golden-master baseline. Only three files carry production behaviour:
cell-model.contribution.ts, cell-model.ts, and useLiveStatus.ts.

The four round-2 units are separable commits — b8b75b7d (Q2), 75fdfb3a +
ed10b61f (Q1), 49dea099 (Q3), b04330ab (Q4) — and round 1's are too, so this
can be read unit by unit rather than as one diff.

Highest-value review targets, in order:

  1. cell-model.contribution.ts — the gate. if (fold.redSignalKnown && !fold.hasNonInfraRed). This is the whole polarity decision. Worth checking: that
    redSignalKnown really is red-row-scoped inside foldFamily (a family-wide
    derivation is what made INFRA_RED_FRESH unreachable in the browser), and that
    the two conjuncts are genuinely independent evidence rather than one restated.
  2. useLiveStatus.ts — truncated semantics. Q1 redefined truncated from
    "cap exhausted" to "there are rows we did not read", proven by one lookahead read
    of page cap+1 whose rows are discarded and only whose emptiness is load-bearing.
    Worth checking: the asymmetry (bulk throws, supplemental warns) is applied at the
    right call sites, and that the lookahead genuinely cannot be confused with a data
    page. Note limitation 5 above — this contract does not cover wave-level loss.

Everything else is fixtures, doubles, and the coherence suite; the disclosed
weaknesses in those are listed under Known limitations of the guards themselves
rather than left for a reviewer to rediscover.

jpr5 added 2 commits July 24, 2026 15:25
…t gray

`classifyRung` opened its red branch with `if (!raw.signalKnown) return
NO_DATA` — so whenever the dashboard's bulk fetch had projected the `signal`
blob away, a genuinely-failing rung was classified "no data" and painted the
muted gray "nothing to see here" chip, while the depth strip beside it
correctly rendered `1P ✗`.

That polarity is backwards twice over:

- `signalKnown === false` never meant "known to have no signal". PocketBase
  omits the `signal` key ONLY under a `fields=` projection; a row that
  genuinely has no signal arrives as `null`, and `null !== undefined`. So the
  flag means "this row came from a projected fetch" — a PENDING attribution,
  the absence of evidence about WHY the rung failed. It was never evidence
  that the failure was infra.
- Measured against production, ~94% of reds are product-class and only ~6%
  are infra-class. Graying every unattributed red lost 94 real failures to
  suppress 6 false alarms — and a masked red is never investigated, while a
  false alarm is looked at once and closed.

Graying a red now requires POSITIVE infra evidence: `hasNonInfraRed` is false
only when every contributing red row's blob actually carries an
INFRA_ERROR_CLASSES attribution, and `signalKnown` is retained as an explicit
second precondition so a missing blob can never be read as an infra
attribution. The residual cost is over-reporting, which is the direction a
health dashboard has to fail in.

Tests: the harness `§7 I5` case and the dashboard's api/render equivalence
case both ASSERTED the buggy gray as intended behaviour — which is why CI
never caught this. Both are inverted, with the reasoning recorded inline.
Four golden-master fixtures (`pos-d{3,4,5,6}-red-signal-unknown`) are
re-frozen; the regenerated baseline diff touches those 4 of 56 and nothing
else.

Adds coherence invariant INV7: a gray chip sitting above a red depth pill
requires positive infra evidence on every red row. INV1-INV6 only relate
chipColor to the other CHIP-side outputs and never inspect the d3/d4/d5/d6
pills, so the engine could return one object saying both `d5.status === "red"`
and `chipColor === "gray"` with every invariant intact. INV7 fails on the old
polarity and closes the gap in the only safe direction — by fixing the chip
upward, never by muting the strip.
… load

The dashboard's bulk initial fetch projects the heavy `signal` blob away
(`STATUS_LIST_FIELDS`) for a real payload win — measured at ~70% of the
response, 371 KB → 113 KB per 500-row page. A supplemental fetch then restored
`signal` for the rows that are read at render time, but it only ever covered
the comm-error AGGREGATE rows: dimensions `d6`/`d4`/`e2e-demos`/
`d5-single-pill-e2e`, narrowed by `key !~ "%/%"`.

`classifyRung` also reads `signal`, to tell an INFRA red from a PRODUCT red,
and the rows it needs were excluded twice over: they are mostly dimension
`d5`/`e2e`/`health` (absent from FLEET_COMM_AGGREGATE_DIMENSIONS entirely) AND
they are per-cell `<dim>:<slug>/<featureId>` keys that `key !~ "%/%"` filters
out. So on every cold load those rungs arrived with no attribution at all, and
self-corrected only when the probe's next sweep rewrote that specific row and
the SSE delta redelivered it with `signal` — up to a full sweep interval
(~29 min observed, ~14 min mean), again on every reload.

The supplemental filter becomes a UNION: the existing comm-error clause OR
`state != "green"`. Scoping by STATE is what keeps it cheap — `classifyRung`
consults `signal` only in its red branch, so green rows never need it, and in
production the non-green rows are ~360 of ~3100 (~430 KB, about a third of what
shipping `signal` on every row would cost) with no schema change. `!= "green"`
rather than an explicit red/degraded list also catches an out-of-vocabulary
state, which `rankOfState` ranks WORST — the rows that matter most can never
fall outside the fetch.

Widening the EXISTING fetch rather than adding a second one reuses its
freshness guard (`supplementalRowIsOlder`) and chimera-avoidance merge verbatim,
keeps first paint to one extra request, and keeps the fail-loud retry posture.
A dimension-scoped hook still narrows the comm-error clause to the matched
literal, and drops it entirely when the scope sits outside the aggregate set —
but the non-green clause always applies, so such a scope no longer skips the
supplemental fetch altogether. Its test is updated accordingly.

Also fixes two test doubles that identified the supplemental request by
`filter` containing `key !~`. That marker now disappears for an out-of-set
dimension scope, so both would silently misclassify a supplemental request as a
BULK page and corrupt the fan-out instrumentation. They key off the absence of
a `fields` projection instead — the property that structurally distinguishes
the two requests and the whole reason this one exists.
@github-actions

github-actions Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Production Digest-Pinning Audit

All 41 services digest-pinned.

Run 2026-07-25 08:26:17 PDT — 0 finding(s).

jpr5 added 6 commits July 24, 2026 16:27
`classifyRung`'s U7 gray branch reads the `signal` blobs of a family's RED rows
and nothing else, but the precondition qualifying what it read — "was `signal`
actually delivered, or projected away?" — was `raw.signalKnown`, a boolean AND
over EVERY present row of the family. A predicate about red-row evidence was
answerable "no" by a row the branch never looks at.

That broke exactly the case the precondition was written to protect. The
dashboard's supplemental cold-load fetch restores `signal` for `state != "green"`
only (by design — the classifier needs it solely in the red branch), so in a
MIXED-state family the red rows arrive WITH attribution and the green siblings
arrive WITHOUT it. The family-wide flag therefore read `false` precisely when it
should have read `true`: D4 = green `chat` + infra-red `tools` skipped the gray
branch, fell through first-strike (its only red is infra, so
`maxNonInfraRedFailCount` is null), and landed on FAIL_FRESH — the browser
painting RED a cell that `/api/matrix`, which always has the full `signal`,
reports as gray. That is the §11.4 api-vs-render drift the read-model exists to
forbid, and it made INFRA_RED_FRESH effectively unreachable in the browser for
every multi-row family: D4, and any multi-pill D5/D6 (whose per-cell
`d5:<slug>/<pill>` keys the supplemental filter's clause-1 `key !~ "%/%"`
excludes). Only single-key D3 was unaffected — there the family's one row IS the
red row and the two scopes coincide, which is why every fixture missed it.

The fix derives the flag where the rows are, at the scope that consumes it:
`foldFamily` now reports `redSignalKnown` over the RED rows only, alongside the
red-scoped `hasNonInfraRed` / `maxNonInfraRedFailCount` / `allRedSoftClass` it
already computed. `RawRung.signalKnown` and its `gatherRows` plumbing are removed
rather than left dead — a family-scoped flag named `signalKnown` sitting next to
a red-scoped consumer is the trap that produced this bug. `anyExpectedMissing`
stays family-scoped, correctly: a missing sub-key IS a family property and it
gates a family-scoped verdict.

`redSignalKnown` is today IMPLIED by `!hasNonInfraRed`, since
`signalHasInfraErrorClass(undefined)` is false and a stripped red row forces
`hasNonInfraRed` on its own. It is kept explicit anyway — this is the
masks-real-red guard and it must not rest on a coincidental property of a helper
two modules away — and pinned directly on the fold so the scope cannot regress
silently.

Coverage. The previous tests named `signalKnown: false` but were insensitive to
it: `raw.signalKnown &&` could be deleted outright and all 181 harness
cell-model tests plus 58 dashboard equivalence tests stayed green, because every
fixture stripped `signal` from ALL rows of the target rung and never from a green
sibling. The new tests construct the mixed-state family that ships the bug, on
the real derivation surface (`buildCellModel`, not a hand-passed flag): D4 chip,
multi-key D5 chip, and the D6 `d6Effective` badge — D6 is the soft-parity top so
its chip is amber either way, but its badge drifts red-vs-null. Each asserts
browser == server == `/api/matrix`. `api-matrix-equivalence`'s
`coldLoadChip === serverChip` guard is extended off single-key D3 to the D4
family. Five `foldFamily` tests pin the flag's scope directly, and the fail-safe
polarity keeps its negative control: a red row whose OWN `signal` was stripped
still renders RED.
…ake servers

PR #6156 silently invalidated the dropped-tail pagination guards added by
PR #4504. Regression in test COVERAGE, not production code — which is why
CI stayed green.

The three fake PB servers in the autocancel suite ignored the `filter` query
param (and `fields`). #6156 made the supplemental `signal` fetch UNCONDITIONAL
(dropping the `commAggregateFilter === null` early return and widening the
filter to `state != "green"`), so a filter-ignoring server answered that
now-always-issued fetch with the ENTIRE dataset — and `fetchInitial`'s
leftover-append then REPAIRED whatever rows the bulk pagination dropped.
Mutating the merge to drop the entire short page kept all three tests GREEN.

The servers now answer a list request the way real PocketBase does: filter,
then sort, then the page slice, then the `fields` projection, with the
COUNT(*) envelope omitted only when `skipTotal` is set. The filter evaluator
covers exactly the grammar `useLiveStatus` emits and THROWS on anything else
(answered as 400) — a silently-unparsed clause would degrade to "match
everything", i.e. straight back into the masking bug. Real-SDK quoting is
matched (single-quoted string params, bare numbers/booleans, verified against
the installed SDK); the sibling suite's double-quoting `pb.filter` stub flaw
is deliberately NOT copied forward, and a wire assertion pins the convention.

The supplemental fetch is discriminated by the ABSENCE of a `fields`
projection — the sibling `useLiveStatus.test.tsx` convention, reused rather
than reinvented. This replaces a `filter.includes("state !=")` substring
check that the union filter had already made unreliable.

Broken assertions repaired:

- over-fetch instrumentation no longer conflates the supplemental serial walk
  with the bulk fan-out (separate page arrays), and the split is now asserted
  rather than assumed
- the FIRST-wave-element server serves POISON rows on the page after the
  short page. Real PB pagination is monotonic, so that page is empty and
  appending it changes nothing — which is exactly why deleting the merge's
  boundary logic left the test green. Poison makes a merge that runs past
  the boundary observable
- `.some(r => r.id === "f0699")` replaced with `rows.at(-1)?.id`, the LAST-row
  boundary check the comment already claimed, plus explicit poison-absence
- the mid-wave suite no longer claims a boundary property its fixture cannot
  measure (its short page is the wave's last element); name and comment now
  state what it does measure, and it gained a real tail-boundary assertion

Mutation red-green, both directions. Drop-the-entire-short-page: PASSED 3/3
before, now FAILS 3/3 (1300 to 1000, 1250 to 1000, 700 to 500).
Boundary-logic-removed: PASSED before, now FAILS on the suite that claims it
(700 to 1000). Reversed-merge-order (same row set): PASSED before, now FAILS
on both new `.at(-1)` assertions. Mutations reverted: 3/3 pass.

Test-only change — no production code touched.
…op its failure blanking the matrix

PR #6156 widened the browser's supplemental `signal` fetch from "comm-error
aggregate rows only" to "comm-error aggregates ∪ every non-green row, all
dimensions", and in doing so removed the early return that had bounded the work.
What was left was a `for(;;)` with no page cap, unprojected, awaited before any
row is returned — so it degrades exactly when the dashboard matters most.
Measured against production: nominally 357 of 3082 rows (one page, 429 KB), but
under a full-column outage the non-green set trends toward the whole collection —
7 pages, 1.73 MB — all of it on the critical path to first paint. Against a
server that never returns a short page it does not terminate at all.

Worse than slow: a supplemental rejection propagated through fetchInitial →
connect() → the retry chain → `setRows([])` + `status: "error"`. A failure of an
ENRICHMENT fetch blanked the ENTIRE dashboard, which directly contradicts the
fail-safe rationale the PR was written to establish. (It also leaked an unhandled
rejection per attempt, because the promise rejects while the bulk pages are still
in flight and nothing is awaiting it yet.)

Three changes, all on the dashboard hook:

PAGE CAP. Both initial-fetch loops now share one bounded implementation
(`fetchStatusPages`) and one cap, `MAX_INITIAL_FETCH_PAGES = 20`. Sized as a
runaway guard rather than a budget: ~3x the real collection, so it never
truncates a legitimate read including the degenerate all-non-green case. The
supplemental loop also picks up the wave-concurrency and short-page merge guards
the bulk loop already had and it did not, which is what made the parity
structural instead of a promise two comment blocks made to each other. On-cap
behavior is deliberately ASYMMETRIC: supplemental truncation DEGRADES (warn, use
what arrived — the unreached rows keep their signal-less bulk copy, which
classifyRung paints RED), while bulk truncation THROWS, because rows the bulk
never read are whole cells that would render as no-data GRAY, i.e. exactly the
masked-failure polarity this PR exists to remove.

NON-FATAL ENRICHMENT. The rejection handler is attached at the fetch site, so a
supplemental failure yields an empty row set, the merge degrades to "bulk rows,
unenriched", and the dashboard RENDERS. Reds stay red via the classifier's
fail-safe polarity; the residual cost is that a comm-error overlay on a green
aggregate waits for its next SSE delta — the pre-CF7-F3-#1 behavior for the
duration of one failed request, instead of a blank matrix. Attaching at creation
also removes the unhandled rejection.

PROJECTION. The supplemental fetch now sends `STATUS_LIST_FIELDS + signal`
instead of no projection. That is exactly the declared StatusRow shape, derived
from the drift-guarded constant so the two cannot diverge, which drops the
columns PocketBase adds and nothing reads (collectionId, collectionName, created,
updated, state_written_at, written_by): 429,085 → 362,982 bytes measured on the
real non-green set, ~260 KB at incident scale. Deliberately NOT narrower — the
merge treats a supplemental row as a COMPLETE row (replaces its bulk twin
wholesale, appends one the bulk snapshot missed), so `key,observed_at,signal`
would have saved another 58 KB by forcing a graft onto a row of a different
vintage, which is the chimera `supplementalRowIsOlder` exists to prevent.

It stays on the first-paint path. Enriching after first render would have removed
it from the critical path, but a non-green row's chip can move once its signal
lands (red → gray for a positively-infra red, red → amber for a soft-class first
strike), and a cold-load verdict that corrects itself a beat later is the class of
symptom this PR set out to eliminate. With the fetch bounded, wave-concurrent and
projected it runs inside the bulk fetch's own round-trip budget, so gating first
paint costs nothing on the happy path.

Tests are REAL-SDK over real sockets, with fake endpoints that actually evaluate
`filter`/`fields`/`sort` (new `__tests__/pb-query-eval.ts`) so a response is a
function of the query the hook sent rather than of fixture layout. Verified by
mutation: restoring the unbounded loop, the fatal rejection, or the missing
projection each turns its own test red.
…e exemption)

INV7 (added with the cold-load gray-masks-red fix) was unsound in two ways
that only failed to bite by fixture accident:

1. WRONG QUANTIFICATION. Its doc says "every CONTRIBUTING red row", but it
   filtered over every row in `live.values()` — a whole-matrix map. Any red
   row belonging to a different column or feature could fail the invariant
   for a cell it contributes nothing to. Now quantified over the exact
   keyspace `buildCellModel` collects (`contributingKeys`).

2. MISSING isStaleCell EXEMPTION. `buildCellModel` deliberately force-grays
   an all-stale cell on every path (agent, starter, null-feature), folding
   ANY stale colour — red included — to the "re-sweep pending" gray. That
   gray is a recency claim about the cell, not an infra attribution for the
   red pill, so an all-stale cell containing a red row legitimately renders
   gray over a red pill. INV7 failed it. Exempted, with the reasoning inline.

Both holes were latent: the current `stale-*` fixture variants are
green/degraded, and the matrix has no cross-cell rows, so nothing hit them —
the next fixture added would have tripped a false positive.

Also adds an anti-vacuity guard (the narrowed quantification must still find
at least one contributing red row whenever the strip reads red, so a future
drift between `contributingKeys` and the engine's keyspace fails loudly
instead of silently passing everything), and fixes the synthetic contribution
helper `c()`, which set `freshestAgeMs: 0` for `ABSENT` — a shape
`classifyRung` never produces (it returns `null`: an absent rung has no
observation to age).

New tests cover both false positives, a control, and four teeth cases
proving INV7 still fails a genuine non-stale gray-chip-over-red-pill.
Every numeric claim below is re-derived from production PocketBase
(showcase-pocketbase-production.up.railway.app) or from repo config on
2026-07-24, not copied from a neighbouring comment.

- Row/page counts: 2455 rows / 5 pages -> 3082 rows (~3100) / 7 pages,
  with the exact source query recorded so the number can be refreshed.
  The INITIAL_FANOUT_BATCH no-over-fetch note now says that it holds
  because the CURRENT page count is odd, not as an algorithm property.
- Byte estimate: ~1.29 MB -> ~1.6 MB. The retired figure applied the
  (correct) 371 KB -> 113 KB per-500-row basis to the OLD 2455-row
  collection. Measured all 7 pages both ways: 2.34 MB full vs 0.70 MB
  projected = 1.64 MB of signal.
- Worst-case re-delivery window: ~29 min -> ~60 min. staleness.ts and
  harness/config/probes/*.yml schedule e2e-demos, starter_smoke and
  d6-all-pills-e2e HOURLY (10/40 * * * *); aimock-wiring is 6-hourly and
  the drift probes are weekly/monthly.
- Restored the coverage-gap acknowledgement this PR deleted, rewritten
  for what is true today: the supplemental union is neither minimal nor
  complete. It is green-blind outside clause 1 (2646 rows carry a signal
  but sit outside it; the 731 green per-cell rows under the aggregate
  dimensions are excluded by BOTH clauses). Currently latent (0
  uncovered rows carry __fleetCommError) but structurally open, and it
  is the hole that let the mis-scoped signal-provenance misreport ship
  green.
- Anchored the 94%/6% product-vs-infra split with its query, date and
  partitioning predicate (336 vs 21 of 357 red rows), and flagged it as
  a snapshot the polarity argument does not depend on. Softened the
  unreproducible "~20% of the matrix" to the derivable bounds.
- Version-qualified the STATUS_LIST_FIELDS omission-vs-null claim to the
  pinned PocketBase 0.22.21 and recorded the upgrade hazard: PB >=0.23's
  PublicExport isVisible/GetHidden path lets a field-level hidden flag
  omit signal independently of our projection, reintroducing the
  ambiguity the provenance flag exists to avoid.

INTEGRATION RECONCILE (folded in when this was cherry-picked on top of
the signalKnown-scope fix). Three conflicts in useLiveStatus.ts, all
row/page-count prose, resolved to the measured 3082-row / 7-page anchor
and to this commit's corrected INITIAL_FANOUT_BATCH note (the "page 7
ends its own wave" claim is only true at an ODD page count, which the
superseded text asserted as an algorithm property). Additionally, every
doc reference to `RawRung.signalKnown` — a field the scope fix DELETED —
was rewritten to name the surviving red-row-scoped
`FamilyFold.redSignalKnown`, so no comment describes a flag that no
longer exists: live-status.ts STATUS_LIST_FIELDS doc (3 sites),
useLiveStatus.ts coverage-gap note, api-matrix-equivalence.test.ts (2
sites).

Comments only - no logic, no reformatting, no reordering.
… both dashboard suites

Integration defect, introduced by folding the autocancel fake-server fidelity
repair together with the bounded/projected supplemental fetch. Each was correct
alone; together they disagreed about how a supplemental request is IDENTIFIED.

The fidelity repair's `isSupplementalRequest` keyed on the ABSENCE of a `fields`
projection. That was true when it was written and is now false: the supplemental
fetch sends `STATUS_LIST_FIELDS,signal`. So all three faithful fake servers
classified the supplemental request as a BULK page, which:

  - failed `expect(fields).not.toContain("signal")` on the "every bulk page
    projects `signal` away" wire contract (the supplemental query was in the
    bulk bucket), and
  - left `supplementalQueries` / `firstElemSupplementalPages` EMPTY, so the two
    `toEqual([1])` bounds assertions compared `[]` against `[1]`.

Whole autocancel suite: 3 failed / 3. Not a flake and not a pre-existing
failure — it is exactly the two-conventions collision the integration had to
resolve.

Resolved toward the convention the mocked sibling suite already uses after the
projection landed: a request is supplemental iff `signal` IS in its `fields`.
That is the property that actually defines the request rather than an artifact
of how it happened to be built, so it survives both the projection being added
and the bulk projection changing width. Both dashboard suites now assert the
SAME convention, and dropping `fields: STATUS_SIGNAL_FIELDS` from the hook turns
both of them red (verified), so neither can silently drift back.

Also corrected the three comments that still described the supplemental fetch as
unprojected.

Tests only — no production change. `git diff` against the hook is empty.
jpr5 added 5 commits July 24, 2026 19:56
…verified against a real server

The dashboard's `useLiveStatus` test doubles carried THREE divergent
implementations of the same PocketBase query evaluator — the nominally-shared
`__tests__/pb-query-eval.ts`, a second complete private copy inside
`useLiveStatus.autocancel.test.tsx`, and a third partial one in the
supplemental-bounds fakes. They disagreed on four axes, and the shared one was
the weakest of the three. Three definitions of "what PocketBase does" is no
definition at all.

There is now exactly one, and every semantic in it is a measured observation from
a real PocketBase v0.22.21 server (the version `showcase/pocketbase/Dockerfile`
pins) plus the real SDK's own `filter()`. `pb-query-eval.test.ts` pins that
oracle case by case, with the live result recorded next to each expectation.

Fidelity defects fixed, all of which the module's own docs asserted backwards:

- Single-quoted literals. `pb.filter()` wraps string params in SINGLE quotes with
  `\'` escaping and emits numbers/booleans/null BARE. The shared tokenizer
  handled only double quotes, so every dimension-scoped filter the hook builds
  threw `unsupported character "'"`.
- LIKE is case-INSENSITIVE (it compiles to SQLite `LIKE`).
- The implicit `%…%` wrap is triggered by `%` alone, and it ESCAPES `%` and `_`
  so they match literally. `_` does not suppress the wrap. Both prior copies got
  a different half of this wrong.
- Ordering and equality follow the COLUMN type: `fail_count > 2` selects
  `fail_count` 10, which the string comparison in the private copy excluded.
- `sort=-key` descends instead of silently no-opping.

And it now genuinely fails loud rather than claiming to. An unterminated literal,
a bare word (which real PB reads as a column reference and 400s on), a dangling
operator or escape, an unbalanced paren, trailing input, an unsupported operator,
a sort it cannot apply, a non-numeric `page`, and a field the row does not carry
all throw — matching the real server, which answers every one of them with a 400.

Serving that contract over HTTP is structural now, not per-fake discipline.
`matchesPbFilter` used to be called bare inside two `createServer` handlers, so a
parse error produced NO response: the hook hung and the test died on a 20 s
`waitFor` timeout with the parse message nowhere in sight. Fakes go through
`evaluatePbList`, which cannot throw — it returns either a 200 or the real
server's own 400 carrying the message.

All three supplemental-bounds fakes now answer through it, on both their bulk and
their supplemental legs. Two of them ignored `filter` entirely while that file's
preamble claimed all of them evaluated it, which left the page-cap tests proving
themselves on fixture shape: with the fakes repaired, breaking the supplemental
filter turns the supplemental cap test red, and breaking the bulk filter turns the
bulk cap test red. Both were green before.
`fetchStatusPages` inferred truncation from cap exhaustion with a full last
page. That is not evidence: the loop learns where the collection ends only
from a SHORT page (`skipTotal: true` drops `totalItems`/`totalPages`), so a
collection of exactly MAX_INITIAL_FETCH_PAGES x INITIAL_PAGE_SIZE rows is read
COMPLETELY and still ends on a full page. The bulk consumer THROWS on
truncation, so at exactly 10,000 rows the dashboard went offline
deterministically and permanently -- every retry, every reload, because the
condition is a pure function of the row count. The function's own JSDoc
asserted the opposite of what it did. This is the same false-outage class
matrix.ts already fixed server-side (any full final page read as truncation
took /api/matrix down on every 500-boundary), reintroduced client-side.

`truncated` now means exactly "there are rows we did not read", and it is proven
rather than inferred: on cap exhaustion with a full last page the loop issues
ONE lookahead read of page MAX_INITIAL_FETCH_PAGES + 1 whose rows are discarded
and only whose emptiness is load-bearing. Chosen over `skipTotal: false` on
page 1 (the matrix.ts shape) because that puts a COUNT(*) on the first-paint
path of EVERY load -- the exact overhead `skipTotal: true` exists to drop --
to disambiguate a case that can only arise after 20 consecutive full pages;
the lookahead puts the whole cost on the pathological path, where it is a
rounding error against the 20 requests that preceded it. A FAILED lookahead
fails safe (unproven completeness is reported as truncated), keeping the bulk
path's fail-loud posture.

The asymmetric on-hit semantics are unchanged and remain correct: supplemental
truncation DEGRADES (reds stay red), bulk truncation THROWS (unread rows are
whole cells that would render gray = masked failure). The false positive is
fixed; the throw is not weakened.

The pagination algorithm is hoisted out of the effect as `paginateStatusPages`
over an injected page reader, so the `truncated` contract can be asserted
directly rather than only through the hook's observable state -- and so every
page of a read, INCLUDING the lookahead, provably carries the same `listOpts`.

MAX_INITIAL_FETCH_PAGES is exported (for a mechanical, two-sided test pin) and
its value is now justified against both bounds it actually has to satisfy:
~3x the measured production worst case below, and bounded runaway damage above;
the value is unchanged at 20.
The cap "drift guard" did not guard. Every assertion in
useLiveStatus.supplemental-bounds.test.tsx was an UPPER bound
(toBeLessThanOrEqual / not.toContain(cap + 1)), so only an increase was
caught. Measured on the pre-fix branch, MAX_INITIAL_FETCH_PAGES could be
halved to 10 or cut to 5 with all 6 tests still green. A lowered cap is just
as much a silent behavior change -- it moves the cap toward the legitimate
read and starts truncating real collections. The bound assertions were also
vacuous, because Math.max of an empty array is -Infinity, so a supplemental
fetch that never ran at all satisfied them.

Both sites now assert the EXACT page sequence a full walk of the cap produces
(1..cap plus the one terminal lookahead), sorted because fan-out waves are
concurrent, and DISTINCT on the fail-loud bulk path because the throw re-runs
the whole loop once per reconnect attempt. Zero pages now fails, a halved cap
now fails. The literal is additionally pinned MECHANICALLY against the
exported constant, so the "MUST match" claim in its doc is checked rather
than trusted.

New file useLiveStatus.page-cap-boundary.test.tsx covers the boundary the
suites never reached -- a COMPLETE read that ends exactly on the cap page --
in both directions and at both levels.

  - DIRECT on paginateStatusPages. Exactly cap x 500 rows is NOT truncated
    (and issues one lookahead, then stops); one row past the cap IS truncated;
    a read ending on a short page never issues the lookahead; a failed
    lookahead fails safe to truncated.
  - THROUGH the hook. A complete 10,000-row collection renders (status live,
    all rows, red cell still RED from a signal-less bulk row) instead of the
    permanent blank-dashboard outage; one row past the cap still fails LOUD
    with an error and no rows.

It carries its own ../lib/pb mock rather than reusing the pb-query-eval fake
servers. The boundary needs 10,000 rows in the BULK response, which no shared
fixture serves, and nothing this file proves should be able to go green or red
because of a change to those servers' filter fidelity.
INV7 (`assertChipStripCoherent`) fired on a legitimate engine shape: with no
`e2e:` row, `scanWorst` breaks at the ABSENT D3 rung (invariant I1) and never
consults D4, so a fresh product-red `chat:<slug>` renders a gray chip over a red
D4 pill. INV7 demanded infra evidence for a red the chip provably never read.
Round-1 finding a4(iii), unfixed by the round-1 INV7 fix; re-raised as a8.

Adds a third, narrow carve-out beside the U8 all-stale one: the gray is excused
only when the ladder walk stopped for want of any observation STRICTLY BELOW the
shallowest red pill. `ladderGapDepth` tests exactly that ("no row for any of the
rung's keys"), which is provably equivalent to `classifyRung`'s ABSENT for a
D3/D4/D5 rung — deliberately not the strip's `status === null`, which also
covers the `anyExpectedMissing` NO_DATA collapse (a rung that does have an
observation and does not stop the walk). `combine.ts` is untouched: the
gap-break's own masking is a separate change needing a golden-master re-freeze.

The allowance is one-directional and canaried. A gap ABOVE the red excuses
nothing, and when the gap-break is eventually fixed the new case's chip stops
being gray, so its precondition assertion fails loudly rather than letting the
carve-out excuse a shape the engine no longer produces.

Also removes INV7's unreachable starter branch (b24). A starter cell has no
depth strip, so INV7's precondition is structurally unsatisfiable there; the
branch implied coverage that does not exist. It is now a loud throw, and a new
test pins the structural reason and fails if the starter axis gains a strip.

New cases: the gap shape (green, plus an in-suite mutation proof that the
allowance is what passes it), a gap above the red, a gapless gray-over-red, and
an UNPERTURBED engine model INV7 still rejects (an infra-red D4 grays a
product-red D6 — D6 is outside `scanWorst`'s scan). That last one corrects the
file's claim that the engine no longer produces a gray-over-red incoherence.

Exhaustive sweep over 295,245 rung combinations: 25,504 INV7 failures without
the allowance, 1,456 with. Every remaining one has its gap at or above the
shallowest red pill, i.e. none is gap-induced; they are two other pre-existing
engine masking mechanisms and INV7 keeps its teeth on them.
…lds mutation-detectable

The fail-safe polarity flip's widest case was frozen by nothing. A stripped-
`signal` red on a `health:`/`agent:` row flips a whole column green->red
(achieved 6->0, isRegression true) because those keys are integration-scoped,
but `red-signal-unknown` was only applied by `positionSweep` (D3-D6), and
`liveness-fresh-red-d1/-d2` use `row()`'s default `signal: null` -- which is
not `undefined`, so they classified FAIL_FRESH under the old polarity too.
Measured: restoring `!redSignalKnown -> NO_DATA` killed 4 golden-master entries,
all D3-D6, and left the entire D1/D2 leg byte-identical.

Underneath that sat a structural blind spot: every fixture variant maps ONE
uniform row shape over ALL keys of a rung, so no family anywhere contained two
DIFFERING red rows and no family contained a green row with an absent `signal`
key. A uniform set has nothing to aggregate, so three explicitly load-bearing
family folds were invisible at golden-master level -- `Math.max`->`Math.min` on
`maxNonInfraRedFailCount`, `allRedSoftClass` `every`->`any`, and re-widening the
provenance flag from red-row to family scope each left all 56 entries identical.

Adds 5 fixtures (56 -> 61 baseline entries):

- `liveness-red-signal-unknown-d1` / `-d2` -- a red D1/D2 row with `signal:
  undefined` over a green D3-D6 ladder. Both now fail under a polarity
  re-widening, joining the 4 existing entries.
- `hetero-d4-red-failcount-max` -- D4 {chat red fc1, tools red fc3}, straddling
  D4_FIRST_STRIKE_THRESHOLD. MAX(1,3)=3 -> FAIL_FRESH/red; MIN(1,3)=1 ->
  FIRST_STRIKE_FRESH/amber, i.e. a fresh sibling re-arming tolerance for an
  already-confirmed failure, which the MAX doc explicitly forbids.
- `hetero-d4-green-stripped-infra-red` -- D4 {chat green signal-omitted, tools
  red driver-error}, the production shape `classifyRung` cites verbatim and the
  first fixture with a green row whose `signal` key is absent. Red-row scoping
  keeps this gray; a family-scoped flag paints it red.
- `hetero-starter-mixed-soft-hard` -- starter {transport-error (soft),
  smoke-failed (hard), rest green}, both below SOFT_MISS_TOLERANCE_THRESHOLD so
  the soft-class quantifier is the only deciding factor.

Each mutation is now caught by exactly one fixture while its pre-existing
sibling stays blind, so the teeth come from the new shapes rather than
incidental coupling. Baseline entries were derived by hand from the source
first and inserted additively (140 insertions, 0 deletions) -- no wholesale
regeneration, so no result is self-approving.

Also closes the D1/D2 gap in the dashboard equivalence suite: the `fail-safe
polarity` fixtures seeded no `health:`/`agent:`/D5/D6 rows, so those rungs
contributed ABSENT -- also gray -- and the gray assertions passed via the
no-data path while naming the infra path. A `greenScaffold` helper makes every
rung but the one under test green-fresh, discriminating pill assertions prove
the gray sits over a present red pill, and a new test pins the whole-column
D1/D2 stripped-red case api-vs-browser (equal chip, achieved 0, regression
true).

Fixtures and baseline only -- no classification logic, `combine.ts`, or
coherence invariant touched.
@jpr5
jpr5 marked this pull request as ready for review July 25, 2026 05:14
jpr5 added a commit that referenced this pull request Jul 25, 2026
…6168)

## The gap

**No CI job ran the showcase unit suites.** Not "ran them partially" —
no job invoked them at all. Verified per suite against `91f0321397` (the
tip of `main` this branched from), by reading every workflow's actual
`run:` lines rather than trusting job names:

| Suite | Tests | Ran in CI before? | Where |
|---|---|---|---|
| `showcase/harness` | 3646 (3625 pass / 3 fail / 18 skip) | **NO** |
nowhere |
| `showcase/shell-dashboard` | 1331 (1330 pass / 1 skip) | **NO** |
nowhere |
| `showcase/shell` | ~57 (8 files) | **NO** | nowhere |
| `showcase/scripts` | — | yes | `showcase_validate.yml` → "Run build
pipeline tests" |

Why each candidate workflow misses them:

- **`test_unit.yml`** — the one whose name implies it covers this —
excludes them *twice over*: `paths-ignore` lists `showcase/**`, **and**
its nx selection is hard-scoped to `--projects='packages/**'`.
- **`showcase_validate.yml`** runs `pnpm exec vitest run` only in
`showcase/scripts`. It has two `working-directory: showcase/harness`
steps, but they are a CVDIAG perf bench (`vitest bench
src/cvdiag/emit-perf.bench.ts`) and an ESM boot-smoke — neither runs the
unit suite.
- **`static_quality.yml`** does run `nx run-many -t check-types`. This
resolves the reported name/invocation divergence: the *job* is called
`check-types` and the harness's script is called `typecheck`, so no
`check-types` target exists on the harness and **the harness is not
typechecked either**.

Net effect: ~5000 showcase unit tests gated nothing. A PR could carry
real defects in `showcase/harness/src/**` and still show an all-green
check list, because no job structurally could have caught them.

## What this wires

New workflow **`test / unit-showcase`**
(`.github/workflows/test_unit-showcase.yml`), two parallel jobs on PR +
push-to-main filtered to `showcase/**`:

- **`harness unit suite`** — `nx run
@copilotkit/showcase-harness:test:ci`, then `nx run
@copilotkit/showcase-harness:test:quarantine-ratchet`. Driven through nx
per the root `CLAUDE.md` task convention.
- **`shell-dashboard unit suite`** — `vitest run` directly; the
dashboard is deliberately outside the pnpm workspace (see the note in
`pnpm-workspace.yaml`) so it is not an nx project and has no target to
run.

New nx targets are declared in **`showcase/harness/package.json`'s
`nx.targets` block**, not in `nx.json` — they are harness-specific, and
a `nx.json` `targetDefaults` entry would silently apply to any future
project that happens to share the script name. Both are `cache: false`
on purpose: the nx `test` named-input covers `src/**` and `*.test.*` but
**not** `vitest.ci.config.ts` or `vitest.quarantine.json`, so a cached
result could survive an edit to the quarantine list.

### Why a separate workflow rather than steps in `showcase_validate.yml`

That file is a single ~900-line job already budgeted at 25 minutes and
is the busiest merge-path workflow in the repo. Splitting the unit
suites out gives them their own name in the check list, their own
concurrency group, and — since the two suites need different package
managers — lets them run in parallel instead of lengthening the critical
job. Naming follows the existing convention (`test_unit.yml`,
`test_unit-python-sdk.yml`, `test_unit-spring-ai.yml`).

**No `continue-on-error` and no `|| true` anywhere in the file.** A gate
that cannot fail is not a gate.

## Hazards, and how each is handled

### 1. The hanging spike test

*Correction to the reported location:* it is
`showcase/shell-dashboard/tests/runtime-env-switch.spike.test.ts`, not
under `showcase/harness/`. It reaches the dashboard suite via that
package's `include: ["src/**/*.test.{ts,tsx}",
"tests/**/*.spike.test.ts"]`.

**Reproduced locally.** vitest sat at **0.0% CPU with zero output** and
never even spawned the `next build` its `beforeAll` calls — no worker
fork, nothing. Killed at ~2 minutes; consistent with the reported
~25-minute stall.

**Handled by excluding it from the unit gate**, not by a hard timeout.
Justification: it is an integration spike by construction — one `next
build` plus two `next start` boots on fixed ports 3801/3802 — and this
package's own config comment already says it is *"too heavy for the
per-file unit suite"* even though the `include` glob pulls it in anyway.
A hard timeout would convert a 25-minute stall into a red gate with
nothing actionable in it; this suite has to stay a fast, trustworthy
unit signal. The spike needs its own job with a real server budget,
which is out of scope for wiring up the unit gate.

Note the `--exclude` values restate the package's existing config
excludes (`tests/visual/**`, `node_modules/**`) because vitest's CLI
`--exclude` **replaces** the config value rather than extending it —
dropping them would silently re-enable them.

### 2. Gitignored generated artifacts

`showcase/.gitignore` ignores `shell/src/data/*.json` and
`shell-dashboard/src/data/*.json`, but the suites consume them:

- `harness/src/probes/frontend-matrix.test.ts` **statically imports**
`shell/src/data/frontend-catalog.json` — a missing file is a module
*load error*, not a test failure.
- `harness/src/fleet/control-plane/d0-gone-predicate.test.ts` reads
`shell/src/data/registry.json` at runtime.
- `shell-dashboard/src/lib/docs-status.ts` **statically imports**
`@/data/docs-status.json`.

Generated as an explicit job step (`generate-registry.ts`, plus
`probe-docs.ts` for the dashboard), mirroring how
`showcase_validate.yml` drives the same generators. The dashboard job
invokes vitest directly rather than `npm test` specifically so the
`pretest` hook does not re-run `probe-docs.ts` and double its ~50
outbound HEAD requests.

Also load-bearing: `npm ci --ignore-scripts` in the dashboard job. That
package's `postinstall` is `cd ../scripts && npm install`, which would
lay an npm-resolved `showcase/scripts/node_modules` over the
pnpm-managed one.

### 3. The 3 pre-existing failures — quarantined behind a ratchet, none
deleted or weakened

Confirmed byte-identical to `origin/main` and pre-existing. A job that
is red on arrival gets ignored or disabled, so the three files are
excluded via `showcase/harness/vitest.quarantine.json` +
`vitest.ci.config.ts` — **and `scripts/quarantine-ratchet.ts` re-runs
each one and requires it to STILL FAIL.** The moment somebody fixes a
quarantined test, the ratchet goes red and names the entry to delete. An
entry therefore cannot outlive the failure it excuses. The ratchet also
fails on an entry pointing at a missing file, on an entry whose filter
matches more than one file, and on a malformed or under-documented
manifest (every entry must carry `file` / `since` / `reason` /
`unquarantineWhen`).

Local `pnpm test` still uses the unfiltered config, so a developer sees
the quarantined failures.

| File | Disposition | Why |
|---|---|---|
| `src/probes/frontend-matrix.test.ts` | quarantine | Asserts hard-coded
per-frontend counts (`react=660`, `angular=636`) against the
**generated** `frontend-catalog.json`, which has grown to 1302 runnable
cells (`react=664`). Stale literals, not a product defect — the two
assertions that express the test's stated intent ("without loss or
duplication": `length === metadata.runnable`, ids unique) both pass.
Exit criterion: derive the counts from the catalog; re-hard-coding fresh
numbers just resets the clock. |
| `src/probes/helpers/d5-mapping-drift.test.ts` | quarantine |
**Stranded by a completed refactor.** It regex-scrapes
`CATALOG_TO_D5_KEY` out of `shell-dashboard/src/lib/live-status.ts` to
prove the dashboard copy hasn't drifted from the harness's
`REGISTRY_TO_D5`. That file is now a one-line `export *` barrel over the
canonical `harness/src/shared/cell-model/live-status.ts` — there is no
second copy to drift and nothing for the regex to find, so the test
throws its own "could not locate" guard. Exit criterion: cell-model
owner deletes it (single-source is a strictly stronger guarantee) or
rewrites it to assert the barrel re-export. |
| `src/probes/helpers/d5-representatives.test.ts` | quarantine |
**Genuine product gap, deliberately not fixed here.**
`d5-browser-use-smoke` registers `browser-use-smoke` in `D5_REGISTRY`
but `D5_REPRESENTATIVES` has no entry, so
`getD5Representative('browser-use-smoke')` returns `undefined` and the
D5 driver has no representative fixture. The test is correct and
reporting a real hole; the fix belongs to the D5 owner, and this PR
touches no product source. |

### 4. New finding: a load-sensitive flaky test

Not one of the 3, and worth fixing separately:
`src/probes/loader/probe-invoker.test.ts` → *"times out at the invoker
level when enumerate() ignores abortSignal"* asserts a **wall-clock**
`elapsed < 150` against a 100ms invoker timeout racing a 200ms
enumerate. 50ms of headroom does not survive CPU contention — it passed
**5/5 in isolation** but failed twice at ~217ms while the machine was
running other vitest suites, and a 4-vCPU runner executing 173 test
files in parallel is exactly that condition.

Mitigated with `retry: 2` **in the CI config only** (base config
unchanged, so local runs still surface non-determinism). This is not
suppression: a genuinely broken test fails all three attempts and the
gate stays red, and vitest prints every retried test. The real fix is
for the probe-loader owner to drive that assertion off fake timers or
widen the bound, after which the `retry` should come out. Flagging the
tradeoff explicitly rather than burying it.

## Deliberate-breakage proof

A job that has never failed is not yet a gate. Scratch commit
`e100df27a7` broke two product-source files, then `4f092eccb1` reverted
it. The final branch diff is **578 insertions, 0 deletions, and zero
product source touched.**

| Run | SHA | `harness unit suite` | `shell-dashboard unit suite` |
Quarantine ratchet |
|---|---|---|---|---|
| baseline
[`30140087665`](https://github.com/CopilotKit/CopilotKit/actions/runs/30140087665)
| `452a26115e` | **success** (3m33s) | **success** (1m35s) | success |
| **breakage**
[`30140218159`](https://github.com/CopilotKit/CopilotKit/actions/runs/30140218159)
| `e100df27a7` | **FAILURE** (3m31s) | **FAILURE** (1m28s) | success |

The breakage — both reproduced locally before pushing:

- `showcase/harness/src/shared/cell-model/staleness.ts`:
`D4_STALE_AFTER_MS` 1h → 10h (a frozen-green D4 row would credit D4 for
ten hours instead of one)
- `showcase/shell-dashboard/src/lib/sort-order.ts`: `sortOrder` `mastra:
8` → `88`

What the RED run actually caught:

```
harness unit suite   —  Test Files 3 failed | 168 passed | 2 skipped (173)
                        Tests      4 failed | 3612 passed | 18 skipped (3634)
  FAIL src/http/matrix.test.ts > stale green ladder: raw state='green' but /api/matrix folds to gray (U8)
  FAIL src/shared/cell-model/cell-model.contribution.test.ts > family fold: one stale-green sibling forces STALE_DEGRADED
       AssertionError: expected 'GREEN_FRESH' to be 'STALE_DEGRADED'
  FAIL src/shared/cell-model/cell-model.equivalence.test.ts > golden-master identity > fixture: pos-d4-stale-green
  FAIL src/shared/cell-model/cell-model.equivalence.test.ts > golden-master identity > fixture: stale-column

shell-dashboard unit suite —  Test Files 3 failed | 64 passed (67)
                              Tests      4 failed | 1326 passed | 1 skipped (1331)
  FAIL src/components/__tests__/depth-utils.test.ts > does not credit D4 when its green chat row is stale
       AssertionError: expected 4 to be 3
  FAIL src/lib/__tests__/cell-model.test.ts > comm-error staleness window > scopes the window PER ROW FAMILY (G3e)
       AssertionError: expected 36060000 to be less than 21600000
```

Three things this establishes beyond "the job can go red":

1. **It catches exactly the class of defect that went undetected on
#6156** — a change to `showcase/harness/src/shared/cell-model/**` landed
4 failures in the harness gate, including two golden-master equivalence
fixtures.
2. **The dashboard job also caught the harness defect**, through the
`live-status.ts` re-export barrel. The shared cell-model now has two
independent gates over it.
3. **`retry: 2` is not suppression.** Every `FAIL` line above appears
three times in the log — the test was retried the full budget and failed
all three attempts. A genuinely broken test cannot pass through it. And
the **quarantine ratchet stayed green on the broken run**, confirming
the quarantine is scoped to its three files and does not swallow
unrelated regressions.

## Runtime

Measured on CI (Depot 4-vCPU), baseline run
[`30140087665`](https://github.com/CopilotKit/CopilotKit/actions/runs/30140087665)
— **both jobs green**:

| Job | CI wall-clock (whole job) | Suite only (local) | Files |
|---|---|---|---|
| `harness unit suite` | **3m33s** | 63.5s | 173 (171 pass / 2 skip,
3616 tests) |
| `shell-dashboard unit suite` | **1m35s** | 7.2s | 67 (1330 pass / 1
skip) |

They run in parallel, so the added critical-path cost is ~3m33s —
comfortably under `showcase_validate.yml`'s existing 25-minute budget
and nowhere near irritating-enough-to-disable. In both jobs the budget
is dominated by install and (for the harness) nx `^build`, not by the
tests.

**No sharding or `nx affected` needed.** `nx affected` would in fact be
actively wrong here: the entire point is that a change anywhere under
`showcase/**` should run the suite covering it, and the historical
failure mode was scope-narrowing, not slowness. If install time later
dominates, the lever is pnpm/npm store caching (already configured) —
not cutting test scope.

## Not covered

`showcase/shell`'s 8 test files (~57 tests) are **also ungated** and I
left them out to keep this change to one concern. They need a third
install path (`showcase/shell` is likewise outside the pnpm workspace)
and its `vitest.config.ts` already has a `globalSetup` that generates
its own `registry.json`. Cheap follow-up.

## Coordination

Concurrent work is adding a vacuity/drift text gate under
`showcase/scripts` and compile-time completeness exports. This PR owns
only the **suite invocation**. The one plausible cherry-pick conflict is
`showcase/harness/package.json` (I added two `scripts` entries and an
`nx.targets` block); `.github/workflows/test_unit-showcase.yml` is a new
file and `nx.json` is deliberately untouched.
@pkg-pr-new

pkg-pr-new Bot commented Jul 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

@copilotkit/a2ui-renderer

pnpm add https://pkg.pr.new/@copilotkit/a2ui-renderer@6156

@copilotkit/agentcore-runner

pnpm add https://pkg.pr.new/@copilotkit/agentcore-runner@6156

@copilotkit/angular

pnpm add https://pkg.pr.new/@copilotkit/angular@6156

@copilotkit/channels

pnpm add https://pkg.pr.new/@copilotkit/channels@6156

@copilotkit/channels-core

pnpm add https://pkg.pr.new/@copilotkit/channels-core@6156

@copilotkit/channels-discord

pnpm add https://pkg.pr.new/@copilotkit/channels-discord@6156

@copilotkit/channels-intelligence

pnpm add https://pkg.pr.new/@copilotkit/channels-intelligence@6156

@copilotkit/channels-slack

pnpm add https://pkg.pr.new/@copilotkit/channels-slack@6156

@copilotkit/channels-teams

pnpm add https://pkg.pr.new/@copilotkit/channels-teams@6156

@copilotkit/channels-telegram

pnpm add https://pkg.pr.new/@copilotkit/channels-telegram@6156

@copilotkit/channels-ui

pnpm add https://pkg.pr.new/@copilotkit/channels-ui@6156

@copilotkit/channels-whatsapp

pnpm add https://pkg.pr.new/@copilotkit/channels-whatsapp@6156

@copilotkit/core

pnpm add https://pkg.pr.new/@copilotkit/core@6156

@copilotkit/react-core

pnpm add https://pkg.pr.new/@copilotkit/react-core@6156

@copilotkit/react-native

pnpm add https://pkg.pr.new/@copilotkit/react-native@6156

@copilotkit/react-textarea

pnpm add https://pkg.pr.new/@copilotkit/react-textarea@6156

@copilotkit/react-ui

pnpm add https://pkg.pr.new/@copilotkit/react-ui@6156

@copilotkit/runtime

pnpm add https://pkg.pr.new/@copilotkit/runtime@6156

@copilotkit/runtime-client-gql

pnpm add https://pkg.pr.new/@copilotkit/runtime-client-gql@6156

@copilotkit/sdk-js

pnpm add https://pkg.pr.new/@copilotkit/sdk-js@6156

@copilotkit/shared

pnpm add https://pkg.pr.new/@copilotkit/shared@6156

@copilotkit/sqlite-runner

pnpm add https://pkg.pr.new/@copilotkit/sqlite-runner@6156

@copilotkit/voice

pnpm add https://pkg.pr.new/@copilotkit/voice@6156

@copilotkit/vue

pnpm add https://pkg.pr.new/@copilotkit/vue@6156

@copilotkit/web-components

pnpm add https://pkg.pr.new/@copilotkit/web-components@6156

@copilotkit/web-inspector

pnpm add https://pkg.pr.new/@copilotkit/web-inspector@6156

commit: 12ea621

@jpr5
jpr5 merged commit edc59c4 into main Jul 26, 2026
24 checks passed
@jpr5
jpr5 deleted the fix/cold-load-gray-masks-red branch July 26, 2026 06:57
jpr5 added a commit that referenced this pull request Jul 29, 2026
…nnot overwrite a newer one (#6174)

## The race, with evidence

Three PRs merged within 34 seconds on 2026-07-26. `Showcase: Build &
Push` has **no concurrency group** (deliberately), so all three ran
simultaneously and raced to push the same `:latest` tags.

| run | commit | PR | start → end |
|---|---|---|---|
| `30190815370` | `7b28934387` | #6162 | 06:18:05 → 06:29:44 |
| `30190823203` | `59f275eedc` | #6161 | 06:18:21 → 06:29:44 |
| `30190831480` | `db75a04837` | #6158 | 06:18:39 → **06:29:13** ←
newest, finished FIRST |

The newest commit finished first, so the older builds overwrote its
`:latest`. Per-service job completion times — older beating newer on
every shared slot:

| service | newer (`db75a04837`) | older (`59f275eedc`) | older won by |
|---|---|---|---|
| `shell-dashboard` | 06:25:33 | 06:25:34 | +1s |
| `showcase-harness` | 06:27:51 | 06:27:55 | +4s |
| `shell` | 06:27:17 | 06:27:28 | +11s |
| `shell-dojo` | 06:25:10 | 06:25:26 | +16s |

**All three runs reported `success`.** Staging served pre-#6158 code
while CI, the redeploy gate and deploy verification all looked clean.
Same failure class as #6171: a success that doesn't mean what it says.

## What I verified in YAML vs took on trust

Verified by reading the files / querying the API:

- **Tagging** — `showcase_build.yml` pushed `:latest` **and** `:${{
github.sha }}` in one `depot/build-push-action` step, in both the
`build` and `build-starters` matrices. **A per-commit sha tag already
existed**; confirmed in GHCR (`showcase-shell-dashboard` has digests
tagged `db75a04837…`, `59f275eedc…`, `d28384a2eb…`).
- **Nothing serialized the pushes.** No concurrency group; confirmed the
header comment states this is intentional.
- **Deploy consumes `:latest`** — `verify-railway-image-refs.ts` is the
SSOT assertion: staging is `ghcr.io/copilotkit/<repo>:latest` (mutable),
**prod is `ghcr.io/copilotkit/<repo>@sha256:<digest>` (already immutably
pinned)**. So this race is **staging-only**; prod was never exposed.
- **`Showcase: Verify Deploy` structurally cannot catch it.** It is a
health probe; it asserts no digest or commit provenance anywhere. Its
#6171 per-commit concurrency key is about *which run verifies*, not
*what image is running*. A stale-but-healthy service passes.
- **The racing runs build DISJOINT service sets** (see below) — I pulled
the actual job lists.

Taken on trust: nothing material. The issue description matched the API
on every point I checked.

## Why NOT a concurrency group

`detect-changes` builds a **per-push, path-filtered** matrix, so
concurrent runs build overlapping but **non-identical** service sets:

- `7b28934387` → ag2, agno, built-in-agent, claude-sdk-python,
claude-sdk-typescript, crewai-crews, langgraph-fastapi,
langgraph-python, langroid, llamaindex, mastra, pydantic-ai, shell-docs,
spring-ai, strands (**15**)
- `db75a04837` → crewai-crews, llamaindex, shell, shell-dashboard,
shell-docs, shell-dojo, showcase-harness (**7**)

`cancel-in-progress: true` would have cancelled the `7b28934387` run and
the ~10 services **only it builds would never have shipped** — trading a
stale-image bug for a never-shipped bug. Per [GitHub's
docs](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#concurrency),
`cancel-in-progress: false` is no better: *"Any previously pending job
or workflow in the concurrency group will be canceled"* — with three
rapid merges the **middle** commit's build is dropped outright. GitHub
also does not guarantee FIFO ordering of queued runs.

Concurrent runs here are **not redundant**, so they must not be
cancelled.

**Re the #6171 interaction:** this design does **not** use
`cancel-in-progress`, so no build is ever superseded-and-cancelled and
the cancelled-slot notifier is never tripped by this change. That
interaction stays theoretical — deliberately.

## The design

Make the one shared mutable resource monotonic instead of serializing
the fleet.

1. The build step pushes **only** the immutable `:<sha>` tag, plus an
`org.opencontainers.image.revision` label.
2. A guard resolves the commit behind the current `:latest`, asks GitHub
`compare/<theirs>...<ours>`, and advances `:latest` (registry-side
retag, no pull) **unless ours is `behind`** — i.e. `:latest` already
holds a descendant and moving it would roll staging back.

**Fails open by design.** No `:latest` yet, unlabelled legacy image,
unreachable API, diverged history → advance. A stuck `:latest` is the
very failure being fixed, so it declines only on *positive proof* of
regression.

**Placement:** in `redeploy-staging` / `redeploy-staging-starters`,
immediately before the Railway pull that consumes `:latest` — not per
build slot. Those jobs already have Node (build slots do **not**, so
per-slot would mean an unpinned `npx tsx` fetch on ~50 parallel
runners), and deciding right before the pull makes the window as narrow
as possible. The image list is the **same matrix ∩ build-success
intersection** that decides what gets redeployed, so a failed build can
never move a tag.

Also adds `showcase_build.yml` to `showcase_validate.yml`'s trigger
paths — the new test asserts against that file's live text, and without
the path a PR re-adding `:latest` would never run the test that catches
it.

## Tradeoffs / what stays open

- **Residual sub-second TOCTOU.** GHCR has no compare-and-swap on tags,
so two runs reading `:latest` simultaneously could still both advance.
This narrows the window from the whole build (~10 min) to inspect→retag.
Fully closing it means retiring the mutable staging tag and pinning
staging to digests the way prod already is — a change to the Railway
image-ref SSOT contract, not a workflow change. **Recommended
follow-up.**
- **The guard is inert for one build per image.** Today's `:latest`
images carry no labels (verified: `showcase-shell-dashboard:latest` has
no `Labels` at all), so the first post-merge build fails open and
advances unconditionally — same as today. Protection starts from the
second build of each image.
- Failure to retag exits non-zero, redding the redeploy job and stopping
the deploy. That is intended: redeploying against a tag that did not
move is exactly the silent false green being fixed.

## Proof

**Red/green on the live YAML.** `advance-latest-tag.test.ts` parses the
real `showcase_build.yml` (extending #6171's `redeploy-guard.test.ts`
pattern). Reverting the workflow to its pre-fix state: **14 failed / 23
passed**. With the fix: **37 passed**. Full `showcase/scripts` suite:
**2382 passed, 73 files**.

**The load-bearing predicate, verified live against the real incident
commits:**

```
compare/db75a04837...59f275e  => behind     (older run arriving late → DECLINE)
compare/59f275eedc...db75a04  => ahead      (newer run → advance)
compare/db75a04837...db75a04  => identical
```

**Label reading, verified against a real multi-platform registry image**
— `docker buildx imagetools inspect ghcr.io/astral-sh/uv:latest` piped
through `extractRevisionLabel()` returns
`3010295ae7ff572de459987ad70db315a62ecd61`, matching `jq` exactly. The
platform-keyed shape is handled.

**Shell/jq transforms** exercised directly, including the empty-CSV edge
case (empty → empty, step skipped by its `if:`).

**Lint:** `actionlint` finding counts byte-identical to the pre-change
baseline (no new findings; the 11 pre-existing are unrelated). `zizmor
--min-severity low` with the repo config: **no findings**.

**Typecheck:** both new files are in `showcase/scripts/tsconfig.json`'s
include set and produce **zero** errors. Worth stating plainly: `nx
run-many -t check-types` **does not reach `showcase/scripts`** — the
project isn't in the nx graph and has no `check-types` target (there are
9 pre-existing type errors in sibling files, which is how I confirmed
it). So the typecheck above is mine, not CI's. The *tests* are gated:
`showcase_validate.yml` runs bare `pnpm exec vitest run` in
`showcase/scripts`, which auto-discovers the new file.

### What I could NOT prove

**I did not construct a real concurrent race on scratch branches.**
Doing it faithfully needs two builds pushing the same GHCR repo with
controlled finish ordering, which means merging to `main` — the only
branch the build workflow triggers on. No run IDs for a live race
demonstration; I am not implying one.

Unproven until this runs on main: that `docker buildx imagetools create`
retags cleanly under the runner's GHCR credentials, and that `npx tsx`
behaves in the redeploy jobs (it is already the established invocation
there — `redeploy-env.ts` — so this is low risk, not zero).

## Normal single-merge builds are unaffected

No concurrency group is added, so nothing queues or cancels. A lone
merge finds `:latest` at its own parent → `ahead` → advances, exactly as
before. Cost is one `imagetools inspect` + one `gh api` + one
registry-side retag per built service, in a job that already exists — no
extra job, no extra checkout, no change to build parallelism.

---

Branched from `db75a04837`; #6156/#6159 landed after, so this will need
main merged in before it goes green.

Probable conflict with the concurrent `git lfs pull` work in
`showcase_validate.yml` — my edit there is only the top-level `on:
paths:` list, so it should merge cleanly, but flagging it.
BenTaylorDev pushed a commit that referenced this pull request Aug 29, 2026
…llowlist

Commits the one-off diagnostic that produced the highest-severity finding of PR
#6156's round-2 review (slot 1-A #1) as a permanent guard. The diagnostic
reconstructed both engines in scratch dirs and diffed them field-by-field; that
form depends on `origin/main` at a moment in time. This is the committable form:
the invariant plus a shape-exact allowlist, one engine, no cross-revision diff.

INV7 promoted from six fixtures to the whole domain — the 6^7 = 279,936
cross-product of the seven status rows an agent-axis cell is derived from (7
slots x {absent, green, greenStale, redFresh, redInfra, redStripped}) — asserting
that no combination renders a red depth pill under a non-committal chip unless
every contributing red row carries positive INFRA_ERROR_CLASSES attribution.
Reproduces slot 1-A's measurement exactly: 19,328 of 279,936, in the same eight
red-pill buckets (pinned separately as SLOT_1A_RED_PILL_BUCKETS).

Two tables, not one, because the residue is not one mechanism:

  - KNOWN_I1_GAP_BREAK_SHAPES (7 shapes, 17,088) — EXCUSED as invariant-I1 debt.
    `scanWorst` breaks at the first ABSENT rung, so a red above the gap is never
    folded and the chip provably never read it. Round-2 partition bucket (d4).
  - QUARANTINED_NON_GAP_MASKING (6 entries, 2,240) — NOT excused. 2,048 are a
    non-infra red D6 sitting outside `scanWorst`'s [D3,D4,D5] walk; 192 have
    their gap at or above the red. The chip read a verdict and still hid a red;
    contiguity excuses nothing here. Separate table, separate wording, separate
    follow-ups, so the I1 note cannot be read as covering them.

The gap predicate mirrors `ladderGapDepth` from cell-model.coherence.test.ts @
49bf40943f: a rung is a gap when no row exists for any of its keys (equivalent to
`classifyRung`'s ABSENT), NOT the strip's `status === null`. Keying off the strip
mis-files the 192 non-gap combinations as excused — measured, not assumed. When
both land, the shared helper should be imported and this copy deleted; the header
says so.

Two-sided by construction, and mutation-proven against the real engine:
  - a shape in no table fails ("NEW masking shape") — proven by deleting an
    entry: reported as 864 + 96 unlisted combinations;
  - an allowlisted shape that stops masking fails ("RATCHET ... OVER-BROAD"), so
    fixing the gap-break forces the table to shrink rather than leaving stale
    cover — proven by inflating an entry 2880 -> 2881;
  - a quarantined shape that stops masking fails ("QUARANTINE SHRANK") — proven
    by inflating an entry 64 -> 65.
In-suite teeth cover the same three directions, including that an emulated (d4)
fix clears all seven allowlisted shapes while leaving the quarantine intact.

Exhaustive, not sampled: the full sweep runs ~2.1 s, so no covering array is
needed. The LiveStatusMap is built once and mutated one key per step in
mixed-radix reflected Gray-code order (Knuth 7.2.1.1 Algorithm H); a control
test re-runs the whole domain rebuilding a fresh map per combination and asserts
an identical histogram. Deterministic: fixed `now` literal, pure engine, no
randomness, no I/O, no wall-clock. The domain identity is asserted too — 6^7
distinct tuples visited exactly once, every (slot, variant) pair 6^6 times, every
step a single-slot delta — so the sweep cannot silently degenerate into a subset.

Product logic is untouched: this is a new test file and nothing else.

NOTE: gates nothing until PR #6168 lands the harness/shell-dashboard unit suites
in CI (they were excluded twice over, by `paths-ignore: showcase/**` and by
`--projects='packages/**'`). Until then it is a local + cr-loop pre-audit
instrument.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant