rhi

Coordinated trade for connected markets
git clone https://radroots.dev/git/rhi.git
Log | Files | Refs | README | LICENSE

AGENTS.md (39132B)


      1 # rhi — repository agent contract
      2 
      3 ## 1. Scope and operating model
      4 
      5 - This file applies to the complete repository unless a nearer `AGENTS.md` is
      6   stricter.
      7 - This repository owns `rhi`, the standalone Radroots evidence-reconciliation
      8   and attestation service. Treat canonical event admission, provenance,
      9   evidence completeness, outcome meaning, identity, persistence, and
     10   publication as security-critical behavior.
     11 - Keep the repository independently cloneable, buildable, testable,
     12   packageable, and operable. Do not depend on private repositories, unreachable
     13   or unlocked artifacts, internal monorepo paths, absolute workstation paths,
     14   or private harnesses. An unpublished public dependency is allowed only when
     15   its exact commit is reachable from the governed public Git source and pinned
     16   by the checked-in source lock.
     17 - All `.github/**` and capsule-local `.act/**` workflow definitions are
     18   forbidden. Keep validation forge-agnostic, do not depend on a private
     19   harness, and leave orchestration exclusively to the parent repository's root
     20   `.act/**` authority.
     21 - Capsule-local human specs, ADRs, runbooks, test plans, and execution evidence
     22   are not owned here; place that authority under the parent repository's
     23   `docs/oss/rhi/**`. Standalone machine contracts and ordinary source, test,
     24   build, package, and operational assets remain capsule-owned.
     25 - Do not add or retain tracked `docs/**`, `.github/**`, or `.act/**` content in
     26   this capsule. Keep human documentation under the parent authority above and
     27   machine-enforced declarations under governed standalone contract surfaces.
     28 - RHI does not own worldwide evidence completeness, trade agreement or
     29   settlement authority, relay storage/tenancy, general SDK generation, hosted
     30   accounts, telemetry, artifact promotion, or deployment transport.
     31 
     32 ## 2. Authority and preflight
     33 
     34 - Before editing, read this file, `README`, `Cargo.toml`,
     35   `radroots.service.source_lock.v4.toml`, and the relevant implementation and
     36   tests. The removed prototype root `config.toml` is not configuration
     37   authority.
     38 - Current compiler/source preparation uses the V4 lock and
     39   `contracts/services_hardening/native_release.v3.json`. Nix inputs are bound;
     40   executed current qualification remains separate. Prepare an exact staged
     41   migration through the source-locked Lib producer, verify and commit the
     42   complete candidate, then require its clean-source check. Archived V3 locks
     43   and earlier contracts retain their history. Step 301 tooling is replay-only
     44   for its original source and does not qualify current inputs.
     45 - `.radroots-consumer-root` is the standalone source-lock identity and must
     46   remain exactly `rhi`. The reserved pre-implementation evidence authority is
     47   `contracts/services_hardening/evidence_policy.v1.json`, and the reserved
     48   pre-implementation operator authority is
     49   `contracts/services_hardening/operator_contract.v1.json`. RHI source and
     50   configuration must implement their exact source, selector, cursor,
     51   completion, coverage, digest, publication-independence, route, wire-model,
     52   identity-role, pagination, mutation, doctor, exit, and TCP semantics;
     53   prototype source behavior is not permission to reinterpret them.
     54 - Treat checked-in source, tests, configuration, and prototype behavior as
     55   implementation evidence, not permission to preserve behavior that the active
     56   requirement removes.
     57 - Do not invent event kinds or tags, evidence-policy fields, source semantics,
     58   protocol behavior, APIs, dependencies, release processes, identity authority,
     59   migration behavior, or external integration semantics.
     60 - Inspect `git status --short`, the exact repository root, and nearby tests
     61   before changing behavior. Preserve unrelated work and stop on an unresolved
     62   evidence-integrity, identity, or publication conflict.
     63 - Keep changes narrowly scoped and independently reviewable. Do not mix
     64   unrelated cleanup, speculative abstractions, roadmap work, or compatibility
     65   scaffolding into a checkpoint.
     66 - RCLD-RSHR-195 Step 246 advances the active native Lib source lock and freezes
     67   RHI state creation behind the runtime-path directory plan plus the sealed
     68   service-SQLite initializer. Explicit initialization may provision only the
     69   exact governed service-instance suffix after identity and catalog validation;
     70   every existing-only open remains non-creating. Do not restore raw paths, raw
     71   SQLx connections, filesystem probes, or directory-creation fallbacks at the
     72   state-host boundary.
     73 
     74 ## 3. Clean-slate service rule
     75 
     76 - Do not add or preserve prototype configuration readers, `.env` runtime
     77   configuration, `RHI_*` runtime selectors, worker paths, JSON/JSONL mutable
     78   state, prototype config/state importers or migrations, old-path probes,
     79   aliases, fallbacks, dual readers/writers or event decoders, deprecated
     80   modules/APIs/re-exports, or old/new feature switches. Offline production
     81   schema migration must never accept an unreleased prototype format.
     82 - Remove superseded behavior and update every affected Radroots-owned consumer
     83   directly. Do not hide a breaking change behind a compatibility adapter unless
     84   an accepted public requirement explicitly requires one.
     85 - Preserve canonical public Nostr interoperability. Clean-slate product
     86   behavior never authorizes wire drift, ad hoc event kinds/tags, or relaxed
     87   signature, event-ID, content, or tag validation.
     88 - A breaking config, CLI, state, evidence, report, attestation, admin, error, or
     89   wire change must update its public machine contracts, examples, tests,
     90   generated surfaces, source guards, and release qualification in the same
     91   coherent sequence.
     92 
     93 ## 4. Canonical admission and provenance
     94 
     95 - Bound event bytes, content, tags, per-tag and aggregate tag bytes, extras,
     96   source results, and authored time before admission. Verify the Nostr event ID
     97   and signature, registered kind, author, canonical mutation content and ID,
     98   canonical serialization, mandatory structural tag cardinality/content
     99   binding, duplicate or conflicting structural tags, and explicit time policy.
    100 - Route accepted trade mutations only through the sealed
    101   `admit_rhi_trade_mutation_event` boundary. Its wire limits come from the
    102   validated configuration, its future-time tolerance is explicit with no
    103   default, and it remains pure; persistence belongs only to the separate typed
    104   repository transaction introduced by Step 184.
    105 - Persist canonical mutation, every distinct signed event carrying it, and
    106   every accepted source observation as separate typed facts. Two events for one
    107   mutation never overwrite one another, and arrival order never selects truth.
    108 - Reject malformed, unsupported, wrong-author, wrong-kind, wrong-ID, wrong-tag,
    109   excessive-future, conflicting, or oversized input before it creates accepted
    110   evidence, advances a checkpoint/completion, or increments dirty generation.
    111 - Make exact event replay idempotent. Repeated source observation preserves the
    112   first bounded provenance fact without multiplying authoritative evidence;
    113   conflicting content for one mutation ID fails independently of arrival order.
    114 - Persist observation and audit time from the injected wall clock using named
    115   integer UTC units. Keep event-authored time as distinct untrusted input; never
    116   label, persist, or reuse it as source observation time.
    117 - Scope checkpoints by stable source plus exact selector/policy. Preserve
    118   equal-timestamp discovery through overlap and deduplication; never use one
    119   global authored timestamp as the sole cursor.
    120 - Increment dirty generation only for relevant newly accepted evidence or a
    121   governing policy change. Duplicate provenance, rejection, and operational
    122   retry do not dirty a trade.
    123 
    124 ## 5. Evidence reconciliation, coverage, and outcome
    125 
    126 - Persist bounded jobs, attempts, lease ownership/expiry, failure counts,
    127   source request/completion/cursor evidence, and next-attempt schedules. Use
    128   compare-and-swap claims, bounded concurrency, renewable/reclaimable leases,
    129   injected time and jitter, and deterministic crash/reopen recovery.
    130 - Record each source result with exact selector digest, required/optional
    131   authority, stable request identity, deadline, lookback/cursor, completion
    132   evidence, accepted-event count, safe outcome code, and bounded timing.
    133 - Derive the bounded canonical per-source request inventory only from an
    134   unexpired claimed reconciliation lease and the exact normalized evidence
    135   policy. Attempt, selector, and request identities are domain-separated;
    136   every deadline is absolute and capped by both configuration and lease
    137   expiry; result ingestion consumes at most the configured source count plus
    138   one before rejecting missing, duplicate, reordered, or excess evidence.
    139 - Query every configured source outside write transactions. A timeout,
    140   unsupported adapter, partial result, raw upstream error, or unknown
    141   completion never masquerades as success.
    142 - Bind every resumed request to its exact prior authored-time/event-ID cursor,
    143   subtract the configured overlap for an inclusive query start, canonicalize
    144   distinct signed-event identities, retain the earliest injected provenance,
    145   and reject conflicting mutation or signed-event identity reuse before the
    146   Step 190 commit boundary.
    147 - Freeze the exact accepted mutation, signed-event, provenance, and per-source
    148   completion inventory in an immutable canonical manifest. Reducers consume a
    149   canonically ordered immutable set with explicit policy digest, reducer
    150   version, coverage, and observed-time input; they have no database insertion,
    151   relay, scheduling, wall-clock, entropy, or network dependency.
    152 - Mint the immutable reconciliation manifest only by consuming a sealed,
    153   durably confirmed source-commit outcome. Bind each source result to its exact
    154   selector, completion, cursor, timing, and persisted-inventory digest, and
    155   bind each observation to the exact canonical signed-event and first-source
    156   provenance. Do not expose a raw manifest constructor or parser from RHI.
    157 - Keep Step 191 manifest materialization pure and in memory. Step 199 alone
    158   owns durable manifest persistence; reducers, coverage/outcome, attestation,
    159   publication, and job finalization retain their ordered owners.
    160 - Reduce only the sealed owned reconciliation manifest. Retain its bounded
    161   canonical mutation material privately from the confirmed Step 190 commit,
    162   map its already-governed evidence coverage into the shared reducer input,
    163   and bind the canonical shared projection digest to the exact manifest and
    164   evidence-policy digests. Do not accept caller mutation material or add
    165   SQLite, filesystem, source, relay, task, clock, entropy, or network access.
    166 - Derive claim-specific coverage and outcome only from that sealed projection.
    167   Missing, partial, unsupported, unavailable, ambiguous, unresolved, or absent
    168   evidence is `Indeterminate`; evidence absence never becomes `Invalid`.
    169   Permit `Valid` only for one clean active agreement claim and `Invalid` only
    170   for one clean cancelled claim. Emit only the fixed stable reason vocabulary.
    171 - Coverage is exactly `Missing`, `Partial`, `ScopeSatisfied`, or `Unsupported`.
    172   ScopeSatisfied means only that the configured policy was satisfied; optional
    173   evidence never substitutes for required-source completion.
    174 - Outcome is exactly `Valid`, `Invalid`, or `Indeterminate`. Missing, partial,
    175   unsupported, unavailable, ambiguous, or unresolved required evidence is
    176   Indeterminate; absence never becomes invalidity.
    177 - Fence final work by dirty generation and policy digest. A stale worker cannot
    178   overwrite newer evidence, and CAS loss leaves no partial report, outbox,
    179   source completion, checkpoint, or job finalization.
    180 - Carry the exact committed attempt and job identities privately through the
    181   sealed manifest, projection, and evaluation chain. A finalization preflight
    182   is not commit authority: rerun its exact lease, generation, policy, and
    183   attempt validator inside the Step 199 atomic transaction before any write.
    184 - Commit a signed finalization only through the sealed attempt repository.
    185   Bind publication authority to the same normalized configuration as the open
    186   state host, reconcile exact prior success before testing the consumed lease,
    187   and write manifest, projection, report, exact signed bytes, explicit
    188   supersession, required outbox/targets, and completed job in one short SQLx
    189   transaction. Disabled publication must create no outbox, and no source,
    190   relay, network, filesystem, task, clock, or entropy operation may occur in
    191   this boundary.
    192 
    193 ## 6. Report, attestation, and publication invariants
    194 
    195 - Bind every immutable report to contract ID/version, issuer public key, trade
    196   ID, exact claim mutation ID, policy and manifest digests, reducer
    197   contract/version, projection digest, outcome and stable reasons, integer UTC
    198   observation time, attestation method `signed_evidence_snapshot`, statement
    199   digest, and explicit superseded report/event reference when applicable.
    200 - Construct the canonical domain-separated statement payload from governed
    201   semantic fields only. Exclude self-referential digest, signature, event ID,
    202   and derived fields; never invent an encoding, preimage, kind, tag, or query.
    203 - Build and sign through typed governed APIs, then revalidate issuer/author,
    204   exact unsigned fields, event ID, signature, canonical report binding, and
    205   applicable Nostr semantics before persistence or publication.
    206 - Construct a signed reconciliation attestation only by consuming the sealed
    207   finalization fence and the independently verified encrypted service identity.
    208   Accept authored time and exactly 32 bytes of Schnorr auxiliary randomness
    209   only through injected authorities. Retain the exact independently verified
    210   signed JSON bytes and their SHA-256; never rebuild, reserialize, or re-sign
    211   them after the boundary succeeds.
    212 - Accept an attestation supersession input only when it is derived from a prior
    213   sealed verified RHI attestation, and rerun the shared report/event binding and
    214   ordering validator before exposing the successor. This pure signing boundary
    215   has no SQLite, filesystem, relay, network, task, or publication authority.
    216 - One generation-fenced transaction commits attempt/source results, immutable
    217   manifest/projection/report, supersession, exact serialized signed event
    218   bytes/digest, immutable target set and initial outbox when required, accepted
    219   source completion/checkpoints, and job finalization before relay I/O.
    220 - Publication is explicitly `required` or `disabled`. Retry and recovery submit
    221   only the committed exact bytes; never deserialize, rebuild, reserialize,
    222   re-sign, or change targets.
    223 - Distinguish pending, submitted, accepted, rejected, rate-limited,
    224   auth-required, failed, and unknown target evidence. Submission or lost
    225   acknowledgement never proves delivery or failure.
    226 - Keep profile and application-handler presence as deterministic durable desired
    227   state with the same commit-before-I/O and exact-byte retry discipline.
    228 - Derive presence desired state only from one complete admitted configuration,
    229   bind it to the latest durable configuration before mutation, and advance its
    230   singleton generation only when the semantic presence authority changes.
    231   Durable desired state contains only the closed mode, document-presence bits,
    232   bounded target counts, queue capacity, and governed digests; it never stores
    233   relay URLs, rendered or signed events, attempts, schedules, or outcomes.
    234 - Build service-profile and application-handler presence only through the
    235   governed typed Lib plans, then independently revalidate exact ID, signature,
    236   author, kind, authored time, ordered tags, and content before persistence.
    237   Commit each verified signed byte sequence and the complete immutable target
    238   inventory before an injected presence sink can observe it. Preserve the
    239   caller's sealed exact-byte capability across an unknown commit result so
    240   reconciliation never depends on re-signing.
    241 - Persist presence `submitted` in a short SQLx-owned transaction before relay
    242   I/O, keep the remote await outside every transaction, and atomically append
    243   the closed attempt outcome with target scheduling, outbox disposition, and
    244   lease release. Cancellation or lost acknowledgement becomes durable
    245   `unknown` before retry of the same retained bytes. Recover an expired stale
    246   desired generation to `unknown` and supersede it without retry entropy so it
    247   cannot block the current generation indefinitely. Never reconstruct exact
    248   committed presence bytes or persist raw relay diagnostics.
    249 
    250 ## 7. Configuration, identity, state, and process boundaries
    251 
    252 - Load exactly one immutable TOML document with
    253   `schema = "radroots.rhi.config"` and `schema_version = 1`. Reject unknown
    254   fields at every object boundary, implicit relays/sources,
    255   complete-by-default evidence, unsafe defaults, environment overlays,
    256   includes, interpolation, fragments, stdin configuration for `run`, hot
    257   reload, and arbitrary leaf flags.
    258 - Parse bootstrap profile, instance, repo-local root, and an optional absolute
    259   config path once as CLI authority; they are not TOML fields. Human output is
    260   the default and governed machine output is explicit.
    261 - Keep every real source explicit with a stable ID, required/optional status,
    262   exact selector, deadline, lookback, overlap/cursor and failure/completion
    263   policy, and relationship to publication. Bind the complete normalized
    264   authority in the evidence-policy digest. Add an adapter only for a real,
    265   qualified evidence source; do not invent a generic source mode.
    266 - Give relays and sources unique stable IDs, canonical URLs, and explicit
    267   read/write/required authority as applicable. Production public connections
    268   enforce secure transport, every-answer network policy, and preserved TLS
    269   SNI/certificate identity; plaintext loopback is simulator-only and is never
    270   selected implicitly.
    271 - Keep parsing and semantic validation pure: no path creation, identity or
    272   credential access, SQLite, DNS, network, clocks, entropy, logging setup,
    273   process mutation, or panic.
    274 - Identity uses only the governed encrypted envelope and separately named
    275   wrapping credential. Do not add plaintext or adjacent keys, implicit identity,
    276   or ordinary-run generation/replacement. Validate expected public-key and
    277   policy bindings before readiness.
    278 - Resolve the wrapping credential only from the validated fixed artifact name
    279   beneath the same instance's canonical secrets root. The resolver is
    280   read-existing-only, accepts no caller path or bytes, and supports only
    281   service-host and repo-local profiles. The governed envelope and credential
    282   are excluded from state backups.
    283 - Do not read, reseal, import, or migrate prototype or legacy identity-envelope
    284   formats. Missing, wrong, legacy, or misbound envelopes and wrapping
    285   credentials fail closed.
    286 - Each instance owns one explicitly initialized `state.sqlite`, retained
    287   `state.lock`, exclusive instance lock, and one live writer authority. Normal
    288   `run` opens existing state only and verifies service, instance, source
    289   generation, schema/migration checksums, identity, and policy metadata before
    290   readiness. Raw pools, connections, or cloneable write authority never escape
    291   typed RHI repositories; live clients mutate only through the Unix admin
    292   boundary and offline state operations must prove that no daemon writer exists.
    293 - Create-new state begins at the shared schema-v1 baseline and applies the
    294   governed RHI schema-v2 configuration-binding migration, schema-v3
    295   immutable trade-evidence migration, schema-v4 source-checkpoint and
    296   dirty-generation migration, schema-v5 bounded reconciliation-job migration,
    297   schema-v6 immutable reconciliation-attempt/source-result migration, and
    298   schema-v7 immutable manifest, projection, report, exact signed-event, and
    299   publication-workflow migration.
    300   Retain at most 1,024 consecutive
    301   immutable configuration generations containing only normalized
    302   config/evidence-policy digests, public identity, exact contract versions,
    303   injected apply time, and bounded build identity. Persist each canonical
    304   mutation, independently signed Nostr event, and accepted configured-source
    305   observation as distinct immutable facts in one SQLx transaction. Exact replay
    306   is idempotent, conflicts fail closed, observation time remains distinct from
    307   authored time, and this persistence step must not advance reconciliation
    308   checkpoints or dirty generation. The composed relay-source ingest path may
    309   advance only its exact scoped checkpoint after complete EOSE evidence and
    310   may dirty a trade only for newly inserted mutation or signed-event evidence;
    311   replayed source observation alone does neither. Never persist raw TOML,
    312   paths, URLs, credential references, or protected identity material. Ordinary startup must
    313   use intent-open, discover source generation under retained authority, and
    314   match the latest durable binding; configuration apply is an exclusive offline
    315   operation.
    316 - Derive publication authority only from one complete validated configuration.
    317   Required mode preserves the exact ordered write-relay target inventory,
    318   requiredness, retry bounds, queue capacity, and domain-separated identities;
    319   disabled mode has no target, retry, network, or hidden fallback authority.
    320   Keep manifest, projection, report, signed-event bytes, and attempt rows
    321   immutable, and expose outbox/target progress only through versioned
    322   compare-and-swap state. Step 198 defines this catalog and performs no SQLite
    323   mutation or relay I/O; later publication steps must use only the committed
    324   exact signed bytes and may never rebuild, reserialize, or re-sign them.
    325   Read retry/recovery payloads only through the sealed committed-publication
    326   capability joined from the immutable outbox and signed-event rows. Recheck
    327   the bounded stored-byte digest on every read, including after reopen. The
    328   capability is not claim authority; later relay execution must borrow its
    329   exact byte slice without parsing or reconstruction.
    330 - Model publication target and attempt evidence only with the closed pending,
    331   submitted, accepted, rejected, rate-limited, auth-required, failed, and
    332   unknown vocabulary. Attempt evidence must derive its identity from the
    333   sealed committed outbox and exact event digest plus bounded target ordinal
    334   and attempt number; never accept caller-supplied identities, arbitrary result
    335   codes, raw relay diagnostics, reversed timestamps, or implicit clock reads.
    336   The model is not claim, transition, or relay authority. The durable executor
    337   must revalidate every live target, lease, revision, attempt, and byte binding.
    338 - Execute publication only through the dedicated exact-byte sink. Persist
    339   Submitted before remote I/O, never hold a SQLx write transaction across that
    340   I/O, and never parse, rebuild, reserialize, or re-sign the committed payload.
    341   Append the closed attempt evidence and compare-and-swap target schedule,
    342   outbox disposition, and lease release together. Cancellation or lost
    343   acknowledgement after Submitted is Unknown until independent evidence;
    344   expired-lease recovery must retain that evidence before bounded injected-
    345   jitter retry. Never persist raw relay diagnostics or blindly repeat an
    346   unknown local commit.
    347 - Commit one exact reconciliation-attempt replay inventory only through the
    348   typed attempt repository. Revalidate the exact live lease, dirty generation,
    349   evidence policy, and every scoped prior checkpoint before mutation; persist
    350   evidence, immutable results, the exact ordered fact/provenance inventory
    351   digest, at most one dirty advance, and eligible checkpoints atomically.
    352   Incomplete or unsupported results never advance, and committed cursor
    353   evidence is minted only after durable commit confirmation.
    354 - Never hold a database transaction while waiting for a source, relay, DNS,
    355   identity provider, clock, entropy, signing, reduction, or backoff.
    356 - Never prune active jobs/outboxes, migration history, current identity/policy
    357   bindings, evidence required to reproduce a current attestation, immutable
    358   report/supersession history, or exact signed bytes required for retry/audit.
    359   Any allowed compaction must be explicit, transactional, bounded, and
    360   verifiability-preserving.
    361 - Parse the process CLI and initialize the tracing subscriber only in the binary
    362   composition boundary. Libraries may emit tracing events but must not install
    363   signal handlers, create Tokio runtimes, call `process::exit`, spawn arbitrary
    364   executables, or detach authoritative tasks.
    365 - Inject wall time, monotonic time, entropy, transport, identity providers,
    366   evidence sources, and failpoints. Supervise and join every authoritative task;
    367   panic, error, or unexpected successful return from a critical task must
    368   coordinate shutdown and produce a nonzero process result.
    369 - Compose those dependencies only through the sealed runtime-adapter boundary.
    370   Wall UTC and process-local monotonic observations remain distinct; jitter is
    371   bounded whole-millisecond full jitter derived only from injected entropy.
    372   The transport-neutral `radroots_transport` source, subscription, and sink
    373   traits are the sole generic event I/O SPI. Credential access must precede
    374   independently verified encrypted-identity access, with no fallback or
    375   generation. The adapter set owns one private shared `TaskSupervisor` and
    376   exposes no task handle or concrete transport handle.
    377 - The existing-state runtime foundation must verify durable configuration
    378   before credential/identity access and must contact no event source,
    379   subscriber, or publication sink. Its passive initial readiness may prove
    380   only existing state, durable configuration, and verified identity. Recovery,
    381   connectivity, listeners, presence desired state, signals, logging, and the
    382   final supervised graph remain with their later owning checkpoints.
    383 - Library code must not install signals, create a runtime, install logging,
    384   call process exit, or detach an authoritative task. Those process authorities
    385   remain exclusively with the final binary checkpoint.
    386 - On startup, reclaim expired reconciliation/publication leases, resume durable
    387   retry schedules with injected bounded jitter, retain unknown submissions,
    388   finalize already-proven outcomes idempotently, and scan all authoritative
    389   relationships. Impossible, corrupt, misbound, orphaned, newer-schema, or
    390   checksum-invalid state fails closed or enters an explicitly safe
    391   repair-required state; it is never silently deleted or guessed.
    392 - The first termination signal begins bounded graceful shutdown and preserves
    393   durable claims and exact publication state; a second signal forces
    394   termination. Critical-task and shutdown failures remain nonzero.
    395 
    396 ## 8. Admin, observability, recovery, and secret boundaries
    397 
    398 - Parse the CLI once and dispatch only pure/offline bootstrap, a live Unix admin
    399   client, or the daemon. Config validation/schema and pre-service initialization
    400   are offline. State init/restore/verify/migrate and initial identity
    401   provisioning require proof that no writer lock exists.
    402 - Detailed status, redacted effective config, online backup, identity status
    403   and public export, reconciliation/job/source status, bounded trade/report
    404   queries, publication/target retry or refresh, metrics snapshot, and presence
    405   status/refresh use bounded, versioned HTTP/JSON over a permissioned Unix
    406   socket while live. Do not add TCP admin, browser auth, CORS, direct writable
    407   CLI fallback, or live direct-SQLite mutation.
    408 - Enforce peer credentials only to the strength qualified for the platform;
    409   keep Linux Tier-1 and filesystem-permission behavior explicit.
    410 - Bind every mutation to stable operation/correlation identity, idempotent
    411   replay, conflicting-reuse rejection, typed bounded responses, and explicit
    412   safe confirmation for destructive or identity-sensitive work. Never unlink
    413   a live socket owner; remove only a proven stale socket under the resolved
    414   instance runtime directory.
    415 - Keep the public RHI route and document vocabulary closed against the exact
    416   operator contract. Step 206 owns the seven common routes and Step 207 owns
    417   the thirteen domain routes. Step 208 removes the stale, never-registered live
    418   identity rekey/replace vocabulary, and Step 209 alone may claim the complete
    419   20-route/33-model surface. Never expose the shared raw router, listener, JSON
    420   handler, or a caller-selected socket path.
    421 - Through Step 209, the active and final route sets are exactly seven common
    422   plus thirteen domain routes. The Step 209 wave contract freezes the complete
    423   original-wire, version, pagination, idempotency, peer, removed-route, and
    424   resource negative matrices against the exact Lib source lock. Pagination is
    425   bounded to 200 items, query fields are closed, authenticated cursors remain
    426   bound by the handler to route/filter/snapshot, and decoded trade parameters
    427   use the exact lowercase-hex trade-ID type. Identity rotation remains offline
    428   create-new plus validated configuration apply and restart; Unix peer
    429   admission grants no direct SQLite or identity-provider mutation authority.
    430 - Step 210 freezes the one-parse CLI execution split. Every admitted command
    431   selects exactly daemon, offline, or permissioned Unix-admin authority. All
    432   twenty live commands map one-to-one to the final twenty-route inventory and
    433   carry no offline or direct-SQLite fallback. Config initialization,
    434   validation, schema, and apply; exclusive state maintenance; initial identity
    435   provisioning; and doctor remain offline. Do not reparse process arguments or
    436   let a live CLI plan obtain SQLite, identity-provider, source, relay, task,
    437   signal, or runtime authority.
    438 - Optional TCP operations expose only cached `/livez`, `/readyz`, and
    439   `/metrics`; requests must not perform SQLite, source, relay, DNS, identity,
    440   evidence, or credential probes.
    441 - Step 212 owns the one-latest passive lifecycle/status cache and the optional
    442   TCP adapter. Detailed status remains permissioned Unix-admin-only. The TCP
    443   surface is exactly cached `/livez`, `/readyz`, and `/metrics`, with two fixed
    444   RHI metric families and no route-registration extension, active probe, or
    445   high-cardinality label authority.
    446 - Keep logs as safe structured stderr output. Keep result data on stdout and
    447   diagnostics on stderr. Use stable bounded public codes/messages, bounded
    448   metric labels, explicit redaction, and no trade/mutation/event/report IDs or
    449   arbitrary upstream text as labels.
    450 - Doctor uses bounded active checks with per-check deadlines, safe structured
    451   required/optional results, and a nonzero result for required failure or
    452   timeout. It covers paths/permissions, writer lock, schema/integrity/free disk,
    453   identity/credential, bind/network policy, required source reachability,
    454   checkpoint plausibility, leases/backlog, publication invariants, and clock
    455   skew without leaking protected details.
    456 - Step 211 freezes the exact fifteen-check doctor inventory, its ordered
    457   per-check deadlines and safe remediation codes, the `pass`, `degraded`, and
    458   `fail` aggregate meanings, and process exit codes zero through six. A required
    459   skipped result is failure; required failure or timeout is exit six; optional
    460   non-pass is degraded success. Dropping a timed-out probe future must stop its
    461   work or leave cleanup owned synchronously by that future, with no detached
    462   probe task. Keep paths, raw errors, arbitrary summaries, and protected values
    463   out of the bounded canonical report and process diagnostics.
    464 - Step 214 freezes the failure-resilience qualification corpus across bounded
    465   resources and backlogs, durable state and disk posture, corruption and
    466   malformed history, cancellation and outage recovery, and safe errors. Keep
    467   every named component vector executable and bind shared durability evidence
    468   to the exact retained Lib source lock. Do not add a second SQLite authority,
    469   a production failpoint surface, or a test environment selector. Step 215
    470   alone owns actual-process and bounded-soak qualification; Steps 216 and 217
    471   own native release evidence and promotion respectively.
    472 - Step 215 closes wave `130-c` with the actual RHI executable. Keep the process
    473   corpus loopback-only, deadline- and output-bounded, and free of production
    474   failpoints or environment-selected test behavior. Every daemon must be
    475   interrupted, joined, and reaped; every admin socket must be absent after
    476   shutdown; and the durable state must verify after every one of the exact
    477   bounded reopen-soak iterations. Step 216 owns native release artifacts, and
    478   Step 217 alone owns promotion and parent-pin alignment.
    479 - Keep plaintext keys, decrypted identity, wrapping credentials, tokens, raw
    480   sensitive evidence, private identifiers, paths, upstream errors, and
    481   equivalent protected material out of config, logs, status, metrics, audit,
    482   fixtures, packages, process arguments, environment contracts, error strings,
    483   and backups. Governed state backups contain neither the encrypted identity
    484   envelope nor any material needed to unwrap it.
    485 - Backup and restore must preserve writer-lock, manifest, digest, integrity,
    486   schema, service, instance, identity, policy, permission, fsync, atomic-rename,
    487   and protected-material-exclusion invariants. Orphaned or impossible state
    488   fails closed or enters an explicitly safe repair-required state; never delete
    489   or guess it silently.
    490 
    491 ## 9. Rust and test discipline
    492 
    493 - The current stable compiler and MSRV are exact Rust 1.99.0, edition 2024
    494   and resolver 3. Keep package minimums, `rust-toolchain.toml` and Cargo metadata
    495   in exact agreement. Preserve original compiler identities in frozen release
    496   history and dedicated nightly tooling. A current minimum change does not
    497   qualify old source-lock, artifact or acquisition descriptors for a new
    498   candidate; update and verify those through their owning producers first.
    499 - Keep `#![forbid(unsafe_code)]` at crate roots; unsafe code is forbidden. Deny
    500   broken rustdoc links, `dbg!`, `todo!`, and `unimplemented!` in production.
    501 - Prefer pure transformations, explicit state machines, validated newtypes,
    502   tagged serialized enums, narrow side-effect boundaries, and private or
    503   `pub(crate)` visibility.
    504 - Keep every implementation module private and expose intended library names
    505   only through the curated crate root. Regenerate and byte-compare
    506   `contracts/api_baselines/rhi.txt` whenever that public surface changes.
    507 - Public errors must use RHI-owned stable classifications with redacted
    508   Display and Debug output and no raw dependency-owned source chain.
    509 - Use `thiserror` for library/domain errors and `anyhow` only at binary, xtask,
    510   or one-shot composition boundaries. Avoid production `unwrap`/`expect` and
    511   environment-dependent `Default`; ordinary `Debug` must never expose secrets.
    512 - Add deterministic positive, negative, exact-boundary, just-over, permutation,
    513   concurrency, crash/retry, cancellation, saturation, redaction, and public-wire
    514   interoperability tests for every behavior change. Tests must not depend on
    515   ambient network or machine-specific state and must contain no real secrets,
    516   realistic private keys, or sensitive evidence.
    517 - Bound every input, adapter result, queue, pool, worker, lease, retry, query,
    518   response, deadline, backlog, retention set, and in-memory collection.
    519 - Treat generated files as generated. Update them through the owning command
    520   and run the corresponding freshness check.
    521 - Keep the native release generator private to `tools/xtask`. It may read
    522   only an exact clean committed capsule revision and must write only one
    523   caller-selected external output directory using the closed inventory in
    524   `contracts/services_hardening/native_release.v1.json`. It must retain
    525   bounded streaming I/O, deterministic archives, exact mode and durability
    526   checks, protected-material scanning, and stable path-free errors.
    527 - Standalone package material may include the fixed systemd instance unit,
    528   config example/schema, native binary/source archives, SBOM, notices,
    529   provenance input, source lock, checksums, and manifest. It must not include
    530   parent-owned human docs, credentials, Nix or OCI inputs/outputs, private
    531   harnesses, signatures, tags, publication, deployment, or generated artifacts
    532   in the source tree.
    533 - RCLD-RSHR-150 Step 227 owns the fixed standalone systemd unit and
    534   `systemd_qualification.v1.json`. Keep the canonical service-host directory
    535   directives, stable exit-code restart split, bounded stop, empty capability
    536   sets, no environment-carried credentials, systemd 252 minimum, and maximum
    537   offline exposure 3.0 exact. The Linux verifier must fail closed when
    538   `systemd-analyze` is absent. Do not enable compatibility-sensitive
    539   `MemoryDenyWriteExecute` or syscall filters until the Step 229 integration
    540   wave proves them against the real binary; do not install, enable, start, or
    541   deploy a production service here.
    542 
    543 ## 10. Canonical verification
    544 
    545 Through RCLD-RSHR-170, run the standalone native command authority through
    546 extbuild. Do not install, repair, invoke, or require Nix, and do not claim Nix,
    547 NixOS-module, or Nix-produced OCI qualification:
    548 
    549 ```text
    550 cargo extbuild doctor
    551 cargo extbuild run -- cargo fmt --all --check
    552 cargo extbuild run -- cargo check --workspace --all-targets --locked
    553 cargo extbuild run -- cargo test --workspace --all-targets --locked
    554 cargo extbuild run -- cargo clippy --workspace --all-targets --locked -- -D warnings
    555 cargo extbuild run -- env RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps --locked
    556 cargo extbuild run -- ./scripts/verify-boundaries.sh
    557 cargo extbuild run -- ./scripts/verify-supply-chain.sh
    558 cargo extbuild run -- ./scripts/verify-systemd.sh
    559 cargo extbuild run -- ./scripts/release-acceptance.sh
    560 ```
    561 
    562 The supply-chain gate requires exact cargo-deny 0.19.8 and cargo-vet 0.10.2,
    563 the checked-in exemption inventory, the locked graph, approved licenses and
    564 sources, and only the explicitly justified Nostr 0.44 advisories. Exemptions
    565 are visible accepted review debt, not claims of independent source audits.
    566 The complete release contract also requires locked all-target check and test
    567 with serialized tests, warnings-denied all-target Clippy, warnings-denied
    568 rustdoc, the source-lock and package-boundary tests, and diff hygiene. Run
    569 additional coverage, SQLx freshness, source-lock, package, systemd, SBOM,
    570 checksum, notice, and fresh-install gates when their surfaces change. Nix and
    571 OCI remain deferred and unclaimed through RCLD-RSHR-170. Use narrower commands
    572 only for iteration, and never claim a command passed unless it ran
    573 successfully.
    574 
    575 ## 11. Commits and irreversible actions
    576 
    577 - Format commits as `<scope>: <imperative summary>`, with a blank line and
    578   `- ` bullets when a body is useful. Split unrelated changes.
    579 - Report the exact files changed, behavior changed, commands run, results,
    580   unresolved risks, and whether the next checkpoint is safe.
    581 - Do not publish, push, tag, sign, deploy, rotate credentials, change ownership,
    582   or mutate external runtime state without explicit authorization for that exact
    583   action.