cyberia 3.2.12 → 3.2.70

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 (194) hide show
  1. package/.env.example +127 -68
  2. package/.github/workflows/cyberia-client.cd.yml +40 -0
  3. package/.github/workflows/cyberia-server.cd.yml +40 -0
  4. package/.github/workflows/docker-image.cyberia-client.ci.yml +49 -0
  5. package/.github/workflows/docker-image.cyberia-client.dev.ci.yml +48 -0
  6. package/.github/workflows/docker-image.cyberia-server.ci.yml +69 -0
  7. package/.github/workflows/docker-image.cyberia-server.dev.ci.yml +69 -0
  8. package/.github/workflows/docker-image.engine-cyberia.ci.yml +52 -0
  9. package/.github/workflows/docker-image.engine-cyberia.dev.ci.yml +52 -0
  10. package/.github/workflows/engine-cyberia.cd.yml +34 -24
  11. package/.github/workflows/engine-cyberia.ci.yml +27 -5
  12. package/.github/workflows/ghpkg.ci.yml +89 -1
  13. package/.github/workflows/gitlab.ci.yml +1 -1
  14. package/.github/workflows/hardhat.ci.yml +1 -1
  15. package/.github/workflows/npmpkg.ci.yml +19 -12
  16. package/.github/workflows/publish.ci.yml +2 -2
  17. package/.github/workflows/publish.cyberia.ci.yml +5 -16
  18. package/.github/workflows/pwa-microservices-template-page.cd.yml +1 -8
  19. package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
  20. package/CHANGELOG.md +451 -1
  21. package/CLI-HELP.md +1040 -1130
  22. package/Dockerfile +141 -43
  23. package/Dockerfile.dev +143 -0
  24. package/Dockerfile.test +165 -0
  25. package/README.md +1 -1
  26. package/baremetal/commission-workflows.json +1 -0
  27. package/bin/build.js +128 -136
  28. package/bin/build.template.js +25 -179
  29. package/bin/cyberia.js +1089 -188
  30. package/bin/deploy.js +6 -3
  31. package/bin/index.js +1089 -188
  32. package/bump.config.js +1 -0
  33. package/compose.env +131 -0
  34. package/conf.js +19 -1
  35. package/deployment.yaml +74 -2
  36. package/docker-compose.yml +316 -0
  37. package/hardhat/hardhat.config.js +2 -2
  38. package/hardhat/package-lock.json +620 -2041
  39. package/hardhat/package.json +7 -5
  40. package/hardhat/scripts/deployObjectLayerToken.js +18 -18
  41. package/hardhat/test/ObjectLayerToken.js +378 -274
  42. package/ipfs/configure-ipfs.sh +13 -0
  43. package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +2 -2
  44. package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +1 -1
  45. package/manifests/deployment/dd-cyberia-development/deployment.yaml +74 -2
  46. package/manifests/deployment/dd-cyberia-development/grpc-service.yaml +17 -0
  47. package/manifests/deployment/dd-cyberia-development/pv-pvc.yaml +32 -0
  48. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  49. package/mongodb/entrypoint.sh +76 -0
  50. package/nginx.conf +87 -0
  51. package/package.json +34 -22
  52. package/pv-pvc.yaml +32 -0
  53. package/scripts/disk-clean.sh +85 -60
  54. package/scripts/kubeadm-node-setup.sh +317 -0
  55. package/scripts/link-local-underpost-cli.sh +6 -0
  56. package/scripts/rocky-kickstart.sh +877 -185
  57. package/scripts/rpmfusion-ffmpeg-setup.sh +26 -50
  58. package/scripts/test-monitor.sh +248 -0
  59. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.router.js +43 -7
  60. package/src/api/atlas-sprite-sheet/atlas-sprite-sheet.service.js +17 -25
  61. package/src/api/cyberia-action/cyberia-action.controller.js +19 -0
  62. package/src/api/cyberia-action/cyberia-action.model.js +21 -29
  63. package/src/api/cyberia-action/cyberia-action.router.js +42 -7
  64. package/src/api/cyberia-action/cyberia-action.service.js +20 -4
  65. package/src/api/cyberia-client-hints/cyberia-client-hints.model.js +58 -57
  66. package/src/api/cyberia-dialogue/cyberia-dialogue.router.js +37 -6
  67. package/src/api/cyberia-dialogue/cyberia-dialogue.service.js +8 -2
  68. package/src/api/cyberia-entity/cyberia-entity.router.js +39 -7
  69. package/src/api/cyberia-entity-type-default/cyberia-entity-type-default.controller.js +74 -0
  70. package/src/api/cyberia-entity-type-default/cyberia-entity-type-default.model.js +67 -0
  71. package/src/api/cyberia-entity-type-default/cyberia-entity-type-default.router.js +63 -0
  72. package/src/api/cyberia-entity-type-default/cyberia-entity-type-default.service.js +46 -0
  73. package/src/api/cyberia-instance/cyberia-fallback-world.js +62 -10
  74. package/src/api/cyberia-instance/cyberia-instance.model.js +32 -2
  75. package/src/api/cyberia-instance/cyberia-instance.router.js +6 -6
  76. package/src/api/cyberia-instance/cyberia-world-generator.js +116 -3
  77. package/src/api/cyberia-instance-conf/cyberia-instance-conf.model.js +3 -0
  78. package/src/api/cyberia-instance-conf/cyberia-instance-conf.router.js +39 -7
  79. package/src/api/cyberia-map/cyberia-map.router.js +21 -6
  80. package/src/api/cyberia-quest/cyberia-quest.controller.js +38 -0
  81. package/src/api/cyberia-quest/cyberia-quest.router.js +47 -7
  82. package/src/api/cyberia-quest/cyberia-quest.service.js +59 -4
  83. package/src/api/cyberia-saga/cyberia-saga.controller.js +74 -0
  84. package/src/api/cyberia-saga/cyberia-saga.model.js +59 -0
  85. package/src/api/cyberia-saga/cyberia-saga.router.js +63 -0
  86. package/src/api/cyberia-saga/cyberia-saga.service.js +42 -0
  87. package/src/api/cyberia-server-defaults/cyberia-server-defaults.js +551 -122
  88. package/src/api/cyberia-skill/cyberia-skill.controller.js +74 -0
  89. package/src/api/cyberia-skill/cyberia-skill.model.js +50 -0
  90. package/src/api/cyberia-skill/cyberia-skill.router.js +63 -0
  91. package/src/api/cyberia-skill/cyberia-skill.service.js +42 -0
  92. package/src/api/ipfs/ipfs.service.js +28 -15
  93. package/src/api/object-layer/object-layer.router.js +25 -15
  94. package/src/api/object-layer/object-layer.service.js +15 -20
  95. package/src/api/object-layer-render-frames/object-layer-render-frames.router.js +39 -7
  96. package/src/cli/baremetal.js +717 -16
  97. package/src/cli/cluster.js +80 -5
  98. package/src/cli/deploy.js +326 -292
  99. package/src/cli/docker-compose.js +648 -0
  100. package/src/cli/env.js +12 -6
  101. package/src/cli/fs.js +75 -30
  102. package/src/cli/image.js +187 -55
  103. package/src/cli/index.js +157 -6
  104. package/src/cli/kickstart.js +142 -20
  105. package/src/cli/monitor.js +387 -6
  106. package/src/cli/release.js +72 -15
  107. package/src/cli/repository.js +339 -40
  108. package/src/cli/run.js +678 -186
  109. package/src/cli/secrets.js +82 -48
  110. package/src/cli/ssh.js +234 -0
  111. package/src/cli/static.js +2 -2
  112. package/src/client/components/core/PanelForm.js +44 -44
  113. package/src/client/components/cyberia/ActionEngineCyberia.js +1867 -0
  114. package/src/client/components/cyberia/EntityEngineCyberia.js +585 -0
  115. package/src/client/components/cyberia/InstanceEngineCyberia.js +219 -13
  116. package/src/client/components/cyberia/MapEngineCyberia.js +154 -71
  117. package/src/client/components/cyberia/ObjectLayerEngineModal.js +40 -63
  118. package/src/client/components/cyberia/ObjectLayerEngineViewer.js +34 -20
  119. package/src/client/components/cyberia/SharedDefaultsCyberia.js +195 -4
  120. package/src/client/components/cyberia-portal/AppShellCyberiaPortal.js +66 -0
  121. package/src/client/components/cyberia-portal/RouterCyberiaPortal.js +8 -0
  122. package/src/client/components/cyberia-portal/TranslateCyberiaPortal.js +8 -0
  123. package/src/client/public/cyberia-docs/ACTION-SYSTEM.md +92 -20
  124. package/src/client/public/cyberia-docs/ARCHITECTURE.md +272 -50
  125. package/src/client/public/cyberia-docs/CYBERIA-CLI.md +3 -3
  126. package/src/client/public/cyberia-docs/CYBERIA-CLIENT.md +39 -22
  127. package/src/client/public/cyberia-docs/CYBERIA-LORE.md +88 -0
  128. package/src/client/public/cyberia-docs/CYBERIA-SAGA.md +394 -0
  129. package/src/client/public/cyberia-docs/CYBERIA-SERVER.md +28 -12
  130. package/src/client/public/cyberia-docs/CYBERIA.md +1 -1
  131. package/src/client/public/cyberia-docs/QUEST-SYSTEM.md +27 -5
  132. package/src/client/public/cyberia-docs/ROADMAP.md +1 -1
  133. package/src/client/public/cyberia-docs/WHITE-PAPER.md +1 -1
  134. package/src/client/services/cyberia-entity-type-default/cyberia-entity-type-default.service.js +99 -0
  135. package/src/client/services/cyberia-instance/cyberia-instance.management.js +2 -2
  136. package/src/client/services/cyberia-map/cyberia-map.management.js +2 -2
  137. package/src/client/services/cyberia-saga/cyberia-saga.service.js +99 -0
  138. package/src/client/services/cyberia-skill/cyberia-skill.service.js +99 -0
  139. package/src/client/services/object-layer/object-layer.management.js +6 -6
  140. package/src/{server → client-builder}/client-build-docs.js +15 -5
  141. package/src/{server → client-builder}/client-build-live.js +3 -3
  142. package/src/{server → client-builder}/client-build.js +25 -22
  143. package/src/{server → client-builder}/client-dev-server.js +3 -3
  144. package/src/{server → client-builder}/client-icons.js +2 -2
  145. package/src/{server → client-builder}/ssr.js +5 -5
  146. package/src/client.build.js +1 -3
  147. package/src/client.dev.js +1 -1
  148. package/src/db/mongo/MongoBootstrap.js +12 -12
  149. package/src/db/mongo/MongooseDB.js +2 -1
  150. package/src/grpc/cyberia/grpc-server.js +255 -70
  151. package/src/index.js +12 -1
  152. package/src/mailer/EmailRender.js +1 -1
  153. package/src/{server → projects/cyberia}/atlas-sprite-sheet-generator.js +2 -2
  154. package/src/{server → projects/cyberia}/besu-genesis-generator.js +3 -3
  155. package/src/projects/cyberia/catalog-cyberia.js +81 -0
  156. package/src/projects/cyberia/gemini-client.js +175 -0
  157. package/src/projects/cyberia/generate-saga.js +2107 -0
  158. package/src/{server → projects/cyberia}/ipfs-client.js +6 -4
  159. package/src/{server → projects/cyberia}/object-layer.js +12 -108
  160. package/src/{server → projects/cyberia}/semantic-layer-generator-floor.js +1 -1
  161. package/src/{server → projects/cyberia}/semantic-layer-generator-resource.js +1 -1
  162. package/src/{server → projects/cyberia}/semantic-layer-generator-skin.js +1 -1
  163. package/src/{server → projects/cyberia}/semantic-layer-generator.js +2 -2
  164. package/src/{server → projects/cyberia}/shape-generator.js +2 -2
  165. package/src/projects/underpost/catalog-underpost.js +60 -0
  166. package/src/runtime/cyberia-client/Dockerfile +31 -83
  167. package/src/runtime/cyberia-client/Dockerfile.dev +23 -30
  168. package/src/runtime/cyberia-server/Dockerfile +23 -42
  169. package/src/runtime/cyberia-server/Dockerfile.dev +20 -35
  170. package/src/runtime/engine-cyberia/Dockerfile +143 -0
  171. package/src/runtime/engine-cyberia/Dockerfile.dev +143 -0
  172. package/src/runtime/engine-cyberia/Dockerfile.test +165 -0
  173. package/src/runtime/engine-cyberia/compose.env +131 -0
  174. package/src/runtime/engine-cyberia/docker-compose.yml +316 -0
  175. package/src/runtime/engine-cyberia/ipfs/configure-ipfs.sh +13 -0
  176. package/src/runtime/engine-cyberia/mongodb/entrypoint.sh +76 -0
  177. package/src/runtime/engine-cyberia/nginx.conf +87 -0
  178. package/src/runtime/express/Express.js +2 -2
  179. package/src/runtime/nginx/Nginx.js +250 -0
  180. package/src/runtime/wp/Dockerfile +3 -3
  181. package/src/server/catalog.js +72 -0
  182. package/src/server/conf.js +415 -60
  183. package/src/server/runtime-status.js +252 -0
  184. package/src/server/start.js +42 -11
  185. package/src/server.js +6 -2
  186. package/test/cyberia-instance-conf-defaults.test.js +140 -0
  187. package/test/deploy-monitor.test.js +267 -0
  188. package/test/shape-generator.test.js +7 -1
  189. package/typedoc.dd-cyberia.json +3 -1
  190. package/typedoc.json +3 -1
  191. package/manifests/deployment/dd-test-development/deployment.yaml +0 -256
  192. package/manifests/deployment/dd-test-development/proxy.yaml +0 -102
  193. /package/src/client/ssr/{Render.js → RootDocument.js} +0 -0
  194. /package/src/{server → client-builder}/client-formatted.js +0 -0
