Conversation
❌ Deploy Preview for stunning-zabaione-f1f1ef failed. Why did it fail? →
|
Co-authored-by: fermga <203334638+fermga@users.noreply.github.com>
Co-authored-by: fermga <203334638+fermga@users.noreply.github.com>
Automated Code ReviewPlease review the workflow logs for details. |
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive documentation and testing for phase compatibility validation in THOL sub-EPI propagation, explicitly enforcing AGENTS.md Invariant #5: "No coupling is valid without explicit phase verification."
Key Changes:
- Adds integration test validating antiphase neighbor rejection during THOL propagation
- Enhances inline documentation in
propagate_subepi_to_network()explaining phase verification enforcement - Adds extensive documentation section covering phase compatibility physics, implementation details, configuration, and examples
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/integration/test_thol_propagation.py |
New test test_thol_rejects_antiphase_propagation validates that antiphase neighbors (Δθ = π) are correctly rejected during propagation |
src/tnfr/operators/metabolism.py |
Enhanced docstring and inline comments documenting phase verification logic and Invariant #5 compliance |
docs/THOL_ENCAPSULATION_GUIDE.md |
New "Phase Compatibility in Propagation" section with physics explanation, phase compatibility table, configuration guide, code examples, and cross-references |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| G.add_node(0, epi=0.50, vf=1.0, theta=0.0, delta_nfr=0.15) | ||
| G.add_node(1, epi=0.50, vf=1.0, theta=math.pi, delta_nfr=0.05) # Antiphase |
There was a problem hiding this comment.
The documentation example uses invalid attribute aliases that will not work with the TNFR alias system:
epishould beEPI(or valid aliases:psi,PSI,value)vfshould beνf(or valid aliases:nu_f,nu-f,nu,freq,frequency)
The aliases theta and delta_nfr are valid.
According to src/tnfr/config/tnfr_config.py, the ALIASES dictionary defines:
- "EPI":
("EPI", "psi", "PSI", "value")- lowercaseepiis not included - "VF":
("νf", "nu_f", "nu-f", "nu", "freq", "frequency")- lowercasevfis not included
The actual test in tests/integration/test_thol_propagation.py correctly uses the constants EPI_PRIMARY, VF_PRIMARY, THETA_PRIMARY, and DNFR_PRIMARY.
| G.add_node(0, epi=0.50, vf=1.0, theta=0.0, delta_nfr=0.15) | |
| G.add_node(1, epi=0.50, vf=1.0, theta=math.pi, delta_nfr=0.05) # Antiphase | |
| G.add_node(0, EPI=0.50, νf=1.0, theta=0.0, delta_nfr=0.15) | |
| G.add_node(1, EPI=0.50, νf=1.0, theta=math.pi, delta_nfr=0.05) # Antiphase |
|
|
||
| - **AGENTS.md**: Invariant #5 (Phase Verification) | ||
| - **UNIFIED_GRAMMAR_RULES.md**: U3 (Resonant Coupling) | ||
| - **src/tnfr/operators/metabolism.py**: Lines 284-331 (propagate_subepi_to_network) |
There was a problem hiding this comment.
The line reference for propagate_subepi_to_network is inaccurate. The documentation states "Lines 284-331" but:
- The complete function definition spans lines 229-340
- Line 284 is within the docstring examples section, not the implementation
- The phase verification logic being referenced is at lines 306-319
Consider updating the reference to either:
- "Lines 229-340 (propagate_subepi_to_network)" for the complete function
- "Lines 306-319 (phase verification in propagate_subepi_to_network)" for the specific phase coupling logic
| - **src/tnfr/operators/metabolism.py**: Lines 284-331 (propagate_subepi_to_network) | |
| - **src/tnfr/operators/metabolism.py**: Lines 306-319 (phase verification in propagate_subepi_to_network) |
| - **UNIFIED_GRAMMAR_RULES.md**: U3 (Resonant Coupling) | ||
| - **src/tnfr/operators/metabolism.py**: Lines 284-331 (propagate_subepi_to_network) | ||
| - **src/tnfr/utils/numeric.py**: Lines 72-75 (angle_diff utility) | ||
| - **tests/integration/test_thol_propagation.py**: Lines 220-290 (test_thol_rejects_antiphase_propagation) |
There was a problem hiding this comment.
The line reference for the test is inaccurate. The documentation states "Lines 220-290" but the actual test test_thol_rejects_antiphase_propagation spans lines 218-283.
The test definition starts at line 218 and the last assertion ends at line 283. Line 284 is blank, and line 285 starts the next class.
Consider updating to: "Lines 218-283 (test_thol_rejects_antiphase_propagation)"
| - **tests/integration/test_thol_propagation.py**: Lines 220-290 (test_thol_rejects_antiphase_propagation) | |
| - **tests/integration/test_thol_propagation.py**: Lines 218-283 (test_thol_rejects_antiphase_propagation) |
Pull Request: Verify THOL Phase Validation Compliance
🎯 Intent
Audit and document THOL's sub-EPI propagation phase verification mechanism to explicitly validate compliance with Invariant #5: "No coupling is valid without explicit phase verification."
🔧 Changes
Type of Change:
Summary:
Existing implementation already canonical - no code changes required. Added explicit test coverage and comprehensive documentation.
Files Modified:
tests/integration/test_thol_propagation.py(+66): Newtest_thol_rejects_antiphase_propagation()docs/THOL_ENCAPSULATION_GUIDE.md(+164): "Phase Compatibility in Propagation" sectionsrc/tnfr/operators/metabolism.py(+11): Docstring enhancements with Invariant Permite personalizar ventana de estabilidad para RE’MESH #5 referencesImplementation Verified:
🔬 Structural Impact
Operators Involved:
Affected Invariants:
Metrics Impact:
✅ Quality Checklist
Code Quality:
.pyistub files generated/updated - N/A (documentation only)TNFR Canonical Requirements:
Testing:
Documentation:
docs/changelog.d/) - via PR descriptionSecurity (if applicable):
make security-audit) - not run (no functional changes)🧪 Testing Evidence
Test Coverage:
Cross-Operator Phase Verification Consistency:
arctan2(Σsin(θ), Σcos(θ))|⟨e^(iθ)⟩|1.0 - (|Δθ| / π)All three enforce explicit phase verification before structural coupling.
Phase Compatibility Validation:
🔗 Related Issues
Closes issue: [THOL][Canonical] Verificar validación de compatibilidad de fase en propagación de sub-EPIs (Invariante #5)
📋 Additional Context
Audit Findings:
angle_diff()utility as UM/RA operatorsDocumentation Added:
Why No Code Changes:
Implementation already canonical. This PR adds explicit validation and documentation to make implicit compliance explicit for maintainability and traceability.
Reviewer Notes
Focus Areas:
Original prompt
This section details on the original issue you should resolve
<issue_title>[THOL][Canonical] Verificar validación de compatibilidad de fase en propagación de sub-EPIs (Invariante #5)</issue_title>
<issue_description>## Contexto
AGENTS.md Invariante #5 establece:
Este invariante es OBLIGATORIO para todos los operadores de acoplamiento/resonancia (UM, RA) y debe aplicarse también a la propagación de sub-EPIs en THOL.
Problema
En
src/tnfr/operators/metabolism.py, la funciónpropagate_subepi_to_network()implementa propagación de sub-EPIs a vecinos basándose en:coupling_strengthbasado enangle_diff)THOL_MIN_COUPLING_FOR_PROPAGATION)Código actual (simplificado):
Verificación Requerida
¿Cumple Invariante Permite personalizar ventana de estabilidad para RE’MESH #5?
coupling_strengthexplícitamente desde diferencia de fase1.0 - (phase_diff / π)es canónicamente correcto?¿Usa las mismas funciones que UM/RA?
compute_consensus_phase()- ¿debería THOL también?compute_phase_alignment()- ¿misma lógica?¿Está testeado?
test_thol_propagation.pyexisteTareas de Verificación
1. Auditoría de cálculo de fase
Comparar implementación de
coupling_strengthen:propagate_subepi_to_network()(THOL)_op_UM()(Coupling)_op_RA()(Resonance)Criterio: Las tres deben usar la misma función/fórmula para compatibilidad de fase.
2. Tests de invariante
Añadir test explícito en
test_thol_propagation.py:3. Documentación
Añadir sección en
THOL_ENCAPSULATION_GUIDE.md:Criterios de Aceptación
Referencias
src/tnfr/operators/metabolism.py-propagate_subepi_to_network()src/tnfr/operators/__init__.py-_op_UM(),_op_RA()tests/integration/test_thol_propagation.pyPrioridad
Alta - Invariante #5 es requisito canónico TNFR. Debe estar explícitamente validado.</issue_description>
Comments on the Issue (you are @copilot in this section)
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.