Skip to content

Latent-Fields/ree-v1-minimal

Repository files navigation

REE-v1-Minimal

A minimal reference implementation of the Reflective-Ethical Engine (REE) architecture.

Status: Baseline/parity substrate. Active but not primary development target. See ree-v3 for current work.

Overview

REE is a reference architecture for ethical agency under uncertainty. This implementation demonstrates the core concepts:

  • Latent Stack (L-space): Multi-timescale predictive state representation
  • E1 (Deep Predictor): Long-horizon context and world model
  • E2 (Fast Predictor): Short-horizon trajectory rollouts
  • E3 (Trajectory Selector): Ethical trajectory selection with scoring
  • Residue Field Ο†(z): Persistent moral cost as geometric deformation
  • Grid World Environment: Toy environment with harm/benefit signals

Documentation

πŸ“š Complete Documentation - Comprehensive guides and references

Quick Links

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         REE Agent Loop                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  1. SENSE       β†’ Receive observations + harm signals           β”‚
β”‚  2. UPDATE      β†’ Update latent stack z(t) = {zΞ³, zΞ², zΞΈ, zΞ΄}   β”‚
β”‚  3. GENERATE    β†’ E2 generates candidate trajectories ΞΆ         β”‚
β”‚  4. SCORE       β†’ J(ΞΆ) = F(ΞΆ) + Ξ»M(ΞΆ) + ρΦ_R(ΞΆ)                β”‚
β”‚  5. SELECT      β†’ E3 selects trajectory under precision control β”‚
β”‚  6. ACT         β†’ Execute next action                           β”‚
β”‚  7. RESIDUE     β†’ Update Ο†(z) if harm occurred                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Installation

# Clone the repository
git clone <repository-url>
cd ree-v1-minimal

# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -e .

Quick Start

from ree_core import REEAgent
from ree_core.environment import GridWorld

# Create environment and agent
env = GridWorld(size=10, num_resources=5, num_hazards=3)
agent = REEAgent(
    observation_dim=env.observation_dim,
    action_dim=env.action_dim,
    latent_dim=64
)

# Run agent loop
obs = env.reset()
for step in range(100):
    action = agent.act(obs)
    obs, harm_signal, done, info = env.step(action)
    agent.update_residue(harm_signal)
    if done:
        break

Running Tests

# Run all tests
pytest tests/ -v

# Run with coverage
pytest tests/ -v --cov=ree_core

Experiment Pack v1 Emission

Run the experiment harness and emit contract-compliant artifacts:

python experiments/run.py \
  --suite baseline_explicit_cost \
  --seed 7 \
  --max-steps 200 \
  --claim-id MECH-056 \
  --claim-id Q-011 \
  --output-root evidence/experiments

Output layout:

<output_root>/<experiment_type>/runs/<run_id>/
  manifest.json
  metrics.json
  summary.md
  jepa_adapter_signals.v1.json   # required for JEPA-backed harness runs
  traces/    # optional
  media/     # optional

Notes:

  • --output-root overrides output location.
  • If --output-root is omitted, REE_EXPERIMENT_OUTPUT_ROOT is used.
  • If neither is set, output defaults to runs/.
  • run_id is deterministic from timestamp_utc + suite + seed unless --run-id is provided.
  • claim linkage can be overridden with --claim-id, --evidence-class, and --evidence-direction.

Field guarantees:

  • manifest.json uses schema version experiment_pack/v1.
  • metrics.json uses schema version experiment_pack_metrics/v1.
  • metrics.values contains numeric values only, keyed by stable snake_case metric IDs.
  • manifest.status is PASS or FAIL; known failures are surfaced in failure_signatures.
  • manifest.json includes claim_ids_tested, evidence_class, evidence_direction, producer_capabilities, and environment.
  • environment includes: env_id, env_version, dynamics_hash, reward_hash, observation_hash, config_hash, tier.
  • JEPA-backed harness runs (runner.name = ree-v1-minimal-harness) include:
    • manifest.artifacts.adapter_signals_path = "jepa_adapter_signals.v1.json"
    • jepa_adapter_signals.v1.json with required keys:
      • schema_version, experiment_type, run_id
      • adapter.{name,version}
      • stream_presence
      • pe_latent_fields (includes mean and p95)
      • uncertainty_estimator
      • signal_metrics with required metric keys/ranges

MECH-056 extension:

  • when claim_ids_tested includes MECH-056, metrics include:
    • trajectory_commit_channel_usage_count
    • perceptual_sampling_channel_usage_count
    • structural_consolidation_channel_usage_count
    • precommit_semantic_overwrite_events
    • structural_bias_magnitude
    • structural_bias_rate
    • environment_shortcut_leakage_events
    • environment_unobservable_critical_state_rate
    • environment_controllability_score
    • environment_transition_consistency_rate
  • summary includes channel escalation order and trigger rationale for non-primary channel activations.

Example output pack:

  • /Users/dgolden/Documents/GitHub/ree-v1-minimal/examples/experiment_pack_example/claim_probe_mech_056/runs/2026-02-13T090000Z_example/

CI drift guard:

EXPERIMENT_PACK_ROOT=tests/fixtures/experiment_pack_v1 python scripts/validate_experiment_packs.py