@@ -22,6 +22,14 @@ class TranslateCyberiaPortal {
22
22
  en: 'Cyberia Instance Engine',
23
23
  es: 'Cyberia Instance Engine',
24
24
  };
25
+ Translate.Data['cyberia-action-engine'] = {
26
+ en: 'Cyberia Action Engine',
27
+ es: 'Cyberia Action Engine',
28
+ };
29
+ Translate.Data['cyberia-entity-engine'] = {
30
+ en: 'Cyberia Entity Engine',
31
+ es: 'Cyberia Entity Engine',
32
+ };
25
33
  }
26
34
  }
27
35
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  The Action System defines how NPC entities interact with players. An **Action** is a spatial, typed payload attached to a map entity that the player activates by tapping the NPC. Actions drive dialogue, shops, crafting, storage, and quest grant events.
10
10
 
11
- > **Implementation status — Pre-alpha:** The CyberiaAction and CyberiaDialogue MongoDB schemas and Engine REST API (`src/api/cyberia-action`, `src/api/cyberia-dialogue`) are defined. Go server integration (NPC tap routing to action handlers, shop/craft transaction processing, quest grant on dialogue completion) is planned for the **Alpha milestone**. The `freeze_start`/`freeze_end` WS messages for modal protection are implemented in the Go server today.
11
+ > **Implementation status — Alpha (talk / quest-talk):** The CyberiaAction and CyberiaDialogue MongoDB schemas and Engine REST API (`src/api/cyberia-action`, `src/api/cyberia-dialogue`) are defined. The `talk` and `quest-talk` paths are wired end-to-end: the Go server binds actions to entities at instance init, validates dialogue completion, grants quests, and advances `talk` objectives (see **Dialogue Interaction Protocol** below). Shop / craft / storage transaction processing remains planned for a later Alpha increment. The `freeze_start`/`freeze_end` WS messages for modal protection are implemented; dialogue freeze now rides on the `dlg_*` frames.
12
12
 
