Bounded independent preview channels

This is service software, not production admission or deployment. The private receipt builder and real source/decoder proof must run on the authorised Vultr audio rail. This Worker never generates an admission, guesses whether a source is dry, parses MPEG, rebuilds audio, or falls back to a subscriber URL.

Consumer contract

POST https://audio.salus-rooms.com/preview accepts exactly one JSON field:

{"slug":"test-narrated-session"}

The request is limited to 1,024 bytes. Paths, URLs, offsets, durations and alternative voices are refused. The response uses the current LIVE audio row. The current row's identity must match the consumer before playback starts. This illustrative software fixture is not an admitted recording:

{
  "schema": "hush-preview-audio/1",
  "slug": "test-narrated-session",
  "sessionId": "11111111-2222-4333-8444-555555555555",
  "narrator": "maya",
  "sourceRowUpdatedAt": "2026-11-07T08:00:00+00:00",
  "sourceIdentity": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "voice": {
    "url": "https://audio.salus-rooms.com/preview/test-narrated-session/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/voice.mp3",
    "sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
    "byteLength": 41700,
    "durationSeconds": 2.6122448979591835,
    "containsPad": false
  },
  "pad": {
    "url": "https://audio.salus-rooms.com/preview/test-narrated-session/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/pad.mp3",
    "sha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
    "byteLength": 41700,
    "durationSeconds": 2.6122448979591835,
    "containsNarration": false,
    "loop": true,
    "track": "test-pad"
  }
}

Each channel has positive finite duration at most 90 seconds and positive integer length at most 2,000,000 bytes, the existing App limit. The producer emits the fixed derived format below regardless of the original source's bitrate. Both channels are bounded. The consumer must not replace the returned pad with the full ambient object or mark these clips as the prepared pilot's unit-gain or faded assets. Its established assigned-pad gain and independent preview budget still apply. This API does not grant alternative narrator selection.

The response URL origin is always https://audio.salus-rooms.com, including requests through the older audio hostname. No redirect or full source URL is returned. sourceIdentity is SHA256 of the exact raw private receipt bytes, which bind the LIVE row and both source/clip descriptors. Changing either channel or even the receipt serialization changes that identity.

GET|HEAD /preview/<slug>/<identity>/{voice|pad}.mp3 resolves the LIVE row and receipt on every request, rechecks both original and both derived object ETags and sizes, then serves only the clipped byte space. Closed, open and suffix byte ranges are supported. HEAD has an empty body and never reads the narration or pad body. A stale If-Range returns the whole clip. It cannot return the source. The response ETag is specific to identity and channel. X-Preview-Duration is clip seconds. All responses use no-store; audio also uses private. There is no shared edge cache or metadata cache bypassing the LIVE check. Existing CORS origins apply; HEAD, Range/If-Range and clipped response headers are exposed.

Result Meaning
400 Invalid request, extra input fields, unsupported slug or query
404 Session/index/proof unavailable or unsupported/unproved format
409 LIVE row, either source, or requested identity changed; resolve afresh
416 Invalid/multiple/outside range, with Content-Range: bytes */<clip-size>
503 Missing binding or upstream session lookup unavailable
500 Unexpected internal failure; no audio fallback

The subscriber and Live Room routes keep their existing authorization rules. No preview token can become a subscriber link because this route never issues one. Every source key is resolved server-side, never taken from the caller.

Private receipt and admission boundary

Receipts live at private/preview-index/v1/<slug>.json in the existing AUDIO_BUCKET (salus-mind). That prefix is outside public-assets' allowlist. The Worker reads at most 16,384 bytes plus one overflow sentinel. No receipt objects or production bindings are published by this code change.

The trusted builder must write schema hush-preview-index/1 with:

Field Required value
session Exact id,slug,narrator,updatedAt,audioKey,ambientTrack matching current LIVE row
proof.method vultr-bounded-derived-v1
proof.frameIndexSha256 Hash of retained frame index and decode/container proof
proof.sourceProvenanceSha256 Hash of exact content proof, binding both full original identities and emitted clips as described below
proof.validatedAt Dated successful admission
voice.original, pad.original Exact full original key,etag,size,sha256, bound to LIVE
voice.source, pad.source Exact private derived clip key,etag,size,sha256
voice.containsPad false
pad.containsNarration, pad.loop false, true
Each clip Fields below, with independently computed clipped SHA256

The original voice key must be the exact allowed HTTPS sessions.audio_url pathname, not a filename derived from the slug. The original pad key is exactly content/ambient/<sessions.ambient_track>.mp3. The service requires one LIVE, audio, explicitly non-coming-soon row with a narrator and assigned pad. Index absence, uncertain content proof or a narrator mismatch fails closed. The containsPad:false and containsNarration:false verdicts apply to the emitted clips; they do not certify the rest of either original master.

Each derived source key is exactly private/preview-channels/v1/<slug>/<clip.sha256>/{voice|pad}.mp3. Its sha256 must equal clip.sha256; its size must equal clip.byteLength and clip.sourceLength. The complete object is the bounded clip. No source offsets, original audio keys, alternate slugs/channels, public prefixes or arbitrary private objects can stand in for it. Both private prefixes are outside the public-assets allowlist.

The trusted Vultr producer decodes the original from a safe prefix, trims the established opening, then re-encodes a bounded clip without added volume, mix, limiter or fade processing. The lossy encoder's measured default amplitude characteristic is recorded in the private proof; bit-exact amplitude is not promised. This avoids the infeasible raw-frame approach: an ordinary source can have no reservoir-independent frame near speech and only one before a long silent lead-in. Such a raw receipt remains refused. The unreleased earlier vultr-mpeg-prefix-v1 method is not accepted.

