From a2fe00968d397d8b9930e233d23f28c65e25f723 Mon Sep 17 00:00:00 2001 From: Nibu Date: Sat, 14 Nov 2026 09:03:17 +0000 Subject: [PATCH] ridge: revalidate index.json, the one mutable pointer; pin pxPerDegH to px_per_deg_h Co-Authored-By: Claude Sonnet 5.5 --- src/app/features/scene/ridge/manifest.test.ts | 10 ++++++++++ src/app/features/scene/ridge/manifest.ts | 9 ++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/app/features/scene/ridge/manifest.test.ts b/src/app/features/scene/ridge/manifest.test.ts index b0f172b7..21444abc 100644 --- a/src/app/features/scene/ridge/manifest.test.ts +++ b/src/app/features/scene/ridge/manifest.test.ts @@ -11,6 +11,7 @@ describe('parseManifest', () => { windowDeg: 72, planeW: 1280, planeH: 600, + pxPerDegH: 1280 / 72, // not px_per_deg_v (17.7): a real bake's two differ 10x horizonRow: 314.5, }); expect(m.view.place).toEqual({ id: 'vienna', lat: 48.19, lon: 16.35, altitudeKm: 0.183 }); @@ -76,6 +77,15 @@ describe('loadManifest', () => { ]); }); + it('revalidates the index, the one mutable pointer, and leaves the content-addressed manifest to the cache', async () => { + const f = serve(files()); + await loadManifest('/b/'); + expect(f.mock.calls).toEqual([ + ['/b/public/ridge/index.json', { cache: 'no-cache' }], + ['/b/public/ridge/vienna-abc123abc123/manifest.json', undefined], + ]); + }); + it('place picks the index entry; an unknown id falls back to the default', async () => { serve(files()); expect((await loadManifest('/b/', 'graz')).view.place.id).toBe('graz'); diff --git a/src/app/features/scene/ridge/manifest.ts b/src/app/features/scene/ridge/manifest.ts index bb3e0b82..a3d0e33e 100644 --- a/src/app/features/scene/ridge/manifest.ts +++ b/src/app/features/scene/ridge/manifest.ts @@ -112,8 +112,8 @@ export function parseManifest(raw: unknown, dir: string): RidgeManifest { }; } -async function getJson(url: string): Promise { - const res = await fetch(url); +async function getJson(url: string, init?: RequestInit): Promise { + const res = await fetch(url, init); if (!res.ok) throw new Error(`ridge: ${url} answered ${res.status}`); return res.json(); } @@ -131,7 +131,10 @@ export function loadManifest(baseUrl: string, placeId?: string): Promise { - const index = parseIndex(await getJson(`${root}index.json`)); + const index = parseIndex( + // The index is the one mutable pointer (a rebake deletes the old directory it named); the manifest and planes are content-addressed. + await getJson(`${root}index.json`, { cache: 'no-cache' }) + ); const id = placeId !== undefined && placeId in index.places ? placeId : index.default; const name = index.places[id]; if (name === undefined) throw new Error(`ridge: index has no place ${id}`);