@eduardbar/drift 1.3.0 → 1.4.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 (168) hide show
  1. package/.gga +50 -0
  2. package/.github/actions/drift-review/README.md +60 -0
  3. package/.github/actions/drift-review/action.yml +131 -0
  4. package/.github/actions/drift-scan/README.md +28 -32
  5. package/.github/actions/drift-scan/action.yml +78 -14
  6. package/.github/workflows/review-pr.yml +34 -41
  7. package/AGENTS.md +75 -251
  8. package/CHANGELOG.md +28 -0
  9. package/README.md +148 -41
  10. package/dist/benchmark.d.ts +1 -1
  11. package/dist/benchmark.js +71 -52
  12. package/dist/cli.js +243 -8
  13. package/dist/config.js +16 -2
  14. package/dist/diff.js +42 -50
  15. package/dist/doctor.d.ts +5 -0
  16. package/dist/doctor.js +133 -0
  17. package/dist/format.d.ts +17 -0
  18. package/dist/format.js +45 -0
  19. package/dist/guard-types.d.ts +57 -0
  20. package/dist/guard-types.js +2 -0
  21. package/dist/guard.d.ts +14 -0
  22. package/dist/guard.js +239 -0
  23. package/dist/index.d.ts +10 -3
  24. package/dist/index.js +4 -1
  25. package/dist/init.d.ts +15 -0
  26. package/dist/init.js +273 -0
  27. package/dist/map-cycles.d.ts +2 -0
  28. package/dist/map-cycles.js +34 -0
  29. package/dist/map-svg.d.ts +19 -0
  30. package/dist/map-svg.js +97 -0
  31. package/dist/map.js +78 -138
  32. package/dist/metrics.js +70 -55
  33. package/dist/output-metadata.d.ts +13 -0
  34. package/dist/output-metadata.js +17 -0
  35. package/dist/plugins-capabilities.d.ts +4 -0
  36. package/dist/plugins-capabilities.js +21 -0
  37. package/dist/plugins-messages.d.ts +10 -0
  38. package/dist/plugins-messages.js +16 -0
  39. package/dist/plugins-rules.d.ts +9 -0
  40. package/dist/plugins-rules.js +137 -0
  41. package/dist/plugins.d.ts +1 -1
  42. package/dist/plugins.js +45 -142
  43. package/dist/reporter-constants.d.ts +16 -0
  44. package/dist/reporter-constants.js +39 -0
  45. package/dist/reporter.d.ts +3 -3
  46. package/dist/reporter.js +35 -55
  47. package/dist/review.d.ts +2 -1
  48. package/dist/review.js +2 -1
  49. package/dist/rules/phase3-configurable.js +23 -15
  50. package/dist/saas/constants.d.ts +15 -0
  51. package/dist/saas/constants.js +48 -0
  52. package/dist/saas/dashboard.d.ts +8 -0
  53. package/dist/saas/dashboard.js +132 -0
  54. package/dist/saas/errors.d.ts +19 -0
  55. package/dist/saas/errors.js +37 -0
  56. package/dist/saas/helpers.d.ts +21 -0
  57. package/dist/saas/helpers.js +110 -0
  58. package/dist/saas/ingest.d.ts +3 -0
  59. package/dist/saas/ingest.js +249 -0
  60. package/dist/saas/organization.d.ts +5 -0
  61. package/dist/saas/organization.js +82 -0
  62. package/dist/saas/plan-change.d.ts +10 -0
  63. package/dist/saas/plan-change.js +15 -0
  64. package/dist/saas/store.d.ts +21 -0
  65. package/dist/saas/store.js +159 -0
  66. package/dist/saas/types.d.ts +191 -0
  67. package/dist/saas/types.js +2 -0
  68. package/dist/saas.d.ts +8 -218
  69. package/dist/saas.js +7 -761
  70. package/dist/sarif.d.ts +74 -0
  71. package/dist/sarif.js +122 -0
  72. package/dist/trust-advanced.d.ts +14 -0
  73. package/dist/trust-advanced.js +65 -0
  74. package/dist/trust-kpi-fs.d.ts +3 -0
  75. package/dist/trust-kpi-fs.js +141 -0
  76. package/dist/trust-kpi-parse.d.ts +7 -0
  77. package/dist/trust-kpi-parse.js +186 -0
  78. package/dist/trust-kpi-types.d.ts +16 -0
  79. package/dist/trust-kpi-types.js +2 -0
  80. package/dist/trust-kpi.d.ts +1 -3
  81. package/dist/trust-kpi.js +6 -266
  82. package/dist/trust-policy.d.ts +32 -0
  83. package/dist/trust-policy.js +160 -0
  84. package/dist/trust-render.d.ts +9 -0
  85. package/dist/trust-render.js +54 -0
  86. package/dist/trust-scoring.d.ts +9 -0
  87. package/dist/trust-scoring.js +208 -0
  88. package/dist/trust.d.ts +4 -32
  89. package/dist/trust.js +29 -432
  90. package/dist/types/app.d.ts +30 -0
  91. package/dist/types/app.js +2 -0
  92. package/dist/types/config.d.ts +25 -0
  93. package/dist/types/config.js +2 -0
  94. package/dist/types/core.d.ts +100 -0
  95. package/dist/types/core.js +2 -0
  96. package/dist/types/diff.d.ts +55 -0
  97. package/dist/types/diff.js +2 -0
  98. package/dist/types/plugin.d.ts +41 -0
  99. package/dist/types/plugin.js +2 -0
  100. package/dist/types/trust.d.ts +120 -0
  101. package/dist/types/trust.js +2 -0
  102. package/dist/types.d.ts +8 -365
  103. package/docs/release-notes-draft.md +40 -0
  104. package/docs/rules-catalog.md +49 -0
  105. package/docs/trust-core-release-checklist.md +37 -5
  106. package/package.json +3 -2
  107. package/packages/vscode-drift/src/code-actions.ts +1 -1
  108. package/schemas/drift-ai-output.v1.json +162 -0
  109. package/schemas/drift-report.v1.json +151 -0
  110. package/schemas/drift-trust.v1.json +131 -0
  111. package/scripts/smoke-repo.mjs +394 -0
  112. package/src/benchmark.ts +75 -53
  113. package/src/cli.ts +285 -13
  114. package/src/config.ts +19 -2
  115. package/src/diff.ts +57 -48
  116. package/src/doctor.ts +173 -0
  117. package/src/format.ts +81 -0
  118. package/src/guard-types.ts +64 -0
  119. package/src/guard.ts +324 -0
  120. package/src/index.ts +35 -0
  121. package/src/init.ts +298 -0
  122. package/src/map-cycles.ts +38 -0
  123. package/src/map-svg.ts +124 -0
  124. package/src/map.ts +111 -142
  125. package/src/metrics.ts +78 -59
  126. package/src/output-metadata.ts +30 -0
  127. package/src/plugins-capabilities.ts +36 -0
  128. package/src/plugins-messages.ts +35 -0
  129. package/src/plugins-rules.ts +296 -0
  130. package/src/plugins.ts +76 -283
  131. package/src/reporter-constants.ts +46 -0
  132. package/src/reporter.ts +64 -65
  133. package/src/review.ts +4 -2
  134. package/src/rules/phase3-configurable.ts +39 -26
  135. package/src/saas/constants.ts +56 -0
  136. package/src/saas/dashboard.ts +172 -0
  137. package/src/saas/errors.ts +45 -0
  138. package/src/saas/helpers.ts +140 -0
  139. package/src/saas/ingest.ts +278 -0
  140. package/src/saas/organization.ts +99 -0
  141. package/src/saas/plan-change.ts +19 -0
  142. package/src/saas/store.ts +172 -0
  143. package/src/saas/types.ts +216 -0
  144. package/src/saas.ts +49 -1031
  145. package/src/sarif.ts +232 -0
  146. package/src/trust-advanced.ts +99 -0
  147. package/src/trust-kpi-fs.ts +169 -0
  148. package/src/trust-kpi-parse.ts +219 -0
  149. package/src/trust-kpi-types.ts +19 -0
  150. package/src/trust-kpi.ts +8 -316
  151. package/src/trust-policy.ts +246 -0
  152. package/src/trust-render.ts +61 -0
  153. package/src/trust-scoring.ts +231 -0
  154. package/src/trust.ts +62 -576
  155. package/src/types/app.ts +30 -0
  156. package/src/types/config.ts +27 -0
  157. package/src/types/core.ts +105 -0
  158. package/src/types/diff.ts +61 -0
  159. package/src/types/plugin.ts +46 -0
  160. package/src/types/trust.ts +134 -0
  161. package/src/types.ts +78 -409
  162. package/tests/cli-sarif.test.ts +92 -0
  163. package/tests/format.test.ts +157 -0
  164. package/tests/new-features.test.ts +10 -2
  165. package/tests/phase1-init-doctor-guard.test.ts +199 -0
  166. package/tests/sarif.test.ts +160 -0
  167. package/tests/trust-kpi.test.ts +31 -4
  168. package/tests/trust.test.ts +18 -0
