@healflow/shared 0.1.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 (53) hide show
  1. package/dist/circuit-breaker.d.ts +23 -0
  2. package/dist/circuit-breaker.d.ts.map +1 -0
  3. package/dist/circuit-breaker.js +75 -0
  4. package/dist/circuit-breaker.js.map +1 -0
  5. package/dist/config-index.d.ts +3 -0
  6. package/dist/config-index.d.ts.map +1 -0
  7. package/dist/config-index.js +19 -0
  8. package/dist/config-index.js.map +1 -0
  9. package/dist/config-loader.d.ts +5 -0
  10. package/dist/config-loader.d.ts.map +1 -0
  11. package/dist/config-loader.js +140 -0
  12. package/dist/config-loader.js.map +1 -0
  13. package/dist/config.d.ts +74 -0
  14. package/dist/config.d.ts.map +1 -0
  15. package/dist/config.js +74 -0
  16. package/dist/config.js.map +1 -0
  17. package/dist/contracts/index.d.ts +204 -0
  18. package/dist/contracts/index.d.ts.map +1 -0
  19. package/dist/contracts/index.js +3 -0
  20. package/dist/contracts/index.js.map +1 -0
  21. package/dist/domain.d.ts +319 -0
  22. package/dist/domain.d.ts.map +1 -0
  23. package/dist/domain.js +3 -0
  24. package/dist/domain.js.map +1 -0
  25. package/dist/enums.d.ts +122 -0
  26. package/dist/enums.d.ts.map +1 -0
  27. package/dist/enums.js +147 -0
  28. package/dist/enums.js.map +1 -0
  29. package/dist/events/index.d.ts +113 -0
  30. package/dist/events/index.d.ts.map +1 -0
  31. package/dist/events/index.js +28 -0
  32. package/dist/events/index.js.map +1 -0
  33. package/dist/healing-rules.d.ts +18 -0
  34. package/dist/healing-rules.d.ts.map +1 -0
  35. package/dist/healing-rules.js +118 -0
  36. package/dist/healing-rules.js.map +1 -0
  37. package/dist/index.d.ts +10 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +26 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/organization-settings.d.ts +4 -0
  42. package/dist/organization-settings.d.ts.map +1 -0
  43. package/dist/organization-settings.js +28 -0
  44. package/dist/organization-settings.js.map +1 -0
  45. package/dist/policy.d.ts +14 -0
  46. package/dist/policy.d.ts.map +1 -0
  47. package/dist/policy.js +68 -0
  48. package/dist/policy.js.map +1 -0
  49. package/dist/policy.test.d.ts +2 -0
  50. package/dist/policy.test.d.ts.map +1 -0
  51. package/dist/policy.test.js +43 -0
  52. package/dist/policy.test.js.map +1 -0
  53. package/package.json +47 -0
