guardrail-core 1.0.0 → 2.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 (74) hide show
  1. package/dist/__tests__/autopilot-enterprise.test.d.ts +7 -0
  2. package/dist/__tests__/autopilot-enterprise.test.d.ts.map +1 -0
  3. package/dist/__tests__/autopilot-enterprise.test.js +334 -0
  4. package/dist/autopilot/autopilot-runner.d.ts +9 -0
  5. package/dist/autopilot/autopilot-runner.d.ts.map +1 -1
  6. package/dist/autopilot/autopilot-runner.js +182 -1
  7. package/dist/autopilot/types.d.ts +18 -2
  8. package/dist/autopilot/types.d.ts.map +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -0
  12. package/dist/smells/index.d.ts +59 -0
  13. package/dist/smells/index.d.ts.map +1 -0
  14. package/dist/smells/index.js +251 -0
  15. package/package.json +19 -2
  16. package/src/__tests__/autopilot.test.ts +0 -196
  17. package/src/__tests__/tier-config.test.ts +0 -289
  18. package/src/__tests__/utils/hash-inline.test.ts +0 -76
  19. package/src/__tests__/utils/hash.test.ts +0 -119
  20. package/src/__tests__/utils/simple.test.ts +0 -10
  21. package/src/__tests__/utils/utils-simple.test.ts +0 -5
  22. package/src/__tests__/utils/utils.test.ts +0 -203
  23. package/src/autopilot/autopilot-runner.ts +0 -503
  24. package/src/autopilot/index.ts +0 -6
  25. package/src/autopilot/types.ts +0 -119
  26. package/src/cache/index.ts +0 -7
  27. package/src/cache/redis-cache.d.ts +0 -155
  28. package/src/cache/redis-cache.d.ts.map +0 -1
  29. package/src/cache/redis-cache.ts +0 -517
  30. package/src/ci/github-actions.ts +0 -335
  31. package/src/ci/index.ts +0 -12
  32. package/src/ci/pre-commit.ts +0 -338
  33. package/src/db/usage-schema.prisma +0 -114
  34. package/src/entitlements.ts +0 -570
  35. package/src/env.d.ts +0 -68
  36. package/src/env.d.ts.map +0 -1
  37. package/src/env.ts +0 -247
  38. package/src/fix-packs/__tests__/generate-fix-packs.test.ts +0 -317
  39. package/src/fix-packs/generate-fix-packs.ts +0 -577
  40. package/src/fix-packs/index.ts +0 -8
  41. package/src/fix-packs/types.ts +0 -206
  42. package/src/index.d.ts +0 -7
  43. package/src/index.d.ts.map +0 -1
  44. package/src/index.ts +0 -12
  45. package/src/metrics/prometheus.d.ts +0 -104
  46. package/src/metrics/prometheus.d.ts.map +0 -1
  47. package/src/metrics/prometheus.ts +0 -446
  48. package/src/quota-ledger.ts +0 -548
  49. package/src/rbac/__tests__/permissions.test.ts +0 -446
  50. package/src/rbac/index.ts +0 -46
  51. package/src/rbac/permissions.ts +0 -301
  52. package/src/rbac/types.ts +0 -298
  53. package/src/tier-config.json +0 -157
  54. package/src/tier-config.ts +0 -815
  55. package/src/types.d.ts +0 -365
  56. package/src/types.d.ts.map +0 -1
  57. package/src/types.ts +0 -441
  58. package/src/utils.d.ts +0 -36
  59. package/src/utils.d.ts.map +0 -1
  60. package/src/utils.ts +0 -140
  61. package/src/verified-autofix/__tests__/format-validator.test.ts +0 -335
  62. package/src/verified-autofix/__tests__/pipeline.test.ts +0 -419
  63. package/src/verified-autofix/__tests__/repo-fingerprint.test.ts +0 -241
  64. package/src/verified-autofix/__tests__/workspace.test.ts +0 -373
  65. package/src/verified-autofix/format-validator.ts +0 -517
  66. package/src/verified-autofix/index.ts +0 -63
  67. package/src/verified-autofix/pipeline.ts +0 -403
  68. package/src/verified-autofix/repo-fingerprint.ts +0 -459
  69. package/src/verified-autofix/workspace.ts +0 -531
  70. package/src/verified-autofix.ts +0 -1187
  71. package/src/visualization/dependency-graph.d.ts +0 -85
  72. package/src/visualization/dependency-graph.d.ts.map +0 -1
  73. package/src/visualization/dependency-graph.ts +0 -495
  74. package/src/visualization/index.ts +0 -5
