Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions DEV_MODE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Holochain Dev Mode

## Purpose

Dev mode is a local-development runtime profile optimized for fast restart loops.

It is not production-like and should only be used for local CRUD/testing workflows.

Core goals:

1. Remove lair/key-derivation startup cost.
2. Preserve Holochain WASM cache across restarts.
3. Reset app/conductor state each run so dev starts are reproducible.

## Activation

Dev mode is controlled by one launch-time environment variable:

```sh
HC_DEV_MODE=1
```

Truthy values are: `1`, `true`, `yes`, `on` (case-insensitive).

When `HC_DEV_MODE` is unset (or falsey), runtime uses normal mode.

## Runtime Behavior

| Area | Normal Mode | Dev Mode (`HC_DEV_MODE=1`) |
|---|---|---|
| Keystore | `LairServerInProc` | `DangerTestKeystore` |
| Device seed | `device_seed_lair_tag = "DEVICE_SEED"` | `danger_generate_throwaway_device_seed = true` |
| Conductor data root | `fs.conductor_dir()` | derived dev dir under `/tmp/conductora_dev/<hash>` |
| Signal setup at launch | policy-driven (see below) | skipped entirely (no WAN reachability check, no local signal service launch) |
| mDNS bootstrap | enabled | skipped |
| Persistent chain/app state | persisted | wiped each launch (WASM cache preserved) |

## Signal Policy

### Dev mode

At launch, dev mode does not run signal setup:

- no WAN signal host reachability check
- no local signal server startup

Conductor network config is forced to local-only placeholders:

- `signal_url = ws://127.0.0.1:1`
- `bootstrap_url = http://127.0.0.1:1`
- `target_arc_factor = 0`

This prevents accidental WAN signal usage in dev startup.

### Normal mode

Normal mode uses `signal_url_configured` intent from storage config:

- `signal_url` missing/null: attempt local signal server startup first.
- `signal_url` configured: run WAN reachability check; if unreachable and `fallback_to_lan_only=true`, attempt local signal fallback.

## Dev Data Directory Isolation

Dev data root is deterministic and derived from:

- provider name
- app id
- canonical workspace path

The helper `dev_conductor_dir(provider_name, app_id)` hashes this input and writes to:

```text
/tmp/conductora_dev/<hash>
```

This avoids a single shared global dev conductor path across clones/branches.

## Restart Wipe Strategy (Cache-Preserving)

Before conductor build in dev mode, `clean_dev_conductor_state(...)` runs.

Preserved:

- `databases/db.key`
- `databases/wasm/`
- `wasm-cache/`

Deleted:

- remaining DB/state paths (conductor/cache/dht/authored/p2p/etc.)
- other conductor state outside preserved cache artifacts

Result:

- fresh app/conductor state each run
- warm WASM cache retained for faster follow-up starts

## Expected Timing

Typical dev warm run is split into phases:

1. Conductor launch: usually around `~3-4s`.
2. Holochain setup/install path: usually around `~1.0-1.5s`.
3. UI readiness can appear later due to frontend retry backoff.

If warm start regresses, check logs first before assuming cache loss.

## Useful Logs

Set host logging to include launch debug logs:

```sh
RUST_LOG=info
# or for more detail:
RUST_LOG=holochain_runtime=debug,conductora_lib=debug
```

Key lines to watch:

- `HOLOCHAIN DEV MODE ENABLED: ...`
- `[LAUNCH] DEV MODE: skipping all signal setup ...`
- `[LAUNCH] DEV MODE: wasm DB + wasm-cache found — warm start ...`
- `[LAUNCH] DEV MODE: conductor state reset in ...`
- `[LAUNCH] Conductor ready in ...`
- `[HOLOCHAIN SETUP] App install/update done in ...`

## Notes

- `holochain_websocket` warnings like `Close("None")` are commonly seen during admin/app websocket lifecycle transitions and are not, by themselves, evidence of WAN signal use.
- Dev mode intentionally prioritizes fast local iteration over production-like network behavior.
2 changes: 1 addition & 1 deletion host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ holon_dance_builders = { path = "../shared_crates/holon_dance_builders" }
shared_validation = { path = "../shared_crates/shared_validation" }
json_schema_validation = { path = "../shared_crates/json_schema_validation" }

holochain_client = { version = "0.7.0"}
holochain_client = { version = "0.7.1"}
tauri = { version = "2", features = ["macros"] }
tauri-build = "2"
tauri-plugin-fs = "2"
Expand Down
6 changes: 3 additions & 3 deletions host/conductora/plugins/tauri-plugin-holochain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ links = "tauri-plugin-holochain"
tauri = { version = "2" }

# Holochain dependencies
holochain_types = "0.5.0"
holochain_types = "0.5"

# Lair dependencies
hc_seed_bundle = "0.3"
lair_keystore_api = "0.6.0"
lair_keystore_api = "0.6"

# Holochain client
holochain_client = "0.7.0"
holochain_client = "0.7.1"

holochain_runtime = { path = "holochain_runtime" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ sbd-server = "0.1.0"
tx5-signal = "0.3.3"

# Lair dependencies
lair_keystore_api = "0.6.0"
lair_keystore = { version = "0.6.0" }
lair_keystore_api = "=0.6.2"
lair_keystore = { version = "=0.6.2" }

# Holochain client
holochain_client = "0.7.0"
holochain_client = "0.7.1"

# Other dependencies
rustls = "0.23"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ pub struct HolochainRuntimeConfig {

/// Force the conductor to run at this admin port
pub admin_port: Option<u16>,

/// Dev mode: skip lair keystore and use an ephemeral in-memory keystore.
/// Keys are NOT persisted across restarts. Suitable only for local CRUD tests.
pub dev_mode: bool,

/// If dev mode is enabled, this is the directory where the ephemeral keystore and other
/// conductor data will be stored. If not set, a temporary directory will be used.
pub dev_data_root: Option<std::path::PathBuf>,

/// Whether `signal_url` was explicitly configured in storage config.
/// Used by launch policy to distinguish missing/null from default runtime values.
pub signal_url_configured: bool,
}

impl HolochainRuntimeConfig {
Expand All @@ -23,11 +35,30 @@ impl HolochainRuntimeConfig {
network_config,
admin_port: None,
fallback_to_lan_only: true,
dev_mode: false,
dev_data_root: None,
signal_url_configured: true,
}
}

pub fn admin_port(mut self, admin_port: u16) -> Self {
self.admin_port = Some(admin_port);
self
}

/// Enable dev mode (ephemeral DangerTestKeystore, no lair, ~instant startup).
pub fn dev_mode(mut self) -> Self {
self.dev_mode = true;
self
}

pub fn dev_data_root(mut self, path: std::path::PathBuf) -> Self {
self.dev_data_root = Some(path);
self
}

pub fn signal_url_configured(mut self, configured: bool) -> Self {
self.signal_url_configured = configured;
self
}
}
Loading
Loading