Skip to content

armgit / kiln

Public Imported from GitHub
0

Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.

fix(site): redirect retired scene-pack releases to their successors (#280)

Matthew Kissingerc3ee4b872864
diff --git a/docs/site-indexing.md b/docs/site-indexing.md
index 1660a944..8747e626 100644
--- a/docs/site-indexing.md
+++ b/docs/site-indexing.md
@@ -80,3 +80,23 @@ already answered with `X-Robots-Tag: noindex`.
The production host is unaffected; `validate-static` checks both.
Robots rules, canonicals and the noindex pages are unchanged.
+
+## Retired scene-pack releases — October 26, 2026
+
+Search Console reported 404s for files under scene-pack releases that production had
+since replaced, for example `/scene-packs/golden-gate/g9/THIRD-PARTY-NOTICES.txt` and
+`/scene-packs/foundry-floor/ff3-review2/licenses/ASSET-LICENSE.txt`. Earlier Pages
+deployments show five retired releases were served: Golden Gate `g9` and `g9-code5`,
+Foundry Floor `ff3-review2`, and Troy `troy-20261005-04` and `troy-20261005-06`.
+
+`site/public/_redirects` moves each retired directory to its current release with a
+`301` splat rule, for example `/scene-packs/golden-gate/g9/*` to
+`/scene-packs/golden-gate/g9-code6/:splat`. Every Golden Gate and Foundry Floor file
+keeps its name in the current release. Most Troy files do too; those that do not
+redirect and then return 404: from `troy-20261005-04`, 24 per-revision source files
+and 8 qualification pages (32 of 1,912), and from `troy-20261005-06`, 36 hashed bundle
+chunks (of 1,937). `validate-static` checks that each rule is a 301 splat move, that no built file
+sits under a retired directory, that each target directory has files (in a packs
+build; the reduced `KILN_SITE_PACKS=0` build has no scene packs), and that no target
+is itself redirected. Asset JSON and GLB 404s and the retired `play.` hosts
+are left alone.
diff --git a/site/public/_redirects b/site/public/_redirects
new file mode 100644
index 00000000..b886988d
--- /dev/null
+++ b/site/public/_redirects
@@ -0,0 +1,10 @@
+# Retired scene-pack releases (Cloudflare Pages redirects, developers.cloudflare.com/pages/configuration/redirects/).
+# Each release below was served in production and was then replaced; its files keep their names under the current
+# release, so a crawled or linked URL (licences, notices, pack files) moves permanently to the same file there.
+# validate-static checks every rule: no built file under a retired prefix, and files under each target prefix.
+# When a scene pack moves to a new release, point its earlier rules at the new one and add one for the release retired.
+/scene-packs/golden-gate/g9/* /scene-packs/golden-gate/g9-code6/:splat 301
+/scene-packs/golden-gate/g9-code5/* /scene-packs/golden-gate/g9-code6/:splat 301
+/scene-packs/foundry-floor/ff3-review2/* /scene-packs/foundry-floor/ff3-review2-code5/:splat 301
+/scene-packs/troy/troy-20261005-04/* /scene-packs/troy/troy-20261005-07/:splat 301
+/scene-packs/troy/troy-20261005-06/* /scene-packs/troy/troy-20261005-07/:splat 301
diff --git a/site/scripts/static-validation-core.mjs b/site/scripts/static-validation-core.mjs
index 7911efc6..c4b90fa2 100644
--- a/site/scripts/static-validation-core.mjs
+++ b/site/scripts/static-validation-core.mjs
@@ -444,6 +444,47 @@ export function headersErrors({ text, inlineScripts = [], files = [], sealedFile
return errors;
}
+/**
+ * The rules of `_redirects` (Cloudflare Pages): `FROM TO STATUS` per line, `#` comments. This site uses them only to
+ * move a retired release directory to its successor, so each rule must be `/a/old/* /a/new/:splat 301`.
+ */
+export function parseRedirectRules(text) {
+ const rules = [];
+ for (const raw of text.split('\n')) {
+ const line = raw.trim();
+ if (!line || line.startsWith('#')) continue;
+ const [from, to, status, ...rest] = line.split(/\s+/);
+ if (!to || rest.length) throw new Error(`_redirects: expected "FROM TO STATUS": ${line}`);
+ rules.push({ from, to, status: Number(status ?? 302) });
+ }
+ return rules;
+}
+
+/**
+ * Every redirect is a permanent splat move between two directories, its target directory has files in the build, no
+ * built file sits under a source directory (a rule would hide it or be dead), and no target is itself redirected.
+ * `targets: false` skips the target check for the reduced build (KILN_SITE_PACKS=0), which carries no scene packs.
+ */
+export function redirectsErrors({ text, files = [], targets = true }) {
+ let rules;
+ try { rules = parseRedirectRules(text); } catch (error) { return [error.message]; }
+ const errors = [];
+ const directory = (path, suffix) => path.startsWith('/') && path.endsWith(suffix) && !path.slice(0, -suffix.length).includes('*') ? path.slice(1, -suffix.length + 1) : null;
+ const sources = rules.map((rule) => directory(rule.from, '/*'));
+ for (const [index, rule] of rules.entries()) {
+ const from = sources[index];
+ const to = directory(rule.to, '/:splat');
+ if (!from || !to) { errors.push(`${rule.from} -> ${rule.to}: expected "/dir/* /other-dir/:splat"`); continue; }
+ if (rule.status !== 301) errors.push(`${rule.from}: status must be 301, got ${rule.status}`);
+ if (sources.indexOf(from) !== index) errors.push(`${rule.from} is redirected twice`);
+ if (sources.includes(to)) errors.push(`${rule.to} is itself redirected; point ${rule.from} at the final directory`);
+ const shadowed = files.filter((file) => file.startsWith(from));
+ if (shadowed.length) errors.push(`${rule.from} covers ${shadowed.length} built files (first /${shadowed[0]})`);
+ if (targets && !files.some((file) => file.startsWith(to))) errors.push(`${rule.to}: no built file under /${to}`);
+ }
+ return errors;
+}
+
export function inspectHtml(html) {
const document = parse(html);
const elements = [];
diff --git a/site/scripts/static-validation.test.ts b/site/scripts/static-validation.test.ts
index 5fa835f1..d6ac292a 100644
--- a/site/scripts/static-validation.test.ts
+++ b/site/scripts/static-validation.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, test } from 'bun:test';
-import { ARCHIVE_INDEX_ROUTE, archiveIndexingErrors, copyErrors, discoveryErrors, embeddedDocumentErrors, foundryFloorErrors, headersErrors, headersFor, inspectHtml, parseHeaderRules, scriptHashSource, isArchiveItemRoute, isEmbeddedDocument, licenceSpellingErrors, ownerReviewErrors, resolveInternalLink, retiredNameErrors, routeForFile, socialMetadataErrors } from './static-validation-core.mjs';
+import { ARCHIVE_INDEX_ROUTE, archiveIndexingErrors, copyErrors, discoveryErrors, embeddedDocumentErrors, foundryFloorErrors, headersErrors, headersFor, inspectHtml, parseHeaderRules, scriptHashSource, isArchiveItemRoute, isEmbeddedDocument, licenceSpellingErrors, ownerReviewErrors, parseRedirectRules, redirectsErrors, resolveInternalLink, retiredNameErrors, routeForFile, socialMetadataErrors } from './static-validation-core.mjs';
import foundryFloor from '../src/data/foundry-floor.json';
+import { readFileSync } from 'node:fs';
test('static routes use directory URLs while 404 keeps its HTML route', () => {
expect(routeForFile('index.html')).toBe('/');
expect(routeForFile('docs/install/index.html')).toBe('/docs/install/');
@@ -455,3 +456,47 @@ ${extra}`;
expect(page.inlineScripts).toEqual([script]);
});
});
+
+describe('retired release directories in _redirects', () => {
+ const built = ['scene-packs/golden-gate/g9-code6/THIRD-PARTY-NOTICES.txt', 'scene-packs/golden-gate/g9-code6/licenses/FEDERAL-DATA.txt', 'scene-packs/troy/troy-20261005-07/web/index.html'];
+ const rule = (from: string, to: string, status = '301') => `/scene-packs/${from}/* /scene-packs/${to}/:splat ${status}\n`;
+
+ test('the published file parses and every rule is a permanent move', () => {
+ const rules = parseRedirectRules(readFileSync(new URL('../public/_redirects', import.meta.url), 'utf8'));
+ expect(rules.length).toBeGreaterThan(0);
+ for (const { from, to, status } of rules) {
+ expect(status).toBe(301);
+ expect(from).toMatch(/^\/scene-packs\/[a-z0-9-]+\/[a-z0-9-]+\/\*$/);
+ expect(to).toMatch(/^\/scene-packs\/[a-z0-9-]+\/[a-z0-9-]+\/:splat$/);
+ }
+ });
+
+ test('a splat move to a built directory passes', () => {
+ const text = `# comment\n\n${rule('golden-gate/g9', 'golden-gate/g9-code6')}${rule('troy/troy-20261005-04', 'troy/troy-20261005-07')}`;
+ expect(redirectsErrors({ text, files: built })).toEqual([]);
+ });
+
+ test('the reduced build has no scene packs, so only its targets go unchecked', () => {
+ const text = rule('golden-gate/g9', 'golden-gate/g9-code6');
+ expect(redirectsErrors({ text, files: ['index.html'], targets: false })).toEqual([]);
+ expect(redirectsErrors({ text, files: ['index.html'] })).toEqual(['/scene-packs/golden-gate/g9-code6/:splat: no built file under /scene-packs/golden-gate/g9-code6/']);
+ expect(redirectsErrors({ text: rule('golden-gate/g9-code6', 'golden-gate/g10'), files: built, targets: false })).toEqual([
+ '/scene-packs/golden-gate/g9-code6/* covers 2 built files (first /scene-packs/golden-gate/g9-code6/THIRD-PARTY-NOTICES.txt)',
+ ]);
+ });
+
+ test('a shadowed, empty, chained, temporary or malformed rule is reported', () => {
+ expect(redirectsErrors({ text: rule('golden-gate/g9-code6', 'golden-gate/g10'), files: built })).toEqual([
+ '/scene-packs/golden-gate/g9-code6/* covers 2 built files (first /scene-packs/golden-gate/g9-code6/THIRD-PARTY-NOTICES.txt)',
+ '/scene-packs/golden-gate/g10/:splat: no built file under /scene-packs/golden-gate/g10/',
+ ]);
+ expect(redirectsErrors({ text: rule('golden-gate/g9', 'golden-gate/g9-code5') + rule('golden-gate/g9-code5', 'golden-gate/g9-code6'), files: built })).toEqual([
+ '/scene-packs/golden-gate/g9-code5/:splat is itself redirected; point /scene-packs/golden-gate/g9/* at the final directory',
+ '/scene-packs/golden-gate/g9-code5/:splat: no built file under /scene-packs/golden-gate/g9-code5/',
+ ]);
+ expect(redirectsErrors({ text: rule('golden-gate/g9', 'golden-gate/g9-code6', '302'), files: built })).toEqual(['/scene-packs/golden-gate/g9/*: status must be 301, got 302']);
+ expect(redirectsErrors({ text: rule('golden-gate/g9', 'golden-gate/g9-code6').repeat(2), files: built })).toEqual(['/scene-packs/golden-gate/g9/* is redirected twice']);
+ expect(redirectsErrors({ text: '/old /new 301\n', files: built })).toEqual(['/old -> /new: expected "/dir/* /other-dir/:splat"']);
+ expect(redirectsErrors({ text: '/a/* /b/:splat 301 extra\n', files: built })).toEqual(['_redirects: expected "FROM TO STATUS": /a/* /b/:splat 301 extra']);
+ });
+});
diff --git a/site/scripts/validate-static.mjs b/site/scripts/validate-static.mjs
index 5558c8a6..a46ccf88 100644
--- a/site/scripts/validate-static.mjs
+++ b/site/scripts/validate-static.mjs
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
import { HtmlValidate } from 'html-validate';
import sharp from 'sharp';
import { engineNoteErrors, isAssetPageRoute, readGlbFacts } from './engine-note.mjs';
-import { ARCHIVE_INDEX_ROUTE, archiveIndexingErrors, copyErrors, DESCRIPTION_WARNING_LENGTH, discoveryErrors, embeddedDocumentErrors, foundryFloorErrors, headersErrors, headersFor, inspectHtml, isArchiveItemRoute, isEmbeddedDocument, isSceneSourceDocument, ORIGIN, parseHeaderRules, resolveInternalLink, retiredNameErrors, routeForFile, scriptHashSource, socialMetadataErrors } from './static-validation-core.mjs';
+import { ARCHIVE_INDEX_ROUTE, archiveIndexingErrors, copyErrors, DESCRIPTION_WARNING_LENGTH, discoveryErrors, embeddedDocumentErrors, foundryFloorErrors, headersErrors, headersFor, inspectHtml, isArchiveItemRoute, isEmbeddedDocument, isSceneSourceDocument, ORIGIN, parseHeaderRules, parseRedirectRules, redirectsErrors, resolveInternalLink, retiredNameErrors, routeForFile, scriptHashSource, socialMetadataErrors } from './static-validation-core.mjs';
import {sealedTroyCache} from './sealed-cache.mjs';
import {viewerModelInput} from './viewer-model-input.mjs';
import { glbJsonText } from './private-data.mjs';
@@ -218,6 +218,16 @@ const headerProblems = headersText ? headersErrors({ text: headersText, inlineSc
for (const message of headerProblems) add('/_headers', 'headers', message);
const headerRules = headersText ? parseHeaderRules(headersText) : [];
const immutableFiles = distFiles.filter((file) => /immutable/.test(headersFor(headerRules, `/${file}`)['cache-control'] ?? ''));
+// Retired release directories move to their successors (dist/_redirects); a missing file means no redirects.
+let redirectsText = '';
+try { redirectsText = await readFile(resolve(root, '_redirects'), 'utf8'); } catch (error) { if (error.code !== 'ENOENT') throw error; }
+// The reduced build (KILN_SITE_PACKS=0, as in CI) has no scene packs, so it cannot check the redirect targets.
+let packsBuild = true;
+try { packsBuild = JSON.parse(await readFile(resolve(root, 'build-info.json'), 'utf8')).kilnSitePacks !== '0'; } catch (error) { if (error.code !== 'ENOENT') throw error; }
+const redirectProblems = redirectsText ? redirectsErrors({ text: redirectsText, files: distFiles, targets: packsBuild }) : [];
+for (const message of redirectProblems) add('/_redirects', 'redirects', message);
+let redirectRules = [];
+try { redirectRules = parseRedirectRules(redirectsText); } catch { /* Reported by redirectsErrors above. */ }
await mkdir(reportDirectory, { recursive: true });
const result = { pages: pages.size, headers: { rules: headerRules.length, inlineScripts: inlineScripts.map(scriptHashSource), immutableFiles: immutableFiles.length, problems: headerProblems.length }, internalErrors: errors.length, htmlErrors: htmlErrorCount, errors, warnings, glbs: { files: glbs.length, withoutDraco: dracoFree }, htmlResults, socialCards: Object.fromEntries(imageChecks), archive, discovery, engineNotes: engineSummary, sitemapUrls, externalLinks: Array.from(external, ([url, from]) => ({ url, pages: Array.from(from) })).sort((a, b) => a.url.localeCompare(b.url)) };
await writeFile(resolve(reportDirectory, 'static-validation.json'), `${JSON.stringify(result, null, 2)}\n`);
@@ -231,6 +241,7 @@ console.log(`Engine notes: ${engineSummary.withNote} of ${engineSummary.assetPag
console.log(`Retired working title: ${retired.length} matches in ${pages.size} pages, ${files.length} file names and the discovery files. Foundry Floor pages: ${foundry.length} problems.`);
console.log(`GLBs: ${glbs.length} read, ${dracoFree} without KHR_draco_mesh_compression. Copy rules (glued numbers, licence spelling, owner status): ${errors.filter((error) => error.kind === 'copy').length} problems.`);
console.log(`Headers: ${headerRules.length} rules in _headers; ${inlineScripts.length} distinct inline scripts, each listed by hash in the report-only CSP; ${immutableFiles.length} files cached as immutable; ${headerProblems.length} problems.`);
+console.log(`Redirects: ${redirectRules.length} rules in _redirects${packsBuild ? '' : ' (targets not checked: reduced build without scene packs)'}; ${redirectProblems.length} problems.`);
console.log(`Warnings: ${warnings.length} meta descriptions over ${DESCRIPTION_WARNING_LENGTH} characters${warnings.length ? ` (${warnings.map((warning) => warning.page).join(', ')})` : ''}.`);
console.log(`Report: ${resolve(reportDirectory, 'static-validation.json')}`);
if (errors.length || htmlErrorCount) process.exitCode = 1;