feat(#62): ideology / government-type change (v0.39.0)
CI / build + unit + e2e (pull_request) Successful in 2m33s

Add a per-nation free-form ideology (form of government) field and a
TurnResult.ideology lever (coups / revolutions / reforms / constitutional
changes) with a deterministic -5 stability dip and political narration.

- shared/types.ts: Nation.ideology?: string (optional/additive)
- shared/protocol.ts: IdeologyChange / IdeologyOps, IDEOLOGY_STABILITY_EFFECT
  = -5, TurnResult.ideology (required, between leaders and markers),
  nationForPrompt now carries ideology
- server/engine.ts: validateIdeologyOps (exported, never throws),
  applyIdeologyChange (resolve -> set field -> -5 dip mirrored to regions +
  re-derived -> political event), ideology block in applyTurnResult after
  leaders / before markers, isMeaningful + validateTurnResult + system prompt
  + runTurn unclear fallback
- server/stub.ts: StubPayload gains ideology; deterministicTurn returns
  ideology: { changes: [] } (never changes one, e2e unaffected)
- Tests: engine.test.ts (validate / isMeaningful / applyTurnResult /
  buildUserPrompt), protocol.test.ts (constant + nationForPrompt),
  db.test.ts (legacy load + round-trip); every TurnResult fixture updated
- package.json -> 0.39.0; CHANGELOG v0.39.0 entry
This commit is contained in:
2026-10-15 20:54:18 +00:00
parent 9d201135b3
commit 7866a1987d
9 changed files with 501 additions and 21 deletions
+12
View File
@@ -88,6 +88,18 @@ export interface Nation {
* each change carries a deterministic stability effect + a narration event.
*/
leader?: { name: string };
/**
* The nation's current form of government (v0.39, #62) — a free-form label
* such as `"democracy"`, `"fascism"` or `"military junta"`. Optional — a
* legacy game (or a nation the LLM has never given an ideology to) has none,
* which is the "no recorded government" baseline. The LLM changes it via
* `TurnResult.ideology` (coups / revolutions / reforms / constitutional
* changes, see `IdeologyChange` in `protocol.ts`); each change carries a
* deterministic stability dip + a political narration event. Distinct from
* the v0.32.0 takeover (which renames the nation) and from `leader` (who is
* in charge): only the form of government and stability move.
*/
ideology?: string;
}
/** Categories a narrative event can take. */