Skip to content

feat: controllable boot, hc-auth, restart-keeping-lair, seed export (Phase 3)#139

Open
zippy wants to merge 1 commit into
feat/tauri-direct-admin-callsfrom
feat/tauri-direct-auth-and-restart
Open

feat: controllable boot, hc-auth, restart-keeping-lair, seed export (Phase 3)#139
zippy wants to merge 1 commit into
feat/tauri-direct-admin-callsfrom
feat/tauri-direct-auth-and-restart

Conversation

@zippy

@zippy zippy commented Jun 4, 2026

Copy link
Copy Markdown
Member

Summary

The "controllable-boot" layer for unyt-on-ASR: splits the lair keystore from the conductor so the conductor can be authenticated, restarted, and seeded under runtime control. Stacked on #138.

Status: Phase 3 / co-design. This is the deferred, co-design slice (designed with the unyt agent). Its consumer is unyt, not the ASR example — several primitives here are intentionally unexercised by ASR itself. Reviewing it now to get eyes on the design; flag if you'd rather land #136#138 first and hold this.

What's in it

  • Controllable bootRuntime::new_with_boot_config(RuntimeBootConfig{ data_root_path, network, hc_auth, pending_import_seed }). Spawns lair in-proc first, optionally runs the hc-auth flow, then builds the conductor with .with_keystore(...) on that same lair. The existing new/new_with_network_config now funnel through it (no API break).
  • hc-auth (crates/runtime/src/hc_auth.rs) — get-or-create a persistent Ed25519 agent key in lair, GET /now challenge, sign via lair, PUT /authenticate → status, build base64 auth material and inject into NetworkConfig.base64_auth_material_{bootstrap,relay}. Auth-server failures return Ok(Failed(..)) so the conductor still boots.
  • Restart-keeping-lairstop_conductor_only (disables apps first) + restart_with_hc_auth returns a fresh Runtime on the same lair; plugin swap_runtime re-binds bound windows' signal forwarders to it.
  • Seed export / restoreexport_agent_seed (inverse of import, via export_seed_by_tag + local box-decrypt), import_seed_into_lair, device_agent_key (the device seed's ed25519 key = deterministic identity for agent-key backup/restore).
  • Deferred bootinit_deferred(config) registers the plugin without booting; the host calls HolochainPlugin::start(passphrase) / start_with_config(...) once a (possibly user-typed) lair password is collected. start_lock serializes concurrent unlocks; a failed unlock is retryable. New EVENT_LAIR_READY.

Review notes

  • New deps in the runtime crate: reqwest (rustls-tls, to match the workspace crypto stack) + base64; holochain_keystore pinned at 0.6.1 (candidate to move to a workspace dep).
  • Tests: export_agent_seed has a byte-exact round-trip test. The hc-auth HTTP flow and restart_with_hc_auth/swap_runtime are not yet covered by automated tests (would need a mock auth server).
  • hc_auth.rs is ported from the unytco tauri-plugin-holochain fork (feat/hc-auth), adapted to this crate's RuntimeError.

Test plan

  • cargo test -p holochain-conductor-runtime (includes the seed round-trip test).
  • hc-auth / restart paths to be validated against a real auth server in the unyt integration (no GL/UI needed for the runtime tests).

Phase 3 support for the unyt-on-ASR migration, on the in-process direct-mode
plugin + runtime.

- Controllable boot: init_deferred registers the plugin without booting;
  HolochainPlugin::start / start_with_config(passphrase, config) boot the
  conductor late (e.g. once a user-typed lair password is collected). The
  runtime is held behind RwLock<Option<_>>; runtime() returns an owned clone;
  new holochain://lair-ready event emitted before EVENT_READY.
- Lair-first boot: spawn lair in-proc (at the same path holochain uses for
  lair_root: None, so existing keystores are reused) and build the conductor
  with .with_keystore(..), so the hc-auth flow can sign a challenge and inject
  the auth material into the NetworkConfig before the network starts.
- hc-auth (crates/runtime/src/hc_auth.rs): GET /now -> sign via lair -> PUT
  /authenticate flow; HcAuthConfig / HcAuthStatus; runtime accessors
  hc_auth_status / hc_auth_agent_key / hc_auth_raw_ed25519_b64url;
  HolochainPluginConfig::with_hc_auth.
- Restart-keeping-lair: stop_conductor_only + restart_with_hc_auth rebuild the
  conductor on the still-running lair; plugin swap_runtime re-binds the
  per-window signal forwarders.
- Agent identity + backup: device_agent_key() (the device seed's ed25519 key, a
  deterministic identity), export_agent_seed() (lair export_seed_by_tag + local
  decrypt), with_pending_import_seed (import as the device seed at boot),
  generate_agent_pub_key().

Adds deps: holochain_keystore, reqwest (rustls-tls), base64. Includes unit
tests for the seed export/import round-trip (incl. a byte-exact ground-truth
check) and device-key identity restore.
@cocogitto-bot

cocogitto-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown

✔️ cc73dd9 - Conventional commits check succeeded.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f86c4da4-35dc-40fc-893d-0c5351fa7f8f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/tauri-direct-auth-and-restart

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant