port: FORMAT.md declared the port's own export invalid; assert audio.json's stems

Audits the open format spec against the validator by breaking each documented
requirement. Four of five caught. The fifth is the doc's error: FORMAT.md said
check refuses any peak >= 0 dBFS, where the implementation is kind-dependent --
a bgm is a sum we produced and is refused at full scale, an se/voice is a disc
wave whose lossy decode overshoots and is allowed to +1.0.

The doc was wrong about our own export: confirm ships at +0.18 and the ADV voice
at +0.31. A consumer implementing a validator from FORMAT.md would have rejected
a valid tree -- the file that exists so someone can check our work without
trusting us. Corrected, with the +1.0 marked as a judgement.

Also closes the last unread authored value: audio.json's  was carried as
stems_why only, so serde ignored the value. Now deserialised and asserted in the
exporter (only sum is implemented); the assertion is proved to fire.

Files, not fixes: a failed export leaves a tree with no manifest, and every tool
then says 'is that an export tree?' -- which nearly made me conclude the
validator was checking nothing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N7FiFFFwbvG2uxdcEh8HyF
This commit is contained in:
Sylpheed port agent
2026-08-30 03:46:13 +00:00
parent fdb33a9abc
commit e647368ddd
4 changed files with 108 additions and 1 deletions

View File

@@ -79,6 +79,20 @@ pub struct BgmSpec {
pub why: String,
#[serde(default)]
pub loop_why: Option<String>,
/// How a bank's two sub-waves become one file. **Only `"sum"` is
/// implemented**, and this field exists to say so when it is not.
///
/// 🔴 It was `stems_why` alone until 2026-08-30 — the *reason* was
/// deserialised and the *value* was not, so `stems` sat in
/// `authored/audio.json` being ignored by serde. Changing it to anything at
/// all did nothing and warned nobody, which is the seventh instance in this
/// port of an authored value with no reader.
///
/// It is ASSERTED rather than implemented: a weighted mix is not written,
/// and inventing one would be a level decision nobody measured (HANDOFF Q10
/// settles that the two waves are summed, not what wave 1 *is*).
#[serde(default)]
pub stems: Option<String>,
#[serde(default)]
pub stems_why: Option<String>,
}
@@ -370,6 +384,18 @@ pub fn export_bgm<S: DiscSource + ?Sized>(
role: &str,
spec: &BgmSpec,
) -> Result<Option<Exported>> {
// Assert the authored value this function was built for, rather than
// silently doing something else. Only `sum` is implemented.
if let Some(mode) = spec.stems.as_deref() {
if mode != "sum" {
bail!(
"authored/audio.json bgm.{role}.stems is {mode:?}; \
export_bgm implements only \"sum\" (HANDOFF Q10 settles that a \
bank's two waves are summed; a weighting would be an unmeasured \
level decision)"
);
}
}
let riffs = match media::sound_bank_riffs(source, &spec.bank) {
Ok(r) if !r.is_empty() => r,
Ok(_) => return Ok(None),