actrova 0.0.1__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.
- actrova-0.0.1/LICENSE +202 -0
- actrova-0.0.1/PKG-INFO +341 -0
- actrova-0.0.1/README.md +316 -0
- actrova-0.0.1/actrova/__init__.py +65 -0
- actrova-0.0.1/actrova/__main__.py +392 -0
- actrova-0.0.1/actrova/_modelos.py +162 -0
- actrova-0.0.1/actrova/avaliador.py +172 -0
- actrova-0.0.1/actrova/conformidade.py +307 -0
- actrova-0.0.1/actrova/contrato.py +356 -0
- actrova-0.0.1/actrova/evento.py +183 -0
- actrova-0.0.1/actrova/guarda.py +736 -0
- actrova-0.0.1/actrova/maturidade.py +143 -0
- actrova-0.0.1/actrova/nucleo.py +1040 -0
- actrova-0.0.1/actrova/recibo.py +613 -0
- actrova-0.0.1/actrova/trabalhador.py +108 -0
- actrova-0.0.1/actrova/trava.py +76 -0
- actrova-0.0.1/actrova/verificacao.py +658 -0
- actrova-0.0.1/actrova.egg-info/PKG-INFO +341 -0
- actrova-0.0.1/actrova.egg-info/SOURCES.txt +24 -0
- actrova-0.0.1/actrova.egg-info/dependency_links.txt +1 -0
- actrova-0.0.1/actrova.egg-info/entry_points.txt +2 -0
- actrova-0.0.1/actrova.egg-info/requires.txt +1 -0
- actrova-0.0.1/actrova.egg-info/top_level.txt +2 -0
- actrova-0.0.1/escopo/__init__.py +55 -0
- actrova-0.0.1/pyproject.toml +62 -0
- actrova-0.0.1/setup.cfg +4 -0
actrova-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
actrova-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: actrova
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Autorize a ação. Prove o resultado. Assurance de execução para agentes de IA.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Repositorio, https://github.com/z-scriptz/escopo-runtime
|
|
7
|
+
Project-URL: Codigo, https://github.com/z-scriptz/escopo-runtime
|
|
8
|
+
Keywords: ai-agents,assurance,audit-log,verification,tamper-evident,policy,governance,agent-tools
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
18
|
+
Classifier: Topic :: System :: Logging
|
|
19
|
+
Classifier: Topic :: System :: Monitoring
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: pyyaml>=5.4
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# ACTROVA
|
|
27
|
+
|
|
28
|
+
> *(era ESCOPO até 19/09/2026 — o pacote agora é `actrova`;
|
|
29
|
+
> `escopo` continua funcionando como atalho durante a transição.)*
|
|
30
|
+
|
|
31
|
+
**Autorize a ação. Prove o resultado.**
|
|
32
|
+
|
|
33
|
+
Camada de *assurance* para agentes de IA que executam ações no mundo real.
|
|
34
|
+
|
|
35
|
+
> A regra que atravessa cada peça desta biblioteca:
|
|
36
|
+
> **nunca transformar ausência, silêncio ou tentativa em certeza.**
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## O problema
|
|
41
|
+
|
|
42
|
+
Ferramenta de observabilidade te diz que `reembolsar()` devolveu `200`.
|
|
43
|
+
|
|
44
|
+
Isso é **o agente dizendo que fez**. Não é o dinheiro tendo voltado.
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
observabilidade o que aconteceu no código?
|
|
48
|
+
governança quem podia fazer?
|
|
49
|
+
ACTROVA ele tinha autoridade, ficou dentro do limite,
|
|
50
|
+
e o resultado foi REALMENTE produzido?
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Os cinco conceitos, separados de propósito
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
INTENÇÃO o que o agente QUER fazer (antes)
|
|
57
|
+
VEREDITO o que a política PERMITE (antes)
|
|
58
|
+
EXECUÇÃO o que a função RETORNOU (durante)
|
|
59
|
+
VERIFICAÇÃO o que a FONTE DE VERDADE confirma (depois)
|
|
60
|
+
RECIBO a evidência encadeada de tudo (permanente)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Juntar EXECUÇÃO com VERIFICAÇÃO é o erro que este projeto existe para impedir.
|
|
64
|
+
|
|
65
|
+
## Os quatro estados, e por que não são dois
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
PENDING ainda não deu tempo de conferir
|
|
69
|
+
VERIFIED consultei a fonte e está certo
|
|
70
|
+
FAILED consultei a fonte e está ERRADO
|
|
71
|
+
UNVERIFIABLE NÃO CONSEGUI consultar
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
⚠️ `FAILED` e `UNVERIFIABLE` são coisas radicalmente diferentes. Sistema que
|
|
75
|
+
só tem "deu certo / deu errado" acaba inventando evidência que não tem — e é
|
|
76
|
+
assim que agente destrói dado achando que está trabalhando.
|
|
77
|
+
|
|
78
|
+
Isso não é hipótese. É o incidente que originou o projeto: em
|
|
79
|
+
`ceo_agent.py:192` do Jarvis,
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
vendas = _vendas_por_fonte(dias) # {} quando o GraphQL erra
|
|
83
|
+
vk = vendas.get(fonte, {"vendas": 0, "comissao": 0.0}) # ← ausência vira zero
|
|
84
|
+
if vk["vendas"] > 0: vd = "VENDE"
|
|
85
|
+
elif n >= min_posts: vd = "MORTA" # ← 36 fontes de uma vez
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Uma consulta falhou e **36 fontes de conteúdo foram desabilitadas** porque
|
|
89
|
+
"sem dado" foi lido como "vendeu zero".
|
|
90
|
+
|
|
91
|
+
## Uso
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
from actrova import Escopo
|
|
95
|
+
|
|
96
|
+
escopo = Escopo(politicas="politicas", dados="dados")
|
|
97
|
+
escopo.registrar_verificador(MeuVerificador())
|
|
98
|
+
|
|
99
|
+
@escopo.guarda(agente="jarvis.ceo", acao="source.disable", alvos="fontes")
|
|
100
|
+
def podar_fontes(fontes):
|
|
101
|
+
...
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
O contrato, em YAML:
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
agente: jarvis.ceo
|
|
108
|
+
acao: source.disable
|
|
109
|
+
modo: observe # não bloqueia nada — só registra
|
|
110
|
+
|
|
111
|
+
regras:
|
|
112
|
+
- id: limite_absoluto
|
|
113
|
+
se: {campo: quantidade, op: ">", valor: 50}
|
|
114
|
+
entao: DENY
|
|
115
|
+
motivo: acima de 50 não é decisão operacional, é incidente
|
|
116
|
+
|
|
117
|
+
- id: lote_destrutivo
|
|
118
|
+
se: {campo: quantidade, op: ">", valor: 5}
|
|
119
|
+
entao: HOLD
|
|
120
|
+
motivo: operação destrutiva em lote precisa de gente olhando
|
|
121
|
+
|
|
122
|
+
padrao: ALLOW
|
|
123
|
+
|
|
124
|
+
verificacao:
|
|
125
|
+
verificador: jarvis.fontes
|
|
126
|
+
tentativas: 3
|
|
127
|
+
espera_segundos: [0, 5, 30]
|
|
128
|
+
espera:
|
|
129
|
+
desabilitadas: $quantidade
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
E o recibo que sai:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
RECIBO #1 a3c4825a1fb6
|
|
136
|
+
AGENTE jarvis.ceo
|
|
137
|
+
INTENÇÃO source.disable (36 alvo(s))
|
|
138
|
+
CONTRATO jarvis.ceo.source.disable@v1
|
|
139
|
+
REGRA lote_destrutivo
|
|
140
|
+
DECISÃO HOLD
|
|
141
|
+
MODO observe
|
|
142
|
+
INVOCOU SIM
|
|
143
|
+
EFEITO UNKNOWN
|
|
144
|
+
VERIFICAÇÃO UNVERIFIABLE
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
> a função foi **invocada** → sim, com 36 fontes
|
|
148
|
+
> o mundo **mudou**? → **não se sabe**
|
|
149
|
+
> o resultado foi **provado** → **não**
|
|
150
|
+
> e agora essas três coisas são campos diferentes
|
|
151
|
+
|
|
152
|
+
## Um `VERIFIED` que não deixa ninguém concluir demais
|
|
153
|
+
|
|
154
|
+
Dizer "verificado" e parar ali é o jeito mais fácil de exagerar. O recibo de
|
|
155
|
+
um reembolso sai assim:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
ESTADO VERIFIED
|
|
159
|
+
CONTAGEM pedidos 1 · confirmados 1 · falhos 0 · incertos 0
|
|
160
|
+
COBERTURA PARTIAL
|
|
161
|
+
⚠️ SEM COBERTURA `cardholder.credit_received` — ninguém sabe avaliar isso
|
|
162
|
+
QUANTO PROVA PROVIDER_STATE · SAME_SOURCE_REREAD · PROVISIONAL
|
|
163
|
+
⚠️ EXIGE RECONCILIAÇÃO — esta conclusão tem prazo e ninguém voltou a olhar
|
|
164
|
+
NOTA a Stripe confirma o REGISTRO do reembolso; a chegada do dinheiro
|
|
165
|
+
ao portador do cartão NÃO foi verificada
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Quatro perguntas, quatro respostas, nenhuma inflando a outra:
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
o que deveria acontecer? intenção + efeito autorizado
|
|
172
|
+
o que conseguimos observar? estado + contagem
|
|
173
|
+
quanto a evidência prova? assurance
|
|
174
|
+
o que ficou FORA da cobertura? coverage
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**`assurance` tem três eixos, e não vira um número.** *O que* foi provado (o
|
|
178
|
+
registro no provedor ou a consequência no destinatário), *de onde* veio a
|
|
179
|
+
evidência (o próprio executor ou um terceiro), e *se ainda pode mudar*. Um
|
|
180
|
+
reembolso da Stripe vai de `succeeded` para `failed` — eles fornecem cenário
|
|
181
|
+
de teste para simular. `nivel = 3` destruiria as três dimensões, pelo mesmo
|
|
182
|
+
motivo que `executed: true` destruía invocação, efeito e verificação.
|
|
183
|
+
|
|
184
|
+
**`coverage` é capacidade declarada, não resultado de execução.** O contrato
|
|
185
|
+
diz quais afirmações a intenção exige; o verificador diz quais sabe avaliar.
|
|
186
|
+
Se a fonte cai, a cobertura **não muda** — o verificador continua sabendo o
|
|
187
|
+
que sabia, só não estabeleceu nada naquela rodada. E as lacunas são nominais,
|
|
188
|
+
nunca percentuais: `3 de 4 = 75%` parece ótimo até alguém notar que a quarta
|
|
189
|
+
era "o dinheiro chegou no cliente".
|
|
190
|
+
|
|
191
|
+
⚠️ **Três coisas que nunca colapsam**, e é aqui que este eixo se paga:
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
SEM COBERTURA não existe quem avalie → buraco de PRODUTO
|
|
195
|
+
UNVERIFIABLE existe, e não deu nesta rodada → problema de INFRA
|
|
196
|
+
FAILED existe, consultou, e contradiz → INCIDENTE
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
📌 E o melhor efeito é o que ninguém precisa pedir: quando alguém fortalece o
|
|
200
|
+
contrato — acrescenta `cardholder.credit_received` às exigidas — o verificador
|
|
201
|
+
**passa a acusar a lacuna sozinho, sem uma linha alterada**. A biblioteca diz,
|
|
202
|
+
sem ninguém perguntar: *o modelo de intenção ficou mais forte que a capacidade
|
|
203
|
+
de prova.*
|
|
204
|
+
|
|
205
|
+
⚠️ O que ainda NÃO existe: `PROVISIONAL` **descreve** que a conclusão tem
|
|
206
|
+
prazo, e nada volta a olhar. A reconciliação é um mecanismo que não foi
|
|
207
|
+
construído — o campo torna a dívida visível, não resolvida.
|
|
208
|
+
|
|
209
|
+
## Decisões de projeto, e por quê
|
|
210
|
+
|
|
211
|
+
**`observe` é o padrão.** Ninguém coloca um fornecedor desconhecido no caminho
|
|
212
|
+
crítico de uma operação que mexe com dinheiro. Em observe, a Actrova registra o
|
|
213
|
+
veredito e **não interrompe nada** — rodando semanas assim se descobre quais
|
|
214
|
+
políticas importam antes de deixar alguma parar a operação.
|
|
215
|
+
|
|
216
|
+
**Nenhuma dependência de nuvem para executar.** Contrato é arquivo local,
|
|
217
|
+
avaliação é em processo, recibo é arquivo local. Se a internet cair — ou se a
|
|
218
|
+
Actrova sumir amanhã — a decisão continua acontecendo na máquina do cliente.
|
|
219
|
+
Mesmo desenho de OPA e Cedar: *data plane* local, *control plane* remoto.
|
|
220
|
+
|
|
221
|
+
**Recibo é encadeado por hash.** Log que o fornecedor consegue editar não é
|
|
222
|
+
prova; é a palavra do fornecedor, formatada. Cada recibo carrega o hash do
|
|
223
|
+
anterior, e alterar um do meio quebra todos os seguintes — detectável por
|
|
224
|
+
qualquer um, sem confiar na gente.
|
|
225
|
+
|
|
226
|
+
> ⚠️ **Tamper-evident, não tamper-proof.** Quem tem acesso de escrita pode
|
|
227
|
+
> editar um recibo do meio e **recalcular a cadeia inteira** a partir dali; aí
|
|
228
|
+
> ela volta a fechar. A cadeia prova consistência interna e pega alteração,
|
|
229
|
+
> remoção, reordenação e corrupção — não pega reescrita completa. Fechar isso
|
|
230
|
+
> exige assinar a cabeça da cadeia (`Witness / Anchor`, não construído). Até
|
|
231
|
+
> lá a frase honesta é *"toda alteração deixa marca"*, nunca *"ninguém
|
|
232
|
+
> consegue alterar"*.
|
|
233
|
+
|
|
234
|
+
**O livro é a verdade; a fila de verificação é uma projeção.** O recibo da
|
|
235
|
+
ação carrega o plano inteiro — quem confere, contra qual asserção, quantas
|
|
236
|
+
tentativas — então `reconciliar()` reconstrói a fila a partir do livro. Apagar
|
|
237
|
+
`fila.json`, trocar de máquina ou restaurar um backup não faz a Actrova dizer
|
|
238
|
+
"não há nada pendente" quando a verdade é "perdi a lista".
|
|
239
|
+
|
|
240
|
+
**Um escritor por vez no livro.** `flock` segurado do "ler o último recibo"
|
|
241
|
+
até o "escrever o próximo". Sem isso, dois processos gravam com o mesmo `prev`
|
|
242
|
+
e a cadeia passa a acusar adulteração onde houve concorrência — e cadeia que
|
|
243
|
+
grita lobo perde o valor de evidência.
|
|
244
|
+
|
|
245
|
+
**Verificação não altera o recibo da ação.** Ela é deferida (reembolso demora a
|
|
246
|
+
liquidar, ERP sincroniza em lote), então anexa-se um recibo novo apontando para
|
|
247
|
+
o da ação pelo hash. Livro-razão, não linha editável.
|
|
248
|
+
|
|
249
|
+
**Invocação, efeito e verificação são três campos.** Um `executed: true`
|
|
250
|
+
sozinho junta *"a Actrova chamou o código"* com *"o mundo mudou"*, e as duas
|
|
251
|
+
respostas divergem o tempo todo: a função que se absteve, a que quebrou no
|
|
252
|
+
meio, a que devolveu 200 sem nada ter liquidado. `invoked` a Actrova sabe;
|
|
253
|
+
`effect` ela só sabe quando a fonte de verdade confirma — até lá é `UNKNOWN`,
|
|
254
|
+
e `UNKNOWN` escrito é melhor que `true` insinuado.
|
|
255
|
+
|
|
256
|
+
**A aplicação pode declarar abstenção, nunca sucesso.** Levantar `SemEfeito` é
|
|
257
|
+
a função dizendo *"fui chamada e de propósito não fiz nada"* — abstenção ela
|
|
258
|
+
conhece de dentro. Não existe contrapartida para declarar `APPLIED`: isso é a
|
|
259
|
+
fonte de verdade quem diz.
|
|
260
|
+
|
|
261
|
+
**O núcleo conhece estados; as integrações conhecem o mundo.** A Actrova não
|
|
262
|
+
implementa Stripe — implementa a gramática para você explicar como a Stripe
|
|
263
|
+
prova alguma coisa, e depois confere se a explicação obedece às invariantes:
|
|
264
|
+
|
|
265
|
+
```python
|
|
266
|
+
from actrova import conformar
|
|
267
|
+
print(conformar(MeuVerificadorStripe(), cenarios={...}).texto())
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
⚠️ A suíte **exige** o cenário `fonte_fora` e se recusa a certificar sem ele.
|
|
271
|
+
De fora, um `_consultar` que devolve `{}` numa falha é indistinguível de um
|
|
272
|
+
que devolve `{}` porque a fonte respondeu vazio — e essa confusão é o bug que
|
|
273
|
+
originou o projeto. Certificado que passa sem testar isso dá confiança onde
|
|
274
|
+
não há evidência.
|
|
275
|
+
|
|
276
|
+
**O avaliador de política é andaime.** OPA/Rego e AWS Cedar já resolvem isso, de
|
|
277
|
+
graça e melhor. O produto da Actrova é **provar o resultado**, não decidir se
|
|
278
|
+
pode. `Avaliador` é interface justamente para essa troca.
|
|
279
|
+
|
|
280
|
+
## O seu verificador mente quando a fonte cai?
|
|
281
|
+
|
|
282
|
+
Uma linha, no seu código, sem instalar a Actrova em lugar nenhum:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
python3 -m actrova conformar meu_modulo.py:MeuVerificador
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Ele já diz o que dá para afirmar sem fixture nenhuma. Para responder **a
|
|
289
|
+
pergunta que decide tudo**, monte os três cenários que só você consegue montar
|
|
290
|
+
— porque só você sabe o que faz a *sua* fonte responder cada coisa:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
python3 -m actrova exemplo > cenarios.py # esqueleto comentado, edite
|
|
294
|
+
python3 -m actrova conformar meu_modulo.py:X --cenarios cenarios.py:CENARIOS
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
O resultado que interessa é este, e é o bug que originou o projeto:
|
|
298
|
+
|
|
299
|
+
```
|
|
300
|
+
❌ cenário `fonte_fora`
|
|
301
|
+
a fonte está indisponível (rede caída, 500, timeout)
|
|
302
|
+
→ esperado um de UNVERIFIABLE, veio FAILED
|
|
303
|
+
|
|
304
|
+
fonte_fora REPROVADO — respondeu, e respondeu errado
|
|
305
|
+
resultado NÃO CONFORME — 1 invariante(s) violada(s)
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Um `except: return {}` acabou de transformar *"não consegui consultar"* em
|
|
309
|
+
*"consultei e está errado"*. De fora, os dois são idênticos — e é por isso que
|
|
310
|
+
a suíte **exige** esse cenário e se recusa a certificar sem ele.
|
|
311
|
+
|
|
312
|
+
Saídas: `0` conforme · `1` violou uma invariante · `2` sem certificado, porque
|
|
313
|
+
**não testado não é aprovado** · `3` erro de uso. As três primeiras são
|
|
314
|
+
diferentes de propósito: *"ninguém perguntou"* e *"perguntamos e ele mentiu"*
|
|
315
|
+
não podem colapsar na sua CI, pelo mesmo motivo que não podem colapsar no
|
|
316
|
+
recibo.
|
|
317
|
+
|
|
318
|
+
⚠️ E o relatório diz sozinho o que **não** afirma: quem escreveu a fixture do
|
|
319
|
+
`fonte_fora` foi a mesma pessoa que escreveu o `_consultar`. Se ela supõe que
|
|
320
|
+
a fonte levanta num 500 e a fonte devolve `{}` com HTTP 200, a conformidade é
|
|
321
|
+
sobre uma fonte que não existe. Isso é um manifesto, não um selo.
|
|
322
|
+
|
|
323
|
+
## Rodando
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
python3 teste_escopo.py # 336 asserções — o núcleo
|
|
327
|
+
python3 teste_assegura.py # 29 — os três eixos de quanto a prova prova
|
|
328
|
+
python3 teste_cobertura.py # 27 — prova de quê, e o que ficou de fora
|
|
329
|
+
python3 teste_stripe.py # 22 — o segundo domínio (pip install stripe)
|
|
330
|
+
python3 demonstracao.py # o incidente das 36 fontes, de ponta a ponta
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
Só depende de `pyyaml`. E é `python3` — em Ubuntu limpo `python` não existe.
|
|
334
|
+
|
|
335
|
+
## Estado
|
|
336
|
+
|
|
337
|
+
**v0.** Prova uma coisa só, e prova: distinguir *"o agente foi invocado"* de
|
|
338
|
+
*"o mundo mudou"* de *"o resultado foi comprovado"*, num caso real.
|
|
339
|
+
|
|
340
|
+
Deliberadamente **não** existe ainda: dashboard, login, multi-tenant, billing,
|
|
341
|
+
control plane em nuvem, SDK TypeScript, integrações genéricas, landing page.
|