Skip to main content

Primus — the installable seed

Author: Jacob Iannotti. Licensed under PolyForm Noncommercial 1.0.0 — free to use, modify, and share for any noncommercial purpose; commercial rights reserved (see the repository-root LICENSE.md).

Primus is the clean, auditable core of the whole vault, now shipped as a Python package: exact invariant recovery with held-out verification and refusal — plus that discipline turned into an accountability certificate for LLM/agent output. One idea: never certify what you cannot exactly verify.

From the vault root (PyPI name: primus-intelligence):

pip install ./Primus

Two operations

collapse — recover the minimal generator beneath a codified surface (numbers, text, ciphers, graphs, schemas, code) under a two-part MDL criterion in exact arithmetic. Verified means one thing only: the rule exactly predicted held-out data it never saw. Anything else is an honest residual, never a confident guess.

from primus import collapse
inv = collapse([1, 1, 2, 3, 5, 8, 13, 21])
inv.verified        # True — held-out terms predicted exactly
inv.explanation     # what was recovered, why it is believed

certify — the front door for the agent era: feed it a model's output, and every checkable claim comes back VERIFIED, REFUTED, or REFUSED; the free-text remainder is reported as unverifiable, never blessed. Checkable kinds (schema primus.certificate/2, contract in SCHEMA.md, shipped in the licensed vault): exact arithmetic incl. powers, percentages, primality, binomials, gcd/lcm, modular and date arithmetic, sums/averages, sequence continuations, and integer runs. Gate an agent on refuted == 0, then read coverage before trusting the pass — a passing gate means nothing checkable was refuted, never the output is true.

from primus import certify
cert = certify("2+2=5. The sequence 2 4 6 8 continues as 10, 12.")
cert["counts"]      # {'checkable': 2, 'verified': 1, 'refuted': 1, 'refused': 0}

The second line exits 1 on any refuted claim — pipe your model's output in place of the example text:

primus collapse "1 1 2 3 5 8 13 21"
echo "17*3 = 51 and 2+2 = 5" | primus certify - --json --gate
primus selftest

Guess-and-prove — primus.conjecture (optional)

The symbolic-regression baseline this project benchmarks against (SYMREG_RESULTS.md) can also serve it: primus conjecture "0 1 128 2187 …" lets a gplearn genetic-programming proposer suggest closed forms for an input the engine refuses — and stamps a candidate ONLY if, after snapping its float constants to exact integers/rationals, it reproduces every supplied term exactly in rational arithmetic, including a holdout suffix the search never saw. The stochastic proposer never stamps; the exact verifier does, and the certificate says exactly what was proven (fit to the given data — never the true generator). Without pip install primus-intelligence[conjecture] the stage degrades to an honest REFUSED. A verified conjecture emits the claim a(n) = <expr> matches <terms>, which the certify gate checks independently as the closed_form claim kind — guess-and-prove output round-trips through the gate. On the live OEIS corpus the gate converted the raw regressor's 27 wrong answers into 26 refusals + 3 exact stamps, with zero stamped-wrong (SYMREG_RESULTS.md).

The MCP server — the gate as agent infrastructure

primus-mcp serves both operations over the Model Context Protocol (stdio, dependency-free), so any MCP-speaking agent can call the verifier natively — certify its own draft answer, gate on counts.refuted == 0, and treat the unverifiable remainder as exactly that.

primus-mcp speaks newline-delimited JSON-RPC on stdio; the second line registers it with Claude Code:

primus-mcp
claude mcp add primus -- primus-mcp

Claude Desktop / Cowork (claude_desktop_config.jsonmcpServers):

{ "primus": { "command": "primus-mcp" } }

Tools exposed: certify(text) → the full certificate as structured content; collapse(surface) → the invariant (or an honest refusal). A refuted claim is a result, not a tool error — isError is reserved for real failures. Protocol conformance is gated by python3 test_mcp_server.py (10 handshake gates against the live subprocess).

The code

src/primus/engine.pythe seed, and the single source of truth (~1,250 lines). The novel part by itself, easy to read and audit in one sitting: collapse, same_generator, cast, transcode, the twin spaces. invariant_engine.py at this folder's root is a compatibility shim so every historical entry point still works.

src/primus/certify.py — the certificate layer: claim extraction (arithmetic, percentages, sequence continuations, integer runs), exact checking through the engine, four-way honesty (verified / refuted / refused / unverifiable), SHA-256 attestation.

src/primus/cli.py — the primus command.

The full integrated system — certification core, intake standardizer, ambiguity crucible, field substrate, organism layer, and this engine as its invariant operation — is Chiron: ../Chiron/chiron.py. There is one program, Chiron; this folder is where its engine began and the clearest place to read the idea in isolation.

The proof

test_invariant_engine.py — the stress tests (48/48). Run it to confirm everything works on your machine.

python3 test_invariant_engine.py

benchmark.py — the proving run: feeds the engine known-generator sequences, shows it part of each, and grades whether the rule it recovered predicts terms it never saw. Results in the reconciled battery map: recovery 98%, precision 100%, zero false confidence.

oeis_live.py — the external proving run: the same held-out discipline against sequences fetched live from OEIS rather than a self-generated bank. Results and the honest miss list in the public external eval.

bench_symreg_external.py / bench_pysr.py — head-to-head against established symbolic-regression baselines (gplearn results in docs/SYMREG.md; PySR harness included, runs wherever PySR is installed).

test_certify_fuzz.py — adversarial gates: hostile input must crash nothing, respect every work bound, and never flip a planted verdict. The fuzzer has already earned its keep twice (a sequence-flood DoS and a quadratic scan cost, both found and fixed — see CHANGELOG.md, shipped in the licensed vault).

test_mcp_server.py — the MCP protocol handshake against the live subprocess.

drift_check.py — differential testing against ../Chiron/chiron.py: contradictions between the seed and the monolith fail the build; deliberate capability differences must be ledgered with a dated reason.

The background

Primus Flow Chart.svg — the system diagram: the cells and every level of the organism the engine grew into, laid out visually.

The Caramuel Primus Calamus (1663) source material — the book with the twin labyrinths the engine uses as built-in ground truth — lives with the ambiguity work in ../Infectatrum.

Requirements

Python 3.9+ with numpy. Everything runs offline; no network, no API keys (oeis_live.py is the one deliberate exception — it exists to fetch external ground truth). __pycache__ folders are auto-generated and safe to delete. The guess-and-prove stage (primus.conjecture) optionally uses gplearn + scikit-learn (pip install primus-intelligence[conjecture]); absent, it refuses honestly and everything else is unaffected.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

primus_intelligence-0.6.4.tar.gz (65.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

primus_intelligence-0.6.4-py3-none-any.whl (66.4 kB view details)

Uploaded Python 3

File details

Details for the file primus_intelligence-0.6.4.tar.gz.

File metadata

  • Download URL: primus_intelligence-0.6.4.tar.gz
  • Upload date:
  • Size: 65.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for primus_intelligence-0.6.4.tar.gz
Algorithm Hash digest
SHA256 70542746e458f56d857b37e11c0852148288878fafd6b80d327a576d7c406454
MD5 a2394db11db02b17ee314b38e8804ed7
BLAKE2b-256 e76a0547004ba6be359c02c7fda917a83617056ba1b93aca1eda4bc2e16dee4e

See more details on using hashes here.

File details

Details for the file primus_intelligence-0.6.4-py3-none-any.whl.

File metadata

File hashes

Hashes for primus_intelligence-0.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d22b1354b2eb278496fc8d4655dbc233ccab52f86eb93ca63a0b1c8870184993
MD5 c85abae767a43e26468f8d3c3dd38993
BLAKE2b-256 7a0cd920fc7f5405b263790e148470f287f311cb5cb45af0ad12a91988c7dc5d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page