ridge: revalidate index.json, the one mutable pointer; pin pxPerDegH to px_per_deg_h

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Nibu 2026-11-14 09:03:17 +00:00
commit a2fe00968d
2 changed files with 16 additions and 3 deletions

View file

@ -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');

View file

@ -112,8 +112,8 @@ export function parseManifest(raw: unknown, dir: string): RidgeManifest {
};
}
async function getJson(url: string): Promise<unknown> {
const res = await fetch(url);
async function getJson(url: string, init?: RequestInit): Promise<unknown> {
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<RidgeMa
const hit = memo.get(key);
if (hit) return hit;
const p = (async () => {
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}`);