@escapeaihq/client-core 0.49.1 → 0.138.0
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.
- package/README.md +445 -153
- package/dist/adapters/capabilities.d.ts +20 -3
- package/dist/adapters/capabilities.d.ts.map +1 -1
- package/dist/adapters/directorAdapter.d.ts +5 -4
- package/dist/adapters/directorAdapter.d.ts.map +1 -1
- package/dist/adapters/directorAdapter.js +5 -4
- package/dist/adapters/directorAdapter.js.map +1 -1
- package/dist/adapters/experienceModelCatalog.d.ts +382 -0
- package/dist/adapters/experienceModelCatalog.d.ts.map +1 -0
- package/dist/adapters/experienceModelCatalog.js +401 -0
- package/dist/adapters/experienceModelCatalog.js.map +1 -0
- package/dist/adapters/extractionAdapter.d.ts +81 -0
- package/dist/adapters/extractionAdapter.d.ts.map +1 -0
- package/dist/adapters/extractionAdapter.js +98 -0
- package/dist/adapters/extractionAdapter.js.map +1 -0
- package/dist/adapters/imageAdapter.d.ts +5 -1
- package/dist/adapters/imageAdapter.d.ts.map +1 -1
- package/dist/adapters/imageAdapter.js +5 -1
- package/dist/adapters/imageAdapter.js.map +1 -1
- package/dist/adapters/index.d.ts +54 -16
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +62 -11
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/momentDirective.d.ts +66 -0
- package/dist/adapters/momentDirective.d.ts.map +1 -0
- package/dist/adapters/momentDirective.js +78 -0
- package/dist/adapters/momentDirective.js.map +1 -0
- package/dist/adapters/momentPolicy.d.ts +132 -0
- package/dist/adapters/momentPolicy.d.ts.map +1 -0
- package/dist/adapters/momentPolicy.js +165 -0
- package/dist/adapters/momentPolicy.js.map +1 -0
- package/dist/adapters/registry.d.ts +1 -1
- package/dist/adapters/registry.d.ts.map +1 -1
- package/dist/adapters/videoGenAdapter.d.ts +55 -0
- package/dist/adapters/videoGenAdapter.d.ts.map +1 -0
- package/dist/adapters/videoGenAdapter.js +78 -0
- package/dist/adapters/videoGenAdapter.js.map +1 -0
- package/dist/adapters/worldAdapter.d.ts +132 -11
- package/dist/adapters/worldAdapter.d.ts.map +1 -1
- package/dist/adapters/worldAdapter.js +127 -11
- package/dist/adapters/worldAdapter.js.map +1 -1
- package/dist/adapters/worldModelPreference.d.ts +173 -0
- package/dist/adapters/worldModelPreference.d.ts.map +1 -0
- package/dist/adapters/worldModelPreference.js +209 -0
- package/dist/adapters/worldModelPreference.js.map +1 -0
- package/dist/adapters/worldModelTradeoffs.d.ts +120 -0
- package/dist/adapters/worldModelTradeoffs.d.ts.map +1 -0
- package/dist/adapters/worldModelTradeoffs.js +154 -0
- package/dist/adapters/worldModelTradeoffs.js.map +1 -0
- package/dist/admin.d.ts +545 -0
- package/dist/admin.d.ts.map +1 -1
- package/dist/admin.js +230 -16
- package/dist/admin.js.map +1 -1
- package/dist/api.d.ts +10281 -2216
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +4174 -1240
- package/dist/api.js.map +1 -1
- package/dist/arcBoardJoin.d.ts +38 -0
- package/dist/arcBoardJoin.d.ts.map +1 -0
- package/dist/arcBoardJoin.js +37 -0
- package/dist/arcBoardJoin.js.map +1 -0
- package/dist/arcPreview.d.ts +49 -0
- package/dist/arcPreview.d.ts.map +1 -0
- package/dist/arcPreview.js +65 -0
- package/dist/arcPreview.js.map +1 -0
- package/dist/audio.d.ts +259 -16
- package/dist/audio.d.ts.map +1 -1
- package/dist/audio.js +605 -114
- package/dist/audio.js.map +1 -1
- package/dist/audioDsp.d.ts +45 -0
- package/dist/audioDsp.d.ts.map +1 -0
- package/dist/audioDsp.js +108 -0
- package/dist/audioDsp.js.map +1 -0
- package/dist/audioProtocol.d.ts +160 -0
- package/dist/audioProtocol.d.ts.map +1 -1
- package/dist/audioProtocol.js +99 -0
- package/dist/audioProtocol.js.map +1 -1
- package/dist/beatTitles.d.ts +33 -0
- package/dist/beatTitles.d.ts.map +1 -0
- package/dist/beatTitles.js +39 -0
- package/dist/beatTitles.js.map +1 -0
- package/dist/castProjection.d.ts +204 -1
- package/dist/castProjection.d.ts.map +1 -1
- package/dist/castProjection.js +202 -0
- package/dist/castProjection.js.map +1 -1
- package/dist/characterGrounding.d.ts +369 -0
- package/dist/characterGrounding.d.ts.map +1 -0
- package/dist/characterGrounding.js +408 -0
- package/dist/characterGrounding.js.map +1 -0
- package/dist/conversation/binding.d.ts +41 -1
- package/dist/conversation/binding.d.ts.map +1 -1
- package/dist/conversation/binding.js +12 -0
- package/dist/conversation/binding.js.map +1 -1
- package/dist/conversation/chatSessionStore.d.ts +178 -0
- package/dist/conversation/chatSessionStore.d.ts.map +1 -0
- package/dist/conversation/chatSessionStore.js +196 -0
- package/dist/conversation/chatSessionStore.js.map +1 -0
- package/dist/conversation/controller.d.ts +60 -0
- package/dist/conversation/controller.d.ts.map +1 -1
- package/dist/conversation/controller.js +104 -3
- package/dist/conversation/controller.js.map +1 -1
- package/dist/conversation/index.d.ts +2 -0
- package/dist/conversation/index.d.ts.map +1 -1
- package/dist/conversation/index.js +2 -0
- package/dist/conversation/index.js.map +1 -1
- package/dist/conversation/participant.d.ts +16 -0
- package/dist/conversation/participant.d.ts.map +1 -1
- package/dist/conversation/readSequencer.d.ts +38 -0
- package/dist/conversation/readSequencer.d.ts.map +1 -0
- package/dist/conversation/readSequencer.js +42 -0
- package/dist/conversation/readSequencer.js.map +1 -0
- package/dist/conversation/roster.d.ts +5 -1
- package/dist/conversation/roster.d.ts.map +1 -1
- package/dist/conversation/roster.js.map +1 -1
- package/dist/conversation/rosterProjection.d.ts +74 -1
- package/dist/conversation/rosterProjection.d.ts.map +1 -1
- package/dist/conversation/rosterProjection.js +135 -1
- package/dist/conversation/rosterProjection.js.map +1 -1
- package/dist/conversation/runtime.d.ts +20 -3
- package/dist/conversation/runtime.d.ts.map +1 -1
- package/dist/conversation/runtime.js +66 -7
- package/dist/conversation/runtime.js.map +1 -1
- package/dist/conversation/types.d.ts +43 -4
- package/dist/conversation/types.d.ts.map +1 -1
- package/dist/conversation/voice.d.ts +290 -13
- package/dist/conversation/voice.d.ts.map +1 -1
- package/dist/conversation/voice.js +565 -42
- package/dist/conversation/voice.js.map +1 -1
- package/dist/creatorCuration.d.ts +134 -0
- package/dist/creatorCuration.d.ts.map +1 -0
- package/dist/creatorCuration.js +228 -0
- package/dist/creatorCuration.js.map +1 -0
- package/dist/creatorDashboard.d.ts +155 -0
- package/dist/creatorDashboard.d.ts.map +1 -0
- package/dist/creatorDashboard.js +237 -0
- package/dist/creatorDashboard.js.map +1 -0
- package/dist/creatorUniverse.d.ts +95 -0
- package/dist/creatorUniverse.d.ts.map +1 -0
- package/dist/creatorUniverse.js +136 -0
- package/dist/creatorUniverse.js.map +1 -0
- package/dist/curationWrite.d.ts +76 -0
- package/dist/curationWrite.d.ts.map +1 -0
- package/dist/curationWrite.js +106 -0
- package/dist/curationWrite.js.map +1 -0
- package/dist/designTokens.d.ts +64 -0
- package/dist/designTokens.d.ts.map +1 -0
- package/dist/designTokens.js +117 -0
- package/dist/designTokens.js.map +1 -0
- package/dist/dialogAttribution.d.ts +79 -0
- package/dist/dialogAttribution.d.ts.map +1 -0
- package/dist/dialogAttribution.js +144 -0
- package/dist/dialogAttribution.js.map +1 -0
- package/dist/dmRunWorldReadiness.d.ts +605 -0
- package/dist/dmRunWorldReadiness.d.ts.map +1 -0
- package/dist/dmRunWorldReadiness.js +775 -0
- package/dist/dmRunWorldReadiness.js.map +1 -0
- package/dist/domains/access.d.ts +32 -0
- package/dist/domains/access.d.ts.map +1 -0
- package/dist/domains/access.js +43 -0
- package/dist/domains/access.js.map +1 -0
- package/dist/domains/adventureDefinitions.d.ts +159 -0
- package/dist/domains/adventureDefinitions.d.ts.map +1 -0
- package/dist/domains/adventureDefinitions.js +168 -0
- package/dist/domains/adventureDefinitions.js.map +1 -0
- package/dist/domains/adventures.d.ts +329 -0
- package/dist/domains/adventures.d.ts.map +1 -0
- package/dist/domains/adventures.js +359 -0
- package/dist/domains/adventures.js.map +1 -0
- package/dist/domains/arcs.d.ts +146 -0
- package/dist/domains/arcs.d.ts.map +1 -0
- package/dist/domains/arcs.js +202 -0
- package/dist/domains/arcs.js.map +1 -0
- package/dist/domains/artifacts.d.ts +259 -0
- package/dist/domains/artifacts.d.ts.map +1 -0
- package/dist/domains/artifacts.js +125 -0
- package/dist/domains/artifacts.js.map +1 -0
- package/dist/domains/chat.d.ts +158 -0
- package/dist/domains/chat.d.ts.map +1 -0
- package/dist/domains/chat.js +224 -0
- package/dist/domains/chat.js.map +1 -0
- package/dist/domains/decisions.d.ts +31 -0
- package/dist/domains/decisions.d.ts.map +1 -0
- package/dist/domains/decisions.js +42 -0
- package/dist/domains/decisions.js.map +1 -0
- package/dist/domains/documents.d.ts +218 -0
- package/dist/domains/documents.d.ts.map +1 -0
- package/dist/domains/documents.js +252 -0
- package/dist/domains/documents.js.map +1 -0
- package/dist/domains/enhancements.d.ts +106 -0
- package/dist/domains/enhancements.d.ts.map +1 -0
- package/dist/domains/enhancements.js +160 -0
- package/dist/domains/enhancements.js.map +1 -0
- package/dist/domains/graph.d.ts +454 -0
- package/dist/domains/graph.d.ts.map +1 -0
- package/dist/domains/graph.js +648 -0
- package/dist/domains/graph.js.map +1 -0
- package/dist/domains/images.d.ts +220 -0
- package/dist/domains/images.d.ts.map +1 -0
- package/dist/domains/images.js +307 -0
- package/dist/domains/images.js.map +1 -0
- package/dist/domains/ingestion.d.ts +312 -0
- package/dist/domains/ingestion.d.ts.map +1 -0
- package/dist/domains/ingestion.js +495 -0
- package/dist/domains/ingestion.js.map +1 -0
- package/dist/domains/me.d.ts +21 -0
- package/dist/domains/me.d.ts.map +1 -0
- package/dist/domains/me.js +23 -0
- package/dist/domains/me.js.map +1 -0
- package/dist/domains/orgs.d.ts +47 -0
- package/dist/domains/orgs.d.ts.map +1 -0
- package/dist/domains/orgs.js +75 -0
- package/dist/domains/orgs.js.map +1 -0
- package/dist/domains/personas.d.ts +135 -0
- package/dist/domains/personas.d.ts.map +1 -0
- package/dist/domains/personas.js +316 -0
- package/dist/domains/personas.js.map +1 -0
- package/dist/domains/projects.d.ts +53 -0
- package/dist/domains/projects.d.ts.map +1 -0
- package/dist/domains/projects.js +94 -0
- package/dist/domains/projects.js.map +1 -0
- package/dist/domains/quests.d.ts +431 -0
- package/dist/domains/quests.d.ts.map +1 -0
- package/dist/domains/quests.js +61 -0
- package/dist/domains/quests.js.map +1 -0
- package/dist/domains/reactor.d.ts +98 -0
- package/dist/domains/reactor.d.ts.map +1 -0
- package/dist/domains/reactor.js +131 -0
- package/dist/domains/reactor.js.map +1 -0
- package/dist/domains/showcase.d.ts +28 -0
- package/dist/domains/showcase.d.ts.map +1 -0
- package/dist/domains/showcase.js +28 -0
- package/dist/domains/showcase.js.map +1 -0
- package/dist/domains/storyboards.d.ts +1253 -0
- package/dist/domains/storyboards.d.ts.map +1 -0
- package/dist/domains/storyboards.js +781 -0
- package/dist/domains/storyboards.js.map +1 -0
- package/dist/domains/studioSettings.d.ts +39 -0
- package/dist/domains/studioSettings.d.ts.map +1 -0
- package/dist/domains/studioSettings.js +80 -0
- package/dist/domains/studioSettings.js.map +1 -0
- package/dist/domains/universes.d.ts +191 -0
- package/dist/domains/universes.d.ts.map +1 -0
- package/dist/domains/universes.js +276 -0
- package/dist/domains/universes.js.map +1 -0
- package/dist/domains/userDefaults.d.ts +18 -0
- package/dist/domains/userDefaults.d.ts.map +1 -0
- package/dist/domains/userDefaults.js +27 -0
- package/dist/domains/userDefaults.js.map +1 -0
- package/dist/domains/visemeBundles.d.ts +262 -0
- package/dist/domains/visemeBundles.d.ts.map +1 -0
- package/dist/domains/visemeBundles.js +373 -0
- package/dist/domains/visemeBundles.js.map +1 -0
- package/dist/domains/workflows.d.ts +142 -0
- package/dist/domains/workflows.d.ts.map +1 -0
- package/dist/domains/workflows.js +245 -0
- package/dist/domains/workflows.js.map +1 -0
- package/dist/enhancementDiff.d.ts +56 -0
- package/dist/enhancementDiff.d.ts.map +1 -0
- package/dist/enhancementDiff.js +110 -0
- package/dist/enhancementDiff.js.map +1 -0
- package/dist/generated/contract.d.ts +372 -0
- package/dist/generated/contract.d.ts.map +1 -0
- package/dist/generated/contract.js +390 -0
- package/dist/generated/contract.js.map +1 -0
- package/dist/graphSchema.d.ts +36 -5
- package/dist/graphSchema.d.ts.map +1 -1
- package/dist/graphSchema.js +88 -2
- package/dist/graphSchema.js.map +1 -1
- package/dist/http.d.ts +70 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +263 -11
- package/dist/http.js.map +1 -1
- package/dist/identity.d.ts +81 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +65 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +118 -0
- package/dist/index.js.map +1 -1
- package/dist/messageContent.d.ts +174 -0
- package/dist/messageContent.d.ts.map +1 -0
- package/dist/messageContent.js +405 -0
- package/dist/messageContent.js.map +1 -0
- package/dist/mutationEpoch.d.ts +83 -0
- package/dist/mutationEpoch.d.ts.map +1 -0
- package/dist/mutationEpoch.js +109 -0
- package/dist/mutationEpoch.js.map +1 -0
- package/dist/obo.d.ts +144 -0
- package/dist/obo.d.ts.map +1 -0
- package/dist/obo.js +135 -0
- package/dist/obo.js.map +1 -0
- package/dist/opusTransport.d.ts +113 -0
- package/dist/opusTransport.d.ts.map +1 -0
- package/dist/opusTransport.js +170 -0
- package/dist/opusTransport.js.map +1 -0
- package/dist/pagination.d.ts +18 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +26 -0
- package/dist/pagination.js.map +1 -0
- package/dist/platformAssistant.d.ts +55 -1
- package/dist/platformAssistant.d.ts.map +1 -1
- package/dist/platformAssistant.js +39 -1
- package/dist/platformAssistant.js.map +1 -1
- package/dist/pollUtils.d.ts +19 -0
- package/dist/pollUtils.d.ts.map +1 -0
- package/dist/pollUtils.js +35 -0
- package/dist/pollUtils.js.map +1 -0
- package/dist/questLog.d.ts +232 -0
- package/dist/questLog.d.ts.map +1 -0
- package/dist/questLog.js +522 -0
- package/dist/questLog.js.map +1 -0
- package/dist/reactor/dmDirectiveToExperience.d.ts +300 -0
- package/dist/reactor/dmDirectiveToExperience.d.ts.map +1 -0
- package/dist/reactor/dmDirectiveToExperience.js +401 -0
- package/dist/reactor/dmDirectiveToExperience.js.map +1 -0
- package/dist/reactor/dmSceneControlPrompt.d.ts +40 -0
- package/dist/reactor/dmSceneControlPrompt.d.ts.map +1 -0
- package/dist/reactor/dmSceneControlPrompt.js +145 -0
- package/dist/reactor/dmSceneControlPrompt.js.map +1 -0
- package/dist/reactor/dmWorldEntry.d.ts +1278 -0
- package/dist/reactor/dmWorldEntry.d.ts.map +1 -0
- package/dist/reactor/dmWorldEntry.js +1396 -0
- package/dist/reactor/dmWorldEntry.js.map +1 -0
- package/dist/reactor/framePromptCompaction.d.ts +223 -0
- package/dist/reactor/framePromptCompaction.d.ts.map +1 -0
- package/dist/reactor/framePromptCompaction.js +393 -0
- package/dist/reactor/framePromptCompaction.js.map +1 -0
- package/dist/reactor/frameWorldBind.d.ts +86 -0
- package/dist/reactor/frameWorldBind.d.ts.map +1 -0
- package/dist/reactor/frameWorldBind.js +79 -0
- package/dist/reactor/frameWorldBind.js.map +1 -0
- package/dist/reactor/happyOysterSeed.d.ts +166 -0
- package/dist/reactor/happyOysterSeed.d.ts.map +1 -0
- package/dist/reactor/happyOysterSeed.js +233 -0
- package/dist/reactor/happyOysterSeed.js.map +1 -0
- package/dist/reactor/happyOysterWalk.d.ts +274 -0
- package/dist/reactor/happyOysterWalk.d.ts.map +1 -0
- package/dist/reactor/happyOysterWalk.js +407 -0
- package/dist/reactor/happyOysterWalk.js.map +1 -0
- package/dist/reactor/happyOysterWorld.d.ts +718 -0
- package/dist/reactor/happyOysterWorld.d.ts.map +1 -0
- package/dist/reactor/happyOysterWorld.js +826 -0
- package/dist/reactor/happyOysterWorld.js.map +1 -0
- package/dist/reactor/heliosCommandDispatcher.d.ts.map +1 -1
- package/dist/reactor/heliosCommandDispatcher.js +5 -2
- package/dist/reactor/heliosCommandDispatcher.js.map +1 -1
- package/dist/reactor/hiddenWorldLifecycle.d.ts +101 -0
- package/dist/reactor/hiddenWorldLifecycle.d.ts.map +1 -0
- package/dist/reactor/hiddenWorldLifecycle.js +119 -0
- package/dist/reactor/hiddenWorldLifecycle.js.map +1 -0
- package/dist/reactor/imageCanvas.d.ts +15 -0
- package/dist/reactor/imageCanvas.d.ts.map +1 -0
- package/dist/reactor/imageCanvas.js +33 -0
- package/dist/reactor/imageCanvas.js.map +1 -0
- package/dist/reactor/index.d.ts +20 -0
- package/dist/reactor/index.d.ts.map +1 -1
- package/dist/reactor/index.js +81 -0
- package/dist/reactor/index.js.map +1 -1
- package/dist/reactor/longLiveCommandDispatcher.d.ts +23 -8
- package/dist/reactor/longLiveCommandDispatcher.d.ts.map +1 -1
- package/dist/reactor/longLiveCommandDispatcher.js +16 -4
- package/dist/reactor/longLiveCommandDispatcher.js.map +1 -1
- package/dist/reactor/longLiveSceneEntry.d.ts +203 -0
- package/dist/reactor/longLiveSceneEntry.d.ts.map +1 -0
- package/dist/reactor/longLiveSceneEntry.js +280 -0
- package/dist/reactor/longLiveSceneEntry.js.map +1 -0
- package/dist/reactor/momentCut.d.ts +153 -0
- package/dist/reactor/momentCut.d.ts.map +1 -0
- package/dist/reactor/momentCut.js +142 -0
- package/dist/reactor/momentCut.js.map +1 -0
- package/dist/reactor/promptAddonRegistry.d.ts +39 -3
- package/dist/reactor/promptAddonRegistry.d.ts.map +1 -1
- package/dist/reactor/promptAddonRegistry.js +44 -5
- package/dist/reactor/promptAddonRegistry.js.map +1 -1
- package/dist/reactor/promptTemplatePreview.d.ts +97 -0
- package/dist/reactor/promptTemplatePreview.d.ts.map +1 -0
- package/dist/reactor/promptTemplatePreview.js +185 -0
- package/dist/reactor/promptTemplatePreview.js.map +1 -0
- package/dist/reactor/reactorAvailability.d.ts +80 -0
- package/dist/reactor/reactorAvailability.d.ts.map +1 -0
- package/dist/reactor/reactorAvailability.js +121 -0
- package/dist/reactor/reactorAvailability.js.map +1 -0
- package/dist/reactor/reactorSessionRefusal.d.ts +125 -0
- package/dist/reactor/reactorSessionRefusal.d.ts.map +1 -0
- package/dist/reactor/reactorSessionRefusal.js +197 -0
- package/dist/reactor/reactorSessionRefusal.js.map +1 -0
- package/dist/reactor/reactorTokenScope.d.ts +47 -0
- package/dist/reactor/reactorTokenScope.d.ts.map +1 -0
- package/dist/reactor/reactorTokenScope.js +64 -0
- package/dist/reactor/reactorTokenScope.js.map +1 -0
- package/dist/reactor/resolveDirectorBeats.d.ts +65 -0
- package/dist/reactor/resolveDirectorBeats.d.ts.map +1 -0
- package/dist/reactor/resolveDirectorBeats.js +86 -0
- package/dist/reactor/resolveDirectorBeats.js.map +1 -0
- package/dist/reactor/sanaLiveEdit.d.ts +117 -0
- package/dist/reactor/sanaLiveEdit.d.ts.map +1 -0
- package/dist/reactor/sanaLiveEdit.js +105 -0
- package/dist/reactor/sanaLiveEdit.js.map +1 -0
- package/dist/reactor/sceneEntry.d.ts +66 -9
- package/dist/reactor/sceneEntry.d.ts.map +1 -1
- package/dist/reactor/sceneEntry.js +59 -66
- package/dist/reactor/sceneEntry.js.map +1 -1
- package/dist/reactor/sceneSeedImage.d.ts +199 -0
- package/dist/reactor/sceneSeedImage.d.ts.map +1 -0
- package/dist/reactor/sceneSeedImage.js +239 -0
- package/dist/reactor/sceneSeedImage.js.map +1 -0
- package/dist/reactor/seedImageOrchestrator.d.ts +70 -3
- package/dist/reactor/seedImageOrchestrator.d.ts.map +1 -1
- package/dist/reactor/seedImageOrchestrator.js +92 -28
- package/dist/reactor/seedImageOrchestrator.js.map +1 -1
- package/dist/reactor/toolPromptAddon.d.ts +37 -28
- package/dist/reactor/toolPromptAddon.d.ts.map +1 -1
- package/dist/reactor/toolPromptAddon.js +63 -101
- package/dist/reactor/toolPromptAddon.js.map +1 -1
- package/dist/reactor/worldMintLoop.d.ts +286 -0
- package/dist/reactor/worldMintLoop.d.ts.map +1 -0
- package/dist/reactor/worldMintLoop.js +381 -0
- package/dist/reactor/worldMintLoop.js.map +1 -0
- package/dist/reactor/worldSteerOutcome.d.ts +98 -0
- package/dist/reactor/worldSteerOutcome.d.ts.map +1 -0
- package/dist/reactor/worldSteerOutcome.js +81 -0
- package/dist/reactor/worldSteerOutcome.js.map +1 -0
- package/dist/retryAfter.d.ts +15 -0
- package/dist/retryAfter.d.ts.map +1 -0
- package/dist/retryAfter.js +75 -0
- package/dist/retryAfter.js.map +1 -0
- package/dist/seriesKey.d.ts +31 -0
- package/dist/seriesKey.d.ts.map +1 -0
- package/dist/seriesKey.js +33 -0
- package/dist/seriesKey.js.map +1 -0
- package/dist/sessionRefresh.d.ts +135 -0
- package/dist/sessionRefresh.d.ts.map +1 -0
- package/dist/sessionRefresh.js +215 -0
- package/dist/sessionRefresh.js.map +1 -0
- package/dist/sharedAudioContext.d.ts +39 -0
- package/dist/sharedAudioContext.d.ts.map +1 -0
- package/dist/sharedAudioContext.js +63 -0
- package/dist/sharedAudioContext.js.map +1 -0
- package/dist/singleFlight.d.ts +51 -0
- package/dist/singleFlight.d.ts.map +1 -0
- package/dist/singleFlight.js +87 -0
- package/dist/singleFlight.js.map +1 -0
- package/dist/storyGraph.d.ts +83 -0
- package/dist/storyGraph.d.ts.map +1 -1
- package/dist/storyGraph.js +169 -4
- package/dist/storyGraph.js.map +1 -1
- package/dist/storyboardMask.d.ts +343 -0
- package/dist/storyboardMask.d.ts.map +1 -0
- package/dist/storyboardMask.js +505 -0
- package/dist/storyboardMask.js.map +1 -0
- package/dist/storyboardTimeline.d.ts +93 -0
- package/dist/storyboardTimeline.d.ts.map +1 -0
- package/dist/storyboardTimeline.js +131 -0
- package/dist/storyboardTimeline.js.map +1 -0
- package/dist/studioAutomation.d.ts +104 -0
- package/dist/studioAutomation.d.ts.map +1 -0
- package/dist/studioAutomation.js +178 -0
- package/dist/studioAutomation.js.map +1 -0
- package/dist/tenantClaim.d.ts +86 -0
- package/dist/tenantClaim.d.ts.map +1 -0
- package/dist/tenantClaim.js +164 -0
- package/dist/tenantClaim.js.map +1 -0
- package/dist/timeFormat.d.ts +25 -0
- package/dist/timeFormat.d.ts.map +1 -1
- package/dist/timeFormat.js +56 -0
- package/dist/timeFormat.js.map +1 -1
- package/dist/toolSchemas.d.ts +53 -10
- package/dist/toolSchemas.d.ts.map +1 -1
- package/dist/toolSchemas.js +36 -9
- package/dist/toolSchemas.js.map +1 -1
- package/dist/transport.d.ts +120 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +282 -0
- package/dist/transport.js.map +1 -0
- package/dist/videoGenFacade.d.ts +63 -0
- package/dist/videoGenFacade.d.ts.map +1 -0
- package/dist/videoGenFacade.js +49 -0
- package/dist/videoGenFacade.js.map +1 -0
- package/dist/visemeScheduler.d.ts +24 -2
- package/dist/visemeScheduler.d.ts.map +1 -1
- package/dist/visemeScheduler.js +31 -2
- package/dist/visemeScheduler.js.map +1 -1
- package/dist/vision/VisionPublisher.d.ts +88 -0
- package/dist/vision/VisionPublisher.d.ts.map +1 -1
- package/dist/vision/VisionPublisher.js +196 -13
- package/dist/vision/VisionPublisher.js.map +1 -1
- package/dist/vision/VisionSourceController.d.ts +67 -1
- package/dist/vision/VisionSourceController.d.ts.map +1 -1
- package/dist/vision/VisionSourceController.js +147 -5
- package/dist/vision/VisionSourceController.js.map +1 -1
- package/dist/vision/index.d.ts +2 -1
- package/dist/vision/index.d.ts.map +1 -1
- package/dist/vision/index.js +2 -1
- package/dist/vision/index.js.map +1 -1
- package/dist/vision/sourceKinds.d.ts +18 -5
- package/dist/vision/sourceKinds.d.ts.map +1 -1
- package/dist/vision/sourceKinds.js +15 -2
- package/dist/vision/sourceKinds.js.map +1 -1
- package/dist/vision/types.d.ts +7 -4
- package/dist/vision/types.d.ts.map +1 -1
- package/dist/vision/visionErrors.d.ts +45 -0
- package/dist/vision/visionErrors.d.ts.map +1 -0
- package/dist/vision/visionErrors.js +66 -0
- package/dist/vision/visionErrors.js.map +1 -0
- package/dist/voiceCloneCaption.d.ts +33 -0
- package/dist/voiceCloneCaption.d.ts.map +1 -0
- package/dist/voiceCloneCaption.js +69 -0
- package/dist/voiceCloneCaption.js.map +1 -0
- package/dist/websocket.d.ts +390 -10
- package/dist/websocket.d.ts.map +1 -1
- package/dist/websocket.js +152 -0
- package/dist/websocket.js.map +1 -1
- package/dist/workflowAuthoring.d.ts +139 -0
- package/dist/workflowAuthoring.d.ts.map +1 -0
- package/dist/workflowAuthoring.js +557 -0
- package/dist/workflowAuthoring.js.map +1 -0
- package/package.json +15 -5
- package/src/__tests__/adapters-director.test.ts +9 -6
- package/src/__tests__/adapters-extraction.test.ts +175 -0
- package/src/__tests__/adapters-image.test.ts +66 -0
- package/src/__tests__/adapters-momentPolicy.test.ts +218 -0
- package/src/__tests__/adapters-platform.test.ts +110 -4
- package/src/__tests__/adapters-videogen.test.ts +53 -0
- package/src/__tests__/adapters-world.test.ts +117 -7
- package/src/__tests__/admin.enhancement-defaults.test.ts +115 -0
- package/src/__tests__/admin.test.ts +282 -0
- package/src/__tests__/adventures-world-state.test.ts +156 -0
- package/src/__tests__/adventures.test.ts +111 -1
- package/src/__tests__/api-pollers.test.ts +113 -23
- package/src/__tests__/api.adventure-definitions.test.ts +312 -0
- package/src/__tests__/api.anchor-beat.test.ts +75 -0
- package/src/__tests__/api.arc-approval.test.ts +171 -0
- package/src/__tests__/api.arc-beats-floor.test.ts +56 -0
- package/src/__tests__/api.arc-generation.test.ts +168 -0
- package/src/__tests__/api.arc-templates.test.ts +78 -0
- package/src/__tests__/api.assignVideoSeries.test.ts +81 -0
- package/src/__tests__/api.cast-frame-choices.test.ts +141 -0
- package/src/__tests__/api.cutscene-registry.test.ts +148 -0
- package/src/__tests__/api.enhancement-addition-actions.test.ts +137 -0
- package/src/__tests__/api.enrichVideo-serialization.test.ts +116 -0
- package/src/__tests__/api.extraction-base.test.ts +87 -0
- package/src/__tests__/api.generateVideo-cutscene.test.ts +148 -0
- package/src/__tests__/api.job-pipeline-stages.test.ts +128 -0
- package/src/__tests__/api.list-images-filters.test.ts +6 -3
- package/src/__tests__/api.quest-curation.test.ts +169 -0
- package/src/__tests__/api.reprocessVideo.test.ts +71 -0
- package/src/__tests__/api.scene-split-merge.test.ts +129 -0
- package/src/__tests__/api.session-quests.test.ts +184 -0
- package/src/__tests__/api.test.ts +122 -0
- package/src/__tests__/api.transferSeries.test.ts +114 -0
- package/src/__tests__/api.unknown-clusters.test.ts +225 -0
- package/src/__tests__/api.uploadVideo-options.test.ts +156 -0
- package/src/__tests__/arcPreview.test.ts +71 -0
- package/src/__tests__/arcStyleProfile.test.ts +204 -0
- package/src/__tests__/artifacts-delete.test.ts +109 -0
- package/src/__tests__/audio.test.ts +864 -5
- package/src/__tests__/audioDsp.test.ts +196 -0
- package/src/__tests__/audioUnavailable.test.ts +43 -0
- package/src/__tests__/cast.test.ts +10 -1
- package/src/__tests__/castCurationProjection.test.ts +84 -0
- package/src/__tests__/castFramePipelinePending.test.ts +171 -0
- package/src/__tests__/castProjection.test.ts +497 -5
- package/src/__tests__/characterGrounding.test.ts +357 -0
- package/src/__tests__/contract.test.ts +97 -0
- package/src/__tests__/conversation/binding.test.ts +53 -0
- package/src/__tests__/conversation/chatSessionStore.test.ts +243 -0
- package/src/__tests__/conversation/controller.test.ts +328 -0
- package/src/__tests__/conversation/readSequencer.test.ts +52 -0
- package/src/__tests__/conversation/rosterProjection.test.ts +204 -3
- package/src/__tests__/conversation/runtime.test.ts +118 -1
- package/src/__tests__/conversation/voice.test.ts +741 -7
- package/src/__tests__/creatorCuration.test.ts +256 -0
- package/src/__tests__/creatorDashboard.test.ts +444 -0
- package/src/__tests__/creatorUniverse.test.ts +138 -0
- package/src/__tests__/curationWrite.test.ts +179 -0
- package/src/__tests__/decisions.test.ts +89 -0
- package/src/__tests__/designTokens.test.ts +72 -0
- package/src/__tests__/dialogAttribution.test.ts +187 -0
- package/src/__tests__/dmDirectiveToExperience.test.ts +198 -0
- package/src/__tests__/dmWorldEntry.test.ts +2102 -0
- package/src/__tests__/enhancementDiff.test.ts +132 -0
- package/src/__tests__/experienceModelCatalog.test.ts +292 -0
- package/src/__tests__/extractionStageState.test.ts +67 -0
- package/src/__tests__/getVideo.test.ts +95 -0
- package/src/__tests__/graphReadAfterWrite.test.ts +211 -0
- package/src/__tests__/graphSchema.test.ts +55 -4
- package/src/__tests__/happyOysterSeed.test.ts +208 -0
- package/src/__tests__/happyOysterWorld.test.ts +1241 -0
- package/src/__tests__/happyOysterWorldRefusal.test.ts +224 -0
- package/src/__tests__/hiddenWorldLifecycle.test.ts +203 -0
- package/src/__tests__/http.session-refresh.test.ts +424 -0
- package/src/__tests__/http.test.ts +316 -0
- package/src/__tests__/identity.test.ts +132 -0
- package/src/__tests__/loadBundleManifest.test.ts +192 -22
- package/src/__tests__/longLiveSceneEntry.test.ts +371 -0
- package/src/__tests__/me.test.ts +74 -0
- package/src/__tests__/messageContent.test.ts +395 -0
- package/src/__tests__/momentCut.test.ts +229 -0
- package/src/__tests__/mutationEpoch.test.ts +218 -0
- package/src/__tests__/obo.test.ts +159 -0
- package/src/__tests__/opusTransport.test.ts +182 -0
- package/src/__tests__/opusTransportLibopus.test.ts +125 -0
- package/src/__tests__/orgs.test.ts +229 -0
- package/src/__tests__/persona-generation.test.ts +187 -1
- package/src/__tests__/platformAssistant.test.ts +140 -0
- package/src/__tests__/projects.test.ts +338 -0
- package/src/__tests__/promptTemplatePreview.test.ts +160 -0
- package/src/__tests__/reactor/__fixtures__/realFramePromptText.ts +23 -0
- package/src/__tests__/reactor/api-reactor.test.ts +60 -21
- package/src/__tests__/reactor/framePromptCompaction.test.ts +300 -0
- package/src/__tests__/reactor/promptAddonRegistry.test.ts +82 -1
- package/src/__tests__/reactor/reactorTokenScope.test.ts +50 -0
- package/src/__tests__/reactor/resolveDirectorBeats.test.ts +156 -0
- package/src/__tests__/reactor/sceneEntry.test.ts +3 -0
- package/src/__tests__/reactor/sceneSeedImage.test.ts +361 -0
- package/src/__tests__/reactor/seedImageOrchestrator.test.ts +43 -5
- package/src/__tests__/reactor/toolPromptAddon.test.ts +34 -42
- package/src/__tests__/reactor-happyOysterWalk.test.ts +294 -0
- package/src/__tests__/reactorAvailability.test.ts +217 -0
- package/src/__tests__/reactorSessionRefusal.test.ts +189 -0
- package/src/__tests__/regeneration.test.ts +9 -9
- package/src/__tests__/reprocessBlockedReason.test.ts +30 -0
- package/src/__tests__/retryAfter.test.ts +65 -0
- package/src/__tests__/roleClaim.test.ts +102 -0
- package/src/__tests__/sanaLiveEdit.test.ts +84 -0
- package/src/__tests__/seriesKey.test.ts +24 -0
- package/src/__tests__/settings-set9.test.ts +238 -0
- package/src/__tests__/singleFlight.test.ts +348 -0
- package/src/__tests__/storyGraph.test.ts +111 -1
- package/src/__tests__/storyboardFrameCutscene.test.ts +115 -0
- package/src/__tests__/storyboardMask.test.ts +527 -0
- package/src/__tests__/storyboardTimeline.test.ts +228 -0
- package/src/__tests__/storyboards.test.ts +639 -0
- package/src/__tests__/studioAutomation.test.ts +325 -0
- package/src/__tests__/toolSchemas.test.ts +11 -18
- package/src/__tests__/transport.test.ts +312 -0
- package/src/__tests__/videoGenFacade.test.ts +141 -0
- package/src/__tests__/videoGraph.test.ts +43 -1
- package/src/__tests__/visemeScheduler.test.ts +55 -1
- package/src/__tests__/visibility.test.ts +143 -0
- package/src/__tests__/voiceCloneCaption.test.ts +80 -0
- package/src/__tests__/voiceFallback.test.ts +55 -0
- package/src/__tests__/websocket-error-turn-ended.test.ts +49 -0
- package/src/__tests__/websocket-session-attach.test.ts +288 -0
- package/src/__tests__/websocket-vision.test.ts +141 -0
- package/src/__tests__/websocket.test.ts +75 -1
- package/src/__tests__/workflowAuthoring.test.ts +187 -0
- package/src/__tests__/workflows.test.ts +640 -0
- package/src/__tests__/worldMintLoop.test.ts +448 -0
- package/src/__tests__/worldModelPreference.test.ts +302 -0
- package/src/__tests__/worldModelTradeoffs.test.ts +89 -0
- package/src/__tests__/worldSteerOutcome.test.ts +62 -0
- package/src/adapters/capabilities.ts +39 -3
- package/src/adapters/directorAdapter.ts +5 -4
- package/src/adapters/experienceModelCatalog.ts +538 -0
- package/src/adapters/extractionAdapter.ts +150 -0
- package/src/adapters/imageAdapter.ts +5 -1
- package/src/adapters/index.ts +104 -17
- package/src/adapters/momentDirective.ts +109 -0
- package/src/adapters/momentPolicy.ts +209 -0
- package/src/adapters/registry.ts +1 -1
- package/src/adapters/videoGenAdapter.ts +124 -0
- package/src/adapters/worldAdapter.ts +221 -16
- package/src/adapters/worldModelPreference.ts +247 -0
- package/src/adapters/worldModelTradeoffs.ts +247 -0
- package/src/admin.ts +842 -16
- package/src/api.ts +12670 -3446
- package/src/arcBoardJoin.ts +46 -0
- package/src/arcPreview.ts +103 -0
- package/src/audio.ts +691 -130
- package/src/audioDsp.ts +132 -0
- package/src/audioProtocol.ts +235 -0
- package/src/beatTitles.ts +51 -0
- package/src/castProjection.ts +311 -0
- package/src/characterGrounding.ts +491 -0
- package/src/conversation/binding.ts +53 -1
- package/src/conversation/chatSessionStore.ts +281 -0
- package/src/conversation/controller.ts +135 -3
- package/src/conversation/index.ts +2 -0
- package/src/conversation/participant.ts +16 -0
- package/src/conversation/readSequencer.ts +55 -0
- package/src/conversation/roster.ts +5 -1
- package/src/conversation/rosterProjection.ts +166 -2
- package/src/conversation/runtime.ts +66 -7
- package/src/conversation/types.ts +43 -4
- package/src/conversation/voice.ts +655 -51
- package/src/creatorCuration.ts +316 -0
- package/src/creatorDashboard.ts +344 -0
- package/src/creatorUniverse.ts +222 -0
- package/src/curationWrite.ts +108 -0
- package/src/designTokens.ts +157 -0
- package/src/dialogAttribution.ts +182 -0
- package/src/dmRunWorldReadiness.ts +1168 -0
- package/src/domains/access.ts +92 -0
- package/src/domains/adventureDefinitions.ts +313 -0
- package/src/domains/adventures.ts +557 -0
- package/src/domains/arcs.ts +350 -0
- package/src/domains/artifacts.ts +349 -0
- package/src/domains/chat.ts +338 -0
- package/src/domains/decisions.ts +62 -0
- package/src/domains/documents.ts +389 -0
- package/src/domains/enhancements.ts +259 -0
- package/src/domains/graph.ts +959 -0
- package/src/domains/images.ts +451 -0
- package/src/domains/ingestion.ts +695 -0
- package/src/domains/me.ts +27 -0
- package/src/domains/orgs.ts +168 -0
- package/src/domains/personas.ts +433 -0
- package/src/domains/projects.ts +177 -0
- package/src/domains/quests.ts +587 -0
- package/src/domains/reactor.ts +163 -0
- package/src/domains/showcase.ts +35 -0
- package/src/domains/storyboards.ts +1698 -0
- package/src/domains/studioSettings.ts +149 -0
- package/src/domains/universes.ts +433 -0
- package/src/domains/userDefaults.ts +37 -0
- package/src/domains/visemeBundles.ts +541 -0
- package/src/domains/workflows.ts +376 -0
- package/src/enhancementDiff.ts +171 -0
- package/src/generated/contract.ts +1011 -0
- package/src/graphSchema.ts +154 -6
- package/src/http.ts +295 -11
- package/src/identity.ts +123 -0
- package/src/index.ts +131 -0
- package/src/messageContent.ts +500 -0
- package/src/mutationEpoch.ts +107 -0
- package/src/obo.ts +201 -0
- package/src/opusTransport.ts +268 -0
- package/src/pagination.ts +29 -0
- package/src/platformAssistant.ts +97 -1
- package/src/pollUtils.ts +35 -0
- package/src/questLog.ts +704 -0
- package/src/reactor/dmDirectiveToExperience.ts +636 -0
- package/src/reactor/dmSceneControlPrompt.ts +152 -0
- package/src/reactor/dmWorldEntry.ts +2226 -0
- package/src/reactor/framePromptCompaction.ts +544 -0
- package/src/reactor/frameWorldBind.ts +133 -0
- package/src/reactor/happyOysterSeed.ts +329 -0
- package/src/reactor/happyOysterWalk.ts +541 -0
- package/src/reactor/happyOysterWorld.ts +1270 -0
- package/src/reactor/heliosCommandDispatcher.ts +5 -1
- package/src/reactor/hiddenWorldLifecycle.ts +182 -0
- package/src/reactor/imageCanvas.ts +38 -0
- package/src/reactor/index.ts +81 -0
- package/src/reactor/longLiveCommandDispatcher.ts +23 -8
- package/src/reactor/longLiveSceneEntry.ts +409 -0
- package/src/reactor/momentCut.ts +219 -0
- package/src/reactor/promptAddonRegistry.ts +83 -5
- package/src/reactor/promptTemplatePreview.ts +240 -0
- package/src/reactor/reactorAvailability.ts +155 -0
- package/src/reactor/reactorSessionRefusal.ts +260 -0
- package/src/reactor/reactorTokenScope.ts +69 -0
- package/src/reactor/resolveDirectorBeats.ts +140 -0
- package/src/reactor/sanaLiveEdit.ts +158 -0
- package/src/reactor/sceneEntry.ts +106 -88
- package/src/reactor/sceneSeedImage.ts +338 -0
- package/src/reactor/seedImageOrchestrator.ts +116 -34
- package/src/reactor/toolPromptAddon.ts +66 -102
- package/src/reactor/worldMintLoop.ts +545 -0
- package/src/reactor/worldSteerOutcome.ts +132 -0
- package/src/retryAfter.ts +71 -0
- package/src/seriesKey.ts +42 -0
- package/src/sessionRefresh.ts +237 -0
- package/src/sharedAudioContext.ts +67 -0
- package/src/singleFlight.ts +91 -0
- package/src/storyGraph.ts +247 -4
- package/src/storyboardMask.ts +756 -0
- package/src/storyboardTimeline.ts +220 -0
- package/src/studioAutomation.ts +208 -0
- package/src/tenantClaim.ts +170 -0
- package/src/timeFormat.ts +51 -0
- package/src/toolSchemas.ts +39 -10
- package/src/transport.ts +327 -0
- package/src/videoGenFacade.ts +90 -0
- package/src/visemeScheduler.ts +36 -3
- package/src/vision/VisionPublisher.ts +204 -14
- package/src/vision/VisionSourceController.ts +187 -6
- package/src/vision/__tests__/VisionPublisher.kvs.test.ts +50 -0
- package/src/vision/__tests__/VisionPublisher.test.ts +291 -0
- package/src/vision/__tests__/VisionSourceController.test.ts +376 -6
- package/src/vision/index.ts +5 -1
- package/src/vision/sourceKinds.ts +19 -5
- package/src/vision/types.ts +7 -4
- package/src/vision/visionErrors.ts +70 -0
- package/src/voiceCloneCaption.ts +77 -0
- package/src/websocket.ts +542 -9
- package/src/workflowAuthoring.ts +664 -0
|
@@ -0,0 +1,2102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the DM world-entry path (§Q DM.1, client half).
|
|
3
|
+
*
|
|
4
|
+
* The load-bearing assertions are the billing-safety ones, because every
|
|
5
|
+
* failure they prevent lands AFTER a permanent, billed, unlistable world
|
|
6
|
+
* exists: `createWorld` fires only when the player opted into auto-fire AND the
|
|
7
|
+
* scene actually changed (a live world is steered, a frame that owns one is
|
|
8
|
+
* reopened), the seed is prepared BYTES and never a URL, and a world that got
|
|
9
|
+
* created despite a failed launch is still handed back for persistence.
|
|
10
|
+
*
|
|
11
|
+
* The LIVE model behaviour is deliberately NOT exercised here — a real
|
|
12
|
+
* `createWorld` is paid and permanent.
|
|
13
|
+
*/
|
|
14
|
+
import {
|
|
15
|
+
DM_WORLD_ATMOSPHERE_MIN_CHARS,
|
|
16
|
+
DM_WORLD_ATMOSPHERE_PREFIX,
|
|
17
|
+
DM_WORLD_BOARD_READ_FAILED_MESSAGE,
|
|
18
|
+
DM_WORLD_BOARD_READ_MAX_ATTEMPTS,
|
|
19
|
+
DM_WORLD_BOARD_READ_RETRY_DELAYS_MS,
|
|
20
|
+
DM_WORLD_BOARD_READ_STATUSES,
|
|
21
|
+
dmWorldBoardBlock,
|
|
22
|
+
dmWorldBoardReadIsRetryable,
|
|
23
|
+
dmWorldBoardReadRetryDelayMs,
|
|
24
|
+
dmWorldEntryBlockIsBoardRead,
|
|
25
|
+
dmWorldEntryBlockIsPending,
|
|
26
|
+
dmWorldEntryBlockIsRetryable,
|
|
27
|
+
isRetryableBoardReadStatus,
|
|
28
|
+
DM_WORLD_AUTO_FIRE_DEFAULT,
|
|
29
|
+
DM_WORLD_AUTO_STOP_MS_DEFAULT,
|
|
30
|
+
DM_WORLD_ENTRY_NO_BOARD_TITLE,
|
|
31
|
+
DM_WORLD_REENTER_ACTION,
|
|
32
|
+
DM_WORLD_REOPEN_NOTICE,
|
|
33
|
+
DM_WORLD_STREAM_DEAD_CONFIRM_MS,
|
|
34
|
+
DM_WORLD_STREAM_END_REASONS,
|
|
35
|
+
DM_WORLD_STREAM_ENDED_TITLE,
|
|
36
|
+
DM_WORLD_STREAM_SILENCE_MS,
|
|
37
|
+
dmWorldStreamEndIsImmediate,
|
|
38
|
+
DM_WORLD_STREAM_STALL_TITLE,
|
|
39
|
+
DM_WORLD_UNRECORDED_NOTICE,
|
|
40
|
+
dmWorldLaunchFailure,
|
|
41
|
+
dmWorldLaunchProgress,
|
|
42
|
+
dmWorldLaunchStage,
|
|
43
|
+
dmWorldReentryPlan,
|
|
44
|
+
dmWorldStreamEndedNotice,
|
|
45
|
+
dmWorldStreamEndReason,
|
|
46
|
+
HAPPY_OYSTER_PHASE_STREAMING,
|
|
47
|
+
HAPPY_OYSTER_PROMPT_MAX_CHARS,
|
|
48
|
+
HappyOysterLaunchError,
|
|
49
|
+
collectDmWorldRecords,
|
|
50
|
+
composeDmWorldPrompt,
|
|
51
|
+
happyOysterPromptIssue,
|
|
52
|
+
dmWorldAtmosphereReservation,
|
|
53
|
+
dmWorldEntryBlock,
|
|
54
|
+
dmWorldEntryBlockTitle,
|
|
55
|
+
dmWorldEntryWouldCreateWorld,
|
|
56
|
+
dmWorldReopenNotice,
|
|
57
|
+
launchDmWorldEntry,
|
|
58
|
+
planDmWorldEntry,
|
|
59
|
+
rememberDmWorldEntry,
|
|
60
|
+
resolveDmWorldEntryFrame,
|
|
61
|
+
summarizeDmWorldPreparation,
|
|
62
|
+
// §Q WORLD.1-A — the shared reopen guard and the two host constants both
|
|
63
|
+
// player surfaces now read.
|
|
64
|
+
dmWorldReopenDecision,
|
|
65
|
+
DM_WORLD_MODE,
|
|
66
|
+
DM_WORLD_NOT_CHOSEN_MESSAGE,
|
|
67
|
+
DM_WORLD_REOPEN_UNRESOLVED_MESSAGE,
|
|
68
|
+
// §Q DM.67 — the route out of a content-refused beat.
|
|
69
|
+
DM_WORLD_CONTENT_REFUSAL_NO_ROUTE,
|
|
70
|
+
DM_WORLD_CONTENT_REFUSAL_ROUTES_LEAD,
|
|
71
|
+
DM_WORLD_REFUSAL_ROUTE_BUILD_HINT,
|
|
72
|
+
DM_WORLD_REFUSAL_ROUTE_REOPEN_HINT,
|
|
73
|
+
dmWorldContentRefusalRoutes,
|
|
74
|
+
dmWorldLaunchIsContentRefusal,
|
|
75
|
+
type DmWorldRecord,
|
|
76
|
+
type DmWorldEntryPlan,
|
|
77
|
+
type HappyOysterBridge,
|
|
78
|
+
type HappyOysterWorldSnapshot,
|
|
79
|
+
type DmWorldSessionEntry,
|
|
80
|
+
type PreparedHappyOysterSeed,
|
|
81
|
+
type StoryboardFrame,
|
|
82
|
+
} from '../index';
|
|
83
|
+
import { REAL_FRAME_PROMPT_TEXT } from './reactor/__fixtures__/realFramePromptText';
|
|
84
|
+
|
|
85
|
+
const READY: HappyOysterWorldSnapshot = {
|
|
86
|
+
phase: 'ready',
|
|
87
|
+
encrypted_world_id: 'ew-dm-1',
|
|
88
|
+
first_frame: null,
|
|
89
|
+
prompt: null,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
function frame(overrides: Partial<StoryboardFrame> = {}): StoryboardFrame {
|
|
93
|
+
return {
|
|
94
|
+
storyboardId: 'sb-1',
|
|
95
|
+
frameId: 'f-1',
|
|
96
|
+
beatId: 'beat-2',
|
|
97
|
+
shotTransition: 'hard_cut',
|
|
98
|
+
durationSeconds: 6,
|
|
99
|
+
prompt: {
|
|
100
|
+
sceneDescription: 'ignored — the compiled variant text is the authority',
|
|
101
|
+
charactersInWords: [],
|
|
102
|
+
action: '',
|
|
103
|
+
cameraProse: '',
|
|
104
|
+
styleTags: [],
|
|
105
|
+
dialogLines: [],
|
|
106
|
+
},
|
|
107
|
+
characterRefs: [],
|
|
108
|
+
settingRefs: [],
|
|
109
|
+
variants: [
|
|
110
|
+
{
|
|
111
|
+
variantId: 'v-1',
|
|
112
|
+
status: 'succeeded',
|
|
113
|
+
origin: 'generate',
|
|
114
|
+
createdAt: '2026-07-28T00:00:00Z',
|
|
115
|
+
promptText: 'A drowned cathedral lit by green fire',
|
|
116
|
+
imageUrl: 'https://s3.example/frames/f-1.png?X-Amz-Signature=abc',
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
extensions: { multiViewAzimuths: [], lift3D: false },
|
|
120
|
+
audioEnabled: false,
|
|
121
|
+
createdAt: '2026-07-28T00:00:00Z',
|
|
122
|
+
status: 'succeeded',
|
|
123
|
+
...overrides,
|
|
124
|
+
} as StoryboardFrame;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const SEED: PreparedHappyOysterSeed = {
|
|
128
|
+
blob: { size: 1234, type: 'image/jpeg' } as Blob,
|
|
129
|
+
plan: {
|
|
130
|
+
source: { width: 1664, height: 936 },
|
|
131
|
+
crop: { x: 0, y: 0, width: 1664, height: 936 },
|
|
132
|
+
output: { width: 1664, height: 936 },
|
|
133
|
+
aspectRatio: 1664 / 936,
|
|
134
|
+
cropped: false,
|
|
135
|
+
scaled: false,
|
|
136
|
+
},
|
|
137
|
+
quality: 0.92,
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
function stubBridge(
|
|
141
|
+
overrides: Partial<HappyOysterBridge> = {},
|
|
142
|
+
): HappyOysterBridge & { calls: string[] } {
|
|
143
|
+
const calls: string[] = [];
|
|
144
|
+
return {
|
|
145
|
+
calls,
|
|
146
|
+
connect: async () => {
|
|
147
|
+
calls.push('connect');
|
|
148
|
+
},
|
|
149
|
+
createWorld: async () => {
|
|
150
|
+
calls.push('createWorld');
|
|
151
|
+
return READY;
|
|
152
|
+
},
|
|
153
|
+
attachWorld: async () => {
|
|
154
|
+
calls.push('attachWorld');
|
|
155
|
+
return READY;
|
|
156
|
+
},
|
|
157
|
+
startTravel: async () => {
|
|
158
|
+
calls.push('startTravel');
|
|
159
|
+
return { streaming: true };
|
|
160
|
+
},
|
|
161
|
+
...overrides,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function createPlan(overrides: Partial<DmWorldEntryPlan> = {}): DmWorldEntryPlan {
|
|
166
|
+
return {
|
|
167
|
+
action: 'create',
|
|
168
|
+
frame: frame(),
|
|
169
|
+
mode: 'adventure',
|
|
170
|
+
handle: null,
|
|
171
|
+
prompt: 'A drowned cathedral lit by green fire',
|
|
172
|
+
seedImageUrl: 'https://s3.example/frames/f-1.png',
|
|
173
|
+
autoStopAfterMs: DM_WORLD_AUTO_STOP_MS_DEFAULT,
|
|
174
|
+
...overrides,
|
|
175
|
+
} as DmWorldEntryPlan;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
describe('resolveDmWorldEntryFrame', () => {
|
|
179
|
+
it('joins the active beat to its board frame', () => {
|
|
180
|
+
const a = frame({ frameId: 'f-a', beatId: 'beat-1' });
|
|
181
|
+
const b = frame({ frameId: 'f-b', beatId: 'beat-2' });
|
|
182
|
+
expect(
|
|
183
|
+
resolveDmWorldEntryFrame({
|
|
184
|
+
frameIds: ['f-a', 'f-b'],
|
|
185
|
+
frames: [b, a],
|
|
186
|
+
activeBeatId: 'beat-2',
|
|
187
|
+
})?.frameId,
|
|
188
|
+
).toBe('f-b');
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('resolves in BOARD order, not payload order, when a beat has several frames', () => {
|
|
192
|
+
const first = frame({ frameId: 'f-first' });
|
|
193
|
+
const second = frame({ frameId: 'f-second' });
|
|
194
|
+
expect(
|
|
195
|
+
resolveDmWorldEntryFrame({
|
|
196
|
+
frameIds: ['f-first', 'f-second'],
|
|
197
|
+
frames: [second, first],
|
|
198
|
+
activeBeatId: 'beat-2',
|
|
199
|
+
})?.frameId,
|
|
200
|
+
).toBe('f-first');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('prefers a RENDERED frame over an earlier unrendered one', () => {
|
|
204
|
+
const unrendered = frame({ frameId: 'f-first', variants: [] });
|
|
205
|
+
const rendered = frame({ frameId: 'f-second' });
|
|
206
|
+
expect(
|
|
207
|
+
resolveDmWorldEntryFrame({
|
|
208
|
+
frameIds: ['f-first', 'f-second'],
|
|
209
|
+
frames: [unrendered, rendered],
|
|
210
|
+
activeBeatId: 'beat-2',
|
|
211
|
+
})?.frameId,
|
|
212
|
+
).toBe('f-second');
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('returns null with no active beat and for an unknown beat', () => {
|
|
216
|
+
const frames = [frame()];
|
|
217
|
+
expect(
|
|
218
|
+
resolveDmWorldEntryFrame({ frameIds: ['f-1'], frames, activeBeatId: null }),
|
|
219
|
+
).toBeNull();
|
|
220
|
+
expect(
|
|
221
|
+
resolveDmWorldEntryFrame({ frameIds: ['f-1'], frames, activeBeatId: ' ' }),
|
|
222
|
+
).toBeNull();
|
|
223
|
+
expect(
|
|
224
|
+
resolveDmWorldEntryFrame({
|
|
225
|
+
frameIds: ['f-1'],
|
|
226
|
+
frames,
|
|
227
|
+
activeBeatId: 'beat-hallucinated',
|
|
228
|
+
}),
|
|
229
|
+
).toBeNull();
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
describe('composeDmWorldPrompt', () => {
|
|
234
|
+
it('uses the frame’s server-compiled prompt as the base', () => {
|
|
235
|
+
expect(composeDmWorldPrompt(frame())).toBe(
|
|
236
|
+
'A drowned cathedral lit by green fire',
|
|
237
|
+
);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('appends the tag text as ATMOSPHERE, never as a replacement', () => {
|
|
241
|
+
const composed = composeDmWorldPrompt(frame(), 'rain, dread, low light');
|
|
242
|
+
expect(composed).toBe(
|
|
243
|
+
`A drowned cathedral lit by green fire${DM_WORLD_ATMOSPHERE_PREFIX}rain, dread, low light`,
|
|
244
|
+
);
|
|
245
|
+
expect(composed).toContain('A drowned cathedral lit by green fire');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('trims the ATMOSPHERE, never the frame, to fit the vendor cap', () => {
|
|
249
|
+
const base = 'x'.repeat(HAPPY_OYSTER_PROMPT_MAX_CHARS - 60);
|
|
250
|
+
const composed = composeDmWorldPrompt(
|
|
251
|
+
frame({
|
|
252
|
+
variants: [
|
|
253
|
+
{
|
|
254
|
+
variantId: 'v-1',
|
|
255
|
+
status: 'succeeded',
|
|
256
|
+
origin: 'generate',
|
|
257
|
+
createdAt: '2026-07-28T00:00:00Z',
|
|
258
|
+
promptText: base,
|
|
259
|
+
imageUrl: 'https://s3.example/f.png',
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
}),
|
|
263
|
+
'y'.repeat(500),
|
|
264
|
+
);
|
|
265
|
+
expect(composed).not.toBeNull();
|
|
266
|
+
expect(composed!.length).toBeLessThanOrEqual(HAPPY_OYSTER_PROMPT_MAX_CHARS);
|
|
267
|
+
expect(composed!.startsWith(base)).toBe(true);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it('drops the atmosphere entirely when there is no room for a usable one', () => {
|
|
271
|
+
const base = 'x'.repeat(HAPPY_OYSTER_PROMPT_MAX_CHARS - 5);
|
|
272
|
+
const composed = composeDmWorldPrompt(
|
|
273
|
+
frame({
|
|
274
|
+
variants: [
|
|
275
|
+
{
|
|
276
|
+
variantId: 'v-1',
|
|
277
|
+
status: 'succeeded',
|
|
278
|
+
origin: 'generate',
|
|
279
|
+
createdAt: '2026-07-28T00:00:00Z',
|
|
280
|
+
promptText: base,
|
|
281
|
+
imageUrl: 'https://s3.example/f.png',
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
}),
|
|
285
|
+
'moonless, freezing',
|
|
286
|
+
);
|
|
287
|
+
expect(composed).toBe(base);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('returns null when the frame carries no compiled prompt', () => {
|
|
291
|
+
expect(
|
|
292
|
+
composeDmWorldPrompt(
|
|
293
|
+
frame({
|
|
294
|
+
variants: [
|
|
295
|
+
{
|
|
296
|
+
variantId: 'v-1',
|
|
297
|
+
status: 'succeeded',
|
|
298
|
+
origin: 'generate',
|
|
299
|
+
createdAt: '2026-07-28T00:00:00Z',
|
|
300
|
+
imageUrl: 'https://s3.example/f.png',
|
|
301
|
+
},
|
|
302
|
+
],
|
|
303
|
+
}),
|
|
304
|
+
),
|
|
305
|
+
).toBeNull();
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
describe('planDmWorldEntry', () => {
|
|
310
|
+
const base = {
|
|
311
|
+
frameIds: ['f-1'],
|
|
312
|
+
frames: [frame()],
|
|
313
|
+
activeBeatId: 'beat-2',
|
|
314
|
+
mode: 'adventure' as const,
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
it('is OPT-IN: with no auto-fire setting a create must be confirmed (rail 1)', () => {
|
|
318
|
+
expect(DM_WORLD_AUTO_FIRE_DEFAULT).toBe(false);
|
|
319
|
+
const result = planDmWorldEntry(base);
|
|
320
|
+
expect(result.ok).toBe(true);
|
|
321
|
+
expect(result.ok && result.plan.action).toBe('confirm_required');
|
|
322
|
+
expect(result.ok && result.plan.autoStopAfterMs).toBeNull();
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it('auto-fires once the player turned it on, with the 30 s stop armed (rails 1 + 4)', () => {
|
|
326
|
+
const result = planDmWorldEntry({ ...base, autoFireEnabled: true });
|
|
327
|
+
expect(result.ok && result.plan.action).toBe('create');
|
|
328
|
+
expect(result.ok && result.plan.autoStopAfterMs).toBe(30_000);
|
|
329
|
+
expect(DM_WORLD_AUTO_STOP_MS_DEFAULT).toBe(30_000);
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it('takes the studio-configured stop interval when the host supplies one', () => {
|
|
333
|
+
const result = planDmWorldEntry({
|
|
334
|
+
...base,
|
|
335
|
+
autoFireEnabled: true,
|
|
336
|
+
autoStopAfterMs: 90_000,
|
|
337
|
+
});
|
|
338
|
+
expect(result.ok && result.plan.autoStopAfterMs).toBe(90_000);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it('STEERS a live world whose scene has not changed - never rebuilds it (owner DM.12)', () => {
|
|
342
|
+
const result = planDmWorldEntry({
|
|
343
|
+
...base,
|
|
344
|
+
frames: [frame({ sequenceId: 'seq-1' })],
|
|
345
|
+
autoFireEnabled: true,
|
|
346
|
+
liveWorld: {
|
|
347
|
+
handle: { encryptedWorldId: 'ew-live', mode: 'adventure' },
|
|
348
|
+
sequenceId: 'seq-1',
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
expect(result.ok && result.plan.action).toBe('steer');
|
|
352
|
+
expect(result.ok && dmWorldEntryWouldCreateWorld(result.plan.action)).toBe(false);
|
|
353
|
+
expect(result.ok && result.plan.handle?.encryptedWorldId).toBe('ew-live');
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('creates only at a SCENE CHANGE - that is what caps spend, not the timeout', () => {
|
|
357
|
+
const result = planDmWorldEntry({
|
|
358
|
+
...base,
|
|
359
|
+
frames: [frame({ sequenceId: 'seq-2' })],
|
|
360
|
+
autoFireEnabled: true,
|
|
361
|
+
liveWorld: {
|
|
362
|
+
handle: { encryptedWorldId: 'ew-live', mode: 'adventure' },
|
|
363
|
+
sequenceId: 'seq-1',
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
expect(result.ok && result.plan.action).toBe('create');
|
|
367
|
+
expect(result.ok && dmWorldEntryWouldCreateWorld(result.plan.action)).toBe(true);
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// §Q DM.62 — TWO NULL ANCHORS ARE NOT ONE SCENE.
|
|
371
|
+
//
|
|
372
|
+
// The pre-fix predicate was `(liveWorld.sequenceId ?? null) === (frame.sequenceId
|
|
373
|
+
// ?? null)`, so every unanchored frame collided with every other one. Live on
|
|
374
|
+
// 2026-08-02: 8 of 21 frames carry a null `sequenceId` and every ENDING is
|
|
375
|
+
// among them, so a world opened on any unanchored beat was re-aimed at the
|
|
376
|
+
// ending's prompt and the ending's own world was never built.
|
|
377
|
+
describe('§Q DM.62 — scene identity never collapses two unknown anchors', () => {
|
|
378
|
+
it('treats a DIFFERENT null-anchor frame as a scene CHANGE, not a steer', () => {
|
|
379
|
+
const result = planDmWorldEntry({
|
|
380
|
+
...base,
|
|
381
|
+
// The ending: its own frame, its own beat, no sequence anchor.
|
|
382
|
+
frameIds: ['f-ending'],
|
|
383
|
+
frames: [frame({ frameId: 'f-ending', beatId: 'beat-2', sequenceId: null })],
|
|
384
|
+
autoFireEnabled: true,
|
|
385
|
+
liveWorld: {
|
|
386
|
+
handle: { encryptedWorldId: 'ew-live', mode: 'adventure' },
|
|
387
|
+
sequenceId: null,
|
|
388
|
+
frameId: 'f-opening',
|
|
389
|
+
beatId: 'beat-1',
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
expect(result.ok && result.plan.action).toBe('create');
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
it('still STEERS the frame the live world was actually seeded from', () => {
|
|
396
|
+
const result = planDmWorldEntry({
|
|
397
|
+
...base,
|
|
398
|
+
frames: [frame({ frameId: 'f-1', sequenceId: null })],
|
|
399
|
+
autoFireEnabled: true,
|
|
400
|
+
liveWorld: {
|
|
401
|
+
handle: { encryptedWorldId: 'ew-live', mode: 'adventure' },
|
|
402
|
+
sequenceId: null,
|
|
403
|
+
frameId: 'f-1',
|
|
404
|
+
},
|
|
405
|
+
});
|
|
406
|
+
expect(result.ok && result.plan.action).toBe('steer');
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
it('keeps DM.12 intact: two ANCHORED frames of one sequence are one scene', () => {
|
|
410
|
+
const result = planDmWorldEntry({
|
|
411
|
+
...base,
|
|
412
|
+
frameIds: ['f-2'],
|
|
413
|
+
frames: [frame({ frameId: 'f-2', sequenceId: 'seq-1' })],
|
|
414
|
+
autoFireEnabled: true,
|
|
415
|
+
liveWorld: {
|
|
416
|
+
handle: { encryptedWorldId: 'ew-live', mode: 'adventure' },
|
|
417
|
+
sequenceId: 'seq-1',
|
|
418
|
+
frameId: 'f-1',
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
expect(result.ok && result.plan.action).toBe('steer');
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
it('falls back to the BEAT when the host recorded no frame id', () => {
|
|
425
|
+
const same = planDmWorldEntry({
|
|
426
|
+
...base,
|
|
427
|
+
frames: [frame({ beatId: 'beat-2', sequenceId: null })],
|
|
428
|
+
autoFireEnabled: true,
|
|
429
|
+
liveWorld: {
|
|
430
|
+
handle: { encryptedWorldId: 'ew-live', mode: 'adventure' },
|
|
431
|
+
sequenceId: null,
|
|
432
|
+
beatId: 'beat-2',
|
|
433
|
+
},
|
|
434
|
+
});
|
|
435
|
+
expect(same.ok && same.plan.action).toBe('steer');
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
it('asks instead of billing when the live world records NO identity at all', () => {
|
|
439
|
+
// codex P1 on #1663 — auto-fire is EXPLICITLY ON here, which is the whole
|
|
440
|
+
// point: nothing is known about what is streaming, so this is an
|
|
441
|
+
// unanswered question rather than a cut, and auto-firing it would bill a
|
|
442
|
+
// second permanent world for a scene that may already be on screen.
|
|
443
|
+
const result = planDmWorldEntry({
|
|
444
|
+
...base,
|
|
445
|
+
autoFireEnabled: true,
|
|
446
|
+
frames: [frame({ sequenceId: null })],
|
|
447
|
+
liveWorld: { handle: { encryptedWorldId: 'ew-live', mode: 'adventure' } },
|
|
448
|
+
});
|
|
449
|
+
expect(result.ok && result.plan.action).toBe('confirm_required');
|
|
450
|
+
expect(result.ok && dmWorldEntryWouldCreateWorld(result.plan.action)).toBe(true);
|
|
451
|
+
// And no auto-stop timer, since nothing was auto-fired.
|
|
452
|
+
expect(result.ok && result.plan.autoStopAfterMs).toBeNull();
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it('still auto-fires a KNOWN cut — the unknown case is the only one held back', () => {
|
|
456
|
+
const result = planDmWorldEntry({
|
|
457
|
+
...base,
|
|
458
|
+
autoFireEnabled: true,
|
|
459
|
+
frameIds: ['f-ending'],
|
|
460
|
+
frames: [frame({ frameId: 'f-ending', beatId: 'beat-2', sequenceId: null })],
|
|
461
|
+
liveWorld: {
|
|
462
|
+
handle: { encryptedWorldId: 'ew-live', mode: 'adventure' },
|
|
463
|
+
frameId: 'f-open',
|
|
464
|
+
},
|
|
465
|
+
});
|
|
466
|
+
expect(result.ok && result.plan.action).toBe('create');
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
it('reopens a frame that already owns a world rather than minting one (owner Q2)', () => {
|
|
471
|
+
const result = planDmWorldEntry({
|
|
472
|
+
...base,
|
|
473
|
+
autoFireEnabled: true,
|
|
474
|
+
frames: [frame({ worldId: 'ew-existing' })],
|
|
475
|
+
});
|
|
476
|
+
expect(result.ok && result.plan.action).toBe('reopen');
|
|
477
|
+
expect(result.ok && dmWorldEntryWouldCreateWorld(result.plan.action)).toBe(false);
|
|
478
|
+
expect(result.ok && result.plan.handle).toEqual({
|
|
479
|
+
encryptedWorldId: 'ew-existing',
|
|
480
|
+
mode: 'adventure',
|
|
481
|
+
});
|
|
482
|
+
expect(result.ok && result.plan.seedImageUrl).toBeNull();
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
it('reopens with the STORED mode, not the session mode (DM.30)', () => {
|
|
486
|
+
const result = planDmWorldEntry({
|
|
487
|
+
...base,
|
|
488
|
+
autoFireEnabled: true,
|
|
489
|
+
frames: [frame({ worldId: 'ew-existing', worldMode: 'adventure' })],
|
|
490
|
+
});
|
|
491
|
+
expect(result.ok && result.plan.handle).toEqual({
|
|
492
|
+
encryptedWorldId: 'ew-existing',
|
|
493
|
+
mode: 'adventure',
|
|
494
|
+
});
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
it('refuses to reopen a world belonging to the other mode (DM.30)', () => {
|
|
498
|
+
// MEASURED live 2026-07-28: a World-Explorer (directing) world reattached
|
|
499
|
+
// from the adventure-mode DM reached the vendor and returned
|
|
500
|
+
// `[MODE_MISMATCH] this world is not a Adventure world (mode 2)` — after
|
|
501
|
+
// the money was spent. This line used to fabricate the handle's mode from
|
|
502
|
+
// `input.mode`, which made `launchHappyOysterWorld`'s pre-flight compare
|
|
503
|
+
// the session mode with itself.
|
|
504
|
+
const result = planDmWorldEntry({
|
|
505
|
+
...base,
|
|
506
|
+
autoFireEnabled: true,
|
|
507
|
+
frames: [frame({ worldId: 'ew-directing', worldMode: 'directing' })],
|
|
508
|
+
});
|
|
509
|
+
expect(result).toMatchObject({ ok: false, reason: 'world_mode_mismatch' });
|
|
510
|
+
expect(result.ok === false && result.message).toContain('directing');
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
it('still reopens a pre-DM.30 binding that carries no mode at all', () => {
|
|
514
|
+
// The milestone run's frame is one of these. Dead-ending every modeless
|
|
515
|
+
// binding would regress a working demo to fix a hypothetical.
|
|
516
|
+
const result = planDmWorldEntry({
|
|
517
|
+
...base,
|
|
518
|
+
autoFireEnabled: true,
|
|
519
|
+
frames: [frame({ worldId: 'ew-legacy' })],
|
|
520
|
+
});
|
|
521
|
+
expect(result.ok && result.plan.action).toBe('reopen');
|
|
522
|
+
expect(result.ok && result.plan.handle).toEqual({
|
|
523
|
+
encryptedWorldId: 'ew-legacy',
|
|
524
|
+
mode: 'adventure',
|
|
525
|
+
});
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
it('carries the tag text only as atmosphere on the composed prompt', () => {
|
|
529
|
+
const result = planDmWorldEntry({
|
|
530
|
+
...base,
|
|
531
|
+
autoFireEnabled: true,
|
|
532
|
+
atmosphere: 'thunder overhead',
|
|
533
|
+
});
|
|
534
|
+
expect(result.ok && result.plan.prompt).toBe(
|
|
535
|
+
`A drowned cathedral lit by green fire${DM_WORLD_ATMOSPHERE_PREFIX}thunder overhead`,
|
|
536
|
+
);
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
it('blocks - before anything can be billed - on every unusable input', () => {
|
|
540
|
+
const auto = { ...base, autoFireEnabled: true };
|
|
541
|
+
expect(planDmWorldEntry({ ...auto, activeBeatId: null })).toMatchObject({
|
|
542
|
+
ok: false,
|
|
543
|
+
reason: 'no_active_beat',
|
|
544
|
+
});
|
|
545
|
+
expect(
|
|
546
|
+
planDmWorldEntry({ ...auto, activeBeatId: 'beat-hallucinated' }),
|
|
547
|
+
).toMatchObject({ ok: false, reason: 'no_frame_for_beat' });
|
|
548
|
+
expect(
|
|
549
|
+
planDmWorldEntry({ ...auto, frames: [frame({ variants: [] })] }),
|
|
550
|
+
).toMatchObject({ ok: false, reason: 'frame_not_rendered' });
|
|
551
|
+
expect(
|
|
552
|
+
planDmWorldEntry({
|
|
553
|
+
...auto,
|
|
554
|
+
frames: [
|
|
555
|
+
frame({
|
|
556
|
+
variants: [
|
|
557
|
+
{
|
|
558
|
+
variantId: 'v-1',
|
|
559
|
+
status: 'succeeded',
|
|
560
|
+
origin: 'generate',
|
|
561
|
+
createdAt: '2026-07-28T00:00:00Z',
|
|
562
|
+
imageUrl: 'https://s3.example/f.png',
|
|
563
|
+
},
|
|
564
|
+
],
|
|
565
|
+
}),
|
|
566
|
+
],
|
|
567
|
+
}),
|
|
568
|
+
).toMatchObject({ ok: false, reason: 'prompt_unavailable' });
|
|
569
|
+
expect(
|
|
570
|
+
planDmWorldEntry({
|
|
571
|
+
...auto,
|
|
572
|
+
frames: [
|
|
573
|
+
frame({
|
|
574
|
+
variants: [
|
|
575
|
+
{
|
|
576
|
+
variantId: 'v-1',
|
|
577
|
+
status: 'succeeded',
|
|
578
|
+
origin: 'generate',
|
|
579
|
+
createdAt: '2026-07-28T00:00:00Z',
|
|
580
|
+
promptText: 'z'.repeat(HAPPY_OYSTER_PROMPT_MAX_CHARS + 1),
|
|
581
|
+
imageUrl: 'https://s3.example/f.png',
|
|
582
|
+
},
|
|
583
|
+
],
|
|
584
|
+
}),
|
|
585
|
+
],
|
|
586
|
+
}),
|
|
587
|
+
).toMatchObject({ ok: false, reason: 'prompt_invalid' });
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
// §Q DM.61(a) — THE PRE-FIRST-TURN BLOCK IS NOT A FAULT REPORT.
|
|
591
|
+
//
|
|
592
|
+
// A definition spawn starts with `current_beat_id=None` until the DM's first
|
|
593
|
+
// `advance_story` (25 of 88 live sessions on 2026-08-02), so "launch, then
|
|
594
|
+
// immediately ask for the world" lands here ON THE HAPPY PATH. The old block
|
|
595
|
+
// stated the join key and stopped; these pin that it now names the move that
|
|
596
|
+
// resolves it, and that the recourse is machine-readable so a surface can
|
|
597
|
+
// put it on a control instead of re-inventing the copy.
|
|
598
|
+
describe('§Q DM.61(a) — the pre-first-turn block carries its way out', () => {
|
|
599
|
+
const blocked = planDmWorldEntry({ ...base, activeBeatId: null });
|
|
600
|
+
|
|
601
|
+
it('names the first turn instead of only the missing beat', () => {
|
|
602
|
+
expect(blocked.ok).toBe(false);
|
|
603
|
+
if (blocked.ok) return;
|
|
604
|
+
expect(blocked.message).toMatch(/first turn/i);
|
|
605
|
+
// The exact pre-fix copy, which said nothing a player could act on.
|
|
606
|
+
expect(blocked.message).not.toBe(
|
|
607
|
+
'No beat is active in this session yet — the world is seeded from the storyboard frame for the current beat.',
|
|
608
|
+
);
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
it('offers a recourse on this reason and on no other', () => {
|
|
612
|
+
// The label says what the CONTROL does (returns to chat) and what it is
|
|
613
|
+
// for (the first turn) — it does not claim to send the turn itself.
|
|
614
|
+
expect(dmWorldEntryBlock('no_active_beat', 'x').recourse).toBe(
|
|
615
|
+
'Back to chat to take your first turn',
|
|
616
|
+
);
|
|
617
|
+
// A block that resolves on a different surface (or not at all) must not
|
|
618
|
+
// grow a button that cannot help — `world_mode_mismatch` above all, whose
|
|
619
|
+
// only real fix is server-side rebinding.
|
|
620
|
+
expect(dmWorldEntryBlock('world_mode_mismatch', 'x').recourse).toBeNull();
|
|
621
|
+
expect(dmWorldEntryBlock('frame_render_failed', 'x').recourse).toBeNull();
|
|
622
|
+
expect(dmWorldEntryBlock(null, 'no board').recourse).toBeNull();
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
it('reads as a story that has not started, not as a broken session', () => {
|
|
626
|
+
expect(dmWorldEntryBlockTitle('no_active_beat')).toBe(
|
|
627
|
+
'The story has not started yet',
|
|
628
|
+
);
|
|
629
|
+
});
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
// §Q SB.34 — the owner's `star-wars` board: 6 beats, 1 rendered, 5 refused by
|
|
633
|
+
// the image model. Every one of the five used to land on `frame_not_rendered`
|
|
634
|
+
// ("has not rendered YET"), which reads as "wait" for something that will
|
|
635
|
+
// never arrive, under the same headline a beat with NO board gets.
|
|
636
|
+
describe('a REFUSED frame vs a MISSING one (§Q SB.34)', () => {
|
|
637
|
+
const blockedFrame = (promptText = 'A rain-lit hangar, the offer made') =>
|
|
638
|
+
frame({
|
|
639
|
+
variants: [
|
|
640
|
+
{
|
|
641
|
+
variantId: 'v-1',
|
|
642
|
+
status: 'failed',
|
|
643
|
+
origin: 'generate',
|
|
644
|
+
createdAt: '2026-07-28T00:00:00Z',
|
|
645
|
+
promptText,
|
|
646
|
+
error:
|
|
647
|
+
'Image composition refused on content policy after 3 prompt stage(s)',
|
|
648
|
+
},
|
|
649
|
+
],
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
it('reports frame_render_failed, not frame_not_rendered, and says why', () => {
|
|
653
|
+
const result = planDmWorldEntry({
|
|
654
|
+
...base,
|
|
655
|
+
autoFireEnabled: true,
|
|
656
|
+
frames: [blockedFrame()],
|
|
657
|
+
});
|
|
658
|
+
expect(result).toMatchObject({ ok: false, reason: 'frame_render_failed' });
|
|
659
|
+
expect(result.ok === false && result.message).toContain(
|
|
660
|
+
'refused on content policy',
|
|
661
|
+
);
|
|
662
|
+
expect(result.ok === false && result.message).toContain('IS storyboarded');
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
it('still says frame_not_rendered while the frame is genuinely in flight', () => {
|
|
666
|
+
expect(
|
|
667
|
+
planDmWorldEntry({
|
|
668
|
+
...base,
|
|
669
|
+
autoFireEnabled: true,
|
|
670
|
+
frames: [
|
|
671
|
+
frame({
|
|
672
|
+
variants: [
|
|
673
|
+
{
|
|
674
|
+
variantId: 'v-1',
|
|
675
|
+
status: 'pending',
|
|
676
|
+
origin: 'generate',
|
|
677
|
+
createdAt: '2026-07-28T00:00:00Z',
|
|
678
|
+
},
|
|
679
|
+
],
|
|
680
|
+
}),
|
|
681
|
+
],
|
|
682
|
+
}),
|
|
683
|
+
).toMatchObject({ ok: false, reason: 'frame_not_rendered' });
|
|
684
|
+
});
|
|
685
|
+
|
|
686
|
+
it('gives a refused frame a DIFFERENT headline from a beat with no frame', () => {
|
|
687
|
+
const missing = planDmWorldEntry({
|
|
688
|
+
...base,
|
|
689
|
+
autoFireEnabled: true,
|
|
690
|
+
activeBeatId: 'beat-hallucinated',
|
|
691
|
+
});
|
|
692
|
+
const refused = planDmWorldEntry({
|
|
693
|
+
...base,
|
|
694
|
+
autoFireEnabled: true,
|
|
695
|
+
frames: [blockedFrame()],
|
|
696
|
+
});
|
|
697
|
+
const titleOf = (r: typeof missing) =>
|
|
698
|
+
r.ok ? null : dmWorldEntryBlockTitle(r.reason);
|
|
699
|
+
expect(titleOf(missing)).not.toBe(titleOf(refused));
|
|
700
|
+
expect(titleOf(refused)).toBe("This beat's frame failed to render");
|
|
701
|
+
// The generic headline is now reserved for "the planner never ran".
|
|
702
|
+
expect(dmWorldEntryBlockTitle(null)).toBe(DM_WORLD_ENTRY_NO_BOARD_TITLE);
|
|
703
|
+
expect(dmWorldEntryBlock(null, 'no board').title).toBe(
|
|
704
|
+
DM_WORLD_ENTRY_NO_BOARD_TITLE,
|
|
705
|
+
);
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
it('STEERS a live world from a refused frame — the prompt survived the failure', () => {
|
|
709
|
+
// The whole point of the accessor split: no image, but the compiled text
|
|
710
|
+
// that beat MEANS is intact, and `instruct` needs no seed image.
|
|
711
|
+
const seedFrame = blockedFrame();
|
|
712
|
+
const result = planDmWorldEntry({
|
|
713
|
+
...base,
|
|
714
|
+
frames: [seedFrame],
|
|
715
|
+
liveWorld: {
|
|
716
|
+
handle: { encryptedWorldId: 'ew-live', mode: 'adventure' },
|
|
717
|
+
sequenceId: seedFrame.sequenceId ?? null,
|
|
718
|
+
// §Q DM.62 — this fixture's frame carries NO sequenceId, so before
|
|
719
|
+
// the identity fix it reached the steer branch purely because two
|
|
720
|
+
// nulls compared equal. That is the bug, not the subject of this
|
|
721
|
+
// test: the live world IS this frame's world, so say so with the
|
|
722
|
+
// frame id and keep testing what the test is about (a refused frame's
|
|
723
|
+
// surviving prompt).
|
|
724
|
+
frameId: seedFrame.frameId,
|
|
725
|
+
},
|
|
726
|
+
});
|
|
727
|
+
expect(result).toMatchObject({ ok: true });
|
|
728
|
+
expect(result.ok && result.plan.action).toBe('steer');
|
|
729
|
+
expect(result.ok && result.plan.prompt).toContain('A rain-lit hangar');
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
it('falls back to prompt_unavailable when the failure predates SB.38', () => {
|
|
733
|
+
// Boards generated before #1575 wrote `promptText: ""` on failures, and
|
|
734
|
+
// nothing rewrites them — so steering one has genuinely nothing to send.
|
|
735
|
+
const result = planDmWorldEntry({
|
|
736
|
+
...base,
|
|
737
|
+
frames: [blockedFrame('')],
|
|
738
|
+
liveWorld: {
|
|
739
|
+
handle: { encryptedWorldId: 'ew-live', mode: 'adventure' },
|
|
740
|
+
sequenceId: null,
|
|
741
|
+
// §Q DM.62 — same reason as the case above: the steer branch is
|
|
742
|
+
// reached by IDENTITY (this world is this frame's), not by two null
|
|
743
|
+
// sequence anchors colliding.
|
|
744
|
+
frameId: 'f-1',
|
|
745
|
+
},
|
|
746
|
+
});
|
|
747
|
+
expect(result).toMatchObject({ ok: false, reason: 'prompt_unavailable' });
|
|
748
|
+
});
|
|
749
|
+
});
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
describe('DM.18 — a REAL frame prompt plans a launch instead of being refused', () => {
|
|
753
|
+
const realFrame = frame({
|
|
754
|
+
variants: [
|
|
755
|
+
{
|
|
756
|
+
variantId: 'v-1',
|
|
757
|
+
status: 'succeeded',
|
|
758
|
+
origin: 'generate',
|
|
759
|
+
createdAt: '2026-07-28T00:00:00Z',
|
|
760
|
+
promptText: REAL_FRAME_PROMPT_TEXT,
|
|
761
|
+
imageUrl: 'https://s3.example/f.png',
|
|
762
|
+
},
|
|
763
|
+
],
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
it('is the case that used to return prompt_invalid', () => {
|
|
767
|
+
// The regression this row exists for: 2363 characters against a 2000 cap.
|
|
768
|
+
expect(REAL_FRAME_PROMPT_TEXT.length).toBeGreaterThan(
|
|
769
|
+
HAPPY_OYSTER_PROMPT_MAX_CHARS,
|
|
770
|
+
);
|
|
771
|
+
});
|
|
772
|
+
|
|
773
|
+
it('plans a create whose prompt fits AND still carries the beat', () => {
|
|
774
|
+
const result = planDmWorldEntry({
|
|
775
|
+
frameIds: ['f-1'],
|
|
776
|
+
frames: [realFrame],
|
|
777
|
+
activeBeatId: 'beat-2',
|
|
778
|
+
mode: 'adventure',
|
|
779
|
+
autoFireEnabled: true,
|
|
780
|
+
});
|
|
781
|
+
expect(result.ok).toBe(true);
|
|
782
|
+
if (!result.ok) return;
|
|
783
|
+
expect(result.plan.action).toBe('create');
|
|
784
|
+
expect(result.plan.prompt.length).toBeLessThanOrEqual(
|
|
785
|
+
HAPPY_OYSTER_PROMPT_MAX_CHARS,
|
|
786
|
+
);
|
|
787
|
+
// Length alone is what head-truncation also satisfies. These are the beat.
|
|
788
|
+
expect(result.plan.prompt).toContain('Characters: Girl —');
|
|
789
|
+
expect(result.plan.prompt).toContain('Soldiers —');
|
|
790
|
+
expect(result.plan.prompt).toContain(
|
|
791
|
+
'the Girl paces the ruined chamber while the Boy wraps his side wound',
|
|
792
|
+
);
|
|
793
|
+
expect(result.plan.prompt).toContain(
|
|
794
|
+
'They pick their way through the burning Battlefield, dodging collapsing archways and stray Soldiers',
|
|
795
|
+
);
|
|
796
|
+
expect(result.plan.prompt).toContain('Scene: Battlefield');
|
|
797
|
+
// The launcher's own gate agrees the prompt is usable.
|
|
798
|
+
expect(happyOysterPromptIssue(result.plan.prompt)).toBeNull();
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
it('steers a live world with the same compacted prompt', () => {
|
|
802
|
+
const result = planDmWorldEntry({
|
|
803
|
+
frameIds: ['f-1'],
|
|
804
|
+
frames: [realFrame],
|
|
805
|
+
activeBeatId: 'beat-2',
|
|
806
|
+
mode: 'adventure',
|
|
807
|
+
liveWorld: {
|
|
808
|
+
handle: { encryptedWorldId: 'ew-live', mode: 'adventure' },
|
|
809
|
+
sequenceId: realFrame.sequenceId ?? null,
|
|
810
|
+
// §Q DM.62 — the real frame carries no sequence anchor either, so the
|
|
811
|
+
// steer this test wants is now anchored on the frame id.
|
|
812
|
+
frameId: realFrame.frameId,
|
|
813
|
+
},
|
|
814
|
+
});
|
|
815
|
+
expect(result.ok).toBe(true);
|
|
816
|
+
if (!result.ok) return;
|
|
817
|
+
expect(result.plan.action).toBe('steer');
|
|
818
|
+
expect(result.plan.prompt.length).toBeLessThanOrEqual(
|
|
819
|
+
HAPPY_OYSTER_PROMPT_MAX_CHARS,
|
|
820
|
+
);
|
|
821
|
+
expect(result.plan.prompt).toContain("Sova's Last Counsel");
|
|
822
|
+
});
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
describe("DM.21 — the DM's atmosphere survives on a REAL frame", () => {
|
|
826
|
+
const ATMOSPHERE = 'ash on the wind, distant screaming, the light gone red';
|
|
827
|
+
|
|
828
|
+
function realFrame(): StoryboardFrame {
|
|
829
|
+
return frame({
|
|
830
|
+
variants: [
|
|
831
|
+
{
|
|
832
|
+
variantId: 'v-1',
|
|
833
|
+
status: 'succeeded',
|
|
834
|
+
origin: 'generate',
|
|
835
|
+
createdAt: '2026-07-28T00:00:00Z',
|
|
836
|
+
promptText: REAL_FRAME_PROMPT_TEXT,
|
|
837
|
+
imageUrl: 'https://s3.example/f.png',
|
|
838
|
+
},
|
|
839
|
+
],
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
it('reserves the prefix plus the atmosphere, capped at the MIN floor', () => {
|
|
844
|
+
expect(dmWorldAtmosphereReservation('')).toBe(0);
|
|
845
|
+
// Longer than the floor — reserve the prefix + the floor.
|
|
846
|
+
expect(dmWorldAtmosphereReservation(ATMOSPHERE)).toBe(
|
|
847
|
+
DM_WORLD_ATMOSPHERE_PREFIX.length + DM_WORLD_ATMOSPHERE_MIN_CHARS,
|
|
848
|
+
);
|
|
849
|
+
// Shorter than the floor — reserve only what it needs, so a short tag does
|
|
850
|
+
// not shed board context for nothing.
|
|
851
|
+
expect(dmWorldAtmosphereReservation('rain')).toBe(
|
|
852
|
+
DM_WORLD_ATMOSPHERE_PREFIX.length + 4,
|
|
853
|
+
);
|
|
854
|
+
});
|
|
855
|
+
|
|
856
|
+
it('carries the atmosphere INTACT alongside the cast, action and setting', () => {
|
|
857
|
+
const composed = composeDmWorldPrompt(realFrame(), ATMOSPHERE);
|
|
858
|
+
expect(composed).not.toBeNull();
|
|
859
|
+
const prompt = composed as string;
|
|
860
|
+
|
|
861
|
+
// The whole point of the row: the DM's own words reach the world.
|
|
862
|
+
expect(prompt).toContain(`${DM_WORLD_ATMOSPHERE_PREFIX}${ATMOSPHERE}`);
|
|
863
|
+
expect(prompt.endsWith(ATMOSPHERE)).toBe(true);
|
|
864
|
+
|
|
865
|
+
// …and they did NOT cost the frame's substance. Length alone would pass
|
|
866
|
+
// while any of these had been shed to make room.
|
|
867
|
+
expect(prompt).toContain('Characters: Girl —');
|
|
868
|
+
expect(prompt).toContain('Soldiers —');
|
|
869
|
+
expect(prompt).toContain(
|
|
870
|
+
'the Girl paces the ruined chamber while the Boy wraps his side wound',
|
|
871
|
+
);
|
|
872
|
+
expect(prompt).toContain(
|
|
873
|
+
'They pick their way through the burning Battlefield, dodging collapsing archways and stray Soldiers',
|
|
874
|
+
);
|
|
875
|
+
expect(prompt).toContain('Scene: Battlefield');
|
|
876
|
+
expect(prompt).toContain(
|
|
877
|
+
'A massive battle erupts, with explosions and destruction',
|
|
878
|
+
);
|
|
879
|
+
|
|
880
|
+
expect(prompt.length).toBeLessThanOrEqual(HAPPY_OYSTER_PROMPT_MAX_CHARS);
|
|
881
|
+
expect(happyOysterPromptIssue(prompt)).toBeNull();
|
|
882
|
+
});
|
|
883
|
+
|
|
884
|
+
it('pays for it in CEREMONY — one more arc stake, nothing else', () => {
|
|
885
|
+
const withAtmosphere = composeDmWorldPrompt(realFrame(), ATMOSPHERE) ?? '';
|
|
886
|
+
const without = composeDmWorldPrompt(realFrame(), null) ?? '';
|
|
887
|
+
const stakes = (text: string): number =>
|
|
888
|
+
(text.split('At stake: ')[1] ?? '').split(' | ').length;
|
|
889
|
+
// DM.18 left four of the board's five conflicts standing; seating the
|
|
890
|
+
// atmosphere costs exactly one more.
|
|
891
|
+
expect(stakes(without)).toBe(4);
|
|
892
|
+
expect(stakes(withAtmosphere)).toBe(3);
|
|
893
|
+
// The `Action` line is byte-identical either way.
|
|
894
|
+
const action = (text: string): string =>
|
|
895
|
+
text.split('\n').find(l => l.startsWith('Action: ')) ?? '';
|
|
896
|
+
expect(action(withAtmosphere)).toBe(action(without));
|
|
897
|
+
expect(action(withAtmosphere)).not.toBe('');
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
it('plans a create carrying the atmosphere', () => {
|
|
901
|
+
const result = planDmWorldEntry({
|
|
902
|
+
frameIds: ['f-1'],
|
|
903
|
+
frames: [realFrame()],
|
|
904
|
+
activeBeatId: 'beat-2',
|
|
905
|
+
mode: 'adventure',
|
|
906
|
+
autoFireEnabled: true,
|
|
907
|
+
atmosphere: ATMOSPHERE,
|
|
908
|
+
});
|
|
909
|
+
expect(result.ok).toBe(true);
|
|
910
|
+
if (!result.ok) return;
|
|
911
|
+
expect(result.plan.action).toBe('create');
|
|
912
|
+
expect(result.plan.prompt).toContain(ATMOSPHERE);
|
|
913
|
+
expect(result.plan.prompt).toContain("Sova's Last Counsel");
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
it('abandons the reservation rather than cut the frame for it', () => {
|
|
917
|
+
// Ceremony-free and already at the cap: there is nothing to give, so the
|
|
918
|
+
// frame keeps every character and the atmosphere is dropped — the ratified
|
|
919
|
+
// precedence, unchanged.
|
|
920
|
+
const action = 'a'.repeat(HAPPY_OYSTER_PROMPT_MAX_CHARS - 8);
|
|
921
|
+
const composed = composeDmWorldPrompt(
|
|
922
|
+
frame({
|
|
923
|
+
variants: [
|
|
924
|
+
{
|
|
925
|
+
variantId: 'v-1',
|
|
926
|
+
status: 'succeeded',
|
|
927
|
+
origin: 'generate',
|
|
928
|
+
createdAt: '2026-07-28T00:00:00Z',
|
|
929
|
+
promptText: `Action: ${action}`,
|
|
930
|
+
imageUrl: 'https://s3.example/f.png',
|
|
931
|
+
},
|
|
932
|
+
],
|
|
933
|
+
}),
|
|
934
|
+
ATMOSPHERE,
|
|
935
|
+
);
|
|
936
|
+
expect(composed).toBe(`Action: ${action}`);
|
|
937
|
+
});
|
|
938
|
+
|
|
939
|
+
it('appends a SHORT atmosphere that fits whole instead of dropping it', () => {
|
|
940
|
+
// Pre-DM.21 the floor was checked against the room even when the whole
|
|
941
|
+
// atmosphere already fitted, so a 4-character tag with 10 characters of
|
|
942
|
+
// room was discarded.
|
|
943
|
+
const base = 'x'.repeat(HAPPY_OYSTER_PROMPT_MAX_CHARS - 20);
|
|
944
|
+
const composed = composeDmWorldPrompt(
|
|
945
|
+
frame({
|
|
946
|
+
variants: [
|
|
947
|
+
{
|
|
948
|
+
variantId: 'v-1',
|
|
949
|
+
status: 'succeeded',
|
|
950
|
+
origin: 'generate',
|
|
951
|
+
createdAt: '2026-07-28T00:00:00Z',
|
|
952
|
+
promptText: base,
|
|
953
|
+
imageUrl: 'https://s3.example/f.png',
|
|
954
|
+
},
|
|
955
|
+
],
|
|
956
|
+
}),
|
|
957
|
+
'rain',
|
|
958
|
+
);
|
|
959
|
+
expect(composed).toBe(`${base}${DM_WORLD_ATMOSPHERE_PREFIX}rain`);
|
|
960
|
+
});
|
|
961
|
+
});
|
|
962
|
+
|
|
963
|
+
describe('rememberDmWorldEntry (rail 2 - nothing hidden, nothing lost)', () => {
|
|
964
|
+
const entry: DmWorldSessionEntry = {
|
|
965
|
+
handle: { encryptedWorldId: 'ew-1', mode: 'adventure' },
|
|
966
|
+
frameId: 'f-1',
|
|
967
|
+
beatId: 'beat-2',
|
|
968
|
+
trigger: 'auto',
|
|
969
|
+
openedAt: 1,
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
it('accumulates every world the session opened', () => {
|
|
973
|
+
const list = rememberDmWorldEntry(rememberDmWorldEntry([], entry), {
|
|
974
|
+
...entry,
|
|
975
|
+
handle: { encryptedWorldId: 'ew-2', mode: 'adventure' },
|
|
976
|
+
});
|
|
977
|
+
expect(list.map(e => e.handle.encryptedWorldId)).toEqual(['ew-1', 'ew-2']);
|
|
978
|
+
});
|
|
979
|
+
|
|
980
|
+
it('de-duplicates by world id so a reopen does not double-list a world', () => {
|
|
981
|
+
const list = rememberDmWorldEntry(rememberDmWorldEntry([], entry), {
|
|
982
|
+
...entry,
|
|
983
|
+
trigger: 'reopen',
|
|
984
|
+
openedAt: 2,
|
|
985
|
+
});
|
|
986
|
+
expect(list).toHaveLength(1);
|
|
987
|
+
expect(list[0].trigger).toBe('reopen');
|
|
988
|
+
});
|
|
989
|
+
});
|
|
990
|
+
|
|
991
|
+
describe('collectDmWorldRecords (§Q DM.24 — a billed world survives the reload)', () => {
|
|
992
|
+
const sessionEntry: DmWorldSessionEntry = {
|
|
993
|
+
handle: { encryptedWorldId: 'ew-live', mode: 'adventure' },
|
|
994
|
+
frameId: 'f-1',
|
|
995
|
+
beatId: 'beat-2',
|
|
996
|
+
trigger: 'auto',
|
|
997
|
+
openedAt: 42,
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
it('lists the board’s bound worlds with NO session entries at all — the reload case', () => {
|
|
1001
|
+
const records = collectDmWorldRecords({
|
|
1002
|
+
frameIds: ['f-1', 'f-2'],
|
|
1003
|
+
frames: [
|
|
1004
|
+
frame({ frameId: 'f-1', worldId: 'ew-a', worldMode: 'adventure' }),
|
|
1005
|
+
frame({ frameId: 'f-2', worldId: 'ew-b', worldMode: 'directing' }),
|
|
1006
|
+
],
|
|
1007
|
+
});
|
|
1008
|
+
expect(records.map(r => r.worldId)).toEqual(['ew-a', 'ew-b']);
|
|
1009
|
+
expect(records.every(r => r.source === 'frame')).toBe(true);
|
|
1010
|
+
expect(records.map(r => r.mode)).toEqual(['adventure', 'directing']);
|
|
1011
|
+
});
|
|
1012
|
+
|
|
1013
|
+
it('reads the board in BOARD order, not frame-array order', () => {
|
|
1014
|
+
const records = collectDmWorldRecords({
|
|
1015
|
+
frameIds: ['f-2', 'f-1'],
|
|
1016
|
+
frames: [
|
|
1017
|
+
frame({ frameId: 'f-1', worldId: 'ew-a' }),
|
|
1018
|
+
frame({ frameId: 'f-2', worldId: 'ew-b' }),
|
|
1019
|
+
],
|
|
1020
|
+
});
|
|
1021
|
+
expect(records.map(r => r.worldId)).toEqual(['ew-b', 'ew-a']);
|
|
1022
|
+
});
|
|
1023
|
+
|
|
1024
|
+
it('reports a PRE-DM.30 binding as mode UNKNOWN rather than guessing one', () => {
|
|
1025
|
+
const [record] = collectDmWorldRecords({
|
|
1026
|
+
frameIds: ['f-1'],
|
|
1027
|
+
frames: [frame({ frameId: 'f-1', worldId: 'ew-a' })],
|
|
1028
|
+
});
|
|
1029
|
+
expect(record.mode).toBeNull();
|
|
1030
|
+
});
|
|
1031
|
+
|
|
1032
|
+
it('flags a world the session opened that NO frame records as session-only', () => {
|
|
1033
|
+
const records = collectDmWorldRecords({
|
|
1034
|
+
frameIds: ['f-1'],
|
|
1035
|
+
frames: [frame({ frameId: 'f-1' })],
|
|
1036
|
+
entries: [sessionEntry],
|
|
1037
|
+
});
|
|
1038
|
+
expect(records).toHaveLength(1);
|
|
1039
|
+
expect(records[0]).toMatchObject({
|
|
1040
|
+
worldId: 'ew-live',
|
|
1041
|
+
source: 'session',
|
|
1042
|
+
mode: 'adventure',
|
|
1043
|
+
frameId: 'f-1',
|
|
1044
|
+
trigger: 'auto',
|
|
1045
|
+
openedAt: 42,
|
|
1046
|
+
});
|
|
1047
|
+
});
|
|
1048
|
+
|
|
1049
|
+
it('does NOT double-list a world that is both bound and opened this session', () => {
|
|
1050
|
+
const records = collectDmWorldRecords({
|
|
1051
|
+
frameIds: ['f-1'],
|
|
1052
|
+
frames: [
|
|
1053
|
+
frame({ frameId: 'f-1', worldId: 'ew-live', worldMode: 'adventure' }),
|
|
1054
|
+
],
|
|
1055
|
+
entries: [sessionEntry],
|
|
1056
|
+
});
|
|
1057
|
+
expect(records).toHaveLength(1);
|
|
1058
|
+
expect(records[0]).toMatchObject({
|
|
1059
|
+
source: 'frame',
|
|
1060
|
+
trigger: 'auto',
|
|
1061
|
+
openedAt: 42,
|
|
1062
|
+
});
|
|
1063
|
+
});
|
|
1064
|
+
|
|
1065
|
+
it('puts durable records before session-only ones', () => {
|
|
1066
|
+
const records = collectDmWorldRecords({
|
|
1067
|
+
frameIds: ['f-1', 'f-2'],
|
|
1068
|
+
frames: [
|
|
1069
|
+
frame({ frameId: 'f-1' }),
|
|
1070
|
+
frame({ frameId: 'f-2', worldId: 'ew-bound' }),
|
|
1071
|
+
],
|
|
1072
|
+
entries: [sessionEntry],
|
|
1073
|
+
});
|
|
1074
|
+
expect(records.map(r => [r.worldId, r.source])).toEqual([
|
|
1075
|
+
['ew-bound', 'frame'],
|
|
1076
|
+
['ew-live', 'session'],
|
|
1077
|
+
]);
|
|
1078
|
+
});
|
|
1079
|
+
|
|
1080
|
+
it('ignores a blank worldId — an unbound frame is not a world', () => {
|
|
1081
|
+
const records = collectDmWorldRecords({
|
|
1082
|
+
frameIds: ['f-1'],
|
|
1083
|
+
frames: [frame({ frameId: 'f-1', worldId: ' ' })],
|
|
1084
|
+
});
|
|
1085
|
+
expect(records).toEqual([]);
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
it('states the unlistable-and-unrecorded risk in ONE sentence the surfaces share', () => {
|
|
1089
|
+
expect(DM_WORLD_UNRECORDED_NOTICE).toContain('billed');
|
|
1090
|
+
expect(DM_WORLD_UNRECORDED_NOTICE).toContain('cannot be listed');
|
|
1091
|
+
});
|
|
1092
|
+
});
|
|
1093
|
+
|
|
1094
|
+
describe('launchDmWorldEntry', () => {
|
|
1095
|
+
it('REFUSES a confirm-required create with no operator confirmation, without opening a session', async () => {
|
|
1096
|
+
const bridge = stubBridge();
|
|
1097
|
+
await expect(
|
|
1098
|
+
launchDmWorldEntry(
|
|
1099
|
+
createPlan({ action: 'confirm_required', autoStopAfterMs: null }),
|
|
1100
|
+
bridge,
|
|
1101
|
+
{ seed: SEED },
|
|
1102
|
+
),
|
|
1103
|
+
).rejects.toBeInstanceOf(HappyOysterLaunchError);
|
|
1104
|
+
expect(bridge.calls).toEqual([]);
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
it('creates once the operator confirms', async () => {
|
|
1108
|
+
const bridge = stubBridge();
|
|
1109
|
+
const result = await launchDmWorldEntry(
|
|
1110
|
+
createPlan({ action: 'confirm_required', autoStopAfterMs: null }),
|
|
1111
|
+
bridge,
|
|
1112
|
+
{ seed: SEED, operatorConfirmed: true },
|
|
1113
|
+
);
|
|
1114
|
+
expect(bridge.calls).toEqual(['connect', 'createWorld', 'startTravel']);
|
|
1115
|
+
expect(result.handle).toEqual({ encryptedWorldId: 'ew-dm-1', mode: 'adventure' });
|
|
1116
|
+
});
|
|
1117
|
+
|
|
1118
|
+
it('sends the seed as BYTES and never as a URL', async () => {
|
|
1119
|
+
let params: Record<string, unknown> | null = null;
|
|
1120
|
+
const bridge = stubBridge({
|
|
1121
|
+
createWorld: async p => {
|
|
1122
|
+
params = p as unknown as Record<string, unknown>;
|
|
1123
|
+
return READY;
|
|
1124
|
+
},
|
|
1125
|
+
});
|
|
1126
|
+
await launchDmWorldEntry(createPlan(), bridge, { seed: SEED });
|
|
1127
|
+
expect(params).not.toBeNull();
|
|
1128
|
+
expect(params!.firstFrameImage).toBe(SEED.blob);
|
|
1129
|
+
expect(params!).not.toHaveProperty('firstFrameImageUrl');
|
|
1130
|
+
});
|
|
1131
|
+
|
|
1132
|
+
it('refuses to create without prepared bytes, without opening a session', async () => {
|
|
1133
|
+
const bridge = stubBridge();
|
|
1134
|
+
await expect(launchDmWorldEntry(createPlan(), bridge, {})).rejects.toThrow(
|
|
1135
|
+
/prepared image bytes/,
|
|
1136
|
+
);
|
|
1137
|
+
expect(bridge.calls).toEqual([]);
|
|
1138
|
+
});
|
|
1139
|
+
|
|
1140
|
+
it('persists the permanent handle on success', async () => {
|
|
1141
|
+
const persisted: unknown[] = [];
|
|
1142
|
+
const entries: DmWorldSessionEntry[] = [];
|
|
1143
|
+
await launchDmWorldEntry(createPlan(), stubBridge(), {
|
|
1144
|
+
seed: SEED,
|
|
1145
|
+
onWorldHandle: (h, entry) => {
|
|
1146
|
+
persisted.push(h);
|
|
1147
|
+
entries.push(entry);
|
|
1148
|
+
},
|
|
1149
|
+
});
|
|
1150
|
+
expect(persisted).toEqual([{ encryptedWorldId: 'ew-dm-1', mode: 'adventure' }]);
|
|
1151
|
+
// Rail 2 - the session record says WHICH moment it is and that nobody asked
|
|
1152
|
+
// for it by hand, which is what a surface labels an auto-fired world with.
|
|
1153
|
+
expect(entries[0]).toMatchObject({
|
|
1154
|
+
frameId: 'f-1',
|
|
1155
|
+
beatId: 'beat-2',
|
|
1156
|
+
trigger: 'auto',
|
|
1157
|
+
});
|
|
1158
|
+
});
|
|
1159
|
+
|
|
1160
|
+
it('persists a world that WAS created even when startTravel fails', async () => {
|
|
1161
|
+
const persisted: unknown[] = [];
|
|
1162
|
+
const bridge = stubBridge({
|
|
1163
|
+
startTravel: async () => {
|
|
1164
|
+
throw new Error('gateway blew up');
|
|
1165
|
+
},
|
|
1166
|
+
});
|
|
1167
|
+
await expect(
|
|
1168
|
+
launchDmWorldEntry(createPlan(), bridge, {
|
|
1169
|
+
seed: SEED,
|
|
1170
|
+
onWorldHandle: h => {
|
|
1171
|
+
persisted.push(h);
|
|
1172
|
+
},
|
|
1173
|
+
}),
|
|
1174
|
+
).rejects.toBeInstanceOf(HappyOysterLaunchError);
|
|
1175
|
+
expect(persisted).toEqual([{ encryptedWorldId: 'ew-dm-1', mode: 'adventure' }]);
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
it('surfaces the launch error even when persistence itself fails', async () => {
|
|
1179
|
+
const bridge = stubBridge({
|
|
1180
|
+
startTravel: async () => {
|
|
1181
|
+
throw new Error('gateway blew up');
|
|
1182
|
+
},
|
|
1183
|
+
});
|
|
1184
|
+
await expect(
|
|
1185
|
+
launchDmWorldEntry(createPlan(), bridge, {
|
|
1186
|
+
seed: SEED,
|
|
1187
|
+
onWorldHandle: () => {
|
|
1188
|
+
throw new Error('the write failed too');
|
|
1189
|
+
},
|
|
1190
|
+
}),
|
|
1191
|
+
).rejects.toThrow(/gateway blew up/);
|
|
1192
|
+
});
|
|
1193
|
+
|
|
1194
|
+
it('reopens without a seed, a prompt or a confirmation', async () => {
|
|
1195
|
+
const bridge = stubBridge();
|
|
1196
|
+
await launchDmWorldEntry(
|
|
1197
|
+
createPlan({
|
|
1198
|
+
action: 'reopen',
|
|
1199
|
+
handle: { encryptedWorldId: 'ew-existing', mode: 'adventure' },
|
|
1200
|
+
prompt: '',
|
|
1201
|
+
seedImageUrl: null,
|
|
1202
|
+
autoStopAfterMs: null,
|
|
1203
|
+
}),
|
|
1204
|
+
bridge,
|
|
1205
|
+
{},
|
|
1206
|
+
);
|
|
1207
|
+
expect(bridge.calls).toEqual(['connect', 'attachWorld', 'startTravel']);
|
|
1208
|
+
});
|
|
1209
|
+
|
|
1210
|
+
it('refuses to launch a STEER plan - that re-aims the live world in the pane', async () => {
|
|
1211
|
+
const bridge = stubBridge();
|
|
1212
|
+
await expect(
|
|
1213
|
+
launchDmWorldEntry(
|
|
1214
|
+
createPlan({
|
|
1215
|
+
action: 'steer',
|
|
1216
|
+
handle: { encryptedWorldId: 'ew-live', mode: 'adventure' },
|
|
1217
|
+
seedImageUrl: null,
|
|
1218
|
+
autoStopAfterMs: null,
|
|
1219
|
+
}),
|
|
1220
|
+
bridge,
|
|
1221
|
+
{},
|
|
1222
|
+
),
|
|
1223
|
+
).rejects.toThrow(/does not launch one/);
|
|
1224
|
+
expect(bridge.calls).toEqual([]);
|
|
1225
|
+
});
|
|
1226
|
+
});
|
|
1227
|
+
|
|
1228
|
+
describe('DM.17 — a reopen never implies continuity the vendor does not provide', () => {
|
|
1229
|
+
it('returns the notice for reopen and NOTHING for every other action', () => {
|
|
1230
|
+
expect(dmWorldReopenNotice('reopen')).toBe(DM_WORLD_REOPEN_NOTICE);
|
|
1231
|
+
expect(dmWorldReopenNotice('steer')).toBeNull();
|
|
1232
|
+
expect(dmWorldReopenNotice('create')).toBeNull();
|
|
1233
|
+
expect(dmWorldReopenNotice('confirm_required')).toBeNull();
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
it('says what is lost, not merely that something is', () => {
|
|
1237
|
+
// The measured fact this row exists for: attachWorld restores the CREATED
|
|
1238
|
+
// scene and the steers are gone. A notice that only said "state may differ"
|
|
1239
|
+
// would be as unhelpful as the silent drop it replaces.
|
|
1240
|
+
expect(DM_WORLD_REOPEN_NOTICE).toMatch(/created from/i);
|
|
1241
|
+
expect(DM_WORLD_REOPEN_NOTICE).toMatch(/steering/i);
|
|
1242
|
+
expect(DM_WORLD_REOPEN_NOTICE).toMatch(/not carried over/i);
|
|
1243
|
+
});
|
|
1244
|
+
});
|
|
1245
|
+
|
|
1246
|
+
describe('DM.43 — a billed world is recorded at MINT time, not at settle time', () => {
|
|
1247
|
+
/**
|
|
1248
|
+
* The known-bad shape, measured on staging 2026-08-01: `createWorld` returns
|
|
1249
|
+
* a permanent id and `startTravel` then occupies the next 60 s — up to ~3
|
|
1250
|
+
* minutes once the SDK's own 3-attempt retry ladder runs. Persisting only on
|
|
1251
|
+
* settle leaves that whole window as a period in which a reload destroys the
|
|
1252
|
+
* only reference to a paid, unlistable world.
|
|
1253
|
+
*/
|
|
1254
|
+
it('hands the handle over BEFORE startTravel is called', async () => {
|
|
1255
|
+
const order: string[] = [];
|
|
1256
|
+
const bridge = stubBridge({
|
|
1257
|
+
createWorld: async () => {
|
|
1258
|
+
order.push('createWorld');
|
|
1259
|
+
return READY;
|
|
1260
|
+
},
|
|
1261
|
+
startTravel: async () => {
|
|
1262
|
+
order.push('startTravel');
|
|
1263
|
+
return { streaming: true };
|
|
1264
|
+
},
|
|
1265
|
+
});
|
|
1266
|
+
await launchDmWorldEntry(createPlan(), bridge, {
|
|
1267
|
+
seed: SEED,
|
|
1268
|
+
onWorldHandle: h => {
|
|
1269
|
+
order.push(`persist:${h.encryptedWorldId}`);
|
|
1270
|
+
},
|
|
1271
|
+
});
|
|
1272
|
+
expect(order).toEqual(['createWorld', 'persist:ew-dm-1', 'startTravel']);
|
|
1273
|
+
});
|
|
1274
|
+
|
|
1275
|
+
it('has already recorded the world while startTravel is STILL HANGING', async () => {
|
|
1276
|
+
// The exact failing input: `startTravel` never settles. Before this row the
|
|
1277
|
+
// handle reached `onWorldHandle` only from the settle paths, so there was
|
|
1278
|
+
// nothing to observe here for minutes.
|
|
1279
|
+
const persisted: string[] = [];
|
|
1280
|
+
let releaseTravel: () => void = () => {};
|
|
1281
|
+
const hangs = new Promise<{ streaming: boolean }>(resolve => {
|
|
1282
|
+
releaseTravel = () => resolve({ streaming: true });
|
|
1283
|
+
});
|
|
1284
|
+
const bridge = stubBridge({ startTravel: () => hangs });
|
|
1285
|
+
const launch = launchDmWorldEntry(createPlan(), bridge, {
|
|
1286
|
+
seed: SEED,
|
|
1287
|
+
onWorldHandle: h => {
|
|
1288
|
+
persisted.push(h.encryptedWorldId);
|
|
1289
|
+
},
|
|
1290
|
+
});
|
|
1291
|
+
// Drain the microtasks up to `startTravel`, then assert mid-flight.
|
|
1292
|
+
for (let i = 0; i < 8; i += 1) await Promise.resolve();
|
|
1293
|
+
expect(persisted).toEqual(['ew-dm-1']);
|
|
1294
|
+
releaseTravel();
|
|
1295
|
+
await launch;
|
|
1296
|
+
// And still exactly once — three offer points, one world, one write.
|
|
1297
|
+
expect(persisted).toEqual(['ew-dm-1']);
|
|
1298
|
+
});
|
|
1299
|
+
|
|
1300
|
+
it('records the world exactly once across the create and failure offers', async () => {
|
|
1301
|
+
const persisted: string[] = [];
|
|
1302
|
+
const bridge = stubBridge({
|
|
1303
|
+
startTravel: async () => {
|
|
1304
|
+
throw new Error('gateway blew up');
|
|
1305
|
+
},
|
|
1306
|
+
});
|
|
1307
|
+
await expect(
|
|
1308
|
+
launchDmWorldEntry(createPlan(), bridge, {
|
|
1309
|
+
seed: SEED,
|
|
1310
|
+
onWorldHandle: h => {
|
|
1311
|
+
persisted.push(h.encryptedWorldId);
|
|
1312
|
+
},
|
|
1313
|
+
}),
|
|
1314
|
+
).rejects.toBeInstanceOf(HappyOysterLaunchError);
|
|
1315
|
+
expect(persisted).toEqual(['ew-dm-1']);
|
|
1316
|
+
});
|
|
1317
|
+
|
|
1318
|
+
it('RETRIES when the host RESOLVES `false` — a soft write failure is not a record', async () => {
|
|
1319
|
+
// The failing input codex found on this very PR: the DM host reports a
|
|
1320
|
+
// failed frame write by resolving `{status:'unavailable'}`, not by
|
|
1321
|
+
// throwing. A launcher that treated "did not throw" as recorded would mark
|
|
1322
|
+
// the world done on a transient API outage and never offer it again —
|
|
1323
|
+
// turning a blip into a permanently unrecorded billed world.
|
|
1324
|
+
const attempts: string[] = [];
|
|
1325
|
+
await launchDmWorldEntry(createPlan(), stubBridge(), {
|
|
1326
|
+
seed: SEED,
|
|
1327
|
+
onWorldHandle: h => {
|
|
1328
|
+
attempts.push(h.encryptedWorldId);
|
|
1329
|
+
return attempts.length > 1;
|
|
1330
|
+
},
|
|
1331
|
+
});
|
|
1332
|
+
expect(attempts).toEqual(['ew-dm-1', 'ew-dm-1']);
|
|
1333
|
+
});
|
|
1334
|
+
|
|
1335
|
+
it('stops offering once the host confirms the write landed', async () => {
|
|
1336
|
+
const attempts: string[] = [];
|
|
1337
|
+
await launchDmWorldEntry(createPlan(), stubBridge(), {
|
|
1338
|
+
seed: SEED,
|
|
1339
|
+
onWorldHandle: h => {
|
|
1340
|
+
attempts.push(h.encryptedWorldId);
|
|
1341
|
+
return true;
|
|
1342
|
+
},
|
|
1343
|
+
});
|
|
1344
|
+
expect(attempts).toEqual(['ew-dm-1']);
|
|
1345
|
+
});
|
|
1346
|
+
|
|
1347
|
+
it('RETRIES a create-time write that failed, and never aborts the launch for it', async () => {
|
|
1348
|
+
const attempts: string[] = [];
|
|
1349
|
+
const bridge = stubBridge();
|
|
1350
|
+
const result = await launchDmWorldEntry(createPlan(), bridge, {
|
|
1351
|
+
seed: SEED,
|
|
1352
|
+
onWorldHandle: h => {
|
|
1353
|
+
attempts.push(h.encryptedWorldId);
|
|
1354
|
+
if (attempts.length === 1) throw new Error('transient write failure');
|
|
1355
|
+
},
|
|
1356
|
+
});
|
|
1357
|
+
// Two offers taken, because the first did not complete: a failed write must
|
|
1358
|
+
// not mark the world as recorded, and must not kill an otherwise fine
|
|
1359
|
+
// launch.
|
|
1360
|
+
expect(attempts).toEqual(['ew-dm-1', 'ew-dm-1']);
|
|
1361
|
+
expect(result.handle.encryptedWorldId).toBe('ew-dm-1');
|
|
1362
|
+
expect(bridge.calls).toEqual(['connect', 'createWorld', 'startTravel']);
|
|
1363
|
+
});
|
|
1364
|
+
});
|
|
1365
|
+
|
|
1366
|
+
describe('DM.42 — the two long waits are told apart, and a dead stream says so', () => {
|
|
1367
|
+
it('reads `starting_stream` as ENTERING, not as a slow build', () => {
|
|
1368
|
+
expect(
|
|
1369
|
+
dmWorldLaunchStage({ preparingSeed: false, clientPhase: 'starting_stream' }),
|
|
1370
|
+
).toBe('entering');
|
|
1371
|
+
expect(dmWorldLaunchStage({ preparingSeed: false, clientPhase: 'connected' })).toBe(
|
|
1372
|
+
'building',
|
|
1373
|
+
);
|
|
1374
|
+
expect(
|
|
1375
|
+
dmWorldLaunchStage({ preparingSeed: true, clientPhase: 'starting_stream' }),
|
|
1376
|
+
).toBe('preparing');
|
|
1377
|
+
});
|
|
1378
|
+
|
|
1379
|
+
it('NEVER shows the 105–240 s build expectation over a stream-start wait', () => {
|
|
1380
|
+
// The measured lie: on 2026-08-01 the pane held its build/reopen copy for
|
|
1381
|
+
// the full 60 s of `starting_stream` on a world whose own phase had already
|
|
1382
|
+
// reached `traveling`.
|
|
1383
|
+
const entering = dmWorldLaunchProgress('entering', 'create');
|
|
1384
|
+
expect(entering.title).not.toMatch(/building/i);
|
|
1385
|
+
expect(entering.detail).not.toMatch(/105/);
|
|
1386
|
+
expect(entering.detail).toMatch(/60 seconds/);
|
|
1387
|
+
expect(entering.detail).toMatch(/built/i);
|
|
1388
|
+
|
|
1389
|
+
const building = dmWorldLaunchProgress('building', 'create');
|
|
1390
|
+
expect(building.title).toMatch(/building/i);
|
|
1391
|
+
expect(building.detail).toMatch(/105–240 seconds/);
|
|
1392
|
+
|
|
1393
|
+
// A reopen has no build to narrate, so it must not borrow the create copy.
|
|
1394
|
+
expect(dmWorldLaunchProgress('building', 'reopen').detail).toBeNull();
|
|
1395
|
+
// ...but once it is entering, it owes the same honest bound.
|
|
1396
|
+
expect(dmWorldLaunchProgress('entering', 'reopen').detail).toMatch(/60 seconds/);
|
|
1397
|
+
});
|
|
1398
|
+
|
|
1399
|
+
it('reports a stalled stream as the cause instead of the RETRY error the SDK throws', () => {
|
|
1400
|
+
// Verbatim terminal state measured on the free reopen path 2026-08-01: the
|
|
1401
|
+
// stream-start timeout is retried by the SDK, the retry hits the vendor's
|
|
1402
|
+
// travel lock, and THAT is the error the caller receives.
|
|
1403
|
+
const view = dmWorldLaunchFailure({
|
|
1404
|
+
reason: 'traveling',
|
|
1405
|
+
message: '[TRAVELING] a travel is live; the world API unlocks when the travel ends',
|
|
1406
|
+
worldId: 'dHpmaEU0-billed',
|
|
1407
|
+
streamStalled: true,
|
|
1408
|
+
});
|
|
1409
|
+
expect(view.title).toBe(DM_WORLD_STREAM_STALL_TITLE);
|
|
1410
|
+
expect(view.title).not.toMatch(/traveling/i);
|
|
1411
|
+
expect(view.detail).toMatch(/no video ever reached this browser/);
|
|
1412
|
+
// Nothing is hidden — the vendor's own text is still carried.
|
|
1413
|
+
expect(view.detail).toMatch(/\[TRAVELING\]/);
|
|
1414
|
+
// §Q DM.43 — a billed world always names itself on a dead end.
|
|
1415
|
+
expect(view.worldId).toBe('dHpmaEU0-billed');
|
|
1416
|
+
// The classification rides on the result, so a surface never has to
|
|
1417
|
+
// string-compare the rendered title to know which state it is in.
|
|
1418
|
+
expect(view.streamStalled).toBe(true);
|
|
1419
|
+
});
|
|
1420
|
+
|
|
1421
|
+
it('leaves an ordinary failure reported as itself', () => {
|
|
1422
|
+
const view = dmWorldLaunchFailure({
|
|
1423
|
+
reason: 'content_rejected',
|
|
1424
|
+
message: 'the seed image was refused',
|
|
1425
|
+
});
|
|
1426
|
+
expect(view.title).toBe('content_rejected');
|
|
1427
|
+
expect(view.detail).toBe('the seed image was refused');
|
|
1428
|
+
expect(view.worldId).toBeNull();
|
|
1429
|
+
expect(view.streamStalled).toBe(false);
|
|
1430
|
+
});
|
|
1431
|
+
});
|
|
1432
|
+
|
|
1433
|
+
// ---------------------------------------------------------------------------
|
|
1434
|
+
// §Q ARC.6k — THE REFUSAL MUST NOT PRESCRIBE AN IMPOSSIBLE ACTION
|
|
1435
|
+
// ---------------------------------------------------------------------------
|
|
1436
|
+
//
|
|
1437
|
+
// The owner's 2026-08-02 session refused with "storyboard this beat before
|
|
1438
|
+
// entering its world". That instruction cannot be followed for a FORK-approved
|
|
1439
|
+
// arc: the session's beats are hashed under the fork Story id while a board is
|
|
1440
|
+
// only ever minted in the canonical story's id space, so a regenerated board
|
|
1441
|
+
// mints canon ids again and the fork session still joins nothing. The join
|
|
1442
|
+
// itself is fixed server-side (`AdventureState.boardBeatId` →
|
|
1443
|
+
// `storyboardJoinBeatId`); this is the advice for the cases where the join
|
|
1444
|
+
// still legitimately finds no frame.
|
|
1445
|
+
describe('planDmWorldEntry — no_frame_for_beat copy (§Q ARC.6k)', () => {
|
|
1446
|
+
const refusal = () =>
|
|
1447
|
+
planDmWorldEntry({
|
|
1448
|
+
frameIds: ['f-1'],
|
|
1449
|
+
frames: [frame({ beatId: 'canon-beat-1' })],
|
|
1450
|
+
// A fork-scoped beat: the shape that matched nothing, forever.
|
|
1451
|
+
activeBeatId: 'fork-hash-75ece0e9',
|
|
1452
|
+
mode: 'adventure',
|
|
1453
|
+
});
|
|
1454
|
+
|
|
1455
|
+
it('never tells a player to storyboard a beat and stop there', () => {
|
|
1456
|
+
const result = refusal();
|
|
1457
|
+
expect(result.ok).toBe(false);
|
|
1458
|
+
if (result.ok) throw new Error('unreachable');
|
|
1459
|
+
expect(result.reason).toBe('no_frame_for_beat');
|
|
1460
|
+
// THE EXACT PRE-FIX SENTENCE.
|
|
1461
|
+
expect(result.message).not.toContain(
|
|
1462
|
+
'storyboard this beat before entering its world',
|
|
1463
|
+
);
|
|
1464
|
+
});
|
|
1465
|
+
|
|
1466
|
+
it('names the fork case and the action that actually resolves it', () => {
|
|
1467
|
+
const result = refusal();
|
|
1468
|
+
if (result.ok) throw new Error('unreachable');
|
|
1469
|
+
expect(result.message).toContain('fork-hash-75ece0e9');
|
|
1470
|
+
expect(result.message).toContain('FORK-approved arc');
|
|
1471
|
+
expect(result.message).toContain('re-approve the arc as a merge');
|
|
1472
|
+
});
|
|
1473
|
+
});
|
|
1474
|
+
|
|
1475
|
+
// ---------------------------------------------------------------------------
|
|
1476
|
+
// §Q DM.66 — A DEAD STREAM IS NOT A LIVE WORLD
|
|
1477
|
+
// ---------------------------------------------------------------------------
|
|
1478
|
+
//
|
|
1479
|
+
// THE KNOWN-BAD PAYLOAD, verbatim from `~/.seer-e2e/checkpoint2-0802-verdicts.md`
|
|
1480
|
+
// §B5 — the second of two samples taken 10 s apart with no user action between:
|
|
1481
|
+
//
|
|
1482
|
+
// s8 {readyState: 4, currentTime: 55.893, paused: false}
|
|
1483
|
+
// s9 {readyState: 0, currentTime: 0, paused: true }
|
|
1484
|
+
//
|
|
1485
|
+
// and the surface after s9 still showed "You're in the world". The reducer must
|
|
1486
|
+
// call s9 dead, and the pre-fix build had no reducer at all.
|
|
1487
|
+
const DEAD_SAMPLE = { readyState: 0, currentTime: 0 };
|
|
1488
|
+
const HEALTHY_SAMPLE = { readyState: 4, currentTime: 55.893 };
|
|
1489
|
+
|
|
1490
|
+
const streamHealth = (
|
|
1491
|
+
overrides: Partial<Parameters<typeof dmWorldStreamEndReason>[0]> = {},
|
|
1492
|
+
) =>
|
|
1493
|
+
dmWorldStreamEndReason({
|
|
1494
|
+
travelCompleted: false,
|
|
1495
|
+
clientPhase: HAPPY_OYSTER_PHASE_STREAMING,
|
|
1496
|
+
userPaused: false,
|
|
1497
|
+
sample: HEALTHY_SAMPLE,
|
|
1498
|
+
msSinceAdvance: 0,
|
|
1499
|
+
...overrides,
|
|
1500
|
+
});
|
|
1501
|
+
|
|
1502
|
+
describe('dmWorldStreamEndReason (§Q DM.66)', () => {
|
|
1503
|
+
it('calls the CHECKPOINT-2 sample dead — the exact reading the UI claimed was live', () => {
|
|
1504
|
+
expect(streamHealth({ sample: DEAD_SAMPLE })).toBe('video_gone');
|
|
1505
|
+
});
|
|
1506
|
+
|
|
1507
|
+
it('leaves a healthy stream alone', () => {
|
|
1508
|
+
expect(streamHealth()).toBeNull();
|
|
1509
|
+
});
|
|
1510
|
+
|
|
1511
|
+
it('does not call a PAUSED world dead — the player is holding it, not losing it', () => {
|
|
1512
|
+
expect(
|
|
1513
|
+
streamHealth({
|
|
1514
|
+
userPaused: true,
|
|
1515
|
+
// Everything an element looks like under the player's own Pause.
|
|
1516
|
+
sample: { readyState: 4, currentTime: 55.893 },
|
|
1517
|
+
msSinceAdvance: DM_WORLD_STREAM_SILENCE_MS * 4,
|
|
1518
|
+
}),
|
|
1519
|
+
).toBeNull();
|
|
1520
|
+
});
|
|
1521
|
+
|
|
1522
|
+
it('reports the vendor-authoritative end ahead of anything inferred', () => {
|
|
1523
|
+
expect(
|
|
1524
|
+
streamHealth({ travelCompleted: true, sample: HEALTHY_SAMPLE }),
|
|
1525
|
+
).toBe('travel_completed');
|
|
1526
|
+
});
|
|
1527
|
+
|
|
1528
|
+
it('reports a client phase that left streaming', () => {
|
|
1529
|
+
expect(streamHealth({ clientPhase: 'connected' })).toBe('session_ended');
|
|
1530
|
+
});
|
|
1531
|
+
|
|
1532
|
+
it('tolerates sub-bound silence — the vendor treats short gaps as rebuffering', () => {
|
|
1533
|
+
// ⛔ THE MIRROR DEFECT. The SDK debounces a `waiting`/`stalled` by 3000 ms
|
|
1534
|
+
// and re-checks; a host that called 3 s of silence "ended" would paint a
|
|
1535
|
+
// dead-stream notice over a stream about to recover.
|
|
1536
|
+
expect(streamHealth({ msSinceAdvance: 3_000 })).toBeNull();
|
|
1537
|
+
expect(DM_WORLD_STREAM_SILENCE_MS).toBeGreaterThan(3_000);
|
|
1538
|
+
});
|
|
1539
|
+
|
|
1540
|
+
it('calls sustained silence dead at the bound', () => {
|
|
1541
|
+
expect(streamHealth({ msSinceAdvance: DM_WORLD_STREAM_SILENCE_MS })).toBe(
|
|
1542
|
+
'video_silent',
|
|
1543
|
+
);
|
|
1544
|
+
});
|
|
1545
|
+
|
|
1546
|
+
it('decides nothing from an element it could not read', () => {
|
|
1547
|
+
expect(streamHealth({ sample: null, msSinceAdvance: null })).toBeNull();
|
|
1548
|
+
});
|
|
1549
|
+
|
|
1550
|
+
it('is reversible — a recovered element goes back to healthy', () => {
|
|
1551
|
+
expect(streamHealth({ sample: DEAD_SAMPLE })).toBe('video_gone');
|
|
1552
|
+
expect(streamHealth({ sample: HEALTHY_SAMPLE, msSinceAdvance: 0 })).toBeNull();
|
|
1553
|
+
});
|
|
1554
|
+
});
|
|
1555
|
+
|
|
1556
|
+
describe('dmWorldStreamEndIsImmediate (§Q DM.66)', () => {
|
|
1557
|
+
it('lets ONLY the vendor-reported end be stated without confirmation', () => {
|
|
1558
|
+
// Everything else is inferred from this client's own view, and a single
|
|
1559
|
+
// sample at HAVE_NOTHING is a source swap or a rebuffer as often as it is
|
|
1560
|
+
// a dead stream. The confirm window is longer than the SDK's own 3 s.
|
|
1561
|
+
expect(dmWorldStreamEndIsImmediate('travel_completed')).toBe(true);
|
|
1562
|
+
for (const reason of DM_WORLD_STREAM_END_REASONS) {
|
|
1563
|
+
if (reason === 'travel_completed') continue;
|
|
1564
|
+
expect(dmWorldStreamEndIsImmediate(reason)).toBe(false);
|
|
1565
|
+
}
|
|
1566
|
+
expect(DM_WORLD_STREAM_DEAD_CONFIRM_MS).toBeGreaterThan(3_000);
|
|
1567
|
+
});
|
|
1568
|
+
});
|
|
1569
|
+
|
|
1570
|
+
describe('dmWorldStreamEndedNotice (§Q DM.66)', () => {
|
|
1571
|
+
it('never claims the world is live, and offers the way back in', () => {
|
|
1572
|
+
const notice = dmWorldStreamEndedNotice('video_gone', { canReenter: true });
|
|
1573
|
+
expect(notice.title).toBe(DM_WORLD_STREAM_ENDED_TITLE);
|
|
1574
|
+
// The pre-fix surface's claim, which this copy replaces.
|
|
1575
|
+
expect(`${notice.title} ${notice.detail}`).not.toContain(
|
|
1576
|
+
"You're in the world",
|
|
1577
|
+
);
|
|
1578
|
+
expect(notice.action).toBe(DM_WORLD_REENTER_ACTION);
|
|
1579
|
+
// Re-entry IS a reopen, so it carries DM.17's measured limit rather than a
|
|
1580
|
+
// second paraphrase of it.
|
|
1581
|
+
expect(notice.detail).toContain(DM_WORLD_REOPEN_NOTICE);
|
|
1582
|
+
});
|
|
1583
|
+
|
|
1584
|
+
it('offers no re-entry when there is no recorded world to go back to', () => {
|
|
1585
|
+
const notice = dmWorldStreamEndedNotice('travel_completed', {
|
|
1586
|
+
canReenter: false,
|
|
1587
|
+
});
|
|
1588
|
+
expect(notice.action).toBeNull();
|
|
1589
|
+
expect(notice.detail).not.toContain(DM_WORLD_REOPEN_NOTICE);
|
|
1590
|
+
// …and does not claim a permanence it has no handle to back up.
|
|
1591
|
+
expect(notice.detail).not.toContain('still recorded');
|
|
1592
|
+
expect(
|
|
1593
|
+
dmWorldStreamEndedNotice('travel_completed', { canReenter: true }).detail,
|
|
1594
|
+
).toContain('still recorded');
|
|
1595
|
+
});
|
|
1596
|
+
|
|
1597
|
+
it('says something specific for every reason it can be handed', () => {
|
|
1598
|
+
const details = DM_WORLD_STREAM_END_REASONS.map(
|
|
1599
|
+
(reason) => dmWorldStreamEndedNotice(reason, { canReenter: false }).detail,
|
|
1600
|
+
);
|
|
1601
|
+
expect(details.every((d) => d.length > 0)).toBe(true);
|
|
1602
|
+
expect(new Set(details).size).toBe(DM_WORLD_STREAM_END_REASONS.length);
|
|
1603
|
+
});
|
|
1604
|
+
});
|
|
1605
|
+
|
|
1606
|
+
describe('dmWorldReentryPlan (§Q DM.66)', () => {
|
|
1607
|
+
const handle = { encryptedWorldId: 'ew-dm-1', mode: 'adventure' as const };
|
|
1608
|
+
const basePlan = (action: DmWorldEntryPlan['action']): DmWorldEntryPlan => ({
|
|
1609
|
+
action,
|
|
1610
|
+
frame: frame(),
|
|
1611
|
+
mode: 'adventure',
|
|
1612
|
+
handle: action === 'reopen' || action === 'steer' ? handle : null,
|
|
1613
|
+
prompt: 'A drowned cathedral lit by green fire',
|
|
1614
|
+
seedImageUrl:
|
|
1615
|
+
action === 'reopen' || action === 'steer'
|
|
1616
|
+
? null
|
|
1617
|
+
: 'https://s3.example/frames/f-1.png',
|
|
1618
|
+
autoStopAfterMs: action === 'create' ? DM_WORLD_AUTO_STOP_MS_DEFAULT : null,
|
|
1619
|
+
});
|
|
1620
|
+
|
|
1621
|
+
it('⛔ NEVER mints a second billed world, whatever the plan it came from', () => {
|
|
1622
|
+
// THE KNOWN-BAD RE-ENTRY: "run the plan again". On a `create` plan that
|
|
1623
|
+
// charges for a new permanent world every time the vendor stops the stream.
|
|
1624
|
+
for (const action of [
|
|
1625
|
+
'create',
|
|
1626
|
+
'confirm_required',
|
|
1627
|
+
'reopen',
|
|
1628
|
+
'steer',
|
|
1629
|
+
] as const) {
|
|
1630
|
+
const reentry = dmWorldReentryPlan(basePlan(action), handle);
|
|
1631
|
+
expect(reentry).not.toBeNull();
|
|
1632
|
+
expect(reentry?.action).toBe('reopen');
|
|
1633
|
+
expect(dmWorldEntryWouldCreateWorld(reentry!.action)).toBe(false);
|
|
1634
|
+
}
|
|
1635
|
+
});
|
|
1636
|
+
|
|
1637
|
+
it('sends nothing a reopen does not carry', () => {
|
|
1638
|
+
const reentry = dmWorldReentryPlan(basePlan('create'), handle);
|
|
1639
|
+
expect(reentry?.handle).toBe(handle);
|
|
1640
|
+
expect(reentry?.prompt).toBe('');
|
|
1641
|
+
expect(reentry?.seedImageUrl).toBeNull();
|
|
1642
|
+
// A re-entry is an explicit player action; the auto-stop rail exists for
|
|
1643
|
+
// worlds the player did not ask for.
|
|
1644
|
+
expect(reentry?.autoStopAfterMs).toBeNull();
|
|
1645
|
+
});
|
|
1646
|
+
|
|
1647
|
+
it('returns nothing when no permanent world exists to reopen', () => {
|
|
1648
|
+
expect(dmWorldReentryPlan(basePlan('create'), null)).toBeNull();
|
|
1649
|
+
expect(dmWorldReentryPlan(null, handle)).toBeNull();
|
|
1650
|
+
});
|
|
1651
|
+
});
|
|
1652
|
+
|
|
1653
|
+
/**
|
|
1654
|
+
* §Q DM.73 — the board-read vocabulary and policy.
|
|
1655
|
+
*
|
|
1656
|
+
* THE KNOWN-BAD BUILD these guard: `GET /stories/{id}/storyboards` answered 429
|
|
1657
|
+
* in the 2026-08-03 GP.21 walk's mount burst, the host caught it and reported
|
|
1658
|
+
* nothing, and the pane rendered "This story has no ratified storyboard yet"
|
|
1659
|
+
* over a `succeeded`, 14/14 board. Every assertion below is about keeping a
|
|
1660
|
+
* FAILED read and an ABSENT board separable.
|
|
1661
|
+
*/
|
|
1662
|
+
describe('DM world board read (§Q DM.73)', () => {
|
|
1663
|
+
it('never renders a failed or pending read as the no-board claim', () => {
|
|
1664
|
+
// ⛔ THE ROW. `no_board` is the generic title, and it is the one thing a
|
|
1665
|
+
// read that did not land may never say.
|
|
1666
|
+
for (const status of ['loading', 'retrying', 'failed'] as const) {
|
|
1667
|
+
const block = dmWorldBoardBlock(status);
|
|
1668
|
+
expect(block).not.toBeNull();
|
|
1669
|
+
expect(block?.title).not.toBe(DM_WORLD_ENTRY_NO_BOARD_TITLE);
|
|
1670
|
+
expect(dmWorldEntryBlockIsBoardRead(block!.reason)).toBe(true);
|
|
1671
|
+
}
|
|
1672
|
+
// The failed message must state UNKNOWN, not absence.
|
|
1673
|
+
expect(DM_WORLD_BOARD_READ_FAILED_MESSAGE).toMatch(/unknown/i);
|
|
1674
|
+
expect(DM_WORLD_BOARD_READ_FAILED_MESSAGE).not.toMatch(/has no (ratified )?storyboard/i);
|
|
1675
|
+
});
|
|
1676
|
+
|
|
1677
|
+
it('speaks only for the statuses that carry a claim of their own', () => {
|
|
1678
|
+
// `loaded` hands the decision to the planner; `absent` is the ONE status
|
|
1679
|
+
// that genuinely means no board, and it keeps the generic rendering.
|
|
1680
|
+
expect(dmWorldBoardBlock('loaded')).toBeNull();
|
|
1681
|
+
expect(dmWorldBoardBlock('absent')).toBeNull();
|
|
1682
|
+
expect(DM_WORLD_BOARD_READ_STATUSES).toHaveLength(5);
|
|
1683
|
+
});
|
|
1684
|
+
|
|
1685
|
+
it('offers a retry for the failed read and for nothing else', () => {
|
|
1686
|
+
expect(dmWorldEntryBlockIsRetryable('board_read_failed')).toBe(true);
|
|
1687
|
+
expect(dmWorldBoardBlock('failed')?.recourse).not.toBeNull();
|
|
1688
|
+
// A retry label on a block that resolves elsewhere would be a control that
|
|
1689
|
+
// does nothing — and on `no_active_beat` it would REPLACE the exit label
|
|
1690
|
+
// DM.61(a) put there.
|
|
1691
|
+
for (const reason of [
|
|
1692
|
+
'board_read_pending',
|
|
1693
|
+
'no_active_beat',
|
|
1694
|
+
'no_frame_for_beat',
|
|
1695
|
+
'frame_render_failed',
|
|
1696
|
+
null,
|
|
1697
|
+
] as const) {
|
|
1698
|
+
expect(dmWorldEntryBlockIsRetryable(reason)).toBe(false);
|
|
1699
|
+
}
|
|
1700
|
+
expect(dmWorldEntryBlockIsBoardRead('no_frame_for_beat')).toBe(false);
|
|
1701
|
+
expect(dmWorldEntryBlockIsBoardRead(null)).toBe(false);
|
|
1702
|
+
});
|
|
1703
|
+
|
|
1704
|
+
// §Q DM.76 — IN FLIGHT is not the same claim as SETTLED, and a surface has to
|
|
1705
|
+
// be able to tell a reader which one it is showing.
|
|
1706
|
+
it('separates the IN-FLIGHT read from every settled block', () => {
|
|
1707
|
+
expect(dmWorldEntryBlockIsPending('board_read_pending')).toBe(true);
|
|
1708
|
+
// `retrying` is still the pending claim — an attempt is scheduled, nothing
|
|
1709
|
+
// has been decided — so both in-flight statuses map to the pending reason.
|
|
1710
|
+
for (const status of ['loading', 'retrying'] as const) {
|
|
1711
|
+
expect(dmWorldEntryBlockIsPending(dmWorldBoardBlock(status)!.reason)).toBe(true);
|
|
1712
|
+
}
|
|
1713
|
+
// ⛔ THE OTHER DIRECTION IS THE HALF THAT MATTERS. A failed read IS settled
|
|
1714
|
+
// — it is the end of this session's attempts, with its own retry control —
|
|
1715
|
+
// so a harness racing terminal states must still see it terminate. Widening
|
|
1716
|
+
// "pending" to cover it would trade DM.76's false FAIL for an infinite wait.
|
|
1717
|
+
for (const reason of [
|
|
1718
|
+
'board_read_failed',
|
|
1719
|
+
'no_active_beat',
|
|
1720
|
+
'no_frame_for_beat',
|
|
1721
|
+
'frame_not_rendered',
|
|
1722
|
+
'frame_render_failed',
|
|
1723
|
+
'prompt_unavailable',
|
|
1724
|
+
'prompt_invalid',
|
|
1725
|
+
'world_mode_mismatch',
|
|
1726
|
+
null,
|
|
1727
|
+
] as const) {
|
|
1728
|
+
expect(dmWorldEntryBlockIsPending(reason)).toBe(false);
|
|
1729
|
+
}
|
|
1730
|
+
});
|
|
1731
|
+
|
|
1732
|
+
it('retries a rate limit and a server fault, and answers a 404 once', () => {
|
|
1733
|
+
expect(isRetryableBoardReadStatus(429)).toBe(true);
|
|
1734
|
+
expect(isRetryableBoardReadStatus(500)).toBe(true);
|
|
1735
|
+
expect(isRetryableBoardReadStatus(503)).toBe(true);
|
|
1736
|
+
// No response at all — a transport failure says nothing about the board.
|
|
1737
|
+
expect(isRetryableBoardReadStatus(undefined)).toBe(true);
|
|
1738
|
+
expect(isRetryableBoardReadStatus(null)).toBe(true);
|
|
1739
|
+
// Answers, not faults: retrying spends the schedule to be told the same.
|
|
1740
|
+
expect(isRetryableBoardReadStatus(404)).toBe(false);
|
|
1741
|
+
expect(isRetryableBoardReadStatus(403)).toBe(false);
|
|
1742
|
+
expect(isRetryableBoardReadStatus(400)).toBe(false);
|
|
1743
|
+
});
|
|
1744
|
+
|
|
1745
|
+
it('reads the status off a thrown error the way http.ts writes it', () => {
|
|
1746
|
+
const throttled = Object.assign(new Error('HTTP 429'), { status: 429 });
|
|
1747
|
+
const missing = Object.assign(new Error('HTTP 404'), { status: 404 });
|
|
1748
|
+
expect(dmWorldBoardReadIsRetryable(throttled)).toBe(true);
|
|
1749
|
+
expect(dmWorldBoardReadIsRetryable(missing)).toBe(false);
|
|
1750
|
+
// A bare network error carries no status and is retryable.
|
|
1751
|
+
expect(dmWorldBoardReadIsRetryable(new Error('Failed to fetch'))).toBe(true);
|
|
1752
|
+
expect(dmWorldBoardReadIsRetryable('not an error')).toBe(true);
|
|
1753
|
+
});
|
|
1754
|
+
|
|
1755
|
+
it('schedules exactly one retry per attempt left, then stops', () => {
|
|
1756
|
+
expect(DM_WORLD_BOARD_READ_RETRY_DELAYS_MS).toHaveLength(
|
|
1757
|
+
DM_WORLD_BOARD_READ_MAX_ATTEMPTS - 1,
|
|
1758
|
+
);
|
|
1759
|
+
expect(dmWorldBoardReadRetryDelayMs(1)).toBe(
|
|
1760
|
+
DM_WORLD_BOARD_READ_RETRY_DELAYS_MS[0],
|
|
1761
|
+
);
|
|
1762
|
+
expect(dmWorldBoardReadRetryDelayMs(2)).toBe(
|
|
1763
|
+
DM_WORLD_BOARD_READ_RETRY_DELAYS_MS[1],
|
|
1764
|
+
);
|
|
1765
|
+
// The ceiling: attempt 3 of 3 has nothing after it.
|
|
1766
|
+
expect(dmWorldBoardReadRetryDelayMs(DM_WORLD_BOARD_READ_MAX_ATTEMPTS)).toBeNull();
|
|
1767
|
+
expect(dmWorldBoardReadRetryDelayMs(99)).toBeNull();
|
|
1768
|
+
expect(dmWorldBoardReadRetryDelayMs(0)).toBeNull();
|
|
1769
|
+
// Backed off, because the 429 came from a burst this read is part of.
|
|
1770
|
+
expect(DM_WORLD_BOARD_READ_RETRY_DELAYS_MS[1]).toBeGreaterThan(
|
|
1771
|
+
DM_WORLD_BOARD_READ_RETRY_DELAYS_MS[0]!,
|
|
1772
|
+
);
|
|
1773
|
+
});
|
|
1774
|
+
});
|
|
1775
|
+
|
|
1776
|
+
describe('dmWorldReopenDecision (§Q WORLD.1-A — the shared reopen guard)', () => {
|
|
1777
|
+
const boundFrame = frame({ frameId: 'f-bound', worldId: 'ew-bound', worldMode: 'adventure' });
|
|
1778
|
+
const record: DmWorldRecord = {
|
|
1779
|
+
worldId: 'ew-bound',
|
|
1780
|
+
mode: 'adventure',
|
|
1781
|
+
frameId: 'f-bound',
|
|
1782
|
+
beatId: 'beat-2',
|
|
1783
|
+
source: 'frame',
|
|
1784
|
+
trigger: null,
|
|
1785
|
+
openedAt: null,
|
|
1786
|
+
};
|
|
1787
|
+
const planFor = (frames: StoryboardFrame[], activeBeatId: string | null) =>
|
|
1788
|
+
planDmWorldEntry({
|
|
1789
|
+
frameIds: frames.map((f) => f.frameId),
|
|
1790
|
+
frames,
|
|
1791
|
+
activeBeatId,
|
|
1792
|
+
mode: 'adventure',
|
|
1793
|
+
});
|
|
1794
|
+
|
|
1795
|
+
it('authorises a reopen OF THE CLICKED WORLD', () => {
|
|
1796
|
+
const decision = dmWorldReopenDecision(record, planFor([boundFrame], 'beat-2'));
|
|
1797
|
+
expect(decision.blocked).toBeNull();
|
|
1798
|
+
expect(decision.plan?.action).toBe('reopen');
|
|
1799
|
+
expect(decision.plan?.handle?.encryptedWorldId).toBe('ew-bound');
|
|
1800
|
+
});
|
|
1801
|
+
|
|
1802
|
+
it('REFUSES when the beat resolves to a frame owning a DIFFERENT world', () => {
|
|
1803
|
+
// The reachable case the guard exists for: two frames carry the same beat
|
|
1804
|
+
// and `resolveDmWorldEntryFrame` prefers the RENDERED one, so the click can
|
|
1805
|
+
// land on a plan for someone else's paid asset.
|
|
1806
|
+
const other = frame({ frameId: 'f-other', worldId: 'ew-other', worldMode: 'adventure' });
|
|
1807
|
+
const decision = dmWorldReopenDecision(record, planFor([other], 'beat-2'));
|
|
1808
|
+
expect(decision.plan).toBeNull();
|
|
1809
|
+
expect(decision.blocked?.message).toBe(DM_WORLD_REOPEN_UNRESOLVED_MESSAGE);
|
|
1810
|
+
});
|
|
1811
|
+
|
|
1812
|
+
it('REFUSES a plan that would CREATE — a reopen button must never mint a world', () => {
|
|
1813
|
+
// The frame the beat resolves to owns NO world, so the planner authorises a
|
|
1814
|
+
// creation. (This arm is caught by the HANDLE clause, not the action one: a
|
|
1815
|
+
// create plan carries `handle: null`. Recorded that way rather than
|
|
1816
|
+
// attributed to the wrong clause.)
|
|
1817
|
+
const unbound = frame({ frameId: 'f-unbound' });
|
|
1818
|
+
const planned = planFor([unbound], 'beat-2');
|
|
1819
|
+
expect(planned.ok && planned.plan.action).toBe('confirm_required');
|
|
1820
|
+
const decision = dmWorldReopenDecision(record, planned);
|
|
1821
|
+
expect(decision.plan).toBeNull();
|
|
1822
|
+
expect(decision.blocked?.message).toBe(DM_WORLD_REOPEN_UNRESOLVED_MESSAGE);
|
|
1823
|
+
});
|
|
1824
|
+
|
|
1825
|
+
it('REFUSES a STEER plan for the same world — this is what the ACTION clause is for', () => {
|
|
1826
|
+
// The one case the handle clause CANNOT catch, and the reason the guard has
|
|
1827
|
+
// two conditions: a live world on an unchanged scene plans to `'steer'` and
|
|
1828
|
+
// carries THAT WORLD'S OWN handle, so the ids match. `launchDmWorldEntry`
|
|
1829
|
+
// throws on a steer plan by design ("a steer re-aims the live world through
|
|
1830
|
+
// the pane"), so admitting it here would turn a reopen click into an error.
|
|
1831
|
+
const planned = planDmWorldEntry({
|
|
1832
|
+
frameIds: [boundFrame.frameId],
|
|
1833
|
+
frames: [boundFrame],
|
|
1834
|
+
activeBeatId: 'beat-2',
|
|
1835
|
+
mode: 'adventure',
|
|
1836
|
+
liveWorld: {
|
|
1837
|
+
handle: { encryptedWorldId: 'ew-bound', mode: 'adventure' },
|
|
1838
|
+
frameId: 'f-bound',
|
|
1839
|
+
},
|
|
1840
|
+
});
|
|
1841
|
+
expect(planned.ok && planned.plan.action).toBe('steer');
|
|
1842
|
+
expect(planned.ok && planned.plan.handle?.encryptedWorldId).toBe(record.worldId);
|
|
1843
|
+
const decision = dmWorldReopenDecision(record, planned);
|
|
1844
|
+
expect(decision.plan).toBeNull();
|
|
1845
|
+
expect(decision.blocked?.message).toBe(DM_WORLD_REOPEN_UNRESOLVED_MESSAGE);
|
|
1846
|
+
});
|
|
1847
|
+
|
|
1848
|
+
it("carries the PLANNER's own refusal through, rather than replacing it", () => {
|
|
1849
|
+
// A cross-mode binding is the refusal a surface most needs to render
|
|
1850
|
+
// verbatim: it can never resolve here, and DM.30 exists because a bare id
|
|
1851
|
+
// reached the vendor and came back `[MODE_MISMATCH]` on a paid handle.
|
|
1852
|
+
const otherMode = frame({
|
|
1853
|
+
frameId: 'f-bound',
|
|
1854
|
+
worldId: 'ew-bound',
|
|
1855
|
+
worldMode: 'directing',
|
|
1856
|
+
});
|
|
1857
|
+
const decision = dmWorldReopenDecision(record, planFor([otherMode], 'beat-2'));
|
|
1858
|
+
expect(decision.plan).toBeNull();
|
|
1859
|
+
expect(decision.blocked?.reason).toBe('world_mode_mismatch');
|
|
1860
|
+
expect(decision.blocked?.message).toContain('directing');
|
|
1861
|
+
});
|
|
1862
|
+
|
|
1863
|
+
it('treats "the host never reached the planner" as a refusal, not a licence', () => {
|
|
1864
|
+
const decision = dmWorldReopenDecision(record, null);
|
|
1865
|
+
expect(decision.plan).toBeNull();
|
|
1866
|
+
expect(decision.blocked?.message).toBe(DM_WORLD_REOPEN_UNRESOLVED_MESSAGE);
|
|
1867
|
+
});
|
|
1868
|
+
});
|
|
1869
|
+
|
|
1870
|
+
describe('the world-not-chosen host block (§Q WORLD.1-A)', () => {
|
|
1871
|
+
it('has its own headline and a way out — it is not the no-board claim', () => {
|
|
1872
|
+
const block = dmWorldEntryBlock('world_not_chosen', DM_WORLD_NOT_CHOSEN_MESSAGE);
|
|
1873
|
+
expect(block.title).not.toBe(DM_WORLD_ENTRY_NO_BOARD_TITLE);
|
|
1874
|
+
expect(block.recourse).not.toBeNull();
|
|
1875
|
+
// It is SETTLED, not in flight, and it is not a read failure — a surface
|
|
1876
|
+
// must not offer a "try again" that retries nothing.
|
|
1877
|
+
expect(dmWorldEntryBlockIsPending('world_not_chosen')).toBe(false);
|
|
1878
|
+
expect(dmWorldEntryBlockIsRetryable('world_not_chosen')).toBe(false);
|
|
1879
|
+
expect(dmWorldEntryBlockIsBoardRead('world_not_chosen')).toBe(false);
|
|
1880
|
+
});
|
|
1881
|
+
});
|
|
1882
|
+
|
|
1883
|
+
describe('DM_WORLD_MODE (§Q WORLD.1-A)', () => {
|
|
1884
|
+
it('is the mode a frame-bound world can actually be reopened from', () => {
|
|
1885
|
+
// The two player surfaces read this ONE constant precisely so a viewer
|
|
1886
|
+
// cannot plan against a mode the episode did not create on: that pairing is
|
|
1887
|
+
// what `planDmWorldEntry` refuses with `world_mode_mismatch`.
|
|
1888
|
+
const bound = frame({ frameId: 'f-bound', worldId: 'ew-bound', worldMode: DM_WORLD_MODE });
|
|
1889
|
+
const planned = planDmWorldEntry({
|
|
1890
|
+
frameIds: ['f-bound'],
|
|
1891
|
+
frames: [bound],
|
|
1892
|
+
activeBeatId: 'beat-2',
|
|
1893
|
+
mode: DM_WORLD_MODE,
|
|
1894
|
+
});
|
|
1895
|
+
expect(planned.ok && planned.plan.action).toBe('reopen');
|
|
1896
|
+
});
|
|
1897
|
+
});
|
|
1898
|
+
|
|
1899
|
+
describe('summarizeDmWorldPreparation (§Q MOMENT.6b)', () => {
|
|
1900
|
+
it('counts BEATS, not frames — a fully prepared board is not "half done"', () => {
|
|
1901
|
+
// Two frames on one beat, one world. Play-time entry joins on the BEAT, so
|
|
1902
|
+
// this beat IS prepared; a frame-grain count would report it 50% done.
|
|
1903
|
+
const a = frame({ frameId: 'f-a', beatId: 'beat-1', worldId: 'ew-1' });
|
|
1904
|
+
const b = frame({ frameId: 'f-b', beatId: 'beat-1' });
|
|
1905
|
+
expect(
|
|
1906
|
+
summarizeDmWorldPreparation({ frameIds: ['f-a', 'f-b'], frames: [a, b] }),
|
|
1907
|
+
).toEqual({ preparedBeats: 1, totalBeats: 1, label: '1 of 1 prepared' });
|
|
1908
|
+
});
|
|
1909
|
+
|
|
1910
|
+
it('counts a beat prepared only when its ANCHOR frame owns the world', () => {
|
|
1911
|
+
// KNOWN-BAD: "any frame on this beat has a worldId" would report this beat
|
|
1912
|
+
// prepared, and entry would then cold-build — the anchor is f-a (first in
|
|
1913
|
+
// board order, rendered) and it owns nothing. The label would be a lie
|
|
1914
|
+
// about the 105-240s this row exists to remove.
|
|
1915
|
+
const anchor = frame({ frameId: 'f-a', beatId: 'beat-1' });
|
|
1916
|
+
const other = frame({ frameId: 'f-b', beatId: 'beat-1', worldId: 'ew-1' });
|
|
1917
|
+
expect(
|
|
1918
|
+
summarizeDmWorldPreparation({
|
|
1919
|
+
frameIds: ['f-a', 'f-b'],
|
|
1920
|
+
frames: [anchor, other],
|
|
1921
|
+
}).preparedBeats,
|
|
1922
|
+
).toBe(0);
|
|
1923
|
+
});
|
|
1924
|
+
|
|
1925
|
+
it('ignores frames with no beat — they are not entry points', () => {
|
|
1926
|
+
const bound = frame({ frameId: 'f-a', beatId: 'beat-1', worldId: 'ew-1' });
|
|
1927
|
+
const loose = frame({ frameId: 'f-b', beatId: null });
|
|
1928
|
+
expect(
|
|
1929
|
+
summarizeDmWorldPreparation({
|
|
1930
|
+
frameIds: ['f-a', 'f-b'],
|
|
1931
|
+
frames: [bound, loose],
|
|
1932
|
+
}),
|
|
1933
|
+
).toEqual({ preparedBeats: 1, totalBeats: 1, label: '1 of 1 prepared' });
|
|
1934
|
+
});
|
|
1935
|
+
|
|
1936
|
+
it('reports an unprepared board honestly', () => {
|
|
1937
|
+
const a = frame({ frameId: 'f-a', beatId: 'beat-1' });
|
|
1938
|
+
const b = frame({ frameId: 'f-b', beatId: 'beat-2' });
|
|
1939
|
+
expect(
|
|
1940
|
+
summarizeDmWorldPreparation({ frameIds: ['f-a', 'f-b'], frames: [a, b] }).label,
|
|
1941
|
+
).toBe('0 of 2 prepared');
|
|
1942
|
+
});
|
|
1943
|
+
});
|
|
1944
|
+
|
|
1945
|
+
describe('collectDmWorldRecords + supersede ledger (§Q MOMENT.8)', () => {
|
|
1946
|
+
it('lists a superseded world — it is permanent, billed and unlistable', () => {
|
|
1947
|
+
// KNOWN-BAD `MOMENT8-supersede-orphans-nothing` grades: dropping the old id
|
|
1948
|
+
// on replacement. HappyOyster exposes no delete and no list, so the row IS
|
|
1949
|
+
// the only remaining route back to a paid asset.
|
|
1950
|
+
const bound = frame({
|
|
1951
|
+
frameId: 'f-a',
|
|
1952
|
+
beatId: 'beat-1',
|
|
1953
|
+
worldId: 'ew-new',
|
|
1954
|
+
worldMode: 'adventure',
|
|
1955
|
+
supersededWorldIds: ['ew-old'],
|
|
1956
|
+
});
|
|
1957
|
+
const records = collectDmWorldRecords({ frameIds: ['f-a'], frames: [bound] });
|
|
1958
|
+
expect(records.map(r => [r.worldId, r.source])).toEqual([
|
|
1959
|
+
['ew-new', 'frame'],
|
|
1960
|
+
['ew-old', 'superseded'],
|
|
1961
|
+
]);
|
|
1962
|
+
});
|
|
1963
|
+
|
|
1964
|
+
it('never assumes a superseded world mode from the world that replaced it', () => {
|
|
1965
|
+
// Substituting the current mode here re-creates the `[MODE_MISMATCH]` bug
|
|
1966
|
+
// DM.30 fixed — after the money is spent.
|
|
1967
|
+
const bound = frame({
|
|
1968
|
+
frameId: 'f-a',
|
|
1969
|
+
worldId: 'ew-new',
|
|
1970
|
+
worldMode: 'adventure',
|
|
1971
|
+
supersededWorldIds: ['ew-old'],
|
|
1972
|
+
});
|
|
1973
|
+
const superseded = collectDmWorldRecords({
|
|
1974
|
+
frameIds: ['f-a'],
|
|
1975
|
+
frames: [bound],
|
|
1976
|
+
}).find(r => r.worldId === 'ew-old');
|
|
1977
|
+
expect(superseded?.mode).toBeNull();
|
|
1978
|
+
});
|
|
1979
|
+
|
|
1980
|
+
it('does not demote a world that is CURRENT on another frame', () => {
|
|
1981
|
+
const current = frame({ frameId: 'f-a', worldId: 'ew-shared' });
|
|
1982
|
+
const historic = frame({
|
|
1983
|
+
frameId: 'f-b',
|
|
1984
|
+
worldId: 'ew-other',
|
|
1985
|
+
supersededWorldIds: ['ew-shared'],
|
|
1986
|
+
});
|
|
1987
|
+
const records = collectDmWorldRecords({
|
|
1988
|
+
frameIds: ['f-a', 'f-b'],
|
|
1989
|
+
frames: [current, historic],
|
|
1990
|
+
});
|
|
1991
|
+
expect(records.find(r => r.worldId === 'ew-shared')?.source).toBe('frame');
|
|
1992
|
+
});
|
|
1993
|
+
|
|
1994
|
+
it('treats an absent ledger as never-superseded', () => {
|
|
1995
|
+
const bound = frame({ frameId: 'f-a', worldId: 'ew-1' });
|
|
1996
|
+
expect(collectDmWorldRecords({ frameIds: ['f-a'], frames: [bound] })).toHaveLength(1);
|
|
1997
|
+
});
|
|
1998
|
+
});
|
|
1999
|
+
|
|
2000
|
+
// ---------------------------------------------------------------------------
|
|
2001
|
+
// §Q DM.67 — A CONTENT-REFUSED BEAT OFFERS THE BEATS THAT CAN STILL OPEN
|
|
2002
|
+
// ---------------------------------------------------------------------------
|
|
2003
|
+
//
|
|
2004
|
+
// The recorded shape (checkpoint-3, 2026-08-02): beat 1 refused
|
|
2005
|
+
// `content_rejected [403004]`, beat 2 opened and played. The pane's card had no
|
|
2006
|
+
// control at all. These pin the decision the card is built from.
|
|
2007
|
+
describe('dmWorldContentRefusalRoutes (§Q DM.67)', () => {
|
|
2008
|
+
const refused = frame({ frameId: 'f-1', beatId: 'beat-1' });
|
|
2009
|
+
const drawn = frame({ frameId: 'f-2', beatId: 'beat-2' });
|
|
2010
|
+
const owned = frame({
|
|
2011
|
+
frameId: 'f-3',
|
|
2012
|
+
beatId: 'beat-3',
|
|
2013
|
+
worldId: 'ew-3',
|
|
2014
|
+
worldMode: 'adventure',
|
|
2015
|
+
});
|
|
2016
|
+
const undrawn = frame({
|
|
2017
|
+
frameId: 'f-4',
|
|
2018
|
+
beatId: 'beat-4',
|
|
2019
|
+
status: 'pending',
|
|
2020
|
+
variants: [],
|
|
2021
|
+
});
|
|
2022
|
+
const board = {
|
|
2023
|
+
frameIds: ['f-1', 'f-2', 'f-3', 'f-4'],
|
|
2024
|
+
frames: [refused, drawn, owned, undrawn],
|
|
2025
|
+
};
|
|
2026
|
+
|
|
2027
|
+
it('classifies ONLY the vendor content refusal as one that has other routes', () => {
|
|
2028
|
+
expect(dmWorldLaunchIsContentRefusal('content_rejected')).toBe(true);
|
|
2029
|
+
for (const other of ['unknown', 'traveling', 'invalid_request', 'not_ready', null, undefined]) {
|
|
2030
|
+
expect(dmWorldLaunchIsContentRefusal(other)).toBe(false);
|
|
2031
|
+
}
|
|
2032
|
+
});
|
|
2033
|
+
|
|
2034
|
+
it('offers every other enterable beat, reopens first, never the refused one', () => {
|
|
2035
|
+
const routes = dmWorldContentRefusalRoutes({
|
|
2036
|
+
...board,
|
|
2037
|
+
mode: DM_WORLD_MODE,
|
|
2038
|
+
refusedBeatIds: ['beat-1'],
|
|
2039
|
+
});
|
|
2040
|
+
expect(routes.map(r => r.beatId)).toEqual(['beat-3', 'beat-2']);
|
|
2041
|
+
expect(routes.map(r => r.action)).toEqual(['reopen', 'confirm_required']);
|
|
2042
|
+
expect(routes.map(r => r.frameId)).toEqual(['f-3', 'f-2']);
|
|
2043
|
+
expect(routes[0].hint).toBe(DM_WORLD_REFUSAL_ROUTE_REOPEN_HINT);
|
|
2044
|
+
expect(routes[1].hint).toBe(DM_WORLD_REFUSAL_ROUTE_BUILD_HINT);
|
|
2045
|
+
});
|
|
2046
|
+
|
|
2047
|
+
it('never offers a beat the planner would refuse (undrawn frame, other-mode world)', () => {
|
|
2048
|
+
const otherMode = frame({
|
|
2049
|
+
frameId: 'f-5',
|
|
2050
|
+
beatId: 'beat-5',
|
|
2051
|
+
worldId: 'ew-5',
|
|
2052
|
+
worldMode: 'directing',
|
|
2053
|
+
});
|
|
2054
|
+
const routes = dmWorldContentRefusalRoutes({
|
|
2055
|
+
frameIds: ['f-1', 'f-4', 'f-5'],
|
|
2056
|
+
frames: [refused, undrawn, otherMode],
|
|
2057
|
+
mode: DM_WORLD_MODE,
|
|
2058
|
+
refusedBeatIds: ['beat-1'],
|
|
2059
|
+
});
|
|
2060
|
+
expect(routes).toEqual([]);
|
|
2061
|
+
});
|
|
2062
|
+
|
|
2063
|
+
it('a route that would mint a world still asks first — no auto-fire on a recovery', () => {
|
|
2064
|
+
const routes = dmWorldContentRefusalRoutes({
|
|
2065
|
+
...board,
|
|
2066
|
+
mode: DM_WORLD_MODE,
|
|
2067
|
+
refusedBeatIds: ['beat-1', 'beat-3'],
|
|
2068
|
+
});
|
|
2069
|
+
expect(routes).toHaveLength(1);
|
|
2070
|
+
expect(routes[0].action).toBe('confirm_required');
|
|
2071
|
+
});
|
|
2072
|
+
|
|
2073
|
+
it('drops EVERY beat refused so far, so a second refusal does not loop back', () => {
|
|
2074
|
+
expect(
|
|
2075
|
+
dmWorldContentRefusalRoutes({
|
|
2076
|
+
...board,
|
|
2077
|
+
mode: DM_WORLD_MODE,
|
|
2078
|
+
refusedBeatIds: ['beat-1', 'beat-2', 'beat-3'],
|
|
2079
|
+
}),
|
|
2080
|
+
).toEqual([]);
|
|
2081
|
+
});
|
|
2082
|
+
|
|
2083
|
+
it('labels a route from the story graph, and degrades to the raw id without one', () => {
|
|
2084
|
+
const beatById = new Map([
|
|
2085
|
+
['beat-2', { beatId: 'beat-2', label: 'the vault', order: 1 }],
|
|
2086
|
+
]) as unknown as Parameters<typeof dmWorldContentRefusalRoutes>[0]['beatById'];
|
|
2087
|
+
const routes = dmWorldContentRefusalRoutes({
|
|
2088
|
+
...board,
|
|
2089
|
+
mode: DM_WORLD_MODE,
|
|
2090
|
+
refusedBeatIds: ['beat-1'],
|
|
2091
|
+
beatById,
|
|
2092
|
+
});
|
|
2093
|
+
expect(routes.find(r => r.beatId === 'beat-2')?.label).toBe('Beat 2 — the vault');
|
|
2094
|
+
expect(routes.find(r => r.beatId === 'beat-3')?.label).toBe('Beat beat-3');
|
|
2095
|
+
});
|
|
2096
|
+
|
|
2097
|
+
it('names the per-beat refusal in its copy, with or without routes', () => {
|
|
2098
|
+
expect(DM_WORLD_CONTENT_REFUSAL_ROUTES_LEAD).toMatch(/content grounds/);
|
|
2099
|
+
expect(DM_WORLD_CONTENT_REFUSAL_ROUTES_LEAD).toMatch(/another beat/);
|
|
2100
|
+
expect(DM_WORLD_CONTENT_REFUSAL_NO_ROUTE).toMatch(/no other beat/);
|
|
2101
|
+
});
|
|
2102
|
+
});
|