Repository navigation
feat(aggregator): browse historical AA dataset batches - #7564
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 31 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 783f9aa4f8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const section = await assemble(await fetchAaPayload(token, ref, row.importBatch)); | ||
| if (section) built++; |
There was a problem hiding this comment.
Count failed historical fetches toward the per-tick limit
When historical queries fail or return payloads that fail assembly, built never increments, so this loop can query every uncached historical batch rather than stopping after two attempts. Each request has a 60-second timeout, so an upstream outage can both amplify Management API pressure and substantially delay publication of the entire fleet feed. Consume the budget before each fetch, regardless of whether assembly succeeds.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 82b77ad (this branch): the per-tick budget is now consumed before each historical fetch (attempts++ ahead of the assemble call), so failed or unassemblable batches count against AA_HISTORICAL_BUILDS_PER_TICK and an upstream outage cannot turn the loop into an unbounded run of 60s queries. Verified in the current head of collect-fleet-feed.ts and by test/aa-batches.test.ts (18/18, lane code-y, task 12631).
| if (isAaBatchCacheEntry(parsed) && isAaSection(parsed.section) && parsed.section.status === "ok") { | ||
| provenance.aa = `live (fleet feed · historical batch ${batch.slice(0, 8)} · collected ${parsed.section.generatedAt})`; | ||
| return { ...parsed.section, batches: batchList }; |
There was a problem hiding this comment.
Reject historical caches invalidated by a config change
After the OpenCode configuration changes, the collector marks caches with mismatched configFingerprint values as unavailable and rebuilds only two historical versions per tick. This reader nevertheless serves any structurally valid cache file, including those invalidated entries, as an ordinary successful section. Selecting a version awaiting rebuild therefore exposes the old fleet catalog and coverage without a stale warning. Honor the collector's cache-validity metadata, or explicitly mark invalidated payloads stale until they are rebuilt.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 6f5a3e2 (this branch): the AA reader in src/sources/live.ts now honors the index's cache-validity flag — a batch whose cache was invalidated (cached === false) is served with stale: true and a staleReason explaining the rebuild, never as an ordinary successful section. Covered by the test "a cache invalidated by a config change is served stale, not as ordinary success" in test/aa-batches.test.ts (18/18, lane code-y, task 12631).
| await writeAaLastGood({ | ||
| batch: latestSection.batch, | ||
| configFingerprint: fingerprint, | ||
| fingerprint: cacheMeta.get(latestSection.batch)?.fingerprint ?? undefined, | ||
| section: latestSection, |
There was a problem hiding this comment.
Persist the batch index in the last-good section
On a subsequent token, index-query, or latest-payload failure, degrade() returns lastGood.section, but this write occurs before batches is attached to the returned section. The per-batch cache also stores sections without that index, so successful collection does not normally preserve it anywhere in the last-good payload. Consequently, a transient collection failure removes the dataset selector and prevents browsing already-cached versions through the page. Persist the completed section, including its batch summaries, after constructing the index.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 82b77ad (this branch): after the batch index is attached, the collector re-writes the last-good payload with the index included (writeAaLastGood with the withIndex section), so a later transient failure degrades to a section that still carries the dataset selector and every cached version stays browsable. The per-batch cache write in assemble() is unchanged; the last-good store is now written twice per successful tick — the second write is the one that persists.
| for (const row of index) { | ||
| if (built >= AA_HISTORICAL_BUILDS_PER_TICK) break; | ||
| if (row.importBatch === latestSection.batch) continue; | ||
| if (cacheMeta.get(row.importBatch)?.cached) continue; |
There was a problem hiding this comment.
Refresh the current-price overlay for cached historical batches
When token prices change and a newer workbook is imported, the new latest payload reads the updated v_current_prices, but previously cached historical payloads are skipped indefinitely while the OpenCode config remains unchanged. Those sections retain both their original prices and the price-derived catalog built by aaSectionFromSupabase, so switching dataset versions also switches token rates despite the page explicitly describing them as a current, non-historical overlay. Refresh the batch-independent prices and rebuild the affected catalog rates without requiring the historical measurements to be fetched again.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 62b9b69 (this branch, lane code-y / task 12631): cached AA sections are now validity-keyed on the current-price overlay as well as the config. Each cache entry records pricesFingerprint (aaPricesFingerprint — sha256 of the section's v_current_prices rows, normalized to the AaPrice field set); the collector hashes the live overlay once per tick (AA_PRICES_SQL, the payload's own prices subquery) and treats any cache whose stored fingerprint differs as invalid, so a price-only change rebuilds historical sections at the usual bounded rate instead of serving frozen prices/catalog as current. Entries written before this change carry no fingerprint and are treated as stale once. Oracle tests in test/aa-batches.test.ts: fingerprint stable across key/row order, changes when any price changes (18/18 pass).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…atch index - Consume the per-tick historical build budget before each fetch so a failing or unassemblable batch still counts (Codex P2 on #7564): an upstream outage can no longer turn the loop into unbounded 60s queries. - Rewrite the last-good AA payload after the batch index exists, so a later transient failure degrades to a page that still offers every cached version instead of losing the dataset selector (Codex P2 on #7564).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…resh A cached historical payload whose configFingerprint no longer matches the current opencode config is marked unavailable in the index and rebuilt a few per tick. The reader served it as an ordinary success, exposing the old fleet catalog and coverage with no warning (Codex P2 on #7564). Honour the index's cached flag: return the payload with stale/staleReason so the page's existing stale banner explains the rebuild.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Review findings addressed (head
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Salvage comparison — closed PR #7381 vs this merged PR (task 14093, lane code-l, 2026-11-10) Task 14093 asked for the salvage remainder of closed PR #7381 (branch Verdict: nothing unique — superseded by this PR. Evidence (fresh, this shift):
No re-application is needed; task 14093 completes as superseded. |
Summary
AA collector now indexes workbook batches from
ainventory.sources, caches batch-scoped payloads, and serves a selected historical version at/aa?batch=<uuid>and/api/aa.json?batch=<uuid>. The selector identifies the active/latest version and downloads use the selected dataset; latest remains the default. Historical query logic avoids the latest-only ranking/threshold views, and carrier duplicates collapse only when semantic fingerprints match.Part of #3302; intentionally does not close it before the requested laptop live verification.
Evidence
PM_AGG_FRESHNESS_PORT=15171 bun test test/aa-batches.test.ts test/aa.test.ts— 58 passed.git diff --check— passed.bun run typecheck— changed code passes; blocked by existingtest/roadmap-annotations.test.ts:89kind typing error./aaand/api/aa.jsonalways served latest only. After: source-level regression test selects a cached historical batch and confirms latest remains the default.Merge Danger
Door: two-way; reverting the PR restores latest-only behavior.
Blast Radius: medium — aggregator collection, cache files beside the feed, live source selection, and AA page/API only.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.