Skip to content

MFBP Specification

MFBP (MindFry Binary Protocol) is a custom binary protocol designed for microsecond-level cognitive reflexes over TCP.

GoalApproach
Low latencyBinary encoding, no text parsing
High throughputPipelining (non-blocking dispatch)
Simple parsingLength-prefixed frames, 1-byte OpCodes
ExtensibilityReserved OpCode ranges

Every MFBP frame follows this structure:

packet-beta
  0-31: "Length (4 bytes, LE)"
  32-39: "OpCode"
  40-95: "Payload (variable)"
FieldSizeDescription
Length4 bytes (u32 LE)Total frame size (includes OpCode + Payload)
OpCode1 byte (u8)Command identifier
PayloadVariableCommand-specific data

Request: LINEAGE.CREATE fire 0.9

OffsetHexDescription
0x0005 00 00 00Length: 5
0x0410OpCode: 0x10 (LineageCreate)
0x0504 00key_len: 4
0x0766 69 72 65key: “fire”
0x0B66 66 66 3Fenergy: 0.9 (f32)

Response: OK

OffsetHexDescription
0x0001 00 00 00Length: 1
0x04F0OpCode: 0xF0 (OK)
OpCodeNamePayloadDescription
0x10LINEAGE.CREATE[key_len:u16, key:bytes, energy:f32]Create new lineage
0x11LINEAGE.GET[key_len:u16, key:bytes, flags?:u8]Get lineage details
0x12LINEAGE.STIMULATE[key_len:u16, key:bytes, delta:f32, flags?:u8]Inject energy
0x13LINEAGE.FORGET[key_len:u16, key:bytes]Soft-delete
0x14LINEAGE.TOUCH[key_len:u16, key:bytes]Update access time
OpCodeNamePayloadDescription
0x20BOND.CONNECT[src_len:u16, src:bytes, tgt_len:u16, tgt:bytes, strength:f32, polarity:i8]Create bond
0x21BOND.REINFORCE[src_len:u16, src:bytes, tgt_len:u16, tgt:bytes, delta:f32]Strengthen bond
0x22BOND.SEVER[src_len:u16, src:bytes, tgt_len:u16, tgt:bytes]Remove bond
0x23BOND.NEIGHBORS[key_len:u16, key:bytes]Get connected lineages
OpCodeNamePayloadDescription
0x30QUERY.CONSCIOUS[min_energy:f32]Get lineages above threshold
0x31QUERY.TOPK[k:u32]Top K by energy
0x32QUERY.TRAUMA[min_rigidity:f32]High-rigidity lineages
0x33QUERY.PATTERN[pattern_len:u16, pattern:bytes]Pattern match keys
OpCodeNamePayloadDescription
0x40SYS.PING(empty)Keep-alive
0x41SYS.STATS(empty)Database statistics
0x42SYS.SNAPSHOT[name_len:u16, name:bytes]Create checkpoint
0x43SYS.RESTORE[name_len:u16, name:bytes]Restore from checkpoint
0x44SYS.FREEZE[state:u8]Pause/resume decay
0x45PHYSICS.TUNE[param_id:u8, value:f32]Adjust physics constants
0x46SYS.MOOD.SET[mood:f32]Set Cortex mood
OpCodeNamePayloadDescription
0xF0RESPONSE.OK(varies)Success
0xF1RESPONSE.ERROR[error_code:u8, msg_len:u16, msg:bytes]Error
0xF2RESPONSE.EVENT[event_type:u8, ...]Subscription notification
flowchart LR
    GET[LINEAGE.GET] --> |0x00| FOUND[Found]
    GET --> |0x01| NF[Not Found]
    GET --> |0x02| REP[Repressed]
    GET --> |0x03| DORM[Dormant]
StatusValueMeaning
FOUND0x00Lineage returned successfully
NOT_FOUND0x01Key does not exist
REPRESSED0x02Below consciousness threshold
DORMANT0x03Deep subconscious, requires bypass
FlagValueEffect
BYPASS_FILTERS0x01Skip mood/threshold checks
INCLUDE_REPRESSED0x02Include below-threshold memories
NO_SIDE_EFFECTS0x04Skip Observer Effect
NO_PROPAGATE0x01 (stimulate)Skip cascade propagation

Combine with bitwise OR: FORENSIC = 0x07 (all bypass flags).

sequenceDiagram
    participant Client
    participant Server

    Client->>Server: TCP Connect (port 9527)
    Client->>Server: SYS.PING
    Server->>Client: RESPONSE.OK + uptime

    Client->>Server: LINEAGE.CREATE "fire" 0.9
    Server->>Client: RESPONSE.OK

    Client->>Server: LINEAGE.GET "fire"
    Server->>Client: RESPONSE.OK + LineageInfo

    Client->>Server: TCP Close

MFBP supports pipelining for high throughput:

sequenceDiagram
    participant Client
    participant Server

    Client->>Server: LINEAGE.CREATE "a"
    Client->>Server: LINEAGE.CREATE "b"
    Client->>Server: BOND.CONNECT "a" → "b"

    Server->>Client: RESPONSE.OK (for "a")
    Server->>Client: RESPONSE.OK (for "b")
    Server->>Client: RESPONSE.OK (for bond)

Responses are returned in FIFO order.


Next: See the complete OpCodes Reference or Wire Format Examples.