Repository navigation
Description
Summary and impact
The mock Flows grid unit test "sizes mixed-sign rows from summaries and stripes by row index" (apps/frontend/src/services/mock/flows-grid.test.tsx:125, expect(cell.style.height).toBe(row.style.height)) intermittently sees a value cell 53px tall inside a row styled 52px. It failed the required frontend quality job on backend PR #86, which changes no frontend files. A flaky required gate blocks unrelated PRs; if the mismatch can reach a rendered frame, it is also a user-visible signed-bar geometry defect (spec §6.6). Unknown which: the investigation decides.
Delivery phase
Phase 1 - frontend with mock services. Delivered together with #76 in one PR (maintainer decision 2026-11-15): branch fix/76-87-unit-headroom, PR body Refs #76 and Refs #87.
Steps to reproduce
Observed once in hosted CI: run https://github.com/DavidVFitzGerald/LCA-diff/actions/runs/43750349407 attempt 1 (PR #86 at d3bd9ed, base 9b0ebba): npm run test:unit, 402 passed / 1 failed, 65.5 s; AssertionError: expected '53px' to be '52px'. Attempt 2 (same SHA) passed; the preceding run 43750251968 at 1b9ee46 passed with identical frontend files. Not yet reproduced locally.
Reproduction attempts (worktree/project from #76):
docker compose -p lca-diff-headroom exec -T workspace bash -lc 'cd apps/frontend && fails=0; for i in $(seq 1 50); do npx vitest run src/services/mock/flows-grid.test.tsx -t "sizes mixed-sign rows" >/dev/null 2>&1 || { fails=$((fails+1)); echo "fail $i"; }; done; echo "isolated fails=$fails/50"'
docker compose -p lca-diff-headroom exec -T workspace bash -lc 'cd apps/frontend && fails=0; for i in $(seq 1 10); do npx vitest run src/services/mock/ >/dev/null 2>&1 || { fails=$((fails+1)); echo "fail $i"; }; done; echo "mock-dir fails=$fails/10"'Plus every full run made for #76.
Expected behavior and authority
Spec §6.6 (signed-bar exact geometry: one row height from the whole-row summary, cells fill it) and §9.2 item 15; roadmap F4 gate (coherent mixed-sign row heights, no height jumps). In every rendered frame, each mounted value cell's height equals its row's height, and rows start where the previous one ends. The unit test should pass deterministically. A test-only fix must first show that product behaviour is correct.
Actual behavior
Intermittent: a mounted value cell has style.height 53px while its row has 52px (the virtualizer's estimate, DEFAULT_ROW_HEIGHT). Only this assertion failed; no backend test or provider data involved.
Lead to check (hypothesis only): SignedValueCell takes row.rowHeight from the summary geometry at render time, while the row's style.height is the virtualizer's row.size, which ComparisonGrid.tsx updates via rowWindow.resizeItem inside a queueMicrotask scheduled from useLayoutEffect. The test's waitFor passes once any row exceeds 52px, and Testing Library's MutationObserver callback may run between the commit and that microtask, or newly summarized rows may be in that window. Whether a browser can paint the mismatch depends on whether the virtualizer's resulting re-render is flushed before paint.
Environment and version
Hosted Ubuntu 24.04, pinned node:24-bookworm container, Node 24.22.3, Vitest 5.1.0, jsdom 31.0.1, @tanstack/react-virtual 3.14.24, React 19.3.1. Mock adapter, synthetic 220 × 2,000+ workload. Reproduce locally in the rootless workspace container.
Context and dependencies
F4 grid #23 / gate #26 (merged, af5317d). Groomed READY 2026-11-15 together with #76; no other dependency. Frontend-only fix in the #76 branch. Concurrent #27 (PR #88) does not touch the grid files.
Acceptance criteria
- AC1 Reproduce/characterize (first step, before any fix). Record the counts from the 50 isolated runs, 10
src/services/mock/runs and the [Task] Restore unit-test budget headroom for the 300-selection and deep-scroll tests #76 baseline full runs. Independently of whether it reproduces, run two temporary, uncommitted probes and record their results:- jsdom: a MutationObserver (or equivalent) during the test's scroll to row 300 that records every mutation batch in which a mounted
[role="gridcell"][data-state]height differs from its row's, and whether the mismatch persists across a macrotask (setTimeout(0)). - browser, both projects: in the large scenario, sample every
requestAnimationFrameduring the scroll to row ~300 and the deep jump toscrollTop40,000 (≥ 300 frames per project), counting frames where any mounted value cell's rendered height (getBoundingClientRect) differs from its row's by > 0.5 px.
- jsdom: a MutationObserver (or equivalent) during the test's scroll to row 300 that records every mutation batch in which a mounted
- AC2 Classify and fix.
- (A) Assertion race only if the browser probe finds 0 mismatched frames in both projects and the jsdom mismatch never survives a macrotask. Fix the test's synchronization so it asserts the same per-row/per-cell equality and row-start contiguity for every mounted row on a settled grid (no tolerance, no
toBeCloseToon heights, no dropping rows from the check); it must still fail if equality is never reached. - (B) Geometry defect if any rendered frame mismatches or the mismatch survives a macrotask. Fix product code so a row and its cells take their height from one value in the same commit (e.g. in
ComparisonGrid.tsx/useFlowGrid.ts/SignedValueCell.tsx), without breaking view anchoring ([Task] F4 — Virtualize comparison rows and columns with sticky alignment #23 D2-D4) or theflushSync-in-lifecycle constraint.
- (A) Assertion race only if the browser probe finds 0 mismatched frames in both projects and the jsdom mismatch never survives a macrotask. Fix the test's synchronization so it asserts the same per-row/per-cell equality and row-start contiguity for every mounted row on a settled grid (no tolerance, no
- AC3 Regression. (A): the corrected unit test plus a committed note in the test explaining the synchronization. (B): a committed regression test (jsdom mutation-level check and/or a browser frame check in
e2e/flows-grid.spec.ts) that is shown to fail on the pre-fix code (record the failing run) and pass after. Existing §6.6 geometry tests (geometry.test.ts,SignedValueCell.test.tsx, the mixed-sign grid test) keep their assertions. - AC4 Stability. After the fix: 0 failures in 50 isolated runs of the test, 10
src/services/mock/runs, and the [Task] Restore unit-test budget headroom for the 300-selection and deep-scroll tests #76 AC3/AC4 full runs. - AC5 Gates. [Task] Restore unit-test budget headroom for the 300-selection and deep-scroll tests #76 AC9 gates pass; full e2e in both projects if product code changed. Evidence (probe method, counts, classification) is recorded in
docs/engineering/unit-headroom-verification.mdand the handoff.
Regression and verification plan
Commands above and in #76's verification plan (project lca-diff-headroom, port 5221). Browser probe via a temporary spec run with npm run test:e2e -- --project=chromium <probe> and --project=firefox <probe>, removed afterwards (git status clean). Independent QA at the delivered SHA. Mock evidence only; does not prove real API integration.
Out of scope and follow-ups
No backend changes, timeout increases for this test, retries or disabled checks. Other flakes get their own issues (#51 already tracked). B4 and I1 unaffected.
Activity
DavidVFitzGerald commentedon Nov 15, 2026
The single failed-job rerun passed, including the full frontend workflow: https://github.com/DavidVFitzGerald/LCA-diff/actions/runs/43750349407 . No source changes occurred between attempts. Keep this investigation open; the transient failure evidence remains in attempt 1.
DavidVFitzGerald commentedon Nov 15, 2026
PM: READY (delivered with #76 in one PR)
fix/76-87-unit-headroom, projectlca-diff-headroomand port 5221. The PR body saysRefs #76andRefs #87.main(af5317d).src/services/mock/, and the [Task] Restore unit-test budget headroom for the 300-selection and deep-scroll tests #76 full runs.ComparisonGrid.tsx,useFlowGrid.tsorSignedValueCell.tsx), with one height source per commit. It must keep the [Task] F4 — Virtualize comparison rows and columns with sticky alignment #23 D2–D4 anchoring and must not callflushSyncinside a lifecycle method. It needs a regression test shown to fail before the fix.row.size. That is updated byresizeItemin a microtask queued fromuseLayoutEffect. This is only a hypothesis; the probes decide.Hand-off: Software Engineer (with #76), then QA at the delivered SHA.
🤖 Generated with Claude Code
DavidVFitzGerald commentedon Nov 15, 2026
Coordinator: state → implementing (one PR for #76 + #87, maintainer decision 2026-11-15). Software Engineer assigned on
fix/76-87-unit-headroomfromaf5317d, worktree/tmp/lca-diff-headroom, Compose projectlca-diff-headroom, port 5221. #52 runs in parallel; AC3 gate runs need a quiet host and are coordinated with the coordinator.🤖 Generated with Claude Code
DavidVFitzGerald commentedon Nov 16, 2026
Engineering: READY FOR QA (#87, delivered with #76)
fix/76-87-unit-headroom7e4e1c2. This commit adds only the doc; every check ran at code SHAdecb56a.d78ccd8docs/engineering/unit-headroom-verification.md, section "Intermittent mixed-sign grid row/cell height assertion in frontend CI #87".AC1: reproduce and characterize, at
af5317dbefore any fixsrc/services/mock/runs had 0 mixed-sign failures; 4 runs failed only on [Task] Restore unit-test budget headroom for the 300-selection and deep-scroll tests #76 budgets. The 3 [Task] Restore unit-test budget headroom for the 300-selection and deep-scroll tests #76 baseline full runs had 0 mixed-sign failures.setTimeout(0).scrollTop40,000, comparinggetBoundingClientRectheights with a 0.5px tolerance. Chromium had 1 of 396 frames mismatched (frame 78, row 302: row 52px, cell 53px); Firefox had 0 of 396.AC2: classification B, geometry defect
Chromium painted a mismatched frame.
Cause. The lead was right:
row.size.resizeItemupdatesrow.sizefrom a microtask after the layout effect, through a non-synchronous re-render, so the new size reaches the row one commit after the cell.Fix (product code).
ComparisonGridpassesrenderCellthe row's height in that commit.FlowsGriduses the summary geometry only once the row has that height. Until then the cell stays pending at the row's height, so every commit has one height per row.pinandrecord([Task] F4 — Virtualize comparison rows and columns with sticky alignment #23 D2–D4) are unchanged. NoflushSyncis added.AC3: regression
row 295: 53px in 52px). After the fix it passes.geometry.test.tsandSignedValueCell.test.tsxare unchanged and pass.AC4: stability
src/services/mock/runs failed, at6c0b839.AC5: gates
Run in the container at
decb56a:npm ci(lockfile unchanged),format:check,lint,typecheckandbuildpass.@smoke: 14 passed.qualitypassed (run 43781924606), and the hostedworkflow_dispatchfull run passed (run 43781929921, 68 browser tests).Limitations and residual risk
af5317d). Atdecb56aits transient unmount can last one more commit, plausibly from this deferral; it is tracked in Bug: deep-scroll focus test loses row 1310 under load (flows-grid D1/D2) #93.Next: QA, at delivered SHA
7e4e1c2.🤖 Generated with Claude Code
DavidVFitzGerald commentedon Nov 16, 2026
Coordinator state: QA. The Engineer handed off PR #94 at
7e4e1c2(code atdecb56a). Independent QA starts in a detached worktree at7e4e1c2. Heavy runs wait for the #52 QA suite to go idle.🤖 Generated with Claude Code
DavidVFitzGerald commentedon Nov 16, 2026
QA: PASS
All #87 criteria passed. The PR as a whole is still held by #76 AC4; see the #76 QA comment.
What I reviewed
fix/76-87-unit-headroom, delivered SHA7e4e1c2a65b43c42cea04f2533e81178a9b276d0. The code SHA isdecb56a; the fix landed ind78ccd8.lca-diff-headroom-qa, port 5229. The worktree was detached at7e4e1c2and stayed clean.Criteria
af5317d(0/50, 0/10, 0/3) and both probes: jsdom showed 2 of 6 batches mismatched in 10 of 10 runs, surviving a microtask but not a macrotask; Chromium showed 1 of 396 frames mismatched and Firefox 0 of 396. I did not re-run the browser probe.AC2: classification and fix
ComparisonGridpassesrow.size, the same value it uses for the row'sstyle.height, torenderCell.FlowsGriduses the summary geometry only whensummarized.rowHeight === rowHeight. Otherwise the cell is pending at the row's height.resizeItemmicrotask inuseLayoutEffect, andpin/record([Task] F4 — Virtualize comparison rows and columns with sticky alignment #23 D2–D4), are untouched. The anchoring, columns and hold files pass.flushSync. The diff adds none; the only existing one is inProcessHeaders.tsxand was already there.[data-state]cells at the row's height. So cells do get the summary geometry once the row resizes, and don't stay pending.AC3: regression test shown failing before the fix
Pre-fix run. I used a scratch copy of the delivered tree with only
ComparisonGrid.tsxandFlowsGrid.tsxrestored frommain, uncommitted. The mixed-sign test failed 3 of 3:Delivered code. The same test passed 3 of 3.
Existing tests. The existing equality, stripe and contiguity checks are unchanged and now run on a settled grid.
geometry.test.tsandSignedValueCell.test.tsxare unchanged and pass. There is no height tolerance and notoBeCloseToon heights; the onlytoBeCloseTois the existing one on row start offsets.AC4: stability, at the delivered code, unscaled
-t "sizes mixed-sign rows"(230 s)src/services/mock/(201 tests each, 410 s)The one failure in the AC4 pairs was the #93 D1/D2 race, not this test.
AC5: gates, in the container
npm ci(lockfile unchanged),format:check,lint,typecheckandbuildpass.@smoke: 14 passed.7e4e1c2is green:quality43781924606,workflow_dispatch43781929921, plus Backend and ETL.unit-headroom-verification.md.Commands
Notes
Next: this issue is ready for review with the PR, but the PR stays held by #76 AC4.
🤖 Generated with Claude Code
DavidVFitzGerald commentedon Nov 16, 2026
Coordinator state: ready for review.
41de025for [Task] Restore unit-test budget headroom for the 300-selection and deep-scroll tests #76, Intermittent mixed-sign grid row/cell height assertion in frontend CI #87 and Bug: deep-scroll focus test loses row 1310 under load (flows-grid D1/D2) #93 (#93 QA, #76 QA), and the hosted checks are green.flushSyncwording, which QA had noted.🤖 Generated with Claude Code
fix: size value cells from their row's committed height (Refs #87)
docs: record the #76 headroom and #87 row-height evidence (Refs #76, #87
DavidVFitzGerald commentedon Nov 16, 2026
Coordinator: closed. PR #94 merged at
eea972fafter QA PASS and green hosted checks.🤖 Generated with Claude Code