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

01

Architecture

One Go module. The HTTP surface is registered in one place and the dashboard is embedded at build time.

  1. Start at the entrypointcmd/rivelo/main.go parses flags, loads configuration, then assembles every service in a fixed order.
  2. Find the routesinternal/server/server.go is the single registration point for /api/runtime, /api/admin/, every native gateway path, /healthz, and the dashboard.
  3. Know the mode splitPrototype mounts only the dashboard and /healthz. Managed mode composes admin, gateway, telemetry, extensions, routing, videos, and files through server options.
  4. Place new codeA domain package lives in internal/<domain> with repository interfaces; SQLite adapters live in internal/store/sqlite.
  5. 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

02

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
BoundValue
One hook call100 ms
All hooks plus core validation per request1 s, sharing the gateway deadline
Private middleware state16 KiB
Executor workers / outstanding16 / 16
Plugin chain8 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

03

Write a plugin

A plugin is a Go package registered at build time, so the trust boundary stays explicit.

  1. Copy the closest adapterStart under plugins/. chatcompletions is a full provider; chatmiddleware holds request, prompt, and SSE redaction examples.
  2. Implement the contractProviders implement extension.Provider and optionally the capability interfaces. Middleware implements Apply and returns exactly one body or event on Replace.
  3. 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.
  4. Keep the core cleaninternal packages must not import a concrete plugin. Only the two assembly points may.
  5. Update module countsExtension catalog tests assert the number of compiled modules. A new module needs those expectations updated.
  6. 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

04

Local development

Two processes: the Go API and the Vite dev server.

dev loop
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

05

API contracts

api/admin.openapi.yaml drives generated TypeScript and the agent route policy. The gateway spec is the documented native contract.

  1. Change the contract firstAdd or edit the path and schemas in api/admin.openapi.yaml.
  2. 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.
  3. Implement the handlerinternal/admin handlers receive injected services; avoid reaching into gateway runtime state.
  4. Regenerate typesnpm run api:types writes apps/dashboard/app/lib/admin-api.d.ts through openapi-typescript.
  5. Use the types in the UIFeature clients import components and operations from that module instead of hand-written shapes.
  6. 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

06

Tests

Unit, integration, and managed browser tests are wired into one command.

full check
npm run check
SuiteCommandCovers
Formattingnpm run format:checkPrettier plus gofmt inventory
API typesnpm run api:types:checkOpenAPI to TypeScript drift
API policynpm run api:policy:checkOpenAPI to agent route map drift
i18nnpm run i18n:checkSix catalogs, keys, placeholders, no hardcoded CJK
TypeScriptnpm run typecheckreact-router typegen plus tsc
Unitnpm run test:unitPure logic, no browser
Go vetnode scripts/tasks.mjs vet-goStatic analysis
Go testsnode scripts/tasks.mjs test-goSQLite, gateway, integration
Prototype E2Enpm run test:e2eDesktop and mobile flows
Managed E2Enpm run test:e2e:managedSynthetic 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

07

Release

Releases are tag-driven and have not been exercised yet.

  1. Know the triggerPushing a v* tag starts release.yml. Normal pushes only run checks.yml.
  2. 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.
  3. Tag the schemaMigrations are bundled into the binary. A backup is only valid with the binary version that produced it.
  4. 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.