Skip to content

Rebuild weekly search report on the durable analytics API (fail-loud)#120

Merged
jpr5 merged 3 commits into
mainfrom
blitz/pathfinder-weekly-report/integration
Jun 22, 2026
Merged

Rebuild weekly search report on the durable analytics API (fail-loud)#120
jpr5 merged 3 commits into
mainfrom
blitz/pathfinder-weekly-report/integration

Conversation

@jpr5

@jpr5 jpr5 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Rebuilds the weekly "Pathfinder Search Query Report" — which failed on 2026-06-21 because the claude.ai routine running it assumed a RAILWAY_API_TOKEN that claude.ai routine runtimes never receive, scraped ephemeral Railway stdout logs, and silently posted a Notion "error page" when its token was missing.

  • Durable data source. Adds a deterministic (no-LLM) report generator (scripts/weekly-search-report/) that reads the query_log-backed analytics JSON API (the same source as monthly-gap-analysis) instead of ephemeral Railway stdout. New analytics surface: GET /api/analytics/tool-breakdown (full tool_name, mirrors getToolCounts) + unique_ip_count_window / unique_session_count_window summary fields — all additive.
  • Fail loud. Missing token / non-2xx fetch / malformed payload / Notion-publish failure / report-write failure each log a greppable [weekly-report] FAILED, post a Slack alert, and exit non-zero — and never publish a degraded/partial page (multi-batch publish archives a partial page on append failure).
  • Runs where the secret exists. New weekly-search-report.yml GHA workflow (Sunday cron) reusing PATHFINDER_ANALYTICS_TOKEN / NOTION_TOKEN / SLACK_WEBHOOK_OSS_ALERTS — already repo secrets in monthly-gap-analysis.yml. The new script dir is gated under tsconfig.scripts.json typecheck + the static-quality prettier check.

Report renders native Notion tables (per-day, tool breakdown, keyword-categorized top queries, top-20, empty-result queries, explore/bash breakdown), and derives the window banner + page title from the actual queried window so labels never contradict the data.

Design spec: https://app.notion.com/p/3873aa38185281f883bef4dda4d51002

Test plan

  • Full suite green: 6518 tests (341 files)
  • tsc --noEmit (root + tsconfig.scripts.json), npm run build, prettier --check, actionlint all clean
  • Red-green: fail-loud regression (missing token → non-zero exit + Slack + no Notion page) reproduces the exact 2026-06-21 failure mode; analytics reader/route + report rendering covered
  • Post-merge: workflow_dispatch the new workflow and verify a correct Notion page, then disable the claude.ai routine trig_01AGpAF4r3z6Utn4hSyBoPhL

Follow-ups (out of scope, logged from CR)

  • Pin prettier as a devDependency (pre-existing unpinned npx prettier CI pattern)
  • Analytics-readers consistency sweep (getBlockedQueries / getAtlasRetrievalMetrics coercion + window alignment + request-source)
  • MCP SSE session liveness (GET/DELETE /mcp don't refresh sessionLastActivity)
  • Report table-rendering edge hardening + parseReportDays upper clamp

🤖 Generated with Claude Code

jpr5 added 3 commits June 22, 2026 14:28
Add getToolBreakdown reader (full tool_name, mirrors getToolCounts) + GET
/api/analytics/tool-breakdown route, and unique_ip_count_window /
unique_session_count_window to the analytics summary. Query_log-backed,
additive. Includes reader + HTTP route tests.
Deterministic (no-LLM) report that reads the durable analytics API and
publishes to Notion. Fails loud (non-zero exit + Slack, never a degraded
page) on missing token / fetch failure / malformed payload. Renders native
Notion tables, derives window/title labels from the actual queried window,
and sanitizes all cell/observation text.
Sunday cron GHA workflow reusing PATHFINDER_ANALYTICS_TOKEN / NOTION_TOKEN /
SLACK_WEBHOOK_OSS_ALERTS. Extend tsconfig.scripts.json + static-quality
prettier glob to typecheck/format-check scripts/weekly-search-report.
@jpr5 jpr5 merged commit ed46def into main Jun 22, 2026
9 checks passed
@jpr5 jpr5 deleted the blitz/pathfinder-weekly-report/integration branch June 22, 2026 21:48
jpr5 added a commit that referenced this pull request Jun 22, 2026
## Summary

Follow-up to #120. The weekly search report previously only emitted to
Slack on **failure** (`#oss-alerts`). A *successful* report is valuable
signal, so on a successful Notion publish it now posts a digest to
**#engr**:

`📊 Pathfinder weekly search report — 2551 tool calls · 198 unique IPs ·
top: Agents/CoAgents/AG-UI · 3.3% empty · [report]` (where **[report]**
is a Slack mrkdwn link to the Notion page).

- New `SLACK_ENGR_WEBHOOK` env (workflow secret `SLACK_WEBHOOK_ENGR`, a
B0T `#engr` incoming webhook — same convention as
`SLACK_WEBHOOK_OSS_ALERTS`/`SLACK_WEBHOOK_TEAM_SHOWCASE`).
- **Failures unchanged** — still fail-loud to `#oss-alerts` via
`SLACK_WEBHOOK`.
- Best-effort success ping: **no-ops when the webhook is unset** (so
this is safe to merge before the secret exists) and never affects the
run's exit code.

## Test plan

- [x] Red-green: success run posts the digest (incl. `<url|report>`) to
the success poster and NOT the failure poster; fetch/token failure posts
to the failure poster and NOT the success poster; unset success webhook
no-ops. (52 report tests; full suite 6522 green)
- [x] `tsc` (root + scripts), `npm run build`, `prettier --check`,
`actionlint` clean
- [ ] After merge: create the B0T `#engr` incoming webhook → set org
secret `SLACK_WEBHOOK_ENGR`; next Sunday run (or a `workflow_dispatch`)
posts to `#engr`

7-agent CR converged on round 1 (zero in-subject findings); pre-existing
report-rendering follow-ups (table backslash-escape, categorization
`useCoAgent` keyword, parseReportDays cap, etc.) tracked from #120, not
in scope here.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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