fix(variation_checker): measure longest run for consecutive same-size shots

Check 2 flagged 'N consecutive same-size shots' from a count of every equal
adjacent pair across the whole plan, not the length of any real run. So three
separate 2-shot groups (wide,wide,cu,cu,med,med) tripped a false '3
consecutive' violation, while a genuine run of 3 (only 2 pairs) was never
flagged. Track the current run length, reset on change, and compare the longest
run >= 3.

Adds regression tests: non-consecutive pairs pass, a true run of 3 is flagged,
unspecified shots don't form a run.

Closes #268
This commit is contained in:
0xDevNinja
2026-07-02 16:52:00 +05:30
parent febc9244d3
commit 364182cc39
2 changed files with 48 additions and 4 deletions

View File

@@ -56,13 +56,20 @@ def check_scene_variation(scenes: list[dict[str, Any]]) -> dict[str, Any]:
suggestions.append("Mix wide establishing shots with close-ups for visual rhythm.")
# --- Check 2: Consecutive same-size shots ---
consecutive_same = 0
# Track the longest actual run of identical shot sizes. Summing every equal
# adjacent pair across the whole plan would count non-consecutive groups
# (e.g. wide,wide,cu,cu,med,med -> 3 pairs) as a single "3 consecutive" run.
longest_run = 1 if shot_sizes else 0
current_run = 1
for i in range(1, len(shot_sizes)):
if shot_sizes[i] == shot_sizes[i-1] and shot_sizes[i] != "unspecified":
consecutive_same += 1
if consecutive_same >= 3:
current_run += 1
longest_run = max(longest_run, current_run)
else:
current_run = 1
if longest_run >= 3:
violations.append(
f"{consecutive_same} consecutive same-size shots. "
f"{longest_run} consecutive same-size shots. "
f"Vary shot sizes between scenes for editorial rhythm."
)