Skip to content

Migrate scheduled AA event gatherer from Supabase to Turso - #11938

Merged
dezren39 merged 3 commits into
mainfrom
aster/gatherer-turso-20261118
Nov 18, 2026
Merged

dezren39 merged 3 commits into
mainfrom
aster/gatherer-turso-20261118

Conversation

@dezren39

@dezren39 dezren39 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Canonicalizes the active standalone #9999 gatherer in scripts, preserving AA/models.dev parsing and diff behavior. Replaces deleted Supabase reads with fleet-platform Hrana; current view ordering matches original source DDL. Commits parent/event inserts atomically, with private UUID intent for ambiguous outcome readback. Strict CLI. Includes narrow systemd service source and schedule registry update. Validation: 8 focused unit tests; production read-only state counts 107 models,1444 measurements,566 current measurements,110 current prices; actual Turso staging atomic insert/defaults and rollback probes pass. No production event writes or service activation yet. Original scratch source unchanged.


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 18, 2026 22:01
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 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-18T22:11:01.792064Z 402a562 New commits
ℹ️ 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.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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 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: 8f977a54c0

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

AA_MODELS_URL = "https://artificialanalysis.ai/models"
MODELSDEV_URL = "https://models.dev/api.json"
II_BENCHMARK = "AA Intelligence Index"
II_VERSION = "4.3.2" # AA's current index version, as labelled in our data

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Record the actual AA index version

When the AA page supplies current Intelligence Index scores, every emitted measurement is labeled 4.3.2 regardless of its actual version. The existing load in pm-stack/aggregator/docs/aa-load-2026-11-12/gen_load.py:646–651 explicitly separates previous-index scores from current 5.0.1 scores. A live run therefore inserts current scores into the historical benchmark-version partition, corrupting version-specific comparisons. Determine and validate the source index version before comparing or inserting observations.

Useful? React with 👍 / 👎.

Comment on lines +315 to +317
def differs(row, pin, pout):
return (row is None or row.get("input_usd_per_1m") != pin
or row.get("output_usd_per_1m") != pout)

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 Include cache rates in price change detection

For a tracked model whose cache_read or cache_write price changes while its ordinary input/output prices stay unchanged, this predicate returns false and no price event is emitted. Both cache rates are parsed and persisted below, so their stored values remain stale indefinitely despite successful daily runs. Compare all persisted pricing dimensions, and apply the same correction to the AA comparison at lines 276–278, which also ignores cached-input changes.

Useful? React with 👍 / 👎.

Comment on lines +191 to +194
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--live',action='store_true')
parser.add_argument('--out',default=os.path.join(HERE,'dry_runs'))
args=parser.parse_args() # Parse before filesystem/credential/network effects.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Disable abbreviated options before accepting the live flag

An invocation with the undeclared flag --liv is accepted as --live, enabling database writes instead of reporting a usage error. The installed argparse.ArgumentParser documentation describes allow_abbrev as “Allow long options to be abbreviated unambiguously”; this parser leaves that behavior enabled. Set allow_abbrev=False to enforce the strict declared-argument contract required by AGENTS.md, particularly for the write-enabling flag.

AGENTS.md reference: AGENTS.md:L47-L50

Useful? React with 👍 / 👎.

Comment on lines +398 to +400
"window_kind": "flat",
"source_kind": r["source_kind"], "source_ref": r["source_ref"],
"source_date": r["source_date"], "ingest_batch_id": batch_id,

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 Populate effective dates so price updates can become current

When an existing price for the same model and context band has a non-null effective_date, gathered updates cannot supersede it because these rows omit that field, whose schema default is NULL. CURRENT_PRICES orders by effective_date DESC NULLS LAST before considering source_date, so even a newer observation loses to the old dated price. The existing load in pm-stack/aggregator/docs/aa-load-2026-11-12/aa-load-2026-11-12.sql:543–551 creates dated prices, and the UI uses the same ordering in pm-stack/aggregator/src/aa-turso-sql.ts:546. Populate an appropriate effective date so updates become visible instead of being reinserted on every subsequent run.

Useful? React with 👍 / 👎.

Comment on lines +230 to +232
if key not in seen_latest:
seen_latest.add(key)
cur_ii[key] = {"value_num": e.get("value_num")}

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 source-date precedence when selecting current measurements

If an older-source observation is imported after a newer-source observation, this assignment replaces the authoritative current value with the historical value: events is ordered only by ingestion time in read_current(), whereas CURRENT_MEASUREMENTS prioritizes source_date. When the live AA score matches that historical value but differs from the actual current-view winner, the gatherer incorrectly declares it unchanged and never inserts the observation needed to update the current view. Preserve source-date ordering when reconciling identities rather than unconditionally overriding the current-view result with the latest-ingested row.

Useful? React with 👍 / 👎.

@dezren39
dezren39 merged commit e632602 into main Nov 18, 2026
@dezren39
dezren39 deleted the aster/gatherer-turso-20261118 branch November 18, 2026 22:09
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.

1 participant