Metadata-Version: 2.4
Name: rhi-mynd
Version: 0.7.0
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)

[![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 0.6.1](https://img.shields.io/badge/version-0.6.1-informational.svg)](CHANGELOG.md)
[![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.24766394-blue.svg)](https://doi.org/10.5281/zenodo.24767268)
[![Tests](https://img.shields.io/badge/tests-119%20passing-brightgreen.svg)](#run-it)

## 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, 212 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.6.0, DOI
[10.5281/zenodo.24767268](https://doi.org/10.5281/zenodo.24767268)
(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`.

**License:** MPL-2.0. See [LICENSE](LICENSE). 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.

## Quickstart

```
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, thresholded retrieval. |
| 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%, coherence cut x0.7, relief phase, 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 (10 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. 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. 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`, 7 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). 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. |
| Benchmarks | `benchmarks/` | Runnable harness (`python3 -m benchmarks.run`): memory recall, collapse recovery, gate discipline, determinism, throughput. 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   # 212 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.

## 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

- **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:** 10% memory-recall hit rate on the
  fixed 50-fact task (storage-side loss under collapse selection is
  the measured bottleneck — see docs/BENCHMARKS.md). No external
  benchmark (SWE-bench etc.) has been run; that needs a real model.
- **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 per rebirth outcome, clamped), not
  gradient learning; whether the adapted weights improve any measured
  outcome is 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.
