Behavior-preserving refactor of server/engine.ts: extract the 8 per-feature LLM
abilities (takeovers, wars, hybrid, economy/trade-embargo, industry, nuclear, leaders,
ideology) into server/abilities/ as an ordered ABILITIES registry, so each ability
owns its own Ability<K> (field, default, validate, apply, schemaLine, constraint,
isMeaningful, stub, payload, optional stateFields) and engine.ts becomes a thin
orchestrator that loops the registry.
Guarantees (all verified)
Identical buildSystemPrompt string (byte-for-byte vs committed goldens).
Identical buildUserPrompt JSON (byte-for-byte vs committed goldens).
Identical applyTurnResult world-state mutations.
Deterministic stub.ts (byte-identical deterministicTurn JSON vs pre-refactor).
All unit tests green (16 files) + typecheck + lint + build.
server/engine.ts re-exports every name it used to, so server/index.ts and all
tests work with zero edits.
No new runtime deps; no @turf/@types/geojson in any .ts; shared/ stays dep-free.
Client (src/) untouched. Not deployed (deliberate — deploy only on request).
## Summary
Behavior-preserving refactor of `server/engine.ts`: extract the 8 per-feature LLM
abilities (takeovers, wars, hybrid, economy/trade-embargo, industry, nuclear, leaders,
ideology) into `server/abilities/` as an ordered `ABILITIES` registry, so each ability
owns its own `Ability<K>` (field, default, validate, apply, schemaLine, constraint,
isMeaningful, stub, payload, optional stateFields) and `engine.ts` becomes a thin
orchestrator that loops the registry.
## Guarantees (all verified)
- Identical `buildSystemPrompt` string (byte-for-byte vs committed goldens).
- Identical `buildUserPrompt` JSON (byte-for-byte vs committed goldens).
- Identical `applyTurnResult` world-state mutations.
- Deterministic `stub.ts` (byte-identical `deterministicTurn` JSON vs pre-refactor).
- All unit tests green (16 files) + typecheck + lint + build.
- `server/engine.ts` re-exports every name it used to, so `server/index.ts` and all
tests work with zero edits.
- No new runtime deps; no `@turf`/`@types/geojson` in any `.ts`; `shared/` stays dep-free.
- Client (`src/`) untouched. **Not deployed** (deliberate — deploy only on request).
## Layout
- `server/abilities/types.ts` — `Ability`/`AbilityField`/`AbilityCtx`/`UserPromptCtx` (zero-arg `stub()`).
- `server/abilities/shared.ts` — the 5 shared primitives (freshNationId, freshWarId, NEW_NATION_STATS, resolveNationRef, resolveRegionKey).
- `server/abilities/*.ts` — the 8 ability modules + `apply-helpers.ts`.
- `server/abilities/index.ts` — assembles the ordered `ABILITIES` registry + re-exports.
- `server/abilities/registry.test.ts` — the contract tests (3 golden-prompt tests, registry order, default() freshness, isMeaningful, stateFields, composition, backward-compat re-export check).
Ships as **v0.40.0**.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Behavior-preserving refactor of
server/engine.ts: extract the 8 per-feature LLMabilities (takeovers, wars, hybrid, economy/trade-embargo, industry, nuclear, leaders,
ideology) into
server/abilities/as an orderedABILITIESregistry, so each abilityowns its own
Ability<K>(field, default, validate, apply, schemaLine, constraint,isMeaningful, stub, payload, optional stateFields) and
engine.tsbecomes a thinorchestrator that loops the registry.
Guarantees (all verified)
buildSystemPromptstring (byte-for-byte vs committed goldens).buildUserPromptJSON (byte-for-byte vs committed goldens).applyTurnResultworld-state mutations.stub.ts(byte-identicaldeterministicTurnJSON vs pre-refactor).server/engine.tsre-exports every name it used to, soserver/index.tsand alltests work with zero edits.
@turf/@types/geojsonin any.ts;shared/stays dep-free.src/) untouched. Not deployed (deliberate — deploy only on request).Layout
server/abilities/types.ts—Ability/AbilityField/AbilityCtx/UserPromptCtx(zero-argstub()).server/abilities/shared.ts— the 5 shared primitives (freshNationId, freshWarId, NEW_NATION_STATS, resolveNationRef, resolveRegionKey).server/abilities/*.ts— the 8 ability modules +apply-helpers.ts.server/abilities/index.ts— assembles the orderedABILITIESregistry + re-exports.server/abilities/registry.test.ts— the contract tests (3 golden-prompt tests, registry order, default() freshness, isMeaningful, stateFields, composition, backward-compat re-export check).Ships as v0.40.0.