refactor: rename core-public -> engine-public; fold helpers in; drop shared

Tighten the package model around the determinism invariant: everything the
engine imports must itself be deterministic.

- Rename core-public -> engine-public (package, dir, `engine-public/*` alias,
  all 118 import sites). It is the deterministic public surface the engine
  depends on and that client/server also use.
- Move the pure formatting helpers (renderNumber/renderTroops) from shared
  into engine-public/format — the engine uses them and they're deterministic.
- Drop the now-empty shared package (and its alias). `shared` was intended for
  client/server-shared, engine-forbidden code; there is none yet, so it is
  removed and can be re-added when such code appears.

Final graph: engine-public (leaf) <- engine <- {client, server};
client/server also -> engine-public.

Verified: tsc clean; 1364 + 65 tests pass; prod build succeeds; engine-public
is a leaf; engine has no client/server imports. Lockfile regenerated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Evan Pelle
2026-06-10 20:32:32 +00:00
parent a7f992e9b0
commit 43d07ca85f
145 changed files with 193 additions and 201 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ import {
UnitType,
} from "engine/game/Game";
import { TileRef } from "engine/game/GameMap";
import { GameID } from "core-public/Schemas";
import { GameID } from "engine-public/Schemas";
import { setup } from "./util/Setup";
import { TestConfig } from "./util/TestConfig";
import { constructionExecution } from "./util/utils";
+1 -1
View File
@@ -1,6 +1,6 @@
import { AttackExecution } from "engine/execution/AttackExecution";
import { Game, Player, PlayerInfo, PlayerType } from "engine/game/Game";
import { GOLD_INDEX_WAR, GOLD_INDEX_WORK } from "core-public/StatsSchemas";
import { GOLD_INDEX_WAR, GOLD_INDEX_WORK } from "engine-public/StatsSchemas";
import { setup } from "./util/Setup";
let game: Game;
+1 -1
View File
@@ -1,6 +1,6 @@
import { SpawnExecution } from "engine/execution/SpawnExecution";
import { Game, Player, PlayerInfo, PlayerType } from "engine/game/Game";
import { GameID } from "core-public/Schemas";
import { GameID } from "engine-public/Schemas";
import { setup } from "./util/Setup";
const gameID: GameID = "test_game";
+1 -1
View File
@@ -1,5 +1,5 @@
import { cosmeticRelationship } from "client/Cosmetics";
import { UserMeResponse } from "core-public/ApiSchemas";
import { UserMeResponse } from "engine-public/ApiSchemas";
const product = { productId: "prod_123", priceId: "price_123", price: "$4.99" };
+1 -1
View File
@@ -9,7 +9,7 @@ import {
UnitType,
} from "engine/game/Game";
import { TileRef } from "engine/game/GameMap";
import { GameID } from "core-public/Schemas";
import { GameID } from "engine-public/Schemas";
import { setup } from "./util/Setup";
import { executeTicks } from "./util/utils";
+1 -1
View File
@@ -2,7 +2,7 @@ import { DonateGoldExecution } from "engine/execution/DonateGoldExecution";
import { DonateTroopsExecution } from "engine/execution/DonateTroopExecution";
import { SpawnExecution } from "engine/execution/SpawnExecution";
import { PlayerInfo, PlayerType } from "engine/game/Game";
import { GameID } from "core-public/Schemas";
import { GameID } from "engine-public/Schemas";
import { setup } from "./util/Setup";
describe("Donate troops to an ally", () => {
+2 -2
View File
@@ -9,14 +9,14 @@ import {
GameMode,
GameType,
} from "engine/game/Game";
import { AnalyticsRecord, GameConfig } from "core-public/Schemas";
import { AnalyticsRecord, GameConfig } from "engine-public/Schemas";
import {
GOLD_INDEX_STEAL,
GOLD_INDEX_TRADE,
GOLD_INDEX_TRAIN_OTHER,
GOLD_INDEX_TRAIN_SELF,
GOLD_INDEX_WAR,
} from "core-public/StatsSchemas";
} from "engine-public/StatsSchemas";
describe("Ranking class", () => {
const mockConfig: GameConfig = {
+1 -1
View File
@@ -2,7 +2,7 @@ import { describe, expect, test } from "vitest";
import {
GraphicsOverrides,
GraphicsOverridesSchema,
} from "core-public/GraphicsOverrides";
} from "engine-public/GraphicsOverrides";
import { applyGraphicsOverrides } from "client/render/gl/RenderOverrides";
import { createRenderSettings } from "client/render/gl/RenderSettings";
+1 -1
View File
@@ -4,7 +4,7 @@ import {
PublicGameInfo,
PublicGames,
PublicGameType,
} from "core-public/Schemas";
} from "engine-public/Schemas";
function lobby(
gameID: string,
+1 -1
View File
@@ -9,7 +9,7 @@ import {
UnitType,
} from "engine/game/Game";
import { TileRef } from "engine/game/GameMap";
import { GameID } from "core-public/Schemas";
import { GameID } from "engine-public/Schemas";
import { setup } from "./util/Setup";
import { constructionExecution, executeTicks } from "./util/utils";
+1 -1
View File
@@ -12,7 +12,7 @@ import {
Nation as ManifestNation,
} from "engine/game/TerrainMapLoader";
import { PseudoRandom } from "engine/PseudoRandom";
import { GameConfig, GameStartInfo } from "core-public/Schemas";
import { GameConfig, GameStartInfo } from "engine-public/Schemas";
function makeManifestNations(count: number): ManifestNation[] {
const result: ManifestNation[] = [];
+2 -2
View File
@@ -1,6 +1,6 @@
import { resolveCosmetics } from "client/Cosmetics";
import { UserMeResponse } from "core-public/ApiSchemas";
import { Cosmetics } from "core-public/CosmeticSchemas";
import { UserMeResponse } from "engine-public/ApiSchemas";
import { Cosmetics } from "engine-public/CosmeticSchemas";
const product = { productId: "prod_1", priceId: "price_1", price: "$4.99" };
+2 -2
View File
@@ -1,5 +1,5 @@
import { PlayerStatsLeafSchema } from "core-public/ApiSchemas";
import { PlayerStatsSchema } from "core-public/StatsSchemas";
import { PlayerStatsLeafSchema } from "engine-public/ApiSchemas";
import { PlayerStatsSchema } from "engine-public/StatsSchemas";
function testPlayerSchema(
json: string,
+1 -1
View File
@@ -1,6 +1,6 @@
import { SpawnExecution } from "engine/execution/SpawnExecution";
import { Player, PlayerInfo, PlayerType } from "engine/game/Game";
import { GameID } from "core-public/Schemas";
import { GameID } from "engine-public/Schemas";
import { setup } from "./util/Setup";
describe("Territory management", () => {
+1 -1
View File
@@ -20,7 +20,7 @@ import {
fetchClanRequests,
fetchClans,
} from "client/ClanApi";
import type { UserMeResponse } from "core-public/ApiSchemas";
import type { UserMeResponse } from "engine-public/ApiSchemas";
const userWithClans = (tags: string[]): UserMeResponse =>
({
+1 -1
View File
@@ -9,7 +9,7 @@ import {
ClanInfoSchema,
ClanJoinRequestSchema,
ClanMemberSchema,
} from "core-public/ClanApiSchemas";
} from "engine-public/ClanApiSchemas";
describe("ClanInfoSchema", () => {
const base = {
+1 -1
View File
@@ -1,7 +1,7 @@
import { NationExecution } from "engine/execution/NationExecution";
import { SpawnExecution } from "engine/execution/SpawnExecution";
import { Cell, Nation, PlayerInfo, PlayerType } from "engine/game/Game";
import { GameConfig, GameID } from "core-public/Schemas";
import { GameConfig, GameID } from "engine-public/Schemas";
import { setup } from "../util/Setup";
import { executeTicks } from "../util/utils";
@@ -9,7 +9,7 @@ import {
PlayerType,
UnitType,
} from "engine/game/Game";
import { GameID } from "core-public/Schemas";
import { GameID } from "engine-public/Schemas";
import { setup } from "../../util/Setup";
import { constructionExecution, executeTicks } from "../../util/utils";
+1 -1
View File
@@ -1,4 +1,4 @@
import { GameID } from "core-public/Schemas";
import { GameID } from "engine-public/Schemas";
import { AttackExecution } from "engine/execution/AttackExecution";
import { SpawnExecution } from "engine/execution/SpawnExecution";
//import { TransportShipExecution } from "engine/execution/TransportShipExecution";
+1 -1
View File
@@ -15,7 +15,7 @@ import {
} from "engine/game/Game";
import { Cluster, TrainStation } from "engine/game/TrainStation";
import { UserSettings } from "engine/game/UserSettings";
import { GameConfig } from "core-public/Schemas";
import { GameConfig } from "engine-public/Schemas";
vi.mock("engine/game/Game");
vi.mock("engine/execution/TrainExecution");
+1 -1
View File
@@ -11,7 +11,7 @@ import {
import { createGame as createGameImpl } from "engine/game/GameImpl";
import { GameMapImpl } from "engine/game/GameMap";
import { UserSettings } from "engine/game/UserSettings";
import { GameConfig } from "core-public/Schemas";
import { GameConfig } from "engine-public/Schemas";
import { TestConfig } from "../../util/TestConfig";
export const W = "W"; // Water
+1 -1
View File
@@ -27,7 +27,7 @@ import {
PathStatus,
SteppingPathFinder,
} from "engine/pathfinding/types";
import { GameConfig } from "core-public/Schemas";
import { GameConfig } from "engine-public/Schemas";
import { TestConfig } from "../util/TestConfig";
export type BenchmarkRoute = {
+3 -3
View File
@@ -20,8 +20,8 @@ vi.mock("server/Logger", () => ({
},
}));
vi.mock("core-public/Schemas", async () => {
const actual = (await vi.importActual("core-public/Schemas")) as any;
vi.mock("engine-public/Schemas", async () => {
const actual = (await vi.importActual("engine-public/Schemas")) as any;
return {
...actual,
GameRecordSchema: {
@@ -31,7 +31,7 @@ vi.mock("core-public/Schemas", async () => {
});
import { GameType } from "engine/game/Game";
import type { GameRecord } from "core-public/Schemas";
import type { GameRecord } from "engine-public/Schemas";
import { archive } from "server/Archive";
function buildRecord(gameType: GameType, flag: string | undefined): GameRecord {
+2 -2
View File
@@ -1,7 +1,7 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("core-public/Schemas", async () => {
const actual = (await vi.importActual("core-public/Schemas")) as any;
vi.mock("engine-public/Schemas", async () => {
const actual = (await vi.importActual("engine-public/Schemas")) as any;
return {
...actual,
GameStartInfoSchema: {
+2 -2
View File
@@ -1,7 +1,7 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("core-public/Schemas", async () => {
const actual = (await vi.importActual("core-public/Schemas")) as any;
vi.mock("engine-public/Schemas", async () => {
const actual = (await vi.importActual("engine-public/Schemas")) as any;
return {
...actual,
GameStartInfoSchema: {
+1 -1
View File
@@ -16,7 +16,7 @@ import {
MapManifest,
} from "engine/game/TerrainMapLoader";
import { UserSettings } from "engine/game/UserSettings";
import { GameConfig } from "core-public/Schemas";
import { GameConfig } from "engine-public/Schemas";
import { TestConfig } from "./TestConfig";
export async function setup(
+1 -1
View File
@@ -25,7 +25,7 @@ import {
UnitUpdate,
} from "engine/game/GameUpdates";
import { TerrainMapData } from "engine/game/TerrainMapLoader";
import { Player, PlayerCosmetics } from "core-public/Schemas";
import { Player, PlayerCosmetics } from "engine-public/Schemas";
import { WorkerClient } from "engine/worker/WorkerClient";
/** Theme stub — returns deterministic colors so PlayerView's color math works. */