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.
- package/.cursor/commands/oxe-retro.md +2 -2
- package/.cursor/commands/oxe-spec.md +2 -2
- package/.github/prompts/oxe-retro.prompt.md +2 -2
- package/.github/prompts/oxe-spec.prompt.md +2 -2
- package/README.md +1 -1
- package/bin/banner.txt +1 -1
- package/bin/lib/oxe-context-engine.cjs +1 -0
- package/bin/lib/oxe-dashboard.cjs +9 -7
- package/bin/lib/oxe-operational.cjs +569 -4
- package/bin/oxe-cc.js +141 -57
- package/commands/oxe/retro.md +2 -2
- package/commands/oxe/spec.md +2 -2
- package/lib/runtime/compiler/graph-compiler.d.ts +83 -0
- package/lib/runtime/compiler/graph-compiler.js +135 -0
- package/lib/runtime/compiler/index.d.ts +1 -0
- package/lib/runtime/compiler/index.js +17 -0
- package/lib/runtime/context/context-pack-builder.d.ts +36 -0
- package/lib/runtime/context/context-pack-builder.js +136 -0
- package/lib/runtime/context/index.d.ts +1 -0
- package/lib/runtime/context/index.js +17 -0
- package/lib/runtime/delivery/branch-manager.d.ts +19 -0
- package/lib/runtime/delivery/branch-manager.js +78 -0
- package/lib/runtime/delivery/ci-checks.d.ts +34 -0
- package/lib/runtime/delivery/ci-checks.js +209 -0
- package/lib/runtime/delivery/index.d.ts +3 -0
- package/lib/runtime/delivery/index.js +19 -0
- package/lib/runtime/delivery/pr-manager.d.ts +30 -0
- package/lib/runtime/delivery/pr-manager.js +82 -0
- package/lib/runtime/events/bus.d.ts +9 -0
- package/lib/runtime/events/bus.js +63 -0
- package/lib/runtime/events/catalog.d.ts +3 -0
- package/lib/runtime/events/catalog.js +30 -0
- package/lib/runtime/events/envelope.d.ts +13 -0
- package/lib/runtime/events/envelope.js +2 -0
- package/lib/runtime/events/index.d.ts +3 -0
- package/lib/runtime/events/index.js +19 -0
- package/lib/runtime/evidence/evidence-store.d.ts +22 -0
- package/lib/runtime/evidence/evidence-store.js +106 -0
- package/lib/runtime/evidence/index.d.ts +1 -0
- package/lib/runtime/evidence/index.js +17 -0
- package/lib/runtime/gate/gate-manager.d.ts +39 -0
- package/lib/runtime/gate/gate-manager.js +104 -0
- package/lib/runtime/gate/index.d.ts +1 -0
- package/lib/runtime/gate/index.js +17 -0
- package/lib/runtime/index.d.ts +16 -0
- package/lib/runtime/index.js +40 -0
- package/lib/runtime/models/attempt.d.ts +12 -0
- package/lib/runtime/models/attempt.js +2 -0
- package/lib/runtime/models/evidence.d.ts +9 -0
- package/lib/runtime/models/evidence.js +2 -0
- package/lib/runtime/models/gate-decision.d.ts +10 -0
- package/lib/runtime/models/gate-decision.js +2 -0
- package/lib/runtime/models/index.d.ts +8 -0
- package/lib/runtime/models/index.js +24 -0
- package/lib/runtime/models/run.d.ts +13 -0
- package/lib/runtime/models/run.js +2 -0
- package/lib/runtime/models/session.d.ts +10 -0
- package/lib/runtime/models/session.js +2 -0
- package/lib/runtime/models/verification-result.d.ts +9 -0
- package/lib/runtime/models/verification-result.js +2 -0
- package/lib/runtime/models/work-item.d.ts +15 -0
- package/lib/runtime/models/work-item.js +2 -0
- package/lib/runtime/models/workspace.d.ts +25 -0
- package/lib/runtime/models/workspace.js +2 -0
- package/lib/runtime/plugins/index.d.ts +2 -0
- package/lib/runtime/plugins/index.js +18 -0
- package/lib/runtime/plugins/plugin-abi.d.ts +76 -0
- package/lib/runtime/plugins/plugin-abi.js +2 -0
- package/lib/runtime/plugins/plugin-registry.d.ts +21 -0
- package/lib/runtime/plugins/plugin-registry.js +114 -0
- package/lib/runtime/policy/index.d.ts +1 -0
- package/lib/runtime/policy/index.js +17 -0
- package/lib/runtime/policy/policy-engine.d.ts +40 -0
- package/lib/runtime/policy/policy-engine.js +80 -0
- package/lib/runtime/projection/index.d.ts +1 -0
- package/lib/runtime/projection/index.js +17 -0
- package/lib/runtime/projection/projection-engine.d.ts +11 -0
- package/lib/runtime/projection/projection-engine.js +218 -0
- package/lib/runtime/reducers/debug-reducer.d.ts +10 -0
- package/lib/runtime/reducers/debug-reducer.js +30 -0
- package/lib/runtime/reducers/index.d.ts +2 -0
- package/lib/runtime/reducers/index.js +18 -0
- package/lib/runtime/reducers/run-state-reducer.d.ts +20 -0
- package/lib/runtime/reducers/run-state-reducer.js +110 -0
- package/lib/runtime/scheduler/index.d.ts +1 -0
- package/lib/runtime/scheduler/index.js +17 -0
- package/lib/runtime/scheduler/multi-agent-coordinator.d.ts +34 -0
- package/lib/runtime/scheduler/multi-agent-coordinator.js +166 -0
- package/lib/runtime/scheduler/scheduler.d.ts +39 -0
- package/lib/runtime/scheduler/scheduler.js +196 -0
- package/lib/runtime/verification/index.d.ts +1 -0
- package/lib/runtime/verification/index.js +17 -0
- package/lib/runtime/verification/verification-compiler.d.ts +56 -0
- package/lib/runtime/verification/verification-compiler.js +147 -0
- package/lib/runtime/workspace/index.d.ts +5 -0
- package/lib/runtime/workspace/index.js +24 -0
- package/lib/runtime/workspace/strategies/ephemeral-container.d.ts +22 -0
- package/lib/runtime/workspace/strategies/ephemeral-container.js +109 -0
- package/lib/runtime/workspace/strategies/git-worktree.d.ts +12 -0
- package/lib/runtime/workspace/strategies/git-worktree.js +79 -0
- package/lib/runtime/workspace/strategies/inplace.d.ts +10 -0
- package/lib/runtime/workspace/strategies/inplace.js +37 -0
- package/lib/runtime/workspace/workspace-manager.d.ts +13 -0
- package/lib/runtime/workspace/workspace-manager.js +2 -0
- package/lib/sdk/index.cjs +24 -7
- package/lib/sdk/index.d.ts +17 -7
- package/oxe/templates/LESSONS-METRICS.template.json +13 -0
- package/oxe/workflows/references/robustness-elevation.md +295 -0
- package/oxe/workflows/references/workflow-runtime-contracts.json +32 -4
- package/oxe/workflows/retro.md +21 -0
- package/oxe/workflows/spec.md +50 -26
- package/oxe/workflows/verify.md +36 -0
- package/package.json +9 -3
- package/packages/runtime/package.json +17 -0
- package/packages/runtime/src/compiler/graph-compiler.ts +245 -0
- package/packages/runtime/src/compiler/index.ts +1 -0
- package/packages/runtime/src/context/context-pack-builder.ts +193 -0
- package/packages/runtime/src/context/index.ts +1 -0
- package/packages/runtime/src/delivery/branch-manager.ts +84 -0
- package/packages/runtime/src/delivery/ci-checks.ts +252 -0
- package/packages/runtime/src/delivery/index.ts +3 -0
- package/packages/runtime/src/delivery/pr-manager.ts +112 -0
- package/packages/runtime/src/events/bus.ts +92 -0
- package/packages/runtime/src/events/catalog.ts +29 -0
- package/packages/runtime/src/events/envelope.ts +14 -0
- package/packages/runtime/src/events/index.ts +3 -0
- package/packages/runtime/src/evidence/evidence-store.ts +130 -0
- package/packages/runtime/src/evidence/index.ts +1 -0
- package/packages/runtime/src/gate/gate-manager.ts +137 -0
- package/packages/runtime/src/gate/index.ts +1 -0
- package/packages/runtime/src/index.ts +32 -0
- package/packages/runtime/src/models/attempt.ts +19 -0
- package/packages/runtime/src/models/evidence.ts +21 -0
- package/packages/runtime/src/models/gate-decision.ts +21 -0
- package/packages/runtime/src/models/index.ts +8 -0
- package/packages/runtime/src/models/run.ts +24 -0
- package/packages/runtime/src/models/session.ts +11 -0
- package/packages/runtime/src/models/verification-result.ts +10 -0
- package/packages/runtime/src/models/work-item.ts +25 -0
- package/packages/runtime/src/models/workspace.ts +28 -0
- package/packages/runtime/src/plugins/index.ts +2 -0
- package/packages/runtime/src/plugins/plugin-abi.ts +95 -0
- package/packages/runtime/src/plugins/plugin-registry.ts +119 -0
- package/packages/runtime/src/policy/index.ts +1 -0
- package/packages/runtime/src/policy/policy-engine.ts +113 -0
- package/packages/runtime/src/projection/index.ts +1 -0
- package/packages/runtime/src/projection/projection-engine.ts +249 -0
- package/packages/runtime/src/reducers/debug-reducer.ts +36 -0
- package/packages/runtime/src/reducers/index.ts +2 -0
- package/packages/runtime/src/reducers/run-state-reducer.ts +127 -0
- package/packages/runtime/src/scheduler/index.ts +1 -0
- package/packages/runtime/src/scheduler/multi-agent-coordinator.ts +231 -0
- package/packages/runtime/src/scheduler/scheduler.ts +281 -0
- package/packages/runtime/src/verification/index.ts +1 -0
- package/packages/runtime/src/verification/verification-compiler.ts +225 -0
- package/packages/runtime/src/workspace/index.ts +5 -0
- package/packages/runtime/src/workspace/strategies/ephemeral-container.ts +121 -0
- package/packages/runtime/src/workspace/strategies/git-worktree.ts +77 -0
- package/packages/runtime/src/workspace/strategies/inplace.ts +35 -0
- package/packages/runtime/src/workspace/workspace-manager.ts +15 -0
- package/packages/runtime/tsconfig.json +17 -0
- package/vscode-extension/oxe-agents-1.0.0.vsix +0 -0
- package/vscode-extension/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { WorkspaceStrategy } from './workspace';
|
|
2
|
+
export type WorkItemStatus = 'pending' | 'ready' | 'running' | 'completed' | 'failed' | 'blocked' | 'skipped';
|
|
3
|
+
export type WorkItemType = 'task' | 'checkpoint' | 'gate' | 'verification';
|
|
4
|
+
export interface WorkItem {
|
|
5
|
+
work_item_id: string;
|
|
6
|
+
run_id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
type: WorkItemType;
|
|
9
|
+
depends_on: string[];
|
|
10
|
+
mutation_scope: string[];
|
|
11
|
+
policy_ref: string | null;
|
|
12
|
+
verify_ref: string[];
|
|
13
|
+
status: WorkItemStatus;
|
|
14
|
+
workspace_strategy: WorkspaceStrategy;
|
|
15
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type WorkspaceStrategy = 'inplace' | 'git_worktree' | 'ephemeral_container';
|
|
2
|
+
export type WorkspaceStatus = 'allocating' | 'ready' | 'dirty' | 'disposed' | 'error';
|
|
3
|
+
export interface Workspace {
|
|
4
|
+
workspace_id: string;
|
|
5
|
+
strategy: WorkspaceStrategy;
|
|
6
|
+
base_commit: string | null;
|
|
7
|
+
branch: string | null;
|
|
8
|
+
container_ref: string | null;
|
|
9
|
+
status: WorkspaceStatus;
|
|
10
|
+
root_path: string;
|
|
11
|
+
}
|
|
12
|
+
export interface WorkspaceLease {
|
|
13
|
+
workspace_id: string;
|
|
14
|
+
strategy: WorkspaceStrategy;
|
|
15
|
+
branch: string | null;
|
|
16
|
+
base_commit: string | null;
|
|
17
|
+
root_path: string;
|
|
18
|
+
ttl_minutes: number;
|
|
19
|
+
}
|
|
20
|
+
export interface SnapshotRef {
|
|
21
|
+
snapshot_id: string;
|
|
22
|
+
workspace_id: string;
|
|
23
|
+
commit: string;
|
|
24
|
+
created_at: string;
|
|
25
|
+
}
|
|
@@ -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("./plugin-abi"), exports);
|
|
18
|
+
__exportStar(require("./plugin-registry"), exports);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { WorkspaceManager } from '../workspace/workspace-manager';
|
|
2
|
+
import type { VerificationResult } from '../models/verification-result';
|
|
3
|
+
export interface ToolInvocationInput {
|
|
4
|
+
action_type: string;
|
|
5
|
+
work_item_id: string;
|
|
6
|
+
run_id: string;
|
|
7
|
+
attempt_id: string;
|
|
8
|
+
params: Record<string, unknown>;
|
|
9
|
+
workspace_root: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ToolInvocationResult {
|
|
12
|
+
success: boolean;
|
|
13
|
+
output: string;
|
|
14
|
+
evidence_paths: string[];
|
|
15
|
+
side_effects_applied: string[];
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ToolProvider {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly kind: 'read' | 'mutation' | 'verification' | 'analysis' | 'external_operation';
|
|
21
|
+
readonly idempotent: boolean;
|
|
22
|
+
supports(actionType: string): boolean;
|
|
23
|
+
invoke(input: ToolInvocationInput): Promise<ToolInvocationResult>;
|
|
24
|
+
}
|
|
25
|
+
export interface WorkspaceProvider extends WorkspaceManager {
|
|
26
|
+
readonly name: string;
|
|
27
|
+
supportsStrategy(strategy: string): boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface VerificationInput {
|
|
30
|
+
check_id: string;
|
|
31
|
+
check_type: string;
|
|
32
|
+
command: string | null;
|
|
33
|
+
work_item_id: string;
|
|
34
|
+
workspace_root: string;
|
|
35
|
+
evidence_dir: string;
|
|
36
|
+
}
|
|
37
|
+
export interface VerifierProvider {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
supports(checkType: string): boolean;
|
|
40
|
+
execute(input: VerificationInput): Promise<VerificationResult>;
|
|
41
|
+
}
|
|
42
|
+
export interface ContextRequest {
|
|
43
|
+
work_item_id: string;
|
|
44
|
+
run_id: string;
|
|
45
|
+
decision_type: 'execute' | 'verify' | 'plan' | 'review';
|
|
46
|
+
artifact_paths: string[];
|
|
47
|
+
project_root: string;
|
|
48
|
+
}
|
|
49
|
+
export interface PluginContextArtifact {
|
|
50
|
+
source: string;
|
|
51
|
+
weight: number;
|
|
52
|
+
reason: string;
|
|
53
|
+
content?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface PluginContextArtifacts {
|
|
56
|
+
included: PluginContextArtifact[];
|
|
57
|
+
excluded: Array<{
|
|
58
|
+
source: string;
|
|
59
|
+
reason: string;
|
|
60
|
+
}>;
|
|
61
|
+
total_weight: number;
|
|
62
|
+
}
|
|
63
|
+
export interface ContextProvider {
|
|
64
|
+
readonly name: string;
|
|
65
|
+
collect(input: ContextRequest): Promise<PluginContextArtifacts>;
|
|
66
|
+
}
|
|
67
|
+
export interface OxePlugin {
|
|
68
|
+
readonly name: string;
|
|
69
|
+
readonly version?: string;
|
|
70
|
+
toolProviders?: ToolProvider[];
|
|
71
|
+
workspaceProviders?: WorkspaceProvider[];
|
|
72
|
+
verifierProviders?: VerifierProvider[];
|
|
73
|
+
contextProviders?: ContextProvider[];
|
|
74
|
+
/** Legacy lifecycle hooks (compatible with oxe-plugins.cjs) */
|
|
75
|
+
hooks?: Record<string, (ctx: Record<string, unknown>) => Promise<void> | void>;
|
|
76
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { OxePlugin, ToolProvider, WorkspaceProvider, VerifierProvider, ContextProvider } from './plugin-abi';
|
|
2
|
+
export declare class PluginRegistry {
|
|
3
|
+
private plugins;
|
|
4
|
+
register(plugin: OxePlugin): void;
|
|
5
|
+
unregister(name: string): void;
|
|
6
|
+
loadFromDirectory(dir: string): string[];
|
|
7
|
+
toolProviderFor(actionType: string): ToolProvider | null;
|
|
8
|
+
workspaceProviderFor(strategy: string): WorkspaceProvider | null;
|
|
9
|
+
verifierProviderFor(checkType: string): VerifierProvider | null;
|
|
10
|
+
contextProviderFor(name: string): ContextProvider | null;
|
|
11
|
+
allContextProviders(): ContextProvider[];
|
|
12
|
+
allToolProviders(): ToolProvider[];
|
|
13
|
+
runHook(hookName: string, ctx: Record<string, unknown>): Promise<void>;
|
|
14
|
+
list(): Array<{
|
|
15
|
+
name: string;
|
|
16
|
+
version?: string;
|
|
17
|
+
providers: string[];
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export declare function globalRegistry(): PluginRegistry;
|
|
21
|
+
export declare function resetGlobalRegistry(): void;
|
|
@@ -0,0 +1,114 @@
|
|
|
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.PluginRegistry = void 0;
|
|
7
|
+
exports.globalRegistry = globalRegistry;
|
|
8
|
+
exports.resetGlobalRegistry = resetGlobalRegistry;
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
class PluginRegistry {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.plugins = [];
|
|
14
|
+
}
|
|
15
|
+
register(plugin) {
|
|
16
|
+
if (this.plugins.some((p) => p.name === plugin.name)) {
|
|
17
|
+
throw new Error(`Plugin "${plugin.name}" is already registered`);
|
|
18
|
+
}
|
|
19
|
+
this.plugins.push(plugin);
|
|
20
|
+
}
|
|
21
|
+
unregister(name) {
|
|
22
|
+
this.plugins = this.plugins.filter((p) => p.name !== name);
|
|
23
|
+
}
|
|
24
|
+
loadFromDirectory(dir) {
|
|
25
|
+
if (!fs_1.default.existsSync(dir))
|
|
26
|
+
return [];
|
|
27
|
+
const loaded = [];
|
|
28
|
+
for (const file of fs_1.default.readdirSync(dir)) {
|
|
29
|
+
if (!file.endsWith('.cjs') && !file.endsWith('.js'))
|
|
30
|
+
continue;
|
|
31
|
+
const fullPath = path_1.default.resolve(dir, file);
|
|
32
|
+
try {
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
34
|
+
const mod = require(fullPath);
|
|
35
|
+
const plugin = 'default' in mod && mod.default ? mod.default : mod;
|
|
36
|
+
if (plugin && plugin.name) {
|
|
37
|
+
this.register(plugin);
|
|
38
|
+
loaded.push(plugin.name);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// skip invalid plugin files
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return loaded;
|
|
46
|
+
}
|
|
47
|
+
toolProviderFor(actionType) {
|
|
48
|
+
for (const plugin of this.plugins) {
|
|
49
|
+
const provider = plugin.toolProviders?.find((p) => p.supports(actionType));
|
|
50
|
+
if (provider)
|
|
51
|
+
return provider;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
workspaceProviderFor(strategy) {
|
|
56
|
+
for (const plugin of this.plugins) {
|
|
57
|
+
const provider = plugin.workspaceProviders?.find((p) => p.supportsStrategy(strategy));
|
|
58
|
+
if (provider)
|
|
59
|
+
return provider;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
verifierProviderFor(checkType) {
|
|
64
|
+
for (const plugin of this.plugins) {
|
|
65
|
+
const provider = plugin.verifierProviders?.find((p) => p.supports(checkType));
|
|
66
|
+
if (provider)
|
|
67
|
+
return provider;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
contextProviderFor(name) {
|
|
72
|
+
for (const plugin of this.plugins) {
|
|
73
|
+
const provider = plugin.contextProviders?.find((p) => p.name === name);
|
|
74
|
+
if (provider)
|
|
75
|
+
return provider;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
allContextProviders() {
|
|
80
|
+
return this.plugins.flatMap((p) => p.contextProviders ?? []);
|
|
81
|
+
}
|
|
82
|
+
allToolProviders() {
|
|
83
|
+
return this.plugins.flatMap((p) => p.toolProviders ?? []);
|
|
84
|
+
}
|
|
85
|
+
async runHook(hookName, ctx) {
|
|
86
|
+
for (const plugin of this.plugins) {
|
|
87
|
+
const hook = plugin.hooks?.[hookName];
|
|
88
|
+
if (hook)
|
|
89
|
+
await hook(ctx);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
list() {
|
|
93
|
+
return this.plugins.map((p) => ({
|
|
94
|
+
name: p.name,
|
|
95
|
+
version: p.version,
|
|
96
|
+
providers: [
|
|
97
|
+
...(p.toolProviders?.map((tp) => `tool:${tp.name}`) ?? []),
|
|
98
|
+
...(p.workspaceProviders?.map((wp) => `workspace:${wp.name}`) ?? []),
|
|
99
|
+
...(p.verifierProviders?.map((vp) => `verifier:${vp.name}`) ?? []),
|
|
100
|
+
...(p.contextProviders?.map((cp) => `context:${cp.name}`) ?? []),
|
|
101
|
+
],
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.PluginRegistry = PluginRegistry;
|
|
106
|
+
let _globalRegistry = null;
|
|
107
|
+
function globalRegistry() {
|
|
108
|
+
if (!_globalRegistry)
|
|
109
|
+
_globalRegistry = new PluginRegistry();
|
|
110
|
+
return _globalRegistry;
|
|
111
|
+
}
|
|
112
|
+
function resetGlobalRegistry() {
|
|
113
|
+
_globalRegistry = null;
|
|
114
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './policy-engine';
|
|
@@ -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("./policy-engine"), exports);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type PolicyAction = 'allow' | 'deny' | 'require_human_gate';
|
|
2
|
+
export interface PolicyWhenClause {
|
|
3
|
+
tool?: string;
|
|
4
|
+
env?: string;
|
|
5
|
+
kind?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PolicyAssertClause {
|
|
8
|
+
diff_within_scope?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface PolicyRule {
|
|
11
|
+
id: string;
|
|
12
|
+
when: PolicyWhenClause;
|
|
13
|
+
assert?: PolicyAssertClause;
|
|
14
|
+
action: PolicyAction;
|
|
15
|
+
}
|
|
16
|
+
export interface PolicyContext {
|
|
17
|
+
tool: string;
|
|
18
|
+
env?: string;
|
|
19
|
+
kind?: string;
|
|
20
|
+
mutation_scope?: string[];
|
|
21
|
+
affected_paths?: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface PolicyDecision {
|
|
24
|
+
allowed: boolean;
|
|
25
|
+
gate_required: boolean;
|
|
26
|
+
reason: string;
|
|
27
|
+
rule_id: string | null;
|
|
28
|
+
}
|
|
29
|
+
export declare class PolicyEngine {
|
|
30
|
+
private readonly rules;
|
|
31
|
+
constructor(rules?: PolicyRule[]);
|
|
32
|
+
evaluate(ctx: PolicyContext): PolicyDecision;
|
|
33
|
+
private matches;
|
|
34
|
+
private checkAssert;
|
|
35
|
+
withRule(rule: PolicyRule): PolicyEngine;
|
|
36
|
+
static fromConfig(config: {
|
|
37
|
+
policies?: PolicyRule[];
|
|
38
|
+
}): PolicyEngine;
|
|
39
|
+
static fromConfigFile(configPath: string): PolicyEngine;
|
|
40
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PolicyEngine = void 0;
|
|
4
|
+
const ALLOW_ALL = {
|
|
5
|
+
allowed: true,
|
|
6
|
+
gate_required: false,
|
|
7
|
+
reason: 'no matching policy — default allow',
|
|
8
|
+
rule_id: null,
|
|
9
|
+
};
|
|
10
|
+
class PolicyEngine {
|
|
11
|
+
constructor(rules = []) {
|
|
12
|
+
this.rules = rules;
|
|
13
|
+
}
|
|
14
|
+
evaluate(ctx) {
|
|
15
|
+
for (const rule of this.rules) {
|
|
16
|
+
if (!this.matches(rule.when, ctx))
|
|
17
|
+
continue;
|
|
18
|
+
if (rule.assert) {
|
|
19
|
+
const assertFailed = this.checkAssert(rule.assert, ctx);
|
|
20
|
+
if (assertFailed) {
|
|
21
|
+
return {
|
|
22
|
+
allowed: false,
|
|
23
|
+
gate_required: false,
|
|
24
|
+
reason: `Assert failed for rule ${rule.id}: ${assertFailed}`,
|
|
25
|
+
rule_id: rule.id,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
switch (rule.action) {
|
|
30
|
+
case 'allow':
|
|
31
|
+
return { allowed: true, gate_required: false, reason: `Allowed by rule ${rule.id}`, rule_id: rule.id };
|
|
32
|
+
case 'deny':
|
|
33
|
+
return { allowed: false, gate_required: false, reason: `Denied by rule ${rule.id}`, rule_id: rule.id };
|
|
34
|
+
case 'require_human_gate':
|
|
35
|
+
return { allowed: true, gate_required: true, reason: `Gate required by rule ${rule.id}`, rule_id: rule.id };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return ALLOW_ALL;
|
|
39
|
+
}
|
|
40
|
+
matches(when, ctx) {
|
|
41
|
+
if (when.tool && when.tool !== ctx.tool)
|
|
42
|
+
return false;
|
|
43
|
+
if (when.env && when.env !== ctx.env)
|
|
44
|
+
return false;
|
|
45
|
+
if (when.kind && when.kind !== ctx.kind)
|
|
46
|
+
return false;
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
checkAssert(assert, ctx) {
|
|
50
|
+
if (assert.diff_within_scope === true) {
|
|
51
|
+
const scope = ctx.mutation_scope ?? [];
|
|
52
|
+
const affected = ctx.affected_paths ?? [];
|
|
53
|
+
if (scope.length === 0)
|
|
54
|
+
return null; // no scope declared — pass
|
|
55
|
+
const outsideScope = affected.filter((p) => !scope.some((s) => p.startsWith(s) || s.startsWith(p)));
|
|
56
|
+
if (outsideScope.length > 0) {
|
|
57
|
+
return `paths outside mutation scope: ${outsideScope.join(', ')}`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
withRule(rule) {
|
|
63
|
+
return new PolicyEngine([...this.rules, rule]);
|
|
64
|
+
}
|
|
65
|
+
static fromConfig(config) {
|
|
66
|
+
return new PolicyEngine(config.policies ?? []);
|
|
67
|
+
}
|
|
68
|
+
static fromConfigFile(configPath) {
|
|
69
|
+
try {
|
|
70
|
+
// Dynamic require to avoid bundling issues
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
72
|
+
const cfg = require(configPath);
|
|
73
|
+
return PolicyEngine.fromConfig(cfg);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return new PolicyEngine();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.PolicyEngine = PolicyEngine;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './projection-engine';
|
|
@@ -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("./projection-engine"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RunState } from '../reducers/run-state-reducer';
|
|
2
|
+
import type { ExecutionGraph } from '../compiler/graph-compiler';
|
|
3
|
+
import type { VerificationResult } from '../models/verification-result';
|
|
4
|
+
import type { CheckResult } from '../verification/verification-compiler';
|
|
5
|
+
export declare class ProjectionEngine {
|
|
6
|
+
projectPlan(state: RunState, graph: ExecutionGraph): string;
|
|
7
|
+
projectVerify(state: RunState, results: VerificationResult[], checkResults?: CheckResult[]): string;
|
|
8
|
+
projectState(state: RunState): string;
|
|
9
|
+
projectRunSummary(state: RunState): string;
|
|
10
|
+
projectPRSummary(state: RunState, graph: ExecutionGraph): string;
|
|
11
|
+
}
|