# --- K. THE DERIVED FORMATS — the whole of Critical rule #4 ----------------
# **Nothing has ever tested this on hardware.** FLAC is the archival master and
# MP3, WavPack and WAV are DERIVED from it by the single post-rip transcode
# adapter. Every rip still produces FLAC first; selecting another format keeps
# that FLAC and derives the chosen one from it.
#
# So each of these three sections proves a different thing:
#
#   * MP3      — lossy by design, best-practice VBR, and the ONLY one with a
#                quality knob. `mp3_vbr_quality 2` is a real VBR setting, not the
#                default, so a knob that reaches nothing would show up.
#   * WavPack  — the second lossless format. Tags and art survive.
#   * WAV      — raw PCM and NO embedded art. Its title says only what K3
#                checks (2026-11-03, review C4): the Settings warning is not
#                graded here, and ffmpeg copies title, artist, album and track
#                into RIFF INFO, which `expect-derived-files wav` reports.
#
# `expect-derived-files` OPENS each derived file (review C4, 2026-11-03): its
# length against its master's, its own tags and cover (MP3, WavPack), and the
# encoder and MP3 `-q:a` that ran, read from the report's `encoder_argv`. Until
# then K1-K3's `expect-tags` and `expect-cover-art` graded the FLAC masters.
#
# Two tracks each. The transcode path is per-file and a third track adds a row,
# not a discriminator.
#
# A DIFFERENT ALBUM TITLE PER FORMAT, so the three land in three folders and
# none of them collides with section F's archival master.

# --- K1-K3. THE DERIVED FORMATS, AND THE ASSERTION THEY DID NOT HAVE -------
# **Added 2026-09-15, after this run passed while producing nothing.** K1 and K2
# are graded ARCHIVAL -- K1's reason in `docs/testing.md` is *"when a user selects
# MP3 the MP3 IS their library entry"* -- and between them they asserted the
# setting round-trip, `expect-rip-complete`, and `rig-check`. None of the three
# can see a derived file:
#
#   * `expect-rip-complete` grades **cyanrip's own log**, and cyanrip is always
#     invoked `-o flac` -- FLAC is the archival master and every other format is
#     derived from it afterwards by our transcode adapter (Critical rule #4),
#     which that log knows nothing about. The witness is identical whether the
#     transcode ran or never happened.
#   * `rig_check.py` contains **zero** mentions of mp3, wavpack, or any derived
#     format. Derived by grep, not assumed.
#   * `set`/`expect output_format mp3` checks a setting against itself.
#
# So on the 2026-09-15 run both sections were green and the folders held **no
# `.mp3` and no `.wv` at all**: each transcode was dropped about three seconds
# after its rip finished, by the next section's Start. Two ARCHIVAL sections
# cannot fail is not a detail of those two sections -- the maintainer's bar is
# *zero failures in the ARCHIVAL sections*, and that sentence means nothing over
# a section with no way to fail.
#
# `expect-derived-output` names the format rather than reading it back from
# Settings, for the reason in the third bullet above.

log --- K1. MP3: the lossy derived output, with a real VBR quality ---
run-size quick
set output_format mp3
expect output_format mp3
set mp3_vbr_quality 2
expect mp3_vbr_quality 2
select-tracks 1-2
album derived mp3 (run) (ripper)
rip
wait-for-rip 3600
snapshot aftermp3
screenshot aftermp3
expect-rip-complete
expect-derived-output mp3
expect-derived-files mp3 2
# The derived gate is graded by the line above; CTDB and FLAC integrity ran
# on this rip too and are graded here, so every ripping section states the
# same claim in the same words.
expect-verification
expect-album-audit
expect-accuraterip
expect-ctdb partial
expect-tags
expect-cover-art
rig-check

log --- K2. WavPack: the second lossless format ---
run-size full
set output_format wavpack
expect output_format wavpack
# A SECOND cover_art MODE (2026-09-30). Every rip here used `embed`, so `file`
# and `complete` had never run on hardware. `file` saves a folder copy and
# embeds nothing; `expect-cover-art` asks the FLACs themselves.
set cover_art file
expect cover_art file
select-tracks 1-2
album derived wavpack (run) (ripper)
rip
wait-for-rip 3600
snapshot afterwavpack
expect-rip-complete
expect-derived-output wavpack
expect-derived-files wavpack
# The derived gate is graded by the line above; CTDB and FLAC integrity ran
# on this rip too and are graded here, so every ripping section states the
# same claim in the same words.
expect-verification
expect-album-audit
expect-accuraterip
expect-ctdb partial
expect-tags
expect-cover-art
rig-check

log --- K3. WAV: raw PCM, its master's length, no embedded art ---
run-size full
set output_format wav
expect output_format wav
# The third mode: `complete` embeds AND saves the folder copy.
set cover_art complete
expect cover_art complete
select-tracks 1-2
album derived wav (run) (ripper)
rip
wait-for-rip 3600
snapshot afterwav
log A4 (TASKS "Three screenshot steps found no window on screen"): the next screenshot records info, not fail, if the display has stopped showing the app
screenshot afterwav
expect-rip-complete
expect-derived-output wav
expect-derived-files wav
# The derived gate is graded by the line above; CTDB and FLAC integrity ran
# on this rip too and are graded here, so every ripping section states the
# same claim in the same words.
expect-verification
expect-album-audit
expect-accuraterip
expect-ctdb partial
expect-tags
expect-cover-art
rig-check

# --- K4. RESTORE THE FORMAT K1-K3 CHANGED ----------------------------------
# **A restore step, and graded UX accordingly** (regraded 2026-09-14). It was
# titled "back to FLAC, the archival master" and graded ARCHIVAL, which read as
# a check on the archival format and is not one: it sets a setting and reads it
# back, which section B already does verbatim at the top of this file and
# section Q does verbatim at the bottom.
#
# **And its effect does not survive to protect anything** — section L reassigns
# `output_format` twice within twenty lines (`portable` -> mp3, then
# `fast_verified` -> flac), so nothing downstream rests on this restore. The
# protection it appeared to provide is now asserted where it is actually needed,
# in L and in N.
#
# FLAC output is not unverified by the regrade: section F rips the whole disc in
# FLAC with `verify_flac_after_rip on`, and section N rips it again under the
# archival preset. Two whole-disc rips are the evidence; a fourth two-track rip
# here would spend six minutes of drive time re-proving them.
log --- K4. restore the output format K1-K3 changed ---
run-size quick
set output_format flac
expect output_format flac
# ...and the cover_art mode K2 and K3 changed, back to what every later rip
# (N) and F's baseline use.
set cover_art embed
expect cover_art embed

