codec-cortex 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codec_cortex-0.3.2.dist-info/METADATA +183 -0
- codec_cortex-0.3.2.dist-info/RECORD +81 -0
- codec_cortex-0.3.2.dist-info/WHEEL +5 -0
- codec_cortex-0.3.2.dist-info/entry_points.txt +2 -0
- codec_cortex-0.3.2.dist-info/licenses/LICENSE +21 -0
- codec_cortex-0.3.2.dist-info/scm_file_list.json +124 -0
- codec_cortex-0.3.2.dist-info/scm_version.json +8 -0
- codec_cortex-0.3.2.dist-info/top_level.txt +1 -0
- cortex/__init__.py +22 -0
- cortex/__main__.py +7 -0
- cortex/_version.py +24 -0
- cortex/cli/__init__.py +5 -0
- cortex/cli/commands/__init__.py +150 -0
- cortex/cli/commands/add.py +89 -0
- cortex/cli/commands/compile.py +31 -0
- cortex/cli/commands/delete.py +44 -0
- cortex/cli/commands/diagram.py +130 -0
- cortex/cli/commands/diff.py +135 -0
- cortex/cli/commands/doctor.py +74 -0
- cortex/cli/commands/format.py +29 -0
- cortex/cli/commands/get.py +45 -0
- cortex/cli/commands/glossary.py +98 -0
- cortex/cli/commands/list.py +44 -0
- cortex/cli/commands/micro.py +79 -0
- cortex/cli/commands/move.py +45 -0
- cortex/cli/commands/new.py +80 -0
- cortex/cli/commands/recover.py +90 -0
- cortex/cli/commands/render.py +93 -0
- cortex/cli/commands/update.py +81 -0
- cortex/cli/commands/v2_canonicalize.py +162 -0
- cortex/cli/commands/v2_compare.py +74 -0
- cortex/cli/commands/v2_convert.py +183 -0
- cortex/cli/commands/v2_explain_loss.py +97 -0
- cortex/cli/commands/v2_inspect.py +113 -0
- cortex/cli/commands/v2_roundtrip.py +104 -0
- cortex/cli/commands/v2_roundtrip_bidir.py +128 -0
- cortex/cli/commands/v2_verify_view.py +65 -0
- cortex/cli/commands/verify.py +119 -0
- cortex/cli/main.py +636 -0
- cortex/core/__init__.py +85 -0
- cortex/core/ast.py +313 -0
- cortex/core/compare.py +180 -0
- cortex/core/document_kind.py +525 -0
- cortex/core/errors.py +399 -0
- cortex/core/lexer.py +267 -0
- cortex/core/parser.py +671 -0
- cortex/core/validator.py +268 -0
- cortex/core/writer.py +249 -0
- cortex/crud/__init__.py +17 -0
- cortex/crud/mutations.py +342 -0
- cortex/crud/selectors.py +95 -0
- cortex/crud/transactions.py +213 -0
- cortex/glossary/__init__.py +21 -0
- cortex/glossary/contracts.py +37 -0
- cortex/glossary/minimal.py +94 -0
- cortex/glossary/model.py +77 -0
- cortex/glossary/resolver.py +96 -0
- cortex/hcortex/__init__.py +35 -0
- cortex/hcortex/edit_parser.py +489 -0
- cortex/hcortex/edit_renderer.py +158 -0
- cortex/hcortex/markdown_model.py +81 -0
- cortex/hcortex/profiles.py +166 -0
- cortex/hcortex/read_renderer.py +342 -0
- cortex/hcortex/recovery.py +782 -0
- cortex/py.typed +0 -0
- cortex/templates/__init__.py +8 -0
- cortex/templates/brain.py +118 -0
- cortex/templates/minimal_glossary.py +42 -0
- cortex/templates/package.py +91 -0
- cortex/templates/skill.py +91 -0
- cortex/v2/__init__.py +30 -0
- cortex/v2/diagnostics.py +57 -0
- cortex/v2/encoder.py +1106 -0
- cortex/v2/equivalence.py +323 -0
- cortex/v2/hcortex_parser.py +615 -0
- cortex/v2/hcortex_renderer.py +450 -0
- cortex/v2/ir.py +223 -0
- cortex/v2/parser.py +655 -0
- cortex/v2/view.py +425 -0
- cortex/v2/view_renderer.py +474 -0
- cortex/v2/writer.py +301 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codec-cortex
|
|
3
|
+
Version: 0.3.2
|
|
4
|
+
Summary: CODEC-CORTEX CLI — modular deterministic processor for .cortex files
|
|
5
|
+
Author: Fidel Ernesto Lozada A.
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/FidelErnesto03/codec-cortex
|
|
8
|
+
Project-URL: Documentation, https://github.com/FidelErnesto03/codec-cortex/blob/main/cli/README.md
|
|
9
|
+
Project-URL: Repository, https://github.com/FidelErnesto03/codec-cortex
|
|
10
|
+
Project-URL: Issues, https://github.com/FidelErnesto03/codec-cortex/issues
|
|
11
|
+
Keywords: cortex,codec,memory,cli,llm,agent,cognitive
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Topic :: Text Processing
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# codec-cortex
|
|
34
|
+
|
|
35
|
+
> Implementación determinista del codec CODEC-CORTEX v0.3.2. El núcleo v2 soporta CORTEX ⇄ HCORTEX verificable sobre los artefactos canónicos del paquete. CORTEX es el formato denso nativo; HCORTEX es su representación humana reversible.
|
|
36
|
+
|
|
37
|
+
`codec-cortex` procesa artefactos `.cortex` y `.hcortex.md` sin depender de LLM: parsea a AST, serializa CORTEX, renderiza HCORTEX, ejecuta validaciones VIEW, compara equivalencia y valida roundtrip bidireccional.
|
|
38
|
+
|
|
39
|
+
> **v0.3.2 — Naming canónico:** los comandos `v2-*` se han renombrado a sus formas canónicas (`roundtrip`, `convert`, `roundtrip-bidir`, `compare`, `verify-view`, `explain-loss`, `canonicalize`, `inspect`). Los nombres `v2-*` se mantienen como alias deprecados y emiten un `WARNING` a stderr al ser invocados. Serán eliminados en v1.0.0.
|
|
40
|
+
|
|
41
|
+
## Modelo conceptual v0.3.2
|
|
42
|
+
|
|
43
|
+
| Concepto | Rol | Estado |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| **CORTEX** | Representación densa nativa. Fuente canónica operacional y base de verificación, reversible por contrato VIEW. | `current` |
|
|
46
|
+
| **HCORTEX / HUMAN-CORTEX** | Representación humana densa y reversible cuando conserva VIEW/trazabilidad equivalente con cobertura válida. | `current` |
|
|
47
|
+
| **VIEW** | Contrato declarativo de correspondencia CORTEX ⇄ HCORTEX. Define render, reversión, campos, preservación y fallback. | `current` |
|
|
48
|
+
| **CORTEX-OUT** | Respuesta conversacional eficiente. No participa en decode/encode/verify/roundtrip. | `specification` |
|
|
49
|
+
|
|
50
|
+
HCORTEX canónico no es "Markdown bonito". Para declararse canónico debe poder participar en `decode/encode/verify/roundtrip` mediante VIEW o trazabilidad equivalente. Un Markdown sin VIEW/trazabilidad se considera `display-only` y debe reportar `reversible:false`.
|
|
51
|
+
|
|
52
|
+
## Gate de reversibilidad
|
|
53
|
+
|
|
54
|
+
`reversible:true` solo es válido cuando:
|
|
55
|
+
|
|
56
|
+
1. `view_coverage == 100%`;
|
|
57
|
+
2. no existen errores `E_VIEW_*` ni `E_HCORTEX_*`;
|
|
58
|
+
3. el modo no es `display`;
|
|
59
|
+
4. el roundtrip canónico aplicable pasa sin pérdida no declarada.
|
|
60
|
+
|
|
61
|
+
## Estado de madurez
|
|
62
|
+
|
|
63
|
+
| Capacidad | Estado | Evidencia principal |
|
|
64
|
+
|---|---|---|
|
|
65
|
+
| CORTEX v2 parser/writer | `current` | `cortex roundtrip` byte-identical |
|
|
66
|
+
| CORTEX → HCORTEX | `current` | genera `skill/hcortex/SKILL.md` byte-identical |
|
|
67
|
+
| HCORTEX → CORTEX | `current` | reconstruye 266/266 entries en `skill/cortex/SKILL.md` |
|
|
68
|
+
| Roundtrip bidireccional | `current` | `cortex roundtrip-bidir` rc=0, 0 diffs en ambos artefactos canónicos |
|
|
69
|
+
| VIEW coverage | `current` | 44/44 VIEW en skill; 10/10 artefactos del corpus migrados a VIEW en v0.3.2 |
|
|
70
|
+
| `cortex canonicalize` (VIEW-aware) | `current` | preserva estructura sin VIEW; canonicalización completa con VIEW (B-01/B-05 fix) |
|
|
71
|
+
| Hash mismatch | `current` para hashes declarados | `E_VIEW_HASH_MISMATCH` si el hash existe y no coincide |
|
|
72
|
+
| `doctor` legacy | `current` | diagnóstico clásico del CLI |
|
|
73
|
+
| `doctor` v2 | `planned` | no existe como comando separado en v0.3.2 |
|
|
74
|
+
| JSON global para comandos legacy soportados | `current` parcial | `--json` donde el comando lo soporta |
|
|
75
|
+
| JSON uniforme para todos los comandos v2 | `planned` | no declarar como actual |
|
|
76
|
+
| MCP server | `future` | no implementado |
|
|
77
|
+
| Runtime de maduración promote/decay | `future` | no implementado |
|
|
78
|
+
|
|
79
|
+
## Artefactos canónicos
|
|
80
|
+
|
|
81
|
+
| Ruta | Rol | Métrica verificada |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| `skill/cortex/SKILL.md` | CORTEX canónico | 43,925 bytes; 14 secciones; 266 entries; 44 VIEW |
|
|
84
|
+
| `skill/hcortex/SKILL.md` | HCORTEX canónico | 47,186 bytes; reversible; roundtrip válido |
|
|
85
|
+
| `benchmarks/v2.0.0/corpus/source/*.cortex` (10) | Corpus migrado a VIEW | 10/10 artefactos con VIEW directives; coverage 100% |
|
|
86
|
+
|
|
87
|
+
## Instalación
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pip install -e .
|
|
91
|
+
# o para desarrollo
|
|
92
|
+
pip install -e ".[dev]"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Comandos principales (nombres canónicos v0.3.2)
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Identidad
|
|
99
|
+
cortex --version
|
|
100
|
+
|
|
101
|
+
# Inspección y cobertura
|
|
102
|
+
cortex inspect skill/cortex/SKILL.md
|
|
103
|
+
cortex verify-view skill/cortex/SKILL.md
|
|
104
|
+
|
|
105
|
+
# Roundtrip CORTEX byte-identical
|
|
106
|
+
cortex roundtrip skill/cortex/SKILL.md
|
|
107
|
+
|
|
108
|
+
# CORTEX → HCORTEX
|
|
109
|
+
cortex convert skill/cortex/SKILL.md --from cortex --to hcortex --out /tmp/skill.hcortex.md
|
|
110
|
+
|
|
111
|
+
# HCORTEX → CORTEX
|
|
112
|
+
cortex convert skill/hcortex/SKILL.md --from hcortex --to cortex --out /tmp/skill.cortex.md
|
|
113
|
+
|
|
114
|
+
# Roundtrip bidireccional
|
|
115
|
+
cortex roundtrip-bidir skill/cortex/SKILL.md
|
|
116
|
+
cortex roundtrip-bidir skill/hcortex/SKILL.md
|
|
117
|
+
|
|
118
|
+
# Comparación de equivalencia
|
|
119
|
+
cortex compare skill/cortex/SKILL.md /tmp/skill.cortex.md
|
|
120
|
+
|
|
121
|
+
# Pérdida / canonicalización (VIEW-aware desde v0.3.2)
|
|
122
|
+
cortex explain-loss skill/hcortex/SKILL.md
|
|
123
|
+
cortex canonicalize skill/cortex/SKILL.md --out /tmp/canonical.cortex.md
|
|
124
|
+
cortex canonicalize benchmarks/v2.0.0/corpus/source/devops-k8s-rollout.cortex \
|
|
125
|
+
--out /tmp/canonical.cortex # WARNING: no VIEW → structure-preserving
|
|
126
|
+
cortex canonicalize skill/cortex/SKILL.md --preserve --out /tmp/preserved.cortex
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Alias deprecados (aún aceptados, removidos en v1.0.0)
|
|
130
|
+
|
|
131
|
+
| Canonical | Alias deprecado |
|
|
132
|
+
|-----------|------------------|
|
|
133
|
+
| `cortex roundtrip` | `cortex v2-roundtrip` |
|
|
134
|
+
| `cortex convert` | `cortex v2-convert` |
|
|
135
|
+
| `cortex roundtrip-bidir` | `cortex v2-roundtrip-bidir` |
|
|
136
|
+
| `cortex compare` | `cortex v2-compare` |
|
|
137
|
+
| `cortex verify-view` | `cortex v2-verify-view` |
|
|
138
|
+
| `cortex explain-loss` | `cortex v2-explain-loss` |
|
|
139
|
+
| `cortex canonicalize` | `cortex v2-canonicalize` |
|
|
140
|
+
| `cortex inspect` | `cortex v2-inspect` |
|
|
141
|
+
|
|
142
|
+
## Comandos legacy principales
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
cortex new brain --name my-brain --out brain.cortex
|
|
146
|
+
cortex verify brain.cortex --strict --kind brain
|
|
147
|
+
cortex render brain.cortex --mode edit --out brain.hcortex.edit.md
|
|
148
|
+
cortex compile brain.hcortex.edit.md --out brain.compiled.cortex
|
|
149
|
+
cortex doctor brain.cortex --strict --kind brain
|
|
150
|
+
cortex diff brain.cortex brain.compiled.cortex --profile structural
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## JSON
|
|
154
|
+
|
|
155
|
+
El flag global `--json` existe, pero no todos los comandos v2 emiten JSON uniforme en v0.3.2. No declarar JSON v2 completo como capacidad actual. Los comandos legacy que lo soportan siguen disponibles; algunos comandos aceptan `--format json` local.
|
|
156
|
+
|
|
157
|
+
## Tests
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
python -m pytest src/tests/ -q
|
|
161
|
+
python -m pytest src/tests/test_v2_3_0_acceptance.py -q
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Documentación
|
|
165
|
+
|
|
166
|
+
| Documento | Contenido |
|
|
167
|
+
|---|---|
|
|
168
|
+
| `STATUS.md` | Matriz honesta de capacidades actuales, planned y future |
|
|
169
|
+
| `CHANGELOG.md` | Cambios por versión |
|
|
170
|
+
| `VIEW_SCHEMA.md` | Contrato VIEW |
|
|
171
|
+
| `EQUIVALENCE.md` | Niveles byte/AST/semantic/content |
|
|
172
|
+
| `BENCHMARK.md` | Evidencia y comandos reproducibles |
|
|
173
|
+
| `PACKAGING.md` | Reglas de paquete limpio |
|
|
174
|
+
| `ERRORS.md` | Taxonomía de errores v2 |
|
|
175
|
+
| `INFORME_DE_ENTREGA_v2.4.0.md` | Informe de entrega alineado |
|
|
176
|
+
|
|
177
|
+
## Licencia
|
|
178
|
+
|
|
179
|
+
MIT. Ver `LICENSE`.
|
|
180
|
+
|
|
181
|
+
## Autoría
|
|
182
|
+
|
|
183
|
+
Fidel Ernesto Lozada A. — `SKILL.md` v1.2.0-enterprise-candidate.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
codec_cortex-0.3.2.dist-info/licenses/LICENSE,sha256=XH2MkxKGvJ_LcevUWgv7_OSxq37wpijTP-FogFipXCU,1080
|
|
2
|
+
cortex/__init__.py,sha256=1Bs8--g5g1S2qeoIvX6uClpbBQWFAMaCQtdQw-dwPK4,899
|
|
3
|
+
cortex/__main__.py,sha256=xUyHJQ7WGSMVwVG4SwzLyHz29cfLJNBzbPgY_x1QO8s,140
|
|
4
|
+
cortex/_version.py,sha256=7Bzncojp21iM-dWXdN6Fqc8CpgZtvRE0o2j65xrTsR8,528
|
|
5
|
+
cortex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
cortex/cli/__init__.py,sha256=tvd7DQfNaSTI3DZ3h6crL-R-KIZIEQ11bmzmMvI66nU,93
|
|
7
|
+
cortex/cli/main.py,sha256=qBuSsVoNgNNYewM_09_T8q9AOJQ0Q7gr8uKhafjU-0Q,28799
|
|
8
|
+
cortex/cli/commands/__init__.py,sha256=SEEf4ZLEoWUWWyfTHJAX5Xa4ioenYNDnqZpU5xaogxw,5689
|
|
9
|
+
cortex/cli/commands/add.py,sha256=UC4Lg_GAupSOPNHNAhsRnCOjSl2B-B6iu95hWfP_Ng8,3118
|
|
10
|
+
cortex/cli/commands/compile.py,sha256=PeiE3F0_kbA-ibC-f2evCAaaNB288eVKMeoM6tWrvs8,1076
|
|
11
|
+
cortex/cli/commands/delete.py,sha256=0zeGt2Ny8ar_ggV3nbMNcJSpU_7iM8QorCDLnYCQd7M,1286
|
|
12
|
+
cortex/cli/commands/diagram.py,sha256=B7gacxogQph9UTgiC3CY1PRJEAnFoQialeoFsNToj_w,4469
|
|
13
|
+
cortex/cli/commands/diff.py,sha256=Wuc6ItkoMTlbfRbRD2n9pJq3uA5JlewDXK7WDS1Xruc,5795
|
|
14
|
+
cortex/cli/commands/doctor.py,sha256=k6biTi5DNwROnulrxhGj3XRWflQLh4V_49xGPn8ZZ90,2833
|
|
15
|
+
cortex/cli/commands/format.py,sha256=ioxiFCZn9O4oifwrzXckBODA-V2zafPfhKa1C8I0w5E,783
|
|
16
|
+
cortex/cli/commands/get.py,sha256=hpHKZPo5y1Gk0NTwfoqzttFt7PNa0edQTJ9qMNY6z1E,1425
|
|
17
|
+
cortex/cli/commands/glossary.py,sha256=cPRwl278gWbveceBcs0DziIFTZK2EwolYzwBB39hXWY,3088
|
|
18
|
+
cortex/cli/commands/list.py,sha256=LmKgvcZBGGiGQ34tfp-GaVhvwHetNHMNRWUaaKZ58mo,1345
|
|
19
|
+
cortex/cli/commands/micro.py,sha256=tRJ0hM0-RUl5ecOjSbGgJrLiWmOWfFYapfbffIJpxk4,2511
|
|
20
|
+
cortex/cli/commands/move.py,sha256=LWB0WT2CF-Lq8C_O76dM9SlQcAsRdiJfo4YNIo0Nn6M,1280
|
|
21
|
+
cortex/cli/commands/new.py,sha256=5xNFj2DyKYNhSLk1fW_AkeZlNq1rovwZZiy4gmIwxac,2614
|
|
22
|
+
cortex/cli/commands/recover.py,sha256=r2aZ6zBIOjdz3bcrEDftXQb-vIw6-WyXCKDq0d15UV4,3716
|
|
23
|
+
cortex/cli/commands/render.py,sha256=OcNIh36Sf0Mau9VoE1cU_7cW9X5HCwve8GCELFxNpcg,3157
|
|
24
|
+
cortex/cli/commands/update.py,sha256=hMia_xx9SgcslvHjM5RQhWVRYnNzP-Cn14lKJK0upns,2423
|
|
25
|
+
cortex/cli/commands/v2_canonicalize.py,sha256=buiFvEB5YrQp3ychLIC4qSdNXt0B-MRXbjSAE6r9hAU,5842
|
|
26
|
+
cortex/cli/commands/v2_compare.py,sha256=BsOagPsppUZWWqd0AlcBQBzy07j-JLDqyHeINv3k1UI,2623
|
|
27
|
+
cortex/cli/commands/v2_convert.py,sha256=Rm92rM5pnU2LIBENOtL3o6VfAovQfqgi33pOInbE6go,7856
|
|
28
|
+
cortex/cli/commands/v2_explain_loss.py,sha256=kiVlL_leO9GZk9u4_vORHHxyy-d_Hdmk5FilAEKt0ic,3521
|
|
29
|
+
cortex/cli/commands/v2_inspect.py,sha256=CI7W5RC8pv837NQhD4uMPoi0Exk6A2MlfUhiiVpn514,4281
|
|
30
|
+
cortex/cli/commands/v2_roundtrip.py,sha256=T6K_fZKylujuM2Lvb2KWCyA43y-LyrkOiwBqf5mCWcQ,4086
|
|
31
|
+
cortex/cli/commands/v2_roundtrip_bidir.py,sha256=EFPQ9lh8xy_-3cSZ75IaDFJjn18juhCrka21jm0mPWg,5051
|
|
32
|
+
cortex/cli/commands/v2_verify_view.py,sha256=PMaYt4iPumOkhCWyKceJ9I6mp07wQp-Ov43V-g5LFMI,2098
|
|
33
|
+
cortex/cli/commands/verify.py,sha256=6szMscLYBgWlmDFl4IsV-RA1C-yK8x0HwJwpOL5QwaA,4250
|
|
34
|
+
cortex/core/__init__.py,sha256=iy6qwId5H9UgPLg1UdaqxkxCR-WxKoUjplNqFHU2KWM,2760
|
|
35
|
+
cortex/core/ast.py,sha256=1m_vXO3C-gx_uOmLinmZH_W6hSb5bFZiylzJGjJCOVs,9523
|
|
36
|
+
cortex/core/compare.py,sha256=eYbO5CMP9Uz1QiTcktONO_TuggeDDv-NkBtAuFHzYn0,7221
|
|
37
|
+
cortex/core/document_kind.py,sha256=pDe9k5zReudIZxOgg9odkSAvzcbfPkMjvXioXW20rE8,22618
|
|
38
|
+
cortex/core/errors.py,sha256=UAdkxPPcyhbS5e5VkTsPNBMbJBLw_FwGF5mG1iyxIN8,13191
|
|
39
|
+
cortex/core/lexer.py,sha256=EfoQGzByljkxa7xYo9N7HM8KQuNQsCW8KIxL7Y9yFE0,8145
|
|
40
|
+
cortex/core/parser.py,sha256=SbMAqua8dC-7s61TqlUFne_qvviL3Tgrhk7tNFgNpds,23866
|
|
41
|
+
cortex/core/validator.py,sha256=6tusJCqKBR66cSc36WTFea2mkRBmgbAt-ynHsK3EtTY,10167
|
|
42
|
+
cortex/core/writer.py,sha256=7DFQa0wauAl3B-5zCMWJ675io3Ke1kPyKqDTprJUsNY,9207
|
|
43
|
+
cortex/crud/__init__.py,sha256=jze-uKxhzZ7G7fdn4SjN79zWiJTh69APgEvvirTAv-8,830
|
|
44
|
+
cortex/crud/mutations.py,sha256=bIToD7eDnvaUlFj_CUC2d-radLwO1pWAzKCAKA39QDU,11240
|
|
45
|
+
cortex/crud/selectors.py,sha256=3LFv4FFy1YeMZ8lY1PYPIxK9aPUedx6VTJlXy94PSu8,2731
|
|
46
|
+
cortex/crud/transactions.py,sha256=j_a43VmRWEYq9VC-HeJwrQDvVCCDviwhEDEZcfjWLVQ,6258
|
|
47
|
+
cortex/glossary/__init__.py,sha256=lz1wLu0jTapR-xiLzAE9LB9P8tkr620WdwIHnV2hF4I,876
|
|
48
|
+
cortex/glossary/contracts.py,sha256=Uh6t1e1Mxia-ZEo6JT5WDN_Y_EsPhcV5ZrbonqJQ6no,1152
|
|
49
|
+
cortex/glossary/minimal.py,sha256=2DcTp_5UgAamUb34Z7XMCv5loCJyU23ZaH8FgZmQET4,5604
|
|
50
|
+
cortex/glossary/model.py,sha256=lW_WmtGG1329NU2jha1QoqepvyNo5qF9Mzn5ZV4199Q,2374
|
|
51
|
+
cortex/glossary/resolver.py,sha256=WHInARfNbNEpnRcSkDKZFW9rWNk8qWkuPFr7aO65lto,2958
|
|
52
|
+
cortex/hcortex/__init__.py,sha256=ns1pnrYqBQ-dLjxU0uIXaVI_fyelmqYZrVEqGDGA-m4,1327
|
|
53
|
+
cortex/hcortex/edit_parser.py,sha256=uyXMYoym8mZxewlu6SEP5jRYAStdZEKWtmrc3ucd7H8,15902
|
|
54
|
+
cortex/hcortex/edit_renderer.py,sha256=AkLuHQYC4AeBopIwF3xN6riBkjcV49sMG8wVKtFXkok,5417
|
|
55
|
+
cortex/hcortex/markdown_model.py,sha256=JLHyN07a5ZOmLsxcSOZagsCJpWsURjRpW2JZdXXZyFc,2759
|
|
56
|
+
cortex/hcortex/profiles.py,sha256=e4ir9O99UThtPThffIP_h68EnE5F0V_iuOtTBfVn4uE,5777
|
|
57
|
+
cortex/hcortex/read_renderer.py,sha256=6usu_ZTp4gS74g9vgNUSCprFo54Vqc1jCndGDiqzmT8,11317
|
|
58
|
+
cortex/hcortex/recovery.py,sha256=huT_EOteDFi_3zOfRglufC3xN-gEHoO2uDDkui9kDPo,29832
|
|
59
|
+
cortex/templates/__init__.py,sha256=D49Z4J-Nvl_o_tPM_z_KvW2m9fRIpHL4jYeSoCBmioo,292
|
|
60
|
+
cortex/templates/brain.py,sha256=Ngs5Aj8Rf3c2LAckJxrN4K9oKGpmaZ-Ou_zZQhkA7jY,3531
|
|
61
|
+
cortex/templates/minimal_glossary.py,sha256=ZeP4GH929_bqoKBVlluAF9Wgv9Ajtz-8HcIETkjsXcY,1564
|
|
62
|
+
cortex/templates/package.py,sha256=g07bX_w1ZLDt7CtvLsYUo6e3w32nYQcCV7QQICmYivE,2861
|
|
63
|
+
cortex/templates/skill.py,sha256=A7w0PK1Bwl2g3opFDnbREQVMdWDRm_LwoipQygXwjuQ,2790
|
|
64
|
+
cortex/v2/__init__.py,sha256=X_F5k1qCigl1tNO7z1BwVD_oCy-hms8A9i4CyIBZDMw,1215
|
|
65
|
+
cortex/v2/diagnostics.py,sha256=K_dFInoAJT3Q27Gorn5oTWlnwMoMceC8SB0TFl-PWAw,2044
|
|
66
|
+
cortex/v2/encoder.py,sha256=3bWh5WI5R4Fxfx0kQpzZ9WoOoNwdLJ-FSd4pKqsQZ9w,38344
|
|
67
|
+
cortex/v2/equivalence.py,sha256=Xjb6LgQvH56Qx-h2TbBI8HILZc05VNNvrtZg3Opnhhk,11948
|
|
68
|
+
cortex/v2/hcortex_parser.py,sha256=aLgjmwuCFLe-nmnjAr1TF1joFOcVRMZixvxUioB_O5E,20336
|
|
69
|
+
cortex/v2/hcortex_renderer.py,sha256=q1Rf1U3veL5ruHkQPz3BVtuNdvVZ80plsPv1mQ4m4s4,16784
|
|
70
|
+
cortex/v2/ir.py,sha256=bCy6a3mbBs2ixwQixGjuEc1i0x0vGLWawTGAC2Pp0jc,8330
|
|
71
|
+
cortex/v2/parser.py,sha256=wQkq7NnBQQDIzgkWxMpn-0GKxEppOPwidDnQOp4VMnY,20075
|
|
72
|
+
cortex/v2/view.py,sha256=Rm9qcEcNDeidWy3Y5CAsSv4dvMrOqvb1Vl3k7WhTetA,15197
|
|
73
|
+
cortex/v2/view_renderer.py,sha256=LQ5IP9b9giYofTL42F4cp6v3uAGvVZWYm0kYeGFw3nA,18553
|
|
74
|
+
cortex/v2/writer.py,sha256=TiEbTfFPwtpFa-jNVbrShviyVvCNAu61baeCCAFnMDM,10913
|
|
75
|
+
codec_cortex-0.3.2.dist-info/METADATA,sha256=rQLFkQ1SE1UxcOEPVbo-3GPx9w5DNdmqSDHwoK9zuI4,8137
|
|
76
|
+
codec_cortex-0.3.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
77
|
+
codec_cortex-0.3.2.dist-info/entry_points.txt,sha256=_Fl_fZk_6jJeX4QXcG1dT4WakyDZVu_G320FkcyQUOI,48
|
|
78
|
+
codec_cortex-0.3.2.dist-info/scm_file_list.json,sha256=Zm6OWQv8RtPgN8c5w4xfa8pzJSYNvNzH976T_BmOpRQ,4411
|
|
79
|
+
codec_cortex-0.3.2.dist-info/scm_version.json,sha256=a54wpletfE6bmUiRUMXsGhr1UwZJYX1Wc2KqMusTe34,160
|
|
80
|
+
codec_cortex-0.3.2.dist-info/top_level.txt,sha256=79LAeTJJ_pMIBy3mkF7uNaN0mdBRt5tGrnne5N_iAio,7
|
|
81
|
+
codec_cortex-0.3.2.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fidel Ernesto Lozada A.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
"INFORME_DE_ENTREGA_v2.4.0.md",
|
|
4
|
+
"README.md",
|
|
5
|
+
"audit.cortex.md",
|
|
6
|
+
"LICENSE",
|
|
7
|
+
"VIEW_SCHEMA.md",
|
|
8
|
+
"pyproject.toml",
|
|
9
|
+
"EQUIVALENCE.md",
|
|
10
|
+
"CHANGELOG.md",
|
|
11
|
+
"ERRORS.md",
|
|
12
|
+
"PACKAGING.md",
|
|
13
|
+
"INFORME_DE_ENTREGA_v0.3.2.md",
|
|
14
|
+
"BENCHMARK.md",
|
|
15
|
+
"INFORME_DE_ENTREGA_v2.3.1.md",
|
|
16
|
+
"STATUS.md",
|
|
17
|
+
"src/cortex/py.typed",
|
|
18
|
+
"src/cortex/__init__.py",
|
|
19
|
+
"src/cortex/__main__.py",
|
|
20
|
+
"src/cortex/core/validator.py",
|
|
21
|
+
"src/cortex/core/__init__.py",
|
|
22
|
+
"src/cortex/core/document_kind.py",
|
|
23
|
+
"src/cortex/core/parser.py",
|
|
24
|
+
"src/cortex/core/writer.py",
|
|
25
|
+
"src/cortex/core/ast.py",
|
|
26
|
+
"src/cortex/core/lexer.py",
|
|
27
|
+
"src/cortex/core/compare.py",
|
|
28
|
+
"src/cortex/core/errors.py",
|
|
29
|
+
"src/cortex/hcortex/recovery.py",
|
|
30
|
+
"src/cortex/hcortex/markdown_model.py",
|
|
31
|
+
"src/cortex/hcortex/edit_parser.py",
|
|
32
|
+
"src/cortex/hcortex/__init__.py",
|
|
33
|
+
"src/cortex/hcortex/edit_renderer.py",
|
|
34
|
+
"src/cortex/hcortex/profiles.py",
|
|
35
|
+
"src/cortex/hcortex/read_renderer.py",
|
|
36
|
+
"src/cortex/crud/transactions.py",
|
|
37
|
+
"src/cortex/crud/selectors.py",
|
|
38
|
+
"src/cortex/crud/__init__.py",
|
|
39
|
+
"src/cortex/crud/mutations.py",
|
|
40
|
+
"src/cortex/glossary/minimal.py",
|
|
41
|
+
"src/cortex/glossary/model.py",
|
|
42
|
+
"src/cortex/glossary/resolver.py",
|
|
43
|
+
"src/cortex/glossary/__init__.py",
|
|
44
|
+
"src/cortex/glossary/contracts.py",
|
|
45
|
+
"src/cortex/v2/__init__.py",
|
|
46
|
+
"src/cortex/v2/hcortex_renderer.py",
|
|
47
|
+
"src/cortex/v2/view_renderer.py",
|
|
48
|
+
"src/cortex/v2/parser.py",
|
|
49
|
+
"src/cortex/v2/diagnostics.py",
|
|
50
|
+
"src/cortex/v2/view.py",
|
|
51
|
+
"src/cortex/v2/writer.py",
|
|
52
|
+
"src/cortex/v2/encoder.py",
|
|
53
|
+
"src/cortex/v2/hcortex_parser.py",
|
|
54
|
+
"src/cortex/v2/ir.py",
|
|
55
|
+
"src/cortex/v2/equivalence.py",
|
|
56
|
+
"src/cortex/templates/package.py",
|
|
57
|
+
"src/cortex/templates/__init__.py",
|
|
58
|
+
"src/cortex/templates/skill.py",
|
|
59
|
+
"src/cortex/templates/brain.py",
|
|
60
|
+
"src/cortex/templates/minimal_glossary.py",
|
|
61
|
+
"src/cortex/cli/__init__.py",
|
|
62
|
+
"src/cortex/cli/main.py",
|
|
63
|
+
"src/cortex/cli/commands/verify.py",
|
|
64
|
+
"src/cortex/cli/commands/__init__.py",
|
|
65
|
+
"src/cortex/cli/commands/v2_verify_view.py",
|
|
66
|
+
"src/cortex/cli/commands/v2_explain_loss.py",
|
|
67
|
+
"src/cortex/cli/commands/get.py",
|
|
68
|
+
"src/cortex/cli/commands/v2_inspect.py",
|
|
69
|
+
"src/cortex/cli/commands/recover.py",
|
|
70
|
+
"src/cortex/cli/commands/diagram.py",
|
|
71
|
+
"src/cortex/cli/commands/v2_convert.py",
|
|
72
|
+
"src/cortex/cli/commands/format.py",
|
|
73
|
+
"src/cortex/cli/commands/add.py",
|
|
74
|
+
"src/cortex/cli/commands/v2_canonicalize.py",
|
|
75
|
+
"src/cortex/cli/commands/move.py",
|
|
76
|
+
"src/cortex/cli/commands/v2_roundtrip_bidir.py",
|
|
77
|
+
"src/cortex/cli/commands/v2_compare.py",
|
|
78
|
+
"src/cortex/cli/commands/render.py",
|
|
79
|
+
"src/cortex/cli/commands/micro.py",
|
|
80
|
+
"src/cortex/cli/commands/list.py",
|
|
81
|
+
"src/cortex/cli/commands/new.py",
|
|
82
|
+
"src/cortex/cli/commands/glossary.py",
|
|
83
|
+
"src/cortex/cli/commands/update.py",
|
|
84
|
+
"src/cortex/cli/commands/doctor.py",
|
|
85
|
+
"src/cortex/cli/commands/compile.py",
|
|
86
|
+
"src/cortex/cli/commands/delete.py",
|
|
87
|
+
"src/cortex/cli/commands/diff.py",
|
|
88
|
+
"src/cortex/cli/commands/v2_roundtrip.py",
|
|
89
|
+
"src/tests/test_fixtures.py",
|
|
90
|
+
"src/tests/test_v1_1_6_fixes.py",
|
|
91
|
+
"src/tests/test_v2_3_0_acceptance.py",
|
|
92
|
+
"src/tests/__init__.py",
|
|
93
|
+
"src/tests/test_audit_gates.py",
|
|
94
|
+
"src/tests/test_v1_1_2_fixes.py",
|
|
95
|
+
"src/tests/test_v1_1_7_fixes.py",
|
|
96
|
+
"src/tests/test_acceptance.py",
|
|
97
|
+
"src/tests/test_v2_2_3_fixes.py",
|
|
98
|
+
"src/tests/test_v2_roundtrip.py",
|
|
99
|
+
"src/tests/test_v1_1_5_fixes.py",
|
|
100
|
+
"src/tests/test_crud.py",
|
|
101
|
+
"src/tests/test_v1_1_3_fixes.py",
|
|
102
|
+
"src/tests/conftest.py",
|
|
103
|
+
"src/tests/test_v1_1_4_fixes.py",
|
|
104
|
+
"src/tests/test_v2_2_2_fixes.py",
|
|
105
|
+
"src/tests/test_v1_1_8_fixes.py",
|
|
106
|
+
"src/tests/test_v2_1_fixes.py",
|
|
107
|
+
"src/tests/test_errors.py",
|
|
108
|
+
"src/tests/test_v2_2_1_fixes.py",
|
|
109
|
+
"src/tests/test_v1_1_9_fixes.py",
|
|
110
|
+
"src/tests/test_v2_2_view.py",
|
|
111
|
+
"src/tests/test_reaudit_gates.py",
|
|
112
|
+
"src/tests/fixtures/SKILL_v2.cortex.md",
|
|
113
|
+
"src/tests/fixtures/brain.cortex",
|
|
114
|
+
"src/tests/fixtures/package.cortex",
|
|
115
|
+
"src/tests/fixtures/SKILL_v2.hcortex.md",
|
|
116
|
+
"src/tests/fixtures/skill.cortex",
|
|
117
|
+
"src/tests/invalid/unknown_sigil.cortex",
|
|
118
|
+
"src/tests/invalid/unbalanced_braces.cortex",
|
|
119
|
+
"src/tests/invalid/glossary_not_first.cortex",
|
|
120
|
+
"src/tests/invalid/missing_glossary.cortex",
|
|
121
|
+
"skill/hcortex/SKILL.md",
|
|
122
|
+
"skill/cortex/SKILL.md"
|
|
123
|
+
]
|
|
124
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cortex
|
cortex/__init__.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""CODEC-CORTEX CLI — modular deterministic processor for .cortex files.
|
|
2
|
+
|
|
3
|
+
This package implements the CODEC-CORTEX specification: a structural,
|
|
4
|
+
LLM-independent CLI that parses, renders, compiles, verifies and mutates
|
|
5
|
+
.cortex files as canonical cognitive memory artefacts.
|
|
6
|
+
|
|
7
|
+
The package is organized in layers:
|
|
8
|
+
|
|
9
|
+
- ``core`` : lexer, parser, AST, writer, validator, compare, errors
|
|
10
|
+
- ``glossary`` : $0 local glossary model, resolver, minimal, contracts
|
|
11
|
+
- ``hcortex`` : HCORTEX-READ and HCORTEX-EDIT renderers and parsers
|
|
12
|
+
- ``crud`` : selectors, mutations, atomic transactions
|
|
13
|
+
- ``templates`` : brain, skill, package, minimal glossary factories
|
|
14
|
+
- ``cli`` : argparse-based command-line entry point
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
from ._version import __version__
|
|
19
|
+
except ImportError:
|
|
20
|
+
# Fallback for editable/dev installs without _version.py
|
|
21
|
+
__version__ = "0.0.0.dev0"
|
|
22
|
+
__all__ = ["__version__"]
|
cortex/__main__.py
ADDED
cortex/_version.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '0.3.2'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 3, 2)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = 'g5c75b3705'
|
cortex/cli/__init__.py
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"""Shared helpers for CLI command modules."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from typing import Any, Dict, Optional
|
|
8
|
+
|
|
9
|
+
from ...core.ast import CortexDocument
|
|
10
|
+
from ...core.parser import parse_cortex
|
|
11
|
+
from ...core.errors import CortexError
|
|
12
|
+
from ...core.validator import validate
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def load_doc(path: str) -> CortexDocument:
|
|
16
|
+
"""Read a .cortex file and parse it into a :class:`CortexDocument`."""
|
|
17
|
+
|
|
18
|
+
if not os.path.exists(path):
|
|
19
|
+
raise CortexError("E013_NOT_FOUND", f"file not found: {path}")
|
|
20
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
21
|
+
text = f.read()
|
|
22
|
+
return parse_cortex(text, path=path)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def emit(payload: Dict[str, Any], *, json_mode: bool = False) -> None:
|
|
26
|
+
"""Print a payload as JSON or as plain text.
|
|
27
|
+
|
|
28
|
+
``payload`` must contain ``text`` (str) for plain mode and any
|
|
29
|
+
JSON-serialisable fields for JSON mode.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
if json_mode:
|
|
33
|
+
print(json.dumps(payload, indent=2, ensure_ascii=False, default=str))
|
|
34
|
+
else:
|
|
35
|
+
text = payload.get("text", "")
|
|
36
|
+
if text:
|
|
37
|
+
print(text)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def emit_json(payload: Any) -> None:
|
|
41
|
+
print(json.dumps(payload, indent=2, ensure_ascii=False, default=str))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def post_mutation_gate(
|
|
45
|
+
doc: CortexDocument,
|
|
46
|
+
args,
|
|
47
|
+
) -> Optional[Dict[str, Any]]:
|
|
48
|
+
"""Validate ``doc`` after a mutation and return an error payload if blocked.
|
|
49
|
+
|
|
50
|
+
v1.1.2: centralised post-mutation validation used by ``add``,
|
|
51
|
+
``update``, ``delete`` and ``move``.
|
|
52
|
+
|
|
53
|
+
v1.1.3 P0-2/P0-3: errors tagged ``bypassable=False`` (secrets in clear
|
|
54
|
+
text, critical sigils incomplete) CANNOT be overridden by ``--force``.
|
|
55
|
+
Only an explicit ``--unsafe-allow-secret-forensics`` flag (for secrets)
|
|
56
|
+
can bypass the secret check, and there is NO bypass for critical-sigil
|
|
57
|
+
incompleteness.
|
|
58
|
+
|
|
59
|
+
Behaviour:
|
|
60
|
+
- If ``--no-validate-write`` is set, return None (skip gate) — but
|
|
61
|
+
only if there are no ``bypassable=False`` errors.
|
|
62
|
+
- Run ``validate(doc, strict=args.strict_write)``.
|
|
63
|
+
- If there are error-severity diagnostics:
|
|
64
|
+
* ``bypassable=False`` errors ALWAYS block (unless the dedicated
|
|
65
|
+
``--unsafe-allow-secret-forensics`` flag is set, and only for
|
|
66
|
+
secret-related codes).
|
|
67
|
+
* Other errors block unless ``--force`` is set.
|
|
68
|
+
- Otherwise return None (mutation can proceed to atomic_write).
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
if getattr(args, "no_validate_write", False):
|
|
72
|
+
# Even with --no-validate-write, bypassable=False errors block
|
|
73
|
+
strict_write = getattr(args, "strict_write", False)
|
|
74
|
+
diagnostics = validate(doc, strict=strict_write)
|
|
75
|
+
non_bypassable = [
|
|
76
|
+
d for d in diagnostics
|
|
77
|
+
if d.get("severity") == "error" and d.get("bypassable") is False
|
|
78
|
+
]
|
|
79
|
+
if non_bypassable:
|
|
80
|
+
# Filter: allow --unsafe-allow-secret-forensics for secret codes
|
|
81
|
+
unsafe = getattr(args, "unsafe_allow_secret_forensics", False)
|
|
82
|
+
if unsafe:
|
|
83
|
+
non_bypassable = [
|
|
84
|
+
d for d in non_bypassable
|
|
85
|
+
if d.get("code") != "E031_SECRET_NOT_BYPASSABLE"
|
|
86
|
+
]
|
|
87
|
+
if non_bypassable:
|
|
88
|
+
return {
|
|
89
|
+
"ok": False,
|
|
90
|
+
"error": {
|
|
91
|
+
"code": "E015_ATOMIC_WRITE_FAILED",
|
|
92
|
+
"message": (
|
|
93
|
+
f"mutation would produce {len(non_bypassable)} "
|
|
94
|
+
"non-bypassable error(s); --no-validate-write cannot "
|
|
95
|
+
"override security/governance rules"
|
|
96
|
+
),
|
|
97
|
+
},
|
|
98
|
+
"diagnostics": non_bypassable,
|
|
99
|
+
}
|
|
100
|
+
return None
|
|
101
|
+
|
|
102
|
+
strict_write = getattr(args, "strict_write", False)
|
|
103
|
+
diagnostics = validate(doc, strict=strict_write)
|
|
104
|
+
errors = [d for d in diagnostics if d.get("severity") == "error"]
|
|
105
|
+
if not errors:
|
|
106
|
+
return None
|
|
107
|
+
|
|
108
|
+
# Split bypassable vs non-bypassable
|
|
109
|
+
non_bypassable = [d for d in errors if d.get("bypassable") is False]
|
|
110
|
+
bypassable = [d for d in errors if d.get("bypassable") is not False]
|
|
111
|
+
|
|
112
|
+
# Non-bypassable errors always block (except secrets with --unsafe flag)
|
|
113
|
+
if non_bypassable:
|
|
114
|
+
unsafe = getattr(args, "unsafe_allow_secret_forensics", False)
|
|
115
|
+
if unsafe:
|
|
116
|
+
# Allow bypassing secret errors ONLY with the dedicated flag
|
|
117
|
+
non_bypassable = [
|
|
118
|
+
d for d in non_bypassable
|
|
119
|
+
if d.get("code") != "E031_SECRET_NOT_BYPASSABLE"
|
|
120
|
+
]
|
|
121
|
+
if non_bypassable:
|
|
122
|
+
return {
|
|
123
|
+
"ok": False,
|
|
124
|
+
"error": {
|
|
125
|
+
"code": "E015_ATOMIC_WRITE_FAILED",
|
|
126
|
+
"message": (
|
|
127
|
+
f"mutation would produce {len(non_bypassable)} "
|
|
128
|
+
"non-bypassable error(s); --force cannot override "
|
|
129
|
+
"security/governance rules (use "
|
|
130
|
+
"--unsafe-allow-secret-forensics for forensic "
|
|
131
|
+
"recovery of secrets, if absolutely necessary)"
|
|
132
|
+
),
|
|
133
|
+
},
|
|
134
|
+
"diagnostics": non_bypassable,
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
# Bypassable errors: block unless --force
|
|
138
|
+
if bypassable and not getattr(args, "force", False):
|
|
139
|
+
return {
|
|
140
|
+
"ok": False,
|
|
141
|
+
"error": {
|
|
142
|
+
"code": "E015_ATOMIC_WRITE_FAILED",
|
|
143
|
+
"message": (
|
|
144
|
+
f"mutation would produce {len(bypassable)} validation error(s); "
|
|
145
|
+
"use --force to persist anyway, or --no-validate-write to skip"
|
|
146
|
+
),
|
|
147
|
+
},
|
|
148
|
+
"diagnostics": bypassable,
|
|
149
|
+
}
|
|
150
|
+
return None
|