1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//! The raw command channel the client contract mandates for every port
//! (`docs/client-contract.md` §5.2 / §7: "every port MUST expose a raw
//! command channel `cmd(argv) -> Reply`"). The typed KV/TTL/pubsub/AOF
//! exports intentionally lag the full verb grammar; this is the escape
//! hatch that reaches whatever the compiled-in dispatcher owns an arm for.
//!
//! # Feature reach
//!
//! The wasm module is built with every feature a browser can host —
//! `core`, `persist`, `index`, `text`, `vector` — so `cmd` reaches the
//! string/hash/list/set/zset, bitmap, keyspace and misc surfaces *and*
//! `IDX.*` / `VIEW.*` / `TABLE.*`. What is left out needs something the
//! browser cannot provide: `replicate` a network peer, `listener` a TCP
//! socket, `tier` a disk directory.
//!
//! It was built `["core", "persist"]` until 2026-08, which meant the
//! project's own landing page demonstrated secondary indexes against an
//! engine compiled without them, and answered its own example with
//! `unknown command`. Verbs outside the embedded surface (streams,
//! transactions, geo, scripting — the ESTORE_OPS manifest is the
//! boundary) still answer that way, and for those it is the correct
//! answer rather than a build mistake.
//!
//! # Persistence note
//!
//! `cmd` runs through [`kevy_embedded::Store::dispatch_argv`] directly, so
//! writes issued this way are **not** mirrored into the host-mediated AOF
//! pump (the typed ops' `log_frame` path). A store that mixes `cmd` writes
//! with the durability pump will not see those writes in its replay log.
//! The typed KV surface remains the durable write path.
use crate::;
/// Run an arbitrary verb and return its RESP reply.
///
/// The argument buffer is **packed argv**: each argument is a `u32`
/// little-endian length prefix followed by that many bytes, back to back
/// — the same layout [`crate::abi_kv::kevy_mget`] uses for keys and the
/// FFI byte-array bindings use for their commands. The RESP-encoded reply
/// lands in the instance result buffer (RESP2; the wasm build negotiates
/// no RESP3); the loader parses it into a `Reply`.
///
/// Returns the reply byte length (`>= 0`), [`ERR`] (`-1`) on a
/// malformed/empty packed argv (message in the result buffer), or
/// [`BAD_HANDLE`] (`-2`) for an unknown handle. A verb-level failure
/// (`-ERR …`, `WRONGTYPE …`) is a *successful* call whose reply bytes are
/// a RESP error frame — not a `-1` status.
///
/// # Safety
///
/// Pointer/length pairs follow the [`crate::arg`] contract.
pub unsafe extern "C"
/// Decode packed argv — a `u32`-LE length prefix then that many bytes,
/// repeated back to back. Returns `None` on a truncated prefix/body or an
/// empty argv (caller misuse, not a protocol error). Mirrors
/// `kevy_ffi::unpack_argv`; kept local so the wasm closure takes no
/// dependency on the C-ABI crate.