@its-not-rocket-science/ananke 0.1.68 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/CHANGELOG.md +274 -0
  2. package/README.md +150 -431
  3. package/STABLE_API.md +113 -490
  4. package/conformance/README.md +46 -44
  5. package/conformance/lockstep-sequence.json +395 -395
  6. package/conformance/phase-order.json +21 -0
  7. package/conformance/replay-parity.json +65 -65
  8. package/conformance/state-hash-regression.json +39 -0
  9. package/conformance/state-hash.json +23 -22
  10. package/dist/src/conformance.d.ts +8 -2
  11. package/dist/src/content/index.d.ts +3 -0
  12. package/dist/src/content/index.js +2 -0
  13. package/dist/src/content/injector.d.ts +19 -0
  14. package/dist/src/content/injector.js +61 -0
  15. package/dist/src/content/loader.d.ts +3 -0
  16. package/dist/src/content/loader.js +170 -0
  17. package/dist/src/content/types.d.ts +56 -0
  18. package/dist/src/content/types.js +1 -0
  19. package/dist/src/content/validator.d.ts +6 -0
  20. package/dist/src/content/validator.js +14 -0
  21. package/dist/src/content-pack.d.ts +3 -2
  22. package/dist/src/content-pack.js +205 -10
  23. package/dist/src/data-governance.d.ts +73 -0
  24. package/dist/src/data-governance.js +188 -0
  25. package/dist/src/debug.d.ts +6 -0
  26. package/dist/src/debug.js +9 -0
  27. package/dist/src/determinism.d.ts +12 -0
  28. package/dist/src/determinism.js +93 -0
  29. package/dist/src/dialogue.d.ts +41 -0
  30. package/dist/src/dialogue.js +113 -2
  31. package/dist/src/economy.d.ts +97 -3
  32. package/dist/src/economy.js +191 -37
  33. package/dist/src/history/autosave.d.ts +19 -0
  34. package/dist/src/history/autosave.js +98 -0
  35. package/dist/src/history/timetravel.d.ts +28 -0
  36. package/dist/src/history/timetravel.js +61 -0
  37. package/dist/src/index.d.ts +19 -31
  38. package/dist/src/index.js +20 -38
  39. package/dist/src/model3d.js +63 -2
  40. package/dist/src/narrative/combat-logger.d.ts +25 -0
  41. package/dist/src/narrative/combat-logger.js +97 -0
  42. package/dist/src/narrative/plausibility.d.ts +30 -0
  43. package/dist/src/narrative/plausibility.js +70 -0
  44. package/dist/src/narrative-layer.d.ts +2 -0
  45. package/dist/src/narrative-layer.js +2 -0
  46. package/dist/src/navigation/causal-chain.d.ts +26 -0
  47. package/dist/src/navigation/causal-chain.js +74 -0
  48. package/dist/src/netcode.d.ts +1 -1
  49. package/dist/src/netcode.js +1 -1
  50. package/dist/src/performance/adaptive-tick.d.ts +23 -0
  51. package/dist/src/performance/adaptive-tick.js +50 -0
  52. package/dist/src/plugins/loader.d.ts +23 -0
  53. package/dist/src/plugins/loader.js +86 -0
  54. package/dist/src/plugins/registry.d.ts +11 -0
  55. package/dist/src/plugins/registry.js +28 -0
  56. package/dist/src/plugins/types.d.ts +31 -0
  57. package/dist/src/plugins/types.js +7 -0
  58. package/dist/src/replay.js +5 -2
  59. package/dist/src/scenario.js +2 -1
  60. package/dist/src/serialization/binary.d.ts +5 -0
  61. package/dist/src/serialization/binary.js +193 -0
  62. package/dist/src/session.d.ts +115 -0
  63. package/dist/src/session.js +228 -0
  64. package/dist/src/sim/ai/decide.js +1 -1
  65. package/dist/src/sim/ai/personality.js +2 -2
  66. package/dist/src/sim/bodyplan.d.ts +30 -0
  67. package/dist/src/sim/context.d.ts +2 -0
  68. package/dist/src/sim/kernel.js +80 -1294
  69. package/dist/src/sim/normalization.d.ts +12 -0
  70. package/dist/src/sim/normalization.js +92 -0
  71. package/dist/src/sim/resolvers/attack-resolver.d.ts +30 -0
  72. package/dist/src/sim/resolvers/attack-resolver.js +310 -0
  73. package/dist/src/sim/resolvers/capability-resolver.d.ts +15 -0
  74. package/dist/src/sim/resolvers/capability-resolver.js +270 -0
  75. package/dist/src/sim/resolvers/grapple-resolver.d.ts +28 -0
  76. package/dist/src/sim/resolvers/grapple-resolver.js +70 -0
  77. package/dist/src/sim/resolvers/shoot-resolver.d.ts +27 -0
  78. package/dist/src/sim/resolvers/shoot-resolver.js +212 -0
  79. package/dist/src/sim/resolvers/treat-resolver.d.ts +16 -0
  80. package/dist/src/sim/resolvers/treat-resolver.js +77 -0
  81. package/dist/src/sim/step/apply/intents.d.ts +6 -0
  82. package/dist/src/sim/step/apply/intents.js +83 -0
  83. package/dist/src/sim/step/kernel-pipeline.d.ts +9 -0
  84. package/dist/src/sim/step/kernel-pipeline.js +15 -0
  85. package/dist/src/sim/step/phases/capability-phase.d.ts +8 -0
  86. package/dist/src/sim/step/phases/capability-phase.js +65 -0
  87. package/dist/src/sim/step/phases/cooldowns-phase.d.ts +3 -0
  88. package/dist/src/sim/step/phases/cooldowns-phase.js +37 -0
  89. package/dist/src/sim/step/phases/prepare-phase.d.ts +10 -0
  90. package/dist/src/sim/step/phases/prepare-phase.js +33 -0
  91. package/dist/src/sim/step/pipeline.d.ts +2 -0
  92. package/dist/src/sim/step/pipeline.js +15 -0
  93. package/dist/src/sim/step/resolvers/impact-resolver.d.ts +9 -0
  94. package/dist/src/sim/step/resolvers/impact-resolver.js +55 -0
  95. package/dist/src/sim/step/world-phases.d.ts +7 -0
  96. package/dist/src/sim/step/world-phases.js +15 -0
  97. package/dist/src/sim/step/world-step-context.d.ts +23 -0
  98. package/dist/src/sim/step/world-step-context.js +1 -0
  99. package/dist/src/sim/systemic-toxicology.js +1 -1
  100. package/dist/src/sim/team.js +2 -2
  101. package/dist/src/sim/testing.js +4 -3
  102. package/dist/src/sim/toxicology.d.ts +1 -1
  103. package/dist/src/sim/toxicology.js +1 -1
  104. package/dist/src/sim/world.d.ts +17 -24
  105. package/dist/src/snapshot.js +3 -6
  106. package/dist/src/tier2.d.ts +19 -0
  107. package/dist/src/tier2.js +21 -0
  108. package/dist/src/tier3.d.ts +10 -0
  109. package/dist/src/tier3.js +12 -0
  110. package/dist/src/version.d.ts +6 -0
  111. package/dist/src/version.js +8 -0
  112. package/dist/src/wasm/bridge.d.ts +14 -0
  113. package/dist/src/wasm/bridge.js +84 -0
  114. package/dist/src/wasm-kernel.d.ts +2 -0
  115. package/dist/src/wasm-kernel.js +1 -0
  116. package/dist/src/world-evolution-backend/engine.d.ts +4 -0
  117. package/dist/src/world-evolution-backend/engine.js +347 -0
  118. package/dist/src/world-evolution-backend/host-schema.d.ts +145 -0
  119. package/dist/src/world-evolution-backend/host-schema.js +375 -0
  120. package/dist/src/world-evolution-backend/index.d.ts +1 -0
  121. package/dist/src/world-evolution-backend/index.js +1 -0
  122. package/dist/src/world-evolution-backend/open-world-host-adapter.d.ts +96 -0
  123. package/dist/src/world-evolution-backend/open-world-host-adapter.js +208 -0
  124. package/dist/src/world-evolution-backend/profiles.d.ts +4 -0
  125. package/dist/src/world-evolution-backend/profiles.js +136 -0
  126. package/dist/src/world-evolution-backend/public.d.ts +11 -0
  127. package/dist/src/world-evolution-backend/public.js +7 -0
  128. package/dist/src/world-evolution-backend/reproducibility.d.ts +8 -0
  129. package/dist/src/world-evolution-backend/reproducibility.js +35 -0
  130. package/dist/src/world-evolution-backend/timeline.d.ts +6 -0
  131. package/dist/src/world-evolution-backend/timeline.js +337 -0
  132. package/dist/src/world-evolution-backend/types.d.ts +138 -0
  133. package/dist/src/world-evolution-backend/types.js +1 -0
  134. package/dist/src/world-evolution-host-backend.d.ts +51 -0
  135. package/dist/src/world-evolution-host-backend.js +97 -0
  136. package/dist/src/world-evolution.d.ts +201 -0
  137. package/dist/src/world-evolution.js +543 -0
  138. package/dist/src/world-factory.js +2 -1
  139. package/dist/tools/pack-cli.js +55 -2
  140. package/docs/bridge-contract.md +140 -332
  141. package/docs/completion-evidence-dashboard.md +63 -0
  142. package/docs/host-contract.md +86 -310
  143. package/docs/host-world-evolution-schema.md +155 -0
  144. package/docs/integration-primer.md +29 -22
  145. package/docs/migration-monolith-to-modular.md +102 -120
  146. package/docs/package-architecture.md +116 -323
  147. package/docs/plugins/README.md +42 -0
  148. package/docs/plugins/hooks.md +22 -0
  149. package/docs/plugins/publishing.md +29 -0
  150. package/docs/plugins/security-model.md +273 -0
  151. package/docs/project-overview.md +30 -30
  152. package/docs/release-dashboard.md +47 -0
  153. package/docs/session-api.md +127 -0
  154. package/docs/stable-api-manifest.json +52 -0
  155. package/docs/trust-dashboard.md +37 -0
  156. package/docs/versioning.md +256 -245
  157. package/docs/wire-protocol.md +140 -209
  158. package/docs/world-evolution-backend.md +200 -0
  159. package/docs/world-evolution-engine.md +150 -0
  160. package/docs/world-evolution-host-backend.md +70 -0
  161. package/docs/world-evolution-orchestration.md +248 -0
  162. package/package.json +125 -6
  163. package/schema/content-pack.schema.json +85 -0
  164. package/schema/plugin.schema.json +57 -0
  165. package/schema/world-evolution-input.schema.json +196 -0
