Skip to content

Mecca-Research/The-Binary-Decomposition-Interface

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

The Binary Decomposition Interface (BDI)

A Modular Kernel and Operating System with Native AI Processes


🎯 Overview and Vision

BDI is a next-generation Application Binary Interface (ABI) and operating system that fundamentally reimagines the interface between software and hardware. It's proposed as a foundational computational substrateβ€”a universal fabric designed to represent any computation, from mathematical proofs to adaptive AI algorithms, in a verifiable, composable, and directly executable format grounded in binary semantics.

Think of BDI less like a translation layer (such as LLVM IR) and more like the fundamental logic gates of computation itself, but imbued with meaning. BDI elevates binary distinction as the ontological primitive, the bedrock upon which all verifiable computational structures are built.

The Philosophical Foundation: Machine Epistemology

BDI emerges from a philosophical standpoint we call Machine Epistemology. This view posits that for knowledge (mathematical, logical, or learned) to be truly verifiable and utilizable by a computational system, it must ultimately be traceable to executable operations on a fundamental binary substrate.

Why binary?

  • It's the minimal distinguishable state (0 β‰  1) required for information processing
  • It has direct physical realizability in transistors and logic gates
  • It possesses proven computational universality (Boolean logic, Turing completeness)

The Vision: A Unified Language from Thought to Silicon

BDI proposes a fundamental shift: moving away from layers of lossy text-based translations towards a unified, semantic, binary graph representation that spans the entire computational stack.

It's an environment where:

  • Logic is Instruction: Mathematical and logical constructs map directly to verifiable graph patterns with execution semantics
  • Memory is Topology: Memory isn't just a flat address space but a structured collection of typed regions influencing execution
  • Proof is Execution Trace: Verification artifacts are embedded and can be dynamically checked or generated
  • Learning is Graph Transformation: Adaptation occurs through verifiable modifications to the executable graph itself

πŸ—οΈ Architecture

BDI is organized into multiple interconnected layers, each serving a critical role in the overall system:

1. C Folder: Core Metaprogramming Engines

The C folder contains the foundational metaprogramming engines that power BDI's capabilities:

  • BCI (Binary Computational Interface): Core binary operations, arithmetic, bitwise operations, SIMD support, and type conversions
  • BTL (Binary Translation Layer): ISA definitions, instruction scheduling, register allocation, and peephole optimizations
  • Compiler: Complete compiler infrastructure including:
    • Lexer and tokenization
    • Parser with extended AST support
    • Semantic analyzer with control flow graphs, escape analysis, lifetime tracking, and type inference
    • Code generation
  • Codegen: BCI-specific code generation utilities
  • Fuzzing: Testing and validation framework
  • Kernel: Operating system kernel components including:
    • Multi-backend support (CPU, GPU, FPGA)
    • Device management and filesystem
    • Graph-based computation and optimization
    • HAM (Hierarchical Adaptive Memory) with compression, entropy management, NUMA support, and tiered memory
    • Process management and system calls
    • Advanced schedulers (priority, wavefront, work-stealing)
  • VM (Virtual Machine): BDI virtual machine with:
    • Bytecode execution and chunk management
    • Garbage collection (generational and mark-sweep)
    • Graph-based execution model
    • JIT compilation with tiered compilation and hot path optimization
    • VM-graph and VM-JIT integration
  • AI Trainer: Native AI training infrastructure with:
    • Automatic differentiation (forward and reverse mode)
    • Loss functions and metrics
    • Optimizers (SGD, Adam, RMSprop) with learning rate scheduling
    • Training loop management

2. bdi_kernel: Monolithic Kernel

The monolithic kernel provides:

  • Memory management and protection
  • Hardware abstraction and direct hardware access
  • Core system services and resource management
  • Security and isolation mechanisms

3. modular_kernel: Customizable Kernel Framework

A flexible framework for creating customized kernel configurations:

  • Modular component architecture
  • Plugin-based extensibility
  • Domain-specific kernel optimization
  • Lightweight deployment options

4. BDI_cpp: Experimental C++ Metaprogramming

Experimental C++ implementation exploring advanced metaprogramming techniques:

  • Current Status: Requires refactoring to C++23 standard
  • Goal: Leverage modern C++ features for enhanced type safety and compile-time computation
  • Priority: Medium-term refactoring effort

πŸ“Š Current State

What's Implemented

