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
49 changes: 49 additions & 0 deletions .github/workflows/neural-fabric.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Neural Fabric CI

on:
push:
branches: [main, neural-fabric-capture]
paths:
- "docs/neural-fabric/**"
- "research/activation-time-targeting/**"
- "schemas/neural-fabric/**"
- "packages/superconscious-core/superconscious_core/neural_fabric/**"
- "scripts/*neural-fabric*"
- "scripts/check-capacity-bounds.py"
- "tests/neural_fabric/**"
- "mk/neural-fabric.mk"
- ".github/workflows/neural-fabric.yml"
pull_request:
branches: [main]
paths:
- "docs/neural-fabric/**"
- "research/activation-time-targeting/**"
- "schemas/neural-fabric/**"
- "packages/superconscious-core/superconscious_core/neural_fabric/**"
- "scripts/*neural-fabric*"
- "scripts/check-capacity-bounds.py"
- "tests/neural_fabric/**"
- "mk/neural-fabric.mk"
- ".github/workflows/neural-fabric.yml"

permissions:
contents: read

jobs:
neural-fabric:
name: Neural Fabric invariant suite
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install numerical stack
run: python -m pip install --upgrade pip pytest numpy scipy scikit-learn matplotlib

- name: Run Neural Fabric CI
run: make -f mk/neural-fabric.mk neural-fabric-ci
203 changes: 203 additions & 0 deletions docs/exploratory/spo-baez-algebra-engine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
# SPO′ Baez Algebra Activation Engine

**Status:** exploratory capture.
**Scope:** semantic geometry / algebraic interoperability / executable prototype.
**Doctrinal boundary:** this is not a theorem, physics claim, consciousness claim, or canonical SourceOS schema. It is an inspectable bridge between the user's SPO′ semantic architecture and a typed algebraic prototype.

## Why this exists

The original SPO′ sketch used a ten-fold algebraic stack to describe recursive semantic activation inside the `S^{15}` field. That sketch intentionally mixed several registers:

- symbolic semantics;
- Baez-style algebraic motifs;
- Sefirot / cybernetic labels;
- recursive Subject–Predicate–Object activation;
- boundary phase matching across an `S^2` identity surface;
- an ontology-compiler direction.

The useful correction is not to delete the structure. The useful correction is to make the structure readable and typed.

This capture therefore preserves the exploratory mapping while separating the algebraic content into two orthogonal axes:

```text
Layer_n := (
Carrier_n,
Mode_n,
x_n in Carrier_n,
phi_n in S^2
)
```

where:

```text
Carrier ∈ {R, C, H, O}
Mode ∈ {NORM, LIE, JORDAN, CLIFFORD, ALTERNATIVE, EXCEPTIONAL_JORDAN}
```

This removes the category drift from the first version, where concrete carriers such as `H` and `O` sat beside property classes such as `Lie algebra`, `Jordan algebra`, and `Clifford algebra`.

## Epistemic labels

| Label | Meaning |
|---|---|
| `[S]` | Symbolic / exploratory correspondence. |
| `[A]` | Algebraic construction or analogy. |
| `[F]` | Formalizable candidate definition. |
| `[C]` | Computable prototype artifact. |
| `[X]` | Known surrogate or non-final implementation. |

The Sefirot naming layer is `[S]`. The Cayley–Dickson carriers and coherence predicates are `[A]/[C]`. The activation predicate is `[F]/[C]`. The exceptional Jordan layer is currently `[X]`.

## Carrier spine

The only strictly algebraic ascent in this prototype is the Cayley–Dickson spine:

```text
R -> C -> H -> O
```

The prototype demonstrates the expected property transitions:

```text
R : ordered, commutative, associative
C : loses order
H : loses commutativity
O : loses associativity, retains alternativity
```

In the executable engine this is represented by a single `CD` class with level:

```text
0 = R
1 = C
2 = H
3 = O
```

## Modes and coherence predicates

| Mode | Coherence predicate |
|---|---|
| `NORM` | Hurwitz norm composition: `|xy|^2 = |x|^2 |y|^2`. |
| `LIE` | Jacobi identity for `[x,y] = xy - yx`; admitted only over associative carriers. |
| `JORDAN` | Jordan identity for `x ∘ y = (xy + yx)/2`. |
| `CLIFFORD` | Embedded quadratic witness: `v^2 = -|v|^2` on the pure-imaginary carrier part. |
| `ALTERNATIVE` | Middle Moufang identity: `(xy)(zx) = x((yz)x)`. |
| `EXCEPTIONAL_JORDAN` | Current surrogate: octonionic Moufang coherence; full `h_3(O)` is a later implementation. |

## Sefirot configuration table

