feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes

This commit is contained in:
Yun Chan 2026-11-14 11:51:41 +09:00
parent 01ef3293cf
commit 66b6b45ba9
399 changed files with 17828 additions and 11330 deletions

View file

@ -8,18 +8,18 @@
## 1. Supabase project (`server/supabase/`)
- `config.toml` — project_id `d3ro-voice`; local ports API 55321 / DB 55322 / Studio 55323 / local SMTP UI 55324; DB major v17; storage 50 MiB; auth `site_url` localhost:5173, redirects include `https://d3ro.chanpaca.net` and `d3ro-voice://auth-callback`; external providers Google/GitHub/Apple; per-function `verify_jwt` settings; analytics off. The mail section uses the Supabase CLI 3.x `[local_smtp]` name rather than the removed `[inbucket]` alias.
- `seed.sql`, `migrations/` (73 source files; last confirmed production state was `20260927000036`), `functions/` (24 source functions; the 23 functions present on 2026-09-27 were redeployed that day), `functions/_shared/`, `tests/`, `deno.json`.
- `seed.sql`, `migrations/` (74 source files; last confirmed production state was `20260927000036`, with `20261113000001_meeting_memos_revision_cas.sql` pending production push), `functions/` (24 source functions; the 23 functions present on 2026-09-27 were redeployed that day), `functions/_shared/`, `tests/`, `deno.json`.
> Note: root `supabase/` contains only empty scaffolding (`.branches/`, `snippets/`). The real project lives under `server/supabase/`.
### 1.1 Migrations (73) — thematic groups
### 1.1 Migrations (74) — thematic groups
| Theme | Examples |
|---|---|
| Core schema + RLS + auth triggers | initial tables, profiles, triggers |
| Storage buckets | audio, meeting documents, exports |
| Teams | team invites, membership, roles, `team_activities` feed (`20260913000033`) |
| Cross-device sync | `20260927000036`: preset prompt RPCs `sync_set_builtin_instruction_prompt_v1` / `sync_list_builtin_instructions_v1` + default SSOT `builtin_instruction_default_prompt_v1`. `20260927000035`: knowledge_documents tombstones/cursor/realtime + `pg_cron` job `prune-sync-tombstones` (daily 03:17 UTC). `20260927000034`: `sync_tombstones` (AFTER DELETE triggers on 8 synced tables, owner-read RLS, realtime, `prune_sync_tombstones_v1`), `history.revision` bump on content change, `meeting_memos.updated_at`, `(user_id, updated_at, id)` cursor indexes, client-keyed `sync_upsert/delete_user_template_v1`, realtime for `devices`/`memo_tags`/`custom_instructions`/`user_templates`, and `export_account_portability` projected back onto v1 archive keys |
| Cross-device sync | `20261113000001`: immutable `meeting_memos.revision` integer column + BEFORE UPDATE trigger (`bump_meeting_memo_revision`) so A→B→A edits always advance `revision` for CAS conflict detection (`GAP-SYNC-08`). `20260927000036`: preset prompt RPCs `sync_set_builtin_instruction_prompt_v1` / `sync_list_builtin_instructions_v1` + default SSOT `builtin_instruction_default_prompt_v1`. `20260927000035`: knowledge_documents tombstones/cursor/realtime + `pg_cron` job `prune-sync-tombstones` (daily 03:17 UTC). `20260927000034`: `sync_tombstones` (AFTER DELETE triggers on 8 synced tables, owner-read RLS, realtime, `prune_sync_tombstones_v1`), `history.revision` bump on content change, `meeting_memos.updated_at`, `(user_id, updated_at, id)` cursor indexes, client-keyed `sync_upsert/delete_user_template_v1`, realtime for `devices`/`memo_tags`/`custom_instructions`/`user_templates`, and `export_account_portability` projected back onto v1 archive keys |
| Knowledge / RAG | `knowledge_documents`, `knowledge_chunks`, pgvector |
| Notifications / push | push tokens, durable outbox |
| Billing | Payple, subscriptions, payment provider events/operations (`'stripe'` provider values kept only for historical rows) |
@ -102,3 +102,11 @@ Shared TS types for these live in `packages/api-client` (SSOT).
- Audio purge source wiring, unit tests, and an isolated local pg_cron/Vault invocation are verified: the fixture queue, `audio_files` row, and Storage object each changed from one to zero and `net._http_response` recorded HTTP 200. Deployment and the production schedule/Vault/object path remain unverified.
External gates are enumerated in `docs/v3/MOBILE_APP_COMPLETION_SSOT.md` §0/§6 and mirrored in `11-gap-backlog.md` (`EXT-*`, `BE-*`).
---
## Wave 6 hardening (2026-11-14)
- **Supabase Edge Functions (`server/supabase/functions`, Deno `270 passed | 0 failed`):** consolidated `jsonResponse`/`json` and streaming byte-bounded `readJsonBody` into `_shared/json-response.ts` across 20 Edge handlers (preserving CORS/`Cache-Control`/header contracts and failing closed with 400/413 on invalid/oversized JSON); hardened `account-delete` (`SAFE_INTERNAL_CODES`), `llm-proxy` (502 + quota refund on invalid provider JSON), `_shared/payple.ts` (`postPaypleJson` with `AbortSignal.timeout`), and `realtime-token/openai-provider.ts` (`AbortSignal.timeout`), backed by `_shared/json-response.test.ts` and tests in `payple`, `realtime-token`, `llm-proxy`, and `stt-proxy`.
- **Cloudflare Worker (`server/cloudflare-worker`, Deno `9 passed | 0 failed`):** added `resolveBackendTargetUrl` blocking `//host`/`\host` SSRF, omitted `backendOrigin` from `/worker-health`, stripped `Host`/hop-by-hop headers, set `redirect: 'manual'`, added `AbortSignal.timeout(30_000)`, sanitized 502/504 JSON responses, removed `console.log`, canceled unread `!response.ok` response bodies in `push-drain.ts`, and added 4 regression tests in `src/index.test.ts`.