asilo-core 0.1.0a1__tar.gz

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.
Files changed (89) hide show
  1. asilo_core-0.1.0a1/.gitignore +24 -0
  2. asilo_core-0.1.0a1/.milpa-manifest.json +11 -0
  3. asilo_core-0.1.0a1/AGENTS.md +56 -0
  4. asilo_core-0.1.0a1/CHANGELOG.md +41 -0
  5. asilo_core-0.1.0a1/LICENSE +201 -0
  6. asilo_core-0.1.0a1/NOTICE +26 -0
  7. asilo_core-0.1.0a1/PKG-INFO +168 -0
  8. asilo_core-0.1.0a1/README.md +134 -0
  9. asilo_core-0.1.0a1/SOURCE.md +33 -0
  10. asilo_core-0.1.0a1/ci/borrador/README.md +96 -0
  11. asilo_core-0.1.0a1/ci/borrador/woodpecker-publicar.yml +116 -0
  12. asilo_core-0.1.0a1/docs/01-manifiesto/01-el-problema.md +44 -0
  13. asilo_core-0.1.0a1/docs/01-manifiesto/02-la-solucion.md +58 -0
  14. asilo_core-0.1.0a1/docs/01-manifiesto/03-que-no-hace.md +62 -0
  15. asilo_core-0.1.0a1/docs/01-manifiesto/README.md +30 -0
  16. asilo_core-0.1.0a1/docs/02-diagramas/D01-contexto.md +75 -0
  17. asilo_core-0.1.0a1/docs/02-diagramas/D01-contexto.mmd +32 -0
  18. asilo_core-0.1.0a1/docs/02-diagramas/D02-capas.md +57 -0
  19. asilo_core-0.1.0a1/docs/02-diagramas/D02-capas.mmd +8 -0
  20. asilo_core-0.1.0a1/docs/02-diagramas/D03-secuencia-enforce-schema.md +68 -0
  21. asilo_core-0.1.0a1/docs/02-diagramas/D03-secuencia-enforce-schema.mmd +29 -0
  22. asilo_core-0.1.0a1/docs/02-diagramas/D04-escalada-humana.md +67 -0
  23. asilo_core-0.1.0a1/docs/02-diagramas/D04-escalada-humana.mmd +20 -0
  24. asilo_core-0.1.0a1/docs/02-diagramas/D05-mapa-capacidades.md +88 -0
  25. asilo_core-0.1.0a1/docs/02-diagramas/D05-mapa-capacidades.mmd +21 -0
  26. asilo_core-0.1.0a1/docs/02-diagramas/D06-donde-encaja-asilo.md +89 -0
  27. asilo_core-0.1.0a1/docs/02-diagramas/D06-donde-encaja-asilo.mmd +27 -0
  28. asilo_core-0.1.0a1/docs/02-diagramas/README.md +44 -0
  29. asilo_core-0.1.0a1/docs/03-operacion/01-instalacion.md +58 -0
  30. asilo_core-0.1.0a1/docs/03-operacion/02-comandos.md +74 -0
  31. asilo_core-0.1.0a1/docs/03-operacion/03-que-no-esta-implementado.md +59 -0
  32. asilo_core-0.1.0a1/docs/03-operacion/README.md +27 -0
  33. asilo_core-0.1.0a1/docs/04-contratos/01-api-publica.md +53 -0
  34. asilo_core-0.1.0a1/docs/04-contratos/02-axiomas.md +47 -0
  35. asilo_core-0.1.0a1/docs/04-contratos/03-contrato-de-errores.md +55 -0
  36. asilo_core-0.1.0a1/docs/04-contratos/04-decisiones.md +50 -0
  37. asilo_core-0.1.0a1/docs/04-contratos/05-fuentes-de-verdad.md +51 -0
  38. asilo_core-0.1.0a1/docs/04-contratos/06-extensibilidad.md +73 -0
  39. asilo_core-0.1.0a1/docs/04-contratos/README.md +42 -0
  40. asilo_core-0.1.0a1/docs/INDEX.md +100 -0
  41. asilo_core-0.1.0a1/docs/PLAN_IMPLEMENTACION.md +288 -0
  42. asilo_core-0.1.0a1/docs/QUICKSTART.md +78 -0
  43. asilo_core-0.1.0a1/docs/api/README.md +46 -0
  44. asilo_core-0.1.0a1/docs/architecture/DIAGRAMS.md +34 -0
  45. asilo_core-0.1.0a1/docs/asilo/arquitectura/ADR-001-asilo.md +55 -0
  46. asilo_core-0.1.0a1/docs/asilo/arquitectura/axiomas.md +33 -0
  47. asilo_core-0.1.0a1/docs/asilo/contratos/error-contract.json +31 -0
  48. asilo_core-0.1.0a1/docs/asilo/seguridad/aduana-llm.md +45 -0
  49. asilo_core-0.1.0a1/docs/asilo/seguridad/pii-policy.md +43 -0
  50. asilo_core-0.1.0a1/docs/glosario.md +55 -0
  51. asilo_core-0.1.0a1/docs/referencias.md +188 -0
  52. asilo_core-0.1.0a1/examples/README.md +12 -0
  53. asilo_core-0.1.0a1/governance/README.md +52 -0
  54. asilo_core-0.1.0a1/governance/ai-trace-allowlist.txt +17 -0
  55. asilo_core-0.1.0a1/governance/decisions/ADR-001-perfil-library.md +32 -0
  56. asilo_core-0.1.0a1/governance/decisions/ADR-002-versionado-y-releases-codeberg.md +65 -0
  57. asilo_core-0.1.0a1/governance/decisions/ADR-003-frontera-metodologia-implementacion.md +33 -0
  58. asilo_core-0.1.0a1/governance/decisions/ADR-004-schema-sin-reejecucion.md +26 -0
  59. asilo_core-0.1.0a1/governance/decisions/ADR-005-herencia-canonica-no-fingida.md +23 -0
  60. asilo_core-0.1.0a1/mkdocs.yml +117 -0
  61. asilo_core-0.1.0a1/pyproject.toml +62 -0
  62. asilo_core-0.1.0a1/reports/2026-08-23-kasai-crew-readiness.md +34 -0
  63. asilo_core-0.1.0a1/reports/2026-08-24-schema-y-capacidades.md +36 -0
  64. asilo_core-0.1.0a1/reports/2026-09-22-mejoras-desde-horcon.md +156 -0
  65. asilo_core-0.1.0a1/reports/README.md +15 -0
  66. asilo_core-0.1.0a1/research/README.md +33 -0
  67. asilo_core-0.1.0a1/research/RESEARCH_PROMPT_ASILO_CORE.md +148 -0
  68. asilo_core-0.1.0a1/research/responses/.gitkeep +0 -0
  69. asilo_core-0.1.0a1/scripts/check_no_ai_traces.py +302 -0
  70. asilo_core-0.1.0a1/scripts/hooks/commit-msg +3 -0
  71. asilo_core-0.1.0a1/scripts/hooks/pre-commit +5 -0
  72. asilo_core-0.1.0a1/scripts/install-hooks.sh +11 -0
  73. asilo_core-0.1.0a1/src/asilo/__init__.py +31 -0
  74. asilo_core-0.1.0a1/src/asilo/cli/__init__.py +4 -0
  75. asilo_core-0.1.0a1/src/asilo/cli/__main__.py +72 -0
  76. asilo_core-0.1.0a1/src/asilo/decorators/__init__.py +15 -0
  77. asilo_core-0.1.0a1/src/asilo/decorators/guardrail.py +38 -0
  78. asilo_core-0.1.0a1/src/asilo/decorators/hitl.py +39 -0
  79. asilo_core-0.1.0a1/src/asilo/decorators/schema.py +63 -0
  80. asilo_core-0.1.0a1/src/asilo/errors.py +38 -0
  81. asilo_core-0.1.0a1/src/asilo/templates/.gitkeep +0 -0
  82. asilo_core-0.1.0a1/src/asilo/templates/__init__.py +7 -0
  83. asilo_core-0.1.0a1/tests/adversarial/README.md +18 -0
  84. asilo_core-0.1.0a1/tests/adversarial/test_ai_trace_check.py +139 -0
  85. asilo_core-0.1.0a1/tests/adversarial/test_fail_closed.py +27 -0
  86. asilo_core-0.1.0a1/tests/unit/test_api_publica.py +27 -0
  87. asilo_core-0.1.0a1/tests/unit/test_cli.py +21 -0
  88. asilo_core-0.1.0a1/tests/unit/test_schema.py +52 -0
  89. asilo_core-0.1.0a1/tmp/.gitkeep +0 -0