13
13
  ---
14
14
 
@@ -27,11 +27,12 @@ CyberiaAction {
27
27
  sourceCellX: Number
28
28
  sourceCellY: Number
29
29
 
30
- // Identity — used to match quest objectives of type 'talk'
31
- provideItemId: String // entity's active skin ObjectLayer item ID (e.g. 'wason', 'alex')
30
+ // Identity — the NPC skin is derived from the `default-<skin>` dialogue code
31
+ // (no stored field); 'talk' objectives match the talked-to bot's active skin.
32
32
 
33
- // Quest grantfirst interaction with this NPC starts the linked quest chain
34
- grantQuestCode: String // empty = no quest granted
33
+ // Quest awardNOT stored on the action. The quest(s) this action awards are
34
+ // the CyberiaQuest documents whose (sourceMapCode, sourceCellX, sourceCellY)
35
+ // match this action's cell; the runtime offers the next acceptable one.
35
36
 
36
37
  // Dialogue
37
38
  dialogCode: String // greeting dialogue shown on tap
@@ -73,7 +74,7 @@ A single `code` groups many ordered dialogue lines. The C client fetches all lin
73
74
 
74
75
  | Type | Description | Active Payload |
75
76
  | ------------ | -------------------------------------------------------------- | ---------------------------------------------------- |
76
- | `quest-talk` | Grants a quest on first interaction, then shows dialogue | `grantQuestCode`, `dialogCode`, `questDialogueCodes` |
77
+ | `quest-talk` | Awards the quest bound to its cell (via Take Quest), shows dialogue | quests bound by cell, `dialogCode`, `questDialogueCodes` |
77
78
  | `talk` | NPC dialogue only — satisfies `talk` quest objectives | `dialogCode`, `questDialogueCodes` |
78
79
  | `shop` | Item shop — player buys items with in-game currency | `shopItems[]` |
79
80
  | `craft` | Crafting station — consume ingredients to produce output items | `craftRecipes[]` |
@@ -83,25 +84,26 @@ A single `code` groups many ordered dialogue lines. The C client fetches all lin
83
84
 
84
85
  ## Action–Quest Integration
85
86
 
86
- The Action System and Quest System are linked through `provideItemId` and `questDialogueCodes`:
87
+ The Action System and Quest System are linked by **cell** (the action and the
88
+ quest it awards share `sourceMapCode/sourceCellX/sourceCellY`) and by the NPC's
89
+ active **skin** (which `talk` objectives match):
87
90
 
88
91
  ```mermaid
89
92
  graph LR
90
- Quest["CyberiaQuest\nstep.objective:\n{ type: 'talk', itemId: 'wason' }"]
91
- Action["CyberiaAction\nprovideItemId: 'wason'\ngrantQuestCode: 'wason-intro'\nquestDialogueCodes: ['wason-intro']"]
93
+ Quest["CyberiaQuest\nsource cell: (12,10)\nstep.objective: { type: 'talk', itemId: 'wason' }"]
94
+ Action["CyberiaAction\nsource cell: (12,10)\nquestDialogueCodes: ['default-wason']"]
92
95
  Progress["CyberiaQuestProgress\nstep.objectiveProgress[i].current++"]
93
96
 
94
- Quest -->|matched by provideItemId| Action
97
+ Quest -->|same source cell| Action
95
98
  Action -->|player completes dialogue| Progress
96
99
  ```
97
100
 
98
101
  **Talk objective satisfaction flow:**
99
102
 
100
103
  1. Player taps NPC → interaction bubble shown.
101
- 2. Player taps interaction bubble → Action is fetched by spatial coordinates.
102
- 3. Client displays `dialogCode` dialogue sequence.
103
- 4. On first tap, if `grantQuestCode` is set server grants the quest.
104
- 5. After viewing all `questDialogueCodes` dialogue lines → server increments the matching `talk` objective's `current` counter.
104
+ 2. Player taps interaction bubble → `modal_interact` opens; the offered quest is the one bound to the NPC's cell.
105
+ 3. Accepting is explicit: the **Take Quest** button sends `quest_accept` and the server grants the acceptable quest bound to that cell (prerequisites met, not active/completed).
106
+ 4. Talk objectives advance only after the player reads **all** `questDialogueCodes` lines (`dlg_complete`), validated server-side; never by a button.
105
107
 
106
108
  ---
107
109
 
@@ -154,6 +156,80 @@ sequenceDiagram
154
156
 
155
157
  ---
156
158
 
159
+ ## Dialogue Interaction Protocol (talk / quest-talk)
160
+
161
+ Tapping an interaction bubble opens the Raylib-native **`modal_interact`** modal
162
+ (top half of the screen). It has a tab strip — **stack** (active item slots),
163
+ **stats** (six-stat stack totals), and **action** (mission interface, shown only
164
+ for action-provider entities, ESI 8) — over a fixed bottom bar of right-aligned
165
+ integration buttons (**Chat**, **Integration**) that open the JS overlay. The
166
+ action tab's **Talk / Take mission** opens `modal_dialogue` (bottom half).
167
+
168
+ The client is identical for `talk` and `quest-talk`; the **server** branches after
169
+ `dlg_complete`. The client never declares the action type, quest code, or quest
170
+ dialogue codes — the server resolves the bound action from its own
171
+ `entityId → CyberiaAction` cache (bound at instance init).
172
+
173
+ ### Wire messages
174
+
175
+ | Direction | Message | When | Payload |
176
+ | --------- | -------------- | ------------------------------------- | ------------------------------------ |
177
+ | C → S | `dlg_start` | `modal_dialogue` opens | `{ entityId, itemId }` |
178
+ | C → S | `dlg_complete` | player reads all lines, closes | `{ entityId, itemId, dialogCode }` |
179
+ | C → S | `dlg_cancel` | player dismisses early (✕ / outside) | `{ entityId, itemId }` |
180
+ | S → C | `dlg_ack` | after `dlg_complete` is processed | `{ questGranted, objectivesDone, quests[] }` |
181
+
182
+ Binary uplink opcodes: `dlg_start` `0x17`, `dlg_complete` `0x18`, `dlg_cancel`
183
+ `0x19` (JSON aliases of the same names are also accepted).
184
+
185
+ `dlg_ack` is notify-only — it carries the affected quest snapshot entries the
186
+ client upserts into its local `quest_store` (Quest Journal); it never gates
187
+ simulation state.
188
+
189
+ ### Server `dlg_complete` handling
190
+
191
+ 1. Validate `player.activeDialogueEntityID == msg.entityId`; drop otherwise.
192
+ 2. Clear the dialogue context and thaw the player (modal protection off).
193
+ 3. Resolve the action from `actionCache[entityId]`. `talk` → ack only.
194
+ 4. `quest-talk`: `dlg_complete` NEVER grants — it advances every active quest
195
+ whose **current step** has a `{ type: 'talk', itemId == bot active skin }`
196
+ objective, **only** when `msg.dialogCode` is in the action's
197
+ `questDialogueCodes`. Granting is a separate explicit `quest_accept`, which
198
+ grants the acceptable quest bound to the NPC's cell. On quest completion,
199
+ deliver rewards (FCT); successors are NOT auto-granted (the player accepts
200
+ each from its NPC).
201
+
202
+ > **Dialogue-code contract.** The C client fetches dialogue groups at
203
+ > `/api/cyberia-dialogue/code/default-<itemId>`, so the code it reports on
204
+ > `dlg_complete` is `default-<provideItemId>`. For a `quest-talk` objective to
205
+ > advance, the action's `questDialogueCodes` must contain that code.
206
+
207
+ ### Freeze semantics
208
+
209
+ | Event | Player state |
210
+ | ---------------------------------- | ------------------------- |
211
+ | `modal_interact` open | Active (no freeze) |
212
+ | `dlg_start` sent | Frozen — immune to damage |
213
+ | `dlg_complete` / `dlg_cancel` sent | Unfrozen |
214
+
215
+ ---
216
+
217
+ ## Fallback World mission instantiation
218
+
219
+ The default mission system is playable in the procedural **Fallback World**.
220
+ `DefaultCyberiaActions` carry `sourceMapCode` / `sourceCellX` / `sourceCellY`
221
+ (all on `fallback-map-0`), and the world generator's
222
+ `generateActionProviderBots()` places one passive NPC bot per action at those
223
+ exact cells (skin = `provideItemId`, zero spawn/aggro radius). The fallback map
224
+ builder reserves those cells (dropping any overlapping obstacle) so the NPCs
225
+ always stand on walkable ground. The Go server then binds each bot back to its
226
+ action by `sourceMapCode + sourceCellX + sourceCellY` at instance init and keeps
227
+ an **ephemeral** per-session `CyberiaQuestProgress` (no persistence) — matching
228
+ the ROADMAP Road-to-Alpha-Open contract. `scp-2040` kill targets spawn from the
229
+ random bot pool, so the intro quest's talk → collect → kill loop is reachable.
230
+
231
+ ---
232
+
157
233
  ## Spatial Binding and Instance Init
158
234
 
159
235
  `sourceMapCode + sourceCellX + sourceCellY` links an Action to a specific entity cell in a specific map. During instance initialization:
@@ -203,8 +279,6 @@ The C client fetches the full `code` group sorted by `order`, then renders lines
203
279
  ```javascript
204
280
  // CyberiaAction
205
281
  { code: 1 } // unique
206
- { provideItemId: 1 }
207
- { grantQuestCode: 1 } // sparse
208
282
  { sourceMapCode: 1, sourceCellX: 1, sourceCellY: 1 }
209
283
 
210
284
  // CyberiaDialogue
@@ -224,10 +298,8 @@ The C client fetches the full `code` group sorted by `order`, then renders lines
224
298
  "sourceMapCode": "cyberia-village",
225
299
  "sourceCellX": 12,
226
300
  "sourceCellY": 8,
227
- "provideItemId": "wason",
228
- "grantQuestCode": "wason-intro",
229
- "dialogCode": "wason-intro",
230
- "questDialogueCodes": ["wason-intro"],
301
+ "dialogCode": "default-wason",
302
+ "questDialogueCodes": ["default-wason"],
231
303
  "shopItems": [],
232
304
  "craftRecipes": [],
233
305
  "storageSlots": 0
@@ -1,78 +1,118 @@
1
- # Cyberia Architecture
1
+ # Cyberia Architecture
2
2
 
3
- Cyberia is the MMO extension that runs on top of Underpost Platform. Keep the model simple:
3
+ Cyberia is the real-time MMO extension that runs on Underpost Platform. This document describes the three Cyberia processes, their boundaries, the data flow between them, and the canonical model for tick, snapshot, prediction, reconciliation, interpolation, and replication.
4
4
 
5
- - Underpost Platform provides the toolchain, deployment surface, PWA delivery, and base infrastructure.
6
- - `engine-cyberia` is the content authority.
7
- - `cyberia-server` is the authoritative simulation.
8
- - `cyberia-client` is the presentation runtime.
5
+ Underpost Platform provides the toolchain, deployment surface, PWA delivery, and base infrastructure. The three Cyberia processes operate on top of it.
9
6
 
10
7
  ---
11
8
 
12
- ## System map
9
+ ## Process model
13
10
 
14
- ```text
15
- Underpost Platform
16
- -> toolchain, deploy, PWA build, static delivery, monitoring
11
+ ```
12
+ ┌─────────────────────────────────────────────────────────────────────────┐
13
+ UNDERPOST PLATFORM (infra · toolchain · deploy · PWA/Workbox) │
14
+ │ │
15
+ │ ┌─────────────────────┐ │
16
+ │ │ Persistent backend │ ← Cyberia content authority + asset backend │
17
+ │ │ ────────────────── │ │
18
+ │ │ engine-cyberia │ Node.js │
19
+ │ │ MongoDB │ │
20
+ │ │ IPFS / Cloudinary │ │
21
+ │ │ ObjectLayerToken │ Hyperledger Besu (off-line dependency) │
22
+ │ └─────────┬───────────┘ │
23
+ │ │ gRPC (world load, hot reload) │
24
+ │ ▼ │
25
+ │ ┌─────────────────────┐ │
26
+ │ │ Authoritative │ ← Cyberia simulation authority │
27
+ │ │ simulation runtime │ │
28
+ │ │ ────────────────── │ │
29
+ │ │ cyberia-server │ Go │
30
+ │ └─────────┬───────────┘ │
31
+ │ │ WebSocket (binary AOI snapshots, typed input commands) │
32
+ │ ▼ │
33
+ │ ┌─────────────────────┐ │
34
+ │ │ Presentation │ ← Cyberia render + prediction client │
35
+ │ │ runtime │ │
36
+ │ │ ────────────────── │ │
37
+ │ │ cyberia-client │ C / WebAssembly (Raylib · Emscripten) │
38
+ │ └─────────────────────┘ │
39
+ │ │ │
40
+ │ │ REST (atlas frames, asset metadata, optional client hints) │
41
+ │ └──→ engine-cyberia │
42
+ └─────────────────────────────────────────────────────────────────────────┘
43
+ ```
17
44
 
18
- engine-cyberia (Node.js)
19
- -> content, validation, persistence, gRPC/REST data services, asset metadata
20
- -> feeds cyberia-server and cyberia-client
45
+ Three processes, strict role separation. The ecosystem is fully operational only when all three are running and healthy at the same time.
21
46
 
22
- cyberia-server (Go)
23
- -> authoritative simulation and tick processing
24
- -> feeds cyberia-client over WebSocket
47
+ ---
25
48
 
26
- cyberia-client (C/WASM)
27
- -> rendering, input, prediction, presentation
28
- ```
49
+ ## Role definitions
29
50
 
30
- ---
51
+ ### engine-cyberia (Node.js) — content authority
31
52
 
32
- ## Responsibility split
53
+ The content-authoring backend and persistence layer for Cyberia. Owns persisted data and exposes it through two transports: gRPC (consumed by `cyberia-server` at boot and during hot reload) and REST (consumed by `cyberia-client` for asset distribution and optional presentation overrides).
33
54
 
34
- | Service | Owns | Must not own |
35
- | ---------------- | ------------------------------------------------------------------------- | --------------------------------------------- |
36
- | `engine-cyberia` | content, validation, persistence, gRPC/REST data services, asset metadata | authoritative simulation, render policy |
37
- | `cyberia-server` | authoritative simulation, world tick, gameplay mutation, AOI replication | content authority, presentation metadata |
38
- | `cyberia-client` | rendering, input, prediction, interpolation, presentation | authoritative world state, gameplay authority |
55
+ What it owns:
39
56
 
40
- Two boundaries are non-negotiable:
57
+ - Content generation, validation, and persistence.
58
+ - Maps, portals, object layers, atlas/sprite-sheet metadata.
59
+ - World configuration: AOI radius, economy rules, skill rules, equipment rules, entity gameplay defaults.
60
+ - Persisted character/quest/dialogue/action data.
61
+ - gRPC `CyberiaDataService` for world load and content streaming.
62
+ - REST APIs for assets and the optional client-hints overrides.
63
+ - Static content distribution + Cloudinary-backed asset flow.
64
+ - Editor and CLI integration for content workflows.
41
65
 
42
- - Do not move authoritative logic into the client.
43
- - Do not move content-authority logic into the Go runtime.
66
+ What it does NOT own:
44
67
 
45
- ---
68
+ - Real-time simulation. It is not a gameplay runtime.
69
+ - Per-tick state advancement.
70
+ - Client presentation policy (palette, camera, dev overlay, icon visuals).
71
+ - World mutation during gameplay.
46
72
 
47
- ## Data flow
73
+ ### cyberia-server (Go) — authoritative simulation runtime
48
74
 
49
- ```text
50
- engine-cyberia --gRPC--> cyberia-server --WebSocket--> cyberia-client
51
- engine-cyberia --REST-------------------------------> cyberia-client
52
- ```
75
+ The tick-based authoritative simulation. Owns world state and the gameplay rules that mutate it.
53
76
 
54
- - `engine-cyberia` publishes world content, validation rules, persistence-backed data, and asset metadata.
55
- - `cyberia-server` loads authoritative world data, advances the simulation tick, and emits per-player AOI snapshots.
56
- - `cyberia-client` sends typed input commands upstream and renders the result locally with prediction and interpolation.
77
+ What it owns:
57
78
 
58
- There is one source of truth per concern:
79
+ - Authoritative world state.
80
+ - The tick: a `uint32` advanced once per simulation step at a fixed `tickRate`.
81
+ - Simulation phases — the only allowed mutators of world state.
82
+ - AOI replication: per-player interest filtering and snapshot emission.
83
+ - Input command processing: typed input commands drained from per-player queues each tick.
84
+ - Snapshot generation and delivery via WebSocket.
59
85
 
60
- - Content and world configuration: `engine-cyberia`
61
- - Real-time authoritative state: `cyberia-server`
62
- - Presentation and local interaction: `cyberia-client`
86
+ What it does NOT own:
63
87
 
64
- ---
88
+ - Persistence (loaded once at boot from engine-cyberia).
89
+ - Client presentation. The server holds no palette, no camera knobs, no dev-overlay flag, no status-icon visuals.
90
+
91
+ ### cyberia-client (C / WebAssembly) — presentation runtime
92
+
93
+ The render and interactive runtime. Compiled to WASM via Emscripten and served as a Progressive Web App through the Underpost Platform delivery pipeline.
65
94
 
66
- ## Operational guardrails
95
+ What it owns:
67
96
 
68
- - Prefer one source of truth for config, deploy IDs, runtime selection, startup behavior, and generated assets.
69
- - Reuse existing helpers and conventions instead of creating parallel implementations.
70
- - Do not duplicate parsing, env resolution, or path normalization logic across modules.
71
- - Treat generated artifacts as outputs only; never hand-edit them.
97
+ - Rendering and UI.
98
+ - Input capture: raw OS events typed input commands with monotonic sequence numbers.
99
+ - Prediction of the local player.
100
+ - Reconciliation against authoritative snapshots.
101
+ - Interpolation of remote entities.
102
+ - Presentation defaults (palette, status-icon visuals, camera knobs, interpolation window, dev-overlay flag) — loaded at startup from the client-hints REST endpoint.
103
+ - Optional client-hints fetch for per-instance presentation overrides.
104
+
105
+ What it does NOT own:
106
+
107
+ - World simulation.
108
+ - Economy outcomes, combat resolution, skill dispatch decisions.
109
+ - Any state another client depends on for correctness.
72
110
 
73
111
  ---
74
112
 
75
- ## Health states
113
+ ## Runtime operating model
114
+
115
+ The three processes are supervised independently. Each service owns its own monitor and reconnector. The game is playable only when all three are healthy at the same time.
76
116
 
77
117
  | State | Meaning |
78
118
  | ---------- | -------------------------------------------------------------------- |
@@ -80,4 +120,186 @@ There is one source of truth per concern:
80
120
  | `degraded` | at least one service is reconnecting or unavailable |
81
121
  | `standby` | gameplay is paused because the full three-service set is not healthy |
82
122
 
83
- This is the model to document, operate, and monitor against.
123
+ Dependency between services is handled by supervision and reconnect loops:
124
+
125
+ - `cyberia-server` dials `engine-cyberia` gRPC at boot and exits on dial failure rather than fabricate a world. On reconnect, it reloads world configuration.
126
+ - `cyberia-client` reconnects to `cyberia-server` over WebSocket and re-fetches content from `engine-cyberia` over REST independently.
127
+ - If any one of the three services goes unhealthy, the game moves to standby until all three recover.
128
+
129
+ Underpost Platform deploy orchestration ensures the backend layer is ready before the simulation layer is started, and the simulation layer is ready before the presentation layer connects. This ordering is an infrastructure concern, not a documentation model: the processes themselves are supervised and reconnect without requiring a manual restart chain.
130
+
131
+ ---
132
+
133
+ ## Tick model
134
+
135
+ The tick is the universal coordinate of the simulation. Every server→client snapshot and every client→server input command carries a tick value.
136
+
137
+ | Concept | Value | Notes |
138
+ | ------------------------ | ------------------------------------- | ------------------------------------------------------------------------------------------------------- |
139
+ | **tick** | `uint32` | Monotonic simulation step counter on `cyberia-server`. Resets only on world rebuild. |
140
+ | **tick rate** | Hz (default `30`) | Simulation frequency. Authoritative; comes from world configuration. The string "fps" is never used to describe the server. |
141
+ | **snapshot rate** | Hz (default `20`) | AOI replication frequency. Decoupled from tick rate so bandwidth scales independently of simulation fidelity. |
142
+ | **tick duration** | `1 / tick_rate` | The dt used by every simulation phase. |
143
+ | **client tick estimate** | derived | Client estimate of the server's current tick, used to stamp outgoing input commands. |
144
+ | **render tick** | `server_tick_estimate − INTERP_TICKS` | The tick the interpolation module samples remote entities at. |
145
+
146
+ Three clocks, one tick number: simulation tick (server), snapshot tick (server replication), render frame (client). The tick number is the only synchronization point.
147
+
148
+ ---
149
+
150
+ ## Simulation phases
151
+
152
+ Inside one simulation tick, `cyberia-server` runs the following phases in fixed order. These are the only functions that mutate authoritative world state:
153
+
154
+ 1. `phaseInput` — drain each player's `InputQueue`; dispatch typed input commands to gameplay handlers.
155
+ 2. `phaseLifecycle` — respawn timers, despawn expirations.
156
+ 3. `phaseSkills` — skill projectile collisions.
157
+ 4. `phaseAI` — bot behaviour decisions.
158
+ 5. `phaseMovement` — integrate positions using `tickDuration`.
159
+ 6. `phasePortals` — portal entry and teleport.
160
+
161
+ A separate ticker runs replication independently of the simulation:
162
+
163
+ - `phaseReplication` — per player: compute AOI, encode snapshot, dispatch. Runs at `snapshotRate`.
164
+
165
+ Phases never read presentation data. They consume world configuration loaded at boot (gameplay rules) and the input queue.
166
+
167
+ ---
168
+
169
+ ## Client render frame
170
+
171
+ The render frame runs at vsync. Inside one render frame, `cyberia-client` performs:
172
+
173
+ 1. Poll any pending optional client-hints fetch.
174
+ 2. Capture raw input → build typed input command (`kind`, `clientTick`, `sequence`, payload) → apply to prediction → send on the wire.
175
+ 3. Reconcile against the latest snapshot: drop input commands ≤ `lastAckedSequence`, rewind self to authoritative position, replay unacked commands.
176
+ 4. Fixed-timestep simulation: while accumulator ≥ `tickDuration`, advance prediction one tick.
177
+ 5. Interpolation: compute remote-entity view positions at `renderTick`.
178
+ 6. Render. Read view models; never mutate world state.
179
+
180
+ Render frame rate is independent of simulation tick rate. The fixed-timestep accumulator ensures the predicted simulation advances at the authoritative `tickRate` regardless of FPS.
181
+
182
+ ---
183
+
184
+ ## Wire protocol — AOI snapshot header
185
+
186
+ Snapshots travel as binary WebSocket frames. The header carries the simulation tick and the per-player acknowledged input sequence.
187
+
188
+ ```
189
+ Header (binary, little-endian, 11 bytes for AOI snapshots):
190
+ [0] u8 msgType 0x01 = aoi_update, 0x03 = full_aoi
191
+ [1..4] u32 tick simulation tick at which the snapshot was produced
192
+ [5..8] u32 lastAcked highest InputCommand.Sequence applied for this player
193
+ [9..10] u16 entityCount entity blocks that follow
194
+ ```
195
+
196
+ Other message types (init data, FCT) use their own headers and are not part of the per-tick replication stream.
197
+
198
+ ---
199
+
200
+ ## Input command pipeline
201
+
202
+ Client input flows through a typed pipeline. There is no JSON intermediate on the binary path. The simulation tick is the only consumer.
203
+
204
+ ```
205
+ WS frame (binary) → decode → typed InputCommand{kind, clientTick, sequence, payload}
206
+
207
+ dispatchInputCommand
208
+
209
+ PlayerState.InputQueue (per-player, bounded)
210
+
211
+ phaseInput (under world mutex, once per simulation tick)
212
+
213
+ phase_input_handlers.go — typed dispatch per InputKind
214
+
215
+ authoritative world state
216
+ ```
217
+
218
+ `InputCommand.Sequence` is monotonic per client. The server tracks the highest applied sequence per player; `phaseReplication` writes it into every snapshot header. The client drops acknowledged input commands from its prediction replay buffer using this value.
219
+
220
+ ---
221
+
222
+ ## Presentation metadata ownership
223
+
224
+ Presentation is client-owned. The authoritative server holds no presentation state.
225
+
226
+ | Concern | Owner | Mechanism |
227
+ | ------------------------------------------------ | --------------------- | ------------------------------------------------------------------------------- |
228
+ | Palette (named ColorRGBA entries) | engine-cyberia (REST) | served by `GET /api/cyberia-client-hints/:CYBERIA_CLIENT_HINTS_CODE`. Source schema: `SharedDefaultsCyberia.js`. |
229
+ | Status-icon visuals (icon stems + border colors) | engine-cyberia (REST) | same |
230
+ | Per-entity-type fallback color keys | engine-cyberia (REST) | same |
231
+ | Camera defaults (smoothing, zoom) | engine-cyberia (REST) | same |
232
+ | Cell-pixel size, default object dims | engine-cyberia (REST) | same |
233
+ | Interpolation window | engine-cyberia (REST) | same |
234
+ | Dev-overlay flag | engine-cyberia (REST) | same |
235
+ | World configuration (gameplay rules) | engine-cyberia (gRPC) | `CyberiaInstanceConf` — no presentation; only simulation |
236
+
237
+ The cyberia-client carries **no** compile-time palette. `domain/presentation_runtime.{c,h}` fetches the full presentation surface on startup; until the fetch settles the runtime returns a tiny inline neutral-grey bootstrap so the splash screen has something to draw. The simulation is unaffected by the fetch outcome.
238
+
239
+ `cyberia-server` never reads any presentation field. The only "representational" data on the simulation wire is the **active item IDs** carried inside each AOI snapshot. Everything else visual is the client's job, fed by the hints REST endpoint.
240
+
241
+ ---
242
+
243
+ ## Canonical vocabulary
244
+
245
+ Every Cyberia document uses the same terms. Aliases are not permitted.
246
+
247
+ | Term | Definition |
248
+ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
249
+ | **tick** | Monotonic simulation step counter. |
250
+ | **tick rate** | Simulation Hz on `cyberia-server`. |
251
+ | **snapshot** | AOI-filtered world view at one tick for one player. |
252
+ | **prediction** | Optimistic local apply of input commands to the predicted self entity. |
253
+ | **reconciliation** | Drop acknowledged inputs, rewind self to authoritative position, replay unacked inputs. |
254
+ | **display smoothing** | Per-render-frame exponential lerp from the discrete predicted self position to a continuous on-screen position. Decouples the visible main player from sim-tick boundaries. |
255
+ | **interpolation** | Render-time smoothing of remote entities, sampled from snapshot history. |
256
+ | **authoritative server** | `cyberia-server`. Sole authority on world state. |
257
+ | **content authority** | `engine-cyberia`. Sole authority on persisted content and world configuration. |
258
+ | **client hints** | Optional presentation overrides served by engine-cyberia. |
259
+ | **world configuration** | Gameplay parameters loaded at server boot from engine-cyberia. |
260
+ | **presentation metadata** | Render-only data. Client-owned. |
261
+ | **input command** | Typed client→server frame with kind, clientTick, sequence, payload. |
262
+ | **AOI** | Area of interest — the spatial filter that defines which entities a given player receives. |
263
+ | **replication** | Production and delivery of snapshots from server to clients. |
264
+ | **simulation phase** | A named step inside one simulation tick. |
265
+ | **healthy** | All three Cyberia services up and connected; game is playable. |
266
+ | **standby** | Game paused because at least one of the three services is not healthy. |
267
+
268
+ Forbidden usages:
269
+
270
+ - "fps" on `cyberia-server` (use **tick rate**).
271
+ - "frame-based" simulation language on the server.
272
+ - "game_state" as a god object on the client.
273
+ - Render metadata in `cyberia-server` state.
274
+ - "engine" without qualifier when the project name is intended. Use **engine-cyberia** for the Cyberia content backend; use **Underpost Platform** for the umbrella product.
275
+
276
+ ---
277
+
278
+ ## Instance topology
279
+
280
+ A `CyberiaInstance` (persisted in MongoDB, served by engine-cyberia) is a directed graph:
281
+
282
+ - **Vertices** — `CyberiaMap` documents (grid-based maps).
283
+ - **Edges** — `PortalEdge` records connecting source cell → target map/cell.
284
+
285
+ Portal modes:
286
+
287
+ | Mode | Behaviour |
288
+ | -------------- | ----------------------------------------------- |
289
+ | `inter-portal` | Teleport to a specific cell on a target map |
290
+ | `inter-random` | Teleport to a random valid cell on a target map |
291
+ | `intra-portal` | Teleport within the same map to a specific cell |
292
+ | `intra-random` | Teleport within the same map to a random cell |
293
+
294
+ Topology modes: `linear`, `hub-spoke`, `open`, `grid`.
295
+
296
+ ---
297
+
298
+ ## Entity types
299
+
300
+ | Type | Behavior | Description |
301
+ | -------------- | --------------------- | --------------------------- |
302
+ | `player` | interactive | Local player (self) |
303
+ | `other_player` | interactive | Remote players inside AOI |
304
+ | `bot` | `hostile` / `passive` | AI-controlled entities |
305
+ | `skill` | `skill` | Runtime-spawned projectile |
@@ -178,8 +178,8 @@ Named scripts from the `scripts/` directory for seeding and build maintenance.
178
178
 
179
179
  | Subcommand | Description |
180
180
  | ---------------------------- | ----------------------------------------------------------------------------------- |
181
- | `import-default-items` | Import default object layers, skill config, dialogues, client-hints to Mongo |
182
- | `seed-skill-config` | Upsert `DefaultSkillConfig` into a `CyberiaInstance` (`--instance-code`) |
181
+ | `import-default-items` | Import default object layers, skills, dialogues, actions/quests, client-hints to Mongo |
182
+ | `seed-skills` | Upsert `DefaultSkillConfig` into the `cyberia-skill` collection (full records) |
183
183
  | `seed-dialogues` | Upsert `DefaultCyberiaDialogues` into the `cyberia-dialogue` collection |
184
184
  | `generate-semantic-examples` | Generate one procedural example per registered semantic prefix |
185
185
  | `build-manifest` | Build K8s Deployment + Service manifests for mmo-client / mmo-server |
@@ -187,7 +187,7 @@ Named scripts from the `scripts/` directory for seeding and build maintenance.
187
187
 
188
188
  ```bash
189
189
  cyberia run-workflow import-default-items --env-path ./engine-private/conf/dd-cyberia/.env.development
190
- cyberia run-workflow seed-skill-config --instance-code default
190
+ cyberia run-workflow seed-skills
191
191
  cyberia run-workflow generate-semantic-examples
192
192
  cyberia run-workflow build-manifest
193
193
  cyberia run-workflow build-server-dashboard