KBEngine Adapter Implementation Design
Goals
The first Engine Bot Backend targets KBEngine, because:
- It already has native Bots.
- The boundary between the C++ network runtime and Python behavior scripts is clear.
- Existing bot connection and protocol implementations can be reused first.
- It has a Python scripting extension entry point, suitable for implementing the Bridge.
- The C++ client_lib does not need to be linked into the Rust Worker.
Target Deployment Shape
Host
├── wavemaker-controller
└── wavemaker-supervisor
├── KBEngine Bots Process A
│ ├── KBEngine C++ Runtime
│ └── Python Bridge
└── KBEngine Bots Process B
├── KBEngine C++ Runtime
└── Python BridgeThe first version does not require Docker. The Supervisor launches the bot binary with a local process launcher. A ContainerProcessLauncher can be added later.
Python Bridge Modules
Suggested logical files:
engine-adapters/kbengine/
├── bridge/
│ ├── __init__.py
│ ├── bootstrap.py
│ ├── client.py
│ ├── command_queue.py
│ ├── event_collector.py
│ ├── metrics_collector.py
│ ├── bot_registry.py
│ ├── capability.py
│ └── protocol/
├── supervisor/
│ ├── process_spec.rs
│ ├── launcher.rs
│ ├── health.rs
│ └── adapter.rs
├── tests/
│ ├── protocol_conformance/
│ ├── integration/
│ └── failure/
└── README.mdThis layout is a suggestion; Python code and Rust code are not required to live in the same language build system.
KBEngine Bridge Lifecycle
- KBEngine Bots starts.
- The engine loads the Bridge bootstrap.
- The Bridge reads the IPC address, token, Swell ID, and Backend ID injected by the Supervisor.
- The Bridge establishes the IPC connection.
- It sends Handshake.
- The Supervisor validates version and capabilities.
- The Controller sends Initialize.
- The Supervisor forwards plans and start commands.
- The Bridge enqueues commands into the engine callback context.
- The Bridge collects bot states, events, and metrics.
- When the Swell ends, StopAdmission runs first.
- Existing bots are drained or awaited according to the DrainPolicy.
- The Bridge sends final state and metrics.
- IPC disconnects and the process exits according to policy.
KBEngine API Verification Checklist
The interfaces below are leads mentioned in ADRs and existing discussions; their semantics must not be inferred from names alone. Source code and runtime behavior must be checked against the version actually in use:
| API / Mechanism | Questions to verify |
|---|---|
KBEngine.addBots() | Parameter meaning, creation pacing, return value, failure callbacks, maximum batch size |
KBEngine.bots | Container type, update timing, stability of bot identity |
KBEngine.callback() | Callback granularity, thread context, maximum lag, exception behavior |
KBEngine.cancelCallback() | Cancellation races and callback handle lifecycle |
onInit() | When the Bridge is initialized, behavior on repeated calls |
onFinish() | Whether it is guaranteed to run on exit, whether asynchronous teardown can be awaited |
| Bot script callbacks | Login success, failure, disconnection, reconnection, and entity state events |
| Process exit | Whether a graceful exit API exists, whether exit codes are reliable |
| Configuration injection | How Swell, Backend, IPC, and authentication parameters are passed |
No Unverified Capability Claims
For example:
destroy_individualreturnsUnknownuntil verified.exact_arrivalshould be declaredUnsupported— orDegradedwith the actual precision — if bots can only be created in callback batches.- If only the total bot count is available and not the logged-in count, the total must not be presented as online users.
- If per-bot latency cannot be obtained, per-bot latency must not be derived from process-level latency.
Mode A / Mode B / Mode C
The original ADR access modes should be kept, but unified under the Backend model.
- Mode A: engine-managed bots. Wavemaker controls and observes native bots through the Bridge.
- Mode B: Wavemaker manages the executor but reuses some client capabilities provided by the engine. The exact boundary follows the existing architecture definition; ownership of sockets must not be assumed.
- Mode C: Wavemaker's Native Runtime owns connections and protocol execution itself.
The three modes are not different compile options of the same Actor; they are different combinations of execution backends and access capabilities. The final mapping must follow the Mode A/B/C definitions in the original architecture document; if they are redefined later, a separate ADR is required.