feat: integrate authored nightdrive soundtrack

This commit is contained in:
2026-09-04 14:39:28 +03:00
parent eb7f276b91
commit 745fa8169e
39 changed files with 1013 additions and 714 deletions

View File

@@ -13,6 +13,7 @@ export const PERFORMANCE_BUDGETS = Object.freeze({
deferredProjectVisuals: 2.5 * 1024 * 1024,
highTierExtras: 750 * 1024,
deferredNonVideo: 3.5 * 1024 * 1024,
deferredAudio: 13 * 1024 * 1024,
imageSceneConcurrency: 2,
videoConcurrency: 1,
mobileTextureDimension: 2048,
@@ -20,6 +21,10 @@ export const PERFORMANCE_BUDGETS = Object.freeze({
highTierGpuEstimate: 192 * 1024 * 1024,
});
export const normalizeDetectedMediaType = (mediaType) => (
typeof mediaType === 'string' ? mediaType.split(';', 1)[0].trim() : null
);
export const resolveBudgetGateMode = ({ transferOnly, runtimeTracePath }) => {
if (transferOnly && runtimeTracePath !== null) throw new Error('Transfer-only mode cannot be combined with runtime evidence.');
if (transferOnly) return { kind: 'transfer-only' };
@@ -39,6 +44,7 @@ export const classifyArtifact = (path, source = '') => {
if (/^assets\/project-[^/]+\.(?:webm|mp4)$/u.test(path)) return 'project-video';
if (/^assets\/project-[^/]*chart[^/]*\.(?:avif|webp|png|jpe?g)$/u.test(path)) return 'chart';
if (/^assets\/project-[^/]+\.(?:avif|webp|png|jpe?g|svg)$/u.test(path)) return 'project-still';
if (/^assets\/nightdrive-(?:intro|main)\.(?:opus|mp3)$/u.test(path)) return 'soundtrack-audio';
if (/^(?:robots\.txt|sitemap\.xml|_headers\.example|_redirects\.example)$/u.test(path)) return 'release-metadata';
throw new Error(`Artifact is unclassified: ${path}`);
};
@@ -51,6 +57,7 @@ const thresholdByTotal = Object.freeze({
firstLiveScene: PERFORMANCE_BUDGETS.firstLiveScene,
deferredProjectVisuals: PERFORMANCE_BUDGETS.deferredProjectVisuals,
deferredNonVideo: PERFORMANCE_BUDGETS.deferredNonVideo,
deferredAudio: PERFORMANCE_BUDGETS.deferredAudio,
highTierExtras: PERFORMANCE_BUDGETS.highTierExtras,
});
@@ -63,13 +70,34 @@ export const evaluateBudgetTotals = (totals) => ({
const violation = (budget, actual, threshold, id) => ({ budget, actual, threshold, ...(id === undefined ? {} : { id }) });
const finitePositiveInteger = (value) => Number.isInteger(value) && value > 0;
export const evaluateMediaAssetBudget = (asset, probe, transferBytes, assetClass = undefined) => {
export const evaluateMediaAssetBudget = (
asset,
probe,
transferBytes,
assetClass = /** @type {'chart' | 'project-still' | 'soundtrack-audio' | undefined} */ (undefined),
) => {
if (probe === null || typeof probe !== 'object') throw new Error(`Media probe evidence is required for ${asset?.id ?? 'unknown asset'}.`);
if (assetClass === 'soundtrack-audio' && !asset?.mediaType?.startsWith('audio/')) {
throw new Error(`Soundtrack classification requires audio media for ${asset?.id ?? 'unknown asset'}.`);
}
if (asset?.mediaType !== probe.mediaType) {
throw new Error(`Manifest and probe evidence disagree for ${asset?.id ?? 'unknown asset'}.`);
}
if (asset.mediaType.startsWith('audio/')) {
if (asset.width !== null || asset.height !== null || probe.width !== null || probe.height !== null) {
throw new Error(`Audio dimensions must be null for ${asset.id}.`);
}
if (!finitePositiveInteger(asset.durationMs) || !finitePositiveInteger(probe.durationMs)
|| Math.abs(asset.durationMs - probe.durationMs) > 100) {
throw new Error(`Verified duration is required for ${asset.id}.`);
}
return { violations: [] };
}
if (!finitePositiveInteger(asset?.width) || !finitePositiveInteger(asset?.height)
|| !finitePositiveInteger(probe.width) || !finitePositiveInteger(probe.height)) {
throw new Error(`Verified dimensions are required for ${asset?.id ?? 'unknown asset'}.`);
}
if (asset.width !== probe.width || asset.height !== probe.height || asset.mediaType !== probe.mediaType) {
if (asset.width !== probe.width || asset.height !== probe.height) {
throw new Error(`Manifest and probe evidence disagree for ${asset.id}.`);
}
const violations = [];