leanwarp 0.2.7__tar.gz → 0.2.9__tar.gz

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 (60) hide show
  1. {leanwarp-0.2.7 → leanwarp-0.2.9}/CHANGELOG.md +38 -2
  2. {leanwarp-0.2.7 → leanwarp-0.2.9}/PKG-INFO +25 -9
  3. {leanwarp-0.2.7 → leanwarp-0.2.9}/README.md +24 -8
  4. {leanwarp-0.2.7 → leanwarp-0.2.9}/docs/agents.md +3 -2
  5. {leanwarp-0.2.7 → leanwarp-0.2.9}/docs/http-api.md +100 -28
  6. {leanwarp-0.2.7 → leanwarp-0.2.9}/pyproject.toml +1 -1
  7. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/cli.py +93 -5
  8. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/client.py +130 -5
  9. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/compact.py +9 -0
  10. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/edits.py +9 -8
  11. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/mcp_server.py +123 -16
  12. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/outcome.py +30 -8
  13. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/session.py +119 -39
  14. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/skills/leanwarp/SKILL.md +25 -12
  15. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/skills/leanwarp/references/usage.md +107 -50
  16. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_ci.py +24 -5
  17. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_client.py +48 -1
  18. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_install.py +2 -1
  19. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_mcp.py +28 -0
  20. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_replay.py +90 -0
  21. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_retries.py +20 -10
  22. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_session.py +113 -13
  23. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_tools.py +48 -1
  24. {leanwarp-0.2.7 → leanwarp-0.2.9}/.gitignore +0 -0
  25. {leanwarp-0.2.7 → leanwarp-0.2.9}/LICENSE +0 -0
  26. {leanwarp-0.2.7 → leanwarp-0.2.9}/docs/README.md +0 -0
  27. {leanwarp-0.2.7 → leanwarp-0.2.9}/docs/assets/leanwarp-banner.svg +0 -0
  28. {leanwarp-0.2.7 → leanwarp-0.2.9}/docs/getting-started.md +0 -0
  29. {leanwarp-0.2.7 → leanwarp-0.2.9}/examples/lean-4.35/.gitignore +0 -0
  30. {leanwarp-0.2.7 → leanwarp-0.2.9}/examples/lean-4.35/LeanWarpExample.lean +0 -0
  31. {leanwarp-0.2.7 → leanwarp-0.2.9}/examples/lean-4.35/README.md +0 -0
  32. {leanwarp-0.2.7 → leanwarp-0.2.9}/examples/lean-4.35/lake-manifest.json +0 -0
  33. {leanwarp-0.2.7 → leanwarp-0.2.9}/examples/lean-4.35/lakefile.toml +0 -0
  34. {leanwarp-0.2.7 → leanwarp-0.2.9}/examples/lean-4.35/lean-toolchain +0 -0
  35. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/__init__.py +0 -0
  36. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/_toml.py +0 -0
  37. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/_version.py +0 -0
  38. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/agents.py +0 -0
  39. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/amounts.py +0 -0
  40. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/config.py +0 -0
  41. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/endpoints.py +0 -0
  42. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/errors.py +0 -0
  43. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/project.py +0 -0
  44. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/py.typed +0 -0
  45. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/resources.py +0 -0
  46. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/transport.py +0 -0
  47. {leanwarp-0.2.7 → leanwarp-0.2.9}/src/leanwarp_cloud/updates.py +0 -0
  48. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/__init__.py +0 -0
  49. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/fixtures/lake-manifest-1.1.0.json +0 -0
  50. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/fixtures/lake-manifest-1.2.0.json +0 -0
  51. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_amounts.py +0 -0
  52. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_config.py +0 -0
  53. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_deadline_transport.py +0 -0
  54. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_environment_compatibility.py +0 -0
  55. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_feedback.py +0 -0
  56. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_project.py +0 -0
  57. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_resources.py +0 -0
  58. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_run_limits.py +0 -0
  59. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_setup.py +0 -0
  60. {leanwarp-0.2.7 → leanwarp-0.2.9}/tests/test_syntax_floor.py +0 -0
@@ -2,6 +2,42 @@
2
2
 
3
3
  Update an installed SDK with `leanwarp update`.
4
4
 
5
+ ## 0.2.9
6
+
7
+ - Three proof rewrites, each written into the file by `apply`:
8
+ `have2lemma` moves each named `have` into its own lemma, `simplify-proofs`
9
+ replaces theorem proofs with shorter ones that still check, and
10
+ `repair-proofs` attempts to fill `sorry` holes within the repair limit and
11
+ time budget. LeanWarp returns the rewritten file only once it has no errors,
12
+ keeps every statement, and each theorem repaired or simplified is complete;
13
+ otherwise `status` is `rejected` with a `reason`.
14
+ - The CLI's `check`, `inspect` and `try-tactics` take `--retention short`, and
15
+ the MCP tools `check`, `inspect` and `try_tactics` take `retention`.
16
+ - Inspect a tactic in a completed proof or a proof hole. `no_goals` identifies
17
+ a known empty tactic state. `omitted` counts hidden goals. Compact MCP
18
+ answers preserve complete selections and goals when they fit.
19
+ - Tactic trials share one capture and race. The default limit sums their
20
+ budgets, adds 100 ms, rounds up to seconds and adds 30 seconds, bounded to
21
+ 120–600 seconds. A shorter explicit limit scales the budgets down. An identical
22
+ retry after an upgrade reuses the accepted operation even if the default changed.
23
+ - If every tactic was skipped, `try-tactics` reports no verdict (CLI exit `4`).
24
+ If a trial ran, read its outcome to see whether it closed the goal.
25
+ - A workspace stop can return `stopping`. Billing for that generation has ended
26
+ while cleanup finishes. The Python client sends a stop without a generation
27
+ once. Pass the workspace generation to retry the same stop safely.
28
+ - Draft and strict checks report `timing.imports_ms` when Lean measured import loading.
29
+
30
+ ## 0.2.8
31
+
32
+ - `check`, `inspect` and `try_tactics` take `retention="short"`: a finished
33
+ result is then eligible for removal about 60 seconds after it finishes, so a
34
+ search loop need not delete each one. The default stays `"standard"`.
35
+ - If `apply` reports a `revision_conflict`, it keeps your local files. Check
36
+ whether the edit was written, then use `reconcile` to review what `sync`
37
+ would upload or delete.
38
+ - `apply` run again after an upload whose response was lost reports `applied`
39
+ when that upload landed, instead of asking to run the operation again.
40
+
5
41
  ## 0.2.7
