Skip to content
Merged
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
57 changes: 57 additions & 0 deletions .github/workflows/e002-canonical-evidence.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: E002 canonical evidence

on:
workflow_dispatch:
push:
branches:
- main
paths:
- .github/workflows/e002-canonical-evidence.yml
- experiments/E001/results/raw/E001__CANONICAL_EVIDENCE__81e7f859f71425bdba7603a61566f9fb47c116f9.tar.gz
- experiments/E002/config/**
- src/superloop_e002/**
- tools/generate_e002_evidence.py

permissions:
contents: read

jobs:
evidence:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"

- name: Generate and repeat E002 canonical instrumentation
env:
PYTHONPATH: src
run: >-
python tools/generate_e002_evidence.py
--output build/e002-canonical
--source-commit "$GITHUB_SHA"

- name: Verify deterministic evidence archive
id: package
shell: bash
run: |
archive="build/e002-canonical.tar.gz"
(cd build && sha256sum --check e002-canonical.tar.gz.sha256)
echo "archive=$archive" >> "$GITHUB_OUTPUT"

- name: Upload canonical evidence
uses: actions/upload-artifact@v4
with:
name: e002-canonical-${{ github.sha }}
path: |
${{ steps.package.outputs.archive }}
${{ steps.package.outputs.archive }}.sha256
if-no-files-found: error
retention-days: 90
22 changes: 17 additions & 5 deletions REPOSITORY_READINESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ This checklist separates repository operations from architectural and ownership

## Current critical path

1. Implement the E002 offline trace replayer without simulator imports.
2. Verify exact state reconstruction and byte-identical telemetry repetition.
3. Add optional shadow mode and prove Stage A trace noninterference.
4. Replay all 72 E001 runs and evaluate the frozen diagnostic thresholds.
5. Classify each pneumatic projection as retain, narrow, revise, or reject.
1. Run the protected E002 evidence workflow from the merged implementation commit.
2. Verify the artifact digest and repeat results under Python 3.13.
3. Record the directed H1–H4 result and classify the pneumatic projections.
4. Decide whether optional shadow mode is warranted by the offline result.
5. Preserve any causal Stage C proposal as a separate, newly frozen experiment.

## E001 Stage A completion

Expand All @@ -77,3 +77,15 @@ This checklist separates repository operations from architectural and ownership
- [x] Pneumatic variables are prohibited from changing Stage A transitions
- [x] Fixed diagnostic baselines and thresholds are declared before implementation
- [x] Retain, narrow, revise, and reject outcomes are defined

## E002 Stage B implementation

- [x] Offline archive reader verifies the frozen E001 archive and embedded digests
- [x] Replayer has no E001 simulator or workload imports
- [x] Tick-boundary state reconstruction covers all 72 source runs
- [x] Exact-rational loop and interlock telemetry is deterministic
- [x] Typed capacity, fault, semantic, stale-authority, and reciprocal-debt channels are separate
- [x] Fixed T1–T3 analysis and exact ROC-AUC calculation are implemented
- [x] Protected Python 3.13 evidence workflow is defined
- [ ] Canonical runner artifact verified and promoted
- [ ] Directed result and outcome classification recorded
4 changes: 3 additions & 1 deletion experiments/E002/results/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ Every result set must identify the E002 specification and configuration digests,

Generated telemetry may not overwrite E001 evidence. Corrections require a new result identifier and preserved supersession record.

No E002 evidence has been produced yet.
The canonical generator is `tools/generate_e002_evidence.py`; the protected runner is `.github/workflows/e002-canonical-evidence.yml`. The generator repeats the full replay and rejects run-summary, telemetry-digest, or aggregate-analysis drift before packaging evidence.

No E002 evidence has been promoted yet. Implementation availability is not an experiment result; interpretation begins only after a digest-linked runner artifact is verified.
6 changes: 5 additions & 1 deletion experiments/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The local CBF configuration preserved all hard invariants and reduced fault radi

## E002 — Noncausal Pneumatic Instrumentation

**Status:** [SpecifiedE1](E002/EXPERIMENT__E002__NONCAUSAL_PNEUMATIC_INSTRUMENTATION__v0.1__2026-07-14.md)
**Status:** [Implementedevidence pending](E002/EXPERIMENT__E002__NONCAUSAL_PNEUMATIC_INSTRUMENTATION__v0.1__2026-07-14.md)

**Registry ID:** `SW.EXPERIMENT.E002`

Expand All @@ -62,6 +62,10 @@ Can pressure, resistance, conductance, candidate flow, occupancy-time, dissipati

E002 replays E001 evidence offline and emits a separate exact-rational telemetry stream. The observables cannot authorize work, create credit, change order, repair circular wait, or become causal input.

### Implementation

The dependency-free replayer verifies the frozen archive and embedded digests without importing E001 transition code. It emits pre- and post-tick loop/interlock records, typed diagnostic states, deterministic summaries, and fixed T1–T3 comparisons. The protected canonical runner repeats the complete matrix before packaging any evidence.

### Exit

Classify the instrumentation as retain, narrow, revise, or reject. No outcome automatically authorizes a causal constitutive layer.
2 changes: 1 addition & 1 deletion registry/CONCEPT_REGISTRY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This registry is the identity and status index for foundational Superloop concep
| `SW.PROTOTYPE.BPE` | Biological Pneumatic Engine | Prototyped / archived input | E2-limited | Recovered PDP v2 prototype; not a Superloop runtime dependency |
| `SW.BRIDGE.CBF_PNEUMATIC` | CBF–Pneumatic Bridge | Formalized | E1 | Controlled synthesis: CBF constitution plus optional pneumatic dynamics |
| `SW.EXPERIMENT.E001` | Three-Ring Bounded Flow | Completed | E4-scoped | Repeated 72-run Python 3.13 comparison; result is limited to the declared three-ring model |
| `SW.EXPERIMENT.E002` | Noncausal Pneumatic Instrumentation | Specified | E1 | Offline Stage B replay of E001 with exact read-only field telemetry |
| `SW.EXPERIMENT.E002` | Noncausal Pneumatic Instrumentation | Implemented / evidence pending | E2 | Offline Stage B replay of E001 with exact read-only field telemetry |

## Naming rule

Expand Down
14 changes: 14 additions & 0 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,17 @@ PYTHONPATH=src python -m superloop_e001 matrix --output /tmp/e001-results
```

The matrix command writes generated evidence only to an explicit output directory. Canonical repository evidence should be promoted separately after review of the source commit and complete manifest.

## E002 Stage B

The representation-only replayer lives in `src/superloop_e002/`. It reads the preserved E001 evidence archive, verifies every source digest, reconstructs state at tick boundaries, and emits separate exact-rational telemetry. It does not import the E001 simulator or workloads.

Generate and repeat the complete E002 evidence set with:

```bash
PYTHONPATH=src python tools/generate_e002_evidence.py \
--output /tmp/e002-canonical \
--source-commit "$(git rev-parse HEAD)"
```

The command writes 72 telemetry streams, 72 run summaries, aggregate analysis, provenance, and a deterministic compressed archive. Generated files never modify the frozen E001 evidence.
5 changes: 5 additions & 0 deletions src/superloop_e002/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""E002 offline pneumatic instrumentation for frozen E001 evidence."""

from .replayer import EvidenceArchive, replay_archive, replay_run

__all__ = ["EvidenceArchive", "replay_archive", "replay_run"]
86 changes: 86 additions & 0 deletions src/superloop_e002/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""Representation-only helpers for E002 canonical telemetry."""

from __future__ import annotations

import hashlib
import json
from dataclasses import dataclass
from fractions import Fraction
from typing import Any


LOOP_IDS = ("A", "B", "C")
INTERLOCKS = {"AB": ("A", "B"), "BC": ("B", "C"), "CA": ("C", "A")}
CAPACITY = 8
DEADLINE_TICKS = 60
PHASE_PERIODS = (2, 3, 4, 6)


def canonical_json(value: Any) -> str:
"""Serialize a JSON-compatible value deterministically."""

return json.dumps(value, ensure_ascii=False, separators=(",", ":"), sort_keys=True)


def digest(value: Any) -> str:
"""Return the SHA-256 digest of canonical JSON."""

return hashlib.sha256(canonical_json(value).encode("utf-8")).hexdigest()


def raw_digest(value: bytes | str) -> str:
"""Return the SHA-256 digest of exact bytes or UTF-8 text."""

payload = value.encode("utf-8") if isinstance(value, str) else value
return hashlib.sha256(payload).hexdigest()


def rational(value: Fraction | int) -> dict[str, int]:
"""Encode an integer or reduced fraction using the E002 wire form."""

fraction = value if isinstance(value, Fraction) else Fraction(value, 1)
return {"numerator": fraction.numerator, "denominator": fraction.denominator}


def parse_rational(value: dict[str, int]) -> Fraction:
"""Decode and validate an E002 rational object."""

fraction = Fraction(value["numerator"], value["denominator"])
if rational(fraction) != value:
raise ValueError(f"noncanonical rational: {value}")
return fraction


@dataclass
class WorkState:
"""Reconstructed active work state, derived only from trace events."""

work_id: str
location: str
admitted_at: int
processed: bool = False
process_count: int = 0
ready_since: int | None = None
provenance_complete: bool = True
lease_fresh_until: int | None = None


def auc(scores_and_labels: list[tuple[Fraction, int]]) -> Fraction | None:
"""Calculate exact ROC-AUC with average-rank tie semantics."""

positive_count = sum(label == 1 for _, label in scores_and_labels)
negative_count = sum(label == 0 for _, label in scores_and_labels)
if not positive_count or not negative_count:
return None
grouped: dict[Fraction, list[int]] = {}
for score, label in scores_and_labels:
counts = grouped.setdefault(score, [0, 0])
counts[label] += 1
wins_twice = 0
lower_negatives = 0
for score in sorted(grouped):
negatives, positives = grouped[score]
wins_twice += 2 * positives * lower_negatives
wins_twice += positives * negatives
lower_negatives += negatives
return Fraction(wins_twice, 2 * positive_count * negative_count)
Loading