@@ -0,0 +1,24 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ venv/
5
+ dist/
6
+ build/
7
+ *.egg-info/
8
+ .pytest_cache/
9
+ .ruff_cache/
10
+ .coverage
11
+ htmlcov/
12
+ .env
13
+ .DS_Store
14
+ tmp/*
15
+ !tmp/.gitkeep
16
+
17
+ # Sitio de documentación ensamblado por `python -m horcon docs build .`
18
+ tmp/site-src/
19
+ tmp/site/
20
+
21
+ # Config local de herramientas de agente (nunca se versiona)
22
+ .claude/
23
+ .cursor/
24
+ .aider*
@@ -0,0 +1,11 @@
1
+ {
2
+ "id": "asilo-core",
3
+ "role": "library",
4
+ "profile": "library",
5
+ "level": 2,
6
+ "parent": "../",
7
+ "anchor": "José Ruiz",
8
+ "scope": "SDK de gobernanza ASILO: decoradores de seguridad, guardrails, Agente Cero y motor de plantillas",
9
+ "inherits": [],
10
+ "overrides": []
11
+ }
@@ -0,0 +1,56 @@
1
+ # Agente — asilo-core
2
+
3
+ > Contrato de arranque. Todo lo que no está aquí se **enlaza**, no se copia.
4
+ > Metodología: [`SOURCE.md`](SOURCE.md) · Mapa documental: [`docs/INDEX.md`](docs/INDEX.md)
5
+
6
+ ## Qué es este repo
7
+
8
+ Librería Python distribuible (perfil Milpa `library`). Implementación candidata de ASILO:
9
+ validación de esquema y errores están activos; política, HITL, auditoría y CLI de dominio siguen
10
+ diferidos. **No** define la metodología: proyecta contratos aceptados.
11
+
12
+ ## Axiomas
13
+
14
+ Una regla que el sistema no puede violar. Estado y verificación en
15
+ [`docs/asilo/arquitectura/axiomas.md`](docs/asilo/arquitectura/axiomas.md).
16
+
17
+ | ID | Axioma |
18
+ |----|--------|
19
+ | AX-01 | Ningún guardrail se desactiva por fallo propio (fail-closed por defecto) |
20
+ | AX-02 | Ninguna salida de modelo se usa sin validar contra un esquema |
21
+ | AX-03 | Ningún secreto se escribe en el repo, incluidos tests y fixtures |
22
+ | AX-04 | Toda acción bloqueada emite un evento de auditoría con `trace_id` |
23
+ | AX-05 | El núcleo no importa el CLI ni sus dependencias |
24
+
25
+ ## Reglas
26
+
27
+ 1. **src-layout es obligatorio.** El paquete vive en `src/asilo/`, nunca en la raíz. Los
28
+ tests corren contra el paquete instalado (`pip install -e .`), no contra archivos sueltos.
29
+ 2. **La API pública es contrato.** Lo no exportado en `src/asilo/__init__.py` es privado.
30
+ Exportar algo nuevo exige entrada en `CHANGELOG.md` en el mismo cambio.
31
+ 3. **Todo guardrail nuevo lleva test adversarial** en `tests/adversarial/`. Un control sin un
32
+ test que intente evadirlo no es un control.
33
+ 4. **Nunca desactivar un guardrail para hacer pasar un test.** Si bloquea algo legítimo, el
34
+ defecto está en el axioma: repórtalo, no lo evadas.
35
+ 5. **Sin dependencias pesadas en el núcleo.** `src/asilo/decorators/` no importa el CLI ni
36
+ Jinja2; la consola es un extra opcional.
37
+ 6. **No inventar axiomas.** El canon vive en el plano de planeación (ver `SOURCE.md`).
38
+
39
+ ## Alcance
40
+
41
+ | Puedes | No puedes |
42
+ |--------|-----------|
43
+ | Editar `src/`, `tests/`, `examples/`, `docs/` | Editar `.milpa-manifest.json` sin decisión en `governance/` |
44
+ | Agregar tests | Borrar tests existentes |
45
+ | Proponer axiomas nuevos en un reporte | Cambiar la semántica de un axioma publicado |
46
+ | Crear ADRs en `governance/decisions/` | Publicar a PyPI |
47
+
48
+ Los hallazgos que no son código van a `reports/` como `YYYY-MM-DD-tema.md`.
49
+
50
+ ## Done
51
+
52
+ - [ ] `pytest` pasa, incluida `tests/adversarial/`.
53
+ - [ ] `CHANGELOG.md` actualizado si cambió la API pública.
54
+ - [ ] `docs/asilo/contratos/` refleja el cambio si cambió un contrato.
55
+ - [ ] Todo doc nuevo enlazado desde `docs/INDEX.md`.
56
+ - [ ] `scripts/check_no_ai_traces.py` pasa (lo aplica el hook `pre-commit`).
@@ -0,0 +1,41 @@
1
+ # Changelog
2
+
3
+ Formato basado en [Keep a Changelog](https://keepachangelog.com/es-ES/1.1.0/).
4
+ Versionado según [Semantic Versioning](https://semver.org/lang/es/).
5
+
6
+ ## [0.1.0a1] — 2026-09-24
7
+
8
+ ### Añadido
9
+ - `[project.urls]` en `pyproject.toml` (Homepage, Documentation, Repository, Changelog, Issues),
10
+ apuntando al repositorio real en Codeberg; verificado con una build real de sdist.
11
+ - `docs/glosario.md`: vocabulario propio de esta implementación, en una línea por término.
12
+ - `docs/04-contratos/06-extensibilidad.md`: qué punto de extensión es real hoy (el modelo Pydantic
13
+ de `enforce_schema`), cuál está declarado en una firma sin funcionar (`axioms_file`,
14
+ `thresholds_file`) y cuál sólo está propuesto (puerto de identidad para `hitl`).
15
+ - `enforce_schema` valida salidas sync/async con Pydantic, ejecuta una sola vez y
16
+ redacta el valor inválido.
17
+ - `asilo status` y `asilo doctor` exponen capacidades reales sin red ni secretos.
18
+ - `NOTICE` con la atribución de copyright y la reserva de marca.
19
+ - Esqueleto inicial del paquete con perfil Milpa `library`.
20
+ - Contratos declarados para `@guardrail`, `@enforce_schema` y `@hitl`.
21
+ - Estructura del CLI del Agente Cero (`init`, `explain`, `run`).
22
+
23
+ ### Cambiado
24
+ - `max_repairs` sólo acepta cero: un decorador de validación no reejecuta funciones con
25
+ posibles efectos secundarios.
26
+ - `asilo init/explain/run` fallan de forma explícita y sin traceback mientras sigan diferidos.
27
+ - `LICENSE` contiene el texto completo de Apache-2.0; antes era solo el aviso de 18
28
+ líneas, que no cumple la sección 4(a) de la propia licencia.
29
+ - Metadatos de licencia según PEP 639 (`license = "Apache-2.0"`, `license-files`).
30
+ - La versión se deriva del tag git vía `hatch-vcs`; ya no se escribe en `pyproject.toml` (ver ADR-002).
31
+ - `README.md`: la sección de seguridad ahora detalla qué protege `enforce_schema` (forma, no
32
+ veracidad ni permisos), qué no protegen los stubs, y por qué una aprobación humana futura no
33
+ puede representarse con un booleano autodeclarado (lección registrada en
34
+ `reports/2026-09-22-mejoras-desde-horcon.md`).
35
+ - `reports/README.md` indexa ahora el reporte `2026-09-22-mejoras-desde-horcon.md`, que existía
36
+ sin enlazar desde el índice.
37
+
38
+ ### Corregido
39
+ - `docs/referencias.md`: el enlace directo al PDF de OWASP Top 10 for LLM Applications (2025)
40
+ devolvía 404 tras una reestructuración del sitio de OWASP; se reemplazó por la página del
41
+ recurso, verificada activa.
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Kasai Labs
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,26 @@
1
+ ASILO Core
2
+ Copyright 2026 Kasai Labs
3
+
4
+ This product includes software developed at Kasai Labs
5
+ (https://codeberg.org/kasailabs).
6
+
7
+ --------------------------------------------------------------------------------
8
+ Marcas / Trademarks
9
+ --------------------------------------------------------------------------------
10
+
11
+ "ASILO", "MILPA" y "Kasai Labs" son marcas de Kasai Labs.
12
+
13
+ La Licencia Apache 2.0 concede derechos sobre el **código**, no sobre las marcas.
14
+ Su seccion 6 ("Trademarks") excluye expresamente los nombres comerciales, marcas
15
+ registradas y marcas de servicio del licenciante.
16
+
17
+ En la practica esto significa que puedes usar, modificar y redistribuir este
18
+ software, incluso comercialmente, pero **no** puedes dar a entender que tu
19
+ version derivada es ASILO oficial ni esta avalada por Kasai Labs.
20
+
21
+ --------------------------------------------------------------------------------
22
+ Metodologia
23
+ --------------------------------------------------------------------------------
24
+
25
+ Este repositorio es una implementacion de referencia. La metodologia ASILO en si
26
+ se documenta en el plano de planeacion (ver SOURCE.md) y no se licencia aqui.
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.5
2
+ Name: asilo-core
3
+ Version: 0.1.0a1
4
+ Summary: SDK de gobernanza para sistemas multi-agente: guardrails, validación de esquemas y Agente Cero
5
+ Project-URL: Homepage, https://codeberg.org/kasailabs/asilo-core
6
+ Project-URL: Documentation, https://codeberg.org/kasailabs/asilo-core/src/branch/main/docs/INDEX.md
7
+ Project-URL: Repository, https://codeberg.org/kasailabs/asilo-core
8
+ Project-URL: Changelog, https://codeberg.org/kasailabs/asilo-core/src/branch/main/CHANGELOG.md
9
+ Project-URL: Issues, https://codeberg.org/kasailabs/asilo-core/issues
10
+ Author: Kasai Labs
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ License-File: NOTICE
14
+ Keywords: agents,ai,governance,guardrails,llm,security
15
+ Classifier: Development Status :: 3 - Alpha
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: pydantic>=2.7
23
+ Requires-Dist: pyyaml>=6.0
24
+ Provides-Extra: cli
25
+ Requires-Dist: jinja2>=3.1; extra == 'cli'
26
+ Requires-Dist: litellm>=1.40; extra == 'cli'
27
+ Requires-Dist: rich>=13.7; extra == 'cli'
28
+ Requires-Dist: typer>=0.12; extra == 'cli'
29
+ Provides-Extra: dev
30
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
31
+ Requires-Dist: pytest>=8.0; extra == 'dev'
32
+ Requires-Dist: ruff>=0.5; extra == 'dev'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # asilo-core
36
+
37
+ > Implementación Python de referencia **candidata** para controles de sistemas multiagente.
38
+ > Aspira a traducir una revisión identificable de ASILO a contratos, decisiones de política,
39
+ > auditoría y revisión humana sin definir la metodología dentro del paquete.
40
+
41
+ **Perfil Milpa:** `library` (P5) · **Distribución prevista:** PyPI `asilo-core` · **Estado:** alpha parcial no publicable
42
+
43
+ ## TL;DR
44
+
45
+ - `enforce_schema` ya valida resultados Pydantic sync/async y nunca reejecuta la función.
46
+ - `asilo status` y `asilo doctor` informan capacidades sin red ni secretos.
47
+ - `guardrail`, HITL, auditoría y comandos de dominio continúan bloqueados.
48
+ - El scaffolding operativo vive hoy en `kasai-crew scaffold`; no se duplica aquí.
49
+ - Empieza por [Quickstart](docs/QUICKSTART.md), [diagramas](docs/architecture/DIAGRAMS.md) e
50
+ [índice](docs/INDEX.md).
51
+
52
+ ---
53
+
54
+ ## Documentación
55
+
56
+ Cuatro niveles, de lo general a lo particular, con ruta de lectura por perfil en
57
+ [`docs/INDEX.md`](docs/INDEX.md):
58
+
59
+ | Perfil | Empieza en |
60
+ |---|---|
61
+ | No técnico | [`docs/01-manifiesto/`](docs/01-manifiesto/README.md) — la aduana: el modelo propone, la librería valida la forma |
62
+ | Arquitecto | [`docs/02-diagramas/`](docs/02-diagramas/README.md) — contexto, capas, secuencia, escalada humana |
63
+ | Operador | [`docs/03-operacion/`](docs/03-operacion/README.md) — instalación, comandos, qué no está implementado |
64
+ | Auditor | [`docs/04-contratos/`](docs/04-contratos/README.md) — API, axiomas, errores, ADR, fuentes de verdad |
65
+
66
+ Sitio navegable (MkDocs Material, con el estándar documental de Horcón), desde la raíz del repo:
67
+
68
+ ```bash
69
+ ../horcon/.venv/bin/python -m horcon audit-docs . # frontmatter, navegación, enlaces
70
+ ../horcon/.venv/bin/python -m horcon docs build . # ensambla tmp/site-src/ y construye tmp/site/
71
+ ../horcon/.venv/bin/python -m horcon docs serve . # sirve en 127.0.0.1
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Diseño objetivo
77
+
78
+ Un agente autónomo puede producir información falsa, filtrar datos o solicitar acciones
79
+ irreversibles. El diseño objetivo interpone controles entre el modelo y el mundo:
80
+
81
+ | Control | Mecanismo objetivo | Estado actual |
82
+ |---------|-------------------|---------------|
83
+ | **Esquema** | `@enforce_schema` valida forma contra Pydantic | implementado; una ejecución, sin repairs |
84
+ | **Política** | `@guardrail` obtiene una decisión antes de ejecutar | stub; contrato pendiente |
85
+ | **Revisión humana** | `@hitl` persiste, autoriza y reanuda una decisión | stub; protocolo pendiente |
86
+ | **Auditoría** | eventos minimizados y trazables | inexistente |
87
+
88
+ Un decorador dentro del mismo proceso no constituye por sí solo una frontera de seguridad:
89
+ código con el mismo privilegio puede evitarlo. El enforcement real depende también del
90
+ sistema consumidor, sus herramientas, credenciales y puntos de aplicación.
91
+
92
+ ### Qué protege cada pieza, y qué no
93
+
94
+ | Pieza | Qué protege hoy | Qué NO protege |
95
+ |---|---|---|
96
+ | `enforce_schema` | La **forma** del resultado contra un modelo Pydantic; una sola ejecución, sin reintentos | Que el contenido sea verdadero, que esté autorizado, o que no lleve una instrucción escondida para el siguiente agente (ver [`docs/asilo/seguridad/aduana-llm.md`](docs/asilo/seguridad/aduana-llm.md)) |
97
+ | `guardrail`, `hitl` | Nada: son firmas con contrato escrito que lanzan `NotImplementedError` | Cualquier cosa que su nombre sugiera; llamarlos no bloquea ni pausa nada todavía |
98
+ | `asilo status` / `asilo doctor` | Informar, sin red, qué existe | Que lo informado sea "seguro"; son diagnóstico, no control |
99
+
100
+ Lo que debe poner quien consume esta librería: autenticación y autorización de quien invoca la
101
+ acción, credenciales de mínimo privilegio, límites de red y un punto de aplicación fuera del
102
+ proceso que pueda de verdad impedir la acción si el decorador falla o se evade.
103
+
104
+ Una lección concreta, tomada de un hallazgo real en el framework hermano Horcón y registrada en
105
+ [`reports/2026-09-22-mejoras-desde-horcon.md`](reports/2026-09-22-mejoras-desde-horcon.md): cuando
106
+ exista una revisión humana real (`hitl` dejará de ser un stub), su aprobación **no puede
107
+ representarse con un booleano autodeclarado** (`approved: true`) ni con un campo de texto que
108
+ rellene el propio código que pide la aprobación. Ese diseño ya falló una vez en un sistema
109
+ relacionado: un campo que declaraba quién firmaba se verificaba con la misma firma que lo emitía,
110
+ así que cualquiera podía declararse revisor humano. Una aprobación debe llevar una referencia
111
+ verificable a quien decide y una huella de qué se revisó exactamente, no la palabra del propio
112
+ proceso que la solicita. Esto no está implementado hoy; es una condición que cualquier contrato
113
+ futuro de `hitl` debe cumplir antes de aceptarse.
114
+
115
+ ## Instalación
116
+
117
+ El paquete aún no está publicado. El siguiente comando documenta la distribución prevista,
118
+ no un paso que funcione hoy:
119
+
120
+ ```bash
121
+ pip install asilo-core
122
+ ```
123
+
124
+ ## API ejecutable: validación de esquema
125
+
126
+ ```python
127
+ from asilo.decorators import enforce_schema
128
+ from pydantic import BaseModel
129
+
130
+ class Reporte(BaseModel):
131
+ titulo: str
132
+ hallazgos: list[str]
133
+
134
+ @enforce_schema(Reporte)
135
+ def normalizar_reporte(payload: dict) -> Reporte:
136
+ return payload
137
+ ```
138
+
139
+ ## CLI y Agente Cero
140
+
141
+ El diagnóstico es ejecutable y no llama red:
142
+
143
+ ```bash
144
+ asilo status
145
+ asilo doctor --json
146
+ ```
147
+
148
+ `asilo init`, `explain` y `run` permanecen reservados y salen con código 2, sin traceback.
149
+ Para preparar un repo, el recorrido vigente es `kasai-crew scaffold --repo RUTA`. Esto evita
150
+ dos implementaciones distintas del Agente 0.
151
+
152
+ ## Estructura
153
+
154
+ Sigue el perfil `library` del doc 21 de Milpa: `src/` layout (el paquete no vive en la
155
+ raíz), `tests/` con suite adversarial obligatoria por tratarse de un proyecto con LLM,
156
+ y `docs/asilo/` con los artefactos de gobernanza del propio SDK.
157
+
158
+ ## Estado de implementación
159
+
160
+ Alpha parcial. Los errores, la validación de esquema y el diagnóstico existen; política,
161
+ auditoría, HITL durable y enforcement externo no. Ver `docs/PLAN_IMPLEMENTACION.md` para
162
+ puertas y criterios de release. No usar este repo para proteger operaciones reales.
163
+
164
+ ## Licencia
165
+
166
+ Apache-2.0 — texto completo en [`LICENSE`](LICENSE).
167
+
168
+ La marca ASILO **no** se licencia con el código (sección 6 de Apache-2.0); ver [`NOTICE`](NOTICE).
@@ -0,0 +1,134 @@
1
+ # asilo-core
2
+
3
+ > Implementación Python de referencia **candidata** para controles de sistemas multiagente.
4
+ > Aspira a traducir una revisión identificable de ASILO a contratos, decisiones de política,
5
+ > auditoría y revisión humana sin definir la metodología dentro del paquete.
6
+
7
+ **Perfil Milpa:** `library` (P5) · **Distribución prevista:** PyPI `asilo-core` · **Estado:** alpha parcial no publicable
8
+
9
+ ## TL;DR
10
+
11
+ - `enforce_schema` ya valida resultados Pydantic sync/async y nunca reejecuta la función.
12
+ - `asilo status` y `asilo doctor` informan capacidades sin red ni secretos.
13
+ - `guardrail`, HITL, auditoría y comandos de dominio continúan bloqueados.
14
+ - El scaffolding operativo vive hoy en `kasai-crew scaffold`; no se duplica aquí.
15
+ - Empieza por [Quickstart](docs/QUICKSTART.md), [diagramas](docs/architecture/DIAGRAMS.md) e
16
+ [índice](docs/INDEX.md).
17
+
18
+ ---
19
+
20
+ ## Documentación
21
+
22
+ Cuatro niveles, de lo general a lo particular, con ruta de lectura por perfil en
23
+ [`docs/INDEX.md`](docs/INDEX.md):
24
+
25
+ | Perfil | Empieza en |
26
+ |---|---|
27
+ | No técnico | [`docs/01-manifiesto/`](docs/01-manifiesto/README.md) — la aduana: el modelo propone, la librería valida la forma |
28
+ | Arquitecto | [`docs/02-diagramas/`](docs/02-diagramas/README.md) — contexto, capas, secuencia, escalada humana |
29
+ | Operador | [`docs/03-operacion/`](docs/03-operacion/README.md) — instalación, comandos, qué no está implementado |
30
+ | Auditor | [`docs/04-contratos/`](docs/04-contratos/README.md) — API, axiomas, errores, ADR, fuentes de verdad |
31
+
32
+ Sitio navegable (MkDocs Material, con el estándar documental de Horcón), desde la raíz del repo:
33
+
34
+ ```bash
35
+ ../horcon/.venv/bin/python -m horcon audit-docs . # frontmatter, navegación, enlaces
36
+ ../horcon/.venv/bin/python -m horcon docs build . # ensambla tmp/site-src/ y construye tmp/site/
37
+ ../horcon/.venv/bin/python -m horcon docs serve . # sirve en 127.0.0.1
38
+ ```
39
+
40
+ ---
41
+
42
+ ## Diseño objetivo
43
+
44
+ Un agente autónomo puede producir información falsa, filtrar datos o solicitar acciones
45
+ irreversibles. El diseño objetivo interpone controles entre el modelo y el mundo:
46
+
47
+ | Control | Mecanismo objetivo | Estado actual |
48
+ |---------|-------------------|---------------|
49
+ | **Esquema** | `@enforce_schema` valida forma contra Pydantic | implementado; una ejecución, sin repairs |
50
+ | **Política** | `@guardrail` obtiene una decisión antes de ejecutar | stub; contrato pendiente |
51
+ | **Revisión humana** | `@hitl` persiste, autoriza y reanuda una decisión | stub; protocolo pendiente |
52
+ | **Auditoría** | eventos minimizados y trazables | inexistente |
53
+
54
+ Un decorador dentro del mismo proceso no constituye por sí solo una frontera de seguridad:
55
+ código con el mismo privilegio puede evitarlo. El enforcement real depende también del
56
+ sistema consumidor, sus herramientas, credenciales y puntos de aplicación.
57
+
58
+ ### Qué protege cada pieza, y qué no
59
+
60
+ | Pieza | Qué protege hoy | Qué NO protege |
61
+ |---|---|---|
62
+ | `enforce_schema` | La **forma** del resultado contra un modelo Pydantic; una sola ejecución, sin reintentos | Que el contenido sea verdadero, que esté autorizado, o que no lleve una instrucción escondida para el siguiente agente (ver [`docs/asilo/seguridad/aduana-llm.md`](docs/asilo/seguridad/aduana-llm.md)) |
63
+ | `guardrail`, `hitl` | Nada: son firmas con contrato escrito que lanzan `NotImplementedError` | Cualquier cosa que su nombre sugiera; llamarlos no bloquea ni pausa nada todavía |
64
+ | `asilo status` / `asilo doctor` | Informar, sin red, qué existe | Que lo informado sea "seguro"; son diagnóstico, no control |
65
+
66
+ Lo que debe poner quien consume esta librería: autenticación y autorización de quien invoca la
67
+ acción, credenciales de mínimo privilegio, límites de red y un punto de aplicación fuera del
68
+ proceso que pueda de verdad impedir la acción si el decorador falla o se evade.
69
+
70
+ Una lección concreta, tomada de un hallazgo real en el framework hermano Horcón y registrada en
71
+ [`reports/2026-09-22-mejoras-desde-horcon.md`](reports/2026-09-22-mejoras-desde-horcon.md): cuando
72
+ exista una revisión humana real (`hitl` dejará de ser un stub), su aprobación **no puede
73
+ representarse con un booleano autodeclarado** (`approved: true`) ni con un campo de texto que
74
+ rellene el propio código que pide la aprobación. Ese diseño ya falló una vez en un sistema
75
+ relacionado: un campo que declaraba quién firmaba se verificaba con la misma firma que lo emitía,
76
+ así que cualquiera podía declararse revisor humano. Una aprobación debe llevar una referencia
77
+ verificable a quien decide y una huella de qué se revisó exactamente, no la palabra del propio
78
+ proceso que la solicita. Esto no está implementado hoy; es una condición que cualquier contrato
79
+ futuro de `hitl` debe cumplir antes de aceptarse.
80
+
81
+ ## Instalación
82
+
83
+ El paquete aún no está publicado. El siguiente comando documenta la distribución prevista,
84
+ no un paso que funcione hoy:
85
+
86
+ ```bash
87
+ pip install asilo-core
88
+ ```
89
+
90
+ ## API ejecutable: validación de esquema
91
+
92
+ ```python
93
+ from asilo.decorators import enforce_schema
94
+ from pydantic import BaseModel
95
+
96
+ class Reporte(BaseModel):
97
+ titulo: str
98
+ hallazgos: list[str]
99
+
100
+ @enforce_schema(Reporte)
101
+ def normalizar_reporte(payload: dict) -> Reporte:
102
+ return payload
103
+ ```
104
+
105
+ ## CLI y Agente Cero
106
+
107
+ El diagnóstico es ejecutable y no llama red:
108
+
109
+ ```bash
110
+ asilo status
111
+ asilo doctor --json
112
+ ```
113
+
114
+ `asilo init`, `explain` y `run` permanecen reservados y salen con código 2, sin traceback.
115
+ Para preparar un repo, el recorrido vigente es `kasai-crew scaffold --repo RUTA`. Esto evita
116
+ dos implementaciones distintas del Agente 0.
117
+
118
+ ## Estructura
119
+
120
+ Sigue el perfil `library` del doc 21 de Milpa: `src/` layout (el paquete no vive en la
121
+ raíz), `tests/` con suite adversarial obligatoria por tratarse de un proyecto con LLM,
122
+ y `docs/asilo/` con los artefactos de gobernanza del propio SDK.
123
+
124
+ ## Estado de implementación
125
+
126
+ Alpha parcial. Los errores, la validación de esquema y el diagnóstico existen; política,
127
+ auditoría, HITL durable y enforcement externo no. Ver `docs/PLAN_IMPLEMENTACION.md` para
128
+ puertas y criterios de release. No usar este repo para proteger operaciones reales.
129
+
130
+ ## Licencia
131
+
132
+ Apache-2.0 — texto completo en [`LICENSE`](LICENSE).
133
+
134
+ La marca ASILO **no** se licencia con el código (sección 6 de Apache-2.0); ver [`NOTICE`](NOTICE).