Skip to content
32 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R21import assert from "node:assert/strict";
2import { test } from "node:test";
3
Merge branch 'worktree-agent-ab9543c492a7ed481' into spend-guardrails4import { expiresIn, formatBytes, legacyArtifactsWorthAsking } from "./artifacts.ts";
Actions: OIDC tokens, the toolkit's cache and artifact services, and artifacts in R25
6test("sizes read as KB, MB or GB", () => {
7 assert.equal(formatBytes(10), "1 KB");
8 assert.equal(formatBytes(412_870), "403 KB");
9 assert.equal(formatBytes(18_734_120), "17.9 MB");
10 assert.equal(formatBytes(5 * 1024 ** 3), "5.00 GB");
11});
12
13test("expiry reads from now", () => {
14 const now = Date.parse("2026-10-08T12:00:00Z");
15 assert.equal(expiresIn("2026-10-22T12:00:00Z", now), "expires in 14 days");
16 assert.equal(expiresIn("2026-10-09T13:00:00Z", now), "expires tomorrow");
17 assert.equal(expiresIn("2026-10-08T20:00:00Z", now), "expires today");
18 assert.equal(expiresIn("2026-10-08T11:00:00Z", now), "expired");
19 assert.equal(expiresIn(null, now), "");
20});
Merge branch 'worktree-agent-ab9543c492a7ed481' into spend-guardrails21
22test("KV is asked for an old, finished run's artifacts only until they have expired", () => {
23 const old = { createdAt: "2026-10-07T12:00:00Z", status: "completed" };
24 const now = Date.parse("2026-10-10T00:00:00Z");
25 assert.ok(legacyArtifactsWorthAsking(old, now));
26 // Still going: its artifacts are in R2, and its page refreshes.
27 assert.ok(!legacyArtifactsWorthAsking({ ...old, status: "in_progress" }, now));
28 // Made after the move to R2.
29 assert.ok(!legacyArtifactsWorthAsking({ ...old, createdAt: "2026-10-09T08:00:00Z" }, now));
30 // Every KV artifact has expired.
31 assert.ok(!legacyArtifactsWorthAsking(old, Date.parse("2026-10-22T00:00:00Z")));
32});

This file's history is long; its oldest lines are credited to the oldest commit read.