docs(docs): R4.1 freeze record (RUST.md §10 draft, fixtures README R4 section)

Oracle table with commits, ledger totals, repository weight, freeze findings,
TypeScript baselines in Chromium, Firefox and WebKit with the watchdog
caveat; TODO R4.1a-f ticked; journal line.
This commit is contained in:
bchanot committed 2026-10-18 15:13:19 +02:00
1 parent 4439fd2420
commit aada7997de
4 files changed
+171 -7

No files matched your search

+1
View File
@@ -282,3 +282,4 @@ Owner go R4.0 (A1-A13: one branch + J1, old PDFs preserved, years 0-99 kept, Pro
Owner validated R4.0 plan with conditions (BDR-057, plan §A.6, LRN-059/060). R3 state checked: merged 8df964b, branch gone. chore/rust-r4-plan finished → develop ae17097. Hotfix bugfix/pdf-download-webkit 2b8000e: downloadBlob (anchor attached, URL revoked after 30 s) shared by rescue copy + PDF export; 3 challengers SOLID, app 405, security PASS, RUST.md 8.7 synced. Playwright WebKit 27.2 now starts (owner installed libs); desktop WebKit/Firefox/Chromium save the PDF even with immediate revoke → fix unproven until owner iPhone run. Stop: owner iPhone validation + CHANGELOG wording, then merge, then feature branch.
- 2026-10-18 owner iPhone run of the Safari fix: all OK → check green (1015) → gitflow finish fcff92b. Owner go R4.1: feature/rust-r4-pdf-core cut from develop.
- 2026-10-18 R4.1 freeze done on feature/rust-r4-pdf-core (eff5405..4439fd2): O1-O13 generators + oracles committed, ledger 299 rows (150 ported / 28 replaced / 88 kept / 33 deleted), browser harness scripts/browser (Chromium 156, Firefox 157, WebKit 27.2, 4 GiB RSS watchdog = not guaranteed limit). TS baselines: CAP export stopped by ceiling in all 3 engines, L peak content 0.8-1.35 GB, import 226 files same outcome everywhere; O9 browsers = Node on 26 rows. Repo +5.92 MB stored vs ~5 MB approved. Frozen step6/r2/r3 goldens untouched. .gitleaks.toml narrow allowlist for compare.json. Next: checkpoint report to owner, then R4.2.
+7 -7
View File
@@ -208,13 +208,13 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo
- [x] R3 closed checked 2026-10-18 (8df964b on develop, branch gone); chore/rust-r4-plan finished into develop ae17097 (owner signal 2026-10-18)
- [x] Safari PDF download fix (bugfix/pdf-download-webkit, 2b8000e + docs + CHANGELOG in owner wording): owner iPhone run 2026-10-18 all OK (several views, warnings alert, prompt open > 30 s); check green (1015 tests, typecheck, lint, build); merged fcff92b
- [x] cut feature/rust-r4-pdf-core from develop 66909b6 (after fcff92b; owner go 2026-10-18); WebKit libs installed by owner 2026-10-18, Playwright WebKit 27.2 runs workers + wasm
- [ ] R4.1 freeze (O1-O13, ledger, browser harness, TS baselines)
- [ ] R4.1a O11 frozen TS scanner copy + O13 synthetic reports L (60×2), CAP (500×2)
- [ ] R4.1b writer oracles: O1 draw logs (12), O2 R3 PDFs (12 + real raster + store path), O3 pre-R2 envelope PDFs
- [ ] R4.1c text, AFM, dates, PNG oracles (O4, O5, O6)
- [ ] R4.1d reader oracles: O7 outcomes + inputs as bytes, O8 differential (full R3 path), O9 inflate (Node)
- [ ] R4.1e browser harness (scripts/browser, Chromium + Firefox + WebKit, 4 GiB RSS watchdog): O9 browser verdicts, O12 TS baselines (export demo/L/CAP, import O2 + hostile)
- [ ] R4.1f O10 report:compare outputs, test ledger (crates/core/tests/pdf/LEDGER.tsv), freeze record (RUST.md §10 draft, fixtures README)
- [x] R4.1 freeze (O1-O13, ledger, browser harness, TS baselines)
- [x] R4.1a O11 frozen TS scanner copy + O13 synthetic reports L (60×2), CAP (500×2)
- [x] R4.1b writer oracles: O1 draw logs (12), O2 R3 PDFs (12 + real raster + store path), O3 pre-R2 envelope PDFs
- [x] R4.1c text, AFM, dates, PNG oracles (O4, O5, O6)
- [x] R4.1d reader oracles: O7 outcomes + inputs as bytes, O8 differential (full R3 path), O9 inflate (Node)
- [x] R4.1e browser harness (scripts/browser, Chromium + Firefox + WebKit, 4 GiB RSS watchdog): O9 browser verdicts, O12 TS baselines (export demo/L/CAP, import O2 + hostile)
- [x] R4.1f O10 report:compare outputs, test ledger (crates/core/tests/pdf/LEDGER.tsv), freeze record (RUST.md §10 draft, fixtures README)
- [ ] R4.2 reader (cargo + wasm, differential, OD-3 thresholds confirmed with owner before R4.3)
- [ ] R4.3 import worker + rescue copy (B.1.5, OD-1 applied, browser proof per slice from here)
- [ ] J1 owner checkpoint (plan A.4)
+20
View File
@@ -36,3 +36,23 @@ under `apps/app/src/assets/brand`, rasteriser stubbed to a 2×1 PNG).
Never regenerate these files without a user decision; the Step 6 engine must
reproduce them. Generation, once: `MAKE_GOLDEN=1 corepack pnpm vitest run
tests/unit/pdf.goldens.test.ts` from `apps/app`.
## R4 freeze (2026-10-18)
What the TypeScript PDF engine and reader produced right before the Rust port,
frozen on branch `feature/rust-r4-pdf-core` (`docs/development/RUST.md` §10.1
lists every oracle with its commit). Generators run behind `MAKE_R4_ORACLES=1`;
without the flag the same tests assert equality with the committed files.
| Path | Content |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `r4/reports/{L,CAP}.json` | Synthetic Report v3 on the draft: 60 observations / 120 views (L) and 500 / 1,000 (CAP), the export memory inputs of plan §B.4 (O13). |
| `goldens/r4/draw.*.json` | Every drawing call of the export (text, image, line, rectangle, link) at full precision, per page and in call order, for the 12 Step 6 report × locale × logo combinations (O1). |
| `pdf/r3/` | The 12 PDFs the R3-era engine produced for those combinations, the store-path export with its `report.json`, and `real/v2full-obs1.fr.logos.pdf` with its two browser PNGs and manifest: the byte references of the writer port (O2). |
| `pdf/step6/envelope.*.pdf` | Three envelope PDFs from before R2 (O3). |
| `pdf/r4/tolerance/` | 51 PDFs, valid and hostile, with today's import outcome and message in `crates/core/tests/oracles/r4/tolerance.json` (O8). |
| `pdf/r4/read/`, `pdf/r4/inflate/` | 155 reader inputs and 24 zlib framing inputs, the bytes behind `read.json` and `inflate.json`; a `<slug>.gen.json` describes a large input by concatenation (O7, O9). |
Synthetic data only, no real bilan. Never regenerate these files to make a
test pass: a difference between the Rust port and an oracle is reported and
decided (plan §A.3), or it is a bug in the port.
+143
View File
@@ -904,3 +904,146 @@ imports it and restyles `data-state` in place as before.
targets the local stack over HTTP): exercise it before the deployment that
needs it.
- WASM budget: 396 KB of 600 KB used; R4 adds the PDF reader and writer.
## 10. R4: the PDF core in Rust (in progress; R4.1 freeze done 2026-10-18)
Plan and contract: `.claude/tasks/plans/2026-10-17-rust-r4-pdf-core.md`
(revision 2, validated by the owner 2026-10-18 with the conditions of its
§A.6). Branch `feature/rust-r4-pdf-core`, cut from develop at 66909b6. This
section is a draft until the switch: it records what R4.1 froze and the
TypeScript baselines every later slice is measured against.
### 10.1 R4.1: what is frozen, and where (no Rust yet)
Every oracle below was generated by the TypeScript code at the commits
listed, behind `MAKE_R4_ORACLES=1`; without the flag the same test asserts
equality with the committed file. None of them is regenerated without the
owner (plan §B.5.1). The Step 6, R2 and R3 goldens and the R3 oracles are
byte-identical to develop (`git diff --stat develop..HEAD` on those paths is
empty).
| Oracle | Content | Files | Commit |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| O11, O13 | frozen TS attachment scanner as the N-1 PDF reader (6 tests); synthetic reports L (60 observations, 120 views) and CAP (500, 1,000) | `packages/core-wasm/tests/n-1/scanner/`, `apps/app/tests/fixtures/r4/reports/{L,CAP}.json` | 7ecbee9 |
| O8 | differential tolerance corpus on the full R3 import path, 51 PDFs with the outcome and message of today | `crates/core/tests/oracles/r4/tolerance.json`, `apps/app/tests/fixtures/pdf/r4/tolerance/` | 7a42979 |
| O1, O2, O3 | 12 draw logs (every text, image, line, rectangle, link at full precision); 12 R3-build PDFs plus the real-raster export of `v2full` observation 1 (two PNGs and a manifest) and the store-path PDF with its report; 3 pre-R2 envelope PDFs | `apps/app/tests/fixtures/goldens/r4/draw.*.json`, `apps/app/tests/fixtures/pdf/r3/`, `apps/app/tests/fixtures/pdf/step6/envelope.*.pdf` | 87b8873 |
| O7, O9 | 155 reader inputs as bytes with their outcome (regex-semantics rows included); 24 zlib framing inputs, 26 verdict rows of `inflateFlate` in Node | `crates/core/tests/oracles/r4/{read,inflate}.json`, `apps/app/tests/fixtures/pdf/r4/{read,inflate}/` | 96df15e |
| O4, O5, O6 | text (`measure` 8 rows with units per glyph and a 200-row width sample, `wrapLines` 5, `safeText` 2, `upper` 4), AFM widths of Helvetica, Helvetica-Bold and Times-Roman over WinAnsi, dates (grid of 4 locales × forms, 22 others), 108 PNG gate and decode cases over 103 files | `crates/core/tests/oracles/r4/{text,afm,dates,png}.json`, `crates/core/tests/fixtures/png/r4/` | 516342b |
| O10 | 230 `report:compare` invocations over 14 scenarios, 72 rows declared `r4Declared`; the test ledger | `crates/core/tests/oracles/r4/compare/`, `crates/core/tests/pdf/LEDGER.tsv`, `scripts/r4-ledger.mjs` | 4bdfda5 |
| O9 browsers, O12 | O9 verdicts in Chromium, Firefox and WebKit; the browser harness and the TS baselines of 10.2 | `crates/core/tests/oracles/r4/inflate.browsers.json`, `scripts/browser/` | 4439fd2 |
Ledger (`crates/core/tests/pdf/LEDGER.tsv`): 299 TypeScript cases at the
freeze, 150 `ported`, 28 `replaced`, 88 `kept`, 33 `deleted`; the census
check of plan §B.6 runs from R4.2 on.
Weight added to the repository by the freeze: 421 blobs, 11.63 MB raw,
5.92 MB stored (plan §A.2 OD-7 said about 5 MB; the overshoot is the
real-raster set and the browser results file, 0.65 MB raw, 45 KB stored).
`.gitleaks.toml` allowlists one generated file, `compare/compare.json`,
whose fixture names contain `key` next to sha256 digests.
Findings of the freeze, each one a declared difference or a port
constraint for the later slices (none changes the TypeScript):
- UPNG deviates from the PNG specification on two inputs (interlaced
filter-3 first row; 16-bit grey tRNS alpha offset); the gate accepts a
palette image without PLTE and pdf-lib then throws; `raster-bad-adler` is
refused by the gate but UPNG decodes it. R4.4 follows the oracles.
- `safeText` maps U+0178 to `ydieresis` (159) and drops the soft hyphen;
`numberToString(1e-7)` gives `0.00000009999999999999999`;
`formatDate("0000-01-01")` gives « 1 janvier 1900 » (years 0 to 99,
arbitration A3: unchanged).
- O8: the decoy-first attachment that R3 imports will be refused by R4
(OD-4 class, to present before the switch); an invalid byte between
tokens, a `/V` number followed by a string and a depth of 65 all give
`attachment_stripped` today.
- The APAFML notice is not in `@pdf-lib/standard-fonts`; R4.4 decides the
AFM source.
- The zlib-dependent verdicts of O9 depend on Node's bundled zlib
(1.3.2.1); the browser columns agree on every row (10.2).
### 10.2 TypeScript baselines (2026-10-18, `scripts/browser/results/2026-10-18-ts-baseline.json`)
Harness: `scripts/browser/` (README there), Playwright 1.64.0 outside the
repository, build `SHEET_BUNDLE=draft` at 87b8873 (the app, engine and
module sources are identical at 516342b, the recorded HEAD), served on
127.0.0.1 with the DEPLOY.md CSP plus `'wasm-unsafe-eval'`, locale fr.
Engines: Chromium headless shell 156.0.8078.4, Firefox 157.0, WebKit 27.2
(WPE MiniBrowser); none is a branded browser or a phone. Host: i7-11700B,
15.1 GB RAM, 8.4 GB available at start, no CPU throttling.
**The 4 GiB RSS watchdog is not a guaranteed memory limit.** It samples the
browser's process tree every 50 ms, so a faster allocation can overshoot
before the kill; summed VmRSS counts shared pages once per process; a
process outside the tree is not seen. It keeps the shared host away from
the kernel OOM killer; `stopped_by_ceiling` is a recorded result.
Export (TS engine). Medians over 3 runs, range in brackets; CAP one run.
"PNG blobs" counts every blob the rasteriser encoded, the first being the
partner SVG logo; the time runs on the page clock from the click to the
PDF Blob's object URL.
| Engine | Report | Outcome | Export s | PDF MB | PNG blobs | View PNG sum MB | View PNG KB | Stopped at |
| -------- | ------ | ------------------ | ---------------- | ------ | --------- | --------------- | ----------- | ----------------------------- |
| Chromium | demo | downloaded | 1.4 (1.4–1.4) | 2.7 | 8 | 3.7 | 508–614 | |
| Chromium | L | downloaded | 19.4 (19.4–19.5) | 41.9 | 121 | 65.8 | 508–614 | |
| Chromium | CAP | stopped_by_ceiling | | | | | | 4,102 MB at 101 s, ≥ 857 PNGs |
| Firefox | demo | downloaded | 1.6 (1.6–1.8) | 2.7 | 8 | 3.2 | 462–492 | |
| Firefox | L | downloaded | 35.3 (24.8–37.0) | 42.1 | 121 | 56.0 | 462–492 | |
| Firefox | CAP | stopped_by_ceiling | | | | | | 4,111 MB at 73 s, ≥ 577 PNGs |
| WebKit | demo | downloaded | 2.6 (2.6–2.6) | 2.4 | 8 | 2.4 | 345–371 | |
| WebKit | L | downloaded | 52.2 (52.2–52.2) | 36.8 | 121 | 42.1 | 345–371 | |
| WebKit | CAP | stopped_by_ceiling | | | | | | 4,101 MB at 384 s, ≥ 973 PNGs |
Export memory, MB. "Summed" is the browser tree, "Content" the content
processes. "Settled": forced GC through CDP plus 1 s in Chromium, 5 s idle
in Firefox and WebKit; the PDF Blob is still alive through its object URL
for 30 s (`download.ts`), so "after" includes it.
| Engine | Report | Summed before / peak / after | Content before / peak / after | JS heap before → after (CDP) |
| -------- | ------ | ------------------------------- | ------------------------------- | ---------------------------- |
| Chromium | demo | 473 / 640 (626–642) / 499 | 155 / 313 / 171 | 7.4 → 9.4 |
| Chromium | L | 475 / 1,128 (1,110–1,137) / 566 | 158 / 805 (787–814) / 201 | 8.1 → 11.1 |
| Chromium | CAP | 502 / 4,102 (stop) / – | 182 / 3,751 / – | 13.2 → – |
| Firefox | demo | 778 / 974 / 815 | 152 / 359 / 228 | |
| Firefox | L | 791 / 1,932 (1,929–1,998) / 943 | 160 / 1,351 (1,346–1,420) / 327 | |
| Firefox | CAP | 834 / 4,111 (stop) / – | 198 / 3,522 / – | |
| WebKit | demo | 499 / 815 / 778 | 306 / 617 / 581 | |
| WebKit | L | 512 / 1,370 (1,368–1,471) / 743 | 316 / 1,157 (1,154–1,209) / 510 | |
| WebKit | CAP | 574 / 4,101 (stop) / – | 375 / 3,895 / – | |
What the export rows say for the plan: CAP (1,000 views) does not complete
in any engine under 4 GiB with the TS engine, as §B.4 predicted; L costs
0.8 to 1.35 GB of content-process peak; browser PNGs are 0.35 to 0.61 MB
per view (WebKit about 40 % smaller than Chromium, hence the PDF sizes),
against the 0.54 MB resvg figure of §B.4.
Import (TS reader), 226 files × 3 engines (678 runs), a fresh context per
file; the duration runs on the Node clock from the file being set to the
first of editor, alert or inline error. No file gets a different outcome or
message in any engine. Every v2, v3, step6 and R3 PDF opens the editor in
39 to 112 ms. The largest growth is `tolerance/values-1m.pdf` (+105 / +153
/ +102 MB summed); the slowest inputs are the 20 to 50 MiB generated ones
(170 to 309 ms, all `error_no_attachment`). Chromium shows one long task on
9 files (52 to 173 ms), all among the 10 to 50 MiB inputs, `values-1m` and
`612-leaves`; Firefox and WebKit do not expose long tasks.
| Engine | Group (files) | Outcome | Duration ms median (range) | Max summed RSS growth MB | Max content growth MB |
| -------- | ------------------------------ | -------------------- | -------------------------- | ------------------------ | --------------------- |
| Chromium | base (3) / r3 (14) / step6 (3) | editor | 53 / 63 / 61 | 28 / 44 / 39 | 23 / 38 / 33 |
| Chromium | tolerance (51) | editor 33, error 18 | 57 (23–122) | 105 | 99 |
| Chromium | read (155) | editor 23, error 132 | 66 (22–309) | 75 | 68 |
| Firefox | base / r3 / step6 | editor | 39 / 73 / 69 | 63 / 54 / 52 | 14 / 33 / 32 |
| Firefox | tolerance / read | as Chromium | 53 (25–153) / 78 (25–286) | 153 / 86 | 131 / 61 |
| WebKit | base / r3 / step6 | editor | 52 / 62 / 66 | 52 / 54 / 53 | 50 / 52 / 51 |
| WebKit | tolerance / read | as Chromium | 59 (23–141) / 75 (22–238) | 102 / 101 | 100 / 99 |
O9 in the browsers: the 26 rows give the same verdict in Chromium 156,
Firefox 157 and WebKit 27.2 as in Node 24.21.0 (8 non-null, 18 null).
Not measured: CAP export time and PDF size (ceiling first); JS heap in
Firefox and WebKit (CDP is Chromium only, and Chromium's figure leaves out
ArrayBuffer memory); memory after an import settles (the §B.3 check belongs
to the R4 worker proof); real browsers and phones (J1 and the owner's
iPhone run). Seen on every page: the known `img-src` refusal of the
footer's external credit logo; no script or wasm violation.