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.

The artifacts service is services/artifacts, the Worker g1t-artifacts, bound as ARTIFACTS by the API, the site and the agents; its live rooms move to it with a Durable Object transfer from g1t-docs-service, and its database, bucket, indexes and queue keep their names. The git store's binding and settings are GITSTORE, its ops scripts gitstore-*, and workflow run artifacts keep their compatible API under run_artifacts modules. The deploy tool puts a Worker that has never deployed before the Workers in its stage that bind to it, and the deploy guide gives the cutover runbook.1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { expiresIn, formatBytes, legacyArtifactsWorthAsking } from "./run-artifacts.ts";
5
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});
21
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});