Core Infrastructure (C Folder):

  • βœ… Complete BCI arithmetic, bitwise, and SIMD operations
  • βœ… BTL instruction set architecture and optimization passes
  • βœ… Full compiler pipeline (lexer, parser, semantic analysis, codegen)
  • βœ… Kernel with multi-backend support (CPU, GPU, FPGA)
  • βœ… HAM hierarchical memory management system
  • βœ… Advanced scheduling algorithms
  • βœ… VM with JIT compilation and garbage collection
  • βœ… Graph-based execution model
  • βœ… AI training infrastructure with autodiff and optimizers
  • βœ… Comprehensive testing framework

Kernel Components:

  • βœ… Basic monolithic kernel structure
  • βœ… Modular kernel framework foundation
  • 🚧 Full hardware driver integration (in progress)

C++ Components:

  • 🚧 BDI_cpp experimental features (requires C++23 refactor)

Development Status

All core metaprogramming engines are implemented, with ongoing work on kernel completion, driver development, and C++23 refactoring.


✨ Key Features and Capabilities

1. Semantic Graph Representation

At its core, a BDI program is a typed, binary-executable graph G = (V, E):

Nodes (V): BDINode structures encapsulating:

  • Unique identifiers and operation types
  • Typed payloads with immediate values
  • Data and control flow connections
  • Semantic metadata and proof tags
  • Hardware hints and region mapping
  • ISA bindings for direct machine code generation

Edges (E): Typed dependencies defining:

  • Data flow between operations
  • Control flow sequences
  • Memory dependencies
  • Type validation at connection points

2. Multifaceted Execution Roles

Universal Semantic Translator: Ingests high-level specifications (mathematical equations, logical proofs, DSL constructs) and decomposes them into semantically equivalent BDI graphs.

Compilation Target & Backend:

  • Direct interpretation via BDIVM
  • AOT compilation to optimized machine code (x86, ARM, RISC-V, custom hardware)
  • Optional lowering to LLVM IR, SPIR-V, or Verilog for compatibility

Runtime Execution Environment:

  • Live introspection of node execution and data flow
  • Dynamic graph modification for adaptive systems
  • Hardware-aware dispatch to CPU cores, GPU streams, FPGA blocks

ISA Semantic Modeler:

  • Typed assembly programming with verifiable structured nodes
  • Cross-ISA reasoning and translation
  • Direct machine instruction representation

Proof-Carrying Execution Framework:

  • Embedded proof tags for formal verification
  • Runtime semantic validation
  • Verifiable execution traces with cryptographic audit trails

3. Advanced Capabilities

  • IR-Free Compilation: Direct DSL-to-binary compilation without lossy intermediate representations
  • Typed Assembly: Low-level programming with type safety and structural validation
  • Semantic Optimization: Intent-based and hardware-aware optimization passes
  • Proof-Carrying Code: Embedded formal verification in executable artifacts
  • Unified Heterogeneous Computing: Single graph representation for CPU, GPU, FPGA, and custom accelerators
  • Intelligent System Substrate: First-class support for learning, feedback, recurrence, and attention mechanisms
  • Live Introspection: Real-time visualization of execution, memory states, and verification steps
  • Composable AI: Build complex agents from verifiable BDI subgraphs

4. Native AI Integration

BDI provides architectural support for intelligent systems:

  • Learning: Direct parameter updates via graph transformations
  • Recurrence: Explicit state management across execution steps
  • Reasoning: Verifiable logic DSL execution with proof tags
  • Adaptation: Inspectable, verifiable graph modifications driven by feedback

πŸ—ΊοΈ Future Plans and Roadmap

Priority 1: Complete Kernel (Highest Priority)

  • Finalize monolithic kernel implementation
  • Complete memory management and hardware protection
  • Integrate all kernel subsystems
  • Comprehensive testing and validation

Priority 2: Vendor-Specific Drivers

  • CPU vendor optimizations (Intel, AMD, ARM)
  • GPU driver support (NVIDIA, AMD, Intel)
  • FPGA integration (Xilinx, Intel)
  • Custom accelerator interfaces

Priority 3: C++23 Refactor

  • Modernize BDI_cpp codebase to C++23 standard
  • Leverage concepts, ranges, and coroutines
  • Enhanced compile-time computation
  • Improved type safety and metaprogramming

Priority 4: BDI Vector Database

  • Native vector storage and retrieval
  • Semantic similarity search
  • Integration with AI training pipeline
  • Optimized for graph-based queries

