Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

add Core Assembly CoS avatar: a 2D-canvas wireframe icosahedron with no WebGL dependency

[._.]/ Adam Eivyf89d7bb81922
diff --git a/client/src/components/cos/CoreCoSAvatar.jsx b/client/src/components/cos/CoreCoSAvatar.jsx
new file mode 100644
index 0000000000..09c30eb8e9
--- /dev/null
+++ b/client/src/components/cos/CoreCoSAvatar.jsx
@@ -0,0 +1,186 @@
+import { useEffect, useRef } from 'react';
+import CoSAvatarFrame from './CoSAvatarFrame';
+import { AGENT_STATES } from './constants';
+import { drawWireframeCore } from '../../lib/wireframeCore.js';
+import { parseColor } from '../../lib/chipContrast.js';
+
+// Core Assembly — the Kestrel Neon concept's rotating wireframe icosahedron,
+// drawn on a plain 2D canvas. No WebGL, so it skips CoSCanvasGuard and works
+// on displays where the three.js avatars fall back to the failure panel.
+//
+// Colors: edges take the agent-state color (the intentional 7-way enum in
+// `AGENT_STATES`, so every state stays distinguishable), while the rings and
+// vertices follow the active theme's secondary accent — magenta under Kestrel
+// Neon, whatever `--port-accent-2` is elsewhere.
+
+// Per-state motion: radians/second of spin and how hard the glow breathes.
+const STATE_MOTION = {
+ sleeping: { spin: 0.25, breathe: 0.15 },
+ thinking: { spin: 0.7, breathe: 0.5 },
+ coding: { spin: 1.1, breathe: 0.8 },
+ investigating: { spin: 0.9, breathe: 0.7 },
+ reviewing: { spin: 0.6, breathe: 0.45 },
+ planning: { spin: 0.5, breathe: 0.35 },
+ ideating: { spin: 1.3, breathe: 1 },
+};
+
+const FALLBACK_NODE_RGB = [255, 43, 214];
+const FALLBACK_DIM_RGB = [107, 115, 144];
+const TILT = 0.5;
+
+const readTriple = (styles, prop, fallback) => {
+ const parts = styles.getPropertyValue(prop).trim().split(/\s+/).map(Number);
+ return parts.length >= 3 && parts.slice(0, 3).every(Number.isFinite) ? parts.slice(0, 3) : fallback;
+};
+
+// Canvas fillStyle can't read CSS custom properties, so resolve the theme
+// tokens once per theme switch (mirrors `rollPalette` / `useChartColors`).
+const resolvePalette = () => {
+ if (typeof window === 'undefined' || typeof getComputedStyle !== 'function') {
+ return { nodeRgb: FALLBACK_NODE_RGB, dimRgb: FALLBACK_DIM_RGB, font: 'monospace' };
+ }
+ const styles = getComputedStyle(document.documentElement);
+ return {
+ nodeRgb: readTriple(styles, '--port-accent-2', FALLBACK_NODE_RGB),
+ dimRgb: readTriple(styles, '--port-text-subtle', FALLBACK_DIM_RGB),
+ font: styles.getPropertyValue('--port-font-mono').trim() || 'monospace',
+ };
+};
+
+const stateEdgeRgb = (state) => {
+ const parsed = parseColor((AGENT_STATES[state] || AGENT_STATES.sleeping).color);
+ return parsed ? [parsed.r, parsed.g, parsed.b] : [0, 240, 255];
+};
+
+export default function CoreCoSAvatar({ state = 'sleeping', speaking = false, background = false }) {
+ const wrapRef = useRef(null);
+ const canvasRef = useRef(null);
+ // Latest props for the animation loop — the loop is bound once so a state
+ // change never restarts the spin from zero.
+ const propsRef = useRef({ state, speaking });
+ propsRef.current = { state, speaking };
+
+ useEffect(() => {
+ const wrap = wrapRef.current;
+ const canvas = canvasRef.current;
+ const ctx = canvas?.getContext('2d');
+ if (!wrap || !ctx) return undefined;
+
+ const media = window.matchMedia?.('(prefers-reduced-motion: reduce)');
+ let reduce = media?.matches ?? false;
+ let palette = resolvePalette();
+ let width = 0;
+ let height = 0;
+ let spin = 0.8;
+ let phase = 0;
+ let lastTs = null;
+ let raf = 0;
+ // Drag offsets so "Drag to rotate" on the frame is true for this avatar too.
+ const drag = { pointerId: null, x: 0, y: 0, ax: 0, ay: 0 };
+
+ const draw = (ts) => {
+ const { state: currentState, speaking: isSpeaking } = propsRef.current;
+ const motion = STATE_MOTION[currentState] || STATE_MOTION.sleeping;
+ const dt = lastTs === null || reduce ? 0 : Math.min(0.1, (ts - lastTs) / 1000);
+ lastTs = ts;
+ spin += dt * motion.spin * (isSpeaking ? 1.8 : 1);
+ phase += dt * (0.4 + (isSpeaking ? 1.2 : 0));
+ const breathe = reduce ? 0 : motion.breathe * (0.5 + 0.5 * Math.sin(ts / 700));
+ drawWireframeCore(ctx, {
+ width,
+ height,
+ ax: TILT + drag.ax,
+ ay: spin + drag.ay,
+ phase,
+ pulse: Math.min(1, breathe + (isSpeaking ? 0.5 : 0)),
+ edgeRgb: stateEdgeRgb(currentState),
+ ...palette,
+ });
+ };
+
+ const loop = (ts) => {
+ draw(ts);
+ if (!reduce) raf = requestAnimationFrame(loop);
+ };
+
+ const restart = () => {
+ cancelAnimationFrame(raf);
+ lastTs = null;
+ raf = requestAnimationFrame(loop);
+ };
+
+ const resize = () => {
+ width = Math.max(1, Math.floor(wrap.clientWidth));
+ height = Math.max(1, Math.floor(wrap.clientHeight));
+ const dpr = Math.min(window.devicePixelRatio || 1, 3);
+ canvas.width = Math.round(width * dpr);
+ canvas.height = Math.round(height * dpr);
+ canvas.style.width = `${width}px`;
+ canvas.style.height = `${height}px`;
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
+ draw(performance.now());
+ };
+
+ const onMotionPreference = () => {
+ reduce = media.matches;
+ restart();
+ };
+ const onPointerDown = (event) => {
+ drag.pointerId = event.pointerId;
+ drag.x = event.clientX;
+ drag.y = event.clientY;
+ canvas.setPointerCapture?.(event.pointerId);
+ };
+ const onPointerMove = (event) => {
+ if (drag.pointerId !== event.pointerId) return;
+ drag.ay += (event.clientX - drag.x) * 0.01;
+ drag.ax += (event.clientY - drag.y) * 0.01;
+ drag.x = event.clientX;
+ drag.y = event.clientY;
+ if (reduce) draw(performance.now());
+ };
+ const onPointerUp = (event) => {
+ if (drag.pointerId === event.pointerId) drag.pointerId = null;
+ };
+
+ resize();
+ restart();
+ const observer = typeof ResizeObserver === 'function' ? new ResizeObserver(resize) : null;
+ observer?.observe(wrap);
+ // Re-resolve the ring/readout colors when the theme switches (same signal
+ // useCanvasRollPalette watches).
+ const themeObserver = typeof MutationObserver === 'function'
+ ? new MutationObserver(() => { palette = resolvePalette(); if (reduce) draw(performance.now()); })
+ : null;
+ themeObserver?.observe(document.documentElement, { attributes: true, attributeFilter: ['data-port-theme'] });
+ media?.addEventListener?.('change', onMotionPreference);
+ canvas.addEventListener('pointerdown', onPointerDown);
+ canvas.addEventListener('pointermove', onPointerMove);
+ canvas.addEventListener('pointerup', onPointerUp);
+ canvas.addEventListener('pointercancel', onPointerUp);
+
+ return () => {
+ cancelAnimationFrame(raf);
+ observer?.disconnect();
+ themeObserver?.disconnect();
+ media?.removeEventListener?.('change', onMotionPreference);
+ canvas.removeEventListener('pointerdown', onPointerDown);
+ canvas.removeEventListener('pointermove', onPointerMove);
+ canvas.removeEventListener('pointerup', onPointerUp);
+ canvas.removeEventListener('pointercancel', onPointerUp);
+ };
+ }, []);
+
+ return (
+ <CoSAvatarFrame label="Core assembly avatar. Drag to rotate." background={background}>
+ <div ref={wrapRef} className="absolute inset-0">
+ <canvas
+ ref={canvasRef}
+ data-testid="core-avatar-canvas"
+ data-state={state}
+ className="block w-full h-full"
+ />
+ </div>
+ </CoSAvatarFrame>
+ );
+}
diff --git a/client/src/components/cos/CoreCoSAvatar.test.jsx b/client/src/components/cos/CoreCoSAvatar.test.jsx
new file mode 100644
index 0000000000..0a1d8d93ec
--- /dev/null
+++ b/client/src/components/cos/CoreCoSAvatar.test.jsx
@@ -0,0 +1,99 @@
+import { act, render, screen } from '@testing-library/react';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+// The renderer is pinned by its own tests; here the wiring is what matters —
+// which colors reach a frame, and that a state change updates the NEXT frame
+// without restarting the loop.
+const drawCalls = vi.hoisted(() => []);
+vi.mock('../../lib/wireframeCore.js', () => ({
+ drawWireframeCore: (_ctx, frame) => { drawCalls.push(frame); },
+}));
+
+import CoreCoSAvatar from './CoreCoSAvatar';
+import { AGENT_STATES } from './constants';
+
+const rgbOf = (hex) => [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16));
+
+describe('CoreCoSAvatar', () => {
+ let rafCallbacks;
+ let reduceMotion;
+
+ beforeEach(() => {
+ drawCalls.length = 0;
+ rafCallbacks = [];
+ reduceMotion = false;
+ // happy-dom has no 2D canvas; the frame math is mocked above, so a bare
+ // context object is enough for the component to size and draw.
+ vi.spyOn(HTMLCanvasElement.prototype, 'getContext').mockReturnValue({ setTransform: vi.fn() });
+ vi.stubGlobal('requestAnimationFrame', vi.fn((cb) => { rafCallbacks.push(cb); return rafCallbacks.length; }));
+ vi.stubGlobal('cancelAnimationFrame', vi.fn());
+ vi.stubGlobal('matchMedia', vi.fn(() => ({
+ get matches() { return reduceMotion; },
+ addEventListener: vi.fn(),
+ removeEventListener: vi.fn(),
+ })));
+ document.documentElement.style.setProperty('--port-accent-2', '255 43 214');
+ document.documentElement.style.setProperty('--port-text-subtle', '107 115 144');
+ });
+
+ afterEach(() => {
+ vi.restoreAllMocks();
+ vi.unstubAllGlobals();
+ });
+
+ const tick = (ts) => act(() => {
+ const pending = rafCallbacks.splice(0);
+ for (const cb of pending) cb(ts);
+ });
+
+ it('draws edges in the agent-state color and rings in the theme secondary accent', () => {
+ render(<CoreCoSAvatar state="coding" />);
+ expect(screen.getByRole('group', { name: /Core assembly avatar/ })).toBeInTheDocument();
+ // The mount resize paints one frame synchronously.
+ expect(drawCalls.length).toBeGreaterThanOrEqual(1);
+ const frame = drawCalls.at(-1);
+ expect(frame.edgeRgb).toEqual(rgbOf(AGENT_STATES.coding.color));
+ expect(frame.nodeRgb).toEqual([255, 43, 214]);
+ expect(frame.dimRgb).toEqual([107, 115, 144]);
+ });
+
+ it('carries a state change into the next animation frame without restarting the spin', () => {
+ const { rerender } = render(<CoreCoSAvatar state="sleeping" />);
+ tick(0);
+ const base = drawCalls.at(-1);
+ tick(100);
+ const before = drawCalls.at(-1);
+ expect(before.edgeRgb).toEqual(rgbOf(AGENT_STATES.sleeping.color));
+ const sleepingStep = before.ay - base.ay;
+ expect(sleepingStep).toBeGreaterThan(0);
+
+ const cancelsBefore = cancelAnimationFrame.mock.calls.length;
+ rerender(<CoreCoSAvatar state="ideating" speaking />);
+ tick(200);
+ const after = drawCalls.at(-1);
+ expect(after.edgeRgb).toEqual(rgbOf(AGENT_STATES.ideating.color));
+ // Ideating spins several times faster than sleeping and speaking adds a
+ // burst, so the same 100ms advances the angle much further — from where it
+ // already was, not from zero.
+ expect(after.ay - before.ay).toBeGreaterThan(sleepingStep * 5);
+ expect(after.pulse).toBeGreaterThan(before.pulse);
+ expect(cancelAnimationFrame.mock.calls.length).toBe(cancelsBefore);
+ });
+
+ it('holds a single static frame when the user prefers reduced motion', () => {
+ reduceMotion = true;
+ render(<CoreCoSAvatar state="thinking" />);
+ const initialFrames = drawCalls.length;
+ tick(16);
+ // The loop drew its one frame and did not schedule another.
+ expect(drawCalls.length).toBe(initialFrames + 1);
+ expect(rafCallbacks).toHaveLength(0);
+ expect(drawCalls.at(-1).pulse).toBe(0);
+ });
+
+ it('hides the canvas from assistive tech on the background stage', () => {
+ const { container } = render(<CoreCoSAvatar state="sleeping" background />);
+ expect(screen.queryByRole('group')).not.toBeInTheDocument();
+ expect(container.querySelector('[aria-hidden="true"]')).toContainElement(screen.getByTestId('core-avatar-canvas'));
+ });
+});
diff --git a/client/src/components/cos/constants.js b/client/src/components/cos/constants.js
index 926f778578..419ec92a21 100644
--- a/client/src/components/cos/constants.js
+++ b/client/src/components/cos/constants.js
@@ -543,6 +543,8 @@ export const AVATAR_STYLE_LABELS = {
esoteric: 'Esoteric (3D)',
nexus: 'Neural Nexus (3D)',
muse: 'Cyber Muse (3D)',
+ // Kestrel Neon's rotating wireframe icosahedron — 2D canvas, no WebGL needed.
+ core: 'Core Assembly (Canvas)',
// Bundled CC0 Kenney Mini Characters — animated rigged GLB avatars.
miniMaleC: 'Mini Character — Male (3D)',
miniFemaleD: 'Mini Character — Female (3D)',
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index e617d6fee8..5a2bc63a06 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -162,6 +162,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `chordPlayback.js` | Chord-sheet play-along for the SongBook `tab`/`chordpro` formats (#4104) — the chord-sheet sibling of `drumPlayback.js` and the fourth consumer of `lookaheadTransport.js`. `sheetChordOccurrences(lines)` flattens `parseTabSheet(text).lines` into the ordered chord tokens, each addressed `{ lineIndex, chordIndex }` so `<TabSheetView>` can light exactly the token that is sounding; `chordMidiNotes(name)` voices one chord (bass note + chord tones, via `chordShapes.chordTones`); `buildChordSchedule(lines, { bpm, beatsPerBar, countInBars })` is the PURE chord→`[{ index, name, lineIndex, chordIndex, midis, startSec, durSec, rest }]` mapping (a chord sheet writes no rhythm, so ONE chord token = ONE bar, and a dash-joined "Am-Am7" splits its bar between its segments) plus the count-in clicks; `resolveChordPlayhead(schedule, posSec)` converts an audio-clock position to `{ countIn, index, beat }`; `createChordPlayer(lines, …)` strums it through `scorePlayback`'s `scheduleTone` with a live metronome toggle. |
| `chordShapes.js` | Chord-name → per-instrument voicing derivation for the SongBook viewer's instrument-view toggle (#2656). `getChordVoicing(name, instrument)` → guitar `{ frets: [6 × (-1/0/n)], baseFret, bass }`, ukulele (4-string GCEA, exact lowest-position search), or piano `{ notes: ['A','C','E'], bass }` with letter-accurate degree spelling (the 3rd of E is G#, never Ab); guitar shapes come from a curated first-position table + movable E-/A-form barre templates offset by `baseFret` (aug/dim7 exploit shape symmetry). Slash chords voice the base chord and carry `bass` separately. `parseChordName(name)`, `splitJoinedChords('Am-Am7')`, `toVoicingInstrument(songInstrument)`, `VOICING_INSTRUMENTS`. `chordTones(name)` returns the instrument-free half — the parse plus `semitones` above the root — so `chordPlayback.js` sounds a sheet without re-typing the interval tables. Reuses `tabNotation.js`'s `CHORD_TOKEN_RE`/`NOTE_TO_PC`/`spellPitchClass` (exported from there for this module) instead of duplicating the tables. Unknown/unparseable chords → null, never throws. |
| `canvasRoll.js` | Shared canvas helpers for the two piano-roll renderers (`<PianoRoll>` falling-note + `<MidiPianoRoll>` DAW-style, #2477). `layerColor(index)` — the per-layer/track palette (8 hues, wraps both directions) used by note bars, keyboards, and legends; `roundRect(ctx, x, y, w, h, r)` — rounded-rect path with `ctx.roundRect` feature-detect and arcTo fallback; `rollPalette()` — resolves the theme-following `{ bg, accent, accentRgb }` from `--port-accent` via `getComputedStyle` (canvas can't read CSS vars); `ROLL_BG` — the shared near-black bg literal. Pure canvas math/palette, no React. |
+| `wireframeCore.js` | The Kestrel Neon "core assembly": icosahedron geometry (`ICOSAHEDRON_VERTICES` / `ICOSAHEDRON_EDGES`, 12 vertices, 30 edges), `rotatePoint` / `projectIcosahedron` (Y-then-X rotation + perspective), and `drawWireframeCore(ctx, frame)` — one 2D-canvas frame of the depth-shaded wireframe with its orbit rings, vertex dots, and corner angle readout. Every color is an `[r, g, b]` triple so the caller sources them from `AGENT_STATES` and resolved theme tokens; no DOM reads. Consumed by `cos/CoreCoSAvatar.jsx`. |
| `chiptunePlayback.js` | Looping WebAudio preview for LLM-generated chiptune scores (#2911) — `buildChiptuneSchedule(score)` (pure pattern/order → absolute-time flatten, MIRRORS `server/lib/chiptuneScore.js` timing semantics), `parseChiptunePitch("C5")` → MIDI, and `createChiptunePlayer(getScore, { onLoop })` — a seamless-loop player over `createLookaheadTransport` (pulse-duty via PeriodicWave, triangle bass, noise-buffer/sine-sweep drums), exposing `position()` (monotonic across loop passes) + `loopSec()` for playhead UIs. No React — `ChiptunePanel` drives it. |
| `colorMatch.js` | Pure grading core for the song system's color-match training mode: `buildColorMatchTimeline(score, { bpm })` → `{ notes, totalMs, msPerQuarter, bpm }` (each note's target frequency + onset/offset window in ms, keyed by the same global note index the renderer flattens, timing mirroring `scorePlayback`); `gradeNote(hz, targetHz)` classifies a sung pitch against a target into `in-tune`/`close`/`off`/`missed` (octave-folded, thresholds `MATCH_IN_TUNE_CENTS`/`MATCH_CLOSE_CENTS`); `noteAtTime(timeline, tMs, fromIdx)` finds the active note for a rAF cursor; `summarizeAccuracy(grades)` → `{ graded, counts, percentInTune, perNote }` per-take summary (`perNote` is the ordered grade list a saved take persists, mirroring the server sanitizer); `gradesFromPerNote(timeline, perNote)` is its inverse — rebuilds the noteIndex→grade map to repaint a saved take's grading on open without re-grading audio; plus `centsBetween` and the `GRADE` enum. No React, no audio — the `useColorMatch` hook drives it. |
| `pitchDetect.js` | Dependency-free vocal pitch-detection core for the song system (tuner / color-match / sing-to-score). `detectFrequency(frame, { sampleRate })` → `{ hz, clarity }` (McLeod NSDF; clarity gate rejects silence/noise); `frequencyToNote(hz, { a4 })` → `{ letter, accidental, octave, step, cents }` (cents ∈ [-50,+50], sharp positive; `step` reuses `scoreNotation`'s `diatonicStep` so detected notes align with the renderer); `noteToFrequency(note, { a4 })` inverse (color-match targets); `createPitchTracker(analyser, { onUpdate })` → `{ stop }` rAF/interval loop with median+EMA smoothing to kill octave jumps; `tuningQuality(cents)` → `{ level, label }` buckets a cents deviation into `in-tune`/`close`/`off`/`none` (thresholds `IN_TUNE_CENTS`/`CLOSE_CENTS`) for the tuner color readout. |
diff --git a/client/src/lib/index.js b/client/src/lib/index.js
index b379555d19..2a521d1fc3 100644
--- a/client/src/lib/index.js
+++ b/client/src/lib/index.js
@@ -128,6 +128,7 @@ export * from './youtubeUrl.js';
// === Page-scoped pure helpers ===
export * from './audioContext.js';
export * from './canvasRoll.js';
+export * from './wireframeCore.js';
export * from './chiptunePlayback.js';
export * from './chordPlayback.js';
export * from './chordShapes.js';
diff --git a/client/src/lib/wireframeCore.js b/client/src/lib/wireframeCore.js
new file mode 100644
index 0000000000..e2ba424d5e
--- /dev/null
+++ b/client/src/lib/wireframeCore.js
@@ -0,0 +1,135 @@
+// Wireframe "core assembly" — the rotating icosahedron the Kestrel Neon theme
+// concept draws in its telemetry panel, rendered on a plain 2D canvas so it
+// needs no WebGL context (unlike the three.js CoS avatars).
+//
+// Geometry is pure and exported so the projection math can be pinned without
+// a canvas; `drawWireframeCore` is the one imperative entry point and takes
+// every color as an `[r, g, b]` triple so callers can source them from the
+// state enum (`AGENT_STATES`) or from resolved theme tokens.
+
+const PHI = (1 + Math.sqrt(5)) / 2;
+
+// The 12 vertices of a unit-ish icosahedron: cyclic permutations of (0, ±1, ±φ).
+export const ICOSAHEDRON_VERTICES = Object.freeze([
+ [-1, PHI, 0], [1, PHI, 0], [-1, -PHI, 0], [1, -PHI, 0],
+ [0, -1, PHI], [0, 1, PHI], [0, -1, -PHI], [0, 1, -PHI],
+ [PHI, 0, -1], [PHI, 0, 1], [-PHI, 0, -1], [-PHI, 0, 1],
+].map(Object.freeze));
+
+// Every vertex pair exactly one edge length (2) apart — 30 edges.
+export const ICOSAHEDRON_EDGES = Object.freeze((() => {
+ const edges = [];
+ const V = ICOSAHEDRON_VERTICES;
+ for (let i = 0; i < V.length; i++) {
+ for (let j = i + 1; j < V.length; j++) {
+ const dx = V[i][0] - V[j][0];
+ const dy = V[i][1] - V[j][1];
+ const dz = V[i][2] - V[j][2];
+ if (Math.abs(Math.sqrt(dx * dx + dy * dy + dz * dz) - 2) < 0.01) edges.push(Object.freeze([i, j]));
+ }
+ }
+ return edges;
+})());
+
+/** Rotate a point about Y by `ay`, then about X by `ax`. */
+export function rotatePoint([x, y, z], ax, ay) {
+ const cy = Math.cos(ay);
+ const sy = Math.sin(ay);
+ const x1 = x * cy - z * sy;
+ const z1 = x * sy + z * cy;
+ const cx = Math.cos(ax);
+ const sx = Math.sin(ax);
+ return [x1, y * cx - z1 * sx, y * sx + z1 * cx];
+}
+
+const CAMERA_DISTANCE = 3.2;
+
+/**
+ * Rotate + perspective-project the icosahedron onto a canvas.
+ * Returns `[sx, sy, depth]` per vertex; `depth` is the rotated z (negative =
+ * toward the viewer), kept so edges can be shaded by how far back they sit.
+ */
+export function projectIcosahedron({ ax, ay, cx, cy, scale }) {
+ return ICOSAHEDRON_VERTICES.map((p) => {
+ const q = rotatePoint(p, ax, ay);
+ const perspective = CAMERA_DISTANCE / (CAMERA_DISTANCE + q[2]);
+ return [cx + q[0] * scale * perspective, cy + q[1] * scale * perspective, q[2]];
+ });
+}
+
+const rgba = ([r, g, b], a) => `rgba(${r},${g},${b},${a.toFixed(3)})`;
+
+const TWO_PI = Math.PI * 2;
+
+/**
+ * Draw one frame of the core assembly.
+ *
+ * @param {CanvasRenderingContext2D} ctx transform already set for the DPR
+ * @param {object} frame
+ * @param {number} frame.width CSS px
+ * @param {number} frame.height CSS px
+ * @param {number} frame.ax tilt (radians)
+ * @param {number} frame.ay spin (radians)
+ * @param {number} frame.phase ring-orbit phase (radians), advances independently of spin
+ * @param {number} frame.pulse 0..1 — scales the glow and the dashed ring's stride
+ * @param {number[]} frame.edgeRgb edge + glow color
+ * @param {number[]} frame.nodeRgb vertex + ring color
+ * @param {number[]} frame.dimRgb corner readout color
+ * @param {string} [frame.font] readout font family
+ */
+export function drawWireframeCore(ctx, {
+ width, height, ax, ay, phase, pulse = 0, edgeRgb, nodeRgb, dimRgb, font = 'monospace',
+}) {
+ ctx.clearRect(0, 0, width, height);
+ const cx = width / 2;
+ const cy = height / 2;
+ const scale = Math.min(width, height) * 0.24 * (1 + pulse * 0.05);
+ const proj = projectIcosahedron({ ax, ay, cx, cy, scale });
+
+ // Outer rings: a steady orbit plus a dashed arc that sweeps with `phase`.
+ ctx.lineWidth = 1;
+ ctx.strokeStyle = rgba(nodeRgb, 0.35);
+ ctx.beginPath();
+ ctx.arc(cx, cy, scale * 1.55, 0, TWO_PI);
+ ctx.stroke();
+ ctx.setLineDash([4, 10 - pulse * 4]);
+ ctx.beginPath();
+ ctx.arc(cx, cy, scale * 1.75, -phase, -phase + Math.PI * 1.4);
+ ctx.stroke();
+ ctx.setLineDash([]);
+
+ // Edges, depth-shaded: near edges are brighter, thicker, and glow.
+ for (const [a, b] of ICOSAHEDRON_EDGES) {
+ const pa = proj[a];
+ const pb = proj[b];
+ const depth = (pa[2] + pb[2]) / 2 / PHI;
+ const near = depth < 0;
+ const alpha = 0.35 + 0.55 * (1 - (depth + 1) / 2);
+ ctx.strokeStyle = rgba(edgeRgb, alpha);
+ ctx.lineWidth = near ? 1.4 : 0.7;
+ ctx.shadowColor = rgba(edgeRgb, 0.8);
+ ctx.shadowBlur = near ? 6 + pulse * 6 : 0;
+ ctx.beginPath();
+ ctx.moveTo(pa[0], pa[1]);
+ ctx.lineTo(pb[0], pb[1]);
+ ctx.stroke();
+ }
+ ctx.shadowBlur = 0;
+
+ // Vertices: solid in front, faded behind.
+ for (const [x, y, depth] of proj) {
+ const near = depth < 0;
+ ctx.fillStyle = rgba(nodeRgb, near ? 1 : 0.4);
+ ctx.beginPath();
+ ctx.arc(x, y, near ? 2.4 : 1.4, 0, TWO_PI);
+ ctx.fill();
+ }
+
+ // Corner readout — only when there is room for it under the rings.
+ if (width >= 120 && height >= 120) {
+ const degrees = ((ay % TWO_PI + TWO_PI) % TWO_PI) * (180 / Math.PI);
+ ctx.fillStyle = rgba(dimRgb, 0.9);
+ ctx.font = `10px ${font}`;
+ ctx.fillText(`ICO-12 · ${degrees.toFixed(0).padStart(3, '0')}°`, 8, height - 8);
+ }
+}
diff --git a/client/src/lib/wireframeCore.test.js b/client/src/lib/wireframeCore.test.js
new file mode 100644
index 0000000000..a404927fe3
--- /dev/null
+++ b/client/src/lib/wireframeCore.test.js
@@ -0,0 +1,68 @@
+import { describe, it, expect, vi } from 'vitest';
+import {
+ ICOSAHEDRON_EDGES,
+ ICOSAHEDRON_VERTICES,
+ drawWireframeCore,
+ projectIcosahedron,
+ rotatePoint,
+} from './wireframeCore.js';
+
+describe('icosahedron geometry', () => {
+ it('has 12 vertices joined by 30 edges, five per vertex', () => {
+ expect(ICOSAHEDRON_VERTICES).toHaveLength(12);
+ expect(ICOSAHEDRON_EDGES).toHaveLength(30);
+ const degree = new Array(12).fill(0);
+ for (const [a, b] of ICOSAHEDRON_EDGES) { degree[a]++; degree[b]++; }
+ expect(degree.every((d) => d === 5)).toBe(true);
+ });
+
+ it('rotation preserves length and a quarter turn about Y maps x onto z', () => {
+ const [x, y, z] = rotatePoint([1, 2, 3], 0.7, -1.3);
+ expect(Math.hypot(x, y, z)).toBeCloseTo(Math.hypot(1, 2, 3), 10);
+ const [qx, , qz] = rotatePoint([1, 0, 0], 0, Math.PI / 2);
+ expect(qx).toBeCloseTo(0, 10);
+ expect(qz).toBeCloseTo(1, 10);
+ });
+
+ it('projects nearer vertices larger than farther ones around the canvas center', () => {
+ const proj = projectIcosahedron({ ax: 0, ay: 0, cx: 100, cy: 100, scale: 30 });
+ expect(proj).toHaveLength(12);
+ // Vertex 5 (0, 1, φ) sits behind the camera plane, vertex 7 (0, 1, -φ) in front:
+ // same y, so the front one must land farther from center (bigger perspective).
+ const back = proj[5];
+ const front = proj[7];
+ expect(front[2]).toBeLessThan(0);
+ expect(back[2]).toBeGreaterThan(0);
+ expect(Math.abs(front[1] - 100)).toBeGreaterThan(Math.abs(back[1] - 100));
+ });
+});
+
+describe('drawWireframeCore', () => {
+ const fakeCtx = () => ({
+ clearRect: vi.fn(), beginPath: vi.fn(), arc: vi.fn(), stroke: vi.fn(), fill: vi.fn(),
+ moveTo: vi.fn(), lineTo: vi.fn(), setLineDash: vi.fn(), fillText: vi.fn(),
+ strokeStyle: '', fillStyle: '', lineWidth: 0, shadowColor: '', shadowBlur: 0, font: '',
+ });
+ const frame = {
+ ax: 0.3, ay: 1.1, phase: 0.2, edgeRgb: [0, 240, 255], nodeRgb: [255, 43, 214], dimRgb: [107, 115, 144],
+ };
+
+ it('strokes every edge and fills every vertex in the state color', () => {
+ const ctx = fakeCtx();
+ drawWireframeCore(ctx, { ...frame, width: 200, height: 200 });
+ // 2 rings + 30 edges strokes; 12 vertex fills.
+ expect(ctx.stroke).toHaveBeenCalledTimes(32);
+ expect(ctx.fill).toHaveBeenCalledTimes(12);
+ expect(ctx.fillText).toHaveBeenCalledWith(expect.stringMatching(/^ICO-12 · \d{3}°$/), 8, 192);
+ // Glow is the edge color, and the last stroke style written was an edge or ring.
+ expect(ctx.shadowColor).toMatch(/^rgba\(0,240,255,/);
+ });
+
+ it('drops the corner readout in a tile too small to hold it', () => {
+ const ctx = fakeCtx();
+ drawWireframeCore(ctx, { ...frame, width: 96, height: 110 });
+ expect(ctx.fillText).not.toHaveBeenCalled();
+ expect(ctx.stroke).toHaveBeenCalledTimes(32);
+ });
+});
+// @vitest-environment node
diff --git a/client/src/pages/ChiefOfStaff.jsx b/client/src/pages/ChiefOfStaff.jsx
index e211975336..ab9eb6a621 100644
--- a/client/src/pages/ChiefOfStaff.jsx
+++ b/client/src/pages/ChiefOfStaff.jsx
@@ -59,13 +59,15 @@ const ConfigTab = lazy(() => import('../components/cos/tabs/ConfigTab'));
const BriefingTab = lazy(() => import('../components/cos/tabs/BriefingTab'));
// Three.js-based avatars lazy-loaded so the R3F stack isn't bundled unless the
-// user's chosen avatar style actually needs it.
+// user's chosen avatar style actually needs it. `core` is a plain 2D canvas
+// (no three.js) but stays lazy so the default SVG path loads nothing extra.
const LAZY_AVATARS = {
cyber: lazy(() => import('../components/cos/CyberCoSAvatar')),
sigil: lazy(() => import('../components/cos/SigilCoSAvatar')),
esoteric: lazy(() => import('../components/cos/EsotericCoSAvatar')),
nexus: lazy(() => import('../components/cos/NexusCoSAvatar')),
muse: lazy(() => import('../components/cos/MuseCoSAvatar')),
+ core: lazy(() => import('../components/cos/CoreCoSAvatar')),
// Bundled CC0 Kenney Mini Characters — animated rigged GLB avatars.
miniMaleC: lazy(() => import('../components/cos/MiniCharMaleC')),
miniFemaleD: lazy(() => import('../components/cos/MiniCharFemaleD')),
diff --git a/docs/features/chief-of-staff.md b/docs/features/chief-of-staff.md
index 14924e330c..7d88f68861 100644
--- a/docs/features/chief-of-staff.md
+++ b/docs/features/chief-of-staff.md
@@ -89,7 +89,7 @@ The `selectModelForTask` function routes tasks to appropriate model tiers:
| domainAutonomy | execute per domain | Off, dry-run, or execute policy for each automatic-work domain |
| domainBudgets | unlimited | Optional daily action and runtime caps per domain |
| persistentMindProfile.enabled | false | Configure a persistent-mind profile without starting it |
-| avatarStyle | svg | Default CoS UI avatar style |
+| avatarStyle | svg | Default CoS UI avatar style (`svg`, `ascii`, `core`, the 3D styles, or a `rigged-<modelId>` record) |
## API Endpoints
diff --git a/server/routes/cosStatusRoutes.js b/server/routes/cosStatusRoutes.js
index dd5243035b..cf2e3c080c 100644
--- a/server/routes/cosStatusRoutes.js
+++ b/server/routes/cosStatusRoutes.js
@@ -46,7 +46,7 @@ export const cosConfigSchema = z.object({
// the same traversal guard `server/routes/avatar.js` enforces), so unknown
// spellings still 400 here instead of persisting a style nothing can render.
avatarStyle: z.union([
- z.enum(['svg', 'ascii', 'cyber', 'sigil', 'esoteric', 'nexus', 'muse', 'miniMaleC', 'miniFemaleD']),
+ z.enum(['svg', 'ascii', 'cyber', 'sigil', 'esoteric', 'nexus', 'muse', 'core', 'miniMaleC', 'miniFemaleD']),
z.string().startsWith(RIGGED_VARIANT_PREFIX).refine(
(value) => AVATAR_VARIANT_PATTERN.test(value.slice(RIGGED_VARIANT_PREFIX.length)),
),
diff --git a/server/routes/cosStatusRoutesAvatar.test.js b/server/routes/cosStatusRoutesAvatar.test.js
index a658888987..8638f000d2 100644
--- a/server/routes/cosStatusRoutesAvatar.test.js
+++ b/server/routes/cosStatusRoutesAvatar.test.js
@@ -14,6 +14,7 @@ import { cosConfigSchema } from './cosStatusRoutes.js';
describe('cosConfigSchema avatarStyle', () => {
it('accepts built-in styles and rigged record spellings', () => {
expect(cosConfigSchema.safeParse({ avatarStyle: 'muse' }).success).toBe(true);
+ expect(cosConfigSchema.safeParse({ avatarStyle: 'core' }).success).toBe(true);
expect(cosConfigSchema.safeParse({ avatarStyle: 'rigged-image3d-abc-123' }).success).toBe(true);
});