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

feat([issue-705]): CyberCity ambient soundscape tied to system state

[._.]/ Adam Eivy8e6e7ceb6642
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 7ba9d2afcd..02fa4ae8f6 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -48,6 +48,7 @@
- **[issue-705] CyberCity earned artifacts** — a "Hall of Achievements" now appears east of downtown as a cluster of trophies on glowing pedestals — but only for milestones you've actually earned: leveling up your adventurer, completing life goals (your 1st, 5th, 10th), and building your best task-completion streak (3, 7, 30 days). Each trophy reads bronze, silver, or gold for how big the milestone is, and the whole cluster shimmers; nothing shows until you've earned your first, so the hall fills in as you make progress.
- **[issue-705] CyberCity memory district** — your long-term memory now crystallizes into a quiet quarter northwest of downtown: each memory category becomes a cluster of glowing crystals, taller and brighter the more (and more important) the memories it holds, and categories that link to each other arc together with light bridges — so the shape of how your knowledge connects is legible at a glance. A glowing well at the district's heart pulses with your Brain inbox backlog, brightening and beating faster the more captures are waiting to be sorted, and calming once the inbox is clear. The district stays hidden until you've recorded your first memory.
- **[issue-705] CyberCity photo mode** — a new camera button drops the city into a cinematic photo mode: the HUD clears, letterbox bars frame the view, and you can cycle through framing presets (establishing shot, downtown, skyline, overhead, horizon, low angle) with the on-screen arrows or ←/→ keys, each a smooth camera fly. Hit Capture to grab a "city postcard" — your screenshot with a CYBERCITY title and a snapshot of your headline stats (systems online, active agents, linked peers, level, streak) baked along the bottom — then preview it and save it as a PNG. Press Esc to fly back out.
+- **[issue-705] CyberCity ambient soundscape** — the city's background music now responds to what's happening in your system (when music is enabled in the city settings). A healthy, quiet system stays calm and bright; as CPU/memory climb or health degrades the music darkens to a tenser chord set with a muffled, anxious tone; and the more agents are actively working, the livelier and busier the lead becomes. A bright chime plays whenever a Chief-of-Staff task completes, so finishing work is something you can hear.
## Changed
diff --git a/client/src/components/city/audio/citySoundEffects.js b/client/src/components/city/audio/citySoundEffects.js
index 4539e54370..a8395c7a9f 100644
--- a/client/src/components/city/audio/citySoundEffects.js
+++ b/client/src/components/city/audio/citySoundEffects.js
@@ -121,12 +121,34 @@ const playDataPulse = (ctx, output) => {
osc.stop(now + 0.12);
};
+// Task complete: a bright two-note major-third chime (E6 → G#6) with a soft bell decay. Played
+// when a CoS task completes (roadmap 3.4) so finishing work has an audible reward in the city.
+const playTaskComplete = (ctx, output) => {
+ const now = ctx.currentTime;
+ const notes = [1318.51, 1661.22]; // E6, G#6 — a rising major third reads as "success"
+ notes.forEach((freq, i) => {
+ const t = now + i * 0.09; // slight arpeggiation
+ const osc = ctx.createOscillator();
+ osc.type = 'sine';
+ osc.frequency.value = freq;
+ const gain = ctx.createGain();
+ gain.gain.setValueAtTime(0.0001, t);
+ gain.gain.exponentialRampToValueAtTime(0.18, t + 0.01);
+ gain.gain.exponentialRampToValueAtTime(0.0001, t + 0.5);
+ osc.connect(gain);
+ gain.connect(output);
+ osc.start(t);
+ osc.stop(t + 0.55);
+ });
+};
+
const SFX_MAP = {
buildingHover: playBuildingHover,
buildingClick: playBuildingClick,
lightning: playLightning,
shootingStar: playShootingStar,
dataPulse: playDataPulse,
+ taskComplete: playTaskComplete,
};
export const playSfx = (name) => {
diff --git a/client/src/components/city/audio/citySynthMusic.js b/client/src/components/city/audio/citySynthMusic.js
index da4e32abca..228b4f14fb 100644
--- a/client/src/components/city/audio/citySynthMusic.js
+++ b/client/src/components/city/audio/citySynthMusic.js
@@ -1,22 +1,47 @@
// Procedural ambient synthwave using Web Audio oscillators
import { getAudioContext, getMusicGain } from './cityAudioEngine';
+import { CHORD_SETS } from '../../../utils/citySoundscape';
let isPlaying = false;
let oscillators = [];
let intervals = [];
let nodesCleanup = [];
-// Chord progressions (Am -> Em -> F -> C) as frequency arrays
-const CHORDS = [
- [110, 130.81, 164.81], // Am (A2, C3, E3)
- [82.41, 123.47, 164.81], // Em (E2, B2, E3)
- [87.31, 110, 130.81], // F (F2, A2, C3)
- [65.41, 98.0, 130.81], // C (C2, G2, C3)
-];
+// Default chord progression (Am -> Em -> F -> C). The soundscape layer (roadmap 3.4) can swap
+// this for the darker `tense` set via setSoundscape(); we keep a mutable pointer so the running
+// chord interval reads whatever's current without re-scheduling.
+const DEFAULT_CHORDS = CHORD_SETS.bright;
+let activeChords = DEFAULT_CHORDS;
+
+// Live references to the modulatable nodes, captured in startMusic(). setSoundscape() ramps
+// these in real time so the music's mood/brightness/energy follows system state. Null while
+// the music is stopped. `baseArpGain` is the energy-driven target the arp envelope peaks at.
+let liveBassFilter = null;
+let livePadOscs = [];
+let liveArpPeak = 0.06; // peak gain the arp pluck opens to; raised/lowered by energy
// Arp note patterns (scale degrees relative to chord root)
const ARP_PATTERN = [0, 2, 4, 7, 12, 7, 4, 2];
+// Apply a soundscape view-model (from computeSoundscape) to the running music graph. Safe to call
+// whether or not music is playing — it just updates the targets the next chord/arp tick uses.
+export const setSoundscape = (params) => {
+ if (!params) return;
+ const ctx = getAudioContext();
+ activeChords = params.chordSet === 'tense' ? CHORD_SETS.tense : CHORD_SETS.bright;
+ liveArpPeak = Math.max(0.01, params.arpGain ?? 0.06);
+ if (ctx && liveBassFilter) {
+ // Ramp the base cutoff smoothly so mood shifts glide rather than click. The LFO still rides
+ // on top of this via its own connection to bassFilter.frequency.
+ liveBassFilter.frequency.setTargetAtTime(params.filterBase ?? 200, ctx.currentTime, 0.5);
+ }
+ if (ctx && livePadOscs.length) {
+ livePadOscs.forEach((osc, i) => {
+ osc.detune.setTargetAtTime((i - 1) * (params.padDetune ?? 8), ctx.currentTime, 0.5);
+ });
+ }
+};
+
const createReverb = (ctx) => {
const convolver = ctx.createConvolver();
const rate = ctx.sampleRate;
@@ -63,7 +88,7 @@ export const startMusic = () => {
let currentChordIdx = 0;
const bassOsc = ctx.createOscillator();
bassOsc.type = 'sawtooth';
- bassOsc.frequency.value = CHORDS[0][0];
+ bassOsc.frequency.value = activeChords[0][0];
const bassGain = ctx.createGain();
bassGain.gain.value = 0.12;
bassOsc.connect(bassGain);
@@ -92,7 +117,7 @@ export const startMusic = () => {
for (let i = 0; i < 3; i++) {
const osc = ctx.createOscillator();
osc.type = 'sine';
- osc.frequency.value = CHORDS[0][i];
+ osc.frequency.value = activeChords[0][i];
osc.detune.value = (i - 1) * 8; // slight spread
osc.connect(padGain);
osc.start();
@@ -121,11 +146,13 @@ export const startMusic = () => {
oscillators.push(arpOsc);
let arpStep = 0;
- // Chord change every 2.4s (4 beats at 100BPM)
+ // Chord change every 2.4s (4 beats at 100BPM). Reads `activeChords` live so a soundscape
+ // mood-swap (bright↔tense) takes effect on the next chord without re-scheduling the interval.
const chordInterval = setInterval(() => {
if (!isPlaying) return;
- currentChordIdx = (currentChordIdx + 1) % CHORDS.length;
- const chord = CHORDS[currentChordIdx];
+ const chords = activeChords;
+ currentChordIdx = (currentChordIdx + 1) % chords.length;
+ const chord = chords[currentChordIdx];
const now = ctx.currentTime;
bassOsc.frequency.setTargetAtTime(chord[0], now, 0.3);
padOscs.forEach((osc, i) => {
@@ -134,10 +161,11 @@ export const startMusic = () => {
}, 2400);
intervals.push(chordInterval);
- // Arp sixteenth notes at 100BPM = 150ms per step
+ // Arp sixteenth notes at 100BPM = 150ms per step. The pluck peaks at `liveArpPeak`, which the
+ // soundscape raises with system energy (more active agents → a louder, livelier lead).
const arpInterval = setInterval(() => {
if (!isPlaying) return;
- const chord = CHORDS[currentChordIdx];
+ const chord = activeChords[currentChordIdx % activeChords.length];
const rootFreq = chord[0] * 4; // two octaves up
const semitone = ARP_PATTERN[arpStep % ARP_PATTERN.length];
const freq = rootFreq * Math.pow(2, semitone / 12);
@@ -145,13 +173,17 @@ export const startMusic = () => {
arpOsc.frequency.setTargetAtTime(freq, now, 0.01);
// Short percussive envelope
- arpGain.gain.setTargetAtTime(0.06, now, 0.005);
+ arpGain.gain.setTargetAtTime(liveArpPeak, now, 0.005);
arpGain.gain.setTargetAtTime(0.0, now + 0.06, 0.04);
arpStep++;
}, 150);
intervals.push(arpInterval);
+ // Expose the modulatable nodes so setSoundscape() can ramp them in real time.
+ liveBassFilter = bassFilter;
+ livePadOscs = padOscs;
+
nodesCleanup.push(reverb, reverbGain, delay, delayFeedback, bassFilter, bassGain, padGain, arpFilter, arpGain);
};
@@ -166,4 +198,8 @@ export const stopMusic = () => {
intervals = [];
nodesCleanup.forEach(node => node.disconnect());
nodesCleanup = [];
+ // Drop references to the now-disconnected nodes so a stray setSoundscape() can't ramp a
+ // dead graph. The next startMusic() re-captures fresh ones.
+ liveBassFilter = null;
+ livePadOscs = [];
};
diff --git a/client/src/hooks/useCityAudio.js b/client/src/hooks/useCityAudio.js
index 60f5a0995e..569862b528 100644
--- a/client/src/hooks/useCityAudio.js
+++ b/client/src/hooks/useCityAudio.js
@@ -1,13 +1,19 @@
import { useState, useEffect, useCallback, useRef } from 'react';
import { initAudio, setMusicVolume, setSfxVolume, cleanup as cleanupAudio } from '../components/city/audio/cityAudioEngine';
-import { startMusic, stopMusic } from '../components/city/audio/citySynthMusic';
+import { startMusic, stopMusic, setSoundscape } from '../components/city/audio/citySynthMusic';
import { playSfx as playSfxFn } from '../components/city/audio/citySoundEffects';
-export default function useCityAudio(settings) {
+// `soundscape` is the computeSoundscape() view-model (roadmap 3.4): the live mood/energy the
+// ambient music should reflect. Optional — when omitted the music plays its default progression.
+export default function useCityAudio(settings, soundscape) {
const [isAudioReady, setIsAudioReady] = useState(false);
const initedRef = useRef(false);
const settingsRef = useRef(settings);
settingsRef.current = settings;
+ // Mirror the latest soundscape so deferred starts (gesture-init, music-toggle) apply it without
+ // depending on render timing.
+ const soundscapeRef = useRef(soundscape);
+ soundscapeRef.current = soundscape;
const musicEnabled = settings?.musicEnabled;
const musicVolume = settings?.musicVolume;
const sfxVolume = settings?.sfxVolume;
@@ -24,6 +30,7 @@ export default function useCityAudio(settings) {
if (settingsRef.current?.musicEnabled) {
startMusic();
setMusicVolume(settingsRef.current.musicVolume);
+ if (soundscapeRef.current) setSoundscape(soundscapeRef.current);
}
}
window.removeEventListener('click', handleGesture);
@@ -37,16 +44,32 @@ export default function useCityAudio(settings) {
};
}, []);
- // Toggle music on/off based on settings
+ // Toggle music on/off based on settings. Apply the current soundscape right after starting so
+ // the music opens in the right mood rather than the default progression for a beat.
useEffect(() => {
if (!isAudioReady || musicEnabled == null) return;
if (musicEnabled) {
startMusic();
+ if (soundscapeRef.current) setSoundscape(soundscapeRef.current);
} else {
stopMusic();
}
}, [isAudioReady, musicEnabled]);
+ // Drive the ambient soundscape from live system state. The deps are the individual field
+ // values (not the `soundscape` object), so a poll that recomputes an equal snapshot — a new
+ // object with identical fields — doesn't re-ramp the graph; only an actual mood/energy change
+ // does. The effect reads the freshest snapshot from the ref at run time.
+ const chordSet = soundscape?.chordSet;
+ const filterBase = soundscape?.filterBase;
+ const arpGain = soundscape?.arpGain;
+ const padDetune = soundscape?.padDetune;
+ useEffect(() => {
+ const s = soundscapeRef.current;
+ if (!isAudioReady || !musicEnabled || !s) return;
+ setSoundscape(s);
+ }, [isAudioReady, musicEnabled, chordSet, filterBase, arpGain, padDetune]);
+
// Update music volume
useEffect(() => {
if (!isAudioReady || !musicEnabled) return;
diff --git a/client/src/pages/CyberCity.jsx b/client/src/pages/CyberCity.jsx
index e8e53b8c1d..0da8ea893d 100644
--- a/client/src/pages/CyberCity.jsx
+++ b/client/src/pages/CyberCity.jsx
@@ -13,11 +13,23 @@ import { CitySettingsProvider, useCitySettingsContext } from '../components/city
import CitySettingsPanel from '../components/city/CitySettingsPanel';
import { computeFilterResult } from '../utils/cityFilter';
import { DEFAULT_PRESET_ID, cyclePreset } from '../utils/cityPhotoMode';
+import { computeSoundscape } from '../utils/citySoundscape';
function CyberCityInner() {
const { apps, cosAgents, cosStatus, eventLogs, agentMap, reviewCounts, instances, systemHealth, notificationCounts, backupStatus, cosTasks, healthMetrics, voiceState, character, aiActivity, loading, connected } = useCityData();
const { settings, updateSetting } = useCitySettingsContext();
- const { playSfx } = useCityAudio(settings);
+
+ // Ambient soundscape (roadmap 3.4): the music's mood follows system health and its energy
+ // follows live agent activity. Derived from data the page already has — no extra fetch.
+ const activeAgentCount = useMemo(
+ () => (cosAgents || []).filter(a => a.status === 'running' || a.state === 'coding' || a.state === 'thinking' || a.state === 'investigating').length,
+ [cosAgents]
+ );
+ const soundscape = useMemo(
+ () => computeSoundscape({ systemHealth, agentCount: activeAgentCount }),
+ [systemHealth, activeAgentCount]
+ );
+ const { playSfx } = useCityAudio(settings, soundscape);
const navigate = useNavigate();
const location = useLocation();
const [filter, setFilter] = useState(() => {
@@ -94,6 +106,26 @@ function CyberCityInner() {
return () => window.removeEventListener('keydown', onKey);
}, [photoMode]);
+ // Task-complete chime (roadmap 3.4): when a CoS task transitions to completed, play a reward
+ // chime. Track the set of completed ids across socket updates and chime on each newly-seen one.
+ // Seeded on first populated render (completedSeenRef === null) so a fresh page load doesn't
+ // chime for every already-completed task in the backlog.
+ const completedSeenRef = useRef(null);
+ useEffect(() => {
+ const completedIds = (cosTasks || []).filter(t => t?.status === 'completed').map(t => t.id);
+ if (completedSeenRef.current === null) {
+ completedSeenRef.current = new Set(completedIds);
+ return;
+ }
+ let fired = false;
+ for (const id of completedIds) {
+ if (!completedSeenRef.current.has(id)) {
+ completedSeenRef.current.add(id);
+ if (!fired) { playSfx('taskComplete'); fired = true; } // one chime per batch, not per task
+ }
+ }
+ }, [cosTasks, playSfx]);
+
// Productivity data for HUD vitals and billboards. Let errors throw —
// `useAutoRefetch` preserves the last-good snapshot on transient failures.
const { data: productivityData } = useAutoRefetch(
diff --git a/client/src/utils/citySoundscape.js b/client/src/utils/citySoundscape.js
new file mode 100644
index 0000000000..9c949c86d8
--- /dev/null
+++ b/client/src/utils/citySoundscape.js
@@ -0,0 +1,72 @@
+// Pure, deterministic mapping from live system state → ambient soundscape parameters
+// (CyberCity v2 roadmap 3.4). The synth-music layer reads these to shift its mood, brightness,
+// and "energy" so the city's drone reflects what's actually happening: a healthy, quiet system
+// sounds calm and bright; a stressed system (high CPU/mem, health warnings) darkens and tenses;
+// active agents add rhythmic energy (a louder arp voice). No Web Audio / React imports so the
+// mapping is unit-testable — citySynthMusic.js applies the result to the live graph.
+
+// Two chord tables the music engine switches between. BRIGHT is the existing major-leaning
+// progression (calm/healthy); TENSE is a darker, more dissonant set used when the system is
+// under stress. Frequencies are bass roots + chord tones in Hz, matching citySynthMusic's shape.
+export const CHORD_SETS = {
+ bright: [
+ [110, 130.81, 164.81], // Am
+ [82.41, 123.47, 164.81], // Em
+ [87.31, 110, 130.81], // F
+ [65.41, 98.0, 130.81], // C
+ ],
+ tense: [
+ [110, 138.59, 164.81], // A diminished-ish (A, C#dim color)
+ [77.78, 116.54, 155.56], // Eb — tritone-ish tension
+ [92.50, 116.54, 138.59], // F#m color
+ [69.30, 103.83, 138.59], // C# — unresolved
+ ],
+};
+
+// Classify overall system stress into a mood. Driven primarily by the health verdict, with a
+// CPU/memory fallback so a system that's hammered but not yet "warning" still tenses up.
+// `health` is the /system/health/details payload (or null); `agentCount` is live agents.
+export function classifyMood(health) {
+ const verdict = health?.overallHealth;
+ if (verdict === 'critical' || verdict === 'unhealthy') return 'tense';
+ const cpu = health?.system?.cpu?.usagePercent ?? 0;
+ const mem = health?.system?.memory?.usagePercent ?? 0;
+ if (cpu >= 85 || mem >= 90) return 'tense';
+ if (verdict === 'degraded' || cpu >= 65 || mem >= 75) return 'neutral';
+ return 'bright';
+}
+
+// Energy 0..1 — how much rhythmic "life" the music has. Rises with the number of active agents
+// (the city is busy → the music gets busier), saturating so a swarm of agents doesn't blow it
+// out. A quiet, agent-less city sits at a low ambient floor, never fully silent.
+export function computeActivityEnergy(agentCount) {
+ const n = Math.max(0, agentCount || 0);
+ // Diminishing returns: 0 agents → 0.15 floor, ~5 agents → ~0.85, asymptotic to 1.
+ return Math.min(1, 0.15 + (1 - Math.exp(-n / 2.5)) * 0.85);
+}
+
+// Full soundscape view-model the music engine applies. `mood` picks the chord table and a base
+// filter brightness; `energy` scales the arp/lead voice gain and a subtle tempo feel; `detune`
+// widens the pads as tension rises for an uneasy shimmer. Deterministic for a given snapshot.
+export function computeSoundscape(snapshot = {}) {
+ const { systemHealth, agentCount } = snapshot;
+ const mood = classifyMood(systemHealth);
+ const energy = computeActivityEnergy(agentCount);
+
+ // Brighter (higher) filter cutoff when healthy; clamped low when tense for a muffled, anxious
+ // tone. Energy nudges it up a touch so a busy-but-healthy city sparkles.
+ const filterBase = (mood === 'bright' ? 320 : mood === 'neutral' ? 220 : 150) + energy * 80;
+
+ return {
+ mood,
+ energy,
+ chordSet: mood === 'tense' ? 'tense' : 'bright', // neutral still uses the bright table, just darker filter
+ filterBase,
+ arpGain: 0.02 + energy * 0.08, // near-silent at rest, prominent when many agents run
+ padDetune: mood === 'tense' ? 14 : mood === 'neutral' ? 10 : 8, // wider = more unease
+ // A gentle tempo feel: the arp envelope opens a little faster with energy. Expressed as a
+ // 0..1 scalar the engine maps onto its arp attack, NOT a literal BPM change (rescheduling
+ // the running intervals mid-stream would race; modulating the voice is equivalent + safe).
+ pulse: energy,
+ };
+}
diff --git a/client/src/utils/citySoundscape.test.js b/client/src/utils/citySoundscape.test.js
new file mode 100644
index 0000000000..9c67d634dc
--- /dev/null
+++ b/client/src/utils/citySoundscape.test.js
@@ -0,0 +1,91 @@
+import { describe, it, expect } from 'vitest';
+import {
+ CHORD_SETS,
+ classifyMood,
+ computeActivityEnergy,
+ computeSoundscape,
+} from './citySoundscape';
+
+describe('CHORD_SETS', () => {
+ it('has bright and tense tables of equal length', () => {
+ expect(CHORD_SETS.bright).toHaveLength(CHORD_SETS.tense.length);
+ for (const set of [...CHORD_SETS.bright, ...CHORD_SETS.tense]) {
+ expect(set).toHaveLength(3);
+ }
+ });
+});
+
+describe('classifyMood', () => {
+ it('is bright for a healthy, quiet system', () => {
+ expect(classifyMood({ overallHealth: 'healthy', system: { cpu: { usagePercent: 10 }, memory: { usagePercent: 20 } } })).toBe('bright');
+ });
+ it('is tense for a critical/unhealthy verdict', () => {
+ expect(classifyMood({ overallHealth: 'critical' })).toBe('tense');
+ expect(classifyMood({ overallHealth: 'unhealthy' })).toBe('tense');
+ });
+ it('tenses on very high CPU/memory even without a warning verdict', () => {
+ expect(classifyMood({ system: { cpu: { usagePercent: 90 } } })).toBe('tense');
+ expect(classifyMood({ system: { memory: { usagePercent: 95 } } })).toBe('tense');
+ });
+ it('is neutral when degraded or moderately loaded', () => {
+ expect(classifyMood({ overallHealth: 'degraded' })).toBe('neutral');
+ expect(classifyMood({ system: { cpu: { usagePercent: 70 } } })).toBe('neutral');
+ });
+ it('defaults to bright with no health data', () => {
+ expect(classifyMood(null)).toBe('bright');
+ expect(classifyMood(undefined)).toBe('bright');
+ expect(classifyMood({})).toBe('bright');
+ });
+});
+
+describe('computeActivityEnergy', () => {
+ it('has a non-zero floor with no agents', () => {
+ expect(computeActivityEnergy(0)).toBeCloseTo(0.15, 5);
+ expect(computeActivityEnergy(undefined)).toBeCloseTo(0.15, 5);
+ });
+ it('rises monotonically with agent count and saturates below 1', () => {
+ const e1 = computeActivityEnergy(1);
+ const e3 = computeActivityEnergy(3);
+ const e10 = computeActivityEnergy(10);
+ expect(e3).toBeGreaterThan(e1);
+ expect(e10).toBeGreaterThan(e3);
+ expect(e10).toBeLessThanOrEqual(1);
+ });
+ it('clamps negatives to the floor', () => {
+ expect(computeActivityEnergy(-5)).toBeCloseTo(0.15, 5);
+ });
+});
+
+describe('computeSoundscape', () => {
+ it('maps a healthy quiet city to a bright, low-energy soundscape', () => {
+ const s = computeSoundscape({ systemHealth: { overallHealth: 'healthy' }, agentCount: 0 });
+ expect(s.mood).toBe('bright');
+ expect(s.chordSet).toBe('bright');
+ expect(s.arpGain).toBeCloseTo(0.02 + 0.15 * 0.08, 4);
+ expect(s.padDetune).toBe(8);
+ });
+ it('maps a stressed city to a tense chord set and muffled filter', () => {
+ const calm = computeSoundscape({ systemHealth: { overallHealth: 'healthy' }, agentCount: 0 });
+ const tense = computeSoundscape({ systemHealth: { overallHealth: 'critical' }, agentCount: 0 });
+ expect(tense.chordSet).toBe('tense');
+ expect(tense.filterBase).toBeLessThan(calm.filterBase);
+ expect(tense.padDetune).toBeGreaterThan(calm.padDetune);
+ });
+ it('raises arp gain and energy as agents spin up', () => {
+ const idle = computeSoundscape({ agentCount: 0 });
+ const busy = computeSoundscape({ agentCount: 6 });
+ expect(busy.arpGain).toBeGreaterThan(idle.arpGain);
+ expect(busy.energy).toBeGreaterThan(idle.energy);
+ expect(busy.pulse).toBe(busy.energy);
+ });
+ it('keeps the bright chord table for neutral mood (only filter darkens)', () => {
+ const s = computeSoundscape({ systemHealth: { overallHealth: 'degraded' }, agentCount: 1 });
+ expect(s.mood).toBe('neutral');
+ expect(s.chordSet).toBe('bright');
+ });
+ it('handles an empty snapshot', () => {
+ const s = computeSoundscape();
+ expect(s.mood).toBe('bright');
+ expect(Number.isFinite(s.filterBase)).toBe(true);
+ });
+});