Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.

Fix CI preflight discovery + create self-contained CEG instrument package - #139

Draft
justinlietz93 with Copilot wants to merge 4 commits into
mainfrom
copilot/create-ceg-package
Draft

Fix CI preflight discovery + create self-contained CEG instrument package#139
justinlietz93 with Copilot wants to merge 4 commits into
mainfrom
copilot/create-ceg-package

Conversation

Copilot AI commented Feb 21, 2026

Copy link
Copy Markdown
Contributor

CI preflight suite has been failing since the glob pattern "Derivation/code/tests/**/test_*preflight*.py" is never shell-expanded (quoted), so pytest sees a literal path and emits "file or directory not found". Additionally, test_ceg_harness_preflight.py imported a non-existent instrumented_ceg module.

Changes

CI fix

  • .github/workflows/preflight-push.yml: replace broken quoted glob with find ... | sort | xargs python -m pytest

New module: instrumented_ceg.py

  • Derivation/code/physics/metriplectic/instrumented_ceg.py — thin wrapper around run_assisted_echo exposing run_ceg_harness(spec, *, write_artifacts=True):
    • write_artifacts=False monkey-patches common.io_paths helpers inside a try/finally to suppress all disk I/O (for test/programmatic use)
    • Appends a diagnostics key summarising per-gate pass/fail from gate_ledger_summary
    • Fixes the failing test_ceg_harness_preflight_smoke preflight test

Self-contained CEG package

Derivation/Metriplectic/CEG_Metriplectic_Assistance/ceg_package/ — flat directory that works with zero repo knowledge:

ceg_package/
├── README.md  ·  CITATION.cff  ·  run_ceg.py        # entry point + docs
├── ceg_instrument/
│   ├── __init__.py          # exports: run_ceg, CegSpec
│   ├── assisted_echo.py     # full experiment logic, local imports only
│   ├── kg_ops.py / j_step.py / kg_noether.py
│   ├── compose.py           # Strang JMJ/MJM, local imports
│   ├── echo_metrics.py / echo_gates.py
│   └── rd_solver.py         # self-contained DG Newton RD solver
├── specs/default_v1c.json
├── published_results/{gate_ledger.json,ceg_summary.csv}
└── paper/README.md

All physics.* / common.* repo imports replaced with relative . imports throughout ceg_instrument/. Public API:

from ceg_instrument import run_ceg, CegSpec

results = run_ceg(CegSpec(
    grid={"N": 256, "dx": 1.0},
    params={"c": 1.0, "m": 0.5, "D": 1.0, "r": 0.1, "u": 0.0, "m_lap_operator": "spectral"},
    dt=0.02, steps=200,
    seeds=list(range(1, 13)),
    lambdas=[0.0, 0.1, 0.2, 0.3, 0.5],
    budget=1e-2,
))
print(results["ceg_summary"])           # {λ: {median, mean, n}}
print(results["gate_ledger_summary"])   # G1–G5 pass rates
Original prompt

Build a SELF-CONTAINED CEG instrument package — zero friction

The previous approach was wrong — it just pointed at files scattered across the repo. The recipient (Asad, Liquid AI) needs a flat, self-contained directory he can copy out of the repo and run immediately with zero knowledge of the repo structure.

Create Derivation/Metriplectic/CEG_Metriplectic_Assistance/ceg_package/ that contains ALL the code, data, paper references, and instructions in ONE place. No symlinks, no "go find it in the repo" — actual copied/adapted files.


Directory structure to create:

ceg_package/
├── README.md                    # THE doc
├── CITATION.cff                 # citation metadata
├── run_ceg.py                   # ONE-FILE entry point that just works
├── ceg_instrument/
│   ├── __init__.py
│   ├── assisted_echo.py         # ADAPTED from physics/metriplectic/assisted_echo.py — self-contained
│   ├── kg_ops.py                # COPIED from physics/metriplectic/kg_ops.py
│   ├── j_step.py                # COPIED from physics/metriplectic/j_step.py  
│   ├── compose.py               # ADAPTED from physics/metriplectic/compose.py — local imports
│   ├── echo_metrics.py          # COPIED from physics/metriplectic/echo_metrics.py
│   ├── echo_gates.py            # COPIED from physics/metriplectic/echo_gates.py
│   ├── kg_noether.py            # ADAPTED from physics/metriplectic/kg_noether.py — local imports
│   └── rd_solver.py             # EXTRACTED: DG Newton solver + exact reaction from rd_conservation + reaction_exact
├── specs/
│   └── default_v1c.json         # The canonical spec
├── published_results/
│   ├── gate_ledger.json         # COPIED run log
│   └── ceg_summary.csv          # COPIED CSV
└── paper/
    └── README.md                # How to find/compile the TeX paper

