Skip to content

fix(boot): substrate refuses to lie when degraded (Slice A) - #1527

Closed
joelteply wants to merge 1 commit into
canaryfrom
e9f50a36/slice-a-reliable-startup
Closed

joelteply wants to merge 1 commit into
canaryfrom
e9f50a36/slice-a-reliable-startup

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Slice A of the post-2026-06-04 startup-reliability iteration. Three sub-fixes addressing the "substrate booted but did nothing" failure mode that ate the morning: continuum-core-server stayed alive on Joel's machine at 1166 MB RSS for 19 hours hosting zero personas because airc ipc-endpoint failed (task #79), PersonaInstanceManagerModule got silently skipped, and a single buried WARN line was the only signal.

Card: e9f50a36-0543-412f-a804-13c21e1cf2c1

A1 — hard-fail boot when (persona seeds on disk) AND (AIRC degraded)

start_server now returns Err(io::Error) instead of logging a single WARN and continuing when:

  • <continuum_root>/personas/*/seed.json exists, AND
  • AIRC discovery failed (no daemon socket or no default room)

Operator sees a clear ERROR with the actionable repair and the process exits non-zero. If NO persona seeds exist (fresh install, inference-only mode, test fixture), the substrate continues to boot — there are no citizens to fail. Boundary intentionally narrow: only hard-fails the case the substrate would otherwise lie about.

Persona-seed detection extracted as count_persona_seeds(&Path) -> usize in modules/persona_instance_manager.rs with 6 unit tests covering missing dir, empty dir, single-seed, multi-seed, persona-dir-without-seed (in-progress mint), and stray-files-at-personas-root.

A2 — ORT panic-stderr filter

Every ORT load site (fastembed preload, TTS/STT init) already wraps the ORT call in catch_unwind and sets ORT_UNAVAILABLE on failure with a clean WARN line. But Rust's DEFAULT panic hook ALSO writes the panic to stderr BEFORE catch_unwind catches it:

thread 'tokio-rt-worker' (36060772) panicked at
  /Users/.cargo/registry/src/.../ort-2.0.0-rc.11/src/lib.rs:191:41:
Failed to load ONNX Runtime dylib: Error { code: GenericFailure, ... }

That trace looks like a substrate bug. It's not — it's just "voice features not available, install libonnxruntime." The new install_ort_panic_filter (called at the top of main) installs a custom panic hook that matches BOTH location().file() containing /ort- AND payload mentioning "Failed to load ONNX Runtime". Other ORT panics (genuine inference bugs) won't match the dylib-load substring and fall through to the default hook. Non-ORT panics always fall through.

A3 — EXPECTED_MODULES current with reality

The list in runtime/runtime.rs had 22 entries. The substrate registers 38 modules. Result: 16 false "Unexpected module registered" WARN lines on every boot for load-bearing modules (airc, persona_instance_manager, persona-rag-inspect, tool-parsing, resource-broker, cargo, inference, sentinel, plasticity, ai_provider, agent, vision, forge, auth, events, pressure-broker).

Now organized by role (infrastructure, resource governance, persona substrate, AI/inference, forge/sentinel, transports, live presence) with a doc-comment explaining what drift between this list and ipc/mod.rs produces (spurious warnings or fail-boot).

End-to-end verified (real binary, this machine)

$ rm AIRC_DAEMON_SOCKET; continuum-core-server …
ERROR Refusing to boot in degraded state: 1 persona seed(s) on disk
      but AIRC discovery failed — no PersonaInstanceManagerModule
      registered, so the substrate cannot host these citizens.
      Resolve: install airc, set AIRC_DAEMON_SOCKET, or run
      `airc room <name>` … then restart continuum-core. To start
      anyway (e.g. for inference-only headless mode), move or
      rename /Users/joel/.continuum/personas aside.
[exit 1]                                            ← A1 hard-fails

$ AIRC_DAEMON_SOCKET=… continuum-core-server …
✅ All 38 expected modules registered                ← A3: 0 unexpected
PersonaAircRuntime bootstrap: identity ready (Paige)
PersonaAircRuntime bootstrap: joined room (cambriantech)
🌐 The Grid hosts citizen Paige (slot 0, role Helper)
(no `thread … panicked at /ort-` trace)             ← A2 filter live

$ airc msg "how's the new substrate boot feel?"
Paige: "Hi there! I'm Paige, an AI on the grid. …"  ← round-trip works

Doctrine

  • [[no-fallbacks-ever]] — refuse to degrade silently
  • [[substrate-is-a-good-citizen-on-the-host]] — speak clearly when degraded; don't scare operators with panic traces they can't act on
  • [[every-error-is-an-opportunity-to-battle-harden]] — the rigging that catches "substrate ran but did nothing" next time
  • [[host-the-seemingly-impossible]] — the substrate is only credible when it's honest about what it can host RIGHT NOW

Out of scope (deferred follow-ups)

  • airc ipc-endpoint subcommand — task Build(deps-dev): Bump @typescript-eslint/parser from 8.29.1 to 8.35.0 #79, the airc-side fix that would obviate the AIRC_DAEMON_SOCKET env var workaround entirely.
  • 200+ stale airc daemon processes on the host — every airc resume from every Claude tab / sandbox / test spawns one and they accumulate. Separate, airc-lifecycle hygiene work.
  • headless-only / live-presence feature split — Slice B of the iteration. Today the headless persona server links bevy_pbr (3D PBR shaders!) because live/avatar/* reaches into bevy. Expected outcome: 105 MB → ~30-40 MB binary, ~34 min → ~5-10 min cold build.
  • Adapter warmup parallelization — Slice C. Today the sequence is serial (airc bootstrap → join room → service-loop attach (4s warmup) → ready). Spawning warmup as a task that races bootstrap collapses 5s → ~1s on cold start.

Test plan

  • cargo test --release -p continuum-core --lib count_persona_seeds — 6/0 pass
  • cargo check --release -p continuum-core --no-default-features --features livekit-webrtc,llama/mac-cpu-only — clean (64 pre-existing warnings, 0 new)
  • Boot with Paige seed + no AIRC_DAEMON_SOCKET → ERROR + exit 1 with actionable message
  • Boot with Paige seed + correct AIRC_DAEMON_SOCKET → 38 modules, 0 unexpected, Paige joins room
  • airc msg → airc inbox round-trip with Paige — coherent reply
  • No thread … panicked at /ort- trace in stderr on Mac Intel without libonnxruntime

References

  • docs/architecture/CBAR-SUBSTRATE-ARCHITECTURE.md (substrate contract)
  • docs/architecture/PERSONA-COGNITION-PIPELINE.md (persona host loop)
  • Memory: [[no-fallbacks-ever]], [[substrate-is-a-good-citizen-on-the-host]], [[every-error-is-an-opportunity-to-battle-harden]]

🤖 Generated with Claude Code

…tion)

Three sub-fixes from the 2026-06-04 "doesn't even RUN anymore" session,
where continuum-core-server booted into a degraded state without saying
so loudly. The substrate stayed alive on Joel's machine at 1166 MB RSS
for 19 hours doing nothing useful, because:

  1. `airc ipc-endpoint` failed (subcommand missing, task #79)
  2. one WARN line buried at boot
  3. `PersonaInstanceManagerModule` silently skipped
  4. no Paige spawn, no error
  5. "running" but unable to host its citizens

`./jtag persona/list` would have surfaced nothing actionable. The "lie"
shape is the [[no-fallbacks-ever]] violation made physical: substrate
present, but doing none of the job it exists to do.

## A1 — hard-fail boot when (persona seeds on disk) AND (AIRC degraded)

If `<continuum_root>/personas/*/seed.json` exists but AIRC discovery
failed, `start_server` now returns `Err(io::Error)` with an actionable
repair message and exits with non-zero status. Operator sees:

  ERROR Refusing to boot in degraded state: 1 persona seed(s) on disk
        but AIRC discovery failed — no PersonaInstanceManagerModule
        registered, so the substrate cannot host these citizens.
        Resolve: install airc, set AIRC_DAEMON_SOCKET, or run
        `airc room <name>` to establish a default room — then restart
        continuum-core. To start anyway (e.g. for inference-only
        headless mode), move or rename /Users/joel/.continuum/personas
        aside.

If NO persona seeds exist (fresh install, inference-only mode, test
fixture), the substrate continues to boot — there are no citizens to
fail. Boundary intentionally narrow: only hard-fails the case the
substrate would otherwise lie about.

Persona-seed detection extracted as `count_persona_seeds(&Path) -> usize`
in `modules/persona_instance_manager.rs` with 6 unit tests covering
missing dir, empty dir, single-seed, multi-seed, persona-dir-without-
seed (in-progress mint), and stray-files-at-personas-root.

## A2 — ORT panic-stderr filter (panic-and-catch is already in place;
this just stops the trace from poisoning the logs)

Every ORT load site (fastembed preload, TTS/STT init) already wraps the
ORT call in `catch_unwind` and sets `ORT_UNAVAILABLE` on failure with a
clean WARN line. But Rust's DEFAULT panic hook ALSO writes the panic to
stderr BEFORE `catch_unwind` catches it, leaving the user staring at:

  thread 'tokio-rt-worker' (36060772) panicked at
    /Users/.cargo/registry/src/.../ort-2.0.0-rc.11/src/lib.rs:191:41:
  Failed to load ONNX Runtime dylib: Error { code: GenericFailure, ... }

That trace looks like a substrate bug. It's not — it's just "voice
features not available, install libonnxruntime." The new
`install_ort_panic_filter` (called at the top of `main`) installs a
custom panic hook that matches BOTH location().file() containing
`/ort-` AND payload mentioning "Failed to load ONNX Runtime". Other
ORT panics (genuine inference bugs) won't match the dylib-load
substring and fall through to the default hook. Non-ORT panics always
fall through.

## A3 — EXPECTED_MODULES current with reality

The list in `runtime/runtime.rs` had 22 entries. The substrate
registers 38 modules. Result: 16 false "Unexpected module registered"
WARN lines on every boot for load-bearing modules (airc,
persona_instance_manager, persona-rag-inspect, tool-parsing,
resource-broker, cargo, inference, sentinel, plasticity, ai_provider,
agent, vision, forge, auth, events, pressure-broker).

Each module is now grouped by role (infrastructure, resource
governance, persona substrate, AI/inference, forge/sentinel,
transports, live presence) with a doc-comment explaining what drift
between this list and `ipc/mod.rs` produces (spurious warnings or
fail-boot), so future maintainers keep them in sync.

## End-to-end verified

  $ rm AIRC_DAEMON_SOCKET; continuum-core-server …
  ERROR Refusing to boot in degraded state: 1 persona seed(s) …
  [exit 1]                                            <- A1 hard-fails

  $ AIRC_DAEMON_SOCKET=… continuum-core-server …
  ok All 38 expected modules registered                <- A3: 0 unexpected
  PersonaAircRuntime bootstrap: identity ready (Paige)
  PersonaAircRuntime bootstrap: joined room (cambriantech)
  The Grid hosts citizen Paige (slot 0, role Helper)
  (no `thread … panicked at /ort-` trace)             <- A2 filter live

  $ airc msg "how's the new substrate boot feel?"
  Paige: "Hi there! I'm Paige, an AI on the grid. …"  <- round-trip works

## Doctrine alignment

- [[no-fallbacks-ever]] — refuse to degrade silently
- [[substrate-is-a-good-citizen-on-the-host]] — speak clearly when
  degraded; don't scare operators with panic traces they can't act on
- [[every-error-is-an-opportunity-to-battle-harden]] — the rigging
  that catches "substrate ran but did nothing" next time
- [[host-the-seemingly-impossible]] — the substrate is only credible
  when it's honest about what it can host RIGHT NOW

## Out of scope

- `airc ipc-endpoint` subcommand (task #79, the airc-side fix)
- 200+ stale airc daemons (separate, airc lifecycle hygiene)
- `headless-only` / `live-presence` feature split (Slice B)
- Adapter warmup parallelization (Slice C)

card: e9f50a36-0543-412f-a804-13c21e1cf2c1

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@joelteply

Copy link
Copy Markdown
Contributor Author

Closing per the convergent adversarial-review verdict. Three reviewers BLOCKed on two real bugs and three doctrinal gaps that don't justify a follow-up — they justify a redesign:

Real bugs in the current PR

  1. A1 + A3 contradict each other. EXPECTED_MODULES now lists persona_instance_manager + persona-rag-inspect, but those modules only register inside the if let Some(persona_bootstrap_deps) branch. The PR body explicitly claims "If NO persona seeds exist (fresh install, inference-only mode, test fixture), the substrate continues to boot." It does not — verify_registration errors with "Missing required modules". The PR breaks the very mode it claims to allow.
  2. AIRC_DAEMON_SOCKET override has no liveness check. Stale socket path → discovery returns Some → module registers → log says "✅ All 38 modules registered, Paige hosted" → every IPC ECONNREFUSED. Same "looks healthy, hosts no one" bug, just shifted state.

Doctrinal gaps two reviewers converged on
3. EXPECTED_MODULES regression class still unguarded. I traded one drift problem (silent unexpected) for another (manual maintenance). [[every-error-is-an-opportunity-to-battle-harden]] demands auto-derivation.
4. "Non-persona use" is an implicit [[no-fallbacks-ever]] fallback. Operator never asked for inference-only; substrate silently substitutes a degraded capability set when seeds are absent. Should require explicit operator intent.
5. Zero start_server integration coverage. The unit tests pin the helper, not the integration. The 2026-06-04 bug class would not be caught by my tests.

The redesign discovery state needs to be a typed value flowing through to verify_registration, with operator intent expressed via explicit --mode=... flag, and the module manifest auto-derived rather than hand-maintained. A second slice (Slice A.2 — substrate boot lifecycle contract) supersedes this PR. Card e9f50a36-0543-412f-a804-13c21e1cf2c1 closed; new card will track the redesign.

Reviews (full text in airc transcript): R1 correctness, R2 doctrine, R3 test coverage — all BLOCK, all converging on the same architectural shape.

@joelteply joelteply closed this Jun 4, 2026
joelteply added a commit that referenced this pull request Jun 7, 2026
…ce A.2.1)

Replaces Slice A (PR #1527, closed via convergent reviewer BLOCK) with
the architectural change Slice A's three patch-fixes were imitating.
Compresses three drifting representations of substrate boot state
(tuple `Option<(PathBuf, RoomId)>` + flat const `EXPECTED_MODULES` +
heuristic seed detection) into one typed primitive each consumer
matches exhaustively. The drift problem dies structurally — not
because we wrote a louder doc-comment this time, but because the
contradictions are no longer expressible.

## Closes (with structural fixes, not patches)

  R1#1 (BLOCKING) — EXPECTED_MODULES contradicted --mode=inference-only
    fix: `verify_registration(&discovery, mode)` computes the required
    set CONDITIONALLY. `MODULES_PERSONA_HOSTING` is only required when
    AIRC is `Healthy` AND `mode.requires_persona_hosting()`. The PR
    title "supports inference-only" is now true by construction.

  R2#1 (BLOCKING) — `AIRC_DAEMON_SOCKET` env var bypassed liveness
    fix: `discover()` aggregator runs Status RPC liveness probe.
    Failure promotes to `AircDiscovery::Degraded { reason:
    StaleSocket(path, underlying_err), partial: ... }` instead of
    the soft-fallback to `Uuid::nil()` that let stale sockets through.

  R2#2 (BLOCKING) — implicit `non-persona-use` fallback
    fix: explicit `--mode=<full-citizen|inference-only|fail-fast>`
    flag (default `FullCitizen`). The operator states intent; the
    substrate doesn't guess from `personas/` directory contents.
    `--mode=inference-only` is what an operator running a forge
    worker / CI runner / model eval harness explicitly opts into.

  R2#3 + R3#3 (BLOCKING) — hand-maintained manifest drift
    fix: `ALL_KNOWN_MODULES` = `MODULES_CORE` ∪ `MODULES_PERSONA_HOSTING`
    is a build-time invariant checked by three unit-test drift catchers
    (`all_known_modules_is_union_of_subsets`,
     `core_and_persona_hosting_are_disjoint`,
     `required_modules_returns_exactly_one_of_two_sets`). A.2.2 layers
    the full insta snapshot of `runtime.registry().module_names()` on
    top. The "we wrote a better doc-comment this time" non-fix is gone.

  R2 NIT — A2 panic filter mutes only signal
    fix: panic filter restored (suppresses misleading stderr trace
    only, catch_unwind safety net unchanged). New boot banner line
    `Boot mode: <label> (<description>)` surfaces operator's chosen
    mode immediately; voice subsystem status line lands in A.2.2.

## Compression payoff (the principle, not the bullets)

Before A.2.1, three pieces of code answered "what is the substrate's
boot state":
  - `Option<(PathBuf, RoomId)>` tuple (some = healthy, none =
    everything-else-collapsed)
  - `EXPECTED_MODULES: &[&str]` flat const (must contain everything
    that registered, period, regardless of state)
  - inline seed-presence check in `ipc/mod.rs` (heuristic guess at
    operator intent)
Each could drift against the other two. Slice A added a fourth (the
hard-fail check) without compressing — that's how it produced PR
claims contradicting its own implementation.

A.2.1 collapses them to ONE typed state (`AircDiscovery`) + ONE
explicit operator-intent flag (`BootMode`) + ONE function answering
"what's required for THIS state" (`required_modules(&discovery,
mode)`). Every consumer reaches through the same primitive. The
"different consumers disagree about what state is" failure mode
is no longer expressible.

## Architecture seam for B'

`AircDiscovery::Healthy/Degraded/Unreachable` is the first instance
of what B' generalizes: every category sidecar (renderer, voice,
inference, foundry) will have the same three-variant health shape.
The substrate-wide controls (`for each category: health()`,
PressureBroker admission, Ares the dispatcher-persona's allocation
cognition) operate uniformly across categories because each
category's state surface looks the same. A.2.1's discipline is the
foundation: the same compression that closes R1#1 here is what
makes Ares possible later.

## Test rigging (the substrate-level kind, not demos)

  - `airc::discovery_state` — 4 tests over `Healthy/Degraded/
    Unreachable` transitions + `StaleSocket` carries path AND
    underlying error
  - `runtime::boot_mode` — 12 tests over canonical/alias/case-insens
    parsing, `requires_persona_hosting`/`requires_voice` queries,
    `extract_boot_mode` against equals-form / space-form / absent /
    dangling-space argv
  - `conditional_modules_tests` — 7 tests over `required_modules`
    dispatch across `(Healthy, Degraded) × (FullCitizen,
    InferenceOnly, FailFast)`, plus three drift catchers that make
    `MODULES_CORE`/`MODULES_PERSONA_HOSTING`/`ALL_KNOWN_MODULES`
    divergence a CI failure instead of a runtime warning

  Total: 23/23 pass. Each primitive exercisable in isolation —
  no demo bin, no binary boot, no live AIRC daemon.

  A.2.2 layers cross-substrate integration tests on top
  (`StubAircCitizen` + tempdir continuum_root + `start_server` end
  to end across the mode × discovery × seed matrix), plus Context
  trait `discovery()`+`boot_mode()` accessors that prepare the
  Context object for B's category-handle uniformity.

## End-to-end verification (deferred to release build + live AIRC)

  Built artifact will be exercised against:
    - `--mode=full-citizen` + AIRC healthy → All N required modules
      registered (N depends on dispatch), Paige hosts, round-trip
      via `airc msg`
    - `--mode=full-citizen` + AIRC unreachable → exit 1 with typed
      reason from `AircDiscovery::Unreachable.reason()`
    - `--mode=full-citizen` + env-var pointed at stale socket →
      exit 1 with `AircDiscovery::Degraded { reason: StaleSocket
      { path, underlying } }`
    - `--mode=inference-only` + AIRC unreachable → boots cleanly,
      INFO line says persona hosting disabled per operator intent
    - `--mode=fail-fast` + libonnxruntime missing → exit 1

## Doctrine alignment (substantively, not as cover)

  [[no-fallbacks-ever]] — typed discovery + explicit mode eliminate
    every silent-substitution path Slice A retained
  [[every-error-is-an-opportunity-to-battle-harden]] — the three
    drift catchers ARE the rigging; the snapshot test in A.2.2 is
    its more thorough sibling
  [[substrate-is-a-good-citizen-on-the-host]] — boot banner names
    the chosen mode; degraded states have human-actionable reasons
  [[host-the-seemingly-impossible]] — the substrate publishes what
    it CAN do honestly; `--mode=full-citizen` is a promise, not
    a hope

## Out of scope (folded into A.2.2)

  - `Context` trait `discovery()` + `boot_mode()` accessors
  - PersonaContext / AgentContext / StubContext implementations
  - `tests/substrate_boot_contract.rs` integration matrix
  - `tests/ort_panic_filter.rs` with `serial_test::serial`
  - `tests/expected_modules_snapshot.rs` insta snapshot of
    `runtime.registry().module_names()` against ALL_KNOWN_MODULES
  - Voice subsystem `🔊 ready / 🔇 unavailable` status line
  - `runtime/mode/get` + `runtime/mode/set` commands — expose
    `BootMode` via the universal Commands surface so widgets,
    personas, and remote continuums can all read/change runtime
    mode through the same primitive (no separate widget API,
    no operator-only escape hatch). Same for `runtime/discovery/get`
    returning the typed `AircDiscovery`. The compression principle
    extends to the control surface: one typed value, one command
    pair, every actor uses the same primitive.

## Out of scope (folded into B')

  - Generalization of `AircDiscovery`'s three-variant pattern to
    `RendererHealth` / `InferenceHealth` / `VoiceHealth`
  - `CategorySidecar` trait + uniform `health()`/`allocate_lane()`
  - Sidecar process pattern (renderer/voice/inference/foundry as
    separate binaries)
  - Ares-the-persona dispatcher (the master control citizen)

card: 4075b9a4-7251-4405-84e5-9033e2213dff
supersedes: PR #1527 (closed via R1+R2+R3 convergent BLOCK)
follow-up: A.2.2 (Context + integration tests), B' (CategorySidecar)

Co-Authored-By: Claude Opus 4.7 <[email protected]>
joelteply added a commit that referenced this pull request Jun 7, 2026
…ce A.2.1) (#1528)

* fix(boot): typed AircDiscovery + BootMode + conditional manifest (Slice A.2.1)

Replaces Slice A (PR #1527, closed via convergent reviewer BLOCK) with
the architectural change Slice A's three patch-fixes were imitating.
Compresses three drifting representations of substrate boot state
(tuple `Option<(PathBuf, RoomId)>` + flat const `EXPECTED_MODULES` +
heuristic seed detection) into one typed primitive each consumer
matches exhaustively. The drift problem dies structurally — not
because we wrote a louder doc-comment this time, but because the
contradictions are no longer expressible.

## Closes (with structural fixes, not patches)

  R1#1 (BLOCKING) — EXPECTED_MODULES contradicted --mode=inference-only
    fix: `verify_registration(&discovery, mode)` computes the required
    set CONDITIONALLY. `MODULES_PERSONA_HOSTING` is only required when
    AIRC is `Healthy` AND `mode.requires_persona_hosting()`. The PR
    title "supports inference-only" is now true by construction.

  R2#1 (BLOCKING) — `AIRC_DAEMON_SOCKET` env var bypassed liveness
    fix: `discover()` aggregator runs Status RPC liveness probe.
    Failure promotes to `AircDiscovery::Degraded { reason:
    StaleSocket(path, underlying_err), partial: ... }` instead of
    the soft-fallback to `Uuid::nil()` that let stale sockets through.

  R2#2 (BLOCKING) — implicit `non-persona-use` fallback
    fix: explicit `--mode=<full-citizen|inference-only|fail-fast>`
    flag (default `FullCitizen`). The operator states intent; the
    substrate doesn't guess from `personas/` directory contents.
    `--mode=inference-only` is what an operator running a forge
    worker / CI runner / model eval harness explicitly opts into.

  R2#3 + R3#3 (BLOCKING) — hand-maintained manifest drift
    fix: `ALL_KNOWN_MODULES` = `MODULES_CORE` ∪ `MODULES_PERSONA_HOSTING`
    is a build-time invariant checked by three unit-test drift catchers
    (`all_known_modules_is_union_of_subsets`,
     `core_and_persona_hosting_are_disjoint`,
     `required_modules_returns_exactly_one_of_two_sets`). A.2.2 layers
    the full insta snapshot of `runtime.registry().module_names()` on
    top. The "we wrote a better doc-comment this time" non-fix is gone.

  R2 NIT — A2 panic filter mutes only signal
    fix: panic filter restored (suppresses misleading stderr trace
    only, catch_unwind safety net unchanged). New boot banner line
    `Boot mode: <label> (<description>)` surfaces operator's chosen
    mode immediately; voice subsystem status line lands in A.2.2.

## Compression payoff (the principle, not the bullets)

Before A.2.1, three pieces of code answered "what is the substrate's
boot state":
  - `Option<(PathBuf, RoomId)>` tuple (some = healthy, none =
    everything-else-collapsed)
  - `EXPECTED_MODULES: &[&str]` flat const (must contain everything
    that registered, period, regardless of state)
  - inline seed-presence check in `ipc/mod.rs` (heuristic guess at
    operator intent)
Each could drift against the other two. Slice A added a fourth (the
hard-fail check) without compressing — that's how it produced PR
claims contradicting its own implementation.

A.2.1 collapses them to ONE typed state (`AircDiscovery`) + ONE
explicit operator-intent flag (`BootMode`) + ONE function answering
"what's required for THIS state" (`required_modules(&discovery,
mode)`). Every consumer reaches through the same primitive. The
"different consumers disagree about what state is" failure mode
is no longer expressible.

## Architecture seam for B'

`AircDiscovery::Healthy/Degraded/Unreachable` is the first instance
of what B' generalizes: every category sidecar (renderer, voice,
inference, foundry) will have the same three-variant health shape.
The substrate-wide controls (`for each category: health()`,
PressureBroker admission, Ares the dispatcher-persona's allocation
cognition) operate uniformly across categories because each
category's state surface looks the same. A.2.1's discipline is the
foundation: the same compression that closes R1#1 here is what
makes Ares possible later.

## Test rigging (the substrate-level kind, not demos)

  - `airc::discovery_state` — 4 tests over `Healthy/Degraded/
    Unreachable` transitions + `StaleSocket` carries path AND
    underlying error
  - `runtime::boot_mode` — 12 tests over canonical/alias/case-insens
    parsing, `requires_persona_hosting`/`requires_voice` queries,
    `extract_boot_mode` against equals-form / space-form / absent /
    dangling-space argv
  - `conditional_modules_tests` — 7 tests over `required_modules`
    dispatch across `(Healthy, Degraded) × (FullCitizen,
    InferenceOnly, FailFast)`, plus three drift catchers that make
    `MODULES_CORE`/`MODULES_PERSONA_HOSTING`/`ALL_KNOWN_MODULES`
    divergence a CI failure instead of a runtime warning

  Total: 23/23 pass. Each primitive exercisable in isolation —
  no demo bin, no binary boot, no live AIRC daemon.

  A.2.2 layers cross-substrate integration tests on top
  (`StubAircCitizen` + tempdir continuum_root + `start_server` end
  to end across the mode × discovery × seed matrix), plus Context
  trait `discovery()`+`boot_mode()` accessors that prepare the
  Context object for B's category-handle uniformity.

## End-to-end verification (deferred to release build + live AIRC)

  Built artifact will be exercised against:
    - `--mode=full-citizen` + AIRC healthy → All N required modules
      registered (N depends on dispatch), Paige hosts, round-trip
      via `airc msg`
    - `--mode=full-citizen` + AIRC unreachable → exit 1 with typed
      reason from `AircDiscovery::Unreachable.reason()`
    - `--mode=full-citizen` + env-var pointed at stale socket →
      exit 1 with `AircDiscovery::Degraded { reason: StaleSocket
      { path, underlying } }`
    - `--mode=inference-only` + AIRC unreachable → boots cleanly,
      INFO line says persona hosting disabled per operator intent
    - `--mode=fail-fast` + libonnxruntime missing → exit 1

## Doctrine alignment (substantively, not as cover)

  [[no-fallbacks-ever]] — typed discovery + explicit mode eliminate
    every silent-substitution path Slice A retained
  [[every-error-is-an-opportunity-to-battle-harden]] — the three
    drift catchers ARE the rigging; the snapshot test in A.2.2 is
    its more thorough sibling
  [[substrate-is-a-good-citizen-on-the-host]] — boot banner names
    the chosen mode; degraded states have human-actionable reasons
  [[host-the-seemingly-impossible]] — the substrate publishes what
    it CAN do honestly; `--mode=full-citizen` is a promise, not
    a hope

## Out of scope (folded into A.2.2)

  - `Context` trait `discovery()` + `boot_mode()` accessors
  - PersonaContext / AgentContext / StubContext implementations
  - `tests/substrate_boot_contract.rs` integration matrix
  - `tests/ort_panic_filter.rs` with `serial_test::serial`
  - `tests/expected_modules_snapshot.rs` insta snapshot of
    `runtime.registry().module_names()` against ALL_KNOWN_MODULES
  - Voice subsystem `🔊 ready / 🔇 unavailable` status line
  - `runtime/mode/get` + `runtime/mode/set` commands — expose
    `BootMode` via the universal Commands surface so widgets,
    personas, and remote continuums can all read/change runtime
    mode through the same primitive (no separate widget API,
    no operator-only escape hatch). Same for `runtime/discovery/get`
    returning the typed `AircDiscovery`. The compression principle
    extends to the control surface: one typed value, one command
    pair, every actor uses the same primitive.

## Out of scope (folded into B')

  - Generalization of `AircDiscovery`'s three-variant pattern to
    `RendererHealth` / `InferenceHealth` / `VoiceHealth`
  - `CategorySidecar` trait + uniform `health()`/`allocate_lane()`
  - Sidecar process pattern (renderer/voice/inference/foundry as
    separate binaries)
  - Ares-the-persona dispatcher (the master control citizen)

card: 4075b9a4-7251-4405-84e5-9033e2213dff
supersedes: PR #1527 (closed via R1+R2+R3 convergent BLOCK)
follow-up: A.2.2 (Context + integration tests), B' (CategorySidecar)

Co-Authored-By: Claude Opus 4.7 <[email protected]>

* fix(boot): close convergent BLOCK on PR #1528 — Uuid::nil + manifest compression + load-bearing seam coverage

Addresses the three converging adversarial reviewers' BLOCK on the
first A.2.1 attempt. Each reviewer independently caught the same
silent-fallback pattern shifted one frame deeper from where Slice A
had it; this commit closes it structurally + adds the test rigging
that locks the closure in.

## R2#1 — `AircModule::from_discovery(Degraded)` Uuid::nil bug

Reviewers #1 (correctness) and #2 (doctrine) both BLOCKED on the
`Degraded` arm reading `partial.peer_id.unwrap_or_else(Uuid::nil)`
and constructing a real `DaemonAircEventTransport` against the
discovered (potentially stale) socket. In `--mode=inference-only`,
the mode gate did not trip, so the module registered, every
realtime publish either ECONNREFUSED'd against the stale socket OR
went out attributed to `Uuid::nil` — exactly the silent-fallback
pattern [[no-fallbacks-ever]] forbids, just shifted one frame from
Slice A's location.

**Fix:** `Degraded` AND `Unreachable` now both collapse to
`with_queue_client(...)`. The `partial` field on the enum is
retained for operator observability (what we DID resolve before
discovery declared not-Healthy), but the module construction does
not pretend. Five new tests in `from_discovery_tests` pin every
branch + the cross-variant invariant `only_healthy_exposes_a_
daemon_socket`. R2#1 is now structurally impossible.

## R2#3 + R3#3 — compression principle violation in manifest

Reviewers #2 and #3 converged on the same point: three constants
(`MODULES_CORE`, `MODULES_PERSONA_HOSTING`, `ALL_KNOWN_MODULES`)
with three drift-catcher tests verifying they agree with each
other. That violates the compression principle Joel emphasized
throughout the session — one logical decision, one place. The
drift catchers don't catch the actual regression class (developer
adds `runtime.register(NewModule)` in `ipc/mod.rs` without
updating a constant).

**Fix:** ONE `MODULES: &[(&str, ModuleCategory)]` list with each
row tagged by category. `required_modules(&discovery, mode)`
filters this list; `all_known_modules()` projects names from it.
No parallel list to drift against. The drift catchers reduce to
correctness tests over the projection (`required_modules_size_
matches_category_dispatch`, `every_core_module_appears_in_every_
required_set`, `persona_hosting_modules_appear_only_when_
dispatched` — the last is the R1#1 structural lock).

The R3#3 "developer adds register without updating manifest"
class still requires the A.2.2 insta snapshot that boots the
runtime and asserts `registry().module_names()` == projection of
`MODULES`. That deferral is honest; the categorized list is the
foundation the snapshot will anchor to.

## Purity — `discover_and_construct` deleted, not deprecated

Per Joel's "purity is always worth it" doctrine, the legacy
`AircModule::discover_and_construct` method is removed entirely.
It carried the same `Uuid::nil()` soft-fallback at line 158 that
R2#1 was about. With `from_discovery()` covering every production
case, the legacy method's only value was easing migration — and
"ease of migration" is not worth retaining a code path that
encodes the bug pattern this slice exists to close.

Same standard for the unused-import cleanup that followed: no
deprecated shims, no commented-out `legacy //` blocks, no
re-exports for "back-compat." If a future caller wants the old
shape, they read the git history and write it again with the
typed primitives.

