Commit Graph
207 Commits
Author SHA1 Message Date
Brandon ThomasandClaude Opus 5.5 330a4f59cf Fuzz: run the CLI cargo built, refuse to run without it, and cap child memory on Linux
- xtask looked for target/release/printcraft-cli even under CARGO_TARGET_DIR
  (which parallel agents use), and a child that failed to spawn counted as a
  pass: such runs fuzzed nothing and reported 0 crashes. The binary now comes
  from CARGO_TARGET_DIR (gates' corpus check and text oracle too), and fuzz
  stops if it is missing.
- On Linux each child runs under a 4 GiB address-space limit, so an input that
  allocates without bound becomes a crash finding instead of exhausting the
  machine: the nightly fuzz job's runner was killed this way every night,
  losing the findings. Allocation failures are kept as the finding's message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 17:59:25 -04:00
Brandon ThomasandClaude Opus 5.5 1ca576309e Git: no line-ending conversion for any file, so Windows checkouts keep asset hashes
Windows runners check out with core.autocrlf=true, which turned the SVG icons'
LF into CRLF, so their SHA-256 no longer matched ATTRIBUTION.toml and
xtask's the_real_manifest_passes failed there (hidden until now behind the
perf-test failure, since cargo test stops at the first failing binary).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 15:55:57 -04:00
Brandon ThomasandClaude Opus 5.5 9ecfd0afbc Tests: frame budgets take turns and keep the best of three rounds
The two budget tests ran in parallel, each with its own render workers, and
a single preempted stretch on a shared CI runner pushed the average over the
40 ms budget (41-52 ms on Ubuntu and Windows). They now hold a lock while
measuring, and a round over budget is measured again (up to three rounds):
noise only adds time, so the best round is the UI's own cost and a real
regression still fails every round. The budget is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 15:55:57 -04:00
Brandon Thomas f5e3255b80 Merge pull request #25 from storytold/pr/never-crash-edit-xfdf
Never crash: edit and xfdf have no expect calls
2026-10-04 14:49:48 -04:00
Brandon Thomas 342593af46 Merge pull request #24 from storytold/pr/never-crash-attrs
Never crash: deny the panic lints in crates that are already clean
2026-10-04 14:49:29 -04:00
Brandon Thomas fb0ea34a01 Merge pull request #23 from storytold/pr/never-crash-create
Never crash: create has no expect calls
2026-10-04 14:49:10 -04:00
Brandon Thomas cec677cd64 Merge pull request #22 from storytold/pr/never-crash-ui
Never crash: UI and app shell have no expect/unreachable
2026-10-04 14:48:48 -04:00
Brandon Thomas b8f40d0c04 Merge pull request #21 from storytold/pr/never-crash-automation
Never crash: the automation (MCP/script) tools have no expect/unreachable
2026-10-04 14:48:27 -04:00
Brandon Thomas 0772e99cde Merge pull request #20 from storytold/pr/never-crash-engine
Never crash: engine denies the panic lints
2026-10-04 14:48:05 -04:00
Brandon Thomas 66d127bb73 Merge pull request #19 from storytold/pr/never-crash-render
Never crash: render has no expect/unreachable
2026-10-04 14:47:45 -04:00
Brandon Thomas 0133cb7454 Merge pull request #18 from storytold/pr/never-crash-organize
Never crash: organize has no expect/unreachable
2026-10-04 14:47:26 -04:00
Brandon Thomas e373293926 Merge pull request #17 from storytold/pr/never-crash-sign
Never crash: sign has no expect/unreachable
2026-10-04 14:47:06 -04:00
Brandon Thomas 414060a3ff Merge pull request #16 from storytold/pr/never-crash-small
Never crash: filters, fonts, js, optimize and a11y deny the panic lints
2026-10-04 14:46:43 -04:00
Brandon Thomas 7da7ec6148 Merge pull request #15 from storytold/pr/never-crash-crypt
Never crash: crypt has no panic paths
2026-10-04 14:46:22 -04:00
Brandon Thomas a76263a9a7 Merge pull request #14 from storytold/pr/never-crash-guard
Never crash: last-resort guard around edits, opens, saves and UI commands
2026-10-04 14:46:00 -04:00
Brandon Thomas 5c4988aed6 Merge pull request #13 from storytold/pr/never-crash-js
Never crash: hostile form scripts can't overflow the stack
2026-10-04 14:45:39 -04:00
Brandon Thomas ff8c75f46f Merge pull request #12 from storytold/pr/never-crash-forms
Never crash: forms scripts can't overflow the stack or the date arithmetic
2026-10-04 14:35:21 -04:00
Brandon Thomas 3dc6a81d31 Merge pull request #11 from storytold/pr/never-crash-steering
Never crash: agent rules, clippy.toml, forbid unsafe
2026-10-04 14:34:59 -04:00
Brandon ThomasandClaude Opus 5.5 ac222e818b Never crash: edit and xfdf have no expect calls
- edit: the substitute font name is a `&str` constant, so there's no `from_utf8(..).expect`.
  Paragraph grouping uses `let … else` / `if let` chains, and the reuse-font path takes the
  metrics with `filter` instead of `expect("checked")`.
