Skip to content

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

fix(workbench): union the zoom denominator, derive the turn timeout from the harness

EtienneLescot8f75e5aa901f
diff --git a/electron/stt/whisperServer.ts b/electron/stt/whisperServer.ts
index 415a5568a..03a8f680b 100644
--- a/electron/stt/whisperServer.ts
+++ b/electron/stt/whisperServer.ts
@@ -175,6 +175,13 @@ export class WhisperServerManager {
private recordError(message: string): void {
this.lastError = message;
+ // ponytail: also to the log, not only to the field. `lastError` is read by
+ // the `status` getter, which nothing on the transcribe path calls — so a
+ // missing or non-executable helper used to leave no trace anywhere in the
+ // main process, and the only way to find out was to instrument the code.
+ // The renderer does toast the failure; a packaged build still needs a line
+ // someone can point at in a bug report.
+ console.error(`[stt] ${message}`);
}
/** True when a process is alive and a model is loaded. */
diff --git a/src/lib/ai-edition/timeline/cursor-track.test.ts b/src/lib/ai-edition/timeline/cursor-track.test.ts
index 082f69a38..b773e099b 100644
--- a/src/lib/ai-edition/timeline/cursor-track.test.ts
+++ b/src/lib/ai-edition/timeline/cursor-track.test.ts
@@ -186,6 +186,66 @@ describe("buildCursorTrack — compression", () => {
expect(worst).toBeLessThanOrEqual(0.02);
});
+ it("keeps the apex of an out-and-back — the case path-space simplification loses", () => {
+ // The regression test for the choice `simplifyAxis` makes: Douglas–Peucker per
+ // axis AGAINST TIME, not over the (x,y) path. Both give the same answer on a
+ // monotonic sweep — the traverse above cannot tell them apart — so this is the
+ // trajectory that separates them. The pointer runs out to 0.9 and comes back
+ // along the same line, which in path space deviates from its chord by nothing:
+ // the whole excursion collapses and interpolation then swears it never happened.
+ const outAndBack: CursorTrackSample[] = Array.from({ length: 200 }, (_, i) => ({
+ timeMs: i * 50,
+ cx: i <= 100 ? 0.1 + i * 0.008 : 0.9 - (i - 100) * 0.008,
+ cy: 0.5, // constant, so the path IS its own chord
+ assetId: "arrow",
+ interactionType: "move" as const,
+ }));
+ const track = build(outAndBack, 5);
+
+ // The turning point survives. Path-space simplification drops it and the best
+ // remaining point sits near 0.74, so this alone fails on the wrong implementation.
+ expect(Math.max(...track.points.map((p) => p.cx))).toBeGreaterThan(0.85);
+
+ // And the same bound the straight traverse claims still holds here.
+ let worst = 0;
+ for (const sample of outAndBack) {
+ 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("says so when the mandatory points push it over maxPoints", () => {
+ // The ceiling is soft: `maxPoints` budgets the rate and the gap floor, and the
+ // mandatory points are exempt. `sweep` samples every 50 ms and the shape here
+ // alternates on every index, so every sample is mandatory and the budget cannot
+ // hold — and the track has to say so rather than let the model read the rows as
+ // "within budget".
+ const flipping = sweep(200, { shape: (i) => (i % 2 === 0 ? "arrow" : "text") });
+ const track = buildCursorTrack({
+ assetId: "asset_1",
+ samples: flipping,
+ durationSec: 60,
+ clips: CLIPS,
+ hz: 5,
+ maxPoints: 20,
+ });
+
+ expect(track.pointCount).toBeGreaterThan(20);
+ expect(track.overBudget).toMatch(/ceiling of 20/);
+ // `truncated` is the other direction — the rate WAS cut — and stays its own signal.
+ expect(track.truncated).toBe(true);
+ });
+
+ it("leaves overBudget off when the ceiling holds", () => {
+ expect(build(sweep(400), 5).overBudget).toBeUndefined();
+ });
+
it("restores per-point virtualSec once the two axes diverge", () => {
const shiftedClips: AxcutClip[] = [
{
diff --git a/src/lib/ai-edition/timeline/cursor-track.ts b/src/lib/ai-edition/timeline/cursor-track.ts
index bdc360f53..aec4324a4 100644
--- a/src/lib/ai-edition/timeline/cursor-track.ts
+++ b/src/lib/ai-edition/timeline/cursor-track.ts
@@ -66,6 +66,14 @@ export interface CursorTrack {
shapeCount: number;
/** True when maxPoints forced a coarser rate than `hz` would give. */
truncated: boolean;
+ /** Present ONLY when the ceiling did not hold. `maxPoints` budgets the rate and
+ * the gap floor; the MANDATORY points are exempt and stack on top — the first
+ * and last sample, a pointer-shape change, a non-move event, the ends of a run
+ * longer than the max gap — so a capture rich in them lands above the ceiling.
+ * Absent means the budget held. It is a separate field from `truncated` on
+ * purpose: that one says "you are seeing less than you asked for", this one
+ * says the opposite. */
+ overBudget?: string;
/** 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. */
@@ -313,6 +321,20 @@ export function buildCursorTrack(options: CursorTrackOptions): CursorTrack {
return point;
});
+ // ponytail: the ceiling is soft, and saying so is the whole point. `maxPoints`
+ // is spent on the gap floor and the rate above it; the mandatory points are
+ // added afterwards and answer to neither. Charging them to the budget instead
+ // would mean dropping a shape change to stay under it, which is the one thing
+ // this track must never do — so the overflow is reported rather than prevented.
+ // The field is absent when the budget held, so the common payload is unchanged.
+ const overBudget =
+ points.length > maxPoints
+ ? `${points.length} points for a ceiling of ${maxPoints}: the mandatory points are ` +
+ `never dropped — the first and last sample, pointer-shape changes, non-move ` +
+ `events and the ends of a parked run — and this recording has enough of them ` +
+ `to land above the budget.`
+ : undefined;
+
return {
assetId,
sampleCount: samples.length,
@@ -321,6 +343,7 @@ export function buildCursorTrack(options: CursorTrackOptions): CursorTrack {
coveredSec,
shapeCount: shapeIndex.size,
truncated,
+ ...(overBudget ? { overBudget } : {}),
virtualEqualsSource: !shifted,
timeBase:
"atSec is SOURCE time of the asset (the recording's own clock). virtualSec is the same " +
diff --git a/technical-documentation/testing/manual-e2e-checklist.md b/technical-documentation/testing/manual-e2e-checklist.md
index f52c6bcfb..94b8c92c8 100644
--- a/technical-documentation/testing/manual-e2e-checklist.md
+++ b/technical-documentation/testing/manual-e2e-checklist.md
@@ -194,7 +194,7 @@ Zoom, speed, annotation, and full-camera regions are stored against a clip in th
### Local transcription and captions — v1.8.0
- [ ] Confirm the transcript pane states that transcription runs locally and that no upload occurs when it is started.
-- [ ] With the Whisper helper binary absent, activate the transcribe action and confirm the UI reports why nothing happened. Observed 2026-07-31: the button produces no message, no error state, and not one line in the main-process log — a build shipped without the helper gives the user a dead button and no way to find out. Verify against a build whose helper was deliberately not packaged, not only against a working one.
+- [ ] With the Whisper helper binary absent, activate the transcribe action and confirm the UI reports why nothing happened, and that the main-process log carries a matching `[stt]` line. The failure now reaches a toast (`transcriptionStore.ts`) and the log (`whisperServer.ts`), but the text it shows is the helper's own — a sentence about a build script, which is not an answer for someone running a packaged build. Verify against a build whose helper was deliberately not packaged, not only against a working one.
- [ ] Run transcription in the packaged build and confirm the model is fetched or reused without an error about a missing cache directory.
- [ ] Confirm a second transcription reuses the cached model instead of downloading it again.
- [ ] Confirm the completed transcript reports the detected language on the media asset card.
diff --git a/vitest.workbench.config.ts b/vitest.workbench.config.ts
index 3e102075b..0e800ae3e 100644
--- a/vitest.workbench.config.ts
+++ b/vitest.workbench.config.ts
@@ -1,5 +1,6 @@
import path from "node:path";
import { defineConfig } from "vitest/config";
+import { DEFAULT_TURN_TIMEOUT_MS } from "./workbench/lib/harness";
// ponytail: separate from vitest.config.ts on purpose — `workbench/` is outside
// that config's include glob AND outside tsconfig.test.json's include, so the
@@ -15,18 +16,31 @@ export default defineConfig({
globals: true,
environment: "node",
include: ["workbench/**/*.wb.ts"],
- testTimeout: 120_000,
+ // ponytail: derived from the harness cutoff, and deliberately ABOVE it. A
+ // `.wb.ts` driving a live turn is cut by whichever deadline fires first;
+ // this one sat at a hardcoded 120 s while the harness moved to 300 s, so
+ // vitest killed the turn before `runTurn` could classify it — a dead worker
+ // where the run should have recorded a TIMEOUT verdict. Equal values would
+ // only make the race unbiased; the margin is what guarantees the harness
+ // wins.
+ testTimeout: DEFAULT_TURN_TIMEOUT_MS + 30_000,
reporters: ["default"],
// ponytail: the fixed cost of the suite is the dynamic
- // `await import("deepagents")` in chat-service.ts:346 — hundreds of
- // milliseconds, paid ONCE PER WORKER. One non-isolated thread makes the
- // marginal cost of a new file its own runtime.
+ // `await import("./deep-agent/service")` in chat-service.ts:398 — the agent
+ // graph, the tool schemas and the document model behind them, paid ONCE PER
+ // WORKER. One non-isolated thread makes the marginal cost of a new file its
+ // own runtime.
//
- // The trade this accepts: `sessionsByProject` (chat-service.ts:36) and
- // `messageCheckpointsBySession` (:48) are module Maps with no exported
- // reset, so state now leaks between files. `runScenario` mints a unique
- // projectId per run, which is what makes that safe — anything calling
- // `runChat` directly would bypass the guard.
+ // (This used to name `deepagents`, a package the tree no longer depends on.
+ // The cost survived the package: it was never that factory, it was the graph
+ // underneath. Re-measure before trusting any figure for it — `await
+ // import(…)` timed inside a `.wb.ts` is enough.)
+ //
+ // The trade this accepts: `sessionsByProject` (chat-service.ts:38) and
+ // `messageCheckpointsBySession` (:50) are module Maps with no exported
+ // reset, so state leaks between files. The harness mints a unique projectId
+ // per run (`lib/harness.ts:239`), which is what makes that safe — anything
+ // calling `runChat` directly would bypass the guard.
pool: "threads",
maxWorkers: 1,
isolate: false,
diff --git a/workbench/README.md b/workbench/README.md
index 510579a9c..4c27de3fd 100644
--- a/workbench/README.md
+++ b/workbench/README.md
@@ -501,9 +501,16 @@ modèle qui apprend la forme de notre générateur obtient une bonne note sans a
`realScreencastDocument()` charge à la place une **vraie prise** — 66,154 s de screencast,
transcrites par le Whisper local (129 mots français horodatés, aucun silence stocké : ils se
déduisent des écarts), avec son sidecar de curseur (1521 échantillons, ~23 Hz, 11 formes de
-pointeur, aucun clic). Les deux fichiers sont dans `workbench/fixtures/`, avec leur provenance et
-la liste de ce qui en a été retiré : `workbench/fixtures/README.md`. Rien d'autre ne doit les
-ouvrir.
+pointeur, aucun clic). Les deux fichiers vivent dans `workbench/fixtures/`, **gitignoré**
+(`.gitignore:126`) : ils ne sont dans aucun clone, et leur provenance est ce paragraphe — il n'y a
+pas de `fixtures/README.md` versionné à aller lire, seulement celui que se garde qui possède la
+prise. Rien d'autre que `lib/real-fixture.ts` ne doit les ouvrir.
+
+Conséquence à connaître avant de lancer le banc : **44 tests L0 échouent dans un clone neuf**,
+tous sur le même `ENOENT` (`l0/real-fixture.wb.ts`, `real-screencast-truth.wb.ts`,
+`quality.wb.ts`, et `score.wb.ts` qui construit le document de chaque scénario du registre).
+Fournir sa propre prise donnera d'autres chiffres que ceux assertés ici. Rien de tout cela n'est
+vu par le CI, qui ne lance pas le banc.
Le document arrive **tel qu'il est sur le disque**, y compris son `cameraTrack: null` alors qu'un
fichier webcam existe à côté de l'enregistrement. Ce n'est pas un oubli de la copie ; c'est l'état
@@ -515,12 +522,17 @@ au-dessus de `electron/media/cursorSidecar.ts`, le parseur de production. Un sc
par `cursorReader:` — **exclusif** de `cursorTelemetry:`, que `defineScenario` refuse de voir
coexister avec lui.
-**Ce que ça coûte au tour, mesuré** : `getCursorTrack` rend **356 points, 24 238 caractères**
-(5 Hz + 56 points gardés pour des changements de forme du pointeur). C'est 2,3× le transcript
-entier, et la requête suivante passe de ~17 k à ~45 k caractères. Les chiffres sont **assertés**
-dans `l0/real-fixture.wb.ts` : ils bougent quand `buildCursorTrack` bouge, et c'est voulu.
-Au-delà de ~25 000 caractères, c'est une trouvaille à signaler — pas un défaut à faire disparaître
-en baissant `DEFAULT_TRACK_HZ`.
+**Ce que ça coûte au tour, mesuré** : `getCursorTrack` rend **148 points, 7 797 caractères** —
+une réduction en keyframes des 1521 échantillons, plus les points qu'aucune interpolation ne
+remet (changement de forme du pointeur, événement autre qu'un déplacement, bornes d'un arrêt).
+C'est **sous** le transcript (10 496). Les chiffres sont **assertés** dans
+`l0/real-fixture.wb.ts` : ils bougent quand `buildCursorTrack` bouge, et c'est voulu. Au-delà de
+~25 000 caractères, c'est une trouvaille à signaler — pas un défaut à faire disparaître en
+baissant `DEFAULT_TRACK_HZ`.
+
+C'était 356 points et 24 238 caractères avant la réduction, soit 2,3× le transcript. Le chiffre
+est gardé ici parce qu'il continue de circuler dans les notes de l'époque : s'il réapparaît
+quelque part, c'est qu'on lit un texte périmé.
Quatre scénarios notés tournent maintenant sur cette fixture (`scenarios/real-screencast.scn.ts`).
Ce qu'ils mesurent a besoin de la vérité terrain — ce que l'utilisateur faisait, annoté à la main —
@@ -564,6 +576,20 @@ trajectoire » sont **deux checks séparés**.
repose** : observation live, ou mécanisme lu dans le code. Une prédiction n'y a pas sa place.
9. `npm run wb && npm run wb:typecheck && npx biome check --write workbench`.
+### Répondre à un échec sans surajuster au banc
+
+Un échec mesuré donne envie d'ajouter la ligne de prompt qui règle ce cas précis. Fait huit fois,
+le prompt système devient la liste des réponses au jeu de tests, et le banc mesure sa propre
+mémoire. Le garde-fou est une question, à se poser avant de committer :
+
+> **Ce correctif se justifie-t-il sans mentionner le scénario qui l'a révélé ?**
+
+Si la seule façon de le défendre est « sinon `describe-zooms` est rouge », ce n'est pas un
+correctif, c'est une réponse apprise. Un correctif légitime se formule comme une propriété du
+produit — « le modèle n'a aucun moyen de savoir qu'un `customScale` rend le `depth` inerte » — et
+le scénario n'en est que le témoin. Cela vaut pour le prompt système comme pour les descriptions
+d'outils, qui sont du prompt sous un autre nom.
+
### Où vit quoi
```
@@ -581,7 +607,7 @@ lib/rubrics.ts les rubrics partagés — une propriété par rubric, aucun s
lib/language.ts ce qui reste des prédicats de texte : de la notation, et du sursis
lib/fixtures.ts les documents de référence, écrits en code
lib/real-fixture.ts le chargeur de la PRISE RÉELLE (projet + sidecar de curseur sur disque)
-fixtures/ les deux fichiers de cette prise, et d'où ils viennent (README.md)
+fixtures/ les deux fichiers de cette prise — GITIGNORÉ, absent de tout clone
lib/score.ts deux axes, porte min(), checks structurels injectés partout,
et le poids indéterminé tenu hors des deux termes du ratio
lib/baseline.ts le ratchet bidirectionnel, plus le seau des non-mesurés
diff --git a/workbench/l0/quality.wb.ts b/workbench/l0/quality.wb.ts
index 13a26357d..2810f9897 100644
--- a/workbench/l0/quality.wb.ts
+++ b/workbench/l0/quality.wb.ts
@@ -415,6 +415,29 @@ describe("zoomPlacement — précision ET rappel, jamais une note unique", () =>
expect(zoomPlacement(document, ZONES, { coverFraction: 0.2 }).missedZones).toHaveLength(2);
});
+ it("ne compte pas deux fois les secondes de deux zooms empilés", () => {
+ // Sur fixture synthétique, à rebours de ce fichier, et pour la raison que
+ // son en-tête donne : ce qui se vérifie ici est de l'arithmétique
+ // d'intervalles, pas une lecture de matériau. Rule 2 dans `timelineMap.ts`
+ // interdit à deux zooms de se chevaucher, mais seul `setZoom` passe par le
+ // clamp qui l'applique — `addZoom` ajoute à la suite — donc l'agent PEUT
+ // empiler, et cet oracle doit être juste sur les documents fautifs qu'il
+ // est là pour exposer.
+ const document = zoom(
+ zoom(recordingWithSilences({ durationSec: 60, silences: [[10, 12]] }), 8, 13),
+ 10,
+ 15,
+ );
+ expect(document.zoomRanges).toHaveLength(2);
+
+ // Union : 8→15, soit 7 s, entièrement sur la zone 8→15. Somme : 5 + 5 = 10 s,
+ // qui rendrait 0,7 — une précision abaissée par le double comptage et non par
+ // un défaut de placement.
+ const placement = zoomPlacement(document, [{ startSec: 8, endSec: 15, label: "zone" }]);
+ expect(placement.zoomSec).toBeCloseTo(7, 4);
+ expect(placement.precision).toBeCloseTo(1, 4);
+ });
+
it("rend une précision de 1 quand aucun zoom n'a été émis", () => {
// Ne rien émettre est un échec de RAPPEL et jamais de précision : gonfler
// la précision d'un document vide serait absurde, l'annuler aussi.
diff --git a/workbench/l0/real-fixture.wb.ts b/workbench/l0/real-fixture.wb.ts
index bb3011bbb..9547ab6f6 100644
--- a/workbench/l0/real-fixture.wb.ts
+++ b/workbench/l0/real-fixture.wb.ts
@@ -75,8 +75,8 @@ describe("la fixture réelle — le document", () => {
it("n'a PAS de piste caméra dans le document, quoi qu'il y ait sur le disque", () => {
// Le dossier d'enregistrement contient bien un fichier webcam ; le document
// écrit par l'app, lui, porte `cameraTrack: null`. La fixture ne corrige
- // pas ça — voir workbench/fixtures/README.md. Cette assertion existe pour
- // que personne ne « complète » la fixture sans s'en apercevoir : le modèle
+ // pas ça — voir workbench/README.md § « La prise réelle ». Cette assertion
+ // existe pour que personne ne « complète » la fixture sans le voir : le modèle
// verra `hasCameraTrack: false`, et c'est l'état réel du projet.
expect(realScreencastDocument().assets[0].cameraTrack).toBeNull();
});
diff --git a/workbench/lib/quality.ts b/workbench/lib/quality.ts
index c97d34e2b..23b6c6d48 100644
--- a/workbench/lib/quality.ts
+++ b/workbench/lib/quality.ts
@@ -48,6 +48,7 @@ import {
} from "./editorial";
import {
intersectSpans,
+ mergeSpans,
overlapSec,
SPAN_EPSILON_SEC,
type Span,
@@ -592,12 +593,16 @@ export function zoomPlacement(
};
});
- // ponytail: the totals are unions, not sums of the per-hit overlaps. Zooms
- // are forbidden from overlapping each other (`timelineMap.ts:113`), so on a
- // valid document the two agree — but this oracle also has to be right about
- // the invalid ones it is partly there to expose, and summing would report a
- // precision above 1 on a document carrying two stacked zooms.
- const zoomSec = totalSec(spans.map((entry) => entry.span));
+ // ponytail: BOTH totals are unions, and `zoomSec` was a sum until it wasn't.
+ // Rule 2 in `timelineMap.ts` forbids two zooms from overlapping, but only
+ // `setZoom` goes through the clamp that enforces it (`replacePillSpan`,
+ // `agent-tools.ts:1395`) — `addZoom` appends (`agent-tools.ts:1349`), so an
+ // agent CAN stack zooms, and `editorial.ts` carries an `overlap` check
+ // precisely because it happens. On such a document a summed denominator
+ // counts the shared seconds twice while the intersected numerator counts them
+ // once, and `precision` reads low for a reason that has nothing to do with
+ // placement. Union on both sides or the ratio is not a ratio of the same thing.
+ const zoomSec = totalSec(mergeSpans(spans.map((entry) => entry.span)));
const onZoneSec = totalSec(
intersectSpans(
spans.map((entry) => entry.span),
diff --git a/workbench/lib/real-fixture.ts b/workbench/lib/real-fixture.ts
index 2efe44c67..17dae60b3 100644
--- a/workbench/lib/real-fixture.ts
+++ b/workbench/lib/real-fixture.ts
@@ -11,9 +11,10 @@
// transcribed by the local Whisper helper, with its own cursor sidecar. Nothing
// is normalised, rounded or tidied on the way in — the document reaches the
// model in the state it has on disk, `originalPath`, absent `cameraTrack` and
-// all. See `workbench/fixtures/README.md` for where it comes from and for the
-// single field that was removed from the sidecar (11 base64 pointer bitmaps,
-// 112 kB, referenced by id and never decoded).
+// all. Where it comes from — and the single field removed from the sidecar (11
+// base64 pointer bitmaps, 112 kB, referenced by id and never decoded) — is in
+// `workbench/README.md` § "La prise réelle". `workbench/fixtures/` is gitignored,
+// so it holds no README any clone can read; do not point readers into it.
//
// The ground truth of what the user was DOING lives nowhere near here. It
// belongs to the assertions; a scenario that let it reach the model would be