Files
Sylpheed/crates/sylpheed-export/examples/record_population.rs
Sylpheed port agent d5294e8910 port: correcting my own correction -- none of the 1530 is a question without content
I told the Decoder their denominator held 1530 questions that were never asked:
records with no timed keyframe, where 'does +0x08 equal the largest keyframe time'
has no meaning. I did not check that and it is wrong.

Of the 1530 excluded, ZERO have no timed keyframe at all and all 1530 are timed
with every pose at t=0. Every one has a largest keyframe time; it is 0. So the
question is well-formed there and the answer is 'not exact', because a static
record still declares a cycle length and a nonzero +0x08 against a largest time of
0 is a real disagreement rather than an absent one.

That makes their 49.6% defensible rather than mistaken. Two statistics over two
populations: 92.3% of records whose largest keyframe time is > 0, and 49.6% of all
nested records including static ones. Neither is the corrected version of the
other. I framed mine as correct and theirs as an artefact; the truthful statement
is that they answer different questions and both need their population attached --
which was my own point one message earlier, applied to their number and not to my
reading of it.

Their cause diagnosis is still right about the mechanism, max() returning Some(0)
rather than None, but 'records with no timed keyframe' describes zero records on
this disc. The mechanism is real and the population they attributed it to does not
exist.

Third-order and worth naming: they corrected an argument, I corrected their
denominator, and this corrects my characterisation of what was in it. Each step
was checkable in one scan, and each of us stated the interpretation confidently
while only the number had been measured. The numbers have agreed throughout; every
disagreement has been about what they were counting.

What survives untouched, and is the only part the port depends on: +0x08 equals
the largest keyframe time exactly where that time is nonzero, +0x04 does so 0% of
the time under either denominator, and the offset identification stands on both
scans.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N7FiFFFwbvG2uxdcEh8HyF
2026-08-31 03:58:44 +00:00

66 lines
3.4 KiB
Rust

//! Why do two "every pak, every timed record" scans disagree by 86 %?
//!
//! This port counts 1 781 timed nested records and reports `+0x08 == max t` at
//! 92.3 %. The Decoder counts 3 311 and reports 49.6 %. Both scans are described
//! the same way, so at least one of them is narrower than its own description --
//! and the exactness figure this port has quoted repeatedly is a property of
//! whichever subset it actually walks.
//!
//! Counts the survivors at each filter, so the gap is located rather than
//! guessed at.
use sylpheed_formats::{pak, ratc, ui_layout};
fn main() {
let root = std::env::var("SYLPHEED_DISC").unwrap_or_else(|_| "/disc".into());
let mut paks: Vec<_> = std::fs::read_dir(format!("{root}/dat")).expect("dat/")
.flatten().map(|e| e.path())
.filter(|p| p.extension().and_then(|s| s.to_str()) == Some("pak")).collect();
paks.sort();
let (mut records, mut in_bounds, mut magic, mut parsed, mut timed) = (0, 0, 0, 0, 0);
let (mut untimed, mut all_at_zero) = (0usize, 0usize);
for p in &paks {
let Ok(ar) = pak::PakArchive::open(p) else { continue };
for e in ar.entries() {
let Ok(by) = ar.read(e) else { continue };
if !ratc::is_ratc(&by) { continue }
let Some(b) = ui_layout::parse_build(&by) else { continue };
for (_, &(o, s)) in &b.records {
records += 1;
if o + 12 > by.len() || o + s > by.len() { continue }
in_bounds += 1;
if &by[o..o + 4] != b"RATC" { continue }
magic += 1;
let Some(lb) = ui_layout::parse_build(&by[o..o + s]) else { continue };
parsed += 1;
let maxt = lb.elements.iter()
.flat_map(|el| el.keyframes.iter().filter_map(|k| k.time))
.max().unwrap_or(0);
// 🔴 `maxt == 0` merges two different populations, and the
// Decoder's cause -- `.max()` returning `Some(0)` -- is only one
// of them. A record with NO timed keyframe has no largest
// keyframe time; a record whose keyframes all sit at t=0 has
// one, and it is 0. Only the first is a question without
// content. Both of us called all 1 530 "the question has no
// meaning"; that is true of one group and an assumption about
// the other.
let any_timed = lb.elements.iter()
.any(|el| el.keyframes.iter().any(|k| k.time.is_some()));
if maxt == 0 {
if any_timed { all_at_zero += 1 } else { untimed += 1 }
continue;
}
timed += 1;
}
}
}
println!(" records declared by parse_build : {records}");
println!(" within the entry's bounds : {in_bounds}");
println!(" carrying the RATC magic : {magic} <- {} dropped here",
in_bounds - magic);
println!(" parsing as a nested build : {parsed}");
println!(" with a largest keyframe time > 0: {timed}");
println!(" of the {} excluded:", untimed + all_at_zero);
println!(" NO timed keyframe at all : {untimed} <- the question has no content");
println!(" timed, but every pose at t=0 : {all_at_zero} <- a largest time EXISTS, and it is 0");
}