Manual
Developer manual
How the code is assembled, where the boundaries are, and how to verify a change before handing it off.
Synced with rivelo@760b3c8
Architecture
One Go module. The HTTP surface is registered in one place and the dashboard is embedded at build time.
- Start at the entrypointcmd/rivelo/main.go parses flags, loads configuration, then assembles every service in a fixed order.
- Find the routesinternal/server/server.go is the single registration point for /api/runtime, /api/admin/, every native gateway path, /healthz, and the dashboard.
- Know the mode splitPrototype mounts only the dashboard and /healthz. Managed mode composes admin, gateway, telemetry, extensions, routing, videos, and files through server options.
- Place new codeA domain package lives in internal/<domain> with repository interfaces; SQLite adapters live in internal/store/sqlite.
- Understand the embedThe dashboard is compiled into the binary with the dashboard build tag. internal/server/assets_dev.go reads the local build during development.
- Environment is read once in internal/config: seven variables including two optional affinity settings
- Migrations are embedded and applied inside one startup transaction
- Version, commit, and build date are linker-injected into internal/version
Authoritative sourcedocs/architecture/repository.md
Extension contracts
Three contracts: Provider adapters, Middleware, and Observers. All run behind bounded execution.
- Provider: Descriptor, Build, InspectJSON, InspectEvent; optional Media, Resource, StreamTracker, ModelLister, AllowanceReader
- Middleware: Descriptor plus Apply returning Keep, Replace, or Reject
- Observer: Identity plus Observe over completed-attempt metadata only
- The public contract lives in extension/contracts.go and depends only on the standard library
| Bound | Value |
|---|---|
| One hook call | 100 ms |
| All hooks plus core validation per request | 1 s, sharing the gateway deadline |
| Private middleware state | 16 KiB |
| Executor workers / outstanding | 16 / 16 |
| Plugin chain | 8 distinct plugin IDs, no duplicates |
Extensions cannot call upstreams, swap credentials, open a second attempt, read secrets, or rewrite billing facts. Reject codes map to 403 policy_rejected and 400 invalid_content; a required failure becomes 500 extension_failed.
Authoritative sourcedocs/architecture/extensions.md
Write a plugin
A plugin is a Go package registered at build time, so the trust boundary stays explicit.
- Copy the closest adapterStart under plugins/. chatcompletions is a full provider; chatmiddleware holds request, prompt, and SSE redaction examples.
- Implement the contractProviders implement extension.Provider and optionally the capability interfaces. Middleware implements Apply and returns exactly one body or event on Replace.
- Register itProviders go into the Providers() list in plugins/builtins/providers.go with a reviewed ProviderPolicy. Middleware goes into extensionModules() in cmd/rivelo/extensions.go.
- Keep the core cleaninternal packages must not import a concrete plugin. Only the two assembly points may.
- Update module countsExtension catalog tests assert the number of compiled modules. A new module needs those expectations updated.
- Build and verifyRebuild, then check /api/admin/extensions or the Plugins page for compiled, saved, active, and available state.
Saving a plugin only changes the saved revision. Active settings and chains are fixed at startup, so a change returns restartRequired and needs a process restart.
Authoritative sourcedocs/architecture/extensions.md
Local development
Two processes: the Go API and the Vite dev server.
npm ci
npm run dev:api -- -prototype # terminal 1: Go on 127.0.0.1:8080
npm run dev # terminal 2: Vite on 127.0.0.1:5173- Vite proxies /healthz, /api, and /v1 to 127.0.0.1:8080 and serves the app at /admin/
- The component preview route exists only in development builds
- Frontend changes hot-reload; Go changes need the API process restarted
- A plain go build does not embed the dashboard; use npm run build for the real artifact
Authoritative sourceapps/dashboard/vite.config.ts
API contracts
api/admin.openapi.yaml drives generated TypeScript and the agent route policy. The gateway spec is the documented native contract.
- Change the contract firstAdd or edit the path and schemas in api/admin.openapi.yaml.
- Decide agent reachMark operations automation keys may call with the AutomationKey security scheme. Everything else stays session-only. Run npm run api:policy to regenerate internal/admin/agent_routes_gen.go.
- Implement the handlerinternal/admin handlers receive injected services; avoid reaching into gateway runtime state.
- Regenerate typesnpm run api:types writes apps/dashboard/app/lib/admin-api.d.ts through openapi-typescript.
- Use the types in the UIFeature clients import components and operations from that module instead of hand-written shapes.
- Gate the changenpm run api:types:check fails when the generated file drifts from the spec.
Native gateway bodies are documented in api/gateway.openapi.yaml and the support matrix. They are deliberately not copied into TypeScript types. Agent reachability is default deny: a bearer request outside the generated allowlist returns 403, and a registered route with no policy decision fails the Go drift test. The operator walkthrough is /docs/agent-access/.
Authoritative sourceapi/admin.openapi.yaml
Tests
Unit, integration, and managed browser tests are wired into one command.
npm run check| Suite | Command | Covers |
|---|---|---|
| Formatting | npm run format:check | Prettier plus gofmt inventory |
| API types | npm run api:types:check | OpenAPI to TypeScript drift |
| API policy | npm run api:policy:check | OpenAPI to agent route map drift |
| i18n | npm run i18n:check | Six catalogs, keys, placeholders, no hardcoded CJK |
| TypeScript | npm run typecheck | react-router typegen plus tsc |
| Unit | npm run test:unit | Pure logic, no browser |
| Go vet | node scripts/tasks.mjs vet-go | Static analysis |
| Go tests | node scripts/tasks.mjs test-go | SQLite, gateway, integration |
| Prototype E2E | npm run test:e2e | Desktop and mobile flows |
| Managed E2E | npm run test:e2e:managed | Synthetic env, seeded logs, real binary |
- Integration tests pair a controlled TLS upstream with a real SQLite database
- Managed E2E creates its own master key, admin token, temp DB, and port
- Playwright must be installed once with npm exec --workspace @rivelo/dashboard -- playwright install chromium
Authoritative sourcepackage.json
Release
Releases are tag-driven and have not been exercised yet.
- Know the triggerPushing a v* tag starts release.yml. Normal pushes only run checks.yml.
- Follow the jobsverify runs the full check; assets build the dashboard; binaries build five platform targets; docker publishes a multi-arch GHCR image with provenance, SBOM, and cosign keyless signing; release uploads SHA256SUMS and notes.
- Tag the schemaMigrations are bundled into the binary. A backup is only valid with the binary version that produced it.
- Respect the gateNo tag, registry push, or signature has been exercised yet. A local image is not a published release.
An older binary refuses a newer schema instead of downgrading. Roll back with the paired backup and matching binary.
Authoritative sourcedocs/operations/release-gates.md
Authoritative source
This manual is a task-oriented guide. Authoritative contracts and defaults live in the repository docs.
- Repository structure
docs/architecture/repository.md - Extension contracts
docs/architecture/extensions.md - Admin API contract
api/admin.openapi.yaml - Agent access policy
docs/architecture/agent-access.md - Gateway API contract
api/gateway.openapi.yaml - Cross-domain roadmap
docs/implementation-roadmap.md