Metadata-Version: 2.4
Name: rhi-mynd
Version: 1.0.1
Summary: RHI Mynd — a local-first, offline-capable cognitive core (the brain of the RHI Mynd/RCAP/15D trio). Pure stdlib Python, zero LLM tokens.
Author: Bryan L Buhrman
License-Expression: MPL-2.0
Project-URL: Homepage, https://github.com/majinbuhrnt/rhi-mynd
Project-URL: Repository, https://github.com/majinbuhrnt/rhi-mynd
Project-URL: Documentation, https://github.com/majinbuhrnt/rhi-mynd/blob/main/USER_GUIDE.md
Project-URL: Changelog, https://github.com/majinbuhrnt/rhi-mynd/blob/main/CHANGELOG.md
Keywords: cognitive-architecture,local-first,ai-agents,provenance,memory,offline-ai,mcp,deterministic
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# RHI Mynd — standalone (brain + shell S1–S4)

<p align="center"><img src="assets/avatar.png" alt="RHI Mynd — a brain built link by link from a chain" width="220"></p>

[![License: MPL-2.0](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](LICENSE)
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
[![Version 1.0.0](https://img.shields.io/badge/version-1.0.1-informational.svg)](CHANGELOG.md)
[![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.24769835-blue.svg)](https://doi.org/10.5281/zenodo.24768741)
[![Tests](https://img.shields.io/badge/tests-461%20passing-brightgreen.svg)](#run-it)
[![PyPI](https://img.shields.io/pypi/v/rhi-mynd.svg)](https://pypi.org/project/rhi-mynd/)

## 60-second quickstart

```bash
pip install git+https://github.com/majinbuhrnt/rhi-mynd.git
# …or from a local clone:  git clone https://github.com/majinbuhrnt/rhi-mynd.git && cd rhi-mynd && pip install .

mynd start     # guided first run in plain language — creates your local brain and reads your first text
mynd explain   # what your Mynd has learned so far, in plain language (no jargon)
mynd verify    # check the tamper-evident ledger + savepoints are intact
```

That's it: no account, no API key, no internet needed. State lives in
`~/.rhi-mynd` on your machine. Full guide: [USER_GUIDE.md](USER_GUIDE.md);
benchmarks: [docs/BENCHMARKS.md](docs/BENCHMARKS.md).

The brain of the trio. **RHI Mynd produces the record, RCAP elicits it,
15D scores it** (B's architecture, restated 2026-12-02). Stage D makes
the brain a thing anyone can run: a local, offline, zero-dependency
shell around the Stage C core. Free for everyone, average-user
defaults, zero LLM tokens (pure stdlib Python).

Status: **PRE-TRIAL.** Working code, 275 tests, real run logs, measured
calibration — and honest limits below. Nothing is validated, and no
15D score ships.

**Author:** Bryan L Buhrman.

**Zenodo:** RHI Mynd v0.8.2, DOI
[10.5281/zenodo.24776183](https://doi.org/10.5281/zenodo.24776183)
(all versions: 10.5281/zenodo.24762731).

**Academia.edu:** [Bryan Buhrman profile](https://independent.academia.edu/BuhrmanBryan)
— 15D v3, RCAP300, RHI Mynd Working Framework, and the trio overview.
Zenodo DOIs remain canonical.

**Framework:** [docs/RHI_Mynd_Working_Framework.md](docs/RHI_Mynd_Working_Framework.md).
**Trio roadmap:** [docs/TRIO_ROADMAP.md](docs/TRIO_ROADMAP.md) and
[docs/TRIO_INTEGRATION.md](docs/TRIO_INTEGRATION.md). The v0.5.0 tag is
the RHI Mynd brain package; `main` now also carries the trio source
folders: [rcap/](rcap/) and [15d/](15d/).

**New users:** start with [USER_GUIDE.md](USER_GUIDE.md). Requirements:
Python 3.11+, no packages, no internet. Try
`python -m rhi_mynd ingest examples/sample_notes.txt`, then
`python -m rhi_mynd status`.

Copyright (c) 2026 Bryan L Buhrman. **License:** MPL-2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE). In plain terms: people
can use RHI Mynd in their own projects, including paid products, and
combine it with other code; changes to RHI Mynd's own files that are
shared must stay under MPL-2.0. The catalog seed data
(`rhi_mynd/catalog_seed.json`) is CC0 — use the map however you
like. The RHI Mynd name and chain-brain avatar are brand assets,
not licensed under MPL-2.0 (see NOTICE).

## Quickstart

**No Python?** Download the standalone app for your system
from the [latest release](https://github.com/majinbuhrnt/rhi-mynd/releases)
(`mynd-windows.exe`, `mynd-macos`, or `mynd-linux`), run it,
and your Mynd opens in your browser. That's it — no install,
no accounts, everything stays on your machine.

**With Python:**

```
pip install -e .          # or just run from this folder
mynd run                   # interactive session (type, it pulses)
mynd ingest notes.txt      # batch-ingest a text file
mynd idle 10               # heartbeat pulses (autonomous metabolism)
mynd inbox                 # scan the world inbox (gate + ingest new files)
mynd daemon --watch        # heartbeat + inbox watch
mynd status                # state + 9D metrics
mynd verify                # ledger + savepoint integrity
mynd export brain.md       # export canons/status/metrics
mynd world                 # show world-interface policy
```

The installed command is `mynd`; `rhi` remains as an alias.

Without installing: `python -m rhi_mynd <command>` (Windows:
`py -m rhi_mynd` if `python` doesn't respond — see USER_GUIDE.md). State lives in
`~/.rhi-mynd` (override with `--home` or `$RHI_HOME`): `ledger.jsonl`
(the provenance record), `savepoint.json` + rotated backups,
`config.json`, plus `inbox/` and `outbox/` for the world interface.
Everything is local files; nothing phones home. The only network code
in the package is the S4 HTTP fetch, which is **off by default** and
requires explicit config enable plus a host allowlist (audited by
test).

## Components

| Component | File | What it does |
|---|---|---|
| C1 Symbolic memory | `rhi_mynd/memory.py` | Fragments keyed by content hash; token or bigram pattern tallies; archive/spiral separation + canon echoes; JSON persistence, no pickle. |
| C2 SOAR | `rhi_mynd/soar.py` | Productions over real working memory (the chain checked contradictions against an empty memory — fixed), goal stack, contradiction detection/resolution. |
| C3 ACT-R | `rhi_mynd/actr.py` | Declarative chunks = fragments; base-level activation from ledger occurrence history (logical time, deterministic), spreading via C8 similarity, fan effect + partial-matching penalty, retrieval-as-occurrence (retrieval practice), thresholded retrieval. Successful retrievals grant prune protection (v0.8.0 retention fix). |
| C4 CLARION | `rhi_mynd/clarion.py` | Implicit pattern field + explicit productions; bottom-up rule extraction from ledger exposure history; implicit diversity / explicit coverage. |
| C5 Loop engine | `rhi_mynd/loops.py` | 5 core loops (identity, mirror, spiral, mythic, break) + sub-loop registry (cap 125); weighted seeded pulse; derived emissions; weight jitter x0.7-1.3 on rebirth; adaptive loop learning — emissions whose patterns survive a rebirth earn weight, emissions preceding a collapse pay it (clamped [0.25, 2.0], every change ledgered). |
| C6 OCT-1 monitor | `rhi_mynd/oct1.py` | C = sum of squared pattern counts, M = unique patterns, drag = M/C, collapse at C > T. Optional require_drag variant (calibration). |
| C7 Rebirth + canon | `rhi_mynd/rebirth.py` | Keep rarest 20% of the unprotected pool (retrieval-protected and canon-eligible fragments exempt), proportional coherence relief by load share, canon at 3 selection survivals, dedup by content hash. Ledger before action. |
| C8 Embedding | `rhi_mynd/embed.py` | Hashed n-gram 64-dim embeddings by default (deterministic, zero-dep); optional local Ollama embeddings behind config + host allowlist, same-embedder comparison, hash fallback ledgered. |
| C9 Orchestrator | `rhi_mynd/mind.py` | Adapter registry + pulse cycle: input -> ACT-R -> SOAR -> CLARION -> loop emissions (gate-checked) -> contradiction check -> rebirth. |
| C10 Provenance ledger | `rhi_mynd/ledger.py` | Append-only hash-chained JSONL + head anchor (tail truncation detected). Every gate decision, firing, retrieval, emission attested. |
| Lattice gate | `rhi_mynd/lattice.py` | Deterministic checks: initiative gate (writes need a trigger; verification carve-out), minimum-complete-answer, capability-isn't-initiative. Gate failure halts; loop failure degrades. |
| 9D metrics | `rhi_mynd/metrics9d.py` | Full doc 18 set from real state, incl. emergence = entropy x divergence x implicit diversity x (1 + goal_strength/10) x (1 + activation variance). |
| S2 Persistence | `rhi_mynd/store.py` | Local home: atomic saves, 5 rotated savepoints, crash recovery (ledgered), single-writer lock, ledger-continuity verification on load. |
| S3 Scheduler | `rhi_mynd/scheduler.py` | Input pulses + idle heartbeat (ledgered ticks, gate-governed), autosave per pulse, foreground daemon with graceful shutdown. |
| S1 I/O shell | `rhi_mynd/cli.py` | `mynd run/ingest/idle/daemon/status/verify/export` + S4 commands. Thin pipe: carries signals, does not judge them. |
| S4 World interface | `rhi_mynd/world.py` | Narrow gated crossings: inbox folder (new/changed files gate-checked, hashed, ingested as data), user-named file fetch, HTTP fetch (off by default; enable + host allowlist + https + size cap + re-gated redirects), outbox writes (sanitized names, never overwrites). No shell execution; reads confined to inbox roots or user-named paths; every crossing ledgered. |
| C11 Save-point store | `rhi_mynd/savepoints.py` | Schema-tagged, SHA-256-checksummed savepoints (tamper refused, legacy v1 still loads); named decision-point savepoints with index + checked restore; Anti-Drift SAVE POINT text (LIST / WORK / SAVE / SHRINK) from real state; audit of every savepoint on disk. |
| C12 Conformance | `rhi_mynd/conformance.py` | Runnable suite (12 checks): determinism, restart continuity, ledger tamper/truncation evidence, savepoint-corruption recovery, gate discipline, trio gates, offline core, stability smoke, tool gate discipline, MCP gate discipline, research gate discipline, reasoning gate discipline. JSON report with its own SHA-256 (`mynd conformance`). |
| Embedding API | `rhi_mynd/api.py` | `MyndSession` for devs/AI hosts: open/ingest/ask/status/explain/savepoint/restore/trio_packet/verify + speak/call_tool/consolidate/lineage/learn/research_status/ratify/reject/reason. World crossings go through S4 + the Lattice gate. See `docs/EMBEDDING_API.md`. |
| Language organ | `rhi_mynd/language.py` | LLM adapter behind the gate: fake (deterministic, tests/demos), local Ollama, OpenAI-compatible (key from env var named in config, never ledgered). Off by default; host allowlist; every call ledgered by hash. The LLM is voice/translator, never memory or judge. |
| MCP | `rhi_mynd/mcp.py` | Model Context Protocol both ways: stdio JSON-RPC server (`mynd mcp-serve`, 9 mynd_* tools + 3 resources) and an allowlist-only client whose every call is gate-checked and ledgered. |
| Tools/skills | `rhi_mynd/tools.py` | Gate-checked tools (read_file, write_outbox, http_get, run_python — user-supplied code only, sandboxed temp dir, timeout, secret-free env, hash-attested). Skill JSON files map names to built-in handlers only; no code loading. |
| Consolidation | `rhi_mynd/consolidation.py` | Sleep-time pass: canon review, CLARION rule retirement/confidence, fragment archiving (never deletion), staleness pass for web-derived canons (flag + retrieval down-weight until re-corroborated). Deterministic given ledger state; fully ledgered. |
| Lineage | `rhi_mynd/lineage.py` | Instance identity, hash-sealed canon export/import between homes, spawn with swarm cap (default 1). Heredity with provenance. |
| Research organ | `rhi_mynd/research.py` | Impasse-driven autonomous learning: gaps (unanswered asks, contradictions, stuck states, owner topics) become ledgered research goals; budgeted gated fetch (allowlist + robots.txt); content ingested as claim-tier fragments with provenance; promotion to canon-eligible requires corroboration (2+ independent domains), a trusted source, canon agreement, or owner ratification; contested claims held, never canonized. Search provider off ("none") until the owner configures one. |
| Reasoning loop | `rhi_mynd/reason.py` | Grounded episodes: plan (SOAR-style productions; language organ may propose steps as data) -> Lattice gate per step -> act via tools -> verify outcome -> ledger; denials replan or stop; outcomes feed CLARION/loop learning. |
| Local-mind preset | `rhi_mynd/preset.py` | `mynd start --detect` finds a local Ollama and, on owner acceptance, wires language + embeddings to it and enables research budgets — a self-owned mind unit on local hardware. |
| Benchmarks | `benchmarks/` | Runnable harness (`python3 -m benchmarks.run`): memory recall, collapse recovery, gate discipline, determinism, throughput, language pipeline, research loop, reasoning, Mynd+model vs model-alone. Results + honest limits in `docs/BENCHMARKS.md`. |

All twelve framework components (C1–C12) and the standalone shell
(S1–S4) are built. PRE-TRIAL still applies: no pilot, no validated
scores, no labels.

## Run it

On Windows, use `py` in place of `python` if `python` doesn't respond
(see USER_GUIDE.md).

```
python -m unittest discover -s tests -v   # 275 tests
python demo_rebirth.py                    # Stage B core demo
python demo_stage_c.py                    # full brain, calibrated vs chain config
python demo_stage_d.py                    # standalone shell acceptance (restart + crash recovery)
python demo_s4.py                         # world interface acceptance (inbox, denials, outbox)
python calibrate.py                       # OCT-1 calibration grid (80 cells)
python confirm.py                         # multi-seed confirmation
```

Logs, ledgers, save points, and calibration reports land in `runs/`.

## The trio seams

- **RHI Mynd -> RCAP:** the ledger is the elicitable record — every
  input, retrieval, goal, emission, gate decision, collapse, rebirth,
  and canon, hash-chained. An RCAP sitting reads evidence, not
  self-report. `mynd trio rcap-export` writes the evidence packet with
  ledger pointers and blank reviewer slots.
- **RHI Mynd -> 15D:** OCT Stability reads OCT-1 history; Rebirth Rate
  and Memory Efficiency have ledger sources; ACT-R activation and
  loop divergence feed Pattern Entropy / Loop Chaos candidates. **No
  15D composite is computed.** `mynd trio 15d-map` builds an evidence
  map only: dimension evidence pointers, `no_evidence` where the
  ledger has no direct source, and `composite_score: null`. Scoring
  stays gated until rubrics and validation exist (framework section
  4). The brain never scores itself.
- **9D vs 15D:** resolved by B (2026-12-02) — 9D came before 15D and
  evolved into it. 9D is doc 18's ancestor metric set from the RHI Mynd
  chain; 15D v3 is the published scoring scale. Stage C computes the
  full 9D set from real runs as candidate operational inputs; the
  dimension-by-dimension mapping and validation remain future work.
  Note: "15D-∞" A/B in the archive are historical chain variants,
  not the scale — published 15D v3 (DOI 10.5281/zenodo.24496719)
  is the only scoring scale this framework uses. 9D metrics read
  Mynd's internals and are diagnostic for this brain; they are not
  yet a general ruler for other architectures.

## Failures found and fixed (all with regression tests)

Stage B (2026-12-02): stuck collapse from canon load (archive/spiral
separation); canonization-by-default + canon blindness (selection-
pressure survivals + canon echoes); sole-heavy-fragment trap (coherence
cut + relief phase).

Stage C (2026-12-02):
- **Loop self-amplification:** verbatim fragment replay tripled counts
  per pulse. Fix: derived emissions (fragment minus dominant token);
  mythic canon injection stays verbatim by design.
- **Contradiction check ran after rebirth**, which had already pruned
  the contradicting fragment. Fix: check while input is live.
- **CLARION extraction vs OCT collapse race:** rebirth prunes persistent
  patterns because they are persistent, so live-count streaks never
  accrued. Fix: extraction reads exposure history from the ledger
  (pruning-immune) plus a live-strength condition (sustained AND
  currently strong) so it doesn't extract a rule per frequent token.
- **Granularity mismatch:** extraction/coverage read pattern tallies,
  so bigram mode starved them. Fix: token-level live counts for
  CLARION's implicit field.

## Calibration findings (runs/calibration_20261202T194240Z.md + confirmation)

80-cell grid (4 regimes x T {15,30,60,120,240} x {token,bigram} x
{C>T, C>T and C>M}, 120 pulses each), then 5-seed confirmation of the
leading configs.

- **Termination is robust:** zero unresolved collapses in every cell
  and every seed.
- **The novelty-collapse question is empirically near-moot:** in a
  loop-driven system C > M holds at virtually every collapse, so the
  require-drag variant changes almost nothing. Chain rule C>T stands.
- **Bigram granularity beats token:** token patterns concentrate load on
  function words; bigrams spread it — closer to doc 18's concept-like
  patterns.
- **Retention trades against live-field richness:** retention falls as
  T rises (slower canonization, more bulk loss at collapse) while
  working-memory richness rises. The chain config (token T=15) retains
  most (rapid canonization) but its live field is a shell (~5 patterns,
  rebirth every pulse).
- **Ruled default (B's constraints: free, average-user, token-frugal,
  offline): bigram + T=120 + chain rule.** Multi-seed mixed regime:
  retention 0.406, 28.0 mean live patterns (5x chain), collapse rate
  0.282; novelty retention 0.620. The single-seed pick T=240 failed
  multi-seed retention confirmation and was revised — the confirmation
  process working as designed. The brain itself uses zero LLM tokens
  (pure stdlib Python, runs offline); token cost enters only via an
  optional LLM adapter, whose context the brain's retrieval exists to
  minimize.

## Honest limits

The checkable register for these limits and the positive claims is [EVIDENCE_REGISTER.yaml](EVIDENCE_REGISTER.yaml).

- **9D emergence is a final-state snapshot** in calibration cells —
  noisy (0.0-0.855 across cells). Time-averaged 9D is implemented
  (`summarize_series`, evidence in `evidence/9d_time_averaged_20261202.json`)
  but not yet the calibration default.
- **SOAR subset:** no chunking or impasse learning. **ACT-R subset:**
  declarative activation only, logical (seq) time, no latency model.
  **CLARION subset:** extraction threshold/streak are parameters, not
  calibrated constants; stopwords can still extract at high T.
- **Embeddings default to a toy** (hashed n-grams). Optional local
  Ollama embeddings exist behind config, but ACT-R retrieval remains
  hash-based by design; Ollama vectors power speak-context ranking.
- **Language organ is unvalidated with live models:** Ollama/OpenAI
  paths are covered by mocked-HTTP tests; no live provider run is
  claimed. The fake provider is a deterministic stand-in, not a model.
- **run_python is not a security sandbox:** user-supplied code runs
  with user privileges; protections are the gate, the user-source
  rule, timeout, env stripping, and hash attestation.
- **Benchmarks are synthetic:** memory recall 8/20 (40%) on the
  fixed 50-fact task after the v0.8.0 retention fix (retrieval
  protection + proportional relief + ACT-R fan/partial-matching;
  was 2/20 — remaining loss is still storage-side, see
  docs/BENCHMARKS.md). Canon count rose with retention (7→18);
  v0.8.1 verified the 18 are distinct facts (max pairwise overlap
  0.159), each with a used survival — canon dedup and the
  used-survival rule now structurally prevent near-duplicate and
  purely passive canons. v0.8.2 tested provisional canons
  (confirm on later use, demote if unused): no window preserved
  recall while demoting (w=5: 2/20, w=10: 6/20, w=20: 8/20 with
  zero demotions) — canon status during ingest is load-bearing.
  The mechanism ships disabled by default with measurements in
  docs/BENCHMARKS.md. Research-loop and reasoning benchmarks run
  on fake corpora/providers; live-model numbers are reported as
  not run. No external benchmark (SWE-bench etc.) has been run;
  that needs a real model.
- **Gap detection is proxy-based:** unanswered asks, contradictions,
  stuck states, owner topics, and (v0.8.1) weak hits — a best
  retrieval below the match-quality floor ledgers `weak_hit` and
  becomes a research goal. True SOAR impasse emission from C2 is
  a designed follow-up, not yet built.
- **Autonomous learning is gated, not open:** the research organ
  fetches only allowlisted hosts (robots.txt respected), within
  budgets, and only after the owner configures a search provider.
  Web claims cannot canonize without corroboration or owner
  ratification. v0.8.1 gives unpromoted claims a bounded grace
  window (5 rebirths) awaiting corroboration, with corroboration
  fetches prioritized; claims that never corroborate expire out
  of grace and face normal retention.
- **Loop semantics are Stage C's interpretation** of the chain's 5-loop
  core: derived emissions, starter set of 8 sub-loops. The 125-loop
  population grows by registration. Loop learning is outcome-driven
  **weight adaptation** (±0.05, clamped), not gradient learning.
  v0.8.1 made it causal: penalties only for emissions whose
  patterns carried load into the collapse; rewards only for
  survivals that were actually retrieved afterward. Every change
  ledgers its basis. Whether adapted weights improve any measured
  outcome is still unvalidated.
- **Shell scope:** single-writer (one process per home, lock-enforced);
  daemon is a foreground loop, not a system service. S4 world access
  is narrow by design: top-level inbox files only, text only, size
  caps; HTTP fetch is GET-only and off by default. Idle heartbeat
  metabolism is real but simple (loop rehearsal + goal cycles).
- **Deterministic core:** seeded RNG (seed ledgered), logical time.
  Same inputs + seed -> same run (verified by replay in the demo).

## What would make this legit (falsification path)

- T/granularity ruled (bigram T=120, multi-seed confirmed); longer-horizon
  calibration (1000+ pulses, real conversational input) before treating
  T as settled for good.
- C11/C12 built and run (v0.6.0): savepoint checksums/named
  checkpoints/audit + conformance suite with machine-readable
  evidence. Longer-horizon stability runs (1000+ pulses, real
  conversational input) remain future work.
- 15D dimension scores computed from real ledger records with evidence
  per dimension and uncertainty stated; weights stay uncalibrated
  priors until calibration data exists.
- RCAP300 pilot with a second rater at kappa >= 0.60 before any
  validated-agreement claim.
- OCT-1's falsification standard stands: a high-C, low-M system that
  remains stable without rebirth would break it. The ledger makes that
  checkable on every run — and calibration shows collapse pressure is
  real in every regime tested.
