Skip to content

Commit 7dcd2e5

Browse files
committed
test(e2e): recompute #275 arithmetic fixtures; isolate e2e schema preload (release gate)
2 parents 2d0b6c7 + a196222 commit 7dcd2e5

4 files changed

Lines changed: 21 additions & 8 deletions

File tree

‎packages/e2e-tests/bunfig.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Keep direct plugin imports in e2e tests away from the user's shared database.
2+
# This is especially important for Pi subagent tests, which open storage without
3+
# first booting the isolated Pi harness process.
4+
[test]
5+
preload = ["../plugin/test-preload.ts"]

‎packages/e2e-tests/tests/context-limits.test.ts‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ describe("context-limit resolution", () => {
5050
const sessionId = await h.createSession();
5151
await h.sendPrompt(sessionId, "probe turn for context-limit resolution.");
5252

53+
// Mock Anthropic uses a shared context window: resolveLimit reserves
54+
// min(8,192, 25% of 50,000) = 8,192 output tokens, leaving 41,808
55+
// usable input tokens. The exact pressure is 20,000 / 41,808 * 100.
5356
// Give the event handler a moment to persist last_context_percentage.
5457
await Bun.sleep(300);
5558

@@ -59,12 +62,12 @@ describe("context-limit resolution", () => {
5962
.get(sessionId) as { last_context_percentage: number } | null;
6063

6164
const pct = row?.last_context_percentage ?? 0;
62-
console.log(`[TEST] last_context_percentage = ${pct} (expected exactly 40 for 20K/50K)`);
65+
console.log(
66+
`[TEST] last_context_percentage = ${pct} (expected 47.83773440489858 for 20K/41,808)`,
67+
);
6368

64-
// 20_000 input_tokens / 50_000 context_limit = exactly 40%. Mock returns
65-
// exact usage and plugin rounds to 1 decimal; this must be 40.0.
66-
// Tightened from the old 35-45 range (Finding #5 — the range was masking
67-
// a real regression surface because ANY value in [35,45] passed).
68-
expect(pct).toBe(40);
69+
// Keep the exact value: a broad range would hide changes to the
70+
// shared-window output reservation arithmetic.
71+
expect(pct).toBe(47.83773440489858);
6972
}, 60_000);
7073
});

‎packages/e2e-tests/tests/pi-context-limits.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ describe("pi context-limit resolution", () => {
6060
{ timeoutMs: 5_000, label: "pi last_context_percentage persisted" },
6161
);
6262

63-
expect(pct).toBe(40);
63+
// Pi's shared-window model reserves min(8,192, 25% of 50,000) =
64+
// 8,192 output tokens, so 20,000 / 41,808 * 100 is the exact pressure.
65+
expect(pct).toBe(47.83773440489858);
6466
}, 60_000);
6567
});

‎packages/e2e-tests/tests/pi-overflow-recovery.test.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ describe("pi context overflow detection", () => {
118118
);
119119

120120
expect(afterNext.detected_context_limit).toBe(120_000);
121-
expect(afterNext.last_context_percentage).toBe(50);
121+
// The detected combined window is narrowed before reservation:
122+
// 120,000 - min(8,192, 25% of 120,000) = 111,808 usable tokens.
123+
// The next pass therefore reports 60,000 / 111,808 * 100 exactly.
124+
expect(afterNext.last_context_percentage).toBe(53.66342301087579);
122125
}, 120_000);
123126

124127
it("does not persist detected_context_limit for non-overflow rate-limit errors", async () => {

0 commit comments

Comments
 (0)