@@ -0,0 +1,55 @@
1
+ import type { DriftIssue, DriftReport, FileReport } from './core.js';
2
+ export interface FileDiff {
3
+ path: string;
4
+ scoreBefore: number;
5
+ scoreAfter: number;
6
+ scoreDelta: number;
7
+ newIssues: DriftIssue[];
8
+ resolvedIssues: DriftIssue[];
9
+ }
10
+ export interface DriftDiff {
11
+ baseRef: string;
12
+ projectPath: string;
13
+ scannedAt: string;
14
+ files: FileDiff[];
15
+ totalScoreBefore: number;
16
+ totalScoreAfter: number;
17
+ totalDelta: number;
18
+ newIssuesCount: number;
19
+ resolvedIssuesCount: number;
20
+ }
21
+ export interface HistoricalAnalysis {
22
+ commitHash: string;
23
+ commitDate: Date;
24
+ author: string;
25
+ message: string;
26
+ files: FileReport[];
27
+ totalScore: number;
28
+ averageScore: number;
29
+ }
30
+ export interface TrendDataPoint {
31
+ date: Date;
32
+ score: number;
33
+ fileCount: number;
34
+ avgIssuesPerFile: number;
35
+ }
36
+ export interface BlameAttribution {
37
+ author: string;
38
+ email: string;
39
+ commits: number;
40
+ linesChanged: number;
41
+ issuesIntroduced: number;
42
+ avgScoreImpact: number;
43
+ }
44
+ export interface DriftTrendReport extends DriftReport {
45
+ trend: TrendDataPoint[];
46
+ regression: {
47
+ slope: number;
48
+ intercept: number;
49
+ r2: number;
50
+ };
51
+ }
52
+ export interface DriftBlameReport extends DriftReport {
53
+ blame: BlameAttribution[];
54
+ }
55
+ //# sourceMappingURL=diff.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=diff.js.map
@@ -0,0 +1,41 @@
1
+ import type { SourceFile } from 'ts-morph';
2
+ import type { DriftConfig } from './app.js';
3
+ import type { DriftIssue } from './core.js';
4
+ export interface PluginRuleContext {
5
+ projectRoot: string;
6
+ filePath: string;
7
+ config?: DriftConfig;
8
+ }
9
+ export interface DriftPluginRule {
10
+ id?: string;
11
+ name: string;
12
+ severity?: DriftIssue['severity'];
13
+ weight?: number;
14
+ detect: (file: SourceFile, context: PluginRuleContext) => DriftIssue[];
15
+ fix?: (issue: DriftIssue, file: SourceFile, context: PluginRuleContext) => DriftIssue | void;
16
+ }
17
+ export interface DriftPlugin {
18
+ name: string;
19
+ apiVersion?: number;
20
+ capabilities?: Record<string, string | number | boolean>;
21
+ rules: DriftPluginRule[];
22
+ }
23
+ export interface LoadedPlugin {
24
+ id: string;
25
+ plugin: DriftPlugin;
26
+ }
27
+ export interface PluginLoadError {
28
+ pluginId: string;
29
+ pluginName?: string;
30
+ ruleId?: string;
31
+ code?: string;
32
+ message: string;
33
+ }
34
+ export interface PluginLoadWarning {
35
+ pluginId: string;
36
+ pluginName?: string;
37
+ ruleId?: string;
38
+ code?: string;
39
+ message: string;
40
+ }
41
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1,120 @@
1
+ import type { DriftIssue, DriftOutputMetadata } from './core.js';
2
+ export type MergeRiskLevel = 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
3
+ export interface TrustGatePolicyPreset {
4
+ branch: string;
5
+ enabled?: boolean;
6
+ minTrust?: number;
7
+ maxRisk?: MergeRiskLevel;
8
+ }
9
+ export interface TrustGatePolicyPack {
10
+ enabled?: boolean;
11
+ minTrust?: number;
12
+ maxRisk?: MergeRiskLevel;
13
+ }
14
+ export interface TrustGatePolicyConfig {
15
+ enabled?: boolean;
16
+ minTrust?: number;
17
+ maxRisk?: MergeRiskLevel;
18
+ presets?: TrustGatePolicyPreset[];
19
+ policyPacks?: Record<string, TrustGatePolicyPack>;
20
+ }
21
+ export interface TrustReason {
22
+ label: string;
23
+ detail: string;
24
+ impact: number;
25
+ }
26
+ export interface TrustFixPriority {
27
+ rank: number;
28
+ rule: string;
29
+ severity: DriftIssue['severity'];
30
+ occurrences: number;
31
+ estimated_trust_gain: number;
32
+ effort: 'low' | 'medium' | 'high';
33
+ suggestion: string;
34
+ confidence?: 'low' | 'medium' | 'high';
35
+ explanation?: string;
36
+ systemic?: boolean;
37
+ }
38
+ export interface TrustAdvancedComparison {
39
+ source: 'previous-trust-json' | 'snapshot-history';
40
+ trend: 'improving' | 'regressing' | 'stable';
41
+ summary: string;
42
+ trust_delta?: number;
43
+ previous_trust_score?: number;
44
+ previous_merge_risk?: MergeRiskLevel;
45
+ snapshot_score_delta?: number;
46
+ snapshot_label?: string;
47
+ snapshot_timestamp?: string;
48
+ }
49
+ export interface TrustAdvancedContext {
50
+ comparison?: TrustAdvancedComparison;
51
+ team_guidance: string[];
52
+ }
53
+ export interface TrustDiffContext {
54
+ baseRef: string;
55
+ status: 'improved' | 'regressed' | 'neutral';
56
+ scoreDelta: number;
57
+ newIssues: number;
58
+ resolvedIssues: number;
59
+ filesChanged: number;
60
+ penalty: number;
61
+ bonus: number;
62
+ netImpact: number;
63
+ }
64
+ export interface DriftTrustReport {
65
+ scannedAt: string;
66
+ targetPath: string;
67
+ trust_score: number;
68
+ merge_risk: MergeRiskLevel;
69
+ top_reasons: TrustReason[];
70
+ fix_priorities: TrustFixPriority[];
71
+ diff_context?: TrustDiffContext;
72
+ advanced_context?: TrustAdvancedContext;
73
+ }
74
+ export type DriftTrustReportJson = DriftTrustReport & DriftOutputMetadata;
75
+ export interface TrustKpiDiagnostic {
76
+ level: 'warning' | 'error';
77
+ code: 'path-not-found' | 'path-not-supported' | 'read-failed' | 'parse-failed' | 'invalid-shape' | 'invalid-diff-context';
78
+ message: string;
79
+ file?: string;
80
+ }
81
+ export interface TrustScoreStats {
82
+ average: number | null;
83
+ median: number | null;
84
+ min: number | null;
85
+ max: number | null;
86
+ }
87
+ export interface TrustDiffTrendSummary {
88
+ available: boolean;
89
+ samples: number;
90
+ statusDistribution: {
91
+ improved: number;
92
+ regressed: number;
93
+ neutral: number;
94
+ };
95
+ scoreDelta: {
96
+ average: number | null;
97
+ median: number | null;
98
+ };
99
+ issues: {
100
+ newTotal: number;
101
+ resolvedTotal: number;
102
+ netNew: number;
103
+ };
104
+ }
105
+ export interface TrustKpiReport {
106
+ generatedAt: string;
107
+ input: string;
108
+ files: {
109
+ matched: number;
110
+ parsed: number;
111
+ malformed: number;
112
+ };
113
+ prsEvaluated: number;
114
+ mergeRiskDistribution: Record<MergeRiskLevel, number>;
115
+ trustScore: TrustScoreStats;
116
+ highRiskRatio: number | null;
117
+ diffTrend: TrustDiffTrendSummary;
118
+ diagnostics: TrustKpiDiagnostic[];
119
+ }
120
+ //# sourceMappingURL=trust.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=trust.js.map
package/dist/types.d.ts CHANGED
@@ -1,366 +1,9 @@
1
- import type { SourceFile } from 'ts-morph';
2
- export interface DriftIssue {
3
- rule: string;
4
- severity: 'error' | 'warning' | 'info';
5
- message: string;
6
- line: number;
7
- column: number;
8
- snippet: string;
9
- }
10
- export interface FileReport {
11
- path: string;
12
- issues: DriftIssue[];
13
- score: number;
14
- }
15
- export interface DriftReport {
16
- scannedAt: string;
17
- targetPath: string;
18
- files: FileReport[];
19
- totalIssues: number;
20
- totalScore: number;
21
- totalFiles: number;
22
- summary: {
23
- errors: number;
24
- warnings: number;
25
- infos: number;
26
- byRule: Record<string, number>;
27
- };
28
- quality: RepoQualityScore;
29
- maintenanceRisk: MaintenanceRiskMetrics;
30
- }
31
- export interface RepoQualityScore {
32
- overall: number;
33
- dimensions: {
34
- architecture: number;
35
- complexity: number;
36
- 'ai-patterns': number;
37
- testing: number;
38
- };
39
- }
40
- export interface RiskHotspot {
41
- file: string;
42
- driftScore: number;
43
- complexityIssues: number;
44
- hasNearbyTests: boolean;
45
- changeFrequency: number;
46
- risk: number;
47
- reasons: string[];
48
- }
49
- export interface MaintenanceRiskMetrics {
50
- score: number;
51
- level: 'low' | 'medium' | 'high' | 'critical';
52
- hotspots: RiskHotspot[];
53
- signals: {
54
- highComplexityFiles: number;
55
- filesWithoutNearbyTests: number;
56
- frequentChangeFiles: number;
57
- };
58
- }
59
- export interface AIOutput {
60
- summary: {
61
- score: number;
62
- grade: string;
63
- total_issues: number;
64
- files_affected: number;
65
- files_clean: number;
66
- ai_likelihood: number;
67
- ai_code_smell_score: number;
68
- };
69
- files_suspected: Array<{
70
- path: string;
71
- ai_likelihood: number;
72
- triggers: string[];
73
- }>;
74
- priority_order: AIIssue[];
75
- maintenance_risk: MaintenanceRiskMetrics;
76
- quality: RepoQualityScore;
77
- context_for_ai: {
78
- project_type: string;
79
- scan_path: string;
80
- rules_detected: string[];
81
- recommended_action: string;
82
- };
83
- }
84
- export interface AIIssue {
85
- rank: number;
86
- file: string;
87
- line: number;
88
- rule: string;
89
- severity: string;
90
- message: string;
91
- snippet: string;
92
- fix_suggestion: string;
93
- effort: 'low' | 'medium' | 'high';
94
- }
95
- export type MergeRiskLevel = 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
96
- export interface TrustGatePolicyPreset {
97
- branch: string;
98
- enabled?: boolean;
99
- minTrust?: number;
100
- maxRisk?: MergeRiskLevel;
101
- }
102
- export interface TrustGatePolicyPack {
103
- enabled?: boolean;
104
- minTrust?: number;
105
- maxRisk?: MergeRiskLevel;
106
- }
107
- export interface TrustGatePolicyConfig {
108
- enabled?: boolean;
109
- minTrust?: number;
110
- maxRisk?: MergeRiskLevel;
111
- presets?: TrustGatePolicyPreset[];
112
- policyPacks?: Record<string, TrustGatePolicyPack>;
113
- }
114
- export interface TrustReason {
115
- label: string;
116
- detail: string;
117
- impact: number;
118
- }
119
- export interface TrustFixPriority {
120
- rank: number;
121
- rule: string;
122
- severity: DriftIssue['severity'];
123
- occurrences: number;
124
- estimated_trust_gain: number;
125
- effort: 'low' | 'medium' | 'high';
126
- suggestion: string;
127
- confidence?: 'low' | 'medium' | 'high';
128
- explanation?: string;
129
- systemic?: boolean;
130
- }
131
- export interface TrustAdvancedComparison {
132
- source: 'previous-trust-json' | 'snapshot-history';
133
- trend: 'improving' | 'regressing' | 'stable';
134
- summary: string;
135
- trust_delta?: number;
136
- previous_trust_score?: number;
137
- previous_merge_risk?: MergeRiskLevel;
138
- snapshot_score_delta?: number;
139
- snapshot_label?: string;
140
- snapshot_timestamp?: string;
141
- }
142
- export interface TrustAdvancedContext {
143
- comparison?: TrustAdvancedComparison;
144
- team_guidance: string[];
145
- }
146
- export interface TrustDiffContext {
147
- baseRef: string;
148
- status: 'improved' | 'regressed' | 'neutral';
149
- scoreDelta: number;
150
- newIssues: number;
151
- resolvedIssues: number;
152
- filesChanged: number;
153
- penalty: number;
154
- bonus: number;
155
- netImpact: number;
156
- }
157
- export interface DriftTrustReport {
158
- scannedAt: string;
159
- targetPath: string;
160
- trust_score: number;
161
- merge_risk: MergeRiskLevel;
162
- top_reasons: TrustReason[];
163
- fix_priorities: TrustFixPriority[];
164
- diff_context?: TrustDiffContext;
165
- advanced_context?: TrustAdvancedContext;
166
- }
167
- export interface TrustKpiDiagnostic {
168
- level: 'warning' | 'error';
169
- code: 'path-not-found' | 'path-not-supported' | 'read-failed' | 'parse-failed' | 'invalid-shape' | 'invalid-diff-context';
170
- message: string;
171
- file?: string;
172
- }
173
- export interface TrustScoreStats {
174
- average: number | null;
175
- median: number | null;
176
- min: number | null;
177
- max: number | null;
178
- }
179
- export interface TrustDiffTrendSummary {
180
- available: boolean;
181
- samples: number;
182
- statusDistribution: {
183
- improved: number;
184
- regressed: number;
185
- neutral: number;
186
- };
187
- scoreDelta: {
188
- average: number | null;
189
- median: number | null;
190
- };
191
- issues: {
192
- newTotal: number;
193
- resolvedTotal: number;
194
- netNew: number;
195
- };
196
- }
197
- export interface TrustKpiReport {
198
- generatedAt: string;
199
- input: string;
200
- files: {
201
- matched: number;
202
- parsed: number;
203
- malformed: number;
204
- };
205
- prsEvaluated: number;
206
- mergeRiskDistribution: Record<MergeRiskLevel, number>;
207
- trustScore: TrustScoreStats;
208
- highRiskRatio: number | null;
209
- diffTrend: TrustDiffTrendSummary;
210
- diagnostics: TrustKpiDiagnostic[];
211
- }
212
- /**
213
- * Layer definition for architectural boundary enforcement.
214
- */
215
- export interface LayerDefinition {
216
- name: string;
217
- patterns: string[];
218
- canImportFrom: string[];
219
- }
220
- /**
221
- * Module boundary definition for cross-boundary enforcement.
222
- */
223
- export interface ModuleBoundary {
224
- name: string;
225
- root: string;
226
- allowedExternalImports?: string[];
227
- }
228
- /**
229
- * Optional project-level configuration for drift.
230
- * Place in drift.config.ts (or .js / .json) at the project root.
231
- */
232
- export interface DriftConfig {
233
- layers?: LayerDefinition[];
234
- modules?: ModuleBoundary[];
235
- plugins?: string[];
236
- performance?: DriftPerformanceConfig;
237
- architectureRules?: {
238
- controllerNoDb?: boolean;
239
- serviceNoHttp?: boolean;
240
- maxFunctionLines?: number;
241
- };
242
- saas?: {
243
- freeUserThreshold?: number;
244
- maxRunsPerWorkspacePerMonth?: number;
245
- maxReposPerWorkspace?: number;
246
- retentionDays?: number;
247
- strictActorEnforcement?: boolean;
248
- maxWorkspacesPerOrganizationByPlan?: {
249
- free?: number;
250
- sponsor?: number;
251
- team?: number;
252
- business?: number;
253
- };
254
- };
255
- trustGate?: TrustGatePolicyConfig;
256
- }
257
- export interface DriftPerformanceConfig {
258
- lowMemory?: boolean;
259
- chunkSize?: number;
260
- maxFiles?: number;
261
- maxFileSizeKb?: number;
262
- includeSemanticDuplication?: boolean;
263
- }
264
- export interface DriftAnalysisOptions {
265
- lowMemory?: boolean;
266
- chunkSize?: number;
267
- maxFiles?: number;
268
- maxFileSizeKb?: number;
269
- includeSemanticDuplication?: boolean;
270
- }
271
- export interface PluginRuleContext {
272
- projectRoot: string;
273
- filePath: string;
274
- config?: DriftConfig;
275
- }
276
- export interface DriftPluginRule {
277
- id?: string;
278
- name: string;
279
- severity?: DriftIssue['severity'];
280
- weight?: number;
281
- detect: (file: SourceFile, context: PluginRuleContext) => DriftIssue[];
282
- fix?: (issue: DriftIssue, file: SourceFile, context: PluginRuleContext) => DriftIssue | void;
283
- }
284
- export interface DriftPlugin {
285
- name: string;
286
- apiVersion?: number;
287
- capabilities?: Record<string, string | number | boolean>;
288
- rules: DriftPluginRule[];
289
- }
290
- export interface LoadedPlugin {
291
- id: string;
292
- plugin: DriftPlugin;
293
- }
294
- export interface PluginLoadError {
295
- pluginId: string;
296
- pluginName?: string;
297
- ruleId?: string;
298
- code?: string;
299
- message: string;
300
- }
301
- export interface PluginLoadWarning {
302
- pluginId: string;
303
- pluginName?: string;
304
- ruleId?: string;
305
- code?: string;
306
- message: string;
307
- }
308
- export interface FileDiff {
309
- path: string;
310
- scoreBefore: number;
311
- scoreAfter: number;
312
- scoreDelta: number;
313
- newIssues: DriftIssue[];
314
- resolvedIssues: DriftIssue[];
315
- }
316
- export interface DriftDiff {
317
- baseRef: string;
318
- projectPath: string;
319
- scannedAt: string;
320
- files: FileDiff[];
321
- totalScoreBefore: number;
322
- totalScoreAfter: number;
323
- totalDelta: number;
324
- newIssuesCount: number;
325
- resolvedIssuesCount: number;
326
- }
327
- /** Historical analysis data for a single commit */
328
- export interface HistoricalAnalysis {
329
- commitHash: string;
330
- commitDate: Date;
331
- author: string;
332
- message: string;
333
- files: FileReport[];
334
- totalScore: number;
335
- averageScore: number;
336
- }
337
- /** Trend data point for score evolution */
338
- export interface TrendDataPoint {
339
- date: Date;
340
- score: number;
341
- fileCount: number;
342
- avgIssuesPerFile: number;
343
- }
344
- /** Blame attribution data */
345
- export interface BlameAttribution {
346
- author: string;
347
- email: string;
348
- commits: number;
349
- linesChanged: number;
350
- issuesIntroduced: number;
351
- avgScoreImpact: number;
352
- }
353
- /** Extended DriftReport with historical context */
354
- export interface DriftTrendReport extends DriftReport {
355
- trend: TrendDataPoint[];
356
- regression: {
357
- slope: number;
358
- intercept: number;
359
- r2: number;
360
- };
361
- }
362
- /** Extended DriftReport with blame data */
363
- export interface DriftBlameReport extends DriftReport {
364
- blame: BlameAttribution[];
365
- }
1
+ export type { DriftIssue, FileReport, RepoQualityScore, RiskHotspot, MaintenanceRiskMetrics, AIIssue, AIOutput, AIOutputJson, DriftReport, DriftReportJson, DriftOutputMetadata, } from './types/core.js';
2
+ export type { MergeRiskLevel, TrustGatePolicyPreset, TrustGatePolicyPack, TrustGatePolicyConfig, TrustReason, TrustFixPriority, TrustAdvancedComparison, TrustAdvancedContext, TrustDiffContext, DriftTrustReport, DriftTrustReportJson, TrustKpiDiagnostic, TrustScoreStats, TrustDiffTrendSummary, TrustKpiReport, } from './types/trust.js';
3
+ export type { LayerDefinition, ModuleBoundary, DriftPerformanceConfig, DriftAnalysisOptions, } from './types/config.js';
4
+ export type { DriftConfig } from './types/app.js';
5
+ export type { PluginRuleContext, DriftPluginRule, DriftPlugin, LoadedPlugin, PluginLoadError, PluginLoadWarning, } from './types/plugin.js';
6
+ export type { FileDiff, DriftDiff, HistoricalAnalysis, TrendDataPoint, BlameAttribution, DriftTrendReport, DriftBlameReport, } from './types/diff.js';
7
+ export type { GuardBaseline, GuardThresholds, GuardOptions, GuardMetrics, GuardCheck, GuardEvaluation, GuardResult, } from './guard-types.js';
8
+ export type { SarifLevel, DriftSarifRule, DriftSarifResult, DriftSarifRun, DriftSarifLog, } from './sarif.js';
366
9
  //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,40 @@
