Relax timeline coverage and add prompt diagnostics

This commit is contained in:
ukr8b3g-cmyk
2026-08-15 13:10:34 +09:00
parent ec197341ef
commit 23b686e582
6 changed files with 161 additions and 30 deletions
+73 -3
View File
@@ -14,6 +14,7 @@ from ComfyUI_H3_Continuum_Join.v2.prompts import (
detect_prompt_mode,
make_prompt_plan,
parse_sparse_prompt_overrides,
prompt_plan_report,
validate_sparse_prompt_overrides,
validate_prompt_plan,
)
@@ -83,14 +84,83 @@ def test_timeline_preamble_is_applied_to_every_chunk():
assert plan["notes"] == ["Auto detected Timeline", "applied timeline preamble to all chunks"]
def test_timeline_requires_coverage():
with pytest.raises(PromptPlanError):
def test_timeline_missing_coverage_warns_and_repeats_previous_prompt():
plan = make_prompt_plan(
mode=PROMPT_MODE_TIMELINE,
script="[0-5s]\none",
chunks=2,
chunk_seconds=5,
)
assert plan["prompts"] == ["one", "one"]
assert any(item["code"] == "H3C-P101" for item in plan["diagnostics"])
assert "fallback" in prompt_plan_report(plan)
def test_timeline_leading_gap_uses_earliest_valid_prompt():
plan = make_prompt_plan(
mode=PROMPT_MODE_TIMELINE,
script="[5-10s]\nsecond",
chunks=2,
chunk_seconds=5,
)
assert plan["prompts"] == ["second", "second"]
assert plan["diagnostics"][0]["code"] == "H3C-P101"
def test_timeline_extra_sections_warn_and_are_ignored():
plan = make_prompt_plan(
mode=PROMPT_MODE_TIMELINE,
script="[0-5s]\none\n[5-10s]\ntwo\n[10-15s]\nextra",
chunks=2,
chunk_seconds=5,
)
assert plan["prompts"] == ["one", "two"]
assert any(item["code"] == "H3C-P104" for item in plan["diagnostics"])
@pytest.mark.parametrize(
("script", "code"),
[
("[0 to 5s]\none", "H3C-P001"),
("[5-5s]\none", "H3C-P002"),
("[Chunk 0]\none", "H3C-P004"),
("[0-5s]\n", "H3C-P005"),
],
)
def test_invalid_timeline_reports_actionable_diagnostic(script, code):
with pytest.raises(PromptPlanError) as captured:
make_prompt_plan(
mode=PROMPT_MODE_TIMELINE,
script="[0-5s]\none",
script=script,
chunks=2,
chunk_seconds=5,
)
message = str(captured.value)
assert code in message
assert "Suggested fix:" in message
def test_duplicate_chunk_section_is_an_error():
with pytest.raises(PromptPlanError, match="H3C-P003"):
make_prompt_plan(
mode=PROMPT_MODE_TIMELINE,
script="[Chunk 1]\none\n[Chunk 1]\ntwo",
chunks=2,
chunk_seconds=5,
)
def test_prompt_preflight_reports_explicit_chunk_sources():
plan = make_prompt_plan(
mode=PROMPT_MODE_TIMELINE,
script="[0-5s]\none\n[5-10s]\ntwo",
chunks=2,
chunk_seconds=5,
)
report = prompt_plan_report(plan)
assert "Prompt Preflight:" in report
assert "Chunk 1 source:" in report
assert "Chunk 2 source:" in report
def test_native_h3_chunk_duration_rejects_sub_four_seconds():
+4
View File
@@ -79,6 +79,7 @@ def test_v323_third_reference_adds_only_the_image_3_extension():
def test_unavailable_picture_tags_warn_without_stopping_like_core():
assert validate_reference_prompts(["Use <Picture 1> and <Picture 2>."], 2) == ""
message = validate_reference_prompts(["Use <Picture 2>."], 1)
assert "H3C-P102" in message
assert "only 1 active reference image(s) reached the Sampler" in message
assert "generation will continue" in message
assert "ignored or hallucinated" in message
@@ -89,6 +90,7 @@ def test_unavailable_picture_tags_warn_without_stopping_like_core():
def test_missing_picture_tag_is_a_warning_not_an_error():
warning = validate_reference_prompts(["The same person walks forward."], 1)
assert "H3C-P103" in warning
assert "no <Picture N> tag" in warning
@@ -166,6 +168,7 @@ def test_unavailable_audio_tags_warn_without_stopping_like_core():
["Perform <Audio 1> and <Audio 2>."], None
)
assert "unavailable <Audio 1>" in message
assert "H3C-P102" in message
assert "unavailable <Audio 2>" in message
assert "generation will continue" in message
@@ -176,6 +179,7 @@ def test_connected_audio_keeps_unavailable_extra_tag_as_warning():
)
assert "unavailable <Audio 2>" in message
assert "no <Audio 1> tag" in message
assert "H3C-P103" in message
def _reference_prompt(checkpoint_name: str) -> dict: