Skip to content

fix(staging): self-heal beat_editors/beat_claims, seed beats table - #863

Open
arc0btc wants to merge 1 commit into
mainfrom
fix/staging-beat-seed-805
Open

fix(staging): self-heal beat_editors/beat_claims, seed beats table#863
arc0btc wants to merge 1 commit into
mainfrom
fix/staging-beat-seed-805

Conversation

@arc0btc

@arc0btc arc0btc commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • beat_claims and beat_editors are added to the always-re-applied SCHEMA_SQL (same self-heal pattern already used for leaderboard_cache), so a DO whose migration_version was bumped past Bug: /api/inscriptions returns stale 2024 data #13/ci: add syntax check and Pages Functions build validation #17 without those tables actually landing recovers on next cold start instead of 500ing GET /api/beats forever on "no such table: beat_editors".
  • POST /api/internal/seed (/test-seed DO route) now accepts a beats array and inserts it before signals — previously only signals/signal_tags/etc. were seeded, so signals referenced beat slugs that never existed as rows, and every GET /api/beats/:slug 404'd.
  • fixtures/seed-staging.json now includes the 7 beats its seed signals actually reference (bitcoin-macro, quantum, agent-economy, agent-skills, governance, infrastructure, security), matching the canonical name/description/color from the migrations that created them.

Context

Closes #805. Root cause was confirmed in the issue thread — this PR implements the two-part fix proposed there (structural self-heal + seed-endpoint fix).

Test plan

🤖 Generated with Claude Code

…805)

GET /api/beats 500ed on staging because migration_version was written
past the beat_editors/beat_claims migrations (#13, #17) without the
tables actually landing — the version counter never retries a migration
once it's marked applied. Add both tables (and their indexes) to the
always-re-applied SCHEMA_SQL so they self-heal on cold start, same
pattern already used for leaderboard_cache.

Beat lookups 404ed separately because /api/internal/seed's /test-seed
route never seeded the beats table itself — only signals, which
reference beat_slug but aren't FK-enforced by sqlite. Add a beats
seed block (ordered before signals) and populate fixtures/seed-staging.json
with the 7 beats staging's seed signals actually reference.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
agent-news af43917 Jul 13 2026, 04:42 AM

@github-actions

Copy link
Copy Markdown
Contributor

Preview deployed: https://agent-news-staging.hosting-962.workers.dev

This preview uses sample data — beats, signals, and streaks are seeded automatically.

@arc0btc

arc0btc commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Self-heal fix for #805 looks correct and low-risk.

What works well:

  • beat_claims/beat_editors added to the always-re-applied SCHEMA_SQL mirrors the existing leaderboard_cache self-heal pattern — consistent with prior art in this file, and CREATE TABLE IF NOT EXISTS + CREATE INDEX IF NOT EXISTS are genuinely idempotent, so this is safe to run on every cold start regardless of migration_version.
  • Seeding order fix (beats before signals) is correct — sqlite doesn't enforce the beats(slug) FK by default, so this was a real bug: signals could seed successfully while every beat lookup 404'd.
  • INSERT OR IGNORE for beats + per-row try/catch keeps one malformed fixture row from aborting the whole seed batch.
  • Test plan explicitly calls out the previously-blocked x402 smoke test steps from staging: /api/beats returns 500, beat lookups 404 — seed data incomplete #805 — good traceability.

[nit] The per-row catch { /* Skip invalid rows silently */ } in the new beats-seeding loop (news-do.ts) swallows the actual error. This is a /test-seed-only path (not production traffic) so low stakes, but if a fixture row is ever malformed, debugging why inserted.beats came back short will require re-adding a log line rather than reading a console.warn. Not blocking — same silent-catch style is already used elsewhere in this route, just flagging for future cleanup.

Approving — this matches the two-part fix the issue thread converged on and both changes are additive/idempotent.

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.

staging: /api/beats returns 500, beat lookups 404 — seed data incomplete

1 participant