commit 899b56d0759f126a82d35565981084d80dba53df
parent d694be7a3493778496e746b6da6696fb34e30ef9
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 11 Nov 2026 12:18:01 -0500
archives: the disk cache's cap defaults to 512 MB, not 2 GB (demo epic D1 review follow-up)
The host's /home is 97% full. ARCHIVE_CACHE_MAX_MB still sets it;
ENVIRONMENT.md regenerated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat:
4 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/ENVIRONMENT.md b/ENVIRONMENT.md
@@ -101,7 +101,7 @@ Tokens, credentials and knobs a running process reads. Most configuration is not
| `TRANSCRIPT_SITE_URL` | — | MCP server: one published archive to read over HTTP. Also the default connected archive (common/lib/remoteArchives.ts): the editor, umtool and the MCP offer it as a source when settings.remoteArchives does not list it, without writing it. | mcp/src/sources.ts |
| `ARCHILYZER_ALLOW_PRIVATE_ARCHIVES` | off | `1` lets the editor connect an archive whose host is this machine or its network (loopback, private, link-local, a `.local` name, or a name resolving to such an address), which is refused otherwise: umtool, which can connect one, is open on the LAN. TRANSCRIPT_SITE_URL's archive, and one already written in settings.json, are connected without it. | common/controller/remoteArchives.ts |
| `ARCHIVE_CACHE_DIR` | `.archive-cache` beside EXPORT_BUILDS_DIR | Where a remote archive's documents (corpus.json, manifests, shard pages) are kept on disk, by the archive's build: a sweep over a published archive downloads a shard once per build, not once per sweep. In a container it is on the builds volume. | common/lib/archiveCache-server.ts |
-| `ARCHIVE_CACHE_MAX_MB` | 2048 | The disk cache of remote archive documents' size cap, MB: past it the least recently used are dropped. | common/lib/archiveCache-server.ts |
+| `ARCHIVE_CACHE_MAX_MB` | 512 | The disk cache of remote archive documents' size cap, MB: past it the least recently used are dropped. | common/lib/archiveCache-server.ts |
| `ARCHIVE_CACHE` | on (off under node's test runner) | `0` reads remote archives without the disk cache (every read over the network, still one at a time); `1` turns it on under node's test runner, where it is off. | common/lib/archiveCache-server.ts |
| `TRANSCRIPT_HUB_URL` | — | MCP server: a hub, federating every archive it lists. | mcp/src/sources.ts |
| `TRANSCRIPT_LOCAL_DIR` | — | MCP server: a composed public dir on disk. | mcp/src/sources.ts |
diff --git a/common/lib/archiveCache-server.test.ts b/common/lib/archiveCache-server.test.ts
@@ -183,3 +183,18 @@ test("a document over the bound is refused: by its Content-Length, or as it stre
rmSync(dir, { recursive: true, force: true });
}
});
+
+test("the cache's cap is 512 MB unless ARCHIVE_CACHE_MAX_MB says otherwise", async () => {
+ const { ARCHIVE_CACHE_DEFAULT_MB } = await import("./archiveCache-server");
+ assert.equal(ARCHIVE_CACHE_DEFAULT_MB, 512);
+ const saved = process.env.ARCHIVE_CACHE_MAX_MB;
+ delete process.env.ARCHIVE_CACHE_MAX_MB;
+ try {
+ assert.equal(new ArchiveDiskCache({ dir: "/nonexistent" }).maxBytes, 512 * 1024 * 1024);
+ process.env.ARCHIVE_CACHE_MAX_MB = "64";
+ assert.equal(new ArchiveDiskCache({ dir: "/nonexistent" }).maxBytes, 64 * 1024 * 1024);
+ } finally {
+ if (saved === undefined) delete process.env.ARCHIVE_CACHE_MAX_MB;
+ else process.env.ARCHIVE_CACHE_MAX_MB = saved;
+ }
+});
diff --git a/common/lib/archiveCache-server.ts b/common/lib/archiveCache-server.ts
@@ -31,7 +31,7 @@
// WHERE. ARCHIVE_CACHE_DIR, else `.archive-cache` beside the export builds
// (EXPORT_BUILDS_DIR's parent: /data/builds in a container — the builds
// volume both the editor and umtool mount — export/ on a checkout). Bounded:
-// past ARCHIVE_CACHE_MAX_MB (default 2048) the least recently used documents
+// past ARCHIVE_CACHE_MAX_MB (default 512: the host's disk is nearly full) the least recently used documents
// are dropped. Never transcripts/ (it is the corpus), never /tmp (it is RAM).
import { createHash } from "node:crypto";
@@ -43,7 +43,8 @@ import { OffOriginError, fetchOnOrigin, plainGetJson, readBounded, type FetchLik
export const CORPUS_TTL_MS = 10 * 60_000;
export const GAP_MS = 250;
-const DEFAULT_MAX_BYTES = 2048 * 1024 * 1024;
+export const ARCHIVE_CACHE_DEFAULT_MB = 512;
+const DEFAULT_MAX_BYTES = ARCHIVE_CACHE_DEFAULT_MB * 1024 * 1024;
type Meta = {
url: string;
@@ -83,7 +84,7 @@ export class ArchiveDiskCache {
private sleep: (ms: number) => Promise<void>;
private gapMs: number;
private corpusTtlMs: number;
- private maxBytes: number;
+ readonly maxBytes: number;
// One network request at a time: each waits on this.
private line: Promise<void> = Promise.resolve();
private lastEnd = 0;
diff --git a/common/lib/envVars.ts b/common/lib/envVars.ts
@@ -137,7 +137,7 @@ const DECLARED: EnvVarDecl[] = [
{ name: "TRANSCRIPT_SITE_URL", audience: "runtime", default: "—", readBy: "mcp/src/sources.ts", doc: "MCP server: one published archive to read over HTTP. Also the default connected archive (common/lib/remoteArchives.ts): the editor, umtool and the MCP offer it as a source when settings.remoteArchives does not list it, without writing it." },
{ name: "ARCHILYZER_ALLOW_PRIVATE_ARCHIVES", audience: "runtime", default: "off", readBy: "common/controller/remoteArchives.ts", doc: "`1` lets the editor connect an archive whose host is this machine or its network (loopback, private, link-local, a `.local` name, or a name resolving to such an address), which is refused otherwise: umtool, which can connect one, is open on the LAN. TRANSCRIPT_SITE_URL's archive, and one already written in settings.json, are connected without it." },
{ name: "ARCHIVE_CACHE_DIR", audience: "runtime", default: "`.archive-cache` beside EXPORT_BUILDS_DIR", readBy: "common/lib/archiveCache-server.ts", doc: "Where a remote archive's documents (corpus.json, manifests, shard pages) are kept on disk, by the archive's build: a sweep over a published archive downloads a shard once per build, not once per sweep. In a container it is on the builds volume." },
- { name: "ARCHIVE_CACHE_MAX_MB", audience: "runtime", default: "2048", readBy: "common/lib/archiveCache-server.ts", doc: "The disk cache of remote archive documents' size cap, MB: past it the least recently used are dropped." },
+ { name: "ARCHIVE_CACHE_MAX_MB", audience: "runtime", default: "512", readBy: "common/lib/archiveCache-server.ts", doc: "The disk cache of remote archive documents' size cap, MB: past it the least recently used are dropped." },
{ name: "ARCHIVE_CACHE", audience: "runtime", default: "on (off under node's test runner)", readBy: "common/lib/archiveCache-server.ts", doc: "`0` reads remote archives without the disk cache (every read over the network, still one at a time); `1` turns it on under node's test runner, where it is off." },
{ name: "TRANSCRIPT_HUB_URL", audience: "runtime", default: "—", readBy: "mcp/src/sources.ts", doc: "MCP server: a hub, federating every archive it lists." },
{ name: "TRANSCRIPT_LOCAL_DIR", audience: "runtime", default: "—", readBy: "mcp/src/sources.ts", doc: "MCP server: a composed public dir on disk." },