Runtime Architecture

View as Markdown

The current UE plugin mirrors the architecture of @forbocai/core and @forbocai/node: a central store, pure slice reducers/selectors, and thunk-based side effects.

Root State

1struct FSDKState {
2 NPCSlice::FNPCSliceState NPCs;
3 MemorySlice::FMemorySliceState Memory;
4 DirectiveSlice::FDirectiveSliceState Directives;
5 BridgeSlice::FBridgeSliceState Bridge;
6 CortexSlice::FCortexSliceState Cortex;
7 SoulSlice::FSoulSliceState Soul;
8 GhostSlice::FGhostSliceState Ghost;
9 APISlice::FAPIState API;
10};

Create a store with:

1auto Store = createSDKStore();

Use ConfigureSDKStore() only when you explicitly want the plugin’s shared helper-layer store.

Pure And Impure Boundaries

Pure pieces

  • slice reducers
  • slice action creators
  • selectors
  • entity adapter updates
  • JSON state-delta merge logic in NPCSlice

Impure pieces

  • API calls in APISlice
  • local llama.cpp model load/inference
  • local SQLite memory access
  • Arweave upload/download helpers
  • commandlet and Blueprint wrapper layers

The impure work is isolated in thunks, just as it is in the TypeScript SDKs.

Middleware

createNpcRemovalListener() is the main cross-slice listener in RuntimeStore.h.

When an NPC is removed, it clears:

  • directives for that NPC
  • bridge validation state
  • ghost session state
  • soul slice state
  • NPC block state
  • memory state if the removed NPC was the active NPC

This is the UE equivalent of the coordinated cleanup behavior in the core SDK.

Thunks First, Wrappers Second

Direct thunk usage is the canonical runtime model:

1#include "Protocol/ProtocolThunks.h"
2#include "Memory/MemoryThunks.h"
3#include "Cortex/CortexThunks.h"
4#include "Bridge/BridgeThunks.h"
5#include "Soul/SoulThunks.h"
6#include "Ghost/GhostThunks.h"

SDKOps::* in CLI/CliOperations.h does not implement a separate system. It dispatches those same thunks and blocks on the resulting func::AsyncResult<T>.

Functional Core Utilities

The plugin still uses functional_core.hpp, but now as support infrastructure for the store/thunk runtime rather than as a separate end-user API surface.

Key types used throughout the runtime:

  • func::Maybe<T>
  • func::Either<L, R>
  • func::AsyncResult<T>
  • func::TestResult<T>
  • func::ValidationPipeline<I, O>

See Functional Core for the helper-layer details.