@melite/models-h3 0.2.0-alpha → 0.2.2-alpha

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,24 @@
1
1
  import { fireControlNets } from '@melite/comfyui-card-kit/guard';
2
2
  import { saveAudio } from '@melite/comfyui-card-kit';
3
3
  import { mediaKindOf } from '@melite/contracts/mediaKinds';
4
- import { assertKeyframeRowShape, FAMILIES, paramSchema, wireList, H3_RECOMMENDED_SAMPLERS } from './schema.js';
4
+ import { assertKeyframeRowShape, FAMILIES, paramSchema, wireList, H3_RECOMMENDED_SAMPLERS, REFINE_DENOISE_DEFAULT } from './schema.js';
5
5
  import { H3_LORA_ROWS } from '@melite/models-h3/mods/loras';
6
6
  import { SAMPLER_OPTIONS, SCHEDULER_OPTIONS } from '@melite/comfyui-card-kit/vocab';
7
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';
8
+ import { DOC_FPS_DEFAULT, GRID_REMAINDER, GRID_STEP_FRAMES, IMAGE_BUS_SLOTS, REF_CAPS, assertGridLength, assertSpanGrid, bookSeconds, imageReferenceCap, isGridLength, isMediaRef, spanStanzaFrames, transitionOverlap } from './timelineContract.js';
9
9
  import { applyH3ReshootCond, applyH3ReshootModel, buildH3Reshoot, reshootArmed, reshootPrompt, } from './reshoot.js';
10
10
 
11
11
 
12
12
 
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
13
+ // default lora to the silveroxides merge"; SILVEROXIDES IS THE
14
+ // MERGE, LIGHTX2V IS NOT). THE ROW IS `h3_silver_dareties` —
15
+ // silveroxides' OFFICIAL silver_official_releases DARE-TIES merge
16
+ // (label "Silveroxides DARE-TIES Merge", strength 0.8, designed
17
+
18
+ // experimental/ LightX2V-turbo × dareties file (h3_lightx2v_turbo)
19
+ // as "the merge" — the F34b class: a merge row the catalog never
20
+ // held; that row stays pick-only under its honest experimental
21
+ // label. The row is resolved from the
20
22
  // family lora CATALOG (mods/loras.ts — the one owner of every lora
21
23
  // filename and default strength; the value was restated as a
22
24
  // literal here, which is how a catalog edit would have silently
