Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit cab41c8131e2f0beafe7b33512da1d49a1195ce4
parent fcdfc744ed93d0ae40daefff152aa984c9aa4749
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 17:49:54 -0400

umtool: every redirects.mjs row is permanent (308)

The moves are settled: all 16 rows (the `/?from=` → `/create` hand-off kept,
the editor still links it) answer 308. A browser caches a 308 forever, so a
row is never repointed or removed. redirects.spec asserts 308 and the
Location for every row; the hrefs unit test asserts `permanent: true`. The
claimed project's page redirect (`/projects/<path>` → its article) stays a
307: it follows state.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/e2e/redirects.spec.ts | 15++++++++-------
Mumtool/lib/hrefs.test.mjs | 3++-
Mumtool/redirects.mjs | 14++++++++------
3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/umtool/e2e/redirects.spec.ts b/umtool/e2e/redirects.spec.ts @@ -3,9 +3,10 @@ import { REDIRECTS } from "./urls"; // --------------------------------------------------------------------------- // Every old page address (umtool/redirects.mjs, the table next.config.ts -// answers): requested with redirects OFF, each must be a 307 -- never a 308, -// which a browser caches forever, until P6 -- to the row's destination, with -// the query passed through. Then the destination itself must answer. +// answers): requested with redirects OFF, each must be a 308 (permanent since +// P6b; a browser caches it forever, so a row is never repointed) to the row's +// destination, with the query passed through. Then the destination itself must +// answer. // // The rows are read from the table, not copied here, so a new row is covered // the day it is added. Parameters get a sample value; `:path*` gets two @@ -45,7 +46,7 @@ test("the table has the P3, P5 and P6 rows, reserved /browse tools before the ca expect(sources.indexOf(s), s).toBeGreaterThanOrEqual(0); expect(sources.indexOf(s), `${s} must come before the catch-all`).toBeLessThan(catchAll); } - for (const r of REDIRECTS) expect(r.permanent, r.source).toBe(false); + for (const r of REDIRECTS) expect(r.permanent, r.source).toBe(true); // P5: the editor's hand-off, only when the query has `from`; the new-article form. expect(REDIRECTS.find((r) => r.source === "/")).toMatchObject({ destination: "/create", has: [{ type: "query", key: "from" }] }); expect(REDIRECTS.find((r) => r.source === "/articles/new")?.destination).toBe("/create?make=article"); @@ -57,11 +58,11 @@ for (const row of REDIRECTS) { const from = fill(row.source); // A row that matches only when the query HAS a key is asked with it. const needs = (row.has ?? []).filter((h) => h.type === "query").map((h) => `${h.key}=testchan%2Fvid1`); - test(`${row.source}${needs.length ? `?${needs.join("&")}` : ""} → ${row.destination} (307, query kept)`, async ({ request }) => { + test(`${row.source}${needs.length ? `?${needs.join("&")}` : ""} → ${row.destination} (308, query kept)`, async ({ request }) => { for (const query of (["", "q=x+y&note=n1"] as string[]).map((q) => [...needs, ...(q ? [q] : [])].join("&"))) { const url = query ? `${from}?${query}` : from; const res = await request.get(url, { maxRedirects: 0 }); - expect(res.status(), url).toBe(307); + expect(res.status(), url).toBe(308); expect(parts(res.headers()["location"]), url).toEqual(parts(expected(row.destination, query))); } // And where it lands answers (the escape hatch needs a project to open). @@ -81,7 +82,7 @@ for (const [old, now] of [ ] as const) { test(`${old} lands on ${now}`, async ({ request }) => { const res = await request.get(old, { maxRedirects: 0 }); - expect(res.status()).toBe(307); + expect(res.status()).toBe(308); expect(parts(res.headers()["location"])).toEqual(parts(now)); expect((await request.get(old)).status()).toBe(200); }); diff --git a/umtool/lib/hrefs.test.mjs b/umtool/lib/hrefs.test.mjs @@ -74,7 +74,8 @@ test("every page address the builders make is still served or redirected", async const { REDIRECTS } = await import("../redirects.mjs"); const old = ["/browse", "/browse/decisions", "/browse/find", "/browse/faces", "/browse/sources", "/browse/trim/:set", "/browse/at", "/browse/:path*", "/articles", "/sites", "/mix", "/bench", "/articles/new", "/"]; for (const s of old) assert.ok(REDIRECTS.some((r) => r.source === s), s); - for (const r of REDIRECTS) assert.equal(r.permanent, false, r.source); + // Permanent (308) since P6b. + for (const r of REDIRECTS) assert.equal(r.permanent, true, r.source); }); test("site pages, tools and piles", () => { diff --git a/umtool/redirects.mjs b/umtool/redirects.mjs @@ -14,9 +14,10 @@ // { // source: "/browse/:path*", // path-to-regexp; `:x*` zero or more segments // destination: "/projects/:path*", // matched parameters carry over -// permanent: false, // 307 until P6, then 308 -- a browser -// // caches a 308 forever, so a wrong one -// // cannot be taken back +// permanent: true, // 308 since P6b (307 before). A browser +// // caches a 308 forever, so a row is never +// // repointed or removed: the old address +// // must keep landing where it said // has: [{ type: "query", key: "from" }], // optional: only when the query has `from` // phase: "P3", // ours, not Next's: which phase added it. // // next.config.ts strips it. @@ -39,9 +40,10 @@ * }} RedirectRow */ -const p3 = (source, destination) => ({ source, destination, permanent: false, phase: "P3" }); -const p5 = (source, destination, extra = {}) => ({ source, destination, permanent: false, ...extra, phase: "P5" }); -const p6 = (source, destination) => ({ source, destination, permanent: false, phase: "P6" }); +// Every row is permanent (308) since P6b: the moves are settled. +const p3 = (source, destination) => ({ source, destination, permanent: true, phase: "P3" }); +const p5 = (source, destination, extra = {}) => ({ source, destination, permanent: true, ...extra, phase: "P5" }); +const p6 = (source, destination) => ({ source, destination, permanent: true, phase: "P6" }); /** @type {RedirectRow[]} */ export const REDIRECTS = [