fix(recovery): restore source removed by production documentation merge

This commit is contained in:
2026-11-10 03:42:10 +01:00
parent 585bdd4b44
commit 3d2fc6f913
957 changed files with 115754 additions and 0 deletions
File diff suppressed because one or more lines are too long
@@ -0,0 +1,57 @@
# ADR-0002: `/api/0pt/*` authenticates via fleet Zitadel Bearer tokens, not NextAuth/Auth.js
- **Status:** Accepted and implemented
- **Date decided:** ~2026-07 ("Wave 2" — commit `1d76d50`,
"feat(auth,foundation): Wave 2 flag-gated Zitadel JWT verify + validation
+ eslint + tests"), fail-closed default landed commit `1c1e2cb`
("fix(auth): make the AUTH_ENFORCE default fail-closed on `/api/0pt/*`")
- **Date of this record:** 2026-08-11 (BACKLOG P1-2 — retroactive)
## Context
0pt's capability surface (`/api/0pt/*`) needs to authenticate requests
against a real identity, and needs that identity to carry a SIAX tenant so
`x-0pt-verified-tenant` can be trusted downstream. SIAX Cloud already runs a
fleet-wide Zitadel IdP (`id-customers.siax.io`) for exactly this purpose —
building a second, repo-local identity provider would duplicate it and
create a second source of truth for "who is this".
## Decision
`middleware.ts` verifies inbound `Authorization: Bearer` tokens against the
fleet Zitadel IdP (`src/auth/zitadel.ts`): JWKS discovered from
`<issuer>/.well-known/openid-configuration` (falling back to
`<issuer>/oauth/v2/keys`), tenant derived from a documented claim-key
precedence (`urn:zitadel:iam:org:id` → `urn:zitadel:iam:user:resourceowner:id`
→ `tenant_id` → `tenant`). No NextAuth/Auth.js dependency was added.
Enforcement is fail-closed by default: `AUTH_ENFORCE` unset (or any value
except the literal string `"false"`) requires a valid, verified token — 401
on missing/invalid, 403 when a client-supplied `X-Tenant-Id` disagrees with
the token's own tenant claim. `AUTH_ENFORCE=false` is a local-dev-only escape
hatch, and is refused at boot when `NODE_ENV=production`
(`assertAuthConfigSafe()` throws rather than serving anonymously).
A separate, older HMAC session cookie (`lib/auth.ts`, with a `DEV_LOGIN_KEY`
dev-login shortcut) exists in parallel and is explicitly **not** the auth
system this ADR is about — it predates the Zitadel work, has no MFA/CSRF/
revocation, and is tracked as its own gap (BACKLOG P0-14, gated on the
account owner's decision about what replaces it).
## Consequences
- 0pt does not maintain its own user/credential store for the capability
layer — identity is entirely delegated to the fleet Zitadel instance.
- A live-verified gap was found and is tracked separately: a 2026-08-10
probe found `GET 0pt.app/api/0pt` returning 200 anonymously despite the
code being fail-closed (BACKLOG P0-4/P0-5, root cause unresolved as of
this record — do not assume the deployed instance enforces this until an
anonymous request gets a real 401 there).
- `middleware.ts` sits outside `tsconfig.check.json`'s blocking type-check
scope (BACKLOG P0-5) — a real gap, not addressed by this ADR.
## See also
- `docs/architecture/ARCHITECTURE.md` §8 "Säkerhet"
- `tests/auth/{context,zitadel}.test.ts`
- `docs/compliance/BACKLOG.md` P0-4, P0-5, P0-14
@@ -0,0 +1,47 @@
# ADR-0003: Lakehouse table format is Apache Iceberg (pointer to `n0d` ADR-0030)
- **Status:** Accepted (decision owned by `n0d`, not by this repo)
- **Date decided:** documented in the `n0d` repo as ADR-0030; referenced in
this repo since commit `2545218` ("Document lakehouse write-path ownership
decision (ADR-0030)")
- **Date of this record:** 2026-08-11 (BACKLOG P1-2 — this is a **pointer**
ADR, not a duplicate decision; it exists so `docs/architecture/decisions/`
is a complete index of decisions that shape this repo, even the ones made
elsewhere)
## Context
BACKLOG P1-2 asks for ADRs to exist in this repo. The lakehouse-format
decision itself was made once, ecosystem-wide, in `n0d` (the repo that owns
the platform's write path across all K1 data producers) — re-deciding it
here would create a second, divergent source of truth for a cross-repo
architectural choice.
## Decision
Apache Iceberg is the canonical SIAX Cloud lakehouse table format. 0pt is a
**write-path owner** within that decision: it maps its own datasets to
Iceberg tables and requests writes through the documented boundary (N0D
executes, 0pt requests — see `docs/ICEBERG_WRITE_BOUNDARY.md`). This repo
does not re-litigate the Iceberg-vs-alternatives choice; it implements its
own slice of it.
## Consequences
- `docs/10-lakehouse-decision.md` and `docs/11-lakehouse-write-plan.md` are
this repo's own follow-up documentation against the `n0d`-owned decision —
read them alongside this pointer, not instead of it.
- `docs/ICEBERG_WRITE_BOUNDARY.md` records the implementation status,
including which parts are live-verified vs. contract-only. That document,
not this ADR, is the source of truth for "is the write path actually
working" — this ADR only records *which format was chosen and by whom*.
- Any future change to the ecosystem-wide format decision would originate in
`n0d`, not here; this repo would need its own follow-up ADR to record how
it adapts.
## See also
- `docs/10-lakehouse-decision.md`
- `docs/11-lakehouse-write-plan.md`
- `docs/ICEBERG_WRITE_BOUNDARY.md`
- `n0d` repo, ADR-0030 (external — not vendored into this repo)
+34
View File
@@ -0,0 +1,34 @@
# Architecture Decision Records — 0pt
BACKLOG P1-2. One file per decision, numbered sequentially, never renumbered
or deleted (superseded decisions get a new ADR that says so, per the
convention below).
| ADR | Title | Status |
|---|---|---|
| [0001](0001-deploy-target-coolify-not-vercel.md) | Deploy target is Coolify, not Vercel | Accepted (migration not yet executed) |
| [0002](0002-auth-zitadel-bearer-not-nextauth.md) | `/api/0pt/*` auth is fleet Zitadel Bearer, not NextAuth | Accepted and implemented |
| [0003](0003-lakehouse-format-iceberg-pointer.md) | Lakehouse format is Apache Iceberg (pointer to `n0d` ADR-0030) | Accepted (owned by `n0d`) |
## Deliberately not yet written here
Two decisions the original BACKLOG (P1-2) named explicitly are **not**
written as ADRs in this pass, on purpose:
- **Payments provider (Stripe vs. Revolut vs. Hyperswitch).** Gated on the
account owner's decision (BACKLOG P1-23) — writing an ADR that presents a
choice as "accepted" before it's actually been decided would misrepresent
the repo's own state, which is exactly what this whole documentation pass
is trying to stop doing.
- **The `services/scrapers/*` keep-vs-remove question.** Explicitly out of
scope for this pass — see `SECURITY.md` and the dated, attributed
provenance record already maintained for that decision elsewhere in this
repo's compliance docs. Not duplicated here.
## Convention
New ADR: `NNNN-short-kebab-title.md`, next sequential number, status one of
`Proposed` / `Accepted` / `Superseded by ADR-NNNN` / `Rejected`. Record the
date the decision was actually made (from `git log`/commit history where
possible), not just the date the ADR file was written, when they differ —
see 0001–0003 for the pattern.