@melite/models-h3 0.1.5-pre-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.
@@ -0,0 +1,134 @@
1
+ import { h3MaskedEditPlane } from './chainEdit.js';
2
+ import { REFINE_UPSCALE_MODEL } from './refine.js';
3
+ /** The upscale entry's required seats (the reshoot idiom: an armed
4
+ * doc with an empty seat refuses loud naming the seat). */
5
+ const REQUIRED_SEATS = [
6
+ ['chain_run', 'the prior chain run whose checkpointed scenes the 2x pass resumes — the engine-side run name (its h3_chains store directory), resolved to the newest per-scene lineage at the execute door'],
7
+ ];
8
+ const num = (e, key, d) => typeof e[key] === 'number' ? e[key] : d;
9
+ const str = (e, key, d) => typeof e[key] === 'string' ? e[key] : d;
10
+ /** The arm predicate: BAG PRESENCE — the same law as the
11
+ * replace/repair/extend/refine/reshoot arms (a commission is armed
12
+ * when its bag is a NON-EMPTY ARRAY). Absent or empty bag = the
13
+ * compose never sees the chain (byte-stable graphs).
14
+ * @param p the gated compose doc
15
+ * @returns true when the upscale bag carries at least one entry */
16
+ export function upscaleArmed(p) {
17
+ const bag = p.upscale;
18
+ return Array.isArray(bag) && bag.length > 0;
19
+ }
20
+ /** The chain-upscale renderer: validates the bound entry, then
21
+ * composes the deferred 2x loop over the named prior run. The film
22
+ * path never reaches here (the card branches on a non-empty upscale
23
+ * bag, and a bag beside any other edit arm refuses loud: one door
24
+ * per doc). The emission ends in ChainAssemble at `<runId>/upscale`
25
+ * (copy_to_output — the estate's film law; the recipe's dated
26
+ * filename and no-copy posture is a browser-session spelling, not an
27
+ * estate one).
28
+ * @param entry the upscale mod's single bound entry
29
+ * @param p the walked doc params (the lora mod bag + scheduler knobs
30
+ * — the family plane this loop renders under)
31
+ * @param facts the family's lane facts (unet off the DECL row)
32
+ * @param g the run's graph builder
33
+ * @param runId the run tree's id (the assemble filename rides it) */
34
+ export function renderH3ChainUpscale(entry, p, facts, g, runId) {
35
+ for (const [seat, what] of REQUIRED_SEATS) {
36
+ const v = entry[seat];
37
+ if (typeof v !== 'string' || v.trim() === '') {
38
+ throw new Error(`h3-timeline upscale: '${seat}' names no run — ${what}; an upscale needs the prior chain run bound`);
39
+ }
40
+ }
41
+ const denoise = num(entry, 'denoise', 0.24);
42
+ if (denoise >= 1) {
43
+ throw new Error(`h3-timeline upscale: denoise ${denoise} >= 1 — a second pass is an upscale, never a re-render (the recipe's pass-2 window is 0.24; a full-noise sigma discards the learned upscaled latent — that is a reshoot, and the reshoot door exists)`);
44
+ }
45
+ const steps = num(entry, 'steps', 20);
46
+ const segmentCrf = num(entry, 'segment_crf', 18);
47
+ const prompt = str(entry, 'prompt', '');
48
+ // ── the family's own plane (the shared masked-edit seat — the
49
+ // operator's lora law; a seat NEVER hand-rolls a stack) ──
50
+ const { sigmaModel, clip, vaeVideo, vaeAudio } = h3MaskedEditPlane(g, p, facts, 6);
51
+ // ── the head (the F19 selection law: the bare run name, resolved
52
+ // to the newest per-scene lineage at the execute door) + the loop
53
+ // family's own adapter/current spine ──
54
+ const manager = g.node('MiniMaxH3ChainCheckpointManager', {
55
+ selection_json: entry['chain_run'],
56
+ });
57
+ const adapter = g.node('MiniMaxH3ChainUpscaleAdapter', {
58
+ source_manifest: manager.out(0),
59
+ profile: 'h3_2x', backend: 'h3_latent', recipe_json: '{}',
60
+ start_clip: 1, end_clip: 0, save_latent: false,
61
+ segment_crf: segmentCrf, start_mode: 'resume',
62
+ });
63
+ const cur = g.node('MiniMaxH3ChainUpscaleCurrent', {
64
+ state: adapter.out(1),
65
+ });
66
+ // ── the conditioning rebuild (the node's own defaults for its
67
+ // reference policy seats — the recipe's spellings: missing caches
68
+ // rebuild text-only, motion refs keep audio, refs stay strict).
69
+ // Blank prompt reuses the source run's own scene prompts ──
70
+ const conditioning = g.node('MiniMaxH3ChainUpscaleReferenceConditioning', {
71
+ state: cur.out(0), clip, video_vae: vaeVideo,
72
+ missing_cache: 'text_only', motion_ref_mode: 'exclude_video_keep_audio',
73
+ prompt_override: prompt,
74
+ override_ref_image_size: 'inherit', override_reference_policy: 'strict',
75
+ override_semantic_anchor_size: 'inherit',
76
+ override_semantic_anchor_mode: 'inherit',
77
+ }).out(0);
78
+ // ── the learned 2x upscale (ONE variant path: multiplier 2.0, the
79
+ // family's single weights spelling, offload after — the recipe's
80
+ // own posture, freeing VRAM for pass 2) + the conditioning sync ──
81
+ const upscaled = g.node('MinimaxH3LatentUpscaler3D', {
82
+ latent: cur.out(2),
83
+ model_name: REFINE_UPSCALE_MODEL,
84
+ // F23 — the combo's child rides its DOTTED path (see refine.ts)
85
+ mode: 'scale by multiplier', 'mode.scale': 2.0,
86
+ align: 32, keep_proportion: true,
87
+ device: 'cuda', precision: 'bf16', offload_after_upscale: true,
88
+ }).out(0);
89
+ const synced = g.node('H3ConditioningSyncFromLatents', {
90
+ original_latent: cur.out(2), upscaled_latent: upscaled,
91
+ positive: conditioning,
92
+ method: 'bilinear', motion_ref_mode: 'conditioning_policy',
93
+ }).out(0);
94
+ // ── pass 2 (the recipe's tail: Pass2Prepare over the upscaled
95
+ // latent + the source's untouched audio latent, then the sampler —
96
+ // DisableNoise because Pass2Prepare owns the noise member, the
97
+ // res_multistep select, the 'simple' schedule at the entry's
98
+ // denoise/steps) ──
99
+ const noise = g.node('RandomNoise', { noise_seed: cur.out(9) }).out(0);
100
+ const sigmas = g.node('BasicScheduler', {
101
+ model: sigmaModel, scheduler: 'simple', steps, denoise,
102
+ }).out(0);
103
+ const pass2 = g.node('MiniMaxH3ChainPass2Prepare', {
104
+ upscaled_video: upscaled, source_audio: cur.out(3),
105
+ model: sigmaModel, noise, sigmas, state: cur.out(0),
106
+ }).out(0);
107
+ const sampled = g.node('SamplerCustomAdvanced', {
108
+ noise: g.node('DisableNoise', {}).out(0),
109
+ guider: g.node('BasicGuider', { model: sigmaModel, conditioning: synced }).out(0),
110
+ sampler: g.node('KSamplerSelect', { sampler_name: 'res_multistep' }).out(0),
111
+ sigmas, latent_image: pass2,
112
+ }).out(0);
113
+ const decoded = g.node('VAEDecode', { samples: sampled, vae: vaeVideo }).out(0);
114
+ // ── the loop tail (top_level_requeue — the estate's requeue driver
115
+ // claims each owed scene and patches the ADAPTER's start_clip; the
116
+ // upscale family's LoopEnd rides the same durable h3_chain rows as
117
+ // the scene chain) + the estate's assemble law ──
118
+ const segment = g.node('MiniMaxH3ChainUpscaleSegmentSave', {
119
+ state: cur.out(0), images: decoded, upscaled_latent: sampled,
120
+ }).out(0);
121
+ const loopEnd = g.node('MiniMaxH3ChainUpscaleLoopEnd', {
122
+ flow: adapter.out(0), state: cur.out(0),
123
+ images: decoded, segment, upscaled_latent: sampled,
124
+ }).out(0);
125
+ g.node('MiniMaxH3ChainAssemble', {
126
+ manifest: loopEnd,
127
+ audio_source: 'plan', filename: `${runId}/upscale`,
128
+ audio_bitrate: 256, copy_to_output: true, output_subfolder: '',
129
+ blend_schedule: 'plan', boundary_tone_match: 'off',
130
+ color_stabilization: 'off', delete_checkpoints_after_assembly: false,
131
+ generated_audio_join: 'av_overlap',
132
+ });
133
+ }
134
+ //# sourceMappingURL=chainUpscale.js.map
@@ -0,0 +1,25 @@
1
+ import type { GraphBuilder } from '@melite/comfyui-card-kit/graph';
2
+ import type { H3Facts } from './actions.js';
3
+ export { solveWindowComposition, type WindowComposition } from './timelineContract.js';
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+ export declare const LAST_FRAME_BATCH_INDEX = 16384;
12
+ /** The extend renderer: validates the bound entry, then composes the
13
+ * fresh-continuation chain plus the join. Like the swap and repair,
14
+ * the film path never reaches here (the card branches on a non-empty
15
+ * extend bag and refuses a bag under an armed reshoot, replace, or
16
+ * repair — one door per doc), and the emission ends in the
17
+ * joined-film SaveVideo.
18
+ * @param entry the extend mod's single bound entry
19
+ * @param p the walked doc params (the lora mod bag + SLA/shift knobs
20
+ * — the family plane this extension renders under)
21
+ * @param facts the family's lane facts (unet off the DECL row)
22
+ * @param g the run's graph builder
23
+ * @param runId the run tree's id (the join prefixes ride it) */
24
+ export declare function renderH3Extend(entry: Record<string, unknown>, p: Record<string, unknown>, facts: H3Facts, g: GraphBuilder, runId: string): void;
25
+ //# sourceMappingURL=extend.d.ts.map
package/lib/extend.js ADDED
@@ -0,0 +1,221 @@
1
+ import { chainSaveBoundaries, concatSavedFilms, filmJoinAudio } from './actions.js';
2
+ import { assertGridLength, solveWindowComposition, CONTEXT_OVERLAP_FRAMES, GRID_MAX_FRAMES, } from './timelineContract.js';
3
+ export { solveWindowComposition } from './timelineContract.js';
4
+ import { loadVideo, renderMaskedEditChain } from './chainEdit.js';
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+ export const LAST_FRAME_BATCH_INDEX = 16384;
13
+ /** The extend entry's required seats (the reshoot/repair idiom: an
14
+ * armed doc with an empty seat refuses loud naming the seat). */
15
+ const REQUIRED_SEATS = [
16
+ ['source_clip', 'the clip whose seconds are extended — ONE staged leaf: the VHS loader + the core LoadVideo read it by staged name, and the timeline reads it back off the native VIDEO wire'],
17
+ ['extend_prompt', 'the continuation text — MOTION+SOUND for the appended seconds (the R2V prompt seat; agent-composed, user-confirmed)'],
18
+ ];
19
+ const num = (p, k, d) => typeof p[k] === 'number' ? p[k] : d;
20
+ const str = (p, k) => typeof p[k] === 'string' ? p[k] : '';
21
+ /** The extend renderer: validates the bound entry, then composes the
22
+ * fresh-continuation chain plus the join. Like the swap and repair,
23
+ * the film path never reaches here (the card branches on a non-empty
24
+ * extend bag and refuses a bag under an armed reshoot, replace, or
25
+ * repair — one door per doc), and the emission ends in the
26
+ * joined-film SaveVideo.
27
+ * @param entry the extend mod's single bound entry
28
+ * @param p the walked doc params (the lora mod bag + SLA/shift knobs
29
+ * — the family plane this extension renders under)
30
+ * @param facts the family's lane facts (unet off the DECL row)
31
+ * @param g the run's graph builder
32
+ * @param runId the run tree's id (the join prefixes ride it) */
33
+ export function renderH3Extend(entry, p, facts, g, runId) {
34
+ for (const [seat, what] of REQUIRED_SEATS) {
35
+ const v = entry[seat];
36
+ if (typeof v !== 'string' || v.trim() === '') {
37
+ throw new Error(`h3-timeline extend: '${seat}' names no media — ${what}; an extend needs both seats bound (source_clip, extend_prompt)`);
38
+ }
39
+ }
40
+ const seed = num(entry, 'seed', 0);
41
+ const steps = num(entry, 'steps', 6);
42
+ const overlapFrames = num(entry, 'overlap_frames', 39);
43
+ const resolution = str(entry, 'resolution') || '736p';
44
+ const statedFrames = Math.round(num(entry, 'extend_seconds', 56 / 24) * 24);
45
+ // THE COMPOSITION DOOR: one window keeps the landed grid law
46
+ // verbatim; beyond it the solver composes N uniform windows and
47
+ // refuses every non-exact landing by name. The solver ALWAYS
48
+ // carries the policy's 39f overlap (every law-home pins 39 —
49
+ // SKILL.md, the registry row, CONTEXT_OVERLAP_FRAMES, the refusal
50
+ // text); the entry knob never rides seam math. A multi-window
51
+ // extend under a knob ≠ 39 would compose exact-DELIVERY numbers
52
+ // the chain then stitches at a different carry — the exactness
53
+ // guarantee breaks silently — so it refuses loud instead (the
54
+ // dsh-docs audit's MED-1).
55
+ const composition = statedFrames <= GRID_MAX_FRAMES
56
+ ? { windows: 1, windowFrames: assertGridLength(statedFrames, 'h3-timeline extend'), deliveredFrames: statedFrames }
57
+ : solveWindowComposition(statedFrames, 'h3-timeline extend');
58
+ if (composition.windows > 1 && overlapFrames !== CONTEXT_OVERLAP_FRAMES) {
59
+ throw new Error(`h3-timeline extend: overlap_frames ${overlapFrames} — the multi-window composition law carries the policy's ${CONTEXT_OVERLAP_FRAMES}f context overlap (every law-home pins 39; the knob feeds only the single-window plan head); re-state overlap_frames 39`);
60
+ }
61
+ const clipSeconds = composition.windowFrames / 24;
62
+ // ── the staged media: the WHOLE prior clip on the VHS seat
63
+ // (force_rate 24 — the one clock) and its LAST FRAME as the
64
+ // in-graph anchor (a positive out-of-band index the engine clamps
65
+ // to the final row — see LAST_FRAME_BATCH_INDEX) ──
66
+ const [priorFrames, priorAudio] = loadVideo(g, str(entry, 'source_clip'));
67
+ const lastFrame = g.node('ImageFromBatch', {
68
+ image: priorFrames, batch_index: LAST_FRAME_BATCH_INDEX, length: 1,
69
+ }).out(0);
70
+ // ── THE SEAT'S OWN PLAN (clause 3): N continuation shots — the
71
+ // literal rules, plan_json_input stays UNWIRED (the plan node's
72
+ // source slicing is the swap's semantics, never a continuation's;
73
+ // the cure for the re-slice bug the unification's survey found) ──
74
+ const shots = Array.from({ length: composition.windows }, (_k, i) => ({
75
+ id: `extend-${i + 1}`, prompt: str(entry, 'extend_prompt'),
76
+ }));
77
+ const planJson = JSON.stringify({ shots });
78
+ const { trimmed, assemblePath, planShape } = renderMaskedEditChain(g, {
79
+ p, facts,
80
+ clipSeconds,
81
+ overlapFrames,
82
+ resolution, seed, steps,
83
+ roles: '',
84
+ sourceClip: str(entry, 'source_clip'),
85
+ windowStart: 0,
86
+ picture1: lastFrame,
87
+ srcFrames: priorFrames,
88
+ srcAudio: priorAudio,
89
+ planJson,
90
+ planFromSource: false,
91
+ denoise: 1,
92
+ // THE LATENT-CARRY TERMINAL (clause 4): N ≥ 2 windows assemble
93
+ // IN-CHAIN — ChainAssemble owns the seams under the policy's
94
+ // overlap (fresh content's soundtrack assembles from the
95
+ // checkpointed H3 sound); one window joins by file directly.
96
+ assemble: composition.windows >= 2
97
+ ? { audioSource: 'generated', filename: `${runId}/extend_chain` }
98
+ : null,
99
+ body: ({ cur, clip, vaeVideo, vaeAudio, mutedChainAudio, sliceAudio }) => {
100
+ // The everywhere-generate mask: an all-white SolidMask sized
101
+ // to the chain's own geometry (nothing held — extended
102
+ // seconds are new content). `.out(0)`: a mask SEAT takes an
103
+ // output LINK `[key, slot]` — a bare node handle serializes
104
+ // `{"id": ...}` and the engine dies at reshape (the F10 burn,
105
+
106
+ const whiteMask = g.node('SolidMask', {
107
+ value: 1, width: cur.out(8), height: cur.out(9),
108
+ }).out(0);
109
+ // ── the fresh-continuation body: the anchor rides BOTH
110
+ // reference seats — the last frame as the pixel anchor
111
+ // (ref_image_0) and the whole clip as the motion identity
112
+ // (ref_video_0), the swap/repair spine's own seats ──
113
+ const r2v = g.node('MiniMaxH3ReferenceToVideo', {
114
+ prompt: str(entry, 'extend_prompt'),
115
+ width: cur.out(8), height: cur.out(9), length: cur.out(6),
116
+ ref_image_size: 'match',
117
+ clip, vae: vaeVideo, audio_vae: vaeAudio,
118
+ 'ref_images.ref_image_0': lastFrame,
119
+ 'ref_videos.ref_video_0': priorFrames,
120
+ 'ref_video_audios.ref_video_audio_0': mutedChainAudio,
121
+ });
122
+ const slice = g.node('H3SourceSlice', {
123
+ source_fps: 24, crop: 'center',
124
+ state: cur.out(0), latent: r2v.out(1),
125
+ audio_vae: vaeAudio, source_frames: priorFrames, source_audio: sliceAudio,
126
+ });
127
+ const edit = g.node('MiniMaxH3FantasticVideoEditLatent', {
128
+ grow: 0, keep_audio: false, megapixels: 0,
129
+ vae: vaeVideo, images: slice.out(0), mask: whiteMask,
130
+ audio_vae: vaeAudio, audio: slice.out(1),
131
+ }).out(0);
132
+ const target = g.node('MiniMaxH3ContexMaskedTarget', {
133
+ mask_meaning: 'white = generate',
134
+ audio_mode: 'generate all audio',
135
+ mask_conversion: 'H3 exact (causal/token max)',
136
+ target_latent: edit, mask: whiteMask,
137
+ }).out(0);
138
+
139
+ // ref_image ride above is a SOFT prior — the model is free to
140
+ // introduce new content in the appended clip's FIRST frame, and
141
+ // the poncho burn did exactly that (a second figure at full
142
+ // size on the first extended frame: a hard pop, no entry). Pin
143
+ // the source's LAST frame at frame_idx 0 through the same
144
+ // H3-native guide lane the reshoot pins its warp with
145
+ // (MiniMaxH3AddGuide, one frame → guide_frames 1): the first
146
+ // appended frame is then FORCED to be the clip's last frame,
147
+ // so anything new must develop from it frame by frame instead
148
+ // of appearing whole.
149
+ const guided = g.node('MiniMaxH3AddGuide', {
150
+ positive: r2v.out(0),
151
+ vae: vaeVideo,
152
+ latent: target,
153
+ image: lastFrame,
154
+ frame_idx: 0,
155
+ }).out(0);
156
+ return { conditioning: guided, targetLatent: target };
157
+ },
158
+ });
159
+
160
+ // run-89976b95026b-8f22c399): the raw prior joins the chain's
161
+ // output at the CHAIN PLAN'S OWN SHOT GEOMETRY — the plan node
162
+ // derives the canvas from the SOURCE'S OWN FRAMES (its aspect)
163
+ // under the stated tier, so an extension whose tier short edge
164
+ // differs from the prior's own (the burn: a 1344×768 source under
165
+ // the default 736p tier rendered the extension at 1280×736 and the
166
+ // engine's concat refused `Expected size 768 but got size 736`)
167
+ // aligns HERE instead of crashing mid-render. The canvas is read
168
+ // off the plan's own width/height outputs — never assumed from a
169
+ // declared width/height row — and nearest-exact keeps the align
170
+ // pixel-verbatim when the plan canvas already equals the source's
171
+ // own (the extension never rewrites history). ──
172
+ const alignedPrior = g.node('ImageScale', {
173
+ image: priorFrames,
174
+ width: planShape.width,
175
+ height: planShape.height,
176
+ upscale_method: 'nearest-exact',
177
+ crop: 'disabled',
178
+ }).out(0);
179
+ // ── THE JOIN (the file-join primitive; the initial raw boundary
180
+ // is the exception the latent carry cannot cross — clause 4) ──
181
+ if (assemblePath !== null) {
182
+ // MULTI-WINDOW: the prior re-muxes at x0 (the join grammar needs
183
+ // an output-dir file; the prior's frames + its own soundtrack
184
+ // ride verbatim — the extension never rewrites history); the
185
+ // ASSEMBLED extension rides the concat's append seat — an exact
186
+ // saved-file path (ChainAssemble's video_path output, wired:
187
+ // the DAG itself proves the assembly completed before the join).
188
+ const priorCreated = g.node('CreateVideo', {
189
+ images: alignedPrior, audio: filmJoinAudio(g, priorAudio), fps: 24, bit_depth: 8,
190
+ });
191
+ const priorSaved = g.node('SaveVideo', {
192
+ video: priorCreated.out(), filename_prefix: `${runId}/x0`,
193
+ format: 'mp4', codec: 'h264',
194
+ }).out();
195
+ const after = chainSaveBoundaries(g, [priorSaved]);
196
+ concatSavedFilms(g, [`${runId}/x0`], after, `${runId}/extend_film`, {
197
+ append: assemblePath,
198
+ });
199
+ return;
200
+ }
201
+ // SINGLE-WINDOW (the landed shape): both parts save at prefixes,
202
+ // the boundary chain orders them, the concat joins, the container
203
+ // delivers <runId>/extend_film.
204
+ const newCreated = g.node('CreateVideo', {
205
+ images: trimmed.out(0), audio: filmJoinAudio(g, trimmed.out(1)), fps: 24, bit_depth: 8,
206
+ });
207
+ const newSaved = g.node('SaveVideo', {
208
+ video: newCreated.out(), filename_prefix: `${runId}/x1`,
209
+ format: 'mp4', codec: 'h264',
210
+ }).out();
211
+ const priorCreated = g.node('CreateVideo', {
212
+ images: alignedPrior, audio: filmJoinAudio(g, priorAudio), fps: 24, bit_depth: 8,
213
+ });
214
+ const priorSaved = g.node('SaveVideo', {
215
+ video: priorCreated.out(), filename_prefix: `${runId}/x0`,
216
+ format: 'mp4', codec: 'h264',
217
+ }).out();
218
+ const after = chainSaveBoundaries(g, [newSaved, priorSaved]);
219
+ concatSavedFilms(g, [`${runId}/x0`, `${runId}/x1`], after, `${runId}/extend_film`);
220
+ }
221
+ //# sourceMappingURL=extend.js.map
package/lib/filmMix.d.ts CHANGED
@@ -3,7 +3,7 @@ export type FilmMixClipClass = 'dialogue' | 'sfx' | 'music';
3
3
  /** One clip row — the card's audio_clips shape, post-parse. */
