@its-not-rocket-science/ananke 0.1.69 → 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 +254 -0
  2. package/README.md +150 -432
  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
@@ -0,0 +1,127 @@
1
+ # Session API (Tier 2 / experimental)
2
+
3
+ `@its-not-rocket-science/ananke/session` is a **host-oriented facade** over existing public simulation APIs.
4
+
5
+ > Stability: this subpath is **Tier 2 / experimental**. It is shipped, but it is not covered by Tier 1 stability guarantees.
6
+
7
+ ## Why this API exists
8
+
9
+ Most hosts need a consistent lifecycle (`create`, `run`, `fork`, save/load) across different simulation modes.
10
+ The session API wraps that lifecycle so hosts can use one integration shape instead of hand-wiring separate tactical and world-evolution loops.
11
+
12
+ ## When to use this vs. low-level functions
13
+
14
+ Use `@its-not-rocket-science/ananke/session` when you want:
15
+
16
+ - a mode-aware session handle (`tactical` or `world_evolution`),
17
+ - a common run/fork/serialize flow,
18
+ - host-level orchestration with minimal glue code.
19
+
20
+ Use low-level functions from `@its-not-rocket-science/ananke` (and other subpaths) when you need:
21
+
22
+ - full control over each tick and command map internals,
23
+ - mode-specific custom scheduling,
24
+ - direct access to domain primitives without facade constraints.
25
+
26
+ ## Supported modes
27
+
28
+ - `"tactical"`
29
+ - `"world_evolution"`
30
+
31
+ ## Runtime portability notes (Node vs browser/worker)
32
+
33
+ `./session` is designed to be importable in browser/worker embedders, but some behavior still varies by runtime:
34
+
35
+ - **Portable by default**
36
+ - Core tactical/session lifecycle (`createSession`, `runSession`, `stepSession`, `forkSession`, `serializeSession`, `deserializeSession`) is runtime-neutral and does not require Node globals.
37
+ - **Optional/conditional behavior**
38
+ - `runSession` strict determinism env override (`ANANKE_STRICT_DETERMINISM`) now only applies when a Node-style `process.env` exists; browser/worker hosts should set `context.strictDeterminism` explicitly instead.
39
+ - Pack checksum validation (`registry.checksum`) is available from the session path without Node-only imports.
40
+ - **Current limits**
41
+ - Session pack loading still mutates in-memory global registries (weapons/armour/archetypes/scenario maps) in-process. This is host-runtime portable, but not yet isolated by namespace/sandbox.
42
+ - `./session` does not provide fetch/file I/O adapters; hosts must supply already-loaded JSON payloads for scenarios/packs.
43
+
44
+ ## Public API surface
45
+
46
+ ### Types
47
+
48
+ - `SessionMode = "tactical" | "world_evolution"`
49
+ - `SessionConfig`
50
+ - `SessionHandle`
51
+ - `RunSessionRequest`
52
+ - `RunSessionResult`
53
+ - `SessionSummary`
54
+ - `ForkSessionRequest`
55
+ - `LoadSessionPackResult`
56
+
57
+ ### Functions
58
+
59
+ - `createSession(config)`
60
+ - `runSession(session, request)`
61
+ - `stepSession(session, request?)`
62
+ - `getSessionSummary(session)`
63
+ - `forkSession(session, request?)`
64
+ - `loadSessionPack(manifestOrRequest)`
65
+ - `serializeSession(session)`
66
+ - `deserializeSession(json)`
67
+
68
+ ## Lifecycle
69
+
70
+ 1. **create** — `createSession(config)`
71
+ 2. **run** — `runSession(session, { steps, ... })` (or single-step via `stepSession`)
72
+ 3. **fork** — `forkSession(session, { ... })`
73
+ 4. **pack load** — `loadSessionPack(packJson, { ... })`
74
+ 5. **serialize** — `serializeSession(session)`
75
+ 6. **deserialize** — `deserializeSession(serialized)`
76
+
77
+ ## Tactical example
78
+
79
+ ```ts no-check-example
80
+ import { createSession, runSession, forkSession, serializeSession, deserializeSession } from "@its-not-rocket-science/ananke/session";
81
+
82
+ const tactical = createSession({
83
+ mode: "tactical",
84
+ worldSeed: 7,
85
+ entities: [
86
+ { id: 1, teamId: 1, seed: 11, archetype: "AMATEUR_BOXER", weaponId: "fists" },
87
+ { id: 2, teamId: 2, seed: 22, archetype: "AMATEUR_BOXER", weaponId: "fists" },
88
+ ],
89
+ enableReplay: true,
90
+ });
91
+
92
+ runSession(tactical, { steps: 10 });
93
+ const branch = forkSession(tactical, { id: "what-if-branch" });
94
+
95
+ const snapshot = serializeSession(branch);
96
+ const restored = deserializeSession(snapshot);
97
+ runSession(restored, { steps: 5 });
98
+ ```
99
+
100
+ ## World-evolution example
101
+
102
+ ```ts no-check-example
103
+ import { createSession, runSession, serializeSession, deserializeSession } from "@its-not-rocket-science/ananke/session";
104
+
105
+ const worldEvolution = createSession({
106
+ mode: "world_evolution",
107
+ canonicalSnapshot: {
108
+ tick: 0,
109
+ worldSeed: 42,
110
+ settlements: [],
111
+ actors: [],
112
+ metrics: {},
113
+ activeEvents: [],
114
+ },
115
+ rulesetId: "standard",
116
+ checkpointInterval: 25,
117
+ });
118
+
119
+ runSession(worldEvolution, {
120
+ steps: 50,
121
+ evolution: { includeDeltas: true },
122
+ });
123
+
124
+ const packed = serializeSession(worldEvolution);
125
+ const resumed = deserializeSession(packed);
126
+ runSession(resumed, { steps: 10 });
127
+ ```
@@ -0,0 +1,52 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "package": "@its-not-rocket-science/ananke",
4
+ "tier": "tier-1",
5
+ "entrypoint": "src/index.ts",
6
+ "symbols": [
7
+ "AnankeScenario",
8
+ "AnankeScenarioEntity",
9
+ "AnimationHints",
10
+ "Command",
11
+ "CommandMap",
12
+ "Entity",
13
+ "EntitySpec",
14
+ "G_mps2",
15
+ "I32",
16
+ "IndividualAttributes",
17
+ "KernelContext",
18
+ "LoadedPlugin",
19
+ "PluginHookContext",
20
+ "PluginHooks",
21
+ "PluginManifest",
22
+ "PluginModule",
23
+ "PluginPermission",
24
+ "PluginRuntimeApi",
25
+ "Q",
26
+ "Replay",
27
+ "ReplayFrame",
28
+ "ReplayRecorder",
29
+ "RigSnapshot",
30
+ "SCALE",
31
+ "WorldState",
32
+ "clampQ",
33
+ "createWorld",
34
+ "deriveAnimationHints",
35
+ "deserializeReplay",
36
+ "extractRigSnapshots",
37
+ "from",
38
+ "installPluginFromRegistry",
39
+ "loadPlugin",
40
+ "loadScenario",
41
+ "mulDiv",
42
+ "q",
43
+ "qDiv",
44
+ "qMul",
45
+ "replayTo",
46
+ "serializeReplay",
47
+ "sqrtQ",
48
+ "stepWorld",
49
+ "to",
50
+ "validateScenario"
51
+ ]
52
+ }
@@ -0,0 +1,37 @@
1
+ # Trust Dashboard
2
+
3
+ > GENERATED FILE: produced by `npm run generate-trust-dashboard`.
4
+ > Do not edit manually; update source artifacts and regenerate.
5
+
6
+ _Last updated: 2026-04-13T19:44:52.475Z_
7
+
8
+ ## Status rules (machine-derived)
9
+
10
+ - **verified**: all required artifacts exist and all checks pass.
11
+ - **partially verified**: required artifacts exist, checks are runnable, and coverage is below threshold.
12
+ - **unverified**: one or more required artifacts are missing or required checks fail.
13
+
14
+ ## Thresholds
15
+
16
+ - docs coherence: semantic inconsistencies must equal **0**.
17
+ - test coverage: line coverage must be **>= 85%**.
18
+ - determinism: CI matrix must pass, wasm coverage must meet threshold (default **90%** unless CI output overrides), and fuzz executions must meet threshold (default **2000** unless CI output overrides).
19
+
20
+ ## Inputs
21
+
22
+ - CI outputs: `docs/dashboard/ci-trust-report.json`
23
+ - Test coverage: `coverage/coverage-summary.json`
24
+ - Doc validation reports: `docs/doc-consistency-report.json`
25
+
26
+ ## Status matrix
27
+
28
+ | Area | Status | Computed summary | Evidence |
29
+ | --- | --- | --- | --- |
30
+ | docs coherence | verified | semantic inconsistencies = 0/0 | doc validation report: `docs/doc-consistency-report.json` |
31
+ | test coverage | unverified | missing coverage summary | coverage summary: `coverage/coverage-summary.json` (missing) |
32
+ | determinism | verified | ci matrix passes=true; wasm coverage 90.00%/90%; fuzz executions 2000/2000 | ci output: `docs/dashboard/ci-trust-report.json` |
33
+
34
+ ## CI stale-file rule
35
+
36
+ - CI must run `npm run check-trust-dashboard-artifacts`.
37
+ - The check re-renders `docs/trust-dashboard.md` in-memory and fails if the committed file differs.