A Modular Kernel and Operating System with Native AI Processes
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.
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)
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
BDI is organized into multiple interconnected layers, each serving a critical role in the overall system:
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
The monolithic kernel provides:
- Memory management and protection
- Hardware abstraction and direct hardware access
- Core system services and resource management
- Security and isolation mechanisms
A flexible framework for creating customized kernel configurations:
- Modular component architecture
- Plugin-based extensibility
- Domain-specific kernel optimization
- Lightweight deployment options
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
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)
All core metaprogramming engines are implemented, with ongoing work on kernel completion, driver development, and C++23 refactoring.
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
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
- 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
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
- Finalize monolithic kernel implementation
- Complete memory management and hardware protection
- Integrate all kernel subsystems
- Comprehensive testing and validation
- CPU vendor optimizations (Intel, AMD, ARM)
- GPU driver support (NVIDIA, AMD, Intel)
- FPGA integration (Xilinx, Intel)
- Custom accelerator interfaces
- Modernize BDI_cpp codebase to C++23 standard
- Leverage concepts, ranges, and coroutines
- Enhanced compile-time computation
- Improved type safety and metaprogramming
- Native vector storage and retrieval
- Semantic similarity search
- Integration with AI training pipeline
- Optimized for graph-based queries
- WASM compilation target
- Browser-based BDI execution
- Portable cross-platform deployment
- Sandboxed execution environment
- Domain-specific language compilers
- Optimized compilation pipelines
- Extended DSL support
- Enhanced semantic preservation
- Extended ML algorithm library
- Graph traversal algorithms
- Neural architecture search
- Reinforcement learning integration
- Multi-agent coordination
- 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)
BDI provides multiple build options depending on your needs:
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
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
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
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.
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
BDI is currently a solo development effort ("Me, Myself and AI"), but the project welcomes interest and collaboration. If you're interested in contributing:
- Explore the codebase: Familiarize yourself with the architecture and existing implementations
- Identify areas of interest: Check the roadmap for priority areas
- Reach out: Contact the maintainer to discuss potential contributions
- Follow best practices: Maintain code quality, documentation, and testing standards
- 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
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.
- GitHub Repository: Mecca-Research/The-Binary-Decomposition-Interface
- Project Website: Coming soon
- Documentation: In development
- Community: To be established
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.
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."