Each Sefirah is now a named `(Carrier, Mode)` configuration rather than a free-floating algebra class.

| Sefirah | Configuration | Preserved role |
|---|---|---|
| Malkhut | `(R, NORM)` | Real grounding; semantic object reality. |
| Yesod | `(C, NORM)` | Phase oscillation; complex coherence. |
| Hod | `(H, NORM)` | Quaternionic rotation; subject-orientation stability. |
| Netzach | `(O, NORM)` | Octonionic emergence; nonlinear semantic branching. |
| Tiferet | `(H, CLIFFORD)` | Boundary mediation; embedded Clifford witness over `H`. |
| Gevurah | `(C, JORDAN)` | Observables, judgment, logical pruning. |
| Chesed | `(H, JORDAN)` | Permission, soft projection, admissible object formation. |
| Binah | `(C, LIE)` | Associative Lie-bracket coherence; placeholder for richer operator-mode treatment. |
| Chokhmah | `(O, ALTERNATIVE)` | Moufang branching and counterfactual recursion. |
| Keter | `(O, EXCEPTIONAL_JORDAN)` | `h_3(O)` / `F_4` direction; currently a surrogate. |

## Activation predicate

The executable SPO′ activation predicate is:

```text
Activation_n =
previous layer on-shell
∧ next layer well-typed
∧ S² phase match
∧ next layer coherent
∧ carrier transition permitted
```

A carrier transition is admitted only if the next layer stays at the same Cayley–Dickson level or rises one level:

```text
Carrier_{n+1} ∈ {Carrier_n, Carrier_n + 1}
```

This gives a minimal typed realization of the earlier symbolic line:

```text
SPO′_n activates when the prior layer is resolved,
the boundary phase matches,
and the algebraic gate permits coherence.
```

## Current limitations

### Exceptional Jordan is a surrogate

`EXCEPTIONAL_JORDAN` currently verifies a necessary octonionic alternativity witness through Moufang coherence. It does **not** yet build the 27-dimensional exceptional Jordan algebra `h_3(O)` of `3x3` Hermitian octonionic matrices.

A future implementation should add:

```text
HermitianOctonionMatrix3x3
exceptional_jordan_product(X,Y) = (XY + YX)/2
exceptional_jordan_identity_check
```

### Lie is carrier-internal, not operator-level

The `LIE` mode currently uses the commutator bracket over associative carriers. That keeps the prototype typed, but it is not the richer object needed for gauge/operator semantics.

A future implementation should add an `OperatorMode` axis carrying operator Lie algebras such as:

```text
u(n), su(2), so(3), g_2 = Der(O)
```

This would let the engine distinguish:

```text
carrier-valued semantic state
operator algebra acting on the state
```

### Clifford is an embedded witness

`CLIFFORD` currently checks the quadratic relation on the pure-imaginary part of an associative carrier. It is not yet a full `Cl(V,Q)` constructor.

## Prototype location

Executable capture:

```text
prototypes/spo/spo_activation_engine.py
```

Run it locally with:

```bash
python3 prototypes/spo/spo_activation_engine.py
```

Expected result:

```text
ALL CHECKS PASS: True
```

## Interpretation boundary

This artifact preserves the exploratory SPO′ / Sefirot / Baez-algebra interface as a readable research object. It does not assert that semantic cognition, consciousness, Ricci flow, or physical matter are mathematically derived by this prototype.

The practical value is interoperability:

```text
semantic triple
-> typed recursive layer
-> carrier/mode gate
-> boundary phase
-> coherence witness
-> activation result
```

That is a usable bridge toward ontology compilation, semantic validation, SocioSphere reasoning-state inspection, and future categorical/operator extensions.
37 changes: 37 additions & 0 deletions docs/neural-fabric/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Neural Fabric Capture

**Status:** initial upstream capture.

**Scope:** Captures the Neural Fabric / lawful-learning substrate, structure, circuit, and activation-time targeting work as repo-native doctrine, reference code, schemas, fixtures, and CI checks.

This directory is the human-facing control plane for two work tracks:

1. **Model-family instantiation** — a unified mapping of the framework across transformer, Hopfield, SSM, MoE, CNN, RNN, diffusion, GNN, EBM, and tree/forest families.
2. **Activation-time targeting** — reproducible CPU-only simulations for steering vectors, SAE clamping, May-Wigner stability monitoring, heavy-tail SPRT probe cost, and Hopfield query injection.

The capture is deliberately evidence-disciplined. The experiments are marked `toy_model_confirmed`, not production-validated. Runtime promotion requires later open-weight transformer probes and governance review.

## Repo surfaces

