oxe-cc 0.9.3 → 1.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 (319) hide show
  1. package/.cursor/commands/oxe-ask.md +1 -1
  2. package/.cursor/commands/oxe-capabilities.md +1 -1
  3. package/.cursor/commands/oxe-checkpoint.md +1 -1
  4. package/.cursor/commands/oxe-compact.md +1 -1
  5. package/.cursor/commands/oxe-dashboard.md +1 -1
  6. package/.cursor/commands/oxe-debug.md +1 -1
  7. package/.cursor/commands/oxe-discuss.md +1 -1
  8. package/.cursor/commands/oxe-execute.md +2 -2
  9. package/.cursor/commands/oxe-forensics.md +1 -1
  10. package/.cursor/commands/oxe-help.md +1 -1
  11. package/.cursor/commands/oxe-loop.md +1 -1
  12. package/.cursor/commands/oxe-milestone.md +1 -1
  13. package/.cursor/commands/oxe-next.md +1 -1
  14. package/.cursor/commands/oxe-obs.md +1 -1
  15. package/.cursor/commands/oxe-plan-agent.md +1 -1
  16. package/.cursor/commands/oxe-plan.md +1 -1
  17. package/.cursor/commands/oxe-project.md +1 -1
  18. package/.cursor/commands/oxe-quick.md +1 -1
  19. package/.cursor/commands/oxe-research.md +1 -1
  20. package/.cursor/commands/oxe-retro.md +1 -1
  21. package/.cursor/commands/oxe-review-pr.md +1 -1
  22. package/.cursor/commands/oxe-route.md +1 -1
  23. package/.cursor/commands/oxe-scan.md +1 -1
  24. package/.cursor/commands/oxe-security.md +1 -1
  25. package/.cursor/commands/oxe-session.md +2 -2
  26. package/.cursor/commands/oxe-ship.md +45 -0
  27. package/.cursor/commands/oxe-skill.md +1 -1
  28. package/.cursor/commands/oxe-spec.md +1 -1
  29. package/.cursor/commands/oxe-ui-review.md +1 -1
  30. package/.cursor/commands/oxe-ui-spec.md +1 -1
  31. package/.cursor/commands/oxe-update.md +1 -1
  32. package/.cursor/commands/oxe-validate-gaps.md +1 -1
  33. package/.cursor/commands/oxe-verify.md +1 -1
  34. package/.cursor/commands/oxe-workstream.md +1 -1
  35. package/.cursor/commands/oxe.md +4 -4
  36. package/.github/copilot-instructions.md +91 -1
  37. package/.github/prompts/oxe-ask.prompt.md +1 -1
  38. package/.github/prompts/oxe-capabilities.prompt.md +1 -1
  39. package/.github/prompts/oxe-checkpoint.prompt.md +1 -1
  40. package/.github/prompts/oxe-compact.prompt.md +1 -1
  41. package/.github/prompts/oxe-dashboard.prompt.md +1 -1
  42. package/.github/prompts/oxe-debug.prompt.md +1 -1
  43. package/.github/prompts/oxe-discuss.prompt.md +1 -1
  44. package/.github/prompts/oxe-execute.prompt.md +2 -2
  45. package/.github/prompts/oxe-forensics.prompt.md +1 -1
  46. package/.github/prompts/oxe-help.prompt.md +1 -1
  47. package/.github/prompts/oxe-loop.prompt.md +1 -1
  48. package/.github/prompts/oxe-milestone.prompt.md +1 -1
  49. package/.github/prompts/oxe-next.prompt.md +1 -1
  50. package/.github/prompts/oxe-obs.prompt.md +1 -1
  51. package/.github/prompts/oxe-plan-agent.prompt.md +1 -1
  52. package/.github/prompts/oxe-plan.prompt.md +1 -1
  53. package/.github/prompts/oxe-project.prompt.md +1 -1
  54. package/.github/prompts/oxe-quick.prompt.md +1 -1
  55. package/.github/prompts/oxe-research.prompt.md +1 -1
  56. package/.github/prompts/oxe-retro.prompt.md +1 -1
  57. package/.github/prompts/oxe-review-pr.prompt.md +1 -1
  58. package/.github/prompts/oxe-route.prompt.md +1 -1
  59. package/.github/prompts/oxe-scan.prompt.md +1 -1
  60. package/.github/prompts/oxe-security.prompt.md +1 -1
  61. package/.github/prompts/oxe-session.prompt.md +2 -2
  62. package/.github/prompts/oxe-ship.prompt.md +45 -0
  63. package/.github/prompts/oxe-skill.prompt.md +1 -1
  64. package/.github/prompts/oxe-spec.prompt.md +1 -1
  65. package/.github/prompts/oxe-ui-review.prompt.md +1 -1
  66. package/.github/prompts/oxe-ui-spec.prompt.md +1 -1
  67. package/.github/prompts/oxe-update.prompt.md +1 -1
  68. package/.github/prompts/oxe-validate-gaps.prompt.md +1 -1
  69. package/.github/prompts/oxe-verify.prompt.md +1 -1
  70. package/.github/prompts/oxe-workstream.prompt.md +1 -1
  71. package/.github/prompts/oxe.prompt.md +3 -3
  72. package/AGENTS.md +43 -28
  73. package/CHANGELOG.md +158 -0
  74. package/README.md +72 -50
  75. package/bin/banner.txt +1 -1
  76. package/bin/lib/oxe-dashboard.cjs +9 -7
  77. package/bin/lib/oxe-operational.cjs +569 -4
  78. package/bin/lib/oxe-project-health.cjs +1 -1
  79. package/bin/oxe-cc.js +141 -57
  80. package/commands/oxe/ask.md +5 -1
  81. package/commands/oxe/checkpoint.md +1 -1
  82. package/commands/oxe/compact.md +1 -1
  83. package/commands/oxe/debug.md +1 -1
  84. package/commands/oxe/execute.md +2 -2
  85. package/commands/oxe/forensics.md +1 -1
  86. package/commands/oxe/loop.md +1 -1
  87. package/commands/oxe/milestone.md +1 -1
  88. package/commands/oxe/next.md +1 -1
  89. package/commands/oxe/obs.md +1 -1
  90. package/commands/oxe/oxe.md +3 -3
  91. package/commands/oxe/project.md +1 -1
  92. package/commands/oxe/research.md +1 -1
  93. package/commands/oxe/retro.md +1 -1
  94. package/commands/oxe/review-pr.md +1 -1
  95. package/commands/oxe/route.md +1 -1
  96. package/commands/oxe/scan.md +1 -1
  97. package/commands/oxe/security.md +1 -1
  98. package/commands/oxe/session.md +2 -2
  99. package/commands/oxe/ship.md +49 -0
  100. package/commands/oxe/spec.md +2 -2
  101. package/commands/oxe/ui-review.md +1 -1
  102. package/commands/oxe/ui-spec.md +1 -1
  103. package/commands/oxe/validate-gaps.md +1 -1
  104. package/commands/oxe/verify.md +2 -2
  105. package/commands/oxe/workstream.md +1 -1
  106. package/lib/runtime/audit/audit-trail.d.ts +71 -0
  107. package/lib/runtime/audit/audit-trail.js +154 -0
  108. package/lib/runtime/audit/index.d.ts +2 -0
  109. package/lib/runtime/audit/index.js +18 -0
  110. package/lib/runtime/audit/policy-pack.d.ts +15 -0
  111. package/lib/runtime/audit/policy-pack.js +57 -0
  112. package/lib/runtime/compiler/graph-compiler.d.ts +83 -0
  113. package/lib/runtime/compiler/graph-compiler.js +135 -0
  114. package/lib/runtime/compiler/index.d.ts +1 -0
  115. package/lib/runtime/compiler/index.js +17 -0
  116. package/lib/runtime/context/context-pack-builder.d.ts +51 -0
  117. package/lib/runtime/context/context-pack-builder.js +178 -0
  118. package/lib/runtime/context/context-pack-store.d.ts +38 -0
  119. package/lib/runtime/context/context-pack-store.js +142 -0
  120. package/lib/runtime/context/context-profiles.d.ts +11 -0
  121. package/lib/runtime/context/context-profiles.js +51 -0
  122. package/lib/runtime/context/index.d.ts +3 -0
  123. package/lib/runtime/context/index.js +19 -0
  124. package/lib/runtime/decision/decision-engine.d.ts +43 -0
  125. package/lib/runtime/decision/decision-engine.js +127 -0
  126. package/lib/runtime/decision/decision-memo.d.ts +53 -0
  127. package/lib/runtime/decision/decision-memo.js +173 -0
  128. package/lib/runtime/decision/index.d.ts +2 -0
  129. package/lib/runtime/decision/index.js +18 -0
  130. package/lib/runtime/delivery/branch-manager.d.ts +19 -0
  131. package/lib/runtime/delivery/branch-manager.js +78 -0
  132. package/lib/runtime/delivery/ci-checks.d.ts +34 -0
  133. package/lib/runtime/delivery/ci-checks.js +209 -0
  134. package/lib/runtime/delivery/index.d.ts +4 -0
  135. package/lib/runtime/delivery/index.js +20 -0
  136. package/lib/runtime/delivery/pr-manager.d.ts +30 -0
  137. package/lib/runtime/delivery/pr-manager.js +82 -0
  138. package/lib/runtime/delivery/promotion-pipeline.d.ts +39 -0
  139. package/lib/runtime/delivery/promotion-pipeline.js +127 -0
  140. package/lib/runtime/events/bus.d.ts +9 -0
  141. package/lib/runtime/events/bus.js +63 -0
  142. package/lib/runtime/events/catalog.d.ts +3 -0
  143. package/lib/runtime/events/catalog.js +30 -0
  144. package/lib/runtime/events/envelope.d.ts +13 -0
  145. package/lib/runtime/events/envelope.js +2 -0
  146. package/lib/runtime/events/index.d.ts +3 -0
  147. package/lib/runtime/events/index.js +19 -0
  148. package/lib/runtime/evidence/evidence-store.d.ts +22 -0
  149. package/lib/runtime/evidence/evidence-store.js +106 -0
  150. package/lib/runtime/evidence/index.d.ts +1 -0
  151. package/lib/runtime/evidence/index.js +17 -0
  152. package/lib/runtime/gate/gate-manager.d.ts +39 -0
  153. package/lib/runtime/gate/gate-manager.js +104 -0
  154. package/lib/runtime/gate/index.d.ts +1 -0
  155. package/lib/runtime/gate/index.js +17 -0
  156. package/lib/runtime/index.d.ts +19 -0
  157. package/lib/runtime/index.js +44 -0
  158. package/lib/runtime/models/attempt.d.ts +12 -0
  159. package/lib/runtime/models/attempt.js +2 -0
  160. package/lib/runtime/models/evidence.d.ts +9 -0
  161. package/lib/runtime/models/evidence.js +2 -0
  162. package/lib/runtime/models/gate-decision.d.ts +10 -0
  163. package/lib/runtime/models/gate-decision.js +2 -0
  164. package/lib/runtime/models/index.d.ts +8 -0
  165. package/lib/runtime/models/index.js +24 -0
  166. package/lib/runtime/models/run.d.ts +13 -0
  167. package/lib/runtime/models/run.js +2 -0
  168. package/lib/runtime/models/session.d.ts +10 -0
  169. package/lib/runtime/models/session.js +2 -0
  170. package/lib/runtime/models/verification-result.d.ts +9 -0
  171. package/lib/runtime/models/verification-result.js +2 -0
  172. package/lib/runtime/models/work-item.d.ts +15 -0
  173. package/lib/runtime/models/work-item.js +2 -0
  174. package/lib/runtime/models/workspace.d.ts +25 -0
  175. package/lib/runtime/models/workspace.js +2 -0
  176. package/lib/runtime/plugins/capability-matrix.d.ts +20 -0
  177. package/lib/runtime/plugins/capability-matrix.js +59 -0
  178. package/lib/runtime/plugins/index.d.ts +4 -0
  179. package/lib/runtime/plugins/index.js +20 -0
  180. package/lib/runtime/plugins/plugin-abi.d.ts +76 -0
  181. package/lib/runtime/plugins/plugin-abi.js +2 -0
  182. package/lib/runtime/plugins/plugin-manifest.d.ts +22 -0
  183. package/lib/runtime/plugins/plugin-manifest.js +91 -0
  184. package/lib/runtime/plugins/plugin-registry.d.ts +21 -0
  185. package/lib/runtime/plugins/plugin-registry.js +119 -0
  186. package/lib/runtime/policy/index.d.ts +1 -0
  187. package/lib/runtime/policy/index.js +17 -0
  188. package/lib/runtime/policy/policy-engine.d.ts +67 -0
  189. package/lib/runtime/policy/policy-engine.js +171 -0
  190. package/lib/runtime/projection/index.d.ts +1 -0
  191. package/lib/runtime/projection/index.js +17 -0
  192. package/lib/runtime/projection/projection-engine.d.ts +11 -0
  193. package/lib/runtime/projection/projection-engine.js +218 -0
  194. package/lib/runtime/reducers/debug-reducer.d.ts +10 -0
  195. package/lib/runtime/reducers/debug-reducer.js +30 -0
  196. package/lib/runtime/reducers/index.d.ts +2 -0
  197. package/lib/runtime/reducers/index.js +18 -0
  198. package/lib/runtime/reducers/run-state-reducer.d.ts +46 -0
  199. package/lib/runtime/reducers/run-state-reducer.js +226 -0
  200. package/lib/runtime/scheduler/agent-registry.d.ts +44 -0
  201. package/lib/runtime/scheduler/agent-registry.js +96 -0
  202. package/lib/runtime/scheduler/agent-roles.d.ts +54 -0
  203. package/lib/runtime/scheduler/agent-roles.js +62 -0
  204. package/lib/runtime/scheduler/index.d.ts +4 -0
  205. package/lib/runtime/scheduler/index.js +20 -0
  206. package/lib/runtime/scheduler/multi-agent-coordinator.d.ts +36 -0
  207. package/lib/runtime/scheduler/multi-agent-coordinator.js +253 -0
  208. package/lib/runtime/scheduler/run-journal.d.ts +18 -0
  209. package/lib/runtime/scheduler/run-journal.js +54 -0
  210. package/lib/runtime/scheduler/scheduler.d.ts +49 -0
  211. package/lib/runtime/scheduler/scheduler.js +324 -0
  212. package/lib/runtime/verification/index.d.ts +2 -0
  213. package/lib/runtime/verification/index.js +18 -0
  214. package/lib/runtime/verification/verification-compiler.d.ts +56 -0
  215. package/lib/runtime/verification/verification-compiler.js +147 -0
  216. package/lib/runtime/verification/verification-manifest.d.ts +58 -0
  217. package/lib/runtime/verification/verification-manifest.js +129 -0
  218. package/lib/runtime/workspace/index.d.ts +5 -0
  219. package/lib/runtime/workspace/index.js +24 -0
  220. package/lib/runtime/workspace/strategies/ephemeral-container.d.ts +22 -0
  221. package/lib/runtime/workspace/strategies/ephemeral-container.js +109 -0
  222. package/lib/runtime/workspace/strategies/git-worktree.d.ts +12 -0
  223. package/lib/runtime/workspace/strategies/git-worktree.js +79 -0
  224. package/lib/runtime/workspace/strategies/inplace.d.ts +10 -0
  225. package/lib/runtime/workspace/strategies/inplace.js +37 -0
  226. package/lib/runtime/workspace/workspace-manager.d.ts +13 -0
  227. package/lib/runtime/workspace/workspace-manager.js +2 -0
  228. package/lib/sdk/index.cjs +24 -7
  229. package/lib/sdk/index.d.ts +17 -7
  230. package/oxe/workflows/ask.md +4 -0
  231. package/oxe/workflows/checkpoint.md +14 -10
  232. package/oxe/workflows/debug.md +19 -15
  233. package/oxe/workflows/execute.md +30 -2
  234. package/oxe/workflows/forensics.md +13 -9
  235. package/oxe/workflows/help.md +97 -49
  236. package/oxe/workflows/loop.md +17 -13
  237. package/oxe/workflows/obs.md +4 -0
  238. package/oxe/workflows/oxe.md +64 -31
  239. package/oxe/workflows/project.md +6 -1
  240. package/oxe/workflows/references/workflow-runtime-contracts.json +23 -0
  241. package/oxe/workflows/research.md +32 -28
  242. package/oxe/workflows/retro.md +4 -0
  243. package/oxe/workflows/review-pr.md +15 -11
  244. package/oxe/workflows/scan.md +4 -0
  245. package/oxe/workflows/security.md +14 -10
  246. package/oxe/workflows/session.md +17 -1
  247. package/oxe/workflows/ship.md +142 -0
  248. package/oxe/workflows/spec.md +15 -0
  249. package/oxe/workflows/ui-review.md +20 -16
  250. package/oxe/workflows/ui-spec.md +7 -3
  251. package/oxe/workflows/validate-gaps.md +13 -9
  252. package/oxe/workflows/verify.md +42 -3
  253. package/package.json +9 -3
  254. package/packages/runtime/package.json +17 -0
  255. package/packages/runtime/src/audit/audit-trail.ts +243 -0
  256. package/packages/runtime/src/audit/index.ts +2 -0
  257. package/packages/runtime/src/audit/policy-pack.ts +62 -0
  258. package/packages/runtime/src/compiler/graph-compiler.ts +245 -0
  259. package/packages/runtime/src/compiler/index.ts +1 -0
  260. package/packages/runtime/src/context/context-pack-builder.ts +259 -0
  261. package/packages/runtime/src/context/context-pack-store.ts +197 -0
  262. package/packages/runtime/src/context/context-profiles.ts +60 -0
  263. package/packages/runtime/src/context/index.ts +3 -0
  264. package/packages/runtime/src/decision/decision-engine.ts +174 -0
  265. package/packages/runtime/src/decision/decision-memo.ts +211 -0
  266. package/packages/runtime/src/decision/index.ts +2 -0
  267. package/packages/runtime/src/delivery/branch-manager.ts +84 -0
  268. package/packages/runtime/src/delivery/ci-checks.ts +252 -0
  269. package/packages/runtime/src/delivery/index.ts +4 -0
  270. package/packages/runtime/src/delivery/pr-manager.ts +112 -0
  271. package/packages/runtime/src/delivery/promotion-pipeline.ts +180 -0
  272. package/packages/runtime/src/events/bus.ts +92 -0
  273. package/packages/runtime/src/events/catalog.ts +29 -0
  274. package/packages/runtime/src/events/envelope.ts +14 -0
  275. package/packages/runtime/src/events/index.ts +3 -0
  276. package/packages/runtime/src/evidence/evidence-store.ts +130 -0
  277. package/packages/runtime/src/evidence/index.ts +1 -0
  278. package/packages/runtime/src/gate/gate-manager.ts +137 -0
  279. package/packages/runtime/src/gate/index.ts +1 -0
  280. package/packages/runtime/src/index.ts +37 -0
  281. package/packages/runtime/src/models/attempt.ts +19 -0
  282. package/packages/runtime/src/models/evidence.ts +21 -0
  283. package/packages/runtime/src/models/gate-decision.ts +21 -0
  284. package/packages/runtime/src/models/index.ts +8 -0
  285. package/packages/runtime/src/models/run.ts +24 -0
  286. package/packages/runtime/src/models/session.ts +11 -0
  287. package/packages/runtime/src/models/verification-result.ts +10 -0
  288. package/packages/runtime/src/models/work-item.ts +25 -0
  289. package/packages/runtime/src/models/workspace.ts +28 -0
  290. package/packages/runtime/src/plugins/capability-matrix.ts +83 -0
  291. package/packages/runtime/src/plugins/index.ts +4 -0
  292. package/packages/runtime/src/plugins/plugin-abi.ts +95 -0
  293. package/packages/runtime/src/plugins/plugin-manifest.ts +113 -0
  294. package/packages/runtime/src/plugins/plugin-registry.ts +124 -0
  295. package/packages/runtime/src/policy/index.ts +1 -0
  296. package/packages/runtime/src/policy/policy-engine.ts +244 -0
  297. package/packages/runtime/src/projection/index.ts +1 -0
  298. package/packages/runtime/src/projection/projection-engine.ts +249 -0
  299. package/packages/runtime/src/reducers/debug-reducer.ts +36 -0
  300. package/packages/runtime/src/reducers/index.ts +2 -0
  301. package/packages/runtime/src/reducers/run-state-reducer.ts +269 -0
  302. package/packages/runtime/src/scheduler/agent-registry.ts +132 -0
  303. package/packages/runtime/src/scheduler/agent-roles.ts +109 -0
  304. package/packages/runtime/src/scheduler/index.ts +4 -0
  305. package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +333 -0
  306. package/packages/runtime/src/scheduler/run-journal.ts +62 -0
  307. package/packages/runtime/src/scheduler/scheduler.ts +441 -0
  308. package/packages/runtime/src/verification/index.ts +2 -0
  309. package/packages/runtime/src/verification/verification-compiler.ts +225 -0
  310. package/packages/runtime/src/verification/verification-manifest.ts +192 -0
  311. package/packages/runtime/src/workspace/index.ts +5 -0
  312. package/packages/runtime/src/workspace/strategies/ephemeral-container.ts +121 -0
  313. package/packages/runtime/src/workspace/strategies/git-worktree.ts +77 -0
  314. package/packages/runtime/src/workspace/strategies/inplace.ts +35 -0
  315. package/packages/runtime/src/workspace/workspace-manager.ts +15 -0
  316. package/packages/runtime/tsconfig.json +17 -0
  317. package/vscode-extension/oxe-agents-0.9.2.vsix +0 -0
  318. package/vscode-extension/oxe-agents-1.0.0.vsix +0 -0
  319. package/vscode-extension/package.json +1 -1
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AuditTrail = void 0;
7
+ exports.createQuota = createQuota;
8
+ exports.checkQuota = checkQuota;
9
+ exports.consumeQuota = consumeQuota;
10
+ const crypto_1 = __importDefault(require("crypto"));
11
+ const path_1 = __importDefault(require("path"));
12
+ const fs_1 = __importDefault(require("fs"));
13
+ const ACTION_SEVERITY = {
14
+ run_started: 'info',
15
+ run_completed: 'info',
16
+ run_paused: 'info',
17
+ run_recovered: 'warn',
18
+ gate_requested: 'warn',
19
+ gate_resolved: 'info',
20
+ policy_denied: 'warn',
21
+ plugin_registered: 'info',
22
+ plugin_invoked: 'info',
23
+ secret_accessed: 'critical',
24
+ infra_mutation: 'critical',
25
+ pr_created: 'info',
26
+ merge_approved: 'warn',
27
+ merge_blocked: 'warn',
28
+ };
29
+ class AuditTrail {
30
+ constructor(projectRoot, remoteSink) {
31
+ this.projectRoot = projectRoot;
32
+ this.remoteSink = remoteSink;
33
+ }
34
+ record(action, actor, options = {}) {
35
+ const entry = {
36
+ audit_id: `aud-${crypto_1.default.randomBytes(4).toString('hex')}`,
37
+ action,
38
+ severity: ACTION_SEVERITY[action],
39
+ run_id: options.runId ?? null,
40
+ work_item_id: options.workItemId ?? null,
41
+ actor,
42
+ resource: options.resource ?? null,
43
+ detail: options.detail ?? {},
44
+ timestamp: new Date().toISOString(),
45
+ };
46
+ this.append(entry);
47
+ return entry;
48
+ }
49
+ query(filter = {}) {
50
+ return this.load().filter((e) => {
51
+ if (filter.action && e.action !== filter.action)
52
+ return false;
53
+ if (filter.severity && e.severity !== filter.severity)
54
+ return false;
55
+ if (filter.runId && e.run_id !== filter.runId)
56
+ return false;
57
+ if (filter.since && e.timestamp < filter.since)
58
+ return false;
59
+ return true;
60
+ });
61
+ }
62
+ critical() {
63
+ return this.query({ severity: 'critical' });
64
+ }
65
+ metrics() {
66
+ const entries = this.load();
67
+ const by_action = {};
68
+ const actorSet = new Set();
69
+ let oldest = null;
70
+ let newest = null;
71
+ let critical_count = 0;
72
+ let warn_count = 0;
73
+ for (const e of entries) {
74
+ by_action[e.action] = (by_action[e.action] ?? 0) + 1;
75
+ actorSet.add(e.actor);
76
+ if (e.severity === 'critical')
77
+ critical_count++;
78
+ if (e.severity === 'warn')
79
+ warn_count++;
80
+ if (!oldest || e.timestamp < oldest)
81
+ oldest = e.timestamp;
82
+ if (!newest || e.timestamp > newest)
83
+ newest = e.timestamp;
84
+ }
85
+ return {
86
+ total_entries: entries.length,
87
+ critical_count,
88
+ warn_count,
89
+ by_action,
90
+ actors: [...actorSet],
91
+ oldest,
92
+ newest,
93
+ };
94
+ }
95
+ append(entry) {
96
+ const p = this.trailPath();
97
+ fs_1.default.mkdirSync(path_1.default.dirname(p), { recursive: true });
98
+ fs_1.default.appendFileSync(p, JSON.stringify(entry) + '\n', 'utf8');
99
+ // Fire-and-forget remote sink (failures are non-fatal)
100
+ if (this.remoteSink) {
101
+ this.remoteSink.write(entry).catch(() => { });
102
+ }
103
+ }
104
+ load() {
105
+ const p = this.trailPath();
106
+ if (!fs_1.default.existsSync(p))
107
+ return [];
108
+ try {
109
+ return fs_1.default
110
+ .readFileSync(p, 'utf8')
111
+ .split('\n')
112
+ .filter(Boolean)
113
+ .map((line) => JSON.parse(line));
114
+ }
115
+ catch {
116
+ return [];
117
+ }
118
+ }
119
+ trailPath() {
120
+ return path_1.default.join(this.projectRoot, '.oxe', 'AUDIT-TRAIL.ndjson');
121
+ }
122
+ }
123
+ exports.AuditTrail = AuditTrail;
124
+ // ─── RunQuota ─────────────────────────────────────────────────────────────────
125
+ function createQuota(runId, limits = {}) {
126
+ return {
127
+ run_id: runId,
128
+ max_work_items: limits.max_work_items ?? Infinity,
129
+ max_mutations: limits.max_mutations ?? Infinity,
130
+ max_retries_total: limits.max_retries_total ?? Infinity,
131
+ consumed_work_items: 0,
132
+ consumed_mutations: 0,
133
+ consumed_retries: 0,
134
+ };
135
+ }
136
+ function checkQuota(quota) {
137
+ if (quota.consumed_work_items > quota.max_work_items) {
138
+ return { quota_type: 'work_items', limit: quota.max_work_items, consumed: quota.consumed_work_items };
139
+ }
140
+ if (quota.consumed_mutations > quota.max_mutations) {
141
+ return { quota_type: 'mutations', limit: quota.max_mutations, consumed: quota.consumed_mutations };
142
+ }
143
+ if (quota.consumed_retries > quota.max_retries_total) {
144
+ return { quota_type: 'retries', limit: quota.max_retries_total, consumed: quota.consumed_retries };
145
+ }
146
+ return null;
147
+ }
148
+ function consumeQuota(quota, type, amount = 1) {
149
+ switch (type) {
150
+ case 'work_items': return { ...quota, consumed_work_items: quota.consumed_work_items + amount };
151
+ case 'mutations': return { ...quota, consumed_mutations: quota.consumed_mutations + amount };
152
+ case 'retries': return { ...quota, consumed_retries: quota.consumed_retries + amount };
153
+ }
154
+ }
@@ -0,0 +1,2 @@
1
+ export * from './audit-trail';
2
+ export * from './policy-pack';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./audit-trail"), exports);
18
+ __exportStar(require("./policy-pack"), exports);
@@ -0,0 +1,15 @@
1
+ import type { PolicyRule, EnvironmentGuardrail } from '../policy/policy-engine';
2
+ import { PolicyEngine } from '../policy/policy-engine';
3
+ export interface PolicyPack {
4
+ pack_id: string;
5
+ org_id: string;
6
+ name: string;
7
+ version: string;
8
+ policies: PolicyRule[];
9
+ guardrail: EnvironmentGuardrail;
10
+ created_at: string;
11
+ }
12
+ export declare function savePolicyPack(projectRoot: string, pack: PolicyPack): void;
13
+ export declare function loadPolicyPack(projectRoot: string, packId: string): PolicyPack | null;
14
+ export declare function listPolicyPacks(projectRoot: string): PolicyPack[];
15
+ export declare function applyPolicyPack(engine: PolicyEngine, pack: PolicyPack): PolicyEngine;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.savePolicyPack = savePolicyPack;
7
+ exports.loadPolicyPack = loadPolicyPack;
8
+ exports.listPolicyPacks = listPolicyPacks;
9
+ exports.applyPolicyPack = applyPolicyPack;
10
+ const path_1 = __importDefault(require("path"));
11
+ const fs_1 = __importDefault(require("fs"));
12
+ function packDir(projectRoot) {
13
+ return path_1.default.join(projectRoot, '.oxe', 'policy-packs');
14
+ }
15
+ function packFilePath(projectRoot, packId) {
16
+ return path_1.default.join(packDir(projectRoot), `${packId}.json`);
17
+ }
18
+ function savePolicyPack(projectRoot, pack) {
19
+ const dir = packDir(projectRoot);
20
+ fs_1.default.mkdirSync(dir, { recursive: true });
21
+ fs_1.default.writeFileSync(packFilePath(projectRoot, pack.pack_id), JSON.stringify(pack, null, 2), 'utf8');
22
+ }
23
+ function loadPolicyPack(projectRoot, packId) {
24
+ const p = packFilePath(projectRoot, packId);
25
+ if (!fs_1.default.existsSync(p))
26
+ return null;
27
+ try {
28
+ return JSON.parse(fs_1.default.readFileSync(p, 'utf8'));
29
+ }
30
+ catch {
31
+ return null;
32
+ }
33
+ }
34
+ function listPolicyPacks(projectRoot) {
35
+ const dir = packDir(projectRoot);
36
+ if (!fs_1.default.existsSync(dir))
37
+ return [];
38
+ return fs_1.default
39
+ .readdirSync(dir)
40
+ .filter((f) => f.endsWith('.json'))
41
+ .map((f) => {
42
+ try {
43
+ return JSON.parse(fs_1.default.readFileSync(path_1.default.join(dir, f), 'utf8'));
44
+ }
45
+ catch {
46
+ return null;
47
+ }
48
+ })
49
+ .filter((p) => p !== null);
50
+ }
51
+ function applyPolicyPack(engine, pack) {
52
+ let result = engine.withGuardrail(pack.guardrail);
53
+ for (const rule of pack.policies) {
54
+ result = result.withRule(rule);
55
+ }
56
+ return result;
57
+ }
@@ -0,0 +1,83 @@
1
+ import type { WorkspaceStrategy } from '../models/workspace';
2
+ export interface ParsedTask {
3
+ id: string;
4
+ title: string;
5
+ wave: number | null;
6
+ dependsOn: string[];
7
+ files: string[];
8
+ verifyCommand: string | null;
9
+ aceite: string[];
10
+ done: boolean;
11
+ meta?: Record<string, unknown> | null;
12
+ }
13
+ export interface ParsedSpecCriterion {
14
+ id: string;
15
+ criterion: string;
16
+ howToVerify: string;
17
+ }
18
+ export interface ParsedSpec {
19
+ objective: string | null;
20
+ criteria: ParsedSpecCriterion[];
21
+ }
22
+ export interface ParsedPlan {
23
+ tasks: ParsedTask[];
24
+ waves: Record<number, string[]>;
25
+ totalTasks: number;
26
+ }
27
+ export interface Action {
28
+ type: 'read_code' | 'generate_patch' | 'run_tests' | 'run_lint' | 'collect_evidence' | 'custom';
29
+ command?: string;
30
+ targets?: string[];
31
+ }
32
+ export interface VerifyContract {
33
+ must_pass: string[];
34
+ acceptance_refs: string[];
35
+ command: string | null;
36
+ }
37
+ export interface NodePolicy {
38
+ requires_human_approval: boolean;
39
+ max_retries: number;
40
+ }
41
+ export interface GraphNode {
42
+ id: string;
43
+ title: string;
44
+ wave: number;
45
+ depends_on: string[];
46
+ workspace_strategy: WorkspaceStrategy;
47
+ mutation_scope: string[];
48
+ actions: Action[];
49
+ verify: VerifyContract;
50
+ policy: NodePolicy;
51
+ }
52
+ export interface GraphEdge {
53
+ from: string;
54
+ to: string;
55
+ type: 'dependency' | 'wave_sequence';
56
+ }
57
+ export interface Wave {
58
+ wave_number: number;
59
+ node_ids: string[];
60
+ }
61
+ export interface ExecutionGraphMetadata {
62
+ compiled_at: string;
63
+ plan_hash: string;
64
+ spec_hash: string;
65
+ node_count: number;
66
+ wave_count: number;
67
+ }
68
+ export interface ExecutionGraph {
69
+ nodes: Map<string, GraphNode>;
70
+ edges: GraphEdge[];
71
+ waves: Wave[];
72
+ metadata: ExecutionGraphMetadata;
73
+ }
74
+ export interface CompilerOptions {
75
+ default_workspace_strategy?: WorkspaceStrategy;
76
+ default_max_retries?: number;
77
+ require_approval_for_all?: boolean;
78
+ skip_done_tasks?: boolean;
79
+ }
80
+ export declare function compile(plan: ParsedPlan, spec: ParsedSpec, options?: CompilerOptions): ExecutionGraph;
81
+ export declare function validateGraph(graph: ExecutionGraph): string[];
82
+ export declare function toSerializable(graph: ExecutionGraph): Record<string, unknown>;
83
+ export declare function fromSerializable(raw: Record<string, unknown>): ExecutionGraph;
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.compile = compile;
7
+ exports.validateGraph = validateGraph;
8
+ exports.toSerializable = toSerializable;
9
+ exports.fromSerializable = fromSerializable;
10
+ const crypto_1 = __importDefault(require("crypto"));
11
+ function compile(plan, spec, options = {}) {
12
+ const { default_workspace_strategy = 'git_worktree', default_max_retries = 2, require_approval_for_all = false, skip_done_tasks = false, } = options;
13
+ const nodes = new Map();
14
+ const edges = [];
15
+ const waveMap = new Map();
16
+ for (const task of plan.tasks) {
17
+ if (skip_done_tasks && task.done)
18
+ continue;
19
+ const waveNumber = task.wave ?? 1;
20
+ const node = {
21
+ id: task.id,
22
+ title: task.title,
23
+ wave: waveNumber,
24
+ depends_on: task.dependsOn,
25
+ workspace_strategy: default_workspace_strategy,
26
+ mutation_scope: task.files,
27
+ actions: buildActions(task),
28
+ verify: {
29
+ must_pass: task.verifyCommand ? ['tests'] : [],
30
+ acceptance_refs: task.aceite,
31
+ command: task.verifyCommand,
32
+ },
33
+ policy: {
34
+ requires_human_approval: require_approval_for_all,
35
+ max_retries: default_max_retries,
36
+ },
37
+ };
38
+ nodes.set(task.id, node);
39
+ for (const dep of task.dependsOn) {
40
+ edges.push({ from: dep, to: task.id, type: 'dependency' });
41
+ }
42
+ if (!waveMap.has(waveNumber))
43
+ waveMap.set(waveNumber, []);
44
+ waveMap.get(waveNumber).push(task.id);
45
+ }
46
+ const waves = Array.from(waveMap.entries())
47
+ .sort(([a], [b]) => a - b)
48
+ .map(([wave_number, node_ids]) => ({ wave_number, node_ids }));
49
+ return {
50
+ nodes,
51
+ edges,
52
+ waves,
53
+ metadata: {
54
+ compiled_at: new Date().toISOString(),
55
+ plan_hash: hashObject(plan),
56
+ spec_hash: hashObject(spec),
57
+ node_count: nodes.size,
58
+ wave_count: waves.length,
59
+ },
60
+ };
61
+ }
62
+ function validateGraph(graph) {
63
+ const errors = [];
64
+ const nodeIds = new Set(graph.nodes.keys());
65
+ for (const [id, node] of graph.nodes) {
66
+ for (const dep of node.depends_on) {
67
+ if (!nodeIds.has(dep)) {
68
+ errors.push(`Node ${id} depends on unknown node ${dep}`);
69
+ }
70
+ }
71
+ }
72
+ // Detect cycles using DFS
73
+ const visited = new Set();
74
+ const inStack = new Set();
75
+ function hasCycle(nodeId) {
76
+ if (inStack.has(nodeId))
77
+ return true;
78
+ if (visited.has(nodeId))
79
+ return false;
80
+ visited.add(nodeId);
81
+ inStack.add(nodeId);
82
+ const node = graph.nodes.get(nodeId);
83
+ if (node) {
84
+ for (const dep of node.depends_on) {
85
+ if (hasCycle(dep))
86
+ return true;
87
+ }
88
+ }
89
+ inStack.delete(nodeId);
90
+ return false;
91
+ }
92
+ for (const id of nodeIds) {
93
+ if (hasCycle(id)) {
94
+ errors.push(`Cycle detected involving node ${id}`);
95
+ break;
96
+ }
97
+ }
98
+ return errors;
99
+ }
100
+ function toSerializable(graph) {
101
+ return {
102
+ nodes: Object.fromEntries(graph.nodes),
103
+ edges: graph.edges,
104
+ waves: graph.waves,
105
+ metadata: graph.metadata,
106
+ };
107
+ }
108
+ function fromSerializable(raw) {
109
+ const nodes = new Map(Object.entries(raw.nodes));
110
+ return {
111
+ nodes,
112
+ edges: raw.edges,
113
+ waves: raw.waves,
114
+ metadata: raw.metadata,
115
+ };
116
+ }
117
+ function buildActions(task) {
118
+ const actions = [];
119
+ if (task.files.length > 0) {
120
+ actions.push({ type: 'read_code', targets: task.files });
121
+ }
122
+ actions.push({ type: 'generate_patch' });
123
+ if (task.verifyCommand) {
124
+ actions.push({ type: 'run_tests', command: task.verifyCommand });
125
+ }
126
+ actions.push({ type: 'collect_evidence' });
127
+ return actions;
128
+ }
129
+ function hashObject(obj) {
130
+ return crypto_1.default
131
+ .createHash('sha256')
132
+ .update(JSON.stringify(obj))
133
+ .digest('hex')
134
+ .slice(0, 12);
135
+ }
@@ -0,0 +1 @@
1
+ export * from './graph-compiler';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./graph-compiler"), exports);
@@ -0,0 +1,51 @@
1
+ import type { WorkItem } from '../models/work-item';
2
+ import type { Evidence } from '../models/evidence';
3
+ import type { RunState } from '../reducers/run-state-reducer';
4
+ import type { ContextProfile } from './context-profiles';
5
+ import type { AutonomyTier } from '../policy/policy-engine';
6
+ export interface ContextArtifact {
7
+ id: string;
8
+ kind: 'evidence' | 'lesson' | 'file' | 'summary';
9
+ content: string;
10
+ relevanceScore: number;
11
+ tags: string[];
12
+ }
13
+ export interface LessonMetric {
14
+ lesson_id: string;
15
+ title: string;
16
+ tags: string[];
17
+ embedding?: number[];
18
+ content: string;
19
+ }
20
+ export interface ContextPackOptions {
21
+ maxArtifacts?: number;
22
+ maxTokensEstimate?: number;
23
+ deduplicateThreshold?: number;
24
+ }
25
+ export interface ContextPack {
26
+ work_item_id: string;
27
+ artifacts: ContextArtifact[];
28
+ total_artifacts_considered: number;
29
+ redundancy_removed: number;
30
+ built_at: string;
31
+ }
32
+ export interface ContextQualityScore {
33
+ completeness: number;
34
+ relevance_mean: number;
35
+ redundancy: number;
36
+ recency_score: number;
37
+ overall: number;
38
+ }
39
+ export declare function scorePackQuality(pack: ContextPack, profile: ContextProfile): ContextQualityScore;
40
+ export declare class ContextPackBuilder {
41
+ private readonly opts;
42
+ constructor(opts?: ContextPackOptions);
43
+ build(workItem: WorkItem, state: RunState, evidenceItems: Evidence[], evidenceContents: Map<string, string>, lessons: LessonMetric[]): ContextPack;
44
+ /** Convenience: build with no evidence, just lessons and state summary */
45
+ buildLightweight(workItem: WorkItem, state: RunState, lessons: LessonMetric[]): ContextPack;
46
+ /**
47
+ * Filter artifacts to those whose path-like tags are within mutation_scope.
48
+ * L0/L1 tiers apply the filter; L2/L3 skip it (full access).
49
+ */
50
+ filterByMutationScope(artifacts: ContextArtifact[], mutationScope: string[], autonomyTier: AutonomyTier): ContextArtifact[];
51
+ }