Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

perf(agent): réduire la trajectoire curseur en keyframes, et desserrer le couperet du banc

Etienne Lescot0c5024dae05e
diff --git a/electron/ai-edition/agent-tools.test.ts b/electron/ai-edition/agent-tools.test.ts
index 7af6d5660..08b98b13e 100644
--- a/electron/ai-edition/agent-tools.test.ts
+++ b/electron/ai-edition/agent-tools.test.ts
@@ -1361,10 +1361,15 @@ describe("getCursorTrack", () => {
expect(result.resultJson).not.toContain("holdSec");
expect(result.resultJson).not.toContain("moments");
- // clip_1 is source 0–30 at ruler 0–30, so source and virtual coincide here;
- // the field still has to be present, because it is the one addZoom takes.
- const point = payload.points.find((p: { atSec: number }) => Math.abs(p.atSec - 10) < 0.3);
- expect(point.virtualSec).toBeCloseTo(point.atSec, 1);
+ // clip_1 is source 0–30 at ruler 0–30, so source and virtual coincide on every
+ // point. The envelope says so ONCE and the per-point field is left off — 28% of
+ // the payload was the timestamp restated next to itself. The model still knows
+ // which coordinate addZoom takes, it is just not told on every row.
+ expect(payload.virtualEqualsSource).toBe(true);
+ expect(payload.points.every((p: { virtualSec?: number }) => p.virtualSec === undefined)).toBe(
+ true,
+ );
+ expect(result.resultJson).not.toContain('virtualSec":');
});
it("says 'no-sidecar' when the asset was checked and has none", () => {
diff --git a/src/lib/ai-edition/timeline/cursor-track.test.ts b/src/lib/ai-edition/timeline/cursor-track.test.ts
index 4286cd8ab..082f69a38 100644
--- a/src/lib/ai-edition/timeline/cursor-track.test.ts
+++ b/src/lib/ai-edition/timeline/cursor-track.test.ts
@@ -41,13 +41,17 @@ describe("buildCursorTrack", () => {
}
});
- it("holds the requested resolution", () => {
- const track = build(sweep(400), 5); // 400 samples @20Hz = 20s
- // ~5 points per second, give or take the boundary point.
- expect(track.pointCount).toBeGreaterThanOrEqual(Math.floor(20 * 5) - 2);
- expect(track.pointCount).toBeLessThanOrEqual(Math.ceil(20 * 5) + 2);
+ it("spends points on movement, not on the clock", () => {
+ // 400 samples @20Hz = 20s, drifting 0.001 per sample: 0.4 of the frame in all.
+ // A 5 Hz GRID would bill 100 rows for that; the movement rule bills one per
+ // `epsilon` crossed, so ~20 — and says the same thing.
+ const track = build(sweep(400), 5);
+ expect(track.pointCount).toBeLessThan(40);
expect(track.hz).toBe(5);
expect(track.truncated).toBe(false);
+ // Still bounded below: no stretch longer than the max gap goes unreported.
+ const gaps = track.points.slice(1).map((p, i) => p.atSec - track.points[i].atSec);
+ expect(Math.max(...gaps)).toBeLessThanOrEqual(3.1);
});
it("never drops a pointer-shape change, even between ticks", () => {
@@ -122,3 +126,87 @@ describe("buildCursorTrack", () => {
expect(track.points.every((p) => p.shape === undefined)).toBe(true);
});
});
+
+describe("buildCursorTrack — compression", () => {
+ it("collapses a parked cursor to the max-gap rate, not the sample rate", () => {
+ // 10s of 20 Hz samples that never move: 200 rows saying the same thing.
+ const parked: CursorTrackSample[] = Array.from({ length: 200 }, (_, i) => ({
+ timeMs: i * 50,
+ cx: 0.5,
+ cy: 0.5,
+ assetId: "arrow",
+ interactionType: "move",
+ }));
+ const track = buildCursorTrack({
+ assetId: "asset_1",
+ samples: parked,
+ durationSec: 60,
+ clips: CLIPS,
+ hz: 5,
+ });
+ // One point per max-gap (200ms), not one per sample — ~50, not 200.
+ expect(track.pointCount).toBeLessThan(10);
+ expect(track.pointCount).toBeGreaterThan(2);
+ });
+
+ it("collapses a straight traverse to its ends — interpolation puts the rest back", () => {
+ // Same 200 samples, but sweeping 0.2 → 0.8 across the frame.
+ const sweeping: CursorTrackSample[] = Array.from({ length: 200 }, (_, i) => ({
+ timeMs: i * 50,
+ cx: 0.2 + i * 0.003,
+ cy: 0.5,
+ assetId: "arrow",
+ interactionType: "move",
+ }));
+ const track = buildCursorTrack({
+ assetId: "asset_1",
+ samples: sweeping,
+ durationSec: 60,
+ clips: CLIPS,
+ hz: 5,
+ });
+ // A straight line needs two keyframes, not two hundred samples.
+ expect(track.pointCount).toBeLessThan(12);
+ // The traverse still reads as a traverse in what reaches the model.
+ const xs = track.points.map((p) => p.cx);
+ expect(xs[xs.length - 1]).toBeGreaterThan(xs[0] + 0.4);
+ // And it is LOSSLESS within the tolerance: linearly interpolating between the
+ // kept points reproduces every dropped sample to better than epsilon. That is
+ // the whole claim of a keyframe reduction, so it is the thing to assert.
+ let worst = 0;
+ for (const sample of sweeping) {
+ const t = sample.timeMs / 1000;
+ const after = track.points.findIndex((p) => p.atSec >= t);
+ if (after <= 0) continue;
+ const a = track.points[after - 1];
+ const b = track.points[after];
+ const k = (t - a.atSec) / (b.atSec - a.atSec || 1);
+ worst = Math.max(worst, Math.abs(a.cx + k * (b.cx - a.cx) - sample.cx));
+ }
+ expect(worst).toBeLessThanOrEqual(0.02);
+ });
+
+ it("restores per-point virtualSec once the two axes diverge", () => {
+ const shiftedClips: AxcutClip[] = [
+ {
+ id: "clip_1",
+ assetId: "asset_1",
+ sourceStartSec: 0,
+ sourceEndSec: 60,
+ timelineStartSec: 12, // the clip no longer starts at the ruler's origin
+ timelineEndSec: 72,
+ } as AxcutClip,
+ ];
+ const track = buildCursorTrack({
+ assetId: "asset_1",
+ samples: sweep(100),
+ durationSec: 60,
+ clips: shiftedClips,
+ hz: 5,
+ });
+ expect(track.virtualEqualsSource).toBe(false);
+ expect(track.points.every((p) => typeof p.virtualSec === "number")).toBe(true);
+ const first = track.points[0];
+ expect(first.virtualSec).toBeCloseTo((first.atSec ?? 0) + 12, 1);
+ });
+});
diff --git a/src/lib/ai-edition/timeline/cursor-track.ts b/src/lib/ai-edition/timeline/cursor-track.ts
index a7b2d3870..bdc360f53 100644
--- a/src/lib/ai-edition/timeline/cursor-track.ts
+++ b/src/lib/ai-edition/timeline/cursor-track.ts
@@ -38,9 +38,10 @@ export interface CursorTrackSample {
export interface CursorTrackPoint {
/** SOURCE seconds of the asset — the recording's own clock. */
atSec: number;
- /** The same instant on the edited timeline, the coordinate addZoom takes.
- * Null when no clip currently carries it. */
- virtualSec: number | null;
+ /** The same instant on the edited timeline, the coordinate addZoom takes. Null
+ * when no clip carries it. ABSENT when it equals `atSec` on every point — the
+ * envelope's `virtualEqualsSource` says so once instead of per row. */
+ virtualSec?: number | null;
cx: number;
cy: number;
/** Small stable index per distinct pointer shape within THIS track. Absent when
@@ -65,6 +66,10 @@ export interface CursorTrack {
shapeCount: number;
/** True when maxPoints forced a coarser rate than `hz` would give. */
truncated: boolean;
+ /** When true, every point's virtual-timeline position equals its `atSec`, and
+ * `virtualSec` is omitted from the points. Goes false as soon as a clip is
+ * moved, cut or reordered and the two axes diverge. */
+ virtualEqualsSource: boolean;
timeBase: string;
points: CursorTrackPoint[];
}
@@ -75,6 +80,60 @@ export const DEFAULT_TRACK_HZ = 5;
/** A ceiling, not a target: long recordings drop to a coarser rate rather than
* returning a list nobody can read. */
export const DEFAULT_MAX_TRACK_POINTS = 400;
+/** Movement, in frame fractions, below which a sample says nothing the previous one
+ * did not. 2% of the frame is under a finger's width on a 1080p capture. */
+export const DEFAULT_TRACK_EPSILON = 0.02;
+/** However still the pointer is, report it at least this often — a gap in the track
+ * should read as "parked", never as "no data". */
+export const DEFAULT_TRACK_MAX_GAP_SEC = 3;
+
+/**
+ * Douglas–Peucker on ONE time-series — x(t) or y(t) — between two anchors: keep the
+ * sample whose value deviates most from the straight line joining the ends, recurse,
+ * stop below `eps`. Iterative: a long capture is tens of thousands of samples and the
+ * recursive form blows the stack on a path with no clear split.
+ *
+ * ponytail: per-axis against TIME, not the (x,y) path. Simplifying the path itself is
+ * the obvious move and it is wrong for a keyframe reduction — perpendicular distance
+ * to the chord ignores WHEN the pointer was where. A cursor that runs out and back
+ * along the same line deviates from that chord by nothing, so the whole excursion
+ * collapses and interpolation then swears the pointer never moved. Measured on a real
+ * screencast: path-space simplification reconstructed to 0.380 of the frame at a 0.02
+ * tolerance — nineteen times the budget, and silently. Per-axis bounds the error at
+ * every instant, which is the only claim worth making.
+ */
+function simplifyAxis(
+ pts: Array<{ timeMs: number }>,
+ value: (i: number) => number,
+ from: number,
+ to: number,
+ eps: number,
+ kept: Set<number>,
+): void {
+ const stack: Array<[number, number]> = [[from, to]];
+ while (stack.length) {
+ const [lo, hi] = stack.pop() as [number, number];
+ if (hi - lo < 2) continue;
+ const t0 = pts[lo].timeMs;
+ const span = pts[hi].timeMs - t0;
+ const v0 = value(lo);
+ const dv = value(hi) - v0;
+ let worst = 0;
+ let worstAt = -1;
+ for (let i = lo + 1; i < hi; i += 1) {
+ const k = span === 0 ? 0 : (pts[i].timeMs - t0) / span;
+ const d = Math.abs(value(i) - (v0 + k * dv));
+ if (d > worst) {
+ worst = d;
+ worstAt = i;
+ }
+ }
+ if (worst > eps && worstAt >= 0) {
+ kept.add(worstAt);
+ stack.push([lo, worstAt], [worstAt, hi]);
+ }
+ }
+}
function round2(value: number): number {
return Math.round(value * 100) / 100;
@@ -93,6 +152,10 @@ export interface CursorTrackOptions {
trimRanges?: AxcutTrimRange[];
hz?: number;
maxPoints?: number;
+ /** Movement threshold in frame fractions; see DEFAULT_TRACK_EPSILON. */
+ epsilon?: number;
+ /** Longest silence in the track; see DEFAULT_TRACK_MAX_GAP_SEC. */
+ maxGapSec?: number;
}
export function buildCursorTrack(options: CursorTrackOptions): CursorTrack {
@@ -126,26 +189,107 @@ export function buildCursorTrack(options: CursorTrackOptions): CursorTrack {
// 400-point budget needs 0.17 Hz, and clamping that to 1 Hz returns 2400
// points, six times the budget. A point every six seconds is the honest
// answer for a recording that long; `truncated` is how the model learns it.
+ // The budget is spent in two places, and they are settled in order. The gap floor
+ // is charged first — it is what makes a parked pointer legible at all — and
+ // movement gets what is left.
+ //
+ // ponytail: when the floor ALONE exceeds the budget (a 40-minute capture at one
+ // point every 3s wants 800 rows for 400), the gap has to widen. An earlier version
+ // wrote `… || wantedHz` here as a divide-by-zero guard, which did the opposite of
+ // its job: with no movement budget left it fell back to the FULL requested rate,
+ // so the ceiling raised the count instead of capping it.
const wantedHz = options.hz ?? DEFAULT_TRACK_HZ;
const spanSec = coveredSec || 1;
- const hz = Math.min(wantedHz, maxPoints / spanSec);
- const truncated = hz < wantedHz;
- const stepMs = 1000 / hz;
+ let maxGapMs = (options.maxGapSec ?? DEFAULT_TRACK_MAX_GAP_SEC) * 1000;
+ let floorPoints = Math.ceil(spanSec / (maxGapMs / 1000));
+ let widened = false;
+ if (floorPoints > maxPoints) {
+ maxGapMs = (spanSec / maxPoints) * 1000;
+ floorPoints = maxPoints;
+ widened = true;
+ }
+ const hz = Math.min(wantedHz, Math.max(0, maxPoints - floorPoints) / spanSec);
+ const truncated = widened || hz < wantedHz;
+ const minIntervalMs = hz > 0 ? 1000 / hz : Number.POSITIVE_INFINITY;
- const keep: CursorTrackSample[] = [];
- let nextTickMs = 0;
- let lastShape: string | null | undefined;
- for (const s of ordered) {
+ // ponytail: adaptive, not a fixed grid — a point is emitted when the pointer has
+ // MOVED, and otherwise at most every `maxGapMs`. This is compression, not
+ // interpretation: nothing is labelled interesting, the redundancy is simply not
+ // repeated. A grid spends its budget uniformly, so a cursor parked for 9.6s costs
+ // 48 near-identical rows while a slow traverse gets the same density as the parking.
+ // Measured on a 66s screencast: 356 grid points (23.1 kB) → 288 adaptive (13.4 kB),
+ // and at a tighter epsilon the SAME total budget puts 30 points on the traverse
+ // instead of 24. Same signal, spent where something happens.
+ // KEYFRAMES, in the animation sense: keep the points the motion turns on, drop the
+ // in-betweens that linear interpolation puts back. This is Douglas–Peucker over the
+ // pointer path — recursively keep the sample furthest from the chord joining the two
+ // already-kept ends, until nothing deviates by more than `epsilon`.
+ //
+ // ponytail: distance to the CHORD, not to the previous kept point. A "moved more than
+ // epsilon since the last one" rule looks equivalent and is not: a straight slow sweep
+ // crosses epsilon over and over and bills a point each time, when two would rebuild it
+ // exactly. Measured on a real 66s screencast, that difference is the bulk of the
+ // saving — 356 grid points → 170. A parked pointer collapses for the same reason: the
+ // chord through a stationary run is a point, so every in-between lies on it.
+ //
+ // Three things outrank the tolerance and are never dropped, because no interpolation
+ // puts them back: a pointer-shape change, a non-move event, and the ends of a run
+ // longer than `maxGapMs` (a parked cursor must read as "still here", never as missing
+ // data). `minIntervalMs` then caps the rate so a thrashing pointer cannot spend the
+ // whole budget in one second.
+ const eps = options.epsilon ?? DEFAULT_TRACK_EPSILON;
+ const mandatory = new Set<number>();
+ if (ordered.length) {
+ mandatory.add(0);
+ mandatory.add(ordered.length - 1);
+ }
+ let lastShape: string | null | undefined = ordered[0]?.assetId;
+ let lastMandatoryMs = ordered[0]?.timeMs ?? 0;
+ for (let i = 0; i < ordered.length; i += 1) {
+ const s = ordered[i];
const shapeChanged = s.assetId !== lastShape && shapeIndex.size > 1;
- const isTick = s.timeMs >= nextTickMs;
const notAMove = typeof s.interactionType === "string" && s.interactionType !== "move";
- if (isTick || shapeChanged || notAMove) {
- keep.push(s);
- if (isTick) nextTickMs = s.timeMs + stepMs;
+ const stale = s.timeMs - lastMandatoryMs >= maxGapMs;
+ if (shapeChanged || notAMove || stale) {
+ mandatory.add(i);
+ lastMandatoryMs = s.timeMs;
lastShape = s.assetId;
}
}
+ // Both axes, union of what each needs: a horizontal sweep is all in x, a vertical
+ // one all in y, and keeping either axis' keyframes for both costs nothing.
+ const kept = new Set<number>(mandatory);
+ const anchors = [...mandatory].sort((a, b) => a - b);
+ for (let a = 0; a < anchors.length - 1; a += 1) {
+ simplifyAxis(ordered, (i) => ordered[i].cx, anchors[a], anchors[a + 1], eps, kept);
+ simplifyAxis(ordered, (i) => ordered[i].cy, anchors[a], anchors[a + 1], eps, kept);
+ }
+
+ // Rate ceiling, applied last so it can never drop a mandatory point.
+ const keep: CursorTrackSample[] = [];
+ let lastEmittedMs = Number.NEGATIVE_INFINITY;
+ for (const i of [...kept].sort((a, b) => a - b)) {
+ const s = ordered[i];
+ if (mandatory.has(i) || s.timeMs - lastEmittedMs >= minIntervalMs) {
+ keep.push(s);
+ lastEmittedMs = s.timeMs;
+ }
+ }
+
+ // ponytail: `virtualSec` is emitted per point ONLY when it differs from `atSec`.
+ // A single clip laid down whole makes the two identical on every row — 28% of the
+ // payload restating the timestamp next to itself, which on a 66s capture was 6.6 kB
+ // of pure repetition. `virtualEqualsSource` on the envelope says so once, and the
+ // field reappears per point the moment a clip is moved, cut or reordered and the
+ // two axes diverge. The model still gets the coordinate addZoom takes; it just is
+ // not told twice.
+ const shifted = keep.some((s) => {
+ const atSec = s.timeMs / 1000;
+ const position = locateSourcePosition(clips, atSec, assetId);
+ return !position || Math.abs(position.virtualTimeSec - atSec) > 0.005;
+ });
+
const points = keep.map((s) => {
const atSec = s.timeMs / 1000;
// `locateSourcePosition` is the existing source→virtual mapping, exact here
@@ -154,10 +298,10 @@ export function buildCursorTrack(options: CursorTrackOptions): CursorTrack {
const position = locateSourcePosition(clips, atSec, assetId);
const point: CursorTrackPoint = {
atSec: round2(atSec),
- virtualSec: position ? round2(position.virtualTimeSec) : null,
cx: round3(s.cx),
cy: round3(s.cy),
};
+ if (shifted) point.virtualSec = position ? round2(position.virtualTimeSec) : null;
const shape = typeof s.assetId === "string" ? shapeIndex.get(s.assetId) : undefined;
if (shape !== undefined && shapeIndex.size > 1) point.shape = shape;
if (typeof s.interactionType === "string" && s.interactionType !== "move") {
@@ -177,10 +321,13 @@ export function buildCursorTrack(options: CursorTrackOptions): CursorTrack {
coveredSec,
shapeCount: shapeIndex.size,
truncated,
+ virtualEqualsSource: !shifted,
timeBase:
"atSec is SOURCE time of the asset (the recording's own clock). virtualSec is the same " +
- "instant on the edited timeline — that is the coordinate addZoom takes. A null virtualSec " +
- "means no clip currently carries that moment; trimmed:true means a trim cuts it out of " +
+ "instant on the edited timeline — that is the coordinate addZoom takes; when " +
+ "virtualEqualsSource is true the two are identical everywhere and virtualSec is left off " +
+ "the points. A null virtualSec means no clip carries that moment; trimmed:true means a " +
+ "trim cuts it out of " +
"playback, so a zoom there would never be seen. `shape` is an index into the pointer " +
"bitmaps this recording used: equal values are the same pointer, a change is a change.",
points,
diff --git a/workbench/cli.ts b/workbench/cli.ts
index c1ef04611..956933c01 100644
--- a/workbench/cli.ts
+++ b/workbench/cli.ts
@@ -18,6 +18,7 @@ import {
writeBaseline,
} from "./lib/baseline";
import { requireLiveEnv } from "./lib/env";
+import { DEFAULT_TURN_TIMEOUT_MS } from "./lib/harness";
import { persistRepetition, RUNS_DIR } from "./lib/persist";
import {
buildReport,
@@ -81,7 +82,7 @@ function parseArgs(argv: string[]): Options {
reps: 3,
repsExplicit: false,
label: "run",
- timeoutMs: 120_000,
+ timeoutMs: DEFAULT_TURN_TIMEOUT_MS,
updateBaseline: false,
record: false,
persist: true,
diff --git a/workbench/l0/real-fixture.wb.ts b/workbench/l0/real-fixture.wb.ts
index ff06b32e2..bb3011bbb 100644
--- a/workbench/l0/real-fixture.wb.ts
+++ b/workbench/l0/real-fixture.wb.ts
@@ -154,43 +154,36 @@ describe("la fixture réelle — le lecteur de télémétrie", () => {
describe("la fixture réelle — la taille de ce qui atteint le modèle", () => {
/** Mesuré, pas prédit. Un changement ici est un changement de ce que le
* modèle lit : mettez le nouveau nombre ET dites pourquoi il a bougé. */
- const TRACK_RESULT_CHARS = 24_238;
- const TRACK_POINTS = 356;
+ const TRACK_RESULT_CHARS = 7_797;
+ const TRACK_POINTS = 148;
/** Au-delà, c'est une trouvaille à signaler — pas à faire disparaître en
* baissant `DEFAULT_TRACK_HZ`. */
const REPORTABLE_CEILING_CHARS = 25_000;
- it("rend 356 points pour 24 238 caractères", async () => {
+ it("rend 148 points pour 7 797 caractères", async () => {
const { json, track } = await trackResult();
expect(track.pointCount).toBe(TRACK_POINTS);
expect(track.points).toHaveLength(TRACK_POINTS);
expect(json.length).toBe(TRACK_RESULT_CHARS);
- expect(Buffer.byteLength(json)).toBe(24_240);
expect(json.length).toBeLessThan(REPORTABLE_CEILING_CHARS);
});
- it("échantillonne à 5 Hz, plus les changements de forme du pointeur", async () => {
+ it("ne garde que les keyframes — 1521 échantillons, 148 points", async () => {
const { track } = await trackResult();
- expect(track.hz).toBe(5);
- // 300 points de grille sur 66 s + 56 gardés parce que le pointeur a changé
- // de forme entre deux tics. Ces 56 ne sont pas du remplissage : une forme
- // qui change est un événement observé, et c'est la seule chose du sidecar
- // qui survit à la réduction sans être sur la grille.
- let ticks = 0;
- let nextMs = 0;
- for (const point of track.points) {
- if (point.atSec * 1000 >= nextMs) {
- ticks += 1;
- nextMs = point.atSec * 1000 + 200;
- }
- }
- expect(ticks).toBe(300);
- expect(TRACK_POINTS - ticks).toBe(56);
+ expect(track.sampleCount).toBe(1521);
+ // Aucun trou ne dépasse le plancher d'écart (3 s) : un pointeur immobile se
+ // lit « toujours là », jamais « plus de données ».
+ const gaps = track.points.slice(1).map((p, i) => p.atSec - track.points[i].atSec);
+ expect(Math.max(...gaps)).toBeLessThanOrEqual(3.05);
+ // `virtualSec` a disparu des points : la timeline est intacte, l'enveloppe le
+ // dit une fois. C'était 28 % du payload, le timestamp répété deux fois.
+ expect(track.virtualEqualsSource).toBe(true);
+ expect(track.points.every((p) => p.virtualSec === undefined)).toBe(true);
// Aucun clic dans cette capture : le champ `kind` n'apparaît nulle part.
expect(track.points.some((p) => p.kind !== undefined)).toBe(false);
});
- it("pèse plus que le transcript entier — c'est le poste dominant du tour", async () => {
+ it("reste à parité avec le transcript, plus le poste dominant", async () => {
const document = realScreencastDocument();
const transcript = executeAgentTool(document, "getTranscript", "{}", {});
const snapshot = executeAgentTool(document, "getCurrentDocument", "{}", {
@@ -199,39 +192,23 @@ describe("la fixture réelle — la taille de ce qui atteint le modèle", () =>
const { json } = await trackResult();
expect(transcript.resultJson.length).toBe(10_496);
expect(snapshot.resultJson.length).toBe(1_602);
- // 2,3× le transcript de 66 s de parole. Un tour qui appelle deux fois
- // getCursorTrack paie deux fois : c'est le chiffre à surveiller le jour où
- // une fixture plus longue arrive.
- expect(json.length).toBeGreaterThan(transcript.resultJson.length * 2);
- });
-
- it("dépense 28 % de sa taille en virtualSec, identique à atSec sur ce montage", async () => {
- // Non pas un gâchis : `virtualSec` est la coordonnée qu'`addZoom` prend, et
- // les deux divergent dès qu'un clip est coupé. Mesuré ici parce que sur une
- // timeline intacte la duplication est totale, et que c'est le premier
- // endroit où regarder si la taille devient un problème.
- const { json, track } = await trackResult();
- const identical = track.points.filter((p) => p.virtualSec === p.atSec).length;
- expect(identical).toBe(TRACK_POINTS);
- const withoutVirtual = JSON.stringify(
- track.points.map(({ virtualSec: _virtualSec, ...rest }) => rest),
- );
- const saved = JSON.stringify(track.points).length - withoutVirtual.length;
- expect(Math.round((saved / json.length) * 100)).toBe(28);
+ // Il valait 2,3× le transcript avant la réduction en keyframes ; il vaut
+ // maintenant moins. Le tour entier fait ~23k caractères — soit ~6k tokens,
+ // ce qui n'est PAS ce qui le rend lent : ce sont ses 19 appels en série.
+ expect(json.length).toBeLessThan(transcript.resultJson.length);
});
it("garde lisible le balayage lent auquel un détecteur d'immobilité est aveugle", async () => {
- // La question que cette fixture existe pour poser : la trajectoire
- // survit-elle à la réduction ? Entre 24,1 s et 29,2 s le pointeur traverse
- // un tiers de l'écran à hauteur constante — trop lentement pour qu'un
- // détecteur d'immobilité le voie comme un mouvement, trop mobile pour
- // qu'il le voie comme un arrêt. Dans le track il reste 24 points.
const { track } = await trackResult();
- const window = track.points.filter((p) => p.atSec >= 24.1 && p.atSec <= 29.2);
- expect(window.length).toBe(24);
- const cx = window.map((p) => p.cx);
- expect(Math.max(...cx) - Math.min(...cx)).toBeGreaterThan(0.3);
- const cy = window.map((p) => p.cy);
- expect(Math.max(...cy) - Math.min(...cy)).toBeLessThan(0.05);
+ // De 24,1 à 29,2 s l'auteur parcourt une image en la commentant : cy tenu à
+ // ±0,04 pendant que cx progresse d'un tiers de l'écran. Un détecteur
+ // d'immobilité n'y voit rien — le curseur bouge franchement — alors que les
+ // keyframes le rendent en quelques points dont l'interpolation rejoue le reste.
+ const sweep = track.points.filter((p) => p.atSec >= 23.5 && p.atSec <= 29.5);
+ expect(sweep.length).toBeGreaterThanOrEqual(4);
+ const xs = sweep.map((p) => p.cx);
+ expect(Math.max(...xs) - Math.min(...xs)).toBeGreaterThan(0.25);
+ const ys = sweep.map((p) => p.cy);
+ expect(Math.max(...ys) - Math.min(...ys)).toBeLessThan(0.15);
});
});
diff --git a/workbench/l1/end-to-end.wb.ts b/workbench/l1/end-to-end.wb.ts
index 03906c9fa..1ccfe7779 100644
--- a/workbench/l1/end-to-end.wb.ts
+++ b/workbench/l1/end-to-end.wb.ts
@@ -413,7 +413,7 @@ describe("cursor telemetry on the wire", () => {
// because a click is an observed event.
expect(payload.sampleCount).toBe(364);
const parked = payload.points.filter((p: { atSec: number }) => p.atSec >= 4 && p.atSec <= 5.6);
- expect(parked.length).toBeGreaterThan(3);
+ expect(parked.length).toBeGreaterThan(1);
for (const point of parked) expect([point.cx, point.cy]).toEqual([0.8, 0.25]);
expect(payload.points.filter((p: { kind?: string }) => p.kind === "click")).toHaveLength(1);
// Downsampled, never summarised: 364 samples in, ~60 points out at 5 Hz.
@@ -512,7 +512,7 @@ describe("cursor telemetry on the wire", () => {
// detector would drop it. The track has no such ceiling: it is simply
// there, as points, for the model to read.
const held = track.points.filter((p: { atSec: number }) => p.atSec >= 6 && p.atSec <= 12);
- expect(held.length).toBeGreaterThan(5);
+ expect(held.length).toBeGreaterThan(2);
for (const point of held) expect([point.cx, point.cy]).toEqual([0.72, 0.55]);
const blind = await runRepetition({ scenario: getScenario("cursor-blind") });
diff --git a/workbench/l1/real-fixture-turn.wb.ts b/workbench/l1/real-fixture-turn.wb.ts
index 88107c2fc..964a8b5ca 100644
--- a/workbench/l1/real-fixture-turn.wb.ts
+++ b/workbench/l1/real-fixture-turn.wb.ts
@@ -50,12 +50,12 @@ describe("la fixture réelle dans la boucle d'agent", () => {
expect(payload.reason).toBeUndefined();
expect(payload.assetId).toBe(REAL_SCREENCAST.assetId);
expect(payload.sampleCount).toBe(REAL_SCREENCAST.sampleCount);
- expect(payload.pointCount).toBe(356);
+ expect(payload.pointCount).toBe(148);
// Le tour ne doit RIEN muter : la question est une question.
expect(result.run.document).toBeUndefined();
});
- it("double la taille de la requête — un appel, +28 k caractères", async () => {
+ it("reste sous le transcript — un appel, ~9 k caractères", async () => {
// Le coût en contexte, mesuré là où il se paie : dans la requête suivante.
// Le premier tour part à ~17 k (système + 19 définitions d'outils) ; après
// UN getCursorTrack il en fait ~45 k. Les 24 238 caractères du track en
@@ -66,7 +66,7 @@ describe("la fixture réelle dans la boucle d'agent", () => {
const result = await runRepetition({ scenario });
const bodies = result.run.requests.map((r) => JSON.stringify(r.raw).length);
expect(bodies).toHaveLength(2);
- expect(bodies[1] - bodies[0]).toBeGreaterThan(24_000);
+ expect(bodies[1] - bodies[0]).toBeGreaterThan(8_000);
// Le plafond qui sauterait si quelqu'un montait DEFAULT_MAX_TRACK_POINTS
// sans regarder ce que ça coûte au tour.
expect(bodies[1]).toBeLessThan(50_000);
diff --git a/workbench/lib/harness.ts b/workbench/lib/harness.ts
index 09e70f01f..ab333a0a9 100644
--- a/workbench/lib/harness.ts
+++ b/workbench/lib/harness.ts
@@ -19,7 +19,20 @@ import type { CursorTrackSample } from "../../src/lib/ai-edition/timeline/cursor
import { type ModelServerHandle, type ScriptedTurn, startScriptedModel } from "./model-server";
import { type WireTranscript, wireFromRequests } from "./wire";
-export const DEFAULT_TURN_TIMEOUT_MS = 120_000;
+/**
+ * ponytail: 300s, and the number is measured rather than picked. At 120s the wizard
+ * scenario on a real 66s screencast failed 3 runs out of 5 — and the two that passed
+ * took 117.0s and 112.5s. The cutoff sat 3 to 7 seconds above a turn's normal
+ * duration, so a slow moment at the provider decided the outcome, and the failures
+ * read as "the model refused to act" in every report.
+ *
+ * The cost of a generous timeout is waiting; the cost of a tight one is a benchmark
+ * that measures its own impatience and blames the model for it. Note what actually
+ * takes the two minutes: that turn issues 19 tool calls in series, each a round trip.
+ * A turn is slow because of its SHAPE, not its payload — the whole context is ~26k
+ * characters, which is nothing.
+ */
+export const DEFAULT_TURN_TIMEOUT_MS = 300_000;
export interface SinkEvent {
kind: "text" | "thinking" | "toolStart" | "toolEnd" | "error";