feat(domain): R4.2a pdf::read scan, strings and stamp (port of scan.ts, JS regex semantics explicit)

find_embedded_files, decode_pdf_string, has_archive_stamp on the frozen O7 oracle: 144 PDF
inputs, 178 candidates, 19 string rows, all equal to the TypeScript.
This commit is contained in:
bchanot committed 2026-10-18 15:44:52 +02:00
1 parent 09ce18b6dc
commit a3fc44fd3a
5 files changed
+819 -12

No files matched your search

+10 -3
View File
@@ -39,11 +39,18 @@ pub fn sha256_hex(data: &[u8]) -> String {
pub fn r4_input(dir: &str, file: &str) -> Vec<u8> {
let base = repo_root().join("apps/app/tests/fixtures/pdf/r4").join(dir);
let stored = base.join(file);
if stored.exists() {
if stored.exists() && !file.ends_with(".gen.json") {
return std::fs::read(&stored).unwrap_or_else(|e| panic!("{stored:?}: {e}"));
}
let slug = file.rsplit_once('.').map_or(file, |(stem, _)| stem);
let description = base.join(format!("{slug}.gen.json"));
// A generator row names its description (`<slug>.gen.json`); a stored name may also be
// asked for by its would-be byte name (`<slug>.pdf`).
let description = match file.strip_suffix(".gen.json") {
Some(_) => base.join(file),
None => base.join(format!(
"{}.gen.json",
file.rsplit_once('.').map_or(file, |(stem, _)| stem)
)),
};
let text = std::fs::read_to_string(&description)
.unwrap_or_else(|e| panic!("{description:?}: {e} (no stored bytes for {file})"));
let spec: Value = serde_json::from_str(&text).unwrap();