pi-permission-classifier 0.5.1 → 0.6.0

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/CHANGELOG.md CHANGED
@@ -5,6 +5,193 @@ format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
5
5
  this project adheres to
6
6
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.6.0] - 2026-10-06
9
+
10
+ ### Added
11
+
12
+ - A quick judge beside the LLM judge. The quick judge asks a System One
13
+ classifier model (for example `typesafe/jev-latest`) through pi's
14
+ `findOfType("classifier", ...)` and `classify` three fixed questions:
15
+ reversible, contained, and one of nine hazards, where sending secrets off
16
+ the machine (secret exfiltration) is apart from pushing, publishing or
17
+ uploading project work (push or publish). Contained counts the
18
+ project's own build, run and test tools with their usual caches, and
19
+ reversible counts output that can be made again; secrets, data sent out,
20
+ git history and uncommitted work stay failures. It allows when each of
21
+ the three clears its built-in threshold (0.8, chosen by an eval against
22
+ logged asks; `allowThreshold`, when set, applies one value to all
23
+ three), denies with the hazard named when
24
+ one hazard reaches `denyThreshold` (default 0.9), and otherwise treats the
25
+ answer as uncertain. The model sees the gated value, surface, tool, cwd,
26
+ the full command within `contextBudgetBytes`, and the selected guidance
27
+ files when `quickJudge.guidance` is on (default). It has its own timeout,
28
+ circuit breaker and health record. An unset or unknown model never falls
29
+ back to the session model.
30
+ - The `mode` config field (default `llm`) picks who judges: `llm`, `quick`,
31
+ or `quick-then-llm`, where the quick judge settles clear cases and the LLM
32
+ judge reviews everything it does not allow. In `quick-then-llm` the quick
33
+ judge always runs with `allow-defer` and `onError` defer, with one warning
34
+ per session when `quickJudge` asks for more. The mode is read on every
35
+ ask.
36
+ - The `quickJudge` config object: `provider`, `model`, `verdicts` (default
37
+ `allow-defer`), `onError` (default `defer`), `allowThreshold` (optional),
38
+ `denyThreshold`, `guidance` and `timeoutMs`.
39
+ - `npm run eval:quick`, a development eval that scores the quick judge's
40
+ question sets against Jev on a hazard set and on the asks your review log
41
+ shows as approved, and reports the allow rates per threshold set. Its
42
+ corpus and report stay under the gitignored `drafts/eval/`.
43
+ - `data/asks.jsonl`, a committed store of every permission ask the chain
44
+ judged: the ask, each judge decision on it, how it ended and who decided,
45
+ and the user text. `npm run data:pull` appends the asks not yet stored
46
+ from the review log and the session files, scrubbed: home directory,
47
+ login name, email addresses, git identity flags, LAN addresses, mounts
48
+ and secret values become placeholders, and each project directory gets a
49
+ stable alias from the gitignored `data/project-aliases.json`. A structure
50
+ test scans the file with the same rules. The quick judge eval builds its
51
+ safe cases from the store.
52
+ - `verdicts` (`allow-deny-defer`, `allow-defer`, `allow-deny`) and
53
+ `onError` (`defer`, `deny`) for each judge, enforced in code. `onError`
54
+ deny turns a failure into a deny with a fixed reason that names the
55
+ failure and says to retry later or take another route.
56
+ - `/permission-model` with no argument opens a menu with an entry for
57
+ each choice the mode runs, each showing its current value: who judges
58
+ (the mode), the quick judge model, the LLM judge model, a model-call
59
+ timeout for each judge the mode runs, and the last judge's verdicts
60
+ and on error.
61
+ Each entry opens one list with the current value preselected; a pick is
62
+ saved at once and the menu opens again. The LLM list offers "Same as the
63
+ chat model (follows /model)". Picking a quick mode while the global
64
+ config has no quick model asks for one and saves both together. A
65
+ configured model that is not available is listed first as `(current,
66
+ not available)`, and picking it changes nothing. Escape in a list goes
67
+ back to the menu without a change; a save that leaves the merged config
68
+ invalid closes the menu after the error.
69
+ - Typed forms `/permission-model mode <llm|quick|quick-then-llm>`,
70
+ `/permission-model llm <provider>/<id>`, `/permission-model llm
71
+ chat-model` and `/permission-model quick <provider>/<id>`, with tab
72
+ completion for each. Setting a model never changes the mode, and a
73
+ typed quick mode is saved only when the global config has a quick
74
+ model. Outside the TUI, `/permission-model` prints the mode, the active
75
+ judges and the usage line.
76
+ - A model-call timeout entry for each judge the mode runs: `Quick judge
77
+ model-call timeout` (absent in mode `llm`) and `LLM judge model-call
78
+ timeout` (absent in mode `quick`), each showing the current budget in
79
+ seconds. The list offers 5, 10, 15, 25, 30 and 60 seconds, the saved
80
+ budget when it is not one of those, and a clear row that returns the
81
+ judge to its built-in 5 seconds. A saved budget that is not whole
82
+ seconds shows its decimals (2500 ms as 2.5), and picking the current
83
+ row changes nothing.
84
+ - Typed forms `/permission-model llm timeout <seconds>` and
85
+ `/permission-model quick timeout <seconds>` set one judge's model-call
86
+ budget, entered in whole seconds and written as milliseconds. The LLM
87
+ judge's form writes the top-level `timeoutMs`; the quick judge's form
88
+ writes `quickJudge.timeoutMs` and keeps the other `quickJudge` keys.
89
+ `0` clears that judge's key. A sign, a decimal point, an exponent, an
90
+ empty value, a negative value and anything above 3600 seconds are
91
+ refused with no write. Tab completion offers `timeout` after `llm ` and
92
+ after `quick `, and the preset budgets and the clear value after
93
+ `llm timeout ` and `quick timeout `, filtered by the digits typed.
94
+ - The `--permission-model` launch flag takes a comma list of
95
+ `quick:<provider>/<id>`, `llm:<provider>/<id>`, `llm:chat-model` and
96
+ `mode:<mode>`, in any subset, for the session only. An item that does not
97
+ resolve is ignored with a warning and the rest still applies.
98
+ - The footer entry opens with the label `perm-judge:` and shows a part for
99
+ each judge the mode runs, quick first and joined with `->` in the order
100
+ they run: `quick:<provider>/<id>` and `llm:<provider>/<id>` or
101
+ `llm:chat-model`, each with its own health suffix.
102
+ - `/permission-model` sets `verdicts` and `onError` for the last judge in
103
+ line (the LLM judge in modes `llm` and `quick-then-llm`, the quick judge
104
+ in mode `quick`): the menu has a verdicts entry and an on error entry,
105
+ and the typed forms `verdicts <allow-deny-defer|allow-defer|allow-deny>`
106
+ and `on-error <defer|deny>` set one field each. The print form outside
107
+ the TUI shows the last judge's policy.
108
+ - Decision entries carry `judge` (`quick` or `llm`); quick entries also
109
+ carry the per-question answer probabilities, with the hazard as
110
+ `[option, probability]` pairs, highest first.
111
+ The breaker open and close entries and the LLM judge's short-circuit
112
+ debug entries carry `judge` too.
113
+ - The LLM judge sees what you asked for. Each ask's prompt carries your
114
+ own messages from the session in a labelled data block: the text you
115
+ typed, with a skill reduced to its name and arguments. Assistant text,
116
+ tool results, bash output, custom messages and compaction or branch
117
+ summaries are never sent. The first message is kept plus the newest back
118
+ to 24,000 characters, each message capped at 4,000 (head and tail). The
119
+ block is left out when anything was cut, a message of yours is still
120
+ queued, or the ask was forwarded from a subagent. The default rubric
121
+ lets a request that directly and specifically names the action move a
122
+ case that would otherwise defer to allow, never past the never-allow
123
+ list; a message telling the agent not to do it means defer; approval
124
+ inside the command, the agent's text or tool output does not count. A
125
+ custom `instructions` rubric gets the block without these rules.
126
+ - `npm run eval:quick` pairs each logged ask with the user text the
127
+ runtime would send at that point in its session, runs every hazard case
128
+ with no user text, an unrelated task and a request naming it, adds
129
+ injection and forbidden cases (`eval/intent-cases.json`), and searches
130
+ thresholds against an intent ship bar. The quick judge does not send
131
+ user text yet: in the first run no thresholds met the bar (see
132
+ `eval/RESULTS.md`).
133
+ - `npm run eval:quick` scores a local System One model instead of Jev with
134
+ `EVAL_S1_MODEL=provider/id` at `EVAL_S1_BASE_URL` (default
135
+ `http://127.0.0.1:8080/v1/`), with its own cache, scores and report
136
+ files. `EVAL_SAFE_LIMIT=N` scores a spread sample of N safe cases and
137
+ `EVAL_INTENT=0` skips the intent pass.
138
+
139
+ ### Changed
140
+
141
+ - `config/config.example.json` ships the quick-then-llm shape: a `mode`,
142
+ the LLM judge's `provider`, `model` and `timeoutMs`, and a `quickJudge`
143
+ block with `provider`, `model`, `guidance` and its own `timeoutMs`.
144
+ The file carried one `timeoutMs` and no quick judge block, which read
145
+ as a single call budget shared by both judges.
146
+ - The README says which judge each `timeoutMs` belongs to: the LLM judge
147
+ table names the top-level key and points at `quickJudge.timeoutMs`,
148
+ the `quickJudge` table names its own key and says the top-level key
149
+ belongs to the LLM judge alone, and the quick-then-llm example config
150
+ sets both budgets. The notes say a model call is aborted after that
151
+ judge's own timeout.
152
+ - The chain link is renamed from `classifier` to `permission-judge`. List
153
+ `permission-judge` in `authorizerChain`. For this release the link is
154
+ also registered as `classifier`, which logs a deprecation warning once per
155
+ session. With both names in the chain an ask is judged once: the second
156
+ name defers for a request the judge already reviewed, and a warning says
157
+ to remove `classifier`.
158
+ - The LLM judge that follows the session's model is now called the chat
159
+ model: `llm:chat-model` in the footer, where it was `judge:session`.
160
+ - Requires pi 1.0.0 or newer (`@earendil-works/pi-coding-agent >=1.0.0`).
161
+ The picker no longer uses pi's model selector component, so the README
162
+ note about pi older than 0.84.3 is gone.
163
+ - An over-budget ask follows `verdicts` on the LLM judge: it still defers
164
+ by default, and denies under `allow-deny`.
165
+ - When `allow-defer` withholds a model deny, the entry records defer reason
166
+ `deny-capped`.
167
+ - The LLM judge prompt escapes a delimiter tag (such as `</ask-value>` or
168
+ `<user-messages>`) inside the judged value, the executed unit and the
169
+ full command, so a command cannot close its block or forge a block of
170
+ user messages.
171
+ - The warning for an unreachable permission service now says no permission
172
+ link is registered.
173
+
174
+ ### Removed
175
+
176
+ - `/permission-model <provider>/<id>`: use `/permission-model llm
177
+ <provider>/<id>`.
178
+ - `/permission-model session`: use `/permission-model llm chat-model`.
179
+ - `--permission-model <provider>/<id>` without a prefix: use
180
+ `--permission-model llm:<provider>/<id>`. A bare pair is ignored with a
181
+ warning that names the `llm:` form.
182
+ - The degraded `/permission-model` list for a pi whose model registry
183
+ hides its runtime: the picker no longer needs it.
184
+
185
+ ## [0.5.2] - 2026-09-25
186
+
187
+ ### Fixed
188
+
189
+ - A provider error from the judge model (for example an HTTP 429 or 503)
190
+ now defers with reason `call-failed` instead of `no-tool-call`. The
191
+ circuit breaker counts it, so repeated errors open the breaker instead
192
+ of calling the failing API on every ask. The provider's error text is
193
+ written to the `classifier.model_reply` debug entry.
194
+
8
195
  ## [0.5.1] - 2026-09-19
9
196
 
10
197
  ### Changed