The admitted output is narrowly MPEG-1 Layer III, constant 128,000-bit/s, 44,100-Hz, with metadata stripped. Each clip specifies:

{
  "codec":"mpeg1-layer3-cbr",
  "container":"metadata-stripped",
  "containerTagBytes":0,
  "firstAudioMainDataBegin":0,
  "sourceOffset":0,
  "sourceLength":41700,
  "frameCount":100,
  "samplesPerFrame":1152,
  "sampleRate":44100,
  "bitrateBps":128000,
  "byteLength":41700,
  "sha256":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
  "opening": {
    "policy":"existing-first-speech-v1",
    "speechStartSample":1323216,
    "sourceStartSample":1290141,
    "sourceSampleRate":44100,
    "retainedPrerollSamples":33075,
    "proofSha256":"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
  }
}

Opening positions count decoded samples in the original source domain. sourceSampleRate is its actual rate, one of 32,000/44,100/48,000; it need not equal the derived output rate. In this example the producer trims at original sample 1,290,141 and includes 33,075 original samples (0.75 seconds) before the detected speech. That preroll is inside the returned duration, not added to it. The output's first frame must have main_data_begin=0 regardless of the original frame's reservoir state. A pad uses opening.policy: "assigned-pad-start-v1", sourceStartSample: 0, retainedPrerollSamples: 0 and its own proofSha256, with no speechStartSample.

These are illustrative synthetic values. The builder must independently prove:

  1. Content proof is bound to both exact LIVE original descriptors (key, ETag, size and full SHA256), each emitted clip SHA256 and its opening-proof SHA256. Immutable provenance may establish that the originals are dry voice and pad-only recordings. Where a legacy certificate is absent, a named, dated listener must hear the whole exact emitted clip, including pauses, at a recorded QA gain and explicitly record no audible baked pad in voice or no audible narration in pad. Record listener, time, gain, verdict and whole-window coverage. This hearing proves only the exposed window; it makes no whole-master or catalogue claim. Missing, refused or uncertain content evidence means no admission. Pipeline structure or object names alone are insufficient.
  2. The producer's original prefix starts at a proven safe decoder boundary and covers the spoken opening and intended bounded excerpt. It must not decode an arbitrary original frame with missing reservoir data. Re-encoding is performed only on the authorised Vultr rail within existing resource caps.
  3. Every derived frame matches the declared codec/rate/bitrate, the object begins and ends at whole frames, its first frame has main_data_begin=0, and frame count gives at most 90 seconds. containerTagBytes and sourceOffset are both zero. Stripped metadata includes full duration, TLEN, iTunSMPB, Xing/Info/VBRI/TOC and any trailing tags. No full-source duration/seek metadata reaches either client.
  4. The complete emitted clip decodes independently on Vultr, has the declared byte hash and duration, and fits the exact existing channel size bound. No volume, mix, limiter or fade filter is added. Its proof records the measured encoder preset amplitude characteristic and fixed encoder delay. The reviewed consumer applies its existing assigned-pad gain and duration-bound envelopes.
  5. The provenance receipt binds the full original source SHA256 to its current R2 ETag and size; a prefix hash is not a full-source hash. The frame and opening proof binds that original to the exact emitted clip hash. A local build result without the derived object's actual uploaded ETag and downloaded-byte proof is preparation, not a final service admission.
  6. The voice opening proof binds the existing preview's detected speech onset, not raw source time zero. For a source beginning with detected silence, the existing detect_speech_start policy starts 0.75 seconds before the detected onset, clamped at source time zero. Otherwise it starts at zero. The source can contain 30 seconds of initial silence. sourceStartSample is exactly max(0, speechStartSample - 3 * sourceSampleRate / 4), and speechStartSample - sourceStartSample equals retainedPrerollSamples. These nonnegative integer positions refer to the original decoded source. The preroll is less than the derived duration when converted at the original source rate. Do not reintroduce the assembler lead-in or skip the existing spoken opening. The private proof must establish this audible opening match; field shape is not proof of it.

The consumer still starts each returned channel at clip time zero. Source positions and preroll are private admission details. The derived clips do not carry the old preview builder's voice/pad fades. A reviewed consumer envelope and handset proof remain release dependencies; these clips must not be described as the old prepared, faded preview assets.

Only named, fresh receipts provide coverage. The service returns an error for unavailable or stale admissions and supplies no replacement asset. Existing mixed consumer fallbacks remain a separate coverage gap.

The Worker verifies receipt shape, exact row/original/derived identity, sample arithmetic, frame-byte plausibility and limits. It trusts the private producer's byte and content proof; numeric fields alone establish neither an MP3 nor a content verdict. Original audio bodies are never read by this route. Each derived-body read is a conditional ranged R2 read confined to the complete bounded private clip. A failed overwrite precondition or unexpected range/size returns 409 before exposing a body. Unsupported output VBR, free-format, other MPEG versions or containers need a separately reviewed contract and decoder proof; no time-to-byte guess or arbitrary header patch is accepted.

Validation and primary references

node --test workers/premium-audio/tests/*.test.mjs tests software behavior with synthetic, non-media bytes. It proves neither real source content nor Vultr admission, deployment, or handset playback. Real admissions and source validation remain a release dependency.