rig-parts 2.65.0 → 2.66.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
@@ -7227,7 +7227,8 @@ and stay absent).
7227
7227
  | <a id="SCENE_REPEAT_DURATION"></a>`SCENE_REPEAT_DURATION` | the declared idle duration disagrees with a character’s source period times its playback count, or `scene.repeats` names a take without a positive authored duration or with animation keys ending off the period clock | use the exact finite, positive product for every character. Declare the whole take duration and make the latest effective scene animation key end exactly at duration divided by the scene repeat count |
7228
7228
  | <a id="SCENE_PHYSICS_CLIP_DECLARED"></a>`SCENE_PHYSICS_CLIP_DECLARED` | a character’s physics-only clip beside `idle` lacks a declaration. The refusal names the character, clip and distinct keyed constraint count | declare literal `false` in `with_idle` at any scale, or declare a whole-period count at scale 1 |
7229
7229
  | <a id="SCENE_PHYSICS_CLIP_ONLY"></a>`SCENE_PHYSICS_CLIP_ONLY` | a `with_idle` entry names `idle`, an absent clip, a clip with no physics keys or a clip with other timelines | use the source name of a physics-only clip beside `idle`. This applies to counts and to `false` |
7230
- | <a id="SCENE_WITH_IDLE_DURATION"></a>`SCENE_WITH_IDLE_DURATION` | a numeric `with_idle` entry implies a duration different from the played idle. The refusal names the clip and the conflicting lengths. The diagnostic searches up to 10,000 copies of each source. Acceptance depends on exact duration equality regardless of that search bound | use the smallest exact pair of whole-period counts when the diagnostic finds one, retime the source clip supplied through `motion.animations_from`, adjust the source idle with `motion.duration`, or declare `false` |
7230
+ | <a id="PHYSICS_CLIPS_MOTION"></a>`PHYSICS_CLIPS_MOTION` | `physicsOnlyClips` receives an invalid motion document | parse the source `motion.json` and supply a valid `rigc-motion/1` document |
7231
+ | <a id="SCENE_WITH_IDLE_DURATION"></a>`SCENE_WITH_IDLE_DURATION` | a numeric `with_idle` entry implies a duration different from the played idle. The refusal names the clip and the conflicting lengths. The diagnostic searches up to 10,000 copies of each source. Acceptance depends on exact duration equality regardless of that search bound | use the suggested whole-period counts when available. The diagnostic can also suggest a scene repeat count, total idle duration and camera terminal key when it knows the scene period. Otherwise determine the scene period before setting `scene.repeats.idle`. You can also retime the source clip supplied through `motion.animations_from`, adjust the source idle with `motion.duration`, or declare `false` |
7231
7232
  | <a id="SCENE_REPEAT_SOURCE_LOOP_CLOSES"></a>`SCENE_REPEAT_SOURCE_LOOP_CLOSES` | a repeated source idle has a loop flag other than `true`, or its original gated keyed poses at the start and stored end do not close or cannot be read | use a closed source idle with `loop: true` and correct the named pose channel |
7232
7233
  | <a id="SCENE_REPEAT_KEY_SEAM"></a>`SCENE_REPEAT_KEY_SEAM` | a repeated source timeline cannot be spliced on its effective key clock, for example because of a setup gap, an unequal boundary state or left limit, a reset at the boundary or a period that collapses on the playback clock. Repeated scene animations also refuse timeline families without a defined splice | author a state timeline that starts at effective time zero and closes continuously, with any explicit reset strictly inside the source period and separate on Core's playback clock |
7233
7234
  | <a id="CE_COMPILE_ANIMATION_GROUP_UNKNOWN"></a>`CE_COMPILE_ANIMATION_GROUP_UNKNOWN` | a scene track names no own declared group, including inherited object names such as `constructor` | name an explicitly declared final group; prototype properties are not groups |
