You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add Lean 4 runtime support with runtimes: front matter (#208)
* feat: add Lean 4 as a first-class tool
Add `tools: lean:` front matter configuration that auto-configures:
- elan installation step (injected into prepare_steps before AWF sandbox)
- lean/lake/elan added to bash command allow-list
- Lean-specific domains (elan.lean-lang.org, leanprover.github.io,
lean-lang.org) added to AWF network allowlist
- Agent prompt supplement informing the agent Lean 4 is available
Supports both simple (`lean: true`) and object (`lean: { toolchain: ... }`)
front matter formats. Default toolchain is "stable"; lean-toolchain files
in the repo override automatically via elan.
Includes:
- LeanToolConfig types with deserialization tests
- Lean domain entries in allowed_hosts.rs
- Standalone compiler wiring (prepare_steps, allowed_domains, copilot_params)
- 1ES compiler: bash allow-list works; elan install via manual steps
- AGENTS.md documentation
- Example agent (examples/lean-verifier.md)
- Unit tests for types, copilot params, allowed domains, prepare steps
Related issues:
- #206 (first-class tool documentation pattern)
- #207 (network ecosystem identifiers)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: symlink lean tools into /tmp/awf-tools/ for AWF chroot compatibility
AWF chroot mode reconstructs PATH from standard system locations,
so $HOME/.elan/bin is not on PATH inside the sandbox. Symlink
lean, lake, and elan into /tmp/awf-tools/ which is always mounted
at /tmp inside the AWF container.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor: move Lean from tools to runtimes
Lean is a language runtime, not a tool (like edit, bash, memory).
Refactor to align with gh-aw's `runtimes:` front matter model:
- New `src/runtimes/` module alongside `src/tools/` and `src/safeoutputs/`
- `src/runtimes/lean.rs`: LeanRuntimeConfig, LeanOptions, install/prompt generators
- `src/runtimes/mod.rs`: module documentation
- `RuntimesConfig` struct in types.rs with `runtimes` field on FrontMatter
- Front matter changes from `tools: lean:` to `runtimes: lean:`
- All compiler references updated (standalone.rs, common.rs)
- AGENTS.md: new "Runtimes Configuration" section, separate from Tools
- Example updated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor: clean up generate_lean_install string formatting
Replace \x20 hex escape sequences with a readable approach: build
the script body as a plain string, then indent each line by 4 spaces
for the YAML block scalar.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: use lean.rs constants instead of mcp_required_hosts
- Use LEAN_BASH_COMMANDS constant in common.rs instead of inline list
- Move lean domains from mcp_required_hosts() to LEAN_REQUIRED_HOSTS
constant in runtimes/lean.rs (lean is a runtime, not an MCP)
- Update standalone.rs and allowed_hosts.rs tests accordingly
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
- Auto-infers org from the git remote URL at compile time (overridable via `org:` field)
461
465
- Fails compilation if org cannot be determined (no explicit override and no ADO git remote)
462
466
467
+
### Runtimes Configuration
468
+
469
+
The `runtimes` field configures language environments that are installed before the agent runs. Unlike tools (which are agent capabilities like edit, bash, memory), runtimes are execution environments that the compiler auto-installs via pipeline steps.
470
+
471
+
Aligned with [gh-aw's `runtimes:` front matter field](https://github.github.com/gh-aw/reference/frontmatter/#runtimes-runtimes).
472
+
473
+
#### Lean 4 (`lean:`)
474
+
475
+
Lean 4 theorem prover runtime. Auto-installs the Lean toolchain via elan, extends the bash command allow-list, adds Lean-specific domains to the network allowlist, and appends a prompt supplement informing the agent that Lean is available.
- Injects an elan installation step into `{{ prepare_steps }}` (runs before AWF network isolation)
490
+
- Defaults to the `stable` toolchain; if a `lean-toolchain` file exists in the repo, elan overrides to that version automatically
491
+
- Auto-adds `lean`, `lake`, and `elan` to the bash command allow-list
492
+
- Adds Lean-specific domains to the network allowlist: `elan.lean-lang.org`, `leanprover.github.io`, `lean-lang.org`
493
+
- Symlinks lean tools into `/tmp/awf-tools/` for AWF chroot compatibility
494
+
- Appends a prompt supplement informing the agent about Lean 4 availability and basic commands
495
+
- Emits a compile-time warning if `tools.bash` is empty (Lean requires bash access)
496
+
497
+
**Note:** In the 1ES target, the bash command allow-list is updated but elan installation must be done manually via `steps:` front matter. The 1ES target handles network isolation separately.
498
+
463
499
### Target Platforms
464
500
465
501
The `target` field in the front matter determines the output format and execution environment for the compiled pipeline.
@@ -1412,6 +1448,7 @@ When extending the compiler:
1412
1448
4. **New template markers**: Handle replacements in the target-specific compiler (e.g., `standalone.rs` or `onees.rs`)
1413
1449
5. **New safe-output tools**: Add to `src/safeoutputs/` — implement `ToolResult`, `Executor`, register in `mod.rs`, `mcp.rs`, `execute.rs`
1414
1450
6. **New first-class tools**: Add to `src/tools/` — extend `ToolsConfig` in `types.rs`, wire in compilers
1451
+
7. **New runtimes**: Add to `src/runtimes/` — extend `RuntimesConfig` in `types.rs`, wire in compilers
1415
1452
7. **Validation**: Add compile-time validation for safe outputs and permissions
description: "Analyzes code and builds formal Lean 4 proofs of critical invariants"
4
+
engine: claude-opus-4.5
5
+
schedule: weekly on friday around 17:00
6
+
tools:
7
+
cache-memory: true
8
+
runtimes:
9
+
lean: true
10
+
safe-outputs:
11
+
create-pull-request:
12
+
target-branch: main
13
+
create-work-item:
14
+
work-item-type: Task
15
+
tags:
16
+
- formal-verification
17
+
- lean4
18
+
permissions:
19
+
write: my-write-arm-connection
20
+
---
21
+
22
+
## Formal Verification Agent
23
+
24
+
You are a formal verification agent. Your job is to analyze the codebase, identify critical invariants and safety properties, and build Lean 4 proofs that verify them.
25
+
26
+
### Workflow
27
+
28
+
1.**Identify invariants**: Review the source code for critical logic — data validation, state transitions, arithmetic bounds, access control checks.
29
+
2.**Model in Lean**: Create `.lean` files that formalize the identified properties as Lean 4 theorems.
30
+
3.**Prove correctness**: Write proofs for each theorem. Use `lake build` to verify the proofs compile.
31
+
4.**Iterate on failures**: If a proof fails, analyze the error output from `lean` to understand why. Either fix the proof or report the property as unverifiable (which may indicate a bug).
32
+
5.**Submit results**: Create a PR with the `.lean` proof files, or create work items for properties that could not be verified.
33
+
34
+
### Guidelines
35
+
36
+
- Start with the simplest invariants first (null checks, bounds checks, type safety).
37
+
- Use `lake init` to create a new Lake project if one doesn't exist.
38
+
- Check your memory for findings from previous runs to avoid re-analyzing the same code.
39
+
- If a property cannot be formalized or proved, use the `create-work-item` tool to flag it for human review.
0 commit comments