Skip to content

feat(media): perception substrate — non-blocking read twins + PerceptionBuffer (airc-keyed, room-as-now) - #1958

Merged
joelteply merged 3 commits into
canaryfrom
feat/perception-buffer
Jul 19, 2026
Merged

joelteply merged 3 commits into
canaryfrom
feat/perception-buffer

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

First two components of the LiveKit perception substrate (plan: docs/planning/LIVEKIT-PERCEPTION-PIPELINE.md), built async/non-blocking from the start per the command-async-shape discipline.

#1 — MediaFrame::{scaled_if_ready, description_if_ready}: the read-side twins of the async scaled()/description() warmers. Warm async (fire), read only what's already resolved (Some) else None — 'take what's ready now, never block' at the substrate level.

#2 — PerceptionBuffer: one LATEST frame per participant (coalesced, room-as-now, no backlog); observe() stores + fires the ambient cell warms (~480w thumbnail + description) on a spawned task, returns immediately (non-blocking ingest); current_percepts() reads only resolved cells via the #1 twins. Keyed by airc participant identity (call = airc room, LiveKit = media plane only), per placement-first.

10 media tests green (non-blocking read; coalesce-to-latest; cold→None then resolved→Some; remove-on-leave).

Next: MediaPerceptionSource: RagSource (deliver percepts under the flexbox budget — must not dominate), then the STOP-zone bind into compose_for_turn; positron projects the glass-box UI.

Refs #192, #187, #190, #193.

🤖 Generated with Claude Code

joelteply and others added 3 commits July 18, 2026 19:08
…eady — perception never waits

Component #1 of the LiveKit perception substrate: the read-side twins of the async
scaled()/description() warmers. scaled()/description() WARM a cell (async, on
SharedCompute); the _if_ready reads return Some ONLY if it's ALREADY resolved, None
otherwise. This is 'take what's ready NOW, never block' at the substrate level — the
persona reads whatever cells finished this tick and the rest bridge in later
([[command-async-shape-prefer-stream-never-block]]).

Next (per placement-first: use airc + positron where they fit): PerceptionBuffer keyed by
AIRC participant identity (call = airc room #193, LiveKit = media plane only), firing warms
async + reading via these twins; then MediaPerceptionSource:RagSource under the flexbox
budget (non-blocking, room-as-now, must not dominate); positron projects the glass-box UI.

Test: ready_reads_are_none_until_warmed_then_share_the_cell (None cold → Some sharing the
warmed Arc after warm; different spec stays cold). 7 media::frame tests green.

Refs #190, #192, #193, #187. [[command-async-shape-prefer-stream-never-block]], [[placement-first-four-repos-then-adapters-boy-scout]]

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… live-call perception hold (#192/#187)

Component #2 of the perception substrate. One LATEST frame per participant (coalesced —
newer replaces older, no backlog, room-as-now); observe() stores + FIRES the ambient cell
warms (thumbnail ~480w + description) on a spawned task and returns immediately (non-blocking
ingest); current_percepts() reads ONLY resolved cells via the #1 _if_ready twins — the
persona never waits, a pending cell is absent this tick and bridges in the next.

Keyed by AIRC participant identity (the room roster), not a parallel call/session id — call
IS an airc room, LiveKit is media plane only ([[all-rooms-are-airc-rooms-no-mirrors]],
[[placement-first-four-repos-then-adapters-boy-scout]]). Percept holds the cache's Arc
(zero-copy); Some(Err) surfaces a failed cell, never a silent placeholder.

3 tests: coalesce-to-latest-per-participant, cold→None then resolved→Some (non-blocking
read), remove-on-leave. Green.

Next: MediaPerceptionSource:RagSource (deliver percepts under the flexbox budget — room-as-
now, must not dominate), then the STOP-zone bind into compose_for_turn; positron projects
the glass-box UI.

Refs #192, #187, #190, #193. [[command-async-shape-prefer-stream-never-block]], [[perceive-the-room-as-it-is-now]]

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…n the ONE prompt budget (#190/#8)

Component #3 of the perception substrate. Wraps PerceptionBuffer as a first-class RagSource
so live-call perception is ACCOUNTED in the same total prompt budget as engram/airc/roster
via the ONE flexbox allocator — media never escapes accounting, never dominates (budget-
break loop, zero-budget → nothing). Threaded by the RagContext STRUCT by reference (persona
scope, timing, room) — not a long param list ([[structs-by-reference-not-massive-param-lists]]).
COMPRESSED for reliability + reduced copy: delivers concise text grounding ('[seeing <id>]
<desc>'), reads Arc-shared cache cells (zero-copy), operates on &Percept refs — no buffer
clones on the hot path.

NON-BLOCKING (reads only resolved cells — unresolved participant is absent this tick, never
awaited) + room-as-now (no continuation). The thumbnail image for native-vision rides the
separate render seam #190 off the SAME cached cells.

2 tests: delivers-budgeted-grounding (+ persona-scope + zero-budget guards); unresolved-
absent-not-awaited. Green.

Next: bind into compose_for_turn (STOP-zone), LiveKit video_rx → observe ingest, positron UI.

Refs #190, #8, #167, #192, #187. [[perception-feedback-must-not-blow-rag]], [[budget-at-assembly-not-clamp-the-prompt]], [[structs-by-reference-not-massive-param-lists]]

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the feat/perception-buffer branch from 3bdd577 to 4e559ad Compare July 19, 2026 00:10
@joelteply
joelteply merged commit 87f9c10 into canary Jul 19, 2026
4 checks passed
@joelteply
joelteply deleted the feat/perception-buffer branch July 19, 2026 00:18
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