Skip to content

Commit d51ffd5

Browse files
authored
Merge branch 'main' into copilot/verify-phase-validation-sub-epis
2 parents ead485e + 48cb4e7 commit d51ffd5

File tree

15 files changed

+2134
-14
lines changed

15 files changed

+2134
-14
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: "Copilot Setup Steps"
2+
3+
# Automatically run the setup steps when they are changed to allow for easy validation,
4+
# and allow manual testing through the repository's "Actions" tab
5+
on:
6+
workflow_dispatch:
7+
push:
8+
paths:
9+
- .github/workflows/copilot-setup-steps.yml
10+
pull_request:
11+
paths:
12+
- .github/workflows/copilot-setup-steps.yml
13+
14+
jobs:
15+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
16+
copilot-setup-steps:
17+
runs-on: ubuntu-latest
18+
19+
# Set the permissions to the lowest permissions possible needed for your steps.
20+
# Copilot will be given its own token for its operations.
21+
permissions:
22+
# Required for actions/checkout - Copilot needs to access the repository
23+
contents: read
24+
25+
# Configure the environment for TNFR development
26+
# Purpose: Enable exploration, study, investigation, and development of TNFR
27+
# (Resonant Fractal Nature Theory - modeling coherent patterns through resonance)
28+
steps:
29+
- name: Checkout TNFR repository
30+
uses: actions/checkout@v5
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v6
34+
with:
35+
# Using Python 3.11 - the primary version for TNFR development and CI
36+
python-version: "3.11"
37+
cache: "pip"
38+
39+
- name: Install TNFR dependencies
40+
run: |
41+
python -m pip install --upgrade pip
42+
# Install TNFR directly from repository source code (NOT from PyPI)
43+
# Using editable mode (-e) to work with the latest development version
44+
# This provides full environment for exploring and developing TNFR:
45+
# - Core operators (13 canonical structural transformations)
46+
# - Test infrastructure for validating invariants
47+
# - Serialization for state preservation
48+
# - NumPy for structural computations
49+
python -m pip install -e .[test,numpy,yaml,orjson]
50+
51+
- name: Verify TNFR installation
52+
run: |
53+
# Verify the TNFR package is properly installed from repo (not PyPI)
54+
python -c "import tnfr; print(f'TNFR version: {tnfr.__version__}')"
55+
python -c "import tnfr, os; print(f'TNFR location: {os.path.dirname(tnfr.__file__)}')"
56+
# Verify core modules are accessible
57+
python -c "from tnfr.operators import Emission, Coherence, Resonance; print('✓ Core operators available')"
58+
python -c "from tnfr.metrics.coherence import compute_global_coherence; print('✓ Metrics available')"
59+
# Display Python environment info
60+
python --version
61+
pip list | grep -E "(tnfr|pytest|numpy|networkx)"

docs/THOL_CONFIGURATION_REFERENCE.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Parameters controlling when and how bifurcation (sub-EPI creation) occurs.
2929
| `THOL_MIN_EPI` | 0.2 | [0.05, 0.5] || Minimum EPI magnitude required for structural bifurcation |
3030
| `THOL_MIN_VF` | 0.1 | [0.01, 1.0] | Hz_str | Minimum structural frequency for reorganization capacity |
3131
| `THOL_ACCEL` | 0.10 | [0.01, 0.5] || Acceleration factor in glyph: ΔNFR += `THOL_accel` × d²EPI/dt² |
32+
| `THOL_MIN_COLLECTIVE_COHERENCE` | 0.3 | [0.0, 1.0] || Minimum collective coherence for sub-EPI ensemble. When multiple sub-EPIs exist and coherence < threshold, warning is logged |
3233

3334
**Physical Basis:**
3435

@@ -38,6 +39,12 @@ From the nodal equation ∂EPI/∂t = νf · ΔNFR(t), bifurcation occurs when *
3839
- **EPI_min**: Coherence floor. Nodes below this lack sufficient form to bifurcate coherently.
3940
- **νf_min**: Reorganization capacity floor. Nodes below this are "frozen" and cannot respond.
4041
- **THOL_accel**: Controls how strongly d²EPI/dt² influences ΔNFR in glyph sequences.
42+
- **THOL_MIN_COLLECTIVE_COHERENCE**: Monitors ensemble coherence of sub-EPIs. According to TNFR.pdf §2.2.10, sub-EPIs must form a **coherent ensemble** rather than fragmenting chaotically. Collective coherence is computed as `C = 1/(1 + var(sub_epi_magnitudes))`. Interpretation:
43+
- **> 0.7**: High coherence (structurally solid bifurcation)
44+
- **0.3-0.7**: Moderate (acceptable, monitor)
45+
- **< 0.3**: Low (possible fragmentation, warning logged)
46+
47+
When multiple sub-EPIs exist and coherence falls below threshold, a warning is logged and the event is recorded in `G.graph["thol_coherence_warnings"]` for analysis. This validation is **non-blocking** (warnings only) to allow research into low-coherence dynamics.
4148

4249
**Configuration Example:**
4350
```python
@@ -48,11 +55,21 @@ G = nx.Graph()
4855
G.graph["BIFURCATION_THRESHOLD_TAU"] = 0.8 # High threshold
4956
G.graph["THOL_MIN_EPI"] = 0.3 # Require strong coherence
5057
G.graph["THOL_MIN_VF"] = 0.2 # Require high capacity
58+
G.graph["THOL_MIN_COLLECTIVE_COHERENCE"] = 0.5 # Require coherent ensemble
5159

5260
# Sensitive bifurcation (easier to trigger)
5361
G.graph["BIFURCATION_THRESHOLD_TAU"] = 0.2 # Low threshold
5462
G.graph["THOL_MIN_EPI"] = 0.1 # Lower coherence floor
5563
G.graph["THOL_MIN_VF"] = 0.05 # Lower capacity floor
64+
G.graph["THOL_MIN_COLLECTIVE_COHERENCE"] = 0.2 # More tolerant of fragmentation
65+
66+
# Monitor collective coherence
67+
from tnfr.operators.health_analyzer import SequenceHealthAnalyzer
68+
analyzer = SequenceHealthAnalyzer()
69+
coherence_stats = analyzer.analyze_thol_coherence(G)
70+
if coherence_stats:
71+
print(f"Mean coherence: {coherence_stats['mean_coherence']:.3f}")
72+
print(f"Nodes below threshold: {coherence_stats['nodes_below_threshold']}")
5673
```
5774

5875
---
@@ -668,6 +685,7 @@ G.graph["BIFURCATION_THRESHOLD_TAU"] = 0.5 # Higher threshold
668685
| Version | Date | Changes |
669686
|---------|------|---------|
670687
| 1.0.0 | 2025-11-09 | Initial release: Centralized all THOL parameters with canonical constraints |
688+
| 1.1.0 | 2025-11-09 | Added `THOL_MIN_COLLECTIVE_COHERENCE` parameter for sub-EPI ensemble validation |
671689

672690
---
673691

src/tnfr/config/defaults_core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class CoreDefaults:
158158
THOL_MIN_DEGREE: int = 1 # Minimum network connectivity
159159
THOL_MIN_HISTORY_LENGTH: int = 3 # Minimum EPI history for acceleration computation
160160
THOL_ALLOW_ISOLATED: bool = False # Require network context by default
161+
THOL_MIN_COLLECTIVE_COHERENCE: float = 0.3 # Minimum collective coherence for sub-EPI ensemble
161162

162163
# VAL (Expansion) precondition thresholds
163164
VAL_MAX_VF: float = 10.0 # Maximum structural frequency threshold

src/tnfr/metrics/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
compute_learning_plasticity,
3333
glyph_history_to_operator_names,
3434
)
35+
from .phase_compatibility import (
36+
compute_network_phase_alignment,
37+
compute_phase_coupling_strength,
38+
is_phase_compatible,
39+
)
3540
from .reporting import (
3641
Tg_by_node,
3742
Tg_global,
@@ -68,4 +73,7 @@
6873
"compute_bifurcation_rate",
6974
"compute_metabolic_efficiency",
7075
"compute_emergence_index",
76+
"compute_phase_coupling_strength",
77+
"is_phase_compatible",
78+
"compute_network_phase_alignment",
7179
)

0 commit comments

Comments
 (0)