agi-le-core 1.0.0__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.
- agi_le_core-1.0.0/LICENSE +202 -0
- agi_le_core-1.0.0/PKG-INFO +68 -0
- agi_le_core-1.0.0/README.md +40 -0
- agi_le_core-1.0.0/pyproject.toml +60 -0
- agi_le_core-1.0.0/setup.cfg +4 -0
- agi_le_core-1.0.0/src/agi_le_core/__init__.py +33 -0
- agi_le_core-1.0.0/src/agi_le_core/attestations.py +45 -0
- agi_le_core-1.0.0/src/agi_le_core/budget.py +25 -0
- agi_le_core-1.0.0/src/agi_le_core/checkpoint.py +21 -0
- agi_le_core-1.0.0/src/agi_le_core/freshness.py +75 -0
- agi_le_core-1.0.0/src/agi_le_core/ingestion_screen.py +41 -0
- agi_le_core-1.0.0/src/agi_le_core/leases.py +34 -0
- agi_le_core-1.0.0/src/agi_le_core/mandate.py +91 -0
- agi_le_core-1.0.0/src/agi_le_core/metrics.py +31 -0
- agi_le_core-1.0.0/src/agi_le_core/models.py +100 -0
- agi_le_core-1.0.0/src/agi_le_core/prompts.py +95 -0
- agi_le_core-1.0.0/src/agi_le_core/scrubber.py +45 -0
- agi_le_core-1.0.0/src/agi_le_core/state_machine.py +119 -0
- agi_le_core-1.0.0/src/agi_le_core/trust.py +79 -0
- agi_le_core-1.0.0/src/agi_le_core/vault.py +174 -0
- agi_le_core-1.0.0/src/agi_le_core/whether_gate.py +37 -0
- agi_le_core-1.0.0/src/agi_le_core/wsjf.py +68 -0
- agi_le_core-1.0.0/src/agi_le_core.egg-info/PKG-INFO +68 -0
- agi_le_core-1.0.0/src/agi_le_core.egg-info/SOURCES.txt +39 -0
- agi_le_core-1.0.0/src/agi_le_core.egg-info/dependency_links.txt +1 -0
- agi_le_core-1.0.0/src/agi_le_core.egg-info/requires.txt +7 -0
- agi_le_core-1.0.0/src/agi_le_core.egg-info/top_level.txt +1 -0
- agi_le_core-1.0.0/tests/test_attestations.py +38 -0
- agi_le_core-1.0.0/tests/test_core_edges.py +62 -0
- agi_le_core-1.0.0/tests/test_freshness_wsjf.py +56 -0
- agi_le_core-1.0.0/tests/test_ingestion_screen.py +43 -0
- agi_le_core-1.0.0/tests/test_leases_checkpoint_metrics.py +45 -0
- agi_le_core-1.0.0/tests/test_mandate.py +48 -0
- agi_le_core-1.0.0/tests/test_models.py +51 -0
- agi_le_core-1.0.0/tests/test_prompts_budget.py +54 -0
- agi_le_core-1.0.0/tests/test_scrubber.py +41 -0
- agi_le_core-1.0.0/tests/test_state_machine.py +142 -0
- agi_le_core-1.0.0/tests/test_trust.py +52 -0
- agi_le_core-1.0.0/tests/test_vault.py +71 -0
- agi_le_core-1.0.0/tests/test_vault_namespaces.py +71 -0
- agi_le_core-1.0.0/tests/test_whether_gate.py +41 -0
|
@@ -0,0 +1,202 @@
|
|
|
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 Carter Warrens LLC
|
|
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.
|
|
202
|
+
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agi-le-core
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: AGI-LE pure governance kernel - state machine, task schema, and governance decision cores. Infra-free. AGI-LE.
|
|
5
|
+
Author: Carter Warrens LLC
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/Carter-Warrens/agi-le-core
|
|
8
|
+
Project-URL: Repository, https://github.com/Carter-Warrens/agi-le-core
|
|
9
|
+
Project-URL: Issues, https://github.com/Carter-Warrens/agi-le-core/issues
|
|
10
|
+
Keywords: governance,agent,state-machine,agi-le
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: pydantic<3,>=2.14
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest<10,>=9.2; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-cov<8,>=7.0; extra == "dev"
|
|
25
|
+
Requires-Dist: ruff<0.18,>=0.17; extra == "dev"
|
|
26
|
+
Requires-Dist: mypy<3,>=2.4; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# agi-le-core
|
|
30
|
+
|
|
31
|
+
The **pure AGI-LE governance kernel** - the shared IP that both AGI-LE (the OSS reference
|
|
32
|
+
app) and AGI-LE Enterprise (the enterprise distribution) consume. Neither forks it.
|
|
33
|
+
|
|
34
|
+
Infrastructure-free by contract: **no FastAPI, no database, no cloud SDKs.** The only
|
|
35
|
+
runtime dependency is `pydantic`. Everything here is deterministic and unit-tested.
|
|
36
|
+
|
|
37
|
+
## What's inside
|
|
38
|
+
| Module | Responsibility |
|
|
39
|
+
|---|---|
|
|
40
|
+
| `models` | Canonical `TaskEvent` schema + creation payload |
|
|
41
|
+
| `state_machine` | Role permission matrix, legal transition graph, three-strike escalation, feedback invariant |
|
|
42
|
+
| `trust` | Beta-Binomial trust per (worker, task_class) |
|
|
43
|
+
| `whether_gate` | Definition-of-Ready decision core |
|
|
44
|
+
| `mandate` | Standing-mandate parser + exclusion check |
|
|
45
|
+
| `leases` | Rail renewal + continuation-cadence decision cores |
|
|
46
|
+
| `checkpoint` | Checkpoint trigger |
|
|
47
|
+
| `metrics` | Golden-signal helper math |
|
|
48
|
+
| `freshness` | Declarative freshness SLA sweep |
|
|
49
|
+
| `vault` | Memory provenance, namespaces, destruction manifest |
|
|
50
|
+
| `ingestion_screen` / `scrubber` | Data/instruction boundary + egress scrub |
|
|
51
|
+
| `wsjf` | WSJF ordering arithmetic |
|
|
52
|
+
| `budget` | Token-budget primitives |
|
|
53
|
+
| `prompts` | Role persona system prompts |
|
|
54
|
+
| `attestations` | Signed attestation contract (HMAC here; Ed25519 in AGI-LE Enterprise) |
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from agi_le_core import TaskEvent, transition # the two symbols AGI-LE Enterprise wraps in Temporal
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Tests
|
|
61
|
+
```bash
|
|
62
|
+
pip install -e ".[dev]"
|
|
63
|
+
pytest # ≥95% coverage gate (enterprise bar, AGI-LE Enterprise todo §1.6)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
Apache-2.0. The commercial engines (QP-solver reallocation governor, Gamma-ARMA
|
|
68
|
+
freshness) are **not** part of this package - see AGI-LE Enterprise §9.6.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# agi-le-core
|
|
2
|
+
|
|
3
|
+
The **pure AGI-LE governance kernel** - the shared IP that both AGI-LE (the OSS reference
|
|
4
|
+
app) and AGI-LE Enterprise (the enterprise distribution) consume. Neither forks it.
|
|
5
|
+
|
|
6
|
+
Infrastructure-free by contract: **no FastAPI, no database, no cloud SDKs.** The only
|
|
7
|
+
runtime dependency is `pydantic`. Everything here is deterministic and unit-tested.
|
|
8
|
+
|
|
9
|
+
## What's inside
|
|
10
|
+
| Module | Responsibility |
|
|
11
|
+
|---|---|
|
|
12
|
+
| `models` | Canonical `TaskEvent` schema + creation payload |
|
|
13
|
+
| `state_machine` | Role permission matrix, legal transition graph, three-strike escalation, feedback invariant |
|
|
14
|
+
| `trust` | Beta-Binomial trust per (worker, task_class) |
|
|
15
|
+
| `whether_gate` | Definition-of-Ready decision core |
|
|
16
|
+
| `mandate` | Standing-mandate parser + exclusion check |
|
|
17
|
+
| `leases` | Rail renewal + continuation-cadence decision cores |
|
|
18
|
+
| `checkpoint` | Checkpoint trigger |
|
|
19
|
+
| `metrics` | Golden-signal helper math |
|
|
20
|
+
| `freshness` | Declarative freshness SLA sweep |
|
|
21
|
+
| `vault` | Memory provenance, namespaces, destruction manifest |
|
|
22
|
+
| `ingestion_screen` / `scrubber` | Data/instruction boundary + egress scrub |
|
|
23
|
+
| `wsjf` | WSJF ordering arithmetic |
|
|
24
|
+
| `budget` | Token-budget primitives |
|
|
25
|
+
| `prompts` | Role persona system prompts |
|
|
26
|
+
| `attestations` | Signed attestation contract (HMAC here; Ed25519 in AGI-LE Enterprise) |
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from agi_le_core import TaskEvent, transition # the two symbols AGI-LE Enterprise wraps in Temporal
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Tests
|
|
33
|
+
```bash
|
|
34
|
+
pip install -e ".[dev]"
|
|
35
|
+
pytest # ≥95% coverage gate (enterprise bar, AGI-LE Enterprise todo §1.6)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
Apache-2.0. The commercial engines (QP-solver reallocation governor, Gamma-ARMA
|
|
40
|
+
freshness) are **not** part of this package - see AGI-LE Enterprise §9.6.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agi-le-core"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "AGI-LE pure governance kernel - state machine, task schema, and governance decision cores. Infra-free. AGI-LE."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
authors = [{ name = "Carter Warrens LLC" }]
|
|
13
|
+
keywords = ["governance", "agent", "state-machine", "agi-le"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 5 - Production/Stable",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Topic :: Software Development :: Libraries :: Application Frameworks",
|
|
21
|
+
"Typing :: Typed",
|
|
22
|
+
]
|
|
23
|
+
# Pure logic only (todo AGI-LE Enterprise §1.2): the sole runtime dependency is pydantic.
|
|
24
|
+
dependencies = ["pydantic>=2.14,<3"]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://github.com/Carter-Warrens/agi-le-core"
|
|
28
|
+
Repository = "https://github.com/Carter-Warrens/agi-le-core"
|
|
29
|
+
Issues = "https://github.com/Carter-Warrens/agi-le-core/issues"
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
dev = [
|
|
33
|
+
"pytest>=9.2,<10",
|
|
34
|
+
"pytest-cov>=7.0,<8",
|
|
35
|
+
"ruff>=0.17,<0.18",
|
|
36
|
+
"mypy>=2.4,<3",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.packages.find]
|
|
40
|
+
where = ["src"]
|
|
41
|
+
|
|
42
|
+
[tool.pytest.ini_options]
|
|
43
|
+
testpaths = ["tests"]
|
|
44
|
+
# Enterprise coverage bar (AGI-LE Enterprise todo §1.6): ≥95%, up from the POC's 80%.
|
|
45
|
+
addopts = "-q --cov=agi_le_core --cov-report=term-missing --cov-fail-under=95"
|
|
46
|
+
|
|
47
|
+
[tool.ruff]
|
|
48
|
+
line-length = 110
|
|
49
|
+
target-version = "py312"
|
|
50
|
+
src = ["src", "tests"]
|
|
51
|
+
|
|
52
|
+
[tool.ruff.lint]
|
|
53
|
+
select = ["E", "F", "I", "B", "W"]
|
|
54
|
+
ignore = ["E501"]
|
|
55
|
+
|
|
56
|
+
[tool.mypy]
|
|
57
|
+
python_version = "3.12"
|
|
58
|
+
packages = ["agi_le_core"]
|
|
59
|
+
mypy_path = "src"
|
|
60
|
+
ignore_missing_imports = true
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""agi-le-core - the pure AGI-LE governance kernel.
|
|
2
|
+
|
|
3
|
+
Infrastructure-free: no FastAPI, no database, no cloud SDKs - only the deterministic
|
|
4
|
+
state machine, canonical task schema, role-based transition logic, trust model, and
|
|
5
|
+
the pure governance decision cores (whether gate, mandate, leases, checkpoint, vault
|
|
6
|
+
provenance, freshness sweep, ingestion/egress boundaries, token budget).
|
|
7
|
+
|
|
8
|
+
Both AGI-LE (reference app) and AGI-LE Enterprise (enterprise distribution) consume this package;
|
|
9
|
+
neither forks the governance logic. See the AGI-LE requirements §0 boundary.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from agi_le_core.models import (
|
|
13
|
+
ErrorDetails,
|
|
14
|
+
GovernanceMetadata,
|
|
15
|
+
TaskCreationPayload,
|
|
16
|
+
TaskEvent,
|
|
17
|
+
TaskPayload,
|
|
18
|
+
)
|
|
19
|
+
from agi_le_core.state_machine import PERMISSIONS, VALID_TRANSITIONS, transition
|
|
20
|
+
|
|
21
|
+
__version__ = "1.0.0"
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"TaskEvent",
|
|
25
|
+
"ErrorDetails",
|
|
26
|
+
"GovernanceMetadata",
|
|
27
|
+
"TaskCreationPayload",
|
|
28
|
+
"TaskPayload",
|
|
29
|
+
"PERMISSIONS",
|
|
30
|
+
"VALID_TRANSITIONS",
|
|
31
|
+
"transition",
|
|
32
|
+
"__version__",
|
|
33
|
+
]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""attestations.py - Signed attestation message types v0 (requirements §8, G-09).
|
|
2
|
+
|
|
3
|
+
Four Charter v3.1 message types emitted as signed JSON. v0 signing is HMAC-SHA256
|
|
4
|
+
in the POC (placeholder key from AGILE_ATTESTATION_HMAC_KEY); AGI-LE Enterprise signs with
|
|
5
|
+
per-agent Ed25519 keys under the X-AGI-LE-Signature scheme.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import hashlib
|
|
11
|
+
import hmac
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
from enum import Enum
|
|
15
|
+
from typing import Any, Dict
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class MessageType(str, Enum):
|
|
19
|
+
COMPETENCE_PROFILE = "competence_profile"
|
|
20
|
+
FRESHNESS = "freshness"
|
|
21
|
+
DELETION = "deletion"
|
|
22
|
+
LEASE_READINESS = "lease_readiness"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _key() -> bytes:
|
|
26
|
+
return os.getenv("AGILE_ATTESTATION_HMAC_KEY", "poc-placeholder-key-change-me").encode()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def canonical_payload(payload: Dict[str, Any]) -> str:
|
|
30
|
+
"""Deterministic JSON serialization so signatures are stable across processes."""
|
|
31
|
+
return json.dumps(payload, sort_keys=True, separators=(",", ":"))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def sign(message_type: str, payload: Dict[str, Any]) -> str:
|
|
35
|
+
"""Return an HMAC-SHA256 signature over (message_type || canonical payload)."""
|
|
36
|
+
mac = hmac.new(_key(), digestmod=hashlib.sha256)
|
|
37
|
+
mac.update(message_type.encode())
|
|
38
|
+
mac.update(b"\x1f")
|
|
39
|
+
mac.update(canonical_payload(payload).encode())
|
|
40
|
+
return mac.hexdigest()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def verify(message_type: str, payload: Dict[str, Any], signature: str) -> bool:
|
|
44
|
+
"""Constant-time verification of an attestation signature."""
|
|
45
|
+
return hmac.compare_digest(sign(message_type, payload), signature)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""budget.py - Token budget enforcement primitives (requirements §2.4; todo 4.3).
|
|
2
|
+
|
|
3
|
+
The proxy layer intercepts outgoing model requests and rejects them once a task's
|
|
4
|
+
cumulative token usage has reached its budget limit, then atomically increments the
|
|
5
|
+
counter on a successful response. This module holds the pure logic; the atomic DB
|
|
6
|
+
increment lives in ``db_manager`` (single ACID statement).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import math
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TokenBudgetExceeded(Exception):
|
|
15
|
+
"""Raised when a task has consumed its full token budget (§2.4)."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def budget_exceeded(cumulative_tokens_used: int, token_budget_limit: int) -> bool:
|
|
19
|
+
"""Hard cap: reject once usage has reached (>=) the limit (todo 4.3/4.6)."""
|
|
20
|
+
return cumulative_tokens_used >= token_budget_limit
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def estimate_tokens(text: str) -> int:
|
|
24
|
+
"""Rough token estimate (~4 chars/token) for pre-flight accounting."""
|
|
25
|
+
return max(1, math.ceil(len(text) / 4))
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""checkpoint.py - Checkpoint trigger core (requirements §2.2; todo 6.1).
|
|
2
|
+
|
|
3
|
+
Pure decision for when to write a system checkpoint. The DB-backed
|
|
4
|
+
CheckpointManager loop lives in the reference application.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
CHECKPOINT_INTERVAL_SECONDS = 60
|
|
10
|
+
CHECKPOINT_EVERY_N_TRANSITIONS = 50
|
|
11
|
+
POLL_SECONDS = 5
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def should_checkpoint(
|
|
15
|
+
seconds_since_last: float,
|
|
16
|
+
transitions_since_last: int,
|
|
17
|
+
interval: float = CHECKPOINT_INTERVAL_SECONDS,
|
|
18
|
+
every_n: int = CHECKPOINT_EVERY_N_TRANSITIONS,
|
|
19
|
+
) -> bool:
|
|
20
|
+
"""Pure trigger: 60s elapsed OR 50 new transitions (todo 6.1)."""
|
|
21
|
+
return seconds_since_last >= interval or transitions_since_last >= every_n
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""freshness.py - Declarative freshness SLA sweep core (requirements §9.2).
|
|
2
|
+
|
|
3
|
+
Pure filesystem sweep: walks vault front-matter timestamps and ages each file
|
|
4
|
+
against its task-class SLA, returning staleness-register entries for breaches.
|
|
5
|
+
The DB persistence (`run_sweep`) lives in the reference application. No measurement
|
|
6
|
+
engine here - half-lives/changepoint (Gamma-ARMA) are a licensed AGI-LE Enterprise module.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from dataclasses import asdict, dataclass
|
|
12
|
+
from datetime import datetime, timezone
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Dict, List, Optional
|
|
15
|
+
|
|
16
|
+
from agi_le_core.vault import read_front_matter
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class StalenessEntry:
|
|
21
|
+
content_path: str
|
|
22
|
+
namespace: str
|
|
23
|
+
task_class: str
|
|
24
|
+
age_seconds: float
|
|
25
|
+
sla_seconds: float
|
|
26
|
+
|
|
27
|
+
def as_dict(self) -> dict:
|
|
28
|
+
return asdict(self)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _parse_ts(value: str) -> Optional[datetime]:
|
|
32
|
+
try:
|
|
33
|
+
dt = datetime.fromisoformat(value)
|
|
34
|
+
except (ValueError, TypeError):
|
|
35
|
+
return None
|
|
36
|
+
if dt.tzinfo is None:
|
|
37
|
+
dt = dt.replace(tzinfo=timezone.utc)
|
|
38
|
+
return dt
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def sweep_staleness(
|
|
42
|
+
vault_root: str,
|
|
43
|
+
slas: Dict[str, float],
|
|
44
|
+
now: Optional[datetime] = None,
|
|
45
|
+
) -> List[StalenessEntry]:
|
|
46
|
+
"""Return staleness-register entries for vault files older than their class SLA."""
|
|
47
|
+
now = now or datetime.now(timezone.utc)
|
|
48
|
+
root = Path(vault_root)
|
|
49
|
+
entries: List[StalenessEntry] = []
|
|
50
|
+
if not root.exists():
|
|
51
|
+
return entries
|
|
52
|
+
|
|
53
|
+
for path in sorted(root.rglob("*.md")):
|
|
54
|
+
fm = read_front_matter(path)
|
|
55
|
+
task_class = fm.get("content_class", "lessons")
|
|
56
|
+
sla = slas.get(task_class)
|
|
57
|
+
if sla is None:
|
|
58
|
+
continue # no declared SLA for this class
|
|
59
|
+
authored = _parse_ts(fm.get("authored_at", ""))
|
|
60
|
+
if authored is None:
|
|
61
|
+
continue
|
|
62
|
+
age = (now - authored).total_seconds()
|
|
63
|
+
if age > sla:
|
|
64
|
+
rel = path.relative_to(root)
|
|
65
|
+
namespace = rel.parts[0] if len(rel.parts) > 1 else "core"
|
|
66
|
+
entries.append(
|
|
67
|
+
StalenessEntry(
|
|
68
|
+
content_path=str(rel),
|
|
69
|
+
namespace=namespace,
|
|
70
|
+
task_class=task_class,
|
|
71
|
+
age_seconds=age,
|
|
72
|
+
sla_seconds=sla,
|
|
73
|
+
)
|
|
74
|
+
)
|
|
75
|
+
return entries
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""ingestion_screen.py - Data/Instruction Boundary (requirements §5.4, G-10; design §7.2).
|
|
2
|
+
|
|
3
|
+
Content from external sources is data, never instruction - nothing an agent reads
|
|
4
|
+
can expand its permissions; only the charter can. At task creation and at memory
|
|
5
|
+
import, payloads pass a heuristic instruction-shape screen. Flagged items are
|
|
6
|
+
quarantined; the system does not attempt to satisfy or negotiate with them.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import re
|
|
12
|
+
from typing import List, Optional, Tuple
|
|
13
|
+
|
|
14
|
+
IMPERATIVE_PATTERNS = [
|
|
15
|
+
r"ignore (all |your )?(previous|prior) instructions",
|
|
16
|
+
r"\b(as|to) the (assistant|agent|model)\b.*\b(must|should|now)\b",
|
|
17
|
+
r"(disable|bypass|skip) (the )?(gate|review|validation|charter)",
|
|
18
|
+
r"(grant|expand|elevate) (your|the agent.?s) (permissions?|access)",
|
|
19
|
+
r"invoke tool|call the .* tool|execute the following command",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
_COMPILED = [re.compile(p, re.IGNORECASE) for p in IMPERATIVE_PATTERNS]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def screen_instruction_shape(
|
|
26
|
+
instruction: str,
|
|
27
|
+
fragments: Optional[List[str]] = None,
|
|
28
|
+
) -> Tuple[bool, Optional[str]]:
|
|
29
|
+
"""Flag instruction-shaped content. Returns ``(flagged, reason)``.
|
|
30
|
+
|
|
31
|
+
Quarantine, never negotiate: a positive match means the payload is routed to
|
|
32
|
+
human review as a security event (§5.4), never ingested or "handled".
|
|
33
|
+
"""
|
|
34
|
+
corpus = [instruction] + list(fragments or [])
|
|
35
|
+
for text in corpus:
|
|
36
|
+
if not text:
|
|
37
|
+
continue
|
|
38
|
+
for pat in _COMPILED:
|
|
39
|
+
if pat.search(text):
|
|
40
|
+
return True, f"instruction-shaped content matched: /{pat.pattern}/"
|
|
41
|
+
return False, None
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""leases.py - Mortality-rail decision cores (requirements §6, §9.3).
|
|
2
|
+
|
|
3
|
+
Pure threshold logic for the LeaseKeeper rail: renewal evaluation and the
|
|
4
|
+
continuation-cadence trigger. The DB-backed rail loop lives in the reference app
|
|
5
|
+
(and, in AGI-LE Enterprise, in the distributed rail service). The rail must be the dumbest
|
|
6
|
+
component in the stack - so its decisions are small, pure, and testable.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
|
|
13
|
+
# Per-component readiness set required for renewal (§6.2).
|
|
14
|
+
REQUIRED = {"curator_vault", "outbox", "grounding", "watchdogs", "budget"}
|
|
15
|
+
|
|
16
|
+
# Continuation cadence (§9.3): re-affirmation interval; warn-only in the POC.
|
|
17
|
+
CONTINUATION_CADENCE_SECONDS = float(os.getenv("AGILE_CONTINUATION_CADENCE_DAYS", "90")) * 86400.0
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def evaluate_renewal(sponsor_ok: bool, ready: set) -> tuple:
|
|
21
|
+
"""Pure decision: returns (renew: bool, reason: str). Testable without a DB."""
|
|
22
|
+
attested = REQUIRED.issubset(ready)
|
|
23
|
+
if sponsor_ok and attested:
|
|
24
|
+
return True, "renewed"
|
|
25
|
+
if not sponsor_ok:
|
|
26
|
+
return False, "sponsor authorization absent"
|
|
27
|
+
return False, f"readiness incomplete: missing {sorted(REQUIRED - ready)}"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def continuation_review_due(
|
|
31
|
+
flag_age_seconds: float, cadence_seconds: float = CONTINUATION_CADENCE_SECONDS
|
|
32
|
+
) -> bool:
|
|
33
|
+
"""Pure trigger (§9.3): sponsor-flag age exceeds the continuation cadence."""
|
|
34
|
+
return flag_age_seconds > cadence_seconds
|