fix(recovery): restore source removed by production documentation merge
This commit is contained in:
@@ -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.
|
||||
@@ -0,0 +1,81 @@
|
||||
# Document workbench — upload → structure → validated export
|
||||
|
||||
The customer-facing slice that turns an uploaded file into evidence-bound data.
|
||||
|
||||
## Routes
|
||||
|
||||
| Route | Purpose | Fails closed with |
|
||||
|---|---|---|
|
||||
| `POST /api/0pt/documents/upload` | multipart upload of the original bytes into DOC0, recorded in a durable attempt journal before dispatch | `503 DOC0_NOT_CONFIGURED`, `503 PROJECT_AUTHORIZATION_NOT_CONFIGURED`, `503 UPLOAD_JOURNAL_NOT_CONFIGURED` |
|
||||
| `POST /api/0pt/documents/structure` | re-reads the DOC0 segment index, calls INF0, validates every field against an exact source span, reserves/settles credits | `503 WORKBENCH_NOT_CONFIGURED`, `503 MODEL_POLICY_NOT_CONFIGURED`, `503 CREDITS_NOT_CONFIGURED`, `402 INSUFFICIENT_CREDITS` |
|
||||
| `GET /api/0pt/documents/models` | the server-approved model routes and limits | `503 MODEL_POLICY_NOT_CONFIGURED` |
|
||||
| `GET /api/0pt/credits/balance` | tenant credit balance | `503 CREDITS_NOT_CONFIGURED` |
|
||||
| `GET /api/0pt/credits/packs` | sellable packs from the server-owned price book | `503 PRICE_BOOK_NOT_CONFIGURED` |
|
||||
| `POST /api/0pt/credits/checkout` | Stripe Checkout session + server price snapshot | `503 PRICE_BOOK_NOT_CONFIGURED`, `503 STRIPE_NOT_CONFIGURED` |
|
||||
| `POST /api/webhooks/stripe` | re-reads the session and payment intent, then grants credits idempotently | non-2xx until processed |
|
||||
|
||||
UI: `/portal/dokument` (upload, structure, review, download) and `/portal/krediter`
|
||||
(balance, packs, checkout). The portal signs in through Zitadel OIDC
|
||||
(`/api/auth/login` → `/api/auth/callback`); the resulting signed session cookie
|
||||
is accepted by middleware as a verified principal (Bearer still wins).
|
||||
|
||||
## Invariants
|
||||
|
||||
1. **Tenant and actor come only from middleware's verified headers.** A customer
|
||||
route never trusts `tenant_id`/`actor_id` from the body.
|
||||
2. **Project access is checked by OpenFGA** (`@siax/access`), the same primitive
|
||||
DOC0 uses. Until the central relationship store is deployed, an explicit
|
||||
server-owned grant list (`OPT_PROJECT_GRANTS`) can be used instead.
|
||||
Unconfigured or unavailable means *denied*, never allowed.
|
||||
3. **The model never sees unverified text.** `Doc0SourceClient` verifies
|
||||
version, tenant, checksum, segment hashes and that the index was not
|
||||
truncated before anything is sent to INF0.
|
||||
4. **Every returned value must point at an exact span** in the source; otherwise
|
||||
the result is `needs_review` and nothing is exported.
|
||||
5. **Credits are reserved before the model runs and settled to measured usage.**
|
||||
An unknown model outcome keeps the reservation for reconciliation instead of
|
||||
releasing it.
|
||||
6. **No price is ever read from the client.** The price book is a versioned,
|
||||
server-owned JSON document (`OPT_CREDIT_PRICE_BOOK`).
|
||||
7. **Trial credits are a grant, not a payment.** `OPT_TRIAL_CREDITS=N` grants N
|
||||
credits once per tenant (`kind='grant'`, idempotency key `trial:<tenant>`),
|
||||
so the ledger is fully exercised before any real purchase. It is never read
|
||||
from a client and never looks like a Stripe payment.
|
||||
8. **Pilot mode is explicit.** `OPT_CREDITS_MODE=off` skips reserve/settle and
|
||||
reports `credits: null`. It is not a silent fallback and it does not enable
|
||||
purchases; unset/`on` requires the price book and the ledger.
|
||||
|
||||
## Reusable packages
|
||||
|
||||
- `packages/siax-access` (`@siax/access`) — framework-neutral OpenFGA
|
||||
relationship checks and a fail-closed `isProjectAccessAllowed`. Intended for
|
||||
DOC0, N0D and every other SIAX product instead of per-repo copies of
|
||||
`project-relationships.ts`.
|
||||
- `src/document-workbench/*` — upload coordination, DOC0 source reading, INF0
|
||||
admission, structured-output validation, export and credit ledger. These
|
||||
modules have no Next.js imports and can be lifted into a published package
|
||||
unchanged.
|
||||
|
||||
## Which AI path is used
|
||||
|
||||
Order:
|
||||
1. **Decision server model** (`DECISION_OLLAMA_URL` + `DECISION_OLLAMA_MODEL`) —
|
||||
the self-hosted Ollama on server-decision-01, used while the external model
|
||||
API is on hold. Internal only, no provider key, no per-token cost.
|
||||
2. **Live LiteLLM gateway** (`INF0_GATEWAY_LITELLM_KEY`).
|
||||
3. Native `INF0_URL` surface.
|
||||
|
||||
Admission — tenant/project scope, model allow-list, data class,
|
||||
external-transfer policy and token limits — runs locally in every path before
|
||||
the request leaves the process. Evidence spans are computed deterministically
|
||||
from the returned values when a small local model omits offsets: a value must
|
||||
occur exactly once in the source, otherwise the result is `needs_review`.
|
||||
|
||||
## What is still deliberately not claimed
|
||||
|
||||
- The output is `mechanically_validated`, not proven complete or semantically
|
||||
correct. OCR quality and coverage require review.
|
||||
- Refunds and chargebacks do not automatically revoke credits; no such handler
|
||||
is wired.
|
||||
- Format breadth is limited by DOC0's parser. A file DOC0 cannot parse is
|
||||
reported, never guessed.
|
||||
Reference in New Issue
Block a user