@rig-c/parts 1.54.0 → 1.55.1

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/src/build.ts CHANGED
@@ -71,8 +71,8 @@ import {
71
71
  splitSchedule,
72
72
  untestedIntervals,
73
73
  } from './autoreplay.ts';
74
- import { besideIdleLine, checkSummaryLine, CLOTH_LINE, type ClothLine, clothWarnText, frameRuns, MOTION_SEAM_LINE, type MotionSeamLine, type MotionSeamPlant, motionSeamWarnText, FOLD_LINE, type FoldsLine, LEVEL_LINE, type LevelLine, LIMB_LINE, type LimbLine, STRESS_LINE, SWEEP_LINE, type SweepLine, buildGateLines, causeLines, environmentLine, IDLE_FPS, IDLE_MAX_PX, maxRgbDiff, REQUIREMENTS_DIR, type CheckReport, type PackLine, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, GATE_PROFILE, JUDGEMENT_LINES, type JudgementLine, packedBuildArgs, packedBuildLabel, type PackMode, readCheckEnvironment, type PackShape, type PageEdges, readFrameSet, rigcFailed, rigcIdentity, rigcRanClause, REPORTED_LINES, type ReportedLine, type RigcRunner, runCheck, SEAM_DIR, SEAM_MEAN_BAR, seamPairText, seamRigPxText, SOURCE_LINE, SEAM_PX_BAR, SEAM_PX_LEVEL, SEAM_PX_LEVEL_HIGH, SPINEBOY_YARDSTICK, STILL_DIR } from './check.ts';
75
- import { type Cut, type Extend, type Limb, loadConfig, loadConfigAndAnimations, loadEarlyConfig, type Patch, type PlanEntry } from './config.ts';
74
+ import { besideIdleLine, checkSummaryLine, inputFileRecord, type InputFileRecord, CLOTH_LINE, type ClothLine, clothWarnText, frameRuns, MOTION_SEAM_LINE, type MotionSeamLine, type MotionSeamPlant, motionSeamWarnText, FOLD_LINE, type FoldsLine, LEVEL_LINE, type LevelLine, LIMB_LINE, type LimbLine, STRESS_LINE, SWEEP_LINE, type SweepLine, buildGateLines, causeLines, environmentLine, IDLE_FPS, IDLE_MAX_PX, maxRgbDiff, REQUIREMENTS_DIR, type CheckReport, type PackLine, DEFAULT_PACK_SHAPE, DEFAULT_PAGE_EDGES, GATE_PROFILE, JUDGEMENT_LINES, type JudgementLine, packedBuildArgs, packedBuildLabel, type PackMode, readCheckEnvironment, type PackShape, type PageEdges, readFrameSet, rigcFailed, rigcIdentity, rigcRanClause, REPORTED_LINES, type ReportedLine, type RigcRunner, runCheck, SEAM_DIR, SEAM_MEAN_BAR, seamPairText, seamRigPxText, SOURCE_LINE, SEAM_PX_BAR, SEAM_PX_LEVEL, SEAM_PX_LEVEL_HIGH, SPINEBOY_YARDSTICK, STILL_DIR } from './check.ts';
75
+ import { type Cut, type Extend, type Limb, loadConfigAndAnimations, loadConfigWithBytes, loadEarlyConfig, type Patch, type PlanEntry } from './config.ts';
76
76
  import { failLine, PartsError, type Problem, refuseIfAny } from './errors.ts';
77
77
  import type { MeshQualityReport, MotionSchedule } from 'rig-c/mesh';
78
78
  import { encodeGif } from './gif.ts';
@@ -83,6 +83,10 @@ import { placeBoneEntriesForSkeleton, poseBoneEntriesForDrawn, REGISTER_OFFSET_B
83
83
  import { type AlternatePartsRecord, type PartRecord, readParts, type RecompositeRecord, type SingleRunPad, tagOf, writeParts } from './parts.ts';
84
84
  import { encodePngBytes, readPng, writePng } from './raster/png.ts';
85
85
  import type { Raster } from './raster/types.ts';
86
+ import { type Mask, newMask } from './raster/types.ts';
87
+ import { type OtherLimbs, splitLines, type SplitCount } from './assemble.ts';
88
+ import type { BoneEntry } from './config.ts';
89
+ import { OPAQUE_ALPHA_ABOVE } from './layers.ts';
86
90
  import { readRequirements, type RequirementLine, summaryText } from './requirements.ts';
87
91
  import { type AutoMeshReport, buildRig, DEFAULT_IDLE_KEYS, type FaceAxis, type IdleKeys, type MeshReport, type RigCommand, rigJsonText, type RigOutput, type RigSpec, SETS_FILE, type StrayCleared, type TurnRow } from './rig.ts';
88
92
  import { KEYPOINT_NAMES, type KeypointName, type PosePoints } from './skeleton.ts';
@@ -172,6 +176,13 @@ export interface AssembleStageInput {
172
176
  * shows the island count go red under it.
173
177
  */
174
178
  setIslands?: 'joints' | 'all';
179
+ /**
180
+ * How a subset set's limb parts share a layer of one island with a limb the set does not carry (issue #609):
181
+ * `"nearest"` (the default, the only one the CLI runs) by the nearest segment line in the set's pose, the other limb
182
+ * placed by the set's skeleton ({@link OtherLimbs}); `"connectivity"` every pixel on the set's limb, the rule before
183
+ * #609 — kept for the selftest's control that shows the second-limb share go red under it.
184
+ */
185
+ setSplit?: 'nearest' | 'connectivity';
175
186
  }
176
187
 
177
188
  /** Where the assemble stage writes: `parts.json`, the directory of part PNGs, the recomposite, and its error map. */
@@ -327,7 +338,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
327
338
  }
328
339
 
329
340
  const altProblems: Problem[] = [];
330
- const altBuilt: Array<{ record: AlternatePartsRecord; images: Array<{ name: string; image: Raster }>; excluded: ExcludedCount[]; islands: IslandCount[] }> = [];
341
+ const altBuilt: Array<{ record: AlternatePartsRecord; images: Array<{ name: string; image: Raster }>; excluded: ExcludedCount[]; islands: IslandCount[]; splits: SplitCount[] }> = [];
331
342
  const baseSlots = result.parts.parts.map((p) => p.name);
