v0.27.0 (#44): LLM-placed named map point markers
CI / build + unit + e2e (pull_request) Successful in 2m36s

- shared: 8 MarkerTypes + MARKER_TYPE_INFO (label/color/glyph); MapMarker;
  GameState.markers (required, [] at init); TurnResult.markers {add,remove};
  MarkerSpec/MarkerInfo; FNV-1a 4-char markerId; MAX_MARKERS=400.
- data: new public/region-centroids.json (1,800 anchors = largest-part centroid
  + spread ~0.1x min-bbox) built by new idempotent scripts/build-region-centroids.mjs.
- server: regions.ts centroid loader (public/ then dist/); engine applyTurnResult
  marker ops (remove -> owner-recompute -> add, jitter, cap, never throws);
  prompt documents the contract; buildUserPrompt carries markers; stub marker-free.
- client: WorldMap symbol layer rendered as canvas per-type icons (glyph CDN dead);
  hover tooltip shows name; click focuses owning nation.
- tests: 168 -> 189 (centroids script, regions centroids, db legacy, engine markers).
This commit is contained in:
2026-10-14 22:37:29 +00:00
parent aa1bd3c5aa
commit a129c2ab81
19 changed files with 10437 additions and 45 deletions
+34
View File
@@ -5,8 +5,10 @@ import { tmpdir } from 'node:os';
import path from 'node:path';
import {
allTerritoryKeys,
centroidOf,
expandCountriesToKeys,
hasAdjacency,
hasCentroids,
hasRegionData,
loadRegions,
neighboursOf,
@@ -103,6 +105,7 @@ describe('regions (region-key loader, v0.19 #16 P1)', () => {
version: 1,
unowned: [],
pendingNationOps: [],
markers: [],
};
// 16 GBR sub-regions + 42 FRA sub-regions, no overlap between the two.
expect(allTerritoryKeys(state).size).toBe(58);
@@ -133,6 +136,19 @@ describe('regions (region-key loader, v0.19 #16 P1)', () => {
expect(neighboursOf([])).toEqual([]);
});
it('(v0.27 #44) hasCentroids() is true and centroidOf resolves a real key to a plausible location', () => {
expect(hasCentroids()).toBe(true);
const ain = centroidOf('ain-lqtt');
expect(ain).toBeDefined();
expect(ain!.lat).toBeCloseTo(46.16, 1);
expect(ain!.lon).toBeCloseTo(4.8, 1);
expect(ain!.spread).toBeGreaterThan(0);
});
it('(v0.27 #44) centroidOf returns undefined for an unknown key', () => {
expect(centroidOf('not-a-real-key-xyz')).toBeUndefined();
});
describe('graceful degradation with no region data', () => {
beforeEach(() => resetRegions());
@@ -146,6 +162,9 @@ describe('regions (region-key loader, v0.19 #16 P1)', () => {
// and no adjacency: the LLM tool / frontier field switch off
expect(hasAdjacency()).toBe(false);
expect(neighboursOf(['moselle-rygy'])).toEqual([]);
// and no centroids: the marker-placement path degrades to a no-op
expect(hasCentroids()).toBe(false);
expect(centroidOf('ain-lqtt')).toBeUndefined();
});
});
@@ -197,6 +216,21 @@ describe('loadRegions resolves the manifest per environment (dev public/ vs prod
expect(loadRegions(prodRoot)).toBe(true);
expect(hasAdjacency()).toBe(false);
expect(neighboursOf(['moselle-rygy'])).toEqual([]);
// and no centroids (not copied into this dist/) -> marker placement degrades
expect(hasCentroids()).toBe(false);
expect(centroidOf('ain-lqtt')).toBeUndefined();
});
it('(v0.27 #44) a dist/ WITH the centroids manifest loads them (prod layout)', () => {
copyFileSync(
path.join(realRoot, 'public', 'region-centroids.json'),
path.join(prodRoot, 'dist', 'region-centroids.json'),
);
expect(loadRegions(prodRoot)).toBe(true);
expect(hasCentroids()).toBe(true);
const ain = centroidOf('ain-lqtt');
expect(ain).toBeDefined();
expect(ain!.lat).toBeCloseTo(46.16, 1);
});
it('returns false and no data when neither public/ nor dist/ holds the files', () => {