@@ -25,7 +27,8 @@ import { applyH3ReshootCond, applyH3ReshootModel, buildH3Reshoot, reshootArmed,
25
27
  // mode flags. A missing catalog row refuses at load — the default
26
28
  // would have no source.
27
29
 
28
- export const H3_DEFAULT_LORA_ID = 'h3_lightx2v_turbo';
30
+
31
+ export const H3_DEFAULT_LORA_ID = 'h3_silver_dareties';
29
32
  /** The absent-bag default as a RESOLVED ROW — the same catalog row the
30
33
  * compose default builds, exposed so the card can serve it as the
31
34
  * ghost chip: the face then shows the adapter the film will actually
@@ -182,7 +185,7 @@ function resolveRefineSeat(p) {
182
185
  // the voice is the rider's (ARM 4f judges it at the family plane),
183
186
  // borrowed verbatim by the arm.
184
187
  function resolveStage2Denoise(p) {
185
- const denoise = p.refine_denoise ?? 0.35;
188
+ const denoise = p.refine_denoise ?? REFINE_DENOISE_DEFAULT;
186
189
  if (!(denoise >= 0.05 && denoise <= 1)) {
187
190
  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`);
188
191
  }
@@ -204,10 +207,25 @@ const mathStepsGold = (fps) => `max(${GRID_REMAINDER}, round(a * ${fps})) + (${G
204
207
  // switch flipped. Orphan + stub prompt = the marker law kept, the
205
208
  // hazard structurally dead.
206
209
  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).
210
+ // ImageSharpenKJ's tuned defaults (the rcas operating point the
211
+ // operator's V9 notes bless — strength 0.3 "looks natural" after the
212
+ // upscaler; radius/threshold/iterations ride for the non-rcas
213
+ // methods. These are OURS, not the pack's served defaults).
210
214
  const SHARPEN_DEFAULTS = { method: 'rcas', strength: 0.3, radius: 1.0, threshold: 0.05, iterations: 10 };
215
+ // The served V3 DynamicCombo's per-option child seats, off the pack's
216
+ // own declaration (ComfyUI-KJNodes nodes/sharpen_nodes.py
217
+ // define_schema: io.DynamicCombo.Option(key=...) inputs). The
218
+ // composer emits ONLY the selected option's children on dotted wires;
219
+ // the engine folds unexpanded seats silently (never an error), so a
220
+ // non-selected seat would ride dead bytes. The U2 wall diffs this map
221
+ // against the pack declaration — a pack-side child change reds there,
222
+ // never here first.
223
+ const SHARPEN_OPTION_CHILDREN = {
224
+ rcas: ['strength'],
225
+ adaptive_usm: ['strength', 'radius', 'threshold'],
226
+ high_pass: ['strength', 'radius'],
227
+ deconvolution: ['strength', 'radius', 'iterations'],
228
+ };
211
229
 
212
230
 
213
231
 
@@ -344,6 +362,22 @@ export function concatSavedFilms(g, prefixes, after, out, opts = {}) {
344
362
  * (the node's context_frames arm). prev_sec scales the carry:
345
363
  * picture snapped to the node's legal context lengths (5/22/39/56
346
364
  * frames — only whole latent steps), audio at 24 frames/second. */
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+ const isSpell = (s) => s.startsWith('$');
374
+ /** THE WIRED SOUNDTRACK SEAT COUNT — mirrors the pack's own
375
+ * WIRED_CLIP_SEATS (vendor melite-audio-nodes film_mix.py): the mix
376
+ * node declares wired_audio_1..4 optional AUDIO seats, and the
377
+ * compose refuses a spelled clip beyond them loud. Raise BOTH
378
+ * together (the refusal names the pack constant as the second
379
+ * cure). */
380
+ const WIRED_CLIP_SEATS = 4;
347
381
  function renderH3Film(p, g, facts, model, runId) {
348
382
  // (the compose dispatch guarantees calls is a non-empty array here)
349
383
  const calls = p.calls;
@@ -465,6 +499,58 @@ function renderH3Film(p, g, facts, model, runId) {
465
499
  // fallback (a row's unstated count read from the family table by
466
500
  // filename) is the same math on every face.
467
501
  const loraStepsApplied = marriedBagKnob(p, 'steps');
502
+
503
+ // MeliteConcatVideos refuses members at mixed fps LOUD at execute
504
+ // — AFTER every window's GPU is paid and every member file is
505
+ // saved (a split doc composes validate-green and dies with the
506
+ // film rendered: window1_CreateVideo fps 48 against window2's 24,
507
+ // the concat naming both rates). The interp decision is the DOC's
508
+ // voice: the stanza merge ({...p, ...knobs} below) folds per-call
509
+ // pins into the params renderH3Window reads, so a call pinning
510
+ // interpolate_enabled or interp_multiplier against the film — or
511
+ // smuggling second_pass_enabled past the knob vocabulary — renders
512
+ // its member at a foreign clock and the join dies there. This
513
+ // sweep judges the RESULT (each window's computed clock against
514
+ // the film's, with the composer's own reads: strict master,
515
+ // truthy switch, raw multiplier), never the key list — zero nodes
516
+ // built, the first split window refusing with its pin state, the
517
+ // film's clock, and the cure (move the pin to the film level;
518
+ // per-shot interp is unstatable because the join cannot restamp
519
+ // one member silently). Agreement — or silence — rides the film's
520
+ // clock untouched; interp_model stays a per-shot choice (the
521
+ // model never touches the clock). The single-window face needs no
522
+ // seat (no join, no clock to split); an extend-time append file at
523
+ // a foreign rate stays the vendor's own loud refusal (both rates
524
+ // named — the correct seat for a file the film never rendered).
525
+ const filmInterpOn = p.second_pass_enabled === true && Boolean(p.interpolate_enabled);
526
+ const filmInterpMult = p.interp_multiplier;
527
+ for (let i = 0; i < calls.length; i += 1) {
528
+ const call = calls[i];
529
+ const knobs = (call.knobs ?? {});
530
+ const merged = { ...p, ...knobs };
531
+ const winOn = merged.second_pass_enabled === true && Boolean(merged.interpolate_enabled);
532
+ if (winOn !== filmInterpOn) {
533
+ // (the pin voice reads key PRESENCE, never undefined-
534
+ // comparison: an explicit null/undefined pin still overrides
535
+ // the merge — {...p, ...{k: undefined}}.k is undefined — so
536
+ // the composer renders it falsy while a !== undefined filter
537
+ // would report "no pin stated". The no-silent-repair law
538
+ // refuses explicit nulls, never fills them.)
539
+ const isObj = typeof knobs === 'object' && knobs !== null;
540
+ const named = ['interpolate_enabled', 'second_pass_enabled']
541
+ .filter((key) => isObj && key in knobs)
542
+ .map((key) => `knobs.${key} = ${typeof knobs[key] === 'undefined' ? 'undefined' : JSON.stringify(knobs[key])}`)
543
+ .join(', ');
544
+ const stated = named !== '' ? named : `knobs = ${JSON.stringify(knobs).slice(0, 80)}`;
545
+ 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`);
546
+ }
547
+ if (filmInterpOn && winOn) {
548
+ const winMult = merged.interp_multiplier;
549
+ if (winMult !== filmInterpMult) {
550
+ 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`);
551
+ }
552
+ }
553
+ }
468
554
  calls.forEach((call, i) => {
469
555
  const k = i + 1;
470
556
  // THE OPENER ANCHOR (cure 8's film arm — session 384a13cd's bread
@@ -863,16 +949,52 @@ function renderH3Film(p, g, facts, model, runId) {
863
949
  // the MIXED audio wired into CreateVideo — the film mp4 carries
864
950
  // the mix, not the raw concat audio. Early return: the
865
951
  // clips-free arm below stays byte-frozen.
952
+ // THE SOUNDTRACK WIRE SEATS (GAPS-20 one-way law, face #14's
953
+
954
+ // spelled clip src names a WIRED STAGE INPUT, never a file. The
955
+ // manifest row carries `wired: k` and NO src key (src embedded
956
+ // in the JSON string is dead text to the merge), and the compose
957
+ // seats the spell on a DECLARED MeliteAudioResample at the film's
958
+ // own clock (FILM_AUDIO_RATE) and carries the HOP'S LINK into the
959
+ // pack's optional AUDIO seat wired_audio_k — rewriteSpells lands
960
+ // the producer's link on the hop's audio input, so the seat
961
+ // receives film-rate audio. THE FILM-CLOCK HOP (F-B cure,
962
+
963
+ // refuses a wired seat at a foreign rate LOUD (film_mix.py
964
+ // seat_source — "a wired producer rides the film's own clock …
965
+ // never silently resampled") and a 24 kHz producer arrives
966
+ // exactly foreign; the resample is a visible node the merged
967
+ // graph carries — the declared hop is the opposite of the silent
968
+ // coercion the law bans. A path row keeps the staged-file
969
+ // handoff byte-identical (the estate boundary — lawful, S3
970
+ // freezes it). Seat overflow refuses loud, naming the row and
971
+ // both cures — never a silent drop.
972
+ const wiredSeats = {};
973
+ let nextSeat = 0;
974
+ const mixRows = manifest.placements.map((pl) => {
975
+ const clip = clips[pl.clip];
976
+ if (!isSpell(clip.src)) {
977
+ return { src: clip.src, start_sec: pl.filmSec, dur_sec: pl.durSec, class: pl.cls };
978
+ }
979
+ nextSeat += 1;
980
+ if (nextSeat > WIRED_CLIP_SEATS) {
981
+ 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`);
982
+ }
983
+ wiredSeats[`wired_audio_${nextSeat}`] = g.node('MeliteAudioResample', {
984
+ audio: clip.src,
985
+ sample_rate: FILM_AUDIO_RATE,
986
+ }).out(0);
987
+ return { wired: nextSeat, start_sec: pl.filmSec, dur_sec: pl.durSec, class: pl.cls };
988
+ });
866
989
  const mix = g.node('MeliteFilmAudioMix', {
867
990
  videos: windowPrefixes.join(','),
868
991
  after,
869
992
  // the manifest rendered verbatim: every placement's source,
870
993
  // 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
- })),
994
+ // two loops read the same order the retired tail did); spelled
995
+ // rows ride wired: k + the wired_audio_k seats above
996
+ clips_json: JSON.stringify(mixRows),
997
+ ...wiredSeats,
876
998
  duck_spans: manifest.duckSpanString,
877
999
  music_duck_spans: manifest.musicDuckSpanString,
878
1000
  duck_db: manifest.duckDb,
@@ -987,7 +1109,7 @@ function renderH3Window(p, g, facts, model, runId) {
987
1109
  // walk-bypass callers get the declared default, never an invented
988
1110
  // one).
989
1111
  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;
1112
+ p.fps_seconds = bookSeconds(p.length, fpsClock);
991
1113
  const isT4r = family === 't4r';
992
1114
  const isChain = family === 't4_chain';
993
1115
 
@@ -997,14 +1119,20 @@ function renderH3Window(p, g, facts, model, runId) {
997
1119
  // refinement inside the 3D-conv kernel, lock_audio true — z_v
998
1120
  // through the LBH kernel, z_a preserved).
999
1121
  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;
1122
+ // THE HEAD STAYS STATED UNDER THE ARM (both r2v seats below): the
1123
+
1124
+ // 84x48 | Pixels 1344x768`) convicted the old half-grid stamp —
1125
+ // pass 1 composed 1344×768 → 672×384 and the handoff's 2.0×
1126
+ // restored base tier, so `latent_2x` rendered the plain pass. The
1127
+ // kernel carries full-base grids (run-e49908ddf224: the same
1128
+ // handoff at 2.0× landed 2688×1536; the chain's h3_2x clips feed
1129
+ // it 82×46 latents daily), so the route now rides the STATED
1130
+ // geometry and doubles ON TOP of it — armed, the render lands at
1131
+ // 2× the stated grid. Route off = the same stated geometry (ARM
1132
+ // 41's byte-stable plain pass — the arm touches nothing but the
1133
+ // handoff's mount).
1134
+ const headW = p.width;
1135
+ const headH = p.height;
1008
1136
 
1009
1137
  // is the fresh-card admission, not a fallback crime. The window
1010
1138
  // shape's text face is p.prompt (declared required=True, "optional
@@ -1260,8 +1388,9 @@ function renderH3Window(p, g, facts, model, runId) {
1260
1388
  // and NEVER builds a loader; files/URLs/estate paths keep the
1261
1389
  // Load* disk handoff (the per-stage path owns those). Before
1262
1390
  // 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('$');
1391
+ // at the merge — the validate-said-nothing disease. (isSpell is
1392
+ // the module-level test — one owner, shared with the film tail's
1393
+ // wired soundtrack seats.)
1265
1394
  const imageRef = (src) => isSpell(src) ? src : g.node('LoadImage', { image: src }).out();
1266
1395
  let anchorRaw;
1267
1396
  if (guideImage !== '') {
@@ -1415,31 +1544,40 @@ function renderH3Window(p, g, facts, model, runId) {
1415
1544
  // hears).
1416
1545
  const pinFps = typeof p.fps === 'number' && p.fps > 0 ? p.fps : DOC_FPS_DEFAULT;
1417
1546
  const read = (key) => (p[key] ?? null);
1547
+ // THE CONDITIONING TENSOR SEAT (the soundtrack merged-form wire,
1548
+ // session 2 — the interim conditioning door deleted): a spelled
1549
+ // stamp names a WIRED STAGE INPUT — it slices through
1550
+ // MeliteAudioTensorSlice.audio_tensor, a typed AUDIO socket the
1551
+ // merge rewrites (rewriteSpells lands the producer's link
1552
+ // there), never MeliteAudioSlice.audio — a Combo FILE seat
1553
+ // validated against the live input-dir listing, where a link
1554
+ // would die at submit (the F17 class). A path stamp keeps the
1555
+ // file node byte-identical (the estate boundary, the S7 arm
1556
+ // freezes it).
1557
+ const sliceSeat = (src, startSeconds, durationSeconds) => isSpell(src)
1558
+ ? g.node('MeliteAudioTensorSlice', {
1559
+ audio_tensor: src,
1560
+ start_seconds: startSeconds,
1561
+ duration_seconds: durationSeconds,
1562
+ }).out(0)
1563
+ : g.node('MeliteAudioSlice', {
1564
+ audio: src,
1565
+ start_seconds: startSeconds,
1566
+ duration_seconds: durationSeconds,
1567
+ }).out(0);
1418
1568
  const stamp = read('dialogue_slice');
1419
1569
  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);
1570
+ dialogueAudio = sliceSeat(stamp.src, stamp.slice_start_seconds, stamp.slice_duration_seconds);
1425
1571
  dialogueFrameIdx = Math.round(stamp.delay_seconds * pinFps);
1426
1572
  }
1427
1573
  const sfxStamp = read('sfx_slice');
1428
1574
  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);
1575
+ sfxAudio = sliceSeat(sfxStamp.src, sfxStamp.slice_start_seconds, sfxStamp.slice_duration_seconds);
1434
1576
  sfxFrameIdx = Math.round(sfxStamp.delay_seconds * pinFps);
1435
1577
  }
1436
1578
  const musicStamp = read('music_slice');
1437
1579
  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);
1580
+ musicAudio = sliceSeat(musicStamp.src, musicStamp.slice_start_seconds, musicStamp.slice_duration_seconds);
1443
1581
  musicFrameIdx = Math.round(musicStamp.delay_seconds * pinFps);
1444
1582
  }
1445
1583
  }
@@ -1880,7 +2018,7 @@ function renderH3Window(p, g, facts, model, runId) {
1880
2018
  iteration, overlap_frames: overlap,
1881
2019
  continue_audio_latent: true,
1882
2020
  model: sigmaModel, sigmas: sched,
1883
- previous_latent: prev.latOut,
2021
+ previous_latent: prev.seamLatent,
1884
2022
  });
1885
2023
  cond = cont.out(0);
1886
2024
  targetLatent = cont.out(1);
@@ -1931,7 +2069,7 @@ function renderH3Window(p, g, facts, model, runId) {
1931
2069
  // — pass A full, pass B closes — unchanged); with no counting row
1932
2070
  // the primary stack already IS the un-distilled base.
1933
2071
  // the bag's own truth: absent p.loras = the default
1934
- // H3_DEFAULT_LORA_ID row (h3_lightx2v_turbo) rides via
2072
+ // H3_DEFAULT_LORA_ID row (h3_silver_dareties) rides via
1935
2073
  // loraStackDefault — a counting distill; a stated bag
1936
2074
  // rides a counting row iff the marriage sees one.
1937
2075
  const distillRides = Array.isArray(p.loras) ? marriedBagKnob(p, 'steps') !== null : true;
@@ -2018,7 +2156,18 @@ function renderH3Window(p, g, facts, model, runId) {
2018
2156
  let vadecRaw;
2019
2157
  // `delivered` fills at the save branches (both families save)
2020
2158
  let delivered = null;
2021
- const rawHandles = { latOut, vdec, vadec, filmImages: latOut, filmAudio: latOut };
2159
+
2160
+ // rate fix, no downsample at the seam. The window-2 crash is
2161
+ // structurally certain") ── the continuation above consumes the
2162
+ // previous window's latent at the BASE rate. When the latent-upscale
2163
+ // handoff mounts, latOut is its 2× spatial output — handing that to
2164
+ // window k+1's MiniMaxH3FiniteLatentContinuation composes a
2165
+ // shape-refused graph before any engine run. The seam handle names
2166
+ // pass 1's own sampled latent on the upscale arm; everywhere else it
2167
+ // stays latOut, so the refine rider's chained texture still crosses
2168
+ // the seam at the same rate (the chained-texture law, intact).
2169
+ const seamLatent = upscaleOn ? sampled.out(0) : latOut;
2170
+ const rawHandles = { seamLatent, latOut, vdec, vadec, filmImages: latOut, filmAudio: latOut };
2022
2171
  if (isChain || isT4r) {
2023
2172
  const prev = p.__prev;
2024
2173
  /* 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 +2185,153 @@ function renderH3Window(p, g, facts, model, runId) {
2036
2185
  vadec = fin.out(2);
2037
2186
  }
2038
2187
  }
2188
+
2189
+ // the operator's gate-11 burn: "THE COMPOSE GATE REFUSED THIS DOC …
2190
+ // the lane refuses it (unsanctioned inject keys)") ── the
2191
+ // image-space finish (sharpen → interp → SeedVR2 → sharpen) used
2192
+ // to live INSIDE the non-reference arm's else block, so a t4r
2193
+ // window (any guide/reference seat) silently composed NO post node
2194
+ // while the doc's keys rode the panel: every door then REFUSED the
2195
+ // doc to hide the omission. The chain is family-agnostic pixel
2196
+ // work on the decoded window — it mounts here for every arm; the
2197
+ // gates are the DOC's own (second_pass_enabled + each limb's
2198
+ // switch), never the lane's. With every gate off this block builds
2199
+ // ZERO nodes and postImage === vdec, so the frozen t4r graphs stay
2200
+ // byte-identical.
2201
+ // sharpen leaves: only the EXPLICITLY-set ones patch the tuned
2202
+ // bag (absent leaves keep SHARPEN_DEFAULTS above). The old
2203
+ // card knob (sharpen_strength) rides the leaf loop like
2204
+ // the renderer alias does.
2205
+ const methodBag = { ...SHARPEN_DEFAULTS };
2206
+ const sharpenLeaves = [
2207
+ ['sharpen_method', 'method'], ['sharpen_strength', 'strength'],
2208
+ ['sharpen_radius', 'radius'], ['sharpen_threshold', 'threshold'],
2209
+ ['sharpen_iterations', 'iterations'],
2210
+ ];
2211
+ for (const [src, dst] of sharpenLeaves) {
2212
+ const val = p[src];
2213
+ if (val !== null && val !== undefined)
2214
+ methodBag[dst] = val;
2215
+ }
2216
+
2217
+ // upstream moved sharpen LAST: interp → VSR → sharpen → CreateVideo
2218
+ // (V7/ours sharpened FIRST — before the upscaler could soften the
2219
+ // detail away). Sharpen rcas 0.3 after upscale "looks natural"
2220
+ // (his V9 notes). The switches stay ours; the ORDER is his.
2221
+ //
2222
+
2223
+ // VIDEO UI LIE… IT WILL ALWAYS UPSCALE") ── each limb mounts
2224
+ // IFF its own doc gate is on; an off limb composes NO node at
2225
+ // all. The pre-burn shape built every limb unconditionally and
2226
+ // routed a lazy ComfySwitchNode around each — the serialized
2227
+ // graph (a face the operator and the engine queue both read)
2228
+ // carried SeedVR2 + interp + sharpen on EVERY doc, switches or
2229
+ // not: the graph itself said "always upscale". The TS build now
2230
+ // picks the wire at compose time — the same mount-behind-the-
2231
+ // gate law the latent-upscale handoff and the refine rider
2232
+ // already ride — and the V9 ORDER is preserved by threading one
2233
+ // `postImage` handle down the chain.
2234
+ let postImage = vdec;
2235
+ const interpOn = secondPassOn && p.interpolate_enabled;
2236
+ if (interpOn) {
2237
+ const film = g.node('FrameInterpolationModelLoader', {
2238
+ model_name: p.interp_model,
2239
+ }).out();
2240
+ const interpMultVal = p.interp_multiplier;
2241
+ const interp = g.node('FrameInterpolate', {
2242
+ interp_model: film, images: postImage, multiplier: interpMultVal,
2243
+ }).out();
2244
+ postImage = interp;
2245
+ }
2246
+ const srSwOn = secondPassOn && p.sr_switch;
2247
+ if (srSwOn) {
2248
+ const srRes = p.sr_resolution;
2249
+
2250
+ // "h3 final" press that OOM'd on the operator's 24GB card:
2251
+ // "torch.OutOfMemoryError: CUDA out of memory. Tried to
2252
+
2253
+ // — the h3 stack was STILL RESIDENT when SeedVR2 loaded its
2254
+ // DiT). The upscaler is the one seat that needs the h3
2255
+ // weights GONE: nothing downstream of this image reads them.
2256
+ // A MeliteBoundary (Layer C, the F41 pass-seam primitive)
2257
+ // carries the decoded frame through while evicting the
2258
+ // models, so the eviction is output-reachable (the DAG proves
2259
+ // it waits for the h3 pass) and SeedVR2 loads into free VRAM.
2260
+ // `through` is the wildcard passthrough: the tensor rides
2261
+ // untouched, only the cache is flushed.
2262
+ const srIn = g.node('MeliteBoundary', {
2263
+ through: postImage, unload_models: true,
2264
+ }).out();
2265
+ const sr = g.node('SeedVR2VideoUpscaler', {
2266
+ image: srIn,
2267
+ dit: g.node('SeedVR2LoadDiTModel', {
2268
+ model: p.sr_model, device: 'cuda:0',
2269
+ }).out(),
2270
+ // THE DECODE'S MEMORY LAW: a 90-frame 1080p decode allocates
2271
+ // ~21.9 GiB of activations in one pass and dies on the 23.52
2272
+
2273
+ // even after the seam boundary freed the h3 stack. Tiled
2274
+ // decode is the loader's own declared lever for exactly this.
2275
+ vae: g.node('SeedVR2LoadVAEModel', {
2276
+ model: LANE_FILES.sr_vae, device: 'cuda:0', decode_tiled: true,
2277
+ }).out(),
2278
+ seed: 42, resolution: srRes,
2279
+ max_resolution: 0, batch_size: 5, uniform_batch_size: false,
2280
+ color_correction: 'lab',
2281
+ }).out();
2282
+ postImage = sr;
2283
+ }
2284
+ // sharpen LAST (V9): the upscaler softens; rcas after it restores.
2285
+ // Renderer alias second (sharpen_* leaves above build the method).
2286
+ if (secondPassOn && p.sharpen_enabled) {
2287
+ // THE V3 COMBO PROJECTION (GAPS-1/F9 cure): the installed
2288
+ // KJNodes serves ImageSharpenKJ.method as a V3 DynamicCombo —
2289
+ // the engine's expansion matches the base wire against the
2290
+ // option keys and folds ONLY the selected option's dotted
2291
+ // children into the execute dict (comfy_api _expand_schema_for_
2292
+ // dynamic + build_nested_inputs; proven against the real _io.py
2293
+ // in the GAPS-1 report). The old flat grouped dict matched no
2294
+ // option key, so the finalized schema dropped `method` outright
2295
+ // and validation failed required_input_missing — every sharpen
2296
+ // compose died there. The option key rides `method`; the
2297
+ // SELECTED option's children ride dotted wires (the F23
2298
+ // mode.scale spelling chainUpscale already rides). Values are
2299
+ // the same bag as before; only the SHAPE changed.
2300
+ const selected = methodBag.method;
2301
+ const sharpenInputs = { image: postImage, method: selected };
2302
+ for (const child of SHARPEN_OPTION_CHILDREN[selected] ?? []) {
2303
+ sharpenInputs[`method.${child}`] = methodBag[child];
2304
+ }
2305
+ const sharpened = g.node('ImageSharpenKJ', sharpenInputs).out();
2306
+ postImage = sharpened;
2307
+ }
2308
+ // THE MUX CLOCK — one owner, both arms (the V9 compensation's one
2309
+ // spelling): an interpolated window plays at base × multiplier. The
2310
+ // t4r arm's clock is the walk-first PrimitiveFloat NODE, the
2311
+ // open/chain arms' is the doc's number; the helper multiplies the
2312
+ // one it was handed. `out(0)` is the expression's FLOAT face.
2313
+ const muxFps = () => {
2314
+ if (!interpOn)
2315
+ return fpsInput;
2316
+ if (typeof fpsInput === 'number')
2317
+ return fpsInput * p.interp_multiplier;
2318
+ return g.node('ComfyMathExpression', {
2319
+ expression: `a * ${String(p.interp_multiplier)}`, 'values.a': fpsInput,
2320
+ }).out(0);
2321
+ };
2039
2322
  if (isT4r) {
2040
2323
  const created = g.node('CreateVideo', {
2041
2324
 
2042
2325
  // as every join leg — the sound VAE's 32 kHz never muxes raw, so
2043
2326
  // one press and one join emit one standard (48 kHz), equal-rate
2044
2327
  // legs paying only the stated law.
2045
- images: vdec, audio: filmJoinAudio(g, vadec), fps: fpsInput, bit_depth: FILM_BIT_DEPTH,
2328
+
2329
+
2330
+ // post limbs by branch omission — the doc's second-pass keys
2331
+ // composed NO node while every gate refused the doc that
2332
+ // stated them. The mux takes the chain's own output and its
2333
+ // compensated clock.
2334
+ images: postImage, audio: filmJoinAudio(g, vadec), fps: muxFps(), bit_depth: FILM_BIT_DEPTH,
2046
2335
  // color_space: pin autofill "sRGB"
2047
2336
  });
2048
2337
 
@@ -2060,77 +2349,9 @@ function renderH3Window(p, g, facts, model, runId) {
2060
2349
  'codec.encoding': 're-encode', 'codec.encoding.crf': 10.0,
2061
2350
  });
2062
2351
  rawHandles.savePassthrough = saved.out(0);
2063
- delivered = { images: vdec, audio: vadec };
2352
+ delivered = { images: postImage, audio: vadec };
2064
2353
  }
2065
2354
  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
2355
 
2135
2356
  // CreateVideo.fps = base × interp multiplier (his Enhancements:
2136
2357
  // PrimitiveFloat 24 → ComfyMathExpression "a * 2" → fps). Without
@@ -2142,7 +2363,7 @@ function renderH3Window(p, g, facts, model, runId) {
2142
2363
  const created = g.node('CreateVideo', {
2143
2364
  // F25: the same join-rate door — the film standard is ONE rate
2144
2365
  // 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,
2366
+ images: postImage, audio: filmJoinAudio(g, vadec), fps: muxFps(), bit_depth: FILM_BIT_DEPTH,
2146
2367
  // color_space: pin autofill "sRGB"
2147
2368
  });
2148
2369
  const saved = g.node('SaveVideo', {
@@ -2195,6 +2416,7 @@ const H3_SAMPLER_OPTIONS = SAMPLER_OPTIONS.filter((n) => H3_RECOMMENDED_SAMPLERS
2195
2416
 
2196
2417
  function applyKeyframeCompose(p) {
2197
2418
  const kfRows = Array.isArray(p.keyframes) ? p.keyframes : [];
2419
+ /* 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
2420
  if (kfRows.length === 0)
2199
2421
  return;
2200
2422
  const calls = Array.isArray(p.calls) ? p.calls : [];
@@ -2221,6 +2443,7 @@ function applyKeyframeCompose(p) {
2221
2443
  const f = kf.frame;
2222
2444
  const image = str(kf.image);
2223
2445
  const w = wins.find((win) => win !== null && f >= win.sf && f <= win.ef - 1);
2446
+ /* 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
2447
  if (w === undefined)
2225
2448
  continue; // unreachable post-gate; the gate owns the refusal
2226
2449
  if (f === w.sf && w.rides.anchor === undefined && !isSeatStated(w, 'anchor')) {
@@ -2356,7 +2579,7 @@ export const film = {
2356
2579
  // bag's own field rows are the served truth.
2357
2580
  { name: "attention_backend", type: "enum", options: ["comfy kitchen attention", "pytorch attention"] },
2358
2581
  { name: "sr_switch", type: "boolean" },
2359
- { name: "sr_resolution", type: "number", bounds: [720, 2160] },
2582
+ { name: "sr_resolution", type: "number", bounds: [768, 2160] },
2360
2583
  { name: "sr_model", type: "enum", options: ["seedvr2_ema_3b_fp16.safetensors", "seedvr2_ema_3b_fp8_e4m3fn.safetensors"] },
2361
2584
  { name: "ref_image_size", type: "string" },
2362
2585
  { name: "shift_video", type: "number", bounds: [1, 20] },