leanwarp 0.2.8__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.
- {leanwarp-0.2.8 → leanwarp-0.2.9}/CHANGELOG.md +27 -2
- {leanwarp-0.2.8 → leanwarp-0.2.9}/PKG-INFO +25 -9
- {leanwarp-0.2.8 → leanwarp-0.2.9}/README.md +24 -8
- {leanwarp-0.2.8 → leanwarp-0.2.9}/docs/agents.md +3 -2
- {leanwarp-0.2.8 → leanwarp-0.2.9}/docs/http-api.md +41 -12
- {leanwarp-0.2.8 → leanwarp-0.2.9}/pyproject.toml +1 -1
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/cli.py +93 -5
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/client.py +106 -5
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/compact.py +9 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/edits.py +9 -8
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/mcp_server.py +123 -16
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/outcome.py +30 -8
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/session.py +45 -25
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/skills/leanwarp/SKILL.md +25 -12
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/skills/leanwarp/references/usage.md +79 -43
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_ci.py +24 -5
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_client.py +1 -1
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_install.py +2 -1
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_mcp.py +28 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_retries.py +20 -10
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_session.py +41 -11
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_tools.py +48 -1
- {leanwarp-0.2.8 → leanwarp-0.2.9}/.gitignore +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/LICENSE +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/docs/README.md +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/docs/assets/leanwarp-banner.svg +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/docs/getting-started.md +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/examples/lean-4.35/.gitignore +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/examples/lean-4.35/LeanWarpExample.lean +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/examples/lean-4.35/README.md +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/examples/lean-4.35/lake-manifest.json +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/examples/lean-4.35/lakefile.toml +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/examples/lean-4.35/lean-toolchain +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/__init__.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/_toml.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/_version.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/agents.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/amounts.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/config.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/endpoints.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/errors.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/project.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/py.typed +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/resources.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/transport.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/src/leanwarp_cloud/updates.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/__init__.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/fixtures/lake-manifest-1.1.0.json +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/fixtures/lake-manifest-1.2.0.json +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_amounts.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_config.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_deadline_transport.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_environment_compatibility.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_feedback.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_project.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_replay.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_resources.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_run_limits.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_setup.py +0 -0
- {leanwarp-0.2.8 → leanwarp-0.2.9}/tests/test_syntax_floor.py +0 -0
|
@@ -2,6 +2,31 @@
|
|
|
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
|
+
|
|
5
30
|
## 0.2.8
|
|
6
31
|
|
|
7
32
|
- `check`, `inspect` and `try_tactics` take `retention="short"`: a finished
|
|
@@ -26,8 +51,8 @@ Update an installed SDK with `leanwarp update`.
|
|
|
26
51
|
accepted. Receipts use the policy `fixed_target_kernel_check_v2`, which
|
|
27
52
|
`OperationOutcome.verified` requires.
|
|
28
53
|
- A `check` sent over HTTP is strict unless it says `"strict": false`.
|
|
29
|
-
- `suggest` no longer has a `partial` tier
|
|
30
|
-
|
|
54
|
+
- `suggest` no longer has a `partial` tier. A suggestion must close its
|
|
55
|
+
declaration even if other declarations still have holes.
|
|
31
56
|
- A batch entry without `timeout` has 60 seconds. A `timeout` the operation
|
|
32
57
|
cannot honour is refused when it is submitted.
|
|
33
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.
|
|
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 |
|
|
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
|
-
|
|
65
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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 |
|
|
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
|
-
|
|
30
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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`, `
|
|
110
|
-
`apply` to write a result
|
|
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,7 +26,7 @@ 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`
|
|
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`,
|
|
@@ -73,7 +73,7 @@ axioms. Send `"strict": false` for a faster draft check while editing.
|
|
|
73
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). |
|
|
74
74
|
| `POST` | `/operations/{operation_id}/cancel` | execute | Ask to cancel, then poll until it ends. |
|
|
75
75
|
| `DELETE` | `/operations/{operation_id}` | write or execute | Delete a finished operation's stored request and result. See [Releasing results](#releasing-results). |
|
|
76
|
-
| `POST` | `/workspaces/{workspace_id}/stop` | write or execute |
|
|
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. |
|
|
77
77
|
| `DELETE` | `/workspaces/{workspace_id}` | write | Delete a workspace. |
|
|
78
78
|
| `POST` | `/feedback` | any | Report a problem with LeanWarp itself. See [Feedback](#feedback). |
|
|
79
79
|
|
|
@@ -104,13 +104,16 @@ start at 1, and columns count characters (Unicode code points).
|
|
|
104
104
|
| `kind` | `payload` |
|
|
105
105
|
| --- | --- |
|
|
106
106
|
| `check` | `file`, `strict` (default `true`; `false` is a draft check, in which `sorry` is only a warning). |
|
|
107
|
-
| `inspect` | `file`, `line`, `column`. |
|
|
107
|
+
| `inspect` | `file`, `line`, `column`. Select a proof hole or a tactic in a proof. |
|
|
108
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`. |
|
|
109
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. |
|
|
110
110
|
| `holes` | `file`, `goals` (default `true`: bounded goals for the first 16 unfinished or unknown placeholders). |
|
|
111
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. |
|
|
112
112
|
| `extract_decls` | `file`. |
|
|
113
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. |
|
|
114
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). |
|
|
115
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). |
|
|
116
119
|
|
|
@@ -119,7 +122,26 @@ a lakefile's `leanOptions` would be, such as `{"maxSynthPendingDepth": 3}`. Opti
|
|
|
119
122
|
that could weaken checking are refused.
|
|
120
123
|
|
|
121
124
|
An operation's `timeout_seconds` limits execution to 1–600 seconds. The default
|
|
122
|
-
depends on the operation. For example, `check` and `inspect` default to 120 seconds
|
|
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
|
+
|
|
123
145
|
Every stage shares that one limit: preparing the file's local imports,
|
|
124
146
|
capturing its proof state, checking it and running tactic trials. A check or
|
|
125
147
|
verification whose Lean run reaches it returns a `timeout` non-verdict, retryable
|
|
@@ -221,8 +243,12 @@ key cannot see, or whose result was already deleted, is left out.
|
|
|
221
243
|
|
|
222
244
|
A completed `suggest` with `status` `closed` returns `patch`. To apply it,
|
|
223
245
|
replace the UTF-8 bytes from `start_utf8_offset` to `end_utf8_offset` with
|
|
224
|
-
`replacement`. A `sorry2lemma`
|
|
225
|
-
`
|
|
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:
|
|
226
252
|
|
|
227
253
|
1. Check that your copy of the file hashes to `source_sha256`. If it doesn't,
|
|
228
254
|
don't apply the result.
|
|
@@ -321,8 +347,10 @@ different `retention` is an `idempotency_conflict`.
|
|
|
321
347
|
Creating a workspace replays this way until 7 days after the workspace is
|
|
322
348
|
deleted; after that, the same key creates a new workspace.
|
|
323
349
|
|
|
324
|
-
|
|
325
|
-
|
|
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
|
|
326
354
|
`not_found`, so after a lost response treat that as deleted. A repeated result
|
|
327
355
|
delete answers `204`.
|
|
328
356
|
|
|
@@ -428,12 +456,13 @@ is `fixed_target_kernel_check_v2`.
|
|
|
428
456
|
produced it. The operation's `build` field names the same build as soon as the
|
|
429
457
|
operation is dispatched to a worker, while it runs, and is `null` until then. An
|
|
430
458
|
operation that was interrupted and rerun names the worker that reran it. A workspace's `bundle_id`
|
|
431
|
-
|
|
432
|
-
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
|
|
433
460
|
[reference](../src/leanwarp_cloud/skills/leanwarp/references/usage.md#results)
|
|
434
461
|
lists them. Completed operations also have `execution`, which says which worker
|
|
435
462
|
ran them and what was reused, and `timing`, with `queued_ms`, `worker_ms`,
|
|
436
|
-
`upload_ms` and `run_ms`.
|
|
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,
|
|
437
466
|
`worker_ms` has parts, and may also include other work: `start_wait_ms`
|
|
438
467
|
(waiting for capacity to start one, after the wait in `queued_ms`), `create_ms`
|
|
439
468
|
(creating it) and `ready_ms` (waiting for it to answer). The worker also reports
|
|
@@ -442,7 +471,7 @@ metering), `project_ms` (preparing the project) and `engine_start_ms` (starting
|
|
|
442
471
|
the Lean engine). It times these itself, so they can overlap `create_ms` and
|
|
443
472
|
need not add up to `ready_ms`. Parts of `run_ms` appear when Lean timed them:
|
|
444
473
|
`elaboration_ms` (checks: importing and checking the file), with `imports_ms`
|
|
445
|
-
(loading the imports, such as Mathlib) inside it for strict checks,
|
|
474
|
+
(loading the imports, such as Mathlib) inside it for draft and strict checks when measured (zero is a measurement),
|
|
446
475
|
`proof_state_ms` and `tactics_ms` (tactic trials: capturing the proof state,
|
|
447
476
|
then running the tactics). After dispatch recovery, `queued_ms` is absent rather than an estimate
|
|
448
477
|
of earlier attempts. Clients should tolerate absent timing.
|
|
@@ -201,12 +201,18 @@ def parser() -> argparse.ArgumentParser:
|
|
|
201
201
|
)
|
|
202
202
|
|
|
203
203
|
inspect = commands.add_parser(
|
|
204
|
-
"inspect",
|
|
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",
|
|
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
|
|
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.
|
|
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
|
|
@@ -48,6 +48,9 @@ OperationKind = Literal[
|
|
|
48
48
|
"holes",
|
|
49
49
|
"extract_decls",
|
|
50
50
|
"sorry2lemma",
|
|
51
|
+
"have2lemma",
|
|
52
|
+
"simplify_proofs",
|
|
53
|
+
"repair_proofs",
|
|
51
54
|
"check_files",
|
|
52
55
|
"verify_batch",
|
|
53
56
|
]
|
|
@@ -634,6 +637,84 @@ class LeanWarpCloud:
|
|
|
634
637
|
idempotency_key=idempotency_key,
|
|
635
638
|
)
|
|
636
639
|
|
|
640
|
+
def have2lemma(
|
|
641
|
+
self,
|
|
642
|
+
workspace_id: str,
|
|
643
|
+
file: str,
|
|
644
|
+
*,
|
|
645
|
+
expected_revision: int,
|
|
646
|
+
max_extractions: int = 64,
|
|
647
|
+
name_prefix: str | None = None,
|
|
648
|
+
idempotency_key: str | None = None,
|
|
649
|
+
) -> dict[str, Any]:
|
|
650
|
+
"""Lift each named `have` into its own lemma; the file is not changed."""
|
|
651
|
+
payload: dict[str, Any] = {"file": file, "max_extractions": max_extractions}
|
|
652
|
+
if name_prefix is not None:
|
|
653
|
+
payload["name_prefix"] = name_prefix
|
|
654
|
+
return self.submit(
|
|
655
|
+
workspace_id,
|
|
656
|
+
"have2lemma",
|
|
657
|
+
expected_revision=expected_revision,
|
|
658
|
+
payload=payload,
|
|
659
|
+
idempotency_key=idempotency_key,
|
|
660
|
+
)
|
|
661
|
+
|
|
662
|
+
def simplify_proofs(
|
|
663
|
+
self,
|
|
664
|
+
workspace_id: str,
|
|
665
|
+
file: str,
|
|
666
|
+
*,
|
|
667
|
+
expected_revision: int,
|
|
668
|
+
tactics: list[str] | None = None,
|
|
669
|
+
timeout_ms: int = 10_000,
|
|
670
|
+
max_simplifications: int = 16,
|
|
671
|
+
min_reduction_bytes: int = 1,
|
|
672
|
+
idempotency_key: str | None = None,
|
|
673
|
+
) -> dict[str, Any]:
|
|
674
|
+
"""Replace theorem proofs with shorter ones that still check; the file is not changed."""
|
|
675
|
+
payload: dict[str, Any] = {
|
|
676
|
+
"file": file,
|
|
677
|
+
"timeout_ms": timeout_ms,
|
|
678
|
+
"max_simplifications": max_simplifications,
|
|
679
|
+
"min_reduction_bytes": min_reduction_bytes,
|
|
680
|
+
}
|
|
681
|
+
if tactics is not None:
|
|
682
|
+
payload["tactics"] = tactics
|
|
683
|
+
return self.submit(
|
|
684
|
+
workspace_id,
|
|
685
|
+
"simplify_proofs",
|
|
686
|
+
expected_revision=expected_revision,
|
|
687
|
+
payload=payload,
|
|
688
|
+
idempotency_key=idempotency_key,
|
|
689
|
+
)
|
|
690
|
+
|
|
691
|
+
def repair_proofs(
|
|
692
|
+
self,
|
|
693
|
+
workspace_id: str,
|
|
694
|
+
file: str,
|
|
695
|
+
*,
|
|
696
|
+
expected_revision: int,
|
|
697
|
+
tactics: list[str] | None = None,
|
|
698
|
+
timeout_ms: int = 10_000,
|
|
699
|
+
max_repairs: int = 16,
|
|
700
|
+
idempotency_key: str | None = None,
|
|
701
|
+
) -> dict[str, Any]:
|
|
702
|
+
"""Try to repair `sorry` holes within the limits. Leaves the local file unchanged."""
|
|
703
|
+
payload: dict[str, Any] = {
|
|
704
|
+
"file": file,
|
|
705
|
+
"timeout_ms": timeout_ms,
|
|
706
|
+
"max_repairs": max_repairs,
|
|
707
|
+
}
|
|
708
|
+
if tactics is not None:
|
|
709
|
+
payload["tactics"] = tactics
|
|
710
|
+
return self.submit(
|
|
711
|
+
workspace_id,
|
|
712
|
+
"repair_proofs",
|
|
713
|
+
expected_revision=expected_revision,
|
|
714
|
+
payload=payload,
|
|
715
|
+
idempotency_key=idempotency_key,
|
|
716
|
+
)
|
|
717
|
+
|
|
637
718
|
def check_files(
|
|
638
719
|
self,
|
|
639
720
|
workspace_id: str,
|
|
@@ -814,11 +895,31 @@ class LeanWarpCloud:
|
|
|
814
895
|
"POST", f"operations/{_segment(operation_id)}/cancel", deadline=deadline, retry=True
|
|
815
896
|
)
|
|
816
897
|
|
|
817
|
-
def stop(
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
898
|
+
def stop(
|
|
899
|
+
self,
|
|
900
|
+
workspace_id: str,
|
|
901
|
+
*,
|
|
902
|
+
generation: int | None = None,
|
|
903
|
+
require_idle: bool = False,
|
|
904
|
+
deadline: float | None = None,
|
|
905
|
+
) -> dict[str, Any]:
|
|
906
|
+
"""End billing for this generation. GET the workspace to follow cleanup.
|
|
907
|
+
|
|
908
|
+
Pass the generation from a prior response to retry that close safely
|
|
909
|
+
across restarts. An unqualified stop acts on the current generation. Set
|
|
910
|
+
require_idle to check for active operations even when replaying a close.
|
|
911
|
+
"""
|
|
912
|
+
path = f"workspaces/{_segment(workspace_id)}/stop"
|
|
913
|
+
query: dict[str, str] = {}
|
|
914
|
+
if generation is not None:
|
|
915
|
+
if type(generation) is not int or not 0 <= generation < 2**63:
|
|
916
|
+
raise UsageError("generation must be a nonnegative 64-bit integer")
|
|
917
|
+
query["generation"] = str(generation)
|
|
918
|
+
if require_idle:
|
|
919
|
+
query["require_idle"] = "true"
|
|
920
|
+
if query:
|
|
921
|
+
path += "?" + urlencode(query)
|
|
922
|
+
return self._request("POST", path, deadline=deadline, retry=generation is not None)
|
|
822
923
|
|
|
823
924
|
def delete_operation(self, operation_id: str, *, deadline: float | None = None) -> None:
|
|
824
925
|
"""Delete a finished operation's stored request and result now, to free the
|
|
@@ -44,6 +44,15 @@ def compact(operation: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
44
44
|
shown = summary(operation)
|
|
45
45
|
if not isinstance(result, Mapping):
|
|
46
46
|
return shown
|
|
47
|
+
if operation.get("kind") == "inspect":
|
|
48
|
+
candidate = {**shown, "result": result}
|
|
49
|
+
if len(json.dumps(candidate, ensure_ascii=False).encode("utf-8")) <= _BUDGET_BYTES:
|
|
50
|
+
return candidate
|
|
51
|
+
return {
|
|
52
|
+
**shown,
|
|
53
|
+
"omitted": {f"result.{key}": _size(value) for key, value in result.items()},
|
|
54
|
+
"hint": 'Request detail="full" to read the complete inspection.',
|
|
55
|
+
}
|
|
47
56
|
counts = _severities(result.get("diagnostics"))
|
|
48
57
|
if counts:
|
|
49
58
|
shown["counts"] = counts
|