6
42
 
7
43
  - Every result says whether there was a verdict. A check, batch entry or
@@ -15,8 +51,8 @@ Update an installed SDK with `leanwarp update`.
15
51
  accepted. Receipts use the policy `fixed_target_kernel_check_v2`, which
16
52
  `OperationOutcome.verified` requires.
17
53
  - A `check` sent over HTTP is strict unless it says `"strict": false`.
18
- - `suggest` no longer has a `partial` tier: run `sorry2lemma` to give each hole
19
- its own lemma, then `suggest` on it.
54
+ - `suggest` no longer has a `partial` tier. A suggestion must close its
55
+ declaration even if other declarations still have holes.
20
56
  - A batch entry without `timeout` has 60 seconds. A `timeout` the operation
21
57
  cannot honour is refused when it is submitted.
22
58
  - Lean options set in your `lakefile` apply to every check and verification.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: leanwarp
3
- Version: 0.2.7
3
+ Version: 0.2.9
4
4
  Summary: Check and verify Lean proofs on LeanWarp from the command line, MCP or Python
5
5
  Project-URL: Repository, https://github.com/Isagoge-Labs/LeanWarp-SDK
6
6
  Project-URL: Homepage, https://isagoge.in/leanwarp
@@ -51,26 +51,42 @@ command, an MCP server and a Python library.
51
51
  | Operation | What you get | CLI |
52
52
  | --- | --- | --- |
53
53
  | Check | Lean's errors and warnings for a file; `--draft` reuses Lean's work on the unchanged part while you edit. | `leanwarp check` |
54
- | Inspect | The goals and local context at a position in a proof. | `leanwarp inspect` |
54
+ | Inspect | Lean’s goals and hypotheses at a tactic or proof hole. | `leanwarp inspect` |
55
55
  | Try tactics | Several tactics from the same captured goal: which close it, which leave goals, which fail. The file is not edited. | `leanwarp try-tactics` |
56
56
  | Verify | Whether a declaration proves exactly the statement you give, checked by Lean's kernel. | `leanwarp verify` |
57
57
  | Holes | Every `sorry` and `?_` in a file, with its position, and the goals of the first 16. | `leanwarp holes` |
58
58
  | Suggest | A tactic that closes a hole, accepted only if nothing else changes and the proof gains no unproved lemma or extra axiom. `apply` writes it into the file. | `leanwarp suggest`, `leanwarp apply` |
59
59
  | Sorry to lemma | The proof of each theorem that still has a `sorry` moved into a new named lemma the theorem then uses; the lemma keeps its `sorry`. `apply` writes it. | `leanwarp sorry2lemma` |
60
+ | Have to lemma | Each named `have` in a theorem's proof moved into its own lemma, which the `have` then uses. `apply` writes it. | `leanwarp have2lemma` |
61
+ | Simplify proofs | Theorem proofs replaced by shorter tactic proofs that still check. `apply` writes it. | `leanwarp simplify-proofs` |
62
+ | Repair proofs | Try tactics on `sorry` holes within the repair limit and time budget. If `source_changed` is true, run `apply`, then `check` to see what remains. | `leanwarp repair-proofs` |
60
63
  | Declarations | The declarations a file adds, with their types and dependencies. | `leanwarp declarations` |
61
64
  | Check files | Up to 64 files checked in one operation. | `leanwarp check-files` |
62
65
  | Verify batch | Up to 64 inline proofs checked in one operation, without uploading them as files; each result keeps its `custom_id`. | `leanwarp verify-batch` |
63
66
 
