oxe-cc 0.9.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/.cursor/commands/oxe-retro.md +2 -2
  2. package/.cursor/commands/oxe-spec.md +2 -2
  3. package/.github/prompts/oxe-retro.prompt.md +2 -2
  4. package/.github/prompts/oxe-spec.prompt.md +2 -2
  5. package/README.md +1 -1
  6. package/bin/banner.txt +1 -1
  7. package/bin/lib/oxe-context-engine.cjs +1 -0
  8. package/bin/lib/oxe-dashboard.cjs +9 -7
  9. package/bin/lib/oxe-operational.cjs +569 -4
  10. package/bin/oxe-cc.js +141 -57
  11. package/commands/oxe/retro.md +2 -2
  12. package/commands/oxe/spec.md +2 -2
  13. package/lib/runtime/compiler/graph-compiler.d.ts +83 -0
  14. package/lib/runtime/compiler/graph-compiler.js +135 -0
  15. package/lib/runtime/compiler/index.d.ts +1 -0
  16. package/lib/runtime/compiler/index.js +17 -0
  17. package/lib/runtime/context/context-pack-builder.d.ts +36 -0
  18. package/lib/runtime/context/context-pack-builder.js +136 -0
  19. package/lib/runtime/context/index.d.ts +1 -0
  20. package/lib/runtime/context/index.js +17 -0
  21. package/lib/runtime/delivery/branch-manager.d.ts +19 -0
  22. package/lib/runtime/delivery/branch-manager.js +78 -0
  23. package/lib/runtime/delivery/ci-checks.d.ts +34 -0
  24. package/lib/runtime/delivery/ci-checks.js +209 -0
  25. package/lib/runtime/delivery/index.d.ts +3 -0
  26. package/lib/runtime/delivery/index.js +19 -0
  27. package/lib/runtime/delivery/pr-manager.d.ts +30 -0
  28. package/lib/runtime/delivery/pr-manager.js +82 -0
  29. package/lib/runtime/events/bus.d.ts +9 -0
  30. package/lib/runtime/events/bus.js +63 -0
  31. package/lib/runtime/events/catalog.d.ts +3 -0
  32. package/lib/runtime/events/catalog.js +30 -0
  33. package/lib/runtime/events/envelope.d.ts +13 -0
  34. package/lib/runtime/events/envelope.js +2 -0
  35. package/lib/runtime/events/index.d.ts +3 -0
  36. package/lib/runtime/events/index.js +19 -0
  37. package/lib/runtime/evidence/evidence-store.d.ts +22 -0
  38. package/lib/runtime/evidence/evidence-store.js +106 -0
  39. package/lib/runtime/evidence/index.d.ts +1 -0
  40. package/lib/runtime/evidence/index.js +17 -0
  41. package/lib/runtime/gate/gate-manager.d.ts +39 -0
  42. package/lib/runtime/gate/gate-manager.js +104 -0
  43. package/lib/runtime/gate/index.d.ts +1 -0
  44. package/lib/runtime/gate/index.js +17 -0
  45. package/lib/runtime/index.d.ts +16 -0
  46. package/lib/runtime/index.js +40 -0
  47. package/lib/runtime/models/attempt.d.ts +12 -0
  48. package/lib/runtime/models/attempt.js +2 -0
  49. package/lib/runtime/models/evidence.d.ts +9 -0
  50. package/lib/runtime/models/evidence.js +2 -0
  51. package/lib/runtime/models/gate-decision.d.ts +10 -0
  52. package/lib/runtime/models/gate-decision.js +2 -0
  53. package/lib/runtime/models/index.d.ts +8 -0
  54. package/lib/runtime/models/index.js +24 -0
  55. package/lib/runtime/models/run.d.ts +13 -0
  56. package/lib/runtime/models/run.js +2 -0
  57. package/lib/runtime/models/session.d.ts +10 -0
  58. package/lib/runtime/models/session.js +2 -0
  59. package/lib/runtime/models/verification-result.d.ts +9 -0
  60. package/lib/runtime/models/verification-result.js +2 -0
  61. package/lib/runtime/models/work-item.d.ts +15 -0
  62. package/lib/runtime/models/work-item.js +2 -0
  63. package/lib/runtime/models/workspace.d.ts +25 -0
  64. package/lib/runtime/models/workspace.js +2 -0
  65. package/lib/runtime/plugins/index.d.ts +2 -0
  66. package/lib/runtime/plugins/index.js +18 -0
  67. package/lib/runtime/plugins/plugin-abi.d.ts +76 -0
  68. package/lib/runtime/plugins/plugin-abi.js +2 -0
  69. package/lib/runtime/plugins/plugin-registry.d.ts +21 -0
  70. package/lib/runtime/plugins/plugin-registry.js +114 -0
  71. package/lib/runtime/policy/index.d.ts +1 -0
  72. package/lib/runtime/policy/index.js +17 -0
  73. package/lib/runtime/policy/policy-engine.d.ts +40 -0
  74. package/lib/runtime/policy/policy-engine.js +80 -0
  75. package/lib/runtime/projection/index.d.ts +1 -0
  76. package/lib/runtime/projection/index.js +17 -0
  77. package/lib/runtime/projection/projection-engine.d.ts +11 -0
  78. package/lib/runtime/projection/projection-engine.js +218 -0
  79. package/lib/runtime/reducers/debug-reducer.d.ts +10 -0
  80. package/lib/runtime/reducers/debug-reducer.js +30 -0
  81. package/lib/runtime/reducers/index.d.ts +2 -0
  82. package/lib/runtime/reducers/index.js +18 -0
  83. package/lib/runtime/reducers/run-state-reducer.d.ts +20 -0
  84. package/lib/runtime/reducers/run-state-reducer.js +110 -0
  85. package/lib/runtime/scheduler/index.d.ts +1 -0
  86. package/lib/runtime/scheduler/index.js +17 -0
  87. package/lib/runtime/scheduler/multi-agent-coordinator.d.ts +34 -0
  88. package/lib/runtime/scheduler/multi-agent-coordinator.js +166 -0
  89. package/lib/runtime/scheduler/scheduler.d.ts +39 -0
  90. package/lib/runtime/scheduler/scheduler.js +196 -0
  91. package/lib/runtime/verification/index.d.ts +1 -0
  92. package/lib/runtime/verification/index.js +17 -0
  93. package/lib/runtime/verification/verification-compiler.d.ts +56 -0
  94. package/lib/runtime/verification/verification-compiler.js +147 -0
  95. package/lib/runtime/workspace/index.d.ts +5 -0
  96. package/lib/runtime/workspace/index.js +24 -0
  97. package/lib/runtime/workspace/strategies/ephemeral-container.d.ts +22 -0
  98. package/lib/runtime/workspace/strategies/ephemeral-container.js +109 -0
  99. package/lib/runtime/workspace/strategies/git-worktree.d.ts +12 -0
  100. package/lib/runtime/workspace/strategies/git-worktree.js +79 -0
  101. package/lib/runtime/workspace/strategies/inplace.d.ts +10 -0
  102. package/lib/runtime/workspace/strategies/inplace.js +37 -0
  103. package/lib/runtime/workspace/workspace-manager.d.ts +13 -0
  104. package/lib/runtime/workspace/workspace-manager.js +2 -0
  105. package/lib/sdk/index.cjs +24 -7
  106. package/lib/sdk/index.d.ts +17 -7
  107. package/oxe/templates/LESSONS-METRICS.template.json +13 -0
  108. package/oxe/workflows/references/robustness-elevation.md +295 -0
  109. package/oxe/workflows/references/workflow-runtime-contracts.json +32 -4
  110. package/oxe/workflows/retro.md +21 -0
  111. package/oxe/workflows/spec.md +50 -26
  112. package/oxe/workflows/verify.md +36 -0
  113. package/package.json +9 -3
  114. package/packages/runtime/package.json +17 -0
  115. package/packages/runtime/src/compiler/graph-compiler.ts +245 -0
  116. package/packages/runtime/src/compiler/index.ts +1 -0
  117. package/packages/runtime/src/context/context-pack-builder.ts +193 -0
  118. package/packages/runtime/src/context/index.ts +1 -0
  119. package/packages/runtime/src/delivery/branch-manager.ts +84 -0
  120. package/packages/runtime/src/delivery/ci-checks.ts +252 -0
  121. package/packages/runtime/src/delivery/index.ts +3 -0
  122. package/packages/runtime/src/delivery/pr-manager.ts +112 -0
  123. package/packages/runtime/src/events/bus.ts +92 -0
  124. package/packages/runtime/src/events/catalog.ts +29 -0
  125. package/packages/runtime/src/events/envelope.ts +14 -0
  126. package/packages/runtime/src/events/index.ts +3 -0
  127. package/packages/runtime/src/evidence/evidence-store.ts +130 -0
  128. package/packages/runtime/src/evidence/index.ts +1 -0
  129. package/packages/runtime/src/gate/gate-manager.ts +137 -0
  130. package/packages/runtime/src/gate/index.ts +1 -0
  131. package/packages/runtime/src/index.ts +32 -0
  132. package/packages/runtime/src/models/attempt.ts +19 -0
  133. package/packages/runtime/src/models/evidence.ts +21 -0
  134. package/packages/runtime/src/models/gate-decision.ts +21 -0
  135. package/packages/runtime/src/models/index.ts +8 -0
  136. package/packages/runtime/src/models/run.ts +24 -0
  137. package/packages/runtime/src/models/session.ts +11 -0
  138. package/packages/runtime/src/models/verification-result.ts +10 -0
  139. package/packages/runtime/src/models/work-item.ts +25 -0
  140. package/packages/runtime/src/models/workspace.ts +28 -0
  141. package/packages/runtime/src/plugins/index.ts +2 -0
  142. package/packages/runtime/src/plugins/plugin-abi.ts +95 -0
  143. package/packages/runtime/src/plugins/plugin-registry.ts +119 -0
  144. package/packages/runtime/src/policy/index.ts +1 -0
  145. package/packages/runtime/src/policy/policy-engine.ts +113 -0
  146. package/packages/runtime/src/projection/index.ts +1 -0
  147. package/packages/runtime/src/projection/projection-engine.ts +249 -0
  148. package/packages/runtime/src/reducers/debug-reducer.ts +36 -0
  149. package/packages/runtime/src/reducers/index.ts +2 -0
  150. package/packages/runtime/src/reducers/run-state-reducer.ts +127 -0
  151. package/packages/runtime/src/scheduler/index.ts +1 -0
  152. package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +231 -0
  153. package/packages/runtime/src/scheduler/scheduler.ts +281 -0
  154. package/packages/runtime/src/verification/index.ts +1 -0
  155. package/packages/runtime/src/verification/verification-compiler.ts +225 -0
  156. package/packages/runtime/src/workspace/index.ts +5 -0
  157. package/packages/runtime/src/workspace/strategies/ephemeral-container.ts +121 -0
  158. package/packages/runtime/src/workspace/strategies/git-worktree.ts +77 -0
  159. package/packages/runtime/src/workspace/strategies/inplace.ts +35 -0
  160. package/packages/runtime/src/workspace/workspace-manager.ts +15 -0
  161. package/packages/runtime/tsconfig.json +17 -0
  162. package/vscode-extension/oxe-agents-1.0.0.vsix +0 -0
  163. package/vscode-extension/package.json +1 -1
