Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

feat: report simultaneous partial layout overlaps

rpone6694d7d2347a
diff --git a/.agents/skills/hypit/references/element-review.md b/.agents/skills/hypit/references/element-review.md
index b48cfe85..9acedef5 100644
--- a/.agents/skills/hypit/references/element-review.md
+++ b/.agents/skills/hypit/references/element-review.md
@@ -119,6 +119,14 @@ element ids. Use those numbers as the mechanical findings and let the observer d
alignment or overflow matches the reference/intent. The report cannot measure renderer-shaped glyph
bounds or infer intent, so the visual pass must still confirm text and marks in the rendered image.
+The same report includes `layout_geometry.overlaps`. It is an advisory list of Source-level placement
+pairs that are on the same Canvas, present during an overlapping timing scope, and have a positive-area
+rectangle intersection without either rectangle fully containing the other. Full containment is omitted
+because a background or parent Frame commonly covers its child intentionally. Treat each entry as a
+candidate finding: confirm it in the rendered frame and against the author intent before changing Source.
+The check compares only declared Canvas/Frame placement bounds; it cannot see glyph-level or other
+package-internal bounds that a Producer does not expose.
+
Do not treat a clearly platform/player/export-tool watermark as authored content. Ignore it when its
provenance is obvious; if it could be part of the design, record the uncertainty instead of inventing
a repair.
diff --git a/.agents/skills/hypit/references/original-authoring/conformance-round.md b/.agents/skills/hypit/references/original-authoring/conformance-round.md
index e31908c6..6f75eb2e 100644
--- a/.agents/skills/hypit/references/original-authoring/conformance-round.md
+++ b/.agents/skills/hypit/references/original-authoring/conformance-round.md
@@ -73,8 +73,10 @@ overflow, and check the final visible bounds against all four Canvas edges.
`authoring_check` returns `layout_geometry` with deterministic Canvas/Frame bounds, centres, parent and
Canvas offsets, containment overflow, and bound element ids. Use it as the mechanical report and make
-the conformance decision from the rendered picture and intent. It cannot measure actual glyph bounds or
-infer intent, so those still require the reader.
+the conformance decision from the rendered picture and intent. It also reports
+`layout_geometry.overlaps` for same-Canvas placements that are simultaneous and partially intersecting;
+full containment is omitted and the entries are advisory candidates, not automatic failures. It cannot
+measure actual glyph or package-internal bounds or infer intent, so those still require the reader.
Clearly platform/player/export-tool watermarks are not authored content and should be ignored. If a mark
could be intentional design, preserve the uncertainty and do not silently remove it.
diff --git a/.agents/skills/hypit/references/preview.md b/.agents/skills/hypit/references/preview.md
index c83f7174..74efa8ab 100644
--- a/.agents/skills/hypit/references/preview.md
+++ b/.agents/skills/hypit/references/preview.md
@@ -111,7 +111,11 @@ evidence and comparison windows only. The sidecar records `"timing_basis": "esti
Before reading the picture, run the route's `reconstruction_check` or `authoring_check` and keep its
`layout_geometry` object with the render. It is the mechanical Canvas/Frame report used to check centre
offsets, frame capacity, and Canvas containment; the observer still confirms rendered text bounds and
-whether any bleed is intentional.
+whether any bleed is intentional. Also inspect `layout_geometry.overlaps`: it lists only partial
+rectangle intersections between same-Canvas placements whose timing scopes overlap. Full containment is
+omitted as a likely intentional parent/background relationship. These are candidates, not automatic
+failures; verify them in the frame and remember that package-internal glyph bounds are not available to
+the mechanical check.
## Open the whole Run for a person
diff --git a/.agents/skills/hypit/references/reconstruction/comparison-round.md b/.agents/skills/hypit/references/reconstruction/comparison-round.md
index cc255d78..cd7b0dc1 100644
--- a/.agents/skills/hypit/references/reconstruction/comparison-round.md
+++ b/.agents/skills/hypit/references/reconstruction/comparison-round.md
@@ -163,7 +163,11 @@ for confirmation rather than silently discarding it.
The `reconstruction_check` JSON includes `layout_geometry`, a mechanical report of Canvas/Frame bounds,
centres, parent/Canvas offsets, containment overflow, and bound element ids. The agent should use those
facts alongside the comparison text. They are deterministic Source facts, not a decision: rendered
-glyph bounds and whether an overhang is intentional still require the observer.
+glyph bounds and whether an overhang is intentional still require the observer. Its
+`layout_geometry.overlaps` list is an advisory set of same-Canvas, temporally simultaneous partial
+rectangle intersections. Full containment is intentionally omitted; confirm each candidate against the
+rendered frame and intent, and do not treat it as an automatic gate failure. The list cannot detect
+overlap between package-internal glyphs or other bounds not exposed by Source placement.
## Measuring, on this route
diff --git a/packages/reference-video-tools/src/checks.ts b/packages/reference-video-tools/src/checks.ts
index ae8aa01d..3ff4939d 100644
--- a/packages/reference-video-tools/src/checks.ts
+++ b/packages/reference-video-tools/src/checks.ts
@@ -377,10 +377,24 @@ type LayoutGeometryEntry = {
readonly unresolved?: string;
};
+/** A mechanically detected partial intersection between two Source-level placements. */
+type LayoutOverlap = {
+ readonly first: string;
+ readonly second: string;
+ readonly canvas: string;
+ readonly first_bounds: Box;
+ readonly second_bounds: Box;
+ readonly intersection: Box;
+ readonly scope: string;
+ readonly note: string;
+};
+
type LayoutGeometryReport = {
readonly coordinate_system: "Canvas pixels, origin top-left, y increases downward";
readonly note: string;
readonly entries: readonly LayoutGeometryEntry[];
+ /** Partial overlaps only; full containment is intentionally omitted. */
+ readonly overlaps: readonly LayoutOverlap[];
};
/** A rectangle in Canvas pixels. The origin is top-left and y increases downward. */
@@ -609,6 +623,107 @@ function framesPastTheCanvas(svml: string): readonly OutOfBoundsFrame[] {
return report;
}
+type PlacementClaim = {
+ readonly id: string;
+ readonly canvas: string;
+ readonly box: Box;
+ readonly start: number;
+ readonly end: number;
+ readonly scope: string;
+};
+
+function overlapArea(left: Box, right: Box): Box | undefined {
+ const intersection = {
+ left: Math.max(left.left, right.left),
+ top: Math.max(left.top, right.top),
+ right: Math.min(left.right, right.right),
+ bottom: Math.min(left.bottom, right.bottom),
+ };
+ return intersection.right > intersection.left && intersection.bottom > intersection.top ? intersection : undefined;
+}
+
+function containsBox(outer: Box, inner: Box): boolean {
+ return outer.left <= inner.left && outer.top <= inner.top
+ && outer.right >= inner.right && outer.bottom >= inner.bottom;
+}
+
+function placementTiming(attributes: string, parsed: ReturnType<typeof parseScript> | undefined): { start: number; end: number; scope: string } {
+ const total = parsed?.tokens.length ?? 1;
+ const during = /\bduring=\{story\.(segment|selection)\.([A-Za-z0-9_-]+)\}/u.exec(attributes);
+ let start = 0;
+ let end = total;
+ let scope = "program";
+ if (during !== null && parsed !== undefined) {
+ const collection = during[1] === "segment" ? parsed.segments : parsed.selections;
+ const found = collection.find((item) => item.id === during[2]);
+ if (found !== undefined) {
+ if ("tokenStart" in found) {
+ start = found.tokenStart;
+ end = found.tokenEndExclusive;
+ } else {
+ start = found.open.boundary.tokenIndex;
+ end = found.close.boundary.tokenIndex;
+ }
+ }
+ scope = `${during[1]}:${during[2]}`;
+ }
+ const until = /\buntil=\{story\.moment\.([A-Za-z0-9_-]+)\}/u.exec(attributes)?.[1];
+ if (until !== undefined && parsed !== undefined) {
+ const moment = parsed.moments.find((item) => item.id === until);
+ if (moment !== undefined) end = Math.min(end, moment.boundary.tokenIndex);
+ scope = `${scope} until ${until}`;
+ }
+ return { start, end, scope };
+}
+
+function layoutOverlaps(svml: string, geometry: FrameGeometry): readonly LayoutOverlap[] {
+ let parsed: ReturnType<typeof parseScript> | undefined;
+ try {
+ const body = scriptBody(svml);
+ parsed = parseScript("<layout-geometry>", body.text, body.offset);
+ } catch {
+ // Keep spatial findings useful while another check reports the malformed Script.
+ }
+ const claims: PlacementClaim[] = [];
+ for (const match of svml.matchAll(/<([a-z][a-z0-9-]*:[A-Za-z][A-Za-z0-9]*)\b([^>]*?)\/?\s*>/gsu)) {
+ const tag = match[1] ?? "";
+ const attributes = match[2] ?? "";
+ if (/:(?:Canvas|Frame|Track|Film|Video|Clock|SemanticTake|Normalize|Take|Item)$/u.test(tag)) continue;
+ const id = /\bid="([^"]+)"/u.exec(attributes)?.[1];
+ // `visual-frame` is the speech/media Track placement port. Do not treat `first-frame` or
+ // `last-frame` generation inputs as a placement claim.
+ const named = /\b(?:frame|visual-frame|canvas)=\{([A-Za-z0-9_-]+)\}/u.exec(attributes)?.[1];
+ if (id === undefined || named === undefined) continue;
+ const canvas = geometry.canvasOf(named);
+ const box = geometry.resolve(named);
+ if (canvas === undefined || box === undefined) continue;
+ const timing = placementTiming(attributes, parsed);
+ if (timing.end <= timing.start) continue;
+ claims.push({ id, canvas, box, ...timing });
+ }
+ const report: LayoutOverlap[] = [];
+ for (let first = 0; first < claims.length; first += 1) {
+ for (let second = first + 1; second < claims.length; second += 1) {
+ const left = claims[first]!;
+ const right = claims[second]!;
+ if (left.id === right.id || left.canvas !== right.canvas || left.end <= right.start || right.end <= left.start) continue;
+ const intersection = overlapArea(left.box, right.box);
+ if (intersection === undefined || containsBox(left.box, right.box) || containsBox(right.box, left.box)) continue;
+ report.push({
+ first: left.id,
+ second: right.id,
+ canvas: left.canvas,
+ first_bounds: left.box,
+ second_bounds: right.box,
+ intersection,
+ scope: left.scope === right.scope ? left.scope : `${left.scope} ∩ ${right.scope}`,
+ note: "Mechanical partial-overlap candidate. Confirm whether the overlap is intentional before editing Source.",
+ });
+ }
+ }
+ return report;
+}
+
/** Build a machine-readable layout report for the agent/observer to interpret. */
function layoutGeometry(svml: string): LayoutGeometryReport {
const geometry = frameGeometry(svml);
@@ -666,6 +781,7 @@ function layoutGeometry(svml: string): LayoutGeometryReport {
coordinate_system: "Canvas pixels, origin top-left, y increases downward",
note: "Use these facts to decide whether centering and containment match the reference/intent. They do not measure rendered glyph bounds or decide whether an overhang is intentional.",
entries,
+ overlaps: layoutOverlaps(svml, geometry),
};
}
diff --git a/packages/reference-video-tools/src/cli.ts b/packages/reference-video-tools/src/cli.ts
index 8d1deaed..40d1977a 100644
--- a/packages/reference-video-tools/src/cli.ts
+++ b/packages/reference-video-tools/src/cli.ts
@@ -76,8 +76,9 @@ function usage(): string {
"drawn at the same Canvas and put the element in the same place off the edge.",
"Both checks also return layout_geometry: deterministic Canvas/Frame bounds, centres, parent and",
"Canvas offsets, containment overflow and bound element ids. Use it as a mechanical geometry report",
- "for the observer to judge centring, frame capacity and Canvas safety; it does not measure rendered",
- "glyph bounds or decide whether an overhang is intentional.",
+ "for the observer to judge centring, frame capacity and Canvas safety; layout_geometry.overlaps adds",
+ "advisory same-Canvas, simultaneous partial-intersection candidates (full containment is omitted).",
+ "It does not measure rendered glyph bounds or decide whether an overhang or overlap is intentional.",
"",
"render_element draws one element of a Source the way that Source configures it, without a Build.",
"The Canvas, frame rate, Recipe values and bindings come from the compiled Graph; missing media is",