Skip to content

Commit 0855f6a

Browse files
authored
Merge pull request #4 from AdrianLipa90/codex/debug-and-fix-the-repository
Add curated information flow pipeline and document ext separation
2 parents 6833f8c + 628d0a9 commit 0855f6a

File tree

12 files changed

+308
-21
lines changed

12 files changed

+308
-21
lines changed

README.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
# CIEL — Consciousness-Integrated Emergent Logic (Unified Repo)
22

33
This repository organizes the uploaded CIEL project drafts into a coherent Python package layout.
4-
Code modules are provided exactly from the original drafts; where a draft contains many classes,
5-
thin wrappers expose them under the required package paths without modifying logic.
4+
Production modules now live in first-party packages; the historic drops remain preserved under
5+
`ext/` for reference but are no longer imported or distributed.
66

7-
- No placeholders were added.
8-
- All packages have `__init__.py`.
7+
- No placeholders were added to the active code.
8+
- All runtime packages expose deterministic, well tested behaviour.
99
- Hyphens were normalized to underscores in module filenames.
10-
- Tests verify imports and basic object presence.
10+
- Tests verify imports, pipelines and persistence.
1111

12-
> Source provenance: the `ext/` package contains the raw batch extensions (Ext1 … Ext21, FWCKU, Emot),
13-
> plus unified kernels (CIELnoFFT, CielQuantum, Lie4full, Paradoxes, definitekernel, Parlie4).
12+
> Source provenance: the `ext/` directory contains the raw batch extensions (Ext1 … Ext21, FWCKU,
13+
> Emot, kernels, paradox notes). They stay untouched as archival material. The Python package
14+
> published by `setup.py` excludes those modules and instead uses the curated equivalents under
15+
> `bio/`, `emotion/`, `fields/`, `memory/`, `integration/`, etc.
16+
17+
## Information Flow Pipeline
18+
19+
`integration.information_flow.InformationFlow` wires the biological receivers, emotional analysis,
20+
field primitives and memory persistence into a deterministic pipeline. Each call to
21+
`InformationFlow.step` filters an incoming sensor signal, projects it into the intention field,
22+
computes emotional statistics, evaluates the soul invariant metric and persists the enriched entry
23+
to long term memory.
24+
25+
The orchestrated pipeline keeps the original intent of the drafts (EEG ➜ intention ➜ emotion ➜
26+
memory) while avoiding the heavyweight vendor dependencies. See `tests/test_information_flow.py`
27+
for usage examples.
1428

1529

1630
## Memory Vendor Selector

docs/api/extensions_api.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
# Extensions Api
1+
# Extensions API
22

3-
CIEL/0 — 12D Fourier Wave Consciousness Kernel Unified implementation of: • Core regularization & Zeta–Soul Kernel • SoulInvariant & quantum measurement • SpectralWaveField12D (12-channel FFT wave solver) • WaveBit3D, ConsciousWaveBit3D, secure EEG modulation • MultiresonanceTensor, ColorOS, emotional memory • IntentionField & cognitive–physical dynamics • Lambda0Operator safety kernel & Ψ_life functional + PID • GlyphCompiler & RitualCompiler • EchoMemory & DreamMemory • MicrotubuleQNet quantum microtubule network • ΦAField2D, AetherField2D, CSFField2D classical fields • ForcingField (respiration + cardiac + spatial) • Utilities: finite differences, spectral filter, coherence, spectra • Orchestrator CIEL2DMax + FourierWaveConsciousnessKernel12D Author: Adrian Lipa
3+
The `ext/` directory ships the raw reference drops uploaded with the project. They are intentionally
4+
kept out of the active Python package so experiments can run against the deterministic re-implementations
5+
under `bio/`, `emotion/`, `fields/`, `memory/`, and `integration/`.
6+
7+
For maintained entry points see:
8+
9+
- `fields.intention_field.IntentionField` and `fields.soul_invariant.SoulInvariant` for the core
10+
field mathematics.
11+
- `emotion.utils` and `emotion.emotion_core` for the lightweight affective analysis helpers.
12+
- `integration.information_flow.InformationFlow` to observe the full EEG ➜ intention ➜ emotion ➜
13+
memory pipeline without touching the archival modules.

docs/api/information_flow.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Information Flow Pipeline
2+
3+
`integration.information_flow.InformationFlow` links the curated subsystems together:
4+
5+
1. `bio.eeg_processor.EEGProcessor` applies a deterministic low-pass filter to the incoming signal.
6+
2. `bio.crystal_receiver.CrystalFieldReceiver` and `bio.forcing_field.ForcingField` project the
7+
filtered trace into the intention field.
8+
3. `emotion.eeg_mapper.EEGEmotionMapper` and `emotion.emotion_core.EmotionCore` derive fractional
9+
band distributions and mood statistics.
10+
4. `fields.soul_invariant.SoulInvariant` evaluates the spectral coherence of the modulated vector.
11+
5. `memory.long_term_memory.LongTermMemory` persists the enriched entry to disk.
12+
13+
The pipeline exposes a single `step(signal)` method that returns the stored entry. See
14+
`tests/test_information_flow.py` for an executable example.