Priority 5: WebAssembly Deployment

  • WASM compilation target
  • Browser-based BDI execution
  • Portable cross-platform deployment
  • Sandboxed execution environment

Priority 6: Custom Compilers

  • Domain-specific language compilers
  • Optimized compilation pipelines
  • Extended DSL support
  • Enhanced semantic preservation

Priority 7: Advanced AI Features

  • Extended ML algorithm library
  • Graph traversal algorithms
  • Neural architecture search
  • Reinforcement learning integration
  • Multi-agent coordination

πŸš€ Getting Started

Prerequisites

  • C compiler with C23 support (GCC 13+, Clang 16+)
  • C++ compiler with C++20 support (C++23 for future refactor)
  • CMake 3.20 or higher
  • Python 3.8+ (for build scripts and testing)

Building BDI

BDI provides multiple build options depending on your needs:

Option 1: Using the Root Makefile (Recommended for Full System)

The root Makefile provides comprehensive build configurations with advanced optimizations:

# Clone the repository
git clone https://github.com/Mecca-Research/The-Binary-Decomposition-Interface.git
cd The-Binary-Decomposition-Interface

# Build in release mode (default, with LTO and optimizations)
make

# Or specify build mode explicitly:
# Debug build with sanitizers
make BUILD_MODE=debug

# Profile-guided optimization (two-step process)
make BUILD_MODE=pgo-gen    # Generate profiling data
# Run your workload here to collect profiles
make BUILD_MODE=pgo-use    # Build optimized binary using profiles

# Run tests
make test

Option 2: Using CMake (For C/ Directory Components)

For building specific components in the C/ directory:

# Navigate to C directory
cd C

# Create build directory
mkdir build && cd build

# Configure with CMake
cmake ..

# Build
make -j$(nproc)

# Run tests
ctest

Option 3: Using C/ Makefile (Lightweight Build)

For a simpler build of core libraries:

# Navigate to C directory
cd C

# Build all libraries and tests
make

# Build specific components
make libbci.a      # Build BCI library only
make libbtl.a      # Build BTL library only

# Run tests
make test

Quick Start Example

Here's a simple example using the BDI Virtual Machine to execute bytecode:

#include <stdio.h>
#include "vm/bci_vm.h"
#include "vm/bci_chunk.h"

int main() {
    // Initialize the VM
    VM vm;
    vm_init(&vm);
    
    // Create a bytecode chunk
    Chunk chunk;
    chunk_init(&chunk);
    
    // Add constants to the chunk
    int constant_idx = chunk_add_constant(&chunk, 42.0);
    
    // Write bytecode instructions
    // OP_CONSTANT: Load constant onto stack
    chunk_write(&chunk, OP_CONSTANT, 1);
    chunk_write(&chunk, constant_idx, 1);
    
    // OP_RETURN: Return from execution
    chunk_write(&chunk, OP_RETURN, 1);
    
    // Execute the bytecode and capture result
    BciVmResult result = vm_interpret_with_result(&vm, &chunk);
    
    if (result.status == INTERPRET_OK) {
        printf("Execution successful! Result: %.2f\n", result.result_value);
    } else {
        printf("Execution failed with status: %d\n", result.status);
    }
    
    // Cleanup
    chunk_free(&chunk);
    vm_free(&vm);
    
    return 0;
}

Note: This example demonstrates the current VM API. The higher-level graph-based API (BDINode, semantic graphs) is under active development. For now, you can work with:

  • VM Layer: Direct bytecode execution (vm/bci_vm.h, vm/bci_chunk.h)
  • Enhanced VM: JIT compilation and GC features (vm/vm.h)
  • BCI Operations: Low-level binary operations (bci/bci_arithmetic.h, bci/bci_bitops.h)
  • Compiler: Full compilation pipeline (compiler/ directory)

For more examples, see the C/tests/ directory.


πŸ“ Project Structure