332
343
  for (const alt of mergedAlts) {
333
344
  if (alt.source === undefined || alt.full === undefined) {
@@ -470,6 +481,16 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
470
481
  let altBones = fields.bones;
471
482
  let altDrawnLength: Record<string, number> | undefined;
472
483
  let altRegistration: { offset: [number, number]; scale: number } | undefined;
484
+ // Issue #588: a subset set that names one limb side keeps, of a layer that holds more than one island, the one its joints fall on.
485
+ const altIslands = alt.parts === undefined || input.setIslands === 'all' ? [] : setIslandSources(fields.limbs ?? {}, altLimbs);
486
+ // Issue #609: the limbs of those layers the set does not carry — the other leg of a two-leg layer.
487
+ const otherLimbs: Record<string, Limb> =
488
+ input.setSplit === 'connectivity'
489
+ ? {}
490
+ : Object.fromEntries(Object.entries(fields.limbs ?? {}).filter(([ln, l]) => !(ln in altLimbs) && l.segments.some((sg) => altIslands.includes(sg.from))));
491
+ const otherBones = new Set(Object.values(otherLimbs).flatMap((l) => l.segments.map((sg) => sg.bone)));
492
+ // The bones the set places: by its skeleton, or by the angles it states; every other bone keeps the base's place unless an ancestor moved.
493
+ const setPlaced = new Set<string>();
473
494
  if (Object.keys(altLimbs).length > 0 && fields.bones !== undefined && (altSkeleton !== undefined || alt.drawn !== undefined)) {
474
495
  const coveredLimbBones = new Set(Object.values(altLimbs).flatMap((l) => l.segments.map((sg) => sg.bone)));
475
496
  const limbDrawn: Record<string, number> = {};
@@ -510,19 +531,23 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
510
531
  }
511
532
  altRegistration = { offset: [reg.offset[0], reg.offset[1]], scale: reg.scale };
512
533
  altDrawnLength = skeletonDrawnLength(fields.bones, coveredLimbBones, joints);
513
- altBones = placeBoneEntriesForSkeleton(fields.bones, coveredLimbBones, joints, limbDrawn);
534
+ // Issue #609: the other limb of a shared layer stands at the set's own keypoints too, so its segment line is the
535
+ // set's; the skeleton file holds them. Only its place widens: drawn and drawnLength stay the covered bones'.
536
+ const placed = new Set([...coveredLimbBones, ...[...otherBones].filter((b) => SKELETON_LIMB_BONES.some(([t]) => t === b))]);
537
+ for (const b of placed) if (SKELETON_LIMB_BONES.some(([t]) => t === b)) setPlaced.add(b);
538
+ altBones = placeBoneEntriesForSkeleton(fields.bones, placed, joints, limbDrawn);
514
539
  } else {
515
540
  altBones = poseBoneEntriesForDrawn(fields.bones, limbDrawn);
516
541
  }
542
+ for (const b of Object.keys(limbDrawn)) setPlaced.add(b);
517
543
  }
544
+ const altOthers = Object.keys(otherLimbs).length === 0 ? undefined : otherLimbsOf(otherLimbs, setPlaced, fields.bones ?? [], result.images, result.parts.rig_size, altSkeleton !== undefined ? 'skeleton' : alt.drawn !== undefined ? 'drawn' : 'none');
518
545
  // Issue #587: a subset set's limb part takes nothing a base part it does not replace covers at setup.
519
546
  const [exW, exH] = result.parts.rig_size;
520
547
  const altExclude =
521
548
  alt.parts === undefined || input.setExclusion === 'none'
522
549
  ? []
523
550
  : setExclusions(result.images, exW, exH, Object.values(altLimbs).flatMap((l) => l.segments.map((sg) => sg.part)), new Set([...coveredSet, ...hidesSet]));
524
- // Issue #588: a subset set that names one limb side keeps, of a layer that holds more than one island, the one its joints fall on.
525
- const altIslands = alt.parts === undefined || input.setIslands === 'all' ? [] : setIslandSources(fields.limbs ?? {}, altLimbs);
526
551
  let altRes: ReturnType<typeof assemble>;
527
552
  try {
528
553
  altRes = assemble({
@@ -545,6 +570,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
545
570
  projectRule: input.project,
546
571
  ...(altExclude.length === 0 ? {} : { exclude: altExclude }),
547
572
  ...(altIslands.length === 0 ? {} : { limbIslands: altIslands }),
573
+ ...(altOthers === undefined ? {} : { otherLimbs: altOthers }),
548
574
  });
549
575
  } catch (err) {
550
576
  if (err instanceof PartsError) {
@@ -594,6 +620,7 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
594
620
  images: keptImages,
595
621
  excluded: altRes.excluded,
596
622
  islands: altRes.islands,
623
+ splits: altRes.splits,
597
624
  });
598
625
  }
599
626
  refuseIfAny(altProblems);
@@ -657,11 +684,58 @@ export function assembleStage(input: AssembleStageInput, outs: AssembleOutputs,
657
684
  for (const d of result.drift) log(driftLine(d));
658
685
  // Issue #588: per subset set, one line per limb part cut from a layer of more than one island, then (issue #587) one
659
686
  // per limb part and base part over it that took a pixel. None otherwise.
660
- for (const b of altBuilt) for (const l of [...islandLines(b.record.name, b.islands), ...excludedLines(b.record.name, b.excluded)]) log(l);
687
+ // Issue #609: then one per limb part cut from a layer of one island that also holds a limb the set does not carry.
688
+ for (const b of altBuilt) for (const l of [...islandLines(b.record.name, b.islands), ...splitLines(b.record.name, b.splits), ...excludedLines(b.record.name, b.excluded)]) log(l);
661
689
  log(`wrote ${outs.partsJson}, ${result.images.length} PNG(s) in ${outs.partsDir}, ${outs.recomposite}, ${outs.errorMap} (uncovered error px red, covered error px blue, the painting grey)${figurePath === null ? '' : `, ${figurePath} (the figure, white, the recomposite was read inside)`}`);
662
690
  return result;
663
691
  }
664
692
 
