@melite/models-h3 0.2.0-alpha → 0.2.3-rc.4

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/lib/actions.js CHANGED
@@ -1,22 +1,25 @@
1
1
  import { fireControlNets } from '@melite/comfyui-card-kit/guard';
2
2
  import { saveAudio } from '@melite/comfyui-card-kit';
3
- import { mediaKindOf } from '@melite/contracts/mediaKinds';
4
- import { assertKeyframeRowShape, FAMILIES, paramSchema, wireList, H3_RECOMMENDED_SAMPLERS } from './schema.js';
3
+ import { assertKeyframeRowShape, FAMILIES, paramSchema, wireList, H3_RECOMMENDED_SAMPLERS, REFINE_DENOISE_DEFAULT, outputNameTailOf } from './schema.js';
5
4
  import { H3_LORA_ROWS } from '@melite/models-h3/mods/loras';
6
5
  import { SAMPLER_OPTIONS, SCHEDULER_OPTIONS } from '@melite/comfyui-card-kit/vocab';
7
- import { computeFilmMix, parseFilmMixClips, spanOverlap, stanzaSecs } from './filmMix.js';
8
- import { GRID_REMAINDER, GRID_STEP_FRAMES, IMAGE_BUS_SLOTS, REF_CAPS, assertGridLength, assertSpanGrid, imageReferenceCap, isGridLength, isMediaRef, DOC_FPS_DEFAULT, spanStanzaFrames, transitionOverlap, } from './timelineContract.js';
6
+ import { chooseLaneClips, computeFilmMix, parseFilmMixClips, spanOverlap, stanzaSecs } from './filmMix.js';
7
+ import { SECOND_PASS_WINDOW } from './secondPass.js';
8
+ import { mountRefModBake } from './refmodBake.js';
9
+ import { DOC_FPS_DEFAULT, GRID_REMAINDER, GRID_STEP_FRAMES, IMAGE_BUS_SLOTS, LAST_FRAME_BATCH_INDEX, REF_CAPS, assertGridLength, assertSpanGrid, bookSeconds, imageReferenceCap, isGridLength, isMediaRef, spanStanzaFrames, transitionOverlap } from './timelineContract.js';
9
10
  import { applyH3ReshootCond, applyH3ReshootModel, buildH3Reshoot, reshootArmed, reshootPrompt, } from './reshoot.js';
10
11
 
11
12
 
12
13
 
13
- // default seat, preferred for detail at 8 steps; the standalone
14
- // LightX2V turbos stay in the catalog for the audio/dialogue
15
- // routes). THE ROW IS `h3_lightx2v_turbo` — the LightX2V turbo
16
- // 4-to-8-step × dareties v4 step600 merge (label "LightX2V Turbo
17
- // 4-8 step", strength 0.6, designed 4–8 steps); there is NO separate
18
- // catalog row labelled "Larry + LightX2V" — F34b's finding was this
19
- // prose naming a row the catalog never held. The row is resolved from the
14
+ // default lora to the silveroxides merge"; SILVEROXIDES IS THE
15
+ // MERGE, LIGHTX2V IS NOT). THE ROW IS `h3_silver_dareties` —
16
+ // silveroxides' OFFICIAL silver_official_releases DARE-TIES merge
17
+ // (label "Silveroxides DARE-TIES Merge", strength 0.8, designed
18
+
19
+ // experimental/ LightX2V-turbo × dareties file (h3_lightx2v_turbo)
20
+ // as "the merge" — the F34b class: a merge row the catalog never
21
+ // held; that row stays pick-only under its honest experimental
22
+ // label. The row is resolved from the
20
23
  // family lora CATALOG (mods/loras.ts — the one owner of every lora
21
24
  // filename and default strength; the value was restated as a
22
25
  // literal here, which is how a catalog edit would have silently
