Skip to content

ops: make deploy guards token + CLI version prerequisites - #81

Merged
BluegReeno merged 2 commits into
mainfrom
archon/task-fix-issue-80
Jul 27, 2026
Merged

ops: make deploy guards token + CLI version prerequisites#81
BluegReeno merged 2 commits into
mainfrom
archon/task-fix-issue-80

Conversation

@BluegReeno

Copy link
Copy Markdown
Owner

Summary

  • make deploy now guards its own two prerequisites — a missing SUPABASE_ACCESS_TOKEN and an outdated supabase CLI — before ever calling supabase functions deploy, instead of failing deep into the deploy with a misleading 403 or a lockfile crash.
  • Both guards live in the deploy recipe as one shell invocation (\ line-continuation), not .ONESHELL:, so the sourced token is visible to the deploy step without changing verify/test's per-line subshell semantics.
  • docs/operations.md §2 (written in docs(operations): deploy prerequisites learned the hard way #79) is reframed, not duplicated: it now explains that make deploy performs both checks automatically, keeping the manual instructions only where they still apply (Path B, which bypasses make deploy).

Changes

Makefile

  • New MIN_SUPABASE_CLI := 2.109.1 variable (the version that reads deno.lock lockfile v5).
  • deploy recipe rewritten as a single logical recipe line, in order:
    1. set -e; (defense-in-depth against a malformed .envrc)
    2. CLI-version guard — compares supabase --version against MIN_SUPABASE_CLI via sort -V; on failure, prints both versions and the brew trust --formula supabase/tap/supabase && brew upgrade supabase remedy to stderr, exit 1.
    3. Token guard — sources .envrc only when SUPABASE_ACCESS_TOKEN is unset and .envrc exists; if still unset, prints a named error pointing to docs/operations.md §2, exit 1. An already-exported token is honoured as-is and .envrc is never re-sourced; a missing .envrc is not itself an error.
    4. The unchanged deploy: supabase functions deploy hal-mcp --no-verify-jwt && ./scripts/verify_deploy.sh.
  • verify and test targets are untouched — diff is scoped to deploy and the new variable.
  • deno.lock is never touched, deleted, or regenerated by this change.

docs/operations.md

  • §2 prose reconciled with the guards above instead of duplicating them: the token-sourcing snippet is scoped under Path B (the only path that still bypasses make deploy and needs manual sourcing); the CLI-version prose now reads as "the guard prints this remedy — run it, then retry" rather than a manual pre-flight step. Version numbers and the do-not-regenerate-the-lockfile warning are kept.

Validation

  • make -n deploy — dry-run confirms the guarded recipe is one logical shell invocation, not silently split across subshells (the exact trap the issue warns about).
  • Token guard, no token + no .envrc → exit 1, named error, never reaches the deploy call.
  • Token guard, no token + .envrc present → .envrc sourced in the same shell, token populated, deploy proceeds.
  • Token guard, token already exported → honoured as-is, .envrc not sourced.
  • CLI guard, MIN_SUPABASE_CLI temporarily raised to 99.0.0 (via make -e, no file edit) → exit 1, names both versions and the brew remedy, no deploy attempt.
  • make test (Level 3 offline suite) — unchanged pass: deno check on both edge functions + 157 pytest passed, proving test/verify weren't affected.
  • deno.lock confirmed untouched.

Full detail in the implementation/validation artifacts for this run.

Fixes #80

make deploy ran the deploy unconditionally: a missing SUPABASE_ACCESS_TOKEN
(direnv doesn't fire non-interactively) failed with a misleading 403, and an
outdated CLI that can't read deno.lock v5 died at bundling after auth succeeded.
Both are now caught up front, as one guarded recipe line so the sourced token
reaches the deploy in the same shell.

Changes:
- Makefile: add MIN_SUPABASE_CLI := 2.109.1; rewrite deploy as one logical
  recipe line — CLI-version guard (sort -V) then token guard (source .envrc
  only when the token is unset and .envrc exists) before the actual deploy
- Makefile: an already-exported token is honoured as-is, a missing .envrc is
  not an error when the token is set, deno.lock is never touched
- docs/operations.md §2: reconcile prose with the guards (#79) — Path A now
  guarded automatically, Path B still sources the token by hand

Fixes #80
Fixed:
- CLAUDE.md's "Edge function deploy" bullet described the pre-#80 manual
  .envrc-sourcing model and made no mention of the automatic token/CLI-
  version guards this PR added to `make deploy`, contradicting the shipped
  behavior for any session that reads only the summary.

Skipped:
- README.md L279/L303 (LOW, optional per docs-impact-findings.md) — still
  technically true, not filed as a standalone finding.
@BluegReeno

Copy link
Copy Markdown
Owner Author

⚡ Self-Fix Report (Aggressive)

Status: COMPLETE
Pushed: ✅ Changes pushed to archon/task-fix-issue-80 (55de9fc)
Philosophy: Fix everything unless clearly a new concern


Fixes Applied (1 total)

Severity Count
🔴 CRITICAL 0
🟠 HIGH 0
🟡 MEDIUM 1
🟢 LOW 0
View all fixes
  • CLAUDE.md deploy summary omits the new automatic guards (CLAUDE.md:80-88) — rewrote the "Edge function deploy" bullet to describe the automatic token guard (named error, never a bare 403) and the MIN_SUPABASE_CLI version guard added by this PR, instead of implying manual .envrc sourcing is still required.

code-review-findings.md reported zero findings (APPROVE — both guards verified live in that review).


Tests Added

(none — Makefile/docs-only change, no runtime surface)


Skipped (1)

Finding Reason
README.md deploy bullet slightly stale on auth-fallback nuance Explicitly marked optional/not filed as a separate finding by the docs-impact review — still technically true

Suggested Follow-up Issues

(none)


Validation

⚠️ deno not installed in this environment (pre-existing, unrelated to this docs-only change) — no type-check/lint/test surface applies to a CLAUDE.md edit.


Self-fix by Archon · aggressive mode · fixes pushed to archon/task-fix-issue-80

@BluegReeno
BluegReeno marked this pull request as ready for review July 27, 2026 13:28
@BluegReeno
BluegReeno merged commit 3fa6099 into main Jul 27, 2026
3 checks passed
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.

ops: make deploy should guard its own prerequisites (token + CLI version)

1 participant