feat(formal): verify + wire Rows.v (P-11 record-row soundness)#648
Merged
Conversation
Rows.v landed in #639 as an explicitly-UNVERIFIED scaffold because the authoring container had no Coq toolchain. Installed Coq 8.18.0 (OCaml 4.14.1, the repo's pinned toolchain) and verified it: coqc -Q . ASFormal Rows.v -> clean Print Assumptions progress / preservation -> "Closed under the global context" (axiom-free, no Admitted) The hand-written proofs compiled first try. So promote the scaffold to a real, wired obligation: * formal/_CoqProject + formal/justfile `check`: add Rows (the recipe fails on any axiom/Admitted, so this now gates Rows too). * formal/Rows.v: replace the UNVERIFIED banner with the verified/wired note; drop the stale "Target:"/"lift into Siblings_Stated" wording. * formal/README.adoc: contents-table row + a "Record rows (P-11)" section. * docs/PROOF-NEEDS.adoc: new P-11 obligation row (mechanized); refresh the Coq-core counts to 18 files / 31 Print-Assumptions reports (also corrects the long-stale "13 files" intro line). * .hypatia-ignore: de-stale the Rows.v comment (now mechanized + wired). Full track re-verified end to end: 18 files, 31 closure reports, zero axioms. dune build clean; soundness-ledger gate green (SOUNDNESS.adoc untouched). Scope unchanged: Wave W0 (monomorphic extensible records); row-*variable* polymorphism is the W1 increment (P-11 row notes it). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BbxKhXQwTvVgkYDgBMLJoa
🔍 Hypatia Security ScanFindings: 41 issues detected
View findings[
{
"reason": "Action denoland/setup-deno@v2 needs attention",
"type": "unpinned_action",
"file": "publish-jsr.yml",
"action": "pin_sha",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in instant-sync.yml",
"type": "secret_action_without_presence_gate",
"file": "instant-sync.yml",
"action": "peter-evans/repository-dispatch",
"rule_module": "workflow_audit",
"severity": "high"
},
{
"reason": "Shell execution -- validate input before passing to shell (1 occurrences, CWE-78)",
"type": "js_exec_sync",
"file": "/home/runner/work/affinescript/affinescript/packages/affinescript-cli/mod.js",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
},
{
"reason": "Shell execution -- validate input before passing to shell (2 occurrences, CWE-78)",
"type": "js_exec_sync",
"file": "/home/runner/work/affinescript/affinescript/packages/affine-vscode/mod.js",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
},
{
"reason": "Shell execution -- validate input before passing to shell (1 occurrences, CWE-78)",
"type": "js_exec_sync",
"file": "/home/runner/work/affinescript/affinescript/affinescript-vite/src/affine-plugin-improved.js",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
},
{
"reason": "expect() in hot path (32 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/affinescript/affinescript/affinescriptiser/src/codegen/wasm_gen.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
},
{
"reason": "expect() in hot path (29 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/affinescript/affinescript/affinescriptiser/src/codegen/affine_gen.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
},
{
"reason": "unsafe block -- requires SAFETY comment (2 occurrences, CWE-676)",
"type": "unsafe_block",
"file": "/home/runner/work/affinescript/affinescript/runtime/src/panic.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
},
{
"reason": "unsafe block -- requires SAFETY comment (1 occurrences, CWE-676)",
"type": "unsafe_block",
"file": "/home/runner/work/affinescript/affinescript/runtime/src/alloc.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
},
{
"reason": "unsafe block -- requires SAFETY comment (3 occurrences, CWE-676)",
"type": "unsafe_block",
"file": "/home/runner/work/affinescript/affinescript/runtime/src/ffi.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
}
]Powered by Hypatia Neurosymbolic CI/CD Intelligence |
hyperpolymath
added a commit
that referenced
this pull request
Jun 27, 2026
…xec) (#664) Third rung of the real lift (`formal/REAL-LIFT.adoc`). Adds **structured control** to the real target IR + source core, and shows the compiler-correctness simulation still holds across a conditional. Axiom-free throughout. ## What landed **Target IR (`formal/RealWasm.v`)** - New instruction `IfElse (thn els : list instr)` — `lib/wasm.ml`'s `If` minus the `block_type` validation annotation. - Because `instr` now nests `list instr`, a *structural* `wexec` is rejected by Coq's guard checker ("cannot guess decreasing argument" — the recursive call descends into a branch sub-list, not the tail). So `wexec` becomes **fuel-indexed** (decreasing on a `nat`), exactly as `REAL-LIFT.adoc` anticipated for R2. Fuel keeps *definitional* computation, so `cbn` / `reflexivity` / the demos still evaluate. - Fuel breaks the old one-line `wexec_seq` (per-cons decrement ⇒ `wexec (is1++is2) ≠ wexec is2 ∘ wexec is1`). Recovered with: - `wexec_le_S` / `wexec_mono` — more fuel never loses a `Some` result; - `wexec_app_some` — additive sequencing: run `is1` with `f1`, then `is2` with `f2`, get `is1++is2` with `f1+f2` (the fuel-world replacement for `wexec_seq`); - `wexec_S_cons` / `wexec_ifelse` — one-step unfold lemmas (by `reflexivity`) used via `rewrite` so `cbn` doesn't over-reduce the `IfElse` branch run. **Source core (`formal/RealCompile.v`)** - New `RIf (c thn els : rexpr)`; `eval` branches on `Z.eqb vc 0`; `compile` emits `compile c ++ [IfElse (compile thn) (compile els)]`. - `compile_correct` restated **existential-in-fuel**: `exists fuel locals', wexec fuel (compile d e) locals st = Some (locals', v :: st) /\ …` (env↔locals agreement + low-slot preservation unchanged). The `RIf` case opens with `change (compile d (RIf …)) with (… ++ [IfElse …])` to expose the `++` while keeping inner compiles named, then discharges via `wexec_app_some` + `wexec_le_S`. - `wexec_sound` retired in this fuel refactor — it was a convenience soundness restatement, not load-bearing for `compile_correct`. ## Verification `coqc` 8.18, whole `formal/` track re-audited after rebasing onto current `main` (incl. #648's now-wired `Rows.v`): - **18 files compile**, **31 `Print Assumptions` reports**, every one *"Closed under the global context"* — **zero axioms, no `Admitted`**. ## Docs `formal/REAL-LIFT.adoc` (R2 row + nested-control section), `formal/README.adoc` (RealWasm/RealCompile rows + "The real lift (R0 → R2)"), `docs/PROOF-NEEDS.adoc` (K-1 row) updated. Conflict-resolved cleanly against #648 (Rows.v / P-11) and #658 (licence normalisation). ## Next Sub-rung **R2-loops** (`Loop`/`Br` + while/for, reusing the fuel device; settles the value-returning-tail question behind #601), then R-mem / R-float / R-str / … per `formal/REAL-LIFT.adoc`. Refs `REAL-LIFT.adoc`, `docs/PROOF-NEEDS.adoc` (K-1 row). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KPG9mEQXFyA3k7NWAzMNMr --- _Generated by [Claude Code](https://claude.ai/code/session_01KPG9mEQXFyA3k7NWAzMNMr)_ Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Rows.v(P-11, record-row soundness) landed in #639 as an explicitly-unverified scaffold — the authoring container had no Coq toolchain, so it shipped un-wired with a loud UNVERIFIED banner. This PR closes that loop: I installed Coq 8.18.0 (OCaml 4.14.1 — the repo's pinned toolchain) and verified it.The hand-written proofs compiled first try, axiom-free, no
Admitted. So the scaffold is promoted to a real, wired obligation.Changes
formal/_CoqProject+formal/justfilecheck: addRows(the recipe fails on any axiom/Admitted, so this now gatesRowstoo).formal/Rows.v: UNVERIFIED banner → verified/wired note; dropped the stale "Target:" / "lift into Siblings_Stated" wording.formal/README.adoc: contents-table row + a "Record rows (P-11)" prose section.docs/PROOF-NEEDS.adoc: new P-11 obligation row (mechanized); refreshed Coq-core counts to 18 files / 31Print Assumptionsreports (also fixes the long-stale "13 files" intro line)..hypatia-ignore: de-stale theRows.vcomment (now mechanized + wired).Verification (run in this environment)
Rows.vre-verified standalone after the comment edits.dune buildclean;tools/check-soundness-ledger.shgreen (SOUNDNESS.adocuntouched).Scope
Unchanged from #639: Wave W0 (monomorphic extensible records — empty/extend/select/restrict over a
lacks-checked row). Row-variable polymorphism (true row polymorphism) is the W1 increment, noted on the P-11 row as the next rung.🤖 Generated with Claude Code
Generated by Claude Code