Skip to content

[Task] F4 — Build shared process headers and comparability warnings #21

Closed

Description

@DavidVFitzGerald

Delivery phase

Phase 1 - frontend with mock services. Milestone F4; task key F4-02.

Goal

Show complete readable process identity and basis information consistently in both comparison tabs.

Context and authority

Read AGENTS.md, docs/product/LCA_diff_PRD.md, docs/engineering/LCA_diff_Implementation_Specification.md, docs/engineering/roadmap.md, and docs/team/product-manager.md. Do not read archive/reference folders. Current governance/spec documents are prepared on branch docs/agent-workflow; acceptance/merge authority follows docs/adr/README.md, not proposed ADR status. Any contract deviation needs an ADR and both current document updates in the same PR.

Specification §§6.3–6.5, 6.8. Planned files: apps/frontend/src/components/comparison/, shared comparison state/hooks and service-header tests (planned).

Requirements and constraints

Use the canonical selection/order from F3 and bulk header services; do not duplicate selection ownership. Build the reusable metadata header now and consume it in Scores under F5. Choose separate documented width bounds per tab within the specification's recommended range, retaining minimum widths and horizontal scroll.

All work runs in containers with synthetic mock data and no API/Firebase/cloud dependency. Keep HTTP/auth/fixtures behind typed services and mock adapters; components consume contracts rather than fixtures. Follow Software Engineer and QA role handoffs, commit focused increments referencing this issue, and leave it open for QA/review.

Acceptance criteria

  • AC1 — Headers visibly show Process Name, Location, Reference Flow Name, Reference Amount and Reference Unit, with full process/release identity available on hover/focus or accessible name.
  • AC2 — Long text ellipsizes and full values are keyboard-discoverable; small selection keeps normal maximum width, large selection reaches a readable minimum and scrolls.
  • AC3 — A non-blocking warning appears if any selected reference amount OR unit differs; equal exact values such as 1 and 1.0 do not cause a false quantity warning.
  • AC4 — The warning states that no normalization was applied, never changes amounts and does not require confirmation or prevent comparison.
  • AC5 — Selection/order updates fetch bounded bulk headers and preserve exact amount strings and safe missing-geography displays.

Out of scope and follow-ups

Sticky virtualization belongs to #23, drag/reorder/removal to #25, and mounting the header in Scores to #28. No interactive normalization.

Verification plan

Run on the Docker host: ./dev shell, then inside /workspaces/lca-diff: npm --prefix apps/frontend run format:check, npm --prefix apps/frontend run lint, npm --prefix apps/frontend run typecheck, npm --prefix apps/frontend run test:unit, and npm --prefix apps/frontend run build. These scripts are established by F1, not claimed available today. Browser scenarios use npm --prefix apps/frontend run test:e2e -- --project=chromium (F1 establishes the pinned Playwright tool/browser setup). No host package installs.

Component tests cover 0/1/many processes, long Unicode names, same/different amount and unit, exact decimal equivalence, width limits and hover/focus identity. Add a browser header/warning scenario.

Record exact commands/results and delivered SHA in the engineering handoff. QA independently checks every criterion at that SHA and reports PASS/FAIL/BLOCKED; unavailable required checks are not passing.

Dependencies and readiness

Blocking predecessors: #20. Also requires verified M1 container runtime and merged bootstrap/M2 configuration; later milestones are planned, not implementation-ready while predecessors remain open. PM must recheck dependencies and actual interfaces before marking READY.

