@crewhaus/tool-proof 0.0.0-stage → 0.8.1
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.
- package/LICENSE +201 -0
- package/NOTICE +9 -0
- package/README.md +149 -2
- package/dist/index.d.ts +148 -0
- package/dist/index.js +365 -0
- package/dist/lib/check.d.ts +122 -0
- package/dist/lib/check.js +260 -0
- package/dist/lib/checkers.d.ts +62 -0
- package/dist/lib/checkers.js +136 -0
- package/dist/lib/config.d.ts +39 -0
- package/dist/lib/config.js +71 -0
- package/dist/lib/context.d.ts +57 -0
- package/dist/lib/context.js +52 -0
- package/dist/lib/evidence.d.ts +57 -0
- package/dist/lib/evidence.js +173 -0
- package/dist/lib/preflight.d.ts +87 -0
- package/dist/lib/preflight.js +196 -0
- package/dist/lib/recheck.d.ts +31 -0
- package/dist/lib/recheck.js +47 -0
- package/dist/lib/roots.d.ts +44 -0
- package/dist/lib/roots.js +105 -0
- package/package.json +55 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
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.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
CrewHaus Factory
|
|
2
|
+
Copyright 2026 Max Meier
|
|
3
|
+
|
|
4
|
+
This product includes software developed by Max Meier
|
|
5
|
+
(operating as StudioMax — https://studiomax.io) and contributors.
|
|
6
|
+
|
|
7
|
+
The CrewHaus name and logo are trademarks of Max Meier. See
|
|
8
|
+
https://github.com/crewhaus/factory/blob/main/TRADEMARK.md for the
|
|
9
|
+
use-of-marks policy.
|
package/README.md
CHANGED
|
@@ -1,3 +1,150 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @crewhaus/tool-proof
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The tools a harness uses to prove its claims, and to check a draft answer before it sends it.
|
|
4
|
+
They are the tool surface of the provability ladder (`provability:` in a spec: cited, grounded,
|
|
5
|
+
checked, proven).
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
tools:
|
|
9
|
+
- all-proof # the tools below (also part of all-safety)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
| Tool | What it does |
|
|
13
|
+
|---|---|
|
|
14
|
+
| `ProofCheckers` | Lists the proof checkers this harness can use, in preference order: whether each can run here (and why not), and the statement language each one checks |
|
|
15
|
+
| `ProofCheck` | Runs a checker on `{ checker, claim, statement, proof }` and saves the verdict as a `prf_…` artifact. On ok the answer cites it as `[n]: proof:prf_…` |
|
|
16
|
+
| `ProvabilityPreflight` | Grades `{ draft }` with the gate's own verifier and returns the verdict, a row per claim and what to fix. Gates nothing |
|
|
17
|
+
|
|
18
|
+
Nothing here cites for the model, and nothing calls a model. A checker's verdict is the only
|
|
19
|
+
thing `ProofCheck` trusts; the preflight is the same `verifyDocument` the gate runs, over the same
|
|
20
|
+
evidence. A spec with a `provability:` block gets `ProvabilityPreflight` from the gate itself
|
|
21
|
+
(`@crewhaus/evaluation-service`), and `ProofCheckers` and `ProofCheck` too at `proven` or when its
|
|
22
|
+
`formal.checkers` is not the default. All three are bound to the gate's configuration, and any of them
|
|
23
|
+
the spec also lists in `tools:` is replaced by the bound one. The builtin instances serve a spec
|
|
24
|
+
without the block.
|
|
25
|
+
|
|
26
|
+
## Checkers
|
|
27
|
+
|
|
28
|
+
From [`@crewhaus/proof-checker`](../proof-checker), in the order `provability.formal.checkers`
|
|
29
|
+
gives (default `builtin`, `smt`), with `builtin` always appended when the list leaves it out:
|
|
30
|
+
|
|
31
|
+
- `builtin`: exact finite arithmetic and logic. No sandbox, always available.
|
|
32
|
+
- `smt`: SMT-LIB 2 checked by Z3 in a container sandbox.
|
|
33
|
+
- `lean4`: Lean 4 in a container sandbox.
|
|
34
|
+
|
|
35
|
+
The sandbox checkers are listed whenever the config names them. They get a container sandbox
|
|
36
|
+
when the run says one is wired or `CREWHAUS_SANDBOX` selects `docker` or `podman` (unset means
|
|
37
|
+
docker); under `noop`, or a value that names no backend, they show as unavailable with the
|
|
38
|
+
reason. With a sandbox, availability is the image's healthcheck, so a missing daemon or image
|
|
39
|
+
reads as unavailable with why, and the first probe may wait on a cold pull. `ProofCheck` refuses
|
|
40
|
+
an unknown or unavailable checker before anything is checked or saved.
|
|
41
|
+
|
|
42
|
+
## Artifacts and events
|
|
43
|
+
|
|
44
|
+
Every check that runs is saved, accepted or rejected, under
|
|
45
|
+
`<cwd>/.crewhaus/proofs/<spec>/artifacts/<prf_id>.json` (mode 0600, never overwritten). A
|
|
46
|
+
rejected proof is kept because it is signal: the bundle can then say why a citation of it
|
|
47
|
+
failed. A check that never finishes is saved as a rejection once it runs past `formal.timeoutMs`
|
|
48
|
+
plus `CHECK_GRACE_MS` (30 s); a cancelled call saves nothing.
|
|
49
|
+
|
|
50
|
+
On the managed shape each turn runs inside its tenant, and the tools file artifacts under the
|
|
51
|
+
tenant's own root (`<tenantRoot>/proofs/<spec>/`) and read its own sessions. A root outside the
|
|
52
|
+
tenant is refused.
|
|
53
|
+
|
|
54
|
+
Each check publishes a `proof_checked` trace event on the run's bus (`checker`, `ok`,
|
|
55
|
+
`artifactId`, `durationMs`, `axioms`) and appends the same payload to the run's session event
|
|
56
|
+
log.
|
|
57
|
+
|
|
58
|
+
## API
|
|
59
|
+
|
|
60
|
+
`createProofTools(opts?): ProofTools` builds the tools (`proofCheckers`, `proofCheck`,
|
|
61
|
+
`provabilityPreflight`, and `all`) over one configuration:
|
|
62
|
+
|
|
63
|
+
| Option | Meaning |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `config` | The lowered `provability:` block. Default: the compiler's defaults at the `grounded` floor (`defaultProvabilityConfig()`). |
|
|
66
|
+
| `specName` / `proofsRoot` | Where artifacts are filed: `<workspaceRoot>/.crewhaus/proofs/<specName>/`, or a root you name. |
|
|
67
|
+
| `workspaceRoot` | Where path sources resolve (default: `process.cwd()` at call time). |
|
|
68
|
+
| `checkers` | The checkers, in preference order. Default: `buildDefaultCheckers(config, …)`, built on first use. |
|
|
69
|
+
| `sessionRootDir` | Where session logs live, when no `evidence` is injected. Default: the run's, the tenant's, `CREWHAUS_SESSION_DIR`, `.crewhaus/sessions`. |
|
|
70
|
+
| `evidence` | `(ctx) => Promise<EvidenceIndex \| { index, turnNumbers?: Set<number> }>`: what the preflight grades against. A builder that rejects or returns anything else, or a `turnNumbers` that is not a `Set`, fails the call. Default: the run's session log, scoped by `config.scope`. |
|
|
71
|
+
| `checkTimeoutMs` | The backstop before a check is saved as a rejection (default `formal.timeoutMs + CHECK_GRACE_MS`). |
|
|
72
|
+
| `now` | Clock for `checkedAt` (tests). |
|
|
73
|
+
|
|
74
|
+
The roots are resolved on every call, for the tenant the call runs under, so one instance built
|
|
75
|
+
at boot serves every tenant of a managed daemon. Pass `specName` and `workspaceRoot` and let the
|
|
76
|
+
tools resolve the root per call, or pass a function of the tenant, such as
|
|
77
|
+
`(tenant) => defaultProofsRoot(cwd, spec, tenant)`. Do not pass a `proofsRoot` string resolved at
|
|
78
|
+
boot to a managed daemon: no tenant exists then, and a root outside the call's tenant is
|
|
79
|
+
refused, so every managed call would fail. `sessionRootDir` works the same way. The gate's
|
|
80
|
+
composition root calls `createProofTools` with the spec's block, its proofs resolver and the
|
|
81
|
+
evidence builder its verifier uses, so the gate and the tools always agree.
|
|
82
|
+
|
|
83
|
+
The exported builtin instances (`proofCheckers`, `proofCheck`, `provabilityPreflight`,
|
|
84
|
+
`PROOF_TOOLS`) are what a spec gets by listing the tools without a `provability:` block: the
|
|
85
|
+
compiler's defaults at the `grounded` floor, artifacts under `.crewhaus/proofs/default/` (a run
|
|
86
|
+
context carries no spec name), and the run's session log as evidence.
|
|
87
|
+
|
|
88
|
+
The pieces are exported for the gate and the CLI: `buildDefaultCheckers`, `defaultCheckerIds`,
|
|
89
|
+
`sandboxImages`, `listCheckers`, `probeChecker`; `runChecker`, `toArtifact`, `checkReport`;
|
|
90
|
+
`preflightBundle`, `preflightConfig`, `preflightReport`; `sessionEvidence`, `currentTurn`,
|
|
91
|
+
`startsTurn`; `proofRecheck` / `recheckProof` (the builtin checker re-running a stored builtin
|
|
92
|
+
proof, the gate's `recheckProof`); `defaultProofsRoot`, `defaultSessionRoot`, `tenantRootOf`,
|
|
93
|
+
`runtimeStateRoots` (the run's own state directories, which the gate and the preflight both
|
|
94
|
+
refuse as sources) and `STATE_ENV_VARS`; and the bounds `PROOF_INPUT_LIMITS`, `REPORT_BYTES`,
|
|
95
|
+
`DRAFT_CHARS`.
|
|
96
|
+
|
|
97
|
+
## Flags
|
|
98
|
+
|
|
99
|
+
| Tool | readOnly | concurrencySafe | destructive | requiresSandbox | scope |
|
|
100
|
+
|---|---|---|---|---|---|
|
|
101
|
+
| `ProofCheckers` | yes | yes | no | no | internal |
|
|
102
|
+
| `ProofCheck` | no | yes | yes (writes one artifact) | no | internal |
|
|
103
|
+
| `ProvabilityPreflight` | yes | yes | no | no | internal |
|
|
104
|
+
|
|
105
|
+
`ProofCheck` is not `requiresSandbox`: the builtin checker needs none, and a tool-level flag would
|
|
106
|
+
deny it on every sandbox-less harness. The sandbox checkers refuse themselves without a sandbox
|
|
107
|
+
and on the `noop` backend, so the sandbox floor applies per checker rather than per tool.
|
|
108
|
+
|
|
109
|
+
Its operative argument is `checker`, so a permission rule can scope it: `alwaysAllow
|
|
110
|
+
ProofCheck(builtin)` allows the sandbox-free checker alone. permission-engine carries that rule
|
|
111
|
+
as a builtin default, beside `alwaysAllow` for `ProofCheckers` and `ProvabilityPreflight`, so a
|
|
112
|
+
`proven` harness reaches its floor through the builtin checker without approval on every
|
|
113
|
+
surface. `smt` and `lean4` start a container and keep the mode's default (allow them with
|
|
114
|
+
`alwaysAllow ProofCheck(smt)`, `ProofCheck(lean4)`).
|
|
115
|
+
|
|
116
|
+
## Reports
|
|
117
|
+
|
|
118
|
+
Each report is small enough for the model to read whole (`REPORT_BYTES`), since the runtime shows
|
|
119
|
+
only the start of a large tool result. The verdict and what to do next come first, then the
|
|
120
|
+
details. The preflight lists unmet claims first and counts any it had no room for; the full proof
|
|
121
|
+
and output stay in the artifact.
|
|
122
|
+
|
|
123
|
+
## What the preflight does not do
|
|
124
|
+
|
|
125
|
+
It never leaves the run. Compared with the gate it skips three steps, with a note in the report
|
|
126
|
+
wherever one would have mattered:
|
|
127
|
+
|
|
128
|
+
- **HEAD requests** (`sources.resolve: head`): no URL is contacted; the draft is checked as if
|
|
129
|
+
`resolve` were `off`.
|
|
130
|
+
- **Replay** (`checked`): cited tools are not re-run; bindings read `replayed: false`.
|
|
131
|
+
- **The paraphrase judge**: never consulted. A paraphrase the gate's judge might accept shows as
|
|
132
|
+
`not_found_in_source` here, so the preflight is the stricter of the two.
|
|
133
|
+
|
|
134
|
+
It does re-check a stored builtin proof and refuse the run's own state directories as sources,
|
|
135
|
+
as the gate does.
|
|
136
|
+
|
|
137
|
+
## Tests
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
bun test src
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The suites pin the package-wide flags and bounds (`index`), run the tools through the executor
|
|
144
|
+
(`integration`), cover `ProofCheck` with the builtin checker, a scripted sandbox and plugin
|
|
145
|
+
checkers that misbehave (`check`), the listing with and without a sandbox (`checkers`), the
|
|
146
|
+
tenant fencing (`tenancy`), and the preflight's parity with the gate (`preflight`). No test needs
|
|
147
|
+
Docker; the sandbox checkers' real images are exercised by `@crewhaus/proof-checker`'s gated live
|
|
148
|
+
test.
|
|
149
|
+
|
|
150
|
+
Design: [design/0.8.0-provability-release.md](../../design/0.8.0-provability-release.md) §6.4, §7.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @crewhaus/tool-proof — the tools a harness proves claims with and checks
|
|
3
|
+
* a draft with before it answers (design/0.8.0-provability-release.md §7).
|
|
4
|
+
*
|
|
5
|
+
* ProofCheckers which proof checkers this harness can use, whether
|
|
6
|
+
* each can run here, and the language each checks
|
|
7
|
+
* ProofCheck run a checker on a proof and save the verdict as a
|
|
8
|
+
* `prf_…` artifact the `proven` rung can cite
|
|
9
|
+
* ProvabilityPreflight grade a draft with the gate's own verifier,
|
|
10
|
+
* without gating
|
|
11
|
+
*
|
|
12
|
+
* Nothing here cites for the model and nothing calls a model. A checker's
|
|
13
|
+
* exit status is the only thing `ProofCheck` trusts, and the preflight is
|
|
14
|
+
* `verifyDocument` — the function the gate calls — over the same evidence.
|
|
15
|
+
*
|
|
16
|
+
* `createProofTools` binds the three tools to one configuration: the
|
|
17
|
+
* composition root (`@crewhaus/evaluation-service`) calls it with the spec's
|
|
18
|
+
* lowered `provability:` block, so the gate and the tools agree on the
|
|
19
|
+
* floor, the checkers, the artifacts root and the evidence. The roots are
|
|
20
|
+
* resolved per call, for the tenant the call runs under: an instance built
|
|
21
|
+
* once at boot serves every tenant of a managed daemon (see
|
|
22
|
+
* {@link CreateProofToolsOptions.proofsRoot}). The exported
|
|
23
|
+
* builtin instances are what a spec gets by listing `proofCheck` (or
|
|
24
|
+
* `all-proof`) in `tools:` with no `provability:` block: the compiler's
|
|
25
|
+
* defaults at the `grounded` floor, checkers in `builtin, smt` order,
|
|
26
|
+
* artifacts under `<cwd>/.crewhaus/proofs/default/` (under the tenant's root
|
|
27
|
+
* inside a managed turn, see `./lib/roots`), and the run's own session log
|
|
28
|
+
* as evidence.
|
|
29
|
+
*
|
|
30
|
+
* Each tool is a thin wrapper over `./lib`, where the behaviour lives.
|
|
31
|
+
*/
|
|
32
|
+
import { CrewhausError } from "@crewhaus/errors";
|
|
33
|
+
import { type ProofChecker } from "@crewhaus/proof-checker";
|
|
34
|
+
import { type EvidenceIndex, type ProvabilityConfig } from "@crewhaus/provability";
|
|
35
|
+
import { type Tenant } from "@crewhaus/tenancy";
|
|
36
|
+
import type { RegisteredTool, ToolExecuteContext } from "@crewhaus/tool-catalog";
|
|
37
|
+
export { AVAILABILITY_TIMEOUT_MS, BUILTIN_ID, type CheckerListing, type DefaultCheckerDeps, buildDefaultCheckers, defaultCheckerIds, listCheckers, probeChecker, sandboxImages, } from "./lib/checkers";
|
|
38
|
+
export { CHECK_GRACE_MS, OUTPUT_CHARS, PROOF_INPUT_LIMITS, REPORT_BYTES, type RunCheckerOptions, checkReport, runChecker, toArtifact, } from "./lib/check";
|
|
39
|
+
export { DEFAULT_EXECUTION_SELECTORS, DEFAULT_FLOOR, DEFAULT_SPEC_NAME, defaultProvabilityConfig, } from "./lib/config";
|
|
40
|
+
export { type SessionEvidence, currentTurn, sessionEvidence, startsTurn } from "./lib/evidence";
|
|
41
|
+
export { DRAFT_CHARS, NOTES_BYTES, ROW_BINDINGS, TABLE_ROWS, preflightBundle, preflightConfig, preflightReport, } from "./lib/preflight";
|
|
42
|
+
export { type RecheckProofOptions, proofRecheck, recheckProof } from "./lib/recheck";
|
|
43
|
+
export { STATE_ENV_VARS, defaultProofsRoot, defaultSessionRoot, runtimeStateRoots, tenantRootOf, } from "./lib/roots";
|
|
44
|
+
/** A call the tools refuse: an unknown or unavailable checker, an artifact that could not be saved. */
|
|
45
|
+
export declare class ProofToolError extends CrewhausError {
|
|
46
|
+
readonly name = "ProofToolError";
|
|
47
|
+
constructor(message: string, cause?: unknown);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* What an injected evidence builder returns: the index alone when it is
|
|
51
|
+
* already restricted to `config.scope`, or the index with the turns
|
|
52
|
+
* `scope: turn` keeps (`VerifyOptions.turnNumbers`), which the preflight
|
|
53
|
+
* forwards to the verifier exactly as the gate does.
|
|
54
|
+
*/
|
|
55
|
+
export type ProofToolEvidence = EvidenceIndex | {
|
|
56
|
+
readonly index: EvidenceIndex;
|
|
57
|
+
readonly turnNumbers?: ReadonlySet<number>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* A directory fixed for the instance's life, or resolved on every call from
|
|
61
|
+
* the tenant the call runs under (`undefined` outside any tenant scope).
|
|
62
|
+
*/
|
|
63
|
+
export type ProofToolsRoot = string | ((tenant: Tenant | undefined) => string);
|
|
64
|
+
export type CreateProofToolsOptions = {
|
|
65
|
+
/**
|
|
66
|
+
* The lowered `provability:` block (`IrProvability`) the gate runs under.
|
|
67
|
+
* Absent: the compiler's defaults at the `grounded` floor.
|
|
68
|
+
*/
|
|
69
|
+
readonly config?: ProvabilityConfig;
|
|
70
|
+
/**
|
|
71
|
+
* Whose proofs these are: artifacts go under
|
|
72
|
+
* `<workspaceRoot>/.crewhaus/proofs/<specName>/artifacts/` (inside a
|
|
73
|
+
* tenant scope, `<tenantRoot>/proofs/<specName>/artifacts/`). Absent: the
|
|
74
|
+
* spec name the run carries, else `default`. Ignored when `proofsRoot` is set.
|
|
75
|
+
*/
|
|
76
|
+
readonly specName?: string;
|
|
77
|
+
/**
|
|
78
|
+
* The proofs root itself, for a caller that resolves it rather than naming
|
|
79
|
+
* `specName`. Inside a tenant scope the root a call resolves must lie
|
|
80
|
+
* under that tenant's root, or the call is refused (`TenancyError`).
|
|
81
|
+
*
|
|
82
|
+
* So a fixed string suits a CLI run or a single-tenant daemon only. A
|
|
83
|
+
* composition root that builds the tools once at boot and serves every
|
|
84
|
+
* tenant — a managed daemon — must NOT pass the boot-time
|
|
85
|
+
* `proofsRoot(cwd, specName)`: no tenant exists at boot, and that root
|
|
86
|
+
* fails every managed call. It either omits this (passing `specName` and
|
|
87
|
+
* `workspaceRoot`; the tools then resolve `<tenantRoot>/proofs/<spec>`
|
|
88
|
+
* per call, `<workspaceRoot>/.crewhaus/proofs/<spec>` outside a tenant),
|
|
89
|
+
* or passes a function of the call's tenant, e.g.
|
|
90
|
+
* `(tenant) => defaultProofsRoot(cwd, specName, tenant)`. The gate's own
|
|
91
|
+
* artifact and bundle stores resolve the same way, per turn —
|
|
92
|
+
* `defaultProofsRoot(cwd, specName, currentTenantContext()?.tenant)` —
|
|
93
|
+
* so a citation the tools filed resolves at the gate.
|
|
94
|
+
*/
|
|
95
|
+
readonly proofsRoot?: ProofToolsRoot;
|
|
96
|
+
/** Where path sources resolve and `.crewhaus/` lives (default: `process.cwd()` at call time). */
|
|
97
|
+
readonly workspaceRoot?: string;
|
|
98
|
+
/**
|
|
99
|
+
* The checkers, in preference order. Absent: `createDefaultCheckers` over
|
|
100
|
+
* `config.formal` with the builtin always present, the sandbox checkers
|
|
101
|
+
* given a container sandbox when one is available.
|
|
102
|
+
*/
|
|
103
|
+
readonly checkers?: ReadonlyArray<ProofChecker>;
|
|
104
|
+
/**
|
|
105
|
+
* Where session `.jsonl` logs live. Default: the run's, else the active
|
|
106
|
+
* tenant's `sessionRoot`, else `CREWHAUS_SESSION_DIR`, else
|
|
107
|
+
* `.crewhaus/sessions` — the runtime's own order. Inside a tenant scope
|
|
108
|
+
* the root a call resolves must lie under the tenant's root: as with
|
|
109
|
+
* `proofsRoot`, a shared instance omits it or passes a function of the
|
|
110
|
+
* call's tenant. Unused when `evidence` is injected.
|
|
111
|
+
*/
|
|
112
|
+
readonly sessionRootDir?: ProofToolsRoot;
|
|
113
|
+
/**
|
|
114
|
+
* The evidence a preflight grades against. Absent: the run's session log
|
|
115
|
+
* (`ctx.runContext.sessionId`), scoped by `config.scope`. The gate's
|
|
116
|
+
* composition root passes the builder its verifier uses. Under
|
|
117
|
+
* `scope: turn` the builder returns either an index already restricted to
|
|
118
|
+
* the turn, or `{ index, turnNumbers }` for the preflight to restrict the
|
|
119
|
+
* way the gate does — never a session-wide index alone, which would let
|
|
120
|
+
* an earlier turn's reading ground this turn's draft.
|
|
121
|
+
*/
|
|
122
|
+
readonly evidence?: (ctx: ToolExecuteContext | undefined) => Promise<ProofToolEvidence>;
|
|
123
|
+
/**
|
|
124
|
+
* The longest one check may take before it is saved as a rejection.
|
|
125
|
+
* Default: `config.formal.timeoutMs` + {@link CHECK_GRACE_MS}.
|
|
126
|
+
*/
|
|
127
|
+
readonly checkTimeoutMs?: number;
|
|
128
|
+
/** Clock for `checkedAt` and bundle timestamps (tests). */
|
|
129
|
+
readonly now?: () => Date;
|
|
130
|
+
};
|
|
131
|
+
export type ProofTools = {
|
|
132
|
+
readonly proofCheckers: RegisteredTool;
|
|
133
|
+
readonly proofCheck: RegisteredTool;
|
|
134
|
+
readonly provabilityPreflight: RegisteredTool;
|
|
135
|
+
/** The three tools, registration-ready. */
|
|
136
|
+
readonly all: readonly RegisteredTool[];
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Build the three proof tools over one configuration (see the module doc).
|
|
140
|
+
* Nothing is created here — no sandbox, no directory, no log read: each
|
|
141
|
+
* tool resolves what it needs on its first call.
|
|
142
|
+
*/
|
|
143
|
+
export declare function createProofTools(opts?: CreateProofToolsOptions): ProofTools;
|
|
144
|
+
export declare const proofCheckers: RegisteredTool;
|
|
145
|
+
export declare const proofCheck: RegisteredTool;
|
|
146
|
+
export declare const provabilityPreflight: RegisteredTool;
|
|
147
|
+
/** Every builtin proof tool, registration-ready. */
|
|
148
|
+
export declare const PROOF_TOOLS: readonly RegisteredTool[];
|