rig-parts 2.57.0 → 2.58.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/cli.ts CHANGED
@@ -973,9 +973,9 @@ usage:
973
973
  [--idle-keys ctl|direct] [--lead-in <periods>] [--seam-pairs] [--keep-stills] [--no-extremes]
974
974
  [--alt <name>=<source>:<full>[:<head>]] [--set <name> | --all-sets]
975
975
  [--environment <schedule.json>] [--wind-band <spec.json>]
976
- build-run.json (rig-run/2, as check-run.json for check) records a run whose
977
- check completed, with argv starting "build": these arguments reproduce the
978
- check with the same package version, run from the --out directory.
976
+ build-run.json (rig-run/3, STABILITY) records a run whose check completed,
977
+ with input paths and SHA-256 digests. Its argv reproduces the check with
978
+ the same package version, run from the --out directory.
979
979
  assemble, then rig, then check, in one process, each stage's own lines
980
980
  printed under [assemble], [rig] and [check]; the first stage that refuses
981
981
  stops the build with its own FAIL lines. The config must already carry
@@ -2511,6 +2511,9 @@ function cmdBuild(args: string[]): number {
2511
2511
  }
2512
2512
  const [config, source, full, out] = ['--config', '--source', '--full', '--out'].map((f) => flags.get(f) as string);
2513
2513
  const head = flags.get('--head') ?? null;
2514
+ const requirements = flags.get('--requirements');
2515
+ const environment = flags.get('--environment');
2516
+ const windBand = flags.get('--wind-band');
2514
2517
  let bin: string;
2515
2518
  let fixedClock: string | undefined;
2516
2519
  let pkg: { name: string; version: string };
