@gotgenes/pi-permission-system 7.4.1 → 8.0.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,22 @@ 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
+ ## [8.0.0](https://github.com/gotgenes/pi-packages/compare/pi-permission-system-v7.4.1...pi-permission-system-v8.0.0) (2026-05-30)
9
+
10
+
11
+ ### ⚠ BREAKING CHANGES
12
+
13
+ * `registerSubagentSession` and `unregisterSubagentSession` are removed from the `PermissionsService` interface and its implementation. The `SubagentSessionInfo` type is no longer re-exported from the public service module.
14
+
15
+ ### Features
16
+
17
+ * remove inbound subagent-registration methods from PermissionsService ([#267](https://github.com/gotgenes/pi-packages/issues/267)) ([552735a](https://github.com/gotgenes/pi-packages/commit/552735a97eec939fc06130bce059c78f03eb8e58))
18
+
19
+
20
+ ### Documentation
21
+
22
+ * **pi-permission-system:** describe event-driven subagent registration ([#267](https://github.com/gotgenes/pi-packages/issues/267)) ([8c39b87](https://github.com/gotgenes/pi-packages/commit/8c39b8785aa389d96b5f38996711d8aa3dbeb284))
23
+
8
24
  ## [7.4.1](https://github.com/gotgenes/pi-packages/compare/pi-permission-system-v7.4.0...pi-permission-system-v7.4.1) (2026-05-30)
9
25
 
10
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gotgenes/pi-permission-system",
3
- "version": "7.4.1",
3
+ "version": "8.0.0",
4
4
  "description": "Permission enforcement extension for the Pi coding agent.",
5
5
  "type": "module",
6
6
  "exports": {
package/src/index.ts CHANGED
@@ -118,12 +118,6 @@ export default function piPermissionSystemExtension(pi: ExtensionAPI): void {
118
118
  sessionRules,
119
119
  );
120
120
  },
121
- registerSubagentSession(sessionKey, info) {
122
- subagentRegistry.register(sessionKey, info);
123
- },
124
- unregisterSubagentSession(sessionKey) {
125
- subagentRegistry.unregister(sessionKey);
126
- },
127
121
  getToolPermission(toolName, agentName) {
128
122
  return runtime.permissionManager.getToolPermission(toolName, agentName);
129
123
  },
package/src/service.ts CHANGED
@@ -11,10 +11,9 @@
11
11
  * reference — this ensures resilience across `/reload` and load-order edge cases.
12
12
  */
13
13
 
14
- import type { SubagentSessionInfo } from "./subagent-registry";
15
14
  import type { PermissionCheckResult, PermissionState } from "./types";
16
15
 
17
- export type { PermissionCheckResult, PermissionState, SubagentSessionInfo };
16
+ export type { PermissionCheckResult, PermissionState };
18
17
 
19
18
  /** Process-global key for the service slot. */
20
19
  const SERVICE_KEY = Symbol.for("@gotgenes/pi-permission-system:service");
@@ -44,27 +43,6 @@ export interface PermissionsService {
44
43
  agentName?: string,
45
44
  ): PermissionCheckResult;
46
45
 
47
- /**
48
- * Register an in-process subagent session.
49
- *
50
- * Call this before `bindExtensions()` so that `isSubagentExecutionContext()`
51
- * and permission-forwarding target resolution can detect the child session.
52
- * Always pair with `unregisterSubagentSession()` in a `finally` block.
53
- *
54
- * @param sessionKey - Unique session identifier (use the session directory path).
55
- * @param info - Agent name and optional parent session ID.
56
- */
57
- registerSubagentSession(sessionKey: string, info: SubagentSessionInfo): void;
58
-
59
- /**
60
- * Remove a previously registered in-process subagent session.
61
- *
62
- * Safe to call even if `registerSubagentSession` was never called for this key.
63
- *
64
- * @param sessionKey - The same key passed to `registerSubagentSession`.
65
- */
66
- unregisterSubagentSession(sessionKey: string): void;
67
-
68
46
  /**
69
47
  * Query the tool-level permission state for pre-filtering tools before
70
48
  * creating a child session.
@@ -23,9 +23,9 @@ export interface SubagentSessionInfo {
23
23
  /**
24
24
  * Registry of active in-process subagent sessions.
25
25
  *
26
- * Owned by `ExtensionRuntime`; exposed to external callers through the
27
- * `PermissionsService` interface (`registerSubagentSession` /
28
- * `unregisterSubagentSession`).
26
+ * Owned by `ExtensionRuntime`; written exclusively by `subscribeSubagentLifecycle`
27
+ * via the `subagents:child:session-created` / `subagents:child:disposed` event
28
+ * subscription (ADR 0002 — the core publishes, consumers observe).
29
29
  *
30
30
  * Concurrent background agents are safe because each session has a unique
31
31
  * directory path as its key — no scalar global flag is needed.
@@ -6,7 +6,6 @@ import {
6
6
  publishPermissionsService,
7
7
  unpublishPermissionsService,
8
8
  } from "#src/service";
9
- import { SubagentSessionRegistry } from "#src/subagent-registry";
10
9
  import type { PermissionCheckResult } from "#src/types";
11
10
 
12
11
  // ── helpers ────────────────────────────────────────────────────────────────
@@ -16,8 +15,6 @@ function makeService(
16
15
  ): PermissionsService {
17
16
  return {
18
17
  checkPermission: vi.fn(),
19
- registerSubagentSession: vi.fn(),
20
- unregisterSubagentSession: vi.fn(),
21
18
  getToolPermission: vi.fn(),
22
19
  ...overrides,
23
20
  };
@@ -130,61 +127,12 @@ describe("service adapter delegation", () => {
130
127
  );
131
128
  });
132
129
 
133
- it("registerSubagentSession delegates to the registry", () => {
134
- const registry = new SubagentSessionRegistry();
135
- const service: PermissionsService = {
136
- checkPermission: vi.fn(),
137
- registerSubagentSession(key, info) {
138
- registry.register(key, info);
139
- },
140
- unregisterSubagentSession(key) {
141
- registry.unregister(key);
142
- },
143
- getToolPermission: vi.fn((): "allow" => "allow"),
144
- };
145
-
146
- publishPermissionsService(service);
147
- getPermissionsService()!.registerSubagentSession("/sessions/task-1", {
148
- agentName: "Explore",
149
- parentSessionId: "parent-abc",
150
- });
151
-
152
- expect(registry.has("/sessions/task-1")).toBe(true);
153
- expect(registry.get("/sessions/task-1")).toEqual({
154
- agentName: "Explore",
155
- parentSessionId: "parent-abc",
156
- });
157
- });
158
-
159
- it("unregisterSubagentSession delegates to the registry", () => {
160
- const registry = new SubagentSessionRegistry();
161
- const service: PermissionsService = {
162
- checkPermission: vi.fn(),
163
- registerSubagentSession(key, info) {
164
- registry.register(key, info);
165
- },
166
- unregisterSubagentSession(key) {
167
- registry.unregister(key);
168
- },
169
- getToolPermission: vi.fn((): "allow" => "allow"),
170
- };
171
-
172
- publishPermissionsService(service);
173
- const svc = getPermissionsService()!;
174
- svc.registerSubagentSession("/sessions/task-1", { agentName: "Explore" });
175
- svc.unregisterSubagentSession("/sessions/task-1");
176
-
177
- expect(registry.has("/sessions/task-1")).toBe(false);
178
- });
179
-
180
130
  it("getToolPermission delegates to the permission manager", () => {
181
131
  const getToolPermissionFn = vi.fn(
182
132
  (_t: string, _a?: string): "deny" => "deny",
183
133
  );
184
134
  const service: PermissionsService = {
185
135
  checkPermission: vi.fn(),
186
- registerSubagentSession: vi.fn(),
187
- unregisterSubagentSession: vi.fn(),
188
136
  getToolPermission(toolName, agentName) {
189
137
  return getToolPermissionFn(toolName, agentName);
190
138
  },
@@ -206,8 +154,6 @@ describe("service adapter delegation", () => {
206
154
  );
207
155
  const service: PermissionsService = {
208
156
  checkPermission: vi.fn(),
209
- registerSubagentSession: vi.fn(),
210
- unregisterSubagentSession: vi.fn(),
211
157
  getToolPermission(toolName, agentName) {
212
158
  return getToolPermissionFn(toolName, agentName);
213
159
  },