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

address review (codex): clarify beats.json is the cut source, strengthen the cache test

[._.]/ Adam Eivy0e2f8d3af067
diff --git a/server/lib/beatGrid.test.js b/server/lib/beatGrid.test.js
index 17fab9a808..d4e696e80a 100644
--- a/server/lib/beatGrid.test.js
+++ b/server/lib/beatGrid.test.js
@@ -1,5 +1,5 @@
import { describe, it, expect, beforeAll, afterAll, afterEach } from 'vitest';
-import { writeFile, mkdtemp, rm } from 'fs/promises';
+import { writeFile, mkdtemp, rm, stat, utimes } from 'fs/promises';
import { tmpdir } from 'os';
import { join } from 'path';
import {
@@ -196,7 +196,7 @@ describe('getBeatGrid (mtime-keyed cache)', () => {
expect(await getBeatGrid(null)).toBeNull();
});
- it('caches by path+mtime and re-measures after the file changes (skipped without ffmpeg)', async () => {
+ it('caches strictly by mtime, not by content (skipped without ffmpeg)', async () => {
if (!ffmpeg) { console.log('⏭️ ffmpeg not found — skipping beat-grid cache round-trip'); return; }
const wavSampleRate = 44100;
const wavPath = join(tmpDir, 'cache-track.wav');
@@ -207,18 +207,27 @@ describe('getBeatGrid (mtime-keyed cache)', () => {
expect(first.bpm).toBeGreaterThan(100 - BPM_TOLERANCE);
expect(first.bpm).toBeLessThan(100 + BPM_TOLERANCE);
- // A second call against the unchanged file must hit the cache: overwrite
- // the file with SILENCE but keep serving the first (cached) result until
- // the mtime moves.
- const cached = await getBeatGrid(wavPath);
- expect(cached).toEqual(first);
-
- // Bump mtime forward so a filesystem with coarse mtime resolution still
- // registers the change, then overwrite with a different tempo.
- await new Promise((resolve) => setTimeout(resolve, 20));
- await writeFile(wavPath, encodeWav(clickTrack({ bpm: 140, durationSec: 6, sampleRate: wavSampleRate }), wavSampleRate));
+ // A repeat call against the unchanged file must be an actual cache HIT,
+ // not a coincidentally-identical recomputation (the DSP is deterministic,
+ // so `toEqual` alone can't tell the two apart). `toBe` asserts the same
+ // object reference, which only a real cache hit can produce — a fresh
+ // analysis always allocates a new result object.
+ const second = await getBeatGrid(wavPath);
+ expect(second).toBe(first);
+
+ // Overwrite with a different tempo, then bump mtime forward explicitly
+ // (rather than relying on write-induced mtime resolution, which can be
+ // coarser than the gap between two writes on some filesystems — a plain
+ // write's own timestamp could otherwise land in the same millisecond as
+ // the original). The cache must invalidate and return a freshly measured,
+ // distinct result.
+ await writeFile(wavPath, encodeWav(clickTrack({ bpm: 130, durationSec: 6, sampleRate: wavSampleRate }), wavSampleRate));
+ const stats = await stat(wavPath);
+ await utimes(wavPath, stats.atime, new Date(stats.mtime.getTime() + 1000));
const updated = await getBeatGrid(wavPath);
expect(updated).not.toBeNull();
- expect(updated.bpm).not.toBe(first.bpm);
+ expect(updated).not.toBe(first);
+ expect(updated.bpm).toBeGreaterThan(130 - BPM_TOLERANCE);
+ expect(updated.bpm).toBeLessThan(130 + BPM_TOLERANCE);
});
});
diff --git a/server/services/taskPromptDefaults/appLaunchVideo.js b/server/services/taskPromptDefaults/appLaunchVideo.js
index 5ffda75754..0251dd70e6 100644
--- a/server/services/taskPromptDefaults/appLaunchVideo.js
+++ b/server/services/taskPromptDefaults/appLaunchVideo.js
@@ -9,7 +9,7 @@ Write only to the supplied output directory (plus the runner's completion sentin
Every scene has durationSec; every visible text element has text, its exact whitespace-separated wordCount, and holdSec. Total 15–120 seconds and within two seconds of the chosen target. Each hold is at least max(0.8, 0.3 * wordCount) and fits its scene. Implement those holds faithfully, including transitions. Choose posterSec at the strongest settled beat.
- index.html and local assets: globalThis.portosComposition = {durationSec, fps:24, width, height, async seek(t){...}}. Use dimensions 1920x1080 (landscape), 1080x1920 (vertical), or 1080x1080 (square). Seek deterministically from t; await fonts and any asynchronous work. No wall-clock animations, external URLs, popups, workers or browser storage. Keep HTML/CSS/JS/SVG/JSON/Markdown/text UTF-8. No raster screenshots or footage.
Direct it like a motion designer, not a slideshow. Banned defaults: a centered title on a gradient, everything fading in, corner labels, frame borders, crop marks or HUD chrome, glow on UI chrome, generic particle bursts and dead beats. Hook within the first two seconds and make something new happen every two to four seconds. Use one display face, one UI face and one accent color from the app's palette. Motion has mass: drive position, scale, radius and width with closed-form springs, not fixed easing curves, with a tiny overshoot on UI and none on type. All motion stays a pure function of t: seeded pseudo-randomness only, never Math.random or timers.
-The server pre-installed the PortOS motion kit at composition/portos-motion.js. Load it with <script src="portos-motion.js"></script> and use globalThis.PortosMotion: spring(t, stiffness, damping) and SPRINGS presets (snappy, default, heavy, playful); track(t, [[time, value], ...]) for any value with several targets (one spring per change, never restart one); indicator() for selection bars that stretch while they travel; swapAlpha() so content inside a morphing container enters after the morph starts and leaves before the next; rng(seed) for seeded noise; beats(bpm) for a beat grid; and renderCues, mixCues and toPcm for synthesized UI sound (click, tick, pop, thump, whoosh, riser). It is ordinary composition source: edit it or delete it if unused. If composition/beats.json exists, it holds a real measured analysis of the chosen library track: {"bpm","beats","downbeats","hits"} (seconds; bpm/beats/downbeats are null/empty when no confident tempo was found). Use its bpm with beats(bpm) instead of guessing one, and place state changes on beats, big moments on downbeats, and UI sounds on hits.
+The server pre-installed the PortOS motion kit at composition/portos-motion.js. Load it with <script src="portos-motion.js"></script> and use globalThis.PortosMotion: spring(t, stiffness, damping) and SPRINGS presets (snappy, default, heavy, playful); track(t, [[time, value], ...]) for any value with several targets (one spring per change, never restart one); indicator() for selection bars that stretch while they travel; swapAlpha() so content inside a morphing container enters after the morph starts and leaves before the next; rng(seed) for seeded noise; beats(bpm) for a beat grid; and renderCues, mixCues and toPcm for synthesized UI sound (click, tick, pop, thump, whoosh, riser). It is ordinary composition source: edit it or delete it if unused. If composition/beats.json exists, it holds a real measured analysis of the chosen library track: {"bpm","beats","downbeats","hits"} (seconds; bpm/beats/downbeats are null/empty when no confident tempo was found). Cut on its beats/downbeats/hits timestamp arrays directly, not a synthetic beats(bpm) grid (which starts at t=0 and will not match this track's real phase): place state changes at entries in beats, big moments at entries in downbeats, and UI sounds at entries in hits. Fall back to beats(bpm) with its bpm only when beats.json is absent or its arrays are empty.
motionStyle picks the film's grammar. "walkthrough": a clear, paced product walkthrough of the recreated key flow, a cursor driving real actions, springs on every change. "showreel": a designer's showreel built around this product, not a slideshow of recreated screens. Cut on a steady beat (a new beat every one to two seconds, landing on bar boundaries when music is present) and give each beat a distinct technique: bold color-field swaps drawn from the app's palette, oversized kinetic typography (scale, mask and slide reveals; repeated-word patterns), spring contrasts (snappy against heavy against playful), generative geometry computed from t (tiling patterns, radial forms, wireframes), shape morphs, and a logo/name lockup endcard. Keep the recreated key flow as one or two punchy beats so the evidence-backed claim still lands. "ui-morph": one shape, never cut. A single container morphs size, radius and fill from state to state along this app's real flow (for example button, input being typed, loader, success check, dashboard card, chart drawing itself, command palette, toast, logo), its content swaps behind a short blur with swapAlpha, a cursor drives each change with real clicks, a state change lands on every beat at 120 BPM, and the last frame equals the first, cursor position included, so it loops. Write the state list on the beat grid in plan.md before any code. In every style, each word shown, including repeated kinetic words, is a storyboard line whose hold meets the reading-time gate.
When generateMusic is true, the user explicitly requests original instrumental music. musicMethod chooses how: "agent" (the default) means compose and synthesize it yourself; "service" means use a configured PortOS music engine. Never require a music engine for the agent method.
For the agent method, implement async globalThis.portosComposition.renderAudio({sampleRate, durationSec}) returning a plain array of exactly Math.round(sampleRate * durationSec) finite mono PCM samples in [-1, 1]. The renderer supplies sampleRate=24000 and the video duration, writes a temporary soundtrack and muxes it into the MP4. Compose a deliberate instrumental arrangement matching the storyboard, with melody, harmony, rhythm, dynamics and an ending; document tempo and musical direction in plan.md. Use native OfflineAudioContext, deterministic sample synthesis, or locally available Tone.js/Strudel code that can export this PCM contract. Use only procedural synthesis, no recordings or fetched samples. Keep all source in composition/ as inspectable UTF-8 JavaScript. No installs, CDN imports, network calls, live playback or binary audio assets. Do not assume Tone.js or Strudel is installed; native Web Audio or plain JavaScript synthesis requires no additional music runtime. Add synthesizeMusic:true to the render JSON; do not set musicTrack or call /api/music/engines or /api/music/generate. Audio played by the page is NOT captured: renderAudio is required. A failed audio render is a failed task, never silently omit requested music.
diff --git a/server/services/taskPromptDefaults/integrity.snapshot.json b/server/services/taskPromptDefaults/integrity.snapshot.json
index 10f87748a8..74e46862c3 100644
--- a/server/services/taskPromptDefaults/integrity.snapshot.json
+++ b/server/services/taskPromptDefaults/integrity.snapshot.json
@@ -2,7 +2,7 @@
"DEFAULT_TASK_PROMPTS": {
"accessibility": "46f628a44a919bb788de8761e86ca0e1",
"api-contract": "d52e00ec53eb5618df1a769efccc08f3",
- "app-launch-video": "ffbdb1e70f02c51c14db59c5b2dd4203",
+ "app-launch-video": "d7ac534353a869136b91b318176c198f",
"better-cognitive-load": "a1fe22f6ef936131456c55a6b0623204",
"better-complexity": "c99f67b43ff54a1c8cf0176c721d9c06",
"better-dependency-freedom": "8a79c8be829f926bbc7720ee29818d53",