@@ -2526,7 +2529,7 @@ function cmdBuild(args: string[]): number {
2526
2529
  const scratch = mkdtempSync(join(tmpdir(), 'rig-parts-build-'));
2527
2530
  try {
2528
2531
  const r = build(
2529
- { config, source, full, head, out, ...(seam === undefined ? {} : { seam: seam as SeamRule }), ...(project === undefined ? {} : { project: project as ProjectRule }), loop, pageEdges: edges, packShape: shape, ...(size === undefined ? {} : { pageSize: size }), ...(flags.has('--requirements') ? { requirements: flags.get('--requirements') as string } : {}), idleKeys: keys, ...(leadText === undefined ? {} : { leadIn: Number(leadText) }), seamPairs: on.has('--seam-pairs'), keepStills: on.has('--keep-stills'), noExtremes: on.has('--no-extremes'), ...(alts.length === 0 ? {} : { alts }), ...(flags.has('--set') ? { set: flags.get('--set') as string } : {}), allSets: on.has('--all-sets'), ...(flags.has('--environment') ? { environment: flags.get('--environment') as string } : {}), ...(flags.has('--wind-band') ? { windBand: flags.get('--wind-band') as string } : {}) },
2532
+ { config, source, full, head, out, ...(seam === undefined ? {} : { seam: seam as SeamRule }), ...(project === undefined ? {} : { project: project as ProjectRule }), loop, pageEdges: edges, packShape: shape, ...(size === undefined ? {} : { pageSize: size }), ...(requirements === undefined ? {} : { requirements }), idleKeys: keys, ...(leadText === undefined ? {} : { leadIn: Number(leadText) }), seamPairs: on.has('--seam-pairs'), keepStills: on.has('--keep-stills'), noExtremes: on.has('--no-extremes'), ...(alts.length === 0 ? {} : { alts }), ...(flags.has('--set') ? { set: flags.get('--set') as string } : {}), allSets: on.has('--all-sets'), ...(environment === undefined ? {} : { environment }), ...(windBand === undefined ? {} : { windBand }) },
2530
2533
  { rig: rigcRunner(bin), check: rigcRunner(bin), checkBin: bin, scratch: join(scratch, 'rig-gate'), stages: {
2531
2534
  assemble: (input, outputs) => runBuildProcess({ stage: 'assemble', bin, input, outputs }, join(scratch, 'workers')),
2532
2535
  rig: (input, _rigc, gateScratch) => runBuildProcess({ stage: 'rig', bin, input, scratch: gateScratch }, join(scratch, 'workers')),
@@ -2536,8 +2539,10 @@ function cmdBuild(args: string[]): number {
2536
2539
  );
2537
2540
  // Issue #1541: written whenever this build's check completed its report, green or not.
2538
2541
  if (r.check !== null) {
2542
+ const cwd = process.cwd();
2539
2543
  writeRunRecord({ pkg, command: 'build', startedAt, finishedAt: fixedClock ?? new Date().toISOString(), outDir: out, configPath: config,
2540
- outputs: [...BUILD_OWNS, ...BUILD_OWNS_FILES], argv: recordArgv('build', args, BUILD_ARGV, out, process.cwd()) });
2544
+ inputs: { cwd, source, full, head, requirements, environment, windBand, alts },
2545
+ outputs: [...BUILD_OWNS, ...BUILD_OWNS_FILES], argv: recordArgv('build', args, BUILD_ARGV, out, cwd) });
2541
2546
  }
2542
2547
  return r.stoppedAt === null ? EXIT_OK : EXIT_REFUSED;
2543
2548
  } finally {
package/docs/AUTHORING.md CHANGED
@@ -7237,6 +7237,7 @@ and stay absent).
7237
7237
  | <a id="RIG_TURN_SURFACE_OVERLAP_SUPPORT"></a>`RIG_TURN_SURFACE_OVERLAP_SUPPORT` | a selected neighbour has missing/invalid geometry, unresolved emitted vectors, or no triangle covering the requested setup point | supply its actual shown setup triangles and existing emitted field; no nearest triangle, extrapolation or target-field fallback is used; an unrelated disconnected drawing with no actual overlap is not selected |
7238
7238
  | <a id="RIG_TURN_SURFACE_OVERLAP_DEPTH"></a>`RIG_TURN_SURFACE_OVERLAP_DEPTH` | same-group overlap neighbours demand incompatible emitted offsets at one target setup point | separate the conflicting support or provide coincident neighbour fields; the refusal names the fields and target vertex |
7239
7239
  | <a id="RIG_TURN_SURFACE_MESH_BINDINGS"></a>`RIG_TURN_SURFACE_MESH_BINDINGS` | an authored surface mesh has unresolved/nonclosing weights or shares a frame moved by a unit/rear turn carrier; declared stop draw aliases resolve to their links for setup sampling | provide weighted bindings closing at 1 in the authored frame; `<link>_d` resolves only for links declared in `config.stops`; use independent chains for parts with different roles |
7240
+ | <a id="RIG_TURN_LEGACY_FACE_WEIGHTS"></a>`RIG_TURN_LEGACY_FACE_WEIGHTS` | legacy head-turn animation derivation reaches a face mesh without the weight rows it needs to locate the face frame | configure the generated face surface through `config.turn.roles` |
7240
7241
  | <a id="RIG_TURN_SURFACE_MESH_ATTACHMENT"></a>`RIG_TURN_SURFACE_MESH_ATTACHMENT` | a surface mesh has an alternate drawing without its own registered depth sampling frame | use the base attachment; explicit islands retain their own slot, attachment and bindings |
7241
7242
  | <a id="RIG_TURN_BODY_UNCOVERED"></a>`RIG_TURN_BODY_UNCOVERED` | **Warning:** a shown part without a body role overlaps a moved `turn.body` surface at setup alpha >= 128 and has different emitted endpoint displacement | declare the intended body role and inspect both endpoints; no role or depth is inferred |
7242
7243
  | <a id="RIG_TURN_HEAD_ROLL"></a>`RIG_TURN_HEAD_ROLL` | **Warning:** a declared head turn has an absolute authored-eye-origin roll above the empirical limit displayed as 18.485385 degrees; names the face/eye parts, both eye bones, signed roll and limit | inspect the neck at both extremes; this proxy does not detect the painting independently, correct tilt or change emitted bytes; see [Head roll before a declared turn](#head-roll-before-a-declared-turn) |
@@ -9729,7 +9730,11 @@ once at the region `bone`'s setup position (requiring `alpha === 255` on the
9729
9730
  cover's art there, [`RIG_TURN_BAND_COVER_SUPPORT`](#RIG_TURN_BAND_COVER_SUPPORT),
9730
9731
  and a valid other-group surface cover,
9731
9732
  [`CONFIG_TURN_BAND_COVER`](#CONFIG_TURN_BAND_COVER)), so every band vertex takes
9732
- `g · D(z_cover)` on that group's side and stays monotone in `g`. A polygon
9733
+ `g · D(z_cover)` on that group's side and stays monotone in `g`.
9734
+ A declared cover on a stopped link raises [`CONFIG_TURN_BAND_COVER`](#CONFIG_TURN_BAND_COVER),
9735
+ and a cover whose region supplies no positive mesh influence or whose part has no
9736
+ blended attachment raises [`RIG_TURN_BAND_COVER_SUPPORT`](#RIG_TURN_BAND_COVER_SUPPORT).
9737
+ A polygon
9733
9738
  region whose edge has short segments can make the band offset cross itself,
9734
9739
  refused as `CONTOUR_PARAMETER` on `regions[i].band`: on that build, a jaw line
9735
9740
  with two extra points, its edges there 23–29 px long, crossed at any band above
package/docs/STABILITY.md CHANGED
@@ -1437,8 +1437,9 @@ the spec. A key added, removed or redefined is a new spec version.
1437
1437
 
1438
1438
  ### Run record (`check-run.json` and `build-run.json`, spec `rig-run/2`)
1439
1439
 
1440
- `check` writes `<out>/check-run.json` and `build` writes `<out>/build-run.json`
1441
- (issue #1541) whenever the run completed its check report, green or not. The names
1440
+ `check` writes `<out>/check-run.json` whenever the run completed its check report,
1441
+ green or not (issue #1541). `build` originally wrote `<out>/build-run.json` in this
1442
+ format. Its current contract is [the build run record](#build-run-record-build-runjson-spec-rig-run3). The names
1442
1443
  cannot be a `run.json`: `rig` and `assemble` write `rig-run/1` as `run.json`, and
1443
1444
  rigc writes its own `run.json` in a packed build directory (`check/build/`). Neither
1444
1445
  file is in `check.json`, and no byte comparison this package makes reads them.
@@ -1461,9 +1462,9 @@ file is in `check.json`, and no byte comparison this package makes reads them.
1461
1462
  Key order is fixed as shown: `spec`, `package`, `command`, `started_at`,
1462
1463
  `finished_at`, `config` (`build` only; `check` reads no config), `outputs`, `argv`.
1463
1464
  `package` and the two times (`SOURCE_DATE_EPOCH` included) are as in `rig-run/1`.
1464
- `config` is the config's `sha256` and its path relative to the real `--out`
1465
- directory, with the config's directory resolved through its links and the file's
1466
- own name kept: a config given through a link is recorded by the link's name.
1465
+ `config` is the config's `sha256` and its path relative to `--out`, using the
1466
+ same directory spelling rule as `argv` below. A config given through a link is
1467
+ recorded by the link's name.
1467
1468
  `outputs` lists every file under the paths the run cleared and wrote —
1468
1469
  for `check`, the report files its `wrote` line names and the directories it names
1469
1470
  (`build/`, `idle_frames/`, …); for `build`, the paths it clears before it starts —
@@ -1475,23 +1476,121 @@ any `-run.json`. Two runs of the same inputs from the same layout differ only in
1475
1476
  `argv` is the command to re-run, then the options as given — not the defaults the
1476
1477
  run used — in the order of the command's flag table (`check --help` lists it):
1477
1478
  valued flags first, a repeated `--alt` in the order given, then the switches
1478
- present. Every path is written relative to the `--out` directory with `/`
1479
- separators: both taken from the working directory, the `--out` directory and the
1480
- path's directory resolved through their links, and the path's own name kept (a path
1481
- given through a link is written by the link's name, as `config.path` is);
1482
- `--out` itself is `.`; a path that cannot be written that way (another Windows drive)
1483
- is written as given. These arguments reproduce the check with the same package
1484
- version, run from the --out directory. When `--out` was given through a link, the
1485
- replay's `build/skeleton.json`, `build/skeleton.model.json` and `check.json` can
1486
- differ from the first run's: rigc spells the skeleton's `images` path from the `--out`
1487
- it is handed without resolving links (rig-c/core#1773). Every other output and key
1488
- matches. A switch's default is not written, so a later
1479
+ present. Each path and `--out` are taken from the working directory. On POSIX,
1480
+ the `--out` directory and the path's directory are resolved through their links.
1481
+ On Windows, both directories keep their supplied spelling. The path keeps its
1482
+ own name and is written relative to `--out` with `/` separators. `--out` itself
1483
+ is `.`. A path on another Windows drive is written as given. These arguments
1484
+ reproduce the check when run from the `--out` directory with the same package
1485
+ version. A switch's default is not written, so a later
1489
1486
  version that changed it would replay differently; that is why the version is in
1490
1487
  `package`. The record is written after the report, in place, and is never a reason to refuse
1491
1488
  the check; a run killed while writing it can leave a partial record, and no other
1492
1489
  file.
1493
1490
 
1494
- `rig-run/2` is stable on the same terms as `rig-run/1`.
1491
+ `rig-run/2` is stable on the same terms as `rig-run/1`. The `check` record retains
1492
+ the same format and bytes for the same files, invocation, version and times.
1493
+
1494
+ ### Build run record (`build-run.json`, spec `rig-run/3`)
1495
+
1496
+ `build` writes `<out>/build-run.json` when its check report completes, including a
1497
+ report with failing bars. Issue #1556 advances `spec` to `rig-run/3` and adds
1498
+ `inputs` between `config` and `outputs`. The fixed key order is `spec`, `package`,
1499
+ `command`, `started_at`, `finished_at`, `config`, `inputs`, `outputs`, `argv`.
1500
+ The other fields and the write timing follow the `rig-run/2` build contract above.
1501
+
1502
+ This example shows a build with full and head layer directories and one alternate tuple.
1503
+ The version and digests are illustrative, and the output list is abbreviated.
1504
+
1505
+ ```json
1506
+ {
1507
+ "spec": "rig-run/3",
1508
+ "package": { "name": "@rig-c/parts", "version": "2.57.0" },
1509
+ "command": "build",
1510
+ "started_at": "2026-11-25T00:00:00.000Z",
1511
+ "finished_at": "2026-11-25T00:00:01.000Z",
1512
+ "config": {
1513
+ "path": "../config.json",
1514
+ "sha256": "00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff"
1515
+ },
1516
+ "inputs": [
1517
+ {
1518
+ "role": "source",
1519
+ "path": "../painting.png",
1520
+ "sha256": "112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00"
1521
+ },
1522
+ {
1523
+ "role": "full",
1524
+ "path": "../layers/full/layers.json",
1525
+ "sha256": "2233445566778899aabbccddeeff00112233445566778899aabbccddeeff0011"
1526
+ },
1527
+ {
1528
+ "role": "head",
1529
+ "path": "../layers/head/layers.json",
1530
+ "sha256": "33445566778899aabbccddeeff00112233445566778899aabbccddeeff001122"
1531
+ },
1532
+ {
1533
+ "role": "alt[0].source",
1534
+ "path": "../side/painting.png",
1535
+ "sha256": "445566778899aabbccddeeff00112233445566778899aabbccddeeff00112233"
1536
+ },
1537
+ {
1538
+ "role": "alt[0].full",
1539
+ "path": "../side/full/layers.json",
1540
+ "sha256": "5566778899aabbccddeeff00112233445566778899aabbccddeeff0011223344"
1541
+ },
1542
+ {
1543
+ "role": "alt[0].head",
1544
+ "path": "../side/head/layers.json",
1545
+ "sha256": "66778899aabbccddeeff00112233445566778899aabbccddeeff001122334455"
1546
+ }
1547
+ ],
1548
+ "outputs": [
1549
+ {
1550
+ "path": "check/check.json",
1551
+ "sha256": "778899aabbccddeeff00112233445566778899aabbccddeeff00112233445566"
1552
+ }
1553
+ ],
1554
+ "argv": [
1555
+ "build", "--config", "../config.json", "--source", "../painting.png",
1556
+ "--full", "../layers/full", "--head", "../layers/head", "--out", ".",
1557
+ "--alt", "side=../side/painting.png:../side/full:../side/head"
1558
+ ]
1559
+ }
1560
+ ```
1561
+
1562
+ Each entry has keys `role`, `path`, `sha256` in that order. The array follows this
1563
+ order regardless of where each flag appears in `argv`.
1564
+
1565
+ | Order | Role | CLI input | File hashed |
1566
+ | --- | --- | --- | --- |
1567
+ | 1 | `source` | `--source` | Painting PNG |
1568
+ | 2 | `full` | `--full` | `<dir>/layers.json` for a directory, or the supplied manifest or PSD |
1569
+ | 3 | `head` | `--head` | `<dir>/layers.json` for a directory, or the supplied manifest or PSD |
1570
+ | 4 | `requirements` | `--requirements` | Requirements JSON |
1571
+ | 5 | `environment` | `--environment` | Environment schedule JSON |
1572
+ | 6 | `wind-band` | `--wind-band` | Wind-band spec JSON |
1573
+ | For each `--alt` in CLI order, first | `alt[i].source` | Tuple source | Alternate painting PNG |
1574
+ | For each `--alt` in CLI order, second | `alt[i].full` | Tuple full | `<dir>/layers.json` for a directory, or the supplied manifest or PSD |
1575
+ | For each `--alt` in CLI order, third | `alt[i].head` | Tuple head | `<dir>/layers.json` for a directory, or the supplied manifest or PSD |
1576
+
1577
+ `i` is zero-based and counts the `--alt` occurrences. Entries for optional flags
1578
+ or tuple members appear only when supplied. The array inventories CLI file
1579
+ inputs. References declared only inside the config and files referenced by a
1580
+ layer manifest are outside this inventory. `config` binds `--config` separately,
1581
+ and `--out` is the output root.
1582
+
1583
+ The run-record writer reads and hashes the raw bytes on disk of the file named by
1584
+ `path` after the check report completes. Keep input files and link targets unchanged
1585
+ from the start of the build until it exits so these digests describe the bytes the
1586
+ stages read.
1587
+
1588
+ Each path uses the shared `--out` link rule. On POSIX the output directory and
1589
+ the file's parent directory resolve through links, and the final filename is kept,
1590
+ including when that filename is a link. On Windows the path is rebased as spelled. Relative
1591
+ paths use `/` separators. A file on another Windows drive is recorded by its
1592
+ file path as given, with `layers.json` appended when the argument names a directory.
1593
+ The paths are relative to the build's `--out` root.
1495
1594
 
1496
1595
  ## Environment
1497
1596
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rig-parts",
3
- "version": "2.57.0",
3
+ "version": "2.58.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": {
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "ag-psd": "^31.0.2",
78
- "@rig-c/core": "3.8.1"
78
+ "@rig-c/core": "3.9.1"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@esotericsoftware/spine-core": "4.3.13",
package/src/build.ts CHANGED
@@ -2952,7 +2952,7 @@ export interface BuildRunners {
2952
2952
  scratch: string;
2953
2953
  }
2954
2954
 
2955
- /** The `rig-run/2` record `build` writes beside its outputs (issue #1541); cleared with them, so a refused build leaves none. */
2955
+ /** The `rig-run/3` record `build` writes beside its outputs after the check report (issues #1541, #1556). */
2956
2956
  export const BUILD_RUN_FILE = 'build-run.json';
2957
2957
  /** Every path `build` writes under `--out`, relative — and so every path it clears first. */
2958
2958
  export const BUILD_OWNS: readonly string[] = ['parts', 'parts.json', SOURCE_COVER_FILE, PAINTING_IN_RIG_FILE, 'recomposite_rig.png', ERROR_MAP_FILE, 'rig', 'check', 'idle.gif', 'idle.png', 'idle-indexed.png', BUILD_RUN_FILE];
@@ -2961,8 +2961,11 @@ export const BUILD_OWNS_FILES: readonly string[] = [CUT_MATERIAL_SOURCES, EDGE_R
2961
2961
 
2962
2962
  function resetBuildOutput(out: string): void {
2963
2963
  makeOutDir(out);
2964
- for (const p of BUILD_OWNS) rmSync(join(out, p), { recursive: true, force: true });
2965
- for (const p of BUILD_OWNS_FILES) rmSync(join(out, p), { force: true });
2964
+ // Bun on Windows returned EINVAL removing a relative path through a junction (BU1556C).
2965
+ // Resolve the spelling against cwd so the path is absolute and keeps the junction.
2966
+ const cleanupOut = sep === '\\' ? resolve(out) : out;
2967
+ for (const p of BUILD_OWNS) rmSync(join(cleanupOut, p), { recursive: true, force: true });
2968
+ for (const p of BUILD_OWNS_FILES) rmSync(join(cleanupOut, p), { force: true });
2966
2969
  }
2967
2970
 
2968
2971
  /** Only selects when cleanup occurs; the real config loader still decides validity. */
package/src/rig.ts CHANGED
@@ -4156,7 +4156,7 @@ function applyStops(
4156
4156
  }
4157
4157
  for (const atts of Object.values(skin)) {
4158
4158
  for (const att of Object.values(atts)) {
4159
- if (!('type' in att)) continue;
4159
+ if (!('type' in att) || att.weights === undefined) continue;
4160
4160
  for (const v of att.weights) {
4161
4161
  for (const w of v) {
4162
4162
  const d = drawn.get(w.bone);
package/src/runstamp.ts CHANGED
@@ -54,8 +54,8 @@ export interface ComposeRun {
54
54
  plates: Array<{ name: string; path: string; sha256: string }>;
55
55
  }
56
56
 
57
- export interface RunStampInputEntry {
58
- role: RunStampInputRole;
57
+ export interface RunStampInputEntry<Role extends string = RunStampInputRole> {
58
+ role: Role;
59
59
  path: string;
60
60
  sha256: string;
61
61
  }
@@ -99,20 +99,12 @@ function relativeToOutRoot(outDir: string, targetPath: string): string {
99
99
  return relative(realOut, realTarget).split(sep).join('/');
100
100
  }
101
101
 
102
- /**
103
- * Build the ordered `inputs` list (`source`, `full`, and `head` when given) for an `assemble` run stamp:
104
- * each entry records `role`, `path` relative to `outDir` by {@link argvPathFromOut} (naming `<dir>/layers.json`
105
- * when given a See-through directory), and `sha256` of the file that `path` names (issue #1554).
106
- */
107
- export function buildAssembleInputs(inputs: RunStampAssembleInputs, outDir: string): RunStampInputEntry[] {
108
- const cwd = inputs.cwd ?? process.cwd();
109
- const raw: ReadonlyArray<readonly [RunStampInputRole, string | null | undefined]> = [
110
- ['source', inputs.source],
111
- ['full', inputs.full],
112
- ['head', inputs.head],
113
- ];
114
- const entries: RunStampInputEntry[] = [];
115
- for (const [role, given] of raw) {
102
+ type RunInputPaths<Role extends string> = Array<readonly [Role, string | null | undefined]>;
103
+
104
+ /** Name and hash the same file. A See-through directory names its manifest (issue #1554). */
105
+ function recordInputs<Role extends string>(paths: RunInputPaths<Role>, outDir: string, cwd: string): RunStampInputEntry<Role>[] {
106
+ const entries: RunStampInputEntry<Role>[] = [];
107
+ for (const [role, given] of paths) {
116
108
  if (given === undefined || given === null) continue;
117
109
  const resolved = resolve(cwd, given);
118
110
  const isDir = statSync(resolved).isDirectory();
@@ -125,6 +117,15 @@ export function buildAssembleInputs(inputs: RunStampAssembleInputs, outDir: stri
125
117
  return entries;
126
118
  }
127
119
 
120
+ /** The ordered inputs (`source`, `full`, and `head` when given) for an `assemble` run stamp. */
121
+ export function buildAssembleInputs(inputs: RunStampAssembleInputs, outDir: string): RunStampInputEntry[] {
122
+ return recordInputs<RunStampInputRole>([
123
+ ['source', inputs.source],
124
+ ['full', inputs.full],
125
+ ['head', inputs.head],
126
+ ], outDir, inputs.cwd ?? process.cwd());
127
+ }
128
+
128
129
  function sortCodeUnits(paths: readonly string[]): string[] {
129
130
  return [...new Set(paths.filter((p) => p !== RUN_STAMP_FILE))].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
130
131
  }
@@ -259,32 +260,32 @@ export function writeRunStamp(input: RunStampInput): RunStamp {
259
260
  }
260
261
 
261
262
  // ---------------------------------------------------------------------------
262
- // rig-run/2: the run record `check` and `build` write (issue #1541)
263
+ // Run records: check (rig-run/2) and build (rig-run/3)
263
264
  // ---------------------------------------------------------------------------
264
265
 
265
266
  export const RUN_RECORD_SPEC = 'rig-run/2' as const;
267
+ export const BUILD_RUN_RECORD_SPEC = 'rig-run/3' as const;
266
268
  /** The record `check` writes in its `--out`; `build` writes {@link BUILD_RUN_FILE}. Neither can be the rig's `run.json`. */
267
269
  export const CHECK_RUN_FILE = 'check-run.json' as const;
268
270
  export { BUILD_RUN_FILE };
269
271
 
270
272
  export type RunRecordCommand = 'check' | 'build';
271
273
 
272
- /**
273
- * A `rig-run/2` record: the `rig-run/1` keys `check` and `build` have, then `argv`, the arguments that reproduce
274
- * the run with the same package version, run from the `--out` directory. `config` is written by `build` only;
275
- * `check` reads no config.
276
- */
277
- export interface RunRecord {
278
- spec: typeof RUN_RECORD_SPEC;
274
+ /** Both records carry the arguments to reproduce the run with the same version, run from `--out`. */
275
+ interface RunRecordFields {
279
276
  package: RunStampPackage;
280
- command: RunRecordCommand;
281
277
  started_at: string;
282
278
  finished_at: string;
283
- config?: RunStampFileEntry;
284
279
  outputs: RunStampFileEntry[];
285
280
  argv: string[];
286
281
  }
287
282
 
283
+ export type BuildRunInputRole = RunStampInputRole | 'requirements' | 'environment' | 'wind-band' | `alt[${number}].${RunStampInputRole}`;
284
+
285
+ export type RunRecord =
286
+ | (RunRecordFields & { spec: typeof RUN_RECORD_SPEC; command: 'check' })
287
+ | (RunRecordFields & { spec: typeof BUILD_RUN_RECORD_SPEC; command: 'build'; config: RunStampFileEntry; inputs: RunStampInputEntry<BuildRunInputRole>[] });
288
+
288
289
  /** One command's flags as its parser takes them: the flag-table order, which values are paths, and values that hold paths inside them. */
289
290
  export interface ArgvTable {
290
291
  valued: readonly string[];
@@ -385,32 +386,65 @@ export function isRunRecordFile(path: string): boolean {
385
386
  return name === RUN_STAMP_FILE || name.endsWith('-run.json');
386
387
  }
387
388
 
388
- export interface RunRecordInput {
389
+ interface RunRecordInputFields {
389
390
  pkg: RunStampPackage;
390
- command: RunRecordCommand;
391
391
  startedAt: string;
392
392
  finishedAt: string;
393
393
  outDir: string;
394
- /** `build` only: the config it read. */
395
- configPath?: string;
396
394
  /** What the run wrote under `outDir`, relative, a directory standing for every file under it. */
397
395
  outputs: readonly string[];
398
396
  argv: readonly string[];
399
397
  }
400
398
 
401
- /** Build a `rig-run/2` record from the files on disk. Pure with respect to the clock: the times are the caller's. */
399
+ interface BuildRunInputs extends RunStampAssembleInputs {
400
+ requirements?: string;
401
+ environment?: string;
402
+ windBand?: string;
403
+ alts?: readonly Omit<RunStampAssembleInputs, 'cwd'>[];
404
+ }
405
+
406
+ export type RunRecordInput = RunRecordInputFields & (
407
+ | { command: 'check' }
408
+ | { command: 'build'; configPath: string; inputs: BuildRunInputs }
409
+ );
410
+
411
+ function buildRunInputs(inputs: BuildRunInputs, outDir: string): RunStampInputEntry<BuildRunInputRole>[] {
412
+ const paths: RunInputPaths<BuildRunInputRole> = [
413
+ ['source', inputs.source],
414
+ ['full', inputs.full],
415
+ ['head', inputs.head],
416
+ ['requirements', inputs.requirements],
417
+ ['environment', inputs.environment],
418
+ ['wind-band', inputs.windBand],
419
+ ];
420
+ inputs.alts?.forEach(({ source, full, head }, i) => {
421
+ paths.push([`alt[${i}].source`, source], [`alt[${i}].full`, full], [`alt[${i}].head`, head]);
422
+ });
423
+ return recordInputs(paths, outDir, inputs.cwd ?? process.cwd());
424
+ }
425
+
426
+ /** Build a run record from the files on disk using the caller's timestamps. */
402
427
  export function buildRunRecord(input: RunRecordInput): RunRecord {
403
428
  const paths = [...new Set(input.outputs.flatMap((e) => filesUnder(input.outDir, e)))].filter((p) => !isRunRecordFile(p)).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
404
- return {
405
- spec: RUN_RECORD_SPEC,
406
- package: { name: input.pkg.name, version: input.pkg.version },
407
- command: input.command,
429
+ const pkg = { name: input.pkg.name, version: input.pkg.version };
430
+ const times = {
408
431
  started_at: input.startedAt,
409
432
  finished_at: input.finishedAt,
410
- ...(input.configPath === undefined ? {} : { config: { path: recordedConfigPath(input.outDir, input.configPath), sha256: sha256OnDisk(input.configPath) } }),
433
+ };
434
+ const tail = {
411
435
  outputs: paths.map((p) => ({ path: p, sha256: sha256OnDisk(join(input.outDir, ...p.split('/'))) })),
412
436
  argv: [...input.argv],
413
437
  };
438
+ if (input.command === 'check') return { spec: RUN_RECORD_SPEC, package: pkg, command: 'check', ...times, ...tail };
439
+ return {
440
+ spec: BUILD_RUN_RECORD_SPEC,
441
+ package: pkg,
442
+ command: 'build',
443
+ ...times,
444
+ config: { path: recordedConfigPath(input.outDir, input.configPath), sha256: sha256OnDisk(input.configPath) },
445
+ inputs: buildRunInputs(input.inputs, input.outDir),
446
+ ...tail,
447
+ };
414
448
  }
415
449
 
416
450
  /** Write `<outDir>/check-run.json` or `<outDir>/build-run.json`, after the command's report is on disk. */
package/src/turn.ts CHANGED
@@ -585,6 +585,10 @@ interface DeformRegionAttachment {
585
585
  rotation?: number;
586
586
  }
587
587
 
588
+ function hasDeformWeights(att: DeformMeshAttachment | DeformRegionAttachment | undefined): att is DeformMeshAttachment {
589
+ return att !== undefined && 'type' in att && att.weights !== undefined;
590
+ }
591
+
588
592
  interface DeriveSpec {
589
593
  kind: 'yaw' | 'pitch';
590
594
  degrees: number;
@@ -754,6 +758,15 @@ export function applyFaceSurfaceDeform(
754
758
  });
755
759
  });
756
760
  }
761
+ const faceSlot = rig.skins.default.face;
762
+ const faceAtt = faceSlot?.face;
763
+ if (faceAtt !== undefined && 'type' in faceAtt && !hasDeformWeights(faceAtt)) {
764
+ preProblems.push({
765
+ code: 'RIG_TURN_LEGACY_FACE_WEIGHTS',
766
+ object: 'skins.default.face.face',
767
+ detail: 'has no weight rows for the legacy head turn face frame; use config.turn.roles for a generated face surface',
768
+ });
769
+ }
757
770
  refuseIfAny(preProblems);
758
771
 
759
772
  const tiltAnim = rawTilt === undefined ? undefined : structuredClone(rawTilt);
@@ -818,9 +831,7 @@ export function applyFaceSurfaceDeform(
818
831
  rig.constraints = nextConstraints;
819
832
  }
820
833
 
821
- const faceSlot = rig.skins.default.face;
822
- if (faceSlot === undefined || faceSlot.face === undefined) return;
823
- const faceAtt = faceSlot.face;
834
+ if (faceSlot === undefined || faceAtt === undefined) return;
824
835
 
825
836
  let faceW = opts.imageWidth ?? 114;
826
837
  let faceH = opts.imageHeight ?? 136;
@@ -883,7 +894,7 @@ export function applyFaceSurfaceDeform(
883
894
  for (const slotName of ['hair_front', 'hair_back', 'hairpin']) {
884
895
  const slotObj = rig.skins.default[slotName];
885
896
  const att = slotObj?.[slotName];
886
- if (att !== undefined && 'type' in att) {
897
+ if (hasDeformWeights(att)) {
887
898
  for (const infls of att.weights) {
888
899
  infls.sort((a, b) => (boneOrder.get(a.bone) ?? 0) - (boneOrder.get(b.bone) ?? 0));
889
900
  }
@@ -1026,9 +1037,9 @@ export function applyFaceSurfaceDeform(
1026
1037
  const hairFrontAtt = rig.skins.default.hair_front?.hair_front;
1027
1038
  const hairBackAtt = rig.skins.default.hair_back?.hair_back;
1028
1039
  const hairpinAtt = rig.skins.default.hairpin?.hairpin;
1029
- const hairFrontVerts = hairFrontAtt !== undefined && 'type' in hairFrontAtt ? getMeshSetup(hairFrontAtt) : null;
1030
- const hairBackVerts = hairBackAtt !== undefined && 'type' in hairBackAtt ? getMeshSetup(hairBackAtt) : null;
1031
- const hairpinVerts = hairpinAtt !== undefined && 'type' in hairpinAtt && !boneMap.has('hairpin') ? getMeshSetup(hairpinAtt) : null;
1040
+ const hairFrontVerts = hasDeformWeights(hairFrontAtt) ? getMeshSetup(hairFrontAtt) : null;
1041
+ const hairBackVerts = hasDeformWeights(hairBackAtt) ? getMeshSetup(hairBackAtt) : null;
1042
+ const hairpinVerts = hasDeformWeights(hairpinAtt) && !boneMap.has('hairpin') ? getMeshSetup(hairpinAtt) : null;
1032
1043
 
1033
1044
  const hyCrown = Y0 + (67 / 128) * H;
1034
1045
  const hyCrownStart = Y0 + (24 / 128) * H;
@@ -1207,8 +1218,7 @@ export function applyFaceSurfaceDeform(
1207
1218
  const rawBackFrac = opts.turn != null ? headTurnFraction(opts.turn, 'hair_back', headParts, opts.partAreas) : null;
1208
1219
  const rawHairpinFrac = opts.turn != null ? headTurnFraction(opts.turn, 'hairpin', headParts, opts.partAreas) : null;
1209
1220
  const hairpinRidesBack =
1210
- hairpinAtt !== undefined &&
1211
- 'type' in hairpinAtt &&
1221
+ hasDeformWeights(hairpinAtt) &&
1212
1222
  hairpinAtt.weights.some((infls) => infls.some((w) => w.bone.includes('hairback_')));
1213
1223
 
1214
1224
  const dxFaceCenterAt = (deg: number): number => FACE_DEFORM_MULT * deg * W * unmult(f.turn_mid_x);
@@ -1552,6 +1562,16 @@ interface Depth25DTurnRig {
1552
1562
  stops?: ReadonlyArray<{ links: readonly string[] }>;
1553
1563
  }
1554
1564
 
1565
+ interface TurnBandCover {
1566
+ part: string;
1567
+ index: number;
1568
+ name: string;
1569
+ bone: string;
1570
+ cover: string;
1571
+ field: 'head' | 'body';
1572
+ canvas: readonly [number, number];
1573
+ }
1574
+
1555
1575
  /** Stop draw bones share their link's setup frame; Core emits them later. */
1556
1576
  function surfaceSetupGraph(rig: Depth25DTurnRig) {
1557
1577
  const aliases = new Map<string, string>();
@@ -1570,6 +1590,7 @@ function buildDepth25DTurnGroup(
1570
1590
  },
1571
1591
  opts: Depth25DTurnOptions,
1572
1592
  group: Depth25DGroupSpec,
1593
+ bandCovers: readonly TurnBandCover[],
1573
1594
  problems: Problem[],
1574
1595
  ): void {
1575
1596
  const { roles } = group;
@@ -1657,82 +1678,73 @@ function buildDepth25DTurnGroup(
1657
1678
  // Issue #1548: resolve declared band covers once per region, at the region bone's setup position,
1658
1679
  // on the cover's extended sheet, requiring full opacity (alpha 255) on the cover's art.
1659
1680
  const bandCoverDepthsByPart = new Map<string, Map<string, number>>();
1660
- {
1681
+ if (bandCovers.length > 0) {
1661
1682
  const field = group.fieldPrefix === 'config.turn' ? 'head' : 'body';
1662
1683
  const setupForCover = surfaceSetupGraph(rig);
1663
1684
  const worldForCover = computeWorldTransforms(setupForCover.bones);
1664
- const checkedPartBones = new Set<string>();
1665
- for (const mesh of opts.surfaceMeshes ?? []) {
1666
- if (mesh.groups === undefined) continue;
1667
- const bands =
1668
- opts.contourBands?.[mesh.part]?.map((b, index) => ({ index, name: b.name, bone: b.bone, cover: b.cover })) ??
1669
- mesh.contourRegions?.map((r) => ({ index: r.index, name: r.name, bone: r.bone, cover: r.cover })) ??
1670
- [];
1671
- for (const reg of bands) {
1672
- const key = `${mesh.part}\0${reg.index}`;
1673
- if (reg.cover === undefined || mesh.groups.get(reg.bone) !== field || checkedPartBones.has(key)) continue;
1674
- checkedPartBones.add(key);
1675
- const coverSheet = surfaceSheets.get(reg.cover);
1676
- if (coverSheet === undefined) continue;
1677
- let pt: readonly [number, number] | undefined = opts.boneLandmarks.get(reg.bone);
1678
- if (pt === undefined) {
1679
- const frame = worldForCover.get(setupForCover.resolve(reg.bone));
1680
- if (frame !== undefined) {
1681
- const [cx, cy] = setupToPaintingPoint([frame.worldX, frame.worldY], mesh.canvas, mesh.canvas);
1682
- pt = [pyRound(cx, 4), pyRound(cy, 4)];
1683
- }
1685
+ for (const reg of bandCovers) {
1686
+ if (reg.field !== field) continue;
1687
+ // Validation requires this group's surface role and input rasters for the cover.
1688
+ // The sheet pass has already refused if it could not prepare any declared surface.
1689
+ const coverSheet = surfaceSheets.get(reg.cover)!;
1690
+ let pt: readonly [number, number] | undefined = opts.boneLandmarks.get(reg.bone);
1691
+ if (pt === undefined) {
1692
+ const frame = worldForCover.get(reg.bone);
1693
+ if (frame !== undefined) {
1694
+ const [cx, cy] = setupToPaintingPoint([frame.worldX, frame.worldY], reg.canvas, reg.canvas);
1695
+ pt = [pyRound(cx, 4), pyRound(cy, 4)];
1684
1696
  }
1685
- const at = `config.meshes.${mesh.part}.contour.regions[${reg.index}].cover`;
1686
- if (pt === undefined) {
1687
- problems.push({
1688
- code: 'RIG_TURN_BAND_COVER_SUPPORT',
1689
- object: at,
1690
- detail: `region "${reg.name}" bone "${reg.bone}" has no resolved setup position to sample cover "${reg.cover}"`,
1691
- });
1692
- continue;
1693
- }
1694
- const { rec: cRec, ext: cExt, zRef: cZRef } = coverSheet;
1695
- const cArt = opts.images.get(cRec.name);
1696
- const padX = Math.floor((cExt.width - cRec.w) / 2);
1697
- const padY = Math.floor((cExt.height - cRec.h) / 2);
1698
- const rawX = pt[0] - cRec.x;
1699
- const rawY = pt[1] - cRec.y;
1700
- const lx = Math.round(rawX + padX);
1701
- const ly = Math.round(rawY + padY);
1702
- const artX = lx - padX;
1703
- const artY = ly - padY;
1704
- const outside =
1705
- rawX < 0 ||
1706
- rawY < 0 ||
1707
- rawX > cRec.w - 1 ||
1708
- rawY > cRec.h - 1 ||
1709
- artX < 0 ||
1710
- artY < 0 ||
1711
- artX >= cRec.w ||
1712
- artY >= cRec.h ||
1713
- lx < 0 ||
1714
- ly < 0 ||
1715
- lx >= cExt.width ||
1716
- ly >= cExt.height;
1717
- const alpha = outside || cArt === undefined ? 0 : cArt.data[(artY * cRec.w + artX) * 4 + 3];
1718
- if (outside || alpha !== 255) {
1719
- problems.push({
1720
- code: 'RIG_TURN_BAND_COVER_SUPPORT',
1721
- object: at,
1722
- detail: outside
1723
- ? `region "${reg.name}" bone "${reg.bone}" setup point [${pt[0]}, ${pt[1]}] lies outside cover "${cRec.name}" bounds [${cRec.x}, ${cRec.y}]..[${cRec.x + cRec.w - 1}, ${cRec.y + cRec.h - 1}] (alpha 0; alpha 255 on "${cRec.name}" is required)`
1724
- : `region "${reg.name}" bone "${reg.bone}" setup point [${pt[0]}, ${pt[1]}] has alpha ${alpha} on cover "${cRec.name}" (texel [${artX}, ${artY}] in [${cRec.x}, ${cRec.y}]..[${cRec.x + cRec.w - 1}, ${cRec.y + cRec.h - 1}]; alpha 255 is required)`,
1725
- });
1726
- continue;
1727
- }
1728
- const zCover = levelToDepthZ(cExt.data[(ly * cExt.width + lx) * 4], cRec.depth);
1729
- let boneDepths = bandCoverDepthsByPart.get(mesh.part);
1730
- if (boneDepths === undefined) {
1731
- boneDepths = new Map<string, number>();
1732
- bandCoverDepthsByPart.set(mesh.part, boneDepths);
1733
- }
1734
- boneDepths.set(reg.bone, pivot + zCover - cZRef);
1735
1697
  }
1698
+ const at = `config.meshes.${reg.part}.contour.regions[${reg.index}].cover`;
1699
+ if (pt === undefined) {
1700
+ problems.push({
1701
+ code: 'RIG_TURN_BAND_COVER_SUPPORT',
1702
+ object: at,
1703
+ detail: `region "${reg.name}" bone "${reg.bone}" has no resolved setup position to sample cover "${reg.cover}"`,
1704
+ });
1705
+ continue;
1706
+ }
1707
+ const { rec: cRec, ext: cExt, zRef: cZRef } = coverSheet;
1708
+ const cArt = opts.images.get(cRec.name);
1709
+ const padX = Math.floor((cExt.width - cRec.w) / 2);
1710
+ const padY = Math.floor((cExt.height - cRec.h) / 2);
1711
+ const rawX = pt[0] - cRec.x;
1712
+ const rawY = pt[1] - cRec.y;
1713
+ const lx = Math.round(rawX + padX);
1714
+ const ly = Math.round(rawY + padY);
1715
+ const artX = lx - padX;
1716
+ const artY = ly - padY;
1717
+ const outside =
1718
+ rawX < 0 ||
1719
+ rawY < 0 ||
1720
+ rawX > cRec.w - 1 ||
1721
+ rawY > cRec.h - 1 ||
1722
+ artX < 0 ||
1723
+ artY < 0 ||
1724
+ artX >= cRec.w ||
1725
+ artY >= cRec.h ||
1726
+ lx < 0 ||
1727
+ ly < 0 ||
1728
+ lx >= cExt.width ||
1729
+ ly >= cExt.height;
1730
+ const alpha = outside || cArt === undefined ? 0 : cArt.data[(artY * cRec.w + artX) * 4 + 3];
1731
+ if (outside || alpha !== 255) {
1732
+ problems.push({
1733
+ code: 'RIG_TURN_BAND_COVER_SUPPORT',
1734
+ object: at,
1735
+ detail: outside
1736
+ ? `region "${reg.name}" bone "${reg.bone}" setup point [${pt[0]}, ${pt[1]}] lies outside cover "${cRec.name}" bounds [${cRec.x}, ${cRec.y}]..[${cRec.x + cRec.w - 1}, ${cRec.y + cRec.h - 1}] (alpha 0; alpha 255 on "${cRec.name}" is required)`
1737
+ : `region "${reg.name}" bone "${reg.bone}" setup point [${pt[0]}, ${pt[1]}] has alpha ${alpha} on cover "${cRec.name}" (texel [${artX}, ${artY}] in [${cRec.x}, ${cRec.y}]..[${cRec.x + cRec.w - 1}, ${cRec.y + cRec.h - 1}]; alpha 255 is required)`,
1738
+ });
1739
+ continue;
1740
+ }
1741
+ const zCover = levelToDepthZ(cExt.data[(ly * cExt.width + lx) * 4], cRec.depth);
1742
+ let boneDepths = bandCoverDepthsByPart.get(reg.part);
1743
+ if (boneDepths === undefined) {
1744
+ boneDepths = new Map<string, number>();
1745
+ bandCoverDepthsByPart.set(reg.part, boneDepths);
1746
+ }
1747
+ boneDepths.set(reg.bone, pivot + zCover - cZRef);
1736
1748
  }
1737
1749
  if (problems.length > startProblems) return;
1738
1750
  }
@@ -2252,8 +2264,8 @@ export function buildDepth25DTurn(
2252
2264
  if (new Set(groups.values()).size === 2) blended.add(mesh.part);
2253
2265
  return { mesh, groups, outside };
2254
2266
  });
2255
- // Issue #1543: a contour region on a turn surface bound to a bone in the
2256
- // other turn group's subtree must weight at least one vertex above 0.
2267
+ // Issue #1543: an other-group region without cover must weight at least one vertex.
2268
+ // Regions declaring cover are checked against their emitted bindings below.
2257
2269
  const checkedBandParts = new Set<string>();
2258
2270
  for (const { mesh } of classified ?? []) {
2259
2271
  if (mesh.contourRegions === undefined || checkedBandParts.has(mesh.part)) continue;
@@ -2277,7 +2289,7 @@ export function buildDepth25DTurn(
2277
2289
  : bodySurface && !headSurface
2278
2290
  ? regGroup === 'head'
2279
2291
  : partGroups.size === 1 && !partGroups.has(regGroup);
2280
- if (!inOtherGroup || reg.weightedVertices > 0) continue;
2292
+ if (!inOtherGroup || reg.weightedVertices > 0 || reg.cover !== undefined) continue;
2281
2293
  problems.push({
2282
2294
  code: 'RIG_TURN_BAND_REACHES_NO_VERTEX',
2283
2295
  object: `config.meshes.${mesh.part}.contour.regions[${reg.index}]`,
@@ -2285,9 +2297,13 @@ export function buildDepth25DTurn(
2285
2297
  });
2286
2298
  }
2287
2299
  }
2288
- // Issue #1548: validate contour.regions[].cover against turn roles, subtree membership, and part depth sheets.
2300
+ // Only validated declarations reach the sampler. Cover matches the exact
2301
+ // emitted influence name and requires a blended part to emit its other field.
2302
+ const bandCovers: TurnBandCover[] = [];
2303
+ const ownershipBands = { ...opts.contourBands };
2289
2304
  {
2290
2305
  const partMap = new Map(opts.parts.map((p) => [p.name, p]));
2306
+ const stoppedLinks = new Set((rig.stops ?? []).flatMap(s => s.links));
2291
2307
  const groupOf = (bone: string): 'head' | 'body' | null =>
2292
2308
  descends(bone, 'head') ? 'head' : !descends(bodyRoot, 'head') && descends(bone, bodyRoot) ? 'body' : null;
2293
2309
  const bandParts = new Set<string>([
@@ -2296,11 +2312,14 @@ export function buildDepth25DTurn(
2296
2312
  ]);
2297
2313
  for (const part of bandParts) {
2298
2314
  const partEntries = (classified ?? []).filter((c) => c.mesh.part === part);
2315
+ const summaries = new Map(partEntries.flatMap(({ mesh }) => (mesh.contourRegions ?? []).map(r => [r.index, r] as const)));
2299
2316
  const bands =
2300
2317
  opts.contourBands?.[part]?.map((b, index) => ({ index, name: b.name, bone: b.bone, cover: b.cover })) ??
2301
- partEntries[0]?.mesh.contourRegions?.map((r) => ({ index: r.index, name: r.name, bone: r.bone, cover: r.cover })) ??
2302
- [];
2318
+ [...summaries.values()];
2303
2319
  if (!bands.some((b) => b.cover !== undefined)) continue;
2320
+ // The normal rig path supplies contourBands; direct callers can supply
2321
+ // covered declarations via contourRegions and get the same owner exemption.
2322
+ ownershipBands[part] ??= bands.filter(b => b.cover !== undefined);
2304
2323
  const headSurface = opts.turn.roles?.[part] === 'surface';
2305
2324
  const bodySurface = opts.turn.body?.roles[part] === 'surface';
2306
2325
  const bandBoneSet = new Set(bands.map((b) => b.bone));
@@ -2325,6 +2344,15 @@ export function buildDepth25DTurn(
2325
2344
  }
2326
2345
  if (reg.cover === undefined) continue;
2327
2346
  const at = `config.meshes.${part}.contour.regions[${reg.index}].cover`;
2347
+ const stoppedLink = setup.resolve(reg.bone);
2348
+ if (stoppedLinks.has(stoppedLink)) {
2349
+ problems.push({
2350
+ code: 'CONFIG_TURN_BAND_COVER',
2351
+ object: at,
2352
+ detail: `region "${reg.name}" declares cover "${reg.cover}" on stopped link "${stoppedLink}"; stops bind the mesh to "${stoppedLink}_d", and cover requires an unstopped control bone`,
2353
+ });
2354
+ continue;
2355
+ }
2328
2356
  if (!headSurface && !bodySurface) {
2329
2357
  problems.push({
2330
2358
  code: 'CONFIG_TURN_BAND_COVER',
@@ -2375,7 +2403,29 @@ export function buildDepth25DTurn(
2375
2403
  object: at,
2376
2404
  detail: `names "${reg.cover}", which carries no depth sheet in parts.json; run assemble with config.depth or provide "${reg.cover}_depth.png"`,
2377
2405
  });
2406
+ continue;
2407
+ }
2408
+ const binding = partEntries.find(({ groups }) => groups.get(reg.bone) === regGroup);
2409
+ if (summaries.get(reg.index)?.weightedVertices === 0 || binding === undefined) {
2410
+ problems.push({
2411
+ code: 'RIG_TURN_BAND_COVER_SUPPORT',
2412
+ object: at,
2413
+ detail: `region "${reg.name}" bone "${reg.bone}" gives no mesh vertex a positive influence from the region to carry cover "${reg.cover}"; move the region onto the mesh or widen its band`,
2414
+ });
2415
+ continue;
2378
2416
  }
2417
+ if (!blended.has(part)) {
2418
+ problems.push({
2419
+ code: 'RIG_TURN_BAND_COVER_SUPPORT',
2420
+ object: at,
2421
+ detail: `region "${reg.name}" bone "${reg.bone}" cannot carry cover "${reg.cover}"; no attachment of "${part}" has positive bindings in both turn groups to emit the other-group deform`,
2422
+ });
2423
+ continue;
2424
+ }
2425
+ bandCovers.push({
2426
+ part, index: reg.index, name: reg.name, bone: reg.bone, cover: reg.cover,
2427
+ field: regGroup, canvas: binding.mesh.canvas,
2428
+ });
2379
2429
  }
2380
2430
  }
2381
2431
  }
@@ -2401,7 +2451,7 @@ export function buildDepth25DTurn(
2401
2451
  });
2402
2452
  refuseIfAny(problems);
2403
2453
  if (blended.size > 0) {
2404
- const owners = turnOverlapOwners(rig, opts, classified ?? [], blended, problems);
2454
+ const owners = turnOverlapOwners(rig, { ...opts, contourBands: ownershipBands }, classified ?? [], blended, problems);
2405
2455
  refuseIfAny(problems);
2406
2456
  const overlapped = surfaceMeshes?.map((mesh, i) => {
2407
2457
  const overlapOwners = owners.get(classified![i].mesh);
@@ -2436,6 +2486,7 @@ export function buildDepth25DTurn(
2436
2486
  { kind: 'pitch', animName: 'tilt', sliderName: 'pitch', dialBone: PITCH_DIAL_BONE, maxDeg: pitchMax },
2437
2487
  ],
2438
2488
  },
2489
+ bandCovers,
2439
2490
  problems,
2440
2491
  );
2441
2492
  }
@@ -2463,6 +2514,7 @@ export function buildDepth25DTurn(
2463
2514
  { kind: 'yaw', animName: BODY_TURN_ANIM, sliderName: bodySlider, dialBone: bodySlider, maxDeg: yawMax },
2464
2515
  ],
2465
2516
  },
2517
+ bandCovers,
2466
2518
  problems,
2467
2519
  );
2468
2520
  }