The-Binary-Decomposition-Interface/
β”œβ”€β”€ C/                          # Core metaprogramming engines
β”‚   β”œβ”€β”€ ai_trainer/            # AI training infrastructure
β”‚   β”œβ”€β”€ bci/                   # Binary Computational Interface
β”‚   β”œβ”€β”€ btl/                   # Binary Translation Layer
β”‚   β”œβ”€β”€ codegen/               # Code generation utilities
β”‚   β”œβ”€β”€ compiler/              # Complete compiler pipeline
β”‚   β”‚   β”œβ”€β”€ ast/              # Abstract syntax tree
β”‚   β”‚   β”œβ”€β”€ codegen/          # Compiler code generation
β”‚   β”‚   β”œβ”€β”€ lexer/            # Lexical analysis
β”‚   β”‚   β”œβ”€β”€ parser/           # Syntax parsing
β”‚   β”‚   β”œβ”€β”€ semantic_analyzer/ # Semantic analysis and type checking
β”‚   β”‚   └── types/            # Type system
β”‚   β”œβ”€β”€ kernel/                # Operating system kernel
β”‚   β”‚   β”œβ”€β”€ backend/          # Hardware backends (CPU, GPU, FPGA)
β”‚   β”‚   β”œβ”€β”€ device/           # Device management
β”‚   β”‚   β”œβ”€β”€ file/             # Filesystem
β”‚   β”‚   β”œβ”€β”€ graph/            # Graph computation
β”‚   β”‚   β”œβ”€β”€ graph_opt/        # Graph optimization
β”‚   β”‚   β”œβ”€β”€ ham/              # Hierarchical Adaptive Memory
β”‚   β”‚   β”œβ”€β”€ motif/            # Pattern matching
β”‚   β”‚   β”œβ”€β”€ process/          # Process management
β”‚   β”‚   β”œβ”€β”€ scheduler/        # Task scheduling
β”‚   β”‚   └── syscalls/         # System call interface
β”‚   β”œβ”€β”€ tests/                 # Testing framework
β”‚   β”œβ”€β”€ trainer/               # Training algorithms
β”‚   β”‚   β”œβ”€β”€ autodiff/         # Automatic differentiation
β”‚   β”‚   β”œβ”€β”€ loss/             # Loss functions
β”‚   β”‚   β”œβ”€β”€ metrics/          # Evaluation metrics
β”‚   β”‚   β”œβ”€β”€ optimizers/       # Optimization algorithms
β”‚   β”‚   └── training/         # Training loops
β”‚   └── vm/                    # Virtual machine
β”‚       β”œβ”€β”€ gc/               # Garbage collection
β”‚       β”œβ”€β”€ graph/            # Graph execution
β”‚       └── jit/              # Just-in-time compilation
β”œβ”€β”€ bdi_kernel/                # Monolithic kernel
β”œβ”€β”€ modular_kernel/            # Modular kernel framework
β”œβ”€β”€ BDI_cpp/                   # Experimental C++ implementation
└── README.md                  # This file

🀝 Contributing

BDI is currently a solo development effort ("Me, Myself and AI"), but the project welcomes interest and collaboration. If you're interested in contributing:

  1. Explore the codebase: Familiarize yourself with the architecture and existing implementations
  2. Identify areas of interest: Check the roadmap for priority areas
  3. Reach out: Contact the maintainer to discuss potential contributions
  4. Follow best practices: Maintain code quality, documentation, and testing standards

Development Guidelines

  • Write clear, documented code with comprehensive comments
  • Include unit tests for new features
  • Follow the existing code style and conventions
  • Update documentation for significant changes
  • Ensure all tests pass before submitting changes

Keeping Your Checkout in Sync

Large changes land frequently across the kernel, compiler, and tooling trees. To help contributors stay current and automatically run the baseline regression suite, use the helper script that lives in tools/resync_and_test.sh:

# Clone a fresh working tree (defaults to the repository's origin remote)
./tools/resync_and_test.sh --destination .cache/bdi-latest

# Or target a specific fork/branch without executing the test suite
./tools/resync_and_test.sh \
  --repo-url git@github.com:Mecca-Research/The-Binary-Decomposition-Interface.git \
  --branch work --skip-tests

The script caches the checkout so subsequent runs simply fast-forward the existing tree before invoking make -C tests run. Point the destination at a scratch directory if you want to keep your main working tree untouched while you track upstream movement.


πŸ“„ License MIT


πŸ”— Additional Resources


πŸ™ Acknowledgments

BDI represents an ambitious vision to fundamentally rethink computational substrates. This project is the result of extensive research, experimentation, and dedication to creating a more verifiable, efficient, and intelligent computing foundation.


πŸ“§ Contact

For questions, collaboration inquiries, or more information about the BDI project, please reach out through the GitHub repository.


"Making executable, verifiable knowledge the cornerstone of future computation."

About

BDI - A proposed foundational computational substrate, a universal fabric designed to represent any computation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published