Skip to content

Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.

test: scale part 5's timing bars to the machine, with a floor

Shrish Dwivedi5b598cbc7293
diff --git a/test/init-bounds-review.test.ts b/test/init-bounds-review.test.ts
index 7d7a99f7..94796120 100644
--- a/test/init-bounds-review.test.ts
+++ b/test/init-bounds-review.test.ts
@@ -9,6 +9,7 @@ import { statSync } from "node:fs";
import { minePreferences } from "../src/init/prefs.js";
import { replaySession } from "../src/init/replay-runs.js";
import { day, done, SHOP, Tx, world } from "./init-mine-fixtures.js";
+import { timeBar } from "./machine-speed.js";
process.env.TZ = "UTC";
@@ -27,7 +28,8 @@ test("20,000 different preference-shaped lines cluster in bounded time, the newe
const t = Date.now();
const found = minePreferences(typed);
const ms = Date.now() - t;
- assert.ok(ms < 5000, `took ${ms} ms`);
+ // 5 s where the bar was set, scaled to this machine, never under 15 s.
+ assert.ok(ms < timeBar(5000, 15_000), `took ${ms} ms`);
assert.ok(found.some((c) => c.shortest === "never squash release commits"));
});
@@ -41,7 +43,8 @@ test("one session with 100,000 typed lines stops at its time cap and says so", (
const r = replaySession(path, { from: 0, to: statSync(path).size }, SHOP, new Date(day(28)), { env: w.env, maxMs: 1500 });
const ms = Date.now() - t;
assert.equal(r.stopped, "time");
- assert.ok(ms < 6000, `took ${ms} ms`);
+ // The 1.5 s cap, and what a slow machine adds around it.
+ assert.ok(ms < 1500 + timeBar(4500, 13_500), `took ${ms} ms`);
} finally {
done(w);
}
diff --git a/test/skills-prompt.test.ts b/test/skills-prompt.test.ts
index f04eeb5c..a4da1e16 100644
--- a/test/skills-prompt.test.ts
+++ b/test/skills-prompt.test.ts
@@ -16,6 +16,7 @@ import type { PendingOffer } from "../src/trace/types.js";
import { emptyState } from "./trace-run-fixtures.js";
import { releaseSkill, shipSkill, WEBSHOP } from "./skills-recall-fixtures.js";
import { box, CWD, gateFor, grow, payload, ranIn, replyAt, save, SID, stateOf, typedIn, withNow, type Box } from "./skills-prompt-fixtures.js";
+import { timeBar } from "./machine-speed.js";
const FROM = "[trail] From Trail, the tool this person installed to keep commands that worked as skills.";
const webshopRelease = () => releaseSkill({ applies: WEBSHOP, trail: "s-7f3a2c" });
@@ -150,7 +151,8 @@ test("the deadline: slow probes are left out, the block still comes inside 400 m
const took = Date.now() - t0;
assert.ok(out.context?.startsWith("[trail] Skill ship-beta-then-prod fits"));
assert.ok(!out.context!.includes("ready:"));
- assert.ok(took < 450, `took ${took} ms`);
+ // The 400 ms deadline, and what a slow machine adds around it.
+ assert.ok(took < 400 + timeBar(50, 200), `took ${took} ms`);
// Past the deadline before the cue (a long lock wait, a slow catch-up): no block, nothing half-done.
let now = 0;
const lb = shipBox("late");