@rig-c/parts 2.47.0 → 2.48.0

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/docs/AUTHORING.md CHANGED
@@ -6396,8 +6396,8 @@ outside the consumed inputs pending [#1177](https://github.com/rig-c/parts/issue
6396
6396
  | <a id="CHECK_SETUP_PAINTING_MEASURED"></a>`CHECK_SETUP_PAINTING_MEASURED` | missing native setup/ownership or unsupported clipping | supply observable textured setup geometry; an unavailable instrument never passes |
6397
6397
  | <a id="CHECK_BOUNDARY_COLOUR_STEP"></a>`CHECK_BOUNDARY_COLOUR_STEP` | the requirements file declares `boundary_colour.max_step_excess` and a part boundary's colour step in the rig's render exceeds the same boundary's step in the rig's own pieces by more than it; the part pair, the frame (`setup` or `idle frame <n> (t <s> s)`), the stage pixel, the excess, the declared allowance and both steps are quoted. Unlike [`CHECK_SETUP_MATCHES_PAINTING`](#CHECK_SETUP_MATCHES_PAINTING), which compares the painting per declared region at the setup pose, this compares against the rig's own flat pieces (`parts.json` placement at setup, each piece's rest colour through its art UVs on every idle frame), so a part drawn over its neighbour's line art is not a failure | the pair's rig image or mesh: `rig/images/<part>.png` (a texture stretched into its padded UVs, or a notch cut out of it), or that part's mesh in `config.json` `meshes` when the mesh cuts a corner off the art; see [Boundary colour step](#boundary-colour-step-issue-942) |
6398
6398
  | <a id="CHECK_BOUNDARY_COLOUR_UNMEASURED"></a>`CHECK_BOUNDARY_COLOUR_UNMEASURED` | `boundary_colour` is declared and the step cannot be taken: no `parts.json`, no `idle`, or a default-skin region or mesh image without a sequence, with a parts record, whose rig image is not its parts PNG with one even pad on every side (refused before anything is built); otherwise a drawn slot has no `parts.json` piece, is clipped, or its rig image is not its parts PNG with one even pad on every side (the slot and frame are named). Never a pass | make every drawn slot a `parts.json` piece, or drop `boundary_colour` from the requirements file (the bar then reports SKIP) |
6399
- | <a id="CHECK_BEHIND_PART_SEAMS"></a>`CHECK_BEHIND_PART_SEAMS` | `behind_seams` is declared and a selected pair exceeds its allowance in the independent motion-opened or standing reading at setup, on an idle frame or at an opted-in named turn pose; the pair, behind slots, reading, frame, counted seam cells and allowance are named | repair the declared seam or author its per-pair allowance; no WARN mode or rest-visible mask; see [Behind-part seams](#behind-part-seams-issue-1314) |
6400
- | <a id="CHECK_BEHIND_PART_SEAMS_UNMEASURED"></a>`CHECK_BEHIND_PART_SEAMS_UNMEASURED` | a pair with an authored effective threshold cannot read a mandatory population: selected pair, eligible behind slots, idle, readable setup, motion support, boundary population, or verified render/grid/material evidence; mandatory unread evidence makes the combined line FAIL. A missing threshold alone is a nonrequired SKIP and HOLE without this refusal code | supply the named measurement evidence; an invalid selected-pair override also refuses by name, and existing renderer or sidecar refusals remain refusals |
6399
+ | <a id="CHECK_BEHIND_PART_SEAMS"></a>`CHECK_BEHIND_PART_SEAMS` | `behind_seams` is declared and a selected pair exceeds its allowance in the independent `motion_opened` reading on an idle frame, in the `standing` reading at setup (compared against the parts' flat recomposite at their painted positions), or in either reading at an opted-in named turn pose; the pair, behind slots, reading, frame, counted seam cells and allowance are named | repair the declared seam in `parts/<part>.png` or `config.json` (`regions`, `meshes`, or `bones`), or author its allowance in `requirements.json` (`behind_seams.allowance` or `behind_seams.pairs[].allowance`); no WARN mode or rest-visible mask; see [Behind-part seams](#behind-part-seams-issue-1314) |
6400
+ | <a id="CHECK_BEHIND_PART_SEAMS_UNMEASURED"></a>`CHECK_BEHIND_PART_SEAMS_UNMEASURED` | a pair with an authored effective threshold cannot read a mandatory population: selected pair, eligible behind slots, `--parts` manifest (`parts.json` and `parts/*.png`) for setup standing's flat recomposite, idle, readable setup, motion support, boundary population, or verified render/grid/material evidence; mandatory unread evidence makes the combined line FAIL. A missing threshold alone is a nonrequired SKIP and HOLE without this refusal code | for the detail `no --parts manifest was supplied; setup standing compares the setup render with the parts' flat recomposite`, supply `parts.json` and `parts/<part>.png` (or pass `--parts <dir>` on the `rig-parts check` command line). For the detail `standing endpoints include ambiguous half-alpha owners`, the line names the case and, for each case, the first endpoint in scan order with both members' alpha: *neither* member reaches 128/255 there (both members' soft edges paint the same cell, each below 128/255) or *both* do (the members' overlap reaches the gap's edge). Edit `parts/<part>.png` of one member, or its source layer, so that exactly one member reaches 128/255 at that endpoint and the other is below it or does not paint it; the corridor is then read and may fail [`CHECK_BEHIND_PART_SEAMS`](#CHECK_BEHIND_PART_SEAMS) on a real gap. A threshold at or above the cell's distance to the recomposite removes the cell from the reading altogether; the threshold decides what could count; it does not clear a cell that could. `requirements.json` `behind_seams.allowance` never clears an unread cell; removing `behind_seams.threshold` (or `behind_seams.pairs[].threshold`), or the pair from `behind_seams.pairs[]` in `requirements.json`, only silences the reading (issues #1405, #1408). For any other detail, supply the named measurement evidence in `parts/<part>.png`, `config.json` or `requirements.json` `behind_seams`; an invalid selected-pair override in `requirements.json` `behind_seams.pairs[]` also refuses by name, and existing renderer or sidecar refusals remain refusals |
6401
6401
  | <a id="SETUP_PAINTING_REQUIRED_LIMIT"></a>`SETUP_PAINTING_REQUIRED_LIMIT` | `setup_painting.required` is `true` and a limit the check needs is absent: `rgb_tolerance`, `regions`, or a region's `max_pixels` (the object names the region). Refused when the requirements file is read, before anything is built (issue #943) | author the named limit; none is derived from the art. Without `required` the same region reports SKIP |
6402
6402
  | <a id="CHECK_SOURCE_GRID"></a>`CHECK_SOURCE_GRID` | the setup-pose still and its black-tinted twin (the coverage `SETUP_POSE_VS_SOURCE` reads) did not come back on one grid over one opaque background | a rigc problem; report it |
6403
6403
  | <a id="CHECK_RIGC_VERSION"></a>`CHECK_RIGC_VERSION` | `rigc --version` is below 1.4.0, or prints no version: its `render` has no `--geometry`, which `TEXTURE_STRETCH` reads. Refused before anything is built | `bun install` (this package depends on rig-c ^2.20.4), or put a newer `rigc` first on `PATH` |
@@ -8372,24 +8372,74 @@ it does not uniquely attribute a defect to one rear slot.
8372
8372
  The two readings are independent:
8373
8373
 
8374
8374
  - `motion_opened` attributes core's stock transported setup-overlap
8375
- `gapCovered` cells to that behind set. Its ordinary all-behind-hidden
8376
- counterfactual must be transparent at the exact seam-cell centre, and setup
8377
- attribution must show A or B covering that material. It uses no one-cell
8378
- floor. A rigidly translated closed pair stays closed; no setup overlap band
8379
- means this half is unmeasured, even when the standing half can read.
8380
- - `standing` scans row and column runs whose combined A/B alpha is below
8381
- 128/255, bracketed immediately by different unambiguous A/B owners. A cell
8382
- counts when the behind set has positive surviving source-over contribution
8383
- and its straight RGB differs from BOTH endpoint neighbours by strictly more
8384
- than the effective T in max-channel distance. Equal-colour antialias ramps
8385
- count zero contrast. Later opaque art contributes no visible rear colour.
8386
- There is no width guess, rest mask or subtraction of setup-visible cells.
8387
- A corridor with an ambiguous endpoint owner stays unread; neither A nor B
8388
- is inferred. Other readable corridors on that frame retain their measured
8389
- cells. A counted total above allowance stays FAIL even when another corridor
8390
- is unread; an unread population cannot turn a measured failure into SKIP.
8391
- With unread corridors and no measured excess, standing is SKIP, never PASS.
8392
- This bracketed-run definition does not certify curved or diagonal openings.
8375
+ `gapCovered` cells to that behind set on every idle frame (and at opted-in
8376
+ turn poses). Its ordinary all-behind-hidden counterfactual must be
8377
+ transparent at the exact seam-cell centre, and setup attribution must show A
8378
+ or B covering that material. It uses no one-cell floor. A rigidly translated
8379
+ closed pair stays closed; no setup overlap band means this half is unmeasured
8380
+ on idle.
8381
+ - `standing` is measured at `setup` against the parts' flat recomposite at their
8382
+ painted positions (issue #1408), and at opted-in turn poses
8383
+ (`behind_seams.turn: true`) by pose endpoint contrast alone. At `setup`, it
8384
+ scans row and column runs whose combined A/B alpha is below 128/255, bracketed
8385
+ immediately by different unambiguous A/B owners (`1` and `2`), and compares
8386
+ the full setup render at each cell with the parts' flat recomposite
8387
+ (`flatComposite` of `parts.json` and `parts/*.png` over white in `rig.json`
8388
+ slot order, rendered onto the pair's native seam grid) when both are
8389
+ flattened source-over white (`[255, 255, 255]`). A cell is geometric when the
8390
+ behind set has positive surviving source-over contribution; it is raw
8391
+ (`raw_px`) when its straight rear RGB differs from both endpoint neighbours
8392
+ (`d[0] > 0` and `d[1] > 0`) and the full setup render's white-flattened RGB
8393
+ differs from the white-flattened parts' recomposite (`dRecomposite > 0`); it
8394
+ counts (`px`) when both endpoint distances and the recomposite distance
8395
+ strictly exceed the effective threshold T (`d[0] > T`, `d[1] > T` and
8396
+ `dRecomposite > T`, in max-channel distance). A cell outside the recomposite's
8397
+ canvas (`alpha === 0` on the rendered recomposite plate) is not excused
8398
+ (`dRecomposite = Infinity`). Equal-colour antialias ramps count zero contrast,
8399
+ and later opaque art — or any intervening or behind part already visible in
8400
+ the parts' recomposite at their painted positions — contributes zero
8401
+ recomposite difference. On a corridor whose endpoint owner is ambiguous
8402
+ (`0` or `3`) at setup, cells within T of the recomposite (`dRecomposite <= T`)
8403
+ are left out of the unread population, without adding their endpoints to
8404
+ `boundary_cells` (`support`), so a corridor whose cells all match the
8405
+ recomposite within T is not unread; elsewhere they stay geometric (`geometric_px`
8406
+ and `samples`) but cannot count (a threshold at or above the cell's distance
8407
+ to the recomposite removes the cell from the reading altogether; the
8408
+ threshold decides what could count; it does not clear a cell that could, and
8409
+ `allowance` never clears an unread cell). An ambiguous endpoint makes a
8410
+ corridor unread only when at least one of its cells differs from the
8411
+ recomposite by more than T (`dRecomposite > T`). Other readable corridors on
8412
+ that frame retain their measured cells. A counted total above allowance stays
8413
+ FAIL even when another corridor is unread; an unread population cannot turn a
8414
+ measured failure into SKIP. With unread corridors and no measured excess,
8415
+ standing is SKIP, never PASS. Without `--parts` (`parts.json` and
8416
+ `parts/*.png`), setup standing is `SKIP` with
8417
+ `reason: "no --parts manifest was supplied; setup standing compares the setup render with the parts' flat recomposite"`,
8418
+ records a `setup` `unmeasured[]` row, and with an authored T emits
8419
+ [`CHECK_BEHIND_PART_SEAMS_UNMEASURED`](#CHECK_BEHIND_PART_SEAMS_UNMEASURED).
8420
+ On idle frames, `standing` is never measured: where a frame's `motion_opened`
8421
+ is read, `frames[].standing` reports `SKIP` with
8422
+ `reason: "not applicable: motion_opened reads the pair"`, zero counts,
8423
+ `box: null`, `samples: []`, no unread fields, and no idle standing problem or
8424
+ unmeasured row; where a frame's `motion_opened` cannot be read,
8425
+ `frames[].standing` reports `SKIP` with
8426
+ `reason: "idle standing is not measured: idle frames have no recomposite oracle, and the pair's idle reading is motion_opened"`
8427
+ while `motion_opened` records its named `HOLE` (and `pairs[].standing`
8428
+ carries the pair's idle summary reason). This bracketed-run definition does
8429
+ not certify curved or diagonal openings.
8430
+
8431
+ Setup standing in `BEHIND_PART_SEAMS` measures whether the rig's setup pose
8432
+ places a selected front pair A/B away from where its parts were painted in
8433
+ `parts.json` and `parts/*.png`, opening a gap over `behind_slots` that was not
8434
+ in the parts' flat recomposite (`8-apart`). Because its oracle is the parts'
8435
+ flat recomposite at their painted positions rather than the `--source`
8436
+ painting, an intervening third part painted between A and B (`7a`), a distant
8437
+ foot or notch across an open silhouette (`7b`), or a half-alpha rear fringe
8438
+ already present in the parts' flat stack reads zero at setup without needing
8439
+ `--source`, and without failing on differences between the parts and the
8440
+ original painting. Fidelity to the `--source` painting is not setup standing's
8441
+ job: fidelity to the painting is [`SETUP_MATCHES_PAINTING`](#CHECK_SETUP_MATCHES_PAINTING)'s
8442
+ and the `RECOMPOSITE_HOLES` / `parts.json` `recomposite` record's job.
8393
8443
 
8394
8444
  Both readings use core's public `seamGridOf` from `@rig-c/core/seam` and its
8395
8445
  official raster traversal. The full
@@ -8398,31 +8448,45 @@ constraints, physics, environment and viewport; the hidden render does not
8398
8448
  combine `--hide` with `--seam`. A viewport match alone is not a seam-grid proof.
8399
8449
  Cells join by world centre and cell side, never by nearest image pixel.
8400
8450
 
8401
- The report keeps `setup` separate from idle. Setup standing is measured in its
8402
- own right; setup motion-opened is zero by definition only if setup was read.
8403
- Standing is measured independently on every idle frame, including the trough.
8404
- Rows name the pair, declaration provenance, animation, `behind_slots`, grid and
8405
- sampled/read/unmeasured frame counts. Independent `motion_opened` and `standing`
8406
- readings retain per-frame `index`, `time`, `px`, `cell`, `box`, `max_px`, the
8407
- earliest worst hit and contiguous spans. `max_run` is temporal, in frames and
8408
- seconds; `max_spatial_run_cells` is the longest counted horizontal/vertical run,
8409
- with world length equal to cells times cell side. Counts named `px` are seam
8410
- cells; rig-pixel area is count times cell side squared. Geometric rear-visible,
8411
- raw contrast and threshold-filtered counts remain distinct. Overlapping pair
8412
- counts are not a unique whole-rig area.
8451
+ The report keeps `setup` separate from idle. Setup standing lives at
8452
+ `pairs[].setup.standing` (`object: "pair \"<A>|<B>\" setup standing"` on
8453
+ excess); setup motion-opened is zero by definition only if setup was read.
8454
+ `pairs[].standing` describes the idle summary only (`status: "SKIP"` with the
8455
+ applicable idle `reason`), without folding setup into it, so a pair with setup
8456
+ `PASS 0`, `motion_opened` `PASS`, and not-applicable idle standing reads
8457
+ `PASS`. Rows name the pair, declaration provenance, animation, `behind_slots`,
8458
+ grid and sampled/read/unmeasured frame counts. The `motion_opened` reading
8459
+ retains per-frame hits (`index`, `time`, `px`, `cell`, `area`, `box`),
8460
+ `max_px`, the earliest worst hit and contiguous `spans`; the idle `standing`
8461
+ summary (`pairs[].standing`) is always `SKIP` with its `reason`, zero counts,
8462
+ `worst: null`, and empty `frames` and `spans` (while setup standing at
8463
+ `pairs[].setup.standing` and turn standing poses retain their measured counts,
8464
+ `box` and `samples`).
8465
+ `max_run` is temporal, in frames and seconds; `max_spatial_run_cells` is the
8466
+ longest counted horizontal/vertical run, with world length equal to cells times
8467
+ cell side. Counts named `px` are seam cells; rig-pixel area is count times cell
8468
+ side squared. Geometric rear-visible, raw contrast and threshold-filtered
8469
+ counts remain distinct. Overlapping pair counts are not a unique whole-rig
8470
+ area.
8413
8471
 
8414
8472
  Issue #1325 adds optional unread-corridor evidence to the per-frame `standing`
8415
- record, both at `BEHIND_PART_SEAMS.pairs[].setup.standing` and at
8416
- `BEHIND_PART_SEAMS.pairs[].frames[].standing`. The fields below are relative to
8417
- that record. They describe bracketed low-alpha runs with an endpoint owner of
8418
- 0 or 3; they do not infer an owner or count those runs as measured contrast.
8419
- The reported cells are the run's interior, excluding its endpoints, whether
8420
- or not rear colour would qualify against T. A cell can be unread on one axis
8421
- and readable on the other; unread evidence does not remove a measured hit.
8473
+ record at `BEHIND_PART_SEAMS.pairs[].setup.standing` (and on turn standing
8474
+ frames when `behind_seams.turn: true`; idle `frames[].standing` is never
8475
+ measured). The fields below are relative to that record. They describe
8476
+ bracketed low-alpha runs with an endpoint owner of 0 or 3 that have at least
8477
+ one cell differing from the parts' recomposite by more than T at setup
8478
+ (`dRecomposite > T`); they do not infer an owner or count those runs as
8479
+ measured contrast. At setup, `unread_corridors[].cells`, `cell_count` and
8480
+ `unread_cells` leave out cells within T of the recomposite (`dRecomposite <= T`)
8481
+ and report the remaining interior cells of the run, excluding its endpoints,
8482
+ whether or not rear colour would qualify against endpoint contrast T (on turn
8483
+ poses, which have no recomposite oracle, all interior cells of the run are
8484
+ reported). A cell can be unread on one axis and readable on the other; unread
8485
+ evidence does not remove a measured hit.
8422
8486
 
8423
8487
  | Field | Contract |
8424
8488
  | --- | --- |
8425
- | `unread_cells` | Optional positive integer: the number of distinct native grid cells in all unread corridors of this frame. Cross-axis intersections count once; this is not a sum of `cell_count` values or a measured defect count. |
8489
+ | `unread_cells` | Optional positive integer: the number of distinct native grid cells in all unread corridors of this frame (at setup, leaving out cells within T of the parts' recomposite). Cross-axis intersections count once; this is not a sum of `cell_count` values or a measured defect count. |
8426
8490
  | `unread_corridors` | Optional nonempty array. Horizontal corridors come first, in top-to-bottom row and left-to-right run order; vertical corridors follow, in left-to-right column and top-to-bottom run order. |
8427
8491
  | `unread_corridors[].axis` | `horizontal` for a row run, `vertical` for a column run. |
8428
8492
  | `unread_corridors[].endpoints` | Two numeric tuples in spatial order: left/right for horizontal, top/bottom for vertical. They are not reordered into A/B ownership order. Each tuple is `[grid_x, grid_y, world_x, world_y, owner]`. |
@@ -8431,8 +8495,8 @@ and readable on the other; unread evidence does not remove a measured hit.
8431
8495
  | `unread_corridors[].endpoints[][2]` | World-space x coordinate of the endpoint cell centre. |
8432
8496
  | `unread_corridors[].endpoints[][3]` | World-space y coordinate of the endpoint cell centre, y up. |
8433
8497
  | `unread_corridors[].endpoints[][4]` | Observed half-alpha owner code: 0 means neither A nor B reaches 128/255; 1 means only A does; 2 means only B does; 3 means both do. A and B are the selected pair's named members; 0 and 3 are not resolved by guessing. |
8434
- | `unread_corridors[].cells` | Interior native-cell centres as numeric `[world_x, world_y]` tuples, y up, left-to-right or top-to-bottom along the run. A centre may occur in multiple corridors. |
8435
- | `unread_corridors[].cell_count` | The number of interior cells in this corridor, exactly `cells.length`. |
8498
+ | `unread_corridors[].cells` | Interior native-cell centres as numeric `[world_x, world_y]` tuples, y up, left-to-right or top-to-bottom along the run, leaving out cells within T of the parts' recomposite at setup (on turn poses, all interior cells of the run). A centre may occur in multiple corridors. |
8499
+ | `unread_corridors[].cell_count` | The number of reported interior cells in this corridor (at setup, leaving out cells within T of the recomposite), exactly `cells.length`. |
8436
8500
  | `unread_corridors[].row_scope` | `pair`; the corridor observes the selected front pair, not an individual rear slot. |
8437
8501
  | `unread_corridors[].row_kind` | `evidence`, including when the required check fails. |
8438
8502
  | `unread_corridors[].row_subjects` | The two selected part names in producer A/B order. |
@@ -8445,19 +8509,20 @@ unmeasured handling; absence of these optional fields alone does not prove a
8445
8509
  fully read frame.
8446
8510
 
8447
8511
  `sampled_frames`, `read_frames` and `unmeasured_frames` count idle frames only.
8448
- A frame enters `read_frames` only when both halves are available and no standing
8449
- corridor is unread. A partially unread frame remains in `unmeasured_frames`
8450
- even when its measured standing cells already make it FAIL. Setup is reported
8451
- separately and is not counted as an idle frame.
8512
+ An idle frame enters `read_frames` when `motion_opened` is read on that frame;
8513
+ when `motion_opened` is unavailable on that frame, the frame enters
8514
+ `unmeasured_frames` (idle `standing` is never measured). Setup is reported
8515
+ separately at `pairs[].setup` and is not counted as an idle frame.
8452
8516
 
8453
8517
  A measured count above the effective allowance is
8454
8518
  [`CHECK_BEHIND_PART_SEAMS`](#CHECK_BEHIND_PART_SEAMS). A pair without an
8455
8519
  effective T reports a nonrequired SKIP and HOLE; missing T alone emits no
8456
8520
  `CHECK_BEHIND_PART_SEAMS_UNMEASURED` problem and cannot establish a behind-part
8457
- PASS. With authored T, missing behind slots, idle, setup, motion support,
8458
- boundary population or verified render/material evidence cannot establish PASS.
8459
- An unavailable reading is SKIP; a partially unread standing reading retains
8460
- any measured FAIL as described above. An unread population reports a HOLE and emits
8521
+ PASS. With authored T, missing behind slots, `--parts` manifest for setup
8522
+ standing's recomposite, idle, setup, motion support, boundary population or
8523
+ verified render/material evidence cannot establish PASS. An unavailable reading
8524
+ is SKIP; a partially unread setup (or turn) standing reading retains any
8525
+ measured FAIL as described above. An unread population reports a HOLE and emits
8461
8526
  [`CHECK_BEHIND_PART_SEAMS_UNMEASURED`](#CHECK_BEHIND_PART_SEAMS_UNMEASURED),
8462
8527
  making the combined line FAIL. Existing hard render and sidecar failures
8463
8528
  remain named refusals. Setup-only or partial readings cannot establish the
@@ -9539,18 +9604,18 @@ Internal `SeamSupport.drawings` never enters check JSON. Named requirement
9539
9604
  | `ANIMATIONS_DO_NOT_FOLD.declared_not_folding` | `ANIMATIONS_DO_NOT_FOLD.declared_not_folding` | part when the supplied mapping resolves a piece; otherwise rig | finding | resolved piece for e.slot; otherwise [] | [check.ts:3697](../src/check.ts#L3697) |
9540
9605
  | `ANIMATIONS_DO_NOT_FOLD.folding` | `ANIMATIONS_DO_NOT_FOLD.folding` | part when the supplied mapping resolves a piece; otherwise rig | finding when entry === undefined; otherwise evidence | resolved piece for slot; otherwise [] | [check.ts:3659](../src/check.ts#L3659) |
9541
9606
  | `ART_JOINT_DISTANCE.joints` | `ART_JOINT_DISTANCE.joints` | 'rig' | finding when status === 'FAIL'; otherwise evidence | [] | [artjoints.ts:86](../src/artjoints.ts#L86) |
9542
- | `BEHIND_PART_SEAMS.contributors` | `BEHIND_PART_SEAMS.turn.pairs[].frames[].standing.samples[].contributors`; `BEHIND_PART_SEAMS.turn.pairs[].frames[].motion_opened.samples[].contributors`; `BEHIND_PART_SEAMS.pairs[].setup.motion_opened.samples[].contributors`; `BEHIND_PART_SEAMS.pairs[].setup.standing.samples[].contributors`; `BEHIND_PART_SEAMS.pairs[].frames[].motion_opened.samples[].contributors`; `BEHIND_PART_SEAMS.pairs[].frames[].standing.samples[].contributors` | 'pair' | evidence | [pair.a, pair.b] | [behindseams.ts:396](../src/behindseams.ts#L396) |
9543
- | `BEHIND_PART_SEAMS.hits` | `BEHIND_PART_SEAMS.pairs[].motion_opened.frames`; `BEHIND_PART_SEAMS.pairs[].standing.frames`; `BEHIND_PART_SEAMS.pairs[].motion_opened.worst`; `BEHIND_PART_SEAMS.pairs[].standing.worst` | 'pair' | finding when r.px > allowance; otherwise evidence | parts | [behindseams.ts:456](../src/behindseams.ts#L456) |
9544
- | `BEHIND_PART_SEAMS.pairs` | `BEHIND_PART_SEAMS.pairs` | 'pair' | finding when failed; otherwise evidence | parts | [behindseams.ts:533](../src/behindseams.ts#L533) |
9607
+ | `BEHIND_PART_SEAMS.contributors` | `BEHIND_PART_SEAMS.turn.pairs[].frames[].standing.samples[].contributors`; `BEHIND_PART_SEAMS.turn.pairs[].frames[].motion_opened.samples[].contributors`; `BEHIND_PART_SEAMS.pairs[].setup.motion_opened.samples[].contributors`; `BEHIND_PART_SEAMS.pairs[].setup.standing.samples[].contributors`; `BEHIND_PART_SEAMS.pairs[].frames[].motion_opened.samples[].contributors`; `BEHIND_PART_SEAMS.pairs[].frames[].standing.samples[].contributors` | 'pair' | evidence | [pair.a, pair.b] | [behindseams.ts:520](../src/behindseams.ts#L520) |
9608
+ | `BEHIND_PART_SEAMS.hits` | `BEHIND_PART_SEAMS.pairs[].motion_opened.frames`; `BEHIND_PART_SEAMS.pairs[].standing.frames`; `BEHIND_PART_SEAMS.pairs[].motion_opened.worst`; `BEHIND_PART_SEAMS.pairs[].standing.worst` | 'pair' | finding when r.px > allowance; otherwise evidence | parts | [behindseams.ts:597](../src/behindseams.ts#L597) |
9609
+ | `BEHIND_PART_SEAMS.pairs` | `BEHIND_PART_SEAMS.pairs` | 'pair' | finding when failed; otherwise evidence | parts | [behindseams.ts:682](../src/behindseams.ts#L682) |
9545
9610
  | `BEHIND_PART_SEAMS.pairs[].frames` | `BEHIND_PART_SEAMS.pairs[].frames` | | | | |
9546
9611
  | `BEHIND_PART_SEAMS.pairs[].setup` | `BEHIND_PART_SEAMS.pairs[].setup` | | | | |
9547
- | `BEHIND_PART_SEAMS.samples` | `BEHIND_PART_SEAMS.turn.pairs[].frames[].standing.samples`; `BEHIND_PART_SEAMS.turn.pairs[].frames[].motion_opened.samples`; `BEHIND_PART_SEAMS.pairs[].setup.motion_opened.samples`; `BEHIND_PART_SEAMS.pairs[].setup.standing.samples`; `BEHIND_PART_SEAMS.pairs[].frames[].motion_opened.samples`; `BEHIND_PART_SEAMS.pairs[].frames[].standing.samples` | 'pair' | evidence | [pair.a, pair.b] | [behindseams.ts:395](../src/behindseams.ts#L395) |
9548
- | `BEHIND_PART_SEAMS.spans` | `BEHIND_PART_SEAMS.pairs[].motion_opened.spans`; `BEHIND_PART_SEAMS.pairs[].standing.spans` | 'pair' | evidence | parts | [behindseams.ts:464](../src/behindseams.ts#L464) |
9549
- | `BEHIND_PART_SEAMS.turn.pairs` | `BEHIND_PART_SEAMS.turn.pairs` | 'pair' | finding when required; otherwise evidence; finding when motion.status === 'FAIL' &#124;&#124; standing.status === 'FAIL' &#124;&#124; threshold !== null && read !== turn.poses.length; otherwise evidence | [pair.a, pair.b]; parts | [behindseams.ts:563](../src/behindseams.ts#L563), [behindseams.ts:605](../src/behindseams.ts#L605) |
9612
+ | `BEHIND_PART_SEAMS.samples` | `BEHIND_PART_SEAMS.turn.pairs[].frames[].standing.samples`; `BEHIND_PART_SEAMS.turn.pairs[].frames[].motion_opened.samples`; `BEHIND_PART_SEAMS.pairs[].setup.motion_opened.samples`; `BEHIND_PART_SEAMS.pairs[].setup.standing.samples`; `BEHIND_PART_SEAMS.pairs[].frames[].motion_opened.samples`; `BEHIND_PART_SEAMS.pairs[].frames[].standing.samples` | 'pair' | evidence | [pair.a, pair.b] | [behindseams.ts:519](../src/behindseams.ts#L519) |
9613
+ | `BEHIND_PART_SEAMS.spans` | `BEHIND_PART_SEAMS.pairs[].motion_opened.spans`; `BEHIND_PART_SEAMS.pairs[].standing.spans` | 'pair' | evidence | parts | [behindseams.ts:605](../src/behindseams.ts#L605) |
9614
+ | `BEHIND_PART_SEAMS.turn.pairs` | `BEHIND_PART_SEAMS.turn.pairs` | 'pair' | finding when required; otherwise evidence; finding when motion.status === 'FAIL' &#124;&#124; standing.status === 'FAIL' &#124;&#124; threshold !== null && read !== turn.poses.length; otherwise evidence | [pair.a, pair.b]; parts | [behindseams.ts:712](../src/behindseams.ts#L712), [behindseams.ts:754](../src/behindseams.ts#L754) |
9550
9615
  | `BEHIND_PART_SEAMS.turn.pairs[].frames` | `BEHIND_PART_SEAMS.turn.pairs[].frames` | | | | |
9551
- | `BEHIND_PART_SEAMS.turn.unmeasured` | `BEHIND_PART_SEAMS.turn.unmeasured` | pair === null ? 'rig' : 'pair' | finding when mandatory; otherwise evidence | pair === null ? [] : [pair.a, pair.b] | [behindseams.ts:555](../src/behindseams.ts#L555) |
9552
- | `BEHIND_PART_SEAMS.unmeasured` | `BEHIND_PART_SEAMS.unmeasured` | pair === null ? 'rig' : 'pair'; 'rig' | finding when required; otherwise evidence; finding | pair === null ? [] : [pair.a, pair.b]; [] | [behindseams.ts:477](../src/behindseams.ts#L477), [behindseams.ts:806](../src/behindseams.ts#L806), [behindseams.ts:838](../src/behindseams.ts#L838) |
9553
- | `BEHIND_PART_SEAMS.unread_corridors` | `BEHIND_PART_SEAMS.turn.pairs[].frames[].standing.unread_corridors`; `BEHIND_PART_SEAMS.pairs[].setup.standing.unread_corridors`; `BEHIND_PART_SEAMS.pairs[].frames[].standing.unread_corridors` | 'pair' | evidence | [pair.a, pair.b] | [behindseams.ts:319](../src/behindseams.ts#L319) |
9616
+ | `BEHIND_PART_SEAMS.turn.unmeasured` | `BEHIND_PART_SEAMS.turn.unmeasured` | pair === null ? 'rig' : 'pair' | finding when mandatory; otherwise evidence | pair === null ? [] : [pair.a, pair.b] | [behindseams.ts:704](../src/behindseams.ts#L704) |
9617
+ | `BEHIND_PART_SEAMS.unmeasured` | `BEHIND_PART_SEAMS.unmeasured` | pair === null ? 'rig' : 'pair'; 'rig' | finding when required; otherwise evidence; finding | pair === null ? [] : [pair.a, pair.b]; [] | [behindseams.ts:618](../src/behindseams.ts#L618), [behindseams.ts:955](../src/behindseams.ts#L955), [behindseams.ts:1003](../src/behindseams.ts#L1003) |
9618
+ | `BEHIND_PART_SEAMS.unread_corridors` | `BEHIND_PART_SEAMS.turn.pairs[].frames[].standing.unread_corridors`; `BEHIND_PART_SEAMS.pairs[].setup.standing.unread_corridors`; `BEHIND_PART_SEAMS.pairs[].frames[].standing.unread_corridors` | 'pair' | evidence | [pair.a, pair.b] | [behindseams.ts:453](../src/behindseams.ts#L453) |
9554
9619
  | `BOUNDARY_COLOUR_STEP.over` | `BOUNDARY_COLOUR_STEP.over` | 'pair' | finding | r.parts | [boundarycolour.ts:221](../src/boundarycolour.ts#L221) |
9555
9620
  | `BOUNDARY_COLOUR_STEP.unmeasured` | `BOUNDARY_COLOUR_STEP.unmeasured` | part when the supplied mapping resolves a piece; otherwise rig | evidence | resolved piece for r.slot; otherwise [] | [boundarycolour.ts:222](../src/boundarycolour.ts#L222) |
9556
9621
  | `CLOTH_SETTLES.rows` | `CLOTH_SETTLES.rows` | 'rig' | finding when speeds.length > 0 && s < speeds.length; otherwise evidence | [] | [check.ts:6144](../src/check.ts#L6144) |
@@ -9574,21 +9639,21 @@ Internal `SeamSupport.drawings` never enters check JSON. Named requirement
9574
9639
  | `SEAM_OVER_RANGE.joints[].poses` | `SEAM_OVER_RANGE.joints[].poses` | 'part' | finding when fail; otherwise evidence | [j.part] | [check.ts:4558](../src/check.ts#L4558) |
9575
9640
  | `SETUP_MATCHES_PAINTING.regions` | `SETUP_MATCHES_PAINTING.regions` | 'rig' | finding when status === 'FAIL'; otherwise evidence | [] | [setuppainting.ts:175](../src/setuppainting.ts#L175) |
9576
9641
  | `SETUP_MATCHES_PAINTING.regions[].slots` | `SETUP_MATCHES_PAINTING.regions[].slots` | part when the supplied mapping resolves a piece; otherwise rig | evidence | resolved piece for slot; otherwise [] | [setuppainting.ts:176](../src/setuppainting.ts#L176) |
9577
- | `STILL_REGIONS_DARK.*.crossing` | `STILL_REGIONS_DARK.*.crossing` | part when the supplied mapping resolves a piece; otherwise rig | finding | resolved piece for sl.name; otherwise [] | [check.ts:9286](../src/check.ts#L9286) |
9578
- | `STILL_REGIONS_DARK.*.still_slots` | `STILL_REGIONS_DARK.*.still_slots` | part when the supplied mapping resolves a piece; otherwise rig | evidence; finding when r.max > tolerance; otherwise evidence | resolved piece for slot; otherwise [] | [check.ts:9272](../src/check.ts#L9272), [check.ts:9277](../src/check.ts#L9277) |
9642
+ | `STILL_REGIONS_DARK.*.crossing` | `STILL_REGIONS_DARK.*.crossing` | part when the supplied mapping resolves a piece; otherwise rig | finding | resolved piece for sl.name; otherwise [] | [check.ts:9288](../src/check.ts#L9288) |
9643
+ | `STILL_REGIONS_DARK.*.still_slots` | `STILL_REGIONS_DARK.*.still_slots` | part when the supplied mapping resolves a piece; otherwise rig | evidence; finding when r.max > tolerance; otherwise evidence | resolved piece for slot; otherwise [] | [check.ts:9274](../src/check.ts#L9274), [check.ts:9279](../src/check.ts#L9279) |
9579
9644
  | `STRESS_OFF_CHAIN.not_read` | `STRESS_OFF_CHAIN.not_read` | 'part' | evidence | [r.part] | [check.ts:4118](../src/check.ts#L4118) |
9580
9645
  | `STRESS_OFF_CHAIN.per_part` | `STRESS_OFF_CHAIN.per_part` | 'part' | finding when poses.some(p => typeof p.reading === 'number' && p.reading > STRESS_RIGID); otherwise evidence | [r.part] | [check.ts:4106](../src/check.ts#L4106) |
9581
9646
  | `STRESS_OFF_CHAIN.per_part[].off_chain` | `STRESS_OFF_CHAIN.per_part[].off_chain` | 'part' | evidence | [r.part] | [check.ts:4106](../src/check.ts#L4106) |
9582
9647
  | `STRESS_OFF_CHAIN.per_part[].poses` | `STRESS_OFF_CHAIN.per_part[].poses` | 'part' | evidence; finding when shown > STRESS_RIGID; otherwise evidence | [r.part] | [check.ts:4074](../src/check.ts#L4074), [check.ts:4092](../src/check.ts#L4092) |
9583
- | `TEXTURE_STRETCH.per_mesh` | `TEXTURE_STRETCH.per_mesh` | part when the supplied mapping resolves a piece; otherwise rig | evidence; finding when severity > TEXTURE_STRETCH_CEILING; otherwise evidence | resolved piece for m.slot; otherwise [] | [check.ts:9936](../src/check.ts#L9936), [check.ts:9946](../src/check.ts#L9946) |
9584
- | `TIP_OVER_ROOT.parts` | `TIP_OVER_ROOT.parts` | 'part' | evidence; finding when !ok && !(!rigid && hanging.onLink && Math.max(c.root, c.tip) < TIP_TRAVEL_FLOOR); otherwise evidence | [p.name] | [check.ts:8661](../src/check.ts#L8661), [check.ts:8666](../src/check.ts#L8666), [check.ts:8687](../src/check.ts#L8687), [check.ts:8698](../src/check.ts#L8698) |
9648
+ | `TEXTURE_STRETCH.per_mesh` | `TEXTURE_STRETCH.per_mesh` | part when the supplied mapping resolves a piece; otherwise rig | evidence; finding when severity > TEXTURE_STRETCH_CEILING; otherwise evidence | resolved piece for m.slot; otherwise [] | [check.ts:9938](../src/check.ts#L9938), [check.ts:9948](../src/check.ts#L9948) |
9649
+ | `TIP_OVER_ROOT.parts` | `TIP_OVER_ROOT.parts` | 'part' | evidence; finding when !ok && !(!rigid && hanging.onLink && Math.max(c.root, c.tip) < TIP_TRAVEL_FLOOR); otherwise evidence | [p.name] | [check.ts:8663](../src/check.ts#L8663), [check.ts:8668](../src/check.ts#L8668), [check.ts:8689](../src/check.ts#L8689), [check.ts:8700](../src/check.ts#L8700) |
9585
9650
  | `WIND_BAND.pairs` | `WIND_BAND.pairs` | 'pair' | finding when !holdsAll; otherwise evidence | [p.a, p.b] | [check.ts:6648](../src/check.ts#L6648) |
9586
9651
  | `WIND_BAND.pairs[].steps` | `WIND_BAND.pairs[].steps` | 'pair' | finding when !s.holds; otherwise evidence | [p.a, p.b] | [check.ts:6659](../src/check.ts#L6659) |
9587
9652
  | `figure_openings.openings` | `figure_openings.openings` | 'pair' | finding | [ps.under, ps.above] | [check.ts:5965](../src/check.ts#L5965) |
9588
- | `loop_physics` | `loop_physics` | 'rig' | evidence | [] | [check.ts:7702](../src/check.ts#L7702) |
9589
- | `requirements.lines.* (bone)` | `requirements.lines.*` | 'rig' | finding when line.status === 'FAIL'; otherwise evidence | [] | [check.ts:8029](../src/check.ts#L8029) |
9590
- | `requirements.lines.* (seam)` | `requirements.lines.*` | 'pair' | finding when line.status === 'FAIL'; otherwise evidence | [r.part, r.neighbour] | [check.ts:8029](../src/check.ts#L8029) |
9591
- | `requirements.lines.* (stretch)` | `requirements.lines.*` | part when the supplied mapping resolves a piece; otherwise rig | finding when line.status === 'FAIL'; otherwise evidence | resolved piece for r.slot; otherwise [] | [check.ts:8029](../src/check.ts#L8029) |
9653
+ | `loop_physics` | `loop_physics` | 'rig' | evidence | [] | [check.ts:7704](../src/check.ts#L7704) |
9654
+ | `requirements.lines.* (bone)` | `requirements.lines.*` | 'rig' | finding when line.status === 'FAIL'; otherwise evidence | [] | [check.ts:8031](../src/check.ts#L8031) |
9655
+ | `requirements.lines.* (seam)` | `requirements.lines.*` | 'pair' | finding when line.status === 'FAIL'; otherwise evidence | [r.part, r.neighbour] | [check.ts:8031](../src/check.ts#L8031) |
9656
+ | `requirements.lines.* (stretch)` | `requirements.lines.*` | part when the supplied mapping resolves a piece; otherwise rig | finding when line.status === 'FAIL'; otherwise evidence | resolved piece for r.slot; otherwise [] | [check.ts:8031](../src/check.ts#L8031) |
9592
9657
  | `seam_cells.frames` | `frames` | 'pair' | evidence | [p.a, p.b] | [check.ts:4849](../src/check.ts#L4849) |
9593
9658
  | `seam_cells.frames[].cells` | `frames[].cells` | part when the supplied mapping resolves a piece; otherwise rig | evidence | resolved piece for cell.setupTop ?? ''; otherwise [] | [check.ts:4809](../src/check.ts#L4809) |
9594
9659
  | `seam_pairs` | `seam_pairs`; `seam_scope.whole_pairs`; `sets.*.seam_pairs`; `sets.*.seam_scope.whole_pairs` | subjects.length === 0 ? 'rig' : subjects.length === 1 ? 'part' : 'pair' | evidence | subjects | [check.ts:2548](../src/check.ts#L2548) |
package/docs/STABILITY.md CHANGED
@@ -1575,19 +1575,67 @@ default, and a pair without either a rig or pair T reports SKIP and a HOLE,
1575
1575
  never PASS. Allowance is a nonnegative safe integer, defaulting to 0 by the
1576
1576
  explicit design ruling, with optional per-pair override for both halves.
1577
1577
 
1578
- Declared readings independently measure motion-opened rear visibility and
1579
- standing contrasting rear visibility on core's official seam grid, at setup
1580
- and every idle frame. There is no WARN mode, one-cell floor, rest mask or
1581
- subtraction of setup-visible cells. `BEHIND_PART_SEAMS` keeps `setup`,
1582
- `motion_opened` and `standing` separate, names the selected pair and provenance,
1583
- per-frame `behind_slots`, grid and sampled/read/unmeasured counts, and reports
1584
- per-frame hits, worst counts, temporal spans and spatial runs. Exceeding the
1585
- allowance uses `CHECK_BEHIND_PART_SEAMS`; a mandatory unread population uses
1586
- `CHECK_BEHIND_PART_SEAMS_UNMEASURED`. Missing behind slots, idle, setup,
1587
- motion support, boundary population or verified render evidence is a HOLE,
1588
- not a zero PASS. Existing render/sidecar refusals remain refusals. The standing
1578
+ Declared readings independently measure motion-opened rear visibility on every
1579
+ idle frame and standing contrasting rear visibility at setup (against the
1580
+ parts' flat recomposite at their painted positions, issue #1408) on core's
1581
+ official seam grid. There is no WARN mode, one-cell floor, rest mask or
1582
+ subtraction of setup-visible cells. At setup, `standing` compares the full setup
1583
+ render (`rasters.full`) with the parts' flat recomposite (`flatComposite` of
1584
+ `parts.json` and `parts/*.png` over white in `rig.json` slot order, rendered
1585
+ onto the pair's native seam grid), both flattened source-over white
1586
+ (`[255, 255, 255]`), by max-channel distance: a bracketed rear-visible cell is
1587
+ raw (`raw_px`) when `d[0] > 0`, `d[1] > 0` and `dRecomposite > 0`, and counts
1588
+ (`px`) when `d[0] > T`, `d[1] > T` and `dRecomposite > T` (a cell outside the
1589
+ recomposite's canvas has `dRecomposite = Infinity`). Setup standing catches a
1590
+ part that the rig places away from where it was painted; it does not measure
1591
+ fidelity to the `--source` painting (which is `SETUP_MATCHES_PAINTING`'s and the
1592
+ `RECOMPOSITE_HOLES` / `parts.json` `recomposite` record's job), and `--source`
1593
+ is not required for `behind_seams`. A recomposite whose size differs from the
1594
+ stage is refused by name and never resampled; and through `check` the loader
1595
+ refuses the same mismatch earlier, as `CHECK_RIG_STAGE_IS_THE_CANVAS`. On a
1596
+ corridor whose endpoint owner is ambiguous (`0` or `3`) at setup, cells within T
1597
+ of the recomposite (`dRecomposite <= T`) are left out of the unread population,
1598
+ without adding their endpoints to `boundary_cells` (`support`); elsewhere they
1599
+ stay geometric (`geometric_px` and `samples`) but cannot count. An ambiguous
1600
+ endpoint makes a corridor unread only when at least one of its cells differs
1601
+ from the recomposite by more than T (`dRecomposite > T`), and `allowance` never
1602
+ clears an unread cell. Without `--parts` (`parts.json` and `parts/*.png`), setup
1603
+ standing is `SKIP` with
1604
+ `reason: "no --parts manifest was supplied; setup standing compares the setup render with the parts' flat recomposite"`,
1605
+ adds a `setup` `unmeasured[]` row, and with an authored T emits
1606
+ `CHECK_BEHIND_PART_SEAMS_UNMEASURED`. On idle frames, `standing` is never
1607
+ measured: `frames[].standing` and `pairs[].standing` carry `status: "SKIP"` with
1608
+ `reason: "not applicable: motion_opened reads the pair"` when `motion_opened`
1609
+ reads that frame (or pair), or
1610
+ `reason: "idle standing is not measured: idle frames have no recomposite oracle, and the pair's idle reading is motion_opened"`
1611
+ when `motion_opened` cannot read that frame (or pair). `pairs[].standing` is
1612
+ the idle summary only; setup status is at `pairs[].setup.standing` (never folded
1613
+ into `pairs[].standing`), and `BehindSeamsStanding` and `BehindSeamsReading`
1614
+ carry an optional `reason` string when `status` is `"SKIP"`. `BEHIND_PART_SEAMS`
1615
+ keeps `setup`, `motion_opened` and `standing` separate, names the selected pair
1616
+ and provenance, per-frame `behind_slots`, grid and sampled/read/unmeasured
1617
+ counts, and reports per-frame hits, worst counts, temporal spans and spatial
1618
+ runs. Exceeding the allowance uses `CHECK_BEHIND_PART_SEAMS`
1619
+ (`object: "pair \"<A>|<B>\" setup standing"` at setup); a mandatory unread
1620
+ population uses `CHECK_BEHIND_PART_SEAMS_UNMEASURED`. Missing behind slots,
1621
+ `--parts` manifest for setup standing's recomposite, idle, setup, motion
1622
+ support, boundary population or verified render evidence is a HOLE, not a zero
1623
+ PASS. Existing render/sidecar refusals remain refusals. The standing
1589
1624
  bracketed-run definition does not certify curved or diagonal openings.
1590
1625
 
1626
+ Per-cell samples are a bounded diagnostic sample; the counts are the
1627
+ measurement (issue #1403). Each measured `samples[]` list (setup standing, idle
1628
+ `motion_opened` on every idle frame, and turn `standing` and `motion_opened` on
1629
+ every turn pose; idle `standing` is never measured and its `samples[]` is always
1630
+ `[]`) holds at most 64 rows.
1631
+ A list that measured more holds 64 and gains `samples_omitted`, the number of
1632
+ rows left out; a list of 64 or fewer has no such field and is written as before.
1633
+ Standing keeps its 64 worst rows: counted first, then the larger of the two
1634
+ distances' minimum, then the earlier measured row. Motion-opened rows carry no
1635
+ distance and keep rows floor(j · n / 64), j = 0 … 63, of the n measured. Kept
1636
+ rows stay in measured order. Every count, `px`, `box`, hit, span, run and status
1637
+ is computed from all cells.
1638
+
1591
1639
  Issue #1323 adds `behind_seams.turn: true` as an explicit opt-in. It references
1592
1640
  existing emitted turn slider ranges, never a second range declaration. Without
1593
1641
  this key no turn rows are written and existing `check.json` bytes are unchanged.
@@ -1599,7 +1647,10 @@ min/max corner, deduplicated in that order. It records planned and observed dial
1599
1647
  spans: pose indices are sample identities, and time is 0 for every reset.
1600
1648
  Turn uses its own setup, rest geometry and transported stock seam evidence;
1601
1649
  idle stock and idle counts are unchanged. The same thresholds, allowances,
1602
- rear-set and unread rules apply. Optional unread-corridor evidence also applies
1650
+ rear-set and endpoint-ownership unread rules apply, without a recomposite
1651
+ comparison (turn poses have no per-pose recomposite oracle, so turn standing is
1652
+ judged by endpoint contrast alone and reports all interior cells of an unread
1653
+ corridor). Optional unread-corridor evidence also applies
1603
1654
  to turn standing rows. No declared dial persists turn SKIP and a named HOLE;
1604
1655
  an effective authored T makes that missing required reading a
1605
1656
  `CHECK_BEHIND_PART_SEAMS_UNMEASURED` failure. Legacy `turn.x` has no declared
@@ -1619,18 +1670,18 @@ An unavailable poser or source is a HOLE. Other animations, between-sample turns
1619
1670
  skins remain unmeasured.
1620
1671
 
1621
1672
  Issue #1325 adds the following optional evidence fields to
1622
- `BEHIND_PART_SEAMS.pairs[].setup.standing` and
1623
- `BEHIND_PART_SEAMS.pairs[].frames[].standing` only. Paths in the table are
1624
- relative to that standing record.
1673
+ `BEHIND_PART_SEAMS.pairs[].setup.standing` (and turn standing records when
1674
+ `behind_seams.turn: true`; idle `frames[].standing` is never measured). Paths in
1675
+ the table are relative to that standing record.
1625
1676
 
1626
1677
  | Field | Stable meaning |
1627
1678
  | --- | --- |
1628
- | `unread_cells` | Distinct native cells in this frame's unread corridors; cross-axis intersections count once. This is an unread population, not a contrast count. |
1629
- | `unread_corridors` | Nonempty array of ambiguous-endpoint runs, horizontal rows before vertical columns, each in native scan order. |
1679
+ | `unread_cells` | Distinct native cells in this frame's unread corridors (at setup, leaving out cells within T of the parts' recomposite); cross-axis intersections count once. This is an unread population, not a contrast count. |
1680
+ | `unread_corridors` | Nonempty array of ambiguous-endpoint runs (at setup, those with at least one cell where `dRecomposite > T`), horizontal rows before vertical columns, each in native scan order. |
1630
1681
  | `unread_corridors[].axis` | `horizontal` or `vertical`. |
1631
1682
  | `unread_corridors[].endpoints` | Two `[grid_x, grid_y, world_x, world_y, owner]` tuples in left/right or top/bottom order. Grid indices are zero-based, x right and y down; world coordinates are cell centres, y up. Owner codes are 0 for neither A/B reaching half alpha, 1 for A only, 2 for B only and 3 for both; no owner is inferred. |
1632
- | `unread_corridors[].cells` | Interior world-centre `[x, y]` tuples in run order, excluding endpoints. All corridor cells are reported, without a rear-colour or contrast filter; intersections may repeat across corridors. |
1633
- | `unread_corridors[].cell_count` | Exactly `cells.length` for that corridor. |
1683
+ | `unread_corridors[].cells` | Interior world-centre `[x, y]` tuples in run order, excluding endpoints. On a corridor whose endpoint owner is ambiguous (`0` or `3`) at setup, cells within T of the parts' recomposite (`dRecomposite <= T`) are left out of the unread population; the remaining interior cells (and on turn poses, all interior cells of the run) are reported without a rear-colour or endpoint-contrast filter; intersections may repeat across corridors. |
1684
+ | `unread_corridors[].cell_count` | The number of reported interior cells in that corridor (at setup, leaving out cells within T of the recomposite), exactly `cells.length`. |
1634
1685
  | `unread_corridors[].row_scope` | `pair`. |
1635
1686
  | `unread_corridors[].row_kind` | `evidence`. |
1636
1687
  | `unread_corridors[].row_subjects` | The two selected part names in producer A/B order. |
@@ -1639,13 +1690,16 @@ Both fields are omitted when no ambiguous corridor is found, preserving the
1639
1690
  bytes of fully read frames; no zero or empty-array placeholders are added.
1640
1691
  `motion_opened` gains no field. Missing optional unread-corridor evidence does
1641
1692
  not certify other unavailable readings or numeric colour underflow as read.
1642
- A corridor with an ambiguous endpoint owner remains unread without choosing
1643
- an A/B owner. Readable corridors retain their measured cells: a standing count
1644
- above allowance remains FAIL even with unread corridors, while unread
1645
- corridors without a measured excess leave standing SKIP. Required unread
1646
- evidence still makes the combined line FAIL. Idle `read_frames` excludes
1647
- partially unread frames, including those whose measured count already fails;
1648
- they remain in `unmeasured_frames`. Setup is counted separately.
1693
+ A corridor with an ambiguous endpoint owner (and, at setup, at least one cell
1694
+ with `dRecomposite > T`) remains unread without choosing an A/B owner. Readable
1695
+ corridors retain their measured cells: a standing count above allowance remains
1696
+ FAIL even with unread corridors, while unread corridors without a measured
1697
+ excess leave standing SKIP. Required unread evidence still makes the combined
1698
+ line FAIL. Idle `read_frames` counts idle frames where `motion_opened` is read
1699
+ (idle `standing` is never measured); on turn poses, `read_poses` excludes
1700
+ partially unread poses, including those whose measured count already fails,
1701
+ keeping them in `unmeasured_poses`. Setup is reported separately at
1702
+ `pairs[].setup`.
1649
1703
  A boundary-colour PASS does not prove seam closure. Without `behind_seams`,
1650
1704
  existing configurations remain optional and their checks retain their behavior;
1651
1705
  no behind-part PASS is claimed. See [Behind-part seams](AUTHORING.md#behind-part-seams-issue-1314).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rig-c/parts",
3
- "version": "2.47.0",
3
+ "version": "2.48.0",
4
4
  "description": "AI-authored 2D character parts from one anime painting and its See-through layer decomposition: measured parts, weighted-mesh rig specs, verified through rig-c before anything is written. A CLI for agents that cannot see the image.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,7 +1,7 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { createHash } from 'node:crypto';
3
3
  import { isAbsolute, join, relative, resolve } from 'node:path';
4
- import type { Plate } from '@rig-c/core/plate';
4
+ import { Plate } from '@rig-c/core/plate';
5
5
  import type { AttachmentRest, Frame } from '@rig-c/core/render-shared';
6
6
  import { seamGridOf, seamsOf, setupCellReader, type SeamCell, type SeamGrid } from '@rig-c/core/seam';
7
7
  import { DRAWN_ALPHA } from '@rig-c/core/passthrough';
@@ -14,6 +14,9 @@ export const BEHIND_SEAM_LINE = 'BEHIND_PART_SEAMS';
14
14
  export const UNDECLARED_BEHIND_SEAM_REASON = 'HOLE: no requirements.behind_seams declares an authored threshold T; not measured, never a pass';
15
15
  export const BEHIND_SEAM_CODE = 'CHECK_BEHIND_PART_SEAMS';
16
16
  export const BEHIND_SEAM_UNMEASURED_CODE = 'CHECK_BEHIND_PART_SEAMS_UNMEASURED';
17
+ export const NO_PARTS_SETUP_STANDING_REASON = "no --parts manifest was supplied; setup standing compares the setup render with the parts' flat recomposite";
18
+ export const IDLE_STANDING_MOTION_READ_REASON = 'not applicable: motion_opened reads the pair';
19
+ export const IDLE_STANDING_NO_ORACLE_REASON = "idle standing is not measured: idle frames have no recomposite oracle, and the pair's idle reading is motion_opened";
17
20
 
18
21
  export interface BehindSeams {
19
22
  /** Opt in to the rig's declared ranges; never supplies or guesses a range. */
@@ -38,7 +41,15 @@ export interface BehindSeamsFramesInput {
38
41
  pages: Map<string, Plate>;
39
42
  stock: readonly BehindSeamsStockPair[] | null;
40
43
  fps: number;
44
+ /** Setup recomposite frame rendered onto the pair's seam grid; absent or null when --parts was not supplied. */
45
+ recomposite?: Frame | null;
41
46
  turn?: BehindSeamsTurnInput;
47
+ /** Issue #1403 plant only: the samples[] cap; production never sets it ({@link BEHIND_SAMPLE_CAP}). */
48
+ sampleCap?: number;
49
+ /** Issue #1408 plant only: skip the setup recomposite comparison; production never sets it. */
50
+ plantSkipRecomposite?: true;
51
+ /** Issue #1408 plant only: measure standing on idle frames without an oracle; production never sets it. */
52
+ plantMeasureIdleStanding?: true;
42
53
  }
43
54
  export interface BehindSeamsTurnPose {
44
55
  name: string;
@@ -93,6 +104,8 @@ export interface BehindSeamsCount {
93
104
  box: [number, number, number, number] | null;
94
105
  max_spatial_run_cells: number;
95
106
  samples: BehindSeamsSample[];
107
+ /** Issue #1403: present only when the list held more than {@link BEHIND_SAMPLE_CAP} rows; the rows left out. */
108
+ samples_omitted?: number;
96
109
  }
97
110
  export type BehindSeamsEndpoint = [grid_x: number, grid_y: number, world_x: number, world_y: number, owner: number];
98
111
  export interface BehindSeamsUnreadCorridor {
@@ -103,6 +116,8 @@ export interface BehindSeamsUnreadCorridor {
103
116
  cell_count: number;
104
117
  }
105
118
  export interface BehindSeamsStanding extends BehindSeamsCount {
119
+ /** Present when standing is SKIP: at setup without --parts, or on every idle frame. */
120
+ reason?: string;
106
121
  /** Distinct grid cells across all unread corridors, including cross-axis intersections. */
107
122
  unread_cells?: number;
108
123
  /** Omitted, together with unread_cells, when every corridor's endpoints are readable. */
@@ -131,6 +146,8 @@ export interface BehindSeamsHit {
131
146
  }
132
147
  export interface BehindSeamsReading {
133
148
  status: 'PASS' | 'FAIL' | 'SKIP';
149
+ /** Present on the idle standing summary, which is never measured on idle frames. */
150
+ reason?: string;
134
151
  frames: BehindSeamsHit[];
135
152
  hit_frames: number;
136
153
  max_px: number;
@@ -173,6 +190,8 @@ export interface BehindSeamsInput {
173
190
  pairs: readonly MotionSeamPair[];
174
191
  stockDir: string | null;
175
192
  fps: number;
193
+ /** Flat recomposite of parts at their painted positions from --parts, or null/undefined when --parts was not supplied. */
194
+ recomposite?: { stage: { x: number; y: number; width: number; height: number }; raster: { width: number; height: number; data: ArrayLike<number> } } | null;
176
195
  unsupported?: string;
177
196
  turnBuild?: { build?: string; reason?: string };
178
197
  }
@@ -215,6 +234,60 @@ export function behindSeamsProblems(value: unknown, at: string): Problem[] {
215
234
  return problems;
216
235
  }
217
236
 
237
+ /**
238
+ * Issue #1403: the most `samples[]` rows one count writes. Per-cell samples are
239
+ * a bounded diagnostic sample; the counts are the measurement. Every count,
240
+ * `px`, `box`, hit, span, run and status is computed from all cells before the
241
+ * list is cut, and a list at or under the cap is written as it was.
242
+ */
243
+ export const BEHIND_SAMPLE_CAP = 64;
244
+
245
+ /** One standing candidate: its measured ordinal, cell, chosen distances, whether it qualified, and the smaller distance. */
246
+ interface StandingCandidate { ord: number; k: number; d: [number, number]; q: boolean; m: number }
247
+
248
+ /**
249
+ * Whether standing candidate `a` ranks worse than `b`. The gate counts a cell
250
+ * when both rear-to-front distances exceed the threshold (`qualifies`), so the
251
+ * smaller of the two is the margin the threshold is compared against: a counted
252
+ * cell ranks first, then the larger smaller-distance, then the earlier measured
253
+ * ordinal. No two candidates tie, so the kept set is one set.
254
+ */
255
+ export function standingWorse(a: Pick<StandingCandidate, 'ord' | 'q' | 'm'>, b: Pick<StandingCandidate, 'ord' | 'q' | 'm'>): boolean {
256
+ if (a.q !== b.q) return a.q;
257
+ if (a.m !== b.m) return a.m > b.m;
258
+ return a.ord < b.ord;
259
+ }
260
+
261
+ /**
262
+ * The {@link BEHIND_SAMPLE_CAP} worst standing candidates seen so far, without
263
+ * keeping the others: at most `cap` entries live at once.
264
+ */
265
+ export class WorstStanding {
266
+ readonly kept: StandingCandidate[] = [];
267
+ seen = 0;
268
+ constructor(readonly cap: number = BEHIND_SAMPLE_CAP) {}
269
+ offer(k: number, d: [number, number], q: boolean): void {
270
+ const c: StandingCandidate = { ord: this.seen++, k, d, q, m: d[0] < d[1] ? d[0] : d[1] };
271
+ if (this.kept.length < this.cap) { this.kept.push(c); return; }
272
+ let weakest = 0;
273
+ for (let i = 1; i < this.kept.length; i++) if (standingWorse(this.kept[weakest], this.kept[i])) weakest = i;
274
+ if (standingWorse(c, this.kept[weakest])) this.kept[weakest] = c;
275
+ }
276
+ /** The kept candidates in measured order. */
277
+ inOrder(): StandingCandidate[] { return [...this.kept].sort((x, y) => x.ord - y.ord); }
278
+ }
279
+
280
+ /**
281
+ * The positions kept from a list of `n` rows that carry no magnitude: all of
282
+ * them at or under `cap`, otherwise floor(j · n / cap) for j = 0 … cap − 1 —
283
+ * `cap` distinct, increasing positions spread across the list, the first row
284
+ * always among them.
285
+ */
286
+ export function evenlySpaced(n: number, cap: number = BEHIND_SAMPLE_CAP): number[] {
287
+ if (n <= cap) return Array.from({ length: n }, (_, i) => i);
288
+ return Array.from({ length: cap }, (_, j) => Math.floor((j * n) / cap));
289
+ }
290
+
218
291
  const emptyCount = (status: BehindSeamsCount['status'] = 'SKIP'): BehindSeamsCount => ({ status, boundary_cells: 0, geometric_px: 0, raw_px: 0, px: 0, box: null, max_spatial_run_cells: 0, samples: [] });
219
292
  type RGB = [number, number, number];
220
293
  interface Material { alpha: Float64Array; base: Float64Array; delta: Float64Array }
@@ -257,15 +330,42 @@ function counted(count: BehindSeamsCount, cells: ReadonlySet<number>, grid: Seam
257
330
  }
258
331
  }
259
332
 
333
+ /** Issue #1405: the unread reason names each ambiguous owner case that occurs, with
334
+ * both members' composite alpha at one endpoint. The named point is the case's first
335
+ * endpoint in scan order, which is `unread_corridors` order: horizontal corridors top
336
+ * to bottom and left to right, then vertical corridors left to right and top to bottom,
337
+ * the left/top endpoint before the right/bottom one. Counts are distinct endpoint cells;
338
+ * a case with none is omitted. */
339
+ export function ambiguousOwnerReason(a: string, b: string, corridors: readonly BehindSeamsUnreadCorridor[], cells: number,
340
+ alpha: (gridX: number, gridY: number) => [number, number]): string {
341
+ const byte = (v: number): string => `${Math.round(v * 255 * 100) / 100}/255`;
342
+ const clauses: string[] = [];
343
+ for (const owner of [0, 3]) {
344
+ const seen = new Set<string>();
345
+ let first: BehindSeamsEndpoint | null = null;
346
+ for (const c of corridors) for (const e of c.endpoints) if (e[4] === owner) { seen.add(`${e[0]},${e[1]}`); first ??= e; }
347
+ if (first === null) continue;
348
+ const [ax, bx] = alpha(first[0], first[1]);
349
+ clauses.push(`${owner === 0 ? `neither "${a}" nor "${b}" reaches` : `both "${a}" and "${b}" reach`} 128/255 at ${seen.size} endpoint cell(s), first at world (${first[2]}, ${first[3]}) ("${a}" ${byte(ax)}, "${b}" ${byte(bx)})`);
350
+ }
351
+ return `standing endpoints include ambiguous half-alpha owners: ${corridors.length} unread corridor(s), ${cells} cell(s); ${clauses.join('; ')}; each endpoint requires exactly one member at 128/255 or more; unread corridors are not zero`;
352
+ }
353
+
260
354
  interface Corridor { endpoints: Array<[number, number]> }
261
355
  interface RasterCache { full: Plate; hidden: Plate }
262
356
 
357
+ function overWhite(data: Uint8Array, q: number, c: number): number {
358
+ return Math.round((data[q + c] * data[q + 3]) / 255 + 255 * (1 - data[q + 3] / 255));
359
+ }
360
+
263
361
  function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pair: MotionSeamPair, frame: Frame, setup: boolean,
264
362
  stock: BehindSeamsStockPair | undefined, threshold: number, allowance: number, unread: (frame: string, reason: string) => void,
265
363
  cache: Map<Frame, Map<string, RasterCache>>, pose?: BehindSeamsTurnPose): BehindSeamsFrame {
364
+ const isIdle = !setup && pose === undefined;
266
365
  const label = pose !== undefined ? `turn ${pose.name}` : setup ? 'setup' : `idle frame ${frame.index}`;
267
366
  const family = pose !== undefined ? 'BEHIND_PART_SEAMS.turn.pairs[].frames' : setup ? 'BEHIND_PART_SEAMS.pairs[].setup' : 'BEHIND_PART_SEAMS.pairs[].frames';
268
- const row: BehindSeamsFrame = { ...checkRow(family, 'pair', false, [pair.a, pair.b]), animation: pose !== undefined ? 'turn' : setup ? null : 'idle', index: frame.index, time: frame.time, ...(pose === undefined ? {} : { pose: pose.name, values: { ...pose.values }, ...(pose.observed_values === undefined ? {} : { observed_values: pose.observed_values, slider_times: pose.slider_times }) }), behind_slots: [], grid: null, motion_opened: emptyCount(), standing: emptyCount() };
367
+ const row: BehindSeamsFrame = { ...checkRow(family, 'pair', false, [pair.a, pair.b]), animation: pose !== undefined ? 'turn' : setup ? null : 'idle', index: frame.index, time: frame.time, ...(pose === undefined ? {} : { pose: pose.name, values: { ...pose.values }, ...(pose.observed_values === undefined ? {} : { observed_values: pose.observed_values, slider_times: pose.slider_times }) }), behind_slots: [], grid: null, motion_opened: emptyCount(),
368
+ standing: isIdle ? { ...emptyCount('SKIP'), reason: IDLE_STANDING_NO_ORACLE_REASON } : emptyCount() };
269
369
  const fail = (reason: string): BehindSeamsFrame => { unread(label, reason); return row; };
270
370
  if (pair.unread !== undefined) return fail(pair.unread);
271
371
  if (frame.attachments === undefined) return fail('draw order/whole attachment geometry is unavailable');
@@ -285,55 +385,90 @@ function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pai
285
385
  const { viewport, cell } = grid, { width, height } = viewport, n = width * height;
286
386
  const A = material(n), B = material(n), project = api.projector(viewport);
287
387
  try {
288
- for (const piece of frame.pieces) if (piece.slot === pair.a || piece.slot === pair.b) {
289
- api.rasterisePiece(api.pageFor(input.pages, piece), piece, project, viewport, (x, y, r, g, b, alpha) => add(piece.slot === pair.a ? A : B, y * width + x, [r, g, b], alpha / 255));
388
+ // Ordinary official full/hidden rendering, both transparent and on the SAME
389
+ // native seam grid. No --seam/--hide combination and no PNG nearest sampling.
390
+ let frameCache = cache.get(frame);
391
+ if (frameCache === undefined) { frameCache = new Map(); cache.set(frame, frameCache); }
392
+ const cacheKey = JSON.stringify([grid, row.behind_slots]);
393
+ let rasters = frameCache.get(cacheKey);
394
+ const behind = new Set(row.behind_slots);
395
+ if (rasters === undefined) {
396
+ rasters = { full: api.renderFrame(frame, input.pages, viewport, [0, 0, 0, 0]), hidden: api.renderFrame({ ...frame, pieces: frame.pieces.filter(p => !behind.has(p.slot)) }, input.pages, viewport, [0, 0, 0, 0]) };
397
+ frameCache.set(cacheKey, rasters);
398
+ }
399
+ const plantIdleStanding = isIdle && input.plantMeasureIdleStanding === true;
400
+ const measureStanding = pose !== undefined || plantIdleStanding || (setup && input.recomposite !== undefined && input.recomposite !== null);
401
+ let recompositeDiff: ((k: number) => number) | null = null;
402
+ if (setup) {
403
+ if (input.recomposite === undefined || input.recomposite === null) {
404
+ row.standing = { ...emptyCount('SKIP'), reason: NO_PARTS_SETUP_STANDING_REASON };
405
+ unread(label, NO_PARTS_SETUP_STANDING_REASON);
406
+ } else if (input.plantSkipRecomposite !== true) {
407
+ const recompositePlate = api.renderFrame(input.recomposite, input.pages, viewport, [0, 0, 0, 0]);
408
+ recompositeDiff = (k: number): number => {
409
+ const q = k * 4;
410
+ if (recompositePlate.data[q + 3] === 0) return Infinity;
411
+ return Math.max(
412
+ Math.abs(overWhite(rasters!.full.data, q, 0) - overWhite(recompositePlate.data, q, 0)),
413
+ Math.abs(overWhite(rasters!.full.data, q, 1) - overWhite(recompositePlate.data, q, 1)),
414
+ Math.abs(overWhite(rasters!.full.data, q, 2) - overWhite(recompositePlate.data, q, 2)),
415
+ );
416
+ };
417
+ }
290
418
  }
291
- const half = DRAWN_ALPHA / 255;
292
- const low = (k: number): boolean => A.alpha[k] + B.alpha[k] * (1 - A.alpha[k]) < half;
293
- const owner = (k: number): number => A.alpha[k] >= half ? B.alpha[k] >= half ? 3 : 1 : B.alpha[k] >= half ? 2 : 0;
294
419
  const corridors = new Map<number, Corridor>();
295
420
  const support = new Set<number>();
296
421
  const unreadCells = new Set<number>(), unreadCorridors: BehindSeamsUnreadCorridor[] = [];
297
- // A measured overlap is support even when the opening population is empty.
298
- for (let k = 0; k < n; k++) if (owner(k) === 3) support.add(k);
299
- for (const [length, lines, step, start] of [[width, height, 1, width], [height, width, width, 1]]) for (let l = 0; l < lines; l++) {
300
- let j = 0;
301
- while (j < length) {
302
- const k = l * start + j * step;
303
- if (!low(k)) {
304
- if (j > 0) { const prev = k - step; if (!low(prev) && owner(prev) > 0 && owner(prev) < 3 && owner(k) > 0 && owner(k) < 3 && owner(prev) !== owner(k)) { support.add(prev); support.add(k); } }
305
- j++; continue;
306
- }
307
- const first = j;
308
- while (j < length && low(l * start + j * step)) j++;
309
- if (first === 0 || j === length) continue; // outer silhouette, never a bracketed opening
310
- const left = l * start + (first - 1) * step, right = l * start + j * step;
311
- const a = owner(left), b = owner(right);
312
- if (a === 0 || b === 0 || a === 3 || b === 3) {
313
- const endpoint = (at: number, owner: number): BehindSeamsEndpoint => [at % width, Math.floor(at / width), ...centre(grid, at), owner];
314
- const cells: Array<[number, number]> = [];
422
+ const half = DRAWN_ALPHA / 255;
423
+ const low = (k: number): boolean => A.alpha[k] + B.alpha[k] * (1 - A.alpha[k]) < half;
424
+ const owner = (k: number): number => A.alpha[k] >= half ? B.alpha[k] >= half ? 3 : 1 : B.alpha[k] >= half ? 2 : 0;
425
+ if (measureStanding) {
426
+ for (const piece of frame.pieces) if (piece.slot === pair.a || piece.slot === pair.b) {
427
+ api.rasterisePiece(api.pageFor(input.pages, piece), piece, project, viewport, (x, y, r, g, b, alpha) => add(piece.slot === pair.a ? A : B, y * width + x, [r, g, b], alpha / 255));
428
+ }
429
+ // A measured overlap is support even when the opening population is empty.
430
+ for (let k = 0; k < n; k++) if (owner(k) === 3) support.add(k);
431
+ for (const [length, lines, step, start] of [[width, height, 1, width], [height, width, width, 1]]) for (let l = 0; l < lines; l++) {
432
+ let j = 0;
433
+ while (j < length) {
434
+ const k = l * start + j * step;
435
+ if (!low(k)) {
436
+ if (j > 0) { const prev = k - step; if (!low(prev) && owner(prev) > 0 && owner(prev) < 3 && owner(k) > 0 && owner(k) < 3 && owner(prev) !== owner(k)) { support.add(prev); support.add(k); } }
437
+ j++; continue;
438
+ }
439
+ const first = j;
440
+ while (j < length && low(l * start + j * step)) j++;
441
+ if (first === 0 || j === length) continue; // outer silhouette, never a bracketed opening
442
+ const left = l * start + (first - 1) * step, right = l * start + j * step;
443
+ const a = owner(left), b = owner(right);
444
+ if (a === 0 || b === 0 || a === 3 || b === 3) {
445
+ const endpoint = (at: number, owner: number): BehindSeamsEndpoint => [at % width, Math.floor(at / width), ...centre(grid, at), owner];
446
+ const cells: Array<[number, number]> = [];
447
+ for (let t = first; t < j; t++) {
448
+ const at = l * start + t * step;
449
+ if (recompositeDiff !== null && recompositeDiff(at) <= threshold) continue;
450
+ unreadCells.add(at); cells.push(centre(grid, at));
451
+ }
452
+ if (cells.length === 0) continue;
453
+ unreadCorridors.push({ ...checkRow('BEHIND_PART_SEAMS.unread_corridors', 'pair', false, [pair.a, pair.b]),
454
+ axis: step === 1 ? 'horizontal' : 'vertical', endpoints: [endpoint(left, a), endpoint(right, b)], cells, cell_count: cells.length });
455
+ continue;
456
+ }
457
+ if (a === b) continue;
458
+ support.add(left); support.add(right);
459
+ const endpoints: [number, number] = a === 1 ? [left, right] : [right, left];
315
460
  for (let t = first; t < j; t++) {
316
461
  const at = l * start + t * step;
317
- unreadCells.add(at); cells.push(centre(grid, at));
462
+ const c = corridors.get(at) ?? { endpoints: [] };
463
+ c.endpoints.push(endpoints); corridors.set(at, c);
318
464
  }
319
- unreadCorridors.push({ ...checkRow('BEHIND_PART_SEAMS.unread_corridors', 'pair', false, [pair.a, pair.b]),
320
- axis: step === 1 ? 'horizontal' : 'vertical', endpoints: [endpoint(left, a), endpoint(right, b)], cells, cell_count: cells.length });
321
- continue;
322
- }
323
- if (a === b) continue;
324
- support.add(left); support.add(right);
325
- const endpoints: [number, number] = a === 1 ? [left, right] : [right, left];
326
- for (let t = first; t < j; t++) {
327
- const at = l * start + t * step;
328
- const c = corridors.get(at) ?? { endpoints: [] };
329
- c.endpoints.push(endpoints); corridors.set(at, c);
330
465
  }
331
466
  }
332
- }
333
- row.standing.boundary_cells = support.size;
334
- if (unreadCorridors.length > 0) {
335
- row.standing.unread_cells = unreadCells.size;
336
- row.standing.unread_corridors = unreadCorridors;
467
+ row.standing.boundary_cells = support.size;
468
+ if (unreadCorridors.length > 0) {
469
+ row.standing.unread_cells = unreadCells.size;
470
+ row.standing.unread_corridors = unreadCorridors;
471
+ }
337
472
  }
338
473
  let motionReadable = setup;
339
474
  const motionCells = new Map<number, SeamCell>();
@@ -356,17 +491,6 @@ function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pai
356
491
  }
357
492
  }
358
493
  }
359
- // Ordinary official full/hidden rendering, both transparent and on the SAME
360
- // native seam grid. No --seam/--hide combination and no PNG nearest sampling.
361
- let frameCache = cache.get(frame);
362
- if (frameCache === undefined) { frameCache = new Map(); cache.set(frame, frameCache); }
363
- const cacheKey = JSON.stringify([grid, row.behind_slots]);
364
- let rasters = frameCache.get(cacheKey);
365
- const behind = new Set(row.behind_slots);
366
- if (rasters === undefined) {
367
- rasters = { full: api.renderFrame(frame, input.pages, viewport, [0, 0, 0, 0]), hidden: api.renderFrame({ ...frame, pieces: frame.pieces.filter(p => !behind.has(p.slot)) }, input.pages, viewport, [0, 0, 0, 0]) };
368
- frameCache.set(cacheKey, rasters);
369
- }
370
494
  const targets = new Set([...corridors.keys(), ...motionCells.keys()]);
371
495
  const rear = material(n), weights = new Map<number, Map<string, number>>();
372
496
  const surviving = new Set<number>(), underflow = new Set<number>();
@@ -396,28 +520,35 @@ function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pai
396
520
  contributors: row.behind_slots.filter(slot => (weights.get(k)?.get(slot) ?? 0) > 0).map(slot => ({ ...checkRow('BEHIND_PART_SEAMS.contributors', 'pair', false, [pair.a, pair.b]), slot, weight: weights.get(k)!.get(slot)! })), distances, counted: counts };
397
521
  };
398
522
  const standingHits = new Set<number>(), motionHits = new Set<number>();
399
- let standingUnderflow = false;
400
- for (const [k, corridor] of corridors) {
401
- if (!surviving.has(k)) continue;
402
- if (rear.alpha[k] <= 0 || underflow.has(k)) { unread(label, 'positive symbolic rear contribution underflowed its numeric colour weight'); standingUnderflow = true; continue; }
403
- row.standing.geometric_px++;
404
- let chosen: [number, number] | null = null, raw = false, qualifies = false;
405
- for (const [a, b] of corridor.endpoints) {
406
- const d: [number, number] = [distance(rear, k, colour(A, a)), distance(rear, k, colour(B, b))];
407
- const r = d[0] > 0 && d[1] > 0, q = d[0] > threshold && d[1] > threshold;
408
- if (chosen === null || q && !qualifies || r && !raw) chosen = d;
409
- raw ||= r; qualifies ||= q;
523
+ const cap = input.sampleCap ?? BEHIND_SAMPLE_CAP;
524
+ if (measureStanding) {
525
+ let standingUnderflow = false;
526
+ const worstStanding = new WorstStanding(cap);
527
+ for (const [k, corridor] of corridors) {
528
+ if (!surviving.has(k)) continue;
529
+ if (rear.alpha[k] <= 0 || underflow.has(k)) { unread(label, 'positive symbolic rear contribution underflowed its numeric colour weight'); standingUnderflow = true; continue; }
530
+ row.standing.geometric_px++;
531
+ const dr = recompositeDiff === null ? Infinity : recompositeDiff(k);
532
+ let chosen: [number, number] | null = null, raw = false, qualifies = false;
533
+ for (const [a, b] of corridor.endpoints) {
534
+ const d: [number, number] = [distance(rear, k, colour(A, a)), distance(rear, k, colour(B, b))];
535
+ const r = d[0] > 0 && d[1] > 0 && dr > 0, q = d[0] > threshold && d[1] > threshold && dr > threshold;
536
+ if (chosen === null || q && !qualifies || r && !raw) chosen = d;
537
+ raw ||= r; qualifies ||= q;
538
+ }
539
+ if (raw) row.standing.raw_px++;
540
+ if (qualifies) standingHits.add(k);
541
+ worstStanding.offer(k, chosen as [number, number], qualifies);
542
+ }
543
+ row.standing.samples = worstStanding.inOrder().map(c => sample(c.k, c.d, c.q));
544
+ if (worstStanding.seen > cap) row.standing.samples_omitted = worstStanding.seen - cap;
545
+ counted(row.standing, standingHits, grid, allowance);
546
+ // Incomplete coverage cannot certify PASS, but cannot hide a measured failure.
547
+ if (support.size === 0 || unreadCorridors.length > 0 || standingUnderflow) {
548
+ if (row.standing.status !== 'FAIL') row.standing.status = 'SKIP';
549
+ if (unreadCorridors.length > 0) unread(label, ambiguousOwnerReason(pair.a, pair.b, unreadCorridors, unreadCells.size, (x, y) => [A.alpha[y * width + x], B.alpha[y * width + x]]));
550
+ else if (support.size === 0) unread(label, 'no A/B boundary support was measured (no overlap, contact or bracketed corridor)');
410
551
  }
411
- if (raw) row.standing.raw_px++;
412
- if (qualifies) standingHits.add(k);
413
- row.standing.samples.push(sample(k, chosen, qualifies));
414
- }
415
- counted(row.standing, standingHits, grid, allowance);
416
- // Incomplete coverage cannot certify PASS, but cannot hide a measured failure.
417
- if (support.size === 0 || unreadCorridors.length > 0 || standingUnderflow) {
418
- if (row.standing.status !== 'FAIL') row.standing.status = 'SKIP';
419
- if (unreadCorridors.length > 0) unread(label, 'standing endpoints include ambiguous half-alpha owners; unread corridors are not zero');
420
- else if (support.size === 0) unread(label, 'no A/B boundary support was measured (no overlap, contact or bracketed corridor)');
421
552
  }
422
553
  for (const k of motionCells.keys()) {
423
554
  if (rasters.hidden.data[k * 4 + 3] !== 0 || rasters.full.data[k * 4 + 3] === 0 || !surviving.has(k)) continue;
@@ -435,12 +566,22 @@ function readBehindFrame(api: BehindSeamsApi, input: BehindSeamsFramesInput, pai
435
566
  motionReadable = false; unread(label, 'stock transported setup-overlap support cannot be bound to the actually drawn setup pair strictly in front of the complete rear set'); continue;
436
567
  }
437
568
  if (rear.alpha[k] <= 0 || underflow.has(k)) { motionReadable = false; unread(label, 'positive symbolic rear contribution underflowed its numeric colour weight'); continue; }
438
- motionHits.add(k); row.motion_opened.samples.push(sample(k, null, true));
569
+ motionHits.add(k);
439
570
  }
571
+ // Motion-opened rows carry no distance; keep evenly spaced rows, built only for what is kept.
572
+ const hitCells = [...motionHits];
573
+ row.motion_opened.samples = evenlySpaced(hitCells.length, cap).map(i => sample(hitCells[i], null, true));
574
+ if (hitCells.length > cap) row.motion_opened.samples_omitted = hitCells.length - cap;
440
575
  row.motion_opened.boundary_cells = motionCells.size;
441
576
  row.motion_opened.geometric_px = motionHits.size; row.motion_opened.raw_px = motionHits.size;
442
577
  counted(row.motion_opened, motionHits, grid, allowance);
443
578
  if (!motionReadable) row.motion_opened.status = 'SKIP';
579
+ if (isIdle && !plantIdleStanding) {
580
+ row.standing = {
581
+ ...emptyCount('SKIP'),
582
+ reason: row.motion_opened.status !== 'SKIP' ? IDLE_STANDING_MOTION_READ_REASON : IDLE_STANDING_NO_ORACLE_REASON,
583
+ };
584
+ }
444
585
  return { ...row, ...checkRow(family, 'pair', row.standing.status === 'FAIL' || row.motion_opened.status === 'FAIL', [pair.a, pair.b]) };
445
586
  } catch (e) { return fail(`official raster/source reading unavailable: ${e instanceof Error ? e.message : String(e)}`); }
446
587
  }
@@ -484,6 +625,8 @@ export function measureBehindSeamFrames(api: BehindSeamsApi, input: BehindSeamsF
484
625
  problems.push(...shape);
485
626
  if (shape.length > 0) { line.status = 'FAIL'; return line; }
486
627
  for (const p of declared.pairs ?? []) if (!selected.has(keyOf(p.part, p.neighbour))) unread(null, 'declaration', `override pair "${p.part}|${p.neighbour}" is not in motionSeamSelection; an override does not create an adjacent pair`, true);
628
+ const active = declared.threshold !== undefined || declared.pairs?.some(p => p.threshold !== undefined) === true;
629
+ if (input.pairs.length === 0 && (input.recomposite === undefined || input.recomposite === null)) unread(null, 'setup', NO_PARTS_SETUP_STANDING_REASON, active);
487
630
  if (input.pairs.length === 0) unread(null, 'selection', 'no selected motion seam pair; no boundary population was measured', declared.threshold !== undefined);
488
631
  const rows = input.pairs.map(pair => {
489
632
  const override = declared.pairs?.find(p => keyOf(p.part, p.neighbour) === keyOf(pair.a, pair.b));
@@ -517,23 +660,29 @@ export function measureBehindSeamFrames(api: BehindSeamsApi, input: BehindSeamsF
517
660
  for (const r of rows) {
518
661
  const { pair, threshold, allowance, setup, frames } = r;
519
662
  const parts: [string, string] = [pair.a, pair.b];
520
- const motion = reading(frames, 'motion_opened', input.fps, allowance, parts), standing = reading(frames, 'standing', input.fps, allowance, parts);
663
+ const motion = reading(frames, 'motion_opened', input.fps, allowance, parts);
521
664
  if ((setup === null || setup.motion_opened.status === 'SKIP') && motion.status !== 'FAIL') motion.status = 'SKIP';
522
- if ((setup === null || setup.standing.status === 'SKIP') && standing.status !== 'FAIL') standing.status = 'SKIP';
523
- if (setup?.standing.status === 'FAIL') standing.status = 'FAIL';
524
- for (const [kind, value] of [['motion_opened', motion], ['standing', standing]] as const) {
525
- if (value.max_px > allowance || kind === 'standing' && (setup?.standing.px ?? 0) > allowance) {
526
- const at = kind === 'standing' && (setup?.standing.px ?? 0) > value.max_px ? `setup (${setup!.standing.px} cells)` : `idle frame ${value.worst?.index} (${value.max_px} cells)`;
527
- problems.push({ code: BEHIND_SEAM_CODE, object: `pair "${pair.pair}" ${kind}`, detail: `${at} exceeds allowance ${allowance}; authored threshold ${threshold}, native seam cells, no one-cell floor or rest mask` });
528
- }
665
+ const idleStandingReason = motion.status !== 'SKIP' ? IDLE_STANDING_MOTION_READ_REASON : IDLE_STANDING_NO_ORACLE_REASON;
666
+ const rawStanding = reading(frames, 'standing', input.fps, allowance, parts);
667
+ const standing: BehindSeamsReading = input.plantMeasureIdleStanding === true
668
+ ? rawStanding
669
+ : { ...rawStanding, status: 'SKIP', reason: idleStandingReason };
670
+ if (motion.max_px > allowance) {
671
+ problems.push({ code: BEHIND_SEAM_CODE, object: `pair "${pair.pair}" motion_opened`, detail: `idle frame ${motion.worst?.index} (${motion.max_px} cells) exceeds allowance ${allowance}; authored threshold ${threshold}, native seam cells, no one-cell floor or rest mask` });
672
+ }
673
+ if ((setup?.standing.px ?? 0) > allowance) {
674
+ problems.push({ code: BEHIND_SEAM_CODE, object: `pair "${pair.pair}" setup standing`, detail: `setup (${setup!.standing.px} cells) exceeds allowance ${allowance}; authored threshold ${threshold}, native seam cells, no one-cell floor or rest mask` });
529
675
  }
530
- const failed = motion.status === 'FAIL' || standing.status === 'FAIL' || line.unmeasured.some(u => u.pair === pair.pair && threshold !== null);
531
- const readFrames = frames.filter(f => f.motion_opened.status !== 'SKIP' && f.standing.status !== 'SKIP' &&
532
- (f.standing.unread_corridors?.length ?? 0) === 0 && !line.unmeasured.some(u => u.pair === pair.pair && u.frame === `idle frame ${f.index}`)).length;
676
+ if (input.plantMeasureIdleStanding === true && standing.max_px > allowance) {
677
+ problems.push({ code: BEHIND_SEAM_CODE, object: `pair "${pair.pair}" standing`, detail: `idle frame ${standing.worst?.index} (${standing.max_px} cells) exceeds allowance ${allowance}; authored threshold ${threshold}, native seam cells, no one-cell floor or rest mask` });
678
+ }
679
+ const failed = motion.status === 'FAIL' || setup?.standing.status === 'FAIL' || standing.status === 'FAIL' || line.unmeasured.some(u => u.pair === pair.pair && threshold !== null);
680
+ const readFrames = frames.filter(f => f.motion_opened.status !== 'SKIP' &&
681
+ !line.unmeasured.some(u => u.pair === pair.pair && u.frame === `idle frame ${f.index}`)).length;
533
682
  line.pairs.push({ ...checkRow('BEHIND_PART_SEAMS.pairs', 'pair', failed, parts), animation: 'idle', pair: pair.pair, parts, declared: [...pair.declared], threshold, allowance, setup, frames, motion_opened: motion, standing,
534
683
  sampled_frames: input.idle.length, read_frames: readFrames, unmeasured_frames: input.idle.length - readFrames });
535
684
  }
536
- line.status = problems.length > start ? 'FAIL' : line.pairs.length === 0 || line.pairs.some(p => p.threshold === null || p.motion_opened.status === 'SKIP' || p.standing.status === 'SKIP') ? 'SKIP' : 'PASS';
685
+ line.status = problems.length > start ? 'FAIL' : line.pairs.length === 0 || line.pairs.some(p => p.threshold === null || p.setup === null || p.setup.standing.status === 'SKIP' || p.motion_opened.status === 'SKIP') ? 'SKIP' : 'PASS';
537
686
  if (declared.turn === true) {
538
687
  line.turn = measureBehindTurnFrames(api, input, declared, problems);
539
688
  if (line.turn.status === 'FAIL' || problems.length > start) line.status = 'FAIL';
@@ -831,7 +980,23 @@ export function measureBehindSeams(api: typeof import('@rig-c/core/render-shared
831
980
  if (input.stockDir === null || sampled.setup === null) throw new Error('existing full stock seam render/setup is unavailable');
832
981
  stock = stockOf(input.stockDir, input.pairs.filter(p => p.unread === undefined), input.fps, sampled.setup, sampled.idle, sampled.rest);
833
982
  } catch (e) { stockError = e instanceof Error ? e.message : String(e); }
834
- const line = measureBehindSeamFrames(api, { ...sampled, pairs: input.pairs, pages: candidate.pages, stock, fps: input.fps,
983
+ const pages = new Map(candidate.pages);
984
+ let recomposite: Frame | null = null;
985
+ if (input.recomposite !== undefined && input.recomposite !== null) {
986
+ const { stage, raster } = input.recomposite;
987
+ if (raster.width !== stage.width || raster.height !== stage.height) {
988
+ return fail(`parts.json rig_size (${raster.width}x${raster.height}) differs from rig stage (${stage.width}x${stage.height}); setup standing does not resample the parts' recomposite`);
989
+ }
990
+ const page = new Plate(raster.width, raster.height);
991
+ page.data.set(raster.data);
992
+ const pageName = 'behind-seams:recomposite';
993
+ pages.set(pageName, page);
994
+ const wx0 = stage.x, wx1 = stage.x + stage.width, wy0 = stage.y, wy1 = stage.y + stage.height;
995
+ recomposite = { index: 0, time: 0, pieces: [{ kind: 'region', slot: 'recomposite', page: pageName, tint: [1, 1, 1, 1],
996
+ world: [wx1, wy1, wx0, wy1, wx0, wy0, wx1, wy0], uvs: [1, 0, 0, 0, 0, 1, 1, 1] }] };
997
+ }
998
+ const line = measureBehindSeamFrames(api, { ...sampled, pairs: input.pairs, pages, stock, fps: input.fps,
999
+ recomposite,
835
1000
  ...(declared.turn === true ? { turn: sampleBehindTurn(api, input, candidate, sampled.setup, acceptedPoser) } : {}) }, declared, problems);
836
1001
  if (stockError !== null) {
837
1002
  line.status = 'FAIL';
@@ -850,9 +1015,12 @@ export function behindSeamLines(line: BehindSeamsMeasured | null): string[] {
850
1015
  const setup = p.setup;
851
1016
  const summary = (kind: 'motion_opened' | 'standing'): string => {
852
1017
  const r = p[kind], w = r.worst;
1018
+ if (r.reason !== undefined) {
1019
+ return `${BEHIND_SEAM_LINE}: pair "${p.pair}" ${kind} ${r.status} — ${r.reason}; threshold ${p.threshold === null ? 'undeclared' : p.threshold}, allowance ${p.allowance}`;
1020
+ }
853
1021
  return `${BEHIND_SEAM_LINE}: pair "${p.pair}" ${kind} ${r.status} — ${r.hit_frames}/${p.frames.length} idle hit frames, sampled/read/unmeasured ${p.sampled_frames ?? p.frames.length}/${p.read_frames ?? 0}/${p.unmeasured_frames ?? 0}, max_px ${r.max_px}, max_run ${r.max_run.frames} frames (${r.max_run.seconds} s), max_spatial_run_cells ${r.max_spatial_run_cells} (${r.max_spatial_run_world} world units), earliest worst ${w === null ? 'none' : `frame ${w.index} t ${w.time}, cell ${w.cell}, box [${w.box.join(', ')}]`}; threshold ${p.threshold === null ? 'undeclared' : p.threshold}, allowance ${p.allowance}`;
854
1022
  };
855
- const setupStanding = setup === null ? '' : setup.standing.px > 0 && setup.standing.status === 'SKIP' ? `${setup.standing.px} cells` : `${setup.standing.status}, ${setup.standing.px} cells`;
1023
+ const setupStanding = setup === null ? '' : setup.standing.reason !== undefined ? `${setup.standing.status} (${setup.standing.reason}), ${setup.standing.px} cells` : setup.standing.px > 0 && setup.standing.status === 'SKIP' ? `${setup.standing.px} cells` : `${setup.standing.status}, ${setup.standing.px} cells`;
856
1024
  return [summary('motion_opened'), summary('standing'), `${BEHIND_SEAM_LINE}: pair "${p.pair}" setup ${setup === null ? 'SKIP — HOLE: setup not read' : `standing ${setupStanding}; motion_opened ${setup.motion_opened.status}, ${setup.motion_opened.px} cells; behind [${setup.behind_slots.join(', ')}]`}`];
857
1025
  }),
858
1026
  ...(line.turn === undefined ? [] : [
package/src/check.ts CHANGED
@@ -7676,8 +7676,10 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
7676
7676
  }
7677
7677
  }
7678
7678
  }
7679
+ const behindSlotOrder = (Array.isArray(inp.rig.slots) ? inp.rig.slots : []).filter(isRecord).map((sl) => String(sl.name));
7679
7680
  behindSeams = measureBehindSeams(officialRenderer(), {
7680
7681
  build: buildDir, rig: inp.rig, pairs: behindPairs, stockDir: behindStockDir, fps: IDLE_FPS,
7682
+ recomposite: inp.parts === null ? null : { stage: inp.stage, raster: flatComposite(inp.parts, inp.partsDir, [255, 255, 255, 255], behindSlotOrder) },
7681
7683
  ...(turnBuild === undefined ? {} : { turnBuild }),
7682
7684
  ...(behindUnsupported.length === 0 ? {} : { unsupported: behindUnsupported.join('; ') }),
7683
7685
  }, behindDeclared, problems);