@openagentsy/hooks 0.0.0-stage → 0.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.
Files changed (307) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +32 -2
  3. package/dist/accountability.d.ts +29 -0
  4. package/dist/accountability.d.ts.map +1 -0
  5. package/dist/accountability.js +21 -0
  6. package/dist/accountability.js.map +1 -0
  7. package/dist/accountability.test.d.ts +2 -0
  8. package/dist/accountability.test.d.ts.map +1 -0
  9. package/dist/accountability.test.js +42 -0
  10. package/dist/accountability.test.js.map +1 -0
  11. package/dist/approvals.d.ts +110 -0
  12. package/dist/approvals.d.ts.map +1 -0
  13. package/dist/approvals.js +464 -0
  14. package/dist/approvals.js.map +1 -0
  15. package/dist/approvals.test.d.ts +2 -0
  16. package/dist/approvals.test.d.ts.map +1 -0
  17. package/dist/approvals.test.js +307 -0
  18. package/dist/approvals.test.js.map +1 -0
  19. package/dist/base-tool.d.ts +26 -0
  20. package/dist/base-tool.d.ts.map +1 -0
  21. package/dist/base-tool.js +37 -0
  22. package/dist/base-tool.js.map +1 -0
  23. package/dist/base-tool.test.d.ts +2 -0
  24. package/dist/base-tool.test.d.ts.map +1 -0
  25. package/dist/base-tool.test.js +34 -0
  26. package/dist/base-tool.test.js.map +1 -0
  27. package/dist/eval/index.d.ts +3 -0
  28. package/dist/eval/index.d.ts.map +1 -0
  29. package/dist/eval/index.js +3 -0
  30. package/dist/eval/index.js.map +1 -0
  31. package/dist/eval/runner.d.ts +179 -0
  32. package/dist/eval/runner.d.ts.map +1 -0
  33. package/dist/eval/runner.js +616 -0
  34. package/dist/eval/runner.js.map +1 -0
  35. package/dist/eval/runner.test.d.ts +2 -0
  36. package/dist/eval/runner.test.d.ts.map +1 -0
  37. package/dist/eval/runner.test.js +431 -0
  38. package/dist/eval/runner.test.js.map +1 -0
  39. package/dist/eval/types.d.ts +173 -0
  40. package/dist/eval/types.d.ts.map +1 -0
  41. package/dist/eval/types.js +104 -0
  42. package/dist/eval/types.js.map +1 -0
  43. package/dist/event.d.ts +59 -0
  44. package/dist/event.d.ts.map +1 -0
  45. package/dist/event.js +178 -0
  46. package/dist/event.js.map +1 -0
  47. package/dist/event.test.d.ts +2 -0
  48. package/dist/event.test.d.ts.map +1 -0
  49. package/dist/event.test.js +49 -0
  50. package/dist/event.test.js.map +1 -0
  51. package/dist/index.d.ts +30 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +29 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/lessons/capture.d.ts +66 -0
  56. package/dist/lessons/capture.d.ts.map +1 -0
  57. package/dist/lessons/capture.js +166 -0
  58. package/dist/lessons/capture.js.map +1 -0
  59. package/dist/lessons/capture.test.d.ts +2 -0
  60. package/dist/lessons/capture.test.d.ts.map +1 -0
  61. package/dist/lessons/capture.test.js +200 -0
  62. package/dist/lessons/capture.test.js.map +1 -0
  63. package/dist/lessons/decide.d.ts +90 -0
  64. package/dist/lessons/decide.d.ts.map +1 -0
  65. package/dist/lessons/decide.js +334 -0
  66. package/dist/lessons/decide.js.map +1 -0
  67. package/dist/lessons/decide.test.d.ts +2 -0
  68. package/dist/lessons/decide.test.d.ts.map +1 -0
  69. package/dist/lessons/decide.test.js +527 -0
  70. package/dist/lessons/decide.test.js.map +1 -0
  71. package/dist/lessons/id.d.ts +5 -0
  72. package/dist/lessons/id.d.ts.map +1 -0
  73. package/dist/lessons/id.js +20 -0
  74. package/dist/lessons/id.js.map +1 -0
  75. package/dist/lessons/index.d.ts +5 -0
  76. package/dist/lessons/index.d.ts.map +1 -0
  77. package/dist/lessons/index.js +5 -0
  78. package/dist/lessons/index.js.map +1 -0
  79. package/dist/lessons/model.d.ts +163 -0
  80. package/dist/lessons/model.d.ts.map +1 -0
  81. package/dist/lessons/model.js +181 -0
  82. package/dist/lessons/model.js.map +1 -0
  83. package/dist/lessons/model.test.d.ts +2 -0
  84. package/dist/lessons/model.test.d.ts.map +1 -0
  85. package/dist/lessons/model.test.js +178 -0
  86. package/dist/lessons/model.test.js.map +1 -0
  87. package/dist/lessons/permissions.test.d.ts +2 -0
  88. package/dist/lessons/permissions.test.d.ts.map +1 -0
  89. package/dist/lessons/permissions.test.js +88 -0
  90. package/dist/lessons/permissions.test.js.map +1 -0
  91. package/dist/lessons/store.d.ts +74 -0
  92. package/dist/lessons/store.d.ts.map +1 -0
  93. package/dist/lessons/store.js +231 -0
  94. package/dist/lessons/store.js.map +1 -0
  95. package/dist/output-checks.d.ts +64 -0
  96. package/dist/output-checks.d.ts.map +1 -0
  97. package/dist/output-checks.js +248 -0
  98. package/dist/output-checks.js.map +1 -0
  99. package/dist/output-checks.test.d.ts +2 -0
  100. package/dist/output-checks.test.d.ts.map +1 -0
  101. package/dist/output-checks.test.js +58 -0
  102. package/dist/output-checks.test.js.map +1 -0
  103. package/dist/paths.d.ts +37 -0
  104. package/dist/paths.d.ts.map +1 -0
  105. package/dist/paths.js +70 -0
  106. package/dist/paths.js.map +1 -0
  107. package/dist/paths.test.d.ts +2 -0
  108. package/dist/paths.test.d.ts.map +1 -0
  109. package/dist/paths.test.js +36 -0
  110. package/dist/paths.test.js.map +1 -0
  111. package/dist/policies/agi-framing.d.ts +12 -0
  112. package/dist/policies/agi-framing.d.ts.map +1 -0
  113. package/dist/policies/agi-framing.js +33 -0
  114. package/dist/policies/agi-framing.js.map +1 -0
  115. package/dist/policies/anti-anthropomorphism.d.ts +13 -0
  116. package/dist/policies/anti-anthropomorphism.d.ts.map +1 -0
  117. package/dist/policies/anti-anthropomorphism.js +34 -0
  118. package/dist/policies/anti-anthropomorphism.js.map +1 -0
  119. package/dist/policies/anti-dependence.d.ts +12 -0
  120. package/dist/policies/anti-dependence.d.ts.map +1 -0
  121. package/dist/policies/anti-dependence.js +33 -0
  122. package/dist/policies/anti-dependence.js.map +1 -0
  123. package/dist/policies/anti-sycophancy.d.ts +13 -0
  124. package/dist/policies/anti-sycophancy.d.ts.map +1 -0
  125. package/dist/policies/anti-sycophancy.js +34 -0
  126. package/dist/policies/anti-sycophancy.js.map +1 -0
  127. package/dist/policies/dark-pattern.d.ts +14 -0
  128. package/dist/policies/dark-pattern.d.ts.map +1 -0
  129. package/dist/policies/dark-pattern.js +44 -0
  130. package/dist/policies/dark-pattern.js.map +1 -0
  131. package/dist/policies/destructive-needs-approval.d.ts +14 -0
  132. package/dist/policies/destructive-needs-approval.d.ts.map +1 -0
  133. package/dist/policies/destructive-needs-approval.js +31 -0
  134. package/dist/policies/destructive-needs-approval.js.map +1 -0
  135. package/dist/policies/discovery.d.ts +12 -0
  136. package/dist/policies/discovery.d.ts.map +1 -0
  137. package/dist/policies/discovery.js +130 -0
  138. package/dist/policies/discovery.js.map +1 -0
  139. package/dist/policies/high-risk.d.ts +25 -0
  140. package/dist/policies/high-risk.d.ts.map +1 -0
  141. package/dist/policies/high-risk.js +105 -0
  142. package/dist/policies/high-risk.js.map +1 -0
  143. package/dist/policies/human-only-decisions.d.ts +14 -0
  144. package/dist/policies/human-only-decisions.d.ts.map +1 -0
  145. package/dist/policies/human-only-decisions.js +33 -0
  146. package/dist/policies/human-only-decisions.js.map +1 -0
  147. package/dist/policies/index.d.ts +29 -0
  148. package/dist/policies/index.d.ts.map +1 -0
  149. package/dist/policies/index.js +82 -0
  150. package/dist/policies/index.js.map +1 -0
  151. package/dist/policies/no-skip-git-hooks.d.ts +14 -0
  152. package/dist/policies/no-skip-git-hooks.d.ts.map +1 -0
  153. package/dist/policies/no-skip-git-hooks.js +31 -0
  154. package/dist/policies/no-skip-git-hooks.js.map +1 -0
  155. package/dist/policies/package-manager.d.ts +12 -0
  156. package/dist/policies/package-manager.d.ts.map +1 -0
  157. package/dist/policies/package-manager.js +29 -0
  158. package/dist/policies/package-manager.js.map +1 -0
  159. package/dist/policies/patterns.d.ts +17 -0
  160. package/dist/policies/patterns.d.ts.map +1 -0
  161. package/dist/policies/patterns.js +30 -0
  162. package/dist/policies/patterns.js.map +1 -0
  163. package/dist/policies/policies.test.d.ts +2 -0
  164. package/dist/policies/policies.test.d.ts.map +1 -0
  165. package/dist/policies/policies.test.js +210 -0
  166. package/dist/policies/policies.test.js.map +1 -0
  167. package/dist/policies/privacy-transparency.d.ts +14 -0
  168. package/dist/policies/privacy-transparency.d.ts.map +1 -0
  169. package/dist/policies/privacy-transparency.js +50 -0
  170. package/dist/policies/privacy-transparency.js.map +1 -0
  171. package/dist/policies/professional-displacement.d.ts +15 -0
  172. package/dist/policies/professional-displacement.d.ts.map +1 -0
  173. package/dist/policies/professional-displacement.js +45 -0
  174. package/dist/policies/professional-displacement.js.map +1 -0
  175. package/dist/policies/protect-policy.d.ts +14 -0
  176. package/dist/policies/protect-policy.d.ts.map +1 -0
  177. package/dist/policies/protect-policy.js +35 -0
  178. package/dist/policies/protect-policy.js.map +1 -0
  179. package/dist/policies/scope-enforcement.d.ts +14 -0
  180. package/dist/policies/scope-enforcement.d.ts.map +1 -0
  181. package/dist/policies/scope-enforcement.js +34 -0
  182. package/dist/policies/scope-enforcement.js.map +1 -0
  183. package/dist/policies/secret-scan-writes.d.ts +13 -0
  184. package/dist/policies/secret-scan-writes.d.ts.map +1 -0
  185. package/dist/policies/secret-scan-writes.js +38 -0
  186. package/dist/policies/secret-scan-writes.js.map +1 -0
  187. package/dist/policies/selection.d.ts +20 -0
  188. package/dist/policies/selection.d.ts.map +1 -0
  189. package/dist/policies/selection.js +93 -0
  190. package/dist/policies/selection.js.map +1 -0
  191. package/dist/policies/structural-bias.d.ts +14 -0
  192. package/dist/policies/structural-bias.d.ts.map +1 -0
  193. package/dist/policies/structural-bias.js +41 -0
  194. package/dist/policies/structural-bias.js.map +1 -0
  195. package/dist/policies/third-party-impact.d.ts +13 -0
  196. package/dist/policies/third-party-impact.d.ts.map +1 -0
  197. package/dist/policies/third-party-impact.js +38 -0
  198. package/dist/policies/third-party-impact.js.map +1 -0
  199. package/dist/policies/tool-call.d.ts +38 -0
  200. package/dist/policies/tool-call.d.ts.map +1 -0
  201. package/dist/policies/tool-call.js +53 -0
  202. package/dist/policies/tool-call.js.map +1 -0
  203. package/dist/policies/truthfulness-uncertainty.d.ts +13 -0
  204. package/dist/policies/truthfulness-uncertainty.d.ts.map +1 -0
  205. package/dist/policies/truthfulness-uncertainty.js +45 -0
  206. package/dist/policies/truthfulness-uncertainty.js.map +1 -0
  207. package/dist/policies/workspace-writes-only.d.ts +25 -0
  208. package/dist/policies/workspace-writes-only.d.ts.map +1 -0
  209. package/dist/policies/workspace-writes-only.js +54 -0
  210. package/dist/policies/workspace-writes-only.js.map +1 -0
  211. package/dist/policy-engine.d.ts +69 -0
  212. package/dist/policy-engine.d.ts.map +1 -0
  213. package/dist/policy-engine.js +145 -0
  214. package/dist/policy-engine.js.map +1 -0
  215. package/dist/policy-registry.d.ts +62 -0
  216. package/dist/policy-registry.d.ts.map +1 -0
  217. package/dist/policy-registry.js +63 -0
  218. package/dist/policy-registry.js.map +1 -0
  219. package/dist/policy-registry.test.d.ts +2 -0
  220. package/dist/policy-registry.test.d.ts.map +1 -0
  221. package/dist/policy-registry.test.js +79 -0
  222. package/dist/policy-registry.test.js.map +1 -0
  223. package/dist/policy-release.d.ts +44 -0
  224. package/dist/policy-release.d.ts.map +1 -0
  225. package/dist/policy-release.js +65 -0
  226. package/dist/policy-release.js.map +1 -0
  227. package/dist/policy.d.ts +141 -0
  228. package/dist/policy.d.ts.map +1 -0
  229. package/dist/policy.js +22 -0
  230. package/dist/policy.js.map +1 -0
  231. package/dist/quality/audit.d.ts +56 -0
  232. package/dist/quality/audit.d.ts.map +1 -0
  233. package/dist/quality/audit.js +52 -0
  234. package/dist/quality/audit.js.map +1 -0
  235. package/dist/quality/findings.d.ts +34 -0
  236. package/dist/quality/findings.d.ts.map +1 -0
  237. package/dist/quality/findings.js +121 -0
  238. package/dist/quality/findings.js.map +1 -0
  239. package/dist/quality/findings.test.d.ts +2 -0
  240. package/dist/quality/findings.test.d.ts.map +1 -0
  241. package/dist/quality/findings.test.js +79 -0
  242. package/dist/quality/findings.test.js.map +1 -0
  243. package/dist/quality/index.d.ts +20 -0
  244. package/dist/quality/index.d.ts.map +1 -0
  245. package/dist/quality/index.js +20 -0
  246. package/dist/quality/index.js.map +1 -0
  247. package/dist/quality/rule.d.ts +43 -0
  248. package/dist/quality/rule.d.ts.map +1 -0
  249. package/dist/quality/rule.js +162 -0
  250. package/dist/quality/rule.js.map +1 -0
  251. package/dist/quality/rule.test.d.ts +2 -0
  252. package/dist/quality/rule.test.d.ts.map +1 -0
  253. package/dist/quality/rule.test.js +187 -0
  254. package/dist/quality/rule.test.js.map +1 -0
  255. package/dist/quality/tools.d.ts +30 -0
  256. package/dist/quality/tools.d.ts.map +1 -0
  257. package/dist/quality/tools.js +33 -0
  258. package/dist/quality/tools.js.map +1 -0
  259. package/dist/quality/tools.test.d.ts +2 -0
  260. package/dist/quality/tools.test.d.ts.map +1 -0
  261. package/dist/quality/tools.test.js +41 -0
  262. package/dist/quality/tools.test.js.map +1 -0
  263. package/dist/quality/waive.d.ts +37 -0
  264. package/dist/quality/waive.d.ts.map +1 -0
  265. package/dist/quality/waive.js +39 -0
  266. package/dist/quality/waive.js.map +1 -0
  267. package/dist/quality/waivers.d.ts +63 -0
  268. package/dist/quality/waivers.d.ts.map +1 -0
  269. package/dist/quality/waivers.js +132 -0
  270. package/dist/quality/waivers.js.map +1 -0
  271. package/dist/quality/waivers.test.d.ts +2 -0
  272. package/dist/quality/waivers.test.d.ts.map +1 -0
  273. package/dist/quality/waivers.test.js +138 -0
  274. package/dist/quality/waivers.test.js.map +1 -0
  275. package/dist/registry.d.ts +86 -0
  276. package/dist/registry.d.ts.map +1 -0
  277. package/dist/registry.js +92 -0
  278. package/dist/registry.js.map +1 -0
  279. package/dist/registry.test.d.ts +2 -0
  280. package/dist/registry.test.d.ts.map +1 -0
  281. package/dist/registry.test.js +117 -0
  282. package/dist/registry.test.js.map +1 -0
  283. package/dist/rules.d.ts +107 -0
  284. package/dist/rules.d.ts.map +1 -0
  285. package/dist/rules.js +632 -0
  286. package/dist/rules.js.map +1 -0
  287. package/dist/rules.test.d.ts +2 -0
  288. package/dist/rules.test.d.ts.map +1 -0
  289. package/dist/rules.test.js +488 -0
  290. package/dist/rules.test.js.map +1 -0
  291. package/dist/secrets.d.ts +17 -0
  292. package/dist/secrets.d.ts.map +1 -0
  293. package/dist/secrets.js +17 -0
  294. package/dist/secrets.js.map +1 -0
  295. package/dist/secrets.test.d.ts +2 -0
  296. package/dist/secrets.test.d.ts.map +1 -0
  297. package/dist/secrets.test.js +20 -0
  298. package/dist/secrets.test.js.map +1 -0
  299. package/dist/shell-env.d.ts +23 -0
  300. package/dist/shell-env.d.ts.map +1 -0
  301. package/dist/shell-env.js +34 -0
  302. package/dist/shell-env.js.map +1 -0
  303. package/dist/shell-env.test.d.ts +2 -0
  304. package/dist/shell-env.test.d.ts.map +1 -0
  305. package/dist/shell-env.test.js +45 -0
  306. package/dist/shell-env.test.js.map +1 -0
  307. package/package.json +49 -4