@@ -0,0 +1,92 @@
1
+ import type { OxeEvent } from './envelope';
2
+ import type { EventType } from './catalog';
3
+ import path from 'path';
4
+ import fs from 'fs';
5
+
6
+ export type EventInput = Partial<Omit<OxeEvent, 'type'>> & { type: EventType };
7
+
8
+ interface OperationalEvent {
9
+ event_id?: string;
10
+ type?: string;
11
+ timestamp?: string;
12
+ session_id?: string | null;
13
+ run_id?: string | null;
14
+ task_id?: string | null;
15
+ work_item_id?: string | null;
16
+ attempt_id?: string | null;
17
+ causation_id?: string | null;
18
+ correlation_id?: string | null;
19
+ payload?: Record<string, unknown>;
20
+ }
21
+
22
+ function loadOperationalModule(): {
23
+ appendEvent: (projectRoot: string, sessionId: string | null, event: Record<string, unknown>) => OperationalEvent;
24
+ readEvents: (projectRoot: string, sessionId: string | null) => OperationalEvent[];
25
+ } {
26
+ const candidates = [
27
+ path.resolve(__dirname, '../../../bin/lib/oxe-operational.cjs'),
28
+ path.resolve(__dirname, '../../../../bin/lib/oxe-operational.cjs'),
29
+ path.resolve(__dirname, '../../../../../bin/lib/oxe-operational.cjs'),
30
+ ];
31
+ for (const candidate of candidates) {
32
+ if (!fs.existsSync(candidate)) continue;
33
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
34
+ return require(candidate) as {
35
+ appendEvent: (projectRoot: string, sessionId: string | null, event: Record<string, unknown>) => OperationalEvent;
36
+ readEvents: (projectRoot: string, sessionId: string | null) => OperationalEvent[];
37
+ };
38
+ }
39
+ throw new Error(`Unable to locate oxe-operational.cjs from ${__dirname}`);
40
+ }
41
+
42
+ const operational = loadOperationalModule();
43
+
44
+ function fromOperationalEvent(raw: OperationalEvent): OxeEvent {
45
+ return {
46
+ id: String(raw.event_id || ''),
47
+ type: String(raw.type || 'RunStarted') as EventType,
48
+ timestamp: String(raw.timestamp || new Date().toISOString()),
49
+ session_id: raw.session_id ?? null,
50
+ run_id: raw.run_id ?? null,
51
+ work_item_id: raw.work_item_id ?? raw.task_id ?? null,
52
+ attempt_id: raw.attempt_id ?? null,
53
+ causation_id: raw.causation_id ?? null,
54
+ correlation_id: raw.correlation_id ?? null,
55
+ payload: raw.payload && typeof raw.payload === 'object' ? raw.payload : {},
56
+ };
57
+ }
58
+
59
+ export function appendEvent(
60
+ projectRoot: string,
61
+ sessionId: string | null,
62
+ input: EventInput,
63
+ causationId?: string
64
+ ): OxeEvent {
65
+ const event = operational.appendEvent(projectRoot, sessionId, {
66
+ event_id: input.id,
67
+ type: input.type,
68
+ timestamp: input.timestamp,
69
+ run_id: input.run_id ?? null,
70
+ work_item_id: input.work_item_id ?? null,
71
+ attempt_id: input.attempt_id ?? null,
72
+ causation_id: input.causation_id ?? causationId ?? null,
73
+ correlation_id: input.correlation_id ?? null,
74
+ payload: input.payload && typeof input.payload === 'object' ? input.payload : {},
75
+ });
76
+ return fromOperationalEvent(event);
77
+ }
78
+
79
+ export function readEvents(
80
+ projectRoot: string,
81
+ sessionId: string | null
82
+ ): OxeEvent[] {
83
+ return operational.readEvents(projectRoot, sessionId).map(fromOperationalEvent);
84
+ }
85
+
86
+ export function filterByRun(events: OxeEvent[], runId: string): OxeEvent[] {
87
+ return events.filter((e) => e.run_id === runId);
88
+ }
89
+
90
+ export function filterByWorkItem(events: OxeEvent[], workItemId: string): OxeEvent[] {
91
+ return events.filter((e) => e.work_item_id === workItemId);
92
+ }
@@ -0,0 +1,29 @@
1
+ export const EVENT_TYPES = [
2
+ 'SessionCreated',
3
+ 'RunStarted',
4
+ 'GraphCompiled',
5
+ 'WorkItemReady',
6
+ 'WorkspaceAllocated',
7
+ 'AttemptStarted',
8
+ 'ToolInvoked',
9
+ 'ToolCompleted',
10
+ 'ToolFailed',
11
+ 'EvidenceCollected',
12
+ 'PolicyEvaluated',
13
+ 'GateRequested',
14
+ 'GateResolved',
15
+ 'VerificationStarted',
16
+ 'VerificationCompleted',
17
+ 'RetryScheduled',
18
+ 'WorkItemCompleted',
19
+ 'WorkItemBlocked',
20
+ 'RunCompleted',
21
+ 'RetroPublished',
22
+ 'LessonPromoted',
23
+ ] as const;
24
+
25
+ export type EventType = (typeof EVENT_TYPES)[number];
26
+
27
+ export function isValidEventType(type: string): type is EventType {
28
+ return (EVENT_TYPES as readonly string[]).includes(type);
29
+ }
@@ -0,0 +1,14 @@
1
+ import type { EventType } from './catalog';
2
+
3
+ export interface OxeEvent {
4
+ id: string;
5
+ type: EventType;
6
+ timestamp: string;
7
+ session_id: string | null;
8
+ run_id: string | null;
9
+ work_item_id: string | null;
10
+ attempt_id: string | null;
11
+ causation_id: string | null;
12
+ correlation_id: string | null;
13
+ payload: Record<string, unknown>;
14
+ }
@@ -0,0 +1,3 @@
1
+ export * from './catalog';
2
+ export * from './envelope';
3
+ export * from './bus';
@@ -0,0 +1,130 @@
1
+ import crypto from 'crypto';
2
+ import path from 'path';
3
+ import fs from 'fs';
4
+ import type { Evidence, EvidenceType } from '../models/evidence';
5
+
6
+ export interface EvidenceCollectOptions {
7
+ work_item_id: string;
8
+ run_id: string;
9
+ attempt_number: number;
10
+ }
11
+
12
+ export interface EvidenceContent {
13
+ evidence: Evidence;
14
+ content: Buffer;
15
+ }
16
+
17
+ const EXT_MAP: Record<EvidenceType, string> = {
18
+ diff: 'patch',
19
+ stdout: 'txt',
20
+ stderr: 'txt',
21
+ junit_xml: 'xml',
22
+ coverage: 'json',
23
+ screenshot: 'png',
24
+ trace: 'json',
25
+ log: 'txt',
26
+ security_report: 'json',
27
+ api_output: 'json',
28
+ summary: 'json',
29
+ };
30
+
31
+ export class EvidenceStore {
32
+ constructor(private readonly projectRoot: string) {}
33
+
34
+ private evidenceDir(runId: string, workItemId: string, attemptNumber: number): string {
35
+ return path.join(
36
+ this.projectRoot,
37
+ '.oxe',
38
+ 'evidence',
39
+ 'runs',
40
+ runId,
41
+ workItemId,
42
+ `attempt-${attemptNumber}`
43
+ );
44
+ }
45
+
46
+ private indexPath(runId: string, workItemId: string, attemptNumber: number): string {
47
+ return path.join(this.evidenceDir(runId, workItemId, attemptNumber), 'index.json');
48
+ }
49
+
50
+ private readIndex(runId: string, workItemId: string, attemptNumber: number): Evidence[] {
51
+ const p = this.indexPath(runId, workItemId, attemptNumber);
52
+ if (!fs.existsSync(p)) return [];
53
+ try {
54
+ return JSON.parse(fs.readFileSync(p, 'utf8')) as Evidence[];
55
+ } catch {
56
+ return [];
57
+ }
58
+ }
59
+
60
+ private writeIndex(runId: string, workItemId: string, attemptNumber: number, items: Evidence[]): void {
61
+ fs.writeFileSync(this.indexPath(runId, workItemId, attemptNumber), JSON.stringify(items, null, 2), 'utf8');
62
+ }
63
+
64
+ async collect(
65
+ type: EvidenceType,
66
+ content: Buffer | string,
67
+ opts: EvidenceCollectOptions
68
+ ): Promise<Evidence> {
69
+ const { work_item_id, run_id, attempt_number } = opts;
70
+ const dir = this.evidenceDir(run_id, work_item_id, attempt_number);
71
+ fs.mkdirSync(dir, { recursive: true });
72
+
73
+ const buf = Buffer.isBuffer(content) ? content : Buffer.from(content, 'utf8');
74
+ const checksum = crypto.createHash('sha256').update(buf).digest('hex').slice(0, 16);
75
+ const ext = EXT_MAP[type] ?? 'bin';
76
+
77
+ const existing = this.readIndex(run_id, work_item_id, attempt_number);
78
+ const seq = existing.filter((e) => e.type === type).length + 1;
79
+ const filename = seq === 1 ? `${type}.${ext}` : `${type}-${seq}.${ext}`;
80
+ const filePath = path.join(dir, filename);
81
+
82
+ fs.writeFileSync(filePath, buf);
83
+
84
+ const evidence: Evidence = {
85
+ evidence_id: `ev-${run_id}-${work_item_id}-a${attempt_number}-${type}-${seq}`,
86
+ attempt_id: `${work_item_id}-a${attempt_number}`,
87
+ type,
88
+ path: path.relative(this.projectRoot, filePath),
89
+ checksum,
90
+ created_at: new Date().toISOString(),
91
+ };
92
+
93
+ this.writeIndex(run_id, work_item_id, attempt_number, [...existing, evidence]);
94
+ return evidence;
95
+ }
96
+
97
+ async list(opts: EvidenceCollectOptions): Promise<Evidence[]> {
98
+ return this.readIndex(opts.run_id, opts.work_item_id, opts.attempt_number);
99
+ }
100
+
101
+ async get(evidenceId: string, opts: EvidenceCollectOptions): Promise<EvidenceContent | null> {
102
+ const items = this.readIndex(opts.run_id, opts.work_item_id, opts.attempt_number);
103
+ const ev = items.find((e) => e.evidence_id === evidenceId);
104
+ if (!ev) return null;
105
+ const absPath = path.join(this.projectRoot, ev.path);
106
+ if (!fs.existsSync(absPath)) return null;
107
+ return { evidence: ev, content: fs.readFileSync(absPath) };
108
+ }
109
+
110
+ async listByRun(runId: string): Promise<Evidence[]> {
111
+ const runDir = path.join(this.projectRoot, '.oxe', 'evidence', 'runs', runId);
112
+ if (!fs.existsSync(runDir)) return [];
113
+ const all: Evidence[] = [];
114
+ for (const workItem of fs.readdirSync(runDir)) {
115
+ const wiDir = path.join(runDir, workItem);
116
+ for (const attempt of fs.readdirSync(wiDir)) {
117
+ const indexPath = path.join(wiDir, attempt, 'index.json');
118
+ if (fs.existsSync(indexPath)) {
119
+ try {
120
+ const items = JSON.parse(fs.readFileSync(indexPath, 'utf8')) as Evidence[];
121
+ all.push(...items);
122
+ } catch {
123
+ // skip corrupt index
124
+ }
125
+ }
126
+ }
127
+ }
128
+ return all;
129
+ }
130
+ }
@@ -0,0 +1 @@
1
+ export * from './evidence-store';
@@ -0,0 +1,137 @@
1
+ import crypto from 'crypto';
2
+ import path from 'path';
3
+ import fs from 'fs';
4
+ import { appendEvent } from '../events/bus';
5
+ import type { GateScope, GateDecisionValue } from '../models/gate-decision';
6
+
7
+ export interface GateContext {
8
+ work_item_id?: string;
9
+ run_id?: string;
10
+ description: string;
11
+ evidence_refs: string[];
12
+ risks: string[];
13
+ }
14
+
15
+ export interface GateToken {
16
+ gate_id: string;
17
+ scope: GateScope;
18
+ requested_at: string;
19
+ context: GateContext;
20
+ status: 'pending' | 'resolved';
21
+ decision?: GateDecisionValue;
22
+ actor?: string;
23
+ reason?: string;
24
+ resolved_at?: string;
25
+ }
26
+
27
+ export interface GateResolution {
28
+ decision: GateDecisionValue;
29
+ actor: string;
30
+ reason?: string;
31
+ }
32
+
33
+ export class GateManager {
34
+ constructor(
35
+ private readonly projectRoot: string,
36
+ private readonly sessionId: string | null,
37
+ private readonly runId: string
38
+ ) {}
39
+
40
+ private gatesPath(): string {
41
+ if (this.sessionId) {
42
+ return path.join(this.projectRoot, '.oxe', this.sessionId, 'execution', 'GATES.json');
43
+ }
44
+ return path.join(this.projectRoot, '.oxe', 'execution', 'GATES.json');
45
+ }
46
+
47
+ private readGates(): GateToken[] {
48
+ const p = this.gatesPath();
49
+ if (!fs.existsSync(p)) return [];
50
+ try {
51
+ return JSON.parse(fs.readFileSync(p, 'utf8')) as GateToken[];
52
+ } catch {
53
+ return [];
54
+ }
55
+ }
56
+
57
+ private writeGates(gates: GateToken[]): void {
58
+ const p = this.gatesPath();
59
+ fs.mkdirSync(path.dirname(p), { recursive: true });
60
+ fs.writeFileSync(p, JSON.stringify(gates, null, 2), 'utf8');
61
+ }
62
+
63
+ async request(scope: GateScope, ctx: GateContext): Promise<GateToken> {
64
+ const token: GateToken = {
65
+ gate_id: `gate-${crypto.randomBytes(4).toString('hex')}`,
66
+ scope,
67
+ requested_at: new Date().toISOString(),
68
+ context: ctx,
69
+ status: 'pending',
70
+ };
71
+
72
+ const gates = this.readGates();
73
+ gates.push(token);
74
+ this.writeGates(gates);
75
+
76
+ appendEvent(this.projectRoot, this.sessionId, {
77
+ type: 'GateRequested',
78
+ run_id: this.runId,
79
+ work_item_id: ctx.work_item_id ?? null,
80
+ payload: {
81
+ gate_id: token.gate_id,
82
+ scope,
83
+ description: ctx.description,
84
+ evidence_refs: ctx.evidence_refs,
85
+ risks: ctx.risks,
86
+ },
87
+ });
88
+
89
+ return token;
90
+ }
91
+
92
+ async resolve(token: GateToken, resolution: GateResolution): Promise<GateToken> {
93
+ const gates = this.readGates();
94
+ const idx = gates.findIndex((g) => g.gate_id === token.gate_id);
95
+ if (idx === -1) throw new Error(`Gate ${token.gate_id} not found`);
96
+
97
+ const resolved: GateToken = {
98
+ ...gates[idx],
99
+ status: 'resolved',
100
+ decision: resolution.decision,
101
+ actor: resolution.actor,
102
+ reason: resolution.reason ?? undefined,
103
+ resolved_at: new Date().toISOString(),
104
+ };
105
+ gates[idx] = resolved;
106
+ this.writeGates(gates);
107
+
108
+ appendEvent(this.projectRoot, this.sessionId, {
109
+ type: 'GateResolved',
110
+ run_id: this.runId,
111
+ payload: {
112
+ gate_id: token.gate_id,
113
+ scope: token.scope,
114
+ decision: resolution.decision,
115
+ actor: resolution.actor,
116
+ },
117
+ });
118
+
119
+ return resolved;
120
+ }
121
+
122
+ isPending(scope: GateScope): boolean {
123
+ return this.readGates().some((g) => g.scope === scope && g.status === 'pending');
124
+ }
125
+
126
+ listPending(): GateToken[] {
127
+ return this.readGates().filter((g) => g.status === 'pending');
128
+ }
129
+
130
+ listAll(): GateToken[] {
131
+ return this.readGates();
132
+ }
133
+
134
+ get(gateId: string): GateToken | null {
135
+ return this.readGates().find((g) => g.gate_id === gateId) ?? null;
136
+ }
137
+ }
@@ -0,0 +1 @@
1
+ export * from './gate-manager';
@@ -0,0 +1,32 @@
1
+ // R1 Public ABI — OXE Runtime Foundation
2
+ export * from './models/index';
3
+ export * from './events/index';
4
+ export * from './reducers/index';
5
+ export * from './compiler/index';
6
+ export * from './scheduler/index';
7
+ export * from './workspace/index';
8
+
9
+ // R2 Public ABI — OXE Evidence & Verification
10
+ export * from './evidence/index';
11
+ // verification exports compile as compileVerification to avoid conflict with compiler/compile
12
+ export {
13
+ compile as compileVerification,
14
+ runCheck,
15
+ runSuite,
16
+ summarizeSuite,
17
+ } from './verification/verification-compiler';
18
+ export type {
19
+ CheckType,
20
+ AcceptanceCheck,
21
+ AcceptanceCheckSuite,
22
+ CheckResult,
23
+ } from './verification/verification-compiler';
24
+ export * from './policy/index';
25
+ export * from './gate/index';
26
+ export * from './projection/index';
27
+
28
+ // R3 Public ABI — OXE Delivery & Extensibility
29
+ export * from './plugins/index';
30
+ export * from './delivery/index';
31
+ export * from './context/index';
32
+ export * from './scheduler/multi-agent-coordinator';
@@ -0,0 +1,19 @@
1
+ export type AttemptOutcome =
2
+ | 'success'
3
+ | 'failure_env'
4
+ | 'failure_policy'
5
+ | 'failure_test'
6
+ | 'failure_timeout'
7
+ | 'cancelled';
8
+
9
+ export interface Attempt {
10
+ attempt_id: string;
11
+ work_item_id: string;
12
+ attempt_number: number;
13
+ workspace_id: string | null;
14
+ agent_profile: string | null;
15
+ model: string | null;
16
+ started_at: string;
17
+ ended_at: string | null;
18
+ outcome: AttemptOutcome | null;
19
+ }
@@ -0,0 +1,21 @@
1
+ export type EvidenceType =
2
+ | 'diff'
3
+ | 'stdout'
4
+ | 'stderr'
5
+ | 'junit_xml'
6
+ | 'coverage'
7
+ | 'screenshot'
8
+ | 'trace'
9
+ | 'log'
10
+ | 'security_report'
11
+ | 'api_output'
12
+ | 'summary';
13
+
14
+ export interface Evidence {
15
+ evidence_id: string;
16
+ attempt_id: string;
17
+ type: EvidenceType;
18
+ path: string;
19
+ checksum: string | null;
20
+ created_at: string;
21
+ }
@@ -0,0 +1,21 @@
1
+ export type GateDecisionValue =
2
+ | 'approved'
3
+ | 'rejected'
4
+ | 'approved_with_caveats'
5
+ | 'needs_more_evidence';
6
+
7
+ export type GateScope =
8
+ | 'plan_approval'
9
+ | 'critical_mutation'
10
+ | 'security'
11
+ | 'pr_promotion'
12
+ | 'merge';
13
+
14
+ export interface GateDecision {
15
+ gate_id: string;
16
+ scope: GateScope;
17
+ decision: GateDecisionValue;
18
+ actor: string;
19
+ reason: string | null;
20
+ timestamp: string;
21
+ }
@@ -0,0 +1,8 @@
1
+ export * from './session';
2
+ export * from './run';
3
+ export * from './work-item';
4
+ export * from './attempt';
5
+ export * from './workspace';
6
+ export * from './evidence';
7
+ export * from './gate-decision';
8
+ export * from './verification-result';
@@ -0,0 +1,24 @@
1
+ export type RunStatus =
2
+ | 'planned'
3
+ | 'running'
4
+ | 'paused'
5
+ | 'waiting_approval'
6
+ | 'failed'
7
+ | 'completed'
8
+ | 'replaying'
9
+ | 'aborted'
10
+ | 'cancelled';
11
+
12
+ export type RunMode = 'completo' | 'por_onda' | 'por_tarefa';
13
+ export type RunInitiator = 'user' | 'scheduler' | 'retry' | 'replay';
14
+
15
+ export interface Run {
16
+ run_id: string;
17
+ session_id: string | null;
18
+ graph_version: string;
19
+ started_at: string;
20
+ ended_at: string | null;
21
+ status: RunStatus;
22
+ initiator: RunInitiator;
23
+ mode: RunMode;
24
+ }
@@ -0,0 +1,11 @@
1
+ export type SessionStatus = 'active' | 'archived' | 'closed';
2
+
3
+ export interface Session {
4
+ session_id: string;
5
+ title: string;
6
+ created_at: string;
7
+ status: SessionStatus;
8
+ repo_root: string;
9
+ baseline_commit: string | null;
10
+ active_run_id: string | null;
11
+ }
@@ -0,0 +1,10 @@
1
+ export type VerificationStatus = 'pass' | 'fail' | 'skip' | 'error';
2
+
3
+ export interface VerificationResult {
4
+ verification_id: string;
5
+ work_item_id: string;
6
+ check_id: string;
7
+ status: VerificationStatus;
8
+ evidence_refs: string[];
9
+ summary: string | null;
10
+ }
@@ -0,0 +1,25 @@
1
+ import type { WorkspaceStrategy } from './workspace';
2
+
3
+ export type WorkItemStatus =
4
+ | 'pending'
5
+ | 'ready'
6
+ | 'running'
7
+ | 'completed'
8
+ | 'failed'
9
+ | 'blocked'
10
+ | 'skipped';
11
+
12
+ export type WorkItemType = 'task' | 'checkpoint' | 'gate' | 'verification';
13
+
14
+ export interface WorkItem {
15
+ work_item_id: string;
16
+ run_id: string;
17
+ title: string;
18
+ type: WorkItemType;
19
+ depends_on: string[];
20
+ mutation_scope: string[];
21
+ policy_ref: string | null;
22
+ verify_ref: string[];
23
+ status: WorkItemStatus;
24
+ workspace_strategy: WorkspaceStrategy;
25
+ }
@@ -0,0 +1,28 @@
1
+ export type WorkspaceStrategy = 'inplace' | 'git_worktree' | 'ephemeral_container';
2
+ export type WorkspaceStatus = 'allocating' | 'ready' | 'dirty' | 'disposed' | 'error';
3
+
4
+ export interface Workspace {
5
+ workspace_id: string;
6
+ strategy: WorkspaceStrategy;
7
+ base_commit: string | null;
8
+ branch: string | null;
9
+ container_ref: string | null;
10
+ status: WorkspaceStatus;
11
+ root_path: string;
12
+ }
13
+
14
+ export interface WorkspaceLease {
15
+ workspace_id: string;
16
+ strategy: WorkspaceStrategy;
17
+ branch: string | null;
18
+ base_commit: string | null;
19
+ root_path: string;
20
+ ttl_minutes: number;
21
+ }
22
+
23
+ export interface SnapshotRef {
24
+ snapshot_id: string;
25
+ workspace_id: string;
26
+ commit: string;
27
+ created_at: string;
28
+ }
@@ -0,0 +1,2 @@
1
+ export * from './plugin-abi';
2
+ export * from './plugin-registry';