myc

Self-custodial remote signer for Radroots apps
git clone https://radroots.dev/git/myc.git
Log | Files | Refs | README | LICENSE

README (36604B)


      1 # mycorrhiza
      2 
      3 This is the README for `myc` which provides a Nostr remote signer for
      4 standalone and application-embedded clients.
      5 
      6 ## Public API boundary
      7 
      8 The library exposes one curated crate-root API. All implementation modules are
      9 private, and public errors use Myc-owned stable classifications with redacted
     10 diagnostics and no raw dependency-owned source chain. The shared runtime-path,
     11 service-SQLite, and storage identity values that appear in signatures are
     12 intentional governed contract types; raw SQLx, provider, transport, Serde, and
     13 task authority never crosses this boundary.
     14 
     15 The runtime foundation is sealed and cannot be forged or reached through a
     16 child module:
     17 
     18 ```compile_fail
     19 use myc::runtime_foundation::MycRuntimeFoundation;
     20 
     21 fn forge(_: MycRuntimeFoundation) {}
     22 ```
     23 
     24 The reviewed all-features surface is frozen in the
     25 [Myc API baseline](contracts/api_baselines/myc.txt).
     26 
     27 Status publication and cached snapshots can be obtained only through the
     28 validated factory and its sealed handles:
     29 
     30 ```compile_fail
     31 use myc::{MycStatusPublisher, MycStatusSnapshot};
     32 
     33 let _publisher = MycStatusPublisher {};
     34 let _snapshot = MycStatusSnapshot {};
     35 ```
     36 
     37 The native package, artifact, and dependency-trust boundary is frozen by
     38 `contracts/services_hardening/native_release.v4.json`. Linux x86_64 and
     39 aarch64 are the only admitted native artifact targets. `cargo xtask
     40 native-release` consumes an exact prebuilt target binary from a clean Git head
     41 and deterministically writes or checks the complete binary/source archive,
     42 systemd, configuration, source-lock, SBOM, notices, checksum, manifest, and
     43 unsigned provenance inventory outside the source tree. The source archive
     44 vendors the exact locked Cargo graph and proves an offline metadata read before
     45 packaging. Signing credentials and parent-owned human documentation are never
     46 inputs.
     47 
     48 The standalone Linux systemd boundary is frozen by
     49 `contracts/services_hardening/systemd_qualification.v1.json` and checked by
     50 `scripts/verify-systemd.sh`. The instance unit uses the canonical service-host
     51 paths, fixed unprivileged account, restrictive directory modes and umask,
     52 fixed restart delay, bounded stop behavior, empty capabilities, no environment-based secret
     53 input, and the reviewed filesystem, kernel, namespace, process, and address-
     54 family protections. The Linux-only verifier requires systemd 252 or newer,
     55 runs syntax verification, and rejects an offline security exposure above 3.0.
     56 Type `simple` remains deliberate: readiness is the cached CLI/admin contract,
     57 not `sd_notify`. Compatibility-sensitive `MemoryDenyWriteExecute` and syscall
     58 filters remain deferred to the Step 229 integration wave rather than being
     59 enabled without real-binary evidence. This qualification does not install,
     60 enable, start, stop, or deploy a production service.
     61 
     62 The canonical service source lock binds the exact active public Lib cohort,
     63 Cargo lock, verified Lib source archive, toolchain, feature profile, and
     64 service contract versions. Source-lock V4 binds the public flake lock to the
     65 same exact Lib revision as Cargo and requires Rust 1.99.0. Its Nix material is
     66 bound input, with current macOS aarch64 and Linux x86_64 execution evidence
     67 required separately. Historical V2/V3 declarations and the archived V3 lock
     68 retain their original scope. NixOS/OCI artifacts, signing, tags, release
     69 publication, deployment and production activation are not established by
     70 these preparation declarations.
     71 
     72 ## Hardened v1 configuration contract
     73 
     74 The target service configuration is frozen by
     75 `contracts/services_hardening/config.v1.schema.json` and the canonical
     76 non-secret `config.v1.example.toml`. It is one strict, immutable TOML document
     77 with explicit identity, relay, authorization, rate, and discovery authority.
     78 Only reviewed bounded operational leaves have defaults. Bootstrap profile,
     79 instance, repo-local root, and config-path selection are CLI concerns and are
     80 not document fields.
     81 
     82 The hardened CLI parser admits the common command tree in one parse. It
     83 requires explicit `--profile <service-host|interactive|repo-local>` and
     84 `--instance <validated-instance-id>` selectors, requires an absolute
     85 `--repo-local-root` only for `repo-local`, and accepts only an optional absolute
     86 `--config` path. Its exact command inventory is `run`; `config
     87 init|validate|show|schema|apply`; `state init|status|backup|restore|verify|migrate`;
     88 `identity init|status|export-public`; `status`; and `doctor`. Identity rotation
     89 is an offline create-new/config-apply lifecycle and is intentionally absent
     90 from the live CLI and Unix-admin inventories.
     91 The process binary uses only this parser and consumes its sealed execution plan
     92 exactly once. Every command reaches its governed config, state, identity,
     93 Unix-admin, doctor, or daemon authority. `run` installs the authoritative
     94 bounded daemon graph; no admitted command can return success through a
     95 prototype or unavailable-operation fallback.
     96 
     97 The selected absolute config path is opened no-follow through its retained
     98 parent descriptor. The loader requires a regular, single-link,
     99 effective-user-owned file with no group/other-write permission, caps bytes
    100 before parsing, and revalidates device, inode, length, and parent identity after
    101 the read. Config initialization consumes bounded non-secret TOML from stdin and
    102 uses create-new `0600` persistence plus file and parent synchronization. Secret
    103 identity provisioning is a separate fixed 117-byte zeroizing stdin document;
    104 secret arguments, environment values, JSON strings, and trailing bytes are not
    105 accepted.
    106 
    107 One binary-owned Tokio runtime is created from the validated fixed thread
    108 limits for each asynchronous command process; there is no CPU-derived default
    109 or library-owned runtime. Existing-state commands discover actual metadata
    110 through the retained shared intent. Offline backup writes the exact canonical
    111 manifest bytes to stdout without a trailing newline, so direct redirection
    112 preserves the bytes bound by its digest. Restore derives expected backup identity
    113 from the trusted manifest digest rather than requiring the damaged live
    114 database to open, and exclusive commands retain the writer-authority boundary.
    115 Deployment directory provisioning remains outside the service executable.
    116 
    117 The parsed invocation is projected once into a sealed execution plan. `run`
    118 selects daemon authority; config, exclusive state/identity provisioning, and
    119 doctor select offline authority; state/identity/service inspection and live
    120 mutations select the permissioned Unix-admin authority. Only explicitly
    121 read-only status, backup, and public-identity operations may fall back when a
    122 later executor proves the daemon writer lock is free. No live plan carries
    123 SQLite authority.
    124 
    125 The active doctor boundary executes the exact 13-check operator inventory in
    126 contract order under fixed per-check deadlines. Check implementations retain
    127 their filesystem, SQLite, provider, bind, network, relay, and clock authority;
    128 only closed pass/fail/skipped observations cross into the report builder. The
    129 builder enforces required-check semantics, returns exit 6 for required failure
    130 or timeout, and emits at most 8,192 bytes of compact canonical JSON using only
    131 fixed summaries and remediation codes. Raw errors, paths, relay URLs,
    132 credentials, public keys, and arbitrary detail strings cannot enter the report.
    133 A pass requires every machine-listed scope facet. Probe futures own their work,
    134 must stop safely when dropped at deadline, and may not detach later mutation.
    135 The production adapter composes secure path and disk inspection, writer-lock
    136 and SQLite authorities, exact schema and outbox checks, provider opening and
    137 Describe verification, validated bind/network policy, and bounded required-
    138 relay reads. It never publishes a relay event. Clock skew remains the sole
    139 optional `Skipped` check until a trusted time source is governed.
    140 
    141 The service status boundary uses the shared service-host lifecycle contract
    142 behind one Myc-owned non-clone publisher and cloneable passive readers. Each
    143 publication validates the lifecycle transition and encodes the complete
    144 bounded `service_status_v1` payload before atomically replacing the single
    145 retained immutable snapshot. Repeated reads return that exact cached value and
    146 perform no SQLite, provider, relay, credential, DNS, clock, filesystem, or
    147 fresh-probe work. Connection counts use the closed pending/active/denied/
    148 expired vocabulary, identity health uses the fixed transport/user/discovery
    149 roles, failed publication preserves the last valid snapshot, and detailed
    150 status remains local to the permissioned Unix-admin surface. Status reason
    151 codes use a closed twelve-value vocabulary; arbitrary strings cannot enter the
    152 cached response.
    153 
    154 The optional TCP operations adapter consumes that same supervisor publication
    155 through a second passive bounded projection and delegates the transport to the
    156 source-locked service-host server. It exposes exactly HTTP/1.1 `GET /livez`,
    157 `GET /readyz`, and `GET /metrics`; every other method, path, or query is
    158 unrouteable. The two Prometheus families are the cached phase and cached
    159 readiness bit with only the closed phase label. Requests perform no SQLite,
    160 filesystem, provider, relay, credential, DNS, or fresh-probe work; the shared
    161 transport still reads its monotonic deadline clock.
    162 Detailed status, configuration, paths, identities, connection/audit data, and
    163 all mutations remain on the permissioned Unix-admin surface. The listener is
    164 disabled unless the validated configuration explicitly enables and binds it,
    165 and its parser floor, headers, response, concurrency, deadline, and idle bounds
    166 remain enforced by the shared server.
    167 
    168 Process outcomes use one exact seven-value vocabulary with exit codes 0
    169 through 6. Diagnostics are compact single-line JSON on stderr; result data is
    170 reserved for stdout, and Myc never writes log files. The structured record
    171 admits only the closed level, event, result, lifecycle, task-failure, and signal
    172 codes. It accepts no caller text, path, SQL, raw cause, identity, relay URL,
    173 credential, secret, or decrypted content. Every public Myc error remains a
    174 crate-owned source-free classification, so ordinary `Display`, `Debug`, and
    175 whole-chain traversal cannot bypass redaction. Current binary dispatch reports
    176 invalid input as exit 2 and service dependency unavailability as exit 3. The
    177 Myc runtime owns one sealed, bounded critical-task graph over the shared supervisor:
    178 task error, panic, join failure, unexpected cancellation, or critical success
    179 before cancellation coordinates shutdown, joins every task, and maps to the
    180 fixed nonzero process result. Tasks receive only a cooperative cancellation
    181 observer; task names and handles remain internal. The binary owns signal
    182 installation. The graph uses one configured absolute graceful-shutdown deadline
    183 for mutation rejection, ingress and operations drain,
    184 recoverable-work persistence, network and SQLite close, and socket close; it
    185 adds no hidden second cleanup budget.
    186 
    187 `parse_myc_config_v1` caps original bytes before decoding, checks the schema
    188 header before closed contract admission, rejects duplicate, null, unknown, and
    189 semantically inconsistent input, and returns an immutable document plus a
    190 deterministic redacted effective-configuration projection. Every projected
    191 leaf records whether it came from the document or one of the exact governed
    192 default authorities. Ordinary errors and `Debug` output contain no source
    193 text, paths, credentials, relay URLs, or identity values.
    194 
    195 The prototype environment loader, `.env` example, environment selectors,
    196 implicit command/profile selection, compatibility aliases, and arbitrary leaf
    197 flags have been removed. Bootstrap now resolves a sealed runtime context from
    198 the validated CLI profile and typed instance ID through the source-locked
    199 `radroots_runtime_paths` authority. Config, state, cache, logs, run, secrets,
    200 `config.toml`, `state.sqlite`, `state.lock`, and `admin.sock` are derived under
    201 the exact `services/myc/<instance>` namespace. The service contains no local
    202 host-environment resolver, worker namespace, ambient selector, or implicit
    203 path default. An explicit absolute `--config` may select the document to read
    204 without changing the canonical common artifact inventory.
    205 
    206 ## Governed state boundary
    207 
    208 Create-new initialization reserves the shared schema-v1 metadata and migration
    209 ledger, retains exclusive writer authority, applies the exact Myc schema-v2
    210 through schema-v12 migrations, binds the normalized configuration, expected
    211 identity roles, and policy versions through a sealed typed repository, and
    212 explicitly closes the host before reporting success. Existing writable open can
    213 resume any exact v1 through v11 prefix or admit the current v12 catalog;
    214 read-only inspection requires the current catalog and exact latest Myc binding.
    215 
    216 Schema v10 adds an append-only configuration-binding history capped at exactly
    217 1,024 generations. Generation 1 is seeded only after the v10 migration commits,
    218 including for an upgraded v9 database, while the immutable original birth
    219 record remains unchanged. `apply_configuration` is admitted only through an
    220 exclusive writable host and independently validates the retained current and
    221 candidate documents before one atomic append. A changed identity expires live
    222 sessions and pending challenges; permission narrowing expires only sessions
    223 whose retained grants are removed. Removing or changing a relay that is still
    224 referenced by nonterminal delivery work fails closed, while safe relay additions
    225 remain admissible. Exact replay returns the retained generation without another
    226 append or revocation, including after an ambiguous caller result. Future startup
    227 must present the latest normalized config and public-identity binding. The
    228 history stores only digests, public identities,
    229 closed contract versions, injected application evidence, and safe build
    230 identity; it stores no credentials, provider envelopes, paths, or relay URLs.
    231 
    232 Schema v11 adds the bounded admin-operation journal. It binds each mutation's
    233 validated operation ID to its fixed route and canonical request digest, retains
    234 at most 128 unresolved Prepared records and 4,096 completed responses, caps a
    235 replayed response model at 8,192 bytes, and prunes only a bounded expired
    236 completed prefix before admission. The journal stores no request body, path,
    237 correlation ID, credential, bundle path, or secret. Completed responses use an
    238 explicit retention policy whose admitted range is 1 through 31,536,000,000
    239 milliseconds; the governed operating value is seven days.
    240 The admin response transport admits at least 8,382 UTF-8 bytes so the maximum
    241 retained model plus the maximum safe correlation identity always fits its
    242 canonical success envelope.
    243 
    244 Schema v12 adds immutable response authority for a connect request awaiting
    245 explicit approval. Myc signs and atomically retains the exact
    246 `pending_connection` response with its initial delivery job before relay
    247 publication, without recording a false terminal operation completion. Exact
    248 replay and delivery use only the retained signed bytes, and a later terminal
    249 response cannot conflict with the pending authority.
    250 
    251 The Step 159 provider and delivery boundary is sealed inside the crate. Both
    252 governed provider kinds execute only fully bound operations, and every result
    253 is independently verified before it becomes authority. Protected blocking
    254 work is joined, local-signer calls use the hardened Unix-admin client, and no
    255 raw provider client, secret, callback, or dependency-owned error crosses the
    256 public API.
    257 
    258 Relay publication uses only the exact source-locked
    259 `radroots_transport_nostr` adapter. Preparation validates the exact committed,
    260 signature-verified event bytes without network I/O. The delivery worker then
    261 persists Submitted immediately before execution. Accepted, rejected,
    262 transport-failed, and unknown acknowledgements remain distinct; cancellation
    263 or lost acknowledgement after Submitted is durably unknown, and retries never
    264 alter the committed bytes. Provider or relay work never occurs inside a SQLite
    265 transaction. The secure command executor and production daemon graph use these
    266 same provider, relay, and exact-byte delivery boundaries.
    267 
    268 The production `run` path owns the exact five-role bounded graph:
    269 `admin_server`, optional `operations_server`, `relay_ingress`,
    270 `provider_dispatch`, and `delivery_outbox`. It creates no task per request or
    271 relay. Required relay subscriptions and provider handshakes complete before
    272 Ready; bounded reconnect publishes Unready when a required dependency is lost,
    273 while optional operations loss publishes Degraded. NIP-46 dispatch verifies,
    274 decrypts, admits, authorizes, executes providers outside transactions,
    275 re-encrypts in the verified request context, signs through the transport provider,
    276 and atomically commits completion, exact response bytes, immutable targets,
    277 and initial outbox state. Completed replay never re-executes a provider.
    278 
    279 Schema v8 adds immutable NIP-46 operation-completion evidence. The Step 147
    280 integration checkpoint binds each durable request to its stable operation and
    281 correlation identities, terminal connect authority or exact active session,
    282 safe completion reason, and any independently verified inner signed-event
    283 bytes and digest. Logout revocation and completion insertion share one
    284 transaction, exact replay returns the stored decision, and failed transactions
    285 expose neither effect. Protected provider output is never persisted. This is an
    286 integration component, not the final production response boundary: Step 148
    287 must compose it with the outer signed response bytes, immutable relay targets,
    288 and initial outbox state in one transaction before RCLD-RSHR-080 can be
    289 promoted to `master`.
    290 
    291 Schema v9 closes that production boundary. `commit_nip46_response` admits only
    292 an independently signature-verified, canonical kind-24133 response bound to the
    293 original client and exact provider signing operation. One SQLite transaction
    294 commits the Step 147 completion, exact response bytes and SHA-256 identity,
    295 immutable configured relay targets, pending delivery job, and zero-attempt
    296 target state. Exact replay returns only the retained response bytes; partial
    297 legacy completion state and mismatched replay fail closed. Provider execution
    298 and relay I/O remain outside the transaction.
    299 
    300 Step 149 closes the repository-owned delivery recovery boundary without
    301 claiming the final daemon task graph. New jobs can be created only by the
    302 atomic signed-response or discovery commit and are rejected at the configured
    303 active-outbox ceiling. Attempt resolution persists caller-injected,
    304 attempt-cap-bounded full jitter; restart recovery scans fixed 128-job cursor
    305 batches, revalidates exact signed source bytes and bounded attempt histories,
    306 recovers only expired leases, and idempotently promotes proven desired
    307 discovery. It performs no relay I/O and creates no task, clock, or entropy
    308 authority. Explicit desired/current offline NIP-05 export re-reads verified
    309 state, works through read-only inspection, and returns canonical compact
    310 `names` plus NIP-46 discovery JSON without hosting it.
    311 
    312 The implemented v1 Myc administration adapter registers the exact 19-route
    313 inventory and validates every request and response against all 32 model
    314 references in `contracts/services_hardening/operator_contract.v1.json`. It
    315 reuses the hardened Lib HTTP/1.1-over-Unix server for original-wire duplicate
    316 and null rejection, percent-decoded bounded path parameters, peer admission,
    317 deadlines, concurrency, body limits, and effective correlation IDs. The Myc
    318 boundary additionally rejects unknown or missing model fields, invalid query
    319 types, noncanonical response JSON, unsafe URLs and identifiers, and response
    320 model drift. Raw shared-host routers and JSON values never cross the public
    321 API.
    322 
    323 The domain handler receives compact canonical model bytes plus the durable
    324 operation ID. A successful mutation means its contract-defined local effect
    325 and operation audit are committed; it does not claim relay submission or
    326 delivery. Identical operation-ID reuse must return the original committed
    327 result, different-byte reuse returns `operation_id_conflict`, and pagination
    328 cursors remain authenticated to the same route, filters, and snapshot. Unit 13
    329 seals that handler boundary inside the production `MycAdminServer`,
    330 projects the exact admitted admin transport limits, and binds only the
    331 canonical permissioned `admin.sock` through the shared host authority. The raw
    332 router, listener, entropy source, and cancellation token remain private. The
    333 existing sole status publisher feeds both detailed local status and the
    334 optional passive three-route TCP operations server, while doctor continues to
    335 accept only its exact injected 13-check probe inventory. Unit 14 supplies the
    336 secure CLI/config bootstrap and concrete doctor probes. Unit 15 alone owns task
    337 spawning, provider/relay wiring, readiness, reconnect, and phase-aware
    338 shutdown.
    339 
    340 The transport capability and admitted request remain non-forgeable outside
    341 the crate:
    342 
    343 ```compile_fail
    344 use myc::{MycAdminRequestDocument, MycAdminRouter};
    345 
    346 let _request = MycAdminRequestDocument {};
    347 let _router = MycAdminRouter {};
    348 ```
    349 
    350 The public Myc repository exposes no raw pool, connection, transaction-control
    351 handle, path, or SQL. Binding and request-admission mutations execute only
    352 inside the shared `ServiceSqliteTransaction` runner. Provider and relay work
    353 cannot occur inside that transaction boundary. The v2 binding table, v3
    354 request/dedup tables, and v4 connection, permission, request-decision, and
    355 authorization-challenge tables and guards are checksum-pinned service-owned
    356 schema objects. Schema v5 adds checksum-pinned audit-sequence, safe operation
    357 audit, request-audit binding, and bounded rate-window objects. Schema v6 adds
    358 checksum-pinned publication-job, target, attempt, transition-guard, and
    359 no-delete objects. Schema v7 adds desired/current discovery state, exact signed
    360 NIP-89 event bytes, deterministic NIP-05 projection inputs, and their delivery
    361 binding.
    362 
    363 The earlier JSON signer store, JSONL audit log, separate signer/audit/outbox
    364 SQLite databases, prototype import/backup adapter, independent migration
    365 directories, and their runtime/operability consumers have been removed. The
    366 only authoritative service-state database is the canonical `state.sqlite` and
    367 the only writer authority is its retained `state.lock`; there is no backend
    368 selection, compatibility reader, prototype importer, or secondary migration
    369 engine.
    370 
    371 The side-effect-free signer-provider contract admits exactly `encrypted_file`
    372 and `local_signer` assignments for the explicit transport, user, and optional
    373 discovery roles. It freezes the seven-operation capability vocabulary, exact
    374 role requirements, stable provider-instance/operation/correlation identities,
    375 absolute deadlines, bounded semantic input and untrusted output, local-signer
    376 resource limits, and logical credential references. Construction derives from
    377 the already admitted v1 configuration, exposes no provider path or secret in
    378 ordinary Debug, and performs no filesystem, credential, socket, clock, task,
    379 or cryptographic work. Envelope execution, credential resolution, Unix-socket
    380 transport, and independent result verification remain later checkpoints.
    381 
    382 The encrypted-file provider now uses the source-locked `radroots_secrets` v2
    383 context-bound envelope behind a sealed Myc boundary. Offline provisioning
    384 requires explicit identity, data-key, envelope-nonce, and wrapping-nonce
    385 material; verifies the derived public key before persistence; and creates one
    386 owner-only envelope without overwrite. Existing reads are bounded, no-follow,
    387 single-link, owner-only, context/reference checked, and independently verify
    388 the decrypted public key against the configured role identity. Protected
    389 material is zeroizing and absent from diagnostics. The service-state backup
    390 inventory remains exactly `state.sqlite`: encrypted identity envelopes,
    391 wrapping credentials, and plaintext identity material are excluded. Canonical
    392 credential artifact resolution remains Step 133 and ordinary run never
    393 provisions an identity.
    394 
    395 Wrapping credentials now resolve only from the shared validated
    396 `ServiceCredentialArtifactName` beneath the sealed runtime context's canonical
    397 instance secrets root. The resolver accepts no path or credential bytes and
    398 reads only an existing exact 32-byte, euid-owned, single-link artifact through
    399 descriptor-relative no-follow admission. Service-host deployments inject or
    400 mount that fixed file; repo-local developers provision it offline. Interactive
    401 resolution is unsupported, and TOML, environment, process arguments, adjacent
    402 envelope files, ordinary run, and state backup neither carry nor create the
    403 credential.
    404 
    405 Local-signer calls use the source-locked hardened Lib administration client for
    406 strict HTTP/1.1 JSON over the configured Unix socket. One fixed
    407 `/v1/provider/operation` endpoint carries a closed internally tagged operation
    408 and result plus exact provider instance, role, operation/correlation IDs,
    409 absolute deadline, expected identity, capability, and contract version. The
    410 validated binding supplies body, deadline, and per-client concurrency limits.
    411 Transport success remains sealed and semantically untrusted until independent
    412 Step 135 verification; cancellation does not prove the signer had no effect,
    413 and signing is never publication. No TCP, browser origin, or child process is
    414 part of this boundary.
    415 
    416 Independent provider verification uses injected completion time and rejects a
    417 late result before semantic exposure. It rebinds the configured role,
    418 instance, identity, operation/correlation IDs, deadline, capability, NIP peer,
    419 direction, and version. Describe/public-identity results must match the
    420 configured identity and limits; signed Nostr events must preserve the exact
    421 canonical unsigned fields, pass event-ID and Schnorr verification, and retain
    422 the exact verified canonical response bytes; NIP-04 and NIP-44 ciphertext must
    423 have canonical protocol shape and exact padding length where the plaintext is
    424 known. NIP-44 v2 plaintext is admitted only through its exact 65,408-byte
    425 implementation ceiling. Verified output remains sealed and redacted, and
    426 neither verification nor signing constitutes publication.
    427 
    428 The obsolete prototype provider tree has been removed. Myc ships no account
    429 keyring, managed-account selector, plaintext or adjacent-key file adapter,
    430 child-process signer, implicit host identity, generic remote-session signer,
    431 or legacy logging/client wrapper. Its removed production dependencies and
    432 Tokio process capability are absent from the locked graph; the active typed
    433 provider contract, encrypted envelope, credential resolver, local-signer
    434 transport, and independent verifier are the only provider boundaries.
    435 
    436 The existing-only runtime foundation owns the writable state host, retained
    437 provider capabilities, and a shared Lib task supervisor. Encrypted-file
    438 identities open only in synchronously joined one-shot startup tasks;
    439 local-signer clients perform no construction-time I/O and remain unready until
    440 their later governed handshake. A passive closed prerequisite snapshot keeps
    441 state, providers, recovery, required relays, admin, and optional operations
    442 conditions explicit without claiming the later status cache or final daemon
    443 task graph.
    444 
    445 Signer-request admission validates bounded client, request, event, method,
    446 canonical request, injected operation entropy, and injected time evidence
    447 before storage. Stable domain-separated operation and correlation identities
    448 bind the logical client request to its persisted entropy evidence. Event
    449 identity and logical request identity retain distinct durable deduplication
    450 records, so an exact replay is idempotent while event or request reuse with
    451 different normalized content records a conflict without retaining the
    452 decrypted request bytes. Replay and conflict counters are bounded and
    453 survive explicit close and reopen; retention remains owned by its later state
    454 checkpoint.
    455 
    456 Connection admission consumes an already-admitted `connect` operation and an
    457 explicit policy generation. Trusted admission creates an active connection;
    458 explicit approval creates a pending connection that can transition once to an
    459 operator-approved or operator-denied terminal decision; direct policy denial
    460 records a durable decision without creating a connection or approval workflow.
    461 Requested and granted permissions are closed, bounded, and independently
    462 bound. Authorization challenges are issued only for a non-connect operation
    463 bound to an active connection, use an operator-owned canonical URL plus
    464 injected entropy and time, and transition once to authorized or expired.
    465 Exact retries return the original durable identity or terminal state, including
    466 after explicit close and reopen.
    467 
    468 Connection admission uses one bounded global window plus one configured relay
    469 window, so arbitrary client keys cannot create persistent subjects before a
    470 connection exists. Challenge creation and authorization use distinct stable
    471 connection-scoped windows. Exact saturation creates no connection, decision,
    472 challenge, or authorization transition beyond the accepted bound, and a
    473 retained rate rejection is replay-stable. Safe audit records preserve exact
    474 typed operation/correlation bindings and use closed category, outcome, and
    475 reason vocabularies; snapshot pagination is bounded and Debug output redacts
    476 identity. Explicit bounded compaction is correlation-idempotent and retires
    477 only expired rate-window and old safe-audit evidence. It never removes schema
    478 history, metadata, connections, decisions, permissions, or challenges.
    479 
    480 Delivery admission copies the exact normalized write-relay inventory,
    481 required-target flags, acknowledgement policy, retry ceiling, backoff, and
    482 attempt deadline into one immutable publication job. Target leases and attempt
    483 records are advanced only through the shared transaction runner; relay I/O is
    484 never awaited while a transaction is open. Exact retries are idempotent, stale
    485 leases recover through injected time evidence, and an acknowledgement whose
    486 outcome is not known remains `unknown` rather than being relabeled as failure
    487 or delivery. This checkpoint binds an artifact digest and precommit identity;
    488 the exact committed signed-event bytes and discovery projection are owned by
    489 their subsequent state checkpoints.
    490 
    491 Discovery desired state is committed atomically with signature-verified,
    492 canonical NIP-89 event bytes, deterministic NIP-05 projection inputs, the
    493 immutable relay targets, and the initial delivery job. The desired generation
    494 may advance independently, while current generation advances only after the
    495 corresponding desired job has proven the configured delivery policy. Restart
    496 reads return the same committed event bytes and projection inputs; publication
    497 and hosted NIP-05 responses remain later runtime concerns and never run inside
    498 the SQLite transaction.
    499 
    500 Explicit state initialization validates runtime identity, build evidence, and
    501 the complete migration/schema catalogs before invoking the runtime-path
    502 directory plan. That plan alone may provision the exact interactive
    503 `services/myc/<instance>` suffix; service-host deployment roots and suffixes
    504 must already exist. The shared service-SQLite initializer owns the one
    505 transaction and exposes only its sealed typed SQLx executor. Existing writable
    506 and inspection opens never provision directories or create missing state.
    507 
    508 Writable hosts expose Myc-bound online-backup and active-integrity operations.
    509 Backup verification retains the exact admitted member inode, and
    510 offline staging derives the same runtime paths, database identity, migration
    511 catalog, and schema catalog from sealed Myc evidence. Finalization returns no
    512 open host; the next writable open alone reconciles durable recovery evidence.
    513 Read-only hosts cannot capture backups, and any live host prevents offline
    514 restore authority. Cancellation, explicit close, and cleanup behavior remain
    515 owned by the source-locked shared SQLx host; Myc maps every public failure to a
    516 stable source-free classification.
    517 
    518 ## Executable qualification
    519 
    520 The Step 161 process qualification is frozen by
    521 `contracts/services_hardening/process_qualification.v1.json`. It runs the
    522 actual `myc` executable under fixed deadlines, bounded captured output, eight
    523 concurrent inspection processes, 32 deterministic reopen iterations, and one
    524 64 MiB crash fixture. External process termination exercises interrupted
    525 backup and pre-marker restore boundaries without adding a production
    526 failpoint, hidden command, environment selector, feature, or detached test
    527 worker. An interrupted backup preserves the live database and leaves explicit
    528 collision evidence. An orphan restore stage prevents admission until an
    529 operator removes the owned test fixture, while a durable replacement marker is
    530 reconciled only by the next governed writable process open.
    531 
    532 The executable corpus composes with the exact Myc component-level atomicity,
    533 backlog, saturation, recovery, property, and adversarial tests and the
    534 source-locked shared SQLx initialization, transaction, backup, close, marker,
    535 restore, and `SIGKILL` failpoint corpus named by that contract. Qualification
    536 adds no runtime authority and makes no RCLD promotion, parent-alignment, Nix,
    537 OCI, signing, publication, or deployment claim.
    538 
    539 ## NIP-46 runtime contract
    540 
    541 Myc listens for encrypted kind-24133 requests on the exact configured relay
    542 inventory. The signer transport identity authors and encrypts
    543 protocol responses; the separate user identity is returned by
    544 `get_public_key` and signs user events. Client-supplied connect metadata is a
    545 bounded, display-only hint and never changes approval, authentication, or
    546 permissions.
    547 
    548 The public approval default is `explicit_user`. Trusted and denied clients,
    549 permission ceilings, allowed signing kinds, auth challenges, relay switching,
    550 and delivery policy are represented only by the strict v1 TOML contract. A
    551 successful `logout` publishes its acknowledgement before
    552 revoking the session. Failed acknowledgement delivery remains recoverable on
    553 restart, while requests from a revoked session remain unauthorized until a new
    554 connect is approved.
    555 
    556 Myc rejects invalid signatures, wrong recipient tags, empty request IDs,
    557 malformed ciphertext, and duplicate event delivery before dispatch. Runtime
    558 state and audit output do not log client private keys or raw connection URIs.
    559 Signer-authored protocol responses use the checked generic-event boundary from
    560 `radroots_nostr`. External custody commands receive canonical unsigned-event
    561 JSON only after typed-authoring policy succeeds, and Myc accepts their result
    562 only when the author and event id match the exact request and the complete
    563 NIP-01 event verifies. Caller-supplied NIP-46 `sign_event` payloads remain a
    564 separate low-level interoperability boundary and receive the same exact-result
    565 integrity checks without acquiring a typed product-authoring claim.
    566 The production external-command executor drains stdout and stderr concurrently,
    567 enforces bounded output, applies one end-to-end timeout, kills and reaps timed
    568 out helpers, and releases Myc's multi-thread Tokio worker while waiting.
    569 Helper-provided stderr and protocol error text are never copied into operator
    570 errors.
    571 
    572 The default Cargo feature profile is `service-host`. Validate the standalone
    573 crate through extbuild:
    574 
    575 ```text
    576 cargo extbuild doctor
    577 cargo extbuild run -- ./scripts/verify-boundaries.sh
    578 cargo extbuild run -- ./scripts/verify-supply-chain.sh
    579 cargo extbuild run -- ./scripts/release-acceptance.sh
    580 ```
    581 
    582 After building one of the two admitted Linux targets, create and then
    583 byte-check an external release directory with explicit deterministic evidence:
    584 
    585 ```text
    586 cargo extbuild run -- cargo xtask native-release --mode write --target <aarch64-unknown-linux-gnu|x86_64-unknown-linux-gnu> --binary <absolute-binary> --output <absolute-new-directory> --source-date-epoch <positive-u32-seconds>
    587 cargo extbuild run -- cargo xtask native-release --mode check --target <same-target> --binary <same-absolute-binary> --output <same-absolute-directory> --source-date-epoch <same-seconds>
    588 ```
    589 
    590 The flake exposes the Myc package, application, checks, and development shell
    591 for `aarch64-darwin` and `x86_64-linux`, plus the NixOS module and unsigned OCI
    592 derivation for `x86_64-linux`. Run Nix and narrower ad hoc Cargo commands
    593 through `cargo extbuild run --` from this repository root.
    594 
    595 ## Copyright
    596 
    597 Except as otherwise noted, all files in the `myc` distribution are
    598 
    599 `Copyright (c) 2026 Tyson Lupul`
    600 
    601 ## License
    602 
    603 This repository is licensed under AGPL-3.0-or-later. See LICENSE.