@mzwing/pi-permission-auto-review 0.1.3 → 0.2.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/README.md CHANGED
@@ -10,6 +10,8 @@ A [Pi](https://github.com/earendil-works/pi) extension that adds Codex-style aut
10
10
 
11
11
  Ours is mostly specialized for OpenAI's `codex-auto-review` model, which is trained to evaluate permission requests in the context of a coding assistant. Our extension aims at providing Codex-style automatic permission reviews for Pi's coding agent.
12
12
 
13
+ The bundled baseline is a Pi-specific adaptation of OpenAI Codex Guardian's [`policy_template.md`](https://github.com/openai/codex/blob/c4f42d161ae44a8d696ee9fb595709661979d187/codex-rs/core/src/guardian/policy_template.md) and [`policy.md`](https://github.com/openai/codex/blob/c4f42d161ae44a8d696ee9fb595709661979d187/codex-rs/core/src/guardian/policy.md) at revision [`c4f42d161ae44a8d696ee9fb595709661979d187`](https://github.com/openai/codex/commit/c4f42d161ae44a8d696ee9fb595709661979d187). It is bundled at build time; the extension never fetches policy text while reviewing an action.
14
+
13
15
  ## Install
14
16
 
15
17
  ```bash
@@ -78,10 +80,42 @@ Custom providers and models must be defined in Pi's `~/.pi/agent/models.json`, t
78
80
 
79
81
  ## Behavior and Limits
80
82
 
83
+ ### Authorization evidence
84
+
85
+ The reviewer reads the current session's complete active branch with `SessionManager.getBranch()`, rather than only the post-compaction model context. This keeps original user authorization available after compaction without mixing in abandoned branches.
86
+
87
+ Only these transcript records can establish authorization:
88
+
89
+ - Pi session user-role messages (`source: "user"`);
90
+ - completed, non-cancelled responses to recognized `ask_user_question` and `plan_mode_question` calls (`source: "user_interaction"`).
91
+
92
+ Pi does not persist the original `input` event source on user-role messages, so `source: "user"` is a trust boundary provided by the Pi runtime rather than cryptographic proof of keyboard input. Trusted extensions can intentionally create such messages with `sendUserMessage()`; as with the rest of Pi's extension model, only trusted extension code should be installed.
93
+
94
+ Structured question responses are accepted only when the non-error result matches a preceding recognized tool call and are rebuilt from `details.answers` data. Free-form tool-result text is never promoted to user evidence. Assistant messages, ordinary tool calls/results, custom messages, and compaction/branch summaries remain untrusted even if their text claims to be user content.
95
+
96
+ Transcript rendering uses separate 10k-token message and tool budgets with per-entry truncation. The first and latest trusted records are retained first, then other trusted records from newest to oldest. The 40-entry recency cap applies only to assistant/tool evidence, so later tool activity cannot evict an already selected user authorization. Truncation indicates missing information; it does not itself raise intrinsic action risk.
97
+
98
+ ### Permission boundaries
99
+
81
100
  - Model, authentication, timeout, provider, or response-format failures defer to the normal human prompt.
82
101
  - Unexpected internal review failures also defer to the human prompt instead of escaping into the permission gate.
83
102
  - Three consecutive denials, or ten denials in the latest fifty reviews, open a circuit breaker until the next Pi turn.
84
- - pi-permission-system prevents authorizers from auto-approving `path` and `external_directory` requests.
103
+ - pi-permission-system's delegation envelope prevents authorizers from auto-approving `path` and `external_directory` requests. An auto-review `allow` for those surfaces is deliberately downgraded to the normal human prompt; this extension does not bypass that boundary.
104
+
105
+ ### Diagnostics
106
+
107
+ Each `auto_review.decision` emitted after transcript construction adds content-free context diagnostics (configuration failures that defer before a review do not have transcript diagnostics):
108
+
109
+ - `policyRevision`
110
+ - `contextSource` (`active-branch`)
111
+ - `transcriptEntriesRetained`
112
+ - `transcriptEntriesOmitted`
113
+ - `transcriptEntriesTruncated`
114
+ - `directUserEntriesRetained` / `directUserEntriesOmitted` / `directUserEntriesTruncated`
115
+ - `userInteractionEntriesRetained` / `userInteractionEntriesOmitted` / `userInteractionEntriesTruncated`
116
+ - `latestTrustedEntryRetained`
117
+
118
+ These fields distinguish missing or truncated authorization evidence from a model decision made after receiving trusted evidence. Transcript text and model rationale are not persisted. The records are written through pi-permission-system's existing permission-review log when that log is enabled.
85
119
 
86
120
  ## License
87
121
 
package/dist/index.d.ts CHANGED
@@ -60,7 +60,7 @@ declare class DenialCircuitBreaker {
60
60
  interface ReviewerFactoryOptions {
61
61
  config: AutoReviewConfig;
62
62
  registry: ModelRegistry;
63
- sessionManager: Pick<SessionManager, "buildContextEntries">;
63
+ sessionManager: Pick<SessionManager, "getBranch">;
64
64
  circuitBreaker: DenialCircuitBreaker;
65
65
  sessionSignal: AbortSignal;
66
66
  }