This project develops a standalone SubRep implementation that transforms skill discovery into a certificate-driven, auditable process. SubRep certifies skills via two mathematical tests (CDS/PDS) that guarantee composition safety across motive shifts, preventing negative transfer before skills enter the library.
This project validates the core mechanism in MO-LunarLander, storing certified skills as native MeTTa Atoms for future Hyperon integration.
| Objective | Goal | Implemented Capabilities |
|---|---|---|
| 1. Neural Skill Generator + MDN | Generate skill summaries and learn motive geometry from experience | 2-head MLP for payoff/motives; MDN input/output contract; candidate-set MDN training and evaluation; auxiliary gate/Q heads |
| 2. Core Certification | Implement CDS/PDS admission tests | CDS test; PDS-epsilon test; MO-LunarLander integration |
| 3. MeTTa Certificate Storage | Store certificates as native atoms | Certificate schema; Hyperon-backed MeTTa bridge; store/retrieve/query operations |
| 4. Validation | Demonstrate the certificate-driven mechanism works | Certified skills pass; unsafe skills are rejected; admission reports document pass/fail behavior |
- Python 3.8+
- Git
# Clone the repository
git clone https://github.com/iCog-Labs-Dev/subrep.git
cd subrep
#Create and activate a virtual environment
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux / macOS
source .venv/bin/activate
python -m pip install -r requirements.txt# Run all tests
python -m pytest -v
# Run certification tests only
python -m pytest tests/test_certification_gates.py -v
# Run the full demo pipeline
python -m demo.run_full_pipelinepython -m demo.run_full_pipelineThe demo pipeline:
- computes an idle baseline,
- executes the trained PPO pilot,
- computes
delta_randdelta_n, - certifies skills with CDS/PDS,
- stores admitted certificates in MeTTa and
SkillLibrary, - writes admission reports to
demo/artifacts/, - runs MDN-based skill selection from the certified library.
To open the Streamlit demo app:
streamlit run demo/streamlit_subrep_demo.pyThe Streamlit app is the demo interface. It can run the real pipeline from the sidebar, then presents the full SubRep story in one place: skill execution, improvement calculation, CDS/PDS admission, certificate storage, trained-MDN selection, zero-shot reuse, and the final audit tables.
# Regenerate the committed PPO pilot checkpoint
python -m pilot.train_pilot --seed 7 --output models/pilot_ppo.pt
# Validate the checkpoint without retraining
python -m pytest tests/test_pilot_performance.py -vAfter running the demo pipeline, admission statistics are generated at:
demo/artifacts/admission_report.jsondemo/artifacts/admission_report.md
The report includes:
- total attempted, admitted, and rejected skills,
- admission and rejection rates,
- CDS and PDS pass counts,
- failure reasons for rejected skills,
- example admitted/rejected records,
- MDN source and support-geometry metadata.
The pipeline looks for the trained MDN checkpoint at:
models/mdn_policy_best.pth
If that file is present, the pipeline uses the trained MDN and records:
mdn_source: trained_checkpoint
If the checkpoint is missing, the pipeline falls back to StubMDN so tests and smoke runs still work. The stub returns fixed alpha/support values and should not be confused with the trained MDN.
python -m data_collector.collect_candidate_sets --contexts 1000 --save-dir data/mdn_candidate_sets --seed 42 --prefix seed42
python -m data_collector.collect_candidate_sets --contexts 1000 --save-dir data/mdn_candidate_sets --seed 43 --prefix seed43
python -m data_collector.collect_candidate_sets --contexts 1000 --save-dir data/mdn_candidate_sets --seed 44 --prefix seed44This produces 3,000 contexts and 21,000 candidate outcomes with the default candidate set.
python -m generator.train_mdn_candidate_sets \
--data-dir data/mdn_candidate_sets \
--pattern "*.npz" \
--seed 42 \
--device cpu \
--policy-checkpoint models/mdn_policy_best.pth \
--auxiliary-checkpoint models/mdn_auxiliary_best.pth \
--q-loss mseOutputs:
models/mdn_policy_best.pth: trained MDN policy/runtime checkpointmodels/mdn_auxiliary_best.pth: trained auxiliary checkpoint
Final MDN training uses candidate-set supervised training with normalized Q targets and MSE Q loss. IPS/DR support exists in the auxiliary trainer for future off-policy logged-data settings, but the final candidate-set checkpoint is not DR-trained.
python -m generator.evaluate_mdn_candidate_sets \
--checkpoint models/mdn_policy_best.pth \
--data-dir data/mdn_candidate_sets_eval \
--pattern "*.npz" \
--seed 100 \
--device cpuThe evaluator reports lift versus PPO/random baselines, balanced top-1 accuracy, regret, gate F1, Q/motive error, per-objective Q diagnostics, and bootstrap confidence intervals.
| Folder | Description |
|---|---|
env/ |
MO-LunarLander wrapper and skill execution loop |
baseline/ |
Idle baseline and improvement computation |
generator/ |
Skill generator, MDN model, trainers, and evaluators |
pilot/ |
PPO pilot policy, training entry point, and checkpoint utilities |
certification/ |
CDS/PDS gates, certificate schema, and MeTTa storage |
library/ |
Runtime skill library and selection strategies |
utils/ |
Shared MDN, geometry, data, checkpoint, and report helpers |
data_collector/ |
Raw rollout and candidate-set data collectors |
demo/ |
End-to-end pipeline and generated admission reports |
tests/ |
Unit, integration, runtime, and end-to-end tests |
- Platform:
mo-gymnasium(MO-LunarLander-v3) - Observation Space:
(8,) - Reward Space:
(2,)mapped to[Safety, Fuel]
- Architecture: 2-head MLP
- Input: state vector
(8,) - Outputs: scalar payoff
(1,), motive vector(2,) - Training: supervised MSE on collected rollout payoff/motive totals
- Input: context vector
(8,) - Outputs: Dirichlet alpha, 2D support values, auxiliary gate logit, auxiliary Q prediction
- 2D Support Contract: support values satisfy
0 <= s0,s1 <= 1ands0 + s1 >= 1
- CDS: Cone-Dominant Subtask, universal-benefit admission
- PDS-epsilon: Pareto-Dominant Subtask, bounded trade-off admission
- Supported regions:
FULL_SIMPLEXand 2DMDN_WX
- Package:
hyperon - Active implementation:
certification/metta_bridge.pyandcertification/metta_storage.py - Persistence:
data/certificates.metta
generator/README.md: skill-generator and MDN training/evaluationdata/README.md: rollout and candidate-set data schemasdocs/CERTIFICATE_STORAGE.md: certificate schema and MeTTa atom formatdocs/ZERO_SHOT_PROTOCOL.md: full-simplex and MDN_WX reuse protocoldocs/INTEGRATION_REPORT.md: integration and validation reportdocs/METTA_INTEGRATION.md: MeTTa and Hyperon integration notes- MeTTa Python Integration Guide
- Extend candidate-set MDN evaluation beyond the current 2-objective MO-LunarLander testbed.
- Add MetaMo integration for dynamic weight management and risk budgets.
- Explore cross-paradigm skill sources through logic macros and evolutionary programs.
- Expand benchmark comparisons against MORL baselines.