@wutangbanger/horus-contracts 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.
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @horus/contracts
3
+ *
4
+ * Pure interface definitions shared between production services and test infrastructure.
5
+ * No implementations here — just contracts. Production code depends on this;
6
+ * test-utils implements these interfaces.
7
+ *
8
+ * This separation ensures production services never depend on test code.
9
+ */
10
+ export interface EventPayload {
11
+ topic: string;
12
+ data: unknown;
13
+ timestamp: number;
14
+ correlationId: string;
15
+ }
16
+ export interface IEventBus {
17
+ publish(topic: string, data: unknown, correlationId?: string): Promise<void>;
18
+ subscribe(topic: string, handler: (payload: EventPayload) => void | Promise<void>): void;
19
+ unsubscribeAll(): void;
20
+ }
21
+ /**
22
+ * Categories map to the five AI agents:
23
+ * failure → Felix (triage latest test failures)
24
+ * diff → Percy (review recent test-file diffs)
25
+ * dashboard → Iris (enrich dashboard with insights)
26
+ * flakiness → Greta (analyze flakiness report)
27
+ * coverage → Saxon (analyze coverage summary)
28
+ */
29
+ export type AgentInsightCategory = 'failure' | 'diff' | 'dashboard' | 'flakiness' | 'coverage';
30
+ export type AgentInsightSeverity = 'info' | 'warning' | 'critical';
31
+ export interface AgentInsight {
32
+ /** Unique ID for this insight record */
33
+ id: string;
34
+ /** Which agent produced this insight (e.g. "felix", "saxon") */
35
+ agentId: string;
36
+ /** ISO 8601 timestamp of when the agent ran */
37
+ runAt: string;
38
+ category: AgentInsightCategory;
39
+ severity: AgentInsightSeverity;
40
+ /** One-line human-readable summary shown in the dashboard */
41
+ summary: string;
42
+ /** Full structured output from the agent — shape varies by agent */
43
+ details: unknown;
44
+ }
45
+ export interface IAgentInsightStore {
46
+ append(insight: AgentInsight): Promise<void>;
47
+ readAll(): Promise<AgentInsight[]>;
48
+ readSince(isoTimestamp: string): Promise<AgentInsight[]>;
49
+ readByAgent(agentId: string): Promise<AgentInsight[]>;
50
+ }
51
+ /**
52
+ * One record per individual test per CI run.
53
+ * Accumulated over time to compute flakiness scores.
54
+ */
55
+ export interface TestRunRecord {
56
+ /** Unique ID for this record */
57
+ id: string;
58
+ /** Full test name, e.g. "OrderService > createOrder > given valid request..." */
59
+ testName: string;
60
+ /** Layer: unit | integration | e2e */
61
+ layer: 'unit' | 'integration' | 'e2e';
62
+ /** ISO 8601 timestamp of the run */
63
+ runAt: string;
64
+ /** Whether this test passed in this run */
65
+ passed: boolean;
66
+ /** Execution time in milliseconds */
67
+ durationMs: number;
68
+ /** Number of retries before this result (0 = first attempt) */
69
+ retries: number;
70
+ /** Git commit SHA or 'local' */
71
+ commitSha: string;
72
+ }
73
+ /**
74
+ * Computed flakiness summary for a single test.
75
+ * Derived from a window of TestRunRecords.
76
+ */
77
+ export interface FlakeScore {
78
+ testName: string;
79
+ layer: TestRunRecord['layer'];
80
+ /** Total runs in the analysis window */
81
+ totalRuns: number;
82
+ passCount: number;
83
+ failCount: number;
84
+ /** 0.0 = always passes, 1.0 = always fails */
85
+ flakeRate: number;
86
+ /** Whether the test is considered flaky (0 < flakeRate < 1) */
87
+ isFlaky: boolean;
88
+ /** Whether the test consistently fails (flakeRate === 1) */
89
+ isAlwaysFailing: boolean;
90
+ /** Average duration in ms */
91
+ avgDurationMs: number;
92
+ }
93
+ export interface ITestRunStore {
94
+ append(record: TestRunRecord): Promise<void>;
95
+ readAll(): Promise<TestRunRecord[]>;
96
+ readSince(isoTimestamp: string): Promise<TestRunRecord[]>;
97
+ readByTest(testName: string): Promise<TestRunRecord[]>;
98
+ }
99
+ /**
100
+ * One snapshot per test:coverage run. Accumulated over time to detect drift.
101
+ */
102
+ export interface CoverageSnapshot {
103
+ id: string;
104
+ capturedAt: string;
105
+ commitSha: string;
106
+ /** Percentage values 0–100 */
107
+ lines: number;
108
+ functions: number;
109
+ branches: number;
110
+ statements: number;
111
+ }
112
+ /**
113
+ * Delta between two consecutive CoverageSnapshots.
114
+ * Negative values mean coverage degraded.
115
+ */
116
+ export interface CoverageDelta {
117
+ lines: number;
118
+ functions: number;
119
+ branches: number;
120
+ statements: number;
121
+ /** True if any metric dropped below its configured threshold */
122
+ belowThreshold: boolean;
123
+ }
124
+ export interface HorusConfig {
125
+ /** Directory where all JSONL report files are written. Default: './reports' */
126
+ reportsDir: string;
127
+ /** Git SHA for test run records. Default: process.env.GITHUB_SHA ?? 'local' */
128
+ commitSha?: string;
129
+ /** Coverage thresholds for delta/belowThreshold calculation */
130
+ coverage?: {
131
+ lines: number;
132
+ functions: number;
133
+ branches: number;
134
+ statements: number;
135
+ };
136
+ }
137
+ export interface IRepository<T extends {
138
+ id: string;
139
+ }> {
140
+ findById(id: string): Promise<T | null>;
141
+ findAll(): Promise<T[]>;
142
+ findWhere(predicate: (item: T) => boolean): Promise<T[]>;
143
+ save(entity: T): Promise<T>;
144
+ update(id: string, patch: Partial<T>): Promise<T | null>;
145
+ delete(id: string): Promise<boolean>;
146
+ }
147
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7E,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACzF,cAAc,IAAI,IAAI,CAAC;CACxB;AAID;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAC5B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IACnB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAID,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;IACnD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACxC,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACxB,SAAS,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACzD,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACzD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtC"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @horus/contracts
3
+ *
4
+ * Pure interface definitions shared between production services and test infrastructure.
5
+ * No implementations here — just contracts. Production code depends on this;
6
+ * test-utils implements these interfaces.
7
+ *
8
+ * This separation ensures production services never depend on test code.
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@wutangbanger/horus-contracts",
3
+ "version": "1.0.0",
4
+ "description": "Shared interface contracts for Horus services",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.build.json",
22
+ "clean": "rm -rf dist"
23
+ }
24
+ }