4
4
  export interface FilmMixClip {
5
5
  readonly src: string;
6
- /** doc-anchored start (frames @24fps — the stamp, studio lanes, and tool face all speak doc). */
6
+ /** doc-anchored start (frames at the DOC CLOCK — the stamp, studio lanes, and tool face all speak doc). */
7
7
  readonly start: number;
8
8
  /** duration (frames; 0 = overlay-only, unsized). */
9
9
  readonly dur: number;
@@ -12,8 +12,10 @@ export interface FilmMixClip {
12
12
  }
13
13
  /** Parse raw audio_clips rows — the card's one law for what a clip
14
14
  * IS: a src without a numeric start_frame refuses loud (never a
15
- * silent misplacement); a row without src is junk and skips; the
16
- * class auto law (text → dialogue, textless → music) rides here. */
15
+ * silent misplacement); a row that states anything without src
16
+ * refuses loud (never a silent phantom row); only the contentless
17
+ * row (no stated key at all) is junk and skips; the class auto law
18
+ * (text → dialogue, textless → music) rides here. */
17
19
  export declare function parseFilmMixClips(rows: readonly unknown[]): FilmMixClip[];
18
20
  /** One window's doc span + seam for the owner map. */
19
21
  export interface FilmMixSpan {
@@ -59,10 +61,16 @@ export interface FilmMixManifest {
59
61
  export interface FilmMixInput {
60
62
  readonly spans: FilmMixSpan[];
61
63
  readonly clips: FilmMixClip[];
62
- /** per-window rendered durations (seconds) — stanza length/24 at
63
- * compose time, probed durations disk-side. THE ground truth the
64
- * owner map accumulates (never re-derived from spans). */
64
+ /** per-window rendered durations (seconds) — stanza length at the
65
+ * doc clock at compose time, probed durations disk-side. THE
66
+ * ground truth the owner map accumulates (never re-derived from
67
+ * spans). */
65
68
  readonly windowSecs: number[];
69
+ /** the DOC CLOCK for the owner map's frames→seconds joins (the
70
+ * overlap trims). Unstated = DOC_FPS_DEFAULT — one clock with
71
+ * stanzaSecs and the stamps (journey audit AUDIO-2: this seat
72
+ * hardcoded /24 while the container played p.fps). */
73
+ readonly fps?: number;
66
74
  readonly duckDb?: number;
67
75
  }
68
76
  /** The duck span string — "start:end" at ms precision, ';'-joined. */
@@ -70,11 +78,19 @@ export declare function formatDuckSpan(start: number, end: number): string;
70
78
  /** Per-window stanza seconds — THE compose-time windowSecs
71
79
  * (computeFilmMix's ground truth): the render grid's own promise,
72
80
  * the deliverer's contract — SaveVideo hands back exactly stanza
73
- * frames at 24fps. No probe, no disk: the clock is pure at
74
- * compose. RAW fractions (frames/24, unrounded): the manifest sums
75
- * these into film starts, and rounding a SUM of rounded parts
76
- * compounds drift (the 3-window seat 7.416 ≠ 7.417 proof) — only
77
- * the final seats/spans round (ms, computeFilmMix's own law). */
78
- export declare function stanzaSecs(spans: readonly FilmMixSpan[]): number[];
81
+ * frames at the DOC CLOCK (fps, unstated = DOC_FPS_DEFAULT; the
82
+ * three-clock cure, journey audit AUDIO-2: this divisor hardcoded
83
+ * /24 while the container played p.fps — a 16fps film's manifest
84
+ * overbooked every window by 1.5x). No probe, no disk: the clock
85
+ * is pure at compose. RAW fractions (frames/fps, unrounded): the
86
+ * manifest sums these into film starts, and rounding a SUM of
87
+ * rounded parts compounds drift (the 3-window seat 7.416 ≠ 7.417
88
+ * proof) — only the final seats/spans round (ms,
89
+ * computeFilmMix's own law).
90
+ *
91
+ * @param spans the film windows, doc frames
92
+ * @param fps the DOC CLOCK (unstated docs pass DOC_FPS_DEFAULT —
93
+ * never a foreign default; the walk fills the same value) */
94
+ export declare function stanzaSecs(spans: readonly FilmMixSpan[], fps?: number): number[];
79
95
  export declare function computeFilmMix(input: FilmMixInput): FilmMixManifest;
80
96
  //# sourceMappingURL=filmMix.d.ts.map
package/lib/filmMix.js CHANGED
@@ -16,12 +16,14 @@
16
16
  //
17
17
  // The two wrongs in the card's history (the +22f carry original,
18
18
  // the start/24 first correction) stay dead in one place.
19
- import { spanOverlap, spanStanzaFrames } from "./timelineContract.js";
20
- export { spanOverlap, spanStanzaFrames } from "./timelineContract.js";
19
+ import { DOC_FPS_DEFAULT, spanOverlap, spanStanzaFrames } from './timelineContract.js';
20
+ export { spanOverlap, spanStanzaFrames } from './timelineContract.js';
21
21
  /** Parse raw audio_clips rows — the card's one law for what a clip
22
22
  * IS: a src without a numeric start_frame refuses loud (never a
23
- * silent misplacement); a row without src is junk and skips; the
24
- * class auto law (text → dialogue, textless → music) rides here. */
23
+ * silent misplacement); a row that states anything without src
24
+ * refuses loud (never a silent phantom row); only the contentless
25
+ * row (no stated key at all) is junk and skips; the class auto law
26
+ * (text → dialogue, textless → music) rides here. */
25
27
  export function parseFilmMixClips(rows) {
26
28
  const clips = [];
27
29
  // THE ROW-LEVEL NUMERIC RESTORE (attempt-035's wire family, the
@@ -49,6 +51,19 @@ export function parseFilmMixClips(rows) {
49
51
  if (positioned) {
50
52
  throw new Error('audio_clips: a positioned clip row has no src — the film mix cannot place a source-less row');
51
53
  }
54
+ // THE SOURCE-LESS ROW LAW (F3-06, R-P3-16): the old whitelist
55
+ // refused only six "positioning" keys and let every OTHER
56
+ // stated key take the silent `continue` — {gain: 0.5} beside a
57
+ // lawful film COMPOSED as a phantom no-op (the run completed,
58
+ // the row performed nothing, nothing said so). A row that
59
+ // states ANYTHING and carries no src places nothing and mixes
60
+ // nothing: refuse it in its own voice. The blank law stays the
61
+ // only tolerance — a row with NO stated key is still skippable
62
+ // authoring junk.
63
+ const stated = Object.keys(row).some((k) => row[k] !== undefined);
64
+ if (stated) {
65
+ throw new Error('audio_clips: a clip row has no src — the film mix cannot mix a source-less row; state src or drop the row');
66
+ }
52
67
  continue;
53
68
  }
54
69
  if (typeof row.start_frame !== 'number' || !Number.isFinite(row.start_frame)) {
@@ -75,36 +90,49 @@ export function formatDuckSpan(start, end) {
75
90
  /** Per-window stanza seconds — THE compose-time windowSecs
76
91
  * (computeFilmMix's ground truth): the render grid's own promise,
77
92
  * the deliverer's contract — SaveVideo hands back exactly stanza
78
- * frames at 24fps. No probe, no disk: the clock is pure at
79
- * compose. RAW fractions (frames/24, unrounded): the manifest sums
80
- * these into film starts, and rounding a SUM of rounded parts
81
- * compounds drift (the 3-window seat 7.416 ≠ 7.417 proof) — only
82
- * the final seats/spans round (ms, computeFilmMix's own law). */
83
- export function stanzaSecs(spans) {
93
+ * frames at the DOC CLOCK (fps, unstated = DOC_FPS_DEFAULT; the
94
+ * three-clock cure, journey audit AUDIO-2: this divisor hardcoded
95
+ * /24 while the container played p.fps — a 16fps film's manifest
96
+ * overbooked every window by 1.5x). No probe, no disk: the clock
97
+ * is pure at compose. RAW fractions (frames/fps, unrounded): the
98
+ * manifest sums these into film starts, and rounding a SUM of
99
+ * rounded parts compounds drift (the 3-window seat 7.416 ≠ 7.417
100
+ * proof) — only the final seats/spans round (ms,
101
+ * computeFilmMix's own law).
102
+ *
103
+ * @param spans the film windows, doc frames
104
+ * @param fps the DOC CLOCK (unstated docs pass DOC_FPS_DEFAULT —
105
+ * never a foreign default; the walk fills the same value) */
106
+ export function stanzaSecs(spans, fps = DOC_FPS_DEFAULT) {
84
107
  // INDEX-AWARE CARRY (the render's chainLike law, stated here so
85
108
  // the clock and the stanza can never disagree): window 1 renders
86
109
  // fresh; k≥2 carries spanOverlap — the same 22 the finalize
87
110
  // trims off the saved clip. The stanza covers carry + span, the
88
111
  // contribution to the film is stanza − carry, so the clock's
89
112
  // window seats land where the saved frames actually are.
90
- return spans.map((s, i) => spanStanzaFrames(s, i > 0 ? spanOverlap(s) : 0) / 24);
113
+ return spans.map((s, i) => spanStanzaFrames(s, i > 0 ? spanOverlap(s) : 0) / fps);
91
114
  }
92
115
  export function computeFilmMix(input) {
93
116
  const { spans, clips, windowSecs } = input;
117
+ // ONE CLOCK (journey audit AUDIO-2): the owner map's frames→seconds
118
+ // joins ride the doc clock the windowSecs were booked at — the
119
+ // overlap trims and the stanza durations must speak the same fps or
120
+ // the film seats drift window by window.
121
+ const fps = input.fps ?? DOC_FPS_DEFAULT;
94
122
  if (windowSecs.length !== spans.length) {
95
123
  throw new Error(`film mix: ${windowSecs.length} window duration(s) for ${spans.length} span(s) — the owner map needs one duration per window (never a guess)`);
96
124
  }
97
125
  const overlaps = spans.map(spanOverlap);
98
126
  // THE OWNER MAP (the fixed point — see module header): the film
99
127
  // seat of doc frame f owned by window w is
100
- // w.filmStartSec + (f − w.docStart)/24, NO carry term (the trim
128
+ // w.filmStartSec + (f − w.docStart)/fps, NO carry term (the trim
101
129
  // already lives inside filmStartSec — each extend join trims the
102
130
  // overlap off the film). Owning window: the LAST whose docStart ≤ f.
103
131
  const filmStarts = [];
104
132
  let elapsed = 0;
105
133
  for (let i = 0; i < spans.length; i++) {
106
134
  filmStarts.push(elapsed);
107
- elapsed += windowSecs[i] - (i > 0 ? overlaps[i] : 0) / 24;
135
+ elapsed += windowSecs[i] - (i > 0 ? overlaps[i] : 0) / fps;
108
136
  }
109
137
  const filmSec = round3(elapsed);
110
138
  // CONDITIONED clips (the stamp law's overlay half): every window
@@ -135,19 +163,22 @@ export function computeFilmMix(input) {
135
163
  conditioned.add(ci);
136
164
  }
137
165
  });
138
- // PLACEMENTS: doc frame → film seat through the owner map.
166
+ // PLACEMENTS: doc frame → film seat through the owner map — the
167
+ // SAME doc clock the windows spoke (AUDIO-2's placements half: the
168
+ // /24 literal here outlived the window cure and drifted every clip
169
+ // seat against its own fps-cut window).
139
170
  const placements = clips.map((clip, ci) => {
140
171
  let owner = 0;
141
172
  for (let w = 0; w < spans.length; w++) {
142
173
  if (clip.start >= spans[w].start)
143
174
  owner = w;
144
175
  }
145
- const filmSeat = Math.max(0, filmStarts[owner] + (clip.start - spans[owner].start) / 24);
176
+ const filmSeat = Math.max(0, filmStarts[owner] + (clip.start - spans[owner].start) / fps);
146
177
  return {
147
178
  clip: ci,
148
179
  cls: clip.cls,
149
180
  filmSec: round3(filmSeat),
150
- durSec: clip.dur > 0 ? round3(clip.dur / 24) : 0,
181
+ durSec: clip.dur > 0 ? round3(clip.dur / fps) : 0,
151
182
  };
152
183
  });
153
184
  // THE DUCK MATRIX (D-M-E): the film's generated audio yields
package/lib/finalize.js CHANGED
@@ -17,9 +17,14 @@ export const H3_T4_STRIP = {
17
17
  'attention_mode', 'blocks_to_swap', 'cache_model', 'offload_device',
18
18
  'swap_io_components'
19
19
  ],
20
+ // decode_tiled is NOT stripped: the SR decode's memory law states
21
+ // it (a 90-frame 1080p decode OOM'd the estate card in one pass),
22
+ // and a strip entry would delete the law on the t4 lane — the very
23
+ // lane the final press derives. The sizes/overlap stay stripped:
24
+ // the node's own declared defaults own them.
20
25
  SeedVR2LoadVAEModel: [
21
26
  'cache_model', 'decode_tile_overlap', 'decode_tile_size',
22
- 'decode_tiled', 'encode_tile_overlap', 'encode_tile_size',
27
+ 'encode_tile_overlap', 'encode_tile_size',
23
28
  'encode_tiled', 'offload_device', 'tile_debug'
24
29
  ],
25
30
  SeedVR2VideoUpscaler: [
package/lib/index.d.ts CHANGED
@@ -3,6 +3,18 @@ import type { ModelDecl } from '@melite/comfyui-card-kit/model-contract';
3
3
  export declare const DECL: ModelDecl;
4
4
  export declare const family: Plugin;
5
5
  export { finalizeH3, H3_T4_STRIP } from "./finalize.js";
6
+ export { renderH3Swap } from "./swap.js";
7
+ export { renderH3Repair } from "./repair.js";
8
+ export { renderH3Extend, LAST_FRAME_BATCH_INDEX } from "./extend.js";
9
+ export { refineArmed, renderH3Refine, renderH3RefineBag, renderH3RefineCarry, renderH3RefineWindow, renderH3RefineWindows, refineWindowCount, refineWindowStarts, tokenExactCarry, nextTokenExact, lawfulCarryStart, REFINE_UPSCALE_MODEL, REFINE_2X_OOM_FRAMES, REFINE_DEFAULT_CLIP_SECONDS, REFINE_DEFAULT_OVERLAP_FRAMES } from "./refine.js";
10
+ export { refinePlaneSchema, REFINE_PLANE_KEYS } from "./schema.js";
11
+ export { MAX_COMPOSED_WINDOWS, SEAM_OVERLAP_FRAMES } from "./timelineContract.js";
12
+ export type { RefineWindowSeat } from "./refine.js";
13
+ export { H3_DEFAULT_LORA_ID, h3DefaultLoraEntry } from "./actions.js";
14
+ export { upscaleArmed, renderH3ChainUpscale } from "./chainUpscale.js";
15
+ export { reshootArmed } from "./reshoot.js";
16
+ export { RESOLUTION_SHORT_EDGE, planTierShape, admitCrossRegimeJoin, } from "./chainEdit.js";
6
17
  export { assertOverlayGated } from "./actions.js";
18
+ export { serveWindowSpec, type WindowSpecProjection } from "./windowSpec.js";
7
19
  export { family as default };
8
20
  //# sourceMappingURL=index.d.ts.map