feat: add tests for import polling, login page, money utilities, and query keys
- Implemented tests for import polling functionality, ensuring correct behavior for active and terminal import statuses. - Created tests for the login page, validating user interactions and error handling. - Added unit tests for money utility functions, covering parsing, formatting, and summation of monetary values. - Developed tests for query keys, ensuring proper scoping and invalidation roots. chore: setup testing environment and configuration - Added setup file for testing with Vitest and Testing Library. - Configured TypeScript and Vite for the frontend project. - Created Docker and Nginx configurations for local development and production environments. - Established a PostgreSQL initialization script for setting up application roles. docs: add README and environment configuration for infra - Included README for the infra directory, detailing local development setup and service descriptions. - Created an example environment configuration file for local development with placeholders for sensitive information.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
# Backup and Restore
|
||||
|
||||
> Status: **design/runbook**. The stack is not deployed yet; no restore has been
|
||||
> performed. Do not treat these targets as verified until a drill passes.
|
||||
|
||||
## Scope and targets (proposed)
|
||||
|
||||
| Item | Method | Retention | RPO target |
|
||||
| --- | --- | --- | --- |
|
||||
| PostgreSQL | Provider-native PITR if available; else nightly `pg_dump -Fc`, encrypted at rest | 30 days | ≤ 24 h |
|
||||
| Object storage (statement files) | Provider versioning/replication of the bucket | 30 days | ≤ 24 h |
|
||||
| KEK / secrets | Secret-manager backup per provider policy | indefinite | ~0 (loss = data loss) |
|
||||
| Redis | none — cache/queue only, rebuilt on restore | — | acceptable loss |
|
||||
| Container images | registry retained per release tag | last 10 releases | — |
|
||||
|
||||
Statement files are envelope-encrypted (ADR 0004): restoring PostgreSQL without
|
||||
the matching DEK rows **and** the KEK makes files permanently undecryptable. KEK
|
||||
backup is therefore mandatory and must be tested like a restore.
|
||||
|
||||
## Restore procedure (draft)
|
||||
|
||||
1. Provision replacement PostgreSQL/Redis/S3 endpoints in the RF region.
|
||||
2. Restore the latest PostgreSQL backup into the new instance; run `alembic upgrade head` to confirm schema state matches the deployed image.
|
||||
3. Restore the object bucket from versioning/replica.
|
||||
4. Restore secrets: KEK, `SESSION_SECRET`, DB/S3/SMTP credentials.
|
||||
5. Deploy the last known-good image tags (API, worker, frontend proxy) with the restored endpoints configured.
|
||||
6. **Re-apply the durable deletion ledger** for entries executed after the backup timestamp (see `deletion-ledger.md`): re-delete purged rows/objects and re-shred DEKs.
|
||||
7. Smoke test: `/healthz` on API, queue consumer alive, one synthetic import end-to-end, login with an invited test user.
|
||||
8. Reopen traffic at the edge.
|
||||
|
||||
## Restore drill
|
||||
|
||||
- Cadence: before beta launch, then quarterly.
|
||||
- Record in this file: date, backup age, result, defects found.
|
||||
- Drills performed: **none yet**.
|
||||
|
||||
A disaster test is a launch gate (plan §10): restore a backup, reapply the
|
||||
completed deletion ledger, and prove purged spaces/keys remain inaccessible.
|
||||
@@ -0,0 +1,40 @@
|
||||
# Beta Release Runbook (closed beta)
|
||||
|
||||
> Status: **template**. No release has been executed. Every unchecked item is
|
||||
> still open; do not check items from this document without doing them.
|
||||
|
||||
## Preconditions (launch gate)
|
||||
|
||||
- [ ] One-shot Alembic migration applied from an empty database on staging.
|
||||
- [ ] Provider-neutral images built and tagged (API/worker: `infra/docker/Dockerfile.backend`; frontend: `infra/docker/Dockerfile.frontend`) and pushed to the registry.
|
||||
- [ ] Same-origin reverse proxy live at the edge with TLS + HSTS; `/api/v1` verified end-to-end (login round-trip).
|
||||
- [ ] `/healthz` (API) and readiness probes wired to the platform; queue-depth and parser-failure metrics visible.
|
||||
- [ ] Backups configured and a **restore drill passed** (`backup-and-restore.md`).
|
||||
- [ ] KEK and secrets present in the secret manager; nothing secret in `VITE_*` or Git (ADR 0004).
|
||||
- [ ] Legal/privacy gate for RF data localization **signed by qualified counsel** — hard gate before any real invite.
|
||||
- [ ] Deletion workflow (30-day window, purge, ledger) reviewed against `deletion-ledger.md`.
|
||||
- [ ] Bank adapters enabled only per `docs/parsers/private-fixture-gate.md`; unsupported formats are not advertised.
|
||||
- [ ] Invites limited to an explicit allowlist; public registration stays off.
|
||||
|
||||
## Launch sequence
|
||||
|
||||
1. Deploy images; run migrations one-shot (`alembic upgrade head`), never on container start.
|
||||
2. Smoke test on production data (synthetic only): invite → register → create space/account → plan month → manual operation → import synthetic statement → review/confirm → close month → reports.
|
||||
3. Verify Mailpit-equivalent SMTP path against the production SMTP relay (invite email delivered).
|
||||
4. Enable email invites for the allowlist; monitor error rates, queue depth, parser failures for the first sessions.
|
||||
|
||||
## Rollback
|
||||
|
||||
- Redeploy previous image tags; migrations are **forward-fix preferred**.
|
||||
- Downgrade only where the migration is marked reversible in Alembic; otherwise restore from backup and re-apply the deletion ledger (see `backup-and-restore.md`).
|
||||
- Never roll forward a parser version without a review diff (ADR 0003).
|
||||
|
||||
## Incidents
|
||||
|
||||
- Financial-data suspected exposure: revoke sessions, rotate `SESSION_SECRET`, preserve audit events, follow the (to-be-written) privacy incident procedure.
|
||||
- Break-glass access: separate role, mandatory reason, short-lived grant, append-only audit — never through ordinary admin tooling.
|
||||
|
||||
## Post-launch
|
||||
|
||||
- Record adapter gate statuses and any layout-drift events.
|
||||
- Keep the restore drill quarterly; update `backup-and-restore.md` drill log.
|
||||
@@ -0,0 +1,36 @@
|
||||
# Deletion Ledger
|
||||
|
||||
> Status: **contract definition**. The hardening workstream (plan §9) implements
|
||||
> this; nothing here is verified in code yet.
|
||||
|
||||
## Purpose
|
||||
|
||||
Space deletion is final and must survive disaster restores. A backup restored
|
||||
after a purge would otherwise resurrect rows, objects and metadata of deleted
|
||||
spaces. The deletion ledger is an append-only record of completed deletions that
|
||||
any restore **must** replay before serving traffic.
|
||||
|
||||
## Lifecycle
|
||||
|
||||
1. **Request** — user requests space deletion. The space is locked immediately (no logins, writes or imports); a 30-day cancellation window starts.
|
||||
2. **Cancel** — within the window the owner may cancel; the lock is lifted, nothing is purged.
|
||||
3. **Purge** (after the window, via Celery worker):
|
||||
- hard-delete all space rows (financial tables, categories, payees, imports, memberships, users where applicable);
|
||||
- delete all S3 objects of the space and destroy the per-file DEK rows (crypto-shred, ADR 0004);
|
||||
- append one ledger entry **only after** all phases succeed.
|
||||
4. **Ledger entry** — append-only, minimal fields: `space_id`, `requested_at`, `purged_at`, `executed_by (job id)`, `phases_completed`, `integrity_hash` (chain hash over prior entry). No financial payloads.
|
||||
|
||||
## Replay after restore
|
||||
|
||||
On any disaster restore (see `backup-and-restore.md` step 6):
|
||||
|
||||
1. Load ledger entries with `purged_at` later than the restored backup timestamp.
|
||||
2. For each: re-delete the space's rows (restored backups may contain them again), re-delete its objects, re-destroy DEK rows.
|
||||
3. Verify: no row with `space_id` in any financial table; bucket prefix absent; decryption of the space's files impossible.
|
||||
4. Record the replay in the drill log.
|
||||
|
||||
## Implementation notes
|
||||
|
||||
- The ledger table itself is never purged by space deletion and is included in backups.
|
||||
- A purge job must be idempotent and resumable: each phase is committed separately and the ledger entry is written last, in the same transaction as the final phase marker.
|
||||
- Ledger integrity is checked on startup after restore (chain hash mismatch = manual escalation).
|
||||
Reference in New Issue
Block a user