File contents:

ceg_package/README.md

# CEG Metriplectic Instrument Package

**Author:** Justin K. Lietz — Neuroca, Inc.  
**ORCID:** [0009-0008-9028-1366](https://orcid.org/0009-0008-9028-1366)  
**Repo:** [github.com/justinlietz93/Prometheus_VDM](https://github.com/justinlietz93/Prometheus_VDM)  
**License:** See LICENSE at repository root

---

## What This Is

A self-contained instrument for measuring **Counterfactual Echo Gain (CEG)** — a gate-certified observable that quantifies whether a model-aware time-reversal improves state recovery vs a model-blind baseline.

The physics: a **metriplectic split** — conservative J-limb (Hamiltonian, symplectic, energy-preserving) composed with dissipative M-limb (entropy-producing, gradient flow) via **Strang splitting**: J(dt/2) → M(dt) → J(dt/2).

The observable:

```
CEG = (E_baseline - E_assisted) / E_baseline ∈ [0, 1]
```

Five instrument gates certify each run:
- **G1** (Noether): J-only energy drift ≤ tolerance  
- **G2** (H-theorem): M-only entropy production ≥ 0  
- **G3** (Energy match): baseline and assisted use identical work budgets  
- **G4** (Strang defect): splitting error scales as O(dt³) with R² ≥ 0.999  
- **G5** (CEG threshold): median CEG across seeds ≥ 0.05  

**Published result** (2025-11-04): 12 seeds × 5 λ values, all gates 100% pass, median CEG = 0.0546 at λ=0.5.

---

## Quick Start

```bash
# Requirements: Python 3.10+, numpy, scipy (matplotlib optional for plots)
pip install numpy scipy matplotlib

# Run with default spec (N=256, dt=0.02, 12 seeds, 5 lambda values)
python run_ceg.py

# Run with custom spec
python run_ceg.py --spec specs/default_v1c.json

# Run with inline overrides
python run_ceg.py --N 512 --dt 0.01 --seeds 1,2,3,4,5
```

---

## Using the Instrument Programmatically

```python
from ceg_instrument import run_ceg, CegSpec

spec = CegSpec(
    grid={"N": 256, "dx": 1.0},
    params={
        "c": 1.0,           # wave speed (J-limb KG)
        "m": 0.5,           # mass (J-limb KG)
        "D": 1.0,           # diffusion coeff (M-limb RD)
        "r": 0.1,           # reaction rate (M-limb RD)
        "u": 0.0,           # saturation (M-limb RD)
        "m_lap_operator": "spectral",
    },
    dt=0.02,
    steps=200,
    seeds=[1,2,3,4,5,6,7,8,9,10,11,12],
    lambdas=[0.0, 0.1, 0.2, 0.3, 0.5],
    budget=1e-2,
)

results = run_ceg(spec)

# What you get back:
print(results["ceg_summary"])           # {λ: {median, mean, n}}
print(results["gate_ledger_summary"])   # {gate: {passed, failed, pass_rate}}

# Per-seed detail:
for s in results["gate_ledger_per_seed"]:
    print(f"Seed {s['seed']}: {[g['gate'] + ':' + str(g['passed']) for g in s['gates']]}")
```

---

## Adapting for Your Own Model

The instrument is modular. To test a different dynamical system:

1. **Replace the J-step** (conservative limb): provide any function `(state, dt, dx, params) -> state` that is reversible and energy-preserving. Currently this is Störmer-Verlet for Klein-Gordon.

2. **Replace the M-step** (dissipative limb): provide any function `(state, dt, dx, params) -> state` that is entropy-producing. Currently this is a discre...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

<!-- START COPILOT CODING AGENT TIPS -->
---

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security)

Copilot AI changed the title [WIP] Build self-contained CEG instrument package Fix CI preflight discovery + create self-contained CEG instrument package Feb 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants