Architecture
Architecture
This note records the production-readiness shape that matters for DoD D.
Scope
- Rust workspace for CLI, engine, router, providers, billing, and protocol.
- Next.js web app for auth, stream API, usage, balance, and dashboard pages.
- Shared canonical usage and cost math across Rust and TypeScript.
- MoA / Self-MoA orchestration in the stream path.
Trust boundaries
- Provider credentials stay in web-side env/config paths, not in
crates/. - Cost reporting is derived from canonical usage, not from ad hoc UI totals.
- Streaming and usage persistence are verified separately from billing math.
- Offline evidence is accepted only when live provider creds are absent, and that assumption must be stated explicitly in the report artifact.
Cost and MoA path
web/lib/billing.tsandcrates/plyrum-billing-client/src/cost.rsimplement the canonical integer micro-RUB cost formula.web/lib/moa.tsdecides when MoA or Self-MoA activates.- The
web/app/api/stream/run/route.tspath is the place where stream, lifecycle, and usage rows converge. - B6 evidence should compare MoA versus direct runs using the same offline harness assumptions when provider credentials are unavailable.
Router -> engine -> providers -> audit
- Router classifies a prompt into workload intent, risk, domains, and model
candidates (
crates/plyrum-router,web/lib/provider-catalog.ts). - Engine executes the DAG or MoA-shaped plan and emits lifecycle frames
through
plyrum-protocol. - Providers stream tokens and canonical usage through the provider registry; web adapters keep raw provider keys server-side.
- Billing normalizes token/cost data into micro-RUB usage records.
- Audit and transcript writers persist redacted JSONL records for CLI tool actions, lifecycle handoffs, and dashboard inspection.
Validation commands
cargo test -p plyrum-billing-clientpnpm -C web testpnpm -C web exec tsc --noEmit --incremental falsecargo test -p plyrum-cli -- --test-threads=1cargo test -p plyrum-cli auto_confirmcargo test -p plyrum-cli working_system_creationcargo test -p plyrum-cli persona_snapshotscargo test -p plyrum-engine moa_pipeline./scripts/smoke.sh
DoD D notes
- This repo now keeps the cost evidence in
target/cost_report.json. - The report is intended to be machine-readable, reproducible, and reviewable without needing live provider access.