@@ -1,323 +1,116 @@
1
- # Ananke Modular Package Architecture
2
-
3
- > **Status: Phase 1 complete** Package stubs with re-exports are published.
4
- > Phase 2 (source migration) moves code into individual packages so combat has
5
- > no campaign dependency at the module level.
6
-
7
- ---
8
-
9
- ## Problem
10
-
11
- `@its-not-rocket-science/ananke` ships 41 subpath exports in a single package.
12
- A host that only needs tactical combat transitively depends on feudal succession,
13
- epidemic simulation, and monetary policy. A renderer integration author has no
14
- clean way to depend only on the bridge layer.
15
-
16
- ---
17
-
18
- ## Package Overview
19
-
20
- | Package | Stability | Description | Key entry point(s) |
21
- |---------|-----------|-------------|-------------------|
22
- | `@ananke/core` | **Stable** | Kernel, entity model, fixed-point units, RNG, replay | `"@ananke/core"` |
23
- | `@ananke/combat` | Experimental | Combat resolution, anatomy, grapple, ranged, competence | `"@ananke/combat"` |
24
- | `@ananke/campaign` | Experimental | World simulation — polity, economy, social, demography | `"@ananke/campaign"` |
25
- | `@ananke/content` | Experimental | Species, equipment catalogue, archetypes, crafting | `"@ananke/content"` |
26
- | `@ananke/bridge` | Experimental | Renderer bridge, interpolation, animation hints *(Phase 2)* | `"@ananke/bridge"` |
27
- | `@its-not-rocket-science/ananke` | **Meta-package** | Re-exports all of the above for backwards compatibility | unchanged |
28
-
29
- > `@ananke/bridge` is not yet a standalone stub — bridge exports are part of
30
- > `@ananke/core` until Phase 2 adds a dedicated `"./bridge"` subpath to the
31
- > monolith.
32
-
33
- ---
34
-
35
- ## Package Dependency Graph
36
-
37
- ```
38
- @ananke/core
39
-
40
- ├── @ananke/combat (peer: @ananke/core)
41
- ├── @ananke/campaign (peer: @ananke/core)
42
- ├── @ananke/content (peer: @ananke/core)
43
- └── @ananke/bridge (peer: @ananke/core) [Phase 2]
44
-
45
- @its-not-rocket-science/ananke (meta: re-exports all four)
46
- ```
47
-
48
- ---
49
-
50
- ## Monolith Subpath → Package Mapping
51
-
52
- ### @ananke/core
53
-
54
- | Monolith subpath | Notes |
55
- |-----------------|-------|
56
- | `"."` | Entire main export — kernel, entity, units, RNG, replay, bridge |
57
-
58
- ### @ananke/combat
59
-
60
- | Monolith subpath | Notes |
61
- |-----------------|-------|
62
- | `"./combat"` | resolveHit, resolveBlock, CombatContext |
63
- | `"./anatomy"` | BodyPlan, AnatomyRegion, injury regions |
64
- | `"./competence"` | skill contest resolution, interspecies signalling |
65
- | `"./wasm-kernel"` | WASM-accelerated combat math |
66
-
67
- ### @ananke/campaign
68
-
69
- | Monolith subpath | Notes |
70
- |-----------------|-------|
71
- | `"./campaign"` | Campaign layer, strategic tick |
72
- | `"./polity"` | Polity, stepPolityDay, tech diffusion |
73
- | `"./social"` | Social relationships, dialogue |
74
- | `"./narrative"` | Narrative event system |
75
- | `"./narrative-prose"` | Prose generation |
76
- | `"./renown"` | Fame and reputation |
77
- | `"./kinship"` | Family trees, genealogy |
78
- | `"./succession"` | Inheritance rules |
79
- | `"./calendar"` | In-world calendar and date tracking |
80
- | `"./feudal"` | Feudal hierarchy |
81
- | `"./diplomacy"` | Treaties and diplomatic acts |
82
- | `"./migration"` | Population movement |
83
- | `"./espionage"` | Espionage and spycraft |
84
- | `"./trade-routes"` | Trade route simulation |
85
- | `"./siege"` | Siege warfare mechanics |
86
- | `"./faith"` | Religion and doctrine |
87
- | `"./demography"` | Population simulation |
88
- | `"./granary"` | Food storage and distribution |
89
- | `"./epidemic"` | Disease spread |
90
- | `"./infrastructure"` | Buildings and construction |
91
- | `"./unrest"` | Civil unrest |
92
- | `"./research"` | Technology research |
93
- | `"./taxation"` | Tax collection |
94
- | `"./military-campaign"` | Military campaign mechanics |
95
- | `"./governance"` | Governance and edicts |
96
- | `"./resources"` | Resource management |
97
- | `"./climate"` | Climate and weather effects |
98
- | `"./famine"` | Famine simulation |
99
- | `"./containment"` | Disease containment |
100
- | `"./mercenaries"` | Mercenary companies |
101
- | `"./wonders"` | Wonders and monuments |
102
- | `"./monetary"` | Monetary policy and currency |
103
-
104
- ### @ananke/content
105
-
106
- | Monolith subpath | Notes |
107
- |-----------------|-------|
108
- | `"./species"` | Species definitions, stat profiles |
109
- | `"./catalog"` | Equipment and item catalogue |
110
- | `"./character"` | Character generation and archetypes |
111
- | `"./crafting"` | Crafting recipes, workshops, manufacturing |
112
-
113
- ---
114
-
115
- ## Source File Package Mapping (Phase 2 migration)
116
-
117
- ### @ananke/core
118
- ```
119
- src/units.ts
120
- src/rng.ts
121
- src/types.ts
122
- src/replay.ts
123
- src/sim/entity.ts
124
- src/sim/kernel.ts
125
- src/sim/seeds.ts
126
- src/sim/world.ts
127
- src/sim/kinds.ts
128
- src/sim/condition.ts
129
- src/sim/body.ts
130
- src/sim/bodyplan.ts
131
- src/sim/limb.ts
132
- src/sim/tick.ts
133
- src/sim/indexing.ts
134
- src/sim/events.ts
135
- src/sim/commands.ts
136
- src/sim/commandBuilders.ts
137
- src/sim/context.ts
138
- src/sim/intent.ts
139
- src/sim/vec3.ts
140
- src/sim/spatial.ts
141
- src/sim/skills.ts
142
- src/sim/traits.ts
143
- src/sim/terrain.ts
144
- src/sim/action.ts
145
- src/sim/step/ (all 10 step files)
146
- src/bridge/ (all 5 bridge files)
147
- src/presets.ts
148
- src/generate.ts
149
- src/derive.ts
150
- src/describe.ts
151
- src/traits.ts
152
- src/metrics.ts
153
- src/dist.ts
154
- src/wasm-kernel.ts
155
- ```
156
-
157
- ### @ananke/combat
158
- ```
159
- src/sim/combat.ts
160
- src/sim/injury.ts
161
- src/sim/wound-aging.ts
162
- src/sim/medical.ts
163
- src/sim/morale.ts
164
- src/sim/grapple.ts
165
- src/sim/ranged.ts
166
- src/sim/stamina.ts (if present)
167
- src/sim/impairment.ts
168
- src/sim/knockback.ts
169
- src/sim/cover.ts
170
- src/sim/cone.ts
171
- src/sim/formation.ts
172
- src/sim/formation-combat.ts
173
- src/sim/formation-unit.ts
174
- src/sim/frontage.ts
175
- src/sim/density.ts
176
- src/sim/occlusion.ts
177
- src/sim/ai/ (all 8 AI files)
178
- src/combat.ts
179
- src/equipment.ts
180
- src/weapons.ts
181
- src/anatomy/ (all 5 anatomy files)
182
- src/competence/ (all 13 competence files)
183
- src/arena.ts
184
- src/dialogue.ts
185
- src/party.ts
186
- src/faction.ts
187
- src/downtime.ts
188
- ```
189
-
190
- ### @ananke/campaign
191
- ```
192
- src/campaign.ts
193
- src/campaign-layer.ts
194
- src/polity.ts
195
- src/polity-vassals.ts
196
- src/social.ts
197
- src/relationships.ts
198
- src/relationships-effects.ts
199
- src/emotional-contagion.ts
200
- src/narrative.ts
201
- src/narrative-layer.ts
202
- src/narrative-prose.ts
203
- src/narrative-render.ts
204
- src/narrative-stress.ts
205
- src/story-arcs.ts
206
- src/quest.ts
207
- src/quest-generators.ts
208
- src/chronicle.ts
209
- src/legend.ts
210
- src/mythology.ts
211
- src/renown.ts
212
- src/kinship.ts
213
- src/succession.ts
214
- src/calendar.ts
215
- src/feudal.ts
216
- src/diplomacy.ts
217
- src/migration.ts
218
- src/espionage.ts
219
- src/trade-routes.ts
220
- src/siege.ts
221
- src/faith.ts
222
- src/demography.ts
223
- src/granary.ts
224
- src/epidemic.ts
225
- src/infrastructure.ts
226
- src/unrest.ts
227
- src/research.ts
228
- src/taxation.ts
229
- src/military-campaign.ts
230
- src/governance.ts
231
- src/resources.ts
232
- src/climate.ts
233
- src/famine.ts
234
- src/containment.ts
235
- src/mercenaries.ts
236
- src/wonders.ts
237
- src/monetary.ts
238
- src/collective-activities.ts
239
- src/economy.ts
240
- src/economy-gen.ts
241
- src/tech-diffusion.ts
242
- src/culture.ts
243
- src/settlement.ts
244
- src/settlement-services.ts
245
- src/channels.ts
246
- src/inheritance.ts
247
- src/progression.ts
248
- src/sim/disease.ts
249
- src/sim/aging.ts
250
- src/sim/sleep.ts
251
- src/sim/mount.ts
252
- src/sim/hazard.ts
253
- src/sim/nutrition.ts
254
- src/sim/thermoregulation.ts
255
- src/sim/toxicology.ts
256
- src/sim/systemic-toxicology.ts
257
- src/sim/substance.ts
258
- src/sim/weather.ts
259
- src/sim/biome.ts
260
- src/sim/tech.ts
261
- ```
262
-
263
- ### @ananke/content
264
- ```
265
- src/species.ts
266
- src/catalog.ts
267
- src/character.ts
268
- src/archetypes.ts
269
- src/crafting/ (all 5 crafting files)
270
- src/inventory.ts
271
- src/item-durability.ts
272
- src/snapshot.ts
273
- src/world-generation.ts
274
- src/world-factory.ts
275
- src/scenario.ts
276
- src/modding.ts
277
- src/lod.ts
278
- src/model3d.ts
279
- ```
280
-
281
- ---
282
-
283
- ## Phase 2: Source Migration Plan
284
-
285
- 1. **Create workspace package directories** with their own `tsconfig.build.json`.
286
- 2. **Move source files** from `src/` into `packages/NAME/src/` following the table above.
287
- 3. **Update internal imports** — use `@ananke/core` etc. instead of relative paths that cross
288
- package boundaries.
289
- 4. **Wire inter-package dependencies** — `@ananke/combat` lists `@ananke/core` as a dependency.
290
- 5. **Update the monolith meta-package** (`@its-not-rocket-science/ananke`) to re-export from
291
- the five sub-packages instead of from `src/`.
292
- 6. **Verify** that all existing tests pass without modification (test paths remain unchanged).
293
-
294
- The most complex step is (3) — identifying which imports cross package boundaries. A planned
295
- tool (`tools/check-package-boundaries.ts`) will analyse the import graph and report violations.
296
-
297
- ---
298
-
299
- ## What Changes for Package Consumers
300
-
301
- ### Phase 1 (now — stubs)
302
- ```typescript
303
- // Before (monolith)
304
- import { resolveHit } from "@its-not-rocket-science/ananke/combat";
305
-
306
- // After (modular stub — same bundle size, cleaner import path)
307
- import { resolveHit } from "@ananke/combat";
308
- ```
309
-
310
- ### Phase 2 (source migration — smaller bundles)
311
- ```typescript
312
- // Same import — but now @ananke/combat has no campaign dependency
313
- import { resolveHit } from "@ananke/combat";
314
- ```
315
-
316
- The import path is the same in Phase 1 and Phase 2; only the bundle contents change.
317
-
318
- ---
319
-
320
- ## Backwards Compatibility
321
-
322
- `@its-not-rocket-science/ananke` will remain published indefinitely as a meta-package.
323
- All 41 subpath exports will continue to work. Existing hosts do not need to migrate.
1
+ # Package architecture: shipped state, partial modularization, and target state
2
+
3
+ This document reconciles three different things that are easy to blur together:
4
+
5
+ 1. What the repository and npm package ship **today**.
6
+ 2. What is **partially implemented** toward modular packages.
7
+ 3. What the **target architecture** is intended to be.
8
+
9
+ ---
10
+
11
+ ## Current state (shipped now)
12
+
13
+ ### What is published today
14
+
15
+ The primary published package is still the monolith:
16
+
17
+ - Package name: `@its-not-rocket-science/ananke`
18
+ - Root entrypoint: `.` → `dist/src/index.js`
19
+ - Many subpath exports (for example `./combat`, `./campaign`, `./species`, `./content`, etc.) from the same monolith build output.
20
+
21
+ In other words: consumers can import many domain-specific entrypoints, but they are exported from one package build at the root.
22
+
23
+ ### Filesystem/layout reality
24
+
25
+ - Main implementation is in `src/`.
26
+ - Workspaces exist at `packages/*`.
27
+ - `packages/core`, `packages/combat`, `packages/campaign`, and `packages/content` currently contain thin Phase 1 wrappers (`index.js` + `index.d.ts`) that re-export monolith entrypoints.
28
+ - `packages/cli` exists, but it is private and points to root `dist/tools/*` binaries.
29
+
30
+ ### Current architecture diagram (monolith-first)
31
+
32
+ ```mermaid
33
+ flowchart LR
34
+ App[Consumer app]
35
+ Mono[@its-not-rocket-science/ananke]
36
+ Dist[dist/src/*]
37
+ Src[src/* implementation]
38
+
39
+ App --> Mono
40
+ Mono --> Dist
41
+ Dist --> Src
42
+
43
+ subgraph Phase 1 workspace wrappers
44
+ Core[@ananke/core]
45
+ Combat[@ananke/combat]
46
+ Campaign[@ananke/campaign]
47
+ Content[@ananke/content]
48
+ end
49
+
50
+ Core -.re-exports.-> Mono
51
+ Combat -.re-exports.-> Mono
52
+ Campaign -.re-exports.-> Mono
53
+ Content -.re-exports.-> Mono
54
+ ```
55
+
56
+ ---
57
+
58
+ ## In progress (partially implemented)
59
+
60
+ Modularization work is in progress and incomplete.
61
+
62
+ ### Already implemented
63
+
64
+ - A modular ownership map and allowed dependency graph exist in `tools/package-boundaries.config.json`.
65
+ - Boundary checking/report tooling exists (`tools/check-package-boundaries.ts`, `npm run check-boundaries*`).
66
+ - Workspace package names and import surfaces for `@ananke/core`, `@ananke/combat`, `@ananke/campaign`, and `@ananke/content` are present.
67
+
68
+ ### Not complete yet
69
+
70
+ - Boundary compliance is not yet achieved. The latest checked-in report (`docs/package-boundary-report.md`, generated 2026-04-09) still shows:
71
+ - hard violations,
72
+ - suspicious imports,
73
+ - and unmapped files.
74
+ - Workspace packages are still wrappers; they do not yet own independent implementation/source trees.
75
+ - Because wrappers re-export from the monolith, modular import paths do **not** yet imply full package isolation.
76
+
77
+ ---
78
+
79
+ ## Target state (planned)
80
+
81
+ The target architecture is modular-first:
82
+
83
+ - Each `@ananke/*` package owns its code, build output, and tests.
84
+ - Cross-package imports follow the declared DAG (for example, `content -> core`, `combat -> core/content`, `campaign -> core/content`).
85
+ - The monolith package remains as a compatibility/meta layer that re-exports modular packages for adopters who want one dependency.
86
+
87
+ ### Target architecture diagram (modular-first)
88
+
89
+ ```mermaid
90
+ flowchart TD
91
+ Core[@ananke/core]
92
+ Content[@ananke/content]
93
+ Combat[@ananke/combat]
94
+ Campaign[@ananke/campaign]
95
+
96
+ Content --> Core
97
+ Combat --> Core
98
+ Combat --> Content
99
+ Campaign --> Core
100
+ Campaign --> Content
101
+
102
+ Meta[@its-not-rocket-science/ananke (compat/meta)]
103
+ Meta --> Core
104
+ Meta --> Content
105
+ Meta --> Combat
106
+ Meta --> Campaign
107
+ ```
108
+
109
+ ---
110
+
111
+ ## What this means for adopters today
112
+
113
+ - You can safely use the monolith package now; it is the most direct reflection of shipped structure.
114
+ - You can also use `@ananke/*` imports today, but treat them as import-path aliases/wrappers rather than fully independent packages.
115
+ - Do not assume current modular imports provide maximum tree-shaking or strict package-boundary guarantees yet.
116
+ - Migration to modular import paths can reduce future refactors, because those paths are intended to remain valid as ownership moves into `@ananke/*` packages.
@@ -0,0 +1,42 @@
1
+ # Ananke Plugin SDK
2
+
3
+ Ananke plugins are third-party extensions that register one or more runtime hooks (for example `beforeStep`, `afterStep`, `afterDamage`, or `matchEnd`) and run in a constrained runtime.
4
+
5
+ > ⚠️ **Security caveat (public plugin loading):** `loadPlugin(...)` is not, by itself, a complete security boundary for hostile third-party code. If you load public/untrusted plugins, read `docs/plugins/security-model.md` and apply `docs/plugins/deployment-checklist.md` before production enablement.
6
+
7
+ ## Write your first plugin in 10 minutes
8
+
9
+ 1. Create a folder under `plugins/`.
10
+ 2. Add `plugin.json` using `schema/plugin.schema.json`.
11
+ 3. Add an `index.js` file exporting `setup(api)`.
12
+ 4. Return handlers keyed by hook name.
13
+ 5. Load with `loadPlugin(path)` and call hooks with `runHook(...)`.
14
+
15
+ ### `plugin.json`
16
+
17
+ ```json
18
+ {
19
+ "id": "ananke-plugin-hello",
20
+ "version": "1.0.0",
21
+ "hooks": ["afterStep"],
22
+ "dependencies": {},
23
+ "permissions": ["read:worldState", "write:telemetry"]
24
+ }
25
+ ```
26
+
27
+ ### `index.js`
28
+
29
+ ```js
30
+ module.exports = {
31
+ setup(api) {
32
+ return {
33
+ afterStep(ctx) {
34
+ const world = api.readWorldState(ctx.worldState);
35
+ api.emitTelemetry("hello.entities", { count: world.entities.length });
36
+ },
37
+ };
38
+ },
39
+ };
40
+ ```
41
+
42
+ See `docs/plugins/hooks.md` for the hook contract, `docs/plugins/publishing.md` for registry publication, and `docs/plugins/security-model.md` for production threat modeling.
@@ -0,0 +1,22 @@
1
+ # Hook reference
2
+
3
+ ## Core lifecycle hooks
4
+
5
+ - `beforeStep(context)` — called before simulation step execution.
6
+ - `afterStep(context)` — called after a simulation step has completed.
7
+ - `afterDamage(context)` — called after a damage event resolves.
8
+ - `matchEnd(context)` — called once at end-of-match with summary fields.
9
+
10
+ ## Plugin runtime API
11
+
12
+ - `hasPermission(permission)`
13
+ - `readWorldState(value)`
14
+ - `mutateWorld(worldState, mutator)` (requires `write:worldState`)
15
+ - `emitTelemetry(metric, payload)` (requires `write:telemetry`)
16
+ - `writeArtifact(path, contents)` (requires `write:artifacts`)
17
+
18
+ ## Permission examples
19
+
20
+ - Read-only observer plugin: `permissions: ["read:worldState"]`
21
+ - Analytics plugin with reports: `permissions: ["read:events", "write:artifacts"]`
22
+ - Full gameplay mutator: `permissions: ["read:worldState", "write:worldState"]`
@@ -0,0 +1,29 @@
1
+ # Publishing plugins to `ananke-plugins`
2
+
3
+ The plugin registry is a GitHub repository that exposes a JSON index consumed by `ananke install <plugin>`.
4
+
5
+ > ⚠️ **Security caveat (public registry):** Registry publication increases exposure to untrusted plugin code paths. Production operators should treat all third-party plugins as untrusted by default and apply `docs/plugins/security-model.md` and `docs/plugins/deployment-checklist.md` before enabling plugins.
6
+
7
+ ## Registry structure
8
+
9
+ - `index.json` at repo root
10
+ - one directory per plugin containing `plugin.json` and `index.js`
11
+
12
+ Example entry:
13
+
14
+ ```json
15
+ {
16
+ "name": "ananke-plugin-logger",
17
+ "manifestUrl": "https://raw.githubusercontent.com/its-not-rocket-science/ananke-plugins/main/ananke-plugin-logger/plugin.json",
18
+ "moduleUrl": "https://raw.githubusercontent.com/its-not-rocket-science/ananke-plugins/main/ananke-plugin-logger/index.js"
19
+ }
20
+ ```
21
+
22
+ ## CI validation workflow
23
+
24
+ 1. Install latest Ananke package.
25
+ 2. Validate each `plugin.json` against `schema/plugin.schema.json`.
26
+ 3. Load each plugin with `loadPlugin` smoke test.
27
+ 4. Run plugin-specific test suite.
28
+
29
+ This keeps registry plugins compatible with the latest API.