From 55599873251d20c0236be613975053f7d2c13798 Mon Sep 17 00:00:00 2001 From: Matthew Jackson <1085847+MattJackson@users.noreply.github.com> Date: Thu, 30 Jul 2026 20:07:11 -0700 Subject: [PATCH] test(mux): replace a false-green discontinuity test with the property it named MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit a_signalled_discontinuity_survives_a_backstop_discard asserted that a SOURCE-signalled discontinuity on discarded bytes still reaches the AU that follows. It did not test that. Deleting the disc_marks push, or the mark-retirement loop inside discard_gap_before, left it passing. The mechanism: the `discontinuity = true` rode the FIRST over-cap push, which still has the next AU's delimiter at buf[0] — so it force-flushes as an over-long AU rather than discarding, and THAT AU consumes the mark. The assertion's `.find(|x| x.data.contains(&0x22))` then filters it out, and the flag it reads comes entirely from `pending_gap`, set by the second push's backstop. Behaviourally identical to the test 40 lines above it, under a name promising something else. I wrote it this morning, in the same commit that fixed a different test for having a fixture that never reached the code it named, while cataloguing that exact shape. Third instance today of writing the bug I was hunting. The two mechanisms cannot be isolated in one fixture — a fragment that trips the backstop sets pending_gap regardless — so they now get one test each. The replacement drives disc_marks end to end with no backstop involved: a flagged fragment that carries a complete AU and is emitted, not discarded. Nothing else pinned that path. Removing the disc_marks push reds it. Found by the round-9 opus escalation over test quality, dispatched because the sonnet pass over the same 17,000 lines of new test code returned zero findings. --- src/mux/au_assembly.rs | 52 ++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/src/mux/au_assembly.rs b/src/mux/au_assembly.rs index dc23824..3152451 100644 --- a/src/mux/au_assembly.rs +++ b/src/mux/au_assembly.rs @@ -1023,36 +1023,48 @@ mod tests { ); } - /// A discontinuity the SOURCE signalled, on bytes the backstop later throws - /// away, must not be lost either — the gap is real regardless of which - /// mechanism noticed it first, and the two must not cancel out. + /// A source-signalled discontinuity reaches the AU it opens. + /// + /// This is the `disc_marks` path — the ORIGINAL mechanism, distinct from + /// the sticky `pending_gap` the backstop sets. Nothing else pins it: the + /// two tests above drive `pending_gap`, and a mark placed on a fragment + /// that is later discarded is retired by design. + /// + /// Deliberately NOT combined with the backstop. A previous version of this + /// test signalled the discontinuity on the first over-cap push and asserted + /// the flag on the AU after the discard — but that first run still has the + /// next AU's delimiter at `buf[0]`, so it force-flushes as an over-long AU, + /// and THAT AU consumes the mark. The assertion was then satisfied entirely + /// by `pending_gap`, making the test a duplicate of the one above it under + /// a name promising something else. The two mechanisms cannot be isolated + /// in one fixture, so they get one test each. #[test] - fn a_signalled_discontinuity_survives_a_backstop_discard() { + fn a_source_signalled_discontinuity_reaches_the_au_it_opens() { let mut a = AuAssembler::for_codec(Codec::H264); - let mut stream = au(0x11, 64); - stream.extend_from_slice(AUD); - a.push(&stream, Some(1000), None, None, false); + // A clean AU first, so there is a prior AU and the gate has somewhere + // to be discontinuous FROM. + let mut first = au(0x11, 64); + first.extend_from_slice(AUD); + let out = a.push(&first, Some(1000), None, None, false); + assert_eq!(out.len(), 1); + assert!(!out[0].discontinuity, "a clean run is continuous"); - // The source says this fragment follows a gap, AND it is start-code-free - // and long enough to trip the backstop. Two runs, so the second reaches - // the discard rather than the force-flush (see the test above). - let junk = vec![0xAB; MAX_AU_BUFFER + 4096]; - a.push(&junk, Some(2000), None, None, true); - a.push(&junk, Some(2100), None, None, false); - - let mut resumed = au(0x22, 64); - resumed.extend_from_slice(AUD); - let out = a.push(&resumed, Some(3000), None, None, false); + // The source flags this fragment as following a gap. It carries the + // body of the next AU and its closing delimiter, so it is emitted + // rather than discarded — the mark must ride through to it. + let mut second = au(0x22, 64); + second.extend_from_slice(AUD); + let out = a.push(&second, Some(2000), None, None, true); let au2 = out .iter() .find(|x| x.data.contains(&0x22)) - .expect("the post-gap AU must emit"); + .expect("the flagged AU must emit"); assert!( au2.discontinuity, - "a source-signalled discontinuity on discarded bytes must still \ - reach the AU that follows them" + "a discontinuity the SOURCE signalled must reach the AU whose bytes \ + carried it; this is the disc_marks path and no other test drives it" ); }