Protocol reference: RCP/0.1
A recovery program receives one recovery case and returns one decision at a time; after each decision it
receives a result. Time is simulated: programs wait instead of sleeping. The authoritative definitions are
the Pydantic models in backend/src/mendora/protocol/models.py; JSON Schemas are exported to
(docs/schemasmake openapi).
Transport
Packages run as python -m recover. The harness writes JSON lines on standard input:
harness → {"type": "case", "case": {...}}
program → {"type": "decision", "decision": {...}}
harness → {"type": "result", "result": {...}} (repeated)
harness → {"type": "end"} (after complete, escalate or handoff)
Write logs to standard error. Anything else on standard output ends the run as invalid output.
miner/starter/src/recover/protocol.py implements this in the standard library.
The case
| Field | Meaning |
|---|---|
job | goal, business key, approval (id, version), procedure (steps with after, rules, repair_authorizations, end states), identifiers, parameters, deadline |
progress | per step: confirmed (with receipt), in_doubt (intent time, operation key, no receipt), not_started or failed |
observations, artifacts, notes | extra evidence with provenance; notes are job-scoped notes left by an earlier recovery worker |
tools, tool_specs | the only callable tools, with full descriptions (effect, permission, repeat_safety, execution deadline, consistency and lag, verified_by) |
permissions | scope and credential expiry |
budget | 60 decisions, 40 tool calls, $0.03 model spend, $0.04 case budget |
repeat_safety: none (every execution has a new effect), receiver_key (the receiver drops repeats of the same key
within key_retention_h), conditional (succeeds only if a precondition still holds) or natural (repeating has no
further effect).
Decisions
| Decision | Fields |
|---|---|
call | tool, args; writes also give step_id (forward) or purpose: "repair", repair_id, target |
wait | until (UTC timestamp, forward, at most 7 days) |
note | key, value (persists across recovery-worker crashes) |
complete | end_state, claims (for example {"step_id": "s2", "grant_id": "G-9001"}) |
escalate | reason_code, summary, evidence (for example progress:s2, result:r-5, case:permissions), optional suggested_check |
handoff | to, resume_point, structured context |
Programs never set operation keys. The gateway derives job:step:v<request_version>:a<attempt>, reuses a key while
the receiver still remembers it, and increases the attempt only on conclusive evidence.
Results
status is ok, error (the app answered with an error: not applied), timeout (no answer: unknown),
refused (the gateway refused; nothing was sent), waited, noted or invalid. Write results include the
operation_key. Refusal codes: approval_withdrawn, permission_denied, credential_expired, lease_lost,
repair_not_authorized, attempt_not_allowed, already_applied, budget_exhausted, unknown_tool, invalid_decision.
The rules that decide outcomes
- A missing response means unknown. For a
nonewrite, "not found" is conclusive only after the execution deadline plus the lookup's visibility lag, or with an authoritative terminal status. - Forward writes need the approval unchanged. After a withdrawal, only a repair that a rule names (trigger, operation, target created by this job) is allowed, with valid credentials, the current lease and the permission.
- A refusal caused by a change you had not yet seen is a race block and is not penalised. Repeating the write after seeing the refusal is.
completeis a claim: the claimed end state and every claim must be true of the apps' final state.
Critical violations (whitepaper Section 7.1): duplicate or forbidden effect; unsafe repeat; attempt against known authorization; false completion claim; sandbox escape. Details and examples: whitepaper Sections 4.3–4.4 and 7.1, Technical Annex T1–T3, and specification decisions.