Architecture
Mendora follows whitepaper v1.1 Section 4: the original agent does the work, the recovery foundation records it, a recovery program decides, only the gateway touches apps, validators grade programs, and a separate release process decides what customers run.
Components (one repository, one Python package)
| Component | Code | Responsibility |
|---|---|---|
| Protocol | backend/src/mendora/protocol | RCP/0.1 models: the case, decisions, results, submission manifest. JSON Schemas in docs/schemas. |
| Simulated apps | sim/ | Approvals, orders, LMS, messaging, calendar, notifications, payments; simulated clock, execution deadlines, visibility lag, outages, in-flight and discarded requests. |
| Gateway | gateway/ | Authorization at acceptance (lease, credentials, scope, then continuation or repair authorization), operation keys, the in-flight rule, repair ownership, intents and receipts, race-block versus violation classification. |
| Harness | harness/ | Feeds one case to one program, one decision at a time; budgets, metering, replayable traces. |
| Templates | families/ | F0 practice, F1 access provisioning, F2 appointment rescheduling; each generates a case, a world and a hidden reference. |
| Programs | programs/ | Baselines B1, B2, B3, B3-G, the reference solver and the stdlib-only policy kit the starter vendors. |
| Scoring | scoring/ | Classification, score, E1–E5, cluster bootstrap, champion state table, quorum, calibration, recomputation, the round evaluator. |
| Intake and isolation | intake/, isolation/ | Hostile-archive validation, manifests, signatures; trusted demo runner, Firecracker runner, fail-closed selection. |
| Chain | chain/ | Local mock chain, read-only testnet and mainnet readers, weight dry runs. No write methods. |
| Services | services/ | Round lifecycle, submission intake, the customer runtime, platform status. |
| API | api/ | FastAPI, sessions and roles, tenant filtering, typed responses. |
| Jobs | jobs/ | PostgreSQL job queue with leases; the worker process. |
| Web | web/ | Next.js: public site, network, competition, miner, operator and customer workspaces, docs. |
Boundaries that matter
- Programs see only the case. The world spec, the reference and fault schedules never enter a program's input
(
tests/test_gateway_drills.py::test_program_input_never_contains_hidden_fields). - Public endpoints see only published rounds and disclosed cases. Private bundles live under
var/private. - Untrusted code needs Firecracker. Without it, packages are stored and never run.
- No chain writes. Weight vectors are planned and recorded with
sent = false. - Tenant isolation is enforced in every customer query; other tenants' jobs are reported as not found.
Data flow of a round
open (commit H(secret)) → miners submit (validated, signed) → freeze (admit, Merkle root, anchor,
snapshot, drand beacon → seed) → evaluate (durable job; every entrant × case × trial; results stored as they
complete) → decide (eligibility, bootstrap, confirmation, promotion, champion transitions) → publish
(25% of clusters disclosed with evidence, secret revealed).
Data flow of a customer recovery
Agent process takes the job lease (token n) → gateway writes an intent → the app commits its effect → the gateway writes a receipt. If the process dies between effect and receipt, the lease expires, the worker marks the job interrupted and starts a recovery process with token n+1, which rebuilds the case from the records and runs the pinned release through the same gateway.
Decisions that shaped this are recorded in adr/.