Repository navigation
feat(perception): live-call perception into cognition — rings, à la carte look, change-monitor, governed - #1961
Merged
Merged
Conversation
…h) + single-source SharedCompute The persona's live-call visual perception now reaches the globally-aware mind. `MediaPerceptionSource` is lifted into each persona's Workspace grounding set at supervisor boot (the same task-#12 RagSourceFaculty bridge roster/doctrine use), so WHO is visible on the call + a description of what they show becomes budgeted, non-blocking framing — read only from cells resolved this tick, competing for context through the ONE flexbox allocator so perception never dominates. Single-source the compute-once cache so the read side and the (coming #192) media ingest cannot diverge: - `runtime::shared_compute::global()` — the ONE process-global SharedCompute; a frame's derivatives (scaled cells, description) are content-hash keyed so N personas viewing one frame describe/scale it ONCE (the multi-persona vision moat). - `Runtime::new` ADOPTS that instance for its own `compute` handle, so a module reaching it via ModuleContext.compute and a persona reaching it via global() see the same cache. - `media::perception_registry()` — the addressable per-persona PerceptionBuffer home (one home, two reachers by persona_id: ingest warms, source reads), mirroring focus::registry(). AMBIENT_PERCEPTION_SIZE (480x270) is the one ambient-cell policy. Read side is off the 30fps media plane entirely: deliver() runs per persona TURN (seconds apart), O(participants) string assembly, no inference, reads only ready cells. The ingest cadence gate (describe << frame rate, governor-priced) lands with the video_rx -> observe() wire in #192. Empty until frames arrive — this wires the READ path into cognition; nothing on the brain's compose path changed (unified.rs untouched — perception is a NEW source with no legacy compose consumer, so only the target Workspace path is wired). Tests: perception_registry idempotent one-buffer-per-persona + singleton; existing source/buffer/compute suites green. Refs #187 #106; sets up #192. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…by construction MANY personas render at 30fps and humans join at 30fps; the ingest primitive must survive that BEFORE #192 wires a raw stream to it. `observe()` previously spawned an LLM describe + scale on EVERY call, and 30fps frames each have a distinct content-hash so the compute-once cache gives ZERO dedup on the frame rate — a raw wire would trigger 30 vision inferences/sec/participant/persona. Separate the two planes: - COALESCE the latest frame UNCONDITIONALLY (O(1) mutex insert — safe at 30fps; the media/display plane). Perception samples the media plane, it does not mirror it. - GATE the expensive warm (scale + describe) behind a per-participant cadence (AMBIENT_WARM_MIN_INTERVAL_MS = 500ms ≈ 2Hz) + an in-flight guard that never stacks a warm on an unfinished one. Extracted as a PURE `should_warm(participant, now_ms)` decision so the 30fps guarantee is asserted without timing or a runtime. `observe()` now takes `now_ms` (substrate passes the monotonic clock in — no Instant::now in the media core). The cadence is a buffer FIELD (default from the const), so the governor can retune it per persona later as an attention-priced resolution field (#173) — a focused persona looks more often, an idle one less. Cross-persona cost stays O(distinct frames), not O(personas): the actual scale/describe runs on the ONE global SharedCompute keyed by content-hash, so N personas viewing one participant's frame share ONE describe (the multi-persona vision moat vs cloud, where N personas = N API calls). The per-persona gate/spawn is cheap and cache-hits after the first. Tests: cadence gates within the interval + reopens after; in-flight guard never stacks. Existing coalesce/read suites updated for the now_ms arg, green. Refs #187 #173; sets up #192 ingest. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…e escalates "Slow cadence not NO cadence" (Joel): an idle observer must not be starved of vision — absent motion it DECAYS to a slow baseline, it does not go to zero. The warm decision is now a band, not a single throttle: - MIN ceiling (AMBIENT_WARM_MIN_INTERVAL_MS = 500ms): never describe faster, even under constant motion — the 30fps rate cap. - BASELINE floor (AMBIENT_WARM_BASELINE_INTERVAL_MS = 5s): describe at LEAST this often even on a dead-static scene — a still participant still refreshes every few seconds so room-as-now stays true, just coarse. - change signal (in between): a relevant motion/scene-change/YOLO hit escalates to the MIN ceiling long before the floor. should_warm now takes `changed`: `warm if !in_flight && (first || (changed && past_min) || past_baseline)`. Both branches are unit-tested (change→fast, static→slow-floor, never-stack). Both intervals are FIELDS so the governor shrinks them for the speaking/acting persona and widens them for idle observers later (attention-priced resolution field, #173) — but never to infinity. observe() passes `changed = true` as a documented INTERIM: no change detector wired yet, so every coalesced frame is treated as potentially-changed (cadence rides the MIN ceiling, behavior-preserving). #192 replaces that `true` with a cheap motion/scene-change/YOLO detector cell (compute-once/shared on the frame hash), at which point a static scene decays to the baseline floor and describes are spent only where something changed. Refs #187 #173 #192. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…eads The spine of the shared-cache perception design: stop thinking "hand each persona images," think "one shared pre-warmed ring per source; personas read views." - PerceptionBuffer's per-participant `latest: MediaFrame` becomes a bounded `FrameRing` (VecDeque, AMBIENT_RING_CAPACITY=8, newest at head). The ring IS the sliding window AND the pre-warmed cache in one object: frames are Arc handles, derivatives dedup by content-hash on the ONE shared compute, so K frames × N sources is cheap and never duplicates a derivative across viewers. `push` coalesces an identical-content head and evicts the oldest past capacity (room-as-now, bounded). ring_capacity is a field so the governor can deepen a source's window later (#173). - Two serving shapes off the ONE store, both zero-copy over warm cells: - GROUPED: `current_percepts` = every ring's HEAD — "everyone at a glance," the human-widget gallery (behavior-preserving: head = the old "latest"). - WINDOWED: `window_percepts(participant, k)` = one source's last-k, newest-first — "what changed / what did I miss." Unknown source → empty (never a fabricated look). Both go through one `percept_of` projection (compression: a frame becomes a percept in exactly one place). This is the foundation for the pull/contact-sheet read (next), the room warm-loop + tiled grouped-describe, and the change signal (compare consecutive ring heads → #192). Design captured in memory (dual-perspective RTOS perception scoring). Tests: ring windows newest-first + coalesces head + bounds capacity; grouped=all-heads vs windowed=one-source-history; existing coalesce/read/cadence suites green (10/10). Refs #187 #192 #173. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…nail/res/full, ASAP "Into their vision à la carte": a persona composes its own view — request images of ONE source or the whole GROUP, at THUMBNAIL / higher-RES / FULL, satisfied ASAP. PerceptionBuffer::look(scope, fidelity, compute) — the PULL side, distinct from the ambient PUSH band: - scope = Source(id) | Everyone (the contact-sheet / gallery). - fidelity = Thumbnail (ambient) | Res(DestSize) (higher/lower) | Full (raw bytes). Higher-res is just a different SIZE key on the same content-hash, so it's compute-once/shared exactly like the thumbnail — a res another persona already pulled is a cache hit here (proven: repeat pull returns the SAME Arc). - ASAP: warm hit → instant; cold cell → warmed NOW. It never consults the ambient warm gate, so a manual pull implicitly JUMPS the cadence band (an explicit high-priority ask). - This is the ONE place perception AWAITS (a deliberate request, not the ambient hot path); targets are snapshotted under the lock and compute is awaited OUTSIDE it (no lock across await). Unknown source → empty (never a fabricated look). With the FrameRing store, that completes the pull model: grouped gallery, per-source history (window_percepts), and now on-demand images at any fidelity — all off the ONE shared, compute-once cache. Tests: source/group × thumbnail/res/full, prefer-warm sharing (same Arc), full=raw, unknown→empty. 11/11 perception suite green. Refs #187 #192. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…es the warm band Replaces the interim `changed = true` with an actual per-source change detector — the universal monitor that gates the expensive describe (any view: call, game, page, movie). - MediaFrame gains a SIGNATURE cell: a tiny 16x12 luma fingerprint (image_ops::luma_signature), compute-once/shared on the content hash like scale/describe — warmed first in the observe spawn (it's the cheapest and it gates the rest). - observe now computes real `changed` via PerceptionBuffer::scene_recently_changed: diff the two most recent frames whose signature has WARMED (image_ops::luma_mean_abs_delta > CHANGE_THRESHOLD=8/255). Reads only ready cells — never awaits on the ingest path; cold start / signatures still warming → true (ride the MIN ceiling until we can tell). So a static scene now genuinely decays to the BASELINE floor; real motion/scene/slide change escalates. - Cheap by construction: a bounded ring scan + a ~192-byte diff, fine per ingest. The signature is shared, so N watchers of one frame diff ONE fingerprint (compute-once on CHANGE, the moat now on the monitor too). should_warm stays pure + param-driven (band logic unchanged, still fully tested); observe just feeds it a real signal instead of a placeholder. NOTE (next commit, per Joel): register perception as a ResourceConsumer with the resource governor (RAM = ring frame bytes; sibling to Serving/Bevy/Voice consumers) so its footprint is accounted and it leases — the "register with the GPU resource monitor" ask. Disk consumer comes with the durable record. Tests: luma signature + delta detect change; signature cell computes-once/shared; scene_recently_changed (same scene → not changed, different → changed, unknown → assume). 23/23 media suite green. Refs #187 #192 #56. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…AM footprint + reclaim) Perception takes its seat at the resource-governor table (#56) — a peer consumer beside Serving (VRAM), Bevy (render VRAM), and Voice (TTS), exactly as Joel asked ("register with the GPU resource monitor"). - PerceptionConsumer (modules/perception_consumer.rs) implements ResourceConsumer: - consumer_id "perception"; footprint() reports Ram = total ring frame bytes read live from the process-global PerceptionRegistry (empty when idle, like the siblings). - reclaim(Ram) evicts oldest ring frames toward the target but ALWAYS keeps each source's head — a live perceiver is never blinded (room-as-now survives a reclaim). Honest Released/Partial with real freed bytes; a non-Ram ask is refused by name (never silent). - Byte accounting + eviction added at each layer: FrameRing::{resident_bytes, evict_oldest}, PerceptionBuffer::{resident_bytes, evict_at_least}, PerceptionRegistry::{total_resident_bytes, evict_at_least} (clones Arcs out — no registry lock held across per-buffer work). - Registered at the boot seam (ipc/mod.rs) right after Voice + Bevy via resource_daemon.add_consumer. Honest scoping: perception holds RAM (the rings it owns), NOT VRAM — the vision-describe it triggers runs on the served VL model, whose VRAM is ServingConsumer's footprint; perception is a demander of that lane, not a holder of its bytes. The shared derivative cache (thumbnails/descriptions/signatures on SharedCompute) is not double-counted here. Disk consumer for the durable record follows when that lands (same pattern, ResourceKind::Disk). Tests: footprint == ring RAM + empty-when-idle; reclaim evicts oldest, keeps head, honest Partial, refuses wrong kind. Green. Refs #56 #187 #192. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
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.
What
Wires live-call perception into the persona's cognition and builds the shared, governed, universal perception substrate underneath it. 7 validated commits; the whole media suite is green.
The mental model (fully captured in memory): one shared pre-warmed ring per source; personas hold cursors/views; serving is a query — grouped (gallery) or windowed (history) or à la carte pull — and it's all the persona's own self-directed view. The system is the humble RTOS-like daemon that is everyone's eyes.
Commits
SharedCompute—MediaPerceptionSourcelifted into each persona's Workspace grounding (task-Build(deps-dev): Bump eslint from 8.57.1 to 9.24.0 #12 bridge);Runtimeadopts the ONE global compute so cross-persona cost is O(distinct frames), not O(personas) (the multi-persona vision moat).observe()coalesces at 30fps (O(1)) but gates the expensive warm; 30fps-safe by construction.FrameRingstore — bounded sliding window = the pre-warmed cache in one object; grouped (current_percepts) + windowed (window_percepts) reads.look()à la carte — pull a source or the group at thumbnail / higher-res / full, satisfied ASAP (warm hit instant, cold warmed now, jumps the band); higher-res is a size-key on the same content hash, so compute-once/shared.PerceptionConsumer— perception joins the resource governor (Build(deps): Bump commander from 13.1.0 to 14.0.0 #56) as a peer beside Serving/Bevy/Voice: reports RAM (ring frame bytes), reclaim evicts oldest frames but always keeps each source's head (never blinds a live perceiver).Scope / honesty
ServingConsumer's footprint). No double-counting the shared derivative cache.unified.rs(the brain) is untouched — perception is a NEW source wired only to the target Workspace path, not the legacy compose path mid-cutover.Validation status
media::*+PerceptionConsumer+shared_computesuites green;should_warm/band logic pure-tested; runtime isolation confirmed after the global-compute adoption.video_rx → observeLiveKit ingest is Phase 2: memory systems, vector search, progressive scoring #192. This PR is the substrate; it needs careful live validation with real personas once ingest is wired.Follow-ons (designed, captured)
Persona-facing
look()command (eyes usable from a turn) · room warm-loop + tiled grouped-describe (grouped serve = grouped compute) ·video_rx → observeingest (#192) · durable governed record + its disk consumer (ResourceKind::Disk).Refs #187 #106 #192 #173 #56.
🤖 Generated with Claude Code