Skip to content

Integration: the six open PSD hardening PRs merged, conflicts resolved (draft) - #1149

Closed
vangel76 wants to merge 14 commits into
storytold:mainfrom
vangel76:psd-integration
Closed

vangel76 wants to merge 14 commits into
storytold:mainfrom
vangel76:psd-integration

Conversation

@vangel76

Copy link
Copy Markdown
Contributor

What this is

A pre-resolved view of the six open PSD hardening PRs merged together on top of upstream/main. Do not merge this PR. Please merge the six single PRs. If you merge them in any order, the later ones can take the conflict resolution from here (the merge commits on this branch show it per PR).

PR Branch Content
#1129 fix-psd-nested-group-depth MAX_GROUP_DEPTH, tree_report()
#1131 fix-psd-nonfinite-and-panic-paths finite guards (samples(), f64_finite, Warp::apply), saturating Rect::new
#1135 fix-psd-lenient-layer-section Psd::warnings, damaged layer section falls back to the merged image
#1134 psd-simplify-dedupe shared open_planes / decode_plane
#1137 psd-optimise borrowed planes, in-place unpredict, mask loop, quad solve
#1139 fix-psd-decode-memory-budget decode memory Budget, channels written straight into the result

Merged in that order, one --no-ff merge each, rerere on, no rebase.

Conflicts and how they were resolved

Test adaptations (signatures changed by the merge)

New integration test

crates/psd/src/tests_integration.rs, all on a 2 MiB thread:

  1. groups nested to 164 + a NaN/inf text transform: parses, tree depth <= 64, text transform finite, composite and every layer decode to a finite result or an error.
  2. damaged layer section: one warning, no layers, merged image decodes.
  3. tiny file claiming 16384x16384 / 4096x4096 (ZIP, ZIP+prediction, RLE, raw) under a 1 MiB budget (and the default budget for the big ones): clean "memory budget" error for composite and layer.

Commands run (target dir target/slot5)

Command Result
cargo test -p effectcraft-psd 44 passed (incl. 3 new integration tests)
cargo test -p effectcraft-engine 549 passed, 2 ignored (+ 2, 7, 15 in the other targets)
cargo test -p effectcraft-media 35 + 4 + 1 + 30 + 1 passed, 1 ignored
cargo test -p effectcraft-script 80 passed
cargo test -p effectcraft-host 16 + 1 + 1 + 6 + 1 + 3 + 2 + 10 passed
cargo clippy --workspace --all-targets -- -D warnings clean (one ptr_arg lint on the first version of release_bytes, fixed in the last commit)
cargo fmt --all --check clean
cargo xtask layers ok
cargo xtask assets ok (39 assets)
cargo xtask wasm ok (32 crates; one pre-existing dead-code warning in ui-egui, untouched)

Not run

cargo xtask ci, the full workspace tests, ui-egui tests (no ui code touched), and the known unrelated ui-egui failure theme::tests::interface_symbols_have_a_glyph_in_every_family.

🤖 Generated with Claude Code

vangel76 and others added 14 commits October 12, 2026 22:56
…annot overflow the stack (storytold#1128)

Psd::tree flattens groups nested deeper than MAX_GROUP_DEPTH into their depth-64 parent, keeping every layer, so the importer recursion and the tree's Drop/Clone/PartialEq are bounded. The import result reports how many groups were flattened.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…amples; no panic in Warp::apply or Rect::new (storytold#1130)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…storytold#1133)

One decode_plane for raw/RLE/ZIP (decode_channel and composite), placed::eight and
quad_from for the SoLd/PlLd transforms, the writer's big-endian and UTF-16 helpers
from descriptor.rs, one delimiter const in engine_data.rs, and the dead binding in
write.rs. No behaviour change; adds ZIP and RLE composite tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…stead of failing the document

Psd::parse drops the layers, records Psd::warnings and keeps the header and
merged image; the importer then imports the flattened image as one layer and
reports 'Layers could not be read'. Header damage and a missing merged image
stay hard errors.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…quad solves (storytold#1136)

Raw channels are borrowed, ZIP planes are un-predicted in place in the inflated buffer,
the 32-bit un-predictor uses one scratch row, the layer mask tests the rect per row
instead of per pixel (and skips a constant factor of 1.0), and a placed-layer bake
solves the quad once and hoists per-triangle invariants. Output is bit-identical;
tests compare against the replaced implementations and count the avoided work.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…torytold#1138)

The 2^28 pixel limit applied per image; one composite or layer decode kept
the ZIP output, a Vec<f32> per channel and the result alive together, and the
bake size came from the file's quad. A decode now charges every buffer
against a byte budget (4 GiB, 1 GiB on 32-bit), checks its whole expected peak
before allocating, writes channels straight into the result and returns an
error when over budget. Bakes are at most 4x the document across and 2^24
pixels.

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

# Conflicts:
#	crates/psd/src/tests.rs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

# Conflicts:
#	crates/engine/src/psd_import.rs
#	crates/engine/src/tests_vector_import.rs
#	crates/psd/src/tests.rs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

# Conflicts:
#	crates/psd/src/tests.rs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

# Conflicts:
#	crates/psd/src/lib.rs
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

# Conflicts:
#	crates/psd/src/lib.rs
#	crates/psd/src/placed.rs
…huge header under a small budget, on a 2 MiB stack

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
h-a-n-a-s-h-i pushed a commit that referenced this pull request Oct 13, 2026
…port formatting (#1149)

The six PSD PRs merged one by one leave #1131's test calling samples()/to_rgb(), which #1139
replaced; vangel76's integration draft #1149 has the adapted version.

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

Copy link
Copy Markdown
Contributor Author

Closing: the maintainers merged all six PSD PRs (#1129, #1131, #1134, #1135, #1137, #1139), so this pre-resolved integration view is no longer needed.

🤖 Generated with Claude Code

@vangel76 vangel76 closed this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant