@vee-stack/delta-cli 2.0.8 → 2.0.10

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 (183) hide show
  1. package/dist/adapters/analysis.adapter.d.ts +29 -0
  2. package/dist/analyzer/commands/analyze.d.ts +14 -0
  3. package/dist/analyzer/commands/config.d.ts +12 -0
  4. package/dist/analyzer/commands/report.d.ts +11 -0
  5. package/dist/analyzer/generators/report.generator.d.ts +43 -0
  6. package/dist/analyzer/index.d.ts +8 -0
  7. package/dist/analyzer/scanners/project.scanner.d.ts +29 -0
  8. package/dist/analyzer/validators/contracts.validator.d.ts +27 -0
  9. package/dist/analyzer/validators/maintainability.validator.d.ts +27 -0
  10. package/dist/analyzer/validators/observability.validator.d.ts +27 -0
  11. package/dist/analyzer/validators/performance.validator.d.ts +27 -0
  12. package/dist/analyzer/validators/security.validator.d.ts +27 -0
  13. package/dist/analyzer/validators/soc.validator.d.ts +27 -0
  14. package/dist/auth/device-auth.d.ts +18 -0
  15. package/dist/auth/secure-auth.d.ts +35 -0
  16. package/dist/bundle.mjs +422 -0
  17. package/dist/commands/analyze.d.ts +12 -0
  18. package/dist/commands/auth-new.d.ts +6 -0
  19. package/dist/commands/auth.d.ts +17 -0
  20. package/dist/commands/config.d.ts +8 -0
  21. package/dist/commands/deploy.d.ts +5 -0
  22. package/dist/commands/init.d.ts +7 -0
  23. package/dist/commands/logout.d.ts +2 -0
  24. package/dist/commands/plugins.d.ts +7 -0
  25. package/dist/commands/status.d.ts +5 -0
  26. package/dist/commands/sync.d.ts +5 -0
  27. package/dist/commands/whoami.d.ts +4 -0
  28. package/dist/components/Dashboard.d.ts +8 -0
  29. package/dist/components/DeltaApp.d.ts +13 -0
  30. package/dist/components/UnifiedManager.d.ts +10 -0
  31. package/dist/core/audit.d.ts +60 -0
  32. package/dist/core/completion.d.ts +79 -0
  33. package/dist/core/contracts.d.ts +127 -0
  34. package/dist/core/engine.d.ts +26 -0
  35. package/dist/core/exit-codes.d.ts +19 -0
  36. package/dist/core/hooks.d.ts +50 -0
  37. package/dist/{apps/cli/src/core/index.js → core/index.d.ts} +1 -1
  38. package/dist/core/policy.d.ts +24 -0
  39. package/dist/core/profiles.d.ts +45 -0
  40. package/dist/core/wizard.d.ts +28 -0
  41. package/dist/interactive/index.d.ts +5 -0
  42. package/dist/plugins/GitStatusPlugin.d.ts +25 -0
  43. package/dist/providers/ai-provider.d.ts +21 -0
  44. package/dist/providers/local-provider.d.ts +21 -0
  45. package/dist/providers/remote-provider.d.ts +15 -0
  46. package/dist/telemetry/wrapper.d.ts +18 -0
  47. package/dist/types/api.d.ts +46 -0
  48. package/dist/ui.d.ts +52 -0
  49. package/dist/welcome.d.ts +8 -0
  50. package/package.json +8 -8
  51. package/dist/analyzer/commands/analyze.js +0 -260
  52. package/dist/analyzer/commands/config.js +0 -83
  53. package/dist/analyzer/commands/report.js +0 -38
  54. package/dist/analyzer/generators/report.generator.js +0 -123
  55. package/dist/analyzer/index.js +0 -44
  56. package/dist/analyzer/scanners/project.scanner.js +0 -92
  57. package/dist/analyzer/validators/contracts.validator.js +0 -42
  58. package/dist/analyzer/validators/maintainability.validator.js +0 -40
  59. package/dist/analyzer/validators/observability.validator.js +0 -39
  60. package/dist/analyzer/validators/performance.validator.js +0 -42
  61. package/dist/analyzer/validators/security.validator.js +0 -66
  62. package/dist/analyzer/validators/soc.validator.js +0 -75
  63. package/dist/apps/cli/src/analyzer/commands/analyze.js +0 -256
  64. package/dist/apps/cli/src/analyzer/commands/config.js +0 -83
  65. package/dist/apps/cli/src/analyzer/commands/report.js +0 -38
  66. package/dist/apps/cli/src/analyzer/generators/report.generator.js +0 -123
  67. package/dist/apps/cli/src/analyzer/index.js +0 -44
  68. package/dist/apps/cli/src/analyzer/scanners/project.scanner.js +0 -92
  69. package/dist/apps/cli/src/analyzer/validators/contracts.validator.js +0 -42
  70. package/dist/apps/cli/src/analyzer/validators/maintainability.validator.js +0 -40
  71. package/dist/apps/cli/src/analyzer/validators/observability.validator.js +0 -39
  72. package/dist/apps/cli/src/analyzer/validators/performance.validator.js +0 -42
  73. package/dist/apps/cli/src/analyzer/validators/security.validator.js +0 -66
  74. package/dist/apps/cli/src/analyzer/validators/soc.validator.js +0 -75
  75. package/dist/apps/cli/src/auth/secure-auth.js +0 -312
  76. package/dist/apps/cli/src/commands/analyze.js +0 -286
  77. package/dist/apps/cli/src/commands/auth-new.js +0 -37
  78. package/dist/apps/cli/src/commands/auth.js +0 -122
  79. package/dist/apps/cli/src/commands/config.js +0 -49
  80. package/dist/apps/cli/src/commands/deploy.js +0 -6
  81. package/dist/apps/cli/src/commands/init.js +0 -47
  82. package/dist/apps/cli/src/commands/logout.js +0 -23
  83. package/dist/apps/cli/src/commands/plugins.js +0 -21
  84. package/dist/apps/cli/src/commands/status.js +0 -80
  85. package/dist/apps/cli/src/commands/sync.js +0 -6
  86. package/dist/apps/cli/src/commands/whoami.js +0 -115
  87. package/dist/apps/cli/src/components/Dashboard.js +0 -168
  88. package/dist/apps/cli/src/components/DeltaApp.js +0 -56
  89. package/dist/apps/cli/src/components/UnifiedManager.js +0 -324
  90. package/dist/apps/cli/src/core/audit.js +0 -184
  91. package/dist/apps/cli/src/core/completion.js +0 -294
  92. package/dist/apps/cli/src/core/contracts.js +0 -6
  93. package/dist/apps/cli/src/core/engine.js +0 -124
  94. package/dist/apps/cli/src/core/exit-codes.js +0 -71
  95. package/dist/apps/cli/src/core/hooks.js +0 -181
  96. package/dist/apps/cli/src/core/policy.js +0 -115
  97. package/dist/apps/cli/src/core/profiles.js +0 -161
  98. package/dist/apps/cli/src/core/wizard.js +0 -203
  99. package/dist/apps/cli/src/index.js +0 -636
  100. package/dist/apps/cli/src/interactive/index.js +0 -11
  101. package/dist/apps/cli/src/plugins/GitStatusPlugin.js +0 -99
  102. package/dist/apps/cli/src/providers/ai-provider.js +0 -74
  103. package/dist/apps/cli/src/providers/local-provider.js +0 -302
  104. package/dist/apps/cli/src/providers/remote-provider.js +0 -100
  105. package/dist/apps/cli/src/types/api.js +0 -3
  106. package/dist/apps/cli/src/ui.js +0 -219
  107. package/dist/apps/cli/src/welcome.js +0 -81
  108. package/dist/auth/secure-auth.js +0 -372
  109. package/dist/bundle.js +0 -504
  110. package/dist/commands/analyze.js +0 -390
  111. package/dist/commands/auth-new.js +0 -37
  112. package/dist/commands/auth.js +0 -134
  113. package/dist/commands/config.js +0 -51
  114. package/dist/commands/deploy.js +0 -6
  115. package/dist/commands/init.js +0 -47
  116. package/dist/commands/logout.js +0 -31
  117. package/dist/commands/plugins.js +0 -21
  118. package/dist/commands/status.js +0 -82
  119. package/dist/commands/sync.js +0 -6
  120. package/dist/commands/whoami.js +0 -72
  121. package/dist/components/Dashboard.js +0 -169
  122. package/dist/components/DeltaApp.js +0 -57
  123. package/dist/components/UnifiedManager.js +0 -344
  124. package/dist/core/audit.js +0 -184
  125. package/dist/core/completion.js +0 -294
  126. package/dist/core/contracts.js +0 -6
  127. package/dist/core/engine.js +0 -124
  128. package/dist/core/exit-codes.js +0 -71
  129. package/dist/core/hooks.js +0 -181
  130. package/dist/core/index.js +0 -7
  131. package/dist/core/policy.js +0 -115
  132. package/dist/core/profiles.js +0 -161
  133. package/dist/core/wizard.js +0 -203
  134. package/dist/index.js +0 -387
  135. package/dist/interactive/index.js +0 -11
  136. package/dist/packages/domain/src/constitution/contracts/index.js +0 -43
  137. package/dist/packages/domain/src/constitution/contracts/ts.rules.js +0 -268
  138. package/dist/packages/domain/src/constitution/index.js +0 -139
  139. package/dist/packages/domain/src/constitution/maintainability/index.js +0 -43
  140. package/dist/packages/domain/src/constitution/maintainability/ts.rules.js +0 -344
  141. package/dist/packages/domain/src/constitution/observability/index.js +0 -43
  142. package/dist/packages/domain/src/constitution/observability/ts.rules.js +0 -307
  143. package/dist/packages/domain/src/constitution/performance/index.js +0 -43
  144. package/dist/packages/domain/src/constitution/performance/ts.rules.js +0 -325
  145. package/dist/packages/domain/src/constitution/security/index.js +0 -50
  146. package/dist/packages/domain/src/constitution/security/ts.rules.js +0 -267
  147. package/dist/packages/domain/src/constitution/soc/index.js +0 -43
  148. package/dist/packages/domain/src/constitution/soc/ts.rules.js +0 -360
  149. package/dist/packages/domain/src/contracts/analysis.contract.js +0 -18
  150. package/dist/packages/domain/src/contracts/index.js +0 -7
  151. package/dist/packages/domain/src/contracts/projects.contract.js +0 -18
  152. package/dist/packages/domain/src/control/registry/rules.registry.js +0 -29
  153. package/dist/packages/domain/src/control/schemas/policies.js +0 -6
  154. package/dist/packages/domain/src/core/analysis/discovery.js +0 -163
  155. package/dist/packages/domain/src/core/analysis/engine.contract.js +0 -298
  156. package/dist/packages/domain/src/core/analysis/engine.js +0 -77
  157. package/dist/packages/domain/src/core/analysis/index.js +0 -14
  158. package/dist/packages/domain/src/core/analysis/orchestrator.js +0 -242
  159. package/dist/packages/domain/src/core/comparison/engine.js +0 -29
  160. package/dist/packages/domain/src/core/comparison/index.js +0 -5
  161. package/dist/packages/domain/src/core/documentation/index.js +0 -5
  162. package/dist/packages/domain/src/core/documentation/pipeline.js +0 -41
  163. package/dist/packages/domain/src/core/fs/adapter.js +0 -111
  164. package/dist/packages/domain/src/core/fs/index.js +0 -5
  165. package/dist/packages/domain/src/core/parser/unified-parser.js +0 -166
  166. package/dist/packages/domain/src/index.js +0 -33
  167. package/dist/packages/domain/src/plugin/registry.js +0 -195
  168. package/dist/packages/domain/src/plugin/types.js +0 -6
  169. package/dist/packages/domain/src/ports/analysis.engine.js +0 -7
  170. package/dist/packages/domain/src/ports/audit.logger.js +0 -7
  171. package/dist/packages/domain/src/ports/project.repository.js +0 -7
  172. package/dist/packages/domain/src/rules/index.js +0 -134
  173. package/dist/packages/domain/src/types/analysis.js +0 -6
  174. package/dist/packages/domain/src/types/errors.js +0 -53
  175. package/dist/packages/domain/src/types/fs.js +0 -6
  176. package/dist/packages/domain/src/types/index.js +0 -7
  177. package/dist/plugins/GitStatusPlugin.js +0 -93
  178. package/dist/providers/ai-provider.js +0 -74
  179. package/dist/providers/local-provider.js +0 -304
  180. package/dist/providers/remote-provider.js +0 -100
  181. package/dist/types/api.js +0 -3
  182. package/dist/ui.js +0 -219
  183. package/dist/welcome.js +0 -81
@@ -1,344 +0,0 @@
1
- /**
2
- * Delta Constitution - Maintainability Rules
3
- * @description Code quality, testing, and documentation standards
4
- * @version 1.0.0
5
- * @see docs/architecture/CONSTITUTION.md
6
- */
7
- // =============================================================================
8
- // MAINTAINABILITY RULE DEFINITIONS
9
- // =============================================================================
10
- export const MaintainabilityRules = {
11
- version: '1.0.0',
12
- lastUpdated: '2026-02-10',
13
- // ============================================================================
14
- // 1. LOCALITY OF BEHAVIOR
15
- // ============================================================================
16
- localityOfBehavior: {
17
- enabled: true,
18
- required: true,
19
- description: 'All related code in one place',
20
- principle: 'Co-location reduces cognitive load',
21
- requirements: {
22
- features: {
23
- location: 'src/features/[name]/',
24
- contains: ['UI', 'hooks', 'services', 'tests'],
25
- maxDepth: 3,
26
- },
27
- modules: {
28
- location: 'src/modules/[name]/',
29
- contains: ['business logic', 'policies', 'types'],
30
- maxDepth: 2,
31
- },
32
- core: {
33
- location: 'src/core/[name]/',
34
- contains: ['pure functions', 'domain logic'],
35
- maxDepth: 2,
36
- },
37
- },
38
- rules: [
39
- {
40
- id: 'MAINT-LOB-001',
41
- name: 'No Deep Nesting',
42
- description: 'Maximum 3 levels of directory nesting',
43
- severity: 'warning',
44
- },
45
- {
46
- id: 'MAINT-LOB-002',
47
- name: 'Related Files Together',
48
- description: 'Tests, types, and implementation in same directory',
49
- severity: 'error',
50
- },
51
- ],
52
- },
53
- // ============================================================================
54
- // 2. TESTING REQUIREMENTS
55
- // ============================================================================
56
- testing: {
57
- enabled: true,
58
- required: true,
59
- description: 'Comprehensive test coverage',
60
- coverage: {
61
- unit: {
62
- target: 80,
63
- minimum: 70,
64
- scope: 'functions, hooks, utilities',
65
- },
66
- integration: {
67
- target: 60,
68
- minimum: 50,
69
- scope: 'modules, services',
70
- },
71
- e2e: {
72
- target: 30,
73
- minimum: 20,
74
- scope: 'critical user flows',
75
- },
76
- },
77
- types: {
78
- unit: {
79
- description: 'Test individual functions in isolation',
80
- location: '__tests__/ or *.test.ts',
81
- tools: ['vitest', 'jest'],
82
- },
83
- integration: {
84
- description: 'Test module interactions',
85
- location: '__tests__/integration/',
86
- tools: ['vitest', 'supertest'],
87
- },
88
- constitution: {
89
- description: 'Test architecture compliance',
90
- location: 'tests/constitution/',
91
- checks: ['import boundaries', 'pure functions', 'policy usage'],
92
- },
93
- },
94
- rules: [
95
- {
96
- id: 'MAINT-TEST-001',
97
- name: 'Test Pure Functions',
98
- description: 'All pure functions must have unit tests',
99
- severity: 'error',
100
- },
101
- {
102
- id: 'MAINT-TEST-002',
103
- name: 'Test Business Logic',
104
- description: 'All business logic in modules must have tests',
105
- severity: 'error',
106
- },
107
- {
108
- id: 'MAINT-TEST-003',
109
- name: 'Mock External Dependencies',
110
- description: 'External services must be mocked in tests',
111
- severity: 'warning',
112
- },
113
- ],
114
- },
115
- // ============================================================================
116
- // 3. DOCUMENTATION
117
- // ============================================================================
118
- documentation: {
119
- enabled: true,
120
- required: true,
121
- description: 'Documentation for every layer',
122
- requirements: {
123
- code: {
124
- jsdoc: true,
125
- description: 'Every exported function must have JSDoc',
126
- required: ['description', 'param', 'returns'],
127
- },
128
- features: {
129
- readme: 'README.md',
130
- blueprint: 'docs/blueprints/[feature].md',
131
- content: ['purpose', 'usage', 'api', 'examples'],
132
- },
133
- modules: {
134
- readme: 'README.md',
135
- content: ['purpose', 'public api', 'policies', 'examples'],
136
- },
137
- architecture: {
138
- location: 'docs/architecture/',
139
- files: [
140
- 'CONSTITUTION.md',
141
- 'OVERVIEW.md',
142
- 'ENTERPRISE_ARCHITECTURE.md',
143
- 'FEATURE_ASSESSMENT_TEMPLATE.md',
144
- ],
145
- },
146
- },
147
- rules: [
148
- {
149
- id: 'MAINT-DOC-001',
150
- name: 'JSDoc Required',
151
- description: 'All public exports must have JSDoc comments',
152
- severity: 'error',
153
- },
154
- {
155
- id: 'MAINT-DOC-002',
156
- name: 'Feature Blueprint',
157
- description: 'Each feature must have a blueprint document',
158
- severity: 'warning',
159
- },
160
- ],
161
- },
162
- // ============================================================================
163
- // 4. PURE FUNCTIONS
164
- // ============================================================================
165
- pureFunctions: {
166
- enabled: true,
167
- required: true,
168
- description: 'Core must use pure functions only',
169
- definition: {
170
- deterministic: 'Same input always produces same output',
171
- noSideEffects: 'No mutation of external state',
172
- noDependencies: 'No reliance on external state',
173
- },
174
- rules: [
175
- {
176
- id: 'MAINT-PURE-001',
177
- name: 'Core Functions Pure',
178
- description: 'All functions in src/core/ must be pure',
179
- severity: 'error',
180
- check: 'AST analysis for side effects',
181
- },
182
- {
183
- id: 'MAINT-PURE-002',
184
- name: 'No Global State',
185
- description: 'No global variables or singletons in Core',
186
- severity: 'error',
187
- forbidden: ['let global', 'var global', 'static state'],
188
- },
189
- ],
190
- benefits: {
191
- testing: 'Easy to test without mocks',
192
- caching: 'Results can be safely cached',
193
- concurrency: 'Safe to run in parallel',
194
- debugging: 'Predictable behavior',
195
- },
196
- },
197
- // ============================================================================
198
- // 5. CODE QUALITY
199
- // ============================================================================
200
- codeQuality: {
201
- enabled: true,
202
- required: true,
203
- description: 'Code quality standards',
204
- metrics: {
205
- complexity: {
206
- cyclomatic: { max: 10, target: 5 },
207
- cognitive: { max: 15, target: 10 },
208
- },
209
- lines: {
210
- function: { max: 50, target: 30 },
211
- file: { max: 300, target: 200 },
212
- },
213
- duplication: {
214
- threshold: '5%',
215
- target: '0%',
216
- },
217
- },
218
- linting: {
219
- eslint: {
220
- config: '.eslintrc.cjs',
221
- extends: ['next', 'typescript', 'prettier'],
222
- customRules: 'constitution rules',
223
- },
224
- prettier: {
225
- config: '.prettierrc',
226
- enabled: true,
227
- },
228
- },
229
- rules: [
230
- {
231
- id: 'MAINT-QUAL-001',
232
- name: 'Max Complexity',
233
- description: 'Cyclomatic complexity <= 10',
234
- severity: 'warning',
235
- },
236
- {
237
- id: 'MAINT-QUAL-002',
238
- name: 'Max Function Length',
239
- description: 'Functions should be <= 50 lines',
240
- severity: 'warning',
241
- },
242
- {
243
- id: 'MAINT-QUAL-003',
244
- name: 'No Code Duplication',
245
- description: 'Duplication <= 5%',
246
- severity: 'error',
247
- },
248
- ],
249
- },
250
- // ============================================================================
251
- // 6. NAMING CONVENTIONS
252
- // ============================================================================
253
- namingConventions: {
254
- enabled: true,
255
- required: true,
256
- description: 'Consistent naming across the codebase',
257
- conventions: {
258
- files: {
259
- components: 'PascalCase.tsx',
260
- hooks: 'camelCase.ts (use*.ts)',
261
- services: 'camelCase.service.ts',
262
- utilities: 'camelCase.ts',
263
- types: 'PascalCase.ts',
264
- constants: 'UPPER_SNAKE_CASE.ts',
265
- },
266
- directories: {
267
- features: 'kebab-case/',
268
- modules: 'kebab-case/',
269
- components: 'kebab-case/',
270
- },
271
- exports: {
272
- functions: 'camelCase',
273
- components: 'PascalCase',
274
- types: 'PascalCase',
275
- constants: 'UPPER_SNAKE_CASE',
276
- },
277
- },
278
- rules: [
279
- {
280
- id: 'MAINT-NAME-001',
281
- name: 'Descriptive Names',
282
- description: 'Names should clearly describe purpose',
283
- examples: {
284
- bad: ['x', 'data', 'process'],
285
- good: ['fileUploadProgress', 'analysisResult', 'validateUserInput'],
286
- },
287
- },
288
- ],
289
- },
290
- };
291
- export function validateTestCoverage(coverage) {
292
- const violations = [];
293
- let score = 100;
294
- const { testing } = MaintainabilityRules;
295
- if (coverage.unit < testing.coverage.unit.minimum) {
296
- violations.push(`MAINT-TEST-COV: Unit coverage ${coverage.unit}% below minimum ${testing.coverage.unit.minimum}%`);
297
- score -= 25;
298
- }
299
- if (coverage.integration < testing.coverage.integration.minimum) {
300
- violations.push(`MAINT-TEST-COV: Integration coverage ${coverage.integration}% below minimum ${testing.coverage.integration.minimum}%`);
301
- score -= 20;
302
- }
303
- if (coverage.e2e < testing.coverage.e2e.minimum) {
304
- violations.push(`MAINT-TEST-COV: E2E coverage ${coverage.e2e}% below minimum ${testing.coverage.e2e.minimum}%`);
305
- score -= 15;
306
- }
307
- return {
308
- valid: violations.length === 0,
309
- violations,
310
- score: Math.max(0, score),
311
- };
312
- }
313
- export function calculateMaintainabilityScore(checks) {
314
- const maxScore = 100;
315
- let score = 0;
316
- // Testing (40 points)
317
- if (checks.hasUnitTests)
318
- score += 15;
319
- if (checks.hasIntegrationTests)
320
- score += 15;
321
- if (checks.hasConstitutionTests)
322
- score += 10;
323
- // Documentation (25 points)
324
- if (checks.hasJSDoc)
325
- score += 10;
326
- if (checks.hasReadme)
327
- score += 10;
328
- if (checks.hasBlueprints)
329
- score += 5;
330
- // Pure functions (20 points)
331
- if (checks.coreUsesPureFunctions)
332
- score += 20;
333
- // Code quality (15 points)
334
- if (checks.hasLinting)
335
- score += 5;
336
- if (checks.hasFormatting)
337
- score += 5;
338
- if (typeof checks.complexity === 'number' && checks.complexity < 10)
339
- score += 5;
340
- const grade = score >= 90 ? 'A' : score >= 80 ? 'B' : score >= 70 ? 'C' : score >= 60 ? 'D' : 'F';
341
- return { score, maxScore, grade };
342
- }
343
- export default MaintainabilityRules;
344
- //# sourceMappingURL=ts.rules.js.map
@@ -1,43 +0,0 @@
1
- /**
2
- * Delta Constitution - Observability Rules Index
3
- * @description Observability rules for all supported languages
4
- * @version 1.0.0
5
- */
6
- // TypeScript / Node.js Rules
7
- export { default as ts, ObservabilityRules as TSObservabilityRules } from './ts.rules';
8
- // Language-agnostic exports
9
- export const ObservabilityAxis = {
10
- name: 'Observability',
11
- description: 'Health Checks, Logging, Metrics, Error Tracking, Alerting',
12
- weight: 5,
13
- languages: ['typescript', 'javascript', 'node'],
14
- principles: [
15
- {
16
- id: 'OBS-001',
17
- name: 'Health Checks',
18
- description: 'Every service exposes /api/health, /api/ready, /api/live',
19
- },
20
- {
21
- id: 'OBS-002',
22
- name: 'Structured Logging',
23
- description: 'JSON structured logs across all layers',
24
- },
25
- {
26
- id: 'OBS-003',
27
- name: 'Error Tracking',
28
- description: 'Centralized error tracking with context',
29
- },
30
- {
31
- id: 'OBS-004',
32
- name: 'Performance Metrics',
33
- description: 'Track latency, throughput, errors, business metrics',
34
- },
35
- {
36
- id: 'OBS-005',
37
- name: 'Alerting',
38
- description: 'Proactive alerts for critical issues',
39
- },
40
- ],
41
- };
42
- export default ObservabilityAxis;
43
- //# sourceMappingURL=index.js.map
@@ -1,307 +0,0 @@
1
- /**
2
- * Delta Constitution - Observability Rules
3
- * @description Monitoring, logging, and health check standards
4
- * @version 1.0.0
5
- * @see docs/architecture/CONSTITUTION.md
6
- */
7
- // =============================================================================
8
- // OBSERVABILITY RULE DEFINITIONS
9
- // =============================================================================
10
- export const ObservabilityRules = {
11
- version: '1.0.0',
12
- lastUpdated: '2026-02-10',
13
- // ============================================================================
14
- // 1. HEALTH CHECKS
15
- // ============================================================================
16
- healthChecks: {
17
- enabled: true,
18
- required: true,
19
- description: 'Health checks for every endpoint and service',
20
- endpoints: {
21
- main: {
22
- path: '/api/health',
23
- method: 'GET',
24
- checks: ['database', 'cache', 'storage'],
25
- response: {
26
- status: 'healthy | degraded | unhealthy',
27
- timestamp: 'ISO 8601',
28
- version: 'app version',
29
- checks: 'Record<string, boolean> - Health check results',
30
- },
31
- },
32
- ready: {
33
- path: '/api/ready',
34
- method: 'GET',
35
- purpose: 'Kubernetes readiness probe',
36
- checks: ['dependencies ready'],
37
- },
38
- live: {
39
- path: '/api/live',
40
- method: 'GET',
41
- purpose: 'Kubernetes liveness probe',
42
- checks: ['process running'],
43
- },
44
- },
45
- requirements: {
46
- allServices: true,
47
- responseTime: '< 500ms',
48
- frequency: 'configurable',
49
- alerting: true,
50
- },
51
- rules: [
52
- {
53
- id: 'OBS-HEALTH-001',
54
- name: 'Health Endpoint Required',
55
- description: 'Every service must expose /api/health',
56
- severity: 'error',
57
- },
58
- {
59
- id: 'OBS-HEALTH-002',
60
- name: 'Dependency Checks',
61
- description: 'Health check must verify all dependencies',
62
- severity: 'error',
63
- },
64
- ],
65
- },
66
- // ============================================================================
67
- // 2. STRUCTURED LOGGING
68
- // ============================================================================
69
- structuredLogging: {
70
- enabled: true,
71
- required: true,
72
- description: 'JSON structured logging across all layers',
73
- format: {
74
- type: 'JSON',
75
- required: ['timestamp', 'level', 'message', 'service'],
76
- optional: ['traceId', 'userId', 'duration', 'metadata'],
77
- },
78
- levels: {
79
- fatal: { level: 60, use: 'Application crash' },
80
- error: { level: 50, use: 'Errors requiring immediate attention' },
81
- warn: { level: 40, use: 'Warnings, recoverable issues' },
82
- info: { level: 30, use: 'General information' },
83
- debug: { level: 20, use: 'Debugging information' },
84
- trace: { level: 10, use: 'Detailed tracing' },
85
- },
86
- layers: {
87
- features: { level: 'info', purpose: 'User actions, UI events' },
88
- modules: { level: 'info', purpose: 'Business logic operations' },
89
- core: { level: 'debug', purpose: 'Domain logic details' },
90
- security: { level: 'info', purpose: 'Audit events, violations' },
91
- infrastructure: { level: 'warn', purpose: 'External service issues' },
92
- },
93
- tools: {
94
- development: 'pino-pretty',
95
- production: 'pino',
96
- transport: 'stdout (containerized)',
97
- },
98
- },
99
- // ============================================================================
100
- // 3. ERROR TRACKING
101
- // ============================================================================
102
- errorTracking: {
103
- enabled: true,
104
- required: true,
105
- description: 'Centralized error tracking and alerting',
106
- tools: {
107
- primary: 'Sentry',
108
- fallback: 'Custom error aggregation',
109
- },
110
- requirements: {
111
- capture: ['exceptions', 'unhandled rejections', 'crashes'],
112
- context: ['user', 'request', 'tags', 'breadcrumbs'],
113
- alerting: {
114
- channels: ['email', 'slack', 'pagerduty'],
115
- rules: [
116
- { condition: 'error rate > 1%', level: 'warning' },
117
- { condition: 'error rate > 5%', level: 'critical' },
118
- { condition: 'fatal error', level: 'critical' },
119
- ],
120
- },
121
- },
122
- rules: [
123
- {
124
- id: 'OBS-ERR-001',
125
- name: 'Error Context',
126
- description: 'All errors must include user and request context',
127
- severity: 'error',
128
- },
129
- {
130
- id: 'OBS-ERR-002',
131
- name: 'Alert Threshold',
132
- description: 'Alert when error rate exceeds 1%',
133
- severity: 'warning',
134
- },
135
- ],
136
- },
137
- // ============================================================================
138
- // 4. PERFORMANCE METRICS
139
- // ============================================================================
140
- performanceMetrics: {
141
- enabled: true,
142
- required: true,
143
- description: 'Performance tracking and dashboards',
144
- metrics: {
145
- api: {
146
- latency: { p50: '100ms', p95: '300ms', p99: '500ms' },
147
- throughput: 'requests per second',
148
- errors: 'error rate percentage',
149
- },
150
- frontend: {
151
- ttfb: 'Time to first byte',
152
- fcp: 'First contentful paint',
153
- lcp: 'Largest contentful paint',
154
- tti: 'Time to interactive',
155
- cls: 'Cumulative layout shift',
156
- },
157
- business: {
158
- activeUsers: 'Concurrent users',
159
- featureUsage: 'Feature adoption rates',
160
- conversion: 'User conversion rates',
161
- },
162
- },
163
- targets: {
164
- lighthouse: {
165
- performance: 90,
166
- accessibility: 90,
167
- 'best-practices': 90,
168
- seo: 90,
169
- },
170
- api: {
171
- p95: '300ms',
172
- p99: '500ms',
173
- errorRate: '0.1%',
174
- },
175
- },
176
- dashboards: {
177
- grafana: 'Primary dashboard',
178
- vercel: 'Built-in analytics',
179
- custom: 'Custom business metrics',
180
- },
181
- },
182
- // ============================================================================
183
- // 5. DISTRIBUTED TRACING
184
- // ============================================================================
185
- distributedTracing: {
186
- enabled: true,
187
- required: false,
188
- description: 'Trace requests across services',
189
- implementation: {
190
- tool: 'OpenTelemetry',
191
- propagation: 'W3C Trace Context',
192
- sampling: '1% in production, 100% in development',
193
- },
194
- spans: {
195
- required: ['request', 'database', 'cache', 'external-api'],
196
- optional: ['render', 'compute', 'validation'],
197
- },
198
- },
199
- // ============================================================================
200
- // 6. ALERTING
201
- // ============================================================================
202
- alerting: {
203
- enabled: true,
204
- required: true,
205
- description: 'Proactive alerting for issues',
206
- channels: {
207
- slack: { type: 'notification', use: 'team alerts' },
208
- email: { type: 'notification', use: 'summary reports' },
209
- pagerduty: { type: 'pager', use: 'critical issues' },
210
- },
211
- rules: [
212
- {
213
- id: 'OBS-ALERT-001',
214
- condition: 'Health check fails',
215
- severity: 'critical',
216
- channel: 'pagerduty',
217
- response: 'immediate',
218
- },
219
- {
220
- id: 'OBS-ALERT-002',
221
- condition: 'Error rate > 1%',
222
- severity: 'warning',
223
- channel: 'slack',
224
- response: 'within 15 min',
225
- },
226
- {
227
- id: 'OBS-ALERT-003',
228
- condition: 'API latency p95 > 500ms',
229
- severity: 'warning',
230
- channel: 'slack',
231
- response: 'within 30 min',
232
- },
233
- {
234
- id: 'OBS-ALERT-004',
235
- condition: 'Security policy violation',
236
- severity: 'critical',
237
- channel: 'pagerduty + slack',
238
- response: 'immediate',
239
- },
240
- ],
241
- },
242
- };
243
- // =============================================================================
244
- // VALIDATION HELPERS
245
- // =============================================================================
246
- export function validateObservabilityCompliance(checks) {
247
- const violations = [];
248
- let score = 100;
249
- if (!checks.hasHealthEndpoint) {
250
- violations.push('OBS-HEALTH-001: Missing health endpoint');
251
- score -= 20;
252
- }
253
- if (!checks.hasStructuredLogging) {
254
- violations.push('OBS-LOG-001: Missing structured logging');
255
- score -= 20;
256
- }
257
- if (!checks.hasErrorTracking) {
258
- violations.push('OBS-ERR-001: Missing error tracking');
259
- score -= 20;
260
- }
261
- if (!checks.hasMetrics) {
262
- violations.push('OBS-MET-001: Missing performance metrics');
263
- score -= 15;
264
- }
265
- if (!checks.hasAlerting) {
266
- violations.push('OBS-ALERT-001: Missing alerting configuration');
267
- score -= 15;
268
- }
269
- return {
270
- compliant: violations.length === 0,
271
- violations,
272
- score: Math.max(0, score),
273
- };
274
- }
275
- export function calculateObservabilityScore(checks) {
276
- const maxScore = 100;
277
- let score = 0;
278
- // Health checks (25 points)
279
- if (checks.hasHealthEndpoint)
280
- score += 15;
281
- if (checks.hasReadinessProbe)
282
- score += 5;
283
- if (checks.hasLivenessProbe)
284
- score += 5;
285
- // Logging (25 points)
286
- if (checks.hasStructuredLogging)
287
- score += 15;
288
- if (checks.hasLogAggregation)
289
- score += 10;
290
- // Error tracking (20 points)
291
- if (checks.hasErrorTracking)
292
- score += 15;
293
- if (checks.hasErrorAlerting)
294
- score += 5;
295
- // Metrics (20 points)
296
- if (checks.hasMetrics)
297
- score += 15;
298
- if (checks.hasDashboards)
299
- score += 5;
300
- // Alerting (10 points)
301
- if (checks.hasAlerting)
302
- score += 10;
303
- const grade = score >= 90 ? 'A' : score >= 80 ? 'B' : score >= 70 ? 'C' : score >= 60 ? 'D' : 'F';
304
- return { score, maxScore, grade };
305
- }
306
- export default ObservabilityRules;
307
- //# sourceMappingURL=ts.rules.js.map