@@ -0,0 +1,113 @@
1
+ import type { ClassificationResult, FailureEvent, Fix, HealingPlan, PullRequestRecord, RootCause, ValidationRun } from '../domain.js';
2
+ import type { FailureCategory, HealingStrategyType } from '../enums.js';
3
+ /** Base event envelope for BullMQ / internal pub-sub */
4
+ export interface HealFlowEvent<T extends string, P> {
5
+ eventId: string;
6
+ eventType: T;
7
+ version: '1.0';
8
+ timestamp: string;
9
+ organizationId: string;
10
+ repositoryId: string;
11
+ correlationId: string;
12
+ payload: P;
13
+ }
14
+ export type FailureIngestedEvent = HealFlowEvent<'failure.ingested', {
15
+ failure: FailureEvent;
16
+ }>;
17
+ export type ReportUploadedEvent = HealFlowEvent<'report.uploaded', {
18
+ reportPath: string;
19
+ format: 'html' | 'json' | 'junit';
20
+ failureCount: number;
21
+ }>;
22
+ export type CiFailureReceivedEvent = HealFlowEvent<'ci.failure.received', {
23
+ ciRunId: string;
24
+ jobName: string;
25
+ logUrl: string;
26
+ failureCount: number;
27
+ }>;
28
+ export type FailureClassifiedEvent = HealFlowEvent<'failure.classified', {
29
+ failureId: string;
30
+ classification: ClassificationResult;
31
+ }>;
32
+ export type RootCauseIdentifiedEvent = HealFlowEvent<'root_cause.identified', {
33
+ rootCause: RootCause;
34
+ }>;
35
+ export type FailuresGroupedEvent = HealFlowEvent<'failures.grouped', {
36
+ rootCauseId: string;
37
+ failureIds: string[];
38
+ deduplicationKey: string;
39
+ }>;
40
+ export type HealingPlanCreatedEvent = HealFlowEvent<'healing.plan.created', {
41
+ plan: HealingPlan;
42
+ }>;
43
+ export type FixGeneratedEvent = HealFlowEvent<'fix.generated', {
44
+ fix: Fix;
45
+ diff: string;
46
+ }>;
47
+ export type FixAppliedEvent = HealFlowEvent<'fix.applied', {
48
+ fixId: string;
49
+ changedFiles: string[];
50
+ }>;
51
+ export type RuntimeHealAttemptedEvent = HealFlowEvent<'runtime.heal.attempted', {
52
+ testFile: string;
53
+ testTitle: string;
54
+ category: FailureCategory;
55
+ strategy: HealingStrategyType;
56
+ success: boolean;
57
+ confidence: number;
58
+ }>;
59
+ export type ValidationStartedEvent = HealFlowEvent<'validation.started', {
60
+ validationId: string;
61
+ fixId: string;
62
+ impactedTests: string[];
63
+ }>;
64
+ export type ValidationCompletedEvent = HealFlowEvent<'validation.completed', {
65
+ validation: ValidationRun;
66
+ }>;
67
+ export type ValidationFailedEvent = HealFlowEvent<'validation.failed', {
68
+ validationId: string;
69
+ fixId: string;
70
+ reason: string;
71
+ regressionDetected: boolean;
72
+ }>;
73
+ export type PrCreatedEvent = HealFlowEvent<'pr.created', {
74
+ pr: PullRequestRecord;
75
+ }>;
76
+ export type PrMergedEvent = HealFlowEvent<'pr.merged', {
77
+ prId: string;
78
+ externalPrNumber: number;
79
+ }>;
80
+ export type LearningUpdatedEvent = HealFlowEvent<'learning.updated', {
81
+ category: FailureCategory;
82
+ strategy: HealingStrategyType;
83
+ success: boolean;
84
+ confidenceDelta: number;
85
+ }>;
86
+ export type HealFlowEventUnion = FailureIngestedEvent | ReportUploadedEvent | CiFailureReceivedEvent | FailureClassifiedEvent | RootCauseIdentifiedEvent | FailuresGroupedEvent | HealingPlanCreatedEvent | FixGeneratedEvent | FixAppliedEvent | RuntimeHealAttemptedEvent | ValidationStartedEvent | ValidationCompletedEvent | ValidationFailedEvent | PrCreatedEvent | PrMergedEvent | LearningUpdatedEvent;
87
+ /** BullMQ queue names (no colons — BullMQ 5.x rejects ":" in queue names) */
88
+ export declare const QUEUE_NAMES: {
89
+ readonly INGESTION: "healflow-ingestion";
90
+ readonly CLASSIFICATION: "healflow-classification";
91
+ readonly ROOT_CAUSE: "healflow-root-cause";
92
+ readonly HEALING: "healflow-healing";
93
+ readonly VALIDATION: "healflow-validation";
94
+ readonly PR: "healflow-pr";
95
+ readonly LEARNING: "healflow-learning";
96
+ readonly INDEXING: "healflow-indexing";
97
+ readonly INTELLIGENCE: "healflow-intelligence";
98
+ };
99
+ export type QueueName = (typeof QUEUE_NAMES)[keyof typeof QUEUE_NAMES];
100
+ /** Dead-letter queues — one per worker queue above */
101
+ export declare const DLQ_QUEUE_NAMES: {
102
+ readonly INGESTION: "healflow-ingestion-dlq";
103
+ readonly CLASSIFICATION: "healflow-classification-dlq";
104
+ readonly ROOT_CAUSE: "healflow-root-cause-dlq";
105
+ readonly HEALING: "healflow-healing-dlq";
106
+ readonly VALIDATION: "healflow-validation-dlq";
107
+ readonly PR: "healflow-pr-dlq";
108
+ readonly LEARNING: "healflow-learning-dlq";
109
+ readonly INDEXING: "healflow-indexing-dlq";
110
+ readonly INTELLIGENCE: "healflow-intelligence-dlq";
111
+ };
112
+ export type DlqQueueName = (typeof DLQ_QUEUE_NAMES)[keyof typeof DLQ_QUEUE_NAMES];
113
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,GAAG,EACH,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAExE,wDAAwD;AACxD,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,CAAC,CAAC;IACb,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;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E,eAAe,CAAC;IAC1B,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;CACzB,CACF,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAC1B,oBAAoB,GACpB,mBAAmB,GACnB,sBAAsB,GACtB,sBAAsB,GACtB,wBAAwB,GACxB,oBAAoB,GACpB,uBAAuB,GACvB,iBAAiB,GACjB,eAAe,GACf,yBAAyB,GACzB,sBAAsB,GACtB,wBAAwB,GACxB,qBAAqB,GACrB,cAAc,GACd,aAAa,GACb,oBAAoB,CAAC;AAEzB,6EAA6E;AAC7E,eAAO,MAAM,WAAW;;;;;;;;;;CAUd,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEvE,sDAAsD;AACtD,eAAO,MAAM,eAAe;;;;;;;;;;CAUlB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DLQ_QUEUE_NAMES = exports.QUEUE_NAMES = void 0;
4
+ /** BullMQ queue names (no colons — BullMQ 5.x rejects ":" in queue names) */
5
+ exports.QUEUE_NAMES = {
6
+ INGESTION: 'healflow-ingestion',
7
+ CLASSIFICATION: 'healflow-classification',
8
+ ROOT_CAUSE: 'healflow-root-cause',
9
+ HEALING: 'healflow-healing',
10
+ VALIDATION: 'healflow-validation',
11
+ PR: 'healflow-pr',
12
+ LEARNING: 'healflow-learning',
13
+ INDEXING: 'healflow-indexing',
14
+ INTELLIGENCE: 'healflow-intelligence',
15
+ };
16
+ /** Dead-letter queues — one per worker queue above */
17
+ exports.DLQ_QUEUE_NAMES = {
18
+ INGESTION: 'healflow-ingestion-dlq',
19
+ CLASSIFICATION: 'healflow-classification-dlq',
20
+ ROOT_CAUSE: 'healflow-root-cause-dlq',
21
+ HEALING: 'healflow-healing-dlq',
22
+ VALIDATION: 'healflow-validation-dlq',
23
+ PR: 'healflow-pr-dlq',
24
+ LEARNING: 'healflow-learning-dlq',
25
+ INDEXING: 'healflow-indexing-dlq',
26
+ INTELLIGENCE: 'healflow-intelligence-dlq',
27
+ };
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":";;;AAoIA,6EAA6E;AAChE,QAAA,WAAW,GAAG;IACzB,SAAS,EAAE,oBAAoB;IAC/B,cAAc,EAAE,yBAAyB;IACzC,UAAU,EAAE,qBAAqB;IACjC,OAAO,EAAE,kBAAkB;IAC3B,UAAU,EAAE,qBAAqB;IACjC,EAAE,EAAE,aAAa;IACjB,QAAQ,EAAE,mBAAmB;IAC7B,QAAQ,EAAE,mBAAmB;IAC7B,YAAY,EAAE,uBAAuB;CAC7B,CAAC;AAIX,sDAAsD;AACzC,QAAA,eAAe,GAAG;IAC7B,SAAS,EAAE,wBAAwB;IACnC,cAAc,EAAE,6BAA6B;IAC7C,UAAU,EAAE,yBAAyB;IACrC,OAAO,EAAE,sBAAsB;IAC/B,UAAU,EAAE,yBAAyB;IACrC,EAAE,EAAE,iBAAiB;IACrB,QAAQ,EAAE,uBAAuB;IACjC,QAAQ,EAAE,uBAAuB;IACjC,YAAY,EAAE,2BAA2B;CACjC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { OrganizationSettings } from './domain.js';
2
+ import type { FailureCategory, HealingStrategyType } from './enums.js';
3
+ export interface HealingPolicyContext {
4
+ category: FailureCategory;
5
+ strategy?: HealingStrategyType;
6
+ testFile: string;
7
+ testTitle?: string;
8
+ confidence: number;
9
+ }
10
+ export interface HealingPolicyResult {
11
+ allowed: boolean;
12
+ adjustedConfidence: number;
13
+ reason?: string;
14
+ matchedRuleId?: string;
15
+ matchedRuleName?: string;
16
+ }
17
+ export declare function evaluateHealingPolicy(ctx: HealingPolicyContext, settings: OrganizationSettings): HealingPolicyResult;
18
+ //# sourceMappingURL=healing-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"healing-rules.d.ts","sourceRoot":"","sources":["../src/healing-rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AA0DD,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,oBAAoB,EACzB,QAAQ,EAAE,oBAAoB,GAC7B,mBAAmB,CAoErB"}
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.evaluateHealingPolicy = evaluateHealingPolicy;
4
+ function pathMatchesPattern(target, pattern) {
5
+ if (pattern.includes('*')) {
6
+ const regex = new RegExp(`^${pattern.replace(/\*/g, '.*').replace(/\//g, '\\/')}$`);
7
+ return regex.test(target);
8
+ }
9
+ return target.includes(pattern);
10
+ }
11
+ function ruleMatches(rule, ctx) {
12
+ if (!rule.enabled)
13
+ return false;
14
+ if (rule.category && rule.category !== ctx.category)
15
+ return false;
16
+ if (rule.strategy && rule.strategy !== ctx.strategy)
17
+ return false;
18
+ if (rule.matchPattern) {
19
+ const haystack = `${ctx.testFile} ${ctx.testTitle ?? ''}`.trim();
20
+ if (!pathMatchesPattern(haystack, rule.matchPattern))
21
+ return false;
22
+ }
23
+ return true;
24
+ }
25
+ function applyRuleAction(rule, current) {
26
+ switch (rule.action) {
27
+ case 'deny':
28
+ return {
29
+ allowed: false,
30
+ adjustedConfidence: current.adjustedConfidence,
31
+ reason: `Blocked by healing rule "${rule.name}"`,
32
+ matchedRuleId: rule.id,
33
+ matchedRuleName: rule.name,
34
+ };
35
+ case 'allow':
36
+ return {
37
+ allowed: true,
38
+ adjustedConfidence: current.adjustedConfidence,
39
+ reason: `Allowed by healing rule "${rule.name}"`,
40
+ matchedRuleId: rule.id,
41
+ matchedRuleName: rule.name,
42
+ };
43
+ case 'boost_confidence': {
44
+ const delta = rule.confidenceDelta ?? 0.05;
45
+ return {
46
+ ...current,
47
+ adjustedConfidence: Math.min(current.adjustedConfidence + delta, 0.99),
48
+ matchedRuleId: rule.id,
49
+ matchedRuleName: rule.name,
50
+ };
51
+ }
52
+ default: {
53
+ const _exhaustive = rule.action;
54
+ return _exhaustive;
55
+ }
56
+ }
57
+ }
58
+ function evaluateHealingPolicy(ctx, settings) {
59
+ let result = {
60
+ allowed: true,
61
+ adjustedConfidence: ctx.confidence,
62
+ };
63
+ if (!settings.autoHealEnabled) {
64
+ return {
65
+ allowed: false,
66
+ adjustedConfidence: ctx.confidence,
67
+ reason: 'Auto-heal is disabled for this organization',
68
+ };
69
+ }
70
+ if (!settings.allowedFixCategories.includes(ctx.category)) {
71
+ return {
72
+ allowed: false,
73
+ adjustedConfidence: ctx.confidence,
74
+ reason: `Category ${ctx.category} is not allowed for automated healing`,
75
+ };
76
+ }
77
+ for (const blockedPath of settings.blockedPaths) {
78
+ if (pathMatchesPattern(ctx.testFile, blockedPath)) {
79
+ return {
80
+ allowed: false,
81
+ adjustedConfidence: ctx.confidence,
82
+ reason: `Test path matches blocked pattern "${blockedPath}"`,
83
+ };
84
+ }
85
+ }
86
+ const rules = [...(settings.healingRules ?? [])].sort((a, b) => a.priority - b.priority);
87
+ let explicitlyAllowed = false;
88
+ for (const rule of rules) {
89
+ if (!ruleMatches(rule, ctx))
90
+ continue;
91
+ const next = applyRuleAction(rule, result);
92
+ result = next;
93
+ if (rule.action === 'deny') {
94
+ return result;
95
+ }
96
+ if (rule.action === 'allow') {
97
+ explicitlyAllowed = true;
98
+ }
99
+ }
100
+ const threshold = settings.minConfidenceThreshold ?? 0.75;
101
+ if (!explicitlyAllowed && result.adjustedConfidence < threshold) {
102
+ return {
103
+ allowed: false,
104
+ adjustedConfidence: result.adjustedConfidence,
105
+ reason: `Confidence ${result.adjustedConfidence.toFixed(2)} is below threshold ${threshold}`,
106
+ matchedRuleId: result.matchedRuleId,
107
+ matchedRuleName: result.matchedRuleName,
108
+ };
109
+ }
110
+ return {
111
+ allowed: result.allowed,
112
+ adjustedConfidence: result.adjustedConfidence,
113
+ reason: result.reason,
114
+ matchedRuleId: result.matchedRuleId,
115
+ matchedRuleName: result.matchedRuleName,
116
+ };
117
+ }
118
+ //# sourceMappingURL=healing-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"healing-rules.js","sourceRoot":"","sources":["../src/healing-rules.ts"],"names":[],"mappings":";;AA2EA,sDAuEC;AA/HD,SAAS,kBAAkB,CAAC,MAAc,EAAE,OAAe;IACzD,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QACpF,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAED,SAA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QACnC,eAAe,EAAE,MAAM,CAAC,eAAe;KACxC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ export * from './enums.js';
2
+ export * from './domain.js';
3
+ export * from './policy.js';
4
+ export * from './organization-settings.js';
5
+ export * from './healing-rules.js';
6
+ export * from './config.js';
7
+ export * from './circuit-breaker.js';
8
+ export * from './events/index.js';
9
+ export * from './contracts/index.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
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("./enums.js"), exports);
18
+ __exportStar(require("./domain.js"), exports);
19
+ __exportStar(require("./policy.js"), exports);
20
+ __exportStar(require("./organization-settings.js"), exports);
21
+ __exportStar(require("./healing-rules.js"), exports);
22
+ __exportStar(require("./config.js"), exports);
23
+ __exportStar(require("./circuit-breaker.js"), exports);
24
+ __exportStar(require("./events/index.js"), exports);
25
+ __exportStar(require("./contracts/index.js"), exports);
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B;AAC5B,8CAA4B;AAC5B,6DAA2C;AAC3C,qDAAmC;AACnC,8CAA4B;AAC5B,uDAAqC;AACrC,oDAAkC;AAClC,uDAAqC"}
@@ -0,0 +1,4 @@
1
+ import type { OrganizationSettings } from './domain.js';
2
+ export declare const DEFAULT_ORGANIZATION_SETTINGS: OrganizationSettings;
3
+ export declare function normalizeOrganizationSettings(raw: unknown): OrganizationSettings;
4
+ //# sourceMappingURL=organization-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization-settings.d.ts","sourceRoot":"","sources":["../src/organization-settings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,eAAO,MAAM,6BAA6B,EAAE,oBAY3C,CAAC;AAEF,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,GAAG,oBAAoB,CAWhF"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_ORGANIZATION_SETTINGS = void 0;
4
+ exports.normalizeOrganizationSettings = normalizeOrganizationSettings;
5
+ const enums_js_1 = require("./enums.js");
6
+ exports.DEFAULT_ORGANIZATION_SETTINGS = {
7
+ prMode: enums_js_1.PrMode.DRAFT_PR,
8
+ prGroupingStrategy: enums_js_1.PrGroupingStrategy.ROOT_CAUSE,
9
+ validationRunsRequired: 3,
10
+ autoHealEnabled: true,
11
+ allowedFixCategories: [enums_js_1.FailureCategory.SELECTOR, enums_js_1.FailureCategory.TIMING, enums_js_1.FailureCategory.OVERLAY],
12
+ blockedPaths: [],
13
+ healingRules: [],
14
+ minConfidenceThreshold: 0.75,
15
+ hourlyEngineerRate: 85,
16
+ hoursPerHealEstimate: 0.5,
17
+ hoursPerPrEstimate: 1,
18
+ };
19
+ function normalizeOrganizationSettings(raw) {
20
+ const value = typeof raw === 'object' && raw !== null ? raw : {};
21
+ return {
22
+ ...exports.DEFAULT_ORGANIZATION_SETTINGS,
23
+ ...value,
24
+ healingRules: value.healingRules ?? [],
25
+ minConfidenceThreshold: value.minConfidenceThreshold ?? exports.DEFAULT_ORGANIZATION_SETTINGS.minConfidenceThreshold,
26
+ };
27
+ }
28
+ //# sourceMappingURL=organization-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization-settings.js","sourceRoot":"","sources":["../src/organization-settings.ts"],"names":[],"mappings":";;;AAiBA,sEAWC;AA5BD,yCAAyE;AAG5D,QAAA,6BAA6B,GAAyB;IACjE,MAAM,EAAE,iBAAM,CAAC,QAAQ;IACvB,kBAAkB,EAAE,6BAAkB,CAAC,UAAU;IACjD,sBAAsB,EAAE,CAAC;IACzB,eAAe,EAAE,IAAI;IACrB,oBAAoB,EAAE,CAAC,0BAAe,CAAC,QAAQ,EAAE,0BAAe,CAAC,MAAM,EAAE,0BAAe,CAAC,OAAO,CAAC;IACjG,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,EAAE;IAChB,sBAAsB,EAAE,IAAI;IAC5B,kBAAkB,EAAE,EAAE;IACtB,oBAAoB,EAAE,GAAG;IACzB,kBAAkB,EAAE,CAAC;CACtB,CAAC;AAEF,SAAgB,6BAA6B,CAAC,GAAY;IACxD,MAAM,KAAK,GACT,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,CAAC,CAAC,CAAE,GAAqC,CAAC,CAAC,CAAC,EAAE,CAAC;IAExF,OAAO;QACL,GAAG,qCAA6B;QAChC,GAAG,KAAK;QACR,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,EAAE;QACtC,sBAAsB,EACpB,KAAK,CAAC,sBAAsB,IAAI,qCAA6B,CAAC,sBAAsB;KACvF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { FailureCategory, HealOutcome, RecommendedAction } from './enums.js';
2
+ import type { ClassificationResult } from './domain.js';
3
+ /** Categories safe for automated healing (runtime + AST). Phase 2 expands list. */
4
+ export declare const AUTOMATION_FIXABLE_CATEGORIES: ReadonlySet<FailureCategory>;
5
+ /** Classify only — report diagnostics, never auto-fix */
6
+ export declare const DIAGNOSE_ONLY_CATEGORIES: ReadonlySet<FailureCategory>;
7
+ /** Never auto-fix — product or infrastructure incidents */
8
+ export declare const BLOCKED_CATEGORIES: ReadonlySet<FailureCategory>;
9
+ export declare function isCategoryAutomationFixable(category: FailureCategory): boolean;
10
+ export declare function resolveFailureOutcome(classification: Pick<ClassificationResult, 'category' | 'isProductBug' | 'isAutomationFixable' | 'confidence'>): {
11
+ outcome: HealOutcome;
12
+ recommendedAction: RecommendedAction;
13
+ };
14
+ //# sourceMappingURL=policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,mFAAmF;AACnF,eAAO,MAAM,6BAA6B,EAAE,WAAW,CAAC,eAAe,CAQrE,CAAC;AAEH,yDAAyD;AACzD,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,eAAe,CAMhE,CAAC;AAEH,2DAA2D;AAC3D,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,eAAe,CAG1D,CAAC;AAEH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAE9E;AAED,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,IAAI,CAClB,oBAAoB,EACpB,UAAU,GAAG,cAAc,GAAG,qBAAqB,GAAG,YAAY,CACnE,GACA;IAAE,OAAO,EAAE,WAAW,CAAC;IAAC,iBAAiB,EAAE,iBAAiB,CAAA;CAAE,CAsChE"}
package/dist/policy.js ADDED
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BLOCKED_CATEGORIES = exports.DIAGNOSE_ONLY_CATEGORIES = exports.AUTOMATION_FIXABLE_CATEGORIES = void 0;
4
+ exports.isCategoryAutomationFixable = isCategoryAutomationFixable;
5
+ exports.resolveFailureOutcome = resolveFailureOutcome;
6
+ const enums_js_1 = require("./enums.js");
7
+ /** Categories safe for automated healing (runtime + AST). Phase 2 expands list. */
8
+ exports.AUTOMATION_FIXABLE_CATEGORIES = new Set([
9
+ enums_js_1.FailureCategory.SELECTOR,
10
+ enums_js_1.FailureCategory.TIMING,
11
+ enums_js_1.FailureCategory.OVERLAY,
12
+ enums_js_1.FailureCategory.IFRAME,
13
+ enums_js_1.FailureCategory.SHADOW_DOM,
14
+ enums_js_1.FailureCategory.AUTH,
15
+ enums_js_1.FailureCategory.SESSION,
16
+ ]);
17
+ /** Classify only — report diagnostics, never auto-fix */
18
+ exports.DIAGNOSE_ONLY_CATEGORIES = new Set([
19
+ enums_js_1.FailureCategory.TEST_DATA,
20
+ enums_js_1.FailureCategory.CONFIGURATION,
21
+ enums_js_1.FailureCategory.NETWORK,
22
+ enums_js_1.FailureCategory.API,
23
+ enums_js_1.FailureCategory.ENVIRONMENT,
24
+ ]);
25
+ /** Never auto-fix — product or infrastructure incidents */
26
+ exports.BLOCKED_CATEGORIES = new Set([
27
+ enums_js_1.FailureCategory.PRODUCT_BUG,
28
+ enums_js_1.FailureCategory.UNKNOWN,
29
+ ]);
30
+ function isCategoryAutomationFixable(category) {
31
+ return exports.AUTOMATION_FIXABLE_CATEGORIES.has(category);
32
+ }
33
+ function resolveFailureOutcome(classification) {
34
+ if (classification.isProductBug || exports.BLOCKED_CATEGORIES.has(classification.category)) {
35
+ return {
36
+ outcome: enums_js_1.HealOutcome.BLOCKED,
37
+ recommendedAction: classification.isProductBug
38
+ ? enums_js_1.RecommendedAction.INVESTIGATE_PRODUCT
39
+ : enums_js_1.RecommendedAction.MANUAL_FIX,
40
+ };
41
+ }
42
+ if (exports.DIAGNOSE_ONLY_CATEGORIES.has(classification.category)) {
43
+ const actionMap = {
44
+ [enums_js_1.FailureCategory.NETWORK]: enums_js_1.RecommendedAction.CHECK_ENVIRONMENT,
45
+ [enums_js_1.FailureCategory.API]: enums_js_1.RecommendedAction.INVESTIGATE_PRODUCT,
46
+ [enums_js_1.FailureCategory.ENVIRONMENT]: enums_js_1.RecommendedAction.CHECK_ENVIRONMENT,
47
+ [enums_js_1.FailureCategory.TEST_DATA]: enums_js_1.RecommendedAction.UPDATE_TEST_DATA,
48
+ [enums_js_1.FailureCategory.CONFIGURATION]: enums_js_1.RecommendedAction.MANUAL_FIX,
49
+ };
50
+ return {
51
+ outcome: enums_js_1.HealOutcome.DIAGNOSED,
52
+ recommendedAction: actionMap[classification.category] ?? enums_js_1.RecommendedAction.MANUAL_FIX,
53
+ };
54
+ }
55
+ if (classification.isAutomationFixable && isCategoryAutomationFixable(classification.category)) {
56
+ return {
57
+ outcome: enums_js_1.HealOutcome.HEALED,
58
+ recommendedAction: classification.confidence >= 0.75
59
+ ? enums_js_1.RecommendedAction.AUTO_HEAL
60
+ : enums_js_1.RecommendedAction.RETRY_TEST,
61
+ };
62
+ }
63
+ return {
64
+ outcome: enums_js_1.HealOutcome.DIAGNOSED,
65
+ recommendedAction: enums_js_1.RecommendedAction.MANUAL_FIX,
66
+ };
67
+ }
68
+ //# sourceMappingURL=policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.js","sourceRoot":"","sources":["../src/policy.ts"],"names":[],"mappings":";;;AA6BA,kEAEC;AAED,sDA2CC;AA5ED,yC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AG,CAAC,EAAE,4BAAiB,CAAC,mBAAmB;YAC5D,CAAC,0BAAe,CAAC,WAAW,CAAC,EAAE,4BAAiB,CAAC,iBAAiB;YAClE,CAAC,0BAAe,CAAC,SAAS,CAAC,EAAE,4BAAiB,CAAC,gBAAgB;YAC/D,CAAC,0BAAe,CAAC,aAAa,CAAC,EAAE,4BAAiB,CAAC,UAAU;SAC9D,CAAC;QACF,OAAO;YACL,OAAO,EAAE,sBAAW,CAAC,SAAS;YAC9B,iBAAiB,EAAE,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,4BAAiB,CAAC,UAAU;SACtF,CAAC;IACJ,CAAC;IAED,IAAI,cAAc,CAAC,mBAAmB,IAAI,2BAA2B,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/F,OAAO;YACL,OAAO,EAAE,sBAAW,CAAC,MAAM;YAC3B,iBAAiB,EACf,cAAc,CAAC,UAAU,IAAI,IAAI;gBAC/B,CAAC,CAAC,4BAAiB,CAAC,SAAS;gBAC7B,CAAC,CAAC,4BAAiB,CAAC,UAAU;SACnC,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,sBAAW,CAAC,SAAS;QAC9B,iBAAiB,EAAE,4BAAiB,CAAC,UAAU;KAChD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=policy.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.test.d.ts","sourceRoot":"","sources":["../src/policy.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const shared_1 = require("@healflow/shared");
5
+ const shared_2 = require("@healflow/shared");
6
+ (0, vitest_1.describe)('policy', () => {
7
+ (0, vitest_1.it)('whitelists only automation-safe categories', () => {
8
+ (0, vitest_1.expect)((0, shared_2.isCategoryAutomationFixable)(shared_1.FailureCategory.SELECTOR)).toBe(true);
9
+ (0, vitest_1.expect)((0, shared_2.isCategoryAutomationFixable)(shared_1.FailureCategory.NETWORK)).toBe(false);
10
+ (0, vitest_1.expect)((0, shared_2.isCategoryAutomationFixable)(shared_1.FailureCategory.PRODUCT_BUG)).toBe(false);
11
+ });
12
+ (0, vitest_1.it)('blocks product bugs', () => {
13
+ const result = (0, shared_2.resolveFailureOutcome)({
14
+ category: shared_1.FailureCategory.PRODUCT_BUG,
15
+ isProductBug: true,
16
+ isAutomationFixable: false,
17
+ confidence: 0.9,
18
+ });
19
+ (0, vitest_1.expect)(result.outcome).toBe(shared_1.HealOutcome.BLOCKED);
20
+ (0, vitest_1.expect)(result.recommendedAction).toBe(shared_1.RecommendedAction.INVESTIGATE_PRODUCT);
21
+ });
22
+ (0, vitest_1.it)('diagnoses network failures', () => {
23
+ const result = (0, shared_2.resolveFailureOutcome)({
24
+ category: shared_1.FailureCategory.NETWORK,
25
+ isProductBug: false,
26
+ isAutomationFixable: false,
27
+ confidence: 0.7,
28
+ });
29
+ (0, vitest_1.expect)(result.outcome).toBe(shared_1.HealOutcome.DIAGNOSED);
30
+ (0, vitest_1.expect)(result.recommendedAction).toBe(shared_1.RecommendedAction.CHECK_ENVIRONMENT);
31
+ });
32
+ (0, vitest_1.it)('allows healing for selector failures with confidence', () => {
33
+ const result = (0, shared_2.resolveFailureOutcome)({
34
+ category: shared_1.FailureCategory.SELECTOR,
35
+ isProductBug: false,
36
+ isAutomationFixable: true,
37
+ confidence: 0.85,
38
+ });
39
+ (0, vitest_1.expect)(result.outcome).toBe(shared_1.HealOutcome.HEALED);
40
+ (0, vitest_1.expect)(result.recommendedAction).toBe(shared_1.RecommendedAction.AUTO_HEAL);
41
+ });
42
+ });
43
+ //# sourceMappingURL=policy.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy.test.js","sourceRoot":"","sources":["../src/policy.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,6CAAmF;AAC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AAC,SAAS,CAAC,CAAC;QACnD,IAAA,eAAM,EAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,0BAAiB,CAAC,iBAAiB,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,sDAAsD,EAAE,GAAG,EAAE;QAC9D,MAAM,MAAM,GAAG,IAAA,8BAAqB,EAAC;YACnC,QAAQ,EAAE,wBAAe,CAAC,QAAQ;YAClC,YAAY,EAAE,KAAK;YACnB,mBAAmB,EAAE,IAAI;YACzB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,IAAA,eAAM,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,oBAAW,CAAC,MAAM,CAAC,CAAC;QAChD,IAAA,eAAM,EAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,0BAAiB,CAAC,SAAS,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@healflow/shared",
3
+ "version": "0.1.0",
4
+ "description": "Shared types, events, and contracts for HealFlow",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./events": {
15
+ "types": "./dist/events/index.d.ts",
16
+ "import": "./dist/events/index.js",
17
+ "require": "./dist/events/index.js",
18
+ "default": "./dist/events/index.js"
19
+ },
20
+ "./contracts": {
21
+ "types": "./dist/contracts/index.d.ts",
22
+ "import": "./dist/contracts/index.js",
23
+ "require": "./dist/contracts/index.js",
24
+ "default": "./dist/contracts/index.js"
25
+ },
26
+ "./config": {
27
+ "types": "./dist/config-index.d.ts",
28
+ "import": "./dist/config-index.js",
29
+ "require": "./dist/config-index.js",
30
+ "default": "./dist/config-index.js"
31
+ }
32
+ },
33
+ "devDependencies": {
34
+ "typescript": "^5.7.2"
35
+ },
36
+ "files": [
37
+ "dist"
38
+ ],
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "scripts": {
43
+ "build": "tsc -p tsconfig.json",
44
+ "typecheck": "tsc -p tsconfig.json --noEmit",
45
+ "lint": "echo 'lint ok'"
46
+ }
47
+ }