693
+ /**
694
+ * Issue #609: what a subset set says of the limbs of its shared layers it does not carry ({@link OtherLimbs}). A bone
695
+ * is placed by the set when the set places it (`setPlaced`: its skeleton's table bones, its drawn bones) or an
696
+ * ancestor of it — the rule `placeBoneEntriesForSkeleton` and `poseBoneEntriesForDrawn` move a child by; any other
697
+ * bone keeps the base's place, which is not the set's, so a limb with one is `unposed`. The base art is each limb's
698
+ * base parts at alpha above `OPAQUE_ALPHA_ABOVE`, at their `parts.json` x, y.
699
+ */
700
+ function otherLimbsOf(
701
+ limbs: Readonly<Record<string, Limb>>,
702
+ setPlaced: ReadonlySet<string>,
703
+ bones: readonly BoneEntry[],
704
+ base: ReadonlyArray<{ record: PartRecord; image: Raster }>,
705
+ rigSize: readonly [number, number],
706
+ pose: OtherLimbs['pose'],
707
+ ): OtherLimbs {
708
+ const parent = new Map<string, string>();
709
+ for (const b of bones) {
710
+ if ('chain' in b) b.points.forEach((_, k) => parent.set(`${b.chain}${k}`, k === 0 ? b.parent : `${b.chain}${k - 1}`));
711
+ else parent.set(b.name, b.parent);
712
+ }
713
+ const placed = (b: string): boolean => {
714
+ for (let at: string | undefined = b, n = 0; at !== undefined && n <= parent.size; at = parent.get(at), n++) if (setPlaced.has(at)) return true;
715
+ return false;
716
+ };
717
+ const [W, H] = rigSize;
718
+ const unposed: Record<string, string[]> = {};
719
+ const baseArt: Record<string, Mask> = {};
720
+ for (const [ln, l] of Object.entries(limbs)) {
721
+ unposed[ln] = l.segments.map((sg) => sg.bone).filter((b) => !placed(b));
722
+ const names = new Set(l.segments.map((sg) => sg.part));
723
+ const m = newMask(W, H);
724
+ for (const { record, image } of base) {
725
+ if (!names.has(record.name)) continue;
726
+ for (let y = 0; y < image.height; y++) {
727
+ for (let x = 0; x < image.width; x++) {
728
+ const rx = record.x + x;
729
+ const ry = record.y + y;
730
+ if (rx >= 0 && ry >= 0 && rx < W && ry < H && image.data[(y * image.width + x) * 4 + 3] > OPAQUE_ALPHA_ABOVE) m.data[ry * W + rx] = 1;
731
+ }
732
+ }
733
+ }
734
+ baseArt[ln] = m;
735
+ }
736
+ return { limbs, unposed, baseArt, drawOrder: base.map((q) => q.record.name), pose };
737
+ }
738
+
665
739
  /**
666
740
  * The line `assemble` prints under `one run:` when the file was padded (issue
667
741
  * #366): its size, the square and the four margins, and that `parts.json`'s
@@ -1396,6 +1470,8 @@ export interface CheckStageInput {
1396
1470
  requirements?: string;
1397
1471
  /** The path `check.json`'s `requirements.file` records (issue #556): `config.requirements` as declared when build read it from the config; absent, `requirements` as given. */
1398
1472
  requirementsAs?: string;
1473
+ /** The config `build` read (issue #607), recorded as `check.json`'s `config`; absent, no key is written, as `check` alone writes none. */
1474
+ config?: InputFileRecord;
1399
1475
  /**
1400
1476
  * `check --seam-pairs` (issue #202): split the seam's counted pixels by pair
1401
1477
  * and draw each pair's picture even when the bar passes. A failing seam is
@@ -1555,7 +1631,7 @@ export function sweepCheckLines(line: SweepLine, steps: ReadonlyMap<string, { le
1555
1631
  return [
1556
1632
  `${SWEEP_LINE}: ${line.status} — ${line.joints.length} joint(s) bent to their declared range's ends and middle${line.physics_left_out === 0 ? '' : `, ${line.physics_left_out} physics constraint(s) left out`}; at each, the pose against the same pose with the joint's own art drawn under the limb, on the rest-pose seam's bar (mean |d| <= ${line.bar.mean.toFixed(1)}, <= ${line.bar.rig_px_over_40} rig px over ${line.bar.level})${s === null ? '' : ` at frame scale ${s}`}`,
1557
1633
  ...line.joints.flatMap((j) => {
1558
- const head = `joint "${j.joint}" (${j.limb}, "${j.part}" on "${j.bone}", range [${j.range.join(', ')}]${j.shape === 'disc' ? `, cap_shape "disc": no pixel over ${line.bar.level} in the disc` : ''})`;
1634
+ const head = `joint "${j.joint}" (${j.limb}, "${j.part}" on "${j.bone}", range [${j.range.join(', ')}]${j.shape === undefined ? '' : `, cap_shape "${j.shape}": no pixel over ${line.bar.level} in the disc`})`;
1559
1635
  if (j.unread !== undefined) return [`${head}: FAIL — not read: ${j.unread}`];
1560
1636
  // Issue #557: the contour step, a reading on every row (check.json carries it only for a short cap).
1561
1637
  return j.poses.map((p) => {
@@ -1620,7 +1696,7 @@ export function checkStage(input: CheckStageInput, rigc: RigcRunner, bin: string
1620
1696
  const entryLine = versionLines.find((l) => l.startsWith('entry:'));
1621
1697
  log(` ${rigcIdentity(bin, v)}${entryLine === undefined ? '' : `; ${entryLine}`}`);
1622
1698
  const mode: PackMode = { pageEdges: input.pageEdges ?? DEFAULT_PAGE_EDGES, packShape: input.packShape ?? DEFAULT_PACK_SHAPE };
1623
- const r = runCheck(input.rig, input.out, rigc, input.parts, mode, input.source, input.requirements, input.seamPairs === true, input.keepStills === true, input.set, input.allSets === true, input.environment, input.requirementsAs);
1699
+ const r = runCheck(input.rig, input.out, rigc, input.parts, mode, input.source, input.requirements, input.seamPairs === true, input.keepStills === true, input.set, input.allSets === true, input.environment, input.requirementsAs, input.config);
1624
1700
  if (r.figures.environment !== undefined) log(` ${environmentLine(r.figures.environment)}`);
1625
1701
  log(` gate rig-play (rigc ${packedBuildLabel(mode)}), verbatim:`);
1626
1702
  for (const l of r.gateHtml) log(l);
@@ -2106,13 +2182,17 @@ export function build(input: BuildInput, run: BuildRunners, log: Log): BuildResu
2106
2182
  log(`rig-parts build: ${input.config} -> ${out}, seam rule ${input.seam}, projection rule ${input.project}, page edges ${input.pageEdges}, pack shape ${input.packShape ?? DEFAULT_PACK_SHAPE}${idleKeys === DEFAULT_IDLE_KEYS ? '' : `, idle keys ${idleKeys}`}${input.loop ? `, with the idle loop${input.leadIn === undefined ? '' : ` after a lead-in of ${input.leadIn} period(s)`}` : ''}`);
2107
2183
 
2108
2184
  let req: BuildRequirements | null = null;
2185
+ let configRecord: InputFileRecord | null = null;
2109
2186
  try {
2110
2187
  // build runs rig next, which needs the whole config, so the full loader is
2111
2188
  // asked first: a config rig would refuse is refused before assemble writes
2112
2189
  // anything, and under [assemble], as it was before the stage had its own
2113
2190
  // narrower door.
2114
2191
  // Issue #556: the flag, or the config's declaration when there is none; both naming other bytes is refused here.
2115
- req = buildRequirements(input.requirements, loadConfig(input.config).requirements, input.config);
2192
+ // Issue #607: the bytes this read parsed are the ones check.json's config record hashes, under the path as typed.
2193
+ const loaded = loadConfigWithBytes(input.config);
2194
+ configRecord = inputFileRecord(loaded.bytes, input.config);
2195
+ req = buildRequirements(input.requirements, loaded.config.requirements, input.config);
2116
2196
  // The same for the requirements file's own shape; its names resolve against the rig, in the check, before it builds.
2117
2197
  if (req !== null) readRequirements(req.read);
2118
2198
  // And the schedule (issue #538), by rigc's own reader, as check reads it.
@@ -2134,7 +2214,7 @@ export function build(input: BuildInput, run: BuildRunners, log: Log): BuildResu
2134
2214
 
2135
2215
  let report: CheckReport;
2136
2216
  try {
2137
- report = checkStage({ rig: join(out, 'rig'), parts: out, out: join(out, 'check'), pageEdges: input.pageEdges, packShape: input.packShape, ...(req === null ? {} : { requirements: req.read, requirementsAs: req.recorded }), seamPairs: input.seamPairs === true, keepStills: input.keepStills === true, ...(input.set === undefined ? {} : { set: input.set }), allSets: input.allSets === true, ...(input.environment === undefined ? {} : { environment: input.environment }) }, run.check, run.checkBin, prefixed('check'));
2217
+ report = checkStage({ rig: join(out, 'rig'), parts: out, out: join(out, 'check'), pageEdges: input.pageEdges, packShape: input.packShape, ...(req === null ? {} : { requirements: req.read, requirementsAs: req.recorded }), seamPairs: input.seamPairs === true, keepStills: input.keepStills === true, ...(input.set === undefined ? {} : { set: input.set }), allSets: input.allSets === true, ...(input.environment === undefined ? {} : { environment: input.environment }), ...(configRecord === null ? {} : { config: configRecord }) }, run.check, run.checkBin, prefixed('check'));
2138
2218
  } catch (err) {
2139
2219
  return refused('check', err);
2140
2220
  }
package/src/check.ts CHANGED
@@ -1888,6 +1888,12 @@ export interface CheckFigures {
1888
1888
  skipped?: { loop?: string; seam?: string };
1889
1889
  /** Written only under `--set` or `--all-sets` (issue #454): each checked alternate set's setup-pose seam and recomposite figures, keyed by set name. */
