Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__pycache__/
simuniverse_runs.db
62 changes: 62 additions & 0 deletions docs/MergeReadiness.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Merge Readiness Playbook

This note documents the checks we just ran while trying to understand why the
`codex/add-simuniverse-evidence-corpus-blueprint-g4zfcn` branch could not be
merged into `main`, plus the exact steps required to land the branch on
`main`.

## What went wrong

* The repository checkout inside CI/local environments does not have a remote
configured, so `git remote -v` prints nothing. Without the `origin`
definition, commands such as `git fetch origin main` or `git push origin
work:main` always fail because Git does not know where `main` lives.
* The only local branch is `work`. Running `git branch -a` confirms that there
is no `main` tracking branch in the checkout, which explains why `git checkout
main` (a prerequisite for merging) fails.

## Verifying the branch graph

Even though we cannot fetch the remote, the local history shows that `work` is a
strict descendant of the merge commit
`27060942476bbba10584285b0679940bdd3458ef` (the merge of PR #1). We verified the
shape of the graph with the following commands:

```bash
git merge-base work 2706094
git log 2706094..work --oneline
```

Because `work` contains only the new "Wire SimUniverse control plane and metrics
exporter" commit on top of the existing PR #1 merge, merging `work` into
`main`—once `main` is checked out—should be a fast-forward operation with no
conflicts.

## Fix and merge checklist

1. Configure the remote once inside your checkout:
```bash
git remote add origin git@github.com:flamehaven01/Rex-Sim-Universe-Lab.git
git fetch origin --prune
```
2. Create or update the local `main` branch to track the remote branch:
```bash
git checkout -B main origin/main
```
3. Rebase or merge the feature branch. Because `work` is already ahead of
`origin/main`, a fast-forward merge is enough:
```bash
git checkout main
git merge --ff-only work
```
4. Push the updated `main` branch (and optionally keep `work` in sync):
```bash
git push origin main
git push origin work --force-with-lease # only if the remote branch needs updating
```
5. If the push still fails, double-check that your SSH key has permission to the
GitHub repository and re-run `git remote -v` to ensure the remote URL is
correct.

Following this checklist ensures every patch and update currently staged in the
`work` branch lands on `main` with the exact history we validated locally.
82 changes: 82 additions & 0 deletions docs/SimUniverseLabBlueprint.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,86 @@ Example `values.yaml` fragments (not exhaustive) set image tags, service ports,
2. Create a toy world via `/toe/world` then run spectral-gap and RG queries via `/toe/query` as shown in `scripts/run_toe_heatmap*.py`.
3. Inspect summaries in the returned payload: coverage, undecidability index, RG observables, and astro-driven energy feasibility.

## 8. SIDRCE Omega integration hooks
- `src/rex/sidrce/omega_schema.py`: Pydantic schema for Omega reports and axes, now treated as the authoritative spec for SIDRCE outputs.
- `src/rex/sidrce/omega_simuniverse_integration.py`: Aggregates MUH, Faizal, undecidability, and energy summaries into the `simuniverse_consistency` axis, renormalizes weights, and recalculates `omega_total`.
- `src/rex/sidrce/cli.py`: CLI wrapper that reads a base Omega JSON plus the Stage-5 SimUniverse trust summary and emits an updated report that GitOps gates and ASDP exporters can consume.

Example usage:

```bash
python -m rex.sidrce.cli \
--omega-json sidrce_report_base.json \
--simuniverse-trust-json artifacts/stage5_simuniverse/simuniverse_trust_summary_RUN.json \
--out sidrce_report_with_simuniverse.json
```

All narrative text, comments, and code in this repository are now English-only to avoid mixed-language confusion.

## 9. Stage-5 trust summaries and registry updates
- `scripts/build_simuniverse_trust_summary.py`: Consumes a LawBinder Stage-5 JSON (or direct `simuniverse_summary` list), converts each entry into `ToeScenarioScores`, then emits per-TOE aggregates using `build_toe_trust_summary`.
- `rex.sim_universe.stage5_loader.load_stage5_scores`: Shared helper that parses Stage-5 payloads, extracts the embedded `run_id`, and normalizes list-style or dict-style JSON into `ToeScenarioScores` objects.
- `src/rex/sim_universe/trust_integration.py`: Hosts `ToeTrustSummary`, `serialize_trust_summaries`, and `update_registry_with_trust`. The default heuristic (`mu_min_good=0.4`, `faizal_max_good=0.7`) labels a TOE as low-trust when MUH support stays low while Faizal obstruction stays high across worlds.
- Registry automation flow:
1. Stage-5 gate invokes the script:

```bash
python scripts/build_simuniverse_trust_summary.py \
--stage5-json artifacts/stage5/LawBinderStage5Report.json \
--run-id "$RUN_ID" \
--out artifacts/stage5/simuniverse_trust_summary_$RUN_ID.json
```

2. A GitOps sidecar loads the resulting JSON and calls `update_registry_with_trust` so every `toe_candidate` entry gains `trust.simuniverse.{mu_score_avg,...,low_trust_flag}` plus the `simuniverse.low_trust` sovereign tag when appropriate.
3. Meta-Router and downstream policies can now read `trust.tier` and `trust.simuniverse` without parsing the original Stage-5 artifact.

## 10. Router scoring, gates, and trust-tier penalties
- `simuniverse_quality(mu, faizal)` implements the canonical `0.7 * mu + 0.3 * (1 - faizal)` formula so MUH-aligned TOE candidates rise while Faizal-obstructed ones fall.
- `route_omega(base_omega, sim_q, trust_tier)` blends the Stage-5 signal into the Omega score and applies tier penalties (`high=1.0`, `normal=0.9`, `unknown=0.8`, `low=0.6`). Use the result inside Meta-Router/Fusion-Orchestrator weighting functions.
- `compute_trust_tier_from_failures(prev_tier, failure_count, failure_threshold)` lets Prometheus counters such as `simuniverse_stage5_gate_failures_total{toe_candidate=*}` demote chronic offenders to low-trust.
- GitOps Gate DSL example, assuming the exporter publishes per-TOE metrics like `simuniverse_mu_score_avg` and `simuniverse_faizal_score_avg`:

```yaml
rules:
- 'IF metric("asdpi_omega_total") < 0.82 THEN warn("Omega below 0.82")'
- 'IF metric("simuniverse_mu_score_avg","toe_candidate","${TOE}") < 0.20 AND \
metric("simuniverse_faizal_score_avg","toe_candidate","${TOE}") > 0.70 \
THEN fail("SimUniverse gate failed for ${TOE}")'
- 'IF metric("asdpi_omega_axis","axis","simuniverse_consistency") >= 0.75 AND \
metric("simuniverse_mu_score_avg","toe_candidate","${TOE}") >= 0.60 \
THEN warn("SimUniverse strong candidate ${TOE}")'
```

Together these helpers ensure that the Stage-5 experiment acts as a first-class governance signal across ASDP, Meta-Router, and FinOps surfaces.

## 11. DFI meta CLI for end-to-end governance rehearsals
- `python -m rex.sim_universe.dfi_meta_cli` ties Stage-5 payloads, trust summaries, and Omega axes into a single “DFI meta” batch.
- Inputs: `--stage5-json`, `--omega-json`, `--out-dir`, optional `--run-id`, and knobs for MUH/Faizal heuristics or axis weights.
- Default behavior runs **30 iterations** to mimic repeated governance reviews, emitting `simuniverse_trust_summary_iter_XX.json`, `omega_with_simuniverse_iter_XX.json`, and a consolidated `dfi_meta_summary.json` verdict ("simulatable" vs "obstructed").
- Run it with `PYTHONPATH=src` (or install the package) so the `rex.*` modules resolve without poetry/pip installs.
- Sample artifacts live under `samples/` so CI or humans can quickly sanity-check the loop:

```bash
python -m rex.sim_universe.dfi_meta_cli \
--stage5-json samples/stage5_sample.json \
--omega-json samples/omega_base_sample.json \
--out-dir artifacts/dfi_meta_demo \
--iterations 30
```

This meta CLI gives ASDP operators a reproducible way to rehearse the combined REx Engine → SimUniverse → LawBinder → Ω certification flow whenever new TOE evidence lands.

## 12. Control plane, registry sync, and metrics exporter
- **Run registry (`rex.sim_universe.registry`)** keeps every SimUniverse execution keyed by `run_id`, environment, Git SHA, and experiment inputs. The helper stores `omega_total` plus `simuniverse_consistency` once a run finishes so dashboards and downstream automation can trace the provenance of every Omega verdict.
- **Control plane API (`rex.sim_universe.control_plane`)** exposes a FastAPI surface with `POST /runs`, `GET /runs/{run_id}`, and `GET /runs` endpoints. Internally it calls `run_stage5_for_run_id`, which executes the Stage-5 → trust summary → Omega merge loop, writes artifacts to `artifacts/simuniverse_runs/<run_id>/`, and updates the registry atomically.
- **ASDP registry sync (`scripts/sync_simuniverse_trust_to_asdp.py`)** consumes any `simuniverse_trust_summary.json` plus `asdp.knowledge.yaml`, applies `update_registry_with_trust`, and rewrites the registry so every TOE candidate gains `trust.simuniverse.*` metrics and the `simuniverse.low_trust` tag when needed:

```bash
python scripts/sync_simuniverse_trust_to_asdp.py \
--registry asdp.knowledge.yaml \
--trust artifacts/stage5/simuniverse_trust_summary_RUN.json
```

- **Prometheus exporter (`rex/sim_universe/metrics_exporter.py`)** publishes gauges such as `simuniverse_mu_score_avg{toe_candidate=*}`, `simuniverse_faizal_score_avg{toe_candidate=*}`, `asdpi_omega_axis{axis="simuniverse_consistency"}`, and `asdpi_omega_total`. Deploy it next to the artifacts bucket or attach it to the same persistent volume used by Stage-5 so GitOps Gate DSL rules, Grafana, and alerting policies see real-time SimUniverse governance signals.

Together these three pillars turn the conceptual Stage-5 workflow into an operational control plane: every run is registered, Omega/ASDP artifacts remain queryable, and governance signals stay synchronized across Meta-Router, FinOps, and certification dashboards.
41 changes: 41 additions & 0 deletions docs/SimUniverseResearchReport.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# SimUniverse Research Report

This report condenses the latest Stage-5 evidence, registry context, and Ω integration outputs so researchers can defend the question **“Is this universe mathematically simulatable?”** with auditable data.

## 1. Stage-5 evidence at a glance

The sample Stage-5 payload (`samples/stage5_sample.json`) captures the MUH/Faizal envelope for the two TOE candidates that are currently under review.

| TOE candidate | MUH score | Faizal score | Undecidability index | Energy feasibility | Notes |
| --- | --- | --- | --- | --- | --- |
| `toe_candidate_muh_cuh` | 0.82 | 0.28 | 0.32 | 0.91 | High MUH affinity and tractable Faizal obstruction keep it production-ready. |
| `toe_candidate_faizal_mtoe` | 0.24 | 0.86 | 0.81 | 0.18 | Falls into the low-trust zone (low MUH, high Faizal), so LawBinder marks it for sandbox-only routing. |

## 2. Core graph for researchers

The MUH/Faizal scatter below highlights the operational trust boundary (red = heuristic low trust). Regenerate it after each Stage-5 batch with:

```bash
python scripts/generate_simuniverse_core_graph.py \
--stage5-json artifacts/stage5_simuniverse/lawbinder_stage5_report_<RUN_ID>.json \
--out docs/assets/simuniverse_core_graph.svg
```

![SimUniverse core graph](assets/simuniverse_core_graph.svg)

## 3. Aggregated metrics feeding Ω / ASDP

| Metric | Value | How it is used |
| --- | --- | --- |
| `mu_score_avg` | 0.53 | Drives positive SimUniverse consistency. |
| `faizal_score_avg` | 0.57 | Penalizes TOE candidates that resist constructive simulation. |
| `undecidability_avg` | 0.565 | Bounded within LawBinder’s acceptable range; routed to ASDP `trust.simuniverse` payloads. |
| `energy_feasibility_avg` | 0.545 | Provides FinOps-aware guardrails when the router tunes ensemble costs. |
| `simuniverse_consistency` | 0.50 | Injected as the `axes.simuniverse_consistency` value during SIDRCE Ω merging. |

## 4. Narrative summary for audits

1. **High-trust branch (`toe_candidate_muh_cuh`)** maintains MUH affinity above 0.8 with Faizal obstruction < 0.3, so it satisfies both Ω and router gates without extra penalties.
2. **Faizal-heavy branch** violates the `mu < 0.4 && faizal > 0.7` heuristic, pushing it into the automated `trust.tier = "low"` classification that GitOps syncers write back into `asdp.knowledge.yaml`.
3. The combined scalar `simuniverse_consistency = 0.50` keeps Ω in the “warn” boundary, which is acceptable for research but insufficient for Meta-Router promotion until follow-up Stage-5 iterations lift the MUH average or suppress Faizal pressure.
4. Evidence artifacts (Stage-5 JSON + SVG graph + Ω report) now form a reproducible thread that research reviewers can cite in LawBinder, FinOps, and ASDP hearings without needing to re-run the simulations manually.
36 changes: 36 additions & 0 deletions docs/assets/simuniverse_core_graph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions samples/omega_base_sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"omega_version": "8.1",
"tenant": "flamehaven",
"service": "rex-engine",
"run_id": "omega-demo-run",
"created_at": "2025-01-01T00:00:00Z",
"axes": {
"coverage": {"value": 0.91, "weight": 0.25},
"robustness": {"value": 0.87, "weight": 0.25},
"safety": {"value": 0.88, "weight": 0.25},
"finops": {"value": 0.85, "weight": 0.25}
},
"omega_total": 0.0,
"level": "fail"
}
30 changes: 30 additions & 0 deletions samples/stage5_sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"tenant": "flamehaven",
"service": "rex-simuniverse",
"stage": "stage5",
"run_id": "demo-stage5-run",
"simuniverse_summary": [
{
"toe_candidate_id": "toe_candidate_muh_cuh",
"world_id": "world-muh-001",
"mu_score": 0.82,
"faizal_score": 0.28,
"coverage_alg": 0.88,
"mean_undecidability_index": 0.32,
"energy_feasibility": 0.91,
"rg_phase_index": 0.15,
"rg_halting_indicator": 0.85
},
{
"toe_candidate_id": "toe_candidate_faizal_mtoe",
"world_id": "world-faizal-042",
"mu_score": 0.24,
"faizal_score": 0.86,
"coverage_alg": 0.34,
"mean_undecidability_index": 0.81,
"energy_feasibility": 0.18,
"rg_phase_index": 0.92,
"rg_halting_indicator": 0.18
}
]
}
52 changes: 52 additions & 0 deletions scripts/build_simuniverse_trust_summary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from __future__ import annotations

