awprove 0.1.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.
- awprove-0.1.0/LICENSE +202 -0
- awprove-0.1.0/PKG-INFO +117 -0
- awprove-0.1.0/README.md +101 -0
- awprove-0.1.0/awprove/__init__.py +30 -0
- awprove-0.1.0/awprove/_doctor.py +201 -0
- awprove-0.1.0/awprove/assertions.py +74 -0
- awprove-0.1.0/awprove/cli.py +119 -0
- awprove-0.1.0/awprove/fixtures.py +94 -0
- awprove-0.1.0/awprove/observation.py +45 -0
- awprove-0.1.0/awprove/pin.py +103 -0
- awprove-0.1.0/awprove/proofs/example-anon.yaml +22 -0
- awprove-0.1.0/awprove/report.py +57 -0
- awprove-0.1.0/awprove/runner.py +336 -0
- awprove-0.1.0/awprove/spec.py +313 -0
- awprove-0.1.0/awprove.egg-info/PKG-INFO +117 -0
- awprove-0.1.0/awprove.egg-info/SOURCES.txt +21 -0
- awprove-0.1.0/awprove.egg-info/dependency_links.txt +1 -0
- awprove-0.1.0/awprove.egg-info/entry_points.txt +2 -0
- awprove-0.1.0/awprove.egg-info/requires.txt +5 -0
- awprove-0.1.0/awprove.egg-info/top_level.txt +1 -0
- awprove-0.1.0/pyproject.toml +29 -0
- awprove-0.1.0/setup.cfg +4 -0
- awprove-0.1.0/tests/test_awprove.py +165 -0
awprove-0.1.0/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.
|
awprove-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: awprove
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Drive a page as the real user, check what actually rendered, and get a test that goes red if it ever stops being true.
|
|
5
|
+
Author: Aither
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Keywords: acceptance,visual,browser,verification,self-testing,aitherium
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: httpx>=0.24
|
|
12
|
+
Requires-Dist: PyYAML>=6.0
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# awprove
|
|
18
|
+
|
|
19
|
+
**Drive a page as the real user, check what actually rendered, and get a test that
|
|
20
|
+
goes red if it ever stops being true.**
|
|
21
|
+
|
|
22
|
+
Every failure that enrages a user answers HTTP 200: a lock screen shown to someone
|
|
23
|
+
already signed in, an empty knowledge base, a chat panel that says "backend
|
|
24
|
+
unavailable". A route probe, a healthcheck and a unit suite all pass while the product
|
|
25
|
+
is unusable — because none of them looks at what the page *became*. And the one-off
|
|
26
|
+
script that finally catches it gets thrown away, so the same class regresses a week
|
|
27
|
+
later with nothing watching.
|
|
28
|
+
|
|
29
|
+
awprove is that loop, written down: a **proof** is a browser journey plus the truths
|
|
30
|
+
that must hold on the rendered page, and `awprove pin` turns a proof into a
|
|
31
|
+
self-testing gate so the truth can't silently regress.
|
|
32
|
+
|
|
33
|
+
## The loop
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
drive -> awprove opens an authenticated session on any AitherBrowser-shaped
|
|
37
|
+
service and walks the journey's steps (goto/click/fill/press/eval)
|
|
38
|
+
see -> it records what the page became: visible text, url, JS probes, network
|
|
39
|
+
check -> every assertion is judged against that — dom_present / dom_absent /
|
|
40
|
+
url_matches / eval_true / network_ok / a VLM question about the screenshot
|
|
41
|
+
pin -> `awprove pin` emits check_awprove_<name>.py, a gate with a --self-test
|
|
42
|
+
that fabricates a passing page and, per assertion, a page that breaks
|
|
43
|
+
exactly that assertion, and proves the verdict flips. No browser needed.
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install awprove # or, in the monorepo: pip install -e AitherOS/packages/awprove
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Use
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# offline: the proof is well-formed AND every assertion provably can fail
|
|
56
|
+
awprove check proofs/example-anon.yaml
|
|
57
|
+
|
|
58
|
+
# live: drive the journey and judge the render (exit 0 pass / 1 fail / 2 could-not-judge)
|
|
59
|
+
awprove run proofs/example-anon.yaml --browser-url https://127.0.0.1:8132
|
|
60
|
+
|
|
61
|
+
# pin it: emit a self-testing gate that fails if the truth stops being true
|
|
62
|
+
awprove pin proofs/example-anon.yaml --out .
|
|
63
|
+
python check_awprove_example_anon.py --self-test
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
A proof is a small YAML file — see [`awprove/proofs/example-anon.yaml`](awprove/proofs/example-anon.yaml):
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
name: example-anon
|
|
70
|
+
base: https://example.com
|
|
71
|
+
steps:
|
|
72
|
+
- act: goto
|
|
73
|
+
value: /
|
|
74
|
+
assert:
|
|
75
|
+
- id: the_page_renders_its_own_heading
|
|
76
|
+
describe: the visible page is the one we asked for, not an error shell
|
|
77
|
+
dom_present: "Example Domain"
|
|
78
|
+
dom_absent: "This page ran into an error"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
For a signed-in journey, add a `session:` block naming the env vars that hold the
|
|
82
|
+
auth token and user profile; awprove seeds the three truthful-session items (auth
|
|
83
|
+
cookie, user localStorage, consent) so a signed-in user is a signed-in user, not the
|
|
84
|
+
logged-out shell.
|
|
85
|
+
|
|
86
|
+
Seeds are only a claim. Set `session.verify_path` (e.g. `/api/auth/me`) and, after
|
|
87
|
+
seeding, awprove asks the app from inside the session whether it sees a signed-in
|
|
88
|
+
user: it fetches that same-origin path with the seeded cookie and bearer. Anything but
|
|
89
|
+
a 200 makes the run DEAD (exit 2, "seeded session not verified"), never FAIL, because
|
|
90
|
+
judging an anonymous page would blame the product for a broken session. The probe is
|
|
91
|
+
off by default: the path must be served by the page's own origin, and an app whose
|
|
92
|
+
auth API lives on another origin (app -> app-api) would answer its static shell's
|
|
93
|
+
404. Absolute URLs, protocol-relative `//host` paths (also spelled `/\host`), and any
|
|
94
|
+
path holding a control character or space (a browser drops a tab or newline, so
|
|
95
|
+
`/<tab>/host` is `//host`) are refused.
|
|
96
|
+
|
|
97
|
+
A `vision_question` assertion needs an eye: pass `--vision-url` (or set
|
|
98
|
+
`AWPROVE_VISION_URL`) to an endpoint that takes `{"image", "prompt"}` and answers
|
|
99
|
+
with `answer`/`description`/`text`. With none configured, or when it fails, the run
|
|
100
|
+
is DEAD rather than silently passed.
|
|
101
|
+
|
|
102
|
+
## Why it's a client, not a service
|
|
103
|
+
|
|
104
|
+
awprove drives any **AitherBrowser-shaped** browser service over HTTP and imports
|
|
105
|
+
nothing from the platform, so it pip-installs and runs on a stranger's machine. The
|
|
106
|
+
browser engine (the fleet's AitherBrowser, or a local Obscura) is the organ; awprove
|
|
107
|
+
is the loop. Same move as `awrelay` (a relay client, not the relay service).
|
|
108
|
+
|
|
109
|
+
## Design note: why the engine can self-test
|
|
110
|
+
|
|
111
|
+
An assertion is a **pure function of an Observation** (`awprove.assertions.evaluate`).
|
|
112
|
+
That is the whole trick: the exact predicate that gates production runs against a
|
|
113
|
+
*fabricated* Observation — a good one and a broken one — with no browser, no network
|
|
114
|
+
and no flake. So every generated gate carries a real `--self-test`, and the engine
|
|
115
|
+
itself is gated by `check_awprove_engine.py` (AWP001/AWP002).
|
|
116
|
+
|
|
117
|
+
Apache-2.0.
|
awprove-0.1.0/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# awprove
|
|
2
|
+
|
|
3
|
+
**Drive a page as the real user, check what actually rendered, and get a test that
|
|
4
|
+
goes red if it ever stops being true.**
|
|
5
|
+
|
|
6
|
+
Every failure that enrages a user answers HTTP 200: a lock screen shown to someone
|
|
7
|
+
already signed in, an empty knowledge base, a chat panel that says "backend
|
|
8
|
+
unavailable". A route probe, a healthcheck and a unit suite all pass while the product
|
|
9
|
+
is unusable — because none of them looks at what the page *became*. And the one-off
|
|
10
|
+
script that finally catches it gets thrown away, so the same class regresses a week
|
|
11
|
+
later with nothing watching.
|
|
12
|
+
|
|
13
|
+
awprove is that loop, written down: a **proof** is a browser journey plus the truths
|
|
14
|
+
that must hold on the rendered page, and `awprove pin` turns a proof into a
|
|
15
|
+
self-testing gate so the truth can't silently regress.
|
|
16
|
+
|
|
17
|
+
## The loop
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
drive -> awprove opens an authenticated session on any AitherBrowser-shaped
|
|
21
|
+
service and walks the journey's steps (goto/click/fill/press/eval)
|
|
22
|
+
see -> it records what the page became: visible text, url, JS probes, network
|
|
23
|
+
check -> every assertion is judged against that — dom_present / dom_absent /
|
|
24
|
+
url_matches / eval_true / network_ok / a VLM question about the screenshot
|
|
25
|
+
pin -> `awprove pin` emits check_awprove_<name>.py, a gate with a --self-test
|
|
26
|
+
that fabricates a passing page and, per assertion, a page that breaks
|
|
27
|
+
exactly that assertion, and proves the verdict flips. No browser needed.
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install awprove # or, in the monorepo: pip install -e AitherOS/packages/awprove
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Use
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# offline: the proof is well-formed AND every assertion provably can fail
|
|
40
|
+
awprove check proofs/example-anon.yaml
|
|
41
|
+
|
|
42
|
+
# live: drive the journey and judge the render (exit 0 pass / 1 fail / 2 could-not-judge)
|
|
43
|
+
awprove run proofs/example-anon.yaml --browser-url https://127.0.0.1:8132
|
|
44
|
+
|
|
45
|
+
# pin it: emit a self-testing gate that fails if the truth stops being true
|
|
46
|
+
awprove pin proofs/example-anon.yaml --out .
|
|
47
|
+
python check_awprove_example_anon.py --self-test
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
A proof is a small YAML file — see [`awprove/proofs/example-anon.yaml`](awprove/proofs/example-anon.yaml):
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
name: example-anon
|
|
54
|
+
base: https://example.com
|
|
55
|
+
steps:
|
|
56
|
+
- act: goto
|
|
57
|
+
value: /
|
|
58
|
+
assert:
|
|
59
|
+
- id: the_page_renders_its_own_heading
|
|
60
|
+
describe: the visible page is the one we asked for, not an error shell
|
|
61
|
+
dom_present: "Example Domain"
|
|
62
|
+
dom_absent: "This page ran into an error"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
For a signed-in journey, add a `session:` block naming the env vars that hold the
|
|
66
|
+
auth token and user profile; awprove seeds the three truthful-session items (auth
|
|
67
|
+
cookie, user localStorage, consent) so a signed-in user is a signed-in user, not the
|
|
68
|
+
logged-out shell.
|
|
69
|
+
|
|
70
|
+
Seeds are only a claim. Set `session.verify_path` (e.g. `/api/auth/me`) and, after
|
|
71
|
+
seeding, awprove asks the app from inside the session whether it sees a signed-in
|
|
72
|
+
user: it fetches that same-origin path with the seeded cookie and bearer. Anything but
|
|
73
|
+
a 200 makes the run DEAD (exit 2, "seeded session not verified"), never FAIL, because
|
|
74
|
+
judging an anonymous page would blame the product for a broken session. The probe is
|
|
75
|
+
off by default: the path must be served by the page's own origin, and an app whose
|
|
76
|
+
auth API lives on another origin (app -> app-api) would answer its static shell's
|
|
77
|
+
404. Absolute URLs, protocol-relative `//host` paths (also spelled `/\host`), and any
|
|
78
|
+
path holding a control character or space (a browser drops a tab or newline, so
|
|
79
|
+
`/<tab>/host` is `//host`) are refused.
|
|
80
|
+
|
|
81
|
+
A `vision_question` assertion needs an eye: pass `--vision-url` (or set
|
|
82
|
+
`AWPROVE_VISION_URL`) to an endpoint that takes `{"image", "prompt"}` and answers
|
|
83
|
+
with `answer`/`description`/`text`. With none configured, or when it fails, the run
|
|
84
|
+
is DEAD rather than silently passed.
|
|
85
|
+
|
|
86
|
+
## Why it's a client, not a service
|
|
87
|
+
|
|
88
|
+
awprove drives any **AitherBrowser-shaped** browser service over HTTP and imports
|
|
89
|
+
nothing from the platform, so it pip-installs and runs on a stranger's machine. The
|
|
90
|
+
browser engine (the fleet's AitherBrowser, or a local Obscura) is the organ; awprove
|
|
91
|
+
is the loop. Same move as `awrelay` (a relay client, not the relay service).
|
|
92
|
+
|
|
93
|
+
## Design note: why the engine can self-test
|
|
94
|
+
|
|
95
|
+
An assertion is a **pure function of an Observation** (`awprove.assertions.evaluate`).
|
|
96
|
+
That is the whole trick: the exact predicate that gates production runs against a
|
|
97
|
+
*fabricated* Observation — a good one and a broken one — with no browser, no network
|
|
98
|
+
and no flake. So every generated gate carries a real `--self-test`, and the engine
|
|
99
|
+
itself is gated by `check_awprove_engine.py` (AWP001/AWP002).
|
|
100
|
+
|
|
101
|
+
Apache-2.0.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""awprove — Aither World Prove.
|
|
2
|
+
|
|
3
|
+
Drive a page as the real user, check what actually rendered, and get a test that
|
|
4
|
+
goes red if it ever stops being true.
|
|
5
|
+
|
|
6
|
+
The loop this session ran by hand, generalized: a *proof* is a journey (acts on a
|
|
7
|
+
real browser) plus the truths that must hold on the rendered page — the failures an
|
|
8
|
+
HTTP 200 hides, like a lock screen shown to a signed-in user or an empty knowledge
|
|
9
|
+
base. `run` drives any AitherBrowser-shaped service and judges the result; `pin`
|
|
10
|
+
emits a self-testing gate so the truth can't silently regress.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from .assertions import AssertionResult, evaluate, evaluate_all
|
|
16
|
+
from .fixtures import break_assertion, passing_observation
|
|
17
|
+
from .observation import Observation
|
|
18
|
+
from .pin import gate_name, synthesize_gate
|
|
19
|
+
from .report import ProofReport
|
|
20
|
+
from .runner import judge, run
|
|
21
|
+
from .spec import Assertion, Proof, ProofError, Step, load_proof
|
|
22
|
+
|
|
23
|
+
__version__ = "0.1.0"
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"Assertion", "AssertionResult", "Observation", "Proof", "ProofError",
|
|
27
|
+
"ProofReport", "Step", "break_assertion", "evaluate", "evaluate_all",
|
|
28
|
+
"gate_name", "judge", "load_proof", "passing_observation", "run",
|
|
29
|
+
"synthesize_gate", "__version__",
|
|
30
|
+
]
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"""Stack-aware `doctor` for awprove.
|
|
2
|
+
|
|
3
|
+
GENERATED BY gen_aw_doctor.py -- DO NOT EDIT.
|
|
4
|
+
Regenerate it with the generator named above; a hand-edit here is reverted by
|
|
5
|
+
the next run and fails the parity gate.
|
|
6
|
+
|
|
7
|
+
Why a doctor exists at all: the aw* bricks are designed to COMPOSE, so the
|
|
8
|
+
interesting failures live BETWEEN them. "awprove is installed" is not the useful
|
|
9
|
+
fact -- "awprove is installed and the thing it pairs with is not" is. This reports
|
|
10
|
+
the whole stack, not just itself.
|
|
11
|
+
|
|
12
|
+
stdlib only, on purpose: a diagnostic that cannot run because a dependency is
|
|
13
|
+
missing is worthless precisely when you need it.
|
|
14
|
+
"""
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import importlib.util
|
|
18
|
+
import os
|
|
19
|
+
import shutil
|
|
20
|
+
import sys
|
|
21
|
+
|
|
22
|
+
#: Frozen from the Aither World registry at generation time. A shipped
|
|
23
|
+
#: package cannot read the registry, and a doctor that guessed at the family
|
|
24
|
+
#: would go stale in silence. Regenerate to update.
|
|
25
|
+
SELF = 'awprove'
|
|
26
|
+
FAMILY = [
|
|
27
|
+
'awask', 'awavatar', 'awbac', 'awbrain', 'awbrowse', 'awcams', 'awclassify', 'awdecide',
|
|
28
|
+
'awdeck', 'awdelphi', 'awdit', 'awembed', 'awevolve', 'awfind', 'awflow', 'awfocus', 'awgit',
|
|
29
|
+
'awgraph', 'awgym', 'awiam', 'awkno', 'awm', 'awmail', 'awmine', 'awnboard', 'awnest', 'awnet',
|
|
30
|
+
'awplay', 'awpool', 'awpredict', 'awprism', 'awreason', 'awrecover', 'awrecurse', 'awrelay',
|
|
31
|
+
'awrena', 'awrepl', 'awreport', 'awresearch', 'awrise', 'awrouter', 'awrtifact', 'awrun',
|
|
32
|
+
'awscope', 'awscreen', 'awseal', 'awsettings', 'awshare', 'awsprite', 'awstorage', 'awsuite',
|
|
33
|
+
'awswarm', 'awtax', 'awtoll', 'awtunnel', 'awvision', 'awvoice', 'awwall', 'gawbbonet',
|
|
34
|
+
]
|
|
35
|
+
PAIRS_WITH = ['awbrowse', 'adk', 'awscreen', 'awvision']
|
|
36
|
+
|
|
37
|
+
#: This brick's OWN config, read out of its source at generation time.
|
|
38
|
+
#: ENV_REQUIRED is `os.environ["X"]` -- absent, that is a KeyError the moment
|
|
39
|
+
#: the line runs. ENV_OPTIONAL is `os.getenv("X")`, which returns None and lets
|
|
40
|
+
#: the caller cope. Only this brick's namespace is listed: reporting the
|
|
41
|
+
#: platform-wide vars it also touches would be noise, and a doctor that floods
|
|
42
|
+
#: gets ignored.
|
|
43
|
+
ENV_REQUIRED = []
|
|
44
|
+
ENV_OPTIONAL = [
|
|
45
|
+
'AWPROVE_BROWSER_CA', 'AWPROVE_BROWSER_HEADERS', 'AWPROVE_BROWSER_INSECURE',
|
|
46
|
+
'AWPROVE_BROWSER_URL', 'AWPROVE_VISION_URL',
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _installed(mod: str) -> "str | None":
|
|
51
|
+
"""Version if importable, else None. Never raises -- a broken sibling must
|
|
52
|
+
not take the diagnostic down with it."""
|
|
53
|
+
try:
|
|
54
|
+
if importlib.util.find_spec(mod) is None:
|
|
55
|
+
return None
|
|
56
|
+
except (ImportError, ValueError):
|
|
57
|
+
return None
|
|
58
|
+
try:
|
|
59
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
60
|
+
try:
|
|
61
|
+
return version(mod)
|
|
62
|
+
except PackageNotFoundError:
|
|
63
|
+
return "installed"
|
|
64
|
+
except Exception:
|
|
65
|
+
return "installed"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def report(out=None) -> int:
|
|
69
|
+
"""Print the stack picture. 0 = this brick and its pairs are present."""
|
|
70
|
+
out = out or sys.stdout
|
|
71
|
+
print(f"{SELF} doctor", file=out)
|
|
72
|
+
|
|
73
|
+
mine = _installed(SELF)
|
|
74
|
+
print(f" self {SELF} {mine or 'NOT IMPORTABLE'}", file=out)
|
|
75
|
+
shim = shutil.which(SELF)
|
|
76
|
+
print(f" command {shim or 'not on PATH'}", file=out)
|
|
77
|
+
|
|
78
|
+
# The stack. Siblings this brick pairs with are called out separately,
|
|
79
|
+
# because a missing pair is a REASON, while a missing unrelated brick is
|
|
80
|
+
# just a fact about your machine.
|
|
81
|
+
missing_pairs, present = [], []
|
|
82
|
+
for name in FAMILY:
|
|
83
|
+
v = _installed(name)
|
|
84
|
+
if v:
|
|
85
|
+
present.append(name)
|
|
86
|
+
elif name in PAIRS_WITH:
|
|
87
|
+
missing_pairs.append(name)
|
|
88
|
+
print(f" stack {len(present)}/{len(FAMILY)} aw* packages installed",
|
|
89
|
+
file=out)
|
|
90
|
+
if present:
|
|
91
|
+
print(f" {' '.join(sorted(present))}", file=out)
|
|
92
|
+
|
|
93
|
+
missing_req = [v for v in ENV_REQUIRED if not os.environ.get(v)]
|
|
94
|
+
if ENV_REQUIRED or ENV_OPTIONAL:
|
|
95
|
+
have = sum(1 for v in ENV_REQUIRED + ENV_OPTIONAL if os.environ.get(v))
|
|
96
|
+
total = len(ENV_REQUIRED) + len(ENV_OPTIONAL)
|
|
97
|
+
print(f" config {have}/{total} of this brick's own vars set", file=out)
|
|
98
|
+
if missing_req:
|
|
99
|
+
# Not a preference. os.environ[...] raises the moment it runs.
|
|
100
|
+
print(f" MISSING REQUIRED: {' '.join(missing_req)}", file=out)
|
|
101
|
+
|
|
102
|
+
local = _local_checks()
|
|
103
|
+
for line in local:
|
|
104
|
+
print(f" {line}", file=out)
|
|
105
|
+
problems, unjudged = _local_verdict()
|
|
106
|
+
|
|
107
|
+
if mine is None:
|
|
108
|
+
print(f"\nverdict: {SELF} itself is not importable. Reinstall it before "
|
|
109
|
+
f"anything else here means much.", file=out)
|
|
110
|
+
return 1
|
|
111
|
+
if missing_req:
|
|
112
|
+
print(f"\nverdict: {SELF} is missing required config "
|
|
113
|
+
f"({', '.join(missing_req)}). Those are read with os.environ[...], "
|
|
114
|
+
f"so the code path that needs them raises rather than degrades.",
|
|
115
|
+
file=out)
|
|
116
|
+
return 1
|
|
117
|
+
# A measured NO outranks a missing optional pair: awrise printed
|
|
118
|
+
# "nothing wakes run-due" and still exited 0 because the missing-pairs
|
|
119
|
+
# branch returned first (measured 2026-09-20).
|
|
120
|
+
if problems:
|
|
121
|
+
for p in problems:
|
|
122
|
+
print(f"\nverdict: {p}", file=out)
|
|
123
|
+
return 1
|
|
124
|
+
if unjudged:
|
|
125
|
+
for u in unjudged:
|
|
126
|
+
print(f"\nverdict: UNJUDGED -- could not judge: {u}", file=out)
|
|
127
|
+
return 2
|
|
128
|
+
if missing_pairs:
|
|
129
|
+
print(f"\nverdict: {SELF} works, but pairs with "
|
|
130
|
+
f"{', '.join(sorted(missing_pairs))} which "
|
|
131
|
+
f"{'is' if len(missing_pairs) == 1 else 'are'} not installed. "
|
|
132
|
+
f"That is a capability you are missing, not an error.", file=out)
|
|
133
|
+
return 0
|
|
134
|
+
print(f"\nverdict: {SELF} and everything it pairs with are present.", file=out)
|
|
135
|
+
return 0
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _local_verdict() -> tuple:
|
|
139
|
+
"""The brick's OWN verdict, folded into the exit code.
|
|
140
|
+
|
|
141
|
+
Without this the local lines are DECORATION. Measured 2026-09-20: awrise
|
|
142
|
+
printed "hostclock NOT INSTALLED -- nothing wakes run-due" and "last tick
|
|
143
|
+
never", then exited 0 -- teaching an operator that a doctor exit code
|
|
144
|
+
carries no information. A brick opts in with `_doctor_local_verdict()`
|
|
145
|
+
returning (problems, unjudged); a brick without one is unaffected.
|
|
146
|
+
"""
|
|
147
|
+
try:
|
|
148
|
+
mod = importlib.import_module(f"{SELF}.doctor_local")
|
|
149
|
+
problems, unjudged = mod._doctor_local_verdict()
|
|
150
|
+
except Exception: # noqa: BLE001
|
|
151
|
+
return [], []
|
|
152
|
+
return list(problems or []), list(unjudged or [])
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def _local_checks() -> "list[str]":
|
|
156
|
+
"""Per-brick checks, if this package defines them.
|
|
157
|
+
|
|
158
|
+
Kept as a HOOK rather than generated guesses: the generator knows the family
|
|
159
|
+
from the registry, but it does not know what awprove needs at runtime, and a
|
|
160
|
+
doctor that invented config requirements would be confidently wrong. A
|
|
161
|
+
package supplies `_doctor_local()` returning display lines; absent, the
|
|
162
|
+
stack picture above still stands on its own.
|
|
163
|
+
"""
|
|
164
|
+
try:
|
|
165
|
+
mod = importlib.import_module(f"{SELF}.doctor_local")
|
|
166
|
+
except Exception:
|
|
167
|
+
return []
|
|
168
|
+
try:
|
|
169
|
+
return list(mod._doctor_local())
|
|
170
|
+
except Exception as exc: # noqa: BLE001
|
|
171
|
+
return [f"local checks raised {type(exc).__name__}: {exc}"]
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def main(argv: "list[str] | None" = None) -> int:
|
|
175
|
+
# --self-test delegates to a SIBLING module when one exists.
|
|
176
|
+
#
|
|
177
|
+
# This file is generated and a fresh run replaces it, so a self-test
|
|
178
|
+
# written HERE is deleted by the next regeneration. awdelphi learned that
|
|
179
|
+
# the expensive way: 125 lines exercising four real failure paths --
|
|
180
|
+
# convergence, roster anonymization, resume, gateway-down -- lived in this
|
|
181
|
+
# file and were destroyed by a routine regeneration, silently, leaving a
|
|
182
|
+
# --self-test flag that reported PASS while asserting nothing.
|
|
183
|
+
#
|
|
184
|
+
# So the seam is a separate module the generator never writes. A package
|
|
185
|
+
# with real machinery to prove puts it in _selftest.py; everything else
|
|
186
|
+
# keeps the honest answer below rather than a self-test that only ever
|
|
187
|
+
# passes.
|
|
188
|
+
argv = list(argv if argv is not None else __import__("sys").argv[1:])
|
|
189
|
+
if "--self-test" in argv:
|
|
190
|
+
try:
|
|
191
|
+
from . import _selftest as _st
|
|
192
|
+
except Exception:
|
|
193
|
+
print("no _selftest module: this doctor reports the stack, and has",
|
|
194
|
+
"no machinery of its own to prove")
|
|
195
|
+
return 0
|
|
196
|
+
return int(_st.run())
|
|
197
|
+
return report()
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
if __name__ == "__main__":
|
|
201
|
+
raise SystemExit(main())
|