Write talking-head scripts and produce Instagram reels and YouTube shorts
96%
Does it follow best practices?
Impact
98%
1.07xAverage score across 8 eval scenarios
Low
Low-risk findings worth noting
#!/usr/bin/env python3
"""What a render was made from, and what checked it — so approvals and QC bind
to the exact file a human or a check looked at.
Three records, all JSON beside the artifact they describe (schema in
references/state-schema.md):
<render>.render.json written by render_reel.py / resolve_render.py: the
output's fingerprint, the plan's sha256, a fingerprint
of every input file, and the render settings
QC reports check_cuts.py, qa_render.py and verify_cut.py add
"video_fp" — the fingerprint of the file they checked
exports/manifest.json export_variants.py: the master it exported from and
the files it wrote
A fingerprint is (path, size, mtime_ns). Every render and re-render writes a
new file, so a changed fingerprint means a different artifact; hashing a
multi-gigabyte master on every `status` would cost seconds for no extra signal.
The plan is small and edited in place, so it is hashed.
pipeline.py reads these; it never trusts a render or a QC result whose
fingerprint no longer matches the file on disk.
"""
import hashlib
import json
from pathlib import Path
RECORD_SCHEMA = 1
def file_fp(path):
"""{"path", "size", "mtime_ns"} for an existing file, else None."""
p = Path(path)
try:
st = p.stat()
except OSError:
return None
if not p.is_file():
return None
return {"path": str(p), "size": st.st_size, "mtime_ns": st.st_mtime_ns}
def fp_matches(fp):
"""True when the file a fingerprint names is still that exact file."""
if not fp:
return False
now = file_fp(fp.get("path", ""))
return bool(now) and now["size"] == fp.get("size") and now["mtime_ns"] == fp.get("mtime_ns")
def sha256_file(path):
h = hashlib.sha256()
with open(path, "rb") as f:
for chunk in iter(lambda: f.read(1 << 20), b""):
h.update(chunk)
return h.hexdigest()
def record_path(render):
p = Path(render)
return p.with_name(p.name + ".render.json")
def write_render_record(render, plan_path, inputs, settings):
"""Describe a finished render. `inputs` maps a name to a path (or None);
lists of paths are fingerprinted element-wise."""
def fp_of(v):
if v is None:
return None
if isinstance(v, (list, tuple)):
return [file_fp(x) for x in v]
return file_fp(v)
rec = {
"schema_version": RECORD_SCHEMA,
"output": file_fp(render),
"plan": {"path": str(plan_path), "sha256": sha256_file(plan_path)},
"inputs": {k: fp_of(v) for k, v in inputs.items()},
"settings": settings,
}
dst = record_path(render)
tmp = dst.with_name(dst.name + ".tmp")
tmp.write_text(json.dumps(rec, indent=2))
tmp.rename(dst)
return rec
def read_render_record(render):
"""The record for this exact render, or None (missing, unreadable, another
schema, or written for an earlier file at the same path)."""
rp = record_path(render)
try:
rec = json.loads(rp.read_text())
except (OSError, json.JSONDecodeError):
return None
if rec.get("schema_version") != RECORD_SCHEMA or not fp_matches(rec.get("output")):
return None
return rec
def stale_inputs(rec):
"""Names of the inputs that changed since the render — [] means current."""
changed = []
plan = rec.get("plan") or {}
try:
if sha256_file(plan["path"]) != plan.get("sha256"):
changed.append("plan")
except (OSError, KeyError):
changed.append("plan")
for name, fp in (rec.get("inputs") or {}).items():
fps = fp if isinstance(fp, list) else [fp]
if any(f is not None and not fp_matches(f) for f in fps):
changed.append(name)
return changed
def qc_reports(pattern, video):
"""Parsed reports matching a glob whose video_fp is this exact video."""
out = []
for p in sorted(Path().glob(pattern)):
try:
rep = json.loads(p.read_text())
except (OSError, json.JSONDecodeError):
continue
fp = rep.get("video_fp") if isinstance(rep, dict) else None
if fp and fp_matches(fp) and Path(fp["path"]).resolve() == Path(video).resolve():
out.append((p, rep))
return out.tessl-plugin
skills
reel-builder
assets
references
scripts
yap-writer