docs+chore: repo hygiene -- v2.0 manifests, ADRs, changelog, doctor, guides
CI (SIAX Cloud) / security (push) Successful in 19s
Security Scan (SIAX Cloud) / security (push) Successful in 19s
CI (SIAX Cloud) / quality (push) Successful in 44s
CI (SIAX Cloud) / security (pull_request) Successful in 21s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 20s
CI (SIAX Cloud) / quality (pull_request) Successful in 42s

BACKLOG P1-1: siax.repo.json/siax.config.json rewritten to be schema-valid
against sax3l/siax-standard's actual v2.0 schemas (lifecycle,
operationalState, gitHost, domains-as-objects, consumedBy, children,
contracts -- validated with jsonschema, not just eyeballed). config.json
restructured to the real deploy-descriptor shape (framework/build/start/
port/healthcheck/environments) instead of duplicating repo.json's identity
fields, which the schema doesn't allow.

BACKLOG P1-2: 3 ADRs for decisions already made and evidenced elsewhere in
this repo (Coolify-not-Vercel, Zitadel-not-NextAuth, Iceberg-format pointer
to n0d ADR-0030) -- retroactive documentation, not new decisions. The
Stripe/Revolut and services/scrapers/* questions are explicitly NOT written
as ADRs here; both are account-owner-gated or actively under review
elsewhere (see docs/architecture/decisions/README.md).

BACKLOG P1-3: CHANGELOG.md from real git log history (no tags/releases
exist yet -- this doesn't invent version numbers that were never cut).

BACKLOG P1-19: `pnpm siax:doctor` (scripts/siax-doctor.mjs, AGENT-04) --
zero-dependency, checks required files + manifest shape, prints
control-IDs. .devcontainer/devcontainer.json (DX-03). compose.dev.yaml
(DX-02 -- UNVERIFIED, no Docker available in this environment to smoke-test,
flagged in the file itself). All 4 prompts + the index rewritten to AGENT-03
shape (goal/context/prerequisites/scope/contract/acceptance-criteria/
control-ID/forbidden-actions).

BACKLOG P1-20: docs/architecture/ARCHITECTURE.md migrated to the v2.0
9-heading template -- new §5 "Ytor och paritet" (capability x
API/CLI/MCP/console coverage table, grounded in the same registry facts
docs/02-architecture.md already established), §6-9 renumbered from the old
§5-8 (all internal cross-references fixed, CLAUDE.md's own §-numbers left
untouched). docs/api/ added (points at contracts/openapi.yaml as the one
SSOT instead of duplicating it as drift-prone prose).

BACKLOG P1-21: packages/schemas now has a real package.json (was loose JSON
files with no package -- pnpm-workspace.yaml's packages/* glob matched an
empty package). Verified `pnpm install --frozen-lockfile` and the full
typecheck/test/build suite still pass with 2 real workspace projects.
apps/ restructuring explicitly NOT attempted (BACKLOG's own effort estimate
is "L" / large -- moving the whole app tree is a bigger, riskier change than
belongs in this pass). Import-boundary check added via dependency-cruiser
(ARK-14) -- installed for real, config tested against this codebase (179
modules, 310 deps, 0 violations), wired as `pnpm run deps:check` (advisory,
not yet a CI gate).

BACKLOG P2-5: docs/02-architecture.md's "Hosting" section marked SUPERSEDED
(the Vercel plan was superseded by the Coolify deploy.target flip,
2026-08-09 -- ADR-0001). README.md/.env.example were checked and are
already accurately framed (live-on-Vercel vs. config-target-is-Coolify) --
not touched.

BACKLOG P3-5: 2 stale github.com/sax3l/0pt/pull/3 links removed (the PR
merged long ago, .env.example is real and current) -- docs/09-build-plan.md,
docs/08-infrastructure.md. The "two diverged remotes, unresolved which is
canonical" language elsewhere (CLAUDE.md, AGENTS.md, SECURITY.md, etc.) is
deliberately NOT touched -- that's a live, correctly-flagged, account-owner-
owned open question per the Gitea-exclusivity mandate, not a stale link.

BACKLOG P6 (19 items): concrete artifacts for the ones that are actually a
file (.editorconfig, dependency-cruiser, deprecation policy, K8s reference
manifest, .actrc, Makefile, ONBOARDING.md); docs/guides/P6-GUIDES.md for the
rest (CLI-13, DOC-18, UI-30, IAM-19, PAY-11, AI-18, OBS-21, TEST-20, NET-19,
SCALE-13, OSS-10, AGENT-13) -- each grounded in this repo's actual code/gaps,
not generic advice.

NOT attempted (out of this task's scope, noted for the record):
- P2-1 (cl0ud app-registry.ts mismatch) -- lives in a different repo
  (sax3l/cl0ud), not cloned/authorized for this task's single-repo PR flow.
- The CI "doctor step" half of P1-15 -- deliberately left out of this PR's
  .gitea/workflows/ci.yml to avoid a 3-way merge conflict with
  ci/security-headers-and-scanning, which already restructured that file;
  add it as a follow-up once that PR merges.

This branch was authored independently of, but shares docs/architecture/
ARCHITECTURE.md and docs/slo.md with, fix/honest-health-check and
ci/security-headers-and-scanning -- expect a small, normal merge conflict
if this is rebased after either of those merge first (both already rebased
cleanly against each other and against main as of this commit).
This commit is contained in:
2026-08-11 14:18:00 +02:00
parent ebffb7df86
commit 328f8a46cb
32 changed files with 1569 additions and 81 deletions
+12 -2
View File
@@ -162,11 +162,21 @@ Flagged so it is not repeated: `src/services/quality-check-service.ts`, `src/ser
| Trigger.dev | the existing queue already schedules jobs; Resend covers mail |
| FlareSolverr / stealth browsers / undetected-* / proxy-fingerprint rotation / fake-account creation | **prohibited** — see CLAUDE.md §1. Replace with compliant fetching. (The Gitea-only scraper stack described under "Two diverged git remotes" above is exactly this — removed there, never present on GitHub `main`.) |
## Hosting (cheapest coherent)
## Hosting (cheapest coherent) — **SUPERSEDED** (BACKLOG P2-5)
> **SUPERSEDED 2026-08-11.** This section describes the original Vercel+Neon
> hosting plan. `siax.config.json` flipped `deploy.target` from `"vercel"` to
> `"coolify"` on 2026-08-09 to match every other SIAX Cloud OS repo — that
> decision supersedes the Vercel prescription below. The live instance is
> **still actually running on Vercel today** (no Coolify app has been
> provisioned yet — see `README.md`'s "Deploy" section and
> `docs/architecture/ARCHITECTURE.md` §5/§8 for the current, verified state);
> this section is kept for history, not as the current target. Do not read
> "Vercel (Hobby/free)" below as still-current guidance.
- **Vercel** (Hobby/free) — Next.js + custom domain `0pt.app`.
- **One small VPS** (e.g. Hetzner ~€5/mo) running `docker-compose` (`infra/docker-compose.yml`): FastAPI, workers, NocoDB, Metabase, (Postgres or use Neon), optional Meilisearch later. Per-service managed platforms (Railway) get expensive once you have 4–5 always-on services; a single VPS + Vercel + R2 lands ≈ <€10/mo to start.
- **Cloudflare R2** — object storage (env-guarded, presign not yet wired — see Components above).
- **Postgres** — on the VPS, or **Neon** free tier if you want it managed.
Full config, env, security, CI/CD: `docs/08-infrastructure.md`. Env var inventory: `.env.example` exists on branch/PR [`feature/0pt-env-example`](https://github.com/sax3l/0pt/pull/3) (unmerged as of this pass) — until it merges to `main`, `docs/08-infrastructure.md` is the source of truth for env var names.
Full config, env, security, CI/CD: `docs/08-infrastructure.md`. Env var inventory: [`.env.example`](../.env.example) (present in this repo today — the linked GitHub PR that originally tracked it has long since merged; removed the stale cross-repo link per BACKLOG P3-5).
+7 -6
View File
@@ -137,12 +137,13 @@ dash.0pt.app { reverse_proxy metabase:3000 }
## Environment variables
**`.env.example` now exists** — added on branch `feature/0pt-env-example`
(`github.com/sax3l/0pt/pull/3`, **not yet merged to `main`** as of this pass). It was previously
impossible to commit: `.gitignore`'s blanket `.env*` rule silently matched `.env.example` too, so it
was never added despite `docs/09-build-plan.md` Phase 0 requiring it since day one. The same PR adds
`!.env.example` to `.gitignore` to fix that. README's "Env inventory: `.env.example`" link is
therefore currently a broken/future reference on `main` until that PR merges.
**`.env.example` now exists and is merged to `main`** (BACKLOG P3-5: the stale
link to the unmerged `github.com/sax3l/0pt/pull/3` that used to sit here has
been removed — that PR landed a while ago). It was previously impossible to
commit: `.gitignore`'s blanket `.env*` rule silently matched `.env.example`
too, so it was never added despite `docs/09-build-plan.md` Phase 0 requiring
it since day one; `.gitignore` now has `!.env.example` to fix that. README's
"Env inventory: `.env.example`" link is a real, current reference.
The table below is grep-verified against `main` this pass, not transcribed from `.env.example`'s own
comments — in one case (`ST0RE_URL`, see note) that turned up a discrepancy worth flagging.
+4 -4
View File
@@ -29,10 +29,10 @@ Phased, in dependency order. **Finish a phase to its acceptance criteria before
**No `sql/002_*` or `sql/003_*` exists anywhere in this repo's history** — some other docs
(`docs/ICEBERG_WRITE_BOUNDARY.md` etc.) cite a `sql/002_p0_dataset_quality.sql` that was never built;
see `docs/08-infrastructure.md`'s "Schema state" section.
- `.env.example` — **now exists**, on branch `feature/0pt-env-example`
(`github.com/sax3l/0pt/pull/3`), **not yet merged to `main`**. It was blocked for the life of this
project by `.gitignore`'s blanket `.env*` rule silently matching it too; the same PR fixes that
with `!.env.example`. Until that PR merges, `main` still has no `.env.example`.
- `.env.example` — **now exists and is merged to `main`** (BACKLOG P3-5: the
stale link to the unmerged `github.com/sax3l/0pt/pull/3` that used to sit
here has been removed — that PR has long since landed, `.env.example` is
a real, current, gitignore-exempted file at the repo root today).
- `infra/docker-compose.yml` and `infra/Caddyfile` are real, committed files (not sketches) covering
exactly the services listed. **This pass found no evidence they've ever actually been run** — no
CI, no deploy log, no reachable host checked. "File exists and looks correct" ≠ "verified to run";
+41
View File
@@ -0,0 +1,41 @@
# API deprecation policy — 0pt
BACKLOG P6 (API-24). There is exactly one prior breaking-ish change in this
repo's history to learn from: `services/api/orchestrator/main.py` moved from
`src/orchestrator` (docs/09-build-plan.md Phase 0) — internal, pre-contract,
no external consumers yet. This policy is written before it's needed for a
real consumer, on purpose (BACKLOG's own framing: "cheaper to write the
policy than to clean up after breaking someone").
## What counts as breaking
- Removing a path, operation, or required request/response field from
`contracts/openapi.yaml`.
- Narrowing an accepted value (enum shrink, type tightening) on a request field.
- Changing a response field's meaning without changing its name/type.
- Changing default auth/tenant behavior on an existing route (e.g. what
BACKLOG P0-4 fixed — the reverse of a break, but the same class of change).
Not breaking: adding an optional field, adding a new path, widening an
accepted value, adding a new enum member a client can ignore.
## Process
1. Mark the field/path `deprecated: true` in `contracts/openapi.yaml` with an
`x-siax-deprecated-since` date and a one-line replacement pointer.
2. Keep the deprecated shape working for **at least one release cycle**
after the replacement ships (see `CHANGELOG.md` once real releases/tags
exist — BACKLOG P1-3).
3. Announce in `CHANGELOG.md`'s `[Unreleased]` section before merge, not
after.
4. Only remove once nothing in this repo's own consumers (Protosell/FiveCRM,
VehIQ per `CLAUDE.md`) is verified to depend on the old shape — "verified"
means checked against those repos, not assumed silent.
## What this repo does NOT have yet
No consumers are known to be live against this contract yet
(`docs/architecture/ARCHITECTURE.md` §2 "Beroenden nedåt": "Inga sådana
anrop finns i det här repot" — unverified downstream). This policy exists
so the first real breaking change has a process to follow, not because one
has happened.
+26
View File
@@ -0,0 +1,26 @@
# API docs — 0pt
BACKLOG P1-20 (DOC-07/08). This directory did not exist before this pass.
**Source of truth:** [`contracts/openapi.yaml`](../../contracts/openapi.yaml)
(OpenAPI 3.1, `0pt Data OS API`). Route handlers in `app/api/*` realize
these contracts; `x-siax-status` on each path says whether it's `live` or
contract-first (target).
This directory does **not** duplicate the contract as hand-written prose —
that would drift the moment one of them is edited and not the other (exactly
the kind of stale-doc problem this whole compliance pass exists to fix).
Instead:
| Question | Where to look |
|---|---|
| What routes exist, request/response shapes | [`contracts/openapi.yaml`](../../contracts/openapi.yaml) directly, or render it with any OpenAPI viewer |
| Which routes are live vs. target-only | `x-siax-status` field per path in the same file |
| Risk level + auth requirement per route | `docs/architecture/ARCHITECTURE.md` §3 "API-yta" |
| Capability → surface (API/CLI/MCP/UI) coverage | `docs/architecture/ARCHITECTURE.md` §5 "Ytor och paritet" |
| The separate FastAPI engine contract (`services/api`) | `docs/04-api.md` |
| The edge-native P0 capability contract (`app/api/0pt/*`) | `docs/12-edge-capability-api.md` |
There are genuinely **two** API surfaces documented separately (edge Next.js
routes vs. the FastAPI engine) — see `docs/02-architecture.md` "Two API
surfaces" for why, before assuming a route lives in the file you expected.
+63 -20
View File
@@ -1,11 +1,11 @@
# 0PT — Arkitektur
**Kategori:** platform (K1) **Underkategori:** data-os **Status:** under utveckling (deployad frontend i drift, capability-lagret ej produktionsklart)
**Senast verifierad mot kod:** 2026-08-07 (commit `6531384`, main) · **Klassificeringsuppdatering:** 2026-08-10 (`siax.repo.json`)
**Senast verifierad mot kod:** 2026-08-07 (commit `6531384`, main) · **Klassificeringsuppdatering:** 2026-08-10 (`siax.repo.json`) · **v2.0-standardmigrering (§5 tillagd, §6–§9 omnumrerade; §6 Deploy-fältet nedan uppdaterat mot `lib/health-checks.ts`):** 2026-08-11 — scoped till dessa avsnitt, ingen fullständig radrad-omverifiering av hela dokumentet gjord denna pass
> **Läsanvisning.** Detta dokument beskriver vad koden i repot **gör**, inte vad
> `README.md`, `CLAUDE.md` eller `docs/01–11` säger att den borde göra. Där de
> avviker står avvikelsen utskriven — se §7. Påståenden märkta *(live-verifierat
> avviker står avvikelsen utskriven — se §8. Påståenden märkta *(live-verifierat
> 2026-08-07)* är kontrollerade mot den körande instansen på `https://0pt.app`.
> Allt annat är läst ur källkoden. Där något inte gick att belägga står **OKÄNT**.
@@ -29,7 +29,7 @@ proveniens (källa, färskhet, konfidens) per fält.
| consumes | CL0UD · ST0RE · N0D · AUD0 · INF0 |
| replacesSaaS | Apollo · Cognism · ZoomInfo · Clearbit (målet för Data OS: ersätta paid enrichment-SaaS) |
| decoupled | `false` |
| designSystem | `null` (eget mono/editorial-system, konsumerar inte @siax/ui — öppen fråga §8.8) |
| designSystem | `null` (eget mono/editorial-system, konsumerar inte @siax/ui — öppen fråga §9.8) |
Ersätter krav på betald enrichment-SaaS (Apollo/Cognism/ZoomInfo/Clearbit) med
egen compliant sourcing + provenance — målet är att Datahub/VehIQ/data-avdelningar
@@ -63,7 +63,7 @@ Tor-rotation, `cloudscraper`, `curl_cffi` TLS-fingerprintbyte, gratis proxypool,
nodriver ("undetected browser") och "fake identity generation".
`services/infra/docker-compose.data-stack.yml` startar `flaresolverr` och
`tor-proxy` som tjänster. Commit `4a164c5` (Simon Axelsson, 2026-07-13) heter
ordagrant *"refactor: remove compliance restrictions"*. Se §7 lucka **S9**.
ordagrant *"refactor: remove compliance restrictions"*. Se §8 lucka **S9**.
---
@@ -74,8 +74,8 @@ ordagrant *"refactor: remove compliance restrictions"*. Se §7 lucka **S9**.
| Beroende | Klient | Env-var | Beteende när env saknas |
|---|---|---|---|
| Zitadel (IdP) | `src/auth/zitadel.ts` | `ZITADEL_ISSUER` (default `https://id-customers.siax.io`) | Använder default-issuern; JWKS hämtas via OIDC-discovery, fallback `<issuer>/oauth/v2/keys` |
| CL0UD (policy) | `src/clients/cl0ud-client.ts` | `CL0UD_URL` | **Fail-open** — returnerar alltid `allow` utan nätanrop (§7 S5) |
| AUD0 (audit) | `src/clients/aud0-client.ts` | `AUD0_URL` | **No-op** — inga auditevent skrivs (§7 S6) |
| CL0UD (policy) | `src/clients/cl0ud-client.ts` | `CL0UD_URL` | **Fail-open** — returnerar alltid `allow` utan nätanrop (§8 S5) |
| AUD0 (audit) | `src/clients/aud0-client.ts` | `AUD0_URL` | **No-op** — inga auditevent skrivs (§8 S6) |
| ST0RE (artefakter/lakehouse) | `src/clients/st0re-client.ts`, `st0re-lakehouse-client.ts` | `ST0RE_URL` | Returnerar deterministisk mockartefakt |
| N0D (jobb) | `src/clients/n0d-client.ts` | `N0D_URL` | Returnerar deterministiskt mockjobb |
| Egen data-engine | `lib/engine.ts` | `ENGINE_URL`, `INTERNAL_TOKEN` | `engineFetch` returnerar `null`, edge räknar lokalt |
@@ -86,7 +86,7 @@ ordagrant *"refactor: remove compliance restrictions"*. Se §7 lucka **S9**.
| Odoo | `src/adapters/odoo-bills-adapter.ts` | `ODOO_BASE_URL` | Adapter inaktiv |
Mönstret är genomgående: **saknad env ⇒ tyst degradering, inte fel.** Det är
bekvämt lokalt och farligt i produktion (§7 S5, S6).
bekvämt lokalt och farligt i produktion (§8 S5, S6).
### Beroenden nedåt (vem konsumerar 0pt)
@@ -98,7 +98,7 @@ här. Betrakta konsumentlistan som odokumenterad tills motparten visats.
- **BigQuery** — hård estate-regel. Ej överträdd.
- **Hogia** — skrivning förbjuden. Ingen referens finns.
- **Protosell-tenantdata** — tenantisolering, se §7 S2.
- **Protosell-tenantdata** — tenantisolering, se §8 S2.
- Nya SaaS-beroenden utan dokumenterat skäl (`CLAUDE.md` §4, "one tool per job").
---
@@ -116,10 +116,10 @@ Risknivå = SIAX L0–L5-taxonomin, bedömd av mig utifrån vad handlern gör.
| Registrera dataset↔Iceberg-mappning | `POST /api/0pt/lakehouse/mappings` | L3 | Nej i kod; `tenant_id` läses ur body |
| Lista mappningar | `GET /api/0pt/lakehouse/mappings` | L2 | Nej; `tenant_id` ur query |
| Hämta mappning | `GET /api/0pt/lakehouse/mappings/{mappingId}` | L2 | Nej |
| Utför Iceberg-write | `POST /api/0pt/lakehouse/mappings/{mappingId}/writes` | **L4** | Nej i kod (CL0UD fail-open, §7 S5) |
| Utför Iceberg-write | `POST /api/0pt/lakehouse/mappings/{mappingId}/writes` | **L4** | Nej i kod (CL0UD fail-open, §8 S5) |
| Registrera rate-policy | `POST /api/0pt/sources/rate-policies` | L2 | Nej |
| Lista/hämta rate-policy | `GET /api/0pt/sources/rate-policies[/{id}]` | L1 | Nej |
| Kör källfråga | `POST /api/0pt/sources/{sourceId}/query` | **L4** | Nej; `connection_config` tas ur body (§7 S10) |
| Kör källfråga | `POST /api/0pt/sources/{sourceId}/query` | **L4** | Nej; `connection_config` tas ur body (§8 S10) |
| Ta emot dokument | `POST /api/0pt/documents/capture` | L3 (PII) | Nej |
| Lista dokument | `GET /api/0pt/documents/capture` | L3 (PII) | Nej |
| Extrahera dokument | `POST /api/0pt/documents/{documentId}/extraction` | L3 (PII) | Nej |
@@ -141,11 +141,11 @@ Risknivå = SIAX L0–L5-taxonomin, bedömd av mig utifrån vad handlern gör.
| Läs/ändra order | `GET,PATCH /api/orders/{id}` | L3 | Nej |
| **Adminmetrik (orderpipeline, belopp)** | `GET /api/admin/metrics` | **L3** | **Nej** *(live-verifierat: 200 anonymt)* |
| Deposition (Stripe checkout) | `POST /api/payments/{order_id}/deposit` | **L4** | Nej |
| **Frigör escrow-slutbetalning** | `POST /api/payments/{order_id}/release` | **L4** | **Nej** — sätter dessutom status `delivered` (§7 S4) |
| **Frigör escrow-slutbetalning** | `POST /api/payments/{order_id}/release` | **L4** | **Nej** — sätter dessutom status `delivered` (§8 S4) |
| Stripe-webhook | `POST /api/webhooks/stripe` | L3 | Signaturkontroll via `STRIPE_WEBHOOK_SECRET` |
| Prenumerationer | `GET,POST /api/subscriptions` | L2 | Nej |
| Filuppladdning | `GET,POST /api/uploads` | L3 | Nej (`501` utan R2) |
| Ta emot kund-DB-grant | `POST /api/connections/db-grant` | **L4** | Nej (`501` utan `GRANT_ENC_KEY`; §7 S7) |
| Ta emot kund-DB-grant | `POST /api/connections/db-grant` | **L4** | Nej (`501` utan `GRANT_ENC_KEY`; §8 S7) |
| Dev-login | `POST /api/auth/login` | L2 | Ja — kräver `AUTH_SECRET` + matchande `DEV_LOGIN_KEY` |
| Logout / me | `POST /api/auth/logout`, `GET /api/auth/me` | L1 | Cookiebaserat |
@@ -156,7 +156,7 @@ Risknivå = SIAX L0–L5-taxonomin, bedömd av mig utifrån vad handlern gör.
`PATCH /orders/{oid}`, `POST /orders/{oid}/run`, `GET /orders/{oid}/status`.
**Ingen autentisering alls** — grep efter `Depends`, `auth`, `token`,
`X-Internal-Token` i filen ger noll träffar, trots att `lib/engine.ts` skickar
`X-Internal-Token`. Se §7 S8.
`X-Internal-Token`. Se §8 S8.
---
@@ -208,7 +208,7 @@ Två konsekvenser, båda dokumenterade i koden själv:
- `dim_contact`: namn, roll, e-post, telefon, LinkedIn — persondata under GDPR.
- `dim_ubo`: verklig huvudman — persondata, potentiellt känslig.
- `db_grants.conn_encrypted`: kunds DB-anslutningssträng (se §7 S7).
- `db_grants.conn_encrypted`: kunds DB-anslutningssträng (se §8 S7).
- Dokumentcapture (`app/api/0pt/documents/capture`) tar emot godtyckliga
dokument, inkl. fakturor/mailbilagor via Graph-adaptern — persondata.
@@ -220,7 +220,50 @@ inget sådant jobb, ingen TTL, ingen `DELETE`-väg och ingen radering finns i ko
---
## 5. Deploy
## 5. Ytor och paritet
**Migrering till standard v2.0 (BACKLOG P1-20/DOC-02):** denna sektion är ny —
v1.0-mallen hade 8 rubriker, v2.0 har 9 (Deploy/Drift/Säkerhet/Öppna frågor
numrerade om §6–§9 nedan, tidigare §5–§8).
Källa: `cl0ud packages/capability-registry/src/registry.ts` (samma verifiering
som `docs/02-architecture.md`s "Six-surface capability model"-avsnitt, ej
omgjord här). 14 `0pt.*`-kapabiliteter är registrerade. Registret har fält för
`api`/`cli`/`mcp`/`ui`/`job`; "CL0UD-konsol" nedan är en separat fråga (om
kapabiliteten är inbäddad i den delade cl0ud-konsolen) som INTE går att
verifiera från detta repo — markerad OKÄNT genomgående, inte gissad.
"Egen konsol" är **ANTAGANDE baserat på sidnamn/routestruktur under `app/`**,
inte spårat anrop-för-anrop mot varje handler — verifiera innan den läses som
hårt bevisad.
| Kapabilitet | API | CLI | MCP | Egen konsol | CL0UD-konsol |
|---|---|---|---|---|---|
| `0pt.order_create` | ✅ | ❌ | ❌ | ✅ (`app/bestall/*`) | OKÄNT |
| `0pt.order_payment` | ✅ | ❌ | ❌ | ✅ (`app/bestall/forskott`) | OKÄNT |
| `0pt.estimate_compute` | ✅ | ❌ | ❌ | ✅ (`app/bestall/beskriv`, ANTAGANDE) | OKÄNT |
| `0pt.catalog_list` | ✅ | ❌ | ❌ | ✅ (`app/katalog`) | OKÄNT |
| `0pt.source_registry_list` | ✅ | ❌ | ❌ | ✅ (`app/kallor`, `app/admin/sources`) | OKÄNT |
| `0pt.query_source` | ✅ | ❌ | ❌ | ❌ (ingen dedikerad sida funnen) | OKÄNT |
| `0pt.vehicle_lookup` | ✅ | ❌ | ❌ | ❌ (ingen dedikerad sida funnen) | OKÄNT |
| `0pt.screen_sanctions` | ✅ | ❌ | ❌ | ❌ (ingen dedikerad sida funnen) | OKÄNT |
| `0pt.document_ocr` | ✅ | ❌ | ❌ | ❌ (ingen dedikerad sida funnen) | OKÄNT |
| `0pt.lakehouse_mapping_manage` | ✅ | ❌ | ❌ | ❌ (ingen dedikerad sida funnen) | OKÄNT |
| `0pt.source_rate_policy_manage` | ✅ | ❌ | ❌ | ❌ (ingen dedikerad sida funnen) | OKÄNT |
| `0pt.lakehouse_write` | ✅ (+job) | ❌ | ❌ | ❌ (ingen dedikerad sida funnen) | OKÄNT |
| `0pt.write_iceberg_table` | ✅ (+job) | ❌ | ❌ | ❌ (ingen dedikerad sida funnen) | OKÄNT |
| `0pt.write_external_record` | ❌ (job-only, `apiEnabled: false`) | ❌ | ❌ | ❌ | OKÄNT |
**Luckor, sammanfattat:** CLI = 0/14, MCP = 0/14 (matchar BACKLOG P1-5/P1-6:
ingen CLI-yta, ingen MCP-yta alls finns i detta repo ännu). API = 13/14 (allt
utom det renodlade job-kapabiliteten). Egen konsol ≈ 5/14, koncentrerat till
order-/katalog-/källflödet; kapabiliteter under `app/api/0pt/*` (lakehouse,
rate-policy, källfråga, sanktionsscreening, dokument-OCR) har ingen synlig UI
alls — matchar BACKLOG P1-8 ("`/api/0pt/*`-kapabiliteterna saknar UI").
---
## 6. Deploy
| Fält | Verifierat läge |
|---|---|
@@ -233,11 +276,11 @@ inget sådant jobb, ingen TTL, ingen `DELETE`-väg och ingen radering finns i ko
| **CI** | `.gitea/workflows/ci.yml`. `quality`-jobb: typecheck (blockerande, endast `src/` + `tests/`), vitest (blockerande, 17 testfiler), eslint (rådgivande), `next build` (blockerande). `security`-jobb: Trivy `--exit-code 0` (rådgivande). Kör på `ubuntu-latest`. |
> **Konflikt att fatta beslut om:** estate-projektet *GCP/Vercel-exit* säger att
> flottan ska bort från Vercel. 0pt:s enda körande instans ligger på Vercel. Se §8.
> flottan ska bort från Vercel. 0pt:s enda körande instans ligger på Vercel. Se §9.
---
## 6. Drift
## 7. Drift
### Hälsokontroll
`GET /api/health` → `{ok, service:"0pt-web", db, queue, ts}`. Den svarar **alltid
@@ -277,7 +320,7 @@ Om/när Postgres provisioneras måste detta lösas separat — jfr estate-blocke
---
## 7. Säkerhet
## 8. Säkerhet
### Vad som faktiskt finns
@@ -396,7 +439,7 @@ bindning till en användarpost. Kommentaren erkänner att det är ett scaffold;
---
## 8. Öppna frågor
## 9. Öppna frågor
1. **Varför kör inte middlewaren i produktion (S1)?** Måste rotorsaksanalyseras.
Ingen dokumentation får påstå att `/api/0pt/*` är skyddat innan en anonym
@@ -408,7 +451,7 @@ bindning till en användarpost. Kommentaren erkänner att det är ett scaffold;
3. **Vercel eller flottan?** *(config-delen löst 2026-08-09, trafik-delen kvarstår.)*
0pt:s enda **körande** instans ligger fortfarande på Vercel — den ändringen är
medvetet INTE gjord här (skulle kräva en egen cutover-plan: verifiera att inget
riktigt kunddata/trafik ligger bakom `0pt.app` — vilket är fallet idag, se §5/§6:
riktigt kunddata/trafik ligger bakom `0pt.app` — vilket är fallet idag, se §6/§7:
`/api/health` visar `db/queue: not_configured`, ordrar lever bara in-memory —
provisionera en Coolify-app, peka DNS om, och avveckla Vercel-projektet, i den
ordningen). Det som ÄR gjort: `siax.config.json` deklarerar nu `target: "coolify"`
@@ -0,0 +1,43 @@
# ADR-0001: Deploy target is Coolify (SIAX Cloud fleet), not Vercel
- **Status:** Accepted (config declares it; migration not yet executed)
- **Date decided:** 2026-08-09 (commit `ad042d8`, "fix(deploy): declare Coolify as the deploy target, not Vercel")
- **Date of this record:** 2026-08-11 (BACKLOG P1-2 — this ADR documents an
already-made decision retroactively; it does not introduce a new one)
## Context
0pt was originally scaffolded and deployed on Vercel (Hobby/free tier,
project `0pt`, scope *Simon Axelsson's projects*). SIAX Cloud's platform
mandate is to replace paid SaaS with self-hosted fleet infrastructure
(Hetzner + Coolify), matching every other SIAX Cloud OS repo (`n0d`,
`st0re`, `aud0`, ...).
## Decision
`siax.config.json`'s `deploy.target` is `"coolify"`, not `"vercel"`. A
Dockerfile written for Coolify (multi-stage, non-root `node` user, `HEALTHCHECK`
against `/api/health`) and `.gitea/workflows/cd.yml` (POSTs a restart to a
Coolify app UUID on push to `main`) both exist and are committed.
## Consequences
- **This is a config-and-tooling change, not a traffic cutover.** As of this
record, no Coolify application has been provisioned for this repo —
`cd.yml`'s `COOLIFY_APP_ID` is a literal placeholder that fails the job
loudly on purpose (see the guard step) rather than posting to a bogus
endpoint. The live instance of `0pt.app` is still served by Vercel.
- Flipping the config was deliberately decoupled from the actual cutover: it
states intent (BACKLOG P0-2 / P3-1 own the "provision the Coolify app, cut
DNS, decommission Vercel" work, gated on a dump-before-write blocker per
the standard's "safe to run now" classification).
- Until the cutover happens, docs describing Vercel as *where 0pt actually
runs today* are accurate; docs prescribing Vercel as *the plan going
forward* are stale (see BACKLOG P2-5 — `docs/02-architecture.md`'s
"Hosting" section is marked SUPERSEDED for exactly this reason).
## See also
- `docs/architecture/ARCHITECTURE.md` §6 "Deploy", §9 "Öppna frågor"
- `README.md` "Deploy" section (kept current with the live/target split)
- `docs/compliance/BACKLOG.md` P0-2, P1-17, P3-1
@@ -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.
+150
View File
@@ -0,0 +1,150 @@
# P6 guides — 0pt
BACKLOG P6: 19 GUIDE-level items, all marked S (small effort), all "NU"
(safe to write now). Several have their own concrete artifact instead of a
guide entry here — see the table. This file covers the rest: real,
actionable "how to build this when it's prioritized" guidance grounded in
0pt's actual code, not generic advice that could apply to any repo.
| Control | Item | Where |
|---|---|---|
| REPO-13 | `.editorconfig` | [`.editorconfig`](../../.editorconfig) |
| ARK-14 | dependency-cruiser | [`.dependency-cruiser.cjs`](../../.dependency-cruiser.cjs), `pnpm run deps:check` |
| API-24 | deprecation policy | [`docs/api/DEPRECATION_POLICY.md`](../api/DEPRECATION_POLICY.md) |
| CD-23 | K8s manifest | [`deploy/k8s/`](../../deploy/k8s/) (reference only, not the deploy path) |
| CI-16 | `act` | [`.actrc`](../../.actrc) |
| DX-11 | Makefile | [`Makefile`](../../Makefile) |
| DX-12 | onboarding | [`ONBOARDING.md`](../../ONBOARDING.md) |
| CLI-13 | `doctor` CLI subcommand | see §1 below |
| DOC-18 | documentation site | see §2 below |
| UI-30 | PWA | see §3 below |
| IAM-19 | impersonation | see §4 below |
| PAY-11 | Hyperswitch ADR | see §5 below |
| AI-18 | assistant | see §6 below |
| OBS-21 | status page | see §7 below |
| TEST-20 | chaos testing | see §8 below |
| NET-19 | IPv6 | see §9 below |
| SCALE-13 | read replicas | see §10 below |
| OSS-10 | upstream contribution | see §11 below |
| AGENT-13 | nightly agent | see §12 below |
---
## 1. CLI-13 — `doctor` CLI subcommand
There is no CLI surface at all yet (BACKLOG P1-5 — L effort, not attempted
this pass). `pnpm run siax:doctor` / `make doctor`
(`scripts/siax-doctor.mjs`) already covers the underlying check logic
(AGENT-04). When P1-5 builds `apps/cli`, wire a `siax 0pt doctor` subcommand
that shells out to (or re-imports) `scripts/siax-doctor.mjs` rather than
re-implementing the checks — one source of truth for "is this repo
compliant", not two that can drift.
## 2. DOC-18 — documentation site
Not built. When prioritized: `contracts/openapi.yaml` already exists as a
real OpenAPI 3.1 SSOT, so the lowest-effort path is a static OpenAPI
renderer (e.g. Redocly CLI or Scalar) pointed at that file, deployed as a
static site — not a hand-authored docs site that would drift from the
contract. `docs/*.md` could be published alongside via any static-site
generator that reads plain Markdown (Docusaurus, Starlight); pick whichever
matches what other SIAX Cloud repos already use, per BACKLOG's "one tool per
job" rule — check `cl0ud`/`n0d` first before introducing a new one here.
## 3. UI-30 — PWA
Not built. Would need: a `manifest.json` (icons already exist at
`public/icon*.png`/`icon.svg` — reuse them, don't regenerate), a service
worker (Next.js has no built-in PWA plugin as of this repo's Next 16; a
minimal hand-written SW covering `/api/health`-style offline detection would
be more honest than a cargo-culted `next-pwa` config, given this app's
`ignoreBuildErrors: true` posture already has enough unverified surface). Low
priority — 0pt's UI is transactional (order flow, portal), not the kind of
app users install to a home screen.
## 4. IAM-19 — impersonation
Not built. Needed pattern once an admin portal exists with real customer
data: a support/admin session that can view-as a specific tenant/user,
**always** logged to AUD0 (BACKLOG P0-18 — AUD0 client exists but is
currently no-op without `AUD0_URL`) with the impersonator's real identity
attached, never silently. Do not build a "become this user" auth shortcut
without that audit trail landing first — an impersonation feature with no
audit log is a privilege-escalation bug wearing a support-tool costume.
## 5. PAY-11 — Hyperswitch ADR
**Proposed, not accepted — payments provider is explicitly gated on the
account owner's decision (BACKLOG P1-23).** This entry exists so the option
is on record, not to decide it. Hyperswitch is an open-source payment
orchestration layer (self-hostable) that could sit in front of
Stripe/Revolut/others rather than 0pt integrating each provider directly
(`lib/stripe.ts` today). Trade-off to weigh when P1-23 is actually decided:
self-hosting Hyperswitch adds an operational dependency (another service to
run/monitor) in exchange for provider-agnosticism; direct integration
(current state) is simpler but couples this repo to Stripe's specific API
shape. Not evaluated further here — that's the ADR this guide is explicitly
not writing.
## 6. AI-18 — assistant
Not built. `app/api/ai/parse` exists today as a heuristic (no model call,
per `CLAUDE.md`/`docs/02-architecture.md`'s "honest heuristic" framing) — a
real assistant feature should route through INF0 (the fleet AI gateway,
`INF0_URL` — documented target, not yet read by any code in this repo) per
the platform mandate, never a raw provider key committed here.
## 7. OBS-21 — status page
Not built. Lowest-effort honest option once `/api/health` + `/api/ready`
are actually monitored (BACKLOG P1-11, not yet wired to Prometheus/GlitchTip
per that item): a self-hosted status page (e.g. Upptime, which is
just-a-GitHub/Gitea-Actions-cron + static site, no server to run) polling
those two endpoints. Do not stand up a status page before the endpoints it
would display are meaningfully monitored — an unmonitored status page that
says "operational" is worse than no status page.
## 8. TEST-20 — chaos testing
Not built, and low-value until BACKLOG P0-12 lands (real DB/persistence —
right now there's no durable state to chaos-test; killing the process loses
nothing that wasn't already going to be lost on the next cold start). Once
persistence exists: start with the cheapest chaos test that matches 0pt's
actual documented failure mode — kill the Postgres connection mid-request
and assert `/api/ready` flips to 503 within one health-check interval (this
is now directly testable thanks to BACKLOG P0-3's real dependency probes).
## 9. NET-19 — IPv6
Not evaluated. `docs/architecture/ARCHITECTURE.md` doesn't currently record
whether the Coolify target node(s) or `0pt.app`'s DNS have AAAA records —
check `z0ne` (SIAX's own DNS product) once a real Coolify app exists for
this repo; premature to configure before there's a fleet IP to point at.
## 10. SCALE-13 — read replicas
Not applicable yet — there is no primary database in production to
replicate (BACKLOG P0-12: state lives in in-memory `Map`s, zero DB
provisioned). Revisit once P0-12 lands and real read/write load is
measured; provisioning a replica against a database that doesn't exist yet
would be pure speculation.
## 11. OSS-10 — upstream contribution
No dependency in this repo has been identified as needing a patch upstream
rather than a workaround here (checked: no local patches in
`pnpm-lock.yaml`'s `patchedDependencies`, none found). Nothing to
contribute upstream today; revisit if/when a real workaround is added for
an upstream bug — file the issue/PR there instead of carrying the
workaround silently forever.
## 12. AGENT-13 — nightly agent
`nightly.yml` already re-runs the full quality + (now blocking) security
gate daily (BACKLOG P0-16). A step beyond that — an agent that reads the
nightly failure and opens a triage PR — is AGENT-06 territory (BACKLOG P1-19
already scopes AGENT-06 as not attempted this pass: it needs real
OpenHands/Aider/SWE-agent infrastructure via INF0, which doesn't exist yet
for this repo). Do not build a bespoke nightly-agent script here ahead of
that shared infrastructure landing — it would be exactly the kind of
one-off tool the "one tool per job" rule (`CLAUDE.md` §4) warns against.