Skip to content

feat(ops): add a read-only backend drift check - #79

Merged
Programcode merged 3 commits into
mainfrom
feat/backend-status
Oct 1, 2026
Merged

Programcode merged 3 commits into
mainfrom
feat/backend-status

Conversation

@Programcode

@Programcode Programcode commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

What

npm run backend:status shows what the current commit has that a Supabase project lacks. Vercel ships the frontend on merge, but migrations and Edge Functions are deployed by hand. On 2026-09-30 production lacked two migrations and ran pre-#75 functions, and nothing in the repo would have shown it.

It runs supabase migration list and supabase functions list, nothing else, and compares their output with the tree committed at HEAD. It reports:

  • migrations on the commit that are not applied, and applied migrations the commit lacks;
  • functions that are not deployed;
  • functions deployed before the last first-parent commit that touched them or any file they import (following relative imports into _shared/);
  • deployed verify_jwt that differs from supabase/config.toml;
  • deployed functions the commit does not have.

Flags: --project-ref <ref> targets another project (the staging work in plan item 8 uses this), and --check exits 1 when a migration is not applied. Exit 2 means the check itself failed. CLI errors are shown with connection-string passwords redacted.

docs/operations.md gains a "Backend drift check" section and makes the command step 1 of every backend deploy. supabase/README.md and AGENTS.md point to it.

Not done: the prod-canary step

I did not add a prod-canary.yml step. --check is ready for one, but it would need a Supabase access token and database access in Actions, which is a production credential. That's Adam's decision.

Evidence

  • New src/test/scripts/backend-status.test.ts (5 tests) builds a throwaway git repo with dated commits and a fake supabase binary. It checks the report, that only the two list commands are called (with --linked by default, --project-ref when given), the --check exit codes, argument rejection and redaction. Flipping the staleness comparison makes it fail.
  • Local: npm run docs:check, npm run lint, npm run typecheck and npm test -- --coverage (110 files, 1112 tests) all pass.
  • Live, read-only, against production at fe6100a: 38 of 38 migrations applied, 12 of 13 functions deployed. The missing one is workspace-invites, which is expected because Collaborative Workspace is hidden.
  • Live, read-only, against staging: migrations current, but stripe-webhook was deployed 2026-05-20 and changed on main on 2026-08-21 (12951b6). Staging's webhook is stale. I have not redeployed it.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a read-only backend status check that compares the linked Supabase project with the current commit and reports migration, function, and configuration differences.
    • Check mode returns distinct exit codes for pending migrations and operational errors.
  • Documentation
    • Updated deployment guidance to check backend status before deployment and rerun the check afterward.
    • Added guidance to use the status check when investigating frontend errors involving Supabase.

Vercel ships the frontend on merge, but migrations and Edge Functions are
deployed by hand, and nothing in the repo showed when production fell
behind. On 2026-09-30 it lacked two migrations and ran pre-#75 functions.

`npm run backend:status` runs `supabase migration list` and
`supabase functions list` and compares them with the migrations and
function folders committed at HEAD. It reports unapplied migrations,
undeployed functions, functions deployed before the last commit that
touched them or a file they import, and verify_jwt drift from
config.toml. `--project-ref <ref>` targets another project, and `--check`
exits 1 when a migration is not applied.

docs/operations.md makes it the first step of every backend deploy.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 08:52
@vercel

vercel Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
debate-navigator Ready Ready Preview Oct 1, 2026 4:16pm UTC

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: 402c07b9-e7a7-43f9-bc28-f4d7d04a8c8e

📥 Commits

Reviewing files that changed from the base of the PR and between d6c7dca and eb5ae65.

📒 Files selected for processing (3)
  • docs/operations.md
  • scripts/backend-status.mjs
  • src/test/scripts/backend-status.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/operations.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Adds a read-only npm run backend:status command. It compares backend state committed at HEAD with a Supabase project, reports migration and function differences, and supports a --check mode. Deployment guidance and integration tests cover the command.

Changes

Backend status check

