Skip to content

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

Closed

Description

@dezren39

Finding (unaddressed PR review comment)

Codex P2 on merged PR #8681 — comment #8681 (comment) by chatgpt-codex-connector[bot], 2026-11-11T13:22:05Z, at pm-stack/aggregator/src/aa-batch-sql.ts:609:

Preserve the selected batch for configs and coding-agent results — When a historical dataset is fetched or its cache is rebuilt, these predicates select the latest canonical ingest rather than the requested batch. collectAaSection still calls fetchAaPayload(row.importBatch) for historical entries, so the resulting payload combines historical rankings and timings with latest configs and CAI observations, then caches that mixture under the historical UUID. This contradicts the dataset selector's explicit promise that older versions show that import's coding-agent rows and snapshot figures. Preserve a mapping to the selected import or reconstruct these sections from its retained snapshot data; latest-batch parity alone does not preserve historical behavior. The same issue applies to the cai predicate below.

No-response evidence

Still live on current main (verified 2026-11-11, two gh api reads)

pm-stack/aggregator/src/aa-batch-sql.ts on main, aaPayloadSql(batch): the configs and cai sections still ignore the batch expression and scope to the latest workbook-import ingest batch (where br.ingest_batch_id = (select ingest_batch_id from ainventory.measurement_events where source_kind = 'workbook-import' order by ingested_at desc limit 1)), while sources/rankings/thresholds/testRunRows scope to ${b}. A header comment (tranche 2 of #4401) documents that canonical events carry no sheet import_batch identity — but the user-visible consequence Codex flagged stands: a historical payload mixes latest configs/CAI with that batch's rankings and is cached under the historical UUID.

Acceptance criteria

  • Historical AA payloads no longer present latest-batch configs/CAI as the selected batch's data (preserve a mapping to the selected import, reconstruct from retained snapshot data, or clearly scope/label those sections as latest-only so the cache under the historical UUID is not a silent mixture), or the finding is resolved by a documented decision on this issue.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 12, 2026
  2. developing-today commented on Nov 12, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    effort/sSmall: expected under 2 hours of work
    and removed
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 12, 2026
  5. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  6. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triaged

    • Agent: queue worker (repo-worker-code), lane code-d
    • Session / ID: task 15065
    • Found via: queue claim (inline triage, runbook 1c)
    • Task: Triage of issue aggregator(aa): historical AA payloads mix latest-batch configs/CAI with the selected batch and cache the mixture under its UUID (from PR #8681) #8817. Work kind: small-fix. Priority: normal (PM-stack correctness; not fleet-stalling, not in Drew's expedite set). Effort: s. Kind: bug (already labelled).
    • Verified live: on main 671088b, aaPayloadSql scopes sources/rankings/thresholds/testRunRows to the selected batch, but configs and cai read measurement_events pinned to the newest workbook-import ingest batch, and the payload is labelled and cached under the selected batch UUID.
    • Live DB evidence (read-only probe, 2026-11-12): measurement_events.ingest_batch_id is the same UUID as ainventory.sources.import_batch for the same import. Workbook-import event batches exist for 10 imports through 2026-10-26 (35 configs rows and 27 cai rows each); the 7 newer workbook batches (2026-10-27 to 2026-10-31) have no measurement events yet.
    • First concrete step / fix shape: scope configs/cai as-of the selected batch — the newest workbook-import event batch imported at or before the selected batch — instead of the newest overall. For the current latest batch this yields exactly today's sections (the 2026-10-26 event batch is the newest in effect); for historical batches it reconstructs their own sections.
    • Acceptance check: payload test that aaPayloadSql for a non-latest batch does not present latest-only configs/CAI as that batch's data; live SQL check of generated payloads for a historical batch and the latest batch.
  7. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

  8. dezren39 commented on Nov 12, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done (already_done — duplicate follow-on)

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

    effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/pr-comment-reviewFiled by the pr-comment-review jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions