my-homelab-configs/docs/opsproof-architecture.md

113 lines
5.2 KiB
Markdown

# OpsProof architecture
## Decision
Use Laravel Go as the OpsProof web application, with Inertia, React, and
TypeScript for the browser experience. Deploy it as an independent Debian
service and keep Jeannie as the sole remediation authority.
Laravel Go and Laravel Rust both provide a compiled full-stack Laravel runtime,
Inertia support, and OpenTelemetry. Laravel Go is the better fit here because:
- Jeannie's API and workflow worker are already written in Go;
- Go's fast compile cycle is useful while Laravel's new runtimes are in beta;
- the application is primarily an orchestration and evidence UI, not a
CPU-bound component that benefits materially from Rust's additional
performance;
- one systems language reduces maintenance and makes the portfolio story more
coherent.
This is a reversible decision. Laravel Go remains behind an HTTP boundary and
must not be imported into the root Go module.
## Component boundaries
```text
browser
|
| Inertia pages and form submissions
v
OpsProof on Debian
|-- session, Dex identity, authorization
|-- incident/proposal/audit records
|-- redaction and public-demo projection
|-- dedicated PostgreSQL database
|
| authenticated structured requests
v
Jeannie API on Debian
|-- command allowlist
|-- status and Doctor evidence
|-- execution tracking
|-- Temporal-backed long operations
v
homelab targets (Debian, OCI, RPi, Orange Pi, Kubernetes)
```
OpsProof may link to Grafana, Loki, Tempo, and change-journal artifacts, but
their data does not grant execution authority. AI explanations must cite the
evidence identifiers supplied to the model and remain visibly unverified until
confirmed by deterministic validation.
## Deployment constraints
- Run on Debian so a Kubernetes outage does not remove the incident UI.
- Keep OpsProof records in its own persistent PostgreSQL service and use the
same database contract for feature tests, migrations, and runtime.
- Build with a pinned Laravel Go dependency and Go 1.27 or newer.
- Publish a health endpoint independently from Jeannie health.
- Send Laravel Go's OpenTelemetry traces to the existing Debian monitoring
stack.
- Store the Jeannie bearer token server-side only.
- Use Dex OIDC for operator mode; never expose operator actions in public demo
mode.
- Give OpsProof its own generated Dex client secret, use authorization code
with PKCE, require a verified email, and re-check the operator allowlist on
every protected request rather than treating a past login as authorization.
- Fail closed when Jeannie is unreachable or its advertised command surface
differs from the proposal.
- Collect the overview through Jeannie's authenticated, read-only status
command and expose only sanitized status fields to browser props.
- Constrain incident routes to known target types, collect focused Doctor JSON
server-side, and expose bounded evidence excerpts rather than executable
commands or the complete private response.
- Treat `opi5/k3s-storage` as a dedicated target, not a free-form host route.
It may execute only the identity-pinned `doctor opi5 --repair-k3s` workflow
when the API policy is enabled and current evidence has the exact stale
read-only mount signature.
- Bind every remediation proposal to one Doctor execution and its evidence IDs.
Keep the proposal blocked when identity, current-evidence validation, or a
target-specific rollback is absent; rendering a command never grants the
authority to execute it.
- Persist proposals, approvals, and execution IDs separately. An approval is
single-use and valid only when freshly collected evidence has the same hash,
the command remains advertised by Jeannie, and its arguments still match the
constrained target. Progress reads the recorded execution; it never retries
the state-changing POST.
- Run the focused Doctor target once after a terminal execution and write a
durable before/after report. Preserve a failed validation as an explicit
outcome rather than inferring success from the execution status alone.
- Keep the unauthenticated portfolio route fixture-only. The OCI edge proxies
`/demo`, `/build/`, and explicit login/operator route families. Root redirects
anonymous users to sign-in and `/demo` remains an explicit public fixture;
live evidence and mutations remain behind Dex authentication and the
server-side operator allowlist. Unknown routes return 404.
## Why not Laravel Rust now?
Laravel Rust is a credible future option, particularly for a high-throughput or
memory-constrained product. OpsProof's latency is dominated by remote checks,
Doctor analysis, and remediation workflows. Rust would not improve those paths
enough to justify another toolchain in the first version. A later comparison
can implement the same read-only overview against the stable contract and
measure build time, binary size, memory, and request throughput.
## Non-goals for the first version
- arbitrary shell execution;
- autonomous remediation without operator approval;
- replacing Jeannie, Holmes, Temporal, or Argo CD;
- storing raw infrastructure secrets in the UI database;
- making Kubernetes a runtime dependency for OpsProof availability;
- presenting sanitized portfolio fixtures as live production data.