ega-v9 0.1.0 → 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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Dae Jung Byun
3
+ Copyright (c) 2026 Daejung Byun
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,44 +1,262 @@
1
- # EGA V9
1
+ # EGA V9 --- Execution Governance AI
2
2
 
3
- Execution Governance AI V9 is a deterministic runtime-governance framework for autonomous AI workflows.
3
+ ## Deterministic Runtime Governance for Autonomous AI Workflows
4
4
 
5
- ## Install
5
+ > **Official Replication Guide for the EGA V9 paper**
6
6
 
7
- ```bash
7
+ EGA V9 is an execution-governance framework for deterministic replay,
8
+ provenance-aware verification, trust-state evaluation, and fail-closed
9
+ containment in autonomous AI workflows.
10
+
11
+ This README serves as the official replication guide accompanying the
12
+ EGA V9 paper.
13
+
14
+ ------------------------------------------------------------------------
15
+
16
+ ## Table of Contents
17
+
18
+ 1. Why EGA V9?
19
+ 2. Installation
20
+ 3. Three-Line Integration
21
+ 4. Quick Start
22
+ 5. [Verified Behavior](#5-verified-behavior)
23
+ 6. Reproducing the Paper
24
+ 7. Publication Verification
25
+ 8. Runtime Architecture
26
+ 9. Repository Structure
27
+ 10. Contact and Collaboration
28
+ 11. License
29
+ 12. Roadmap
30
+
31
+ ------------------------------------------------------------------------
32
+
33
+ ## 1. Why EGA V9?
34
+
35
+ **LLM-based guards add cost. Runtime failures still happen.**
36
+
37
+ EGA V9 takes a different approach.
38
+
39
+ Instead of asking another LLM whether an execution is safe, EGA V9 verifies workflow execution deterministically.
40
+
41
+ ### EGA V9
42
+
43
+ - Runtime verification with **0 additional LLM calls**
44
+ - Median (P50) verification latency: **0.003055 ms**
45
+ - **10,000 workflows evaluated**
46
+ - **0% false positives / 0% false negatives**
47
+ - Deterministic replay, provenance verification, and fail-closed containment
48
+
49
+ > **Deterministic Replay > Probabilistic Trust**
50
+
51
+ ------------------------------------------------------------------------
52
+
53
+ ## 2. Installation
54
+
55
+ ``` bash
8
56
  npm install ega-v9
9
57
  ```
10
58
 
11
- ## Quick Start
59
+ Repository replication:
60
+
61
+ ``` bash
62
+ git clone https://github.com/paibyun9/EGA-V9.git
63
+ cd EGA-V9
64
+ npm ci
65
+ ```
66
+
67
+ ------------------------------------------------------------------------
68
+
69
+ ## 3. Three-Line Integration
70
+
71
+ Protect an existing AI application with a single middleware.
72
+
73
+ ### Before
12
74
 
13
75
  ```javascript
14
- import { govern } from "ega-v9";
76
+ app.post("/checkout", async (req) => {
77
+ await agent.buy(req.body.item);
78
+ });
79
+ ```
15
80
 
16
- const result = govern([
17
- { step: 1, action: "search_product", item: "laptop" },
18
- { step: 2, action: "select_product", quantity: 1 },
19
- { step: 3, action: "checkout_request", approved: true }
20
- ]);
81
+ ### After
82
+
83
+ ```javascript
84
+ const { ega } = require("ega-v9");
21
85
 
22
- console.log(result.verification);
86
+ app.use(ega.guard());
23
87
  ```
24
88
 
25
- ## Core Concepts
89
+ A verified request proceeds to the protected route. A replay mismatch is fail-closed contained before the protected operation is executed.
90
+
91
+ ------------------------------------------------------------------------
92
+
93
+ ## 4. Quick Start
94
+
95
+ Create a file named `quick-start.cjs`.
96
+
97
+ ```javascript
98
+ const { verifyExecution } = require("ega-v9");
26
99
 
27
- - Deterministic replay
28
- - Provenance-aware verification
29
- - Trust-state evaluation
30
- - Fail-closed containment
100
+ const workflow = [
101
+ {
102
+ step: 1,
103
+ action: "search_product",
104
+ item: "laptop"
105
+ },
106
+ {
107
+ step: 2,
108
+ action: "select_product",
109
+ quantity: 1
110
+ },
111
+ {
112
+ step: 3,
113
+ action: "checkout_request",
114
+ approved: true
115
+ }
116
+ ];
31
117
 
32
- ## Example Output
118
+ const result = verifyExecution(workflow);
33
119
 
34
- ```json
120
+ console.log({
121
+ status: result.status,
122
+ replayConsistency:
123
+ result.detection.status === "match",
124
+ trustState:
125
+ result.trust.currentTier,
126
+ containmentRequired:
127
+ result.containment.activated &&
128
+ !result.containment.executionAllowed,
129
+ executionAllowed:
130
+ result.containment.executionAllowed
131
+ });
132
+ ```
133
+
134
+ Run:
135
+
136
+ ```bash
137
+ node quick-start.cjs
138
+ ```
139
+
140
+ Expected output:
141
+
142
+ ```text
35
143
  {
36
- "replayConsistency": true,
37
- "trustState": "VERIFIED",
38
- "containmentRequired": false
144
+ status: 'verified',
145
+ replayConsistency: true,
146
+ trustState: 'T1',
147
+ containmentRequired: false,
148
+ executionAllowed: true
39
149
  }
40
150
  ```
41
151
 
42
- ## License
152
+ ---
153
+
154
+ ## 5. Verified Behavior
155
+
156
+ The Quick Start example demonstrates deterministic runtime verification.
157
+
158
+ ```text
159
+ {
160
+ status: 'verified',
161
+ replayConsistency: true,
162
+ trustState: 'T1',
163
+ containmentRequired: false,
164
+ executionAllowed: true
165
+ }
166
+ ```
167
+
168
+ This output demonstrates that:
169
+
170
+ - ✅ Replay consistency is verified.
171
+ - ✅ The workflow remains in Trust State **T1**.
172
+ - ✅ No containment is required.
173
+ - ✅ Execution is allowed.
174
+
175
+ These results were verified using the published EGA V9 Release Candidate package.
176
+
177
+ ------------------------------------------------------------------------
178
+
179
+ ## 6. Reproducing the Paper
180
+
181
+ The complete replication workflow used in the EGA V9 paper is available here:
182
+
183
+ → Detailed guide → **[Reproducing the Paper](docs/REPRODUCING_THE_PAPER.md)**
184
+
185
+ This guide explains how to:
186
+
187
+ - Build the SDK
188
+ - Run the benchmark
189
+ - Regenerate Table 4
190
+ - Execute all publication verification gates
191
+ - Reproduce the paper artifacts
192
+
193
+ ------------------------------------------------------------------------
194
+
195
+ ## 7. Publication Verification
196
+
197
+ The complete publication verification workflow is documented here.
198
+
199
+ Detailed guide → **[Publication Verification](docs/PUBLICATION_VERIFICATION.md)**
200
+
201
+ ------------------------------------------------------------------------
202
+
203
+ ## 8. Runtime Architecture
204
+
205
+ The complete EGA V9 runtime architecture is documented here.
206
+
207
+ Detailed guide → **[Runtime Architecture](docs/RUNTIME_ARCHITECTURE.md)**
208
+
209
+ ------------------------------------------------------------------------
210
+
211
+ ## 9. Repository Structure
212
+
213
+ ``` text
214
+ EGA-V9/
215
+ ├── benchmarks/
216
+ ├── crates/
217
+ ├── dashboard/
218
+ ├── docs/
219
+ ├── packages/sdk-ts/
220
+ ├── paper/generated/
221
+ ├── publication/
222
+ ├── scripts/
223
+ ├── package.json
224
+ ├── SECURITY.md
225
+ ├── LICENSE
226
+ └── README.md
227
+ ```
228
+
229
+ ------------------------------------------------------------------------
230
+
231
+ ## 10. Contact and Collaboration
232
+
233
+ contact@lcm3.com
234
+
235
+ Feedback from researchers, developers, startups, and enterprise
236
+ engineering teams is welcome.
237
+
238
+ ------------------------------------------------------------------------
239
+
240
+ ## 11. License
241
+
242
+ Released under the MIT License.
243
+
244
+ ------------------------------------------------------------------------
245
+
246
+ ## 12. Roadmap
247
+
248
+ Current development:
249
+
250
+ - Complete README replication guide
251
+ - Finalize SDK
252
+ - Finalize benchmark reproducibility
253
+ - Finalize Stage E
254
+ - Release v1.0.0
255
+
256
+ ------------------------------------------------------------------------
257
+
258
+ ## Release Integrity Principle
43
259
 
