| 1 | # The dot whale |
| 2 | |
| 3 | The whale is one drawing function, not a server: activity, time and options |
| 4 | in, 980 dots and their colours out. Each terminal runs it locally over its own |
| 5 | session (founder decision 290). The companion process that once owned a shared |
| 6 | world, with its recording, sound, browser view and extra terminal views, is |
| 7 | retired. |
| 8 | |
| 9 | The underwater transcript's completion visitor is a separate, bounded |
| 10 | decoration and is described at the end. |
| 11 | |
| 12 | ## Ownership |
| 13 | |
| 14 | - `pet/src/core/dot-field.ts`, `dot-forms.ts`, `dot-body.ts` and |
| 15 | `dot-pixel-body.ts` own the whale and its activity forms. |
| 16 | - `pet/src/core/pet-engine.ts` owns the reducer from typed Engine metadata to |
| 17 | the activity the dot field draws. |
| 18 | - `crates/tui/src/tui/pet_watch/pet-native.js` is the committed bundle of those |
| 19 | sources; `pet/scripts/build-pet.mjs` writes it and fails `npm --prefix pet run |
| 20 | check` when the committed copy is stale. |
| 21 | - `crates/tui/src/tui/pet_watch/dots.rs` runs the bundle in an embedded QuickJS |
| 22 | runtime on its own thread, feeds it this terminal's metadata and hands |
| 23 | validated frames to the view. |
| 24 | - `crates/tui/src/tui/pet_watch/full.rs` owns the `/whale` layout: the whale, |
| 25 | the status mark and word, and the reply and agents inspector. |
| 26 | - `vendor/codewhale-ratatui` owns `DotWhale`, which paints a prepared frame in |
| 27 | Braille cells, and the half-block whale `PetMode` draws when no frame exists. |
| 28 | - `crates/tui/src/tui/ambient_life/pet_sim.rs` owns the Rust particle |
| 29 | simulation used by the completion cameo, with `whale-points.tsv` as its |
| 30 | authored body, `pet_widget.rs` for particle-to-Braille rendering and |
| 31 | `pet_cameo.rs` for the completion presentation. |
| 32 | |
| 33 | ## Whale forms |
| 34 | |
| 35 | `projectDotField` projects the 980 points and their materials from the typed |
| 36 | activity projection and a supplied time. It keeps no clock, consumes no |
| 37 | randomness and holds no state. The fixed `[-1, 1]` envelope keeps scale stable |
| 38 | across forms; consumers fit that envelope rather than fitting each changing |
| 39 | shape. Each point carries one `[r, g, b, alpha]` material. |
| 40 | |
| 41 | The body samples 980 interior points from the filled whale mark, preserving its |
| 42 | eye, mouth and curled negative space at home. A second, pixel body derived from |
| 43 | `pet/assets/pixel-whale.svg` remains in the shared core; the terminal draws the |
| 44 | smooth body only. |
| 45 | |
| 46 | During activity all 980 points leave the whale and become the thing the work |
| 47 | is, in motion (CURRENT_DECISIONS §205.5). Shape, movement and colour carry the |
| 48 | meaning; `dot-forms.ts` owns the thirteen forms: |
| 49 | |
| 50 | | Activity | Form | Hue | |
| 51 | | --- | --- | --- | |
| 52 | | executing, tool | a wrench turning a bolt | 198 | |
| 53 | | editing | a pencil writing a line | 172 | |
| 54 | | reading | an open book, a page turning | 186 | |
| 55 | | searching | a lens sweeping lines of text | 205 | |
| 56 | | testing | a flask bubbling | 150 | |
| 57 | | browsing | a globe turning | 212 | |
| 58 | | computer | a pointer clicking a button | 222 | |
| 59 | | memory | layers settling into a stack | 268 | |
| 60 | | thinking | a bulb lighting up | 48 | |
| 61 | | responding | a speech bubble typing | 190 | |
| 62 | | delegating | a pod of small whales: two for up to two parallel agents, otherwise three | 200 | |
| 63 | | waiting (needs you) | a bell ringing, in a warm hue | 38 | |
| 64 | | done | a check mark, then home | 160 | |
| 65 | |
| 66 | Each form is a list of parts sampled with a seeded generator. Dots are |
| 67 | allocated to parts by area and assigned by rank, so each dot travels a short |
| 68 | way from its place in the whale. Both body styles are compiled once at module |
| 69 | load. A form is a pure function of its kind, the body style, the dot index and |
| 70 | the time: no `Math.random`, wall clock or DOM, and identical input gives |
| 71 | identical output. Forms are drawn at 1.22 times their authored size and every |
| 72 | point stays inside ±0.94. Observed failure tints the form hue 16. |
| 73 | |
| 74 | An 8.4-second cycle returns all 980 points to the filled whale between |
| 75 | expressions, using the presentation's admission timestamp rather than its |
| 76 | heartbeats. Dots leave with a short stagger. Completion holds the check for |
| 77 | 800 ms and settles into the whale within 1.7 seconds. Still presents one fixed |
| 78 | pose of the form, evaluated at 1.3 seconds of its motion, during activity and |
| 79 | the filled whale at rest, without the cycle or swim; it never shows a |
| 80 | mid-morph pose. Unobserved, stale and idle presentations stay the whale. |
| 81 | `build-dot-bodies.py --whale-body` reproducibly derives the interior sampling |
| 82 | from the pinned alpha mask in `pet/public/whale.png`. |
| 83 | |
| 84 | What this design does not do: forms carry no text, so they do not say which |
| 85 | file, command or page is involved; that stays in the caption and the inspector. |
| 86 | Forms are not chosen from tool names or arguments, only from the typed activity |
| 87 | kind. The pod shows at most three whales however many agents run. Forms do not |
| 88 | follow the interface language and have no user-selectable variants. In small |
| 89 | terminals thin parts can thin out in Braille, and the caption is the legible |
| 90 | fallback. |
| 91 | |
| 92 | ## The `/whale` view |
| 93 | |
| 94 | `/whale` makes the whale the main view above the existing composer; `F5` opens |
| 95 | replies and agents over it through the existing modal stack. The view starts no |
| 96 | Engine turn and substitutes no demonstration data. It begins unobserved and |
| 97 | does not backfill events from before the first `/whale` in a process. |
| 98 | |
| 99 | `ui/event_loop.rs` passes accepted foreground Engine events to |
| 100 | `pet_watch::observe`. Its allowlist keeps only lifecycle kind, stable ids, |
| 101 | admitted operation kind and action identity, channel and outcome. Prompt text, |
| 102 | reasoning, tool names, arguments, results, paths and routing credentials never |
| 103 | enter the dot whale's queue. No session context or KV-cache prefix is changed. |
| 104 | |
| 105 | The Engine admits `activity_kind` and an optional `action_id` on operation |
| 106 | start and completion. An action id is a bounded canonical or admitted |
| 107 | integration identifier, at most 256 UTF-8 bytes without control characters. It |
| 108 | is not a command, path, argument, result or text-derived guess. The reducer |
| 109 | uses the typed kind for the form and the id for variation. Unknown or stale |
| 110 | observation keeps an honest unobserved whale. |
| 111 | |
| 112 | The thread wakes at most every 66 ms while a form is moving, every 250 ms |
| 113 | otherwise and every 500 ms when held still, and sleeps when the view is hidden |
| 114 | or a still pose has settled. A frame that fails validation is dropped; three |
| 115 | failures in a row stop the thread and the view falls back to the half-block |
| 116 | whale with a notice. `/whale still` and reduced motion select the still pose. |
| 117 | `/whale color` recolours the frame in the terminal, keeping each dot's |
| 118 | brightness; it does not change the dot field. |
| 119 | |
| 120 | What the view does not do: it keeps no recording, plays no sound and opens no |
| 121 | port. Its only shared state is the name and colour in `settings.toml` |
| 122 | (`whale_name`, `whale_color`), which the desktop app reads and writes too; |
| 123 | hold-still is not saved. |
| 124 | |
| 125 | To regenerate the bundle after changing `pet/src/core`: |
| 126 | |
| 127 | ```sh |
| 128 | npm --prefix pet ci --ignore-scripts |
| 129 | npm --prefix pet run sync |
| 130 | ``` |
| 131 | |
| 132 | ## Completion is a bounded observation |
| 133 | |
| 134 | A completion does not identify which Whalesong category was last active. The |
| 135 | single visitor therefore uses `other · drift`, with observed coverage. Existing |
| 136 | `AmbientActivity::Subagents` presents three fixed, staggered peer slots, each |
| 137 | labelled `agent · pod`. At rest the three peers remain three animals; the core's |
| 138 | six-satellite working gait is not multiplied into eighteen animals. |
| 139 | |
| 140 | The complete creature and its caption are preflighted against `is_open_water`. |
| 141 | A text collision with either withholds the entire creature. Off-screen peers |
| 142 | are withheld instead of clamping them into an overlapping stack. On a 40-column |
| 143 | surface the middle peer remains visible. Content always owns its cells. |
| 144 | |
| 145 | The core is stepped at fixed 30 Hz into two bounded raster caches. A frame is |
| 146 | selected solely from the supplied completion age, so skipped draws, rewind, |
| 147 | resizes, and rendering another session do not alter its pose. There are no new |
| 148 | random choices. The existing theme supplies the habitat ink; the cameo adds no |
| 149 | status-bar colour meaning and never spends Failure red. |
| 150 | |
| 151 | The shell already owns an 800 ms completion light pulse and a 600 ms life fade. |
| 152 | It now passes the motion-gated clock through that full 1.4-second interval. The |
| 153 | ocean still clips its light pulse at 800 ms. The low-level cameo retains the |
| 154 | 2.4-second safety limit from its predecessor; the shell's life fade ends first. |
| 155 | Reduced motion exits before constructing marks or initializing the caches. |
| 156 | |
| 157 | The generic widget retains the core's unknown rendering and the literal |
| 158 | `· unobserved` cue. If the whole cue cannot fit, it withholds the whole widget. |
| 159 | Sleep dimming does not set unknown coverage. |
| 160 |