Skip to content

Commit 0eefd29

Browse files
committed
fix(check): report motion sidecars next to sub-compositions
1 parent 3ac5265 commit 0eefd29

7 files changed

Lines changed: 105 additions & 11 deletions

File tree

‎docs/packages/cli.mdx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,8 +1588,11 @@ edge, on any aspect ratio. Mark text that may sit outside them with
15881588
Layout sampling cannot catch a render-≠-preview bug: an entrance the seek lands
15891589
past, a broken stagger order, an element that drifts off-frame mid-tween, a shot
15901590
that freezes. Motion assertions can. Drop a `*.motion.json` sidecar next to the
1591-
composition and `check` evaluates it automatically — no flag, no changes to your
1592-
HTML. Without a sidecar, nothing changes.
1591+
entry composition (`index.html`) and `check` evaluates it automatically — no flag,
1592+
no changes to your HTML. A sidecar next to a sub-composition is not evaluated
1593+
yet: `check` reports it as an ignored warning, so move those assertions into
1594+
`index.motion.json` with root-timeline selectors and times. Without a sidecar,
1595+
nothing changes.
15931596

15941597
```json
15951598
{

‎packages/cli/src/commands/check.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,6 +2280,32 @@ describe("check pipeline", () => {
22802280
});
22812281
});
22822282

2283+
it("warns when a motion sidecar sits next to a sub-composition", async () => {
2284+
const dir = mkdtempSync(join(tmpdir(), "hf-check-nested-motion-"));
2285+
try {
2286+
writeFileSync(join(dir, "index.html"), "<html></html>");
2287+
mkdirSync(join(dir, "compositions"));
2288+
writeFileSync(
2289+
join(dir, "compositions", "scene-b.motion.json"),
2290+
JSON.stringify({ assertions: [{ kind: "appearsBy", selector: "#x", bySec: 1 }] }),
2291+
);
2292+
const { deps } = dependencies(fakeDriver());
2293+
2294+
const report = await runCheckPipeline(
2295+
{ dir, name: "nested-motion", indexPath: join(dir, "index.html") },
2296+
DEFAULT_CHECK_OPTIONS,
2297+
deps,
2298+
);
2299+
2300+
const warning = report.motion.findings.find((f) => f.code === "motion_spec_ignored");
2301+
expect(warning?.severity).toBe("warning");
2302+
expect(warning?.message).toContain("compositions/scene-b.motion.json");
2303+
expect(report.motion.warningCount).toBeGreaterThanOrEqual(1);
2304+
} finally {
2305+
rmSync(dir, { recursive: true, force: true });
2306+
}
2307+
});
2308+
22832309
it("marks browserSkipped true when the linter itself crashes", async () => {
22842310
const { deps } = dependencies(fakeDriver());
22852311
deps.lintProject = vi.fn(async () => {

‎packages/cli/src/utils/checkPipeline.ts‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ import {
5858
type Canvas,
5959
type MotionFrame,
6060
} from "./motionAudit.js";
61-
import { findMotionSpec, readMotionSpec, type MotionAssertion } from "./motionSpec.js";
61+
import {
62+
findMotionSpec,
63+
findNestedMotionSpecs,
64+
readMotionSpec,
65+
type MotionAssertion,
66+
} from "./motionSpec.js";
6267
import { auditCraft } from "./craftAudit.js";
6368
import { inspectHdrAutoPromotion, remoteMediaNotInspected } from "./hdrPromotion.js";
6469
import { collectProjectMedia, type ProjectMedia } from "./projectMedia.js";
@@ -1811,8 +1816,9 @@ export async function runCheckPipeline(
18111816
}
18121817

18131818
const motion = dependencies.resolveMotionSpec(project.dir);
1814-
const specFindings =
1815-
motion.kind === "invalid"
1819+
const ignoredMotionSpecs = findNestedMotionSpecs(project.dir);
1820+
const specFindings = [
1821+
...(motion.kind === "invalid"
18161822
? [
18171823
findingAtRoot(
18181824
"motion_spec_invalid",
@@ -1821,7 +1827,17 @@ export async function runCheckPipeline(
18211827
relative(project.dir, motion.path) || "index.motion.json",
18221828
),
18231829
]
1824-
: [];
1830+
: []),
1831+
...ignoredMotionSpecs.map((path) => {
1832+
const file = (relative(project.dir, path) || path).replace(/\\/g, "/");
1833+
return findingAtRoot(
1834+
"motion_spec_ignored",
1835+
"warning",
1836+
`Motion spec ${file} is not evaluated: check reads only the sidecar next to the entry HTML. Move its assertions into index.motion.json, or apply them to the root timeline.`,
1837+
file,
1838+
);
1839+
}),
1840+
];
18251841

18261842
const deadline = new CheckDeadline(idleWindow(options.timeout), options.budget);
18271843
const forgetStop = onStopSignal(deadline.stop);

‎packages/cli/src/utils/motionSpec.test.ts‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
1+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
22
import { tmpdir } from "node:os";
33
import { join } from "node:path";
44
import { describe, expect, it, onTestFinished } from "vitest";
5-
import { findMotionSpec, parseMotionSpec, readMotionSpec, type MotionSpec } from "./motionSpec.js";
5+
import {
6+
findMotionSpec,
7+
findNestedMotionSpecs,
8+
parseMotionSpec,
9+
readMotionSpec,
10+
type MotionSpec,
11+
} from "./motionSpec.js";
612

713
const RFC_SPEC = {
814
duration: 6,
@@ -25,6 +31,21 @@ function tempDir(prefix: string): string {
2531
return dir;
2632
}
2733

34+
describe("findNestedMotionSpecs", () => {
35+
it("reports sidecars next to sub-compositions but not the root sidecar", () => {
36+
const dir = tempDir("hf-motion-nested-");
37+
mkdirSync(join(dir, "compositions"));
38+
writeFileSync(join(dir, "index.motion.json"), "{}");
39+
writeFileSync(join(dir, "compositions", "scene-a.motion.json"), "{}");
40+
writeFileSync(join(dir, "compositions", "scene-b.motion.json"), "{}");
41+
42+
expect(findNestedMotionSpecs(dir)).toEqual([
43+
join(dir, "compositions", "scene-a.motion.json"),
44+
join(dir, "compositions", "scene-b.motion.json"),
45+
]);
46+
});
47+
});
48+
2849
describe("parseMotionSpec", () => {
2950
it("parses the RFC four-assertion spec", () => {
3051
const spec = expectOk(parseMotionSpec(RFC_SPEC));

‎packages/cli/src/utils/motionSpec.ts‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { existsSync, readdirSync } from "node:fs";
22
import { readJsonFileText } from "./jsonFlag.js";
3-
import { basename, join } from "node:path";
3+
import { basename, dirname, join } from "node:path";
44

55
/**
66
* Declarative motion-verification spec (issue #1437). A sidecar JSON file
@@ -140,3 +140,31 @@ export function readMotionSpec(path: string): MotionSpecParse {
140140
}
141141
return parseMotionSpec(raw);
142142
}
143+
144+
/** Sidecars below the project root; findMotionSpec reads only the entry composition's. */
145+
export function findNestedMotionSpecs(projectDir: string): string[] {
146+
if (!existsSync(projectDir)) return [];
147+
const found: string[] = [];
148+
const pending = [projectDir];
149+
while (pending.length > 0) {
150+
const dir = pending.pop()!;
151+
let entries;
152+
try {
153+
entries = readdirSync(dir, { withFileTypes: true });
154+
} catch {
155+
continue;
156+
}
157+
for (const entry of entries) {
158+
if (entry.isDirectory()) {
159+
if (isSearchableDir(entry.name)) pending.push(join(dir, entry.name));
160+
} else if (entry.isFile() && entry.name.endsWith(".motion.json")) {
161+
found.push(join(dir, entry.name));
162+
}
163+
}
164+
}
165+
return found.filter((path) => dirname(path) !== projectDir).sort();
166+
}
167+
168+
function isSearchableDir(name: string): boolean {
169+
return name !== "node_modules" && name !== "dist" && !name.startsWith(".");
170+
}

‎skills-manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"files": 81
1111
},
1212
"hyperframes-cli": {
13-
"hash": "132e56038dbd2365",
13+
"hash": "f86f298c79ec6a41",
1414
"files": 14
1515
},
1616
"hyperframes-registry": {

‎skills/hyperframes-cli/references/lint-validate-inspect.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ npx hyperframes check --frame-check # media (img/svg/video/canvas) out-of-fr
9191

9292
`check` verifies **motion intent** against the same seeked timeline the renderer uses — the closest automated proxy for "render the MP4 and watch it". It catches render-vs-preview bugs layout sampling can't: an entrance reveal the seek lands past, a broken stagger order, an element drifting off-frame mid-tween, a frozen shot.
9393

94-
Drop a `*.motion.json` sidecar next to the composition (matching the html basename when several compositions share a dir). `check` discovers it automatically — no flag, no authoring-framework changes. With no sidecar, `check` behaves exactly as before.
94+
Drop a `*.motion.json` sidecar next to the entry composition (`index.html`). When several compositions share the project root, the basename picks the matching composition. `check` discovers it automatically — no flag, no authoring-framework changes. Sidecars next to sub-compositions are currently reported as ignored warnings rather than evaluated, because selectors and assertion times are root-timeline relative; keep those assertions in the entry composition's sidecar. With no sidecar, `check` behaves exactly as before.
9595

9696
```json
9797
{

0 commit comments

Comments
 (0)