```text
docs/neural-fabric/ human doctrine and mapping docs
research/activation-time-targeting/ reference simulation suite and claim summaries
schemas/neural-fabric/ JSON schemas for model families and targeting results
packages/superconscious-core/.../neural_fabric/ stable reference primitives
scripts/ invariant validators and capacity checks
tests/neural_fabric/ smoke tests for core primitives and result invariants
mk/neural-fabric.mk local CI entrypoint
.github/workflows/neural-fabric.yml GitHub Actions lane
```

## Epistemic boundary

The framework treats a neural network as a governed circuit fabric: substrate and structure are declared, mixture choices are trained, circuits are discovered post-training, and intervention/targeting is governed by audit events. That does not claim sentience, production safety, or universal interpretability. It gives us a disciplined architecture for measuring and governing activation-time control without retraining.

## CI entrypoint

```bash
make -f mk/neural-fabric.mk neural-fabric-ci
```

This validates schema syntax, compiles the reference package, checks committed reference result invariants, and runs smoke tests.
23 changes: 23 additions & 0 deletions mk/neural-fabric.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.PHONY: neural-fabric-static neural-fabric-smoke neural-fabric-ci neural-fabric-full

neural-fabric-static:
python3 -m json.tool schemas/neural-fabric/model-family.v1.json >/dev/null
python3 -m json.tool schemas/neural-fabric/targeting-experiment.v1.json >/dev/null
python3 -m json.tool schemas/neural-fabric/targeting-result.v1.json >/dev/null
python3 -m compileall packages/superconscious-core/superconscious_core/neural_fabric scripts research/activation-time-targeting/code >/dev/null

# NOTE: neural-fabric-smoke / neural-fabric-full depend on the results-validation
# and experiment-harness that are not yet committed (scripts/validate-neural-fabric-results.py,
# scripts/check-capacity-bounds.py, tests/neural_fabric, research/.../run_suite.py). They are
# kept here as the roadmap for that harness and are intentionally NOT part of neural-fabric-ci
# until those files land, so CI gates only what this module actually delivers.
neural-fabric-smoke:
python3 scripts/validate-neural-fabric-results.py research/activation-time-targeting
python3 scripts/check-capacity-bounds.py --m 60 --C 0.4 --s 0.1
python3 -m pytest tests/neural_fabric -q

neural-fabric-full:
python3 research/activation-time-targeting/code/run_suite.py --out research/activation-time-targeting/results/generated
python3 scripts/validate-neural-fabric-results.py research/activation-time-targeting

neural-fabric-ci: neural-fabric-static
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Neural Fabric reference primitives.

This package contains stable, CPU-only primitives extracted from the
activation-time targeting suite. Research scripts may depend on these modules;
runtime promotion still requires policy review and production evidence.
"""

from .may_wigner import may_wigner_number, classify_may_wigner
from .hopfield import hopfield_retrieve, query_injection, logit_boost

__all__ = [
"may_wigner_number",
"classify_may_wigner",
"hopfield_retrieve",
"query_injection",
"logit_boost",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""Hopfield retrieval and activation-time intervention primitives."""
from __future__ import annotations

import numpy as np


def _softmax(x: np.ndarray) -> np.ndarray:
z = x - np.max(x)
e = np.exp(z)
return e / e.sum()


def hopfield_retrieve(patterns: np.ndarray, query: np.ndarray, *, beta: float = 1.0) -> tuple[np.ndarray, np.ndarray]:
"""Return Hopfield-style retrieved vector and pattern weights.

`patterns` is shaped [N, d]. The update is the transformer-attention/Hopfield
primitive: softmax(beta * X q) followed by X^T w.
"""
X = np.asarray(patterns, dtype=float)
q = np.asarray(query, dtype=float)
if X.ndim != 2:
raise ValueError("patterns must be a rank-2 array")
if q.shape != (X.shape[1],):
raise ValueError(f"query shape {q.shape} does not match pattern dimension {X.shape[1]}")
logits = beta * (X @ q)
weights = _softmax(logits)
return weights @ X, weights


def query_injection(query: np.ndarray, target_pattern: np.ndarray, strength: float) -> np.ndarray:
"""Inject target direction into the query vector without changing weights."""
return np.asarray(query, dtype=float) + float(strength) * np.asarray(target_pattern, dtype=float)


def logit_boost(patterns: np.ndarray, query: np.ndarray, *, target_idx: int, strength: float, beta: float = 1.0) -> np.ndarray:
"""Boost one target logit directly and return the resulting distribution."""
X = np.asarray(patterns, dtype=float)
q = np.asarray(query, dtype=float)
logits = beta * (X @ q)
logits[int(target_idx)] += float(strength)
return _softmax(logits)
Loading
Loading