Skip to content

Commit 260033f

Browse files
Copilotfermga
andcommitted
Enhance operator documentation with anti-patterns, relationships, compatibility matrix, and test references
Co-authored-by: fermga <203334638+fermga@users.noreply.github.com>
1 parent 640d8cc commit 260033f

File tree

4 files changed

+841
-14
lines changed

4 files changed

+841
-14
lines changed

docs/grammar/03-OPERATORS-AND-GLYPHS.md

Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,30 @@ Coherence()(G, 0)
230230
print(f"ΔNFR after coherence: {G.nodes[0]['dnfr']:.3f}") # Reduced
231231
```
232232

233+
### Anti-Patterns
234+
```python
235+
# ✗ WRONG: Coherence without stabilization target
236+
[Emission, Coherence, Coherence, Coherence] # Redundant, no new structure to stabilize
237+
238+
# ✗ WRONG: Coherence on EPI=0 node
239+
G.add_node(0, EPI=0.0, vf=1.0, theta=0.0, dnfr=0.0)
240+
Coherence()(G, 0) # Violates precondition: EPI > 0
241+
242+
# ✓ CORRECT: Coherence after structure creation/destabilization
243+
[Emission, Dissonance, Coherence, Silence] # Stabilizes after destabilization
244+
```
245+
246+
### Relationships
247+
- **Must precede**: Any operator that requires stable base (especially ZHIR)
248+
- **Should follow**: Destabilizers (OZ, VAL, ZHIR) per U2
249+
- **Can follow**: Any operator that modifies structure
250+
251+
### Test References
252+
- `tests/unit/operators/test_coherence_dnfr_reduction.py` - ΔNFR reduction validation
253+
- `tests/unit/operators/test_coherence_preconditions.py` - EPI > 0 requirement
254+
- `tests/unit/operators/test_coherence_ct_tracking.py` - C(t) monotonicity
255+
- `tests/unit/operators/test_coherence_phase_locking.py` - Phase stabilization
256+
233257
---
234258

235259
## 4. Dissonance (OZ) ⚡
@@ -285,6 +309,28 @@ for op in sequence:
285309
op(G, 0)
286310
```
287311

312+
### Anti-Patterns
313+
```python
314+
# ✗ WRONG: Dissonance without stabilizer (violates U2)
315+
[Emission, Dissonance, Silence] # Missing Coherence/THOL
316+
317+
# ✗ WRONG: Multiple dissonances without handlers (violates U4a)
318+
[Emission, Dissonance, Dissonance, Silence] # No handlers between
319+
320+
# ✓ CORRECT: Dissonance with proper stabilization
321+
[Emission, Coherence, Dissonance, Coherence, Silence]
322+
```
323+
324+
### Relationships
325+
- **Must follow**: Stabilizers (IL, THOL) in sequence per U2
326+
- **Often precedes**: ZHIR (Mutation) - creates context for transformation
327+
- **Can close**: Sequences (U1b role)
328+
329+
### Test References
330+
- `tests/unit/operators/test_dissonance_preconditions.py` - EPI threshold validation
331+
- `tests/unit/operators/test_destabilizer_telemetry.py` - ΔNFR increase tracking
332+
- `tests/unit/operators/test_graduated_destabilizer_windows.py` - U2 compliance
333+
288334
---
289335

290336
## 5. Coupling (UM) 🔗
@@ -339,6 +385,27 @@ Coupling()(G, 0, 1)
339385
print(f"Nodes coupled: {G.has_edge(0, 1)}") # True
340386
```
341387

388+
### Anti-Patterns
389+
```python
390+
# ✗ WRONG: Coupling without phase verification (violates U3)
391+
G.add_node(0, EPI=0.5, vf=1.0, theta=0.0, dnfr=0.0)
392+
G.add_node(1, EPI=0.6, vf=1.0, theta=np.pi, dnfr=0.0) # Antiphase!
393+
Coupling()(G, 0, 1) # Should fail - destructive interference
394+
395+
# ✓ CORRECT: Phase verification before coupling
396+
validate_resonant_coupling(G, 0, 1) # Explicit check
397+
Coupling()(G, 0, 1)
398+
```
399+
400+
### Relationships
401+
- **Requires**: Phase verification (U3) via `validate_resonant_coupling()`
402+
- **Often precedes**: Reception (EN), Resonance (RA)
403+
- **Enables**: Network information flow
404+
405+
### Test References
406+
- `tests/unit/operators/test_coupling_preconditions.py` - Phase compatibility validation
407+
- `tests/unit/operators/test_coupling_metrics.py` - Edge creation verification
408+
342409
---
343410

344411
## 6. Resonance (RA) 🌊
@@ -387,6 +454,33 @@ Resonance()(G, 0, 1) # Then resonate
387454
print("Pattern propagated through resonance")
388455
```
389456

457+
### Anti-Patterns
458+
```python
459+
# ✗ WRONG: Resonance without coupling (no edges)
460+
G = nx.Graph()
461+
G.add_node(0, EPI=0.5, vf=1.0, theta=0.0, dnfr=0.0)
462+
G.add_node(1, EPI=0.6, vf=1.0, theta=0.1, dnfr=0.0)
463+
Resonance()(G, 0, 1) # No edge exists - violates precondition
464+
465+
# ✗ WRONG: Resonance with incompatible phases (violates U3)
466+
G.add_node(2, EPI=0.5, vf=1.0, theta=np.pi, dnfr=0.0) # Antiphase
467+
G.add_edge(0, 2)
468+
Resonance()(G, 0, 2) # Destructive interference
469+
470+
# ✓ CORRECT: Couple first, verify phases, then resonate
471+
Coupling()(G, 0, 1) # Creates edge with phase check
472+
Resonance()(G, 0, 1) # Amplifies
473+
```
474+
475+
### Relationships
476+
- **Requires**: Existing coupling (edges) and phase compatibility (U3)
477+
- **Often follows**: Coupling (UM)
478+
- **Effect**: Amplifies coherent patterns without altering identity
479+
480+
### Test References
481+
- `tests/integration/test_coherence_operator_integration.py` - Propagation validation
482+
- Phase verification enforced by grammar system
483+
390484
---
391485

392486
## 7. Silence (SHA) 🔇
@@ -433,6 +527,30 @@ Silence()(G, 0) # Freeze state
433527
print(f"νf after silence: {G.nodes[0]['vf']:.3f}") # ≈ 0
434528
```
435529

530+
### Anti-Patterns
531+
```python
532+
# ✗ WRONG: Silence in middle without reactivation
533+
[Emission, Silence, Coherence] # Node frozen, can't apply Coherence
534+
535+
# ✗ WRONG: Silence without prior stabilization
536+
[Emission, Dissonance, Silence] # Freezing unstable state
537+
538+
# ✓ CORRECT: Silence as final closure after stabilization
539+
[Emission, Coherence, Silence]
540+
541+
# ✓ CORRECT: Reactivation after silence
542+
[Emission, Silence, Emission, Coherence, Silence] # Reactivate with AL
543+
```
544+
545+
### Relationships
546+
- **Closes**: Sequences (U1b role)
547+
- **Should follow**: Stabilization (IL, THOL)
548+
- **Reactivation**: Requires generator (AL, NAV, REMESH)
549+
550+
### Test References
551+
- Latency/reactivation tested in emission tests
552+
- νf → 0 enforced by operator implementation
553+
436554
---
437555

438556
## 8. Expansion (VAL) 📈
@@ -477,6 +595,27 @@ sequence = [
477595
]
478596
```
479597

598+
### Anti-Patterns
599+
```python
600+
# ✗ WRONG: Expansion without stabilizer (violates U2)
601+
[Emission, Expansion, Silence] # Missing IL/THOL
602+
603+
# ✗ WRONG: Multiple expansions without stabilization
604+
[Emission, Expansion, Expansion, Silence] # Unbounded growth
605+
606+
# ✓ CORRECT: Each expansion balanced
607+
[Emission, Expansion, Coherence, Expansion, Coherence, Silence]
608+
```
609+
610+
### Relationships
611+
- **Requires**: Stabilizer (IL, THOL) per U2
612+
- **Often follows**: Emission or Reception (adding capacity)
613+
- **Inverse**: Contraction (NUL) reduces complexity
614+
615+
### Test References
616+
- `tests/unit/operators/test_destabilizer_telemetry.py` - ΔNFR increase validation
617+
- `tests/unit/operators/test_graduated_destabilizer_windows.py` - U2 compliance
618+
480619
---
481620

482621
## 9. Contraction (NUL) 📉
@@ -519,6 +658,29 @@ sequence = [
519658
]
520659
```
521660

661+
### Anti-Patterns
662+
```python
663+
# ✗ WRONG: Contraction on low-dimensional EPI
664+
G.add_node(0, EPI=0.5, vf=1.0, theta=0.0, dnfr=0.0) # Scalar EPI
665+
Contraction()(G, 0) # Cannot reduce below dim=1
666+
667+
# ✗ WRONG: Excessive contraction losing information
668+
[Emission, Expansion, Contraction, Contraction, Contraction] # Over-simplification
669+
670+
# ✓ CORRECT: Balanced complexity management
671+
[Emission, Expansion, Contraction, Coherence, Silence]
672+
```
673+
674+
### Relationships
675+
- **Inverse**: Expansion (VAL) - manages complexity bidirectionally
676+
- **Not a destabilizer**: Reduces complexity without requiring stabilizers
677+
- **Often follows**: Expansion or complex transformations
678+
679+
### Test References
680+
- `tests/unit/operators/test_contraction.py` - Dimensionality reduction
681+
- `tests/unit/operators/test_contraction_preconditions.py` - dim(EPI) > 1 validation
682+
- `tests/unit/operators/test_contraction_density_metrics.py` - Coherence preservation
683+
522684
---
523685

524686
## 10. Self-organization (THOL) 🌱
@@ -571,6 +733,29 @@ sequence = [
571733
]
572734
```
573735

736+
### Anti-Patterns
737+
```python
738+
# ✗ WRONG: THOL without recent destabilizer (violates U4b)
739+
[Emission, Coherence, SelfOrganization(), Silence] # No OZ/VAL/ZHIR within ~3 ops
740+
741+
# ✗ WRONG: THOL without follow-up stabilization
742+
[Emission, Dissonance, SelfOrganization, Silence] # Should add IL after
743+
744+
# ✓ CORRECT: THOL with proper context
745+
[Emission, Coherence, Dissonance, SelfOrganization, Coherence, Silence]
746+
# ^recent destabilizer ^transformer ^stabilizer
747+
```
748+
749+
### Relationships
750+
- **Requires**: Recent destabilizer (~3 ops) per U4b
751+
- **Handles**: Bifurcations from OZ, VAL
752+
- **Creates**: Sub-EPIs (fractal structure)
753+
- **Stabilizes**: System after transformation (U2 role)
754+
755+
### Test References
756+
- `tests/unit/operators/test_thol_coherence.py` - Fractal organization validation
757+
- `tests/unit/operators/test_controlled_bifurcation.py` - U4a handler role
758+
574759
---
575760

576761
## 11. Mutation (ZHIR) 🧬
@@ -624,6 +809,31 @@ sequence = [
624809
]
625810
```
626811

812+
### Anti-Patterns
813+
```python
814+
# ✗ WRONG: ZHIR without prior Coherence (violates U4b)
815+
[Emission, Dissonance, Mutation, Coherence, Silence] # No IL before OZ
816+
817+
# ✗ WRONG: ZHIR without recent destabilizer (violates U4b)
818+
[Emission, Coherence, Mutation, Silence] # No OZ/VAL within ~3 ops
819+
820+
# ✗ WRONG: ZHIR without handler (violates U4a)
821+
[Emission, Coherence, Dissonance, Mutation, Silence] # Missing IL/THOL after
822+
823+
# ✓ CORRECT: All U4b requirements met
824+
[Emission, Coherence, Dissonance, Mutation, Coherence, Silence]
825+
# ^prior IL ^recent dest ^transform ^handler+stab
826+
```
827+
828+
### Relationships
829+
- **Requires**: Prior IL + recent destabilizer + handler (U4b + U4a)
830+
- **Triggers**: Phase transformation (θ → θ')
831+
- **Most constrained**: Strictest grammar requirements of all operators
832+
833+
### Test References
834+
- `tests/unit/operators/test_bifurcation.py` - Transformation validation
835+
- `tests/unit/operators/test_canonical_grammar_rules.py` - U4b compliance
836+
627837
---
628838

629839
## 12. Transition (NAV) ➡️
@@ -665,6 +875,29 @@ sequence = [
665875
]
666876
```
667877

878+
### Anti-Patterns
879+
```python
880+
# ✗ WRONG: NAV without latent structure to activate
881+
G.add_node(0, EPI=0.0, vf=0.0, theta=0.0, dnfr=0.0) # Completely dormant
882+
Transition()(G, 0) # No previous state to transition from
883+
884+
# ✓ CORRECT: NAV activating preserved state
885+
[Emission, Silence, Transition, Coherence, Silence] # Reactivate after silence
886+
887+
# ✓ CORRECT: NAV as regime shift
888+
[Emission, Coherence, Transition, Reception, Silence] # Mode change
889+
```
890+
891+
### Relationships
892+
- **Generator role**: Can start sequences (U1a)
893+
- **Closure role**: Can end sequences (U1b)
894+
- **Dual nature**: Both activator and terminator
895+
- **Often used for**: Regime shifts, mode transitions
896+
897+
### Test References
898+
- Grammar tests validate U1a/U1b dual role
899+
- Latent activation tested in integration tests
900+
668901
---
669902

670903
## 13. Recursivity (REMESH) 🔄
@@ -708,6 +941,30 @@ sequence = [
708941
]
709942
```
710943

944+
### Anti-Patterns
945+
```python
946+
# ✗ WRONG: REMESH without history/previous states
947+
G = nx.Graph()
948+
G.add_node(0, EPI=0.0, vf=1.0, theta=0.0, dnfr=0.0)
949+
Recursivity()(G, 0) # No EPI history to reference
950+
951+
# ✓ CORRECT: REMESH with established patterns
952+
[Emission, Coherence, Emission, Recursivity] # Has history
953+
954+
# ✓ CORRECT: Multi-scale organization
955+
[Emission, Coupling, SelfOrganization, Recursivity] # Fractal + recursive
956+
```
957+
958+
### Relationships
959+
- **Generator role**: Can start sequences (U1a)
960+
- **Closure role**: Can end sequences (U1b)
961+
- **Creates**: Recursive patterns across scales
962+
- **Requires**: Previous EPI states (history)
963+
964+
### Test References
965+
- `tests/unit/operators/test_remesh_operator_integration.py` - Recursive structure validation
966+
- Multi-scale fractality tests
967+
711968
---
712969

713970
## Operator Composition Patterns

0 commit comments

Comments
 (0)