@@ -0,0 +1,145 @@
1
+ /**
2
+ * The policy engine (§21.3).
3
+ *
4
+ * The engine asks the stack for a decision and records what it decided. The
5
+ * record carries the id of the policy, the version it had at that moment,
6
+ * the session and the outcome, so a regression is attributed to the version
7
+ * that caused it.
8
+ *
9
+ * The engine writes through a sink and knows nothing of any store, so the
10
+ * log is the caller's choice: the ledger is the one the plan names, and the
11
+ * rows survive a restart because they are rows in a database and not words
12
+ * in a process.
13
+ */
14
+ /** The id of the row that records the assembled stack. */
15
+ export const STACK_POLICY_ID = 'oa.policy.stack';
16
+ /** The version of the stack row. */
17
+ export const STACK_POLICY_VERSION = '1.0.0';
18
+ /**
19
+ * The moment a context is about.
20
+ *
21
+ * A context with a tool call is about the call, one with a response is
22
+ * about the reply, and one with a request is about the request. A context
23
+ * with none of them is about nothing, and no policy runs.
24
+ */
25
+ export function momentOf(ctx) {
26
+ if (ctx.toolCall !== undefined)
27
+ return 'PreToolCall';
28
+ if (ctx.response !== undefined)
29
+ return 'PreResponse';
30
+ if (ctx.request !== undefined)
31
+ return 'UserPromptSubmit';
32
+ return undefined;
33
+ }
34
+ /**
35
+ * A decision, as the engine reports it.
36
+ *
37
+ * A decision that allowed the thing through carries no findings, and a
38
+ * decision that flagged carries the severity of the flag.
39
+ */
40
+ export function outcomeOf(module, result) {
41
+ const base = { policyId: module.id, version: module.version, layer: module.layer };
42
+ switch (result.action) {
43
+ case 'allow':
44
+ return { ...base, action: 'allow', findings: [] };
45
+ case 'flag':
46
+ return { ...base, action: 'flag', severity: result.severity, findings: result.findings };
47
+ case 'block':
48
+ return {
49
+ ...base,
50
+ action: 'block',
51
+ reason: result.reason,
52
+ findings: result.finding === undefined ? [] : [result.finding],
53
+ };
54
+ case 'transform':
55
+ return { ...base, action: 'transform', findings: [] };
56
+ }
57
+ }
58
+ /** The engine of a registry. */
59
+ export class PolicyEngine {
60
+ /** The registry the stack comes from. */
61
+ registry;
62
+ /** Where the firings go. */
63
+ sink;
64
+ /** The sessions whose stack was already recorded. */
65
+ assembled = new Set();
66
+ /**
67
+ * An engine of a registry.
68
+ *
69
+ * The engine holds no state beyond the sessions whose stack it recorded,
70
+ * so it may be built once for a session and used for every call in it.
71
+ */
72
+ constructor(registry, options = {}) {
73
+ this.registry = registry;
74
+ this.sink = options.sink;
75
+ }
76
+ /**
77
+ * Ask the stack, and record what it decided.
78
+ *
79
+ * The stack is recorded once per session: the first row of the session
80
+ * carries the whole stack, so a reader can see what the session was
81
+ * guarded by without reading every row.
82
+ */
83
+ evaluate(ctx) {
84
+ const classification = ctx.request?.classification ?? {};
85
+ const selection = this.registry.explain(classification);
86
+ this.recordStack(ctx, selection);
87
+ const moment = momentOf(ctx);
88
+ if (moment === undefined)
89
+ return [];
90
+ const outcomes = [];
91
+ for (const module of selection.modules) {
92
+ if (!module.appliesTo.includes(moment))
93
+ continue;
94
+ const result = module.evaluate(ctx);
95
+ const outcome = outcomeOf(module, result);
96
+ outcomes.push(outcome);
97
+ this.record(ctx, module, outcome);
98
+ }
99
+ return outcomes;
100
+ }
101
+ /** The row that records the stack of a session. */
102
+ recordStack(ctx, selection) {
103
+ if (this.sink === undefined)
104
+ return;
105
+ if (this.assembled.has(ctx.session.id))
106
+ return;
107
+ this.assembled.add(ctx.session.id);
108
+ const stack = selection.modules.map((module) => ({
109
+ id: module.id,
110
+ version: module.version,
111
+ }));
112
+ this.sink.record({
113
+ sessionId: ctx.session.id,
114
+ policyId: STACK_POLICY_ID,
115
+ policyVersion: STACK_POLICY_VERSION,
116
+ layer: 2,
117
+ action: 'allow',
118
+ reason: 'stack-assembled',
119
+ classification: ctx.highRiskDomain ?? ctx.request?.classification?.highRiskDomain,
120
+ detail: JSON.stringify(stack),
121
+ origin: 'first-party',
122
+ });
123
+ }
124
+ /** The row that records one decision. */
125
+ record(ctx, module, outcome) {
126
+ if (this.sink === undefined)
127
+ return;
128
+ const firing = {
129
+ sessionId: ctx.session.id,
130
+ policyId: outcome.policyId,
131
+ policyVersion: outcome.version,
132
+ layer: outcome.layer,
133
+ action: outcome.action,
134
+ severity: outcome.severity,
135
+ reason: outcome.reason,
136
+ classification: ctx.highRiskDomain ?? ctx.request?.classification?.highRiskDomain,
137
+ origin: module.origin,
138
+ };
139
+ if (outcome.findings.length > 0) {
140
+ firing.detail = JSON.stringify(outcome.findings);
141
+ }
142
+ this.sink.record(firing);
143
+ }
144
+ }
145
+ //# sourceMappingURL=policy-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-engine.js","sourceRoot":"","sources":["../src/policy-engine.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;GAYG;AAEH,0DAA0D;AAC1D,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEjD,oCAAoC;AACpC,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAQ5C;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAkB;IACzC,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,aAAa,CAAC;IACrD,IAA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,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnD,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,62 @@
1
+ import type { RequestClassification } from '@openagentsy/core';
2
+ import type { PolicyLayer, PolicyModule } from './policy.js';
3
+ /**
4
+ * The policy registry (§21.4).
5
+ *
6
+ * The registry holds the modules and assembles the stack from a
7
+ * classification. The assembly is explainable: `explain` says which modules
8
+ * were selected and why each of them is in the stack, so a reader can tell
9
+ * a guardrail that is always on from one the classifier brought in.
10
+ */
11
+ /** Why a module is in the stack. */
12
+ export interface PolicySelectionReason {
13
+ /** The stable id of the module. */
14
+ policyId: string;
15
+ /** The version it carried. */
16
+ version: string;
17
+ /** The layer it acts at. */
18
+ layer: PolicyLayer;
19
+ /** Why it was selected. */
20
+ reason: string;
21
+ }
22
+ /** The stack, and why it is what it is. */
23
+ export interface PolicySelection {
24
+ /** The modules that were selected. */
25
+ modules: PolicyModule[];
26
+ /** The reason of each of them, in the order they were selected. */
27
+ reasons: PolicySelectionReason[];
28
+ }
29
+ /** The registry of a set of modules. */
30
+ export declare class PolicyRegistry {
31
+ /** The modules, by id. */
32
+ private readonly byId;
33
+ /**
34
+ * A registry of a set of modules.
35
+ *
36
+ * Two modules with the same id are one module: the first one wins, and a
37
+ * plugin that claims the id of a first-party policy does not replace it.
38
+ */
39
+ constructor(modules: readonly PolicyModule[]);
40
+ /** Every module of the registry. */
41
+ list(): PolicyModule[];
42
+ /**
43
+ * A registry of the first-party policies and the ones a plugin brought.
44
+ *
45
+ * The candidates are the modules a host loaded, and the ones that are
46
+ * policies are marked external: a module that came from a plugin is the
47
+ * plugin's, and it does not count towards the first-party release
48
+ * criteria.
49
+ */
50
+ static withPlugins(firstParty: readonly PolicyModule[], candidates: readonly unknown[]): PolicyRegistry;
51
+ /** The stack for a classification. */
52
+ select(classification: RequestClassification): PolicyModule[];
53
+ /**
54
+ * The stack for a classification, and why each module is in it.
55
+ *
56
+ * The explanation is the reason the stack is what it is, so it is built
57
+ * once and read twice: the modules come out of it and the reasons come
58
+ * with them.
59
+ */
60
+ explain(classification: RequestClassification): PolicySelection;
61
+ }
62
+ //# sourceMappingURL=policy-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-registry.d.ts","sourceRoot":"","sources":["../src/policy-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG/D,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE7D;;;;;;;GAOG;AAEH,oCAAoC;AACpC,MAAM,WAAW,qBAAqB;IACpC,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,KAAK,EAAE,WAAW,CAAC;IACnB,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,2CAA2C;AAC3C,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,mEAAmE;IACnE,OAAO,EAAE,qBAAqB,EAAE,CAAC;CAClC;AAED,wCAAwC;AACxC,qBAAa,cAAc;IACzB,0BAA0B;IAC1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4B;IAEjD;;;;;OAKG;gBACS,OAAO,EAAE,SAAS,YAAY,EAAE;IAQ5C,oCAAoC;IACpC,IAAI,IAAI,YAAY,EAAE;IAItB;;;;;;;OAOG;IACH,MAAM,CAAC,WAAW,CAChB,UAAU,EAAE,SAAS,YAAY,EAAE,EACnC,UAAU,EAAE,SAAS,OAAO,EAAE,GAC7B,cAAc;IAIjB,sCAAsC;IACtC,MAAM,CAAC,cAAc,EAAE,qBAAqB,GAAG,YAAY,EAAE;IAI7D;;;;;;OAMG;IACH,OAAO,CAAC,cAAc,EAAE,qBAAqB,GAAG,eAAe;CAehE"}
@@ -0,0 +1,63 @@
1
+ import { discoverPolicyModules } from './policies/discovery.js';
2
+ import { selectPolicies } from './policies/selection.js';
3
+ /** The registry of a set of modules. */
4
+ export class PolicyRegistry {
5
+ /** The modules, by id. */
6
+ byId;
7
+ /**
8
+ * A registry of a set of modules.
9
+ *
10
+ * Two modules with the same id are one module: the first one wins, and a
11
+ * plugin that claims the id of a first-party policy does not replace it.
12
+ */
13
+ constructor(modules) {
14
+ this.byId = new Map();
15
+ for (const module of modules) {
16
+ if (this.byId.has(module.id))
17
+ continue;
18
+ this.byId.set(module.id, module);
19
+ }
20
+ }
21
+ /** Every module of the registry. */
22
+ list() {
23
+ return [...this.byId.values()];
24
+ }
25
+ /**
26
+ * A registry of the first-party policies and the ones a plugin brought.
27
+ *
28
+ * The candidates are the modules a host loaded, and the ones that are
29
+ * policies are marked external: a module that came from a plugin is the
30
+ * plugin's, and it does not count towards the first-party release
31
+ * criteria.
32
+ */
33
+ static withPlugins(firstParty, candidates) {
34
+ return new PolicyRegistry([...firstParty, ...discoverPolicyModules(candidates)]);
35
+ }
36
+ /** The stack for a classification. */
37
+ select(classification) {
38
+ return this.explain(classification).modules;
39
+ }
40
+ /**
41
+ * The stack for a classification, and why each module is in it.
42
+ *
43
+ * The explanation is the reason the stack is what it is, so it is built
44
+ * once and read twice: the modules come out of it and the reasons come
45
+ * with them.
46
+ */
47
+ explain(classification) {
48
+ const selected = selectPolicies(this.list(), classification);
49
+ const modules = [];
50
+ const reasons = [];
51
+ for (const entry of selected) {
52
+ modules.push(entry.module);
53
+ reasons.push({
54
+ policyId: entry.module.id,
55
+ version: entry.module.version,
56
+ layer: entry.module.layer,
57
+ reason: entry.reason,
58
+ });
59
+ }
60
+ return { modules, reasons };
61
+ }
62
+ }
63
+ //# sourceMappingURL=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KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC3B,OAAO,CAAC,IAAI,CAAC;gBACX,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE;gBACzB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO;gBAC7B,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK;gBACzB,MAAM,EAAE,KAAK,CAAC,MAAM;aACrB,CAAC,CAAC;QACL,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAC9B,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=policy-registry.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-registry.test.d.ts","sourceRoot":"","sources":["../src/policy-registry.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,79 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { FIRST_PARTY_POLICY_IDS, firstPartyPolicyModules } from './policies/index.js';
3
+ import { PolicyRegistry } from './policy-registry.js';
4
+ /**
5
+ * The selection of the policy stack (§21.4).
6
+ *
7
+ * The registry assembles the stack from the classification, and the
8
+ * assembly is explainable: every module says why it is in the stack.
9
+ */
10
+ /** The catalogue of the first-party policies. */
11
+ function registry() {
12
+ return new PolicyRegistry(firstPartyPolicyModules({ workspace: '/tmp/openagentsy-registry-test' }));
13
+ }
14
+ describe('the policy registry', () => {
15
+ it('gives every session the baseline stack and the always-on guardrails', () => {
16
+ const selected = registry().select({});
17
+ const ids = selected.map((module) => module.id);
18
+ expect(ids).toContain('oa.truthfulness-uncertainty');
19
+ expect(ids).toContain('oa.anti-sycophancy');
20
+ expect(ids).toContain('oa.no-skip-git-hooks');
21
+ expect(ids).not.toContain('oa.high-risk.medical');
22
+ });
23
+ it('adds the high-risk module of the domain the classification named', () => {
24
+ const selected = registry().select({ highRiskDomain: 'medical', confidence: 0.9 });
25
+ const ids = selected.map((module) => module.id);
26
+ expect(ids).toContain('oa.high-risk.medical');
27
+ expect(ids).not.toContain('oa.high-risk.legal');
28
+ });
29
+ it('says why each module was selected', () => {
30
+ const selection = registry().explain({ highRiskDomain: 'legal' });
31
+ const reason = (id) => selection.reasons.find((entry) => entry.policyId === id)?.reason;
32
+ expect(reason('oa.no-skip-git-hooks')).toBe('the guardrail applies to every tool call');
33
+ expect(reason('oa.anti-sycophancy')).toBe('every session gets this policy');
34
+ expect(reason('oa.high-risk.legal')).toBe('the classification named the legal domain');
35
+ expect(reason('oa.high-risk.medical')).toBeUndefined();
36
+ });
37
+ it('carries the version of every module it selected', () => {
38
+ const selection = registry().explain({});
39
+ for (const entry of selection.reasons) {
40
+ expect(entry.version).toMatch(/^\d+\.\d+\.\d+$/);
41
+ }
42
+ });
43
+ it('runs a module a plugin brought, and marks it external', () => {
44
+ const candidate = {
45
+ id: 'acme.no-warnings',
46
+ version: '0.1.0',
47
+ layer: 4,
48
+ description: 'A module a downstream project brought.',
49
+ appliesTo: ['PreResponse'],
50
+ evaluate: () => ({ action: 'allow' }),
51
+ };
52
+ const registry = PolicyRegistry.withPlugins(firstPartyPolicyModules({ workspace: '/tmp/ws' }), [
53
+ candidate,
54
+ ]);
55
+ const selected = registry.select({});
56
+ const module = selected.find((entry) => entry.id === 'acme.no-warnings');
57
+ expect(module?.origin).toBe('external');
58
+ });
59
+ it('drops a candidate that is not a policy', () => {
60
+ const registry = PolicyRegistry.withPlugins(firstPartyPolicyModules({ workspace: '/tmp/ws' }), [
61
+ { id: 'acme.broken', version: 'not-a-version' },
62
+ 'nonsense',
63
+ ]);
64
+ expect(registry.select({}).map((module) => module.id)).not.toContain('acme.broken');
65
+ });
66
+ it('holds every first-party policy of §21.2 with an id and a version', () => {
67
+ const modules = firstPartyPolicyModules({ workspace: '/tmp/ws' });
68
+ const ids = modules.map((module) => module.id);
69
+ for (const id of FIRST_PARTY_POLICY_IDS) {
70
+ expect(ids).toContain(id);
71
+ }
72
+ expect(new Set(ids).size).toBe(ids.length);
73
+ for (const module of modules) {
74
+ expect(module.version).toMatch(/^\d+\.\d+\.\d+$/);
75
+ expect(module.origin).toBe('first-party');
76
+ }
77
+ });
78
+ });
79
+ //# sourceMappingURL=policy-registry.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-registry.test.js","sourceRoot":"","sources":["../src/policy-registry.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;GAKG;AAEH,iDAAiD;AACjD,SAAS,QAAQ;IACf,OAAO,IAAI,cAAc,CACvB,uBAAuB,CAAC,EAAE,SAAS,EAAE,gCAAgC,EAAE,CAAC,CACzE,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,EAAE,CAAC,qEAAqE,EAAE,GAAG,EAAE;QAC7E,MAAM,QAAQ,GAAG,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAEvC,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAChD,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,6BAA6B,CAAC,CAAC;QACrD,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;QAC5C,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC;QAC9C,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,E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G,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACtF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QAC1E,MAAM,OAAO,GAAG,uBAAuB,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC;QAElE,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC/C,KAAK,MAAM,EAAE,IAAI,sBAAsB,EAAE,CAAC;YACxC,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAC5B,CAAC;QACD,MAAM,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YAClD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { PolicyModule } from './policy.js';
2
+ /**
3
+ * The release criteria of the policy library (§18.3).
4
+ *
5
+ * `oa release-check` is a later bean; what it needs from here is the list
6
+ * of criteria the policy library answers, the severity of each of them and
7
+ * whether it is met. The severity follows the decision the human made: a
8
+ * first-party template and a first-party role are held to the criteria
9
+ * hard, and a library is held to them softly.
10
+ */
11
+ /** What is being released. */
12
+ export type ReleaseScope = 'template' | 'role' | 'library';
13
+ /** How hard a criterion is held. */
14
+ export type ReleaseSeverity = 'hard' | 'soft';
15
+ /** One criterion, and whether it is met. */
16
+ export interface ReleaseCriterion {
17
+ /** The stable id of the criterion. */
18
+ id: string;
19
+ /** What the criterion asks for, in a line. */
20
+ description: string;
21
+ /** How hard the criterion is held. */
22
+ severity: ReleaseSeverity;
23
+ /** Whether the modules meet it. */
24
+ met: boolean;
25
+ /** What the answer was, in a line. */
26
+ detail: string;
27
+ }
28
+ /**
29
+ * The severity a scope holds a criterion to.
30
+ *
31
+ * A template and a role are what a person installs and trusts, so a
32
+ * criterion is hard there. A library is a building block, and a soft
33
+ * criterion is what a soft failure looks like.
34
+ */
35
+ export declare function severityFor(scope: ReleaseScope): ReleaseSeverity;
36
+ /**
37
+ * The criteria the policy library answers, and their answers.
38
+ *
39
+ * Only the first-party modules are counted: a module a plugin brought is
40
+ * marked external and does not count towards the criteria of a first-party
41
+ * release.
42
+ */
43
+ export declare function policyReleaseCriteria(modules: readonly PolicyModule[], scope: ReleaseScope): ReleaseCriterion[];
44
+ //# sourceMappingURL=policy-release.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-release.d.ts","sourceRoot":"","sources":["../src/policy-release.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;;;;GAQG;AAEH,8BAA8B;AAC9B,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAE3D,oCAAoC;AACpC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9C,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,QAAQ,EAAE,eAAe,CAAC;IAC1B,mCAAmC;IACnC,GAAG,EAAE,OAAO,CAAC;IACb,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,eAAe,CAEhE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,KAAK,EAAE,YAAY,GAClB,gBAAgB,EAAE,CAoDpB"}
@@ -0,0 +1,65 @@
1
+ import { isSemver } from './policies/discovery.js';
2
+ /**
3
+ * The severity a scope holds a criterion to.
4
+ *
5
+ * A template and a role are what a person installs and trusts, so a
6
+ * criterion is hard there. A library is a building block, and a soft
7
+ * criterion is what a soft failure looks like.
8
+ */
9
+ export function severityFor(scope) {
10
+ return scope === 'library' ? 'soft' : 'hard';
11
+ }
12
+ /**
13
+ * The criteria the policy library answers, and their answers.
14
+ *
15
+ * Only the first-party modules are counted: a module a plugin brought is
16
+ * marked external and does not count towards the criteria of a first-party
17
+ * release.
18
+ */
19
+ export function policyReleaseCriteria(modules, scope) {
20
+ const severity = severityFor(scope);
21
+ const firstParty = modules.filter((module) => module.origin === 'first-party');
22
+ const external = modules.filter((module) => module.origin === 'external');
23
+ const withoutId = firstParty.filter((module) => module.id.trim().length === 0);
24
+ const withoutVersion = firstParty.filter((module) => !isSemver(module.version));
25
+ const withoutLayer = firstParty.filter((module) => !Number.isInteger(module.layer));
26
+ return [
27
+ {
28
+ id: 'policy-ids',
29
+ description: 'Every first-party policy module carries a stable id.',
30
+ severity,
31
+ met: withoutId.length === 0,
32
+ detail: withoutId.length === 0
33
+ ? `${firstParty.length} first-party modules carry an id`
34
+ : `${withoutId.length} modules carry no id`,
35
+ },
36
+ {
37
+ id: 'policy-versions',
38
+ description: 'Every first-party policy module carries a version.',
39
+ severity,
40
+ met: withoutVersion.length === 0,
41
+ detail: withoutVersion.length === 0
42
+ ? `${firstParty.length} first-party modules carry a version`
43
+ : `${withoutVersion.length} modules carry no version`,
44
+ },
45
+ {
46
+ id: 'policy-layers',
47
+ description: 'Every first-party policy module maps to a layer of the guardrail stack.',
48
+ severity,
49
+ met: withoutLayer.length === 0,
50
+ detail: withoutLayer.length === 0
51
+ ? `${firstParty.length} first-party modules map to a layer`
52
+ : `${withoutLayer.length} modules map to no layer`,
53
+ },
54
+ {
55
+ id: 'policy-origin',
56
+ description: 'The modules a plugin brought are marked external and do not count towards the criteria.',
57
+ severity,
58
+ met: external.every((module) => module.origin === 'external'),
59
+ detail: external.length === 0
60
+ ? 'no plugin module is in the release'
61
+ : `${external.length} plugin modules are marked external and are not counted`,
62
+ },
63
+ ];
64
+ }
65
+ //# sourceMappingURL=policy-release.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-release.js","sourceRoot":"","sources":["../src/policy-release.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAiCnD;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAAmB;IAC7C,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAgC,EAChC,KAAmB;IAEnB,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC;IAC/E,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;IAE1E,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;IAC/E,MAAM,cAAc,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CA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J,QAAQ,CAAC,MAAM,KAAK,CAAC;gBACnB,CAAC,CAAC,oCAAoC;gBACtC,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,yDAAyD;SAClF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,141 @@
1
+ import type { PolicyAction, PolicyOrigin, PolicySeverity, RequestClassification } from '@openagentsy/core';
2
+ /**
3
+ * The policy module interface (§21.1).
4
+ *
5
+ * A policy is a module with a stable id, a version and a decision. The id
6
+ * is what a firing is attributed to and what a project enables or disables,
7
+ * so it does not change when the behaviour does — the version changes then,
8
+ * and the firing log records the version that was in force when the policy
9
+ * fired.
10
+ */
11
+ /** The layers of the guardrail stack (§17.4). */
12
+ export type PolicyLayer = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
13
+ /** The moments a policy is checked at (§21.1). */
14
+ export type PolicyMoment = 'UserPromptSubmit' | 'PreToolCall' | 'PostToolCall' | 'PreResponse' | 'PostResponse' | 'PreCompact' | 'SubagentStop';
15
+ /** A file a call touches. */
16
+ export interface FileChange {
17
+ /** The path the change writes to, when it names one. */
18
+ path?: string;
19
+ /** The path the change moves from, when it names one. */
20
+ fromPath?: string;
21
+ }
22
+ /** What a policy found. */
23
+ export interface PolicyFinding {
24
+ /** The policy that found it. */
25
+ policyId: string;
26
+ /** What kind of thing it is. */
27
+ type: string;
28
+ /** The text that matched. */
29
+ match: string;
30
+ }
31
+ /**
32
+ * What a policy is asked.
33
+ *
34
+ * The context carries what the policy needs and nothing else: the request
35
+ * and its classification, the tool call and its result, the response, the
36
+ * session the work happens in, the files it touches and the high-risk domain
37
+ * the classifier fired on (§20.3).
38
+ */
39
+ export interface PolicyContext {
40
+ /** The request, and the classification of it. */
41
+ request?: {
42
+ text: string;
43
+ classification?: RequestClassification;
44
+ };
45
+ /** The tool call, when the policy is asked about one. */
46
+ toolCall?: {
47
+ name: string;
48
+ args: unknown;
49
+ };
50
+ /** The result of the tool call, when there is one. */
51
+ toolResult?: {
52
+ output: unknown;
53
+ };
54
+ /** The response, when the policy is asked about one. */
55
+ response?: {
56
+ text: string;
57
+ };
58
+ /** The session the work happens in. */
59
+ session: {
60
+ id: string;
61
+ taskId?: string;
62
+ roleId: string;
63
+ };
64
+ /** The files the work touches. */
65
+ files?: FileChange[];
66
+ /** The high-risk domain the classifier fired on, when it fired (§20.3). */
67
+ highRiskDomain?: string;
68
+ /** The declared scope of the role (§22), when the role declares one. */
69
+ scope?: {
70
+ declaredPaths?: readonly string[];
71
+ };
72
+ }
73
+ /**
74
+ * What a policy decided.
75
+ *
76
+ * A policy that lets the thing through says so, a policy that notes
77
+ * something flags it, a policy that stops it blocks it with a reason, and a
78
+ * policy that changes it hands the change back.
79
+ */
80
+ export type PolicyResult = {
81
+ action: 'allow';
82
+ } | {
83
+ action: 'flag';
84
+ findings: PolicyFinding[];
85
+ severity: PolicySeverity;
86
+ } | {
87
+ action: 'block';
88
+ reason: string;
89
+ finding?: PolicyFinding;
90
+ } | {
91
+ action: 'transform';
92
+ payload: unknown;
93
+ };
94
+ /** A policy module. */
95
+ export interface PolicyModule {
96
+ /** The stable id of the policy, e.g. `oa.anti-sycophancy`. */
97
+ id: string;
98
+ /** The version of the policy, e.g. `1.0.0`. */
99
+ version: string;
100
+ /** The layer of the guardrail stack the policy acts at (§17.4). */
101
+ layer: PolicyLayer;
102
+ /** What the policy is for, in a line. */
103
+ description: string;
104
+ /** The moments the policy is checked at. */
105
+ appliesTo: PolicyMoment[];
106
+ /** Whether the policy is ours or came from a plugin (§21). */
107
+ origin: PolicyOrigin;
108
+ /** The decision the policy makes. */
109
+ evaluate: (ctx: PolicyContext) => PolicyResult;
110
+ }
111
+ /** The result of a policy that let the thing through. */
112
+ export declare function allow(): PolicyResult;
113
+ /** The result of a policy that noted something. */
114
+ export declare function flag(findings: PolicyFinding[], severity?: PolicySeverity): PolicyResult;
115
+ /** The result of a policy that stopped the thing. */
116
+ export declare function block(reason: string, finding?: PolicyFinding): PolicyResult;
117
+ /**
118
+ * The findings of a set of matches.
119
+ *
120
+ * The policy id is on every finding, so a finding that travels on its own
121
+ * still says which policy produced it.
122
+ */
123
+ export declare function findingsOf(policyId: string, type: string, matches: readonly string[]): PolicyFinding[];
124
+ /** What a policy did, as the engine reports it. */
125
+ export type PolicyOutcome = {
126
+ /** The policy that was asked. */
127
+ policyId: string;
128
+ /** The version it carried at that moment. */
129
+ version: string;
130
+ /** The layer it acts at. */
131
+ layer: PolicyLayer;
132
+ /** What it decided. */
133
+ action: PolicyAction;
134
+ /** The severity of a flag. */
135
+ severity?: PolicySeverity | undefined;
136
+ /** Why it acted. */
137
+ reason?: string | undefined;
138
+ /** What it found. */
139
+ findings: PolicyFinding[];
140
+ };
141
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;GAQG;AAEH,iDAAiD;AACjD,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAExD,kDAAkD;AAClD,MAAM,MAAM,YAAY,GACpB,kBAAkB,GAClB,aAAa,GACb,cAAc,GACd,aAAa,GACb,cAAc,GACd,YAAY,GACZ,cAAc,CAAC;AAEnB,6BAA6B;AAC7B,MAAM,WAAW,UAAU;IACzB,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,2BAA2B;AAC3B,MAAM,WAAW,aAAa;IAC5B,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,KAAK,E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