Files
raea/engine/cli/src/held.ts
shinyobjectz 8f92302403 SG10, SG12, SG13, SG14, SG15: raea render holds its 3D to type that reads, parts that don't snap, a camera that settles and a composed frame, and raea show won't post a render that still holds an error
raea-sys-stage (systems/stage) reads every frame's parts through its camera at the end of every render, beside the
clipping check: RichText too small or turned too far to read, a reveal that never starts or never finishes, words not
held long enough to read (SG10); a part's size on screen jumping in one frame, and a line built as a growing chain of
parts (SG12); a camera whose speed kinks or that goes in and back out within 1.5 s (SG13); frames with almost nothing
on screen, and the shot's subject cut by the edge (SG14). RichText read={false} leaves scenery out. raea scene stage
runs the same checks without drawing; raea scene moved from raea-runtime-export into raea-app-scene so the export crate
keeps room under its 2,000 lines.

Calibrated on the mobile-ads film (13,174 frames) and 33 clean scenes: the snap check as first written said 1,446
errors on the film and 1,252 on four clean scenes, and the lurch check 48 on Stay from f32 acos noise; what was left
out is each a measured false error (pop-ins, shared names, layout edits, parts over 6 m, speeds under what can be
seen, the gap between two long moves). The film now holds 375 errors (lurches at its spline's keys, labels at 60-75
degrees, code at 3-7 px); no type or snap error on the clean scenes.

raea show refuses a file whose newest render in its project's record holds an error it wasn't let through with,
naming each (engine/cli/src/held.ts); --despite CHECK "why" passes one and the why goes on the item. A still stepped
alone (raea check --quick, render --at) is judged for what a still shows, never for reveals or reading time.
2026-11-21 19:09:56 -08:00

86 lines
4.1 KiB
TypeScript

// A render that still holds an error isn't shown (docs/stage-guards.feature SG15). raea render exits 1 on an error and
// keeps its findings in the project's record (core/facts/src/record.rs: one file a render, in the project's own .raea
// folder), but the file it wrote is still there to post. raea show looks each file up: the newest render that wrote
// it, and that render's errors less those it was let through with (raea render --despite) and those raea show
// --despite CHECK "why" names. What's left refuses the show, each error named; the agent fixes it, or says why it goes
// anyway, and the person reads the why on the item.
/** A check let through, and why. */
export interface Despite {
check: string;
why: string;
}
interface Entry {
at?: number;
by?: string;
out?: string | null;
findings?: { check?: string; level?: string; says?: string }[];
despite?: Despite[];
}
/** What it reads the record through (app.ts's Here): a file's text, whether a path exists, a folder's names. */
export interface Records {
exists: (path: string) => boolean;
read: (path: string) => string;
list?: (dir: string) => string[];
}
const slashed = (p: string) => p.replace(/\\/g, "/").replace(/\/+$/, "");
const up = (p: string) => p.slice(0, Math.max(0, p.lastIndexOf("/")));
const rooted = (p: string) => p.startsWith("/") || /^[A-Za-z]:\//.test(p);
/** The nearest folder at or above `from` holding .raea/project (as the record's own up() finds it). */
function projectAbove(from: string, h: Records): string | undefined {
for (let d = slashed(from); d; d = up(d)) if (h.exists(`${d}/.raea/project`)) return d;
return undefined;
}
function entries(project: string, h: Records): Entry[] {
// the project's own .raea, never ~/.raea
const own = `${project}/.raea`;
const dir = `${own}/record`;
if (!h.list || !h.exists(dir)) return [];
return h.list(dir).filter((n) => n.endsWith(".json")).flatMap((n) => {
try {
return [JSON.parse(h.read(`${dir}/${n}`)) as Entry];
} catch {
return []; // a half-written entry is no render's
}
});
}
/** Each file's open errors, as "FILE: CHECK: what it says": none for a file no render in its project wrote. */
export function openErrors(files: string[], cwd: string, despite: Despite[], h: Records): string[] {
const out: string[] = [];
const read = new Map<string, Entry[]>();
for (const file of files.map(slashed)) {
const project = projectAbove(up(file), h) ?? projectAbove(cwd, h);
if (!project) continue;
if (!read.has(project)) read.set(project, entries(project, h));
const wrote = (e: Entry) => {
if (e.by !== "raea render" || !e.out) return false;
const o = slashed(rooted(slashed(e.out)) ? e.out : `${project}/${e.out}`);
return file === o || file.startsWith(`${o}/`);
};
const last = read.get(project)!.filter(wrote).sort((a, b) => (b.at ?? 0) - (a.at ?? 0))[0];
if (!last) continue;
const let_ = new Set([...(last.despite ?? []), ...despite].map((d) => d.check));
const name = file.slice(up(file).length + 1);
for (const f of last.findings ?? []) if (f.level === "error" && f.check && !let_.has(f.check)) out.push(`${name}: ${f.check}: ${f.says ?? ""}`);
}
return out;
}
/** The refusal, or nothing when every file is clear. */
export function held(files: string[], cwd: string, despite: Despite[], h: Records): string | undefined {
const open = openErrors(files, cwd, despite, h);
if (!open.length) return undefined;
const checks = [...new Set(open.map((l) => l.split(": ")[1]))];
return `not shown: the render still holds ${open.length === 1 ? "an error" : `${open.length} errors`} (raea findings --open):\n ${open.slice(0, 12).join("\n ")}${open.length > 12 ? `\n and ${open.length - 12} more` : ""}\nfix ${open.length === 1 ? "it" : "them"} and render again, or say why it goes anyway: ${checks.map((c) => `--despite ${c} "why"`).join(" ")} (the person reads the why on the item)`;
}
/** The ask line the person reads, with what was let through and why. */
export const askWith = (ask: string | undefined, despite: Despite[]) =>
[ask, ...despite.map((d) => `let through: ${d.check}, ${d.why}`)].filter(Boolean).join(" · ") || undefined;