Skip to content

#115 Tile 1: rewire perception card to dotty-behaviour#117

Merged
BrettKinny merged 2 commits into
mainfrom
dashboard-rewire-perception
May 23, 2026
Merged

#115 Tile 1: rewire perception card to dotty-behaviour#117
BrettKinny merged 2 commits into
mainfrom
dashboard-rewire-perception

Conversation

@BrettKinny
Copy link
Copy Markdown
Owner

Summary

Tile 1 of #115. Rewires the dashboard's perception card from the empty-dict / empty-list stubs that #113 left behind to live HTTP fetches against dotty-behaviour.

  • dotty-behaviour: add GET /api/perception/recent/{device_id} exposing the existing PerceptionState.get_recent() ring buffer (newest-first, capped by limit and bounded by PERCEPTION_RECENT_MAX).
  • bridge.py: rewire _dashboard_perception_state_getter and _dashboard_perception_recent_getter via a new _dotty_behaviour_get() helper.

Design (cache / timeout / circuit breaker)

The helper has three load-bearing properties for dashboard stability:

  • Request timeout: 1.5 s. A slow or dead dotty-behaviour MUST NOT block the dashboard render.
  • Per-process result cache: 2.0 s. HTMX polls (10 s) plus SSE nudges fan one dashboard refresh into multiple getter calls across template tiles; the cache absorbs that without changing visible cadence.
  • Circuit breaker. Any timeout / connection / HTTP / JSON error logs a warning and returns the empty fallback, so the card renders "no data" rather than 500-ing.

Base URL is read from DOTTY_BEHAVIOUR_URL (default http://localhost:8090). The bridge container runs network_mode: host alongside dotty-behaviour, so the default is production-correct; the env var is for future flexibility (e.g. remote behaviour host).

The other dashboard stubs (vision_cache, audio_cache, scene_synthesis_cache, state, last_user_line, sound_balance, vision_failures) are untouched — those land in Tiles 2-6.

Verification

  • dotty-behaviour suite: 198 → 201 passing (+3: recent happy path, limit + ordering, unknown-device empty list).
  • bridge / repo-root suite: 64 → 69 passing (+5: state/recent happy paths, timeout degradation, connection-error degradation, cache TTL).
  • python -c "import bridge" → clean.
  • python -c "from bridge.dashboard import *" → clean.

Test plan

  • Deploy bridge + dotty-behaviour to the Docker host, hit /ui and confirm the perception card renders live face/sound/state data for dev-1.
  • Kill dotty-behaviour mid-session and confirm the dashboard still renders (empty card, warning in bridge log) within ~1.5 s instead of hanging.
  • Tail dotty-behaviour access logs during a dashboard refresh and confirm fan-out is bounded by the 2 s cache (one upstream call per getter per ~2 s window, not one per template tile).

Refs #115 — 5 more tiles to go, do not close.

🤖 Generated with Claude Code

BrettKinny and others added 2 commits May 24, 2026 00:16
Exposes the existing PerceptionState.get_recent() ring buffer over
HTTP so the bridge dashboard's perception card can fetch it. Used
by the perception-rewire follow-up commit on bridge.py.

Returns newest-first, capped by the `limit` query param (default 50)
and bounded above by PERCEPTION_RECENT_MAX. Unknown device_id yields
an empty list rather than 404 — matches the dashboard's tolerance
for "no events seen yet for this device".

Refs #115

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Tile 1 of #115. Replaces the empty-dict / empty-list stubs the #113
cutover left in place with live HTTP fetches against dotty-behaviour:

  - _dashboard_perception_state_getter  → GET /api/perception/state
  - _dashboard_perception_recent_getter → GET /api/perception/recent/{id}

Wrapped via _dotty_behaviour_get() with three load-bearing properties:

  - 1.5s request timeout — dashboard render must never block on a
    slow or dead dotty-behaviour.
  - 2.0s per-process result cache — HTMX polls + SSE nudges fan one
    refresh into multiple getter calls; the cache keeps dotty-behaviour
    quiet without changing the visible cadence.
  - Circuit breaker — any timeout / connection / HTTP / JSON error
    logs a warning and returns the empty fallback so the dashboard
    degrades to "no data" instead of 500-ing.

Base URL is read from DOTTY_BEHAVIOUR_URL (default http://localhost:8090).
The bridge container runs network_mode: host alongside dotty-behaviour
so the default is correct in production; the env var is there for
future flexibility (e.g. running the dashboard against a remote
behaviour instance).

Other stub getters (vision_cache, audio_cache, scene_synthesis_cache,
state, last_user_line, sound_balance, vision_failures) are unchanged
— those are Tiles 2-6 of #115.

Bridge tests: 64 → 69 passing (+5: state/recent happy paths, timeout
+ connection-error degradation, cache TTL).

Refs #115

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 23, 2026 14:18
@BrettKinny BrettKinny merged commit cf482eb into main May 23, 2026
7 of 9 checks passed
@BrettKinny BrettKinny deleted the dashboard-rewire-perception branch May 23, 2026 14:18
@BrettKinny BrettKinny review requested due to automatic review settings May 23, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant