@jetta/cargo-stabilizer 0.1.0-11 → 0.1.0-12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -13,13 +13,14 @@ Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
13
13
  - Empty-space candidate discovery for floor and elevated slots via `@jetta/empty-spaces-manager`.
14
14
  - Supporter-top candidate slots aligned to each stacked item footprint, included in beam expansion (`top_k ∪ supporter_top`).
15
15
  - Elevated candidates must sit on a supporter `(x, z)` origin so stacked loose items copy the supporter footprint.
16
- - `cargo_stabilizer.pin_tie_ratio_blocks` (default `false`): when true, 3_2/2_3 groups stay pinned; otherwise every item is movable.
16
+ - `cargo_stabilizer.pin_tie_ratio_blocks` (default `false`): when true, only **floor five-slot** `3_2`/`2_3` walls stay pinned; stacked tie-ratio items and generic groups stay movable.
17
17
  - Public contract exports: `parse_stabilizer_input`, `parse_stabilizer_output`, `safe_parse_stabilizer_input`, `safe_parse_stabilizer_output`, and related domain types.
18
18
 
19
19
  ### Changed
20
20
 
21
21
  - README documents I/O contract mapping, configuration keys, dependencies, and test/coverage commands.
22
22
  - Reorder objective is whole-cargo `transport_score`; loose-item score sum is only a tie-break. Axle, waypoint, and milkrun gates are unchanged.
23
+ - `pin_tie_ratio_blocks` pins only floor five-slot `3_2`/`2_3` walls; stacked members of the same group stay movable.
23
24
 
24
25
  ### Testing
25
26
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @jetta/cargo-stabilizer
2
2
 
3
- TypeScript library that reorders items to improve **whole-cargo transport stability**. By default every item is movable; set `cargo_stabilizer.pin_tie_ratio_blocks` to pin 3_2/2_3 groups. The reorder objective is `transport_score` (loose-item score sum is a tie-break). Implements five config-selectable strategies with organization gates (waypoint order, milkrun wall reservation) and empty-space candidate discovery (JET-2262).
3
+ TypeScript library that reorders items to improve **whole-cargo transport stability**. By default every item is movable; set `cargo_stabilizer.pin_tie_ratio_blocks` to pin **floor five-slot** `3_2`/`2_3` walls. Stacked tie-ratio pieces and generic groups stay movable one item at a time. The reorder objective is `transport_score` (loose-item score sum is a tie-break). Implements five config-selectable strategies with organization gates (waypoint order, milkrun wall reservation) and empty-space candidate discovery (JET-2262).
4
4
 
5
5
  ## Requirements
6
6
 
