From 1a23d0bed06e51579543c42253ceaf0508d62762 Mon Sep 17 00:00:00 2001 From: Anton Date: Sun, 8 Nov 2026 08:18:41 -0500 Subject: [PATCH] chore(release): 1.10.0 --- .github/DISCUSSION_TEMPLATE/q-a.yml | 2 +- .github/DISCUSSION_TEMPLATE/show-and-tell.yml | 2 +- .github/ISSUE_TEMPLATE/bug_report.yml | 4 +- .github/ISSUE_TEMPLATE/feature_request.yml | 2 +- CHANGELOG.md | 10 + CITATION.cff | 2 +- Cargo.lock | 75 ++- Cargo.toml | 4 +- bindings/node/index.js | 2 +- bindings/node/npm/darwin-arm64/package.json | 2 +- bindings/node/npm/darwin-x64/package.json | 2 +- bindings/node/npm/linux-x64-gnu/package.json | 2 +- bindings/node/npm/win32-x64-msvc/package.json | 2 +- bindings/node/package.json | 10 +- bindings/python/pyproject.toml | 2 +- codemeta.json | 2 +- crates/packvium-core/src/api.rs | 508 ++++++++++++++++-- crates/packvium-core/src/artifact_exports.rs | 76 ++- crates/packvium-core/src/artifacts.rs | 4 +- crates/packvium-core/src/bounds.rs | 406 ++++++++++++-- crates/packvium-core/src/canonical_json.rs | 2 +- crates/packvium-core/src/compression.rs | 15 + crates/packvium-core/src/contact_graph.rs | 25 + crates/packvium-core/src/execution.rs | 42 +- crates/packvium-core/src/fixed.rs | 228 +++++++- crates/packvium-core/src/geometry.rs | 216 ++++++-- crates/packvium-core/src/hull.rs | 122 ++--- crates/packvium-core/src/lib.rs | 6 +- crates/packvium-core/src/model.rs | 256 ++++++++- crates/packvium-core/src/nested.rs | 459 +++++++++++++++- crates/packvium-core/src/pallet_overhang.rs | 292 ++++++++++ crates/packvium-core/src/rebalance.rs | 20 +- crates/packvium-core/src/request_errors.rs | 263 ++++++++- .../src/result_validation/accounting.rs | 13 +- .../src/result_validation/bound.rs | 280 +++++++++- .../src/result_validation/container.rs | 110 +++- .../src/result_validation/facts.rs | 18 + .../src/result_validation/geometry.rs | 66 ++- .../src/result_validation/json.rs | 20 + .../src/result_validation/mod.rs | 3 + .../src/result_validation/num.rs | 68 +++ .../src/result_validation/objective.rs | 8 +- .../src/result_validation/placement_ids.rs | 167 ++++++ .../src/result_validation/spec.rs | 105 +++- .../src/result_validation/stacking.rs | 65 ++- .../src/result_validation/units.rs | 51 ++ crates/packvium-core/src/revisions.rs | 443 +++++++++++++-- crates/packvium-core/src/sequence.rs | 24 + crates/packvium-core/src/solvers/blocks.rs | 10 +- crates/packvium-core/src/solvers/exact.rs | 83 ++- crates/packvium-core/src/solvers/extreme.rs | 363 ++++++++++++- crates/packvium-core/src/solvers/grid.rs | 20 +- crates/packvium-core/src/solvers/maximal.rs | 21 + crates/packvium-core/src/solvers/portfolio.rs | 58 ++ crates/packvium-core/src/units.rs | 12 + crates/packvium-core/src/validation.rs | 48 +- crates/packvium-core/src/value_text.rs | 3 +- docs/GUARANTEES.md | 2 +- docs/PUBLIC-API.md | 103 +++- tests/node/addon.test.mjs | 5 +- tests/python/test_wheel.py | 6 +- 61 files changed, 4754 insertions(+), 486 deletions(-) create mode 100644 crates/packvium-core/src/pallet_overhang.rs create mode 100644 crates/packvium-core/src/result_validation/placement_ids.rs diff --git a/.github/DISCUSSION_TEMPLATE/q-a.yml b/.github/DISCUSSION_TEMPLATE/q-a.yml index 427014e..5f9e849 100644 --- a/.github/DISCUSSION_TEMPLATE/q-a.yml +++ b/.github/DISCUSSION_TEMPLATE/q-a.yml @@ -10,7 +10,7 @@ body: id: package-version attributes: label: Package and version - placeholder: "packvium-native-rust 1.9.0 (Rust)" + placeholder: "packvium-native-rust 1.10.0 (Rust)" validations: required: true - type: textarea diff --git a/.github/DISCUSSION_TEMPLATE/show-and-tell.yml b/.github/DISCUSSION_TEMPLATE/show-and-tell.yml index d1ddf42..0b2fc0b 100644 --- a/.github/DISCUSSION_TEMPLATE/show-and-tell.yml +++ b/.github/DISCUSSION_TEMPLATE/show-and-tell.yml @@ -16,7 +16,7 @@ body: id: package-version attributes: label: Package and version - placeholder: "packvium-native-rust 1.9.0 (Rust)" + placeholder: "packvium-native-rust 1.10.0 (Rust)" validations: required: false - type: textarea diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 799c36d..0252e54 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -33,8 +33,8 @@ body: id: version attributes: label: Package version - description: The exact version installed, for example 1.9.0. - placeholder: "1.9.0" + description: The exact version installed, for example 1.10.0. + placeholder: "1.10.0" validations: required: true - type: input diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index ced8846..6336594 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -29,7 +29,7 @@ body: id: version attributes: label: Package version - placeholder: "1.9.0" + placeholder: "1.10.0" validations: required: true - type: textarea diff --git a/CHANGELOG.md b/CHANGELOG.md index a6067fc..1cb4342 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ PyPI, `@packvium/native` and its platform packages on npm, and the C library on Releases. The format follows [Keep a Changelog](https://keepachangelog.com/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.10.0] + +The compiled engines rebuilt on the 1.10.0 core: a pallet load may overhang its deck, +`gusseted_bag` joins the flat bag, a convex hull turns 24 ways, every placement carries a +`placement_id`, a request may declare its `currency`, and `maximum_value`, +`open_dimension_height` and `maximum_volume` state a lower bound. `units` now refuses every key +but `length`, and the grid lattice and block loader number containers per type (`large#1`, not +`large#10`). The Node addon is built with napi 3.16. The wheel and addon tests mask +`duration_ms` in every alternative, not only the answer. + ## [1.9.0] The compiled engines rebuilt on the 1.9.0 core: the centre of gravity is checked under a support diff --git a/CITATION.cff b/CITATION.cff index a23a13b..32889b2 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -5,7 +5,7 @@ type: software authors: - name: "Packvium contributors" website: "https://packvium.com" -version: "1.9.0" +version: "1.10.0" license: MIT url: "https://packvium.com" repository-code: "https://github.com/toxakara/packvium-native" diff --git a/Cargo.lock b/Cargo.lock index 2450eed..0c53cee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,9 +31,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "convert_case" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "affbf0190ed2caf063e3def54ff444b449371d55c58e513a95ab98eca50adb49" +checksum = "1af709f1f33454bf52eadfc8c78b3b9ef9cb26fb54d16dc9cd9a7299f899fd1b" dependencies = [ "unicode-segmentation", ] @@ -185,9 +185,9 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "js-sys" -version = "0.3.104" +version = "0.3.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0c1080212aad755ea003d18543e8768dd432c48819efd73a7bf1e39b7a5a3a" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" dependencies = [ "cfg-if", "futures-util", @@ -196,9 +196,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.189" +version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" [[package]] name = "libloading" @@ -218,9 +218,9 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "napi" -version = "3.12.2" +version = "3.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c5f4d5375213fdb7be2655e152386e82f026f9a5ba36a75556e11359aafe09" +checksum = "907ff7366fb7182e28edd0f08ef8ac5d6b13b8d65a3c0b3a10bf3ac092437d6b" dependencies = [ "bitflags", "ctor", @@ -234,42 +234,42 @@ dependencies = [ [[package]] name = "napi-build" -version = "2.4.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60fdf9b392c50e7c4170fa633bd909490ed7835cea4c046776d1a4dd8d2ae0ab" +checksum = "b899b545d3aa6dca985939059f258c5488d34e4ecf39c274e20009748f4b846d" [[package]] name = "napi-derive" -version = "3.6.3" +version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa55ea69990c90b888e9e77044410e304ce7f35de599dc6d0b5c1923d2e59af" +checksum = "d32eb00f92f84cf462fc328f49082b29c2a7d2eebeb1d447d19c1f9fdd9f89ee" dependencies = [ "convert_case", "ctor", "napi-derive-backend", "proc-macro2", "quote", - "syn 2.0.119", + "syn 3.0.3", ] [[package]] name = "napi-derive-backend" -version = "6.1.2" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df4056ac7c18e4438ccf0edaed4340ca0d269278c8ec19284f7b23cb039fd0ae" +checksum = "d1fe28c64d8fc12e69f9b817d0febdbe7914555760f1e353106281b8ff99cc90" dependencies = [ "convert_case", "proc-macro2", "quote", "semver", - "syn 2.0.119", + "syn 3.0.3", ] [[package]] name = "napi-sys" -version = "3.3.0" +version = "3.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85fbf1fa9f1babfe396d74bbbf52b3643770243e8f5b0b46715d4caf7f0dfc9a" +checksum = "d153beb7d5c973f4b9395be8a83054a28968b61188f1dd1a2cc2321af22daea2" dependencies = [ "libloading", ] @@ -288,7 +288,7 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "packvium-core" -version = "1.9.0" +version = "1.10.0" dependencies = [ "libc", "serde", @@ -300,7 +300,7 @@ dependencies = [ [[package]] name = "packvium-ffi" -version = "1.9.0" +version = "1.10.0" dependencies = [ "packvium-core", "serde_json", @@ -308,7 +308,7 @@ dependencies = [ [[package]] name = "packvium-node-native" -version = "1.9.0" +version = "1.10.0" dependencies = [ "napi", "napi-build", @@ -318,7 +318,7 @@ dependencies = [ [[package]] name = "packvium-python-native" -version = "1.9.0" +version = "1.10.0" dependencies = [ "packvium-core", "pyo3", @@ -461,9 +461,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.151" +version = "1.0.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" dependencies = [ "itoa", "memchr", @@ -519,18 +519,18 @@ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" [[package]] name = "thiserror" -version = "2.0.20" +version = "2.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.20" +version = "2.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" dependencies = [ "proc-macro2", "quote", @@ -563,12 +563,11 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wasm-bindgen" -version = "0.2.127" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b70935747edd64d89de3efa29d73789b806c15798f8e7dca4d8ac356b50ce70" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" dependencies = [ "cfg-if", - "once_cell", "rustversion", "wasm-bindgen-macro", "wasm-bindgen-shared", @@ -576,9 +575,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.127" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77775f8f3f7217702089053b94958f8f54061a3f663417df76e19cbdcca29bc1" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -586,22 +585,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.127" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e11d33f857dc2fb11b8bc75aee111aa9cbeb12cd9f25efd3d4c2a3dd4e235284" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.119", + "syn 3.0.3", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.127" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef64dbcc55df09c7e5a46182d181c2cfa3e925f3da937ea764728b4bbb9dcbf" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" dependencies = [ "unicode-ident", ] diff --git a/Cargo.toml b/Cargo.toml index e32efaa..097344a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ members = [ default-members = ["crates/packvium-core", "crates/packvium-ffi"] [workspace.package] -version = "1.9.0" +version = "1.10.0" edition = "2024" rust-version = "1.88" license = "MIT" @@ -26,4 +26,4 @@ thiserror = "2.0.19" # package hashes too; default features off, it needs nothing from std. sha2 = { version = "0.10.9", default-features = false } web-time = "1.1.0" -packvium-core = { path = "crates/packvium-core", version = "1.9.0" } +packvium-core = { path = "crates/packvium-core", version = "1.10.0" } diff --git a/bindings/node/index.js b/bindings/node/index.js index 1172c16..d673e71 100644 --- a/bindings/node/index.js +++ b/bindings/node/index.js @@ -13,7 +13,7 @@ 'use strict'; /** The release this loader belongs to; a binary from any other release is refused. */ -const EXPECTED_VERSION = '1.9.0'; +const EXPECTED_VERSION = '1.10.0'; function firstLoadable(attempts) { const failures = []; diff --git a/bindings/node/npm/darwin-arm64/package.json b/bindings/node/npm/darwin-arm64/package.json index f9d5678..22cfb41 100644 --- a/bindings/node/npm/darwin-arm64/package.json +++ b/bindings/node/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@packvium/native-darwin-arm64", - "version": "1.9.0", + "version": "1.10.0", "cpu": [ "arm64" ], diff --git a/bindings/node/npm/darwin-x64/package.json b/bindings/node/npm/darwin-x64/package.json index 18f422b..1b2221a 100644 --- a/bindings/node/npm/darwin-x64/package.json +++ b/bindings/node/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "@packvium/native-darwin-x64", - "version": "1.9.0", + "version": "1.10.0", "cpu": [ "x64" ], diff --git a/bindings/node/npm/linux-x64-gnu/package.json b/bindings/node/npm/linux-x64-gnu/package.json index e763c3b..3dbd40d 100644 --- a/bindings/node/npm/linux-x64-gnu/package.json +++ b/bindings/node/npm/linux-x64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@packvium/native-linux-x64-gnu", - "version": "1.9.0", + "version": "1.10.0", "cpu": [ "x64" ], diff --git a/bindings/node/npm/win32-x64-msvc/package.json b/bindings/node/npm/win32-x64-msvc/package.json index 5842d1d..6e54b33 100644 --- a/bindings/node/npm/win32-x64-msvc/package.json +++ b/bindings/node/npm/win32-x64-msvc/package.json @@ -1,6 +1,6 @@ { "name": "@packvium/native-win32-x64-msvc", - "version": "1.9.0", + "version": "1.10.0", "cpu": [ "x64" ], diff --git a/bindings/node/package.json b/bindings/node/package.json index 7fd36f9..38a3d83 100644 --- a/bindings/node/package.json +++ b/bindings/node/package.json @@ -1,6 +1,6 @@ { "name": "@packvium/native", - "version": "1.9.0", + "version": "1.10.0", "description": "Compiled Rust engine for @packvium/engine. Not meant to be installed directly.", "license": "MIT", "main": "index.js", @@ -31,9 +31,9 @@ "url": "https://github.com/toxakara/packvium-native/issues" }, "optionalDependencies": { - "@packvium/native-darwin-arm64": "1.9.0", - "@packvium/native-darwin-x64": "1.9.0", - "@packvium/native-win32-x64-msvc": "1.9.0", - "@packvium/native-linux-x64-gnu": "1.9.0" + "@packvium/native-darwin-arm64": "1.10.0", + "@packvium/native-darwin-x64": "1.10.0", + "@packvium/native-win32-x64-msvc": "1.10.0", + "@packvium/native-linux-x64-gnu": "1.10.0" } } diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml index ba43187..55ef2ac 100644 --- a/bindings/python/pyproject.toml +++ b/bindings/python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "packvium-native-rust" -version = "1.9.0" +version = "1.10.0" requires-python = ">=3.9" description = "Compiled Rust backend for Packvium, consumed by the packvium-native selector" readme = "README.md" diff --git a/codemeta.json b/codemeta.json index a87a577..4d4a14a 100644 --- a/codemeta.json +++ b/codemeta.json @@ -3,7 +3,7 @@ "@type": "SoftwareSourceCode", "name": "Packvium native engines: Python wheels, Node addons and the C library", "description": "Compiled Rust backend for Packvium, consumed by the packvium-native selector", - "version": "1.9.0", + "version": "1.10.0", "license": "https://spdx.org/licenses/MIT", "author": [ { diff --git a/crates/packvium-core/src/api.rs b/crates/packvium-core/src/api.rs index ce70249..cae8e01 100644 --- a/crates/packvium-core/src/api.rs +++ b/crates/packvium-core/src/api.rs @@ -6,6 +6,7 @@ use crate::geometry::{ALL_DIRECTIONS, Aabb, Dimensions, Point, Rotation, ShapeTy use crate::hull::{self, Vertex}; use crate::made_to_measure::{MAX_EXACT_INTEGER, MadeToMeasure, sides_of}; use crate::model::*; +use crate::pallet_overhang::{OverhangLimit, solving_frame}; use crate::policy::{PolicyConstraint, PolicyRuleSet}; use crate::rebalance::rebalance_weight; use crate::request_errors; @@ -63,6 +64,8 @@ pub fn rebalance_json( let request_value: Value = serde_json::from_str(request_input)?; let request = request_from_json(&request_value)?; validate_request(&request)?; + // A result's coordinates are in each pallet's solving frame. + let request = with_solving_frames(&request); let result_value: Value = serde_json::from_str(result_input)?; let original = parse_rebalance_result(&request, &result_value)?; // A packing the tariff cannot price is refused here for the same reason @@ -393,6 +396,7 @@ fn parse_rebalance_result(request: &PackingRequest, value: &Value) -> PackResult .and_then(Value::as_array) .cloned() .unwrap_or_default(), + currency: optional_text(root.get("currency")), }) } @@ -412,6 +416,17 @@ pub fn pack_request_with_policy( policy: &PolicyRuleSet, ) -> PackResult { validate_request(request)?; + let framed; + let request = if request + .containers + .iter() + .any(|container| container.pallet_overhang_limit.is_some()) + { + framed = with_solving_frames(request); + &framed + } else { + request + }; // Once per pack, from the request alone and before the first solver runs, so computing // the bound never depends on which solver won or how much of the deadline was left // (OPTIMALITY-GAP.md F3). @@ -432,6 +447,7 @@ pub fn pack_request_with_policy( cite_support_rejections(&mut result, request, ®istry.constraints); cite_limit_rejections(&mut result, request); result.catalog_versions_used = request.catalog_versions_used.clone(); + echo_currency(&mut result, request.currency.as_deref()); // Independent validation re-derives every guarantee from per-item placements. // A container built by GridSolver's compact fast path carries a // `lattice_summary` instead; expand it into the identical placements the O(n) @@ -482,6 +498,15 @@ pub fn pack_request_with_policy( Ok(result) } +/// The request's currency on the result and on every alternative, as the reference states +/// it on each packing it returns. Never scored. `O(alternatives)`. +fn echo_currency(result: &mut PackingResult, currency: Option<&str>) { + result.currency = currency.map(str::to_owned); + for alternative in &mut result.alternatives { + alternative.currency = result.currency.clone(); + } +} + /// States the request's bound on a result and, by the same rule, on each alternative /// (OPTIMALITY-GAP.md § 1.3). /// @@ -772,12 +797,10 @@ const UNSUPPORTED_ITEM_FIELDS: &[&str] = &[]; /// because the next reserved value will need it, and because `reject_unsupported` takes its /// lists as parameters precisely so it remains testable when they are empty. const UNSUPPORTED_SHAPE_TYPES: &[&str] = &[]; -// `pallet_overhang_limit` was reserved in the schema by at the 1.1.0 contract freeze -// and is refused everywhere until an engine implements it from a request: a field a caller -// can set and the solver ignores is worse than a refusal. // `access_directions` left this list in, which wired the reserved field through to -// the stop-accessibility rule in all four engines at once. -const UNSUPPORTED_CONTAINER_FIELDS: &[&str] = &["pallet_overhang_limit"]; +// the stop-accessibility rule in all four engines at once, and `pallet_overhang_limit` in +//, which did the same for the pallet deck. +const UNSUPPORTED_CONTAINER_FIELDS: &[&str] = &[]; fn reject_unsupported(object: &Map) -> PackResult<()> { reject_listed_fields( @@ -855,6 +878,7 @@ fn reject_listed_fields( } } found.extend(made_to_measure_combinations(object)); + found.extend(pallet_overhang_combinations(object)); if found.is_empty() { return Ok(()); } @@ -900,13 +924,6 @@ fn made_to_measure_combinations(object: &Map) -> Vec { { found.push("container.made_to_measure+obstacles".to_string()); } - if container - .get("void_fill_reserve_ratio") - .and_then(Value::as_f64) - .is_some_and(|ratio| ratio > 0.0) - { - found.push("container.made_to_measure+void_fill_reserve_ratio".to_string()); - } } if entries("fixed_placements").iter().any(|entry| { entry @@ -919,6 +936,64 @@ fn made_to_measure_combinations(object: &Map) -> Vec { found } +/// The combinations a pallet with an overhang limit refuses: obstacles and axles +/// sit in the declared frame the widened frame moves, doors and route corridors need a wall +/// the overhang crosses, a reserve is a share of a volume the limit leaves undefined, and a +/// box cut to measure has no deck. A flat bag beside it is a request error instead. Checked +/// on the raw request. `O(items + containers)`. +fn pallet_overhang_combinations(object: &Map) -> Vec { + let entries = |key: &str| { + object + .get(key) + .and_then(Value::as_array) + .map(Vec::as_slice) + .unwrap_or(&[]) + .iter() + .filter_map(Value::as_object) + .collect::>() + }; + let non_empty = |value: Option<&Value>| { + value + .and_then(Value::as_array) + .is_some_and(|list| !list.is_empty()) + }; + let set = |value: Option<&Value>| value.is_some_and(|value| !value.is_null()); + let mut found = Vec::new(); + let mut pallets = false; + for container in entries("containers") { + if !set(container.get("pallet_overhang_limit")) { + continue; + } + pallets = true; + let reserve = container + .get("void_fill_reserve_ratio") + .and_then(Value::as_f64) + .is_some_and(|ratio| ratio > 0.0); + for (name, present) in [ + ( + "access_directions", + non_empty(container.get("access_directions")), + ), + ("axles", set(container.get("axles"))), + ("made_to_measure", set(container.get("made_to_measure"))), + ("obstacles", non_empty(container.get("obstacles"))), + ("void_fill_reserve_ratio", reserve), + ] { + if present { + found.push(format!("container.pallet_overhang_limit+{name}")); + } + } + } + if pallets + && entries("items") + .iter() + .any(|item| set(item.get("stop_index"))) + { + found.push("container.pallet_overhang_limit+item.stop_index".to_string()); + } + found +} + /// The request a JSON document describes, or the first rule it breaks. /// /// Unsupported fields are refused first, as `unsupported_feature`; then the schema's rule @@ -1054,11 +1129,15 @@ fn parse_request(object: &Map) -> PackResult { .map(|value| parse_container(value, length_unit)) .collect::>>()?; let catalog_versions_used = parse_catalog_versions(object.get("catalog_versions_used"))?; - let fixed_placements = - fixed::require_fixed_placement_shapes(object.get("fixed_placements"), length_unit)? - .iter() - .map(|value| parse_fixed_placement(value, length_unit)) - .collect::>>()?; + let currency = optional_text(object.get("currency")); + let fixed_placements = fixed::require_fixed_placement_shapes( + object.get("fixed_placements"), + length_unit, + &fixed::hull_item_types(object.get("items")), + )? + .iter() + .map(|value| parse_fixed_placement(value, length_unit)) + .collect::>>()?; Ok(PackingRequest { items, containers, @@ -1066,6 +1145,7 @@ fn parse_request(object: &Map) -> PackResult { output_length_unit, output_weight_unit, catalog_versions_used, + currency, fixed_placements, fixed_containers: Vec::new(), }) @@ -1363,7 +1443,7 @@ fn parse_item(value: &Value, unit: &str) -> PackResult { .and_then(Value::as_bool) .unwrap_or(false) { - rotations.retain(|rotation| Rotation::UPRIGHT.contains(rotation)); + rotations.retain(|rotation| rotation.is_upright()); } if rotations.is_empty() { return Err(PackError::InvalidInput(format!( @@ -1639,11 +1719,29 @@ fn parse_container(value: &Value, unit: &str) -> PackResult { rate_table: parse_rate_table(map.get("rate_table"))?, access_directions: parse_access_directions(map.get("access_directions"))?, preloaded: Vec::new(), - deformable_boundary: parse_deformable_boundary(map.get("deformable_boundary"))?, + deformable_boundary: parse_deformable_boundary(map.get("deformable_boundary"), unit)?, made_to_measure: parse_made_to_measure(map.get("made_to_measure"), unit)?, + pallet_overhang_limit: parse_pallet_overhang_limit(map.get("pallet_overhang_limit"), unit)?, + deck: None, }) } +/// `container.pallet_overhang_limit`. `request_errors` has already refused every +/// malformed value and every frame past the box ceiling. +fn parse_pallet_overhang_limit( + value: Option<&Value>, + unit: &str, +) -> PackResult> { + let Some(map) = value.and_then(Value::as_object) else { + return Ok(None); + }; + let axis = |name: &str| Length::parse(map.get(name).unwrap_or(&Value::Null), unit); + Ok(Some(OverhangLimit { + length: axis("length")?, + width: axis("width")?, + })) +} + /// `container.made_to_measure`. `request_errors` has already refused every /// malformed value, every axis off the machine grid and every price past `2^53 - 1`. fn parse_made_to_measure(value: Option<&Value>, unit: &str) -> PackResult> { @@ -1673,15 +1771,25 @@ fn parse_made_to_measure(value: Option<&Value>, unit: &str) -> PackResult