@@ -1,206 +0,0 @@
1
- /**
2
- * Fix Packs Types
3
- *
4
- * First-class objects that group findings into actionable batches.
5
- * Used by CLI, Autopilot, and Verified AutoFix.
6
- */
7
-
8
- import { Tier } from '../tier-config';
9
-
10
- // ============================================================================
11
- // FINDING CATEGORY ENUM
12
- // ============================================================================
13
-
14
- export const FINDING_CATEGORIES = [
15
- 'secrets',
16
- 'routes',
17
- 'mocks',
18
- 'auth',
19
- 'placeholders',
20
- 'deps',
21
- 'types',
22
- 'tests',
23
- 'security',
24
- 'performance',
25
- ] as const;
26
-
27
- export type FindingCategory = typeof FINDING_CATEGORIES[number];
28
-
29
- // ============================================================================
30
- // SEVERITY LEVELS
31
- // ============================================================================
32
-
33
- export const SEVERITY_LEVELS = ['critical', 'high', 'medium', 'low', 'info'] as const;
34
- export type SeverityLevel = typeof SEVERITY_LEVELS[number];
35
-
36
- export const SEVERITY_ORDER: Record<SeverityLevel, number> = {
37
- critical: 0,
38
- high: 1,
39
- medium: 2,
40
- low: 3,
41
- info: 4,
42
- };
43
-
44
- // ============================================================================
45
- // FIX STRATEGY
46
- // ============================================================================
47
-
48
- export const FIX_STRATEGIES = [
49
- 'auto', // Fully automated fix
50
- 'guided', // AI-guided with human review
51
- 'manual', // Requires manual intervention
52
- 'ai-assisted', // AI generates suggestions
53
- ] as const;
54
-
55
- export type FixStrategy = typeof FIX_STRATEGIES[number];
56
-
57
- // ============================================================================
58
- // FINDING INTERFACE
59
- // ============================================================================
60
-
61
- export interface Finding {
62
- id: string;
63
- category: FindingCategory;
64
- severity: SeverityLevel;
65
- title: string;
66
- description: string;
67
- file: string;
68
- line?: number;
69
- column?: number;
70
- endLine?: number;
71
- endColumn?: number;
72
- code?: string;
73
- suggestion?: string;
74
- rule?: string;
75
- metadata?: Record<string, unknown>;
76
- }
77
-
78
- // ============================================================================
79
- // FIX PACK INTERFACE
80
- // ============================================================================
81
-
82
- export interface FixPack {
83
- id: string;
84
- title: string;
85
- severity: SeverityLevel;
86
- findings: Finding[];
87
- files: string[];
88
- strategy: FixStrategy;
89
- estimatedImpact: EstimatedImpact;
90
- requiresHumanReview: boolean;
91
- category: FindingCategory;
92
- createdAt: string;
93
- metadata?: FixPackMetadata;
94
- }
95
-
96
- export interface EstimatedImpact {
97
- filesAffected: number;
98
- linesChanged: number;
99
- riskLevel: 'low' | 'medium' | 'high';
100
- confidence: number;
101
- timeEstimateMinutes: number;
102
- }
103
-
104
- export interface FixPackMetadata {
105
- repoFingerprint?: string;
106
- generatedBy?: string;
107
- version?: string;
108
- tags?: string[];
109
- }
110
-
111
- // ============================================================================
112
- // REPO FINGERPRINT
113
- // ============================================================================
114
-
115
- export interface RepoFingerprint {
116
- id: string;
117
- name: string;
118
- framework?: string;
119
- language?: string;
120
- hasTypeScript: boolean;
121
- hasTests: boolean;
122
- packageManager?: 'npm' | 'yarn' | 'pnpm';
123
- gitRemote?: string;
124
- hash: string;
125
- }
126
-
127
- // ============================================================================
128
- // GENERATOR OPTIONS
129
- // ============================================================================
130
-
131
- export interface GenerateFixPacksOptions {
132
- findings: Finding[];
133
- repoFingerprint: RepoFingerprint;
134
- groupByCategory?: boolean;
135
- groupByFileProximity?: boolean;
136
- maxPackSize?: number;
137
- minPackSize?: number;
138
- requiredTier?: Tier;
139
- }
140
-
141
- export interface GenerateFixPacksResult {
142
- packs: FixPack[];
143
- ungrouped: Finding[];
144
- stats: {
145
- totalFindings: number;
146
- totalPacks: number;
147
- byCategory: Record<FindingCategory, number>;
148
- bySeverity: Record<SeverityLevel, number>;
149
- };
150
- }
151
-
152
- // ============================================================================
153
- // FIX PACK EXECUTION
154
- // ============================================================================
155
-
156
- export interface FixPackExecutionOptions {
157
- pack: FixPack;
158
- projectPath: string;
159
- dryRun?: boolean;
160
- autoApply?: boolean;
161
- maxAttempts?: number;
162
- onProgress?: (stage: string, message: string) => void;
163
- }
164
-
165
- export interface FixPackExecutionResult {
166
- success: boolean;
167
- packId: string;
168
- appliedFixes: number;
169
- skippedFixes: number;
170
- errors: string[];
171
- duration: number;
172
- filesModified: string[];
173
- diffs: Array<{
174
- file: string;
175
- content: string;
176
- }>;
177
- }
178
-
179
- // ============================================================================
180
- // HELPER FUNCTIONS
181
- // ============================================================================
182
-
183
- export function compareSeverity(a: SeverityLevel, b: SeverityLevel): number {
184
- return SEVERITY_ORDER[a] - SEVERITY_ORDER[b];
185
- }
186
-
187
- export function isHigherSeverity(a: SeverityLevel, b: SeverityLevel): boolean {
188
- return compareSeverity(a, b) < 0;
189
- }
190
-
191
- export function getHighestSeverity(severities: SeverityLevel[]): SeverityLevel {
192
- if (severities.length === 0) return 'info';
193
- return severities.reduce((highest, current) =>
194
- isHigherSeverity(current, highest) ? current : highest
195
- );
196
- }
197
-
198
- export function generatePackId(category: FindingCategory, index: number, hash: string): string {
199
- const categoryPrefix = category.slice(0, 3).toUpperCase();
200
- const hashSuffix = hash.slice(0, 6);
201
- return `FP-${categoryPrefix}-${String(index).padStart(3, '0')}-${hashSuffix}`;
202
- }
203
-
204
- export function sortPacksBySeverity(packs: FixPack[]): FixPack[] {
205
- return [...packs].sort((a, b) => compareSeverity(a.severity, b.severity));
206
- }
package/src/index.d.ts DELETED
@@ -1,7 +0,0 @@
1
- export * from "./types";
2
- export * from "./utils";
3
- export * from "./env";
4
- export * from "./cache/redis-cache";
5
- export * from "./metrics/prometheus";
6
- export * from "./visualization/dependency-graph";
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kCAAkC,CAAC"}
package/src/index.ts DELETED
@@ -1,12 +0,0 @@
1
- export * from "./cache/redis-cache";
2
- export * from "./entitlements";
3
- export * from "./env";
4
- export * from "./fix-packs";
5
- export * from "./metrics/prometheus";
6
- export * from "./rbac";
7
- export * from "./tier-config";
8
- export * from "./types";
9
- export * from "./utils";
10
- export * from "./visualization/dependency-graph";
11
- export * from "./autopilot";
12
- export * from "./verified-autofix";
@@ -1,104 +0,0 @@
1
- /**
2
- * Prometheus Metrics
3
- *
4
- * Production-ready metrics collection for Guardrail AI
5
- * Exposes metrics in Prometheus format for monitoring and alerting
6
- */
7
- export interface MetricLabels {
8
- [key: string]: string;
9
- }
10
- export interface MetricValue {
11
- value: number;
12
- labels: MetricLabels;
13
- timestamp?: number;
14
- }
15
- export interface Metric {
16
- name: string;
17
- help: string;
18
- type: "counter" | "gauge" | "histogram" | "summary";
19
- values: MetricValue[];
20
- }
21
- declare class Counter {
22
- readonly name: string;
23
- readonly help: string;
24
- readonly labelNames: string[];
25
- private values;
26
- constructor(name: string, help: string, labelNames?: string[]);
27
- inc(labels?: MetricLabels, value?: number): void;
28
- get(labels?: MetricLabels): number;
29
- reset(): void;
30
- collect(): MetricValue[];
31
- private labelsToKey;
32
- private keyToLabels;
33
- }
34
- declare class Gauge {
35
- readonly name: string;
36
- readonly help: string;
37
- readonly labelNames: string[];
38
- private values;
39
- constructor(name: string, help: string, labelNames?: string[]);
40
- set(labels: MetricLabels, value: number): void;
41
- set(value: number): void;
42
- inc(labels?: MetricLabels, value?: number): void;
43
- dec(labels?: MetricLabels, value?: number): void;
44
- get(labels?: MetricLabels): number;
45
- collect(): MetricValue[];
46
- private labelsToKey;
47
- private keyToLabels;
48
- }
49
- declare class Histogram {
50
- readonly name: string;
51
- readonly help: string;
52
- readonly labelNames: string[];
53
- private buckets;
54
- private values;
55
- constructor(
56
- name: string,
57
- help: string,
58
- labelNames?: string[],
59
- buckets?: number[],
60
- );
61
- observe(labels: MetricLabels, value: number): void;
62
- observe(value: number): void;
63
- startTimer(labels?: MetricLabels): () => number;
64
- collect(): MetricValue[];
65
- private labelsToKey;
66
- private keyToLabels;
67
- }
68
- /**
69
- * Guardrail Metrics Registry
70
- */
71
- declare class MetricsRegistry {
72
- readonly scansTotal: Counter;
73
- readonly scanDuration: Histogram;
74
- readonly injectionsDetected: Counter;
75
- readonly injectionScanDuration: Histogram;
76
- readonly vulnerabilitiesFound: Counter;
77
- readonly vulnerablePackages: Gauge;
78
- readonly secretsDetected: Counter;
79
- readonly complianceScore: Gauge;
80
- readonly complianceViolations: Counter;
81
- readonly apiRequestsTotal: Counter;
82
- readonly apiRequestDuration: Histogram;
83
- readonly agentActionsTotal: Counter;
84
- readonly agentActionsBlocked: Counter;
85
- readonly cacheHits: Counter;
86
- readonly cacheMisses: Counter;
87
- readonly activeConnections: Gauge;
88
- readonly memoryUsageBytes: Gauge;
89
- /**
90
- * Generate Prometheus-formatted output
91
- */
92
- generatePrometheusOutput(): string;
93
- /**
94
- * Update system metrics
95
- */
96
- updateSystemMetrics(): void;
97
- /**
98
- * Reset all metrics (for testing)
99
- */
100
- resetAll(): void;
101
- }
102
- export declare const metrics: MetricsRegistry;
103
- export { Counter, Gauge, Histogram };
104
- //# sourceMappingURL=prometheus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prometheus.d.ts","sourceRoot":"","sources":["prometheus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,CAAC;IACpD,MAAM,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,cAAM,OAAO;aAIO,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,MAAM;aACZ,UAAU,EAAE,MAAM,EAAE;IALtC,OAAO,CAAC,MAAM,CAAkC;gBAG9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,MAAM,EAAO;IAG3C,GA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