64
- The [reference](https://isagoge.in/leanwarp/docs/reference#commands)
65
- lists every command and option; `leanwarp skill --reference` prints it.
67
+ For a hole-free proof in `Main.lean`, inspect the start of `exact` on line 2.
68
+
69
+ ```lean
70
+ example (h : True) : True := by
71
+ exact h
72
+ ```
66
73
 
67
- ### Coming soon
74
+ `leanwarp inspect Main.lean --line 2 --column 3` shows the goal `True` and
75
+ the hypothesis `h : True`. A `goal_status` of `no_goals` means the selected
76
+ tactic state has no remaining goals. With `omitted`, the goals did not fit
77
+ and `context_omitted.goal_contexts` gives their count.
68
78
 
69
- These are planned and not available yet:
79
+ A per-tactic timeout above 60,000 ms is capped at 60,000 ms.
80
+ Tactic trials default to 30 seconds plus the sum of those tactic
81
+ budgets and 100 ms, rounded up and bounded to 120–600 seconds. An explicit
82
+ operation limit shorter than the sum scales down the per-tactic budgets.
83
+
84
+ The [reference](https://isagoge.in/leanwarp/docs/reference#commands)
85
+ lists every command and option; `leanwarp skill --reference` prints it.
70
86
 
71
- - **Proof simplification**: replace a proof with a shorter one that still checks.
72
- - **`have` extraction**: lift named `have` blocks into top-level lemmas.
73
- - **Batch repair**: fill several holes in one operation.
87
+ LeanWarp returns a rewritten file only after checking it: no errors, every
88
+ statement unchanged, nothing added but the reported lemmas, and every theorem a
89
+ repair or simplification edits complete, with no axiom beyond Lean's own.
74
90
 
75
91
  ## Install in two steps
76
92
 
@@ -16,26 +16,42 @@ command, an MCP server and a Python library.
16
16
  | Operation | What you get | CLI |
17
17
  | --- | --- | --- |
18
18
  | Check | Lean's errors and warnings for a file; `--draft` reuses Lean's work on the unchanged part while you edit. | `leanwarp check` |
19
- | Inspect | The goals and local context at a position in a proof. | `leanwarp inspect` |
19
+ | Inspect | Lean’s goals and hypotheses at a tactic or proof hole. | `leanwarp inspect` |
20
20
  | Try tactics | Several tactics from the same captured goal: which close it, which leave goals, which fail. The file is not edited. | `leanwarp try-tactics` |
21
21
  | Verify | Whether a declaration proves exactly the statement you give, checked by Lean's kernel. | `leanwarp verify` |
22
22
  | Holes | Every `sorry` and `?_` in a file, with its position, and the goals of the first 16. | `leanwarp holes` |
23
23
  | Suggest | A tactic that closes a hole, accepted only if nothing else changes and the proof gains no unproved lemma or extra axiom. `apply` writes it into the file. | `leanwarp suggest`, `leanwarp apply` |
24
24
  | Sorry to lemma | The proof of each theorem that still has a `sorry` moved into a new named lemma the theorem then uses; the lemma keeps its `sorry`. `apply` writes it. | `leanwarp sorry2lemma` |
25
+ | Have to lemma | Each named `have` in a theorem's proof moved into its own lemma, which the `have` then uses. `apply` writes it. | `leanwarp have2lemma` |
26
+ | Simplify proofs | Theorem proofs replaced by shorter tactic proofs that still check. `apply` writes it. | `leanwarp simplify-proofs` |
27
+ | Repair proofs | Try tactics on `sorry` holes within the repair limit and time budget. If `source_changed` is true, run `apply`, then `check` to see what remains. | `leanwarp repair-proofs` |
25
28
  | Declarations | The declarations a file adds, with their types and dependencies. | `leanwarp declarations` |
26
29
  | Check files | Up to 64 files checked in one operation. | `leanwarp check-files` |
27
30
  | Verify batch | Up to 64 inline proofs checked in one operation, without uploading them as files; each result keeps its `custom_id`. | `leanwarp verify-batch` |
28
31
 
29
- The [reference](https://isagoge.in/leanwarp/docs/reference#commands)
30
- lists every command and option; `leanwarp skill --reference` prints it.
32
+ For a hole-free proof in `Main.lean`, inspect the start of `exact` on line 2.
33
+
34
+ ```lean
35
+ example (h : True) : True := by
36
+ exact h
37
+ ```
31
38
 
32
- ### Coming soon
39
+ `leanwarp inspect Main.lean --line 2 --column 3` shows the goal `True` and
40
+ the hypothesis `h : True`. A `goal_status` of `no_goals` means the selected
41
+ tactic state has no remaining goals. With `omitted`, the goals did not fit
42
+ and `context_omitted.goal_contexts` gives their count.
33
43
 
34
- These are planned and not available yet:
44
+ A per-tactic timeout above 60,000 ms is capped at 60,000 ms.
45
+ Tactic trials default to 30 seconds plus the sum of those tactic
46
+ budgets and 100 ms, rounded up and bounded to 120–600 seconds. An explicit
47
+ operation limit shorter than the sum scales down the per-tactic budgets.
48
+
49
+ The [reference](https://isagoge.in/leanwarp/docs/reference#commands)
50
+ lists every command and option; `leanwarp skill --reference` prints it.
35
51
 
36
- - **Proof simplification**: replace a proof with a shorter one that still checks.
37
- - **`have` extraction**: lift named `have` blocks into top-level lemmas.
38
- - **Batch repair**: fill several holes in one operation.
52
+ LeanWarp returns a rewritten file only after checking it: no errors, every
53
+ statement unchanged, nothing added but the reported lemmas, and every theorem a
54
+ repair or simplification edits complete, with no axiom beyond Lean's own.
39
55
 
40
56
  ## Install in two steps
41
57
 
@@ -106,8 +106,9 @@ The agent should first read the resources `leanwarp://guide` and
106
106
 
107
107
  - **Setup:** `doctor`, `files`, `environments`, `connect`.
108
108
  - **Proofs:** `check`, `inspect`, `try_tactics`, `verify_target`, `holes`,
109
- `suggest`, `sorry2lemma`, `extract_decls`, `check_files`, `verify_batch`, and
110
- `apply` to write a result into its file.
109
+ `suggest`, `sorry2lemma`, `have2lemma`, `simplify_proofs`, `repair_proofs`,
110
+ `extract_decls`, `check_files`, `verify_batch`, and `apply` to write a result
111
+ into its file.
111
112
  - **Control:** `wait`, `status`, `cancel`, `stop`, `recover`.
112
113
  - **Workspaces and account:** the rest.
113
114
 
@@ -26,14 +26,16 @@ Authorization: Bearer lw_live_…
26
26
  `completed`, `failed` or `cancelled`. The server holds each read until the
27
27
  operation ends or `wait_seconds` (0 to 20) pass, so you don't need to poll
28
28
  quickly.
29
- 6. `POST /workspaces/{workspace_id}/stop` stops the worker.
29
+ 6. `POST /workspaces/{workspace_id}/stop` ends billing for the current workspace generation. A running worker returns `202` with `state: stopping`, its `generation`, and `charge_cutoff_at`. Poll the workspace until it is `stopped`. A workspace with nothing to clean up returns `200`.
30
30
 
31
31
  Steps 3 to 5 can be one request: `POST /workspaces/{workspace_id}/run` takes the
32
32
  files to upload or delete (`files`, `delete_paths`) with the operation (`kind`,
33
- `payload`, and optionally `resource_profile` and `timeout_seconds`). It returns
34
- the new `revision` and the `operation`. Add `?wait_seconds=20` to hold it until
35
- the operation ends. One `Idempotency-Key` covers the upload and the operation;
36
- resending replays whichever already happened. Use a new key for each different
33
+ `payload`, and optionally `resource_profile`, `timeout_seconds` and
34
+ `retention`). `timeout_seconds` limits running the operation; starting a worker
35
+ does not count against it (see below). It returns the new `revision` and the
36
+ `operation`. Add `?wait_seconds=20` to hold it until the operation ends. One
37
+ `Idempotency-Key` covers the upload and the operation; resending replays
38
+ whichever already happened. Use a new key for each different
37
39
  request: the upload commits first, so files sent under a key already used for
38
40
  another operation are committed before that conflict is reported. After a
39
41
  rejected request, `GET /workspaces/{workspace_id}/files` shows whether the upload
@@ -71,7 +73,7 @@ axioms. Send `"strict": false` for a faster draft check while editing.
71
73
  | `GET` | `/operations?ids=A,B,…` | read | Up to 100 operations at once. `&wait_seconds=N` returns as soon as any of them ends, waiting up to 20 seconds. See [Waiting on many operations](#waiting-on-many-operations). |
72
74
  | `POST` | `/operations/{operation_id}/cancel` | execute | Ask to cancel, then poll until it ends. |
73
75
  | `DELETE` | `/operations/{operation_id}` | write or execute | Delete a finished operation's stored request and result. See [Releasing results](#releasing-results). |
74
- | `POST` | `/workspaces/{workspace_id}/stop` | write or execute | Stop the worker. Files are kept. |
76
+ | `POST` | `/workspaces/{workspace_id}/stop` | write or execute | End billing and request cleanup. An optional `generation` query parameter scopes a retry to the generation from the first answer. A retry returns the saved close even if new work has queued. Disconnect sends `require_idle=true` to check for active work on that generation. Files are kept. |
75
77
  | `DELETE` | `/workspaces/{workspace_id}` | write | Delete a workspace. |
76
78
  | `POST` | `/feedback` | any | Report a problem with LeanWarp itself. See [Feedback](#feedback). |
77
79
 
@@ -102,13 +104,16 @@ start at 1, and columns count characters (Unicode code points).
102
104
  | `kind` | `payload` |
103
105
  | --- | --- |
104
106
  | `check` | `file`, `strict` (default `true`; `false` is a draft check, in which `sorry` is only a warning). |
105
- | `inspect` | `file`, `line`, `column`. |
106
- | `try_tactics` | `file`, `line`, `column`, `tactics` (1 to 32), `timeout_ms` per tactic (default 30000). |
107
+ | `inspect` | `file`, `line`, `column`. Select a proof hole or a tactic in a proof. |
108
+ | `try_tactics` | `file`, `line`, `column`, `tactics` (1 to 32), `timeout_ms` per tactic (default 30000). Near the operation's limit, tactics tried together share the time left, and those with no time left are listed in `skipped`. |
107
109
  | `verify_target` | `file`, `candidate_declaration`, `target_statement`, `target_context` (it may import only the environment's packages, never the workspace's modules), `execution_mode` (`reusable` or `fresh`), `timeout` seconds. |
108
110
  | `holes` | `file`, `goals` (default `true`: bounded goals for the first 16 unfinished or unknown placeholders). |
109
- | `suggest` | `file`, `line`, `column`. Optional `tactics` (1 to 32) to use instead of LeanWarp's portfolio, and `timeout_ms` per tactic (learned budgets by default). |
111
+ | `suggest` | `file`, `line`, `column`. Optional `tactics` (1 to 32) to use instead of LeanWarp's portfolio, and `timeout_ms` per tactic (learned budgets by default). Near the operation's limit, tactics tried together share the time left. |
110
112
  | `extract_decls` | `file`. |
111
113
  | `sorry2lemma` | `file`, `max_extractions` (1 to 256, default 64), optional `name_prefix`, `strict_final_check` (default `false`). |
114
+ | `have2lemma` | `file`, `max_extractions` (1 to 256, default 64), optional `name_prefix`. |
115
+ | `simplify_proofs` | `file`. Optional `tactics` (1 to 32, without `sorry` or `admit`) instead of LeanWarp's default list, `timeout_ms` per attempt (1 to 60000, default 10000), `max_simplifications` (1 to 256, default 16), `min_reduction_bytes` (default 1). |
116
+ | `repair_proofs` | `file`. Optional `tactics` (1 to 32, without `sorry` or `admit`) instead of LeanWarp's default list, `timeout_ms` per attempt (1 to 60000, default 10000), `max_repairs` (1 to 256, default 16). The operation attempts repairs within its time budget and repair limit; remaining holes can be `skipped`. Each theorem it edits must end complete. |
112
117
  | `check_files` | `files` (1 to 64 distinct paths), `strict` (default `true`), optional `timeout` seconds per file (default 60), which starts once the file's imports have loaded, except in a file using `native_decide`. It must fit the operation's budget for its entries (see below). |
113
118
  | `verify_batch` | `codes`: 1 to 64 objects `{"custom_id", "proof"}`. Each `custom_id` is unique and 1 to 128 characters, without control characters. Proofs must not be blank. The payload is at most 256 KiB of UTF-8. Also `strict` (default `true`) and optional `timeout` seconds per proof (default 60), which starts once the proof's imports have loaded, except in a proof using `native_decide`. It must fit the operation's budget for its entries (see below). The proofs run in the workspace's environment. They may import its packages, such as Mathlib, but not the workspace's own modules. Such a proof is refused without running: `status` `rejected`, `failure.kind` `policy`, `error.code` `unsupported_import`. A code may add `target`: `{"context", "statement", "declaration"}` (see below). |
114
119
 
@@ -116,6 +121,43 @@ Any `payload` may also carry `lean_options`, an object of Lean options applied a
116
121
  a lakefile's `leanOptions` would be, such as `{"maxSynthPendingDepth": 3}`. Options
117
122
  that could weaken checking are refused.
118
123
 
124
+ An operation's `timeout_seconds` limits execution to 1–600 seconds. The default
125
+ depends on the operation. For example, `check` and `inspect` default to 120 seconds,
126
+ and `suggest`, `simplify_proofs`, `repair_proofs`, `check_files` and
127
+ `verify_batch` to 600.
128
+ For `try_tactics` with N submitted tactics the default in seconds is
129
+ `min(600, max(120, 30 + ceil((N × timeout_ms + 100) / 1000)))`.
130
+ A per-tactic timeout above 60,000 ms is capped at 60,000 ms before calculating
131
+ the default limit or running a race. Each trial reports its `effective_timeout_ms`.
132
+ An explicit limit shorter than the sum scales the per-tactic budgets down.
133
+ Whitespace-equivalent tactics share a trial and each input position receives its
134
+ outcome. When the remaining time cannot fund a race, every input appears in
135
+ `skipped` with reason `operation_budget_exhausted`. A zero-duration engine
136
+ timeout appears in `results`.
137
+
138
+ Inspection returns `selected_hole` or `selected_tactic` and one complete list
139
+ in `goal_contexts`. With `goal_status: no_goals` Lean observed an empty tactic
140
+ state. With `omitted`, `context_omitted.goal_contexts` counts the hidden goals.
141
+ Both have public `status: unavailable`. A usable observation has
142
+ `status: metadata_only`, `observation_only: true` and `retained_proof_state: false`.
143
+ An unknown draft hole may recover goals by capture, with `observation_only: false`.
144
+
145
+ Every stage shares that one limit: preparing the file's local imports,
146
+ capturing its proof state, checking it and running tactic trials. A check or
147
+ verification whose Lean run reaches it returns a `timeout` non-verdict, retryable
148
+ with more time. A batch keeps the entries it finished (see below). Otherwise,
149
+ including a check that reaches it while its imports are still being prepared,
150
+ the operation fails with `operation_timeout`.
151
+
152
+ Starting a worker does not count against `timeout_seconds`, so a file gets the
153
+ same limit on a warm worker as on a cold one. A start has its own limits. It
154
+ fails with `capacity_unavailable` if it is still waiting for capacity 10 minutes
155
+ after the operation's submission, queueing included (whenever the service
156
+ reclaims an operation and must start a worker for it, the wait starts afresh).
157
+ It then has up to 15 minutes to create the worker and 5 more for it to become
158
+ ready (`worker_start_timeout`). Both failures are retryable, and nothing ran.
159
+ Uploading files counts against neither limit.
160
+
119
161
  `suggest`, `check_files` and `verify_batch` stop starting new work after four
120
162
  minutes. Their default `timeout_seconds` is 600, enough for the work still in
121
163
  flight to finish. A lower `timeout_seconds` stops starting new work ten seconds
@@ -173,6 +215,16 @@ with `operation_active`; cancel it or wait. Reading an operation never deletes i
173
215
  Resubmitting a deleted request with the same `Idempotency-Key` answers
174
216
  `operation_expired` and does not run it again.
175
217
 
218
+ A `check`, `inspect` or `try_tactics` can instead ask for short retention: send
219
+ `"retention": "short"` with the operation. Its result is then eligible for
220
+ removal about 60 seconds after it finishes, instead of an hour, so a search loop
221
+ stays within its limits without a `DELETE` for each result. This is not an
222
+ erasure time: history removes results only when it needs room, so a quiet
223
+ workspace may keep one longer, and each workspace's newest operation is always
224
+ kept. Until it is removed, resending the request returns the original result;
225
+ afterwards it answers `operation_expired`, as a deleted one does. Other kinds
226
+ refuse `"short"` with `invalid_request`. The default is `"standard"`.
227
+
176
228
  ### Waiting on many operations
177
229
 
178
230
  `GET /operations?ids=A,B,…&wait_seconds=N` names up to 100 operations and holds the
@@ -191,8 +243,12 @@ key cannot see, or whose result was already deleted, is left out.
191
243
 
192
244
  A completed `suggest` with `status` `closed` returns `patch`. To apply it,
193
245
  replace the UTF-8 bytes from `start_utf8_offset` to `end_utf8_offset` with
194
- `replacement`. A `sorry2lemma` with `source_changed` returns the whole
195
- `transformed_source`. To apply either one:
246
+ `replacement`. A `sorry2lemma`, `have2lemma`, `simplify_proofs` or
247
+ `repair_proofs` with `source_changed` returns the whole `transformed_source`.
248
+ The last three return it only once LeanWarp's audit has accepted the rewritten
249
+ file. If the audit rejects it, the response gives the reason and marks the
250
+ proposed edits as rejected. It returns zero accepted edits and no replacements.
251
+ To apply an accepted edit:
196
252
 
197
253
  1. Check that your copy of the file hashes to `source_sha256`. If it doesn't,
198
254
  don't apply the result.
@@ -280,15 +336,21 @@ twice. Use a new key for each new request.
280
336
 
281
337
  LeanWarp keeps a window of finished history, not all of it (see
282
338
  [limits](../src/leanwarp_cloud/skills/leanwarp/references/usage.md#credentials-credit-and-limits)).
283
- A replay within an hour of the original always returns its result. Later, a
284
- submission whose operation was removed returns `operation_expired` for at least
285
- 7 days, and is not run again. Reading that operation returns `not_found`.
339
+ A replay returns the original result while it is stored. Unless you explicitly
340
+ delete it, history keeps a finished result for at least an hour, or a minute
341
+ with [short retention](#releasing-results). After deletion or removal by history,
342
+ replaying the submission returns `operation_expired` for at least 7 days.
343
+ Reading the removed operation returns `not_found`. `retention` is part of the
344
+ request: leaving it out is the same as `"standard"`, and resending a key with a
345
+ different `retention` is an `idempotency_conflict`.
286
346
 
287
347
  Creating a workspace replays this way until 7 days after the workspace is
288
348
  deleted; after that, the same key creates a new workspace.
289
349
 
290
- Stopping a worker, cancelling an operation and deleting a workspace or a result
291
- need no key: repeating them changes nothing. A repeated workspace delete answers
350
+ Stop, cancel and delete requests need no idempotency key. To retry a stop,
351
+ specify the original workspace generation. A stop without a generation acts on
352
+ the current worker, which may have changed since the first request.
353
+ A repeated workspace delete answers
292
354
  `not_found`, so after a lost response treat that as deleted. A repeated result
293
355
  delete answers `204`.
294
356
 
@@ -319,17 +381,18 @@ do next. It may change. Common codes:
319
381
  | `idempotency_conflict` | 409 | The `Idempotency-Key` was used for a different request. |
320
382
  | `operation_expired` | 409 | The request already ran and its result is no longer stored. It was not run again. |
321
383
  | `operation_active` | 409 | The operation has not finished, so its result cannot be deleted yet. |
322
- | `operation_limit_exceeded` | 429 | The workspace holds the account's limit of operations from the last hour (1,000 by default). |
384
+ | `operation_limit_exceeded` | 429 | The workspace stores the account's limit of operations (1,000 by default). |
323
385
  | `operation_storage_limit_exceeded` | 429 | Stored results, and the space held for queued and running operations, reached the account's limit (512 MiB by default). |
324
386
  | `source_history_limit_exceeded` | 429 | The workspace reached the account's sync limit (1,000 by default) within the last hour, or stored source reached the account's limit (64 MiB by default). |
325
387
  | `workspace_creation_limit_exceeded` | 429 | The account created its limit of workspaces within the last hour (300 by default). |
326
388
 
327
389
  The four limits above free with time, so they answer `429` with `Retry-After`:
328
- the seconds until the oldest record that counts leaves the hour-long window (or
329
- the whole window when nothing is waiting to leave it; for storage held only by
330
- running operations, 30 seconds). Deleting results you have read frees operation
331
- history and storage at once. Stored source frees only when you delete files or
332
- workspaces, so waiting does not help that case. An account's limits can be
390
+ the seconds until enough records that count can be removed, an hour after each
391
+ finished or a minute for short retention (or the whole hour-long window when
392
+ nothing is waiting to leave it; for storage held only by running operations, 30
393
+ seconds). Deleting results you have read frees operation history and storage at
394
+ once. Stored source frees only when you delete files or workspaces, so waiting
395
+ does not help that case. An account's limits can be
333
396
  raised; email contact@isagoge.in.
334
397
 
335
398
  ## Results and failed operations
@@ -393,15 +456,24 @@ is `fixed_target_kernel_check_v2`.
393
456
  produced it. The operation's `build` field names the same build as soon as the
394
457
  operation is dispatched to a worker, while it runs, and is `null` until then. An
395
458
  operation that was interrupted and rerun names the worker that reran it. A workspace's `bundle_id`
396
- is the build its next worker starts on; a running worker keeps its own build
397
- until it stops. The operation's own fields are under `result.result`, and the
459
+ names its current build. After a build update, the next operation starts a new worker. The operation's own fields are under `result.result`, and the
398
460
  [reference](../src/leanwarp_cloud/skills/leanwarp/references/usage.md#results)
399
461
  lists them. Completed operations also have `execution`, which says which worker
400
462
  ran them and what was reused, and `timing`, with `queued_ms`, `worker_ms`,
401
- `upload_ms` and `run_ms`. Parts of `run_ms` appear when Lean timed them:
402
- `elaboration_ms` (checks: importing and checking the file), `proof_state_ms` and
403
- `tactics_ms` (tactic trials: capturing the proof state, then running the
404
- tactics). After dispatch recovery, `queued_ms` is absent rather than an estimate
463
+ `upload_ms` and `run_ms`. On terminal operations, `timing.total_ms` measures
464
+ elapsed service time from enqueue until completion, failure, or cancellation,
465
+ including time spent in earlier attempts after recovery. When a worker was started for the operation,
466
+ `worker_ms` has parts, and may also include other work: `start_wait_ms`
467
+ (waiting for capacity to start one, after the wait in `queued_ms`), `create_ms`
468
+ (creating it) and `ready_ms` (waiting for it to answer). The worker also reports
469
+ its own measures of its start: `isolation_ms` (setting up resource limits and
470
+ metering), `project_ms` (preparing the project) and `engine_start_ms` (starting
471
+ the Lean engine). It times these itself, so they can overlap `create_ms` and
472
+ need not add up to `ready_ms`. Parts of `run_ms` appear when Lean timed them:
473
+ `elaboration_ms` (checks: importing and checking the file), with `imports_ms`
474
+ (loading the imports, such as Mathlib) inside it for draft and strict checks when measured (zero is a measurement),
475
+ `proof_state_ms` and `tactics_ms` (tactic trials: capturing the proof state,
476
+ then running the tactics). After dispatch recovery, `queued_ms` is absent rather than an estimate
405
477
  of earlier attempts. Clients should tolerate absent timing.
406
478
 
407
479
  A service update can interrupt an operation that is running. Most finish during
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "leanwarp"
3
- version = "0.2.7"
3
+ version = "0.2.9"
4
4
  description = "Check and verify Lean proofs on LeanWarp from the command line, MCP or Python"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -201,12 +201,18 @@ def parser() -> argparse.ArgumentParser:
201
201
  )
202
202
 
203
203
  inspect = commands.add_parser(
204
- "inspect", help="show the goals and local context at a position in a proof"
204
+ "inspect",
205
+ help="show goals at a tactic or proof hole",
206
+ description="Show goals at a tactic or proof hole. no_goals means a known empty state. "
207
+ "omitted means the complete goal list did not fit.",
205
208
  )
206
209
  inspect.add_argument("file", metavar="FILE", help="a .lean file in the project")
207
210
 
208
211
  tactics = commands.add_parser(
209
- "try-tactics", help="try tactics at a position without editing the file"
212
+ "try-tactics",
213
+ help="try tactics at a position without editing the file",
214
+ description="Try tactics from one captured goal. The default limit uses the sum of the "
215
+ "tactic budgets plus overhead. A shorter explicit limit scales budgets down.",
210
216
  )
211
217
  tactics.add_argument("file", metavar="FILE", help="a .lean file in the project")
212
218
 
@@ -293,6 +299,59 @@ def parser() -> argparse.ArgumentParser:
293
299
  help="also report whether the result passes a strict check (it keeps the sorrys)",
294
300
  )
295
301
 
302
+ lifts = commands.add_parser(
303
+ "have2lemma",
304
+ help="move each named `have` in a theorem's proof into its own lemma; "
305
+ "`leanwarp apply` writes the new file",
306
+ )
307
+ lifts.add_argument("file", metavar="FILE", help="a .lean file in the project")
308
+ lifts.add_argument(
309
+ "--max", type=int, default=64, metavar="N", help="at most this many, 1 to 256"
310
+ )
311
+ lifts.add_argument("--prefix", metavar="NAME", help="prefix for the generated lemmas")
312
+
313
+ rewrites = []
314
+ for name, noun, help_text in (
315
+ (
316
+ "simplify-proofs",
317
+ "simplifications",
318
+ "replace theorem proofs with shorter ones that still check; "
319
+ "`leanwarp apply` writes the new file",
320
+ ),
321
+ (
322
+ "repair-proofs",
323
+ "repairs",
324
+ "try to repair sorry holes; use `leanwarp apply` when source_changed is true",
325
+ ),
326
+ ):
327
+ rewrite = commands.add_parser(name, help=help_text)
328
+ rewrite.add_argument("file", metavar="FILE", help="a .lean file in the project")
329
+ rewrite.add_argument(
330
+ "--tactic",
331
+ action="append",
332
+ metavar="TACTIC",
333
+ help="a tactic to try instead of LeanWarp's default list; repeat for several",
334
+ )
335
+ rewrite.add_argument(
336
+ "--tactic-timeout",
337
+ type=int,
338
+ default=10_000,
339
+ metavar="MS",
340
+ help="milliseconds per attempt, 1 to 60000 (default 10000)",
341
+ )
342
+ rewrite.add_argument(
343
+ "--max", type=int, default=16, metavar="N", help=f"at most this many {noun}, 1 to 256"
344
+ )
345
+ rewrites.append(rewrite)
346
+ simplify, repair = rewrites
347
+ simplify.add_argument(
348
+ "--min-saving",
349
+ type=int,
350
+ default=1,
351
+ metavar="BYTES",
352
+ help="keep a shorter proof only if it saves at least this many bytes (default 1)",
353
+ )
354
+
296
355
  batch = commands.add_parser(
297
356
  "check-files", help="check several files in one operation (up to 64)"
298
357
  )
@@ -332,7 +391,8 @@ def parser() -> argparse.ArgumentParser:
332
391
 
333
392
  commands.add_parser(
334
393
  "apply",
335
- help="write the latest suggest or sorry2lemma result into its file and upload it",
394
+ help="write the latest suggest, sorry2lemma, have2lemma, simplify-proofs or "
395
+ "repair-proofs result into its file and upload it",
336
396
  )
337
397
 
338
398
  for operation in (
@@ -344,6 +404,9 @@ def parser() -> argparse.ArgumentParser:
344
404
  holes,
345
405
  declarations,
346
406
  obligations,
407
+ lifts,
408
+ simplify,
409
+ repair,
347
410
  batch,
348
411
  proofs,
349
412
  ):
@@ -365,6 +428,14 @@ def parser() -> argparse.ArgumentParser:
365
428
  help="stop the operation on the server after this long, 1 to 600",
366
429
  )
367
430
 
431
+ for operation in (check, inspect, tactics):
432
+ operation.add_argument(
433
+ "--retention",
434
+ choices=("standard", "short"),
435
+ help="short: the result may be removed about a minute after it finishes, "
436
+ "so a search loop need not delete each one (default: standard)",
437
+ )
438
+
368
439
  wait = commands.add_parser("wait", help="wait for the latest operation's result")
369
440
  waiting = wait.add_mutually_exclusive_group()
370
441
  waiting.add_argument(
@@ -385,7 +456,9 @@ def parser() -> argparse.ArgumentParser:
385
456
  commands.add_parser("sync", help="upload changed files (operations also sync automatically)")
386
457
  commands.add_parser("cancel", help="cancel the latest operation")
387
458
  stop = commands.add_parser("stop", help="stop the worker; saved files are kept")
388
- stop.add_argument(
459
+ stop_options = stop.add_mutually_exclusive_group()
460
+ stop_options.add_argument("--generation", type=int, help="retry the close for this generation")
461
+ stop_options.add_argument(
389
462
  "--delete",
390
463
  action="store_true",
391
464
  help="also delete a workspace made by `connect --ephemeral`, and disconnect",
@@ -587,6 +660,7 @@ def _operation(project: ProjectSession, args: argparse.Namespace) -> dict[str, A
587
660
  *_request(args),
588
661
  wait_seconds=0 if args.block else inline,
589
662
  timeout_seconds=args.execution_timeout,
663
+ retention=getattr(args, "retention", None),
590
664
  )
591
665
  if args.block and not OperationOutcome(operation).terminal:
592
666
  return project.wait(
@@ -613,6 +687,18 @@ def _request(args: argparse.Namespace) -> tuple[str, dict[str, Any]]:
613
687
  payload.update(max_extractions=args.max, strict_final_check=args.strict_final_check)
614
688
  if args.prefix is not None:
615
689
  payload["name_prefix"] = args.prefix
690
+ elif kind == "have2lemma":
691
+ payload["max_extractions"] = args.max
692
+ if args.prefix is not None:
693
+ payload["name_prefix"] = args.prefix
694
+ elif kind in {"simplify_proofs", "repair_proofs"}:
695
+ payload["timeout_ms"] = args.tactic_timeout
696
+ if kind == "simplify_proofs":
697
+ payload.update(max_simplifications=args.max, min_reduction_bytes=args.min_saving)
698
+ else:
699
+ payload["max_repairs"] = args.max
700
+ if args.tactic:
701
+ payload["tactics"] = args.tactic
616
702
  elif kind == "check_files":
617
703
  payload.update(files=args.files, strict=not args.draft)
618
704
  if args.file_timeout is not None:
@@ -668,6 +754,8 @@ def main(argv: list[str] | None = None) -> int:
668
754
  root.error("check takes a FILE or --all")
669
755
  if args.command == "check" and args.all and args.wait is not None:
670
756
  root.error("check --all always waits until it is done; drop --wait")
757
+ if args.command == "check" and args.all and args.retention is not None:
758
+ root.error("--retention applies to one file's check; drop it with --all")
671
759
  if args.command == "wait" and args.execution_timeout is not None and not args.block:
672
760
  root.error("--execution-timeout on wait needs --block")
673
761
  if args.command == "setup" and args.remove and (args.refresh or args.no_mcp):
@@ -778,7 +866,7 @@ def main(argv: list[str] | None = None) -> int:
778
866
  _emit(_export(project, args.output, args.workspace))
779
867
  return 0
780
868
  if args.command == "stop":
781
- stopped = project.stop(delete=args.delete)
869
+ stopped = project.stop(delete=args.delete, generation=args.generation)
782
870
  _emit(stopped)
783
871
  # Tearing down that left the workspace in place did not finish its job.
784
872
  return 2 if args.delete and not stopped["deleted"] else 0