Relax prompt validation and document project rules
This commit is contained in:
@@ -4,6 +4,13 @@
|
||||
Native MiniMax H3 audio/video continuation for ComfyUI. V1 supplies manual Join/Finish nodes; V2 integrates N chunks over the same continuation core.
|
||||
|
||||
## Non-negotiable rules
|
||||
- Follow ComfyUI Core behavior for user-facing validation. Do not add Continuum-only input restrictions or compatibility stops without documenting and obtaining approval for the exception.
|
||||
- Prompt content must never block execution. Empty, malformed, incomplete, or unknown prompt syntax falls back to a Fixed prompt and is passed through as entered. Valid Timeline/List/JSON syntax is still parsed normally.
|
||||
- Keep warnings diagnostic-only unless execution cannot continue safely. Hard stops are limited to corrupt internal contracts such as invalid latent/layout topology, incompatible Assembly Plan data, broken stored revision schema/hash, unusable required payloads, or decode formats that cannot be assembled.
|
||||
- Unknown upstream nodes, models, wrappers, or merged models must not be rejected solely because they are unknown.
|
||||
- Keep legacy `strict_compatibility` inputs loadable for old workflows, but they must not enable Continuum-only blocking behavior.
|
||||
- Before code changes, create a snapshot of the active local runtime. Preserve the current compact V3.4 UI unless the user explicitly approves a UI change.
|
||||
- Runtime tests must record the workflow, prompt, media inputs, model/LoRA/sampler/step settings, dimensions, chunk count/duration, elapsed time, and observed result. Inspect embedded workflow metadata when present.
|
||||
- Do not globally replace `PackedLayout`, `MiniMaxH3.extra_conds`, or other ComfyUI classes.
|
||||
- Keep SageAttention, Sol-Attn, and Spectrum external; integrate through public ComfyUI wrappers and H3 payload contracts.
|
||||
- Preserve the identity of `layout.position_ids` when changing MM-RoPE coordinates.
|
||||
@@ -26,3 +33,11 @@ pytest -q
|
||||
Runtime installer verification must check native PackedLayout behavior and all registered nodes.
|
||||
|
||||
GPU checks must cover Sage only, Sage+Sol, Sage+Spectrum, and Sage+Sol+Spectrum with identical prompts and seeds. V2 must also be compared against the equivalent V1 3×5-second graph.
|
||||
|
||||
## Reusable local environment
|
||||
|
||||
- Source repository: `D:\Codex\_git_push_work\ComfyUI-H3-Continuum`
|
||||
- Active ComfyUI runtime: `D:\StabilityMatrix\Data\Packages\ComfyUI_WAN\custom_nodes\ComfyUI-H3-Continuum`
|
||||
- Reuse the repository's existing pytest configuration and helper scripts instead of rediscovering paths on every task.
|
||||
- GitHub authentication for this repository is already configured. Do not request a new login or token unless an actual authentication command fails.
|
||||
- Commit and push only when the user explicitly requests publication.
|
||||
|
||||
@@ -71,7 +71,7 @@ class H3ContinuumJoin:
|
||||
"audio_continuity": (
|
||||
"BOOLEAN",
|
||||
{
|
||||
"default": True,
|
||||
"default": False,
|
||||
"tooltip": "Carry the previous native audio latent and place it on the new clip timeline.",
|
||||
},
|
||||
),
|
||||
@@ -127,9 +127,9 @@ class H3ContinuumJoin:
|
||||
previous_state=None,
|
||||
):
|
||||
issues = check_comfy_h3_runtime()
|
||||
if issues and strict_compatibility:
|
||||
raise RuntimeError("H3 runtime is incompatible: " + "; ".join(issues))
|
||||
patched_model = patch_model(model, strict=strict_compatibility, debug=debug)
|
||||
if issues and debug:
|
||||
print("H3 runtime compatibility advisory: " + "; ".join(issues))
|
||||
patched_model = patch_model(model, strict=False, debug=debug)
|
||||
video, _audio = extract_av_streams(latent)
|
||||
current_frames = pixel_frames_for_latent_t(int(video.shape[2]))
|
||||
if not is_valid_frame_count(current_frames):
|
||||
|
||||
+5
-5
@@ -210,7 +210,7 @@ class H3ContinuumSamplerV2:
|
||||
"tooltip": "Change this to derive new seeds for regenerated chunks only.",
|
||||
},
|
||||
),
|
||||
"strict_compatibility": ("BOOLEAN", {"default": True}),
|
||||
"strict_compatibility": ("BOOLEAN", {"default": False}),
|
||||
"debug": ("BOOLEAN", {"default": False}),
|
||||
"seam_correction": (
|
||||
SEAM_CORRECTION_OPTIONS,
|
||||
@@ -366,7 +366,7 @@ class H3ContinuumSamplerV2:
|
||||
diagnostics_mode=diagnostics,
|
||||
reroll_from_chunk=int(reroll_from_chunk),
|
||||
reroll_nonce=int(reroll_nonce),
|
||||
strict_compatibility=bool(strict_compatibility),
|
||||
strict_compatibility=False,
|
||||
debug=bool(debug),
|
||||
seam_correction=seam_correction,
|
||||
enable_preview=bool(show_preview),
|
||||
@@ -570,7 +570,7 @@ class H3ContinuumAdvanced:
|
||||
"INT",
|
||||
{"default": 0, "min": 0, "max": 0xFFFFFFFF, "step": 1},
|
||||
),
|
||||
"strict_compatibility": ("BOOLEAN", {"default": True}),
|
||||
"strict_compatibility": ("BOOLEAN", {"default": False}),
|
||||
"debug": ("BOOLEAN", {"default": False}),
|
||||
"show_preview": ("BOOLEAN", {"default": True}),
|
||||
},
|
||||
@@ -609,7 +609,7 @@ class H3ContinuumAdvanced:
|
||||
"diagnostics": normalize_diagnostics_mode(diagnostics),
|
||||
"reroll_from_chunk": int(reroll_from_chunk),
|
||||
"reroll_nonce": int(reroll_nonce),
|
||||
"strict_compatibility": bool(strict_compatibility),
|
||||
"strict_compatibility": False,
|
||||
"debug": bool(debug),
|
||||
"show_preview": bool(show_preview),
|
||||
"last_frame": last_frame,
|
||||
@@ -729,7 +729,7 @@ class H3ContinuumSampler:
|
||||
"diagnostics": DIAGNOSTICS_OPTIONS[0],
|
||||
"reroll_from_chunk": 0,
|
||||
"reroll_nonce": 0,
|
||||
"strict_compatibility": True,
|
||||
"strict_compatibility": False,
|
||||
"debug": False,
|
||||
"show_preview": True,
|
||||
"last_frame": None,
|
||||
|
||||
+25
-18
@@ -24,20 +24,18 @@ def _prompt_error(code,reason,*,line_number=None,source=None,suggested_fix):
|
||||
raise PromptPlanError("\n".join(lines))
|
||||
def prompt_hash(prompt:str)->str: return hashlib.sha256(prompt.encode("utf-8")).hexdigest()
|
||||
def _normalize_prompt(value:str,*,label:str)->str:
|
||||
text=str(value).strip()
|
||||
if not text: _prompt_error("H3C-P005",f"{label} is empty",suggested_fix="provide non-empty prompt text")
|
||||
return text
|
||||
return "" if value is None else str(value)
|
||||
def _parse_json_list(script:str):
|
||||
stripped=script.lstrip()
|
||||
if not stripped.startswith("["): return None
|
||||
try: value=json.loads(script)
|
||||
except json.JSONDecodeError: return None
|
||||
if not isinstance(value,list) or not all(isinstance(item,str) for item in value): raise PromptPlanError("JSON prompt list must be an array of strings")
|
||||
if not isinstance(value,list) or not all(isinstance(item,str) for item in value): return None
|
||||
return [_normalize_prompt(item,label=f"prompt {index+1}") for index,item in enumerate(value)]
|
||||
def _parse_list(script,chunks):
|
||||
values=_parse_json_list(script)
|
||||
if values is None: values=[_normalize_prompt(part,label=f"prompt {index+1}") for index,part in enumerate(_LIST_SEPARATOR.split(script)) if part.strip()]
|
||||
if not values: raise PromptPlanError("prompt list contains no prompts")
|
||||
if not values: values=[str(script)]
|
||||
notes=[]
|
||||
if len(values)<chunks: notes.append(f"repeated the last prompt for {chunks-len(values)} chunk(s)"); values.extend([values[-1]]*(chunks-len(values)))
|
||||
elif len(values)>chunks: notes.append(f"ignored {len(values)-chunks} extra prompt(s)"); values=values[:chunks]
|
||||
@@ -145,7 +143,7 @@ def detect_prompt_mode(script):
|
||||
text=str(script)
|
||||
for line in text.splitlines():
|
||||
if _TIMELINE_HEADER.match(line) or _CHUNK_HEADER.match(line): return PROMPT_MODE_TIMELINE
|
||||
if _TIMELINE_LIKE_HEADER.match(line): _prompt_error("H3C-P001","invalid timeline header",source=line.strip(),suggested_fix="use [0-5s] or [Chunk 1]")
|
||||
if _TIMELINE_LIKE_HEADER.match(line): return PROMPT_MODE_FIXED
|
||||
if _parse_json_list(text) is not None or _LIST_SEPARATOR.search(text): return PROMPT_MODE_LIST
|
||||
return PROMPT_MODE_FIXED
|
||||
def resolve_prompt_mode(mode,script):
|
||||
@@ -153,20 +151,26 @@ def resolve_prompt_mode(mode,script):
|
||||
if mode==PROMPT_FORMAT_AUTO: return detect_prompt_mode(script)
|
||||
if mode in explicit: return explicit[mode]
|
||||
if mode in (PROMPT_MODE_FIXED,PROMPT_MODE_LIST,PROMPT_MODE_TIMELINE): return mode
|
||||
raise PromptPlanError(f"unknown prompt format: {mode!r}")
|
||||
return PROMPT_MODE_FIXED
|
||||
def make_prompt_plan(*,mode,script,chunks,chunk_seconds):
|
||||
chunks=int(chunks); chunk_seconds=float(chunk_seconds)
|
||||
if not 1<=chunks<=16: raise PromptPlanError("chunks must be between 1 and 16")
|
||||
if not 4.0<=chunk_seconds<=15.0: raise PromptPlanError("chunk_seconds must be between 4.0 and 15.0 for native H3")
|
||||
resolved_mode=resolve_prompt_mode(mode,script); notes=[]
|
||||
if mode==PROMPT_FORMAT_AUTO:
|
||||
detected={PROMPT_MODE_FIXED:PROMPT_FORMAT_FIXED,PROMPT_MODE_LIST:PROMPT_FORMAT_LIST,PROMPT_MODE_TIMELINE:PROMPT_FORMAT_TIMELINE}[resolved_mode]; notes.append(f"Auto detected {detected}")
|
||||
if resolved_mode==PROMPT_MODE_FIXED: prompt=_normalize_prompt(script,label="fixed prompt"); prompts=[prompt]*chunks
|
||||
elif resolved_mode==PROMPT_MODE_LIST: prompts,parse_notes=_parse_list(script,chunks); notes.extend(parse_notes)
|
||||
elif resolved_mode==PROMPT_MODE_TIMELINE: prompts,parse_notes,diagnostics=_parse_timeline(script,chunks,chunk_seconds); notes.extend(parse_notes)
|
||||
else: raise PromptPlanError(f"unknown prompt mode: {resolved_mode!r}")
|
||||
notes=[]; diagnostics=[]
|
||||
try:
|
||||
resolved_mode=resolve_prompt_mode(mode,script)
|
||||
if mode==PROMPT_FORMAT_AUTO:
|
||||
detected={PROMPT_MODE_FIXED:PROMPT_FORMAT_FIXED,PROMPT_MODE_LIST:PROMPT_FORMAT_LIST,PROMPT_MODE_TIMELINE:PROMPT_FORMAT_TIMELINE}[resolved_mode]; notes.append(f"Auto detected {detected}")
|
||||
if resolved_mode==PROMPT_MODE_FIXED: prompt=_normalize_prompt(script,label="fixed prompt"); prompts=[prompt]*chunks
|
||||
elif resolved_mode==PROMPT_MODE_LIST: prompts,parse_notes=_parse_list(script,chunks); notes.extend(parse_notes)
|
||||
elif resolved_mode==PROMPT_MODE_TIMELINE: prompts,parse_notes,diagnostics=_parse_timeline(script,chunks,chunk_seconds); notes.extend(parse_notes)
|
||||
else: raise PromptPlanError(f"unknown prompt mode: {resolved_mode!r}")
|
||||
except (PromptPlanError,TypeError,ValueError) as exc:
|
||||
resolved_mode=PROMPT_MODE_FIXED; prompts=[_normalize_prompt(script,label="fixed prompt")]*chunks
|
||||
notes.append("Prompt syntax was not recognized; used Fixed prompt fallback")
|
||||
diagnostics=[{"level":"warning","code":"H3C-P100","message":str(exc)}]
|
||||
result={"magic":PROMPT_PLAN_MAGIC,"schema_version":PROMPT_PLAN_SCHEMA_VERSION,"mode":resolved_mode,"chunks":chunks,"chunk_seconds":chunk_seconds,"prompts":prompts,"hashes":[prompt_hash(p) for p in prompts],"notes":notes}
|
||||
if resolved_mode==PROMPT_MODE_TIMELINE: result["diagnostics"]=diagnostics
|
||||
if diagnostics: result["diagnostics"]=diagnostics
|
||||
return result
|
||||
def validate_prompt_plan(plan):
|
||||
if not isinstance(plan,dict) or plan.get("magic")!=PROMPT_PLAN_MAGIC: raise PromptPlanError("invalid H3 Continuum prompt plan")
|
||||
@@ -186,9 +190,12 @@ def build_sampler_prompt_plan(*,prompt_mode,prompt_script,sequence_prompt,prompt
|
||||
if sequence_prompt is not None: return make_prompt_plan(mode=prompt_mode,script=sequence_prompt,chunks=chunks,chunk_seconds=chunk_seconds)
|
||||
if prompt_plan is not None:
|
||||
plan=validate_prompt_plan(prompt_plan)
|
||||
if int(plan["chunks"])!=chunks: raise PromptPlanError("connected prompt_plan chunks do not match the Sampler chunks widget")
|
||||
if abs(float(plan["chunk_seconds"])-chunk_seconds)>1e-6: raise PromptPlanError("connected prompt_plan chunk_seconds do not match the Sampler widget")
|
||||
return plan
|
||||
prompts=list(plan["prompts"])
|
||||
if len(prompts)<chunks: prompts.extend([prompts[-1] if prompts else ""]*(chunks-len(prompts)))
|
||||
elif len(prompts)>chunks: prompts=prompts[:chunks]
|
||||
result=dict(plan); result["chunks"]=chunks; result["chunk_seconds"]=chunk_seconds; result["prompts"]=prompts; result["hashes"]=[prompt_hash(p) for p in prompts]
|
||||
if int(plan["chunks"])!=chunks or abs(float(plan["chunk_seconds"])-chunk_seconds)>1e-6: result["notes"]=list(plan.get("notes") or [])+["adapted connected prompt plan to Sampler chunk settings"]
|
||||
return validate_prompt_plan(result)
|
||||
return make_prompt_plan(mode=prompt_mode,script=prompt_script,chunks=chunks,chunk_seconds=chunk_seconds)
|
||||
def apply_prompt_overrides(plan,overrides):
|
||||
plan=validate_prompt_plan(plan); prompts=list(plan["prompts"]); replaced=[]
|
||||
|
||||
+1
-1
@@ -297,7 +297,7 @@ app.registerExtension({
|
||||
: "Basic";
|
||||
apiNode.inputs.debug = Boolean(settingValue(SETTINGS.developerDiagnostics, false));
|
||||
apiNode.inputs.show_preview = Boolean(settingValue(SETTINGS.samplingPreview, true));
|
||||
apiNode.inputs.strict_compatibility = true;
|
||||
apiNode.inputs.strict_compatibility = false;
|
||||
} else if (node.comfyClass === ASSEMBLE_SEAM_NODE_CLASS) {
|
||||
apiNode.inputs.diagnostics = settingValue(SETTINGS.detailedReport, false)
|
||||
? "Detailed Report"
|
||||
|
||||
Reference in New Issue
Block a user