fv-skills-baif 2.2.1 → 2.3.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +37 -6
  3. package/agents/fvs-axiom-auditor.md +2 -2
  4. package/agents/fvs-crypto-executor.md +9 -6
  5. package/agents/fvs-crypto-thinker.md +5 -5
  6. package/agents/fvs-doc-syncer.md +1 -1
  7. package/agents/fvs-draft-investigator.md +1 -1
  8. package/agents/fvs-equivalence-assessor.md +1 -1
  9. package/agents/fvs-extract-applier.md +3 -3
  10. package/agents/fvs-extract-bisector.md +3 -3
  11. package/agents/fvs-extract-classifier.md +2 -2
  12. package/agents/fvs-lean-refactorer.md +2 -2
  13. package/commands/fvs/aeneas-extract.md +18 -2
  14. package/commands/fvs/crypto-execute.md +21 -3
  15. package/commands/fvs/crypto-followup.md +48 -7
  16. package/commands/fvs/crypto-plan.md +56 -8
  17. package/commands/fvs/crypto-review.md +70 -127
  18. package/commands/fvs/fc.md +3 -2
  19. package/commands/fvs/formalise.md +4 -3
  20. package/commands/fvs/help.md +40 -14
  21. package/commands/fvs/lean-formalise.md +21 -3
  22. package/commands/fvs/lean-refactor.md +22 -4
  23. package/commands/fvs/lean-spec-review.md +41 -0
  24. package/commands/fvs/lean-specify.md +69 -3
  25. package/commands/fvs/lean-verify.md +21 -3
  26. package/commands/fvs/trust-audit.md +21 -3
  27. package/fv-skills/VERSION +1 -1
  28. package/fv-skills/references/aeneas-patterns.md +1 -1
  29. package/fv-skills/references/crypto-plan-review.md +19 -4
  30. package/fv-skills/references/fc-spec-review.md +81 -0
  31. package/fv-skills/references/lean-refactoring.md +6 -6
  32. package/fv-skills/templates/config.json +6 -0
  33. package/fv-skills/workflows/aeneas-extract.md +24 -4
  34. package/fv-skills/workflows/crypto-execute.md +24 -4
  35. package/fv-skills/workflows/crypto-followup.md +50 -5
  36. package/fv-skills/workflows/crypto-plan.md +49 -5
  37. package/fv-skills/workflows/crypto-review.md +42 -63
  38. package/fv-skills/workflows/lean-formalise.md +20 -2
  39. package/fv-skills/workflows/lean-refactor.md +22 -4
  40. package/fv-skills/workflows/lean-spec-review.md +136 -0
  41. package/fv-skills/workflows/lean-specify.md +61 -3
  42. package/fv-skills/workflows/lean-verify.md +21 -3
  43. package/fv-skills/workflows/trust-audit.md +21 -3
  44. package/package.json +1 -1
  45. package/scripts/build-plugin.cjs +1 -0
  46. package/scripts/fvs-codex-think.mjs +290 -198
  47. package/scripts/fvs-spec-review.mjs +295 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,47 @@ All notable changes to FVS (Formal Verification Skills) will be documented in th
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/).
6
6
 