Activity

  1. added
    task
    frontend
    blocked
    on Nov 13, 2026
  2. DavidVFitzGerald commented on Nov 13, 2026

    @DavidVFitzGerald
    OwnerAuthor

    PM: BLOCKED

    Groomed using docs/team/product-manager.md for F4, Phase 1 — frontend with mock services. Documentation review: PASS for scope, required sections, specification coverage and acyclic dependency links; this is not application QA or implementation readiness.

    Blocking predecessor issues: #20. The M1 runtime gate (#2) and merged bootstrap/M2 configuration (#3) also remain required. PM must recheck merged dependencies and current interfaces before changing this to READY.

    Engineer implements one issue, commits regularly and hands the delivered SHA plus exact container checks to independent QA; do not close before QA, review and approved merge. No backend/Firebase/cloud credentials or host installations are required for Phase 1.

  3. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    PM: READY (recheck)

    The blocking predecessor #20 is closed (PR #63 merged). M1 and the bootstrap/M2 configuration are merged. The actual interfaces were rechecked:

    • the ordered selection store in app/selection.ts
    • DataService.headers and the ProcessHeader DTO (exact decimal reference_amount)
    • services/decimal.ts for exact comparison

    Removing the blocked label.

  4. removed
    blocked
    on Nov 14, 2026
  5. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: READY FOR QA

    Criteria

    • AC1, implemented. Headers show Process Name, Location, Reference Flow Name, Reference Amount and Reference Unit. Each header's accessible description and its hover/focus overlay give the full identity: release, revision and process ID.

    • AC2, implemented. Values ellipsize, and the name clamps to 2 lines. Full values are reachable by keyboard: one roving tab stop, with arrows, Home and End. Widths are clamp(available / count, min, max):

      • Flows: 120–240 px
      • Scores: 110–230 px (documented in components/comparison/model.ts)

      Many columns stay at the minimum width and scroll horizontally. They are windowed, so 300 selected columns mount about 13.

    • AC3, implemented. The warning appears if any amount differs exactly or any unit differs as an exact string. 1, 1.0 and 1e0 (across releases) raise no warning.

    • AC4, implemented. The text says "No normalization has been applied", with a "Why?" tooltip. There is no dialog or confirmation, values are not rescaled, and the warning never blocks comparison.

    • AC5, implemented. One headers query per revision:

      • The key is order-independent, so a reorder makes no request.
      • Headers are cached per process, so an added process fetches only uncached IDs.
      • Batches stay within SERVICE_WINDOW (100).
      • Exact amount strings are shown.
      • Missing geography shows —, read as "not specified".
      • Responses for another revision are rejected as STALE_SNAPSHOT; missing or extra IDs as UNKNOWN_PROCESS.

    Commands (./dev up, then in the workspace container at /workspaces/lca-diff)

    • npm --prefix apps/frontend run format:check — pass
    • npm --prefix apps/frontend run lint — pass
    • npm --prefix apps/frontend run typecheck — pass
    • npm --prefix apps/frontend run test:unit — 23 files, 275 tests pass, stable over 3 consecutive runs
    • npm --prefix apps/frontend run build — pass
    • npm --prefix apps/frontend run test:e2e -- --project=chromium — 19/19 pass
    • npm --prefix apps/frontend run test:e2e -- --project=firefox e2e/process-headers.spec.ts — pass

    The stderr lines in the process-tree and process-search unit tests are pre-existing: the count is identical on the base commit.

    Notes for QA

    • Supporting changes.
      • The UI lint boundary now allows transport-free services/decimal; a boundary test pins this.
      • Bulk selection seeds the per-process header cache, so headers are not fetched twice.
      • The test harness mount accepts an optional ui.
      • The bulk-selection.test.tsx header-failure stub now fails only multi-ID (bulk) reads, because the Flows header now also reads the single pre-selected process.
    • Early windowing. Header columns are windowed now, not left to [Task] F4 — Virtualize comparison rows and columns with sticky alignment #23. Unwindowed headers made the 300-process bulk test intermittently time out in jsdom, which also points to a real browser cost. [Task] F4 — Virtualize comparison rows and columns with sticky alignment #23 should share this column window with the cells.
    • Manual check. Sign in as [email protected], then expand transport systems › road › operations › infrastructure.
      • Select Alpha: no warning.
      • Add Gamma: the warning names units.
      • Add Beta: the warning names amounts and units.
      • Focus a header and use the arrows; the overlay shows the full identity.
      • Remove Gamma from the selected list: the warning names amounts only.

    Limitations and follow-ups

    Next: independent QA at 4c8fde9.

  6. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: FAIL

    Criteria

    AC Verdict Evidence
    AC1: five fields, plus full identity on hover/focus or in the accessible name PASS (see D1 for the failure state) Code: ProcessHeaders.tsx HeaderCell and details(). The accessible description includes release, revision and process ID. The overlay appears on focus and hover. Unit test and E2E cover this in Chromium and Firefox.
    AC2: ellipsis, keyboard discoverability, max width for few columns, min width and scroll for many PASS Bounds are Flows 120–240 and Scores 110–230, inside §6.3's ranges (110–130 min, 230–260 max). clamp(floor(avail/count)) is used. The scroller has overflow-x: auto. With 300 columns, under 20 are mounted. There is one roving tab stop.
    AC3: warning when any amount OR unit differs, and no false warning for 1/1.0 FAIL Exact decimal compare is correct (1, 1.0, 1e0, +1.000, 10, 0.1E2, .1e+2; -0 equals 0; 1 vs 1.0…01 warns). Units compare as exact strings. But a known difference disappears when a later header read fails (D1).
    AC4: says no normalization was applied, never changes amounts, no confirmation or block PASS The text reads "No normalization has been applied." The "Why?" tooltip is shown on focus and hover. There is no dialog. Exact lexemes such as 2.0000000000000000000000001 and 1.0 are shown unchanged.
    AC5: bounded bulk headers on selection/order updates, exact strings, safe missing geography PASS (observation O1) 250 IDs were fetched as 100/100/50. A reorder makes no request. An add fetches only the new ID. A removal makes no request. A wrong revision gives STALE_SNAPSHOT, and missing or duplicate IDs give UNKNOWN_PROCESS; none of these are cached (QA probes P5 and P6). Blank geography shows — with the accessible text "not specified".

    Defects

    D1: Medium (blocks AC3). A failed header read hides known comparability differences and reverts loaded headers to "Loading…".

    • Where:
      • apps/frontend/src/components/comparison/useSelectionHeaders.ts:58 (result.data ?? [])
      • apps/frontend/src/app/queries.ts:303 (placeholderData applies only while the query is pending)
      • apps/frontend/src/components/comparison/ComparisonHeader.tsx:48
    • Cause:
      • The selection key changes, so a new query is created. On failure that query enters error with no data, because placeholder data is not used in the error state.
      • retry: false is the global default (ApplicationProviders.tsx:34), so any single transient failure reaches this state.
      • The per-process cache still holds the already-validated headers, but they are not used.
    • Repro (component, discovery mock, comparison-headers.test.tsx fixtures):
      1. Select r1:p0 (Alpha, kg) and r1:p3 (Gamma, MJ).
      2. The warning reads "…different reference units. No normalization has been applied."
      3. Make headers return failure("TEMPORARILY_UNAVAILABLE"), then select r1:p2.
    • Expected:
      • The known Alpha/Gamma unit difference is still warned about, because they are still selected (AC3; README: "reports only differences already known").
      • Alpha and Gamma keep their loaded metadata (AC1), and the error alert explains that the new process could not load.
    • Actual:
      • The warning text is "".
      • All 3 columns are aria-busy="true", and Alpha shows "Reference Loading…" next to the error alert.
      • The state persists until Retry succeeds.
      • The same happens on any failed refetch after a selection change.
    • Suggested direction (engineering's choice):
      • Build headers and loaded from the per-process cache in addition to result.data, including in the error state.
      • Distinguish "failed" from "loading" in the cell.
      • Add a regression test for "known difference survives a failed add".
    • Test gap: the existing "explains a failed header read" test starts from an empty cache, so it cannot detect this.

    Observations (non-blocking, suggested follow-ups)

    O1: Bulk-seeded header cache skips #21's validation.

    • useBulkSelection.ts:155 passes headersFor results (queries.ts:205) to rememberHeaders. That path, from [Task] F3: implement filter-scoped bulk selection and tri-state parent checkboxes #19, does not check the response snapshot, the per-item revision or the ID set.
    • rememberHeaders keys each header by the release, revision and ID the response itself reports. selectionHeaders then serves those headers with no request, which bypasses its own STALE_SNAPSHOT/UNKNOWN_PROCESS checks.
    • The README says "Seed the per-process cache from any validated header read" and "every batch must answer the requested revision". Bulk reads are not validated.
    • Impact is mock-only today. Bulk selection already trusts these headers for the selection entries, a pre-existing [Task] F3: implement filter-scoped bulk selection and tri-state parent checkboxes #19 gap.
    • Recommendation: validate in headersFor, or validate before rememberHeaders. Fix it with D1 or track it for I1 adapter parity.

    O2: Malformed amounts throw during render. compareDecimal throws TypeError on a malformed amount, and comparability() calls it during render. DTOs are typed as DecimalString and the mock validates them, but a real adapter should reject malformed amounts at the boundary (I1).

    O3: Large-selection evidence is component-level only. Windowing and minimum width for hundreds of columns are proven only in jsdom. Real-browser evidence of horizontal scrolling at minimum width is deferred to #23, as documented.

    Checked with no issue found:

    • Roving tab stop:
      • Removing the focused or active column moves the single tab stop to index 0.
      • The active column stays mounted when it is windowed out (End on 62 columns mounted indices 0–12 plus 61).
      • Removing that windowed active column leaves exactly one tab stop.
    • Account change and signout:
      • After switching account, no account-a query keys remain. The per-process header keys include the UID.
      • After signout, no query holds data and the column shows no header data.
    • Lint boundary: services/decimal.ts imports only type DecimalString from contracts, so it is transport-free. The boundary test pins both the decimal allowance and the continued rejection of services/mock/runtime.
    • Selection ownership: useSelectionHeaders and ComparisonHeader read useSelection().entries and own no order. Components import only services/contracts (type) and services/decimal.
    • Tests fail without the behavior:
      • The model tests would fail under a string comparison for 1/1.0.
      • The call-count test would fail if a reorder refetched.
      • The tab-stop and windowing tests assert counts.
    • Scope and contract:
      • The bulk-selection.test.tsx stub change is justified, because the Flows header now reads the single pick.
      • Early header windowing is an implementation choice within §§6.3/9.1.
      • No PRD or spec deviation was found, so no ADR is needed.

    Commands and results

    All commands ran via docker compose --project-directory . -f compose.yaml exec -T workspace bash -lc 'cd /workspaces/lca-diff && …'.

    Command Result
    npm --prefix apps/frontend run format:check pass
    npm --prefix apps/frontend run lint pass (0 warnings)
    npm --prefix apps/frontend run typecheck pass
    npm --prefix apps/frontend run test:unit, run 1 23 files, 275 tests passed
    npm --prefix apps/frontend run test:unit, run 2 23 files, 275 tests passed (stable)
    npm --prefix apps/frontend run build pass (vite 8.3.8, 102 modules)
    npm --prefix apps/frontend run test:e2e -- --project=chromium 19/19 passed
    npm --prefix apps/frontend run test:e2e -- --project=firefox e2e/process-headers.spec.ts 1/1 passed
    QA probe npx vitest run src/services/mock/zz-qa-headers.test.tsx (temporary file, deleted afterwards) P1 reproduces D1 (logged evidence above). P3–P7 passed.

    The working tree was clean after the probe was removed (git status --short printed nothing). Implementation and tests are unchanged.

    Not run: real API, Firebase or authorization checks, which are out of scope for Phase 1.

    Next action

    FAIL returns to Engineering to fix D1 with a regression test and, optionally, O1. QA will then recheck the new SHA: AC1, AC3, AC5 and the full required checks.

  7. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: READY FOR QA (after QA FAIL)

    Delivered SHA: c559c63 on feat/f4-process-headers (PR #65). It contains one fix commit on top of 4c8fde9.

    Fixes

    D1, fixed. Placeholder data applies only while a query is pending, so a failed read left no headers at all.

    • useSelectionHeaders now falls back to the validated per-process cache (queries.cachedHeaders) for any revision whose query has no data.
    • Already-loaded columns and known differences now survive a failed read; only unread columns stay busy.
    • Regression test: "keeps loaded headers and known differences when a later read fails (QA D1)" in services/mock/comparison-headers.test.tsx. It loads kg/MJ headers first, then makes the next read fail and retries.

    O1, fixed.

    • The bulk read headersFor now applies the same shared invalidHeaders check as selectionHeaders: it must answer the requested revision (STALE_SNAPSHOT otherwise) with exactly the requested IDs, once each (UNKNOWN_PROCESS otherwise).
    • A read with any invalid batch fails as a whole, so rememberHeaders only ever receives validated headers.
    • New tests in the same file:
      • rejection of another revision, a missing ID and a duplicated ID, each leaving the cache empty
      • a valid read whose headers the selection query reuses

    O2, documented, not fixed. The README now states that the real adapter must validate decimal amounts at its boundary (I1).

    O3: unchanged, deferred to #23.

    Mutation check

    • Reverting the D1 fallback fails the D1 test.
    • Removing the bulk validation fails all three rejection tests.

    Commands

    Run in the workspace container at /workspaces/lca-diff:

    • npm --prefix apps/frontend run format:check — pass
    • npm --prefix apps/frontend run lint — pass
    • npm --prefix apps/frontend run typecheck — pass
    • npm --prefix apps/frontend run build — pass
    • npm --prefix apps/frontend run test:unit — 23 files, 280 tests pass (run twice)
    • npm --prefix apps/frontend run test:e2e -- --project=chromium — 19/19 pass
    • npm --prefix apps/frontend run test:e2e -- --project=firefox e2e/process-headers.spec.ts — 1/1 pass

    Next: QA recheck at c559c63.

  8. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: FAIL

    • Verified SHA: c559c638b46f099a0022d2cb00ab51b512178111 (feat/f4-process-headers, PR F4: shared process headers and comparability warnings (#21) #65). The fix diff is 4c8fde9..c559c63; the whole PR is 16e9802..c559c63.
    • Mode: Phase 1, mock services only. There is no real API, Firebase or authorization evidence.
    • Environment: the existing rootless workspace container (lca-diff-dev-workspace-1) at /workspaces/lca-diff. Nothing was installed on the host.
    • Authority used: AGENTS.md, docs/team/qa-engineer.md, issue [Task] F4 — Build shared process headers and comparability warnings #21 and its comments, spec §§6.3–6.5, 6.8 and 7.1–7.3, and apps/frontend/src/services/README.md. No archive or reference folders were used.

    Summary

    • O1 is fixed, and every required check passes.
    • D1 is fixed only while the per-process header cache is still in memory. That cache is made of unobserved TanStack queries. They are garbage-collected after the default gcTime of 5 minutes, even while their columns are on screen.
    • After that, a single failed read on the next selection change reproduces D1 exactly: the known difference disappears and every column reverts to "Loading…". Reading a comparison for more than 5 minutes before adding a process is an ordinary journey, so AC3 still fails (D2 below).

    Criteria

    AC Verdict Evidence
    AC1: five fields, plus full identity on hover/focus or in the accessible name PASS Unchanged by the fix. Unit tests and E2E pass in Chromium and Firefox. Loaded columns keep their metadata after an immediate failed read (probe R1).
    AC2: ellipsis, keyboard discoverability, max/min width, scroll PASS Not touched by the fix. Unit and E2E tests pass; the evidence from the previous QA still applies.
    AC3: warning when any amount OR unit differs, and no false warning for 1/1.0 FAIL The immediate-failure cases pass (R1–R5). The known difference is still lost when a failure follows cache expiry (D2).
    AC4: says no normalization was applied, never changes amounts, no confirmation or block PASS Not touched by the fix; tests pass.
    AC5: bounded bulk headers, exact strings, safe missing geography PASS A valid 260-ID bulk read makes requests of 100/100/60 IDs and seeds 260 per-process entries. The comparison header then makes no extra request (probe B5). Invalid bulk reads are rejected (O1). After cache expiry, all IDs are refetched, not only the new one. That follows from D2 and does not by itself violate the "uncached IDs" wording.

    Status of earlier findings

    • D1: partly fixed. The remaining gap is D2. The scenarios below were verified with the probe zz-qa-recheck.test.tsx, run under src/services/mock/ and deleted afterwards.
      • R1, the original scenario.
        • Load Alpha (kg) and Gamma (MJ), then fail the next read and add the r1:p2 process.
        • The warning still reads "…different reference units." and does not claim amounts.
        • Alpha and the MJ column keep aria-busy="false" with their values shown. Only the unread column is busy (1 of 3).
        • Retry recovers to "different reference amounts and units", requesting only ["r1:p2"].
      • R2a, two revisions, failure in the r1 group. The r2 column and the loaded r1 columns stay loaded, the warning stays, 1 column is busy, and Retry recovers.
      • R2b, two revisions, failure of a new r2 group. The r1 columns and the warning stay, and Retry requests only ["r2:p0"].
      • R3, deselect and reselect, then a failure.
        • Reselecting comes from the cache, with no request and no alert.
        • A later failure keeps the warning.
        • Deselecting the failed process clears the alert and leaves nothing busy.
      • R4, the very first read fails. The warning is empty, all 3 columns are busy, there is no equality claim, and Retry recovers.
      • R5, account change and signout during the failure state.
        • After switching to account-b, no account-a query keys remain, the warning is empty and no MJ value is shown.
        • After signout, no query holds data, and no kg or MJ value is shown.
      • R6 and R6b, cache expiry: FAIL (D2).
    • O1: fixed.
      • headersFor applies the shared invalidHeaders check: the requested revision (STALE_SNAPSHOT) and the exact ID set, each once (UNKNOWN_PROCESS).

      • End to end through the App's bulk branch action (probe zz-qa-bulk.test.tsx), four tampered multi-ID responses were tried:

        • one header from another revision
        • a missing ID
        • a duplicated ID
        • a wrong response snapshot

        Each one leaves "Selected processes (0)" and 0 per-process cache entries, and shows "Selection unchanged: could not update processes in rail. Response does not match…".

      • A valid bulk read seeds the cache, and the comparison header then issues no extra request.

    • O2: documented as an I1 adapter obligation in the README. This is acceptable for Phase 1. The mock creates DTOs as DecimalString, and only the real adapter can receive malformed amounts. I1 should carry a test that a malformed reference_amount becomes a structured error at the boundary rather than a render-time TypeError.
    • O3: unchanged, deferred to [Task] F4 — Virtualize comparison rows and columns with sticky alignment #23 as documented. This is acceptable.

    Defects

    D2: Medium (blocks AC3). D1 comes back once the per-process header cache expires, after 5 minutes.

    • Where:
      • apps/frontend/src/app/queries.ts:160: rememberHeaders → client.setQueryData(headerKey(header), header). These header queries never have observers.
      • apps/frontend/src/app/ApplicationProviders.tsx:31-37: there is no gcTime override, so TanStack Query 5.107.1 uses the default of 300000 ms. refetchOnWindowFocus: false means nothing repopulates the cache.
      • apps/frontend/src/components/comparison/useSelectionHeaders.ts:62-63: the fallback queries.cachedHeaders(...), and the placeholderData in queries.ts:336, both read only those expiring entries.
    • Cause:
      • The current selection's set query stays observed and keeps its data.
      • The per-process entries that the fallback and placeholder depend on are collected after 5 minutes, while the columns are still displayed.
      • The README says "Headers are immutable per revision and cached per process"; in practice they are cached for at most 5 minutes unobserved.
    • Repro (probe R6b; component level, discovery mock, the same fixtures as comparison-headers.test.tsx):
      1. vi.useFakeTimers({ shouldAdvanceTime: true }), then render ComparisonHeader through mount({ ui }).
      2. Select r1:p0 (Alpha, kg) and r1:p3 (Gamma, MJ), and wait until they are loaded. The warning reads "…different reference units."
      3. Per-process header entries: 2, with observer counts [0, 0] and gcTime [300000, 300000].
      4. vi.advanceTimersByTime(301000). Per-process header entries: 0.
      5. Make headers return failure("TEMPORARILY_UNAVAILABLE", true), then select r1:p2.
    • Expected: as with an immediate failure (R1), the Alpha/Gamma unit difference is still warned about, and only the new column is busy.
    • Actual:
      • The warning text is "", and 3 of 3 columns are aria-busy="true".
      • The failed request was for ["r1:p0","r1:p2","r1:p3"]; every ID was refetched.
      • This is the D1 behavior, and it lasts until Retry succeeds.
      • Removing the entries by hand, as in R6, gives the same result.
    • Suggested direction (engineering's choice):
      • Keep validated header entries for the session, for example with client.setQueryDefaults([...header prefix], { gcTime: Infinity }). They are already UID-scoped and cleared on signout or account change; recheck this.
      • Alternatively, fall back to the last successful data of the revision's previous selection query.
    • Test gap: add a regression test that advances time past gcTime before the failed read.

    Other checks

    • The new tests fail without the fix (mutation check). This ran in a container-local copy at /tmp/qa-mut; tracked files were not touched, and the copy was deleted afterwards.
      • Restoring the 4c8fde9 version of useSelectionHeaders.ts fails only "keeps loaded headers and known differences when a later read fails (QA D1)" (1 failed, 11 passed).
      • Removing the invalidHeaders call from headersFor fails exactly the three "rejects … before anything can be cached" tests (3 failed, 9 passed).
    • Scope: the fix is limited to queries.ts (shared validator, cachedHeaders, deduplication of IDs in headersFor), useSelectionHeaders.ts, the README and tests. There is no scope creep.
    • ADR: no PRD or spec deviation was found, so no ADR is needed.
    • Pre-existing noise: the flushSync was called from inside a lifecycle method stderr in the bulk and tree tests predates this fix.

    Commands and results

    All commands ran via docker compose --project-directory . -f compose.yaml exec -T workspace bash -lc 'cd /workspaces/lca-diff && …'.

    Command Result
    npm --prefix apps/frontend run format:check pass
    npm --prefix apps/frontend run lint pass (--max-warnings 0)
    npm --prefix apps/frontend run typecheck pass
    npm --prefix apps/frontend run build pass
    npm --prefix apps/frontend run test:unit, run 1 23 files, 280 tests passed
    npm --prefix apps/frontend run test:unit, run 2 23 files, 280 tests passed (stable)
    npm --prefix apps/frontend run test:e2e -- --project=chromium 19/19 passed
    npm --prefix apps/frontend run test:e2e -- --project=firefox e2e/process-headers.spec.ts 1/1 passed
    QA probe npx vitest run src/services/mock/zz-qa-recheck.test.tsx (temporary file, deleted afterwards) 8 tests ran. R1–R5 assertions pass. R6 and R6b log the D2 evidence above.
    QA probe npx vitest run src/services/mock/zz-qa-bulk.test.tsx (temporary file, deleted afterwards) 5/5 passed (O1 end to end)
    Mutation runs of comparison-headers.test.tsx in /tmp/qa-mut D1 mutation: 1 failed / 11 passed. O1 mutation: 3 failed / 9 passed.

    The working tree was clean afterwards (git status --short printed nothing). Implementation and tests are unchanged.

    Not run: real API, Firebase or authorization checks, which are out of scope for Phase 1.

    Next action

    FAIL returns to Engineering to fix D2 with a regression test that crosses gcTime. QA will then recheck the new SHA: AC3, AC5 and the full required checks. O2 should be carried as an explicit I1 test obligation.

  9. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Engineering: READY FOR QA (after QA FAIL at c559c63)

    Delivered SHA: 8da80b3 on feat/f4-process-headers (PR #65).

    D2 — fixed

    • Cause: per-process header entries have no observers, so TanStack Query garbage-collected them after its default 5-minute gcTime. A later failed read then lost the loaded columns and the known comparability warning again.
    • Fix: rememberHeaders registers query defaults for the UID-scoped header key prefix, with gcTime: Infinity and staleTime: Infinity.
      • Headers are immutable per revision, so keeping them for the session is safe.
      • Signout and account change call client.clear(), which still removes them.
    • Regression test: "keeps them after the default cache lifetime has passed (QA D2)" in services/mock/comparison-headers.test.tsx.
      • It loads the kg/MJ headers, advances fake timers by 30 minutes, then makes the next read fail.
      • The units warning stays, Alpha and Delta stay loaded, only Gamma is busy, and the failed request asked only for ["r1:p2"].
      • With the defaults removed, this test fails (1 failed, 13 passed).
    • Second new test: "clears the session-long header cache on signout".

    Commands

    All run in the workspace container.

    Command Result
    npm --prefix apps/frontend run format:check pass
    npm --prefix apps/frontend run lint pass
    npm --prefix apps/frontend run typecheck pass
    npm --prefix apps/frontend run build pass
    npm --prefix apps/frontend run test:unit (run twice) 23 files, 282 tests, pass
    npm --prefix apps/frontend run test:e2e -- --project=chromium 19/19 pass
    Firefox: e2e/process-headers.spec.ts 1/1 pass

    Next: QA recheck at 8da80b3. Focus on AC3 and AC5, plus the full required checks.

  10. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    QA: PASS

    • Verified SHA: 8da80b31283928cde4879e7711987d618fcfbd34 (feat/f4-process-headers, PR F4: shared process headers and comparability warnings (#21) #65). The fix diff is c559c63..8da80b3, which touches queries.ts, the services README and comparison-headers.test.tsx. The whole PR is 16e9802..8da80b3.
    • Mode: Phase 1, mock services only. There is no real API, Firebase or authorization evidence.
    • Environment: the existing rootless workspace container (project lca-diff-dev) at /workspaces/lca-diff. Nothing was installed on the host.
    • Authority used: AGENTS.md, docs/team/qa-engineer.md, issue [Task] F4 — Build shared process headers and comparability warnings #21 and its comments, spec §§6.3–6.5, 6.8 and 7.1–7.3, and apps/frontend/src/services/README.md. No archive or reference folders were used.

    Summary

    • D2 is fixed. Validated per-process headers now stay cached for the session (gcTime: Infinity), so the D1 failure fallback survives any length of idle time.
    • The defaults apply only to the UID-scoped header prefix, and signout or account change still removes every entry.
    • All required checks pass, and no new defects were found.

    Criteria

    AC Verdict Evidence
    AC1: five fields, plus full identity on hover/focus or in the accessible name PASS The fix does not touch it. Unit tests and the E2E spec pass in Chromium and Firefox. Loaded columns keep their metadata after a failed read, both immediately (R1) and after 5 min, 24 h and 30 days (D2 probes).
    AC2: ellipsis, keyboard discoverability, max/min width, scroll PASS The fix does not touch it. Unit and E2E tests pass.
    AC3: warning when any amount OR unit differs, and no false warning for 1/1.0 PASS R1–R5 still pass. After a 5 min, 24 h or 30 day wait followed by a failed read, the warning still reads "…different reference units." and does not claim amounts. Retry recovers to "different reference amounts and units".
    AC4: says no normalization was applied, never changes amounts, no confirmation or block PASS The fix does not touch it. Tests pass, and the warning text still says "No normalization has been applied".
    AC5: bounded bulk headers, exact strings, safe missing geography PASS After any wait, a failed read requests only the unread ID: ["r1:p2"], or ["r2:p0"] for a new revision. The O1 bulk probe passes 5/5.

    Status of earlier findings

    • D1: fixed. R1 to R4 were rerun at this SHA and all pass.
    • D2: fixed. Probe zz-qa-d2.test.tsx, run under src/services/mock/ and deleted afterwards. The setup matches R6b: fake timers, then load Alpha (kg) and Gamma (MJ).
      • Before the wait there are 2 per-process entries, with gcTime [Infinity, Infinity].
      • After waiting 5 min + 1 s, 24 h or 30 days, there are still 2 entries.
      • A failed read then selects r1:p2, with the same result after each wait:
        • the warning still reports the unit difference
        • Alpha has aria-busy="false"
        • 1 of 3 columns is busy
        • the failed request was [["r1:p2"]]
      • Retry then recovers to "amounts and units", requesting only ["r1:p2"].
    • O1: fixed. The bulk probe passes 5/5 (tampered revision, missing ID, duplicated ID, wrong snapshot, and a valid seed).
    • O2: remains an I1 adapter test obligation, as documented in the README.
    • O3: remains deferred to [Task] F4 — Virtualize comparison rows and columns with sticky alignment #23, as documented.

    Safety of the fix

    • Scope of the defaults (S1). setQueryDefaults uses the prefix ["lca-services", 1, namespace, uid, "header"]. TanStack's partialMatchKey compares each element exactly, so the headers selection-set queries do not match.

      • Observed: the header entries have gcTime Infinity, while the headers and releases queries keep 300000.
      • After deselecting everything and waiting 6 minutes, the unobserved headers queries were collected and the header entries remained.
      • An unrelated key resolves to empty defaults ({}).
    • Cross-UID safety (S2). After 24 h of idle time:

      • switching to account-b leaves 0 account-a keys and shows no MJ value
      • after signout, 0 queries hold data and there are 0 header entries

      Both paths go through client.clear() in service-context.ts:65/:100, which removes queries regardless of gcTime. rememberHeaders does nothing while uid === null.

      • The registered defaults themselves stay on the client after clear(), at one tiny entry per account and namespace. They hold no data. This is not a defect.
    • Staleness across revisions (S3). Keys include release_id and revision_id. The cached keys were [r1, r1-rev, r1:p0] and [r1, r1-rev, r1:p3], so a new r2 selection does not reuse r1 data and fetches only r2:p0.

      • staleTime: Infinity has no practical effect, because these entries are never observed or refetched; they are only read with getQueryData.
      • Published revisions are immutable (§6.8), so caching for the session is correct.
    • Growth (S4). 300 headers make 300 entries, about 77 KB of JSON (around 258 B each). They stay after the selection is cleared.

      • Growth is bounded by the headers the user actually loads during the session, which the selection itself already holds while selected.
      • Given there is no selection cap, small immutable DTOs and clearing on signout or account change, I judge this acceptable for Phase 1. It is a follow-up observation, not a defect.
    • Mutation check. In a container-local copy (/tmp/qa-mut, deleted afterwards; tracked files untouched), I removed the setQueryDefaults call. The new test "keeps them after the default cache lifetime has passed (QA D2)" then fails (1 failed, 13 passed).

      • The signout test passes either way, as expected: it guards existing clearing behaviour, not the fix.

    Scope and ADR

    • The fix is limited to three files: an 11-line change in queries.ts, the README, and 2 tests. There is no scope creep.
    • No PRD or spec deviation was found, so no ADR is needed.

    Commands and results

    All commands ran via docker compose --project-directory . -f compose.yaml exec -T workspace bash -lc 'cd /workspaces/lca-diff && …'.

    Command Result
    npm --prefix apps/frontend run format:check pass
    npm --prefix apps/frontend run lint pass
    npm --prefix apps/frontend run typecheck pass
    npm --prefix apps/frontend run build pass
    npm --prefix apps/frontend run test:unit, run 1 23 files, 282/282 passed
    npm --prefix apps/frontend run test:unit, run 2 23 files, 282/282 passed
    npm --prefix apps/frontend run test:e2e -- --project=chromium 19/19 passed
    npm --prefix apps/frontend run test:e2e -- --project=firefox e2e/process-headers.spec.ts 1/1 passed
    QA probe npx vitest run src/services/mock/zz-qa-d2.test.tsx (temporary file, deleted afterwards) 13/13 passed (R1–R5, D2 ×3, S1–S4)
    QA probe npx vitest run src/services/mock/zz-qa-bulk.test.tsx (temporary file, deleted afterwards) 5/5 passed
    Mutation run of comparison-headers.test.tsx in /tmp/qa-mut, without setQueryDefaults 1 failed (the D2 test) / 13 passed

    git status --short was empty afterwards, and HEAD is unchanged at 8da80b3. Implementation and tests are unchanged.

    Not run: real API, Firebase or authorization checks, which are out of scope for Phase 1.

    Follow-ups (non-blocking)

    • O2: add an I1 test that a malformed reference_amount from the real adapter becomes a structured boundary error.
    • O3: tracked in [Task] F4 — Virtualize comparison rows and columns with sticky alignment #23.
    • Optional: if very long sessions with very large selection churn become a concern, consider an LRU bound or per-revision eviction for the session header cache. This is not required by the current spec.

    Next action

    PASS goes to the coordinator/maintainer for PR #65 review and merge. QA does not close the issue or merge.

  11. DavidVFitzGerald commented on Nov 14, 2026

    @DavidVFitzGerald
    OwnerAuthor

    Coordinator: closed

    Closing this issue now that QA has passed, the required checks pass and the maintainer has merged the PR.

    Carried forward:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    frontendtask

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions