@codacy/verity-cli 0.33.3-experimental.d8b96f8 → 0.33.3-experimental.db99356

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.
@@ -0,0 +1,135 @@
1
+ ---
2
+ description: >-
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.
10
+ ---
11
+ # /verity-prove — Formal verification of small pieces of code
12
+
13
+ **The words after `/verity-prove` are the hint.** `/verity-prove` alone means "find me
14
+ something worth checking"; `/verity-prove can the Stripe webhook double-charge on a
15
+ redelivered event?` names the target and the worry. Carry it through every step as
16
+ `$ARGUMENTS`.
17
+
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
+
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.
29
+
30
+ ## The flow
31
+
32
+ ### 1. Candidates — one command
33
+
34
+ ```bash
35
+ verity prove candidates --hint "$ARGUMENTS" --json # hint given
36
+ verity prove candidates --limit 8 --json # no hint
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.
44
+
45
+ ### 2. Confirm with the user — always
46
+
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.
52
+
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.
56
+
57
+ ### 3. Set up once per repo
58
+
59
+ ```bash
60
+ verity prove init
61
+ ```
62
+
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`.
66
+
67
+ ### 4. Generate the model — one command
68
+
69
+ ```bash
70
+ verity prove generate src/pay.ts#charge --hint "$ARGUMENTS"
71
+ verity prove generate src/handler.ts --lines 120-180 --hint "$ARGUMENTS" # a region
72
+ ```
73
+
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
83
+
84
+ ```bash
85
+ verity prove replay <Name> # every counterexample
86
+ verity prove replay <Name> --property P2 # one
87
+ ```
88
+
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:
117
+
118
+ ```bash
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
120
+ ```
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
+
125
+ ## Do not
126
+
127
+ - Search the codebase yourself before the ranker has answered, or instead of asking the user.
128
+ - Model code the user did not confirm.
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.
135
+ - Commit, stage, or un-ignore anything under `.verity/proofs/`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/verity-cli",
3
- "version": "0.33.3-experimental.d8b96f8",
3
+ "version": "0.33.3-experimental.db99356",
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",