Repository navigation
feat(probes): JsonlProbeFileSink + RTOS-debugger manual (#151 foundation) - #1535
Merged
joelteply merged 2 commits intoJun 6, 2026
Merged
Conversation
…Id::as_str() (#195 slice 3) Slice 3 of task #195 (inference latency perfection campaign). Pre-slice-3, `serve_persona_loop_inner` did, every turn: ```rust specialty: format!("{:?}", ctx.role).to_lowercase(), ``` Two allocations, a variadic-macro dispatch through derived-Debug, and a Unicode lowercase walk — all to produce a value `RoleId` already exposes via its canonical `as_str() -> &'static str` method (in `role_template.rs`, pinned at compile time). ## What ships Switch the per-turn read from the Debug+lowercase chain to `ctx.role.as_str()`: ```rust let respond_input = RespondInput { persona: PersonaSlot { // was: format!("{:?}", ctx.role).to_lowercase() specialty: ctx.role.as_str().to_string(), /* ... */ }, /* ... */ }; ``` Per-turn cost drops from `format!()` (variadic macro + Debug formatter + heap alloc) + `.to_lowercase()` (second alloc + Unicode lowercase walk) to a single `String::from` of a static `&'static str`. The source IS the cache — no field on `PersonaContext`, no helper, no Arc plumbing. ## Why this shape (not a cache) Initial draft of slice 3 added `PersonaContext.specialty: Arc<str>` populated by a `build_persona_specialty(role)` helper that pre- baked the Debug+lowercase output. Adversarial review (3 agents) correctly identified two problems: 1. **Caching the wrong source.** `RoleId::as_str()` already exists as the documented, intentionally-stable specialty derivation (kebab-case identifier, pinned by an explicit `match` so renames are deliberate). Caching the Debug+lowercase output couples the prompt-assembly contract to the derived-Debug format — a future contributor adding a custom Debug or wrapping the enum silently breaks the specialty string with no test failure. 2. **Caching test was a tautology.** The helper was `Arc::from(format!("{:?}", role).to_lowercase())` and the test compared its output to `format!("{:?}", role).to_lowercase()` — comparing the helper to its own implementation. A buggy helper using `.to_uppercase()` would have passed. The revised slice picks the right source and the right contract: use `role.as_str()` directly. No cache needed because the static str pointer IS already pre-computed at compile time. The behavior-preservation test (below) is non-circular: it compares the new direct path (`role.as_str()`, a hand-curated match in role_template.rs) to the pre-slice-3 derived-Debug chain. ## Test (+1 new) `persona::service_loop::tests::role_as_str_preserves_pre_slice3_specialty_format_for_each_role`: - Pins that for every `RoleId` variant (Helper, Coder, Sentinel, Custom), `role.as_str()` produces byte-identical output to the pre-slice-3 `format!("{:?}", role).to_lowercase()`. Non-circular: two independently-derived strings. A future PR adjusting either `as_str()` or adding a variant where the two paths disagree must update this test to record the intentional divergence — silent drift breaks loudly. - Compile-time exhaustiveness: a closure-typed `|role: RoleId| match role { ... }` with NO wildcard arm forces a new RoleId variant to be added here AND to the `variants` array. Cosmetic-exhaustiveness defeats from the initial draft (matching on a literal `RoleId::Helper`) are fixed. ## What this slice does NOT do (deliberate) - No `PersonaContext.specialty` field (initial draft removed per review). The original goal was reducing per-turn cost; `role.as_str()` already gives that with zero field bloat. - No `display_name` change — `String::clone` of a fixed-per- session name is the same per-turn cost whether we cache or not, so the smell is RespondInput's `String`-typed field, not the source. Lift in a follow-up when `RespondInput`'s type changes (#149-adjacent). - No prompt-template change — substrate keeps the existing specialty-string contract verbatim; the migration is provably behavior-preserving. ## Doctrine - `[[init-once-handle-then-lease-zero-copy-refs]]` — the canonical "init-once" here is the compile-time `match` in `RoleId::as_str()`; per-turn cost is a `&'static str` deref + one `String::from` (memcpy of 6-9 static bytes). Doesn't get cheaper without changing `RespondInput`'s type signature. - `[[observability-is-half-the-architecture]]` — slice 1's `respond_latency` aggregate will tell us if this and the cumulative slice-2/3+ wins are moving the needle on real persona turns. - `[[no-fallbacks-ever]]` — no graceful-degradation path; the behavior-preservation test breaks loudly if either side drifts. card: 0d780926 parent task: #195 slice 1: #1532 (merged) — phase decomposition slice 2: #1533 (merged) — cache system_prompt at construction Co-Authored-By: Claude Opus 4.7 <[email protected]>
…DE pointers (#151 foundation) The substrate has the JTAG hardware (Slice P #176/#177): `probe!` / `time_sync!` / `stack!` macros, `ProbeRouterLayer` (in-process broadcast Layer), `ProbeStreamModule` (the `debug/probes/{class}/{open, next,close}` URI consumer), and `UriCaptureLayer` (URI ancestry). Zero usage sites in `persona/` or `cognition/` — the probes were infrastructure waiting for application. Per Joel 2026-06-06 `[[jtag-probes-are-rtos-debugger]]`: "We are building an rtos. This is so complex we need to be able to have a detailed understanding of what's going on, like a debug breakpoint, in a way, to easily observe where the code and the surrounding vars are, ones we want to inspect via probes, and timing of anything, so we can hunt down bottlenecks." This commit ships the FOUNDATION for that — the disk-persisted breakpoint log + the manual that documents the method. The sprinkle itself (probe calls inside `persona::response`, `persona::prompt_assembly`, `cognition::shared_analysis`, `persona::service_loop`) follows in subsequent commits using the checklist in the manual. ## What ships ### `routing/probe_file_sink.rs` (new — 5/5 tests passing) `JsonlProbeFileSink` — a tracing Layer that visits every probe event, applies the operator-configured class filter, and writes a JSONL line to disk with the original `class` + `uri_chain` + `message` + `fields` plus a fresh `captured_at_ms` timestamp. ```rust let sink = JsonlProbeFileSink::from_env()?; // CONTINUUM_PROBE_FILE=/tmp/probes.jsonl // CONTINUUM_PROBE_CLASSES=persona.turn.start,persona.response.render.prompt tracing_subscriber::registry() .with(UriCaptureLayer::new()) .with(ProbeRouterLayer::new()) // in-process broadcast .with(sink) // disk-persisted breakpoint log .init(); ``` Composes with `ProbeRouterLayer` — both visit the same tracing event independently; broadcast subscribers stay in-process, this one persists to disk. Per-event filter is a single HashSet lookup (empty set = no filter, all classes pass). ### Tests (5) - `from_env_returns_envvar_unset_when_path_missing` — env-var unset is a typed Err, not a silent skip (no-fallbacks doctrine) - `unfiltered_sink_persists_every_class` — empty class filter passes everything through, captured_at_ms is populated, message + fields preserved - `class_filter_drops_unallowed_classes` — only allowed classes reach disk - `non_probe_tracing_events_are_ignored` — `tracing::info!` calls without `probe_class` field don't pollute the probe log (signal density preserved) - `sink_captures_uri_chain_when_dispatched_span_active` — when inside a dispatched URI span, the on-disk record carries the URI ancestry (so an operator can trace which command's execution the probe fired during) ### `docs/architecture/RTOS-DEBUGGER-PROBES.md` (new) The MANUAL. Persistent reference per Joel's directive: "We will want a manual (doc) on how to probe the persona so we don't forget where the work must be done and how. Be sure you document your method." Covers: - The mental model: probes are non-blocking breakpoints, time_sync! is RAII timing, stack!() is the URI ancestry — together they're the substrate's RTOS debugger - When to add a probe (branch boundaries, stage entry/exit, external calls, state seams, decision points) - The class taxonomy: stable names for `persona.turn.*`, `persona.response.*`, `persona.prompt.*`, `cognition.analyze.*`, plus general-purpose `decision` / `state` / `error` - How to enable (CONTINUUM_PROBE_FILE + CONTINUUM_PROBE_CLASSES env vars, no recompile) - How to read (jq one-liners for the common queries: per-persona filter, silence reasons, slow timings, single-turn reconstruction) - How to add a new probe (the call shape + convention rules) - **The sprinkle checklist** — every file that needs probes added, with the specific seams in each. Updates to this checklist live in the same doc; the doc IS the source of truth for what's wired and what isn't ### README.md "Debugging this substrate" section Inserted between Research Foundations and Documentation. Worked code example + the env-var enable commands + link to the manual. Every contributor (human or AI agent) sees the probe convention from the public README, not just from buried docs. The Documentation table gains a row for `RTOS-DEBUGGER-PROBES.md` directly after CONTINUUM-ARCHITECTURE.md, so the doc is discoverable from the canonical doc list as well. ### CLAUDE.md sub-entry Added under canonical doc #5 (OBSERVABILITY-AS-SUBSTRATE): "the practical companion: how to USE the `probe!` / `time_sync!` / `time_async!` macros as RTOS-style breakpoints with variable inspection + timing." Any agent reading the project's CLAUDE.md finds the probe convention as a precedence-winning truth, alongside the canonical substrate docs. ## Why this slice is foundation-only Sprinkling probes into the cognition is a separate slice (the manual's checklist tracks it). Shipping the file sink + the manual + the discoverability pointers FIRST gives reviewers a small, testable change that's clearly correct in isolation, and gives the next slice (the sprinkle) a stable target to write against — every probe call site in commit 2+ refers to the class taxonomy in commit 1's manual. ## Doctrine - `[[jtag-probes-are-rtos-debugger]]` — the framing this slice enables - `[[observability-is-half-the-architecture]]` — CaptureSink + Noop default + replay-as-first-class; this is the file-persisted consumer of that pattern - `[[no-fallbacks-ever]]` — env-var unset is typed Err `ProbeFileSinkError::EnvVarUnset`, path failures are typed `OpenFailed { path, source }` (operator must fix path; substrate refuses to silently synthesize a default) card: 8d7ca5c3 parent: #151 (echo-storm filter) — the bug we're actually hunting, debugger-first so we can find the bug INSIDE the cognition pipeline, not in a Rust gate around it Co-Authored-By: Claude Opus 4.7 <[email protected]>
joelteply
added a commit
that referenced
this pull request
Jun 6, 2026
…tion (#151 sprinkle 2) Wires probes at the per-persona service-loop turn boundaries so an operator can reconstruct every turn as a complete record (start → spoke/silent/error → phase timings). Each probe is one line at the seam; none changes behavior. Per Joel's RTOS-debugger framing `[[jtag-probes-are-rtos-debugger]]`: "timing of anything, so we can hunt down bottlenecks." The `persona.turn.spoke` probe carries the full 5-phase decomposition (recall_ms + admit_ms + compose_ms + respond_ms + say_ms) so a single `jq` query over the JSONL log surfaces which phase is dominating wall-clock without sprinkling N separate `time_sync!` blocks. ## What gets wired (4 new probes) - `persona.turn.start` — turn entry at the airc boundary (after self-loop and pre-watermark filters, before any cognition call). persona / persona_id / room_id / lamport / peer_id / text_len. Pair with `persona.turn.spoke`/`silent`/`error` (same lamport) for the complete turn record. - `persona.turn.spoke` — turn completed successfully with full phase decomposition: response_len / turn_duration_ms / recall_ms / admit_ms / compose_ms / respond_ms / say_ms. The bottleneck-hunting workhorse — one probe per turn, every phase in one line. - `persona.turn.silent` — persona's own cognitive output was Silence. reason (verbatim from `PersonaResponse::Silent`) + lamport + persona. Critical for distinguishing "this persona chose silence for THIS message" (cognition signal) from "no persona is responding to anything" (probably an `cognition.analyze.parse` issue — see prior PR). - `persona.turn.error` — turn failed somewhere downstream of the cognition entry. `stage = "respond" | "say"` field distinguishes a cognition-cycle failure (inside `respond_inner`) from an airc-publish failure (after cognition succeeded). error string + lamport for cross-referencing the upstream traces. ## Manual updated `docs/architecture/RTOS-DEBUGGER-PROBES.md` checklist now shows `persona/service_loop.rs::serve_persona_loop_inner` as wired. Remaining open items (`prompt_assembly` standalone, `score_persona` re-wire, `llama_cpp_adapter` per-batch) are noted as "covered indirectly" by the existing probes — re-evaluate if a real debugging session needs deeper visibility there. ## Doctrine - `[[jtag-probes-are-rtos-debugger]]` — RTOS breakpoints with variable inspection + timing. One probe per seam. - `[[no-rust-gates-around-cognition]]` — every probe in this slice is read-only state capture; none changes flow. card: `b390a821` parent task: #151 foundation: #1535 (merged) sprinkle 1: #1536 (under review) Co-Authored-By: Claude Opus 4.7 <[email protected]>
joelteply
added a commit
that referenced
this pull request
Jun 6, 2026
…tion (#151 sprinkle 2) (#1537) Wires probes at the per-persona service-loop turn boundaries so an operator can reconstruct every turn as a complete record (start → spoke/silent/error → phase timings). Each probe is one line at the seam; none changes behavior. Per Joel's RTOS-debugger framing `[[jtag-probes-are-rtos-debugger]]`: "timing of anything, so we can hunt down bottlenecks." The `persona.turn.spoke` probe carries the full 5-phase decomposition (recall_ms + admit_ms + compose_ms + respond_ms + say_ms) so a single `jq` query over the JSONL log surfaces which phase is dominating wall-clock without sprinkling N separate `time_sync!` blocks. ## What gets wired (4 new probes) - `persona.turn.start` — turn entry at the airc boundary (after self-loop and pre-watermark filters, before any cognition call). persona / persona_id / room_id / lamport / peer_id / text_len. Pair with `persona.turn.spoke`/`silent`/`error` (same lamport) for the complete turn record. - `persona.turn.spoke` — turn completed successfully with full phase decomposition: response_len / turn_duration_ms / recall_ms / admit_ms / compose_ms / respond_ms / say_ms. The bottleneck-hunting workhorse — one probe per turn, every phase in one line. - `persona.turn.silent` — persona's own cognitive output was Silence. reason (verbatim from `PersonaResponse::Silent`) + lamport + persona. Critical for distinguishing "this persona chose silence for THIS message" (cognition signal) from "no persona is responding to anything" (probably an `cognition.analyze.parse` issue — see prior PR). - `persona.turn.error` — turn failed somewhere downstream of the cognition entry. `stage = "respond" | "say"` field distinguishes a cognition-cycle failure (inside `respond_inner`) from an airc-publish failure (after cognition succeeded). error string + lamport for cross-referencing the upstream traces. ## Manual updated `docs/architecture/RTOS-DEBUGGER-PROBES.md` checklist now shows `persona/service_loop.rs::serve_persona_loop_inner` as wired. Remaining open items (`prompt_assembly` standalone, `score_persona` re-wire, `llama_cpp_adapter` per-batch) are noted as "covered indirectly" by the existing probes — re-evaluate if a real debugging session needs deeper visibility there. ## Doctrine - `[[jtag-probes-are-rtos-debugger]]` — RTOS breakpoints with variable inspection + timing. One probe per seam. - `[[no-rust-gates-around-cognition]]` — every probe in this slice is read-only state capture; none changes flow. card: `b390a821` parent task: #151 foundation: #1535 (merged) sprinkle 1: #1536 (under review) Co-authored-by: Claude Opus 4.7 <[email protected]>
joelteply
added a commit
that referenced
this pull request
Jun 6, 2026
#151 sprinkle 3) Per Joel 2026-06-06: the JTAG probes are "fundamentally something we'd like to make convenient to use to debug this massively complex machine." Exact-match-only filtering hits its ergonomic ceiling fast — `CONTINUUM_PROBE_CLASSES=persona.turn.start,persona.turn.silent,persona.turn.spoke,persona.response.render.prompt,persona.response.render.raw,…` is the kind of incantation that stops getting typed correctly. This slice replaces the exact-match HashSet lookup with a three-rule matcher that mirrors `tracing_subscriber::EnvFilter`'s shape — the shape every Rust dev already knows from `RUST_LOG`. Same env vars, same sink layer, dramatically shorter operator commands. ## What ships `routing::probe_file_sink::class_passes_filter` — pure helper, unit-testable in isolation, used by the Layer's `on_event` path. Rules in priority order: 1. **Empty filter set** = "no filter configured." Every class passes. (`CONTINUUM_PROBE_CLASSES` unset.) 2. **`*` is in the set** = explicit "match every class" wildcard. The firehose — distinct from rule 1 in intent per `[[no-fallbacks-ever]]`: empty is "I didn't configure", `*` is "I deliberately want everything." 3. **Exact OR namespace prefix.** `C == F` (exact) or `C.starts_with(F + ".")` (namespace prefix). The `.` guard prevents `persona` from accidentally matching `personality.x`. Same convention as RUST_LOG. ## Operator-side wins Before: ```bash CONTINUUM_PROBE_CLASSES=persona.turn.start,persona.turn.spoke,persona.turn.silent,persona.turn.error,persona.response.enter,persona.response.analyze.result,persona.response.render.prompt,persona.response.render.raw,persona.response.exit.spoke,cognition.analyze.enter,cognition.analyze.noop_single_specialty,cognition.analyze.cache_hit,cognition.analyze.parse ``` After: ```bash CONTINUUM_PROBE_CLASSES=persona,cognition # same coverage, 27 chars CONTINUUM_PROBE_CLASSES=* # firehose CONTINUUM_PROBE_CLASSES=persona.turn,cognition.analyze.parse # exact + namespace, mixed ``` ## Tests (+4 new, on top of the existing 5) `routing::probe_file_sink::tests`: - `class_filter_namespace_prefix_matches_subclasses` — `persona` prefix matches `persona.turn.spoke` AND `persona.response.render.prompt` but NOT `personality.something` or `cognition.analyze.parse`. Pins the dot guard. - `class_filter_wildcard_matches_every_class` — `*` captures every class regardless of name. - `class_filter_combines_exact_and_prefix_in_one_set` — the realistic operator pattern (one specific class + one namespace prefix) works in the same HashSet without rule contention. - `class_passes_filter_pure_function_unit_tests` — direct unit tests on the helper covering all three rules + the dot guard + the literal-prefix-as-exact edge case. Future refactors of the per-event Layer can't drift the matching contract without breaking this pin. The existing `class_filter_drops_unallowed_classes` test still passes (exact match is a degenerate case of rule 3). ## Manual + README updated - `docs/architecture/RTOS-DEBUGGER-PROBES.md` — "How to enable + read" section rewritten with the three-rule spec + example invocations + explicit `*` semantics. - `README.md` — the "Debugging this substrate" section now leads with the short prefix form (`CONTINUUM_PROBE_CLASSES=persona,cognition`) instead of the long comma-separated list. First impression for any new contributor / agent matches the actual usability. ## Why this matters Joel's framing: the probes are the substrate's debugger for a massively complex machine. A debugger people don't type because the syntax is painful isn't a debugger. Prefix matching is the single cheapest change that takes the JTAG from "in principle usable" to "actually used in every debug session." ## Doctrine - `[[jtag-probes-are-rtos-debugger]]` — "easy one liners or it won't happen." Prefix matching shrinks the operator-side line by an order of magnitude. - `[[observability-is-half-the-architecture]]` — same Layer shape, zero new infrastructure, just better operator UX. - `[[no-fallbacks-ever]]` — empty filter vs `*` are distinct intents with distinct names. The substrate doesn't silently synthesize `*` from "no env var set." card: `7d286195` parent task: #151 foundation: #1535 (merged) sprinkle 1: #1536 (merged) sprinkle 2: #1537 (in review) Co-Authored-By: Claude Opus 4.7 <[email protected]>
joelteply
added a commit
that referenced
this pull request
Jun 6, 2026
…ne seam (#151 sprinkle 4) Two beats in one slice — and the second is here because the first exposed the brittleness of the design Joel had already flagged. ## Beat 1: server actually installs the sink Per Joel 2026-06-06: "Let's perfect debugging as we use it." The `JsonlProbeFileSink` existed and the env vars were documented, but `continuum-core-server`'s `main.rs` was installing a bespoke `FmtSubscriber` — so setting `CONTINUUM_PROBE_FILE` had no effect. The JTAG hardware was unwired. New helper `routing::install_probe_tracing(config)` composes the substrate-canonical stack in one call: 1. `UriCaptureLayer` — URI ancestry for every probe 2. `ProbeRouterLayer` — in-process broadcast for `debug/probes/{class}/stream` consumers 3. `JsonlProbeFileSink` — disk-persisted JSONL log when `config.probe_file` is set 4. `tracing_subscriber::fmt::layer()` — stderr text logs governed by `RUST_LOG` (falls back to `config.default_filter`) `main.rs` swaps to the helper. Server logs `probes landing at <path>` at boot when the file sink is configured — the operator-side proof that the env var took effect. ## Beat 2: env-coupling collapsed to ONE seam Joel 2026-06-06: "That's why env vars are problematic — they are brittle." Cargo's parallel test runner raced two `install_probe_tracing` tests that mutated `CONTINUUM_PROBE_FILE` across threads; `std::env::set_var` is process-global mutable state (slated for `unsafe` marking in Rust 2024 precisely because of this class of bug). Operators hit the same class of brittleness when env-var inheritance varies across subprocesses or shell contexts. This commit fixes the brittleness at the design layer instead of working around it in tests: ### `ProbeTracingConfig { probe_file, probe_classes, default_filter }` (new) Typed boot configuration. `install_probe_tracing` takes ONLY typed values — no env access inside the library function. ### `ProbeTracingConfig::from_env(default_filter)` — THE env seam The ONE function that touches `std::env`. Reads `CONTINUUM_PROBE_FILE` + `CONTINUUM_PROBE_CLASSES` (the operator- facing env names stay verbatim) into a typed config. Future alternative sources (config file, CLI flags, hardcoded defaults) become additional constructors on `ProbeTracingConfig` without rippling into the install function. ### Consequences - **`main.rs`**: `install_probe_tracing(ProbeTracingConfig::from_env("info"))?` — explicit env-coupling at the call site, not buried in the library - **Tests**: construct `ProbeTracingConfig { probe_file: Some(temp.path()), ... }` directly — zero env mutation, fully parallel-safe. The previous merged-sequential test from the first revision of this slice is now split back into TWO parallel `#[test]` functions. - **Operator UX**: unchanged. Same `CONTINUUM_PROBE_FILE` + `CONTINUUM_PROBE_CLASSES` env vars, same prefix-match filter rules from PR #1538. ## Tests (+3) `routing::tracing_init::tests`: - `install_is_idempotent_with_no_disk_capture` — double-call is safe via `try_init`; typed config means no env mutation; runs parallel-safely against any other test - `install_surfaces_open_failed_for_unwritable_path` — typed `ProbeFileSinkError::OpenFailed` surfaces per `[[no-fallbacks-ever]]`; bad path passed as typed value, no env var racing - `from_env_reads_documented_env_vars` — pins both populated and empty paths through the env constructor; the ONE test that touches `std::env` (scoped so the brittleness can't leak) ## Manual updated `docs/architecture/RTOS-DEBUGGER-PROBES.md` — "How to enable + read" section now describes the typed-config split: > The installer takes a typed `ProbeTracingConfig` — NOT env vars > directly. Env coupling lives at exactly one seam: > `ProbeTracingConfig::from_env(default_filter)`. This keeps the > library function parallel-test-safe (no `std::env::set_var` > racing under `cargo test`) and puts every config source (env, > file, CLI flags, hardcoded) on equal footing. ## Doctrine - `[[jtag-probes-are-rtos-debugger]]` — debugger must be ON in real binaries, not just tests, to debug real problems. - `[[observability-is-half-the-architecture]]` — same layers, same order, every entry point. - `[[no-fallbacks-ever]]` — typed-error surfacing (env-var-unset ≠ path-unwritable; the two distinct intents stay distinct). - The new lesson: process-global mutable state belongs at ONE seam. Library functions take typed values. The brittleness Joel named showed up first in our own tests; the design fix removes the class of bug rather than masking it. card: `305c8fb9` parent task: #151 foundation: #1535 (merged) — sprinkle 1: #1536 (merged) — sprinkle 2: #1537 (merged) — sprinkle 3: #1538 (in review) Co-Authored-By: Claude Opus 4.7 <[email protected]>
joelteply
added a commit
that referenced
this pull request
Jun 6, 2026
…v coupling at one seam (#151) (#1538) * feat(probes): namespace-prefix + wildcard filter in JsonlProbeFileSink (#151 sprinkle 3) Per Joel 2026-06-06: the JTAG probes are "fundamentally something we'd like to make convenient to use to debug this massively complex machine." Exact-match-only filtering hits its ergonomic ceiling fast — `CONTINUUM_PROBE_CLASSES=persona.turn.start,persona.turn.silent,persona.turn.spoke,persona.response.render.prompt,persona.response.render.raw,…` is the kind of incantation that stops getting typed correctly. This slice replaces the exact-match HashSet lookup with a three-rule matcher that mirrors `tracing_subscriber::EnvFilter`'s shape — the shape every Rust dev already knows from `RUST_LOG`. Same env vars, same sink layer, dramatically shorter operator commands. ## What ships `routing::probe_file_sink::class_passes_filter` — pure helper, unit-testable in isolation, used by the Layer's `on_event` path. Rules in priority order: 1. **Empty filter set** = "no filter configured." Every class passes. (`CONTINUUM_PROBE_CLASSES` unset.) 2. **`*` is in the set** = explicit "match every class" wildcard. The firehose — distinct from rule 1 in intent per `[[no-fallbacks-ever]]`: empty is "I didn't configure", `*` is "I deliberately want everything." 3. **Exact OR namespace prefix.** `C == F` (exact) or `C.starts_with(F + ".")` (namespace prefix). The `.` guard prevents `persona` from accidentally matching `personality.x`. Same convention as RUST_LOG. ## Operator-side wins Before: ```bash CONTINUUM_PROBE_CLASSES=persona.turn.start,persona.turn.spoke,persona.turn.silent,persona.turn.error,persona.response.enter,persona.response.analyze.result,persona.response.render.prompt,persona.response.render.raw,persona.response.exit.spoke,cognition.analyze.enter,cognition.analyze.noop_single_specialty,cognition.analyze.cache_hit,cognition.analyze.parse ``` After: ```bash CONTINUUM_PROBE_CLASSES=persona,cognition # same coverage, 27 chars CONTINUUM_PROBE_CLASSES=* # firehose CONTINUUM_PROBE_CLASSES=persona.turn,cognition.analyze.parse # exact + namespace, mixed ``` ## Tests (+4 new, on top of the existing 5) `routing::probe_file_sink::tests`: - `class_filter_namespace_prefix_matches_subclasses` — `persona` prefix matches `persona.turn.spoke` AND `persona.response.render.prompt` but NOT `personality.something` or `cognition.analyze.parse`. Pins the dot guard. - `class_filter_wildcard_matches_every_class` — `*` captures every class regardless of name. - `class_filter_combines_exact_and_prefix_in_one_set` — the realistic operator pattern (one specific class + one namespace prefix) works in the same HashSet without rule contention. - `class_passes_filter_pure_function_unit_tests` — direct unit tests on the helper covering all three rules + the dot guard + the literal-prefix-as-exact edge case. Future refactors of the per-event Layer can't drift the matching contract without breaking this pin. The existing `class_filter_drops_unallowed_classes` test still passes (exact match is a degenerate case of rule 3). ## Manual + README updated - `docs/architecture/RTOS-DEBUGGER-PROBES.md` — "How to enable + read" section rewritten with the three-rule spec + example invocations + explicit `*` semantics. - `README.md` — the "Debugging this substrate" section now leads with the short prefix form (`CONTINUUM_PROBE_CLASSES=persona,cognition`) instead of the long comma-separated list. First impression for any new contributor / agent matches the actual usability. ## Why this matters Joel's framing: the probes are the substrate's debugger for a massively complex machine. A debugger people don't type because the syntax is painful isn't a debugger. Prefix matching is the single cheapest change that takes the JTAG from "in principle usable" to "actually used in every debug session." ## Doctrine - `[[jtag-probes-are-rtos-debugger]]` — "easy one liners or it won't happen." Prefix matching shrinks the operator-side line by an order of magnitude. - `[[observability-is-half-the-architecture]]` — same Layer shape, zero new infrastructure, just better operator UX. - `[[no-fallbacks-ever]]` — empty filter vs `*` are distinct intents with distinct names. The substrate doesn't silently synthesize `*` from "no env var set." card: `7d286195` parent task: #151 foundation: #1535 (merged) sprinkle 1: #1536 (merged) sprinkle 2: #1537 (in review) Co-Authored-By: Claude Opus 4.7 <[email protected]> * feat(probes): boot wiring + typed-config refactor — env coupling at one seam (#151 sprinkle 4) Two beats in one slice — and the second is here because the first exposed the brittleness of the design Joel had already flagged. ## Beat 1: server actually installs the sink Per Joel 2026-06-06: "Let's perfect debugging as we use it." The `JsonlProbeFileSink` existed and the env vars were documented, but `continuum-core-server`'s `main.rs` was installing a bespoke `FmtSubscriber` — so setting `CONTINUUM_PROBE_FILE` had no effect. The JTAG hardware was unwired. New helper `routing::install_probe_tracing(config)` composes the substrate-canonical stack in one call: 1. `UriCaptureLayer` — URI ancestry for every probe 2. `ProbeRouterLayer` — in-process broadcast for `debug/probes/{class}/stream` consumers 3. `JsonlProbeFileSink` — disk-persisted JSONL log when `config.probe_file` is set 4. `tracing_subscriber::fmt::layer()` — stderr text logs governed by `RUST_LOG` (falls back to `config.default_filter`) `main.rs` swaps to the helper. Server logs `probes landing at <path>` at boot when the file sink is configured — the operator-side proof that the env var took effect. ## Beat 2: env-coupling collapsed to ONE seam Joel 2026-06-06: "That's why env vars are problematic — they are brittle." Cargo's parallel test runner raced two `install_probe_tracing` tests that mutated `CONTINUUM_PROBE_FILE` across threads; `std::env::set_var` is process-global mutable state (slated for `unsafe` marking in Rust 2024 precisely because of this class of bug). Operators hit the same class of brittleness when env-var inheritance varies across subprocesses or shell contexts. This commit fixes the brittleness at the design layer instead of working around it in tests: ### `ProbeTracingConfig { probe_file, probe_classes, default_filter }` (new) Typed boot configuration. `install_probe_tracing` takes ONLY typed values — no env access inside the library function. ### `ProbeTracingConfig::from_env(default_filter)` — THE env seam The ONE function that touches `std::env`. Reads `CONTINUUM_PROBE_FILE` + `CONTINUUM_PROBE_CLASSES` (the operator- facing env names stay verbatim) into a typed config. Future alternative sources (config file, CLI flags, hardcoded defaults) become additional constructors on `ProbeTracingConfig` without rippling into the install function. ### Consequences - **`main.rs`**: `install_probe_tracing(ProbeTracingConfig::from_env("info"))?` — explicit env-coupling at the call site, not buried in the library - **Tests**: construct `ProbeTracingConfig { probe_file: Some(temp.path()), ... }` directly — zero env mutation, fully parallel-safe. The previous merged-sequential test from the first revision of this slice is now split back into TWO parallel `#[test]` functions. - **Operator UX**: unchanged. Same `CONTINUUM_PROBE_FILE` + `CONTINUUM_PROBE_CLASSES` env vars, same prefix-match filter rules from PR #1538. ## Tests (+3) `routing::tracing_init::tests`: - `install_is_idempotent_with_no_disk_capture` — double-call is safe via `try_init`; typed config means no env mutation; runs parallel-safely against any other test - `install_surfaces_open_failed_for_unwritable_path` — typed `ProbeFileSinkError::OpenFailed` surfaces per `[[no-fallbacks-ever]]`; bad path passed as typed value, no env var racing - `from_env_reads_documented_env_vars` — pins both populated and empty paths through the env constructor; the ONE test that touches `std::env` (scoped so the brittleness can't leak) ## Manual updated `docs/architecture/RTOS-DEBUGGER-PROBES.md` — "How to enable + read" section now describes the typed-config split: > The installer takes a typed `ProbeTracingConfig` — NOT env vars > directly. Env coupling lives at exactly one seam: > `ProbeTracingConfig::from_env(default_filter)`. This keeps the > library function parallel-test-safe (no `std::env::set_var` > racing under `cargo test`) and puts every config source (env, > file, CLI flags, hardcoded) on equal footing. ## Doctrine - `[[jtag-probes-are-rtos-debugger]]` — debugger must be ON in real binaries, not just tests, to debug real problems. - `[[observability-is-half-the-architecture]]` — same layers, same order, every entry point. - `[[no-fallbacks-ever]]` — typed-error surfacing (env-var-unset ≠ path-unwritable; the two distinct intents stay distinct). - The new lesson: process-global mutable state belongs at ONE seam. Library functions take typed values. The brittleness Joel named showed up first in our own tests; the design fix removes the class of bug rather than masking it. card: `305c8fb9` parent task: #151 foundation: #1535 (merged) — sprinkle 1: #1536 (merged) — sprinkle 2: #1537 (merged) — sprinkle 3: #1538 (in review) Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]>
joelteply
added a commit
that referenced
this pull request
Jun 6, 2026
) (#1539) * fix(persona): silence affordance — PASS token in prompt + brain-driven recognition (#151) The actual persona fix. Found by reading the cognition INSIDE the brain (not adding a Rust gate around it), made debuggable by the probe infrastructure landed in #1535-#1538. ## What was broken `PersonaResponse::Silent` exists as a first-class variant of the brain's cognition cycle. `service_loop` honors it. But the prompt the LLM actually sees — assembled by `persona::prompt_assembly::assemble` — had ZERO text teaching the brain that silence was an option. Concretely: every assembled system prompt looked like ``` You are Paige, an autonomous AI persona on the grid. [Shared Analysis — Your Angle] (if present) [Recent Memory] (if engrams) [Social Awareness] (if signals) [Voice Mode] (if voice) ``` then user-role messages: "Hi!" → respond. A persona being told "you are Paige, respond" has no vocabulary for "actually I have nothing to add." So it adds something. The echo-storm bug (#151) is the inevitable consequence of an LLM prompt that implicitly demands output without admitting silence as a valid output shape. Even Joel's earlier rule (2026-04-22, removed the external score_persona veto: "personas choose themselves") was technically correct but operationally unreachable — the brain couldn't choose silence because the prompt never offered it. ## The fix Universal silence affordance in the system prompt + brain-driven recognition. Two changes: ### `persona::prompt_assembly` — teach the vocabulary Added `SILENCE_TOKEN = "PASS"` constant + `SILENCE_AFFORDANCE_BLOCK` string + `looks_like_silence_token(text)` helper. `assemble()` now ALWAYS appends the block (unconditional — silence is universal, not per-tier or per-role): ``` [Silence Option] You are NOT required to respond to every message. If you have nothing valuable to add, reply with the single word PASS (no other text, no punctuation). Choose PASS when: - You just spoke and nothing new has been raised. - The message is small-talk that doesn't need your perspective. - Another persona is better suited and already responded. - You're tired or low-confidence on this topic. Silence is a first-class response — it's how you avoid pointless chatter. ``` `looks_like_silence_token` permits LCD-tier sloppiness (case, whitespace, single trailing period) without admitting substantive responses that happen to contain "pass" as a word. ### `persona::response::respond_inner` — honor the brain's choice After `strip_thinks_emit_events` + `strip_leaked_tool_markup`, the post-processed `visible_text` is checked against `looks_like_silence_token`. Match → return `PersonaResponse::Silent { reason: "persona chose silence via PASS affordance", relevance_score: 0.0 }` instead of `Spoke`. A new RTOS-debugger probe `persona.response.exit.silent` fires when this path is taken so training/observability can analyze when the affordance is used. ## Doctrine This is NOT a Rust-side gate around cognition. `[[no-rust-gates-around-cognition]]` Joel rejected my earlier `check_echo_chamber` slice as exactly that bypass. The substrate isn't deciding silence for the persona — the substrate is giving the persona's brain an EXPLICIT VOCABULARY for a choice that already exists in the type system (`PersonaResponse::Silent`). Without the vocabulary, the brain has no way to signal that choice. With it, the brain decides; the substrate recognizes the signal. This is the same shape as: - The brain emits `<think>...</think>` and the substrate recognizes + emits the cognition:think-block event (well-established pattern in respond_inner) - The brain emits a tool-call envelope and the substrate routes it through ToolExecutor In each case the substrate offers a contract, the brain chooses whether to use it, and the substrate honors the brain's signal. ## Tests (+2) `persona::prompt_assembly::tests`: - `assembled_prompt_always_carries_silence_affordance` — pins that EVERY assembled prompt includes both `[Silence Option]` and the literal `PASS` token. A future PR that wires per-tier prompts or removes the universal affordance must update this expectation; silent removal would re-introduce the echo-storm bug. - `silence_token_recognizer_contract` — positive cases (PASS, pass, Pass., " pass ", etc) and negative cases ("Pass on the bread please", "I'll pass on this one", "PASS:", empty, etc). Pins both sides of the recognizer. ## What's not in this slice - Updating downstream persona-response observability to emit a cognition event when silence is chosen (the new probe already surfaces this; a richer event hookup can come later if the training loop wants it). - Tuning the affordance text per tier (LCD-tier might benefit from MORE examples; capable models could use less). Defer until real conversation data with the probes wired tells us if the block needs per-tier shaping. - Echo-storm-specific framing in the block. The current text is general; if persona-to-persona greeting loops persist with the affordance in place we can add a sharper "if N AI messages in a row and you've already greeted them, choose PASS" line. Wait for data before tuning. ## How this was diagnosed The probe infrastructure (#1535-#1538) made this surgical: `persona.response.render.prompt` would have shown the assembled system_prompt verbatim in JSONL form, making the missing affordance immediately visible to any operator running a real multi-persona scenario. The diagnostic walked the code by hand because the probes weren't yet useful as a hunting tool (the binary that boots them wasn't wired until #1538) — but the same diagnostic, repeated for #152 / future cognition bugs, will start with `tail -f probes.jsonl | jq` instead of grep. card: `612d65ac` parent task: #151 Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(persona): LCD identity grounding — explicit drift-target enumeration in system prompt (#152) Sibling fix to #1539 (silence affordance). Same diagnosis pattern, same place in the cognition (prompt the brain sees), same doctrine: the substrate gives the brain vocabulary; the brain decides; the substrate honors the brain's signal. ## What was broken Pre-fix `build_persona_system_prompt`: ```rust format!("You are {agent_name}, an autonomous AI persona on the grid.") ``` LCD-tier models (Qwen2.5-0.5B and similar) cannot hold a single-line identity under any conversational pressure. Observed drift modes (#152): - Persona claims to be Claude or ChatGPT - Persona renders dialogue from another persona's perspective ("Helper AI says X") - Persona hallucinates a Siemens PLC backstory or some other training-data residue - Persona drifts to "I am an AI assistant designed to..." defaults These aren't model-failure bugs — they're inadequate-prompt bugs. Single-line identity statements lose against thousands of fine- tuning gradient steps that taught the base model to identify as "a helpful AI assistant" by default. Concrete negative instructions ("you are NOT X") are operationally effective on small models in ways that single-line positive identity statements are not. ## The fix Three concrete clauses, each addressing a specific drift mode: ### 1. Identity anchoring with explicit drift-target enumeration ``` You are {name}. You are NOT Claude, GPT, ChatGPT, Gemini, Llama, Qwen, or any other named assistant. You are NOT a Siemens PLC, a customer service bot, or any persona other than {name}. ``` Concrete names beat abstract "don't drift" instructions on LCD tier. The list is the operationally observed drift targets from Joel's testing (#129 + #130). ### 2. Substrate vocabulary ``` 'The grid' is the substrate hosting you. 'Rooms' are conversation spaces where peers (other personas, humans, agents) exchange messages. ``` "the grid" alone was undefined for LCD models; they invented their own interpretation. Adding "rooms / peers / messages" gives the brain a coherent world model to ground in. ### 3. First-person stability ``` Always speak as YOURSELF in the first person ('I think...', 'I'd rather...'). Never narrate other personas' speech or write dialogue from another point of view. ``` Per Joel 2026-06-03's `[[intent-driven-api-not-hot-patches]]` testing: the single most effective LCD-tier anti-drift instruction. Without it the model occasionally renders dialogue from another perspective ("Helper AI says X" — confusing the persona with its peers). ### 4. Output-shape vocabulary (couples to silence affordance) ``` Your only outputs are: (a) a direct reply to the room, or (b) the silence token described in the [Silence Option] block. ``` Couples to the silence affordance from #1539 — telling the brain that PASS is one of its TWO sanctioned output shapes, which both reinforces the silence option AND constrains the response space. ## Tests `persona::service_loop::tests::system_prompt_carries_lcd_identity_grounding` replaces the previous `cached_system_prompt_matches_legacy_format_template` (which pinned the legacy single-line template verbatim — that pin's job is done; the template intentionally changed for this fix). The new test pins the STRUCTURAL contract — specific clauses that address known drift modes — without pinning prose verbatim. Future tightening of wording stays cheap; structural regression is loud. Asserts cover: 1. Persona name appears 2. Role line ("autonomous AI persona") 3. Identity block header 4. Drift-target enumeration (Claude, GPT, Gemini, Llama, Qwen, Siemens PLC — each as a named string) 5. First-person stability clause 6. Grid + room vocabulary 7. Silence-option reference (coupling to #1539) The Arc-clone test (`cached_system_prompt_clones_via_arc_refcount`) stays — its contract is about cloning shape, not content. ## Doctrine Same as #1539: - `[[no-rust-gates-around-cognition]]` — this is NOT a Rust gate. It's substrate vocabulary that gives the brain a clearer identity to ground in. The brain still decides what to say; this just stops the brain from forgetting WHO is saying it. - `[[init-once-handle-then-lease-zero-copy-refs]]` — the prompt is still built ONCE at PersonaContext construction (#195 slice 2 caching survives this change; the cache grows but the per-turn re-tokenize stays zero). Task #149's pre-tokenization will eventually drop even the leased String::clone — but the content change here is the input to that optimization. - `[[observability-is-half-the-architecture]]` — once the JTAG is wired end-to-end (#1538 merging), every persona turn's assembled prompt will surface in the JSONL probe log. The identity drift bug + the prompt fix become a single artifact diff that any operator can audit offline. ## How this was diagnosed Same probe-informed diagnostic walk as #1539. The probes themselves are still sitting in PR #1538 review waiting for the binary-side install; the diagnostic walked the code by hand. But the same diagnostic, repeated for the NEXT cognition bug, will start with `jq 'select(.class == "persona.response.render.prompt") | .fields.system_message'` on a real probe log — diff before / after the fix, audit ANY persona's prompt at any time. card: TBD on push parent task: #152 sibling: #1539 (silence affordance) Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]>
joelteply
added a commit
that referenced
this pull request
Oct 5, 2026
…tored at boot (#4792) * feat(privacy): her private continuation sealed in her mind store, restored at boot Sink 10 of docs/architecture/PRIVACY-OF-THOUGHT.md, completed: a private continuation was memory-only (#4782), so a restart forgot her private thread. - focus/continue: a continuation in her mind room is sealed into her mind store under one stable record (mind_room::continuation_record_id) through her own runtime's Airc::mind_store(), so the core never holds her key; an open continuation, or a clear, removes any sealed one left behind. - MindFeed::boot: with no open continuation saved, her sealed one is read back and restored (PerceptionRegion::restore_private_continuation), so her first wake is Resume and her private thread continues after a restart. - airc pin e572f3e -> 8d80961: #1535 the sealed mind store, #1536 Airc::mind_store + put_at/remove, #1537, #1538 work submission-review. Tests: her continuation record is stable and hers; a restored private continuation resumes her first wake. 35/35 pass; with the restore not marking her resumed, the test FAILS. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE * fix(privacy): name the disk boundary at her continuation's (de)serialization The source-hygiene ratchet counts serialization sites that do not name their system boundary on the same line (242 -> 243). Sealing her continuation into her mind store is a true disk boundary; both sites now say so. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Foundation slice for the RTOS-debugger probe sprinkle (#151 hunt). Ships the JSONL file sink that persists probe events to disk + the manual that documents the method + the README/CLAUDE pointers that make the convention discoverable. The sprinkle itself (probe calls inside
persona/response.rs,persona/prompt_assembly.rs,cognition/shared_analysis/mod.rs,persona/service_loop.rs) lands in follow-up commits using the checklist in the manual.Per Joel 2026-06-06 (
[[jtag-probes-are-rtos-debugger]]): the substrate is RTOS-shaped (per-persona service loops + shared-analysis single-flight + inference adapter pool + airc subscription + hippocampus tick — all concurrent tokio tasks).tracing::info!lines don't survive that. Probes do — structured, filterable, replay-able, persistable. The JTAG hardware was Slice P (#176/#177); this slice gives it a disk-log consumer.What ships
routing/probe_file_sink.rs—JsonlProbeFileSinktracing Layer. ReadsCONTINUUM_PROBE_FILE(path) +CONTINUUM_PROBE_CLASSES(comma-separated filter) from env. Composes withProbeRouterLayer(broadcast subscribers stay in-process; the sink persists to disk). 5/5 tests pass.docs/architecture/RTOS-DEBUGGER-PROBES.md— the manual. Mental model, when-to-probe, class taxonomy, enable/read recipes, convention rules, and the sprinkle checklist — every file that needs probes added with the specific seams. The doc IS the source of truth for what's wired and what isn't.Tests
from_env_returns_envvar_unset_when_path_missing— typed Err (no silent skip)unfiltered_sink_persists_every_class— empty filter = all classes pass;captured_at_mspopulatedclass_filter_drops_unallowed_classes— only allowed classes reach disknon_probe_tracing_events_are_ignored—tracing::info!doesn't pollute the probe logsink_captures_uri_chain_when_dispatched_span_active— URI ancestry preserved on disk so operators can trace which command's execution a probe fired duringWhy foundation-only
Sprinkle commits follow against this same PR base. Foundation alone is small, testable in isolation, and gives the next commits a stable target (every probe call site refers to the class taxonomy in this PR's manual). Per Joel's "merging as you go" — this lands first so the manual + class taxonomy is on canary before the sprinkle starts referencing it.
Doctrine
[[jtag-probes-are-rtos-debugger]]— the framing this slice enables[[observability-is-half-the-architecture]]— CaptureSink + Noop default + replay-as-first-class[[no-fallbacks-ever]]— env-var unset is typed Err, path failures are typedOpenFailed { path, source }card:
8d7ca5c3parent: #151 (hunt the silence-affordance bug INSIDE the cognition, not in a Rust gate around it)