fix(core): enforce strict runtime safety

This commit is contained in:
James
2026-07-11 21:31:30 -07:00
parent ebbd1eb2c2
commit 0af07a07c5
24 changed files with 348 additions and 116 deletions
@@ -0,0 +1,57 @@
import { describe, expect, it } from "vitest";
import {
PLAY_REBIND_HOLD_SECONDS,
TIMELINE_REBIND_INTERVAL_FRAMES,
shouldAttemptPeriodicTimelineBind,
} from "./timelineRebindPolicy";
describe("shouldAttemptPeriodicTimelineBind", () => {
it("only checks for replacements at the periodic boundary", () => {
expect(
shouldAttemptPeriodicTimelineBind({
tick: TIMELINE_REBIND_INTERVAL_FRAMES - 1,
isPlaying: false,
hasCapturedTimeline: true,
currentTimeSeconds: 0,
}),
).toBe(false);
expect(
shouldAttemptPeriodicTimelineBind({
tick: TIMELINE_REBIND_INTERVAL_FRAMES,
isPlaying: false,
hasCapturedTimeline: true,
currentTimeSeconds: 0,
}),
).toBe(true);
});
it("holds a captured timeline during the first playback seconds", () => {
expect(
shouldAttemptPeriodicTimelineBind({
tick: TIMELINE_REBIND_INTERVAL_FRAMES,
isPlaying: true,
hasCapturedTimeline: true,
currentTimeSeconds: PLAY_REBIND_HOLD_SECONDS - 0.001,
}),
).toBe(false);
expect(
shouldAttemptPeriodicTimelineBind({
tick: TIMELINE_REBIND_INTERVAL_FRAMES,
isPlaying: true,
hasCapturedTimeline: true,
currentTimeSeconds: PLAY_REBIND_HOLD_SECONDS,
}),
).toBe(true);
});
it("does not hold when no timeline has bound yet", () => {
expect(
shouldAttemptPeriodicTimelineBind({
tick: TIMELINE_REBIND_INTERVAL_FRAMES,
isPlaying: true,
hasCapturedTimeline: false,
currentTimeSeconds: 0,
}),
).toBe(true);
});
});