1
+ # Release Notes Draft (S5)
2
+
3
+ ## Scope
4
+
5
+ This draft covers the latest trust-core and SARIF-related changes prepared for release packaging.
6
+
7
+ ## What changed
8
+
9
+ - Added/solidified release-facing CLI capabilities:
10
+ - `init` for project scaffolding and baseline bootstrap.
11
+ - `doctor` for environment diagnostics.
12
+ - `guard` for non-regression enforcement by diff or baseline.
13
+ - Consolidated output format behavior around `--format` and preserved legacy aliases for compatibility.
14
+ - Added SARIF output coverage across critical commands (`scan`, `ci`, `diff`, `review`, `trust`).
15
+ - Aligned CI and action v2 contract expectations with SARIF-enabled workflows.
16
+ - Expanded tests and docs to reduce release risk in CLI output contracts.
17
+
18
+ ## User impact
19
+
20
+ - Teams can ingest drift findings in SARIF-native tooling without custom adapters.
21
+ - Trust/review automation in PRs is more consistent thanks to normalized output contracts.
22
+ - Onboarding and guardrail setup are faster with `init`, `doctor`, and `guard`.
23
+
24
+ ## Risks and watch points
25
+
26
+ - SARIF consumers may still differ in strictness; validate in at least one real CI environment.
27
+ - Legacy alias paths (`--json`, `--comment`, `--markdown`) depend on compatibility behavior and should remain covered by tests.
28
+ - Trust/reporting flows rely on artifact path conventions in CI; keep workflow and docs synchronized.
29
+
30
+ ## Minimal validation before tag
31
+
32
+ - Smoke no-build commands:
33
+ - `scan --format sarif`
34
+ - `ci --format sarif`
35
+ - `trust --format sarif`
36
+ - `review --format sarif` (or `diff --format sarif` fallback)
37
+ - Targeted tests:
38
+ - `tests/cli-sarif.test.ts`
39
+ - `tests/format.test.ts`
40
+ - `tests/sarif.test.ts`
@@ -0,0 +1,49 @@
1
+ # drift rules catalog (current)
2
+
3
+ Source of truth: `RULE_WEIGHTS` in `src/analyzer.ts`.
4
+
5
+ This catalog reflects the current repository state and includes all rule IDs currently weighted/scored by drift.
6
+
7
+ | id | severity | weight | phase/origin | note |
8
+ |---|---|---:|---|---|
9
+ | `large-file` | error | 20 | phase0-basic | file exceeds size threshold |
10
+ | `large-function` | error | 15 | phase0-basic | function exceeds line threshold |
11
+ | `debug-leftover` | warning | 10 | phase0-basic | debug console calls / TODO-like leftovers |
12
+ | `dead-code` | warning | 8 | phase0-basic | unused named imports in file |
13
+ | `duplicate-function-name` | error | 18 | phase0-basic | repeated function names in same file |
14
+ | `comment-contradiction` | warning | 12 | comments rule | comment restates obvious code intent |
15
+ | `no-return-type` | info | 5 | phase0-basic | missing explicit return type |
16
+ | `catch-swallow` | warning | 10 | phase0-basic | empty catch blocks |
17
+ | `magic-number` | info | 3 | magic rule | numeric literals used directly |
18
+ | `any-abuse` | warning | 8 | phase0-basic | explicit `any` usage |
19
+ | `high-complexity` | error | 15 | phase1-complexity | high cyclomatic complexity |
20
+ | `deep-nesting` | warning | 12 | nesting rule | nested control flow too deep |
21
+ | `too-many-params` | warning | 8 | nesting rule | function has too many parameters |
22
+ | `high-coupling` | warning | 10 | coupling rule | too many module dependencies |
23
+ | `promise-style-mix` | warning | 7 | promise rule | mixed async/await and then/catch styles |
24
+ | `unused-export` | warning | 8 | phase2-crossfile | export not imported elsewhere |
25
+ | `dead-file` | warning | 10 | phase2-crossfile | file not imported by project |
26
+ | `unused-dependency` | warning | 6 | phase2-crossfile | package.json dependency unused in sources |
27
+ | `circular-dependency` | error | 14 | phase3-arch | circular import graph edges |
28
+ | `layer-violation` | error | 16 | phase3-arch (config-driven) | invalid import direction across configured layers |
29
+ | `cross-boundary-import` | warning | 10 | phase3-arch (config-driven) | invalid import across configured modules/boundaries |
30
+ | `controller-no-db` | warning | 11 | phase3-configurable | controller imports DB/repository concerns directly |
31
+ | `service-no-http` | warning | 11 | phase3-configurable | service imports/uses HTTP transport concerns |
32
+ | `max-function-lines` | warning | 9 | phase3-configurable | function/method exceeds configured max lines |
33
+ | `over-commented` | info | 4 | phase5-ai | excessive comments heuristic |
34
+ | `hardcoded-config` | warning | 10 | phase5-ai | hardcoded URLs/secrets/config literals |
35
+ | `inconsistent-error-handling` | warning | 8 | phase5-ai | mixed error-handling styles |
36
+ | `unnecessary-abstraction` | warning | 7 | phase5-ai | wrappers/abstractions with little value |
37
+ | `naming-inconsistency` | warning | 6 | phase5-ai | mixed naming conventions |
38
+ | `ai-code-smell` | warning | 12 | analyzer meta-rule | aggregated AI-smell signal from multiple heuristics |
39
+ | `semantic-duplication` | warning | 12 | phase8-semantic | AST fingerprint identifies equivalent functions |
40
+ | `plugin-error` | warning | 4 | plugin diagnostics | plugin load/contract/runtime failure surfaced as issue |
41
+ | `plugin-warning` | info | 0 | plugin diagnostics | non-fatal plugin validation warning |
42
+ | `analysis-skip-max-files` | info | 0 | analysis guardrail diagnostics | file skipped due to `maxFiles` limit |
43
+ | `analysis-skip-file-size` | info | 0 | analysis guardrail diagnostics | file skipped due to `maxFileSizeKb` limit |
44
+
45
+ ## Notes
46
+
47
+ - Config-driven rules require matching config blocks to execute (`layers`, `modules`/legacy aliases, `architectureRules`).
48
+ - `plugin-*` and `analysis-skip-*` are diagnostic rules emitted as issues and included in scoring with their configured weights.
49
+ - Total rule IDs currently defined: **35**.