## ORT panic filter — held for A.2.2 per reviewer #2

Reviewer #2's BLOCKING #3: shipping `install_ort_panic_filter`
WITHOUT the paired `🔊/🔇 Voice subsystem: <state>` boot banner
line leaves the default-mode (`FullCitizen`) operator with zero
signal that voice is unavailable. The filter mutes the only
signal; the indicator hasn't landed yet.

**Fix:** removed the panic filter entirely from A.2.1. Both the
filter AND the indicator (with its `libloading::Library::new(
"libonnxruntime.dylib")` dlopen probe) land together in A.2.2.
This is what reviewer #2 explicitly recommended as the doctrinally
honest sequencing: "ship them together OR hold both."

## Test coverage added

- `from_discovery_tests` (5 tests):
  - healthy_produces_fully_configured_module
  - degraded_with_partial_socket_collapses_to_queue_only (R2#1)
  - degraded_with_full_partial_state_still_collapses_to_queue_only
  - unreachable_collapses_to_queue_only
  - only_healthy_exposes_a_daemon_socket (cross-variant invariant)

- `discovery_failure_mapping_tests` (10 tests):
  - All 8 `DiscoveryError → DiscoveryFailure` variant projections
  - stale_socket_from_status_err carries path + underlying
  - stale_socket_handles_non_status_errors

- `conditional_modules_tests` (refactored, now 9 tests for the
  new MODULES shape):
  - full_citizen_healthy_requires_persona_hosting_modules (R1)
  - inference_only_does_not_require_persona_hosting_modules (R1)
  - fail_fast_healthy_requires_persona_hosting_modules
  - full_citizen_degraded_uses_core_only_set
  - modules_list_has_unique_names (drift catcher)
  - required_modules_size_matches_category_dispatch
  - all_known_modules_derives_from_modules
  - every_core_module_appears_in_every_required_set
  - persona_hosting_modules_appear_only_when_dispatched
    (the structural R1#1 lock)

- `discovery_state::tests` (unchanged, 4 tests)
- `boot_mode::tests` (unchanged, 12 tests)

**Total: 40/40 pass.** Cargo check clean.

## Reviewer findings status

| Finding | Reviewer | Status |
|---|---|---|
| R1#1 — `EXPECTED_MODULES` contradicts inference-only | R1 | CLOSED via categorized MODULES + `persona_hosting_modules_appear_only_when_dispatched` test |
| R2#1 — env-var stale socket bypass | R2 | CLOSED structurally via `Degraded → queue-only` collapse + 5 from_discovery tests |
| R2#2 — implicit non-persona-use fallback | R2 | (already closed in original A.2.1 via explicit `--mode`) |
| R2#3 / R3#3 — manifest drift | R2,R3 | PARTIALLY CLOSED via categorized MODULES; full closure (registration-site snapshot) deferred to A.2.2 with honest scope |
| R3#1 — start_server integration | R3 | Deferred to A.2.2 (StubAircCitizen infra) |
| R3#2 — panic filter test | R3 | Filter held for A.2.2 per R2 #3 |
| R3#5 — substrate boot smoke | R3 | Deferred to A.2.2 |
| R2 NIT — voice indicator | R2 | Held for A.2.2 (ships with panic filter + dlopen probe together) |

## Doctrine alignment

- [[no-fallbacks-ever]] — structurally, not just doctrinally:
  Degraded cannot produce a daemon transport at all
- [[compression-principle]] — one MODULES list, no parallel
  constants
- [[every-error-is-an-opportunity-to-battle-harden]] — 15 new
  tests pin the load-bearing seams the convergent review named
- [[substrate-is-a-good-citizen-on-the-host]] — refusing to ship
  the panic filter without the indicator pair
- Joel's "purity is always worth it" — discover_and_construct
  deleted, not deprecated

card: 4075b9a4-7251-4405-84e5-9033e2213dff (A.2.1)

Co-Authored-By: Claude Opus 4.7 <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant