Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/DISCUSSION_TEMPLATE/q-a.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ body:
id: package-version
attributes:
label: Package and version
placeholder: "@packvium/engine 1.8.0 (JavaScript)"
placeholder: "@packvium/engine 1.9.0 (JavaScript)"
validations:
required: true
- type: textarea
Expand Down
2 changes: 1 addition & 1 deletion .github/DISCUSSION_TEMPLATE/show-and-tell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ body:
id: package-version
attributes:
label: Package and version
placeholder: "@packvium/engine 1.8.0 (JavaScript)"
placeholder: "@packvium/engine 1.9.0 (JavaScript)"
validations:
required: false
- type: textarea
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ body:
id: version
attributes:
label: Package version
description: The exact version installed, for example 1.8.0.
placeholder: "1.8.0"
description: The exact version installed, for example 1.9.0.
placeholder: "1.9.0"
validations:
required: true
- type: input
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ body:
id: version
attributes:
label: Package version
placeholder: "1.8.0"
placeholder: "1.9.0"
validations:
required: true
- type: textarea
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
node: ["16", "18", "20", "22", "24", "26"]
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with:
node-version: ${{ matrix.node }}
- if: matrix.node == '16'
Expand All @@ -33,8 +33,8 @@ jobs:
# the fallback needs that never made it into the published tarball.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with: {node-version: "22"}
- run: npm pack
- name: Install the packed tarball into a clean project and import it
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
- uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
with:
fail-on-severity: low
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with: {node-version: "22"}
- run: npm test

Expand All @@ -44,7 +44,7 @@ jobs:
fi

- run: npm pack
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: tarball
path: "*.tgz"
Expand All @@ -61,12 +61,12 @@ jobs:
id-token: write # npm Trusted Publishing and the attestation
attestations: write # build provenance, so a consumer can verify where a file came from
steps:
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with: {node-version: "22", registry-url: "https://registry.npmjs.org"}
# OIDC trusted publishing needs npm 11.5.1 or newer; Node 22 bundles npm 10 (see release.yml).
- run: npm install -g npm@^11.5.1
- run: npm --version
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: tarball
- uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with: {node-version: "22"}
- run: npm test

Expand All @@ -40,7 +40,7 @@ jobs:
fi

- run: npm pack
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: tarball
path: "*.tgz"
Expand All @@ -53,7 +53,7 @@ jobs:
id-token: write # npm Trusted Publishing and the attestation
attestations: write # build provenance, so a consumer can verify where a file came from
steps:
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
with: {node-version: "22", registry-url: "https://registry.npmjs.org"}
# npm's OIDC trusted publishing needs npm 11.5.1 or newer; Node 22 still bundles
# npm 10, which performs no OIDC exchange at all. The publish then goes out
Expand All @@ -62,7 +62,7 @@ jobs:
# that sent 1.0.0 out by hand, permanently without provenance.
- run: npm install -g npm@^11.5.1
- run: npm --version
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: tarball
- uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1
Expand All @@ -80,7 +80,7 @@ jobs:
permissions:
contents: write # the Release is the only thing this workflow writes to the repository
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
- name: Create the GitHub Release from the tag
env:
GH_TOKEN: ${{ github.token }}
Expand Down
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,45 @@ What changed in `@packvium/engine` on npm, release by release. The format follow
[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.9.0]

The fallback now checks what the addon checks, spends an effort budget the same way and reports
its time.

### Changed

- **Under a clearance a compressible item bears its load on its own footprint**, so its crush
check is stricter and `validate` measures its own compressed volume.
- **Breaking for weights past `2^53 - 1` ticks:** a weight's `ticks`, and a `shipping_cost`
score position, are a `BigInt` past it, so `JSON.stringify` refuses such a result; the new
`stringifyExact` and `parseExact` carry it through JSON exactly. Below it nothing changes.
- **A weight is at most `2^63 - 1` ticks, and so is every item's weight times its quantity plus
the heaviest tare**: past it, `invalid_request` / `above_maximum`; a weight written as a JSON
number past `2^53 - 1` is `invalid_value` and must be a string.
- **The centre of gravity is checked under a `minimum_support_ratio` above 0:** a placement
covering at most half its base with the centroid outside the contact hull is refused.
A request without a ratio packs as before.
- **Agrees with the other engines where 1.8 did not:** nesting under a clearance shares the
items' own overlap and a deep nesting column nests in pairs; a length past `2^53 - 1` ticks or
a box past `10^30` cubic ticks is `invalid_request` / `above_maximum`; a side that reads as zero
ticks is `invalid_value` / `must be positive`; an obstacle box outside its container is
`invalid_value` / `lies outside inner_dimensions`, each at its own pointer.
- **`validate` checks the centroid (`centre_of_gravity_unsupported`) and the whole stack's load
(`top_load_exceeded`)**, an item on several bearers shared by contact area. It no longer
holds that item's whole weight against every bearer, so it accepts some results 1.8 rejected
and names the overloaded bearer.
- **A plan beam wider than 1 compares every container type**, whatever the node limit.
- **The JavaScript fallback spends `effort_budget` as the other engines do**, and its `quality`
beam refines its best order once instead of its first two: about 1.6x faster, no score changed.
- **`algorithm.duration_ms` reports the milliseconds the fallback took**; it was always 0.
- **The native backend accepts null obstacle coordinates as zero**, including additional boxes,
consistently with request admission.

### Fixed

- **The fallback no longer slides an item under a `ground_contact_rule: single` item that already
rests on one supporter.**

## [1.8.0]

`validate` works after a plain `npm install`, results say how far they can be from the best
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type: software
authors:
- name: "Packvium contributors"
website: "https://packvium.com"
version: "1.8.0"
version: "1.9.0"
license: MIT
url: "https://packvium.com"
repository-code: "https://github.com/toxakara/packvium-node"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ Documentation, the constraint reference and the benchmarks are at
| --- | --- | --- |
| Python — [`packvium`](https://pypi.org/project/packvium/) | `pip install packvium` | [packvium-python](https://github.com/toxakara/packvium-python) |
| PHP — [`packvium/packvium`](https://packagist.org/packages/packvium/packvium) | `composer require packvium/packvium` | [packvium-php](https://github.com/toxakara/packvium-php) |
| Rust — [`packvium`](https://crates.io/crates/packvium) | `packvium = "1.8"` | [packvium-rust](https://github.com/toxakara/packvium-rust) |
| Rust — [`packvium`](https://crates.io/crates/packvium) | `packvium = "1.9"` | [packvium-rust](https://github.com/toxakara/packvium-rust) |
| Node.js — [`@packvium/engine`](https://www.npmjs.com/package/@packvium/engine) | `npm install @packvium/engine` | [packvium-node](https://github.com/toxakara/packvium-node) |
| Browser / WebAssembly — [`@packvium/browser`](https://www.npmjs.com/package/@packvium/browser) | `npm install @packvium/browser` | [packvium-wasm](https://github.com/toxakara/packvium-wasm) |
| PHP FFI bridge — [`packvium/native-bridge`](https://packagist.org/packages/packvium/native-bridge) | `composer require packvium/native-bridge` | [packvium-php-bridge](https://github.com/toxakara/packvium-php-bridge) |
Expand Down Expand Up @@ -350,7 +350,7 @@ CodeMeta form.
@software{packvium_node,
author = {{Packvium contributors}},
title = {Packvium for Node.js},
version = {1.8.0},
version = {1.9.0},
license = {MIT},
url = {https://packvium.com}
}
Expand Down
2 changes: 1 addition & 1 deletion artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const FORMAT = 'packvium-operational-artifact/v1';
* The engine's own name is deliberately not recorded: four correct builders naming themselves
* would emit four different documents.
*/
export const SUITE_VERSION = '1.8.0';
export const SUITE_VERSION = '1.9.0';

/** The deterministic part of `result.algorithm`; `duration_ms` is wall-clock time. */
const SOLVER_FIELDS = ['profile', 'solver', 'seed', 'time_limit_reached', 'effort_limit_reached'];
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"@type": "SoftwareSourceCode",
"name": "Packvium for Node.js",
"description": "Deterministic 3D bin-packing and cartonization engine for pallets, containers, trucks and shipping cartons. Exact integer geometry, reproducible results.",
"version": "1.8.0",
"version": "1.9.0",
"license": "https://spdx.org/licenses/MIT",
"author": [
{
Expand Down
10 changes: 9 additions & 1 deletion commerce-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function isUnary(operator) {
}

/**
* Value equality over the JSON scalar types, matching the reference implementation
* Structural equality over JSON values, matching the reference implementation
* exactly -- including that a boolean equals the integer it stands for, the one place a
* naive `===` would disagree and quietly change a decision.
*/
Expand All @@ -175,12 +175,20 @@ export function valuesEqual(left, right) {
if (Array.isArray(left) || Array.isArray(right)) return false;
if (left === null || right === null) return left === right;
if (typeof left !== typeof right) return false;
if (typeof left === 'object') {
const keys = Object.keys(left);
return keys.length === Object.keys(right).length
&& keys.every((key) => Object.hasOwn(right, key) && valuesEqual(left[key], right[key]));
}
return left === right;
}

function contains(haystack, needle) {
if (Array.isArray(haystack)) return haystack.some((entry) => valuesEqual(entry, needle));
if (typeof haystack === 'string') return typeof needle === 'string' && haystack.includes(needle);
if (haystack !== null && typeof haystack === 'object') {
return typeof needle === 'string' && Object.hasOwn(haystack, needle);
}
return false;
}

Expand Down
23 changes: 16 additions & 7 deletions commerce.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function loadHistories(value, path, identityKeys, label, parseVersion) {
const fields = asObject(entry, entryPath);
checkKeys(fields, entryPath, [...identityKeys, 'versions']);
const identity = identityKeys.map((name) => asText(fields[name], `${entryPath}.${name}`));
const key = identity.join('/');
const key = identity.length === 1 ? identity[0] : JSON.stringify(identity);
if (histories.has(key)) fail(entryPath, `duplicate ${label} history for '${key}'`);
const versions = asList(fields.versions, `${entryPath}.versions`);
if (versions.length === 0) {
Expand Down Expand Up @@ -180,7 +180,7 @@ function parseTariff(value, path, [carrierId, serviceId], number) {
['minimum_charge_minor', 'fuel_surcharge_permille', 'accessorials'],
);
const zonesPath = `${path}.cost_per_dimensional_kg_minor`;
const costPerDimensionalKgMinor = {};
const costPerDimensionalKgMinor = Object.create(null);
const zones = asObject(fields.cost_per_dimensional_kg_minor, zonesPath);
for (const [zone, cost] of Object.entries(zones)) {
costPerDimensionalKgMinor[zone] = nonNegative(
Expand Down Expand Up @@ -214,7 +214,7 @@ function parseTariff(value, path, [carrierId, serviceId], number) {
}

function parseAccessorials(value, path) {
const charges = {};
const charges = Object.create(null);
asList(value, path).forEach((entry, index) => {
const entryPath = `${path}[${index}]`;
const fields = asObject(entry, entryPath);
Expand Down Expand Up @@ -311,12 +311,18 @@ function parseRollback(fields, path, number, history) {
if (target === undefined) {
fail(path, `rollback_to names version ${toVersion}, which is not published yet`);
}
const publishedAt = asInteger(fields.published_at, `${path}.published_at`);
const publishedAt = nonNegative(
asInteger(fields.published_at, `${path}.published_at`),
path, 'published_at cannot be negative',
);
const note = asText(optional(fields, 'note') ?? '', `${path}.note`);
return {
number,
snapshot: target.snapshot,
effectiveAt: asInteger(optional(fields, 'effective_at') ?? publishedAt, `${path}.effective_at`),
effectiveAt: nonNegative(
asInteger(optional(fields, 'effective_at') ?? publishedAt, `${path}.effective_at`),
path, 'effective_at cannot be negative',
),
publishedAt,
rolledBackFrom: toVersion,
note: note === '' ? `rollback to version ${toVersion}` : note,
Expand Down Expand Up @@ -481,7 +487,7 @@ export function quote(document, request) {
}

function resolveTariff(carriers, identity, fields, pin) {
const history = carriers.get(`${identity.carrier_id}/${identity.service_id}`);
const history = carriers.get(JSON.stringify([identity.carrier_id, identity.service_id]));
if (pin === 'tariff_version') {
const version = asInteger(fields.tariff_version, 'request.tariff_version');
const tariff = history?.find((candidate) => candidate.version === version);
Expand Down Expand Up @@ -591,7 +597,10 @@ export function catalogVersionInfo(document, request) {
const fields = asObject(request, 'request');
checkKeys(fields, 'request', ['catalog_id', 'resolved_at'], ['version', 'as_of']);
const catalogId = asText(fields.catalog_id, 'request.catalog_id');
const resolvedAt = asInteger(fields.resolved_at, 'request.resolved_at');
const resolvedAt = nonNegative(
asInteger(fields.resolved_at, 'request.resolved_at'),
'request.resolved_at', 'resolved_at cannot be negative',
);
const version = optional(fields, 'version') === undefined
? undefined
: asInteger(fields.version, 'request.version');
Expand Down
Loading
Loading