How nucleoidai/nucleoid works
Project Type and Purpose
• Nucleoid is a neuro-symbolic AI runtime that integrates declarative (logic) programming with data management and knowledge graph generation.
• Its purpose is to support adaptive reasoning by dynamically managing both logic and data in a unified runtime, serving as a foundation for decision‐making and symbolic reasoning.
File Structure
• Notice key top-level directories:
– “arc” folder: Appears to be the primary Node.js implementation with its source code for the runtime, evaluations, and training data.
– “src” folder: Contains various modules related to the language, AST, and runtime core such as Expression, Instruction, Scope, and modules under “src/lang” and “src/nuc”. These reflect the implementation of the declarative language, parsers, interpreters, and abstract syntax trees.
– “python” folder: Provides additional components written in Python, including a nucleoid submodule (graph, parsing, state management) and tests. This highlights the multi-language support (Node.js/JavaScript and Python).
– Other directories like “.github” contain workflows and metadata for CI/CD, while configuration files (e.g., package.json, ESLint configuration) indicate standard practices.
• Patterns such as compiler modules (“src/experimental/compiler.js” and “compiler.py”), and dedicated “data/evaluation”, “data/training”, and “instruct_dataset” folders, showcase the dynamic data ingestion and evaluation process.
Readme Insights
• The README explains the core ideas of neuro-symbolic AI, a declarative runtime that mixes symbolic reasoning (logic graph) with dynamic data updates.
• It emphasizes integration with external services (e.g., OpenAI, Azure, and others in “arc/src/lib”) and shows that there are both fast (neural network based learning) and deliberate (symbolic logic) decision-making paths.
• Technologies mentioned include Node.js, Express.js, and hints of future TypeScript and more advanced ES support. There’s also multi-language support with Python tools.
a. Main Components:
– Frontend/API/Interface Layer: Represented by Express routes (located under “src/routes”) and CLI entry points (e.g., server.js, bin.js). This layer handles user interactions (e.g., terminal, chat interface, OpenAPI).
– Runtime Engine: The core of Nucleoid which runs the declarative logic. This comprises the main runtime modules in “arc/src/app.js”, “nucleoid.js”, “src/stack.js”, “src/state.js”, and others that manage the execution of logic statements.
– Data and Knowledge Graph: The component that stores, updates, and evaluates both logic and data statements. This includes the in-memory datastore and the continuous construction of the logic graph.
– Integration & Library Modules: Elements in “arc/src/lib” handle integrations with external services (e.g., Azure, OpenAI, Claude, Llama, etc.), supporting neuro-symbolic processing.
– Multi-language Support: The Python side (under “python/”) and related tests illustrate auxiliary support and experiments. This can be represented as a parallel engine that interoperates with the main runtime to experiment with or extend the system.
– Evaluation & Training Data: The “arc/src/data/evaluation” and “arc/src/data/training” directories indicate modules processing evaluated and training examples that feed into the runtime for adaptive reasoning.
b. Relationships & Interactions:
– Illustrate directional data flows between the language processing/parsing modules and the knowledge graph datastore. For example, once the AST is generated, it feeds into the logic engine that updates the graph.
– Show integration between external library modules (e.g., for neural network outputs) and the engine, which informs both immediate inference and knowledge graph updates.
– Represent the multi-language bridge: a connection between the primary Node.js engine and the Python components as they both support distinct aspects of the system.
c. Highlighting Architectural Patterns:
– Separation of Concerns / Layered Architecture: Distinct layers for presentation (routes, server), core logic (runtime engine, datastore), language processing (parsers, AST modules), and integration (external library calls).
– Dynamic Data Flow & Plasticity: Emphasize the “on-chain data store” and continuous update process of the knowledge graph, as well as the adaptive reasoning cycle.
– Modularity and Extensibility: Note the finely partitioned modules (logic, libraries, training data, evaluations) allowing feature extensions.
Instructing the Principal Software Engineer
– Begin by listing all the major system components as identified above.
– Make sure the modular components (for Node.js and Python processing) are clearly indicated and show how they interact or complement one another.
– Include annotations or notes to mention that the system’s adaptive reasoning and plasticity are achieved by the real-time, in-memory computing model and the continuous re-evaluation of declarative statements.