style: collapse multi-line comments to single lines

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
xuanru
2026-07-25 08:15:03 +00:00
co-authored by Claude Opus 4.8
parent 5f111609e8
commit 1ba459a0da
8 changed files with 16 additions and 96 deletions
@@ -379,10 +379,7 @@ describe("installPageFunctionGuard", () => {
describe("DENSE_GEOMETRY_SEEK_OPTIONS", () => {
it("is genuinely geometry-only — no post-seek settle waits at the 600-sample cap", () => {
// Regression for the dense content_overlap grid: geometry (getBoundingClientRect)
// is valid synchronously after setTime, so the dense pass must NOT inherit AUDIT's
// rAF settle / font wait / paint sleep — those multiply by sample count into tens of
// seconds. Any future edit that reintroduces a wait here must fail this test.
// Dense pass must not inherit AUDIT's post-seek waits — geometry is valid synchronously after setTime, and waits multiply by sample count.
expect(DENSE_GEOMETRY_SEEK_OPTIONS.animationFrameSettle).toBe("none");
expect(DENSE_GEOMETRY_SEEK_OPTIONS.waitForFontsMs).toBe(0);
expect(DENSE_GEOMETRY_SEEK_OPTIONS.settleMs).toBe(0);
@@ -18,15 +18,7 @@ export const AUDIT_SEEK_OPTIONS = {
settleMs: 120,
} as const;
// Genuinely geometry-only variant for the dense content_overlap re-sampling
// grid. It keeps only the timeline setTime + preferred-target seek cascade and
// drops EVERY post-seek wait — no rAF settle, no font wait, no paint-settle
// sleep — because getBoundingClientRect geometry is valid synchronously once
// GSAP has written the inline transforms at setTime; a geometry-only reader
// never paints, so it needs none of the visual-stability waits. At up to
// OVERLAP_MAX_SAMPLES seeks the full AUDIT settle (double rAF + up to 500ms
// font wait + 120ms sleep) is ~30s of frame waits + ~72s of sleep with no DOM
// work; this variant eliminates all of it.
// Geometry-only seek for the dense content_overlap grid: getBoundingClientRect is valid synchronously after setTime, so drop all post-seek waits (rAF/font/sleep) that would multiply across the dense grid.
export const DENSE_GEOMETRY_SEEK_OPTIONS = {
...AUDIT_SEEK_OPTIONS,
animationFrameSettle: "none",
+2 -6
View File
@@ -1347,9 +1347,7 @@ describe("contrast candidate round-trip", () => {
});
describe("dense motion-overlap re-sampling", () => {
// The default grid is 9 base samples at index+0.5 (0.5,1.5,...,8.5) over a 9s
// composition; the collision below lives entirely inside (3.5, 4.5), a gap
// the sparse grid seeks straight past. Only the 8fps dense pass observes it.
// Collision lives inside (3.5, 4.5), a gap the sparse base grid seeks past; only the 8fps dense pass observes it.
const inBetweenGridWindow = (time: number): boolean => time >= 3.6 && time <= 4.4;
it("detects a content_overlap that occurs ONLY between two sparse grid samples", async () => {
@@ -1371,9 +1369,7 @@ describe("dense motion-overlap re-sampling", () => {
});
it("runs the dense pass even when sparse fingerprints are identical (aliased motion)", async () => {
// A constant geometry fingerprint no longer suppresses the pass: an
// animation aliased to the sparse grid has identical fingerprints yet still
// collides between samples — the false-negative the removed gate caused.
// Aliased motion has identical fingerprints yet still collides between samples — the false-negative the removed gate caused.
const driver = fakeDriver({
collectLayoutGeometry: vi.fn(async () => "static"),
collectLayout: vi.fn(async (_time: number) => []),
@@ -1425,11 +1425,7 @@
return issues;
};
// content_overlap only, for the dense motion re-sampling grid (checkPipeline
// collectMotionOverlapSamples). Two free-positioned text blocks crossing mid-orbit
// collide for a fraction of a second the sparse layout grid seeks straight
// past; this reruns just the overlap detector — same collectSolidTextBlocks /
// overlapIssue 0.2-area threshold, no new detection surface — on a fine grid.
// Reruns only the overlap detector (same threshold, no new surface) on a fine grid for the dense motion re-sampling pass.
window.__hyperframesOverlapAudit = function auditOverlap(options) {
const time = options && typeof options.time === "number" ? options.time : 0;
const root =
+4 -35
View File
@@ -421,19 +421,9 @@ async function collectGridSamples(
return collected;
}
// content_overlap sampling density for the dense motion re-pass. The sparse
// layout grid (default 9 points over multiple seconds) seeks straight past a
// mid-orbit text-on-text crossing that only overlaps for a fraction of a
// second: an in-corpus orbit (samples/fuzz016) collides at 28% area for ~0.4s,
// entirely between two adjacent base samples. 8fps (~0.125s spacing) lands
// enough samples inside a window that narrow to observe it. Overlap collection
// is text-only (collectSolidTextBlocks), far cheaper than a full layout audit,
// so a fine grid here is affordable where densifying every detector would not.
// Dense grid catches mid-motion text collisions the sparse layout grid seeks past; text-only overlap collection is cheap enough to afford it.
const OVERLAP_SAMPLE_FPS = 8;
// Absolute ceiling on dense seeks so the pass stays bounded. This holds a true
// 8fps grid for compositions up to OVERLAP_MAX_SAMPLES / OVERLAP_SAMPLE_FPS
// (~75s); longer compositions degrade below 8fps rather than growing the seek
// budget without limit. (Corpus compositions run 7-8s, well inside 8fps.)
// Ceiling that bounds dense seeks; past ~75s the grid degrades below 8fps rather than growing the seek budget without limit.
const OVERLAP_MAX_SAMPLES = 600;
function buildOverlapSampleTimes(duration: number): number[] {
@@ -448,23 +438,7 @@ function buildOverlapSampleTimes(duration: number): number[] {
);
}
/**
* Dense motion-overlap re-sampling. Reruns ONLY content_overlap on a fine time
* grid so transient text collisions during continuous motion are observed at
* all — the detector itself is unchanged (same 0.2-area threshold), only the
* sampling density is.
*
* This runs UNCONDITIONALLY (bounded + text-only), NOT gated on sparse-grid
* geometry fingerprints changing. That gate was the motivating false-negative:
* an animation aliased to the sparse grid (the same pose sampled at every base
* point) has identical fingerprints yet still collides *between* those samples,
* so gating on fingerprint change skipped the exact transient this pass exists
* to catch. A static composition simply yields no overlaps at the extra times,
* so the only cost of running always is a bounded set of cheap text-only seeks.
* Findings feed the existing collapse/persistence tiering (a graze stays info,
* a held collision re-promotes to error). Skips times already in the base grid
* to avoid double-collecting overlaps collectLayout already found.
*/
/** Reruns content_overlap on a fine grid, unconditionally rather than gated on fingerprint change, since an animation aliased to the sparse grid collides between identical-fingerprint samples. */
async function collectMotionOverlapSamples(
driver: CheckAuditDriver,
grid: SampleGrid,
@@ -473,12 +447,7 @@ async function collectMotionOverlapSamples(
const baseTimes = new Set(grid.layoutSamples);
for (const time of buildOverlapSampleTimes(grid.duration)) {
if (baseTimes.has(time)) continue;
// Settle-free seek: collectOverlap reads getBoundingClientRect geometry
// only, which is valid synchronously after the timeline setTime (GSAP
// writes inline transforms synchronously). The dense pass makes up to
// OVERLAP_MAX_SAMPLES seeks, so skipping the 120ms per-seek paint settle
// here (vs. the full-settle driver.seek the base grid uses to feed
// contrast/rotation/frame checks) removes ~72s of pure sleep at the ceiling.
// Settle-free seek: collectOverlap reads getBoundingClientRect geometry, valid synchronously after setTime, so the dense pass skips the per-seek paint settle.
await driver.seekGeometry(time);
collected.layoutIssues.push(...(await driver.collectOverlap(time)));
}
+2 -7
View File
@@ -173,15 +173,10 @@ export interface CheckAuditDriver {
getCanvas(): Promise<Canvas>;
findAmbiguousSelectors(selectors: string[]): Promise<AnchoredLayoutIssue[]>;
seek(time: number): Promise<void>;
/** Cheap settle-free seek for the geometry-only dense content_overlap pass:
* setTime + timeline seek with no paint-settle sleep. Only collectOverlap
* (getBoundingClientRect geometry) consumes the result, which is valid
* synchronously after setTime — see checkPipeline collectMotionOverlapSamples. */
/** Settle-free seek for the geometry-only dense content_overlap pass; only collectOverlap consumes it, and getBoundingClientRect is valid synchronously after setTime. */
seekGeometry(time: number): Promise<void>;
collectLayout(time: number, tolerance: number): Promise<AnchoredLayoutIssue[]>;
/** content_overlap only, for the dense motion re-sampling grid — catches
* transient text-on-text collisions the sparse layout grid seeks past. See
* checkPipeline detectMotionTextOverlap. */
/** content_overlap only, for the dense re-sampling grid — catches transient text collisions the sparse grid seeks past. */
collectOverlap(time: number): Promise<AnchoredLayoutIssue[]>;
/** Frozen-sweep guard (#U10): an opaque per-sample geometry+opacity
* fingerprint of the current seeked state, for detecting a timeline that
+2 -5
View File
@@ -228,8 +228,7 @@ describe("persistence-tiered severity (#U10)", () => {
});
it("keeps a content_overlap that spans under the 500ms floor as a warning, even with 2 occurrences", () => {
// Two occurrences from the dense 8fps re-pass span only ~125ms — under the
// held-duration floor, so occurrences>=2 alone must NOT promote to error.
// Two dense-pass occurrences ~125ms apart are under the held-duration floor, so occurrences>=2 alone must not promote to error.
const collapsed = collapseStaticLayoutIssues(
[
{ ...issue("content_overlap", "warning"), time: 4.0 },
@@ -243,9 +242,7 @@ describe("persistence-tiered severity (#U10)", () => {
});
it("does NOT promote content_overlap whose two occurrences span exactly 499ms (under the floor)", () => {
// Boundary: a two-occurrence span one millisecond short of the 500ms floor
// stays a warning. Guards the AND-tighten for sparse callers (--samples 20,
// --at, short comps) whose two samples can land <500ms apart.
// Boundary: a span one millisecond short of the 500ms floor stays a warning — guards the AND-tighten for sparse callers.
const collapsed = collapseStaticLayoutIssues(
[
{ ...issue("content_overlap", "warning"), time: 4.0 },
+3 -25
View File
@@ -181,25 +181,7 @@ export function dedupeLayoutIssues(issues: LayoutIssue[]): LayoutIssue[] {
return result;
}
// Persistence-tier thresholds (#U10, adapted from Adam Rosler's visual-linter
// design). The approach doc frames these as held-duration floors — ignore
// under ~250ms, re-promote content_overlap at >= ~500ms — measured against the
// SAME firstSeen/lastSeen span this collapse step already tracks. `occurrences`
// is a NECESSARY guard (one sample can't span any duration), but it is NOT a
// sufficient proxy for the 500ms floor: the dense content_overlap re-pass
// (checkPipeline collectMotionOverlapSamples) samples at 8fps, so two adjacent
// occurrences there span only ~125ms — the old "occurrences >= 2 => held >=
// 500ms" shortcut held only for the coarse ~1s-spaced base grid and breaks
// under dense sampling. content_overlap promotion therefore requires BOTH
// occurrences >= 2 AND a literal firstSeen..lastSeen span >= 500ms, so the
// wall-clock floor is honored regardless of sampling density. The ~250ms
// ignore floor needs no separate constant — see the occurrences <= 1 branch.
//
// SEMANTICS CHANGE (intentional): this is stricter than the prior
// occurrences >= 2 => error rule for SPARSE callers too, not only the dense
// pass. Under `--samples 20`, `--at`, or a short composition, two adjacent
// samples can land < 500ms apart; such a pair now stays a warning instead of
// auto-promoting to error. Only a genuinely held (>= 500ms) collision promotes.
// Persistence-tier thresholds (#U10): occurrences>=2 alone can't imply the 500ms floor under dense 8fps sampling, so content_overlap promotion requires a literal firstSeen..lastSeen span >= 500ms — stricter for sparse callers too.
const CONTENT_OVERLAP_HELD_ERROR_MS = 500;
const HELD_ACROSS_SAMPLES_MIN_OCCURRENCES = 2;
@@ -321,13 +303,9 @@ function isCanvasBreachHeldLarge(issue: LayoutIssue, occurrences: number): boole
return overlapX > 0 && overlapY > 0;
}
// Split out of applyPersistenceTier so the compound "held long enough" test
// (>= 2 samples AND wall-clock span >= the ms floor) reads as one boolean
// question instead of adding a compound branch to the tiering ladder above.
// Split out of applyPersistenceTier so the compound "held long enough" test reads as one boolean question.
function isContentOverlapHeldLongEnough(issue: LayoutIssue, occurrences: number): boolean {
// Need at least two samples to measure a span at all, AND that span must
// clear the wall-clock floor — dense 8fps re-sampling makes occurrences>=2
// alone (potentially ~125ms) too weak to imply a genuinely held collision.
// Two samples measure a span, but under dense 8fps sampling that span must still clear the wall-clock floor.
if (occurrences < HELD_ACROSS_SAMPLES_MIN_OCCURRENCES) return false;
const firstSeen = issue.firstSeen ?? issue.time;
const lastSeen = issue.lastSeen ?? issue.time;