@@ -25,7 +28,8 @@ import { applyH3ReshootCond, applyH3ReshootModel, buildH3Reshoot, reshootArmed,
25
28
  // mode flags. A missing catalog row refuses at load — the default
26
29
  // would have no source.
27
30
 
28
- export const H3_DEFAULT_LORA_ID = 'h3_lightx2v_turbo';
31
+
32
+ export const H3_DEFAULT_LORA_ID = 'h3_silver_dareties';
29
33
  /** The absent-bag default as a RESOLVED ROW — the same catalog row the
30
34
  * compose default builds, exposed so the card can serve it as the
31
35
  * ghost chip: the face then shows the adapter the film will actually
@@ -182,9 +186,11 @@ function resolveRefineSeat(p) {
182
186
  // the voice is the rider's (ARM 4f judges it at the family plane),
183
187
  // borrowed verbatim by the arm.
184
188
  function resolveStage2Denoise(p) {
185
- const denoise = p.refine_denoise ?? 0.35;
186
- if (!(denoise >= 0.05 && denoise <= 1)) {
187
- throw new Error(`h3 action: refine_denoise ${String(p.refine_denoise)} falls outside the refinement window [0.05, 1] — 1 is the full-denoise taomate mechanic, 0.30–0.35 the SOTA refinement window; a dead or over-terminal second pass never composes`);
189
+ const denoise = p.refine_denoise ?? REFINE_DENOISE_DEFAULT;
190
+ // THE SHARED WINDOW (secondPass.ts): the bounds are the seat's
191
+ // own — this door keeps its taomate voice.
192
+ if (!(denoise >= SECOND_PASS_WINDOW[0] && denoise <= SECOND_PASS_WINDOW[1])) {
193
+ throw new Error(`h3 action: refine_denoise ${String(p.refine_denoise)} falls outside the refinement window [${SECOND_PASS_WINDOW.join(', ')}] — 1 is the full-denoise taomate mechanic, 0.30–0.35 the SOTA refinement window; a dead or over-terminal second pass never composes`);
188
194
  }
189
195
  return denoise;
190
196
  }
@@ -204,10 +210,25 @@ const mathStepsGold = (fps) => `max(${GRID_REMAINDER}, round(a * ${fps})) + (${G
204
210
  // switch flipped. Orphan + stub prompt = the marker law kept, the
205
211
  // hazard structurally dead.
206
212
  const I2V_MARKER_PROMPT = 'i2v marker branch — orphaned, never executed (r2v is the only lane)';
207
- // ImageSharpenKJ's grouped-widget defaults (the rcas block the python
208
- // builds when no sharpen leaf is injected; the card exposes only the
209
- // strength leaf — sharpen_strength).
213
+ // ImageSharpenKJ's tuned defaults (the rcas operating point the
214
+ // operator's V9 notes bless — strength 0.3 "looks natural" after the
215
+ // upscaler; radius/threshold/iterations ride for the non-rcas
216
+ // methods. These are OURS, not the pack's served defaults).
210
217
  const SHARPEN_DEFAULTS = { method: 'rcas', strength: 0.3, radius: 1.0, threshold: 0.05, iterations: 10 };
218
+ // The served V3 DynamicCombo's per-option child seats, off the pack's
219
+ // own declaration (ComfyUI-KJNodes nodes/sharpen_nodes.py
220
+ // define_schema: io.DynamicCombo.Option(key=...) inputs). The
221
+ // composer emits ONLY the selected option's children on dotted wires;
222
+ // the engine folds unexpanded seats silently (never an error), so a
223
+ // non-selected seat would ride dead bytes. The U2 wall diffs this map
224
+ // against the pack declaration — a pack-side child change reds there,
225
+ // never here first.
226
+ const SHARPEN_OPTION_CHILDREN = {
227
+ rcas: ['strength'],
228
+ adaptive_usm: ['strength', 'radius', 'threshold'],
229
+ high_pass: ['strength', 'radius'],
230
+ deconvolution: ['strength', 'radius', 'iterations'],
231
+ };
211
232
 
212
233
 
213
234
 
@@ -344,6 +365,22 @@ export function concatSavedFilms(g, prefixes, after, out, opts = {}) {
344
365
  * (the node's context_frames arm). prev_sec scales the carry:
345
366
  * picture snapped to the node's legal context lengths (5/22/39/56
346
367
  * frames — only whole latent steps), audio at 24 frames/second. */
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+ const isSpell = (s) => s.startsWith('$');
377
+ /** THE WIRED SOUNDTRACK SEAT COUNT — mirrors the pack's own
378
+ * WIRED_CLIP_SEATS (vendor melite-audio-nodes film_mix.py): the mix
379
+ * node declares wired_audio_1..4 optional AUDIO seats, and the
380
+ * compose refuses a spelled clip beyond them loud. Raise BOTH
381
+ * together (the refusal names the pack constant as the second
382
+ * cure). */
383
+ const WIRED_CLIP_SEATS = 4;
347
384
  function renderH3Film(p, g, facts, model, runId) {
348
385
  // (the compose dispatch guarantees calls is a non-empty array here)
349
386
  const calls = p.calls;
@@ -465,6 +502,58 @@ function renderH3Film(p, g, facts, model, runId) {
465
502
  // fallback (a row's unstated count read from the family table by
466
503
  // filename) is the same math on every face.
467
504
  const loraStepsApplied = marriedBagKnob(p, 'steps');
505
+
506
+ // MeliteConcatVideos refuses members at mixed fps LOUD at execute
507
+ // — AFTER every window's GPU is paid and every member file is
508
+ // saved (a split doc composes validate-green and dies with the
509
+ // film rendered: window1_CreateVideo fps 48 against window2's 24,
510
+ // the concat naming both rates). The interp decision is the DOC's
511
+ // voice: the stanza merge ({...p, ...knobs} below) folds per-call
512
+ // pins into the params renderH3Window reads, so a call pinning
513
+ // interpolate_enabled or interp_multiplier against the film — or
514
+ // smuggling second_pass_enabled past the knob vocabulary — renders
515
+ // its member at a foreign clock and the join dies there. This
516
+ // sweep judges the RESULT (each window's computed clock against
517
+ // the film's, with the composer's own reads: strict master,
518
+ // truthy switch, raw multiplier), never the key list — zero nodes
519
+ // built, the first split window refusing with its pin state, the
520
+ // film's clock, and the cure (move the pin to the film level;
521
+ // per-shot interp is unstatable because the join cannot restamp
522
+ // one member silently). Agreement — or silence — rides the film's
523
+ // clock untouched; interp_model stays a per-shot choice (the
524
+ // model never touches the clock). The single-window face needs no
525
+ // seat (no join, no clock to split); an extend-time append file at
526
+ // a foreign rate stays the vendor's own loud refusal (both rates
527
+ // named — the correct seat for a file the film never rendered).
528
+ const filmInterpOn = p.second_pass_enabled === true && Boolean(p.interpolate_enabled);
529
+ const filmInterpMult = p.interp_multiplier;
530
+ for (let i = 0; i < calls.length; i += 1) {
531
+ const call = calls[i];
532
+ const knobs = (call.knobs ?? {});
533
+ const merged = { ...p, ...knobs };
534
+ const winOn = merged.second_pass_enabled === true && Boolean(merged.interpolate_enabled);
535
+ if (winOn !== filmInterpOn) {
536
+ // (the pin voice reads key PRESENCE, never undefined-
537
+ // comparison: an explicit null/undefined pin still overrides
538
+ // the merge — {...p, ...{k: undefined}}.k is undefined — so
539
+ // the composer renders it falsy while a !== undefined filter
540
+ // would report "no pin stated". The no-silent-repair law
541
+ // refuses explicit nulls, never fills them.)
542
+ const isObj = typeof knobs === 'object' && knobs !== null;
543
+ const named = ['interpolate_enabled', 'second_pass_enabled']
544
+ .filter((key) => isObj && key in knobs)
545
+ .map((key) => `knobs.${key} = ${typeof knobs[key] === 'undefined' ? 'undefined' : JSON.stringify(knobs[key])}`)
546
+ .join(', ');
547
+ const stated = named !== '' ? named : `knobs = ${JSON.stringify(knobs).slice(0, 80)}`;
548
+ throw new Error(`h3-timeline window ${i + 1}: ${stated} states a ${winOn ? 'doubled' : 'base-rate'} member against the film's ${filmInterpOn ? 'interpolated' : 'base-rate'} clock — the join shares one clock (MeliteConcatVideos refuses mixed-fps members at execute, after every window renders); move the pin to the film level (interpolate_enabled), per-window interp is unstatable`);
549
+ }
550
+ if (filmInterpOn && winOn) {
551
+ const winMult = merged.interp_multiplier;
552
+ if (winMult !== filmInterpMult) {
553
+ throw new Error(`h3-timeline window ${i + 1}: knobs.interp_multiplier = ${JSON.stringify(knobs.interp_multiplier)} states a ×${String(winMult)} member against the film's ×${String(filmInterpMult)} clock — the join shares one clock (MeliteConcatVideos refuses mixed-fps members at execute, after every window renders); move the pin to the film level (interp_multiplier), per-window interp is unstatable`);
554
+ }
555
+ }
556
+ }
468
557
  calls.forEach((call, i) => {
469
558
  const k = i + 1;
470
559
  // THE OPENER ANCHOR (cure 8's film arm — session 384a13cd's bread
@@ -515,16 +604,24 @@ function renderH3Film(p, g, facts, model, runId) {
515
604
  if (sf !== null && ef !== null && Number.isFinite(sf) && Number.isFinite(ef) && ef > sf) {
516
605
  const carry = i > 0 ? overlap : 0;
517
606
  const genStart = sf - carry;
518
- for (let ci = 0; ci < clips.length; ci++) {
519
- const clip = clips[ci];
520
- if (clip.dur <= 0)
607
+
608
+ // a clip that STARTS inside this window owns its class's
609
+ // lane; a seam-crossing clip owns only a window no same-class
610
+ // clip starts inside (the line continues, never restarts, but
611
+ // it yields to the window's own speech); two same-class
612
+ // starters inside one window refuse loud. Row order
613
+
614
+ // window 2's dialogue lane from the row that started there,
615
+ // and window 2 re-performed line 1 while the real row
616
+ // conditioned nothing.
617
+ const lanes = chooseLaneClips(clips, sf, ef, genStart);
618
+ for (const cls of ['dialogue', 'sfx', 'music']) {
619
+ const ci = lanes[cls];
620
+ if (ci === undefined)
521
621
  continue;
522
- if (stamps[clip.cls] !== undefined)
523
- continue; // one lane per class per window
622
+ const clip = clips[ci];
524
623
  const lo = Math.max(clip.start, genStart);
525
624
  const hi = Math.min(clip.start + clip.dur, ef);
526
- if (hi - lo < 2.4)
527
- continue; // below the slice node's 0.1s floor
528
625
  // ONE CLOCK (journey audit AUDIO-2): the stamps' seconds
529
626
  // speak the DOC CLOCK — p.fps when stated, the schema row's
530
627
  // default otherwise. The /24 literal stretched a 16fps
@@ -532,9 +629,13 @@ function renderH3Film(p, g, facts, model, runId) {
532
629
  // the audit's worst burn).
533
630
  const stampFps = typeof p.fps === 'number' && p.fps > 0 ? p.fps : DOC_FPS_DEFAULT;
534
631
  const ms = (frames) => Math.round((frames / stampFps) * 1000) / 1000;
535
- stamps[clip.cls] = {
632
+ stamps[cls] = {
536
633
  src: clip.src,
537
- slice_start_seconds: ms(Math.max(0, genStart - clip.start)),
634
+ // the SOURCE in-point rides BOTH halves (the clipping
635
+ // lane): the conditioning slice starts in_frames into the
636
+ // source, exactly where the pristine overlay starts — the
637
+ // model hears the segment the film plays.
638
+ slice_start_seconds: ms(clip.srcIn + Math.max(0, genStart - clip.start)),
538
639
  slice_duration_seconds: ms(hi - lo),
539
640
  delay_seconds: ms(Math.max(0, clip.start - genStart)),
540
641
  text: clip.text,
@@ -636,7 +737,10 @@ function renderH3Film(p, g, facts, model, runId) {
636
737
  // in renderH3Window's family line, never a window that claims
637
738
  // t4_open while its chain rides the reference arm).
638
739
  const winPins = (p.__keyframe_pins ?? {})[String(k)] ?? [];
639
- stanza.variant = (guide !== '' || hasRefs || hasDirectRefs || anyStamp || winPins.length > 0) ? 't4r' : chainLike ? 't4_chain' : 't4_open';
740
+ // the seam keyframe pin is the same class (an image guide at
741
+ // frame 0) — the window derives the reference lane with it
742
+ const seamKeyframe = stanza.__seam_keyframe === true;
743
+ stanza.variant = (guide !== '' || hasRefs || hasDirectRefs || anyStamp || winPins.length > 0 || seamKeyframe) ? 't4r' : chainLike ? 't4_chain' : 't4_open';
640
744
  // the distill's steps apply unless this call's knobs pinned steps
641
745
  // — or the DOC did (the __steps_pinned stamp, the walk's own
642
746
  // explicit-keys fact; the single-window marriage always consulted
@@ -729,6 +833,14 @@ function renderH3Film(p, g, facts, model, runId) {
729
833
  if (i > 0) {
730
834
  stanza.__iteration = k - 1;
731
835
  stanza.__overlap = overlap;
836
+ // THE THIRD CARRY MODE (the context-carry modes): a
837
+ // 'carry+keyframe' seam chains like extend (the overlap
838
+ // derives the same 22f — transitionOverlap reads only 'cut')
839
+ // AND stamps the keyframe pin — the renderer's seam block
840
+ // mounts the previous window's decoded final frame as this
841
+ // window's first-frame guide (one derivation, no new chain).
842
+ if (call.transition === 'carry+keyframe')
843
+ stanza.__seam_keyframe = true;
732
844
  }
733
845
  if (prev !== undefined)
734
846
  stanza.__prev = prev;
@@ -863,16 +975,58 @@ function renderH3Film(p, g, facts, model, runId) {
863
975
  // the MIXED audio wired into CreateVideo — the film mp4 carries
864
976
  // the mix, not the raw concat audio. Early return: the
865
977
  // clips-free arm below stays byte-frozen.
978
+ // THE SOUNDTRACK WIRE SEATS (GAPS-20 one-way law, face #14's
979
+
980
+ // spelled clip src names a WIRED STAGE INPUT, never a file. The
981
+ // manifest row carries `wired: k` and NO src key (src embedded
982
+ // in the JSON string is dead text to the merge), and the compose
983
+ // seats the spell on a DECLARED MeliteAudioResample at the film's
984
+ // own clock (FILM_AUDIO_RATE) and carries the HOP'S LINK into the
985
+ // pack's optional AUDIO seat wired_audio_k — rewriteSpells lands
986
+ // the producer's link on the hop's audio input, so the seat
987
+ // receives film-rate audio. THE FILM-CLOCK HOP (F-B cure,
988
+
989
+ // refuses a wired seat at a foreign rate LOUD (film_mix.py
990
+ // seat_source — "a wired producer rides the film's own clock …
991
+ // never silently resampled") and a 24 kHz producer arrives
992
+ // exactly foreign; the resample is a visible node the merged
993
+ // graph carries — the declared hop is the opposite of the silent
994
+ // coercion the law bans. A path row keeps the staged-file
995
+ // handoff byte-identical (the estate boundary — lawful, S3
996
+ // freezes it). Seat overflow refuses loud, naming the row and
997
+ // both cures — never a silent drop.
998
+ const wiredSeats = {};
999
+ let nextSeat = 0;
1000
+ const mixRows = manifest.placements.map((pl) => {
1001
+ const clip = clips[pl.clip];
1002
+ // THE OVERLAY'S IN-POINT (the clipping lane): in_sec rides only
1003
+ // when the clip starts past the source head — a 0 in-point omits
1004
+ // the key, byte-identical to every manifest row composed before
1005
+ // the lane existed (the wired-row arm freezes that shape).
1006
+ const inSec = Math.round((clip.srcIn / (typeof p.fps === 'number' && p.fps > 0 ? p.fps : DOC_FPS_DEFAULT)) * 1000) / 1000;
1007
+ const inField = inSec > 0 ? { in_sec: inSec } : {};
1008
+ if (!isSpell(clip.src)) {
1009
+ return { src: clip.src, start_sec: pl.filmSec, dur_sec: pl.durSec, class: pl.cls, ...inField };
1010
+ }
1011
+ nextSeat += 1;
1012
+ if (nextSeat > WIRED_CLIP_SEATS) {
1013
+ throw new Error(`[h3-timeline] audio_clips[${pl.clip}] (${clip.cls}, src ${clip.src}) needs wired soundtrack seat ${nextSeat} but the film mix declares only ${WIRED_CLIP_SEATS} (wired_audio_1..${WIRED_CLIP_SEATS}) — wire fewer soundtrack producers, or raise WIRED_CLIP_SEATS in the melite-audio-nodes pack`);
1014
+ }
1015
+ wiredSeats[`wired_audio_${nextSeat}`] = g.node('MeliteAudioResample', {
1016
+ audio: clip.src,
1017
+ sample_rate: FILM_AUDIO_RATE,
1018
+ }).out(0);
1019
+ return { wired: nextSeat, start_sec: pl.filmSec, dur_sec: pl.durSec, class: pl.cls, ...inField };
1020
+ });
866
1021
  const mix = g.node('MeliteFilmAudioMix', {
867
1022
  videos: windowPrefixes.join(','),
868
1023
  after,
869
1024
  // the manifest rendered verbatim: every placement's source,
870
1025
  // film seat, duration, and class — doc order kept (the node's
871
- // two loops read the same order the retired tail did)
872
- clips_json: JSON.stringify(manifest.placements.map((pl) => {
873
- const clip = clips[pl.clip];
874
- return { src: clip.src, start_sec: pl.filmSec, dur_sec: pl.durSec, class: pl.cls };
875
- })),
1026
+ // two loops read the same order the retired tail did); spelled
1027
+ // rows ride wired: k + the wired_audio_k seats above
1028
+ clips_json: JSON.stringify(mixRows),
1029
+ ...wiredSeats,
876
1030
  duck_spans: manifest.duckSpanString,
877
1031
  music_duck_spans: manifest.musicDuckSpanString,
878
1032
  duck_db: manifest.duckDb,
@@ -892,11 +1046,18 @@ function renderH3Film(p, g, facts, model, runId) {
892
1046
  // clips-free arm rides — container mux only (CreateVideo +
893
1047
  // SaveVideo h264/mp4 on the decoded window files), never the
894
1048
  // mix. The mix rides it: audio carries the node's output.
895
- return concatSavedFilms(g, windowPrefixes, after, `${runId}/h3_t4_film`, {
1049
+
1050
+ // press): a spelled output_name rides the DELIVERED film's
1051
+ // prefix leaf (`h3_t4_film_<slug>`) so the artifact is BORN
1052
+ // named — absent, the machinery prefix is byte-frozen. Both
1053
+ // film arms carry it; the windows and the audio stem stay
1054
+ // machinery (chain intermediates, and the film-lead finders
1055
+ // key on the film stem alone).
1056
+ return concatSavedFilms(g, windowPrefixes, after, `${runId}/h3_t4_film${outputNameTailOf(p)}`, {
896
1057
  audio: meter.out(0),
897
1058
  });
898
1059
  }
899
- return concatSavedFilms(g, windowPrefixes, after, `${runId}/h3_t4_film`);
1060
+ return concatSavedFilms(g, windowPrefixes, after, `${runId}/h3_t4_film${outputNameTailOf(p)}`);
900
1061
  }
901
1062
  /** THE FUN-CONTROLNET CHAIN (002 H2/H4 + 007 L7): family-owned,
902
1063
  * the LTX_lora_loader precedent — the node pair is the family's
@@ -987,7 +1148,7 @@ function renderH3Window(p, g, facts, model, runId) {
987
1148
  // walk-bypass callers get the declared default, never an invented
988
1149
  // one).
989
1150
  const fpsClock = typeof p.fps === 'number' && p.fps > 0 ? p.fps : DOC_FPS_DEFAULT;
990
- p.fps_seconds = Math.round((p.length / fpsClock) * 1000) / 1000;
1151
+ p.fps_seconds = bookSeconds(p.length, fpsClock);
991
1152
  const isT4r = family === 't4r';
992
1153
  const isChain = family === 't4_chain';
993
1154
 
@@ -997,14 +1158,20 @@ function renderH3Window(p, g, facts, model, runId) {
997
1158
  // refinement inside the 3D-conv kernel, lock_audio true — z_v
998
1159
  // through the LBH kernel, z_a preserved).
999
1160
  const upscaleOn = p.second_pass_enabled === true && p.upscale_route === "latent_2x";
1000
- // THE HEAD HALVES UNDER THE ARM (both r2v seats below): pass 1
1001
- // composes the quarter grid the kernel was distilled on
1002
- // (1344×768 → 672×384); the handoff doubles the latent in-band
1003
- // before the second pass. Route off = stated geometry (ARM 41's
1004
- // byte-stable plain pass — the halving never touches the legacy
1005
- // graph).
1006
- const headW = upscaleOn ? p.width / 2 : p.width;
1007
- const headH = upscaleOn ? p.height / 2 : p.height;
1161
+ // THE HEAD STAYS STATED UNDER THE ARM (both r2v seats below): the
1162
+
1163
+ // 84x48 | Pixels 1344x768`) convicted the old half-grid stamp —
1164
+ // pass 1 composed 1344×768 → 672×384 and the handoff's 2.0×
1165
+ // restored base tier, so `latent_2x` rendered the plain pass. The
1166
+ // kernel carries full-base grids (run-e49908ddf224: the same
1167
+ // handoff at 2.0× landed 2688×1536; the chain's h3_2x clips feed
1168
+ // it 82×46 latents daily), so the route now rides the STATED
1169
+ // geometry and doubles ON TOP of it — armed, the render lands at
1170
+ // 2× the stated grid. Route off = the same stated geometry (ARM
1171
+ // 41's byte-stable plain pass — the arm touches nothing but the
1172
+ // handoff's mount).
1173
+ const headW = p.width;
1174
+ const headH = p.height;
1008
1175
 
1009
1176
  // is the fresh-card admission, not a fallback crime. The window
1010
1177
  // shape's text face is p.prompt (declared required=True, "optional
@@ -1045,7 +1212,17 @@ function renderH3Window(p, g, facts, model, runId) {
1045
1212
  min_seq_len: p.sla_min_seq_len,
1046
1213
  dense_last_steps: p.sla_dense_last_steps,
1047
1214
  protect_audio: p.sla_protect_audio,
1048
- enabled: true,
1215
+ // THE NODE-SEAT BYPASS (the velocity arena's slaoff arm, caught
1216
+
1217
+ // pass the model straight through, for a like-for-like speed
1218
+ // baseline without rewiring" — is the DESIGNED bypass, and this
1219
+ // seat hardcoded true while sla_enabled:false only flipped the
1220
+ // DOWNSTREAM ComfySwitchNode. Both switch arms ride the SLA-
1221
+ // patched model (the dense arm wraps it), so the flag never
1222
+ // actually bypassed sparsity. The doc's flag now rides the
1223
+ // node's own input: false passes the model through UNPATCHED on
1224
+ // every arm; true (the declared default) is unchanged.
1225
+ enabled: p.sla_enabled,
1049
1226
  dense_steps: p.sla_dense_steps,
1050
1227
  dense_backend: p.sla_dense_backend,
1051
1228
  disable_fp16_accum: p.sla_disable_fp16_accum,
@@ -1260,8 +1437,9 @@ function renderH3Window(p, g, facts, model, runId) {
1260
1437
  // and NEVER builds a loader; files/URLs/estate paths keep the
1261
1438
  // Load* disk handoff (the per-stage path owns those). Before
1262
1439
  // this arm the ports validated green at the lattice and died
1263
- // at the merge — the validate-said-nothing disease.
1264
- const isSpell = (s) => s.startsWith('$');
1440
+ // at the merge — the validate-said-nothing disease. (isSpell is
1441
+ // the module-level test — one owner, shared with the film tail's
1442
+ // wired soundtrack seats.)
1265
1443
  const imageRef = (src) => isSpell(src) ? src : g.node('LoadImage', { image: src }).out();
1266
1444
  let anchorRaw;
1267
1445
  if (guideImage !== '') {
@@ -1415,31 +1593,40 @@ function renderH3Window(p, g, facts, model, runId) {
1415
1593
  // hears).
1416
1594
  const pinFps = typeof p.fps === 'number' && p.fps > 0 ? p.fps : DOC_FPS_DEFAULT;
1417
1595
  const read = (key) => (p[key] ?? null);
1596
+ // THE CONDITIONING TENSOR SEAT (the soundtrack merged-form wire,
1597
+ // session 2 — the interim conditioning door deleted): a spelled
1598
+ // stamp names a WIRED STAGE INPUT — it slices through
1599
+ // MeliteAudioTensorSlice.audio_tensor, a typed AUDIO socket the
1600
+ // merge rewrites (rewriteSpells lands the producer's link
1601
+ // there), never MeliteAudioSlice.audio — a Combo FILE seat
1602
+ // validated against the live input-dir listing, where a link
1603
+ // would die at submit (the F17 class). A path stamp keeps the
1604
+ // file node byte-identical (the estate boundary, the S7 arm
1605
+ // freezes it).
1606
+ const sliceSeat = (src, startSeconds, durationSeconds) => isSpell(src)
1607
+ ? g.node('MeliteAudioTensorSlice', {
1608
+ audio_tensor: src,
1609
+ start_seconds: startSeconds,
1610
+ duration_seconds: durationSeconds,
1611
+ }).out(0)
1612
+ : g.node('MeliteAudioSlice', {
1613
+ audio: src,
1614
+ start_seconds: startSeconds,
1615
+ duration_seconds: durationSeconds,
1616
+ }).out(0);
1418
1617
  const stamp = read('dialogue_slice');
1419
1618
  if (stamp !== null) {
1420
- dialogueAudio = g.node('MeliteAudioSlice', {
1421
- audio: stamp.src,
1422
- start_seconds: stamp.slice_start_seconds,
1423
- duration_seconds: stamp.slice_duration_seconds,
1424
- }).out(0);
1619
+ dialogueAudio = sliceSeat(stamp.src, stamp.slice_start_seconds, stamp.slice_duration_seconds);
1425
1620
  dialogueFrameIdx = Math.round(stamp.delay_seconds * pinFps);
1426
1621
  }
1427
1622
  const sfxStamp = read('sfx_slice');
1428
1623
  if (sfxStamp !== null) {
1429
- sfxAudio = g.node('MeliteAudioSlice', {
1430
- audio: sfxStamp.src,
1431
- start_seconds: sfxStamp.slice_start_seconds,
1432
- duration_seconds: sfxStamp.slice_duration_seconds,
1433
- }).out(0);
1624
+ sfxAudio = sliceSeat(sfxStamp.src, sfxStamp.slice_start_seconds, sfxStamp.slice_duration_seconds);
1434
1625
  sfxFrameIdx = Math.round(sfxStamp.delay_seconds * pinFps);
1435
1626
  }
1436
1627
  const musicStamp = read('music_slice');
1437
1628
  if (musicStamp !== null) {
1438
- musicAudio = g.node('MeliteAudioSlice', {
1439
- audio: musicStamp.src,
1440
- start_seconds: musicStamp.slice_start_seconds,
1441
- duration_seconds: musicStamp.slice_duration_seconds,
1442
- }).out(0);
1629
+ musicAudio = sliceSeat(musicStamp.src, musicStamp.slice_start_seconds, musicStamp.slice_duration_seconds);
1443
1630
  musicFrameIdx = Math.round(musicStamp.delay_seconds * pinFps);
1444
1631
  }
1445
1632
  }
@@ -1653,156 +1840,11 @@ function renderH3Window(p, g, facts, model, runId) {
1653
1840
  // resolve through wireList; the cap check below guards the UNION.
1654
1841
  // (The refs-lane REPLACE canon governs the image/video/audio BUS
1655
1842
  // lanes only — REFMOD IS NOT REFERENCE.)
1656
- const bagMods = wireList(rb0.mods);
1657
- const declaredMods = wireList(p.ref_mods);
1658
- const seenMods = new Set(declaredMods.map((m) => m.trim()));
1659
- const refModsAll = [...declaredMods, ...bagMods.filter((m) => !seenMods.has(m.trim()))];
1660
- if (refModsAll.length > 0) {
1661
- if (refModsAll.length > REF_CAPS.refmods) {
1662
- throw new Error(`[h3-timeline] ref_mods exceeds the loader's ${String(REF_CAPS.refmods)} slots (saw ${String(refModsAll.length)})`);
1663
- }
1664
- const modStems = [];
1665
- const modImages = [];
1666
- const modVideos = [];
1667
- const modAudios = [];
1668
- for (const src of refModsAll) {
1669
- // Trim, then query-strip (the estate precedent:
1670
- // timelineContract's _kindOfFile splits '?' first), then split
1671
- // on BOTH separators — a backslash-prefixed or padded entry
1672
- // would otherwise pass the suffix check with junk baked into
1673
- // the stem and die server-side as a combo miss. The two `as`
1674
- // casts are total (split always yields a non-empty array), so
1675
- // this adds no defensive branches to the coverage face.
1676
- // A data: URL rides VERBATIM past the split (the studio's
1677
- // upload chips commit data URLs; the run's staging walk
1678
- // uploads them into the engine's input tree and rewrites the
1679
- // load nodes' slots — the family reads off the MIME here).
1680
- const raw = src.trim();
1681
- const query = raw.split('?')[0];
1682
- const base = query.split(/[\\/]/).pop();
1683
- if (raw.startsWith('data:')) {
1684
- const mime = /^data:([^;,]+)[;,]/.exec(raw)?.[1] ?? '';
1685
- if (mime.startsWith('image/'))
1686
- modImages.push(raw);
1687
- else if (mime.startsWith('video/'))
1688
- modVideos.push(raw);
1689
- else if (mime.startsWith('audio/'))
1690
- modAudios.push(raw);
1691
- else {
1692
- throw new Error(`[h3-timeline] ref_mods entries are ANY media (image/video/audio — the system bakes the pack) or pre-baked .safetensors stems under models/refmods/ (saw '${src.slice(0, 60)}')`);
1693
- }
1694
- continue;
1695
- }
1696
- if (base.endsWith('.safetensors')) {
1697
- modStems.push(base.slice(0, -'.safetensors'.length));
1698
- continue;
1699
- }
1700
- // ANY media kind boards (mediaKindOf — the contracts SSOT):
1701
- // image → the creator's refs_image.ref_image_N, video →
1702
- // refs_video.ref_video_N via the component split, audio → the
1703
- // audio extractor. Anything
1704
- // the estate does not recognize as media refuses HERE, loud,
1705
- // instead of dying server-side (the I2V census-alignment law).
1706
- const kind = mediaKindOf(base);
1707
- if (kind === 'image')
1708
- modImages.push(query);
1709
- else if (kind === 'video')
1710
- modVideos.push(query);
1711
- else if (kind === 'audio')
1712
- modAudios.push(query);
1713
- else {
1714
- throw new Error(`[h3-timeline] ref_mods entries are ANY media (image/video/audio — the system bakes the pack) or pre-baked .safetensors stems under models/refmods/ (saw '${src}')`);
1715
- }
1716
- }
1717
- // The chain's law: each mods source appends through its own
1718
- // Apply (Apply passes conditioning through, one mods input), in
1719
- // fixed order — pre-baked stems, the baked visual pack, then
1720
- // each baked audio pack.
1721
- const applyMods = (mods) => {
1722
- cond = g.node('MiniMaxH3RefModApply', {
1723
- conditioning: cond, mods, override: false, retention: 1,
1724
- curve_direction: 'constant', scramble_seed: -1,
1725
- curve_shape: 'linear', curve_value: 1,
1726
- }).out(0);
1727
- };
1728
- if (modStems.length > 0) {
1729
- const loaderInputs = { show_info: false };
1730
- for (let i = 0; i < REF_CAPS.refmods; i++) {
1731
- const stem = modStems[i];
1732
- loaderInputs[`mod_${i + 1}`] = stem === undefined ? '(none)' : stem;
1733
- loaderInputs[`strength_${i + 1}`] = 1;
1734
- loaderInputs[`copies_${i + 1}`] = 1;
1735
- }
1736
- applyMods(g.node('MiniMaxH3RefModsLoader', loaderInputs).out(0));
1737
- }
1738
- if (modImages.length > 0 || modVideos.length > 0) {
1739
- // One creator node stacks every visual ref of the seat into a
1740
- // single video-kind mod (the node's own grammar: stills into
1741
- // the refs_image autogrow container's grown slots, frame
1742
- // batches into refs_video's — DOTTED container.slot addressing,
1743
- // the r2v ref_images.ref_image_0 receipt; a BARE ref_image_1
1744
- // key is an undeclared input and phase 1 refuses it, the
1745
-
1746
- // ref's basename, sanitized node-side — a data: upload chip
1747
- // has no basename, so a data-only seat names the generic
1748
- // 'mod'. save rides the node default (true) so the baked pack
1749
- // lands in the loader's dropdown for later reuse.
1750
- const firstVisual = (modImages[0] ?? modVideos[0]);
1751
- const nameBase = firstVisual.startsWith('data:') ? 'mod' : firstVisual.split(/[\\/]/).pop()?.replace(/\.[^.]+$/, '') ?? 'mod';
1752
- // THE STATED BAKE (study §5/§7.2; value-arms ARMs 13/14): the
1753
- // fidelity dials are DECLARED params (schema.ts, the refmod
1754
- // group) and ride the node verbatim. Before this, pool and
1755
- // identity were SILENT engine defaults (nothing named them)
1756
- // and mode/save were pinned constants — the dials did not
1757
- // exist on this lane. The fallbacks are the declared defaults
1758
- // verbatim — one owner, the schema.
1759
- const bakeMode = typeof p.refmod_mode === 'string' ? p.refmod_mode : 'Compressed Reference';
1760
- const bakePool = typeof p.refmod_pool === 'number' && Number.isFinite(p.refmod_pool) ? p.refmod_pool : 16;
1761
- const bakeIdentity = typeof p.refmod_identity === 'number' && Number.isFinite(p.refmod_identity) ? p.refmod_identity : 500;
1762
- const extractInputs = {
1763
- name: nameBase,
1764
- mode: bakeMode, concept_type: 'generic',
1765
- save: p.refmod_save !== false,
1766
- pool_h: bakePool, pool_w: bakePool, identity: bakeIdentity,
1767
-
1768
- // (MiniMax-H3 VAE loader) or a standard VAE' — the engine
1769
- // refuses the extract at run time without one; both inputs
1770
- // are schema-optional, so no phase-1 judge can catch it).
1771
- // The family's own optimized H3 VAE rides (the int8-convrot
1772
- // video VAE, the same handle the film lane loads); no
1773
- // MINIMAX_H3_AV_ENCODER loader node exists in this engine's
1774
- // /object_info, so the standard-VAE input is THE wire.
1775
- vae: vaeVideo,
1776
- };
1777
- modImages.forEach((img, i) => {
1778
- extractInputs[`refs_image.ref_image_${i}`] = g.node('LoadImage', { image: img, upload: 'image' }).out(0);
1779
- });
1780
- modVideos.forEach((vid, i) => {
1781
- extractInputs[`refs_video.ref_video_${i}`] = g.node('GetVideoComponents', {
1782
- video: g.node('LoadVideo', { file: vid }).out(),
1783
- }).out(0);
1784
- });
1785
- applyMods(g.node('MiniMaxH3RefModExtract', extractInputs).out(0));
1786
- }
1787
- for (const src of modAudios) {
1788
- // Audio mods are their own extractor (AUDIO in, one mod out);
1789
- // one node per entry, voice-grade defaults, saved for reuse
1790
- // (a data: upload chip names the generic 'audio_mod').
1791
- // budget_policy + concept_type are REQUIRED bare combos in the
1792
- // engine's /object_info — no declared default, so no primed
1793
- // builder autofills them (the B7 wall refuses at compose) — the
1794
- // graph states the pack's own signature defaults
1795
- // (vendor/ComfyUI-MiniMaxH3Mod/nodes.py:2143: budget_policy
1796
- // 'error', concept_type 'voice').
1797
- applyMods(g.node('MiniMaxH3RefModAudioExtract', {
1798
- audio: g.node('LoadAudio', { audio: src }).out(),
1799
- audio_vae: vaeAudio,
1800
- name: src.startsWith('data:') ? 'audio_mod' : src.split(/[\\/]/).pop()?.replace(/\.[^.]+$/, '') ?? 'audio_mod',
1801
- budget_policy: 'error', concept_type: 'voice',
1802
- save: true,
1803
- }).out(0));
1804
- }
1805
- }
1843
+ // THE REFMOD BAKE now lives in refmodBake.ts (queue 13 P0-1:
1844
+ // one law, one home, two doors — the film path and the masked
1845
+ // edit chain mount the identical bake; see that module for the
1846
+ // merge law and the any-media law this seat obeys).
1847
+ cond = mountRefModBake(g, { p, bagMods: wireList(rb0.mods), cond, vaeVideo, vaeAudio });
1806
1848
  // ── sampler stack ──────────────────────────────────────────────────
1807
1849
  // card knob first (seed), renderer alias second.
1808
1850
  const noise = g.node('RandomNoise', { noise_seed: (p.noise_seed ?? p.seed) }).out();
@@ -1815,7 +1857,12 @@ function renderH3Window(p, g, facts, model, runId) {
1815
1857
  const ersde = g.node('SamplerER_SDE', {
1816
1858
  solver_type: 'ODE', max_stage: 3, eta: 0.0, s_noise: 1.0,
1817
1859
  }).out();
1818
- // template carries switch=false as a LITERAL, not a bool node
1860
+ // The ER_SDE wrap is THIS ESTATE's spelling — no official h3
1861
+ // workflow template composes SamplerER_SDE (verified across
1862
+
1863
+ // to a PrimitiveBoolean node, never a literal. The literal
1864
+ // false pins the pick to KSamplerSelect — the false side of
1865
+ // the templates' own sampler switch (their default posture).
1819
1866
  sampler = g.node('ComfySwitchNode', { switch: false, on_true: ersde, on_false: samplerSel }).out();
1820
1867
  }
1821
1868
  // THE FUN-CONTROLNET SEAT (007 L7): one insertion past the sigma
@@ -1828,12 +1875,14 @@ function renderH3Window(p, g, facts, model, runId) {
1828
1875
  // and every row fact (schedule capability, strength ceiling, the
1829
1876
  // clip/mask channels) arrived stamped by the service resolution.
1830
1877
 
1831
- // just ahead of it: the CrossView LoRA on the post-shift model —
1832
- // the official order (distill lora → shift → attention → the
1833
- // CrossView LoRA LAST) so the camera-trained adapters win, with
1834
- // any file-based picks refining on top. The hoisted reshootChain
1835
- // (the window head) is the one build — the film loop's stamped
1836
- // handles or the single-window's own.
1878
+ // comfy-reshoot reference app — reshoot.ts's pinned revision, NOT
1879
+ // a workflow template; no template carries a CrossView leg)
1880
+ // mounts just ahead of it: the CrossView LoRA on the post-shift
1881
+ // model — that app's order (distill lora → shift → attention →
1882
+ // the CrossView LoRA LAST) so the camera-trained adapters win,
1883
+ // with any file-based picks refining on top. The hoisted
1884
+ // reshootChain (the window head) is the one build — the film
1885
+ // loop's stamped handles or the single-window's own.
1837
1886
  if (reshootChain !== undefined)
1838
1887
  sigmaModel = applyH3ReshootModel(g, sigmaModel, p);
1839
1888
  sigmaModel = applyH3FunControlNets(g, sigmaModel, vaeVideo, fireControlNets(model, p));
@@ -1875,12 +1924,31 @@ function renderH3Window(p, g, facts, model, runId) {
1875
1924
  /* v8 ignore next 1 -- the film loop stamps __overlap on every window k≥2 before the render (the seam block mounts only when it did) */
1876
1925
  const overlap = p.__overlap ?? 0;
1877
1926
  if (prev !== undefined && overlap > 0) {
1927
+ // THE KEYFRAME CARRY (the third carry mode): the continuation
1928
+ // below chains the latent AND the prior window's decoded
1929
+ // FINAL FRAME is pinned as this window's first-frame guide —
1930
+ // extend.ts's own last-frame idiom (ImageFromBatch at the
1931
+ // clamp index, length 1), mounted through the image-pin
1932
+ // grammar (AddGuide at frame_idx 0, the keyframe lane's own
1933
+ // node) BEFORE the continuation wraps the conditioning: the
1934
+ // hard image anchor rides inside the drift-controlled seam.
1935
+ // The window derived t4r for the pin (the loop's variant
1936
+ // line), so the guide chain exists on this arm.
1937
+ if (p.__seam_keyframe === true) {
1938
+ const priorLast = g.node('ImageFromBatch', {
1939
+ image: prev.vdec, batch_index: LAST_FRAME_BATCH_INDEX, length: 1,
1940
+ }).out(0);
1941
+ cond = g.node('MiniMaxH3AddGuide', {
1942
+ positive: cond, latent: targetLatent,
1943
+ frame_idx: 0, vae: vaeVideo, image: priorLast,
1944
+ }).out(0);
1945
+ }
1878
1946
  const cont = g.node('MiniMaxH3FiniteLatentContinuation', {
1879
1947
  positive: cond, target_latent: targetLatent,
1880
1948
  iteration, overlap_frames: overlap,
1881
1949
  continue_audio_latent: true,
1882
1950
  model: sigmaModel, sigmas: sched,
1883
- previous_latent: prev.latOut,
1951
+ previous_latent: prev.seamLatent,
1884
1952
  });
1885
1953
  cond = cont.out(0);
1886
1954
  targetLatent = cont.out(1);
@@ -1931,7 +1999,7 @@ function renderH3Window(p, g, facts, model, runId) {
1931
1999
  // — pass A full, pass B closes — unchanged); with no counting row
1932
2000
  // the primary stack already IS the un-distilled base.
1933
2001
  // the bag's own truth: absent p.loras = the default
1934
- // H3_DEFAULT_LORA_ID row (h3_lightx2v_turbo) rides via
2002
+ // H3_DEFAULT_LORA_ID row (h3_silver_dareties) rides via
1935
2003
  // loraStackDefault — a counting distill; a stated bag
1936
2004
  // rides a counting row iff the marriage sees one.
1937
2005
  const distillRides = Array.isArray(p.loras) ? marriedBagKnob(p, 'steps') !== null : true;
@@ -2018,7 +2086,18 @@ function renderH3Window(p, g, facts, model, runId) {
2018
2086
  let vadecRaw;
2019
2087
  // `delivered` fills at the save branches (both families save)
2020
2088
  let delivered = null;
2021
- const rawHandles = { latOut, vdec, vadec, filmImages: latOut, filmAudio: latOut };
2089
+
2090
+ // rate fix, no downsample at the seam. The window-2 crash is
2091
+ // structurally certain") ── the continuation above consumes the
2092
+ // previous window's latent at the BASE rate. When the latent-upscale
2093
+ // handoff mounts, latOut is its 2× spatial output — handing that to
2094
+ // window k+1's MiniMaxH3FiniteLatentContinuation composes a
2095
+ // shape-refused graph before any engine run. The seam handle names
2096
+ // pass 1's own sampled latent on the upscale arm; everywhere else it
2097
+ // stays latOut, so the refine rider's chained texture still crosses
2098
+ // the seam at the same rate (the chained-texture law, intact).
2099
+ const seamLatent = upscaleOn ? sampled.out(0) : latOut;
2100
+ const rawHandles = { seamLatent, latOut, vdec, vadec, filmImages: latOut, filmAudio: latOut };
2022
2101
  if (isChain || isT4r) {
2023
2102
  const prev = p.__prev;
2024
2103
  /* v8 ignore next 1 -- the film loop stamps __overlap on every window k≥2 before the render (the block mounts only when it did) */
@@ -2036,13 +2115,153 @@ function renderH3Window(p, g, facts, model, runId) {
2036
2115
  vadec = fin.out(2);
2037
2116
  }
2038
2117
  }
2118
+
2119
+ // the operator's gate-11 burn: "THE COMPOSE GATE REFUSED THIS DOC …
2120
+ // the lane refuses it (unsanctioned inject keys)") ── the
2121
+ // image-space finish (sharpen → interp → SeedVR2 → sharpen) used
2122
+ // to live INSIDE the non-reference arm's else block, so a t4r
2123
+ // window (any guide/reference seat) silently composed NO post node
2124
+ // while the doc's keys rode the panel: every door then REFUSED the
2125
+ // doc to hide the omission. The chain is family-agnostic pixel
2126
+ // work on the decoded window — it mounts here for every arm; the
2127
+ // gates are the DOC's own (second_pass_enabled + each limb's
2128
+ // switch), never the lane's. With every gate off this block builds
2129
+ // ZERO nodes and postImage === vdec, so the frozen t4r graphs stay
2130
+ // byte-identical.
2131
+ // sharpen leaves: only the EXPLICITLY-set ones patch the tuned
2132
+ // bag (absent leaves keep SHARPEN_DEFAULTS above). The old
2133
+ // card knob (sharpen_strength) rides the leaf loop like
2134
+ // the renderer alias does.
2135
+ const methodBag = { ...SHARPEN_DEFAULTS };
2136
+ const sharpenLeaves = [
2137
+ ['sharpen_method', 'method'], ['sharpen_strength', 'strength'],
2138
+ ['sharpen_radius', 'radius'], ['sharpen_threshold', 'threshold'],
2139
+ ['sharpen_iterations', 'iterations'],
2140
+ ];
2141
+ for (const [src, dst] of sharpenLeaves) {
2142
+ const val = p[src];
2143
+ if (val !== null && val !== undefined)
2144
+ methodBag[dst] = val;
2145
+ }
2146
+
2147
+ // upstream moved sharpen LAST: interp → VSR → sharpen → CreateVideo
2148
+ // (V7/ours sharpened FIRST — before the upscaler could soften the
2149
+ // detail away). Sharpen rcas 0.3 after upscale "looks natural"
2150
+ // (his V9 notes). The switches stay ours; the ORDER is his.
2151
+ //
2152
+
2153
+ // VIDEO UI LIE… IT WILL ALWAYS UPSCALE") ── each limb mounts
2154
+ // IFF its own doc gate is on; an off limb composes NO node at
2155
+ // all. The pre-burn shape built every limb unconditionally and
2156
+ // routed a lazy ComfySwitchNode around each — the serialized
2157
+ // graph (a face the operator and the engine queue both read)
2158
+ // carried SeedVR2 + interp + sharpen on EVERY doc, switches or
2159
+ // not: the graph itself said "always upscale". The TS build now
2160
+ // picks the wire at compose time — the same mount-behind-the-
2161
+ // gate law the latent-upscale handoff and the refine rider
2162
+ // already ride — and the V9 ORDER is preserved by threading one
2163
+ // `postImage` handle down the chain.
2164
+ let postImage = vdec;
2165
+ const interpOn = secondPassOn && p.interpolate_enabled;
2166
+ if (interpOn) {
2167
+ const film = g.node('FrameInterpolationModelLoader', {
2168
+ model_name: p.interp_model,
2169
+ }).out();
2170
+ const interpMultVal = p.interp_multiplier;
2171
+ const interp = g.node('FrameInterpolate', {
2172
+ interp_model: film, images: postImage, multiplier: interpMultVal,
2173
+ }).out();
2174
+ postImage = interp;
2175
+ }
2176
+ const srSwOn = secondPassOn && p.sr_switch;
2177
+ if (srSwOn) {
2178
+ const srRes = p.sr_resolution;
2179
+
2180
+ // "h3 final" press that OOM'd on the operator's 24GB card:
2181
+ // "torch.OutOfMemoryError: CUDA out of memory. Tried to
2182
+
2183
+ // — the h3 stack was STILL RESIDENT when SeedVR2 loaded its
2184
+ // DiT). The upscaler is the one seat that needs the h3
2185
+ // weights GONE: nothing downstream of this image reads them.
2186
+ // A MeliteBoundary (Layer C, the F41 pass-seam primitive)
2187
+ // carries the decoded frame through while evicting the
2188
+ // models, so the eviction is output-reachable (the DAG proves
2189
+ // it waits for the h3 pass) and SeedVR2 loads into free VRAM.
2190
+ // `through` is the wildcard passthrough: the tensor rides
2191
+ // untouched, only the cache is flushed.
2192
+ const srIn = g.node('MeliteBoundary', {
2193
+ through: postImage, unload_models: true,
2194
+ }).out();
2195
+ const sr = g.node('SeedVR2VideoUpscaler', {
2196
+ image: srIn,
2197
+ dit: g.node('SeedVR2LoadDiTModel', {
2198
+ model: p.sr_model, device: 'cuda:0',
2199
+ }).out(),
2200
+ // THE DECODE'S MEMORY LAW: a 90-frame 1080p decode allocates
2201
+ // ~21.9 GiB of activations in one pass and dies on the 23.52
2202
+
2203
+ // even after the seam boundary freed the h3 stack. Tiled
2204
+ // decode is the loader's own declared lever for exactly this.
2205
+ vae: g.node('SeedVR2LoadVAEModel', {
2206
+ model: LANE_FILES.sr_vae, device: 'cuda:0', decode_tiled: true,
2207
+ }).out(),
2208
+ seed: 42, resolution: srRes,
2209
+ max_resolution: 0, batch_size: 5, uniform_batch_size: false,
2210
+ color_correction: 'lab',
2211
+ }).out();
2212
+ postImage = sr;
2213
+ }
2214
+ // sharpen LAST (V9): the upscaler softens; rcas after it restores.
2215
+ // Renderer alias second (sharpen_* leaves above build the method).
2216
+ if (secondPassOn && p.sharpen_enabled) {
2217
+ // THE V3 COMBO PROJECTION (GAPS-1/F9 cure): the installed
2218
+ // KJNodes serves ImageSharpenKJ.method as a V3 DynamicCombo —
2219
+ // the engine's expansion matches the base wire against the
2220
+ // option keys and folds ONLY the selected option's dotted
2221
+ // children into the execute dict (comfy_api _expand_schema_for_
2222
+ // dynamic + build_nested_inputs; proven against the real _io.py
2223
+ // in the GAPS-1 report). The old flat grouped dict matched no
2224
+ // option key, so the finalized schema dropped `method` outright
2225
+ // and validation failed required_input_missing — every sharpen
2226
+ // compose died there. The option key rides `method`; the
2227
+ // SELECTED option's children ride dotted wires (the F23
2228
+ // mode.scale spelling chainUpscale already rides). Values are
2229
+ // the same bag as before; only the SHAPE changed.
2230
+ const selected = methodBag.method;
2231
+ const sharpenInputs = { image: postImage, method: selected };
2232
+ for (const child of SHARPEN_OPTION_CHILDREN[selected] ?? []) {
2233
+ sharpenInputs[`method.${child}`] = methodBag[child];
2234
+ }
2235
+ const sharpened = g.node('ImageSharpenKJ', sharpenInputs).out();
2236
+ postImage = sharpened;
2237
+ }
2238
+ // THE MUX CLOCK — one owner, both arms (the V9 compensation's one
2239
+ // spelling): an interpolated window plays at base × multiplier. The
2240
+ // t4r arm's clock is the walk-first PrimitiveFloat NODE, the
2241
+ // open/chain arms' is the doc's number; the helper multiplies the
2242
+ // one it was handed. `out(0)` is the expression's FLOAT face.
2243
+ const muxFps = () => {
2244
+ if (!interpOn)
2245
+ return fpsInput;
2246
+ if (typeof fpsInput === 'number')
2247
+ return fpsInput * p.interp_multiplier;
2248
+ return g.node('ComfyMathExpression', {
2249
+ expression: `a * ${String(p.interp_multiplier)}`, 'values.a': fpsInput,
2250
+ }).out(0);
2251
+ };
2039
2252
  if (isT4r) {
2040
2253
  const created = g.node('CreateVideo', {
2041
2254
 
2042
2255
  // as every join leg — the sound VAE's 32 kHz never muxes raw, so
2043
2256
  // one press and one join emit one standard (48 kHz), equal-rate
2044
2257
  // legs paying only the stated law.
2045
- images: vdec, audio: filmJoinAudio(g, vadec), fps: fpsInput, bit_depth: FILM_BIT_DEPTH,
2258
+
2259
+
2260
+ // post limbs by branch omission — the doc's second-pass keys
2261
+ // composed NO node while every gate refused the doc that
2262
+ // stated them. The mux takes the chain's own output and its
2263
+ // compensated clock.
2264
+ images: postImage, audio: filmJoinAudio(g, vadec), fps: muxFps(), bit_depth: FILM_BIT_DEPTH,
2046
2265
  // color_space: pin autofill "sRGB"
2047
2266
  });
2048
2267
 
@@ -2060,77 +2279,9 @@ function renderH3Window(p, g, facts, model, runId) {
2060
2279
  'codec.encoding': 're-encode', 'codec.encoding.crf': 10.0,
2061
2280
  });
2062
2281
  rawHandles.savePassthrough = saved.out(0);
2063
- delivered = { images: vdec, audio: vadec };
2282
+ delivered = { images: postImage, audio: vadec };
2064
2283
  }
2065
2284
  else {
2066
- // sharpen leaves: only the EXPLICITLY-set ones patch the grouped
2067
- // dict (absent leaves keep ImageSharpenKJ's own defaults). The old
2068
- // card knob (sharpen_strength) rides the leaf loop like
2069
- // the renderer alias does.
2070
- const method = { ...SHARPEN_DEFAULTS };
2071
- const sharpenLeaves = [
2072
- ['sharpen_method', 'method'], ['sharpen_strength', 'strength'],
2073
- ['sharpen_radius', 'radius'], ['sharpen_threshold', 'threshold'],
2074
- ['sharpen_iterations', 'iterations'],
2075
- ];
2076
- for (const [src, dst] of sharpenLeaves) {
2077
- const val = p[src];
2078
- if (val !== null && val !== undefined)
2079
- method[dst] = val;
2080
- }
2081
-
2082
- // upstream moved sharpen LAST: interp → VSR → sharpen → CreateVideo
2083
- // (V7/ours sharpened FIRST — before the upscaler could soften the
2084
- // detail away). Sharpen rcas 0.3 after upscale "looks natural"
2085
- // (his V9 notes). The switches stay ours; the ORDER is his.
2086
- //
2087
-
2088
- // VIDEO UI LIE… IT WILL ALWAYS UPSCALE") ── each limb mounts
2089
- // IFF its own doc gate is on; an off limb composes NO node at
2090
- // all. The pre-burn shape built every limb unconditionally and
2091
- // routed a lazy ComfySwitchNode around each — the serialized
2092
- // graph (a face the operator and the engine queue both read)
2093
- // carried SeedVR2 + interp + sharpen on EVERY doc, switches or
2094
- // not: the graph itself said "always upscale". The TS build now
2095
- // picks the wire at compose time — the same mount-behind-the-
2096
- // gate law the latent-upscale handoff and the refine rider
2097
- // already ride — and the V9 ORDER is preserved by threading one
2098
- // `postImage` handle down the chain.
2099
- let postImage = vdec;
2100
- const interpOn = secondPassOn && p.interpolate_enabled;
2101
- if (interpOn) {
2102
- const film = g.node('FrameInterpolationModelLoader', {
2103
- model_name: p.interp_model,
2104
- }).out();
2105
- const interpMultVal = p.interp_multiplier;
2106
- const interp = g.node('FrameInterpolate', {
2107
- interp_model: film, images: postImage, multiplier: interpMultVal,
2108
- }).out();
2109
- postImage = interp;
2110
- }
2111
- const srSwOn = secondPassOn && p.sr_switch;
2112
- if (srSwOn) {
2113
- const srRes = p.sr_resolution;
2114
- const sr = g.node('SeedVR2VideoUpscaler', {
2115
- image: postImage,
2116
- dit: g.node('SeedVR2LoadDiTModel', {
2117
- model: p.sr_model, device: 'cuda:0',
2118
- }).out(),
2119
- vae: g.node('SeedVR2LoadVAEModel', {
2120
- model: LANE_FILES.sr_vae, device: 'cuda:0',
2121
- }).out(),
2122
- seed: 42, resolution: srRes,
2123
- max_resolution: 0, batch_size: 5, uniform_batch_size: false,
2124
- color_correction: 'lab',
2125
- }).out();
2126
- postImage = sr;
2127
- }
2128
- // sharpen LAST (V9): the upscaler softens; rcas after it restores.
2129
- // Renderer alias second (sharpen_* leaves above build the method).
2130
- if (secondPassOn && p.sharpen_enabled) {
2131
- const sharpened = g.node('ImageSharpenKJ', { image: postImage, method }).out();
2132
- postImage = sharpened;
2133
- }
2134
2285
 
2135
2286
  // CreateVideo.fps = base × interp multiplier (his Enhancements:
2136
2287
  // PrimitiveFloat 24 → ComfyMathExpression "a * 2" → fps). Without
@@ -2142,7 +2293,7 @@ function renderH3Window(p, g, facts, model, runId) {
2142
2293
  const created = g.node('CreateVideo', {
2143
2294
  // F25: the same join-rate door — the film standard is ONE rate
2144
2295
  // on every mux seat (t4r above, this window arm, every join).
2145
- images: postImage, audio: filmJoinAudio(g, vadec), fps: interpOn ? fpsInput * p.interp_multiplier : fpsInput, bit_depth: FILM_BIT_DEPTH,
2296
+ images: postImage, audio: filmJoinAudio(g, vadec), fps: muxFps(), bit_depth: FILM_BIT_DEPTH,
2146
2297
  // color_space: pin autofill "sRGB"
2147
2298
  });
2148
2299
  const saved = g.node('SaveVideo', {
@@ -2195,6 +2346,7 @@ const H3_SAMPLER_OPTIONS = SAMPLER_OPTIONS.filter((n) => H3_RECOMMENDED_SAMPLERS
2195
2346
 
2196
2347
  function applyKeyframeCompose(p) {
2197
2348
  const kfRows = Array.isArray(p.keyframes) ? p.keyframes : [];
2349
+ /* v8 ignore next 1 -- the sole caller (the keyframe placement gate) runs only when kfRows.length > 0, so the empty re-entry never fires; the guard stays as the function's own contract */
2198
2350
  if (kfRows.length === 0)
2199
2351
  return;
2200
2352
  const calls = Array.isArray(p.calls) ? p.calls : [];
@@ -2221,6 +2373,7 @@ function applyKeyframeCompose(p) {
2221
2373
  const f = kf.frame;
2222
2374
  const image = str(kf.image);
2223
2375
  const w = wins.find((win) => win !== null && f >= win.sf && f <= win.ef - 1);
2376
+ /* v8 ignore next 1 -- unreachable post-gate: the placement gate above refuses any frame without a covering finite window, so the find always lands; the guard stays as the loop's own contract */
2224
2377
  if (w === undefined)
2225
2378
  continue; // unreachable post-gate; the gate owns the refusal
2226
2379
  if (f === w.sf && w.rides.anchor === undefined && !isSeatStated(w, 'anchor')) {
@@ -2356,7 +2509,7 @@ export const film = {
2356
2509
  // bag's own field rows are the served truth.
2357
2510
  { name: "attention_backend", type: "enum", options: ["comfy kitchen attention", "pytorch attention"] },
2358
2511
  { name: "sr_switch", type: "boolean" },
2359
- { name: "sr_resolution", type: "number", bounds: [720, 2160] },
2512
+ { name: "sr_resolution", type: "number", bounds: [768, 2160] },
2360
2513
  { name: "sr_model", type: "enum", options: ["seedvr2_ema_3b_fp16.safetensors", "seedvr2_ema_3b_fp8_e4m3fn.safetensors"] },
2361
2514
  { name: "ref_image_size", type: "string" },
2362
2515
  { name: "shift_video", type: "number", bounds: [1, 20] },
@@ -2384,6 +2537,14 @@ export const film = {
2384
2537
  { name: "refmod_identity", type: "number", bounds: [0, 2000] },
2385
2538
  { name: "refmod_save", type: "boolean" },
2386
2539
  { name: "image_name", type: "string" },
2540
+
2541
+ // the deliverable slug the compose threads into every save
2542
+ // prefix (outputNameTailOf at the film stems). Plain string HERE
2543
+ // — the CARD schema row owns the slug law (charset + length,
2544
+ // refused loud at the walk); this row is the ADVERTISED face, so
2545
+ // the agent's film action names its own output. Absent = the
2546
+ // machinery prefix verbatim.
2547
+ { name: "output_name", type: "string" },
2387
2548
  ],
2388
2549
  facts: parseH3Facts,
2389
2550
  build({ p: docIn, facts, g, model, runId }) {