- xfdf: a comment key that vanished between listing and lookup is skipped.

Both crates now deny the panic lints. Adds the root clippy.toml (identical to #11) so tests may
still unwrap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 14:23:06 -04:00
e7ba974fe1 Edit text: a rewritten paragraph keeps its place in the text object it shares (#7)
* Edit text: a rewritten paragraph keeps its place in the text object it shares

A rewritten paragraph was drawn again just before the BT of its text object. When earlier
paragraphs shared that BT … ET (as in text-only pages), the paragraph moved ahead of them in
the content: reading order changed (screen readers, copy, `pdftotext -raw`) and text_paragraphs
renumbered, so after text_edit paragraph 2 a following text_edit paragraph 1 rewrote the
already edited paragraph instead of the first one. The text object is now split where the
paragraph was, and the second half resumes from the same line matrix and text state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Edit text: read the text before a paragraph without slicing by input positions (never-panic rule)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Edit text: test a recoloured paragraph in a shared text object (split + q/Q together)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: storybored379 <storybored379@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
2026-10-04 14:00:31 -04:00
95af23d3a5 Forms: multi-select list values survive XML, CSV and text import (#5)
Export data writes a multi-select list's values into one cell joined by ", " ("A, C"), but
import passed the cell on as a single choice, which the list refused, so the selection was
silently lost on an export → import round trip (the field was only counted as rejected).
A multi-select list now splits such a cell into its options, unless the whole cell is itself
one of them.

Co-authored-by: storybored379 <storybored379@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 14:00:23 -04:00
Brandon ThomasandClaude Opus 5.5 59f74ea386 Root clippy.toml: tests may unwrap, expect, panic and index
The same file as the steering PR (#11), so this PR stands on its own. The crate-level
`#![deny(clippy::unwrap_used, …)]` applies to production code only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:35:01 -04:00
Brandon ThomasandClaude Opus 5.5 4e74f9ed6a Root clippy.toml: tests may unwrap, expect, panic and index
The same file as the steering PR (#11), so this PR stands on its own. The crate-level
`#![deny(clippy::unwrap_used, …)]` applies to production code only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:35:00 -04:00
Brandon ThomasandClaude Opus 5.5 e96a89c871 Root clippy.toml: tests may unwrap, expect, panic and index
The same file as the steering PR (#11), so this PR stands on its own. The crate-level
`#![deny(clippy::unwrap_used, …)]` applies to production code only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:35:00 -04:00
Brandon ThomasandClaude Opus 5.5 f688415504 Root clippy.toml: tests may unwrap, expect, panic and index
The same file as the steering PR (#11), so this PR stands on its own. The crate-level
`#![deny(clippy::unwrap_used, …)]` applies to production code only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:35:00 -04:00
Brandon ThomasandClaude Opus 5.5 0e2f8a2fb3 Root clippy.toml: tests may unwrap, expect, panic and index
The same file as the steering PR (#11), so this PR stands on its own. The crate-level
`#![deny(clippy::unwrap_used, …)]` applies to production code only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:35:00 -04:00
Brandon ThomasandClaude Opus 5.5 6ea62a0f6b Root clippy.toml: tests may unwrap, expect, panic and index
The same file as the steering PR (#11), so this PR stands on its own. The crate-level
`#![deny(clippy::unwrap_used, …)]` applies to production code only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:35:00 -04:00
Brandon ThomasandClaude Opus 5.5 dd0eed7425 Root clippy.toml: tests may unwrap, expect, panic and index
The same file as the steering PR (#11), so this PR stands on its own. The crate-level
`#![deny(clippy::unwrap_used, …)]` applies to production code only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:35:00 -04:00
Brandon ThomasandClaude Opus 5.5 926171569e Root clippy.toml: tests may unwrap, expect, panic and index
The same file as the steering PR (#11), so this PR stands on its own. The crate-level
`#![deny(clippy::unwrap_used, …)]` applies to production code only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:35:00 -04:00
Brandon ThomasandClaude Opus 5.5 cfe84da351 Root clippy.toml: tests may unwrap, expect, panic and index
The same file as the steering PR (#11), so this PR stands on its own. The crate-level
`#![deny(clippy::unwrap_used, …)]` applies to production code only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:35:00 -04:00
Brandon ThomasandClaude Opus 5.5 9902ff3043 Root clippy.toml: tests may unwrap, expect, panic and index
The same file as the steering PR (#11), so this PR stands on its own. The crate-level
`#![deny(clippy::unwrap_used, …)]` applies to production code only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:35:00 -04:00
Brandon ThomasandClaude Opus 5.5 b834c6c063 Root clippy.toml: tests may unwrap, expect, panic and index
The same file as the steering PR (#11), so this PR stands on its own. The crate-level
`#![deny(clippy::unwrap_used, …)]` applies to production code only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:34:59 -04:00
24f0a8928e Edit text: a paragraph's new colour no longer spills into the text after it (#6)
Rewriting a paragraph (text_edit, Format text) draws it in its own text object, then sets the
text state back for what follows, but not the fill colour. Changing one paragraph's colour
therefore also coloured every paragraph after it in the same content stream (recolour the
first paragraph of a page red and the rest of the page turns red). The rewritten paragraph is
now wrapped in q … Q, so its colour and other graphics state stay with it.

Co-authored-by: storybored379 <storybored379@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:24:17 -04:00
096b515719 Forms: CSV import keeps values that span lines (#4)
* Forms: CSV import keeps values that span lines

A quoted CSV value may hold line breaks, and export_data writes multiline text fields that
way. The importer split the file into lines before reading quotes, so such a value was cut
at its first line break and every later column was lost (an export, then an import, of a form
with a multiline field silently dropped data). CSV records now end only at unquoted line
breaks; tab-delimited text is read as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Forms: build CSV records without unwrap (never-panic rule)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: storybored379 <storybored379@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
2026-10-04 13:24:11 -04:00
3908a03aa6 Optimizer: Audit space usage counts images PrintCraft added as images (#3)
Content added with Edit ▸ Add content records its image in the content stream's dictionary
(/PCAdded /Image). The audit claimed a page's content streams before its resources and
followed that reference, so an added image's bytes were reported as Content Streams and
Images showed 0 % (a 1.9 MB picture read as 99.9 % content). Resources are now claimed
first, so whatever a content stream's dictionary points at keeps its own category.

Co-authored-by: storybored379 <storybored379@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:24:06 -04:00
Brandon ThomasandClaude Opus 5.5 554969da72 Never crash: forbid unsafe, clippy.toml for tests, guard and craftrules link
Follows the owner's AGENTS.md §4 / CLAUDE.md rules with what the shared standard
(craftrules/standards/never-crash.md) adds: why (lost work) and that it outranks feature work,
the `unsafe` ban (workspace `unsafe_code = "forbid"`; no unsafe exists outside vendor/),
the last-resort guard around commands and file import/export, the clippy ratchet attribute,
and a root clippy.toml that lets tests use unwrap/expect/panic/indexing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:24:00 -04:00
Brandon ThomasandClaude Opus 5.5 d9d7caca22 Agent rules: never panic (AGENTS.md §4, CLAUDE.md non-negotiables)
Untrusted input (PDFs, scripts, MCP calls, settings) must yield errors, not crashes: Result
over unwrap/expect, no input-derived indexing, checked arithmetic, capped allocations, bounded
recursion, lock-poison handling, and a regression test for every crash fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:24:00 -04:00
Brandon ThomasandClaude Opus 5.5 1434db626a Never crash: deny the panic lints in crates that are already clean
annot, compare, content, cos, export, geom, model, ocr, preflight, print and redact have no
production `unwrap`/`expect`/`panic!`/`unreachable!`/`todo!`/`unimplemented!`. The attribute
keeps it that way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:12:21 -04:00
Brandon ThomasandClaude Opus 5.5 7632d8b179 Never crash: create has no expect calls
`add_page` returns the crate's error when the new document has no page tree, and text pages are
filled with `if let`. The crate now denies the panic lints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:12:21 -04:00
Brandon ThomasandClaude Opus 5.5 51027324e1 Never crash: UI and app shell have no expect/unreachable
Each "checked" `expect` becomes `let … else`, `if let` or `?`, with the obvious fallback (the
dialog closes, the command is ignored, the view refresh is skipped). ui-egui and the three apps
now deny the panic lints. The Windows `build.rs` reports a failed resource step with
`cargo::error` instead of panicking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:12:20 -04:00
Brandon ThomasandClaude Opus 5.5 d54f7c2fa7 Never crash: the automation (MCP/script) tools have no expect/unreachable
- Renderer cache: built with the entry API instead of insert-then-`expect`.
- Page-text cache: filled and read with `get`/`get_mut`.
- Schemas and form JSON: extended through `if let` instead of `as_object_mut().expect`.
- A replace-text mark of the wrong shape is an invalid-argument error.

The crate now denies the panic lints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:12:20 -04:00
Brandon ThomasandClaude Opus 5.5 f7a0d3a3b9 Never crash: render has no expect/unreachable
The text reading order uses `let … else`, `while let` and `get_mut` instead of `expect`, and
named destinations bind their key with an or-pattern instead of `unreachable!`. The crate now
denies the panic lints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:12:20 -04:00
Brandon ThomasandClaude Opus 5.5 c74fb89a0d Never crash: organize has no expect/unreachable
The outline import, bookmark lookup and page-label code use `first`/`last`, a final `Err` and a
default range instead of `expect`/`unreachable!`. The crate now denies the panic lints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:12:20 -04:00
Brandon ThomasandClaude Opus 5.5 456a42a896 Never crash: sign has no expect/unreachable
PKCS #12 HMAC errors now propagate as `SignError`. Key-bag lookup uses `find_map` and chain
building uses `let … else`. `der::oid` (only ever given this crate's OID literals) keeps the
standard's narrow, documented `expect` exception. The crate now denies the panic lints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:12:20 -04:00
Brandon ThomasandClaude Opus 5.5 7f09486004 Never crash: last-resort guard around edits, opens, saves and UI commands
`printcraft_engine::guard` wraps `catch_unwind` and returns an error message.
- `Session::apply`: edits run on a copy of the document, so a panic leaves it unchanged and is
  reported as an error. A panic while refreshing rolls the edit back.
- `Session::open`, `save_bytes`, `save_full_bytes` and `export_data` report a panic as an
  open, write or export error.
- `PrintCraftApp::execute`: a command that panics shows a notice, and the app and its documents
  keep running.
- The desktop app installs a panic hook that logs every panic to stderr, with a backtrace when
  `RUST_BACKTRACE` is set.

Autosave and crash recovery (`RecoveryStore`) were already in place for anything that escapes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:06:24 -04:00
Brandon ThomasandClaude Opus 5.5 18c1acdb31 Never crash: hostile form scripts can't overflow the stack
boa's parser and compiler recurse once per nesting level and have no limit of their own: about
100 nested parentheses in a field or document script overflowed a 2 MiB stack and aborted the
app, which `catch_unwind` can't stop. `printcraft_js::run` now:
- refuses a script longer than 256 KiB, or one that nests brackets more than 64 deep, chains
  more than 64 prefix operators, or has more than 4096 `?`. Strings and comments are skipped.
  The script fails with an error, as a syntax error would;
- runs the engine on its own thread with a 1 GiB stack, which is address space, committed only
  as it's used. That covers every unbracketed construct a 256 KiB script can nest. A panic
  inside the engine becomes a script error. On wasm the script still runs inline.

Regression tests: `deeply_nested_scripts_fail_instead_of_crashing`, which aborted the test
process before this change, and `ordinary_nesting_still_runs`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:06:24 -04:00
Brandon ThomasandClaude Opus 5.5 58cd6614ea Never crash: engine denies the panic lints
The one `unreachable!` in the scoped refresh becomes a full refresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:06:23 -04:00
Brandon ThomasandClaude Opus 5.5 9fc3354fe6 Never crash: filters, fonts, js, optimize and a11y deny the panic lints
- js: `host()` returns a script error instead of panicking when the host state is missing.
- optimize, a11y: the graphics-state stack is read with `last`/`last_mut` instead of `expect`.
- fonts: the standard-14 ASCII map is built from `u8`, which can't fail.
- filters: zlib encoding into a `Vec` keeps the standard's narrow, documented `expect` exception.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:06:23 -04:00
Brandon ThomasandClaude Opus 5.5 95d8ba3101 Never crash: crypt has no panic paths
AES blocks come from `as_chunks`, the IV from `split_first_chunk`, and the R6 hash takes its
AES key and IV with `first_chunk`, so no `expect` is needed. The crate now denies the panic lints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:06:23 -04:00
Brandon ThomasandClaude Opus 5.5 15f6fa7d4c Never crash: forms scripts can't overflow the stack or the date arithmetic
Two crashes that a PDF can trigger, each with a regression test that failed before this change:
- Deeply nested arguments in a field's format script (`[[[[…` or `new Array(new Array(…`) and
  deeply nested simplified field notation (`((((…` or `----…1`) recursed until the stack
  overflowed, which aborts the whole app. Nesting is now capped at 64 levels; deeper input is
  rejected like any other unparseable script.
- A date with a huge year (`1/1/2147483647`) overflowed `weekday`, and a `DateTime` with month 0
  indexed before the month names. The weekday math is now done in i64, years beyond i32 don't
  parse, and month and day names are looked up with `get`.

Also removes the crate's remaining `expect`/`unreachable!` calls and denies the panic lints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 13:06:23 -04:00