44
- MIT
260
+ > Do not trust a published result merely because it appears in a paper.
261
+ > Reproduce the benchmark, regenerate the publication artifact, and
262
+ > verify the release gates.
@@ -0,0 +1,188 @@
1
+ export type EGATrustLevel = "supported" | "verified";
2
+ export type EGAStatus = "verified" | "contained" | "failed";
3
+ export type EGADetectionStatus = "match" | "mismatch";
4
+ export type EGAContainmentMode = "observe" | "fail-closed";
5
+ export type EGATrustTier = "T1" | "T2" | "T3" | "T4";
6
+ export type EGAEventType = "workflow.started" | "workflow.verified" | "replay.mismatch" | "hash.verified" | "mutation.detected" | "containment.activated" | "execution.blocked" | "quarantine.created" | "lineage.reconstructed" | "business.metrics.collected" | "trust.evaluated" | "trust.escalated" | "approval.required" | "privilege.escalation.gated" | "mitre.mapped" | "eventbus.event.recorded";
7
+ export type EGAClientIdentity = {
8
+ anonymousClientId: string;
9
+ source: "host-header" | "unknown";
10
+ domainHint?: string;
11
+ };
12
+ export type EGALicenseState = {
13
+ mode: "alpha" | "enterprise";
14
+ status: "active" | "grace" | "suspended" | "expired";
15
+ enforcement: "disabled" | "observe" | "warn" | "protect" | "block";
16
+ reason: string;
17
+ };
18
+ export type EGAMitreAtlasMapping = {
19
+ mapped: boolean;
20
+ attackType: string;
21
+ atlasTechnique: string;
22
+ attackTechnique: string;
23
+ severity: "none" | "low" | "medium" | "high" | "critical";
24
+ reason: string;
25
+ };
26
+ export type EGAEvent = {
27
+ id: string;
28
+ sequence: number;
29
+ type: EGAEventType;
30
+ timestamp: string;
31
+ requestId: string;
32
+ replayRoot: string;
33
+ trustLevel: EGATrustLevel;
34
+ status: EGAStatus;
35
+ clientIdentity?: EGAClientIdentity;
36
+ licenseState?: EGALicenseState;
37
+ details?: Record<string, unknown>;
38
+ };
39
+ export type EGAEventSummary = {
40
+ total: number;
41
+ byType: Record<string, number>;
42
+ latest?: EGAEvent;
43
+ };
44
+ export type EGABusinessMetrics = {
45
+ detected: boolean;
46
+ amount?: number;
47
+ price?: number;
48
+ quantity?: number;
49
+ currency?: string;
50
+ estimatedTransactionValue?: number;
51
+ };
52
+ export type EGABusinessTrustProfile = {
53
+ currentTier: EGATrustTier;
54
+ riskScore: number;
55
+ approvalRequired: boolean;
56
+ privilegeEscalationGate: boolean;
57
+ reason: string;
58
+ };
59
+ export type EGABusinessGovernanceProfile = {
60
+ metrics: EGABusinessMetrics;
61
+ trust: EGABusinessTrustProfile;
62
+ };
63
+ export type EGAProvenanceNodeType = "input" | "tool_output" | "policy" | "decision" | "business_metrics" | "trust_escalation";
64
+ export type EGAProvenanceNode = {
65
+ id: string;
66
+ type: EGAProvenanceNodeType;
67
+ label: string;
68
+ data: Record<string, unknown>;
69
+ };
70
+ export type EGAProvenanceEdge = {
71
+ from: string;
72
+ to: string;
73
+ label: string;
74
+ };
75
+ export type EGAProvenanceGraph = {
76
+ graphId: string;
77
+ lineage: string[];
78
+ nodes: EGAProvenanceNode[];
79
+ edges: EGAProvenanceEdge[];
80
+ businessMetrics: EGABusinessMetrics;
81
+ businessGovernanceProfile: EGABusinessGovernanceProfile;
82
+ };
83
+ export type EGARequestContext = {
84
+ requestId: string;
85
+ replayRoot: string;
86
+ trustLevel: EGATrustLevel;
87
+ status: EGAStatus;
88
+ scorpLock: boolean;
89
+ clientIdentity: EGAClientIdentity;
90
+ licenseState: EGALicenseState;
91
+ mitreMapping: EGAMitreAtlasMapping;
92
+ detection: {
93
+ status: EGADetectionStatus;
94
+ expectedReplayRoot?: string;
95
+ actualReplayRoot: string;
96
+ };
97
+ containment: {
98
+ activated: boolean;
99
+ mode: EGAContainmentMode;
100
+ reason?: string;
101
+ quarantineId?: string;
102
+ executionAllowed: boolean;
103
+ };
104
+ trust: EGABusinessTrustProfile;
105
+ businessGovernanceProfile: EGABusinessGovernanceProfile;
106
+ provenance: EGAProvenanceGraph;
107
+ };
108
+ export type EGAGuardDecision = {
109
+ verified: boolean;
110
+ containmentRequired: boolean;
111
+ executionAllowed: boolean;
112
+ trustState: EGATrustTier;
113
+ reason: string | null;
114
+ latencyMicroseconds: number;
115
+ verification: EGARequestContext;
116
+ };
117
+ export type EGAGuardRequest = {
118
+ method?: string;
119
+ originalUrl?: string;
120
+ url?: string;
121
+ path?: string;
122
+ body?: unknown;
123
+ query?: unknown;
124
+ params?: unknown;
125
+ headers?: Record<string, unknown>;
126
+ egaWorkflow?: unknown;
127
+ ega?: EGARequestContext;
128
+ egaDecision?: EGAGuardDecision;
129
+ };
130
+ export type EGAGuardResponse = {
131
+ statusCode?: number;
132
+ setHeader?: (name: string, value: string) => void;
133
+ status?: (code: number) => EGAGuardResponse;
134
+ json?: (body: unknown) => void;
135
+ };
136
+ export type EGAGuardNext = (error?: unknown) => void;
137
+ export type EGAWorkflowResolver = (req: EGAGuardRequest) => unknown | Promise<unknown>;
138
+ export type EGAGuardOptions = {
139
+ mode?: "observe" | "fail-closed";
140
+ statusCode?: number;
141
+ policyId?: string;
142
+ resolveWorkflow?: EGAWorkflowResolver;
143
+ onVerified?: (decision: EGAGuardDecision) => void | Promise<void>;
144
+ onContained?: (decision: EGAGuardDecision) => void | Promise<void>;
145
+ };
146
+ export type EGAOptions = {
147
+ appName?: string;
148
+ trustLevel?: EGATrustLevel;
149
+ telemetry?: boolean;
150
+ failClosed?: boolean;
151
+ policyId?: string;
152
+ approvalThreshold?: number;
153
+ };
154
+ type NextFunction = EGAGuardNext;
155
+ type EGARequest = EGAGuardRequest;
156
+ type EGAResponse = EGAGuardResponse;
157
+ export declare class EGA {
158
+ private readonly options;
159
+ private readonly eventLog;
160
+ private eventSequence;
161
+ private constructor();
162
+ static init(options?: EGAOptions): EGA;
163
+ guard(): (req: EGARequest, res: EGAResponse, next: NextFunction) => void;
164
+ events(type?: EGAEventType): EGAEvent[];
165
+ latestEvents(limit?: number): EGAEvent[];
166
+ eventSummary(): EGAEventSummary;
167
+ explain(context?: EGARequestContext): EGAProvenanceGraph | undefined;
168
+ canonicalize(input: unknown): string;
169
+ replayRoot(input: unknown): string;
170
+ detect(input: unknown, expectedReplayRoot?: string): {
171
+ status: "match" | "mismatch";
172
+ expectedReplayRoot: string | undefined;
173
+ actualReplayRoot: string;
174
+ };
175
+ private createReplayRoot;
176
+ private buildProvenanceGraph;
177
+ private getExpectedReplayRoot;
178
+ private recordEvent;
179
+ }
180
+ export declare function verifyExecution(input: unknown): EGARequestContext;
181
+ export declare function replay(input: unknown): EGARequestContext;
182
+ export declare function provenance(input: unknown): EGARequestContext;
183
+ export declare function contain(input: unknown): EGARequestContext;
184
+ declare function createGuard(options?: EGAGuardOptions): (req: EGAGuardRequest, res: EGAGuardResponse, next: EGAGuardNext) => Promise<void>;
185
+ export declare const ega: Readonly<{
186
+ guard: typeof createGuard;
187
+ }>;
188
+ export {};