Cross-repo contract lockstep:

  • lock file: contracts/ree_assembly_contract_lock.v1.json
  • vendored contract schemas:
    • contracts/ree_assembly/schemas/v1/manifest.schema.json
    • contracts/ree_assembly/schemas/v1/metrics.schema.json
    • contracts/ree_assembly/schemas/v1/jepa_adapter_signals.v1.json
  • CI fails when either:
    • lock-file hashes do not match vendored schemas
    • emitted packs fail required manifest/metrics/adapter checks

Contract update procedure:

  1. pick REE_assembly source commit to sync.
  2. copy schemas from that commit into contracts/ree_assembly/schemas/v1/.
  3. compute sha256 and update contracts/ree_assembly_contract_lock.v1.json.
  4. refresh fixture/example packs if required fields changed.
  5. run EXPERIMENT_PACK_ROOT=tests/fixtures/experiment_pack_v1 python scripts/validate_experiment_packs.py.

Weekly producer handoff report (parity/backstop lane):

  • source template: /Users/dgolden/Documents/GitHub/REE_assembly/evidence/planning/WEEKLY_HANDOFF_TEMPLATE.md
  • current-cycle report path: evidence/planning/weekly_handoff/latest.md
  • generate from latest bridging qualification runs:
python3 scripts/generate_weekly_handoff.py \
  --run-root runs/bridging_qualification_056_058_059_060 \
  --output evidence/planning/weekly_handoff/latest.md
  • validate required sections/columns:
python3 scripts/validate_weekly_handoff.py --input evidence/planning/weekly_handoff/latest.md
  • deterministic generation behavior:
    • rows are sorted by experiment_type then run_id.
    • generated_utc defaults to max observed run timestamp unless overridden.
    • parity note compares claim-summary directionality against latest ree-v2 handoff when available; otherwise emits N/A.
    • default --parity-authority=deprecated marks this lane as non-authoritative for parity decisions.
    • Local Compute Options Watch defaults to N/A for parity/backstop unless explicitly overridden.

Ingestion compatibility check (from REE_assembly checkout):

python3 evidence/experiments/scripts/build_experiment_indexes.py --root /path/to/your/output_root

Project Structure

ree-v1-minimal/
β”œβ”€β”€ ree_core/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ agent.py              # Main REE agent implementation
β”‚   β”œβ”€β”€ latent/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── stack.py          # L-space latent stack
β”‚   β”œβ”€β”€ predictors/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ e1_deep.py        # E1 deep predictor
β”‚   β”‚   └── e2_fast.py        # E2 fast predictor
β”‚   β”œβ”€β”€ trajectory/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── e3_selector.py    # E3 trajectory selector
β”‚   β”œβ”€β”€ residue/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── field.py          # Residue field Ο†(z)
β”‚   β”œβ”€β”€ environment/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── grid_world.py     # Toy grid world
β”‚   └── utils/
β”‚       β”œβ”€β”€ __init__.py
β”‚       └── config.py         # Configuration utilities
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ test_latent_stack.py
β”‚   β”œβ”€β”€ test_predictors.py
β”‚   β”œβ”€β”€ test_trajectory.py
β”‚   β”œβ”€β”€ test_residue.py
β”‚   β”œβ”€β”€ test_environment.py
β”‚   └── test_agent.py
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ basic_agent.py
β”‚   └── residue_visualization.py
β”œβ”€β”€ docs/
β”‚   └── architecture.md
β”œβ”€β”€ pyproject.toml
└── README.md

Key Concepts

Non-Negotiable Invariants

Per the REE specification, this implementation ensures:

  1. Ethical cost is persistent - Residue cannot be reset or cleared
  2. Harm via mirror modelling - Not symbolic rules
  3. Moral residue cannot be erased - Only integrated and contextualized
  4. Language cannot override harm sensing - Embodied signals take priority
  5. Precision is depth-specific - Not global

Trajectory Scoring

The trajectory scoring function combines three terms:

J(΢) = F(΢) + λ·M(΢) + ρ·Φ_R(΢)
  • F(ΞΆ): Reality constraint (predictive coherence, physical viability)
  • M(ΞΆ): Ethical cost (predicted degradation of self/others)
  • Ξ¦_R(ΞΆ): Residue field (persistent curvature from past harm)

Learn More

  • πŸ“– Documentation - Complete guides and API reference
  • 🎯 Examples - Working code examples
  • πŸ§ͺ Tests - Test suite and usage patterns
  • 🀝 Contributing - How to contribute

Key Features

βœ… Multi-timescale Latent Representation: Hierarchical state spanning perception to motivation
βœ… Ethical Path-Dependence: Geometric residue field makes moral cost trajectory-dependent
βœ… Architectural Invariants: Residue cannot be erased, ensuring ethical continuity
βœ… Predictive Processing: Unified framework based on precision-weighted prediction errors
βœ… Extensible Design: Easy to integrate with custom environments and components

License

Apache License 2.0 (see LICENSE).

Citation

  • Cite this repository using CITATION.cff.
  • For canonical architectural attribution, cite Daniel Golden's REE specification in https://github.com/Latent-Fields/REE_assembly/ (also captured as the preferred citation in CITATION.cff).

About

THe first Claude Cowork instantiation of minimal REE

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages