Skip to content

fix(slack): require per-date evidence before crediting raw agentic-traffic projection#2487

Open
akshaymagapu wants to merge 1 commit into
mainfrom
fix/agentic-traffic-status-raw-date-check
Open

fix(slack): require per-date evidence before crediting raw agentic-traffic projection#2487
akshaymagapu wants to merge 1 commit into
mainfrom
fix/agentic-traffic-status-raw-date-check

Conversation

@akshaymagapu
Copy link
Copy Markdown
Contributor

Summary

The `check agentic traffic db status` Slack command was permissively crediting any raw `wrpc_import_agentic_traffic` projection_audit row in the lookup window as "raw OK for dateStr", regardless of which date the row actually covered. Raw rows carry no per-date metadata, so a raw run for an earlier date inside the window was indistinguishable from a raw run for `dateStr` itself.

This produced false "raw OK, daily missing" diagnostics. Concrete example from the 2026-05-25 report:

  • `sskm.de` and `wknd.enablementadobe.com` were reported as `missing: daily` only, but the DB shows neither raw nor daily had any rows for 2026-05-25 — both were stale by 1-2 days. The raw side was credited because earlier-date raw runs happened to fall in the audit lookup window.

Fix

Raw is now credited for `dateStr` only via one of two date-specific signals:

  1. Daily refresh metadata proof: a daily refresh audit row whose `dailyRefreshDates` includes `dateStr`. Daily refresh is a `postSuccessMessage` from raw (see projector `agenticTrafficAnalyticsConfig`), so a daily-for-X row proves raw succeeded for X.
  2. Fallback for the legitimate "raw OK, daily not yet run" case: a raw audit row whose `projected_at` lands on or after `dateStr + 1 day` UTC (the raw projector runs the day after the traffic day) with `output_count > 0`.

Also adds `output_count` to the projection_audit select.

Test plan

  • `npx mocha test/support/slack/commands/check-agentic-traffic-db-status.test.js` — 14/14 pass
  • Updated existing test that asserted the old (buggy) behavior
  • New regression test: raw + daily both flagged missing when neither has per-date evidence
  • New regression test: raw correctly counted via post-day `projected_at` + positive `output_count` fallback
  • New regression test: raw NOT counted when `projected_at < dateStr+1d` even with positive `output_count`
  • `npx eslint` clean on both files

🤖 Generated with Claude Code

…affic projection

The agentic-traffic DB status check was permissively crediting any raw
`wrpc_import_agentic_traffic` projection_audit row in the lookup window as
"raw OK for dateStr", regardless of which date the row actually covered.
Raw rows carry no per-date metadata, so a raw run for an earlier date inside
the window (e.g. dateStr-2) was indistinguishable from a raw run for dateStr
itself. This produced false "raw OK, daily missing" diagnostics for sites
whose raw + daily had both been missing for days.

Raw is now credited for dateStr only via one of two date-specific signals:
1. A daily refresh audit row whose `dailyRefreshDates` includes dateStr.
   Daily refresh is a post-success message from raw, so this proves raw
   succeeded for dateStr.
2. Fallback for "raw OK, daily not yet run": a raw audit row whose
   `projected_at` is on or after dateStr+1 day UTC (raw projector runs the
   day after the traffic day) with `output_count > 0`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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