Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pm-stack/aggregator/scripts/collect-fleet-feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
// section and logs only that it was omitted.
// - the AA cost explorer data — Supabase `ainventory` (the AA
// import: v_rankings, v_threshold_metrics,
// benchmark_results — both the AA Intelligence Index rows and the
// measurement_events — both the AA Intelligence Index rows and the
// Coding Agent Index rows, kept as separate benchmark families —
// the Test_Runs data, and the price event log's v_current_prices),
// read through v_latest_import_batch via the Management API SQL endpoint.
Expand Down
25 changes: 20 additions & 5 deletions pm-stack/aggregator/src/aa-batch-sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,17 @@ select coalesce((
* The full AA section payload for one batch (null = latest). This mirrors the
* collector's previous AA_SQL exactly except that every batch predicate and
* both latest-pinned views now take the same batch expression.
*
* Tranche 2 of code#4401 (2026-11-11): the 'configs' and 'cai' sections no
* longer read the frozen ainventory.benchmark_results table; they read the
* canonical ainventory.measurement_events store. Canonical events carry no
* sheet import_batch identity, so those two sections ignore the batch
* expression and scope to the latest workbook-import ingest batch — the
* events' own equivalent of the latest import batch — with the filters that
* reproduce the retired table's latest-batch rows exactly (verified by
* full-row EXCEPT comparison before the table was dropped: configs 35/35,
* cai 27/27, zero differences either way). benchmark_results is dropped;
* measurement_events is the one canonical read path for benchmark facts.
*/
export function aaPayloadSql(batch: string | null): string {
const b = batchExpression(batch);
Expand Down Expand Up @@ -591,12 +602,14 @@ select jsonb_build_object(
'configs', coalesce((
select jsonb_agg(jsonb_build_object(
'modelName', model_name, 'benchmark', benchmark, 'effort', effort,
'intelligence', value_num, 'costPerTaskUsd', cost_per_task_usd, 'speedTps', speed_tps
'intelligence', value_num, 'costPerTaskUsd', cost_per_task_usd, 'speedTps', output_tps
) order by model_name, effort)
from ainventory.benchmark_results br
where br.import_batch = ${b}
from ainventory.measurement_events br
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)
Comment on lines +608 to +609

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 in render.ts 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.

Useful? React with 👍 / 👎.

and br.benchmark like 'AA Intelligence Index%'
and br.metric = 'intelligence_index'
and br.benchmark_version is null
), '[]'::jsonb),
'testRunRows', coalesce((
select jsonb_agg(jsonb_build_object('rowIndex', row_index, 'cells', data->'cells') order by row_index)
Expand All @@ -617,10 +630,12 @@ select jsonb_build_object(
'sweAtlas', nullif(raw->>'swe_atlas_qna_pct', '')::numeric,
'snapshotDate', nullif(raw->>'snapshot_date', ''), 'sourceUrl', nullif(raw->>'source_url', '')
) order by value_num desc nulls last, model_name)
from ainventory.benchmark_results br
where br.import_batch = ${b}
from ainventory.measurement_events br
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)
and br.benchmark like 'Artificial Analysis Coding Agent Index%'
and br.metric = 'cai_index_score'
and br.raw->>'benchmark_version' is not null
), '[]'::jsonb),
'prices', coalesce((
select jsonb_agg(jsonb_build_object(
Expand Down
5 changes: 3 additions & 2 deletions pm-stack/aggregator/src/aa.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// The AA cost explorer as data. The source of record is the Supabase
// `ainventory` schema (the AA import: v_rankings,
// v_threshold_metrics, benchmark_results, and the Test_Runs data in
// sheet_rows, all read through v_latest_import_batch). The collector
// v_threshold_metrics, measurement_events (the canonical benchmark
// store, code#4401), and the Test_Runs data in sheet_rows, read
// through v_latest_import_batch where the store carries batch identity). The collector
// queries it, assembles the section with the helpers here, and embeds
// it in the fleet feed; the aggregator renders the section as-is.
// Everything in this module is pure and unit-tested (test/aa.test.ts),
Expand Down
4 changes: 2 additions & 2 deletions pm-stack/aggregator/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ export interface AaThreshold {
usdPerUsablePoint: number | null;
}

/** One AA Intelligence Index row of ainventory.benchmark_results. */
/** One AA Intelligence Index row of ainventory.measurement_events (canonical, code#4401). */
export interface AaConfig {
modelName: string;
benchmark: string;
Expand Down Expand Up @@ -880,7 +880,7 @@ export interface AaTestRun {
}

/**
* One Coding Agent Index row of ainventory.benchmark_results (the
* One Coding Agent Index row of ainventory.measurement_events (the
* import's Coding_Agent_Results rows): a model + effort + agent
* harness observation, kept strictly separate from the AA Intelligence
* Index — no score conversion between the indexes (the ChatGPT
Expand Down
Loading