TypeScript or Rust: Choosing the Backend (kbengine.core.backend)
The extension ships two implementations of the language services: the original TypeScript face and the Rust core (kode-server, kode2). The kbengine.core.backend setting picks who serves and how. The switch is live — changing it re-assembles the lane through the existing configuration chain (no window reload) and it is always reversible; any invalid value falls back to ts.
One distinction the rest of this page depends on: the extension actually has two lanes, and the backend switch governs only one of them.
- Serving lane (interactive requests: definition, hover, completion, …) — mode-gated.
rustserves from kode-server;tsserves pure TypeScript;shadowserves TypeScript and mirrors for comparison. - Tool lane (command-level analysis: def formatting, def MD5, client SDK generation, trap lint rules, config derive/resolve, message table, …) — binary-gated, not mode-gated. These faces consult kode-server whenever the binary resolves, in every mode; without a binary each face falls back to its TypeScript implementation or reports an honest no-op (whichever it documents).
The three modes at a glance
rust (default) | ts | shadow | |
|---|---|---|---|
| Serving lane | kode-server serves first; TS takes over on empty / failure / 2 s interactive budget | TS serves; the Rust serving lane is off and the process is stopped at switch time | TS serves |
| Shadow mirror-compare | not run (rust serving does not go through compare) | not run | same-parameter textDocument/definition and textDocument/diagnostic requests are mirrored to kode-server; the outcome (match / diff / rust-error / rust-timeout / rust-unavailable) goes only into the diff log and never changes what you see |
| Diagnostics | TS base face first; Rust supplement diagnostics merge in asynchronously (the .def face needs all five def feature switches on; the Python create-params face is Rust-only); Rust failure or timeout silently keeps the TS face | TS face only | TS face only (the diagnostic face is still one of the two mirrored surfaces) |
| Tool lane | Rust-first | still Rust-first — the tool lane only requires the kode-server binary | Rust-first (same as rust) |
| kode-server process | started on demand | stopped at switch time; a later tool-lane call re-attaches if the binary is present | started on demand |
| Corpus mirror to Rust | yes (yields to interaction every 8 files; mirror generations are single-flight) | off | yes |
| Diff log | not written | not written | written; inspect via kbengine.core.showShadowDiffLog |
Related settings: kbengine.core.serverPath (binary path; empty auto-probes target/{debug,release}/kode-server under the extension root; under rust a discovery miss falls back to the TS serving lane) and kbengine.core.shadow.timeoutMs (mirror-request timeout, default 2000; a timeout logs rust-timeout and changes nothing).
Serving-lane faces, face by face
Every face below is Rust-first with TS fallback when backend=rust and the binary is present: the Rust answer wins, an empty result, a failure, or the 2 s interactive budget expiry hands the request to the TypeScript implementation. Failure never removes a capability — the sentinel design distinguishes an authoritative Rust "no result" from a Rust failure, so the TS face still runs on failure. Under shadow all of these serve TypeScript; only the two marked rows additionally mirror.
| Face | Notes |
|---|---|
| Definition (F12 / hover link) | also the mirrored shadow surface |
| Hover | |
| Completion | |
| Completion item resolve | |
| Find references | |
| Document symbols (outline) | |
| Workspace symbols | |
| Prepare rename | |
| Rename | .def entity rename drives the def↔py full-corpus rename pipeline |
| Code actions | |
| Signature help | |
Diagnostics — .def face | Rust supplement merges into the TS collection by message key; requires all five def feature switches on, otherwise the whole face stays TS |
| Diagnostics — Python face | TS base plus Rust supplement; the create-params checks exist only on the Rust side |
Serving-lane protection: each request races a 2 s interactive budget; startup failures are accounted per client, and a wedged server cannot hang the editor (the request falls back to TS).
Tool-lane faces (binary-gated)
These faces call kode-server through the command-level RPC leg regardless of the backend mode:
.defnative formatting — Rust-only; without the binary the formatter honestly returns "no edits"- def MD5 (engine-format MD5) — Rust-only; without the binary the workspace MD5 reports "unknown" rather than a wrong value
- Client entity SDK generation — Rust-primary; falls back to the TypeScript generator when Rust is unavailable
- Trap lint rules (fixed-dict nested mutation, destroyed entity reference, timer cleanup on destroy) — Rust structural reply, message rendering stays TS; a malformed reply discards the whole surface back to the TS analyzer (never a partial adoption)
- Config derive / config resolve, workspace anchor scan, message table build, def index first-scan symbol extraction, self-attribute flow / none diagnostics, RPC argument-count checks, local return type inference, space navigation, cell-data keys completion, index event coalescing
Command-leg protection: consecutive timeouts open a circuit (reset by kbengine.core.restart or a process rebuild) that routes the tool lane to TS without burning budget on a wedged process.
What never depends on kode-server
These work identically in all three modes and need no backend switch:
- pyrefly stub inference (
kbengine.infer.*— a Python toolchain, discovered / auto-installed / version-gated independently) - The Python index and its TS-side services (under
rustthe full first scan no longer self-starts on activation; the first TS-face query triggers it lazily) - Engine lifecycle: server start/stop, telnet, hot reload, log tail
- Webview panels, code/entity generators, config auto-discovery, database simulation and drift check, dependency graph, flow diagram
- Wireshark/protocol tooling analysis (rides the
kode-kbengineCLI — its own binary, wired viakbengine.protocol.cliPath, not the backend switch) - The built-in Kode MCP server (
kode-mcpbinary,kbengine.mcp.enabled— also not the backend switch)
Which mode should I pick?
rust(default) — you want the fastest, richest answers and the Rust-only capabilities (def formatting, def MD5, Rust-side diagnostics). Recommended for every project with a built or packaged binary.ts— the kill-switch. If the Rust core misbehaves (wedged, crash loop) and evenkbengine.core.restartdoes not help, switching totsstops the serving lane immediately with user-invisible rollback. Interactive behavior returns to the pure TypeScript implementation; the tool lane keeps using the binary if it is present.shadow— parity verification before trusting the serving lane: TypeScript keeps serving while definition and diagnostic requests are cross-checked against Rust and divergences land in the diff log. Choose it when you want to measure Rust-vs-TS equivalence on your own corpus without any behavior change.- No binary at all (pure-TS VSIX, or
rustwith a discovery miss): the serving lane is TypeScript either way; the tool lane degrades honestly per face. Installing a platform VSIX (shipsbin/kode-server) or building withcargo build -p kode-server --releasere-enables it — run Developer: Reload Window after installing so activation rediscovers the binary.
How to tell which track you are on, and how to switch
- Status bar Kode core light (priority 94): shows the current lane (Rust / Rust-fallback-TS / TS / Shadow parity); click opens the
kbengine.core.statusQuickPickaggregate menu — backend-mode log, copy the kode-server launch command, run kode-server in a standalone terminal. - Status bar Core health light (priority 91): probes kode-server every 10 s with a 2 s budget; six states —
off(backend=ts, hidden),bypassed(configured rust/shadow but no binary found — actually serving TS),unresponsive,degraded(probe passes, command legs timing out),ok,idle. Click for details, restart, or switching tracks (the switch writeskbengine.core.backend). - Commands:
kbengine.core.restart(stop and rebuild on next request),kbengine.core.statusQuickPick,kbengine.core.healthPanel,kbengine.core.showShadowDiffLog,kbengine.core.standaloneTerminal.
Ground truth anchors: src/backend/kodeCoreGate.ts (mode resolution, serveFromRust, runInRust, circuit), src/backend/kodeCoreShadowFaces.ts (serving faces, shadow compares), src/languageProviders/* (provider wiring), src/kodeCoreHealthLight.ts (six-state light), src/kodeCoreGateWiring.ts (commands and lane rebuild), src/sdk-gen/clientSdkGenerator.ts, src/defMd5Check.ts, src/backend/defFormat.ts.