# Platterpus UI script — ONE bounded -O read, run by hand (TASKS R24).
#
# Run it with:  ./platterpus-x86_64.AppImage --run-script overreadprobe
#          or:  Tools → Advanced → Run tests…, choose Over-read probe, press Run
#
# WHAT IT IS FOR. `-O` reads past the disc's edges: into the lead-out, so the
# last track can be read at a positive offset without padding, and into the
# lead-in for a negative one. On builds of the cyanrip fork before `.24` it read
# those frames through paranoia's retries, and on 2026-07-22 that hung the rig's
# BDR-209D for about 23 minutes, which is why every other script here keeps
# `force_overread` off. From `.24` (93afa15) the fork bounds it: each frame
# outside the disc is read once, a frame the drive refuses is written as
# silence, and the track says so in its log:
# `Beyond disc: N of M frames refused (written as silence)`. Every later build
# does the same, read from each one's source and listed, with citations, in
# `fork_source.BUILD_TAGS_BOUNDING_OVERREAD`. This script is the one hardware
# read of that bound that has never been filed: the LAST track at +667, which
# reaches two frames past the lead-out, then track 1 at -667, two frames before
# the disc, each under a time limit of a few minutes. Its readings decide
# whether Platterpus ever offers `-O` on this drive.
#
# THE TIME LIMIT CANNOT BE LEFT OFF. The `cyanrip` steps below have no timeout
# argument and this script has no `cyanrip-timeout` line: the runner kills the
# ripper at its own fixed limit (`CYANRIP_VERB_TIMEOUT_S`, 300 seconds) and
# records the kill.
#
# WHAT IT RECORDS. The transcript keeps each step's exit code, its exact argv
# and each read's whole output; cyanrip prints the `Beyond disc:` line to its
# output as well as its log (`cyanrip@edb73dd:src/cyanrip_log.c:627` writes it,
# and `:1955` copies every log line to standard output), so the line is in the
# transcript. The two reads' own logs are in two folders in the rips folder:
# `overreadleadout` (the last track) and `overreadleadin` (track 1). Send the
# transcript, and the log from each of those two folders.
#
# YOUR OVERREAD SETTING IS LEFT AS YOU HAD IT. The reads below pass `-O`
# themselves and never change the setting; the probe records it before the
# first read (`keep`) and checks after the last that it is still that value
# (`expect-kept`). It used to check it was OFF, and failed the probe on an
# owner whose setting was on before the run started (TASKS R189).
#
# ONE THING TO DO BY HAND FIRST: put the reference disc in and let the drive
# settle. Run it on its own, not during a Full run.

log ===== One bounded -O read of the last track, then of track 1 =====

log --- 1. a build that bounds -O, or stop ---
cyanrip --version
expect-exit 0
# `.23` and earlier have no bound on -O; on them this read could hang the
# drive until the step's limit kills it. Stop rather than find out. The verb
# passes the builds `fork_source.BUILD_TAGS_BOUNDING_OVERREAD` lists (`.24` to
# `.32` on 2026-11-16), fails a build known not to bound -O, and stops as not
# determined on one Platterpus cannot place.
expect-ripper-bounds-overread
abort-if-failed the installed ripper is not one whose -O is bounded

log --- 2. the disc and the drive's offset, or stop ---
rescan
pick-release 1 90
expect-tracks 1+
set-drive-offset
# +667 is the BDR-209D's offset, which is what reaches past the lead-out here.
# Asked of the selected drive's own saved offset (each drive has its own from
# 0.7.124), the one `(offset)` below expands to, never of `read_offset`, which
# no longer decides a rip's offset.
expect-drive-offset 667
abort-if-failed not the BDR-209D at +667, so the read would not be the one asked for

log --- 3. the read: last track only, -O, killed at the step's fixed limit ---
# Your Overread setting as it is now, so step 5 can check nothing changed it.
keep force_overread
cyanrip -N -s (offset) -l (lasttrack) -O -D overreadleadout (consumer) (diagnostics)
expect-exit 0
expect-cyanrip Beyond disc:
snapshot afteroverread

log --- 4. the lead-in side: track 1 at a deliberately wrong -667, the same limit ---
# The lead-in side of the same bound, asked for by the fork as the optional
# second read: the reference disc's track 1 starts at LSN 0, so -667 reads two
# frames BEFORE the disc through the same bounded branch. Typed, not (offset),
# because a wrong offset is the point; it reaches only this argv, never the
# drive's setting. Its audio is not kept. If step 3 hit the limit, this one will
# tell nothing new.
cyanrip -N -s -667 -l 1 -O -D overreadleadin (consumer) (diagnostics)
expect-exit 0
expect-cyanrip Beyond disc:

log --- 5. your Overread setting is what it was before the first read ---
expect-kept force_overread
