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

keep refusing excerpts that start past the render, give no slack without an fps, and register the helper in the lib barrel and README

[._.]/ Adam Eivy42d4affaccfc
diff --git a/server/lib/README.md b/server/lib/README.md
index 6c3da44202..8361ad37fe 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -851,6 +851,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `sheetPointers.js` | Browser-safe persisted character-sheet layout: `LEGACY_SHEET_VARIANT_ID`, `readSheetPointer`, `listSheetPointers`, identity-preserving `applySheetPointerToCharacter`, and default-variant browser adapter `applySheetPointer`. |
| `musicVideoGrade.js` | Opt-in Music Video grade presets, bounded normalization, and shared song-timed RGB curves with deterministic grain for composed and document encodes. |
| `musicVideoDependencies.js` | Versioned take/evidence provenance, dependency comparisons and bounded selective-repair previews. |
+| `musicVideoExcerptRange.js` | `excerptRangeFits(startSec, endSec, totalSec, fps)`: whether a code/document excerpt window fits a frame-quantized render, allowing the end up to one frame past it (scene ends follow the analysed song length; the caller clamps). The start must fall inside the render; an unknown fps allows no slack. |
| `musicVideoPlateEvidence.js` | Asset-bound authored-shot plate requirements, current evidence and selected-image admission. |
| `codeAnimationProjects.js` | Machine-local Production project, patch and independent budget schemas; package imports grant no execution authority. |
diff --git a/server/lib/index.js b/server/lib/index.js
index 131cbb621a..baf317b9eb 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -829,6 +829,7 @@ export * from './imageLimits.js';
export * from './musicVideoActionContract.js';
export * from './musicVideoGrade.js';
export * from './musicVideoDependencies.js';
+export * from './musicVideoExcerptRange.js';
export * from './musicVideoPlateEvidence.js';
export * from './codeAnimationProjects.js';
diff --git a/server/lib/musicVideoExcerptRange.js b/server/lib/musicVideoExcerptRange.js
index a46b5a98e5..1d41517964 100644
--- a/server/lib/musicVideoExcerptRange.js
+++ b/server/lib/musicVideoExcerptRange.js
@@ -2,9 +2,10 @@
* Whether an excerpt window fits a render of `totalSec` at `fps`. The end may run past the
* render by up to one frame: scene timings come from the analysed song length while a
* render's duration is frame-quantized, so the last scene's end (119.943s) can sit a
- * fraction of a frame past a 24 fps document render (119.92s). Callers clamp the end.
+ * fraction of a frame past a 24 fps document render (119.92s). Callers clamp the end. The
+ * start must still fall inside the render, and an unknown fps allows no slack.
*/
-export function excerptRangeFits(startSec, endSec, totalSec, fps = 24) {
+export function excerptRangeFits(startSec, endSec, totalSec, fps) {
const frame = Number.isFinite(fps) && fps > 0 ? 1 / fps : 0;
- return startSec >= 0 && endSec > startSec && endSec <= totalSec + frame + 1e-6;
+ return startSec >= 0 && startSec < totalSec && endSec > startSec && endSec <= totalSec + frame + 1e-6;
}
diff --git a/server/lib/musicVideoExcerptRange.test.js b/server/lib/musicVideoExcerptRange.test.js
index f0405ac2e2..fb4b973963 100644
--- a/server/lib/musicVideoExcerptRange.test.js
+++ b/server/lib/musicVideoExcerptRange.test.js
@@ -10,8 +10,11 @@ describe('excerptRangeFits', () => {
expect(excerptRangeFits(0, 120, 119.92, 24)).toBe(false);
expect(excerptRangeFits(5, 5, 119.92, 24)).toBe(false);
expect(excerptRangeFits(-1, 4, 119.92, 24)).toBe(false);
+ // The slack is for the end only: a window starting past the render is still refused.
+ expect(excerptRangeFits(119.93, 119.95, 119.92, 24)).toBe(false);
});
it('allows no slack without a usable fps', () => {
- expect(excerptRangeFits(0, 119.93, 119.92, 0)).toBe(false);
+ for (const fps of [undefined, 0, Number.NaN]) expect(excerptRangeFits(0, 119.93, 119.92, fps)).toBe(false);
+ expect(excerptRangeFits(0, 119.92, 119.92, undefined)).toBe(true);
});
});