Binary request-response protocol over TCP or Unix domain sockets.
:4847/tmp/iskra.sockEvery message (request or response) is length-prefixed:
[4 bytes] length (uint32 LE) - byte count of everything that follows
[N bytes] payload
Maximum frame size: 4 MiB.
[1 byte] op code
[N bytes] op-specific fields
[1 byte] status
[N bytes] op-specific fields
Status codes:
| Value | Name | Meaning |
|---|---|---|
| 0x00 | OK | Success, payload contains result |
| 0x01 | NOT_FOUND | Lookup returned no match, payload empty |
| 0x02 | ERROR | Server error, payload is UTF-8 error message |
| Type | Encoding |
|---|---|
| uint8 | 1 byte |
| uint16 | 2 bytes LE |
| uint32 | 4 bytes LE |
| uint64 | 8 bytes LE |
| string | uint16 length prefix + UTF-8 bytes |
| Key | 16 bytes (two uint64 LE) |
All multi-byte integers are little-endian.
Exact bigram lookup at a specific domain and coord.
Request:
| Field | Type | Description |
|---|---|---|
| domain | uint8 | Domain byte (0x01=EN, 0x02=JA, 0x10=MoxieSRC, ...) |
| coord | uint64 | 64-bit packed coordinate |
| prev | string | Previous token |
| next | string | Next token |
Response (OK):
| Field | Type | Description |
|---|---|---|
| weight | uint32 | Observation count (0 = never observed) |
Bigram lookup with full coord relaxation cascade. Strips coord axes one at a time (pragmatic -> register -> valency -> semantic -> grammatical -> cooccur -> morph) until a non-zero weight is found.
Request:
| Field | Type | Description |
|---|---|---|
| domain | uint8 | Domain byte |
| coord | uint64 | Starting coord (most specific) |
| prev | string | Previous token |
| next | string | Next token |
Response (OK):
| Field | Type | Description |
|---|---|---|
| weight | uint32 | First non-zero weight found |
| matched_coord | uint64 | Coord level that matched (0 = base/dictionary form) |
Record one observation of a (prev -> next) transition. Increments count if the bigram exists, inserts with count=1 if new.
Request:
| Field | Type | Description |
|---|---|---|
| domain | uint8 | Domain byte |
| coord | uint64 | Context coord for this observation |
| prev | string | Previous token |
| next | string | Next token |
Response (OK):
| Field | Type | Description |
|---|---|---|
| recIdx | uint32 | Record index of the bigram entry |
Bulk ingest a token sequence. Records bigrams for all adjacent pairs (tokens[0]->tokens[1], tokens[1]->tokens[2], ...).
Request:
| Field | Type | Description |
|---|---|---|
| domain | uint8 | Domain byte |
| coord | uint64 | Base context coord for the sequence |
| count | uint16 | Number of tokens |
| tokens | string[] | Token sequence (count entries) |
Response (OK):
Empty payload.
Compute candidate next positions from a current walk state. Returns continuations ordered by descending bigram weight.
Request:
| Field | Type | Description |
|---|---|---|
| domain | uint8 | Domain byte |
| coord | uint64 | Current context coord |
| word | string | Current word (prev token for bigram lookup) |
| maxCandidates | uint16 | Maximum candidates to return |
Response (OK):
| Field | Type | Description |
|---|---|---|
| count | uint16 | Number of candidates |
| candidates[] | variable | Repeated candidate entries |
Each candidate entry:
| Field | Type | Description |
|---|---|---|
| domain | uint8 | Candidate domain |
| coord | uint64 | Matched coord |
| word | string | Next word |
| score | uint32 | Accumulated walk score |
| depth | uint8 | Steps taken |
| weight | uint32 | Bigram weight for this transition |
Cross-domain translation via sub-lattice composition. Finds the best match for a word in dstDomain using coord-relaxation and cross-domain links.
Request:
| Field | Type | Description |
|---|---|---|
| srcDomain | uint8 | Source domain byte |
| dstDomain | uint8 | Destination domain byte |
| coord | uint64 | Semantic/morph context in source domain |
| word | string | Word to translate |
Response (OK):
| Field | Type | Description |
|---|---|---|
| result | string | Translated word in destination domain |
Returns NOT_FOUND (0x01) if no translation exists at any relaxation level.
Raw record lookup by branch and key.
Request:
| Field | Type | Description |
|---|---|---|
| branch | uint8 | Branch index (0-7) |
| key | Key | 128-bit lattice key |
Response (OK):
| Field | Type | Description |
|---|---|---|
| found | uint8 | 1 if found, 0 if not |
| form | string | Surface form of the record |
| count | uint32 | MetaEntry.Count |
Insert a new record into the lattice.
Request:
| Field | Type | Description |
|---|---|---|
| branch | uint8 | Branch index (0-7) |
| key | Key | 128-bit lattice key |
| form | string | Surface form to store |
| kind | uint16 | NodeKind bitfield |
| stage | uint8 | Stage tag |
Response (OK):
| Field | Type | Description |
|---|---|---|
| recIdx | uint32 | Record index of the new entry |
Execute a full beam search walk. Starts from the given word and walks maxSteps iterations with the specified beam width and walk kind.
Request:
| Field | Type | Description |
|---|---|---|
| domain | uint8 | Domain byte |
| coord | uint64 | Starting context coord |
| word | string | Starting word |
| width | uint16 | Beam width (number of parallel hypotheses) |
| maxSteps | uint16 | Maximum walk iterations |
| kind | uint8 | Walk kind: 0=translate, 1=elaborate, 2=narrow |
Walk kinds:
Response (OK):
| Field | Type | Description |
|---|---|---|
| domain | uint8 | Final domain |
| depth | uint8 | Steps actually taken |
| coord | uint64 | Final coord |
| score | uint32 | Accumulated confidence score |
| word | string | Final word reached |
Force immediate persistence of the lattice to disk.
Request:
Empty (just the op byte).
Response (OK):
Empty payload.
Record a typed reference from src to target. References use the same storage as bigrams (Bcooccur branch) but with a RefKind byte set on the MetaEntry. The coord gets RefKind bits set at [15:13] so reference keys hash differently from sequential bigrams.
Request:
| Field | Type | Description |
|---|---|---|
| domain | uint8 | Domain byte |
| coord | uint64 | Context coord |
| src | string | Source symbol |
| target | string | Target symbol |
| kind | uint8 | Reference type (1-7) |
Reference types:
| Value | Name | Meaning |
|---|---|---|
| 1 | RefContains | src contains target (directory/scope) |
| 2 | RefRequires | src requires target (type constraint) |
| 3 | RefProduces | src produces target (return/output) |
| 4 | RefOperatesOn | src operates on target (parameter) |
| 5 | RefIsA | src is a target (subtype/hypernym) |
| 6 | RefBinds | src modifies relationship between neighbors |
| 7 | RefContext | src disambiguated by target (path segment) |
Response (OK):
| Field | Type | Description |
|---|---|---|
| recIdx | uint32 | Record index of the reference entry |
Return all typed references originating from src in the given domain.
Request:
| Field | Type | Description |
|---|---|---|
| domain | uint8 | Domain byte |
| src | string | Source symbol to query |
Response (OK):
| Field | Type | Description |
|---|---|---|
| count | uint16 | Number of references |
| refs[] | variable | Repeated RefEntry |
Each RefEntry:
| Field | Type | Description |
|---|---|---|
| recIdx | uint32 | Record index |
| target | string | Target symbol |
| kind | uint8 | Reference type (1-7) |
| weight | uint32 | Observation count |
Follow references from src outward, one depth level at a time, up to maxDepth. Returns the full reachable tree of symbols with their relationship types. Cost is proportional to ambiguity depth.
Request:
| Field | Type | Description |
|---|---|---|
| domain | uint8 | Domain byte |
| src | string | Starting symbol |
| maxDepth | uint8 | Maximum depth levels to walk |
Response (OK):
| Field | Type | Description |
|---|---|---|
| layerCount | uint8 | Number of depth layers |
| layers[] | variable | Repeated RefLayer |
Each RefLayer:
| Field | Type | Description |
|---|---|---|
| count | uint16 | Number of entries in this layer |
| entries[] | variable | Repeated RefEntry (same format as GetRefs) |
Bits 15-13 of the coord encode the RefKind for reference records. When these bits are non-zero, the record is a typed reference rather than a sequential bigram. This ensures reference keys hash to different lattice positions than bigrams for the same word pair, naturally distributing them at higher depth where expansion has created room.
bits 15-13 refkind (3 bits): reference type (0=bigram, 1-7=typed ref)
bits 12-8 position (4 bits): sequence order within a definition
bits 7-2 (available)
bits 1-0 register (2 bits): social register
| Value | Domain | Description |
|---|---|---|
| 0x01 | LangEN | English vocabulary |
| 0x02 | LangJA | Japanese vocabulary |
| 0x10 | MoxieSRC | Moxie source constructs |
| 0x11 | MoxieAST | Moxie AST nodes |
| 0x12 | MoxieIR | Moxie IR (LLVM) |
| 0x13 | MoxieASM | Assembly |
| 0x14 | MoxieBIN | Binary/bytecode |
| Index | Name | Semantic axis |
|---|---|---|
| 0 | Bsemantic | Ontological category |
| 1 | Bgrammatical (Bnoun) | Syntactic role |
| 2 | Bcooccur | Co-occurrence / bigrams |
| 3 | Bmorphology (Bverb) | Morphological state |
| 4 | Bpragmatic (Bmodifier) | Domain/register context |
| 5 | Bphonology | Phonological (reserved) |
| 6 | Bvalency | Argument count |
| 7 | Bregister | Social register |
bits 63-48 semantic (16 bits): 8 subject|object category pairs
bits 47-32 (reserved)
bits 31-29 grammatical (3 bits): syntactic role
bits 28-25 cooccur (4 bits): prev_type(2) + next_type(2)
bits 24-20 morphstate (5 bits): tense/aspect/polarity/formality/evidential
bits 19-18 pragmatic (2 bits): domain context
bits 17-16 valency (2 bits): argument count
bits 15-2 (reserved)
bits 1-0 register (2 bits): social register
coord=0 is the base key (dictionary form, context-free lookups).
The server flushes to disk after every 64 write operations (IngestBigram, IngestText) or 5 seconds since last flush, whichever comes first. Clients can force an immediate flush with OpFlush.