You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Task] F4 follow-up — verify comparison row-page tokens and multi-release snapshot order #64
Phase 1 - frontend with mock services. Milestone F4 follow-up from the #20 QA (observation O1).
Goal
Make every page of one comparison row query prove that it belongs to the same comparison session, and test snapshot ordering against more than one release.
Context and authority
Read AGENTS.md, docs/team/product-manager.md, docs/engineering/LCA_diff_Implementation_Specification.md §§7.2–7.3 and apps/frontend/src/services/README.md (#20 section). Do not read archive/reference folders.
flowRowPages checks each page against the requested snapshot, but not that later pages carry the first page's comparison_token. A probe returning t1 and then t2 under the same snapshot was accepted.
The query test "accepts the requested snapshot in any release order" uses the single-release mock catalog, so reversing the snapshot checks nothing. QA confirmed the behaviour with a three-release fake service.
Requirements and constraints
Later row pages must match the first page's token. A mismatch fails explicitly (STALE_SNAPSHOT), with nothing cached as a mixed session.
Add a multi-release fixture or fake service for the snapshot release-order test.
Plain flowCells/score queries are not in scope unless they are needed by the consumer issue.
Containers only. No contract change.
Acceptance criteria
AC1 - A row page whose token differs from the first page's token fails as STALE_SNAPSHOT and is not cached; a regression test fails without the fix.
AC2 - Release-order tolerance is tested with at least two releases for cell windows, summaries and row pages, and a missing or extra release is still rejected.
Out of scope and follow-ups
Real-adapter enforcement belongs to I1. Score-query validation belongs to F5 (#28) if needed there.
Verification plan
Inside the workspace container: format:check, lint, typecheck, test:unit and build. Independent QA verifies at the delivered SHA.
Dependencies and readiness
Depends on #20 (PR #63) being merged. It can be done before or alongside #21/#22.
Branch fix/f4-row-page-tokens, delivered SHA cf9ff3e, branched from main at 16e9802. PR is linked above. Work was done in a separate worktree and container (lca-diff-tokens).
Acceptance criteria
AC1 — implemented. The page parameter of flowRowPages carries the token of the page it continues. A row page with a different token fails as STALE_SNAPSHOT and is not appended; the cached pages remain [first]. Test: "rejects a later page carrying another token and never appends it" in services/mock/comparison-queries.test.ts. It fails against the old queries.ts.
AC2 — implemented. The tests use a two-release mock catalog, and the request lists the releases in the reverse of the mock's sorted answer. This order is accepted for:
row pages (2 pages)
summaries
cell windows
A missing release and an extra release are each still rejected as STALE_SNAPSHOT for all three response kinds. The old single-release test is removed, because reversing a one-release snapshot checked nothing.
Commands
Run in the workspace container:
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 — 21 files, 257 tests, run twice, all pass
npm --prefix apps/frontend run test:e2e -- --project=chromium — 18/18 pass
Limitations
No plain flowCells or score-query changes; these are out of scope.
Verified SHA:cf9ff3e119203b915dd0be85ebf7cb7abcb6d773 (branch fix/f4-row-page-tokens, PR #66; diff reviewed against main at 16e9802) Mode: Phase 1, mock services only. This does not validate a real backend, auth or security. Environment: dedicated worktree LCA-diff-f4-tokens, Compose project lca-diff-tokens, service workspace. Every tool ran inside the container; nothing was installed on the host.
Criteria
AC1 — PASS. A row page whose token differs from the first page's token fails as STALE_SNAPSHOT and is not cached. The regression test fails without the fix.
Code (apps/frontend/src/app/queries.ts, flowRowPages).getNextPageParam returns {cursor, token} taken from the page being continued. queryFn sends only cursor to the service, then calls mismatch() with comparison_token: pageParam.token. The first page has no token to match and is checked against the snapshot only. Because each page is matched to the one before it, every page must match the first.
Regression check. I copied apps/frontend to /tmp inside the container and replaced queries.ts with 16e9802's version. Only the new test "rejects a later page carrying another token and never appends it" failed (1 failed / 10 passed). With the delivered queries.ts, all 11 pass.
Adversarial probes. I wrote a temporary zz-qa-64.test.ts that wraps the mock flowRows and overrides tokens. All 6 probes passed. The file was deleted afterwards.
P1, token change on page 3. Pages 1–2 (t1) are accepted. Page 3 (t2) fails as STALE_SNAPSHOT. The cache holds 2 pages, both t1.
P2, t1 → t2 → t1, and fetchNextPage after an error.
Page 2 (t2) is rejected and the cache stays at 1 page.
A retried fetchNextPage answered with t1 is accepted, giving pages [t1, t1].
pageParams[1].token === "t1", and the service was called 3 times.
P3, legitimate new session on refetch. After pages [t1, t1], the service switches to t9.
refetch() succeeds with [t9, t9]: page 1 is fetched without a token, and page 2 is then matched to page 1's new token.
invalidateQueries also succeeds, with no error.
A new session is accepted, not falsely rejected.
P3b, refetch that diverges mid-chain (t9, then tX). It fails as STALE_SNAPSHOT. TanStack keeps the previous [t1, t1]; nothing mixed is cached.
P4, abort.cancelQueries during a slow fetchNextPage appends nothing (still 1 page). A later fetchNextPage succeeds (2 pages).
P5, no pageParam leak.
The query key contains no cursor or token, and an identical flowRowPages call yields an equal key. The cache holds exactly 1 query.
The service request carries a string cursor and no comparison_token, so the request DTO and contract are unchanged.
AC2 — PASS. Release-order tolerance is tested with two releases for cell windows, summaries and row pages, and a missing or extra release is still rejected.
Order really differs.twoReleases() adds a second release, ...0b0, with its own revision and prefixed process IDs. The mock sorts refs by release_id (comparison.ts, snapshot()), and the request lists them reversed. The test asserts rows.pages[0].revision_snapshot equals [second, first], the reverse of the request, so the order difference is checked, not assumed.
Coverage.readAll reads 2 row pages, then summaries, then a cell window, all through the query helpers. It passes at the delivered SHA.
Mutation check. I removed the .sort(...) from snapshotKey in the /tmp copy. "accepts both releases in any order..." then fails, so the test detects order sensitivity.
Missing or extra release. Each case is run separately for flowRows, flowSummaries and flowCells, with only that operation's response changed. Every case is rejected as STALE_SNAPSHOT.
Old test removal is justified. The removed "accepts the requested snapshot in any release order" test reversed a one-release snapshot, which does nothing. The new two-release test replaces it with stronger coverage.
The contracts DTOs and the PRD/spec are unchanged, and plain flowCells and score queries are untouched.
The change is consistent with spec §7.1 (rows return a "comparison cache token"), §7.3 and §7.4 (STALE_SNAPSHOT).
It is an ordinary implementation choice within existing contracts, so no ADR is needed.
Commands and results
All commands were run as docker compose --project-directory . -f compose.yaml -p lca-diff-tokens exec -T workspace bash -lc 'cd /workspaces/lca-diff && npm --prefix apps/frontend run <script>':
format:check: pass ("All matched files use Prettier code style!")
lint: pass (--max-warnings 0)
typecheck: pass
build: pass (97 modules)
test:unit, run 1: 257/257 passed
test:unit, run 2: 257/257 passed
test:e2e -- --project=chromium: 18/18 passed
Probe and mutation runs:
npx vitest run src/services/mock/zz-qa-64.test.ts: 6/6 passed (temporary file, removed afterwards)
/tmp copy with the old queries.ts: npx vitest run src/services/mock/comparison-queries.test.ts gave 1 failed (the AC1 test) / 10 passed
/tmp copy with snapshotKey unsorted: 1 failed (the AC2 order test) / 10 passed
git status --short in the worktree is clean, and the /tmp copy was removed.
Defects
None.
Observations (non-blocking)
O1. The guard is only exercised through a wrapped fake. In the native mock, a real token rotation (for example LRU eviction at token_limit) shows up as an invalid-cursor error, not as a page with a different token. Real-adapter enforcement remains I1, as already scoped.
O2. Order tolerance is checked in sequence. Summaries and cell windows are only reached after row pages pass. All three must pass for the test to pass, so this is adequate, but a failure would point first to row pages.
O3. The token is kept in cached pageParams. This is internal TanStack cache state, not a query key, and is cleared with the rest of the query cache.
Next: ready for maintainer review/merge of PR #66 (coordinator/maintainer).
Activity
DavidVFitzGerald commentedon Nov 14, 2026
Engineering: READY FOR QA
Branch
fix/f4-row-page-tokens, delivered SHAcf9ff3e, branched frommainat16e9802. PR is linked above. Work was done in a separate worktree and container (lca-diff-tokens).Acceptance criteria
AC1 — implemented. The page parameter of
flowRowPagescarries the token of the page it continues. A row page with a different token fails asSTALE_SNAPSHOTand is not appended; the cached pages remain[first]. Test: "rejects a later page carrying another token and never appends it" inservices/mock/comparison-queries.test.ts. It fails against the oldqueries.ts.AC2 — implemented. The tests use a two-release mock catalog, and the request lists the releases in the reverse of the mock's sorted answer. This order is accepted for:
A missing release and an extra release are each still rejected as
STALE_SNAPSHOTfor all three response kinds. The old single-release test is removed, because reversing a one-release snapshot checked nothing.Commands
Run in the workspace container:
npm --prefix apps/frontend run format:check— passnpm --prefix apps/frontend run lint— passnpm --prefix apps/frontend run typecheck— passnpm --prefix apps/frontend run build— passnpm --prefix apps/frontend run test:unit— 21 files, 257 tests, run twice, all passnpm --prefix apps/frontend run test:e2e -- --project=chromium— 18/18 passLimitations
flowCellsor score-query changes; these are out of scope.Next: independent QA at
cf9ff3e.DavidVFitzGerald commentedon Nov 14, 2026
QA: PASS
Verified SHA:
cf9ff3e119203b915dd0be85ebf7cb7abcb6d773(branchfix/f4-row-page-tokens, PR #66; diff reviewed againstmainat16e9802)Mode: Phase 1, mock services only. This does not validate a real backend, auth or security.
Environment: dedicated worktree
LCA-diff-f4-tokens, Compose projectlca-diff-tokens, serviceworkspace. Every tool ran inside the container; nothing was installed on the host.Criteria
AC1 — PASS. A row page whose token differs from the first page's token fails as
STALE_SNAPSHOTand is not cached. The regression test fails without the fix.apps/frontend/src/app/queries.ts,flowRowPages).getNextPageParamreturns{cursor, token}taken from the page being continued.queryFnsends onlycursorto the service, then callsmismatch()withcomparison_token: pageParam.token. The first page has no token to match and is checked against the snapshot only. Because each page is matched to the one before it, every page must match the first.apps/frontendto/tmpinside the container and replacedqueries.tswith16e9802's version. Only the new test "rejects a later page carrying another token and never appends it" failed (1 failed / 10 passed). With the deliveredqueries.ts, all 11 pass.zz-qa-64.test.tsthat wraps the mockflowRowsand overrides tokens. All 6 probes passed. The file was deleted afterwards.t1) are accepted. Page 3 (t2) fails asSTALE_SNAPSHOT. The cache holds 2 pages, botht1.fetchNextPageafter an error.t2) is rejected and the cache stays at 1 page.fetchNextPageanswered witht1is accepted, giving pages[t1, t1].pageParams[1].token === "t1", and the service was called 3 times.[t1, t1], the service switches tot9.refetch()succeeds with[t9, t9]: page 1 is fetched without a token, and page 2 is then matched to page 1's new token.invalidateQueriesalso succeeds, with no error.t9, thentX). It fails asSTALE_SNAPSHOT. TanStack keeps the previous[t1, t1]; nothing mixed is cached.cancelQueriesduring a slowfetchNextPageappends nothing (still 1 page). A laterfetchNextPagesucceeds (2 pages).pageParamleak.flowRowPagescall yields an equal key. The cache holds exactly 1 query.cursorand nocomparison_token, so the request DTO and contract are unchanged.AC2 — PASS. Release-order tolerance is tested with two releases for cell windows, summaries and row pages, and a missing or extra release is still rejected.
twoReleases()adds a second release,...0b0, with its own revision and prefixed process IDs. The mock sorts refs byrelease_id(comparison.ts,snapshot()), and the request lists them reversed. The test assertsrows.pages[0].revision_snapshotequals[second, first], the reverse of the request, so the order difference is checked, not assumed.readAllreads 2 row pages, then summaries, then a cell window, all through the query helpers. It passes at the delivered SHA..sort(...)fromsnapshotKeyin the/tmpcopy. "accepts both releases in any order..." then fails, so the test detects order sensitivity.flowRows,flowSummariesandflowCells, with only that operation's response changed. Every case is rejected asSTALE_SNAPSHOT.Scope / ADR — PASS.
queries.ts(an internalRowPageParamtype and theflowRowPagespaging logic), theservices/README.md[Task] F4 — Add snapshot-consistent flow windows and whole-row chart summaries #20 section, and tests.contractsDTOs and the PRD/spec are unchanged, and plainflowCellsand score queries are untouched.STALE_SNAPSHOT).Commands and results
All commands were run as
docker compose --project-directory . -f compose.yaml -p lca-diff-tokens exec -T workspace bash -lc 'cd /workspaces/lca-diff && npm --prefix apps/frontend run <script>':format:check: pass ("All matched files use Prettier code style!")lint: pass (--max-warnings 0)typecheck: passbuild: pass (97 modules)test:unit, run 1: 257/257 passedtest:unit, run 2: 257/257 passedtest:e2e -- --project=chromium: 18/18 passedProbe and mutation runs:
npx vitest run src/services/mock/zz-qa-64.test.ts: 6/6 passed (temporary file, removed afterwards)/tmpcopy with the oldqueries.ts:npx vitest run src/services/mock/comparison-queries.test.tsgave 1 failed (the AC1 test) / 10 passed/tmpcopy withsnapshotKeyunsorted: 1 failed (the AC2 order test) / 10 passedgit status --shortin the worktree is clean, and the/tmpcopy was removed.Defects
None.
Observations (non-blocking)
token_limit) shows up as an invalid-cursor error, not as a page with a different token. Real-adapter enforcement remains I1, as already scoped.pageParams. This is internal TanStack cache state, not a query key, and is cleared with the rest of the query cache.Next: ready for maintainer review/merge of PR #66 (coordinator/maintainer).
fix: bind later flow-row pages to the first page's comparison token (…
DavidVFitzGerald commentedon Nov 14, 2026
Coordinator: closed
Closing this issue now that QA has passed, the required checks pass and the maintainer has merged the PR.
cf9ff3e(report).qualitycheck passed on PR F4 follow-up: bind row pages to one comparison token; multi-release snapshot tests (#64) #66.mainon 2026-11-14 (headf138482).Carried forward: real-adapter token enforcement belongs to I1.