@codacy/verity-cli 0.33.3-experimental.52f1656 → 0.33.3-experimental.53cd005
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.
- package/bin/verity.js +12183 -4727
- package/data/grammars/tree-sitter-go.wasm +0 -0
- package/data/grammars/tree-sitter-java.wasm +0 -0
- package/data/grammars/tree-sitter-javascript.wasm +0 -0
- package/data/grammars/tree-sitter-python.wasm +0 -0
- package/data/grammars/tree-sitter-tsx.wasm +0 -0
- package/data/grammars/tree-sitter-typescript.wasm +0 -0
- package/data/grammars/web-tree-sitter.wasm +0 -0
- package/data/skills/verity-prove/SKILL.md +95 -134
- package/package.json +9 -2
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,174 +1,135 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: >-
|
|
3
|
-
Formally verify a small, risky piece of code with a Lean 4 model
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
Formally verify a small, risky piece of code with a Lean 4 model written by the
|
|
4
|
+
Verity service: rank candidates from git history and the user's hint, CONFIRM with
|
|
5
|
+
the user which code to model, have the service generate the model, check it locally
|
|
6
|
+
with `verity prove check`, and replay any counterexample on the real code before
|
|
7
|
+
calling it a bug. Use when the user asks to verify, prove, or model-check code, or
|
|
8
|
+
asks "can this race / double run / fail open?". Anything typed after /verity-prove
|
|
9
|
+
is the user's hint: the file, function, or worry to check.
|
|
9
10
|
---
|
|
10
11
|
# /verity-prove — Formal verification of small pieces of code
|
|
11
12
|
|
|
12
13
|
**The words after `/verity-prove` are the hint.** `/verity-prove` alone means "find me
|
|
13
14
|
something worth checking"; `/verity-prove can the Stripe webhook double-charge on a
|
|
14
|
-
redelivered event?`
|
|
15
|
-
|
|
15
|
+
redelivered event?` names the target and the worry. Carry it through every step as
|
|
16
|
+
`$ARGUMENTS`.
|
|
16
17
|
|
|
17
|
-
Verity keeps **Lean 4 models of the riskiest code**, not of the codebase
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
code. When it holds you know exactly how far it was checked.
|
|
18
|
+
Verity keeps **Lean 4 models of the riskiest code**, not of the codebase: a few dozen
|
|
19
|
+
lines that abstract ONE function and check a few properties by exhaustive bounded
|
|
20
|
+
search. When a property fails you get the **shortest sequence of actions** that breaks
|
|
21
|
+
it — a hypothesis to replay on the real code.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
**The service does the work; you orchestrate and present.** Ranking, writing the model
|
|
24
|
+
and replaying its counterexample all run on the Verity service through the CLI. You
|
|
25
|
+
do not search the codebase by hand, read the Lean library, or write Lean yourself
|
|
26
|
+
unless a step below says so. Each step is one command; read its output, decide, move on.
|
|
27
|
+
Lean runs on this machine only because the user asked for it; nothing here blocks a
|
|
28
|
+
commit or a push.
|
|
26
29
|
|
|
27
30
|
## The flow
|
|
28
31
|
|
|
29
|
-
### 1.
|
|
32
|
+
### 1. Candidates — one command
|
|
30
33
|
|
|
31
34
|
```bash
|
|
32
|
-
verity prove candidates --
|
|
33
|
-
verity prove candidates --
|
|
34
|
-
verity prove candidates src/payments # scoped to a path
|
|
35
|
+
verity prove candidates --hint "$ARGUMENTS" --json # hint given
|
|
36
|
+
verity prove candidates --limit 8 --json # no hint
|
|
35
37
|
```
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
The hint **widens the pool** (files it names by path or content come first) and the
|
|
40
|
+
service ranks it, naming a symbol and the properties worth checking per file. Do not
|
|
41
|
+
search for the code yourself: if the ranker's list does not contain what the user
|
|
42
|
+
meant, say so and ask them for the file or function. A named file or function in the
|
|
43
|
+
hint skips ranking: go straight to step 2 with it.
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
own words ("can the webhook double-charge?", "does the retry ever lose the feedback?"):
|
|
45
|
+
### 2. Confirm with the user — always
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
**Do not generate a model until the user has said which code.** Present at most three
|
|
48
|
+
candidates in one short message: file, the symbol the ranker named, the first property
|
|
49
|
+
it suggested, the reason. Ask. Their answer is the scope; do not widen it. If the hint
|
|
50
|
+
is a worry in the user's words, it becomes an `intent` property — that needs no further
|
|
51
|
+
confirmation, they just gave it.
|
|
46
52
|
|
|
47
|
-
A
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
so the user sees what else the history says — but the hint decides.
|
|
53
|
+
A hint that names the code, or a candidate the user saw in an earlier session, is
|
|
54
|
+
**not** a confirmation of the exact symbol and property. Still ask, in one line:
|
|
55
|
+
"I'll model `<file>#<symbol>` for `<property>` — go ahead?" It costs the user one word.
|
|
51
56
|
|
|
52
|
-
###
|
|
57
|
+
### 3. Set up once per repo
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
pick one, name something else, or narrow the property. Their answer is the scope; do not
|
|
58
|
-
widen it.
|
|
59
|
+
```bash
|
|
60
|
+
verity prove init
|
|
61
|
+
```
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
If Lean is missing, say what will be installed and where before running
|
|
64
|
+
`verity lean install` (official release, ≈800 MB download, 2.7 GB on disk, into
|
|
65
|
+
`~/.verity/lean`). Everything else needs only `verity login`.
|
|
62
66
|
|
|
63
|
-
###
|
|
67
|
+
### 4. Generate the model — one command
|
|
64
68
|
|
|
65
69
|
```bash
|
|
66
|
-
verity prove
|
|
70
|
+
verity prove generate src/pay.ts#charge --hint "$ARGUMENTS"
|
|
71
|
+
verity prove generate src/handler.ts --lines 120-180 --hint "$ARGUMENTS" # a region
|
|
67
72
|
```
|
|
68
73
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
###
|
|
78
|
-
|
|
79
|
-
Rules that keep models small and honest:
|
|
80
|
-
|
|
81
|
-
- **One symbol.** The header names it: `Verity.model { name, abstracts := [{ file, symbol, sha256 }] }`.
|
|
82
|
-
Get the hash with `verity prove hash <file>`. `verity prove check` reports drift when the file changes.
|
|
83
|
-
When the code is a *region* rather than a named function (a branch inside a large
|
|
84
|
-
handler), add `lines := "a-b"` (1-based, inclusive) — `verity prove replay` needs it
|
|
85
|
-
to know which real lines must run.
|
|
86
|
-
- **State = only what the property reads.** Actions = the operations that can interleave
|
|
87
|
-
(a retry, a second call, a concurrent writer). Steps = what the code does, not what it should.
|
|
88
|
-
- **Properties are tagged.** `kind := .structural` for the catalogue (idempotence, no lost
|
|
89
|
-
update, status only moves forward, retries terminate, never fails open, bounded size,
|
|
90
|
-
check-then-act is atomic, no double effect). `kind := .intent` **only** when a human
|
|
91
|
-
wrote the expectation down — a doc comment, an ADR, a ticket, a Standard rule — and
|
|
92
|
-
`source :=` cites it. Never invent intent.
|
|
93
|
-
- **End with the checks.** `#eval Verity.model …` then one `#eval Verity.check …` per
|
|
94
|
-
property (bounded exploration), `Verity.checkData` for input properties, `Verity.proved`
|
|
95
|
-
only beside a real theorem. `sorry` fails the run.
|
|
96
|
-
- Keep it under ~120 lines. If it wants more, the scope is wrong — go back to step 2.
|
|
97
|
-
|
|
98
|
-
`Models/README.md` has the skeleton; `cli/tests/fixtures/proofs/SeedRunner.lean` in
|
|
99
|
-
Verity's own repo is a worked example (the VRT-243 seed-duplication bug).
|
|
100
|
-
|
|
101
|
-
### 5. Check it
|
|
74
|
+
The service writes the model, the linter fences it, this machine elaborates it, with
|
|
75
|
+
up to **3** rounds on compiler errors — all inside the command. It prints the check:
|
|
76
|
+
per property `✓ holds to bound k`, `✗ COUNTEREXAMPLE` with the trace, or `? inconclusive`.
|
|
77
|
+
Only if it ends with "no model elaborated" do you write one by hand from
|
|
78
|
+
`.verity/proofs/Models/README.md` (one symbol, ≤ ~120 lines, `#eval Verity.model …`
|
|
79
|
+
header, one `#eval Verity.check …` per property, tagged `.structural` or `.intent` with
|
|
80
|
+
`source :=`); check it with `verity prove check <Name>`.
|
|
81
|
+
|
|
82
|
+
### 5. Replay before you call it a bug — one command
|
|
102
83
|
|
|
103
84
|
```bash
|
|
104
|
-
verity prove
|
|
105
|
-
verity prove
|
|
106
|
-
verity prove check <Name> --json # for scripts
|
|
85
|
+
verity prove replay <Name> # every counterexample
|
|
86
|
+
verity prove replay <Name> --property P2 # one
|
|
107
87
|
```
|
|
108
88
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
only git-tracked files are ever read — and requires three things before accepting
|
|
138
|
-
its answer: code actually ran (a shell call with output), the real function's lines
|
|
139
|
-
appear verbatim in what it wrote, and the harness itself printed
|
|
140
|
-
`REPLAY_RESULT=reproduced`. `REPRODUCED` → the
|
|
141
|
-
real code does this. `DIVERGED` → the model is wrong about the code. `UNVERIFIED` →
|
|
142
|
-
not evidence either way. `UNREPLAYABLE` → it could not run the function faithfully.
|
|
143
|
-
Read its reason: the stubs it chose are where a false reproduction hides.
|
|
144
|
-
2. When the replay is unverified or unreplayable — or the code needs a runtime the
|
|
145
|
-
container lacks (Deno edge functions, a real database) — replay by hand: read the
|
|
146
|
-
real function again, map every trace action to a real call, and reproduce it with a
|
|
147
|
-
throwaway harness in a scratch directory that loads the real module and stubs only
|
|
148
|
-
I/O boundaries. **Never edit the user's source files to do this.**
|
|
149
|
-
3. Reproduced → report it as a bug, with the trace and the reproduction. Not reproduced
|
|
150
|
-
→ the model is wrong (`model-divergence`): say so, fix the model, do not report a bug.
|
|
151
|
-
|
|
152
|
-
This is the rule Verity applies everywhere (memory: *replay formal counterexamples
|
|
153
|
-
against changed code before blocking*). A model that finds a bug in itself is noise.
|
|
154
|
-
|
|
155
|
-
### 7. Report, in a few lines
|
|
156
|
-
|
|
157
|
-
State what was modelled, what was checked to what bound, what was refuted and whether
|
|
158
|
-
it replayed, and what remains `intent` awaiting the user's confirmation. **Never offer
|
|
159
|
-
to commit the model** — `.verity/proofs/` is machine-local and ignores itself; models
|
|
160
|
-
would only confuse reviewers. What reaches the team is the bug report and, when asked,
|
|
161
|
-
the fix. Then record the outcome:
|
|
89
|
+
The service replays the trace on the real code in a network-less container and accepts
|
|
90
|
+
an answer only when code ran, the real function's lines appear verbatim in the harness,
|
|
91
|
+
and the harness itself printed `REPLAY_RESULT=reproduced`. A model's counterexamples
|
|
92
|
+
replay in parallel, so the command takes about as long as one replay (~30 s). **Run it
|
|
93
|
+
in the foreground and wait for it**: do not background it, do other work, or report
|
|
94
|
+
before every verdict is in. Read the verdict:
|
|
95
|
+
|
|
96
|
+
- **REPRODUCED** — the real code does this. **This is final: do not replay by hand
|
|
97
|
+
as well.** Report it as a bug (step 6).
|
|
98
|
+
- **DIVERGED** — the model is wrong about the code. Revise it **at most twice**, each
|
|
99
|
+
time saying what the replay showed:
|
|
100
|
+
`verity prove generate <target> --revise <Name> --note "<what the replay showed>"`,
|
|
101
|
+
then replay again. After two divergences, report "no faithful model found for
|
|
102
|
+
`<symbol>`" — that is a valid result, not a bug.
|
|
103
|
+
- **UNVERIFIED / UNREPLAYABLE** — not evidence either way. Only now replay by hand:
|
|
104
|
+
a throwaway harness in a scratch directory that loads the real module and stubs only
|
|
105
|
+
I/O boundaries **in memory**. Never edit the user's source files, and never read from
|
|
106
|
+
or write to the user's databases, services or local stacks to do this — ask first if
|
|
107
|
+
a stub cannot be faithful.
|
|
108
|
+
|
|
109
|
+
Never weaken or delete a property to get green; never add one to make something fail.
|
|
110
|
+
|
|
111
|
+
### 6. Report, in a few lines
|
|
112
|
+
|
|
113
|
+
What was modelled, what was checked to what bound, what was refuted and whether it
|
|
114
|
+
replayed, and what remains `intent` awaiting the user's confirmation. **Never offer to
|
|
115
|
+
commit the model** — `.verity/proofs/` is machine-local and ignores itself. What reaches
|
|
116
|
+
the team is the bug report and, when asked, the fix. Then record the outcome:
|
|
162
117
|
|
|
163
118
|
```bash
|
|
164
119
|
verity reflect --user-input "Modelled runSeed (cli/src/lib/seed-runner.ts): P1 at-most-once refuted in 2 steps, replayed — guard checks a path the server never writes." --kind gotcha
|
|
165
120
|
```
|
|
166
121
|
|
|
122
|
+
The abstracted file's content leaves the machine for the Verity service and its
|
|
123
|
+
replay container; only git-tracked files are ever read.
|
|
124
|
+
|
|
167
125
|
## Do not
|
|
168
126
|
|
|
127
|
+
- Search the codebase yourself before the ranker has answered, or instead of asking the user.
|
|
169
128
|
- Model code the user did not confirm.
|
|
170
|
-
-
|
|
171
|
-
-
|
|
172
|
-
-
|
|
129
|
+
- Write Lean by hand while `verity prove generate` can still try.
|
|
130
|
+
- Replay by hand after a REPRODUCED verdict, or present a model-only counterexample as a bug.
|
|
131
|
+
- Background `verity prove replay`, or report before its verdicts are in.
|
|
132
|
+
- Write to the user's databases or local services, even throwaway rows.
|
|
133
|
+
- Put `sorry` in a model, weaken a property to get green, or touch source files.
|
|
134
|
+
- Run Lean from a hook, or install anything silently.
|
|
173
135
|
- Commit, stage, or un-ignore anything under `.verity/proofs/`.
|
|
174
|
-
- Model a whole module. If the state has more than ~6 fields, narrow it.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codacy/verity-cli",
|
|
3
|
-
"version": "0.33.3-experimental.
|
|
3
|
+
"version": "0.33.3-experimental.53cd005",
|
|
4
4
|
"description": "CLI for Verity quality gate service",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"homepage": "https://verity.md",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"bin/verity.js",
|
|
15
15
|
"data/skills/",
|
|
16
|
+
"data/grammars/",
|
|
16
17
|
"package.json",
|
|
17
18
|
"README.md",
|
|
18
19
|
"LICENSE",
|
|
@@ -31,8 +32,14 @@
|
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/node": "^20",
|
|
33
34
|
"esbuild": "^0.25.12",
|
|
35
|
+
"tree-sitter-go": "0.25.0",
|
|
36
|
+
"tree-sitter-java": "0.23.5",
|
|
37
|
+
"tree-sitter-javascript": "0.25.0",
|
|
38
|
+
"tree-sitter-python": "0.25.0",
|
|
39
|
+
"tree-sitter-typescript": "0.23.2",
|
|
34
40
|
"tsx": "^4.21.0",
|
|
35
|
-
"typescript": "^5.4"
|
|
41
|
+
"typescript": "^5.4",
|
|
42
|
+
"web-tree-sitter": "0.27.0"
|
|
36
43
|
},
|
|
37
44
|
"dependencies": {
|
|
38
45
|
"commander": "^12",
|