Skip to content

Commit 6b984f4

Browse files
hyperpolymathclaude
andcommitted
docs(V4): design proof_attempts ↔ VQL-DT certificate integration
Proposes auto-minting PROVEN certificates (τ=0.80, n≥20) and SANCTIFY certificates (k≥2 provers, n≥50 combined) via materialized views over mv_prover_success_by_class, with evidence cursors back to attempt_ids. Uses current real-data snapshot (2026-04-05) as baseline: safety z3:0.5×4, equiv agda:1.0×5, totality idris2:0.0×5 — all below threshold, showing the loop needs to converge before certification is meaningful. Closes pending design question #22. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a0cda84 commit 6b984f4

1 file changed

Lines changed: 239 additions & 0 deletions

File tree

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
// SPDX-License-Identifier: PMPL-1.0-or-later
2+
= V4: proof_attempts ↔ VQL-DT Certificate Integration
3+
:toc: left
4+
:toclevels: 2
5+
:date: 2026-04-05
6+
:status: draft
7+
8+
== Context
9+
10+
VeriSimDB's `proof_attempts` table (ClickHouse) records every prover invocation
11+
across the hyperpolymath estate, aggregated via `mv_prover_success_by_class`
12+
into a recommendation source for `/api/v1/proof_attempts/strategy`.
13+
14+
VQL-DT has 11 proof types. Two of them — *PROVEN* and *SANCTIFY* — are
15+
currently certificate-shaped (proven_bridge parses external JSON/CBOR blobs)
16+
but have no live connection to actual prover outcomes accumulating in
17+
ClickHouse.
18+
19+
The question: how should VQL-DT `PROOF PROVEN(...)` and `PROOF SANCTIFY(...)`
20+
relate to the evidence in `proof_attempts`?
21+
22+
== Decision (proposed)
23+
24+
*Option (iii): both auto-mint certificates AND require evidence rows.*
25+
26+
Certificates are minted by a materialized view policy, not hand-authored.
27+
Every certificate references the specific `attempt_id`s that back it.
28+
29+
=== PROVEN certificate
30+
31+
A *PROVEN* certificate asserts:
32+
33+
[quote]
34+
____
35+
For obligation class `C`, prover `P` succeeds at rate ≥ `τ_proven`
36+
given ≥ `N_proven` attempts.
37+
____
38+
39+
Minting rule (computed nightly from `mv_prover_success_by_class`):
40+
41+
[source]
42+
----
43+
PROVEN(class=C, prover=P) ⟺
44+
success_count(C,P) / total_attempts(C,P) ≥ τ_proven
45+
∧ total_attempts(C,P) ≥ N_proven
46+
----
47+
48+
Defaults: `τ_proven = 0.80`, `N_proven = 20`.
49+
50+
=== SANCTIFY certificate
51+
52+
A *SANCTIFY* certificate is a higher-tier attestation requiring
53+
*portfolio agreement*:
54+
55+
[quote]
56+
____
57+
For obligation class `C`, at least `k_sanctify` distinct provers
58+
each hold a PROVEN certificate, covering ≥ `N_sanctify` combined attempts.
59+
____
60+
61+
Minting rule:
62+
63+
[source]
64+
----
65+
SANCTIFY(class=C) ⟺
66+
|{ P : PROVEN(C,P) holds }| ≥ k_sanctify
67+
∧ Σ_P total_attempts(C,P) ≥ N_sanctify
68+
----
69+
70+
Defaults: `k_sanctify = 2`, `N_sanctify = 50`.
71+
72+
== Schema
73+
74+
Add two new ClickHouse views on top of `mv_prover_success_by_class`:
75+
76+
[source,sql]
77+
----
78+
CREATE MATERIALIZED VIEW mv_proven_certificates
79+
ENGINE = ReplacingMergeTree()
80+
ORDER BY (obligation_class, prover_used)
81+
AS
82+
SELECT
83+
obligation_class,
84+
prover_used,
85+
sum(success_count) AS success_count,
86+
sum(total_attempts) AS total_attempts,
87+
sum(success_count) / sum(total_attempts) AS success_rate,
88+
now() AS minted_at,
89+
if(sum(success_count) / sum(total_attempts) >= 0.80
90+
AND sum(total_attempts) >= 20, 'proven', 'pending') AS status
91+
FROM mv_prover_success_by_class
92+
GROUP BY obligation_class, prover_used;
93+
94+
CREATE MATERIALIZED VIEW mv_sanctify_certificates
95+
ENGINE = ReplacingMergeTree()
96+
ORDER BY obligation_class
97+
AS
98+
SELECT
99+
obligation_class,
100+
count(DISTINCT prover_used) AS proven_provers,
101+
sum(total_attempts) AS combined_attempts,
102+
now() AS minted_at,
103+
if(count(DISTINCT prover_used) >= 2
104+
AND sum(total_attempts) >= 50, 'sanctified', 'pending') AS status
105+
FROM mv_proven_certificates
106+
WHERE status = 'proven'
107+
GROUP BY obligation_class;
108+
----
109+
110+
== Evidence linkage
111+
112+
Certificates must be *falsifiable* — each one carries a cursor back to the
113+
attempts that established it. Add a `proof_attempts_cert_evidence` table:
114+
115+
[source,sql]
116+
----
117+
CREATE TABLE proof_attempts_cert_evidence (
118+
cert_id String, -- sha256(cert_type|class|prover|minted_at)
119+
cert_type Enum8('proven'=1, 'sanctify'=2),
120+
obligation_class String,
121+
prover_used String,
122+
attempt_id String, -- back-reference to proof_attempts
123+
minted_at DateTime64(3)
124+
) ENGINE = MergeTree()
125+
ORDER BY (cert_id, attempt_id);
126+
----
127+
128+
A nightly job samples up to 100 `attempt_id`s per certificate as evidence
129+
(oldest + most recent + random middle — so falsifying any sample invalidates
130+
the claim).
131+
132+
== VQL surface
133+
134+
Add VQL-DT endpoints that resolve against the new MVs:
135+
136+
[source]
137+
----
138+
-- Look up whether a (class, prover) pair is certified
139+
PROOF PROVEN(class='linearity', prover='lean')
140+
→ consults mv_proven_certificates, returns status + evidence cursor
141+
142+
-- Look up whether a class is portfolio-certified
143+
PROOF SANCTIFY(class='equiv')
144+
→ consults mv_sanctify_certificates, returns proven_provers list
145+
146+
-- Query the evidence directly
147+
SELECT * FROM REFLECT
148+
WHERE cert_id = 'abc123...' AND cert_type = 'proven'
149+
→ walks proof_attempts_cert_evidence, returns attempt rows
150+
----
151+
152+
== Integration points
153+
154+
[cols="1,3"]
155+
|===
156+
| Component | Hook
157+
158+
| verisim-api
159+
| New `GET /api/v1/proof_attempts/certificates?class=X[&prover=Y]`
160+
returning certificate status + evidence cursor.
161+
162+
| hypatia proof_strategy_selection rule
163+
| Already picks top prover by `success_rate`. Augment to prefer
164+
*PROVEN-certified* pairs over uncertified ones with equal or higher
165+
success rate. Uncertified pairs fall through to novelty guard.
166+
167+
| echidnabot fleet dispatch
168+
| When dispatching, attach the (class, prover) certificate ID to the
169+
GraphQL mutation for audit trail. hypatia's ProofObligationInput already
170+
carries `prover_hint` — add optional `cert_id`.
171+
172+
| proven-library bridge
173+
| Existing `proven_bridge.rs` parses external PROVEN blobs. Extend to
174+
*emit* locally-minted blobs when an attempt crosses a threshold.
175+
176+
| VQL-DT type checker
177+
| `PROOF PROVEN(class, prover)` becomes a well-typed query against
178+
`mv_proven_certificates`. No longer requires external contract file.
179+
|===
180+
181+
== Thresholds are policy
182+
183+
`τ_proven`, `N_proven`, `k_sanctify`, `N_sanctify` live in a config table
184+
(`proof_attempts_cert_policy`), not hardcoded. One row per certificate tier.
185+
Policy changes re-compute the MVs on next materialization.
186+
187+
Default policy bootstrapped from current real data (as of 2026-04-05):
188+
189+
[cols="1,1,1,1"]
190+
|===
191+
| class | best prover | rate × n | current cert?
192+
193+
| safety | z3 | 0.5 × 4 | no (needs τ≥0.8, n≥20)
194+
| linearity | coq | 1.0 × 1 | no (needs n≥20)
195+
| termination | lean | 1.0 × 1 | no (needs n≥20)
196+
| equiv | agda | 1.0 × 5 | no (needs n≥20)
197+
| equiv | lean | 1.0 × 5 | no (needs n≥20)
198+
| totality | idris2 | 0.0 × 5 | no (fails τ)
199+
|===
200+
201+
These numbers show the evidence threshold matters: one obligation is not
202+
enough to certify a prover, but the loop can converge quickly once batch
203+
runs scale.
204+
205+
== Non-goals
206+
207+
* *Not* replacing external PROVEN contracts from the proven library.
208+
VQL-DT `PROVEN` expressions can still reference external JSON/CBOR.
209+
The new minting path is additive — it turns the estate's own proof-running
210+
behaviour into first-class evidence.
211+
* *Not* generating machine-checkable proofs from `proof_attempts` alone.
212+
A PROVEN certificate is a statistical attestation (N trials, success rate),
213+
not a Coq proof term.
214+
215+
== Implementation order
216+
217+
. Add `proof_attempts_cert_policy` config table + seed defaults (V4a)
218+
. Create `mv_proven_certificates` + `mv_sanctify_certificates` MVs (V4b)
219+
. Create `proof_attempts_cert_evidence` table + nightly sampling job (V4c)
220+
. Add `GET /api/v1/proof_attempts/certificates` endpoint (V4d)
221+
. Extend hypatia `proof_strategy_selection` to prefer certified pairs (V4e)
222+
. Update VQL-DT parser/typechecker to resolve `PROOF PROVEN(class, prover)`
223+
against the MV (V4f)
224+
. Documentation + VQL-SPEC update (V4g)
225+
226+
V4a–V4d are pure schema/endpoint work, ~1 session. V4e–V4g integrate across
227+
three repos (hypatia, verisimdb, echidna).
228+
229+
== Open questions
230+
231+
. Should PROVEN certificates *decay* if recent attempts shift the rate below
232+
`τ_proven`? Proposed: yes, use a sliding-window variant MV
233+
(`last 30 days` rather than all-time).
234+
. How do we handle certificate *revocation* — if a previously-PROVEN prover
235+
suddenly starts failing? Proposed: emit a `revoked` status alongside
236+
`proven`/`pending`.
237+
. Should failures be weighted more heavily than successes for novelty? E.g.
238+
2 failures cancel 1 success when `total_attempts < 10`. Proposed: no,
239+
keep statistics honest; policy thresholds handle this.

0 commit comments

Comments
 (0)