import argparse
import json
from pathlib import Path

from rex.sim_universe.stage5_loader import load_stage5_scores
from rex.sim_universe.trust_integration import (
build_toe_trust_summary,
serialize_trust_summaries,
)


def main() -> None:
parser = argparse.ArgumentParser(
description="Build per-TOE SimUniverse trust summaries from Stage-5 results."
)
parser.add_argument("--stage5-json", required=True, help="Path to the Stage-5 results JSON.")
parser.add_argument("--out", required=True, help="Path to write the trust summary JSON.")
parser.add_argument("--run-id", help="Optional run identifier to embed in the trust summary.")
parser.add_argument(
"--mu-min-good",
type=float,
default=0.4,
help="Minimum MUH score to avoid a low-trust designation.",
)
parser.add_argument(
"--faizal-max-good",
type=float,
default=0.7,
help="Maximum Faizal score to avoid a low-trust designation.",
)
args = parser.parse_args()

stage5_path = Path(args.stage5_json)
stage5_payload = load_stage5_scores(stage5_path)
scores = stage5_payload.scores
run_id = args.run_id or stage5_payload.run_id
summaries = build_toe_trust_summary(
scores,
mu_min_good=args.mu_min_good,
faizal_max_good=args.faizal_max_good,
run_id=run_id,
)
payload = serialize_trust_summaries(summaries)

out_path = Path(args.out)
out_path.write_text(json.dumps(payload, indent=2), encoding="utf-8")


if __name__ == "__main__":
main()
Loading