Skip to content

Add binary wire protocol (CogPacket) for inter-runtime communication#109

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/cognitive-layer-stack-77KUH
Feb 14, 2026
Merged

Add binary wire protocol (CogPacket) for inter-runtime communication#109
AdaWorldAPI merged 1 commit into
mainfrom
claude/cognitive-layer-stack-77KUH

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Summary

Introduces a binary wire protocol (CogPacket) to replace JSON serialization for internal communication between ladybug-rs, crewai-rust, and n8n-rs. The protocol uses bitpacked binary packets built on the Container primitive, eliminating JSON overhead and enabling direct fingerprint-based routing through BindSpace.

Key Changes

  • New wire.rs module (865 lines): Implements the complete CogPacket binary protocol

    • 64-byte header with magic, version, flags, opcode, addressing, cognitive state, and checksum
    • Support for 1-2 Container payloads (1024-2048 bytes total)
    • 8+8 BindSpace addressing (prefix:slot) directly in packet header
    • Bitpacked field modulation: resonance threshold, fan-out, depth/noise/speed bias, exploration
    • Satisfaction scores (10 layers × 6 bits) and NARS truth values (frequency/confidence as f32)
    • Zero-copy little-endian serialization/deserialization
    • CRC32-like checksum verification
    • Well-known opcodes (RESONATE, EXECUTE, DELEGATE, VALIDATE, CRYSTALLIZE, etc.)
    • Comprehensive test suite (13 tests covering roundtrip, dual containers, packing, validation)
  • Updated cognitive_kernel.rs: Adds packet processing pipeline

    • New process_packet() method: routes incoming CogPackets through the 10-layer stack
    • Container↔Fingerprint bridging functions for BindSpace integration
    • Extracts field modulation and NARS truth values from packet headers
    • Populates response headers with cognitive state (cycle, layer, satisfaction, validation results)
    • Supports crystallization events and causal rung encoding (Pearl's see/do/imagine)
    • Integration test for packet roundtrip processing
  • Updated nars.rs: Adds Debug derive to TruthValue for wire protocol logging

  • Updated legacy.rs: Adds missing fields to V1 snapshot test data for compatibility

  • Updated lib.rs: Exports new wire module in public API

Implementation Details

  • No JSON: Packets are pure binary with deterministic little-endian encoding
  • Fingerprint routing: Container payloads are converted to 16K-bit fingerprints for BindSpace resonance queries, replacing string-based step_type dispatch
  • Field modulation in headers: Agents communicate style hints (resonance threshold, exploration, speed bias) through packet headers instead of JSON metadata
  • Dual-container support: Delegation packets carry both content and context containers for cross-runtime operations
  • Checksum protection: XOR-fold of header words with rotation-based mixing prevents corruption
  • Backward compatibility: from_step_type() helper converts legacy V1 delegation strings to CogPackets for migration

The protocol is designed for zero-copy processing and direct hardware-friendly serialization, enabling efficient inter-runtime communication while maintaining full cognitive state fidelity.

https://claude.ai/code/session_01NocTBszN8LoR9Vrc7Tn4oF

Replace JSON serialization for internal communication with binary CogPacket
wire protocol. The 1088-byte packets carry full cognitive state (10-layer
satisfaction, NARS truth values, field modulation) through 8+8/4096 opcode
addressing. CognitiveKernel.process_packet() routes by fingerprint resonance
instead of step_type string dispatch.

- wire.rs: CogPacket binary format (64-byte header + Container payload)
- cognitive_kernel.rs: process_packet() for L4 Self-Realization
- nars.rs: add Serialize/Deserialize to TruthValue
- legacy.rs: fix test constructors for cognitive awareness fields
- 37 wire tests + 11 kernel tests all passing

https://claude.ai/code/session_01NocTBszN8LoR9Vrc7Tn4oF
@AdaWorldAPI AdaWorldAPI merged commit 1d61435 into main Feb 14, 2026
2 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants