@@ -2564,6 +2564,63 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => { |
2564 | 2564 | }), |
2565 | 2565 | ); |
2566 | 2566 |
|
| 2567 | + it.effect.each([ |
| 2568 | + { name: "a newer transcript too large to finish", sizes: [63, 2], skipped: 1 }, |
| 2569 | + { |
| 2570 | + name: "a transcript that only fits when each byte is read once", |
| 2571 | + sizes: [63.5], |
| 2572 | + skipped: 0, |
| 2573 | + }, |
| 2574 | + ])("shares the Claude metadata budget across $name", ({ sizes, skipped }) => |
| 2575 | + Effect.gen(function* () { |
| 2576 | + const path = yield* Path.Path; |
| 2577 | + const nowMs = Date.parse("2026-08-24T12:00:00.000Z"); |
| 2578 | + yield* TestClock.setTime(nowMs); |
| 2579 | + const claudeHomePath = yield* makeTempDir("t3code-metadata-budget-claude-"); |
| 2580 | + const codexHomePath = yield* makeTempDir("t3code-metadata-budget-codex-"); |
| 2581 | + const workspace = yield* makeTempDir("t3code-metadata-budget-workspace-"); |
| 2582 | + // Sizes in MiB against the 64 MiB per-source budget; cwd follows the image. |
| 2583 | + const sessions = sizes.map((size, index) => ({ sessionId: `image-${index}`, size })); |
| 2584 | + for (const [index, { sessionId, size }] of [ |
| 2585 | + ...sessions, |
| 2586 | + { sessionId: "older", size: 0 }, |
| 2587 | + ].entries()) { |
| 2588 | + const image = { |
| 2589 | + type: "image", |
| 2590 | + source: { |
| 2591 | + type: "base64", |
| 2592 | + media_type: "image/png", |
| 2593 | + data: "A".repeat(size * 1024 * 1024), |
| 2594 | + }, |
| 2595 | + }; |
| 2596 | + yield* writeTranscript({ |
| 2597 | + filePath: path.join(claudeHomePath, "projects", "-budget", `${sessionId}.jsonl`), |
| 2598 | + contents: encodeTranscriptRecord({ |
| 2599 | + type: "user", |
| 2600 | + sessionId, |
| 2601 | + message: { |
| 2602 | + role: "user", |
| 2603 | + content: [{ type: "text", text: "Review this" }, ...(size === 0 ? [] : [image])], |
| 2604 | + }, |
| 2605 | + cwd: workspace, |
| 2606 | + }), |
| 2607 | + mtimeMs: nowMs - (index + 1) * 60_000, |
| 2608 | + }); |
| 2609 | + } |
| 2610 | + |
| 2611 | + const threads = yield* runRecentThreads({ |
| 2612 | + claudeHomePath, |
| 2613 | + codexHomePath, |
| 2614 | + workspaceRoot: workspace, |
| 2615 | + }); |
| 2616 | + |
| 2617 | + expect(threads.map((thread) => thread.providerSessionId)).toEqual([ |
| 2618 | + ...sessions.slice(skipped).map(({ sessionId }) => sessionId), |
| 2619 | + "older", |
| 2620 | + ]); |
| 2621 | + }), |
| 2622 | + ); |
| 2623 | + |
2567 | 2624 | it.effect("imports every transcript that fits the per-file record limit", () => |
2568 | 2625 | Effect.gen(function* () { |
2569 | 2626 | const path = yield* Path.Path; |
|