Skip to content

fix(aggregator): scope AA configs/cai as-of the selected batch (#8817) - #8834

Merged
dezren39 merged 2 commits into
mainfrom
queue/15065-8817-aa-payload-batch-scope
Nov 12, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/15065-8817-aa-payload-batch-scope

Conversation

@dezren39

@dezren39 dezren39 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Fixes #8817.

Problem

aaPayloadSql scoped sources/rankings/thresholds/testRunRows to the selected batch, but the configs and cai sections pinned measurement_events to the newest workbook-import ingest batch overall. A historical payload therefore mixed the newest configs/CAI into data labelled and cached under the historical batch UUID (Codex P2 on PR #8681, discussion 4538397747).

Fix

Scope both sections AS-OF the selected batch: the newest workbook-import event batch imported at or before it. Live verification (2026-11-12) showed measurement_events.ingest_batch_id is the importing batch's ainventory.sources.import_batch, and that not every workbook import produces benchmark events (the imports after 2026-10-26 have none yet), so as-of is the correct mapping:

  • historical batch: its own event batch is selected (provenance-checked live: the 2026-10-22 batch now selects its own ingest batch instead of the 2026-10-26 one; same for 2026-10-25);
  • latest batch: the newest event batch in effect is selected, identical to the previous behaviour (the 2026-10-31 batch still selects the 2026-10-26 event batch);
  • a batch older than every event batch gets empty sections rather than another batch's data (no such batch exists in current data).

Tests

Task 15065 (queue triage, fixed inline per runbook 1c).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 12, 2026 02:31
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0bc18975-5c9f-4124-be57-bb505d359632
Commits

Reviewing files that changed from the base of the PR and between ac13883 and d186f85.

Files selected for processing: 4

  • pm-stack/aggregator/scripts/collect-fleet-feed.ts
  • pm-stack/aggregator/src/aa-batch-sql.ts
  • pm-stack/aggregator/src/aa-batches.ts
  • pm-stack/aggregator/test/aa-batches.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T02:41:02.399143Z d186f85 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0ebd5c04a

ℹ️ 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".

Comment thread pm-stack/aggregator/src/aa-batch-sql.ts Resolved
@dezren39

Copy link
Copy Markdown
Member Author

Fixed in d186f85. The collector now validity-keys AA batch caches with the payload SQL revision, following the existing pricesFingerprint pattern:

  • aa-batch-sql.ts exports AA_PAYLOAD_SQL_REVISION = 1 (bump whenever aaPayloadSql semantics change).
  • Cache entries and the last-good store carry sqlRevision; the collector stamps it on every write, requires (sqlRevision ?? 0) === AA_PAYLOAD_SQL_REVISION when accepting a cached batch or reusing last-good, and otherwise marks the batch uncached so it rebuilds at the bounded historical rate (the latest batch rebuilds on the same tick via the normal fetch path).
  • Pre-revision entries carry no sqlRevision, read as 0, and are invalidated by this change itself; live.ts already serves collector-invalidated batches stale-marked as awaiting rebuild, so nothing keeps serving the mixed sections as current.

Tests: bun test test/aa-batches.test.ts 23/23 (new guard test for the sqlRevision field); tsc error set identical to main (26 pre-existing, line shifts only).

@dezren39

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: d186f85b11

ℹ️ 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".

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.

aggregator(aa): historical AA payloads mix latest-batch configs/CAI with the selected batch and cache the mixture under its UUID (from PR #8681)

1 participant