Layer / File(s) Summary
Read committed backend state
scripts/backend-status.mjs
The script parses command options and reads migration, function, import, and configuration data from HEAD. It also looks up first-parent change dates for backend files.
Compare and report backend status
scripts/backend-status.mjs, package.json, src/test/scripts/backend-status.test.ts
The command queries the selected project and reports migration and function differences. --check returns 1 when committed migrations are pending; argument and operational errors return 2. Integration tests cover reports, project targeting, read-only commands, exit behavior, and sanitized errors.
Add status checks to deployment guidance
AGENTS.md, docs/operations.md, supabase/README.md
Deployment guidance documents when to run the check and directs operators to confirm intended changes are no longer pending. Operations guidance also documents command behavior, limitations, and an incident troubleshooting step.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  actor Operator
  participant Npm as npm run backend:status
  participant Script as backend-status.mjs
  participant Git
  participant SupabaseCLI as Supabase CLI
  Operator->>Npm: Run status command
  Npm->>Script: Execute script
  Script->>Git: Read committed backend state at HEAD
  Script->>SupabaseCLI: List project migrations and functions
  Git-->>Script: Return committed migrations and function configuration
  SupabaseCLI-->>Script: Return deployed migration and function data
  Script-->>Operator: Print backend status report
Loading

Architecture Summary

Architecture risk: 🔵 Low · up to eb5ae

The change affects 6 systems.

Changed systems: AGENTS.md, docs, package.json, scripts, src, supabase

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — AGENTS.md (service) was modified; 1 changed file maps to changed impact.
  • observed — docs (service) was modified; 1 changed file maps to changed impact.
  • observed — package.json (service) was modified; 1 changed file maps to changed impact.
  • observed — scripts (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in AGENTS.md: The Deployment guidance adds a read-only npm run backend:status check before backend deployment and states that it lists missing items in the linked project.
  • observed — Modified behavior in package.json: Added the backend:status package script to execute scripts/backend-status.mjs with Node.
  • observed — Modified behavior in supabase/README.md: The second deployment-checklist step now adds a pending-changes check using npm run backend:status and links to the backend drift-check instructions.
  • observed — Modified behavior in docs/operations.md: Adds documentation for npm run backend:status: it inspects the CLI-resolved project, or an explicitly supplied project ref, without changing schema, data, functions, or secrets; the CLI creates a short-lived login role to connect. It compares the committed HEAD tree with project migrations and functions, including deployment status, commit-relative function dates, and verify_jwt configuration. The documentation notes first-parent merge dating, the stale-checkout limitation, shallow-clone behavior, expected absence of workspace-invites in production, and --check exit codes 1 for unapplied migrations and 2 for check failure. It also documents why scheduled production checks await a decision.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Essentials by visiting https://app.coderabbit.ai/settings/billing.

Comment @coderabbitai help to get the list of available commands.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 57 minutes.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

A function deployed from an out-of-date checkout gets a fresh deploy
date, so backend:status reports it as current. Say so in the report
and the docs, and deploy functions only from an up-to-date main.

Drop the untested claim about SUPABASE_DB_PASSWORD, and note that a CI
step would need a production credential that AGENTS.md keeps out of
jobs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

live-e2e failure is not from this PR. It fails on main code too.

The same 5 tests fail with the same timings on two unrelated open PRs today: runs 36839258226 (t3code/pgtap-coverage-untested-tables) and 36840738694 (t3code/make-staging-usable). The tests are Attack/Brainstorm, live sparring, Crossfire, case-generation research, and web import. This PR changes only scripts/backend-status.mjs, its test, package.json and docs. None of that is loaded by the app or the Edge Functions.

The function log in the failure artifact shows why. AI requests (attack, factoids, ask) start deep research and then hit the local edge runtime's wall-clock limit (wall clock duration warning → early termination has been triggered) before a model reply arrives. From 2026-09-24 until today, live-e2e jobs ended in 3 to 5 seconds without running, so this is the first real run in a week. It says nothing about production: the canary runs since 2026-09-30 didn't run either.

That regression needs its own fix. The other checks on d6c7dca pass: quality, database-tests and the Vercel build.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 58 minutes.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 58 minutes.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

A function whose deploy date is missing or unreadable was compared as
current, so a stale function could pass unnoticed. It is now listed as
changed with "deploy date unknown".

The report label read the linked ref file, but the Supabase CLI prefers
SUPABASE_PROJECT_ID over it, so the label could name a different project
than the one inspected. The label now follows the CLI's order.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Programcode
Programcode merged commit 4698e1f into main Oct 1, 2026
7 of 8 checks passed
Programcode added a commit that referenced this pull request Oct 1, 2026
Brings in #79 to #83 and #85.

Conflict in .superset/db-gate.sh: both sides added a function to the
readiness loop. The loop now waits for both `voice` and `account`.

#82 replaced the "Which debate is this for?" dialog with the first-debate
offer when no debate is current. e2e/voice-rounds.spec.ts still clicked
the old button in two places, so it answers the new offer the way
e2e/sparring.spec.ts does.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — eb5ae659 Deployed Oct 1, 2026 by vercel[bot]
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.

2 participants