AntFleet

Disagreement · 8ff8c1af-anthropic-6

Telemetry: global UPDATE provider_metrics SET updated_at runs even when there are no rows, but more importantly is a no-op blanket write

mismatch
repo 56f59a0d·PR #2·reviewed 4 days ago

Primary finding

Telemetry: global UPDATE provider_metrics SET updated_at runs even when there are no rows, but more importantly is a no-op blanket write

mediummaintainabilityhigh
  • src/providers/telemetry.ts:168-174
  • src/providers/telemetry.ts:277-284
Blanket UPDATE rewriting updated_at on every row of provider_metrics on every flush that has decisions/failures is O(N rows) per flush and corrupts the per-row updated_at meaning — a watcher cannot distinguish 'metrics for X were updated' from 'a decision was logged.' If the UI uses per-row updated_at to detect actual metric churn (which the column is named for), this update creates false positives. Cleaner: add a separate watermark/meta table with a single 'last_event_ts' value; or have the UI watch the decisions/failures tables directly.

Recommendation

Introduce a meta(k,v) table with last_event_ts, or have getLastUpdatedTime() take MAX(updated_at, MAX(timestamp from events)). Avoid mutating every metrics row.

Counterpart finding

Telemetry ‘global updated_at’ logic does nothing when metrics table is empty (watchers never see changes)

mediumbughigh
  • src/providers/telemetry.ts:161-165
When there are no rows in provider_metrics, the UPDATE affects 0 rows. The intent (comment) is to bump a global heartbeat so UI watch mode sees a change via MAX(updated_at), but with an empty table nothing changes, so getLastUpdatedTime continues to return 0 and watchers never update despite decisions/failures being recorded.

Recommendation

Implement a real heartbeat separate from per-provider metrics. Options: - Add a small meta table: CREATE TABLE IF NOT EXISTS meta (k TEXT PRIMARY KEY, v INTEGER NOT NULL); and upsert meta('last_updated', now) on every flush. - Or insert/update a dedicated sentinel row in provider_metrics (e.g., id='__heartbeat__') with ON CONFLICT(id) DO UPDATE SET updated_at=excluded.updated_at to guarantee at least one row exists. Prefer the meta table to avoid corrupting per-provider updated_at semantics.

Why this didn't post

This finding didn't meet AntFleet's unanimous agreement threshold. Both frontier models review every PR independently; only findings they both flag with the same severity and category are posted to the PR. This one fell through.

read the methodology →

From the same review

These findings passed the unanimous gate on the same PR review. The disagreement above was filtered out; the findings below were posted.