@@ -8078,7 +8079,7 @@ the composed idle under `<out>/check/`, at the viewport used for the shipped fra
8078
8079
  | `characters[].with_idle` | map from each source physics-only clip beside `idle` to a safe integer of at least 1 or literal `false` (issue #1615). A count requires character scale 1 and folds whole periods into the played idle. `false` leaves that clip out of the idle at any character scale. Both retain the prefixed side clip, which must pass the character's scale checks. See [Physics clips and scene repeats](#physics-clips-and-scene-repeats-issue-1615) |
8079
8080
  | `characters[].accept` | optional, a list of bar names: the bars this character's own check may have failed and still be composed (issue #203). `compose --accept <bar>[,<bar>…]` is the same list for every character; the two are joined, so the command line applies to every character and a character's list adds to it. Each name is one of the bars `check`'s summary names, less the gate — `loop`, `seam`, `BREATH_VISIBLE`, `BLINK_NO_HOLE`, `CHAIN_LAG`, `TIP_OVER_ROOT`, `STILL_REGIONS_DARK`, `TEXTURE_STRETCH`, `ANIMATIONS_DO_NOT_FOLD` (issue #320), `STRESS_OFF_CHAIN` (issue #347), `SEAM_OVER_MOTION` (the body-root bar, issue #686); anything else is `SCENE_ACCEPT_KNOWN`. When `check/check.json` declares `spec: "rig-parts-check/1"`, `compose` reads its `bar_outcomes` for the bars whose outcome status is `FAIL` in the report's order (issue #1373); without that spec it keeps the legacy `barsNotMet` reading. A build is taken when every bar its `check.json` failed is named; its gate red, a declared requirement not PASS, or a bar not named is `SCENE_BUILD_GREEN` as before. **It is for looking, not for shipping:** the `[compose]` line says which failing bars were accepted, `scene.json` records them as the character's `accepted`, the composed rig's own check measures them again and reports them as it finds them, and the run exits 1 even when that check is PASS (a composed rig has no `parts.json`, so the seam and four judgement lines say SKIP there). A list that accepts nothing — every build green — composes to the bytes a scene without one writes |
8080
8081
  | `animations` | optional map by scene clip name, each value a rigc `MotionAnimation` (`duration`, `tracks`, optional `loop`, `note`, and core timeline collections). Names resolve against the final scene without another prefix or unit conversion: `root`, `plate`, declared named plate bones and `<id>:<bone>`, including generated dials. Keying `root` moves the whole scene. A new name adds a clip. `idle` appends the resulting tracks and timelines to the composed idle, preserving character metadata and physics constraints. Its duration must exactly equal the composed idle (`SCENE_DURATION_AGREES`, or `SCENE_REPEAT_DURATION` when a character opts in to repetition). Imported animation names are reserved (`SCENE_ANIMATION_NAME_FREE`). See `repeats` for period-authored tracks and deforms |
8081
- | `repeats` | optional map from authored take names to safe integers of at least 2 (issue #1615). Repeats the scene-authored tracks, deforms and camera keys on a single period clock. `animations.<take>.duration` is the whole take duration. See [Physics clips and scene repeats](#physics-clips-and-scene-repeats-issue-1615) |
8082
+ | `repeats` | optional map from authored take names to safe integers of at least 2 (issue #1615). Repeats the scene-authored tracks, deforms and camera keys on a single period clock. `animations.<take>.duration` is the whole take duration. `scene.json` echoes the map in declared order as its final top-level key after `idle_duration` and omits it when absent. See [Physics clips and scene repeats](#physics-clips-and-scene-repeats-issue-1615) |
8082
8083
  | `camera` | optional keyed view over composed animation names. See [Keyed scene camera](#keyed-scene-camera-issue-1596) for the camera clock, coverage requirements and opt-in report version |
8083
8084
  | `order` | the draw order, back to front: a character id (its slots not named elsewhere, in its own order) or one `<id>:<slot>`. Every slot of every character is drawn exactly once. Interleaving is written by naming slots: `["a", "b:arm_l", "b"]` draws `b`'s left arm between `a` and the rest of `b` |
8084
8085
 
@@ -8402,8 +8403,17 @@ seam evidence after the run. This refusal clears `rig/`, `check/`, `scene.json`
8402
8403
  #### Physics clips and scene repeats (issue #1615)
8403
8404
 
8404
8405
  A physics-only side clip typically enters a character build through
8405
- `motion.animations_from`. It has at least one track, every track targets a
8406
- physics constraint alone, and it has no other populated timeline collections.
8406
+ `motion.animations_from`. It has at least one track, every track targets only
8407
+ a named physics constraint, and every other animation payload is empty or
8408
+ absent. Clip metadata such as `loop` and `note` is allowed.
8409
+
8410
+ To discover the source clip names for `with_idle`, import `physicsOnlyClips`
8411
+ from `@rig-c/parts/physics-clips` and pass the parsed `rigc-motion/1` value from
8412
+ the character's `motion.json`. `compose` uses the same export. It returns
8413
+ `{ name, duration, constraints }` rows in source animation order, excluding
8414
+ `idle`. Constraint names are distinct and follow first-keyed order. If no clips
8415
+ match, it returns `[]`. Invalid motion raises [`PHYSICS_CLIPS_MOTION`](#PHYSICS_CLIPS_MOTION).
8416
+
8407
8417
  Declare each such clip by its source name in `characters[].with_idle`. A count
8408
8418
  copies that many whole periods into the composed `idle` with the character's
8409
8419
  prefix. Literal `false` plays the idle without that clip. The standalone
@@ -8421,6 +8431,16 @@ Use `idle_repeats` and an explicit scene idle duration when the character idle
8421
8431
  also needs to fill multiple periods. The counts for the idle and the physics
8422
8432
  clip may differ as long as their products agree exactly.
8423
8433
 
8434
+ For example, when the diagnostic finds a shared 3 s duration and the scene's
8435
+ own period also fits, it can advise `idle_repeats: 3`, `with_idle.wind: 2`,
8436
+ `scene.repeats.idle: 3`, and `scene.animations.idle.duration: 3`. The composed
8437
+ camera ends at 3 s and its authored terminal key stays at 1 s. When the
8438
+ scene's period is undeclared, the advice gives
8439
+ `idle_repeats: 3` and `with_idle.wind: 2` (3 s) and explains that a
8440
+ `scene.repeats` count requires the scene's own period. When one source idle
8441
+ period is enough, omit `idle_repeats`. For a matching untiled scene, also
8442
+ omit `scene.repeats.idle` and keep the current scene duration and camera end.
8443
+
8424
8444
  Set `scene.repeats.<take>` to author the scene animation and any camera track
8425
8445
  for that take over a shared period. Give `scene.animations.<take>.duration`
8426
8446
  the positive whole take length and divide it by the scene repeat count to get
package/docs/STABILITY.md CHANGED
@@ -457,6 +457,22 @@ the sorted field names whose presence or digest changed. It returns an empty
457
457
  array for matching or legacy manifests. See the workflow in
458
458
  [Keeping assembled parts current](AUTHORING.md#keeping-assembled-parts-current).
459
459
 
460
+ ## Programmatic physics-only clip discovery
461
+
462
+ The stable named subpath `@rig-c/parts/physics-clips` exports
463
+ `physicsOnlyClips(motion: unknown): Array<{ name: string; duration: number; constraints: string[] }>`.
464
+ Pass a parsed `rigc-motion/1` document. Results follow the document's
465
+ `animations` order, excluding `idle`. A clip qualifies when it has at least one
466
+ track, every track targets only a named physics constraint, and other animation
467
+ payloads are empty or absent. Clip metadata such as `loop` and `note` is allowed.
468
+ Each result carries the source clip name and duration, with distinct constraint
469
+ names in first-keyed order. An input with no qualifying clips returns `[]`.
470
+ Invalid motion is refused with
471
+ `PHYSICS_CLIPS_MOTION`.
472
+
473
+ `compose` uses the same export to discover clips for `characters[].with_idle`.
474
+ See [Physics clips and scene repeats](AUTHORING.md#physics-clips-and-scene-repeats-issue-1615).
475
+
460
476
  ## Programmatic parts file references
461
477
 
462
478
  `@rig-c/parts/src/parts.ts` exports `partsFileReferences(dir: string):
@@ -1196,7 +1212,7 @@ execution in historical evidence is inferred from a current export.
1196
1212
  | scene placement pivot | `compose` | Issue #1498 adds optional literal `true` at `characters[].placement_pivot` in `spine-parts-scene/1`. It emits the identity `<id>:placement` under `root` and requires a scene-authored `translate`, `translatex` or `translatey` key in final scene pixels. The existing placement math stays on the original first-level bones, root regions and root weights. Source root bindings use the unkeyed identity `<id>:root` child when needed. `SCENE_FIELD_TYPE` refuses other explicit values, `SCENE_PIVOT_NAME_FREE` a source bone collision, `SCENE_PIVOT_DECLARED` an unresolved pivot targeted directly or through a bone group without an opt-in, `SCENE_PIVOT_UNUSED` an unused declaration and `SCENE_PIVOT_TRACK` a forbidden property or carrier key. `SCENE_PLATE_NAME_FREE` still governs named plate collisions. Core's unknown-bone refusal, rig gate, scene clip timing and endpoint closure still apply. `scene.json` adds `placement_pivot` with the generated name after the bounds fields and counts the generated bones for that character. `compose-run.json` binds the declaration through `scene.sha256` with its existing shape and key order. Omitting the declaration preserves default output bytes at the same paths, subject to the existing Core receipt clocks. |
1197
1213
  | `compose-run.json` | `compose` | spec `rig-compose-run/1` (issue #1348), separate from `rig-run/1`; a stable contract as of 2.44.0. Written at the `--out` root only after the gate and check are green and no accepted failing character remains. Fixed keys in order: `spec`, `scene` (`path`, `sha256`), `characters` (each `id`, `build`, `files`, each file `path`, `sha256`, then optional `placement`), `plate` (`path`, `sha256`, or null), `plates` (each `name`, `path`, `sha256`), then optional `output_profile` (`"preview"` or `"no-extremes"`, issue #1610). Scene and plate paths are the supplied and declared paths; character file paths are build-relative. Characters sort by `id`, files by `path`, named plates by `name`, in code-unit order. Each character's files are exactly `check/check.json`, `parts.json`, `rig/rig.json`, `rig/motion.json` and each distinct image the default skin names under `rig/images/`, including a generator's depth image. Every `sha256` is of the raw file bytes compose consumed before the gate. Only a character with `canvas_clip: true` has `placement`, with `canvas_clip: true`, `bounds` and `clipped_bounds` in that order from the scene report. Identical inputs at identical supplied paths with the same output profile give identical record bytes. The receipt inventories the listed inputs and selected profile, without clocks. Compose owns the name: a file of that name at the `--out` root is deleted at the start of every compose, before stage validation, so a refused rerun leaves none. |
1198
1214
  | compose output profiles | `compose` | Issue #1610 adds `--no-extremes` to omit only the extremes diagnostic renders, and `--output-profile preview` to also omit `check/idle_frames/`, `check/contact.png` and `check/motion_heat.png`. Preview takes precedence when both flags are given. Preview uses the stock idle render and existing readers. Before preview success, Parts removes the idle render directory, including Core's temporary contact sheet, skips copying the sheet to the check root, and skips generating heat. Each omission has a diagnostic `SKIP` line naming its selected flag. The gate, camera binding and check requirements still apply. Success prints `compose: PREVIEW — checks met; …` or `compose: NO EXTREMES — checks met; …`, respectively, and writes `output_profile` as `"preview"` or `"no-extremes"`. Default compose keeps its existing file bytes (with the nested Core receipt clock comparison described above), output paths and `compose: PASS — …` line. `COMPOSE_PREVIEW_REQUIRED_CHECK` refuses a valid loop seam pair in preview with `found=preview, required=default or no-extremes`, because the `loop_seam` record in `check.json` binds the paths and hashes of first and wrap PNGs that must remain under `check/idle_frames/`. Compose clears its owned outputs before this refusal. See [Compose output profiles](AUTHORING.md#compose-output-profiles-issue-1610). |
1199
- | the scene report | `compose` | spec `spine-parts-scene-report/1`; the plate block carries `sha256` of the plate PNG's bytes after `size` (issue #1183, additive under *What "stable" means here*: a new report key in a minor version, so the spec stays `/1`); `pack_mode` records `page_size` only when `--page-size <px>` is given (issue #1352, additive; without `--page-size`, rigc's default 2048 px page and padding 2 on each side bound any plate or region side to at most 2044 px before `CE_ATLAS_REGION_EXCEEDS_PAGE`) |
1215
+ | the scene report | `compose` | spec `spine-parts-scene-report/1`; the plate block carries `sha256` of the plate PNG's bytes after `size` (issue #1183, additive under *What "stable" means here*: a new report key in a minor version, so the spec stays `/1`); `pack_mode` records `page_size` only when `--page-size <px>` is given (issue #1352, additive; without `--page-size`, rigc's default 2048 px page and padding 2 on each side bound any plate or region side to at most 2044 px before `CE_ATLAS_REGION_EXCEEDS_PAGE`). `scene.json` echoes the optional `repeats` map in declared order as the final top-level key after `idle_duration`, omitting it when absent. |
1200
1216
  | keyed scene camera | `compose` | optional `camera` in `spine-parts-scene/1` (issue #1596). A camera scene writes `spine-parts-scene-report/2` at the existing `scene.json` path with its keyed camera, sampled coverage and framing verdict, and packed model SHA-256. Report /1 and the existing output inventory and bytes are preserved for scenes without a camera, subject to the existing Core receipt clocks. The camera path uses Core animation easing and the posed backdrop at each sampled frame. Rig, motion and stock check outputs retain their existing semantics. The compose input receipt stays `rig-compose-run/1`. See [Keyed scene camera](AUTHORING.md#keyed-scene-camera-issue-1596) |
1201
1217
  | physics clips and scene repeats | `compose` | Issue #1615 adds `characters[].with_idle` and top-level `repeats` to `spine-parts-scene/1`. Each physics-only side clip requires literal `false` at any character scale or a safe integer count of at least 1 at scale 1. Numeric declarations fold whole periods into `idle` with exact duration equality. Both values retain `<id>:<clip>` subject to the character's scale checks, and the character report row echoes `with_idle` when declared. A scene repeat count is a safe integer of at least 2 on an authored take. Its duration remains the whole take length. Its tracks, deforms and camera keys use the exact duration divided by the count as their period. Repeated camera keys are expanded in report /2, with coverage on the full take clock and per-frame figure measurements. See [Physics clips and scene repeats](AUTHORING.md#physics-clips-and-scene-repeats-issue-1615) |
1202
1218
  | `idle.png`, `idle-indexed.png`, `idle.gif` | `loop`, `build --loop` | APNG and GIF encodings of the rendered idle |
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "rig-parts",
3
- "version": "2.65.0",
3
+ "version": "2.66.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": {
7
7
  "./assembly-reading": "./src/assembly-reading.ts",
8
+ "./physics-clips": "./src/physics-clips.ts",
8
9
  "./cloth-targets.json": "./src/cloth-targets.json",
9
10
  "./*": "./*"
10
11
  },
@@ -0,0 +1,50 @@
1
+ import { PartsError, type Problem, refuseIfAny } from './errors.ts';
2
+
3
+ function isRecord(value: unknown): value is Record<string, unknown> {
4
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
5
+ }
6
+
7
+ function kind(value: unknown): string {
8
+ return value === null ? 'null' : Array.isArray(value) ? 'array' : value === undefined ? 'absent' : typeof value;
9
+ }
10
+
11
+ const CLIP_FIELDS = new Set(['duration', 'loop', 'note', 'tracks']);
12
+ const OTHER_TARGETS = ['bone', 'group', 'slot', 'path', 'slider'];
13
+
14
+ /** The side clips that need a compose `with_idle` declaration, in motion order. */
15
+ export function physicsOnlyClips(motion: unknown): Array<{ name: string; duration: number; constraints: string[] }> {
16
+ const code = 'PHYSICS_CLIPS_MOTION';
17
+ if (!isRecord(motion) || motion.spec !== 'rigc-motion/1' || !isRecord(motion.animations)) {
18
+ const found = isRecord(motion)
19
+ ? `spec ${typeof motion.spec === 'string' ? JSON.stringify(motion.spec) : kind(motion.spec)}; animations ${kind(motion.animations)}`
20
+ : kind(motion);
21
+ throw new PartsError([{ code, object: 'motion', detail: `found ${found}. Pass a parsed rigc-motion/1 with an animations object` }]);
22
+ }
23
+ const clips: ReturnType<typeof physicsOnlyClips> = [];
24
+ const problems: Problem[] = [];
25
+ for (const [name, clip] of Object.entries(motion.animations)) {
26
+ if (!isRecord(clip) || typeof clip.duration !== 'number' || !Number.isFinite(clip.duration) ||
27
+ !Array.isArray(clip.tracks) || !clip.tracks.every(isRecord)) {
28
+ const found = isRecord(clip)
29
+ ? `duration ${typeof clip.duration === 'number' ? clip.duration : kind(clip.duration)}, tracks ${kind(clip.tracks)}`
30
+ : kind(clip);
31
+ problems.push({ code, object: `motion.animations[${JSON.stringify(name)}]`, detail: `found ${found}. Requires a finite duration and an array of track objects` });
32
+ continue;
33
+ }
34
+ if (name === 'idle' || clip.tracks.length === 0 || Object.entries(clip).some(([key, value]) =>
35
+ !CLIP_FIELDS.has(key) && value !== undefined && !(Array.isArray(value) && value.length === 0))) continue;
36
+
37
+ const constraints = new Set<string>();
38
+ for (const track of clip.tracks) {
39
+ if (typeof track.physics !== 'string' || track.physics === '' ||
40
+ OTHER_TARGETS.some(key => Object.hasOwn(track, key))) {
41
+ constraints.clear();
42
+ break;
43
+ }
44
+ constraints.add(track.physics);
45
+ }
46
+ if (constraints.size > 0) clips.push({ name, duration: clip.duration, constraints: [...constraints] });
47
+ }
48
+ refuseIfAny(problems);
49
+ return clips;
50
+ }
package/src/scene.ts CHANGED
@@ -116,6 +116,7 @@ import { ACCEPTABLE_BARS, barsNotMet, CHECK_SPEC, type CheckReport, COMPOSE_PREV
116
116
  import { CONSTRAINT_BONE_FIELDS, editorReceiptProblems, ROOT_BONE } from './config.ts';
117
117
  import { cropToSpineY } from './coords.ts';
118
118
  import { failLine, PartsError, type Problem, refuseIfAny } from './errors.ts';
119
+ import { physicsOnlyClips } from './physics-clips.ts';
119
120
  import { readParts } from './parts.ts';
120
121
  import { missingReceipts, readEditorReceipts, type EditorReceipts } from './editreceipt.ts';
121
122
  import { edgeLength } from './length.ts';
@@ -589,18 +590,6 @@ function animationsOf(motion: MotionSpec): Record<string, SceneAnimation> {
589
590
  return motion.animations as unknown as Record<string, SceneAnimation>;
590
591
  }
591
592
 
592
- function physicsClipTargets(clip: SceneAnimation): ReadonlySet<string> | undefined {
593
- if (clip.tracks.length === 0 || Object.entries(clip).some(([key, value]) =>
594
- !['duration', 'loop', 'note', 'tracks'].includes(key) && value !== undefined && !(Array.isArray(value) && value.length === 0))) return undefined;
595
- const targets = new Set<string>();
596
- for (const track of clip.tracks) {
597
- if (typeof track.physics !== 'string' || track.physics === '' ||
598
- ['bone', 'group', 'slot', 'path', 'slider'].some(key => Object.hasOwn(track, key))) return undefined;
599
- targets.add(track.physics);
600
- }
601
- return targets;
602
- }
603
-
604
593
  /** Maximum copies of each source searched for a diagnostic hint. Acceptance compares the declared counts directly. */
605
594
  const WITH_IDLE_DIAGNOSTIC_COPY_LIMIT = 10_000;
606
595
 
@@ -608,7 +597,7 @@ function compareRepeatDurations(left: number, right: number): -1 | 0 | 1 {
608
597
  return left === right ? 0 : left < right ? -1 : 1;
609
598
  }
610
599
 
611
- function idleRepeatAdvice(idlePeriod: number, clipPeriod: number): string {
600
+ function idleRepeatAdvice(name: string, idlePeriod: number, clipPeriod: number, scenePeriodMatchesIdle: boolean): string {
612
601
  if (Number.isFinite(idlePeriod) && idlePeriod > 0 && Number.isFinite(clipPeriod) && clipPeriod > 0) {
613
602
  let idleCount = 1;
614
603
  let clipCount = 1;
@@ -618,7 +607,21 @@ function idleRepeatAdvice(idlePeriod: number, clipPeriod: number): string {
618
607
  if (!Number.isFinite(idleDuration) || !Number.isFinite(clipDuration)) break;
619
608
  // Only the smaller product can catch the other, so the first match has the least idle count and then clip count.
620
609
  const order = compareRepeatDurations(idleDuration, clipDuration);
621
- if (order === 0) return `Smallest exact counts: idle ${idleCount}, clip ${clipCount} (${idleDuration} s).`;
610
+ if (order === 0) {
611
+ const clipField = `with_idle.${name}: ${clipCount}`;
612
+ const unknownScenePeriod = "Cannot name a scene.repeats count because the scene's own period is not declared.";
613
+ if (idleCount === 1) {
614
+ const sceneAdvice = scenePeriodMatchesIdle
615
+ ? `Omit scene.repeats.idle and keep scene.animations.idle.duration: ${idleDuration} (camera terminal key ${idleDuration} s).`
616
+ : unknownScenePeriod;
617
+ return `Omit idle_repeats and write ${clipField} (${idleDuration} s). ${sceneAdvice}`;
618
+ }
619
+ if (scenePeriodMatchesIdle) {
620
+ return `Write idle_repeats: ${idleCount}, ${clipField}, scene.repeats.idle: ${idleCount}, and scene.animations.idle.duration: ${idleDuration} ` +
621
+ `(composed camera terminal key ${idleDuration} s, authored terminal key stays at ${idlePeriod} s).`;
622
+ }
623
+ return `Write idle_repeats: ${idleCount} and ${clipField} (${idleDuration} s). ${unknownScenePeriod}`;
624
+ }
622
625
  if (order < 0) idleCount++;
623
626
  else clipCount++;
624
627
  }
@@ -1392,6 +1395,7 @@ interface SceneReportV1 {
1392
1395
  characters: SceneCharacterReport[];
1393
1396
  order: { declared: string[]; slots: string[]; judged_by: 'nothing' };
1394
1397
  idle_duration: number;
1398
+ repeats?: Record<string, number>;
1395
1399
  }
1396
1400
 
1397
1401
  export type SceneReport = SceneReportV1 | (Omit<SceneReportV1, 'spec'> & {
@@ -1731,12 +1735,11 @@ export function composeScene(
1731
1735
  const b = byId.get(c.id);
1732
1736
  if (b === undefined) continue;
1733
1737
  const animations = animationsOf(b.motion);
1738
+ const physicsClips = new Map(physicsOnlyClips(b.motion).map(row => [row.name, row]));
1734
1739
  const clips = new Map<string, SceneAnimation>();
1735
- for (const [name, source] of Object.entries(animations)) {
1736
- if (name === 'idle') continue;
1737
- const targets = physicsClipTargets(source);
1738
- if (targets !== undefined && !Object.hasOwn(declarations, name)) {
1739
- const count = targets.size;
1740
+ for (const { name, constraints } of physicsClips.values()) {
1741
+ if (!Object.hasOwn(declarations, name)) {
1742
+ const count = constraints.length;
1740
1743
  const advice = c.scale === 1
1741
1744
  ? 'Declare its whole-period repeat count to carry it into idle or false to play idle without it'
1742
1745
  : `At scale ${c.scale}, declare false to play idle without it. A repeat count applies at scale 1 only`;
@@ -1747,19 +1750,21 @@ export function composeScene(
1747
1750
  for (const [name, count] of Object.entries(declarations)) {
1748
1751
  const object = `${character}.with_idle[${JSON.stringify(name)}]`;
1749
1752
  const source = name !== 'idle' && Object.hasOwn(animations, name) ? animations[name] : undefined;
1750
- if (source === undefined || physicsClipTargets(source) === undefined) {
1753
+ const physicsClip = physicsClips.get(name);
1754
+ if (source === undefined || physicsClip === undefined) {
1751
1755
  fail('SCENE_PHYSICS_CLIP_ONLY', object, `character ${show(c.id)} ${source === undefined ? 'has no clip beside idle named' : 'has a clip with other timelines or no physics keys named'} ${show(name)}. Name a clip beside idle with only physics-constraint tracks`);
1752
1756
  continue;
1753
1757
  }
1754
1758
  if (count === false || c.scale !== 1) continue;
1755
- const period = source.duration;
1759
+ const period = physicsClip.duration;
1756
1760
  const foldedDuration = count * period;
1757
1761
  if (Number.isFinite(foldedDuration)) withIdleClockFields.push(`${object} for character ${show(c.id)} implies ${foldedDuration} s (${count} × ${period} s)`);
1758
1762
  const sourceIdle = animations.idle.duration;
1759
1763
  if (!Number.isFinite(foldedDuration) || foldedDuration <= 0 || compareRepeatDurations(idleDuration, foldedDuration) !== 0) {
1760
1764
  const idleField = c.idle_repeats === undefined ? `character ${show(c.id)}'s source idle` : `${character}.idle_repeats: ${c.idle_repeats} (implies ${c.idle_repeats * sourceIdle} s)`;
1761
1765
  const sceneField = clip === undefined ? '' : ` ${sceneIdleClock} declares ${clip.duration} s.`;
1762
- fail('SCENE_WITH_IDLE_DURATION', object, `character ${show(c.id)} clip ${show(name)} at ${count} × ${period} s implies ${foldedDuration} s. The played idle is ${idleDuration} s with ${idleField}.${sceneField} ${idleRepeatAdvice(sourceIdle, period)}`);
1766
+ const advice = idleRepeatAdvice(name, sourceIdle, period, sceneIdleRepeat === undefined && clip?.duration === sourceIdle);
1767
+ fail('SCENE_WITH_IDLE_DURATION', object, `character ${show(c.id)} clip ${show(name)} at ${count} × ${period} s implies ${foldedDuration} s. The played idle is ${idleDuration} s with ${idleField}.${sceneField} ${advice}`);
1763
1768
  continue;
1764
1769
  }
1765
1770
  clips.set(name, source);
@@ -2358,6 +2363,7 @@ export function composeScene(
2358
2363
  characters: rows,
2359
2364
  order: { declared: [...scene.order], slots: slots.map((s) => s.name), judged_by: 'nothing' },
2360
2365
  idle_duration: idleDuration,
2366
+ ...(scene.repeats === undefined ? {} : { repeats: { ...scene.repeats } }),
2361
2367
  };
2362
2368
  return { rig, motion, images, report, repeatSeams, ...(sceneAnimations === undefined ? {} : { sceneAnimations }), ...(sceneCamera === undefined ? {} : { sceneCamera }) };
2363
2369
  }
@@ -2795,7 +2801,8 @@ export function composeStage(input: ComposeInput, run: ComposeRunners, log: Log)
2795
2801
  }
2796
2802
  const writeCameraReport = (): void => {
2797
2803
  if (evidence === undefined || !cameraBound) return;
2798
- composed.report = { ...r, spec: SCENE_CAMERA_REPORT_SPEC, camera: evidence.report };
2804
+ const { repeats, ...base } = r;
2805
+ composed.report = { ...base, spec: SCENE_CAMERA_REPORT_SPEC, camera: evidence.report, ...(repeats === undefined ? {} : { repeats }) };
2799
2806
  writeFileSync(reportPath, rigJsonText(composed.report));
2800
2807
  say(`${wroteRig}, and ${reportPath}`);
2801
2808
  };