@komarspn/pi-permission-system 16.0.2

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.
Files changed (203) hide show
  1. package/CHANGELOG.md +2234 -0
  2. package/LICENSE +21 -0
  3. package/README.md +158 -0
  4. package/config/config.example.json +39 -0
  5. package/package.json +82 -0
  6. package/schemas/permissions.schema.json +158 -0
  7. package/src/active-agent.ts +72 -0
  8. package/src/async-cache.ts +21 -0
  9. package/src/bash-arity.ts +210 -0
  10. package/src/builtin-tool-input-formatters.ts +82 -0
  11. package/src/canonicalize-path.ts +30 -0
  12. package/src/common.ts +121 -0
  13. package/src/config-loader.ts +432 -0
  14. package/src/config-modal.ts +259 -0
  15. package/src/config-paths.ts +47 -0
  16. package/src/config-reporter.ts +34 -0
  17. package/src/config-store.ts +222 -0
  18. package/src/decision-audit.ts +75 -0
  19. package/src/decision-reporter.ts +41 -0
  20. package/src/denial-messages.ts +232 -0
  21. package/src/expand-home.ts +28 -0
  22. package/src/extension-config.ts +79 -0
  23. package/src/extension-paths.ts +66 -0
  24. package/src/forwarded-permissions/io.ts +404 -0
  25. package/src/forwarded-permissions/permission-forwarder.ts +580 -0
  26. package/src/forwarding-manager.ts +74 -0
  27. package/src/gate-prompter.ts +12 -0
  28. package/src/handlers/before-agent-start.ts +94 -0
  29. package/src/handlers/gates/bash-command.ts +75 -0
  30. package/src/handlers/gates/bash-external-directory.ts +127 -0
  31. package/src/handlers/gates/bash-path-extractor.ts +15 -0
  32. package/src/handlers/gates/bash-path.ts +152 -0
  33. package/src/handlers/gates/bash-program.ts +1143 -0
  34. package/src/handlers/gates/bash-token-classification.ts +105 -0
  35. package/src/handlers/gates/candidate-check.ts +32 -0
  36. package/src/handlers/gates/descriptor.ts +81 -0
  37. package/src/handlers/gates/external-directory-messages.ts +20 -0
  38. package/src/handlers/gates/external-directory.ts +133 -0
  39. package/src/handlers/gates/helpers.ts +76 -0
  40. package/src/handlers/gates/path.ts +91 -0
  41. package/src/handlers/gates/runner.ts +186 -0
  42. package/src/handlers/gates/skill-input-gate-pipeline.ts +104 -0
  43. package/src/handlers/gates/skill-input.ts +46 -0
  44. package/src/handlers/gates/skill-read.ts +87 -0
  45. package/src/handlers/gates/tool-call-gate-pipeline.ts +129 -0
  46. package/src/handlers/gates/tool.ts +102 -0
  47. package/src/handlers/gates/types.ts +13 -0
  48. package/src/handlers/index.ts +3 -0
  49. package/src/handlers/lifecycle.ts +95 -0
  50. package/src/handlers/permission-gate-handler.ts +190 -0
  51. package/src/handlers/tool-call-boundary.ts +91 -0
  52. package/src/index.ts +225 -0
  53. package/src/input-normalizer.ts +157 -0
  54. package/src/logging.ts +113 -0
  55. package/src/mcp-targets.ts +170 -0
  56. package/src/node-modules-discovery.ts +76 -0
  57. package/src/normalize.ts +43 -0
  58. package/src/path-utils.ts +355 -0
  59. package/src/pattern-suggest.ts +132 -0
  60. package/src/permission-dialog.ts +138 -0
  61. package/src/permission-event-rpc.ts +223 -0
  62. package/src/permission-events.ts +266 -0
  63. package/src/permission-forwarding.ts +188 -0
  64. package/src/permission-gate.ts +94 -0
  65. package/src/permission-manager.ts +392 -0
  66. package/src/permission-merge.ts +32 -0
  67. package/src/permission-prompter.ts +142 -0
  68. package/src/permission-prompts.ts +93 -0
  69. package/src/permission-resolver.ts +109 -0
  70. package/src/permission-session.ts +189 -0
  71. package/src/permission-ui-prompt.ts +127 -0
  72. package/src/permissions-service.ts +63 -0
  73. package/src/persistent-approval-recorder.ts +139 -0
  74. package/src/policy-loader.ts +350 -0
  75. package/src/prompting-gateway.ts +104 -0
  76. package/src/rule.ts +188 -0
  77. package/src/scope-merge.ts +72 -0
  78. package/src/service-lifecycle.ts +49 -0
  79. package/src/service.ts +163 -0
  80. package/src/session-approval-recorder.ts +6 -0
  81. package/src/session-approval.ts +43 -0
  82. package/src/session-logger.ts +91 -0
  83. package/src/session-rules.ts +79 -0
  84. package/src/skill-prompt-sanitizer.ts +292 -0
  85. package/src/status.ts +35 -0
  86. package/src/subagent-context.ts +104 -0
  87. package/src/subagent-lifecycle-events.ts +72 -0
  88. package/src/subagent-registry.ts +105 -0
  89. package/src/synthesize.ts +92 -0
  90. package/src/system-prompt-sanitizer.ts +274 -0
  91. package/src/tool-access-extractor-registry.ts +68 -0
  92. package/src/tool-input-formatter-registry.ts +67 -0
  93. package/src/tool-input-preview.ts +34 -0
  94. package/src/tool-input-prompt-formatters.ts +63 -0
  95. package/src/tool-preview-formatter.ts +207 -0
  96. package/src/tool-registry.ts +148 -0
  97. package/src/types.ts +64 -0
  98. package/src/wildcard-matcher.ts +120 -0
  99. package/src/yolo-mode.ts +30 -0
  100. package/test/active-agent.test.ts +155 -0
  101. package/test/async-cache.test.ts +48 -0
  102. package/test/bash-arity.test.ts +144 -0
  103. package/test/bash-external-directory.test.ts +956 -0
  104. package/test/builtin-tool-input-formatters.test.ts +109 -0
  105. package/test/canonicalize-path.test.ts +93 -0
  106. package/test/common.test.ts +287 -0
  107. package/test/composition-root.test.ts +603 -0
  108. package/test/config-loader.test.ts +740 -0
  109. package/test/config-modal.test.ts +320 -0
  110. package/test/config-paths.test.ts +83 -0
  111. package/test/config-pipeline.test.ts +90 -0
  112. package/test/config-reporter.test.ts +147 -0
  113. package/test/config-store.test.ts +466 -0
  114. package/test/decision-audit.test.ts +72 -0
  115. package/test/decision-reporter.test.ts +112 -0
  116. package/test/denial-messages.test.ts +656 -0
  117. package/test/detect-permissive-bash-fallback.test.ts +56 -0
  118. package/test/expand-home.test.ts +93 -0
  119. package/test/extension-config.test.ts +129 -0
  120. package/test/extension-paths.test.ts +108 -0
  121. package/test/forwarded-permissions/io.test.ts +251 -0
  122. package/test/forwarding-manager.test.ts +194 -0
  123. package/test/handlers/before-agent-start.test.ts +317 -0
  124. package/test/handlers/external-directory-integration.test.ts +623 -0
  125. package/test/handlers/external-directory-session-dedup.test.ts +430 -0
  126. package/test/handlers/external-directory-symlink-acceptance.test.ts +149 -0
  127. package/test/handlers/gates/bash-command-metamorphic.test.ts +83 -0
  128. package/test/handlers/gates/bash-command.test.ts +191 -0
  129. package/test/handlers/gates/bash-external-directory.test.ts +269 -0
  130. package/test/handlers/gates/bash-path.test.ts +337 -0
  131. package/test/handlers/gates/bash-program.test.ts +410 -0
  132. package/test/handlers/gates/bash-token-classification.test.ts +241 -0
  133. package/test/handlers/gates/candidate-check.test.ts +52 -0
  134. package/test/handlers/gates/external-directory-messages.test.ts +61 -0
  135. package/test/handlers/gates/external-directory.test.ts +259 -0
  136. package/test/handlers/gates/helpers.test.ts +177 -0
  137. package/test/handlers/gates/path.test.ts +294 -0
  138. package/test/handlers/gates/runner.test.ts +447 -0
  139. package/test/handlers/gates/skill-input-gate-pipeline.test.ts +176 -0
  140. package/test/handlers/gates/skill-input.test.ts +131 -0
  141. package/test/handlers/gates/skill-read.test.ts +158 -0
  142. package/test/handlers/gates/tool-call-gate-pipeline.test.ts +252 -0
  143. package/test/handlers/gates/tool.test.ts +223 -0
  144. package/test/handlers/input-events.test.ts +168 -0
  145. package/test/handlers/input.test.ts +199 -0
  146. package/test/handlers/lifecycle.test.ts +221 -0
  147. package/test/handlers/tool-call-boundary.test.ts +145 -0
  148. package/test/handlers/tool-call-events.test.ts +277 -0
  149. package/test/handlers/tool-call.test.ts +395 -0
  150. package/test/handlers/validate-requested-tool.test.ts +92 -0
  151. package/test/helpers/gate-fixtures.ts +323 -0
  152. package/test/helpers/handler-fixtures.ts +335 -0
  153. package/test/helpers/make-fake-pi.ts +100 -0
  154. package/test/helpers/manager-harness.ts +112 -0
  155. package/test/helpers/session-fixtures.ts +204 -0
  156. package/test/input-normalizer.test.ts +367 -0
  157. package/test/logging.test.ts +51 -0
  158. package/test/mcp-targets.test.ts +233 -0
  159. package/test/node-modules-discovery.test.ts +97 -0
  160. package/test/normalize.test.ts +247 -0
  161. package/test/path-utils.test.ts +650 -0
  162. package/test/pattern-suggest.test.ts +248 -0
  163. package/test/permission-dialog.test.ts +241 -0
  164. package/test/permission-event-rpc.test.ts +541 -0
  165. package/test/permission-events.test.ts +402 -0
  166. package/test/permission-forwarder.test.ts +369 -0
  167. package/test/permission-forwarding.test.ts +315 -0
  168. package/test/permission-gate.test.ts +305 -0
  169. package/test/permission-manager-unified.test.ts +3368 -0
  170. package/test/permission-merge.test.ts +61 -0
  171. package/test/permission-prompter.test.ts +518 -0
  172. package/test/permission-prompts.test.ts +363 -0
  173. package/test/permission-resolver.test.ts +265 -0
  174. package/test/permission-session.test.ts +363 -0
  175. package/test/permission-ui-prompt.test.ts +146 -0
  176. package/test/permissions-service.test.ts +177 -0
  177. package/test/persistent-approval-recorder.test.ts +133 -0
  178. package/test/pi-infrastructure-read.test.ts +369 -0
  179. package/test/policy-loader.test.ts +561 -0
  180. package/test/prompting-gateway.test.ts +230 -0
  181. package/test/rule.test.ts +604 -0
  182. package/test/scope-merge.test.ts +116 -0
  183. package/test/service-lifecycle.test.ts +163 -0
  184. package/test/service.test.ts +308 -0
  185. package/test/session-approval.test.ts +75 -0
  186. package/test/session-logger.test.ts +200 -0
  187. package/test/session-rules.test.ts +304 -0
  188. package/test/session-start.test.ts +112 -0
  189. package/test/skill-prompt-sanitizer.test.ts +374 -0
  190. package/test/status.test.ts +10 -0
  191. package/test/subagent-context.test.ts +326 -0
  192. package/test/subagent-lifecycle-events.test.ts +132 -0
  193. package/test/subagent-registry.test.ts +145 -0
  194. package/test/synthesize.test.ts +300 -0
  195. package/test/system-prompt-sanitizer.test.ts +382 -0
  196. package/test/tool-access-extractor-registry.test.ts +77 -0
  197. package/test/tool-input-formatter-registry.test.ts +75 -0
  198. package/test/tool-input-preview.test.ts +129 -0
  199. package/test/tool-input-prompt-formatters.test.ts +115 -0
  200. package/test/tool-preview-formatter.test.ts +458 -0
  201. package/test/tool-registry.test.ts +197 -0
  202. package/test/wildcard-matcher.test.ts +424 -0
  203. package/test/yolo-mode.test.ts +188 -0
@@ -0,0 +1,97 @@
1
+ import { beforeEach, describe, expect, test, vi } from "vitest";
2
+
3
+ // Hoisted stubs for mocks that reference them in vi.mock factories.
4
+ const { mockSpawnSync, mockExistsSync } = vi.hoisted(() => ({
5
+ mockSpawnSync: vi.fn(),
6
+ mockExistsSync: vi.fn(),
7
+ }));
8
+
9
+ // Mock node:child_process so tests don't spawn real subprocesses.
10
+ vi.mock("node:child_process", () => ({
11
+ spawnSync: mockSpawnSync,
12
+ default: { spawnSync: mockSpawnSync },
13
+ }));
14
+
15
+ // Mock node:fs so existsSync is controllable.
16
+ vi.mock("node:fs", () => ({
17
+ existsSync: mockExistsSync,
18
+ default: { existsSync: mockExistsSync },
19
+ }));
20
+
21
+ import { discoverGlobalNodeModulesRoot } from "#src/node-modules-discovery";
22
+
23
+ describe("discoverGlobalNodeModulesRoot", () => {
24
+ beforeEach(() => {
25
+ mockSpawnSync.mockReset();
26
+ mockExistsSync.mockReset();
27
+ });
28
+
29
+ test("returns node_modules root when URL is inside a node_modules tree", () => {
30
+ const fakeUrl =
31
+ "file:///opt/homebrew/lib/node_modules/@gotgenes/pi-permission-system/dist/external-directory.js";
32
+ const result = discoverGlobalNodeModulesRoot(fakeUrl);
33
+ expect(result).toBe("/opt/homebrew/lib/node_modules");
34
+ expect(mockSpawnSync).not.toHaveBeenCalled();
35
+ });
36
+
37
+ test("calls npm root -g as fallback when walk-up finds no node_modules ancestor", () => {
38
+ const npmRootPath = "/opt/homebrew/lib/node_modules";
39
+ mockSpawnSync.mockReturnValue({
40
+ status: 0,
41
+ stdout: `${npmRootPath}\n`,
42
+ });
43
+ mockExistsSync.mockReturnValue(true);
44
+
45
+ const fakeUrl = "file:///Users/dev/my-project/src/external-directory.ts";
46
+ const result = discoverGlobalNodeModulesRoot(fakeUrl);
47
+
48
+ expect(mockSpawnSync).toHaveBeenCalledWith(
49
+ "npm",
50
+ ["root", "-g"],
51
+ expect.objectContaining({ encoding: "utf-8" }),
52
+ );
53
+ expect(result).toBe(npmRootPath);
54
+ });
55
+
56
+ test("returns null when walk-up fails and npm root -g returns non-zero exit", () => {
57
+ mockSpawnSync.mockReturnValue({ status: 1, stdout: "" });
58
+
59
+ const fakeUrl = "file:///Users/dev/my-project/src/external-directory.ts";
60
+ const result = discoverGlobalNodeModulesRoot(fakeUrl);
61
+
62
+ expect(result).toBeNull();
63
+ });
64
+
65
+ test("returns null when walk-up fails and spawnSync throws", () => {
66
+ mockSpawnSync.mockImplementation(() => {
67
+ throw new Error("ENOENT");
68
+ });
69
+
70
+ const fakeUrl = "file:///Users/dev/my-project/src/external-directory.ts";
71
+ const result = discoverGlobalNodeModulesRoot(fakeUrl);
72
+
73
+ expect(result).toBeNull();
74
+ });
75
+
76
+ test("returns null when walk-up fails and npm root -g returns non-existent path", () => {
77
+ mockSpawnSync.mockReturnValue({
78
+ status: 0,
79
+ stdout: "/some/nonexistent/node_modules\n",
80
+ });
81
+ mockExistsSync.mockReturnValue(false);
82
+
83
+ const fakeUrl = "file:///Users/dev/my-project/src/external-directory.ts";
84
+ const result = discoverGlobalNodeModulesRoot(fakeUrl);
85
+
86
+ expect(result).toBeNull();
87
+ });
88
+
89
+ test("returns null when walk-up fails and npm root -g returns empty stdout", () => {
90
+ mockSpawnSync.mockReturnValue({ status: 0, stdout: " " });
91
+
92
+ const fakeUrl = "file:///Users/dev/my-project/src/external-directory.ts";
93
+ const result = discoverGlobalNodeModulesRoot(fakeUrl);
94
+
95
+ expect(result).toBeNull();
96
+ });
97
+ });
@@ -0,0 +1,247 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { normalizeFlatConfig } from "#src/normalize";
3
+
4
+ describe("normalizeFlatConfig", () => {
5
+ describe("string shorthand", () => {
6
+ test("string value produces a single catch-all rule for the surface", () => {
7
+ const result = normalizeFlatConfig({ read: "allow" });
8
+ expect(result).toEqual([
9
+ { surface: "read", pattern: "*", action: "allow", origin: "builtin" },
10
+ ]);
11
+ });
12
+
13
+ test("string shorthand works for multiple surfaces", () => {
14
+ const result = normalizeFlatConfig({ read: "allow", write: "deny" });
15
+ expect(result).toEqual([
16
+ { surface: "read", pattern: "*", action: "allow", origin: "builtin" },
17
+ { surface: "write", pattern: "*", action: "deny", origin: "builtin" },
18
+ ]);
19
+ });
20
+
21
+ test("universal fallback '*' becomes a catch-all rule with surface '*'", () => {
22
+ const result = normalizeFlatConfig({ "*": "ask" });
23
+ expect(result).toEqual([
24
+ { surface: "*", pattern: "*", action: "ask", origin: "builtin" },
25
+ ]);
26
+ });
27
+
28
+ test("external_directory string shorthand maps directly to its surface", () => {
29
+ const result = normalizeFlatConfig({ external_directory: "ask" });
30
+ expect(result).toEqual([
31
+ {
32
+ surface: "external_directory",
33
+ pattern: "*",
34
+ action: "ask",
35
+ origin: "builtin",
36
+ },
37
+ ]);
38
+ });
39
+
40
+ test("invalid string values (non-PermissionState) are ignored", () => {
41
+ const result = normalizeFlatConfig({
42
+ read: "allow",
43
+ write: "invalid" as never,
44
+ });
45
+ expect(result).toEqual([
46
+ { surface: "read", pattern: "*", action: "allow", origin: "builtin" },
47
+ ]);
48
+ });
49
+ });
50
+
51
+ describe("object pattern map", () => {
52
+ test("object value produces one rule per pattern", () => {
53
+ const result = normalizeFlatConfig({
54
+ bash: { "*": "ask", "git *": "allow" },
55
+ });
56
+ expect(result).toEqual([
57
+ { surface: "bash", pattern: "*", action: "ask", origin: "builtin" },
58
+ {
59
+ surface: "bash",
60
+ pattern: "git *",
61
+ action: "allow",
62
+ origin: "builtin",
63
+ },
64
+ ]);
65
+ });
66
+
67
+ test("mcp object map produces rules with surface 'mcp'", () => {
68
+ const result = normalizeFlatConfig({
69
+ mcp: { "*": "ask", mcp_status: "allow" },
70
+ });
71
+ expect(result).toEqual([
72
+ { surface: "mcp", pattern: "*", action: "ask", origin: "builtin" },
73
+ {
74
+ surface: "mcp",
75
+ pattern: "mcp_status",
76
+ action: "allow",
77
+ origin: "builtin",
78
+ },
79
+ ]);
80
+ });
81
+
82
+ test("skill object map produces rules with surface 'skill'", () => {
83
+ const result = normalizeFlatConfig({
84
+ skill: { "*": "ask", librarian: "allow" },
85
+ });
86
+ expect(result).toEqual([
87
+ { surface: "skill", pattern: "*", action: "ask", origin: "builtin" },
88
+ {
89
+ surface: "skill",
90
+ pattern: "librarian",
91
+ action: "allow",
92
+ origin: "builtin",
93
+ },
94
+ ]);
95
+ });
96
+
97
+ test("invalid action values in object map are ignored", () => {
98
+ const result = normalizeFlatConfig({
99
+ bash: { "git *": "allow", "rm -rf *": "bad" as never },
100
+ });
101
+ expect(result).toEqual([
102
+ {
103
+ surface: "bash",
104
+ pattern: "git *",
105
+ action: "allow",
106
+ origin: "builtin",
107
+ },
108
+ ]);
109
+ });
110
+ });
111
+
112
+ describe("mixed surfaces", () => {
113
+ test("full mixed config produces rules in insertion order", () => {
114
+ const result = normalizeFlatConfig({
115
+ "*": "ask",
116
+ read: "allow",
117
+ write: "deny",
118
+ bash: { "*": "ask", "git *": "allow" },
119
+ mcp: { mcp_status: "allow" },
120
+ skill: { "*": "ask" },
121
+ external_directory: "ask",
122
+ });
123
+ expect(result).toEqual([
124
+ { surface: "*", pattern: "*", action: "ask", origin: "builtin" },
125
+ { surface: "read", pattern: "*", action: "allow", origin: "builtin" },
126
+ { surface: "write", pattern: "*", action: "deny", origin: "builtin" },
127
+ { surface: "bash", pattern: "*", action: "ask", origin: "builtin" },
128
+ {
129
+ surface: "bash",
130
+ pattern: "git *",
131
+ action: "allow",
132
+ origin: "builtin",
133
+ },
134
+ {
135
+ surface: "mcp",
136
+ pattern: "mcp_status",
137
+ action: "allow",
138
+ origin: "builtin",
139
+ },
140
+ { surface: "skill", pattern: "*", action: "ask", origin: "builtin" },
141
+ {
142
+ surface: "external_directory",
143
+ pattern: "*",
144
+ action: "ask",
145
+ origin: "builtin",
146
+ },
147
+ ]);
148
+ });
149
+ });
150
+
151
+ describe("empty and edge cases", () => {
152
+ test("empty permission object produces empty ruleset", () => {
153
+ expect(normalizeFlatConfig({})).toEqual([]);
154
+ });
155
+
156
+ test("non-object values (null, array) nested in map are skipped", () => {
157
+ const result = normalizeFlatConfig({
158
+ bash: null as never,
159
+ read: "allow",
160
+ });
161
+ expect(result).toEqual([
162
+ { surface: "read", pattern: "*", action: "allow", origin: "builtin" },
163
+ ]);
164
+ });
165
+ });
166
+
167
+ describe("deny with reason", () => {
168
+ test("{ action: 'deny', reason } produces a deny rule carrying the reason", () => {
169
+ const result = normalizeFlatConfig({
170
+ bash: { "npm *": { action: "deny", reason: "Use pnpm instead" } },
171
+ });
172
+ expect(result).toEqual([
173
+ {
174
+ surface: "bash",
175
+ pattern: "npm *",
176
+ action: "deny",
177
+ reason: "Use pnpm instead",
178
+ origin: "builtin",
179
+ },
180
+ ]);
181
+ });
182
+
183
+ test("{ action: 'deny' } without a reason produces a deny rule without reason", () => {
184
+ const result = normalizeFlatConfig({
185
+ bash: { "rm -rf *": { action: "deny" } },
186
+ });
187
+ expect(result).toEqual([
188
+ {
189
+ surface: "bash",
190
+ pattern: "rm -rf *",
191
+ action: "deny",
192
+ origin: "builtin",
193
+ },
194
+ ]);
195
+ });
196
+
197
+ test("deny-with-reason and plain strings coexist in the same surface", () => {
198
+ const result = normalizeFlatConfig({
199
+ bash: {
200
+ "git *": "allow",
201
+ "npm *": { action: "deny", reason: "Use pnpm" },
202
+ "*": "ask",
203
+ },
204
+ });
205
+ expect(result).toEqual([
206
+ {
207
+ surface: "bash",
208
+ pattern: "git *",
209
+ action: "allow",
210
+ origin: "builtin",
211
+ },
212
+ {
213
+ surface: "bash",
214
+ pattern: "npm *",
215
+ action: "deny",
216
+ reason: "Use pnpm",
217
+ origin: "builtin",
218
+ },
219
+ { surface: "bash", pattern: "*", action: "ask", origin: "builtin" },
220
+ ]);
221
+ });
222
+
223
+ test("top-level deny-with-reason object is treated as a pattern map", () => {
224
+ // At the surface level, { action: "deny", reason: "..." } is parsed as a
225
+ // pattern→action map: "action" is a pattern key with action "deny", and
226
+ // "reason" maps to a non-PermissionState string that is dropped.
227
+ const result = normalizeFlatConfig({
228
+ bash: { action: "deny", reason: "Not allowed" } as never,
229
+ });
230
+ expect(result).toEqual([
231
+ {
232
+ surface: "bash",
233
+ pattern: "action",
234
+ action: "deny",
235
+ origin: "builtin",
236
+ },
237
+ ]);
238
+ });
239
+
240
+ test("non-string reason is rejected (malformed config)", () => {
241
+ const result = normalizeFlatConfig({
242
+ bash: { "npm *": { action: "deny", reason: 42 } as never },
243
+ });
244
+ expect(result).toEqual([]);
245
+ });
246
+ });
247
+ });