pezkuwichain 9c6af146e6 ops: let a function be retired, not just deployed (#17)
* ops: let a function be retired, not just deployed

The guarded deploy could create and update, never remove. rsync runs without
--delete on purpose, so one project cannot wipe another's functions — but the
consequence was that nothing ever left. A function deleted from its repository
kept serving traffic, and nobody would know.

Found the concrete case on 2026-08-01: email-verification had been removed from
pwap on 2026-07-30 and was still live and reachable with only the anon key,
running under the service-role key with Access-Control-Allow-Origin *. Its
verify path sets profiles.email_verified for whatever user_id a token maps to.
It was not exploitable — the send path calls getUserByEmail, which the SDK does
not have, so no tokens could be minted and the table was empty. Broken is not
the same as safe; it was protected by a bug, not by design.

- --audit compares the volume against the registry both directions and exits 1
  on drift. Runs after every deploy too, so a leftover is stated rather than
  invisible.
- --retire moves functions into /opt/supabase-self-hosted/retired-functions/
  with a timestamp. Quarantined, not deleted: retiring the wrong thing has to be
  one command to undo, and that copy is the only remaining record of what was
  serving traffic.
- _cloud_hosted names now count as declared. They live on the cloud project and
  are owned by nobody here, so without this the audit would have offered to
  retire ask and telegram-bot, which look live.

Applied: email-verification retired and dropped from the registry; the audit is
clean; two-factor-auth and the miniapp's check-deposits both still answer.

* ops: catch the function a project still serves but no longer ships

The retire mechanism closed the second half of the problem. This closes the
first: nothing could detect that email-verification needed retiring.

It was never an orphan. The registry listed it as owned and current, the volume
agreed, and both were right about each other — the repository was the one that
had dropped it. Volume-vs-registry compares two of the three and cannot see a
disagreement in the third. It only became visible as drift because I removed it
from the registry by hand, which means the mechanism did not find it; I did.

A deploy is the one moment we hold the project's actual source next to the
registry and the volume, so it is the only place all three can be compared.
Anything the project owns, that is on disk, and that is absent from what it just
shipped, is now named with the command to retire it.

Warns rather than refuses: deleting a function and shipping an unrelated change
in the same commit is ordinary, and blocking that deploy until someone retires
would punish the correct move. It is printed in the deploy output and recorded
as an ABANDONED line in the deploy log.

Verified against a source tree missing eight of pwap-web's functions: all eight
named, deploy still allowed.
2026-08-01 02:30:25 -07:00

Pezkuwi Telegram Mini App

Telegram Mini App for Pezkuwichain - Forum, Announcements, Rewards, and Wallet integration.

Tech Stack

  • Frontend: React 18 + TypeScript + Vite
  • Styling: Tailwind CSS + shadcn/ui patterns
  • State: TanStack Query (React Query)
  • Backend: Supabase (PostgreSQL + Auth + Edge Functions)
  • Testing: Vitest + Testing Library
  • CI/CD: GitHub Actions

Getting Started

Prerequisites

  • Node.js >= 18
  • npm >= 9
  • Supabase account

Installation

# Clone the repo
git clone https://github.com/pezkuwichain/pezkuwi-telegram-miniapp.git
cd pezkuwi-telegram-miniapp

# Install dependencies
npm install

# Copy environment template
cp .env.example .env

# Add your Supabase credentials to .env

Development

# Start dev server
npm run dev

# Run tests
npm run test

# Type check
npm run typecheck

# Lint
npm run lint

# Format code
npm run format

# Full validation (typecheck + lint + test + build)
npm run validate

Build

npm run build

Output will be in dist/ directory.

Project Structure

src/
├── contexts/       # React contexts (Auth)
├── hooks/          # Custom hooks (Supabase, Telegram)
├── lib/            # Utilities (env, supabase client)
├── sections/       # Main app sections
│   ├── Announcements.tsx
│   ├── Forum.tsx
│   ├── Rewards.tsx
│   └── Wallet.tsx
├── test/           # Test setup
├── types/          # TypeScript types
├── App.tsx         # Main app component
└── main.tsx        # Entry point

Database Schema

Tables (prefixed with tg_ to avoid conflicts):

  • tg_users - Telegram users
  • tg_announcements - Admin announcements
  • tg_announcement_reactions - Like/dislike reactions
  • tg_threads - Forum threads
  • tg_thread_likes - Thread likes
  • tg_replies - Thread replies
  • tg_reply_likes - Reply likes

Environment Variables

Variable Description
VITE_SUPABASE_URL Supabase project URL
VITE_SUPABASE_ANON_KEY Supabase anon/public key

Telegram Setup

  1. Create bot via @BotFather
  2. Enable Mini App in bot settings
  3. Set Mini App URL to deployment URL
  4. Deploy telegram-auth Edge Function to Supabase

License

MIT

S
Description
No description provided
Readme MIT 8.6 MiB
Languages
TypeScript 91.4%
Python 3.1%
PLpgSQL 2.4%
JavaScript 2.2%
Shell 0.4%
Other 0.4%