OpCodes Reference
OpCodes Reference
Section titled “OpCodes Reference”All MFBP OpCodes with wire format details. All multi-byte integers are little-endian.
Lineage Operations 0x10-0x1F
Section titled “Lineage Operations 0x10-0x1F”0x10 LINEAGE.CREATE
Section titled “0x10 LINEAGE.CREATE”Creates a new lineage with initial energy.
| Field | Type | Description |
|---|---|---|
| key_len | u16 | Key length |
| key | [u8] | UTF-8 key bytes |
| energy | f32 | Initial energy |
Response: id: u32
Errors: ALREADY_EXISTS
0x11 LINEAGE.GET
Section titled “0x11 LINEAGE.GET”Retrieves lineage metadata. Triggers Observer Effect (+0.01 energy) unless NO_SIDE_EFFECTS.
| Field | Type | Description |
|---|---|---|
| key_len | u16 | Key length |
| key | [u8] | UTF-8 key bytes |
| flags | u8? | Optional query flags |
Response:
| Field | Type | Description |
|---|---|---|
| status | u8 | See status codes |
| energy | f32 | Current energy |
| rigidity | f32 | Trauma marker |
| created | u64 | Unix timestamp |
| accessed | u64 | Last access time |
Status: 0x00 FOUND · 0x01 NOT_FOUND · 0x02 REPRESSED · 0x03 DORMANT
Flags: 0x01 BYPASS · 0x02 INCLUDE_REPRESSED · 0x04 NO_SIDE_EFFECTS · 0x07 FORENSIC
0x12 LINEAGE.STIMULATE
Section titled “0x12 LINEAGE.STIMULATE”Injects energy delta. Triggers synaptic cascade unless NO_PROPAGATE.
| Field | Type | Description |
|---|---|---|
| key_len | u16 | Key length |
| key | [u8] | UTF-8 key bytes |
| delta | f32 | Energy to inject |
| flags | u8? | 0x01 NO_PROPAGATE |
Response: OK
0x13 LINEAGE.FORGET
Section titled “0x13 LINEAGE.FORGET”Soft-deletes a lineage (sets energy to 0).
| Field | Type | Description |
|---|---|---|
| key_len | u16 | Key length |
| key | [u8] | UTF-8 key bytes |
Response: OK
0x14 LINEAGE.TOUCH
Section titled “0x14 LINEAGE.TOUCH”Updates last access time without side effects.
| Field | Type | Description |
|---|---|---|
| key_len | u16 | Key length |
| key | [u8] | UTF-8 key bytes |
Response: OK
Bond Operations 0x20-0x2F
Section titled “Bond Operations 0x20-0x2F”0x20 BOND.CONNECT
Section titled “0x20 BOND.CONNECT”Creates or updates a directed bond.
| Field | Type | Description |
|---|---|---|
| src_len | u16 | Source key length |
| src | [u8] | Source key |
| tgt_len | u16 | Target key length |
| tgt | [u8] | Target key |
| strength | f32 | Bond strength (0.0–1.0) |
| polarity | i8 | +1 synergy · 0 neutral · -1 antagonism |
Response: OK
0x21 BOND.REINFORCE
Section titled “0x21 BOND.REINFORCE”Strengthens an existing bond by delta.
| Field | Type | Description |
|---|---|---|
| src_len | u16 | Source key length |
| src | [u8] | Source key |
| tgt_len | u16 | Target key length |
| tgt | [u8] | Target key |
| delta | f32 | Strength delta |
Response: OK
0x22 BOND.SEVER
Section titled “0x22 BOND.SEVER”Removes a bond between two lineages.
| Field | Type | Description |
|---|---|---|
| src_len | u16 | Source key length |
| src | [u8] | Source key |
| tgt_len | u16 | Target key length |
| tgt | [u8] | Target key |
Response: OK
0x23 BOND.NEIGHBORS
Section titled “0x23 BOND.NEIGHBORS”Returns all lineages bonded to key.
| Field | Type | Description |
|---|---|---|
| key_len | u16 | Key length |
| key | [u8] | UTF-8 key bytes |
Response: count: u32 followed by repeating [key_len, key, strength, polarity]
Query Operations 0x30-0x3F
Section titled “Query Operations 0x30-0x3F”0x30 QUERY.CONSCIOUS
Section titled “0x30 QUERY.CONSCIOUS”Returns lineages above energy threshold.
| Field | Type | Description |
|---|---|---|
| min_energy | f32 | Minimum energy |
Response: count: u32 + [key_len, key, energy]...
0x31 QUERY.TOPK
Section titled “0x31 QUERY.TOPK”Returns top K lineages by energy.
| Field | Type | Description |
|---|---|---|
| k | u32 | Number to return |
Response: count: u32 + [key_len, key, energy]...
0x32 QUERY.TRAUMA
Section titled “0x32 QUERY.TRAUMA”Returns high-rigidity lineages.
| Field | Type | Description |
|---|---|---|
| min_rigidity | f32 | Minimum rigidity |
Response: count: u32 + [key_len, key, rigidity]...
0x33 QUERY.PATTERN
Section titled “0x33 QUERY.PATTERN”Pattern match on keys (glob syntax: *, ?).
| Field | Type | Description |
|---|---|---|
| pattern_len | u16 | Pattern length |
| pattern | [u8] | Glob pattern |
Response: count: u32 + [key_len, key]...
System Operations 0x40-0x4F
Section titled “System Operations 0x40-0x4F”0x40 SYS.PING
Section titled “0x40 SYS.PING”Keep-alive heartbeat. No payload.
Response: uptime: u64 (seconds)
0x41 SYS.STATS
Section titled “0x41 SYS.STATS”Returns database statistics. No payload.
Response:
| Field | Type |
|---|---|
| lineage_count | u32 |
| bond_count | u32 |
| mood | f32 |
| uptime | u64 |
0x42 SYS.SNAPSHOT
Section titled “0x42 SYS.SNAPSHOT”Creates named persistence checkpoint.
| Field | Type | Description |
|---|---|---|
| name_len | u16 | Name length |
| name | [u8] | Checkpoint name |
Response: OK
0x43 SYS.RESTORE
Section titled “0x43 SYS.RESTORE”Hot-swaps state from checkpoint.
| Field | Type | Description |
|---|---|---|
| name_len | u16 | Name length |
| name | [u8] | Checkpoint name |
Response: OK
0x44 SYS.FREEZE
Section titled “0x44 SYS.FREEZE”Pauses or resumes decay processing.
| Field | Type | Description |
|---|---|---|
| state | u8 | 0x00 thaw · 0x01 freeze |
Response: OK
0x45 PHYSICS.TUNE
Section titled “0x45 PHYSICS.TUNE”Adjusts runtime physics constants.
| Field | Type | Description |
|---|---|---|
| param_id | u8 | Parameter ID |
| value | f32 | New value |
Parameters:
| ID | Name | Default | Description |
|---|---|---|---|
0x01 | DECAY_MULTIPLIER | 1.0 | Global decay rate |
0x02 | TRAUMA_THRESHOLD | 0.8 | Rigidity trigger |
0x03 | BOND_PRUNE | 0.1 | Min bond strength |
0x04 | MIN_ENERGY | 0.01 | Decay floor |
Response: OK
0x46 SYS.MOOD.SET
Section titled “0x46 SYS.MOOD.SET”Sets Cortex mood (affects consciousness threshold).
| Field | Type | Description |
|---|---|---|
| mood | f32 | 0.0 depressed → 1.0 euphoric |
Response: OK
Response Codes 0xF0-0xFF
Section titled “Response Codes 0xF0-0xFF”| Code | Name | Payload |
|---|---|---|
0xF0 | OK | Command-specific response |
0xF1 | ERROR | [code: u8, msg_len: u16, msg: [u8]] |
0xF2 | EVENT | Subscription notification (reserved) |
Error Codes
Section titled “Error Codes”| Code | Name | Description |
|---|---|---|
0x01 | ALREADY_EXISTS | Key already exists |
0x02 | NOT_FOUND | Key not found |
0x03 | REPRESSED | Below consciousness threshold |
0x04 | INVALID | Malformed request |
0x05 | INTERNAL | Server-side failure |