@@ -73,7 +73,7 @@ Exported parsers: `parse_stabilizer_input`, `parse_stabilizer_output`, `safe_par
73
73
  | `cargo_stabilizer.transport_stability_floor` | `0` | Hard minimum transport stability score (gate, not the maximize objective) |
74
74
  | `cargo_stabilizer.max_iteration` | `10` | Greedy / SA iteration budget |
75
75
  | `cargo_stabilizer.preserve_tie_block_organization` | `true` | When true, enforce waypoint Z zones and macro delivery order |
76
- | `cargo_stabilizer.pin_tie_ratio_blocks` | `false` | When true, do not move 3_2/2_3 groups; other items remain movable |
76
+ | `cargo_stabilizer.pin_tie_ratio_blocks` | `false` | When true, do not move floor five-slot `3_2`/`2_3` walls; stacked tie-ratio items and other groups remain movable |
77
77
  | `cargo_stabilizer.enforce_milkrun_wall_reservation` | `false` | When true, reserve rear compound-wall Z bands using profile key below |
78
78
  | `number_of_wall_to_allocate_from_last_waypoints` | `0` | Count of trailing waypoints whose compound walls are reserved (read from `cargo_state.config.algoritmo` when milkrun enforcement is enabled) |
79
79
  | `folga_de_peso_nos_eixos` | `0` | Axle folga percent |
@@ -3,7 +3,7 @@ import type { LooseItemRef } from './loose_item_filter.js';
3
3
  /**
4
4
  * Collects items the stabilizer may move.
5
5
  * @param containers - Container list from env.
6
- * @param pin_tie_ratio_blocks - When true, skip 3_2/2_3 groups.
6
+ * @param pin_tie_ratio_blocks - When true, skip floor five-slot 3_2/2_3 walls.
7
7
  * @returns Movable item references with container index.
8
8
  */
9
9
  export declare function collect_movable_items(containers: {
@@ -11,8 +11,8 @@ export declare function collect_movable_items(containers: {
11
11
  }[], pin_tie_ratio_blocks: boolean): LooseItemRef[];
12
12
  /**
13
13
  * @param item - Item record.
14
- * @param tie_ratio_group_ids - Group ids that contain a 3_2/2_3 member.
15
- * @returns True when the item belongs to a pinned tie-ratio group.
14
+ * @param pinned_group_ids - Floor five-slot 3_2/2_3 group ids.
15
+ * @returns True when the item is a floor member of a pinned wall.
16
16
  */
17
- export declare function is_tie_ratio_block_item(item: StabilizerItem, tie_ratio_group_ids: Set<string>): boolean;
17
+ export declare function is_tie_ratio_block_item(item: StabilizerItem, pinned_group_ids: Set<string>): boolean;
18
18
  //# sourceMappingURL=collect_movable_items.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collect_movable_items.d.ts","sourceRoot":"","sources":["../../../src/core/filters/collect_movable_items.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AAExF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAE1D;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACjC,UAAU,EAAE;IAAE,KAAK,EAAE,cAAc,EAAE,CAAA;CAAE,EAAE,EACzC,oBAAoB,EAAE,OAAO,GAC9B,YAAY,EAAE,CAMhB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACnC,IAAI,EAAE,cAAc,EACpB,mBAAmB,EAAE,GAAG,CAAC,MAAM,CAAC,GACjC,OAAO,CAOT"}
1
+ {"version":3,"file":"collect_movable_items.d.ts","sourceRoot":"","sources":["../../../src/core/filters/collect_movable_items.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAI1D;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACjC,UAAU,EAAE;IAAE,KAAK,EAAE,cAAc,EAAE,CAAA;CAAE,EAAE,EACzC,oBAAoB,EAAE,OAAO,GAC9B,YAAY,EAAE,CAMhB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACnC,IAAI,EAAE,cAAc,EACpB,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,GAC9B,OAAO,CAOT"}
@@ -1,38 +1,27 @@
1
- import { TIE_RATIO_ORIENTATION } from '../constants/TieRatioOrientation.js';
1
+ import { collect_pinned_floor_tie_ratio_group_ids } from './collect_pinned_floor_tie_ratio_group_ids.js';
2
+ import { is_item_on_cm_floor } from './is_item_on_cm_floor.js';
2
3
  /**
3
4
  * Collects items the stabilizer may move.
4
5
  * @param containers - Container list from env.
5
- * @param pin_tie_ratio_blocks - When true, skip 3_2/2_3 groups.
6
+ * @param pin_tie_ratio_blocks - When true, skip floor five-slot 3_2/2_3 walls.
6
7
  * @returns Movable item references with container index.
7
8
  */
8
9
  export function collect_movable_items(containers, pin_tie_ratio_blocks) {
9
10
  const pinned_groups = pin_tie_ratio_blocks
10
- ? collect_tie_ratio_group_ids(flatten_container_items(containers))
11
+ ? collect_pinned_floor_tie_ratio_group_ids(flatten_container_items(containers))
11
12
  : new Set();
12
13
  return collect_items_except_pinned(containers, pinned_groups);
13
14
  }
14
15
  /**
15
16
  * @param item - Item record.
16
- * @param tie_ratio_group_ids - Group ids that contain a 3_2/2_3 member.
17
- * @returns True when the item belongs to a pinned tie-ratio group.
17
+ * @param pinned_group_ids - Floor five-slot 3_2/2_3 group ids.
18
+ * @returns True when the item is a floor member of a pinned wall.
18
19
  */
19
- export function is_tie_ratio_block_item(item, tie_ratio_group_ids) {
20
- if (item.group_id == null) {
20
+ export function is_tie_ratio_block_item(item, pinned_group_ids) {
21
+ if (item.group_id == null || !is_item_on_cm_floor(item)) {
21
22
  return false;
22
23
  }
23
- return tie_ratio_group_ids.has(item.group_id);
24
- }
25
- function collect_tie_ratio_group_ids(items) {
26
- const group_ids = new Set();
27
- for (const item of items) {
28
- if (item.group_id == null) {
29
- continue;
30
- }
31
- if (is_tie_ratio_orientation(read_tie_ratio_orientation(item))) {
32
- group_ids.add(item.group_id);
33
- }
34
- }
35
- return group_ids;
24
+ return pinned_group_ids.has(item.group_id);
36
25
  }
37
26
  function collect_items_except_pinned(containers, pinned_groups) {
38
27
  const movable = [];
@@ -62,11 +51,3 @@ function flatten_container_items(containers) {
62
51
  }
63
52
  return items;
64
53
  }
65
- function read_tie_ratio_orientation(item) {
66
- const orientation = item.attributes?.tie_ratio_orientation;
67
- return typeof orientation === 'string' ? orientation : undefined;
68
- }
69
- function is_tie_ratio_orientation(orientation) {
70
- return orientation === TIE_RATIO_ORIENTATION.THREE_TWO
71
- || orientation === TIE_RATIO_ORIENTATION.TWO_THREE;
72
- }
@@ -0,0 +1,8 @@
1
+ import type { StabilizerItem } from '../validation/contract/stabilizer_domain_schema.js';
2
+ /**
3
+ * Group ids of floor five-slot 3_2/2_3 walls that the stabilizer must pin.
4
+ * @param items - All items in the cargo.
5
+ * @returns Group ids with exactly five floor tie-ratio members.
6
+ */
7
+ export declare function collect_pinned_floor_tie_ratio_group_ids(items: StabilizerItem[]): Set<string>;
8
+ //# sourceMappingURL=collect_pinned_floor_tie_ratio_group_ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collect_pinned_floor_tie_ratio_group_ids.d.ts","sourceRoot":"","sources":["../../../src/core/filters/collect_pinned_floor_tie_ratio_group_ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AAMxF;;;;GAIG;AACH,wBAAgB,wCAAwC,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAQ7F"}
@@ -0,0 +1,41 @@
1
+ import { TIE_RATIO_ORIENTATION } from '../constants/TieRatioOrientation.js';
2
+ import { is_item_on_cm_floor } from './is_item_on_cm_floor.js';
3
+ const FULL_TIE_RATIO_FLOOR_COUNT = 5;
4
+ /**
5
+ * Group ids of floor five-slot 3_2/2_3 walls that the stabilizer must pin.
6
+ * @param items - All items in the cargo.
7
+ * @returns Group ids with exactly five floor tie-ratio members.
8
+ */
9
+ export function collect_pinned_floor_tie_ratio_group_ids(items) {
10
+ const floor_tie_count_by_group = new Map();
11
+ for (const item of items) {
12
+ add_floor_tie_member(floor_tie_count_by_group, item);
13
+ }
14
+ return groups_with_full_floor_wall(floor_tie_count_by_group);
15
+ }
16
+ function add_floor_tie_member(counts, item) {
17
+ if (item.group_id == null || !is_item_on_cm_floor(item)) {
18
+ return;
19
+ }
20
+ if (!is_tie_ratio_orientation(read_tie_ratio_orientation(item))) {
21
+ return;
22
+ }
23
+ counts.set(item.group_id, (counts.get(item.group_id) ?? 0) + 1);
24
+ }
25
+ function groups_with_full_floor_wall(counts) {
26
+ const pinned = new Set();
27
+ for (const [group_id, count] of counts) {
28
+ if (count === FULL_TIE_RATIO_FLOOR_COUNT) {
29
+ pinned.add(group_id);
30
+ }
31
+ }
32
+ return pinned;
33
+ }
34
+ function read_tie_ratio_orientation(item) {
35
+ const orientation = item.attributes?.tie_ratio_orientation;
36
+ return typeof orientation === 'string' ? orientation : undefined;
37
+ }
38
+ function is_tie_ratio_orientation(orientation) {
39
+ return orientation === TIE_RATIO_ORIENTATION.THREE_TWO
40
+ || orientation === TIE_RATIO_ORIENTATION.TWO_THREE;
41
+ }
@@ -0,0 +1,8 @@
1
+ import type { StabilizerItem } from '../validation/contract/stabilizer_domain_schema.js';
2
+ /**
3
+ * True when the item rests on the cargo-movement floor (z is height).
4
+ * @param item - Stabilizer item in CM coordinates.
5
+ * @returns True when height origin is on the floor.
6
+ */
7
+ export declare function is_item_on_cm_floor(item: StabilizerItem): boolean;
8
+ //# sourceMappingURL=is_item_on_cm_floor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is_item_on_cm_floor.d.ts","sourceRoot":"","sources":["../../../src/core/filters/is_item_on_cm_floor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AAIxF;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAGjE"}
@@ -0,0 +1,9 @@
1
+ const CM_FLOOR_HEIGHT_EPSILON = 1e-6;
2
+ /**
3
+ * True when the item rests on the cargo-movement floor (z is height).
4
+ * @param item - Stabilizer item in CM coordinates.
5
+ * @returns True when height origin is on the floor.
6
+ */
7
+ export function is_item_on_cm_floor(item) {
8
+ return item.z <= CM_FLOOR_HEIGHT_EPSILON;
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetta/cargo-stabilizer",
3
- "version": "0.1.0-11",
3
+ "version": "0.1.0-12",
4
4
  "description": "Stable loose-item reorder library for cargo-movement (JET-2262)",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",