7
+ ## [2.3.1] - 2026-09-09
8
+
9
+ ### Added
10
+ - Crypto plan and follow-up review now support selected Codex, Claude, or external reviewers with
11
+ explicit model/effort choices, read-only execution, honest provenance, immutable hash-bound
12
+ packets, and a three-round author/reviewer loop. Automatic handoff stays interactive, while
13
+ one-run Skip and `crypto_review.automatic: false` retain an explicit unreviewed trusted path.
14
+ This resolves
15
+ [GitHub issue #51](https://github.com/Beneficial-AI-Foundation/formal-verification-skills/issues/51).
16
+
17
+ ### Changed
18
+ - Crypto and functional-correctness review now treat `APPROVE-WITH-EDITS` as terminal once the
19
+ authoring seat applies the exhaustively named bounded edits and reruns its gates. Reviewer output
20
+ remains immutable; only true `REJECT`, `REVISE`, or `BLOCKED` verdicts start a fresh review.
21
+ This resolves
22
+ [GitHub issue #52](https://github.com/Beneficial-AI-Foundation/formal-verification-skills/issues/52).
23
+
24
+ ## [2.3.0] - 2026-09-07
25
+
26
+ ### Added
27
+ - `/fvs:lean-spec-review` adversarially reviews a functional-correctness specification against
28
+ its Rust implementation, extracted Lean definitions, and interpretation layer before proof work.
29
+ Users choose the reviewer runtime, model, and effort: Codex offers GPT Sol and Astra, Claude
30
+ offers Fable, cheaper or custom models remain available, and effort defaults to `max`.
31
+ - `/fvs:lean-specify` now offers the same review flow automatically after successful generation
32
+ checks. Existing projects need no migration: a missing `spec_review.automatic` setting enables
33
+ the menu, while `{"spec_review":{"automatic":false}}` disables only the automatic handoff.
34
+ - Review records preserve runtime/model provenance, source hashes, immutable history, validated
35
+ `PASS | REVISE | BLOCKED` verdicts, and orchestrator triage. Other providers use an exported
36
+ review packet and imported response rather than arbitrary command execution. This resolves
37
+ [GitHub issue #46](https://github.com/Beneficial-AI-Foundation/formal-verification-skills/issues/46)
38
+ and delivers the functional-correctness slice of
39
+ [GitHub issue #32](https://github.com/Beneficial-AI-Foundation/formal-verification-skills/issues/32).
40
+
41
+ ### Fixed
42
+ - Lean workflows now retrieve the project cache before build-capable work and cap Lake concurrency
43
+ at four threads unless the caller overrides it. Crypto execution accepts IDE diagnostics when
44
+ available and keeps a documented headless fallback. This resolves
45
+ [GitHub issue #49](https://github.com/Beneficial-AI-Foundation/formal-verification-skills/issues/49)
46
+ and [GitHub issue #50](https://github.com/Beneficial-AI-Foundation/formal-verification-skills/issues/50).
47
+
7
48
  ## [2.2.1] - 2026-08-28
8
49
 
9
50
  ### Fixed
package/README.md CHANGED
@@ -160,6 +160,7 @@ Commands are grouped into five bundles. Each bundle has a **router** command tha
160
160
  |---------|-------------|
161
161
  | `/fvs:fc-plan` | Pick next verification targets via greedy dependency graph traversal |
162
162
  | `/fvs:lean-specify` | Generate a style-checked Lean spec skeleton with `@[step]` theorem pattern |
163
+ | `/fvs:lean-spec-review` | Adversarially review an FC specification with a chosen runtime, model, and effort |
163
164
  | `/fvs:lean-verify` | Attempt proof with domain tactics while blocking new target-style violations |
164
165
  | `/fvs:natural-language` | Generate natural language explanation of module or function with pre/post conditions |
165
166
  | `/fvs:lean-refactor` | Refactor, simplify, and decompose verified proofs (dead code removal, simp sharpening, tactic golf) — *also in Formalise* |
@@ -171,6 +172,29 @@ Commands are grouped into five bundles. Each bundle has a **router** command tha
171
172
  rejects ordinary Lean identifiers with three or more namespace dots, steering generated code
172
173
  toward scoped namespaces, `open`, and local names.
173
174
 
175
+ After `lean-specify`, an interactive review menu asks reviewer, then model, then effort; it never
176
+ auto-selects a choice. It offers the other runtime first, a fresh reviewer in the current runtime,
177
+ or another provider. Choose GPT Sol or Astra for Codex, Fable for Claude, or a cheaper/custom model;
178
+ effort defaults to `max` and can be lowered. Other providers use an exported source packet and
179
+ imported response. One-run `Skip review` records `Unreviewed (user skipped)` and does not begin
180
+ proof work. Reviews and source hashes live under `.formalising/spec-reviews/`.
181
+
182
+ The reviewer stays read-only and `review.md` stays immutable. The `lean-specify` authoring seat
183
+ writes separate `triage.md`. PASS proceeds; APPROVE-WITH-EDITS also proceeds after accepted bounded
184
+ edits pass the structure/style/build gates, with no redundant second review. Only REVISE/BLOCKED
185
+ starts another fresh review, carrying prior records as untrusted history, with a three-round cap.
186
+
187
+ Automatic review works even without a config file. To disable the automatic menu, merge this
188
+ setting into `.formalising/fvs-config.json` (or create that file with just this object):
189
+
190
+ ```json
191
+ {"spec_review": {"automatic": false}}
192
+ ```
193
+
194
+ `/fvs:lean-spec-review <spec.lean>` remains available when automation is disabled. No migration or
195
+ health command is needed. Missing/authentication failures offer setup and an explicit fallback;
196
+ reviewer changes are never silent. A PASS approves the statement for proof work, not the proof.
197
+
174
198
  `lean-specify`, `lean-verify`, and `lean-formalise` share an indexed proof-engineering store at
175
199
  `.formalising/proof-engineering/`. Commands read `index.md` first, load at most eight relevant
176
200
  lessons as delimited untrusted reference data, and reconcile at most three evidence-backed
@@ -199,7 +223,7 @@ secrets, raw transcripts, ephemeral error dumps, unsupported guesses, or inferre
199
223
  | `/fvs:lean-formalise` | Formalise paper/math content into Lean 4 specs and definitions (one-shot) |
200
224
  | `/fvs:lean-refactor` | Refactor, simplify, and decompose verified proofs — *also in Formal-Core* |
201
225
  | `/fvs:crypto-plan` | Author the next bounded, runtime-neutral plan for a topic-based crypto formalisation iteration (KB-grounded, cached under `sources/`) |
202
- | `/fvs:crypto-review` | Send an initial or follow-up crypto plan to authenticated Codex for independent, read-only adversarial review before execution |
226
+ | `/fvs:crypto-review` | Review a crypto plan with selected Codex, Claude, or Other runtime/model/effort |
203
227
  | `/fvs:crypto-execute` | Run the current iteration's bounded plan under the green-build guard |
204
228
  | `/fvs:crypto-eval` | Adversarially evaluate the iteration; ends in one of ACCEPT / FOLLOWUP / HUMAN_RULING / BLOCKED |
205
229
  | `/fvs:crypto-followup` | Convert eval findings into the next follow-up plan; HALTs on HUMAN_RULING |
@@ -257,12 +281,12 @@ The paper track formalises papers directly into Lean 4 — no Rust, no Aeneas. T
257
281
 
258
282
  - **One-shot:** `/fvs:lean-formalise` reads your PDFs / images / LaTeX (optionally grounded in a NotebookLM knowledge base via `/fvs:kb-setup`) and produces Lean definition and spec files in a single pass.
259
283
  - **Iterative crypto loop:** for larger crypto formalisations, a topic-based, restartable loop with
260
- an independent pre-execution review gate:
284
+ a fresh pre-execution review gate:
261
285
 
262
286
  `/fvs:crypto-plan` → `/fvs:crypto-review` → `/fvs:crypto-execute` → `/fvs:crypto-eval` → `/fvs:crypto-followup` → `/fvs:crypto-review` → repeat
263
287
 
264
- A high-effort thinker authors each bounded plan. Before execution, authenticated Codex
265
- independently attacks the plan or follow-up under a read-only sandbox and returns an
288
+ A high-effort thinker authors each bounded plan. Before execution, a selected Codex, Claude, or
289
+ Other fresh reviewer attacks the plan or follow-up under read-only controls and returns an
266
290
  evidence-backed APPROVE / APPROVE-WITH-EDITS / REJECT verdict. The executor runs an approved plan
267
291
  under a green-build guard; the post-execution adversarial eval tries to refute the spec, proof,
268
292
  and assumptions and ends in exactly one of ACCEPT / FOLLOWUP / HUMAN_RULING / BLOCKED. Follow-up
@@ -272,8 +296,15 @@ The paper track formalises papers directly into Lean 4 — no Rust, no Aeneas. T
272
296
  The authoring, execution, eval, and follow-up stages use the lightweight proof-engineering overlay:
273
297
  they load at most eight relevant `crypto`/`shared` lessons and propose at most three reviewed
274
298
  updates. Modeling lessons require paper or standard citations and remain provisional until an
275
- accepted adversarial eval or explicit human ruling. The independent `crypto-review` gate is
276
- deliberately memory-blind, so inherited lessons cannot frame the second-runtime critique.
299
+ accepted adversarial eval or explicit human ruling. The `crypto-review` gate is deliberately
300
+ memory-blind. It labels cross-runtime, same-runtime fresh reviewer, and unverified provenance;
301
+ Other uses packet export/import. APPROVE-WITH-EDITS becomes terminal after the authoring seat
302
+ applies accepted edits and reruns gates, with no second review. REJECT starts a fresh reviewed
303
+ revision with prior history, capped at three reviewer rounds per invocation. Automatic plan and
304
+ follow-up handoff asks reviewer -> model -> effort and never auto-selects. One-run `Skip review`
305
+ records `Unreviewed (user skipped)` and never starts execution. To opt out persistently, merge
306
+ `"crypto_review": {"automatic": false}` into `.formalising/fvs-config.json`; standalone review
307
+ and explicit trusted-path execution remain available without fabricating approval.
277
308
 
278
309
  **Single- vs dual-runtime (`--codex`).** By default the loop is single-runtime — the thinking stages (`crypto-plan`, `crypto-eval`, `crypto-followup`) run the in-runtime `fvs-crypto-thinker`. Pass `--codex` to hand a stage's thinking to an independent **Codex CLI** thinker instead, so the adversarial planner/evaluator runs on a *different engine* than the executor and blind spots don't correlate. `crypto-execute` is the runtime-neutral executor and takes no `--codex`. Without the Codex CLI installed, a `--codex` stage stops with an install hint rather than silently falling back.
279
310
 
@@ -31,7 +31,7 @@ Iterate exactly the parent-supplied canonical atom IDs. For each entry, introspe
31
31
 
32
32
  ## 2. Introspect each declaration with `#print axioms`
33
33
  For each usable FQN, run `#print axioms <FQN>` via `lake env lean` (introspection only -- if you
34
- must rebuild anything use `nice -n 19 lake build`, NEVER a bare `lake build`). `#print axioms` is the
34
+ must rebuild anything use `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build`, NEVER a bare `lake build`). `#print axioms` is the
35
35
  authoritative oracle; static grep never determines inventory membership or classification.
36
36
 
37
37
  ## 3. Classify from the `#print axioms` output
@@ -64,7 +64,7 @@ count; unresolved entries are explicit, never omitted.
64
64
  </process>
65
65
 
66
66
  <fvs_hard_rules>
67
- - NEVER run a bare `lake build` -- use `nice -n 19 lake build` if you must rebuild; introspection uses `lake env lean` + `#print axioms`.
67
+ - NEVER run a bare `lake build` -- use `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` if you must rebuild; introspection uses `lake env lean` + `#print axioms`.
68
68
  - NEVER edit generated Lean (`Types.lean` / `Funs.lean`) -- you introspect them, you never write them.
69
69
  - Read-only: never write or modify any file -- you RETURN the classified, ordered table as text; the command body persists it and fires the gate.
70
70
  - Never widen the inventory beyond the strictly-scoped target; surface cone prerequisites separately, never fold them in.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: fvs-crypto-executor
3
3
  description: Write-capable executor for the crypto formalisation loop. Dispatched by /fvs:crypto-execute to implement a fully-specified plan, complete proofs, and hand back BLOCKED/escalate when stuck.
4
- tools: Read, Bash, Grep, Glob, Write
4
+ tools: Read, Bash, Grep, Glob, Write, mcp__ide__getDiagnostics
5
5
  color: pink
6
6
  ---
7
7
 
@@ -44,7 +44,10 @@ in your prompt. Execute the discipline below in order.
44
44
  3. **Complete the proofs.** Drive each proof to a closed goal. Use the `mcp__ide__getDiagnostics`
45
45
  runtime tool to read the live goal state and error/warning diagnostics as you work — it is your
46
46
  in-loop feedback signal, not a substitute for the authoritative build in step 4. Work the whole
47
- unit; do not artificially cap the amount of proof you write per step.
47
+ unit; do not artificially cap the amount of proof you write per step. In a headless runtime where
48
+ the IDE MCP tool is not registered, or when its call fails because the tool/server is unavailable,
49
+ fall back to Bash: use `lake env lean <file>` for file diagnostics and the bounded full-project
50
+ build in step 4 as the authoritative check.
48
51
 
49
52
  4. **Self-fix mechanical issues, and run the build as the style authority.** After the proofs close
50
53
  under diagnostics, run the build and fix mechanical fallout yourself (unresolved identifiers,
@@ -79,7 +82,7 @@ user-compiles-between-steps pair-programming. That discipline belongs to the FC
79
82
  </process>
80
83
 
81
84
  <fvs_hard_rules>
82
- - NEVER run a bare `lake build` -- always `nice -n 19 lake build` with the `set -o pipefail` / `${PIPESTATUS` guard so a piped build failure is never masked.
85
+ - NEVER run a bare `lake build` -- always `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` with the `set -o pipefail` / `${PIPESTATUS` guard so a piped build failure is never masked.
83
86
  - NEVER edit generated Lean (`Types.lean` / `Funs.lean`).
84
87
  - All writes MUST use the Write tool -- never echo, cat, or Bash redirection. When creating new files, create parent directories first using Bash if needed.
85
88
  - Escalate, do not overrule: never change an immutable public statement to force a proof through -- HALT and ask, then record the approved before/after.
@@ -96,7 +99,7 @@ On successful completion, end your output with:
96
99
 
97
100
  **Iteration:** nN
98
101
  **Files written:** {list of file paths, including IMPLEMENTATION_nN.md}
99
- **Build:** green via `nice -n 19 lake build`
102
+ **Build:** green via `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build`
100
103
  **Obligations:** {named allowed-sorry obligations with their statements, or "none"}
101
104
  **Summary:** {1-2 sentences on what was implemented and proven}
102
105
  ```
@@ -119,7 +122,7 @@ When genuinely stuck:
119
122
 
120
123
  **Iteration:** nN
121
124
  **Blocker:** {the concrete missing prerequisite, red build, or modeling decision}
122
- **Build state:** {last known state from `nice -n 19 lake build`}
125
+ **Build state:** {last known state from `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build`}
123
126
  **What would unblock:** {the specific input needed}
124
127
  ```
125
128
 
@@ -128,7 +131,7 @@ When genuinely stuck:
128
131
  <success_criteria>
129
132
  - [ ] Implemented the fully-specified plan as a whole unit (no unauthorised `sorry`; immutable public statements preserved verbatim)
130
133
  - [ ] Kernel-checked signatures, then completed proofs using `mcp__ide__getDiagnostics` for in-loop goal/diagnostic feedback
131
- - [ ] Ran `nice -n 19 lake build` as the style authority and self-fixed mechanical + style fallout (expecting style warnings that surface only at build time, not in isolation checks)
134
+ - [ ] Ran `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` as the style authority and self-fixed mechanical + style fallout (expecting style warnings that surface only at build time, not in isolation checks)
132
135
  - [ ] Escalated (never overruled) any immutable-public-statement change; handed back BLOCKED when genuinely stuck
133
136
  - [ ] Did NOT use the one-`sorry` / ≤3-line / user-compiles-between-steps proof-attempt grind
134
137
  - [ ] Wrote the run report to `IMPLEMENTATION_nN.md` and returned with a ## IMPLEMENTATION COMPLETE / ## ESCALATE / ## BLOCKED header
@@ -41,7 +41,7 @@ coarse go/no-go compile check, and only when viability genuinely hinges on an ar
41
41
  That single go/no-go probe is a viability check, NOT a style certification -- `lake build` in the
42
42
  executor's loop remains the style authority (a planner that does not fully compile cannot certify
43
43
  style). `Bash` stays in your tool list SOLELY for that one permitted go/no-go probe, and so the plan
44
- can author the `nice -n 19 lake build` command as text the executor runs; it is not a license to
44
+ can author the `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` command as text the executor runs; it is not a license to
45
45
  iterate a proof while planning.
46
46
 
47
47
  The plan is bounded and runtime-neutral -- it must be executable by a Claude, Codex, or other
@@ -60,7 +60,7 @@ runtime's executor with no thinker in the loop. State EVERY field explicitly:
60
60
  6. **Stop conditions** -- the explicit conditions under which the executor halts (target reached,
61
61
  build red after N attempts, a modeling decision needed). A modeling decision or any change to a
62
62
  public statement is ESCALATED to the user -- never decided by the thinker.
63
- 7. **Verification commands** -- ALWAYS `nice -n 19 lake build` (never a bare `lake build`), with the
63
+ 7. **Verification commands** -- ALWAYS `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` (never a bare `lake build`), with the
64
64
  `set -o pipefail` / `${PIPESTATUS` guard so a piped build failure is never masked.
65
65
  8. **Expected artifact updates** -- which `fv-plans/<topic>/{plans,reviews,sources,merge}` files the
66
66
  run is expected to produce or update.
@@ -104,7 +104,7 @@ that silently picks one side of a modeling decision -- the ruling is reserved fo
104
104
 
105
105
  If the prior eval was `FOLLOWUP`, author the next bounded plan using the full `plan`-mode contract
106
106
  (branch/state, exact targets, immutable public statements, allowed-`sorry` policy, stop conditions,
107
- `nice -n 19 lake build` verification, expected artifact updates).
107
+ `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` verification, expected artifact updates).
108
108
 
109
109
  End with `## PLAN COMPLETE` (a follow-up plan) or `## ERROR` (HALT for an HUMAN_RULING you cannot
110
110
  resolve without the human).
@@ -113,7 +113,7 @@ resolve without the human).
113
113
  </process>
114
114
 
115
115
  <fvs_hard_rules>
116
- - NEVER run a bare `lake build` -- always `nice -n 19 lake build` with the `set -o pipefail` / `${PIPESTATUS` guard so a piped build failure is never masked.
116
+ - NEVER run a bare `lake build` -- always `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` with the `set -o pipefail` / `${PIPESTATUS` guard so a piped build failure is never masked.
117
117
  - NEVER edit generated Lean (`Types.lean` / `Funs.lean`).
118
118
  - Author-by-return: never write or modify a project file -- you RETURN the plan/eval/followup as text; the command body persists it under `fv-plans/<topic>/`.
119
119
  - On an `HUMAN_RULING`, HALT and ask -- never fabricate a plan that silently makes the modeling decision.
@@ -155,7 +155,7 @@ On HALT / failure:
155
155
  </return_format>
156
156
 
157
157
  <success_criteria>
158
- - [ ] In `plan`/`followup` mode, authored a bounded, runtime-neutral plan stating branch/state, exact target files+theorems, immutable public statements, old->new API map (if a port), allowed-`sorry` policy, stop conditions, `nice -n 19 lake build` verification, and expected artifact updates
158
+ - [ ] In `plan`/`followup` mode, authored a bounded, runtime-neutral plan stating branch/state, exact target files+theorems, immutable public statements, old->new API map (if a port), allowed-`sorry` policy, stop conditions, `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` verification, and expected artifact updates
159
159
  - [ ] In `eval` mode, took an adversarial posture (tried to refute), judged each `sorry` as a named obligation not by count, and ended in exactly one of ACCEPT | FOLLOWUP | HUMAN_RULING | BLOCKED
160
160
  - [ ] On `HUMAN_RULING`, HALTed and asked for the modeling decision -- never fabricated a plan
161
161
  - [ ] Author-by-return: no project file written or modified; no `gh` auto-open; Lean-via-Aeneas pipeline only; no bare `lake build`
@@ -74,7 +74,7 @@ The parent provides a `<sync_mode>` tag. Execute the matching mode.
74
74
  <fvs_hard_rules>
75
75
  - Reconcile-not-append: never duplicate an existing catalog entry or reference section; update in place.
76
76
  - "Fixed in upstream main" is NOT "fixed for us" -- never auto-retire a catalog entry until the resolved pin carries the fix.
77
- - NEVER run a bare `lake build` (use `nice -n 19 lake build` if a build is ever needed).
77
+ - NEVER run a bare `lake build` (use `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` if a build is ever needed).
78
78
  - NEVER edit generated Lean (`Types.lean` / `Funs.lean`).
79
79
  - NEVER call `gh` to OPEN/create an upstream artifact (gh api READ for fetching docs/issues is allowed).
80
80
  - Propose each change for approval; all writes use the Write/Edit tool.
@@ -78,7 +78,7 @@ the local-clone commit, the existing-issue numbers you dedup'd against, the cata
78
78
  - ESCAPE all interpolated MFE/error/tool output when writing `*.html` (error strings can contain markup).
79
79
  - Quote and validate every clone path as a directory before `git -C`; never `eval` a path.
80
80
  - Dedup first: cite an existing issue rather than drafting a duplicate.
81
- - NEVER run a bare `lake build` (use `nice -n 19 lake build` if you must reproduce anything).
81
+ - NEVER run a bare `lake build` (use `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` if you must reproduce anything).
82
82
  - NEVER edit generated Lean (`Types.lean` / `Funs.lean`).
83
83
  - Write only to the workspace; all writes use the Write/Edit tool.
84
84
  - This is a Lean-via-Aeneas pipeline only -- no other-framework verification paths.
@@ -82,7 +82,7 @@ This is the load-bearing constraint of your role:
82
82
  <fvs_hard_rules>
83
83
  - NEVER write section 7 or the ratification token -- you are not the proposer and not the human reviewer.
84
84
  - Read-only: never write or modify a file (return the drafted sections as text).
85
- - NEVER run a bare `lake build` (use `nice -n 19 lake build` if you must reproduce anything).
85
+ - NEVER run a bare `lake build` (use `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` if you must reproduce anything).
86
86
  - NEVER edit generated Lean (`Types.lean` / `Funs.lean`).
87
87
  - NEVER call `gh` to open or create any upstream artifact.
88
88
  - This is a Lean-via-Aeneas pipeline only -- no other-framework verification paths.
@@ -83,12 +83,12 @@ crate root using the Write tool:
83
83
  - append the trusted assumption to `src-assumptions.md` when the recipe axiomatizes, excludes, or
84
84
  gates an item (every A-opacity and every gated build-script edit leaves an assumption).
85
85
 
86
- Then rebuild to confirm the recipe cleared the blocker, ALWAYS with `nice -n 19 lake build`.
86
+ Then rebuild to confirm the recipe cleared the blocker, ALWAYS with `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build`.
87
87
 
88
88
  </process>
89
89
 
90
90
  <fvs_hard_rules>
91
- - NEVER run a bare `lake build`. Always `nice -n 19 lake build`.
91
+ - NEVER run a bare `lake build`. Always `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build`.
92
92
  - NEVER edit generated Lean (`Types.lean` / `Funs.lean`). A-opacity edits the RUST source or the
93
93
  hand-authored external files; `tweaks-substitution` repairs generated text only via the guarded
94
94
  substitution mechanism, never a hand edit of a generated file.
@@ -139,7 +139,7 @@ On failure:
139
139
  - [ ] Generated Lean (`Types.lean` / `Funs.lean`) never edited by hand
140
140
  - [ ] Reversible records written (src-modifications + src-assumptions where an assumption arises)
141
141
  - [ ] `tweaks-substitution` guards honored (>= 1 match; 0-match is a HARD failure)
142
- - [ ] Rebuild run with `nice -n 19 lake build`, never bare
142
+ - [ ] Rebuild run with `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build`, never bare
143
143
  - [ ] All writes via the Write tool; no `gh` auto-open; Lean-via-Aeneas pipeline only
144
144
  - [ ] Result returned with the appropriate header
145
145
  - [ ] No @-references used (all reference content is inlined by the parent)
@@ -28,7 +28,7 @@ tool.
28
28
  1. **Shrink.** Starting from the failing input, remove code until the failure disappears, then
29
29
  restore the smallest unit that brings it back. Drive every step by an oracle run -- the actual
30
30
  extraction step that the classifier said failed (read its exit status with `set -o pipefail` /
31
- `${PIPESTATUS[0]}`, never the tail of a piped log; rebuild with `nice -n 19 lake build` when the
31
+ `${PIPESTATUS[0]}`, never the tail of a piped log; rebuild with `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` when the
32
32
  failing layer is `lean`).
33
33
  2. **Grow.** From that minimal core, add back only what is needed to make the example
34
34
  self-contained and reproducible. The result is the MFE: the smallest standalone reproduction of
@@ -73,7 +73,7 @@ proposal awaiting a separate disposition.
73
73
 
74
74
  <fvs_hard_rules>
75
75
  - NEVER auto-apply a fix and NEVER stamp a ratification token -- you propose, never dispose.
76
- - NEVER run a bare `lake build`. Always `nice -n 19 lake build`.
76
+ - NEVER run a bare `lake build`. Always `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build`.
77
77
  - NEVER edit generated Lean (`Types.lean` / `Funs.lean`).
78
78
  - NEVER call `gh` to open or create any upstream artifact.
79
79
  - A catalog candidate with an empty `evidence` field is malformed -- evidence is the real MFE path,
@@ -119,7 +119,7 @@ On failure:
119
119
 
120
120
  <success_criteria>
121
121
  - [ ] Two-phase shrink-then-grow minimization driven by the actual failing-layer oracle
122
- - [ ] Exit status read via `set -o pipefail` / `${PIPESTATUS[0]}`; rebuilds use `nice -n 19 lake build`
122
+ - [ ] Exit status read via `set -o pipefail` / `${PIPESTATUS[0]}`; rebuilds use `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build`
123
123
  - [ ] Variant budget enforced as a hard cap; exhaustion emits best partial + ESCALATE
124
124
  - [ ] Catalog candidate is schema-conformant with `status: candidate`, REAL `evidence` (the MFE path), and `pin_context`
125
125
  - [ ] Category assigned by the safe-by-construction A/B test (meaning judgment -> B)
@@ -52,7 +52,7 @@ tool's own exit status:
52
52
  # Illustrative only: this is what the ORCHESTRATOR ran. You (the classifier) are
53
53
  # read-only -- you read the resulting build.log to interpret it, you do NOT re-run the build.
54
54
  set -o pipefail
55
- nice -n 19 lake build 2>&1 | tee build.log
55
+ LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build 2>&1 | tee build.log
56
56
  status=${PIPESTATUS[0]} # the build's exit status, not tee's
57
57
  ```
58
58
 
@@ -91,7 +91,7 @@ bisection by the parent, not to a recipe.
91
91
  <fvs_hard_rules>
92
92
  These FVS invariants bind you even though you do not write files:
93
93
 
94
- - NEVER run a bare `lake build`. Always `nice -n 19 lake build`.
94
+ - NEVER run a bare `lake build`. Always `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build`.
95
95
  - NEVER edit generated Lean (`Types.lean` / `Funs.lean`) -- you are read-only regardless.
96
96
  - NEVER call `gh` to open or create any upstream artifact.
97
97
  - This is a Lean-via-Aeneas pipeline only -- no other-framework verification paths.
@@ -80,7 +80,7 @@ After applying a refactoring:
80
80
  **Tier:** {1|2|3|4}
81
81
  **Lines:** {before} -> {after}
82
82
 
83
- Verify: nice -n 19 lake build
83
+ Verify: LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build
84
84
  ```
85
85
 
86
86
  When no further refactoring is possible:
@@ -108,7 +108,7 @@ When something goes wrong:
108
108
  - NEVER touch `unfold + step` structural backbone
109
109
  - NEVER write changes without explaining the specific heuristic being applied
110
110
  - If a change breaks the build, REVERT and return ERROR with the build output
111
- - Use `nice -n 19 lake build` for all build checks, NEVER plain `lake build`
111
+ - Use `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` for all build checks, NEVER plain `lake build`
112
112
  - After a failed refactoring attempt, do not retry the same heuristic
113
113
  - Prefer conservative changes -- when in doubt, leave it alone
114
114
  - Do NOT use @-references. All reference knowledge is inlined by the parent command.
@@ -91,6 +91,22 @@ Follow the PRE-FLIGHT step of the workflow:
91
91
  Initialise the workspace tree `<extract_workspace>/<target>/` with subdirs `equivalence-gate/`,
92
92
  `mwe/`, `drafts/`, `catalog-candidates/`, `escalations/`.
93
93
 
94
+ Run the mandatory cache preflight from the validated Lean project root. A failure stops the
95
+ workflow before extraction, delegation, or build:
96
+
97
+ ```bash
98
+ if { [ ! -f lakefile.lean ] && [ ! -f lakefile.toml ]; } || [ ! -f lean-toolchain ]; then
99
+ echo "FVS >> ERROR: run from the Lean project root" >&2
100
+ exit 1
101
+ fi
102
+ LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake exe cache get
103
+ CACHE_STATUS=$?
104
+ if [ "$CACHE_STATUS" -ne 0 ]; then
105
+ echo "FVS >> ERROR: Lake cache preflight failed; stopping workflow" >&2
106
+ exit "$CACHE_STATUS"
107
+ fi
108
+ ```
109
+
94
110
  ## Step 3: Run the bounded loop
95
111
 
96
112
  Repeat EXTRACT -> CLASSIFY -> DISPATCH -> DOCUMENT until clean or escalated, enforcing the
@@ -98,7 +114,7 @@ loop bounds (per-blocker attempt-cap 3, per-run cycle hard-cap ~25, bisection va
98
114
  ~12, no-progress key `sha256(layer || signature)` -- a same-key recurrence after an applied
99
115
  fix escalates immediately).
100
116
 
101
- - **EXTRACT:** run extraction and build under `set -o pipefail` + `nice -n 19 lake build`;
117
+ - **EXTRACT:** run extraction and build under `set -o pipefail` + `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build`;
102
118
  read the tool's real exit status via `${PIPESTATUS[0]}`, never the tail of a piped log.
103
119
  Clean -> success oracle (Step 5). Failure -> classify.
104
120
  - **CLASSIFY:** `Task(subagent_type="fvs-extract-classifier", model="$CLASSIFIER_MODEL", ...)`
@@ -204,7 +220,7 @@ per model-profiles runtime handling).
204
220
  <success_criteria>
205
221
  - [ ] `<path>` auto-detected into crate/folder/file; the loop scoped accordingly.
206
222
  - [ ] Pin-audit warn-and-confirm on drift records `pin_context`; clone staleness reported gracefully.
207
- - [ ] EXTRACT reads the tool's real exit status (`set -o pipefail` / `${PIPESTATUS[0]}`); always `nice -n 19 lake build`.
223
+ - [ ] EXTRACT reads the tool's real exit status (`set -o pipefail` / `${PIPESTATUS[0]}`); always `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build`.
208
224
  - [ ] The orchestrator fires the gate itself, dispatching `fvs-equivalence-assessor` distinctly from `fvs-extract-bisector`; the success oracle greps `equivalence-ratified:` and refuses completion without it.
209
225
  - [ ] Reversible records at the crate root; generated Lean never written; annotations preferred.
210
226
  - [ ] Attempt-cap 3 + no-progress rule enforced; escalation is a human decision point and a valid outcome.
@@ -94,6 +94,24 @@ Read the bounded executor plan for this iteration -- `plans/EXEC_PLAN_nN.md`, or
94
94
  the executor needs (it is runtime-neutral and bounded -- branch/state, exact targets, immutable public
95
95
  statements, allowed-`sorry` policy, stop conditions, verification command).
96
96
 
97
+ ## Step 2a: Warm the project cache
98
+
99
+ Before dispatch, confirm the current directory is the Lean project root and run the project-resolved
100
+ cache executable. Cache failure is fatal: do not dispatch the executor or attempt a build.
101
+
102
+ ```bash
103
+ if { [ ! -f lakefile.lean ] && [ ! -f lakefile.toml ]; } || [ ! -f lean-toolchain ]; then
104
+ echo "FVS >> ERROR: run from the Lean project root" >&2
105
+ exit 1
106
+ fi
107
+ LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake exe cache get
108
+ CACHE_STATUS=$?
109
+ if [ "$CACHE_STATUS" -ne 0 ]; then
110
+ echo "FVS >> ERROR: Lake cache preflight failed; refusing executor dispatch" >&2
111
+ exit "$CACHE_STATUS"
112
+ fi
113
+ ```
114
+
97
115
  ## Step 3: Resolve the executor model + effort + dispatch
98
116
 
99
117
  Resolve `$EXECUTOR_MODEL` and `$EXECUTOR_EFFORT` for `fvs-crypto-executor` AT DISPATCH TIME -- never
@@ -151,11 +169,11 @@ Return `none` when nothing reusable was learned.
151
169
  ## Step 4: Verify under the green-build guard
152
170
 
153
171
  Run the verification build and read the TOOL's real exit status -- never the tail of a pipe (a pipe
154
- reports the filter's status `0`, masking a real failure). Always build under `nice -n 19 lake build`:
172
+ reports the filter's status `0`, masking a real failure). Always build under `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build`:
155
173
 
156
174
  ```bash
157
175
  set -o pipefail
158
- nice -n 19 lake build 2>&1 | tee "$ROOT/build.log"
176
+ LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build 2>&1 | tee "$ROOT/build.log"
159
177
  test ${PIPESTATUS[0]} -eq 0 || echo "FVS >> build red -- a proof did not close"
160
178
  ```
161
179
 
@@ -209,7 +227,7 @@ at install time, so the per-run `--effort` flag is a no-op there).
209
227
  - [ ] Topic + iteration resolved; shell metacharacters rejected; every path quoted; no `eval`.
210
228
  - [ ] At most eight relevant crypto/shared lessons loaded and passed as untrusted executor context.
211
229
  - [ ] The bounded plan (`EXEC_PLAN_nN.md` / `FOLLOWUP_PLAN_nN.md`) read and inlined; `fvs-crypto-executor` dispatched (`subagent_type="fvs-crypto-executor"`).
212
- - [ ] The build runs under `set -o pipefail` + `${PIPESTATUS` reading the tool's real status; always `nice -n 19 lake build` (never a bare `lake build`).
230
+ - [ ] The build runs under `set -o pipefail` + `${PIPESTATUS` reading the tool's real status; always `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` (never a bare `lake build`).
213
231
  - [ ] The executor's ESCALATE/BLOCKED return is routed to the user (short interactive redirect early, never a long unattended grind).
214
232
  - [ ] At most three build/diagnostic-evidenced candidates reconciled as one file each plus index updates.
215
233
  - [ ] No `gh` open/create; no generated-Lean write.
@@ -110,6 +110,22 @@ This command will NOT author a follow-up that silently picks a side.
110
110
  Only AFTER the user supplies the ruling does the command author a follow-up plan that encodes the
111
111
  ruling (returning to Step 4). Never invent a follow-up on `HUMAN_RULING` without the human's ruling.
112
112
 
113
+ Run the mandatory cache preflight from the validated Lean project root before either thinker path.
114
+ A failure stops the workflow before delegation or any authored build plan:
115
+
116
+ ```bash
117
+ if { [ ! -f lakefile.lean ] && [ ! -f lakefile.toml ]; } || [ ! -f lean-toolchain ]; then
118
+ echo "FVS >> ERROR: run from the Lean project root" >&2
119
+ exit 1
120
+ fi
121
+ LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake exe cache get
122
+ CACHE_STATUS=$?
123
+ if [ "$CACHE_STATUS" -ne 0 ]; then
124
+ echo "FVS >> ERROR: Lake cache preflight failed; stopping workflow" >&2
125
+ exit "$CACHE_STATUS"
126
+ fi
127
+ ```
128
+
113
129
  ## Step 4: Resolve the thinker + dispatch (followup mode)
114
130
 
115
131
  Default (no `--codex`) -- dispatch the in-runtime thinker. Resolve `$THINKER_MODEL` for
@@ -160,7 +176,7 @@ The thinker (in-runtime or Codex) authors the follow-up plan; THIS command body
160
176
  `plans/FOLLOWUP_PLAN_nN.md` carrying
161
177
  the full bounded-plan contract (branch/state, exact target files + theorems, immutable public
162
178
  statements that must not change, allowed-`sorry` policy, stop conditions, the verification command
163
- `nice -n 19 lake build` under the `set -o pipefail` / `${PIPESTATUS` guard, expected artifact
179
+ `LEAN_NUM_THREADS="${LEAN_NUM_THREADS:-4}" nice -n 19 lake build` under the `set -o pipefail` / `${PIPESTATUS` guard, expected artifact
164
180
  updates).
165
181
 
166
182
  The artifact MUST also record:
@@ -169,8 +185,9 @@ The artifact MUST also record:
169
185
  Authoring runtime: {Claude Code | OpenCode | Gemini | Codex | Codex CLI}
170
186
  ```
171
187
 
172
- Use `Codex CLI` for `--codex`; otherwise name the actual host runtime. This provenance is mandatory
173
- for `/fvs:crypto-review` to prove the reviewer is independent.
188
+ Use `Codex CLI` for `--codex`; otherwise name the actual host runtime. `/fvs:crypto-review` uses
189
+ this provenance to label cross-runtime review as independent and same-runtime review as fresh but
190
+ not independent; missing provenance fails closed.
174
191
 
175
192
  ## Step 4a: Reconcile Follow-Up Lessons
176
193
 
@@ -180,6 +197,31 @@ required. Strengthen an equivalent record or create one file per new lesson unde
180
197
  `lessons/crypto/`, updating the index in the same reviewable diff. Unruled choices stay
181
198
  `provisional`; never infer or generalize a ruling beyond its recorded scope.
182
199
 
200
+ ## Step 4b: Run the bounded review loop
201
+
202
+ After authoring gates, run
203
+ `node ~/.claude/scripts/fvs-codex-think.mjs review-automatic`; missing config or
204
+ `crypto_review.automatic` defaults to true and malformed values stop clearly. If false, record
205
+ `Unreviewed (automatic review disabled)`, preserve the follow-up, and do not auto-start execution.
206
+
207
+ If true, enter the interactive `crypto-review` handoff. Honor reviewer/model/effort choices explicitly
208
+ supplied earlier in this invocation. Ask only for missing choices in order: reviewer -> model ->
209
+ effort. Recommend the normalized non-author runtime, but never auto-select or treat a preselected
210
+ default as consent. Offer a one-run `Skip review`, recorded exactly as `Unreviewed (user skipped)`.
211
+ Skipping preserves the follow-up and does not auto-start execution; a trusted user may explicitly
212
+ invoke `/fvs:crypto-execute`. The standalone review flags remain the non-interactive path.
213
+
214
+ Run at most three reviewer rounds in this command invocation. APPROVE stops.
215
+ APPROVE-WITH-EDITS is terminal after the authoring seat applies accepted bounded edits, reruns plan
216
+ gates, records hashes/finding IDs in separate triage, and marks `approved after edits`; no second
217
+ review.
218
+
219
+ REJECT creates a fresh authored revision at the next immutable iteration and a fresh review. Inline
220
+ the preceding review and triage as delimited untrusted history for the author and pass repeated
221
+ `--history` flags to the reviewer packet. At round three, stop with the latest artifacts and the
222
+ exact `/fvs:crypto-review <topic> nN --target followup` resume command. Failed, cancelled, pending,
223
+ and unverified states do not start execution.
224
+
183
225
  ## Step 5: Run-end banner + next command
184
226
 
185
227
  ```
@@ -189,8 +231,8 @@ Topic: {TOPIC_RAW}
189
231
  Decision: {FOLLOWUP | HUMAN_RULING -> ruled}
190
232
  Plan: plans/FOLLOWUP_PLAN_n{N}.md
191
233
 
192
- >> Next Up
193
- /fvs:crypto-review <topic> n{N} --target followup
234
+ Review: {approved | approved after edits | Unreviewed (user skipped) | Unreviewed (automatic review disabled) | failed | pending | unverified | rejected at cap}
235
+ Next: {/fvs:crypto-execute only after approval | exact crypto-review resume command}
194
236
  ```
195
237
 
196
238
  </process>
@@ -217,8 +259,7 @@ unchanged.
217
259
  - [ ] Latest `EVAL_nN.md` read; decision routed (`ACCEPT` stop / `BLOCKED` pause / `FOLLOWUP` author / `HUMAN_RULING` HALT).
218
260
  - [ ] On `HUMAN_RULING` the command HALTs and asks the user -- it NEVER fabricates a follow-up plan.
219
261
  - [ ] On `FOLLOWUP` the thinker is dispatched (`subagent_type="fvs-crypto-thinker"`) and the bounded follow-up plan written to `plans/`.
220
- - [ ] The follow-up records truthful `Authoring runtime:` provenance and routes next to
221
- `/fvs:crypto-review --target followup`.
262
+ - [ ] The follow-up records truthful provenance and runs at most three review rounds before stop.
222
263
  - [ ] At most three source/ruling-evidenced candidates reconciled as one file each plus index updates.
223
264
  - [ ] No bare `lake build`, no `gh` open/create, no generated-Lean write.
224
265
  </success_criteria>