1890
1890
  sets?: Record<string, SetCheckFigures>;
1891
+ /**
1892
+ * Written only by `build` (issue #607): the config it read, the path as `--config` was typed and the sha256 of the
1893
+ * bytes its full loader parsed ({@link inputFileRecord}), just before the requirements block. Provenance, not a
1894
+ * bar; `check` and `compose` read no config and write no key.
1895
+ */
1896
+ config?: InputFileRecord;
1891
1897
  /** Written only under `--requirements` (issue #93): the file's fps, the summary, and one line per declared requirement, by name. */
1892
1898
  requirements?: RequirementsBlock;
1893
1899
  PASS: boolean;
@@ -2018,7 +2024,15 @@ export const LIMB_LINE = 'LIMB_ONE_BONE';
2018
2024
  * {@link SEAM_PX_LEVEL}: the disc is the cap's whole claim, so one uncovered
2019
2025
  * pixel of it is one too many. The level is the seam's; the count's bar is
2020
2026
  * the card's ("the joint disc holds no background pixel"), not a figure
2021
- * measured here. Its row says `shape: "disc"`; no other row changes.
2027
+ * measured here. Its row says `shape: "disc"`.
2028
+ * - **So is a ball** (issue #598). A joint whose cap record says
2029
+ * `shape: "ball"` (`cap_shape: "ball"`, issue #579) is held to the same
2030
+ * rule over the same comparison, and its row says `shape: "ball"`. The
2031
+ * comparison already reads the whole disc — the underlay is the limb's art
2032
+ * at rest inside the disc on both sides of the joint line — and the whole
2033
+ * disc is what a ball writes (its lower half into the lower piece), so the
2034
+ * rule reads both halves: a ball whose lower half the art does not give
2035
+ * shows it at a bend. No row of a rig without `"disc"` or `"ball"` changes.
2022
2036
  * - **Opt-in by construction.** Written only when `parts.json` holds a limb
2023
2037
  * record with a `range`; a rig without one renders nothing more and writes
2024
2038
  * what it wrote.
@@ -3070,8 +3084,8 @@ export interface SweepJoint {
3070
3084
  range: [number, number];
3071
3085
  at: [number, number];
3072
3086
  radius: number;
3073
- /** Issue #360: the cap's record says `shape: "disc"` — the disc is held to no pixel uncovered ({@link sweepLine}). */
3074
- disc?: true;
3087
+ /** Issues #360 and #598: the cap's record says `shape: "disc"` or `"ball"` — the disc is held to no pixel uncovered ({@link sweepLine}). */
3088
+ shape?: 'disc' | 'ball';
3075
3089
  /** Issue #557: the upper segment's bone (the limb record one segment up), whose direction the contour step is read across; null when parts.json has none. */
3076
3090
  upperBone?: string | null;
3077
3091
  /** Issue #557: the cap's record carries `short_px` — the step is then written into check.json ({@link SweepPose}). */
@@ -3094,7 +3108,7 @@ export function sweepJoints(parts: PartsFile): SweepJoint[] {
3094
3108
  range: [l.range[0], l.range[1]],
3095
3109
  at: [l.cap.at[0], l.cap.at[1]],
3096
3110
  radius: l.cap.radius,
3097
- ...(l.cap.shape === 'disc' ? { disc: true as const } : {}),
3111
+ ...(l.cap.shape === undefined ? {} : { shape: l.cap.shape }),
3098
3112
  upperBone: up,
3099
3113
  ...(l.cap.short_px === undefined ? {} : { short: { left: l.cap.short_px.left, right: l.cap.short_px.right } }),
3100
3114
  });
@@ -3325,8 +3339,8 @@ export interface SweepRow {
3325
3339
  range: [number, number];
3326
3340
  at: [number, number];
3327
3341
  radius: number;
3328
- /** Issue #360: written only for a joint whose cap is `cap_shape: "disc"`, held to no pixel over the level in its disc. */
3329
- shape?: 'disc';
3342
+ /** Issues #360 and #598: written only for a joint whose cap is `cap_shape: "disc"` or `"ball"`, held to no pixel over the level in its disc. */
3343
+ shape?: 'disc' | 'ball';
3330
3344
  under_px: number;
3331
3345
  status: 'PASS' | 'FAIL';
3332
3346
  poses: SweepPose[];
@@ -3363,7 +3377,7 @@ export function sweepLine(
3363
3377
  const seen: { grid: FrameSet | null } = { grid: null };
3364
3378
  const rows: SweepRow[] = joints.map((j, i) => {
3365
3379
  const object = (at: string): string => `joint "${j.joint}" (config.limbs.${j.limb} segment ${j.segment}, part "${j.part}", bone "${j.bone}") ${at}`;
3366
- const head = { part: j.part, limb: j.limb, segment: j.segment, joint: j.joint, bone: j.bone, range: j.range, at: j.at, radius: j.radius, ...(j.disc === true ? { shape: 'disc' as const } : {}), under_px: underPx[i] };
3380
+ const head = { part: j.part, limb: j.limb, segment: j.segment, joint: j.joint, bone: j.bone, range: j.range, at: j.at, radius: j.radius, ...(j.shape === undefined ? {} : { shape: j.shape }), under_px: underPx[i] };
3367
3381
  const why = unread[i];
3368
3382
  if (why !== null) {
3369
3383
  problems.push({ code: `CHECK_${SWEEP_LINE}`, object: object(`over its range [${j.range.join(', ')}]`), detail: `is not read: ${why}; a joint not read is not a pass` });
@@ -3388,8 +3402,8 @@ export function sweepLine(
3388
3402
  const f = seamFigures(under.frames[0].image, bare.frames[0].image, { x: 0, y: 0, width: vp.pixelWidth, height: vp.pixelHeight }, vp, bare.background, { sx: 1, sy: 1, tx: 0, ty: 0 });
3389
3403
  const mean = round3(f.mean);
3390
3404
  const scale = round6(vp.scale);
3391
- // Issue #360: a disc cap promises the disc covered at every pose, so one pixel over the level there is a FAIL of its own.
3392
- const discFail = j.disc === true && f.over40 > 0 && !seamFails(mean, f.over40, scale);
3405
+ // Issues #360 and #598: a disc or ball cap promises the disc covered at every pose, so one pixel over the level there is a FAIL of its own.
3406
+ const discFail = j.shape !== undefined && f.over40 > 0 && !seamFails(mean, f.over40, scale);
3393
3407
  const fail = seamFails(mean, f.over40, scale) || discFail;
3394
3408
  if (discFail) {
3395
3409
  problems.push({
@@ -3397,7 +3411,7 @@ export function sweepLine(
3397
3411
  object: object(`bent ${a}°`),
3398
3412
  detail:
3399
3413
  `${f.over40} frame px over ${SEAM_PX_LEVEL} (${f.over80} over ${SEAM_PX_LEVEL_HIGH}) at frame scale ${scale}, mean |d| ${mean}/255, against the same pose with the joint's own art drawn under the limb (${underPx[i]} px, the disc of radius ${j.radius} px about [${j.at.join(', ')}]); ` +
3400
- `the cap is cap_shape "disc", which promises the disc covered at every pose — no pixel of it over ${SEAM_PX_LEVEL}, under the rest-pose seam's bar as well — and the bend shows what lies behind the limb there: a cap pixel the art did not give ("limb cap:" counts them as missing), or a pixel cleared from "${j.part}" after assemble wrote it`,
3414
+ `the cap is cap_shape "${j.shape}", which promises the disc covered at every pose${j.shape === 'ball' ? ', on both sides of the joint line' : ''} — no pixel of it over ${SEAM_PX_LEVEL}, under the rest-pose seam's bar as well — and the bend shows what lies behind the limb there: a cap pixel the art did not give ("limb cap:" counts them as missing), or a pixel cleared from "${j.part}" after assemble wrote it`,
3401
3415
  });
3402
3416
  } else if (fail) {
3403
3417
  problems.push({
@@ -3922,7 +3936,7 @@ export function environmentLine(env: CheckEnvironment): string {
3922
3936
  * MEASURABLE is a problem. Without it nothing here reads, writes or prints
3923
3937
  * anything it did not before.
3924
3938
  */
3925
- export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, partsHome?: string, mode: PackMode = DEFAULT_PACK_MODE, source?: string, requirements?: string, seamPairsAsked = false, keepStills = false, set?: string, allSets = false, environment?: string, requirementsAs: string | undefined = requirements): CheckReport {
3939
+ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, partsHome?: string, mode: PackMode = DEFAULT_PACK_MODE, source?: string, requirements?: string, seamPairsAsked = false, keepStills = false, set?: string, allSets = false, environment?: string, requirementsAs: string | undefined = requirements, config?: InputFileRecord): CheckReport {
3926
3940
  let inp: CheckInputs;
3927
3941
  let reqFile: RequirementsFile | null = null;
3928
3942
  let reqRecord: RequirementsFileRecord | null = null;
@@ -4575,6 +4589,7 @@ export function runCheck(rigDir: string, outDir: string, rigc: RigcRunner, parts
4575
4589
  ...(sourceRead === null ? {} : { [SOURCE_LINE]: sourceRead }),
4576
4590
  ...(Object.keys(skipped).length === 0 ? {} : { skipped }),
4577
4591
  ...(Object.keys(setsFigures).length === 0 ? {} : { sets: setsFigures }),
4592
+ ...(config === undefined ? {} : { config }),
4578
4593
  ...(reqBlock === null ? {} : { requirements: reqBlock }),
4579
4594
  PASS: false,
4580
4595
  };
@@ -4685,7 +4700,23 @@ export interface RequirementsFileRecord {
4685
4700
  export function requirementsFileRecord(path: string, recorded: string): RequirementsFileRecord {
4686
4701
  const bytes = readFileSync(resolve(path));
4687
4702
  const raw = JSON.parse(bytes.toString('utf8')) as Record<string, unknown>;
4688
- return { path: recorded, sha256: createHash('sha256').update(bytes).digest('hex'), keys: Object.keys(raw) };
4703
+ return { ...inputFileRecord(bytes, recorded), keys: Object.keys(raw) };
4704
+ }
4705
+
4706
+ /**
4707
+ * An input file as `check.json` records it — the path as the caller wrote it,
4708
+ * never resolved, then the sha256 of the bytes read — in the order the
4709
+ * requirements record (issue #556) opens with; `build`'s `config` record
4710
+ * (issue #607) is this and nothing more.
4711
+ */
4712
+ export interface InputFileRecord {
4713
+ path: string;
4714
+ sha256: string;
4715
+ }
4716
+
4717
+ /** The {@link InputFileRecord} of `bytes`, recorded as `recorded`: the one place a record's digest is taken. */
4718
+ export function inputFileRecord(bytes: Uint8Array, recorded: string): InputFileRecord {
4719
+ return { path: recorded, sha256: createHash('sha256').update(bytes).digest('hex') };
4689
4720
  }
4690
4721
 
4691
4722
  /** The throwaway copies' specs and builds, under `--out`; removed before the stage returns. */
package/src/cloth.ts CHANGED
@@ -105,7 +105,9 @@ export interface ClothRecipe {
105
105
  * Issue #518: draft the parts this recipe meshes in the influence mode (`meshes.<part>.influence`, issue #378) rather
106
106
  * than on a lattice: `across`, `max` and `shape` as declared (no default — the reading that fixed the radius did not
107
107
  * vary them), `cell` the lattice cell the part would have had, and `radius` as declared or, absent, drafted as
108
- * {@link INFLUENCE_RADIUS_CELLS} cells past the part's farthest lattice vertex from its nearest link.
108
+ * {@link INFLUENCE_RADIUS_CELLS} cells past the part's farthest lattice vertex from its nearest link. Issue #615:
109
+ * under `split.hold_tip: true` the drafted mesh also declares `hold_tip: true` and `max` at least 8 (the lattice's
110
+ * held-fork smoothing cap), so the rig stage smooths its shares as it smooths the lattice's.
109
111
  */
110
112
  influence?: { across: boolean; max: number; shape: 'linear' | 'smooth'; radius?: number };
111
113
  }
@@ -116,8 +118,13 @@ export interface ClothRecipe {
116
118
  * cloth fixture and the public `wind` example (8 covered parts, `render --folds` with the physics on under wind
117
119
  * +1 -> -1 -> calm and a hip sway of 8 and 30 degrees, max 6, across, smooth): farthest + 2 to + 6 cells read 0
118
120
  * folded frames on every part, + 2 at the window's edge on one front-hair part, and a fold returned at 8-11 cells on
119
- * another. 3 is one cell inside that edge. [Hypothesis until a third subject: each edge rests on one part.] Past the
120
- * floor alone the mesh folds more than its lattice, and a larger radius is not safer; no ceiling is drafted.
121
+ * another. That reading counted folds only. Read against `check` as well (the rig as built under the same wind
122
+ * schedule, the three covered `wind` parts at the same number of cells), + 4 is the ceiling: `wind` `bottomwear`'s
123
+ * `CHECK_TIP_OVER_ROOT` ratio is 1.898 on the lattice, 1.801 at + 2 cells, 1.590 at + 3 and 1.471 at + 4, under the
124
+ * floor 1.4725, and 1.351 at + 6 (#513, rig-parts 1.52.0, rigc 2.60.0; the lattice, + 3 and + 4 read again on
125
+ * rig-parts 1.54.0, rigc 2.60.0 with the same figures, #599). The window that holds both is + 2 to + 3 cells, and 3 is
126
+ * its upper edge: one cell inside the fold edge, one under the check ceiling. [Hypothesis until a third subject: each
127
+ * edge rests on one part.] Past the floor alone the mesh folds more than its lattice, and a larger radius is not safer.
121
128
  */
122
129
  export const INFLUENCE_RADIUS_CELLS = 3;
123
130
 
@@ -44,6 +44,11 @@ export interface ClothEdit extends ConfigEdit {
44
44
  label: string;
45
45
  /** Issue #571: the input's entry was the previous recipe's draft (`--from`), and only that made it the recipe's. */
46
46
  previous?: true;
47
+ /**
48
+ * Issue #630: the entry is written back to the draft without the recipe (`--from`): the previous recipe drafted it
49
+ * and the recipe now does not — a tag whose recipe was dropped while another was kept.
50
+ */
51
+ plain?: true;
47
52
  }
48
53
 
49
54
  /**
@@ -105,8 +110,23 @@ function shown(v: unknown): string {
105
110
  * recipe's as `I` equal to `P` is — an owned name is replaced, and a name in `V` and not in `D` is removed — and a
106
111
  * conflict is an `I` equal to none of `D`, `P` and `V`, its first differing field read against `V` where `V` holds the
107
112
  * name. Without `previous` every rule, and every word of the refusal, is the one above.
113
+ *
114
+ * Issue #630: with `V`, a name `D` holds equal to `P` that `V` lacks or holds differently — an entry the previous
115
+ * recipe drafted (or replaced) and this one leaves to the draft without the recipe, as for a tag whose recipe was
116
+ * dropped while another was kept — is owned too: inserted where the input lacks it, replaced where the input equals
117
+ * `V`, and a conflict where it equals neither. Such an edit carries `plain`. `keepDropped` is the selftest's mutant
118
+ * only (the writer before #630, which never owned it); no flag or environment reaches it.
108
119
  */
109
- function entryEdits(path: readonly string[], identity: (e: unknown) => string | null, drafted: readonly unknown[], plain: readonly unknown[], input: readonly unknown[], conflicts: Problem[], previous: readonly unknown[] | null): ClothEdit[] {
120
+ function entryEdits(
121
+ path: readonly string[],
122
+ identity: (e: unknown) => string | null,
123
+ drafted: readonly unknown[],
124
+ plain: readonly unknown[],
125
+ input: readonly unknown[],
126
+ conflicts: Problem[],
127
+ previous: readonly unknown[] | null,
128
+ keepDropped = false,
129
+ ): ClothEdit[] {
110
130
  const section = path.join('.');
111
131
  const D = byName(drafted, identity, 'drafted', section);
112
132
  const P = byName(plain, identity, 'plain', section);
@@ -116,7 +136,10 @@ function entryEdits(path: readonly string[], identity: (e: unknown) => string |
116
136
  keys.forEach((k, i) => {
117
137
  if (k !== null) where.set(k, [...(where.get(k) ?? []), i]);
118
138
  });
119
- const owned = [...D.keys()].filter((k) => !P.has(k) || canon(P.get(k)) !== canon(D.get(k)));
139
+ const recipes = new Set([...D.keys()].filter((k) => !P.has(k) || canon(P.get(k)) !== canon(D.get(k))));
140
+ // Issue #630: a plain entry the previous recipe drafted differently or took away, which this recipe leaves plain.
141
+ const returned = new Set(V === null || keepDropped ? [] : [...D.keys()].filter((k) => !recipes.has(k) && (!V.has(k) || canon(V.get(k)) !== canon(D.get(k)))));
142
+ const owned = [...D.keys()].filter((k) => recipes.has(k) || returned.has(k));
120
143
  const removed = [...P.keys(), ...(V === null ? [] : [...V.keys()].filter((k) => !P.has(k)))].filter((k) => !D.has(k));
121
144
  const replace: string[] = [];
122
145
  const remove: string[] = [];
@@ -166,7 +189,7 @@ function entryEdits(path: readonly string[], identity: (e: unknown) => string |
166
189
  vouched.add(k);
167
190
  } else conflict(k, at[0], false);
168
191
  }
169
- const mark = (k: string): { previous?: true } => (vouched.has(k) ? { previous: true } : {});
192
+ const mark = (k: string): { previous?: true; plain?: true } => ({ ...(vouched.has(k) ? { previous: true as const } : {}), ...(returned.has(k) ? { plain: true as const } : {}) });
170
193
  const edits: ClothEdit[] = [];
171
194
  const work = [...keys];
172
195
  for (const k of replace) edits.push({ path: [...path, work.indexOf(k)], value: D.get(k), label: `${section}["${k}"] replaced`, ...mark(k) });
@@ -186,7 +209,7 @@ function entryEdits(path: readonly string[], identity: (e: unknown) => string |
186
209
  break;
187
210
  }
188
211
  }
189
- edits.push({ path: [...path, pos], value: D.get(k), insert: true, label: `${section}["${k}"] inserted` });
212
+ edits.push({ path: [...path, pos], value: D.get(k), insert: true, label: `${section}["${k}"] inserted`, ...mark(k) });
190
213
  work.splice(pos, 0, k);
191
214
  }
192
215
  return edits;
@@ -206,10 +229,20 @@ function entryEdits(path: readonly string[], identity: (e: unknown) => string |
206
229
  * object entry (`meshes.<part>`, `regions.<part>`) the recipe drafts is replaced whole already, so `previous` changes
207
230
  * nothing there. Null — no `--from` — is the writer before #571, rule for rule and byte for byte.
208
231
  *
232
+ * Issue #630: where the two drafts agree and the previous draft differs — what the previous recipe drafted and this one
233
+ * leaves to the draft without the recipe, a tag whose recipe was dropped while another was kept — the entry goes back
234
+ * to the plain draft: in an array section by {@link entryEdits}' rule, and at any other entry (`meshes.<part>`,
235
+ * `regions.<part>`, a section the input holds whole) when the input equals the previous draft there or lacks the entry
236
+ * in an object it holds; an input equal to neither the draft nor the previous draft there is a hand edit, refused by
237
+ * name. Each such edit that writes the plain draft's value carries `plain` (a removal does not, as an array name the
238
+ * previous recipe drafted and the plain draft lacks is removed without it). A section the input lacks is left to the
239
+ * input, as before.
240
+ *
209
241
  * `whole` is the selftest's mutant only (issue #552): `bones`, `constraints` and `motion.tracks` replaced whole, as
210
- * the #537 writer did; no flag or environment reaches it.
242
+ * the #537 writer did; `keepDropped` is the selftest's mutant only (issue #630): the writer before it, which leaves a
243
+ * dropped recipe's entries as the previous draft wrote them. No flag or environment reaches either.
211
244
  */
212
- export function clothConfigEdits(drafted: Proposal, plain: Proposal, input: unknown, whole = false, previous: Proposal | null = null): ClothEdit[] {
245
+ export function clothConfigEdits(drafted: Proposal, plain: Proposal, input: unknown, whole = false, previous: Proposal | null = null, keepDropped = false): ClothEdit[] {
213
246
  const edits: ClothEdit[] = [];
214
247
  const conflicts: Problem[] = [];
215
248
  const d = JSON.parse(JSON.stringify(drafted)) as Record<string, unknown>;
@@ -224,27 +257,56 @@ export function clothConfigEdits(drafted: Proposal, plain: Proposal, input: unkn
224
257
  const one = (path: readonly string[], a: unknown, b: unknown): void => {
225
258
  const s = arrayOf(path);
226
259
  const mine = valueAt(input, path);
227
- if (s !== undefined && Array.isArray(b) && (a === undefined || Array.isArray(a)) && Array.isArray(mine)) edits.push(...entryEdits(path, s.identity, b, Array.isArray(a) ? a : [], mine, conflicts, prevAt(path)));
260
+ if (s !== undefined && Array.isArray(b) && (a === undefined || Array.isArray(a)) && Array.isArray(mine)) edits.push(...entryEdits(path, s.identity, b, Array.isArray(a) ? a : [], mine, conflicts, prevAt(path), keepDropped));
228
261
  else edits.push({ path, value: b, label: path.join('.') });
229
262
  };
230
263
  // Issue #571: an array section the two drafts agree at, where the previous draft differs — its entries the previous recipe drafted and this one does not.
264
+ // Issue #630: and any other entry there, which goes back to the draft (the plain draft's value, the two agreeing).
231
265
  const prevOnly = (path: readonly string[], b: unknown): void => {
266
+ if (v === null) return;
232
267
  const s = arrayOf(path);
233
268
  const mine = valueAt(input, path);
234
269
  const c = valueAt(v, path);
235
- if (v === null || s === undefined || !Array.isArray(b) || !Array.isArray(mine) || canon(c) === canon(b)) return;
236
- edits.push(...entryEdits(path, s.identity, b, b, mine, conflicts, prevAt(path)));
270
+ if (canon(c) === canon(b)) return;
271
+ if (s !== undefined && (Array.isArray(b) || b === undefined) && Array.isArray(mine)) {
272
+ const drafts = Array.isArray(b) ? b : [];
273
+ edits.push(...entryEdits(path, s.identity, drafts, drafts, mine, conflicts, prevAt(path), keepDropped));
274
+ return;
275
+ }
276
+ if (keepDropped || s !== undefined) return;
277
+ // The entry's own object must be the input's: a section the input lacks is the input's to lack, as before #630.
278
+ const holder = path.length === 1 ? input : valueAt(input, path.slice(0, -1));
279
+ if (!isPlain(holder) || (path.length === 1 && mine === undefined)) return;
280
+ const where = `config.${path.join('.')}`;
281
+ if (canon(mine) === canon(b)) return;
282
+ if (mine === undefined || canon(mine) === canon(c)) {
283
+ edits.push({ path, value: b, label: `${path.join('.')} ${b === undefined ? 'removed' : mine === undefined ? 'inserted' : 'replaced'}`, ...(b !== undefined ? { plain: true as const } : {}), ...(mine !== undefined ? { previous: true as const } : {}) });
284
+ return;
285
+ }
286
+ const field = firstField(mine, c);
287
+ const at = (e: unknown, f: string): string => (isPlain(e) && e[f] !== undefined ? `${f} ${shown(e[f])}` : `no ${f}`);
288
+ conflicts.push({
289
+ code: 'PROPOSE_WRITE_CONFIG_CONFLICT',
290
+ object: where,
291
+ detail: `${path.join('.')} is the previous recipe's, the recipe now leaves it to the draft without the recipe, and it was changed by hand: it equals neither the draft nor the previous recipe's draft: it holds ${field === null ? shown(mine) : at(mine, field)} where the previous recipe's draft writes ${c === undefined ? 'no such entry' : field === null ? shown(c) : at(c, field)} and the draft writes ${b === undefined ? 'no such entry' : field === null ? shown(b) : at(b, field)}, so the write would drop the hand edit; take the draft by removing the hand edit (or the entry), or keep the recipe for that part (its config.cloth block)`,
292
+ });
293
+ };
294
+ const prevKeys = (section: string, have: readonly string[]): string[] => {
295
+ const pv = v === null ? undefined : v[section];
296
+ return isPlain(pv) ? Object.keys(pv).filter((k) => !have.includes(k)) : [];
237
297
  };
238
298
  for (const section of PROPOSAL_CONFIG_SECTIONS) {
239
299
  const a = p[section];
240
300
  const b = d[section];
241
301
  if (JSON.stringify(a) === JSON.stringify(b)) {
242
- if (isPlain(b)) for (const k of Object.keys(b)) prevOnly([section, k], b[k]);
302
+ if (isPlain(b)) for (const k of [...Object.keys(b), ...prevKeys(section, Object.keys(b))]) prevOnly([section, k], b[k]);
303
+ else if (b === undefined && isPlain(v === null ? undefined : v[section])) for (const k of prevKeys(section, [])) prevOnly([section, k], undefined);
243
304
  else prevOnly([section], b);
244
305
  continue;
245
306
  }
246
307
  if (isPlain(a) && isPlain(b)) {
247
- for (const k of [...Object.keys(b), ...Object.keys(a).filter((k) => !(k in b))]) {
308
+ const keys = [...Object.keys(b), ...Object.keys(a).filter((k) => !(k in b))];
309
+ for (const k of [...keys, ...prevKeys(section, keys)]) {
248
310
  if (JSON.stringify(a[k]) !== JSON.stringify(b[k])) one([section, k], a[k], b[k]);
249
311
  else prevOnly([section, k], b[k]);
250
312
  }
@@ -278,6 +340,11 @@ export function previousCount(edits: readonly ClothEdit[]): number {
278
340
  return edits.filter((e) => e.previous === true).length;
279
341
  }
280
342
 
343
+ /** Issue #630: how many edits wrote an entry back to the draft without the recipe — a dropped recipe's entries. */
344
+ export function plainCount(edits: readonly ClothEdit[]): number {
345
+ return edits.filter((e) => e.plain === true).length;
346
+ }
347
+
281
348
  /** What each edit names, in order: what the write line prints. */
282
349
  export function editPaths(edits: readonly ClothEdit[]): string[] {
283
350
  return edits.map((e) => e.label);
package/src/config.ts CHANGED
@@ -328,9 +328,11 @@ export type MeshSpec = LatticeMeshSpec | ContourMeshSpec | AutoMeshSpec | Influe
328
328
  * `buildSegmentsLattice` and `influenceShares` from `rig-c/mesh`, promised for this call (rig-c/core#1450), so the
329
329
  * rule is core's and the mesh is written with explicit weights like every other mode (`src/rig.ts`). `segments`
330
330
  * names the links as in every mode; each entry is one of rig-c's `bones` entries, which `across: false` keeps apart.
331
+ * `hold_tip: true` (issue #615, optional, written by `propose --cloth` from the recipe's `split.hold_tip`) smooths the
332
+ * pulled shares by the lattice's held-fork passes, capped at `max`; absent, the shares are rig-c's as pulled.
331
333
  */
332
334
  export interface InfluenceMeshSpec {
333
- influence: { cell: number; radius: number; across: boolean; max: number; shape: 'linear' | 'smooth' };
335
+ influence: { cell: number; radius: number; across: boolean; max: number; shape: 'linear' | 'smooth'; hold_tip?: true };
334
336
  segments: Segment[];
335
337
  }
336
338
 
@@ -1159,22 +1161,38 @@ function partNameOk(name: string): boolean {
1159
1161
  // the loader
1160
1162
  // ---------------------------------------------------------------------------
1161
1163
 
1162
- /** The file as parsed JSON, or a refusal naming why not. Both loaders read through it. */
1163
- function readConfigFile(path: string): Json {
1164
+ /** The file's bytes as read and as parsed JSON, or a refusal naming why not. Every loader reads through it. */
1165
+ function readConfigBytes(path: string): { raw: Json; bytes: Buffer } {
1164
1166
  if (!existsSync(path)) refuseIfAny([{ code: 'CONFIG_FILE_PRESENT', object: path, detail: 'no such file' }]);
1167
+ const bytes = readFileSync(path);
1165
1168
  let raw: Json;
1166
1169
  try {
1167
- raw = JSON.parse(readFileSync(path, 'utf8'));
1170
+ raw = JSON.parse(bytes.toString('utf8'));
1168
1171
  } catch (err) {
1169
1172
  refuseIfAny([{ code: 'CONFIG_IS_JSON', object: path, detail: `does not parse as JSON: ${(err as Error).message}` }]);
1170
1173
  }
1171
- return raw;
1174
+ return { raw, bytes };
1175
+ }
1176
+
1177
+ /** The file as parsed JSON, or a refusal naming why not. */
1178
+ function readConfigFile(path: string): Json {
1179
+ return readConfigBytes(path).raw;
1172
1180
  }
1173
1181
 
1174
1182
  export function loadConfig(path: string): CharacterConfig {
1175
1183
  return loadConfigAndAnimations(path).config;
1176
1184
  }
1177
1185
 
1186
+ /**
1187
+ * The full loader, with the bytes it parsed (issue #607): `build` hashes these
1188
+ * into `check.json`'s `config` record, so the digest is of the bytes this read
1189
+ * took, not of a later read of the same path.
1190
+ */
1191
+ export function loadConfigWithBytes(path: string): { config: CharacterConfig; bytes: Buffer } {
1192
+ const { raw, bytes } = readConfigBytes(path);
1193
+ return { config: parseConfigFrom(raw, dirname(resolve(path))).config, bytes };
1194
+ }
1195
+
1178
1196
  /**
1179
1197
  * The full loader with the file `motion.animations_from` names read beside it,
1180
1198
  * relative to the config's directory: every problem in either is one refusal.
@@ -2476,8 +2494,11 @@ function checkInfluence(c: Check, at: string, m: Record<string, Json>): void {
2476
2494
  for (const k of INFLUENCE_FOREIGN_FIELDS) {
2477
2495
  if (k in m) c.fail('CONFIG_INFLUENCE_MODE', `${at}.${k}`, `is ${show(m[k])} on an influence mesh; it pulls each vertex by rig-c's influence (radius, across, max, shape), which reads no ${k} — remove ${k}`);
2478
2496
  }
2479
- const o = c.object(`${at}.influence`, m.influence, ['cell', 'radius', 'across', 'max', 'shape'], []);
2497
+ const o = c.object(`${at}.influence`, m.influence, ['cell', 'radius', 'across', 'max', 'shape'], ['hold_tip']);
2480
2498
  if (o === null) return;
2499
+ // Issue #615: one spelling — true smooths the held fork, absent leaves the shares as pulled; false would be a second
2500
+ // spelling of absent, and a mesh_report row that echoes it would differ from the one written before the field existed.
2501
+ if ('hold_tip' in o && o.hold_tip !== true) c.fail('CONFIG_FIELD_TYPE', `${at}.influence.hold_tip`, `is ${show(o.hold_tip)}; true (the pulled shares smoothed across the held fork, capped at max) is required — remove hold_tip to keep the shares as rig-c pulls them`);
2481
2502
  if ('cell' in o) c.int(`${at}.influence.cell`, o.cell, 1);
2482
2503
  if ('radius' in o) c.number(`${at}.influence.radius`, o.radius, 'positive');
2483
2504
  if ('across' in o && typeof o.across !== 'boolean') c.fail('CONFIG_FIELD_TYPE', `${at}.influence.across`, `is ${show(o.across)}; true (every link within radius pulls, across the segments entries) or false (only the links of the entry nearest the vertex) is required`);