Skip to content

Automind: Erik Meijer's neural computer on Reaqtor (.NET 10)#1

Open
HowardvanRooijen wants to merge 1 commit into
mainfrom
feature/automind-poc
Open

Automind: Erik Meijer's neural computer on Reaqtor (.NET 10)#1
HowardvanRooijen wants to merge 1 commit into
mainfrom
feature/automind-poc

Conversation

@HowardvanRooijen

Copy link
Copy Markdown
Member

A .NET 10 implementation of Erik Meijer's neural computer — the architecture from Virtual Machinations: Using Large Language Models as Neural Computers (ACM Queue, 2024) and Unleashing the Power of End-User Programmable AI (ACM Queue, 2025) — with Nuqleon / Bonsai / Reaqtive / Reaqtor as the load-bearing substrate, integrated with Microsoft.Extensions.AI against local Ollama models.

The defining property: a reasoning derivation is a durable standing query. Kill the process mid-thought — mid-LLM-call, mid-tool-call, even mid-rule — restart it, and the derivation resumes from the last checkpoint and completes, re-issuing exactly the in-flight work that was lost.

The papers' concepts → this implementation

Neural computer (papers) Realization
Reasoning engine (control unit) Pure DerivationStep state machine hosted in a checkpointed Reaqtor operator
LLM as branch predictor IChatClient (OllamaSharp) with streaming hedge-cut + assistant-prefill resume
Environment σ (register set) var → JSON map in checkpointed operator state; the model never sees values
Tools as instruction set (relations) URI-identified artifacts (automind://tools/*) invoked by the engine
Intentional representation Structured IR (JSON) + Bonsai expression trees over universalis:// params
Query comprehensions LINQ pipelines over JSON rows — nested results, HAVING and all
RAG as virtual memory In-process ONNX embeddings (bge-micro-v2) paging rules/docs into the context
Tree-of-thought backtracking Choice points + value-sanitized teachings + temperature ladder + restart
Pre/post-condition contracts Vanilla Universalis clauses; pre gates the run, post restarts the derivation
Self-learning Successful derivations become durable rules (IR + Bonsai) that run LLM-free

What's in the box

  • Universalis language core — hedge scanner/parser, literate recognizer, evaluator (one-way patterns, zip lifting, conditionals, query comprehensions → LINQ), contracts, Bonsai rule compilation. The parser carries dozens of live-derived teachings and heals for real 8B-model instincts (accumulators, dot-paths, ternaries, sentence-form conditionals, call-wrapped bindings…).
  • Pure kernel — deterministic step function (no I/O, no clocks): interception protocol, prompting (LAWS + byte-exact few-shots), tree-of-thought backtracking with identical-failure escalation and restart, completion contracts, protocol repairs (phantom-variable guard, post-answer-noise skipping, duplicate-call detection).
  • Reaqtor substrate — checkpointing engine host, kill-safe atomic file store (version-gated snapshot skip), a derivation driver that re-issues in-flight effects on recovery with the same request ids — gated on tool idempotency so side-effecting calls are never double-fired — and an LLM transport self-heal with capped backoff.
  • Two execution modes — Mode A (hedge-by-hedge interception) and Mode B (ask --mode-b): one schema-constrained completion returns the complete program in the papers' {comment|expression}[] interchange form, executed through the same recognizer/evaluator with durable tool suspension. Mode B is the conformance floor for models that can't hold the interception protocol.
  • MCP bridge--mcp "<command>" surfaces any MCP stdio server's tools as Universalis predicates, invoked through the durable hedge protocol (never native function calling): register discipline, checkpointed suspension, and backtracking apply unchanged. Idempotency comes only from server annotations; server specs persist with the data directory and reconnect on resume. A self-contained sample server (tools/McpSampleServer) removes external dependencies.
  • Model-swap matrixscripts/run-model-matrix.ps1 measures any installed model against the conformance gate, four Mode A derivations, and the Mode B floor; verdicts in docs/model-matrix.md. Measured: qwen2.5-coder:7b fully conformant and fastest on every cell; granite3.3:8b Mode A; qwen3:8b Mode A (fragile — thinking eats segment budget; a streaming <think> suppressor keeps chain-of-thought from ever executing); gemma4 Mode B only — the fallback story validated by measurement.
  • Full observability — the pure kernel is observed around: every kernel trace event rides derivation.step spans as automind.trace.* events, so the span stream reconstructs the complete internal logic flow. Spans for LLM calls, tool invocations (+mcp.call), engine lifecycle, store persistence (backup fallback = Error status, never silent), rules, and RAG recall; counters for backtracks/restarts/repairs/answers/failures; a JSONL file sink (--otel-log) so every run leaves a greppable artifact. The CLI surfaces generation wall time (heartbeat, slow-segment annotations, per-answer LLM footer).
  • The six paper demosdemo list / scripts/run-demos.ps1: the composed WEATHER rule, loopless bulk PDF conversion, contracts (holds + instant zero-LLM refusal), the BTC conditional checklist, and the flagship grouped query as a stored intentional program. Every worked example in the two papers is implemented — as demos, golden tests, live tests, or few-shot exemplars.

Validation

  • 176 fast tests (golden transcripts, kill/recover matrix, store atomicity, in-process MCP loopback, paper examples as fixtures) + Ollama/embedding-gated live suites.
  • Demo pack 6/6 first-attempt on granite3.3:8b; the flagship chaos-kill → resume → exactly-one-answer cycle verified live, including on the public NuGet packages.
  • Max-effort adversarial code review (55 agents, 51 verified findings): all 15 reported correctness bugs fixed with regression tests — including a recovery double-fire, a permanent CLI hang, an unbounded success-path loop, and two silent-wrong-answer classes.
  • Runtime-profiled clean (dotnet-counters + dotnet-trace): flat working set, 21 ms total GC pause per derivation, no CPU hotspots (~97% of sampled time is threads waiting on the model, as designed).

Running it

Prereqs: .NET 10 SDK and Ollama with granite3.3:8b. Everything else — including the Reaqtor/Reaqtive/Nuqleon stack (1.0.0-beta.24) — restores from nuget.org.

dotnet test Automind.slnx --filter "TestCategory!=RequiresOllama"   # no model needed
pwsh scripts/run-demos.ps1 -Retries 1                                # the six paper demos
dotnet run --project src/Automind.Cli -- ask "What is the current weather in Palo Alto?" --data .\data

See the README for the flagship durable-reasoning walkthrough (AUTOMIND_CHAOS), Mode B, the MCP bridge, and the observability guide.

Known v1 limits

Tool/rule calls inside conditional branches teach instead of executing (call before the checklist); rules persist as catalog rows rather than engine-defined artifacts; answers can carry model prose verbatim; MCP bridging is stdio-only and maps required parameters only.

Implements Erik Meijer's Automind/Universalis papers (ACM Queue 2024/2025)
as a durable neural computer: a local Ollama model as the branch
predictor, a pure kernel step function intercepting generation at [...]
hedge boundaries, and Nuqleon/Bonsai/Reaqtive/Reaqtor as the load-bearing
substrate - a reasoning derivation is a checkpointed standing query that
survives process death and resumes exactly-once.

- Universalis.Core: hedge scanner/parser (+ live-derived instinct
  teachings and heals), literate recognizer, evaluator (patterns, zip
  lifting, conditionals, query comprehensions -> LINQ), contracts,
  Bonsai rule compilation
- Automind.Kernel: pure derivation step machine, prompt assembly,
  tree-of-thought backtracking + restart, completion contracts, protocol
  repairs (phantom guard, post-answer-noise skip, escalation), Mode B
  whole-program synthesis through the same execution machinery
- Automind.Reaqtor: checkpointing engine host, kill-safe atomic file
  store (version-gated snapshot skip), derivation driver with idempotency-
  gated recovery re-issue and transport self-heal, think-tag suppression,
  full OpenTelemetry instrumentation (kernel trace bridge, JSONL sink)
- Automind.Mcp: MCP stdio servers' tools as Universalis predicates -
  invoked through the durable hedge protocol, never native function
  calling; specs persist and reconnect on resume
- Automind.Memory: in-process ONNX embeddings (bge-micro-v2) as the RAG
  virtual-memory pager
- Automind.Cli: Spectre repl/ask/resume/rules/learn-doc/store/demo, six
  paper demos, chaos kill switch, generation-visibility UX
- scripts: demo-pack runner (per-demo telemetry, failed-attempt log
  preservation), model-swap matrix, embedding model fetch
- docs/model-matrix.md: measured per-model conformance verdicts
  (qwen2.5-coder:7b fully conformant; gemma4 rescued by Mode B)

Restores entirely from public nuget.org (Reaqtor 1.0.0-beta.24;
transitive Newtonsoft.Json advisory lifted to 13.0.4). Hardened by a
max-effort adversarial code review (15 verified findings fixed) and
runtime-profiled clean (flat heap, 21ms total GC pause, no CPU
hotspots). 176 fast tests + Ollama/embedding-gated live suites; demo
pack 6/6 first-attempt.
Copilot AI review requested due to automatic review settings July 17, 2026 07:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR builds out Automind’s “durable reasoning as standing queries” stack on .NET 10 by introducing the Universalis language core (IR + parser/evaluator/rendering), a Reaqtor-backed substrate (durable tool/LLM bridging + checkpoint/recovery plumbing), an MCP bridge (including a self-contained sample server), and a substantial MSTest suite plus scripts/docs to validate model conformance and demos end-to-end.

Changes:

  • Add Universalis.Core: IR model, canonical JSON, parser/scanner, evaluation (numeric tower), and rendering (answer assembly + paper-shape import/export).
  • Add Automind substrate components: Reaqtor artifacts/operators, telemetry surface, durable catalogs, and an Ollama streaming segment bridge with <think> suppression.
  • Add MCP tooling: predicate/signature mapping, stdio bridging, in-process loopback tests, and a tiny sample MCP server.

Reviewed changes

Copilot reviewed 113 out of 114 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tools/McpSampleServer/Program.cs Minimal stdio MCP server with two read-only tools for bridge demos/tests.
tools/McpSampleServer/McpSampleServer.csproj Adds the sample MCP server project with ModelContextProtocol dependency.
tests/Universalis.Core.Tests/Universalis.Core.Tests.csproj Adds Universalis.Core test project (MSTest SDK project).
tests/Universalis.Core.Tests/RoundTripTests.cs Adds round-trip tests for parsing/rendering/IR JSON and paper-shape import/export.
tests/Universalis.Core.Tests/PatternMatcherTests.cs Adds pattern-matching tests (open/closed patterns, arrays, numeric-aware equality).
tests/Universalis.Core.Tests/LiterateRecognizerTests.cs Adds streaming recognizer tests for conditionals and comprehensions.
tests/Universalis.Core.Tests/LiftingTests.cs Adds zip-lifting and tool-plan tests for list/scalar broadcasting behaviors.
tests/Universalis.Core.Tests/HedgeScannerTests.cs Adds hedge scanner tests including incremental vs batch property test.
tests/Universalis.Core.Tests/BonsaiTests.cs Adds Bonsai compilation/serialization tests for rules and conditionals.
tests/Automind.Reaqtor.Tests/ThinkFilterTests.cs Adds tests for <think> suppression behavior in streamed LLM output.
tests/Automind.Reaqtor.Tests/SubstrateHarness.cs Adds a durable-engine harness for kill/recover fidelity and output collection.
tests/Automind.Reaqtor.Tests/FileStoreTests.cs Adds durable store transactional/checkpoint/backup/torn-file behavior tests.
tests/Automind.Reaqtor.Tests/Fakes.cs Adds fake LLM and tool implementations to drive deterministic durability tests.
tests/Automind.Reaqtor.Tests/EngineSmokeTests.cs Adds a checkpoint/recover “standing query resumes” smoke test.
tests/Automind.Reaqtor.Tests/Automind.Reaqtor.Tests.csproj Adds Automind.Reaqtor test project (MSTest SDK project).
tests/Automind.Mcp.Tests/McpPredicateMapperTests.cs Adds tests for MCP → predicate mapping, idempotency, and result mapping.
tests/Automind.Mcp.Tests/LoopbackBridgeTests.cs Adds in-process MCP server loopback tests for list/map/invoke/error paths.
tests/Automind.Mcp.Tests/Automind.Mcp.Tests.csproj Adds Automind.Mcp test project (MSTest SDK project).
tests/Automind.Kernel.Tests/DerivationHarness.cs Adds a golden-transcript harness for stepping the pure kernel deterministically.
tests/Automind.Kernel.Tests/Automind.Kernel.Tests.csproj Adds Automind.Kernel test project (MSTest SDK project).
tests/Automind.Integration.Tests/MemoryPagerTests.cs Adds integration tests for ONNX embedding pager indexing/recall and chunking.
tests/Automind.Integration.Tests/Automind.Integration.Tests.csproj Adds integration test project referencing MCP/Memory/Reaqtor + OllamaSharp.
src/Universalis.Core/Universalis.Core.csproj Adds Universalis.Core project with Nuqleon JSON/Bonsai dependencies.
src/Universalis.Core/Rendering/AnswerAssembler.cs Implements “values view” answer assembly and whitespace normalization.
src/Universalis.Core/Parsing/UniversalisParser.cs Adds batch parser with tolerant “markdown-like bracket” reclassification.
src/Universalis.Core/Parsing/HedgeScanner.cs Adds incremental hedge scanner + batch splitter with serializable state.
src/Universalis.Core/Ir/Terms.cs Defines IR terms + arithmetic expression AST with JSON polymorphism.
src/Universalis.Core/Ir/Statements.cs Defines IR statements (calls, bindings, comparisons, display).
src/Universalis.Core/Ir/Program.cs Defines program items + structured blocks (conditional/comprehension) + contracts/rules.
src/Universalis.Core/Ir/PaperShape.cs Implements paper-shape JSON export/import (Mode B interchange form).
src/Universalis.Core/Ir/IrJson.cs Provides canonical IR JSON serialization/deserialization entry points.
src/Universalis.Core/Evaluation/NumericOps.cs Implements decimal-first numeric tower and numeric-aware structural equality.
src/Universalis.Core/Evaluation/EvalTypes.cs Defines evaluation outcomes, tool lifting plan types, and signature catalog.
src/Universalis.Core/Evaluation/EvalEnv.cs Implements sigma environment with canonical JSON text and lazy JsonNode memoization.
src/Universalis.Core/Compilation/BonsaiSerialization.cs Adds Bonsai JSON serialization glue for compiled rule trees.
src/Automind.Tools/PrimitiveTools.cs Adds deterministic primitive tools (WEATHER/TODAY/MATH) as tool relations.
src/Automind.Tools/ITool.cs Defines tool abstractions and tool registry conventions (automind://tools/*).
src/Automind.Tools/Automind.Tools.csproj Adds Automind.Tools project referencing Universalis.Core.
src/Automind.Reaqtor/Telemetry/AutomindDiagnostics.cs Adds shared telemetry surface (ActivitySource + Meter/counters/histograms).
src/Automind.Reaqtor/Reactive/ToolInvokeObservable.cs Adds in-engine artifact for tool routing and async invocation execution.
src/Automind.Reaqtor/Reactive/TimerObservable.cs Adds stateless periodic observable marshaled onto engine scheduler.
src/Automind.Reaqtor/Reactive/IngressObservable.cs Adds reliable ingress observable with sequence persistence and replay.
src/Automind.Reaqtor/Reactive/EgressObserver.cs Adds reliable egress observer with stable sequence IDs across recovery.
src/Automind.Reaqtor/Reactive/DerivationOutput.cs Adds DTO for derivation outputs across client↔engine boundary.
src/Automind.Reaqtor/Reactive/ConsoleObserver.cs Adds a simple console sink observer for diagnostics.
src/Automind.Reaqtor/Llm/ThinkFilter.cs Adds leading <think> suppressor to prevent accidental hedge execution.
src/Automind.Reaqtor/Llm/OllamaSegmentStreamer.cs Adds streaming hedge-cut segment streamer + Mode B schema decoding support.
src/Automind.Reaqtor/Llm/OllamaLlmService.cs Adds production LLM service with transient transport retry policy.
src/Automind.Reaqtor/Llm/ILlmService.cs Defines LLM service abstraction and segment result DTO.
src/Automind.Reaqtor/IO/ReliableSubject.cs Adds in-memory reliable subject with dedupe and replay by sequence ID.
src/Automind.Reaqtor/IO/IReliableSubject.cs Adds reliable subject interface used by ingress/egress manager.
src/Automind.Reaqtor/IO/AutomindIngressEgressManager.cs Adds get-or-create topic manager to avoid recovery-order traps.
src/Automind.Reaqtor/Engine/AutomindUris.cs Defines Automind-owned artifact URI catalog.
src/Automind.Reaqtor/Engine/AutomindServices.cs Defines operator-context service injection bundle for engine operators.
src/Automind.Reaqtor/Engine/AutomindEngineFactory.cs Adds engine create/recover helper with initial artifact checkpointing.
src/Automind.Reaqtor/Engine/AutomindArtifacts.cs Defines artifact catalog (timer/ingress/egress/derivation/tool router).
src/Automind.Reaqtor/Client/AutomindClientContext.cs Adds strongly-typed client context for known engine artifacts.
src/Automind.Reaqtor/Catalog/ToolRegistryStepContextProvider.cs Builds per-step context snapshot from tool registry and learned rules.
src/Automind.Reaqtor/Catalog/RuleCatalogStore.cs Adds durable rule catalog storage with IR + Bonsai JSON.
src/Automind.Reaqtor/Catalog/McpCatalogStore.cs Adds durable MCP server command persistence per data directory.
src/Automind.Reaqtor/Catalog/DocCatalogStore.cs Adds durable document store for later re-embedding on startup.
src/Automind.Reaqtor/Catalog/ConversationCatalog.cs Adds durable conversation index to support recovery-order topic creation.
src/Automind.Reaqtor/Automind.Reaqtor.csproj Adds Automind.Reaqtor project and pins Newtonsoft.Json via central packages.
src/Automind.Memory/OnnxMemoryPager.cs Adds in-process ONNX embedding pager and paragraph-aware chunking.
src/Automind.Memory/Automind.Memory.csproj Adds Automind.Memory project and suppresses SK experimental warnings.
src/Automind.Mcp/McpToolBridge.cs Adds stdio MCP client bridge to surface MCP tools as Universalis predicates.
src/Automind.Mcp/McpPredicateMapper.cs Adds pure mapping for tool naming/signatures/idempotency/result mapping.
src/Automind.Mcp/McpBridgedTool.cs Adds ITool wrapper over MCP tool invocation (throws on error results).
src/Automind.Mcp/Automind.Mcp.csproj Adds Automind.Mcp project with ModelContextProtocol dependency.
src/Automind.Kernel/Prompting/PromptState.cs Adds serializable prompt state for durable LLM request re-issuance.
src/Automind.Kernel/Contract/TraceEvents.cs Adds user-facing trace event contract (JSON polymorphic).
src/Automind.Kernel/Contract/QuestionEnvelope.cs Adds question envelope contract including σ bindings, outputs, contracts, Mode B.
src/Automind.Kernel/Contract/DerivationState.cs Adds full checkpointed derivation state model (including Mode B queue/pc).
src/Automind.Kernel/Contract/DerivationEvents.cs Adds derivation event/effect contracts plus step-context snapshot shape.
src/Automind.Kernel/Automind.Kernel.csproj Adds Automind.Kernel project referencing Universalis.Core.
src/Automind.Cli/OtelFileLog.cs Adds JSONL file exporter for spans/metrics (minimal OpenTelemetry sink).
src/Automind.Cli/CheckpointCoordinator.cs Adds serialized host-side checkpoint policy (debounce + periodic safety).
src/Automind.Cli/Automind.Cli.csproj Adds CLI project dependencies (Spectre.Console, OpenTelemetry, OllamaSharp, etc.).
scripts/run-model-matrix.ps1 Adds script to run conformance + derivation battery across Ollama models and write report.
scripts/run-demos.ps1 Adds demo runner script with retries and per-demo telemetry artifacts.
scripts/fetch-embedding-model.ps1 Adds helper script to download the bge-micro-v2 ONNX embedding model files.
NuGet.config Restricts restore to nuget.org feed.
global.json Pins .NET SDK 10.0.300 and Microsoft.Testing.Platform runner configuration.
docs/model-matrix.md Adds a captured model-swap matrix report with findings and rerun guidance.
Directory.Packages.props Adds central package management and pins versions (Reaqtor stack, AI, telemetry).
Directory.Build.props Sets repo-wide net10.0, LangVersion 14.0, nullable, implicit usings, Werror.
Automind.slnx Adds solution definition containing src/tests/tools projects.
.gitignore Adds ignores for build outputs and runtime state/model directories.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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