diff --git a/PROJECT_STATE.md b/PROJECT_STATE.md index 7b9ead6..8bf1410 100644 --- a/PROJECT_STATE.md +++ b/PROJECT_STATE.md @@ -12,6 +12,15 @@ Updated: 2026-08-27 +## V3.6.1 Prompt Parser hotfix implementation (unreleased, 2026-08-27) + +- Shared `v2/prompts.py` now detects mixed Timeline headers and standalone `---` List separators without stopping generation. Auto and explicit Timeline keep Timeline assignment, remove only standalone separator lines, emit `H3C-P105`, and retain the existing `H3C-P101` previous-prompt fallback for uncovered chunks. Text after a removed separator is not reassigned to another chunk. +- Explicit List retains its existing separator parsing and only reports `H3C-P105` when valid Timeline headers are present. Explicit Fixed remains literal and warning-free. Invalid Timeline still fails open to the original Fixed text with `H3C-P100`. +- Reports with parser warnings now begin with `PROMPT PREFLIGHT WARNING`; Timeline source/fallback diagnostics and explicit-List section mappings expose the resolved per-chunk assignment. Prompt Plan Preview uses the same Python parser and report. No Frontend/JavaScript parser or Toast was added. +- Run Storage schema is unchanged. A dedicated regression confirms that hashes from the legacy mixed Prompt text and the normalized resolved Prompt produce distinct revision identities, preventing incorrect reuse. +- Validation: parser plus Run Storage focused `71 passed`; related public/schema/workflow suite `94 passed`; full pytest `538 passed`; compileall, V3.6.0 source runtime verifier against ComfyUI_WAN, and `git diff --check` pass. Only the known `pynvml` FutureWarning appeared. GPU testing was intentionally not run. +- Accepted pre-change snapshot: `pre-v361-prompt-parser-hotfix-accepted-20260827_190257` (214 Git-visible/untracked nonignored files, SHA-256 mismatch 0, revision `0d18e3abe0923502171f47f24769e957057eaf15`). Frontend, version metadata, release files, runtime copies, commit, and push remain unchanged. + ## V3.6.0 public release implementation (2026-08-27) - Added the new public `H3ContinuumSamplerV36` / `H3 Continuum Sampler V3.6` without replacing or redirecting V3.5.3/V3.4 nodes. Its final required widget is `Continuation Backend` with only `Standard` and `Compatibility`; internal transport identifiers are not exposed. diff --git a/WORKLOG.md b/WORKLOG.md index 8625ed4..da5e036 100644 --- a/WORKLOG.md +++ b/WORKLOG.md @@ -1,5 +1,12 @@ # Work Log +## 2026-08-27 - V3.6.1 mixed Prompt syntax parser hotfix (unreleased) + +- Preserved all existing tracked/untracked work and created verified snapshot `pre-v361-prompt-parser-hotfix-accepted-20260827_190257` at revision `0d18e3abe0923502171f47f24769e957057eaf15` (214 files, zero SHA-256 mismatch). The standard snapshot attempt stopped only on the known `.pytest_cache` ACL before any edit. +- Updated only the shared Python Prompt planner and tests: Auto/Timeline now ignore standalone `---` lines when Timeline syntax is active, issue `H3C-P105`, keep following text in the current Timeline section, and preserve `H3C-P101` fallback. Explicit List keeps List parsing with a mixed-syntax warning; Explicit Fixed and invalid-Timeline Fixed fallback remain literal/fail-open. +- Warning reports now lead with `PROMPT PREFLIGHT WARNING` and retain resolved Timeline or List source mappings. Prompt Preview consumes the same plan/report; no Frontend Toast, JavaScript parser duplication, schema bump, or Production Sampling/Masked AV/Reference/Terminal/Assembly/Seam change was introduced. +- Added mixed Auto/Timeline/List/Fixed, shared-preamble separator, five-chunk trailing separator, missing-chunk fallback, report, Preview, invalid fallback, and Run Storage revision-separation regressions. Results: focused `71 passed`, related `94 passed`, full `538 passed`, compileall PASS, V3.6.0 source runtime verifier against ComfyUI_WAN PASS, and `git diff --check` PASS. GPU, runtime synchronization, version metadata, release, commit, and push were intentionally not performed. + ## 2026-08-27 - V3.6.0 public release implementation and GPU smoke - Added `H3 Continuum Sampler V3.6` as a new public Node ID while preserving V3.5.3/V3.4 nodes and widget sequences. Public backend choices are only `Standard` and `Compatibility`: Standard maps to Masked AV or Masked Video according to Audio Continuity, while Compatibility maps to the original Reference Context path. Internal transport names remain private. diff --git a/tests/test_v2_prompts.py b/tests/test_v2_prompts.py index 5689327..de78ec0 100644 --- a/tests/test_v2_prompts.py +++ b/tests/test_v2_prompts.py @@ -3,6 +3,8 @@ import pytest from ComfyUI_H3_Continuum_Join.constants import ( PROMPT_FORMAT_AUTO, PROMPT_FORMAT_FIXED, + PROMPT_FORMAT_LIST, + PROMPT_FORMAT_TIMELINE, PROMPT_MODE_FIXED, PROMPT_MODE_LIST, PROMPT_MODE_TIMELINE, @@ -18,6 +20,7 @@ from ComfyUI_H3_Continuum_Join.v2.prompts import ( validate_sparse_prompt_overrides, validate_prompt_plan, ) +from ComfyUI_H3_Continuum_Join.v2.nodes import H3ContinuumPromptPlanPreview def test_fixed_prompt_repeats_without_mutation(): @@ -71,6 +74,126 @@ def test_timeline_prompt_maps_ranges_and_chunk_headers(): chunk_seconds=5, ) assert plan["prompts"] == ["one", "two", "three"] + assert not any(item["code"] == "H3C-P105" for item in plan.get("diagnostics", [])) + + +def test_clean_list_keeps_assignments_without_mixed_syntax_warning(): + plan = make_prompt_plan( + mode=PROMPT_FORMAT_LIST, + script="A\n---\nB\n---\nC", + chunks=3, + chunk_seconds=5, + ) + assert plan["prompts"] == ["A", "B", "C"] + assert not any(item["code"] == "H3C-P105" for item in plan.get("diagnostics", [])) + + +@pytest.mark.parametrize("mode", [PROMPT_FORMAT_AUTO, PROMPT_FORMAT_TIMELINE]) +def test_timeline_mixed_with_list_separator_warns_and_ignores_separator(mode): + plan = make_prompt_plan( + mode=mode, + script="[Chunk 1]\nA\n[Chunk 2]\nB\n---\nC", + chunks=3, + chunk_seconds=5, + ) + assert plan["mode"] == PROMPT_MODE_TIMELINE + assert plan["prompts"] == ["A", "B\nC", "B\nC"] + assert all("---" not in prompt for prompt in plan["prompts"]) + assert any(item["code"] == "H3C-P105" for item in plan["diagnostics"]) + assert any(item["code"] == "H3C-P101" for item in plan["diagnostics"]) + + +def test_timeline_mixed_separator_is_removed_from_shared_preamble(): + plan = make_prompt_plan( + mode=PROMPT_FORMAT_AUTO, + script="Shared preamble\n---\n[Chunk 1]\nA\n[Chunk 2]\nB", + chunks=2, + chunk_seconds=5, + ) + assert plan["prompts"] == ["Shared preamble\n\nA", "Shared preamble\n\nB"] + assert all("---" not in prompt for prompt in plan["prompts"]) + assert any(item["code"] == "H3C-P105" for item in plan["diagnostics"]) + + +def test_five_chunk_timeline_with_trailing_separator_preserves_all_assignments(): + script = "\n".join( + [ + "[Chunk 1]", "A", "[Chunk 2]", "B", "[Chunk 3]", "C", + "[Chunk 4]", "D", "[Chunk 5]", "E", "---", + ] + ) + plan = make_prompt_plan( + mode=PROMPT_FORMAT_AUTO, + script=script, + chunks=5, + chunk_seconds=5, + ) + assert plan["prompts"] == ["A", "B", "C", "D", "E"] + assert any(item["code"] == "H3C-P105" for item in plan["diagnostics"]) + + +def test_explicit_list_with_timeline_header_warns_but_keeps_list_parsing(): + plan = make_prompt_plan( + mode=PROMPT_FORMAT_LIST, + script="[Chunk 1]\nA\n---\nB\n---\nC", + chunks=3, + chunk_seconds=5, + ) + assert plan["mode"] == PROMPT_MODE_LIST + assert plan["prompts"] == ["[Chunk 1]\nA", "B", "C"] + assert any(item["code"] == "H3C-P105" for item in plan["diagnostics"]) + assert [item["message"] for item in plan["diagnostics"] if item["code"] == "H3C-P000"] == [ + "Chunk 1 source: List section 1", + "Chunk 2 source: List section 2", + "Chunk 3 source: List section 3", + ] + + +def test_explicit_fixed_keeps_all_special_syntax_literal_without_warning(): + script = "[Chunk 1]\nA\n[0-5s]\nB\n---\nC" + plan = make_prompt_plan( + mode=PROMPT_FORMAT_FIXED, + script=script, + chunks=2, + chunk_seconds=5, + ) + assert plan["prompts"] == [script, script] + assert "diagnostics" not in plan + + +def test_mixed_syntax_report_leads_with_warning_and_resolved_chunk_sources(): + plan = make_prompt_plan( + mode=PROMPT_FORMAT_AUTO, + script="[Chunk 1]\nA\n[Chunk 2]\nB\n---\nC", + chunks=3, + chunk_seconds=5, + ) + report = prompt_plan_report(plan) + assert report.startswith("PROMPT PREFLIGHT WARNING") + assert "H3C-P105" in report + assert "H3C-P101" in report + assert "Chunk 1 source:" in report + assert "Chunk 3 source:" in report + + +def test_prompt_preview_uses_the_same_mixed_syntax_resolution(): + script = "[Chunk 1]\nA\n[Chunk 2]\nB\n---\nC" + expected = make_prompt_plan( + mode=PROMPT_FORMAT_AUTO, + script=script, + chunks=3, + chunk_seconds=5, + ) + preview_plan, preview_report = H3ContinuumPromptPlanPreview().build( + PROMPT_FORMAT_AUTO, + script, + 3, + 5, + ) + assert preview_plan == expected + assert preview_report.startswith("PROMPT PREFLIGHT WARNING") + assert "Chunk 2:\nB\nC" in preview_report + assert "Chunk 3:\nB\nC" in preview_report def test_timeline_preamble_is_applied_to_every_chunk(): @@ -140,6 +263,19 @@ def test_invalid_timeline_falls_back_with_actionable_diagnostic(script, code): assert code in plan["diagnostics"][0]["message"] +def test_invalid_mixed_timeline_fallback_preserves_original_text(): + script = "[Chunk 0]\nA\n---\nB" + plan = make_prompt_plan( + mode=PROMPT_FORMAT_TIMELINE, + script=script, + chunks=2, + chunk_seconds=5, + ) + assert plan["mode"] == PROMPT_MODE_FIXED + assert plan["prompts"] == [script, script] + assert plan["diagnostics"][0]["code"] == "H3C-P100" + + def test_duplicate_chunk_section_falls_back_without_blocking(): plan = make_prompt_plan( mode=PROMPT_MODE_TIMELINE, diff --git a/tests/test_v31_run_storage.py b/tests/test_v31_run_storage.py index 1b3d8ee..796f181 100644 --- a/tests/test_v31_run_storage.py +++ b/tests/test_v31_run_storage.py @@ -30,6 +30,7 @@ from ComfyUI_H3_Continuum_Join.graph_contract import ( classify_h3_checkpoint, ) from ComfyUI_H3_Continuum_Join.state import make_plan +from ComfyUI_H3_Continuum_Join.v2.prompts import make_prompt_plan, prompt_hash from ComfyUI_H3_Continuum_Join.v2.session import make_chunk_entry from ComfyUI_H3_Continuum_Join.v3.nodes import _validate_regenerate_storage @@ -295,7 +296,7 @@ def _sampling_contract( upstream_graph_reasons=None, execution_semantics=None, reference_audio_contract=None, - reference_audio_vae=None, + reference_audio_vae=None, prompt_hashes=None, ): return build_sampling_contract( model=model or _Model(), @@ -306,7 +307,7 @@ def _sampling_contract( sigmas=torch.tensor([1.0, 0.0]), prompt_plan={ "chunks": 3, - "hashes": ["1" * 64, "2" * 64, "3" * 64], + "hashes": list(prompt_hashes or ["1" * 64, "2" * 64, "3" * 64]), "mode": "list", }, width=96, @@ -331,6 +332,25 @@ def _sampling_contract( ) +def test_mixed_timeline_normalization_separates_run_storage_revision(): + script = "[Chunk 1]\nA\n[Chunk 2]\nB\n---\nC" + normalized = make_prompt_plan( + mode="Auto", + script=script, + chunks=3, + chunk_seconds=5, + ) + legacy_hashes = [prompt_hash("A"), prompt_hash("B\n---\nC"), prompt_hash("B\n---\nC")] + + legacy_contract, legacy_safe, legacy_reasons = _sampling_contract(prompt_hashes=legacy_hashes) + normalized_contract, normalized_safe, normalized_reasons = _sampling_contract(prompt_hashes=normalized["hashes"]) + + assert legacy_safe, legacy_reasons + assert normalized_safe, normalized_reasons + assert normalized["prompts"] == ["A", "B\nC", "B\nC"] + assert revision_identity(legacy_contract) != revision_identity(normalized_contract) + + def test_reference_audio_revision_separates_changes_and_restores_on_disconnect(): model = _Model() clip = _Clip() diff --git a/v2/prompts.py b/v2/prompts.py index 8ceec00..e02e1bd 100644 --- a/v2/prompts.py +++ b/v2/prompts.py @@ -37,18 +37,20 @@ 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: values=[str(script)] - notes=[] + source_count=len(values); notes=[] if len(values)chunks: notes.append(f"ignored {len(values)-chunks} extra prompt(s)"); values=values[:chunks] - return values,notes -def _timeline_preamble(script): + sources=[min(index+1,source_count) for index in range(len(values))] + return values,notes,sources +def _timeline_preamble(script,*,ignore_list_separators=False): body=[] for line in str(script).splitlines(): if _TIMELINE_HEADER.match(line) or _CHUNK_HEADER.match(line): break + if ignore_list_separators and _LIST_SEPARATOR.fullmatch(line): continue body.append(line) return "\n".join(body).strip() -def _parse_timeline_sections(script,*,allow_preamble=True): - preamble=_timeline_preamble(script) +def _parse_timeline_sections(script,*,allow_preamble=True,ignore_list_separators=False): + preamble=_timeline_preamble(script,ignore_list_separators=ignore_list_separators) sections=[]; current=None; body=[] def finish(): nonlocal current,body @@ -75,6 +77,8 @@ def _parse_timeline_sections(script,*,allow_preamble=True): continue if _TIMELINE_LIKE_HEADER.match(line): _prompt_error("H3C-P001","invalid timeline header",line_number=line_number,source=line.strip(),suggested_fix="use [0-5s] or [Chunk 1]") + if ignore_list_separators and _LIST_SEPARATOR.fullmatch(line): + continue body.append(line) finish() if not sections: raise PromptPlanError("timeline contains no sections") @@ -97,9 +101,9 @@ def validate_sparse_prompt_overrides(overrides,*,chunks): validated[index]=_normalize_prompt(prompt,label=f"Clip {index} Override") if not validated: raise PromptPlanError("Sparse Clip Overrides contains no overrides") return validated -def _parse_timeline(script,chunks,chunk_seconds): - sections=_parse_timeline_sections(script); prompts=[]; notes=[]; diagnostics=[] - if _timeline_preamble(script): notes.append("applied timeline preamble to all chunks") +def _parse_timeline(script,chunks,chunk_seconds,*,ignore_list_separators=False): + sections=_parse_timeline_sections(script,ignore_list_separators=ignore_list_separators); prompts=[]; notes=[]; diagnostics=[] + if _timeline_preamble(script,ignore_list_separators=ignore_list_separators): notes.append("applied timeline preamble to all chunks") seen_chunks={}; total_end=chunks*chunk_seconds; usable=[] for item in sections: if item["kind"]=="chunk": @@ -140,6 +144,14 @@ def _parse_timeline(script,chunks,chunk_seconds): diagnostics.append({"level":"info","code":"H3C-P000","message":f"Chunk {chunk_index} source: {previous_source}"}) if len(scored)>1 and abs(scored[0][0]-scored[1][0])<1e-9: notes.append(f"chunk {chunk_index} had an equal-overlap timeline tie; used the earlier section") return prompts,notes,diagnostics +def _has_timeline_header(script): + return any(_TIMELINE_HEADER.match(line) or _CHUNK_HEADER.match(line) for line in str(script).splitlines()) +def _has_list_separator(script): + return _LIST_SEPARATOR.search(str(script)) is not None +def _mixed_syntax_diagnostic(*,timeline_active): + message="Mixed Timeline and List prompt syntax detected. Use either [Chunk N] / [0-5s] sections or --- separators, not both." + if timeline_active: message+=" Standalone --- separators were ignored because Timeline syntax is active." + return {"level":"warning","code":"H3C-P105","message":message} def detect_prompt_mode(script): text=str(script) for line in text.splitlines(): @@ -163,8 +175,15 @@ def make_prompt_plan(*,mode,script,chunks,chunk_seconds): 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) + elif resolved_mode==PROMPT_MODE_LIST: + prompts,parse_notes,list_sources=_parse_list(script,chunks); notes.extend(parse_notes) + if _has_timeline_header(script): + diagnostics.append(_mixed_syntax_diagnostic(timeline_active=False)) + diagnostics.extend({"level":"info","code":"H3C-P000","message":f"Chunk {index+1} source: List section {source}"} for index,source in enumerate(list_sources)) + elif resolved_mode==PROMPT_MODE_TIMELINE: + mixed_syntax=_has_list_separator(script) + prompts,parse_notes,diagnostics=_parse_timeline(script,chunks,chunk_seconds,ignore_list_separators=mixed_syntax); notes.extend(parse_notes) + if mixed_syntax: diagnostics.insert(0,_mixed_syntax_diagnostic(timeline_active=True)) 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 @@ -215,8 +234,18 @@ def prompt_plan_report(plan): if note: result+=" "+note+"." diagnostics=list(plan.get("diagnostics") or []) if not diagnostics: return result+"\nPrompt Preflight: OK." - lines=[result,"Prompt Preflight:"] - for item in diagnostics: + warnings=[item for item in diagnostics if str(item.get("level","info")).lower()=="warning"] + info=[item for item in diagnostics if str(item.get("level","info")).lower()!="warning"] + lines=[] + if warnings: + lines.append("PROMPT PREFLIGHT WARNING") + for item in warnings: + code=str(item.get("code","H3C-P000")); message=str(item.get("message","")) + lines.append(f"- WARNING {code}: {message}") + lines.append("") + lines.extend([result,"Prompt Preflight:"]) + for item in info: level=str(item.get("level","info")).upper(); code=str(item.get("code","H3C-P000")); message=str(item.get("message","")) lines.append(f"- {level} {code}: {message}") + if not info: lines.append("- See warning(s) above.") return "\n".join(lines)