diff --git a/AGENTS.md b/AGENTS.md index 47566bb..ca1c184 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -16,7 +16,8 @@ Read `docs/ARCHITECTURE.md` before any task. One task id per branch/PR (`task/BI 6. **Biometrics are opt-in per organization** and the legal basis is stored with the setting. 7. **No third-party AI by default.** Faces and OCR run locally; external fallbacks are opt-in per organization. 8. **Language:** code, comments, identifiers and commit messages in English. User-facing copy via i18n (pt-PT first). -9. **Never commit** secrets, `.env`, generated status/summary markdown files, or build output. +9. **Never commit** secrets, `.env`, generated status/summary markdown files, or build output. Deploys never + overwrite a server `.env` (norm BIT-25005, `docs/DEPLOY.md`). 10. **Green CI before merge:** `pnpm -r build && pnpm -r typecheck && pnpm -r test` and `cargo fmt --check`, `cargo clippy -D warnings`, `cargo test`. diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 7c00170..d8a1df9 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -54,13 +54,21 @@ Archive import: folder names changed across seasons (`LPbwin - 22-23`, `LPBetcli `LPBetclic - 24-25`, `LPBetclic 25-26`), so the importer proposes a folder -> competition/match mapping that an editor confirms before import. -## RAW support (LightCraft rev pinned in Cargo.toml, checked 2026-10-11) +## Editor scope + +JPEG first: most event and match photographers shoot JPEG for speed, so JPEG must be perfect before RAW. +Default editor modules: Crop (with straighten and aspect presets) and Basic (white balance, exposure, +contrast, highlights, shadows, whites, blacks, texture, clarity, dehaze, vibrance, saturation). Every other +LightCraft module (curves, colour mixer, grading, masks, detail, optics...) is available but off by default; +each user chooses which panels to show, and the choice syncs across their devices. + +## RAW support (secondary; LightCraft rev pinned in Cargo.toml, checked 2026-10-11) - Canon EOS R1, R3 (CR3): unverified; lossless and single-tile C-RAW decode, other CRX variants fall back to the embedded preview. No measured Canon colour calibration yet. - Nikon Z 9, Z 8: NEF decodes except High Efficiency (HE / HE*), which is preview-only. - Sony A9 / A9 II / A9 III: verified. -Action: collect real files from each body, add them to our reference set, contribute samples upstream. +Action (low priority): collect real files from each body, add them to our reference set, contribute samples upstream. ## Phases (gate to pass) @@ -75,6 +83,11 @@ Action: collect real files from each body, add them to our reference set, contri 5. Player identification: jersey OCR, faces, global search (parity with old projects validated). 6. Cutover: final import, redirects, old projects read-only, then switched off. +## Deploy + +Push to `main` -> Gitea webhook per container -> pull, build, migrate, reload, health check, auto-rollback. +Details: `docs/DEPLOY.md`. + ## Infrastructure (`next`) | Container | Services | Domain | diff --git a/docs/DEPLOY.md b/docs/DEPLOY.md new file mode 100644 index 0000000..cb5aa3e --- /dev/null +++ b/docs/DEPLOY.md @@ -0,0 +1,40 @@ +# Deploy + +Same model as the other BitReport projects (see `app.photoreport.pt/DEPLOY.md`, BIT-23722): push to `main` on +Gitea -> webhook -> the container pulls and redeploys itself. No manual `scp`/`rsync` of code. + +## Flow per container + +1. Gitea sends a push webhook to `https:///_deploy/gitea` (one webhook per container). +2. The receiver (small Node service, `infra/deploy-receiver`) verifies `X-Gitea-Signature` (HMAC-SHA256 with + the webhook secret from `.env`), checks `ref == refs/heads/main`, and that the push touched a path this + container owns (table below). Otherwise it answers 202 and does nothing. +3. It runs `infra/deploy/.sh ` under a lock (one deploy at a time per container): + - `git fetch` + `git reset --hard ` in `/srv/photoreport` + - `pnpm install --frozen-lockfile` / `cargo build --release -p ` as needed + - build only the affected package (`pnpm --filter build`) + - API only: `prisma migrate deploy` + - reload the process (PM2 for Node, systemd for Rust/Python workers) + - health check (`/health` must report the new `version`); on failure, reset to the previous sha and reload +4. Result (sha, duration, status) is posted to the deploy log and, on failure, to the notifications channel. + +## What a deploy never touches (norm BIT-25005) + +- `.env` is never created from `.env.example` over an existing file and never overwritten; a backup + `.env.bak.deploy` is written before each deploy. New variables are appended, never replaced. +- Data directories, Garage buckets, database contents (only versioned migrations run). + +## Path ownership + +| Container | Redeploys when these paths change | +| --- | --- | +| pr-api | `apps/api/**`, `packages/contracts/**`, `packages/metadata/**`, `prisma/**` | +| pr-app | `apps/app/**`, `packages/ui/**`, `packages/sdk/**`, `engine/**` (WASM build) | +| pr-site | `apps/site/**`, `packages/ui/**` | +| pr-workers | `workers/media/**`, `workers/render/**`, `engine/**`, `packages/metadata/**` | +| pr-ml | `workers/ml/**` | + +## Desktop and print agent + +Not deployed by webhook. A tag `desktop-v*` / `agent-v*` triggers Gitea Actions to build installers per OS and +publish a Gitea release; the Tauri updater and the agent's updater read from it.