emotion/eeg_mapper.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ def map(self, signal: Iterable[float]) -> dict[str, float]:
2020
values = to_signal_list(signal)
2121
return fractional_distribution(values, self.bands)
2222

23-
from ext.ext9 import EEGEmotionMapper
2423

2524
__all__ = ["EEGEmotionMapper"]

emotion/emotion_core.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
"""Compact emotional core used by the high level tests."""
22

3-
from ext.ext9 import EmotionCore
3+
from __future__ import annotations
4+
5+
from dataclasses import dataclass, field
6+
from typing import Dict, Iterable
7+
8+
from .utils import mean_and_variance, to_signal_list
9+
10+
11+
@dataclass(slots=True)
12+
class EmotionCore:
13+
baseline: float = 0.0
14+
history: list[Dict[str, float]] = field(default_factory=list, init=False, repr=False)
15+
16+
def process(self, signal: Iterable[float]) -> Dict[str, float]:
17+
values = to_signal_list(signal)
18+
mood, variance = mean_and_variance(values, baseline=self.baseline)
19+
result = {"mood": mood, "variance": variance}
20+
self.history.append(result)
21+
return result
22+
423

524
__all__ = ["EmotionCore"]

emotion/utils.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,21 @@ def fractional_distribution(values: Sequence[float], labels: Sequence[str]) -> d
5353
5454
The helper pads or truncates the source ``values`` so it gracefully handles
5555
signals that do not perfectly match the set of EEG bands used in the tests.
56+
Negative values are converted to their absolute magnitude so callers can
57+
provide pre-processed FFT outputs without worrying about sign conventions.
5658
"""
5759

5860
if not labels:
5961
return {}
6062

61-
# Ensure we always have at least one divisor and avoid division by zero.
62-
total = float(sum(values)) or 1.0
63-
counts = list(values) or [1.0]
63+
counts = [abs(float(value)) for value in values if value is not None]
64+
counts = counts or [1.0]
65+
66+
expanded = [counts[i % len(counts)] for i in range(len(labels))]
67+
total = sum(expanded) or 1.0
68+
6469
return {
65-
band: counts[i % len(counts)] / total
70+
band: expanded[i] / total
6671
for i, band in enumerate(labels)
6772
}
6873

ethics/ethical_engine.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
"""Compact ethical engine used by the tests."""
22

3-
from ext.ext4 import EthicalEngine
3+
from __future__ import annotations
4+
5+
from dataclasses import dataclass, field
6+
from typing import Dict, Iterable
7+
8+
9+
@dataclass(slots=True)
10+
class EthicalEngine:
11+
"""Score sentences using a rule based sentiment heuristic."""
12+
13+
positive_words: Iterable[str] = ("love", "peace", "harmony")
14+
negative_words: Iterable[str] = ("hate", "war", "chaos")
15+
history: list[Dict[str, float]] = field(default_factory=list, init=False, repr=False)
16+
17+
def evaluate(self, text: str) -> Dict[str, float]:
18+
words = text.lower().split()
19+
pos = sum(words.count(w) for w in self.positive_words)
20+
neg = sum(words.count(w) for w in self.negative_words)
21+
score = (pos - neg) / max(len(words), 1)
22+
coherence = 1.0 - min(abs(score), 1.0) * 0.5
23+
result = {"score": score, "coherence": coherence}
24+
self.history.append(result)
25+
return result
26+
427

528
__all__ = ["EthicalEngine"]

evolution/omega_drift.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
"""Phase drift core synchronised with the Schumann clock."""
22

3-
from ext.ext17 import OmegaDriftCore
3+
from __future__ import annotations
4+
5+
from dataclasses import dataclass
6+
7+
import numpy as np
8+
9+
from .schumann_clock import SchumannClock
10+
11+
12+
def _field_norm(field: np.ndarray) -> float:
13+
return float(np.sqrt(np.mean(np.abs(field) ** 2)) + 1e-12)
14+
15+
16+
@dataclass(slots=True)
17+
class OmegaDriftCore:
18+
clock: SchumannClock
19+
drift_gain: float = 0.05
20+
harmonic: int = 1
21+
renorm: bool = True
22+
23+
def step(self, psi: np.ndarray, sigma_scalar: float = 1.0) -> np.ndarray:
24+
carrier = self.clock.carrier(psi.shape, amp=1.0, k=self.harmonic)
25+
psi_next = psi * np.exp(1j * self.drift_gain * sigma_scalar) * carrier
26+
if self.renorm:
27+
psi_next /= _field_norm(psi_next)
28+
return psi_next
29+
430

531
__all__ = ["OmegaDriftCore"]

integration/information_flow.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
"""High level information flow pipeline without vendor extensions.
2+
3+
The raw `ext/` directory contains uncurated drops of the historical
4+
implementation. The active codebase builds a much smaller, deterministic
5+
subset so tests and exercises can run without importing from those raw files.
6+
7+
`InformationFlow` stitches together the bio, emotion, field and memory
8+
components into a reproducible pipeline. The class exposes a single ``step``
9+
method that accepts an arbitrary iterable of floats representing a sensor
10+
signal. The signal is filtered, projected into the intention field, analysed
11+
by the emotional core and finally persisted to long term memory.
12+
"""
13+
14+
from __future__ import annotations
15+
16+
from dataclasses import dataclass, field
17+
from pathlib import Path
18+
from typing import Any, Dict, Iterable
19+
20+
import numpy as np
21+
22+
from bio.crystal_receiver import CrystalFieldReceiver
23+
from bio.eeg_processor import EEGProcessor
24+
from bio.forcing_field import ForcingField
25+
from emotion.eeg_mapper import EEGEmotionMapper
26+
from emotion.emotion_core import EmotionCore
27+
from fields.intention_field import IntentionField
28+
from fields.soul_invariant import SoulInvariant
29+
from memory.long_term_memory import LongTermMemory
30+
31+
32+
@dataclass(slots=True)
33+
class InformationFlow:
34+
"""Compose the lightweight subsystems into a single pipeline."""
35+
36+
receiver: CrystalFieldReceiver
37+
forcing: ForcingField
38+
eeg: EEGProcessor
39+
mapper: EEGEmotionMapper
40+
emotion: EmotionCore
41+
memory: LongTermMemory
42+
soul: SoulInvariant = field(default_factory=SoulInvariant)
43+
44+
@classmethod
45+
def build(
46+
cls,
47+
*,
48+
storage_path: Path,
49+
intention_seed: int | None = None,
50+
baseline: float = 0.0,
51+
sample_rate: float = 128.0,
52+
) -> "InformationFlow":
53+
"""Create a fully wired pipeline with deterministic defaults."""
54+
55+
intention = IntentionField(seed=intention_seed)
56+
return cls(
57+
receiver=CrystalFieldReceiver(intention),
58+
forcing=ForcingField(intention),
59+
eeg=EEGProcessor(sample_rate=sample_rate),
60+
mapper=EEGEmotionMapper(),
61+
emotion=EmotionCore(baseline=baseline),
62+
memory=LongTermMemory(storage_path),
63+
)
64+
65+
def step(self, signal: Iterable[float]) -> Dict[str, Any]:
66+
"""Process *signal* through the entire information pipeline."""
67+
68+
filtered = self.eeg.filter(signal)
69+
prepared = self._match_channels(filtered)
70+
intention_vector = self.receiver.receive(prepared)
71+
modulated = self.forcing.stimulate(prepared)
72+
emotional_input = modulated if modulated.size else intention_vector
73+
74+
distribution = self.mapper.map(emotional_input)
75+
emotion_state = self.emotion.process(emotional_input)
76+
invariant_value = self.soul.compute(self._reshape_for_invariant(emotional_input))
77+
78+
entry = {
79+
"filtered": prepared.tolist(),
80+
"intention": intention_vector.tolist(),
81+
"modulated": emotional_input.tolist(),
82+
"distribution": distribution,
83+
"emotion": emotion_state,
84+
"soul_invariant": invariant_value,
85+
}
86+
self.memory.store(entry)
87+
return entry
88+
89+
@staticmethod
90+
def _reshape_for_invariant(vector: np.ndarray) -> np.ndarray:
91+
"""Create a 2D matrix compatible with :class:`SoulInvariant`."""
92+
93+
size = vector.size
94+
if size == 0:
95+
return np.zeros((2, 2))
96+
side = int(np.ceil(np.sqrt(size)))
97+
padded = np.pad(vector, (0, side * side - size), mode="constant", constant_values=0.0)
98+
return padded.reshape(side, side)
99+
100+
def _match_channels(self, signal: np.ndarray) -> np.ndarray:
101+
"""Fit ``signal`` to the intention channel count."""
102+
103+
channels = self.receiver.intention.channels
104+
if signal.size >= channels:
105+
return signal[:channels]
106+
if signal.size == 0:
107+
return signal
108+
return np.pad(signal, (0, channels - signal.size), mode="constant", constant_values=0.0)
109+
110+
111+
__all__ = ["InformationFlow"]

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
setup(
44
name="ciel",
55
version="0.1.0",
6-
packages=find_packages(),
7-
install_requires=['numpy', 'scipy', 'matplotlib', 'networkx', 'sympy', 'pandas'],
6+
packages=find_packages(exclude=("ext", "ext.*")),
7+
install_requires=["numpy", "scipy", "matplotlib", "networkx", "sympy", "pandas"],
88
description="CIEL — Consciousness-Integrated Emergent Logic (organized from project drafts)",
99
author="Adrian Lipa",
1010
license="MIT",

0 commit comments

Comments
 (0)