@ancplua/qyl-api-schema 0.2.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 (54) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +89 -0
  3. package/VERSIONING.md +74 -0
  4. package/api/routes.tsp +1052 -0
  5. package/api/streaming.tsp +335 -0
  6. package/common/errors.tsp +206 -0
  7. package/common/pagination.tsp +254 -0
  8. package/common/types.tsp +345 -0
  9. package/generated/README.md +26 -0
  10. package/generated/otel-keys.gen.tsp +1648 -0
  11. package/index.tsp +55 -0
  12. package/intelligence/causal-rules.tsp +34 -0
  13. package/intelligence/diagnostic-patterns.tsp +54 -0
  14. package/intelligence/investigation-strategies.tsp +37 -0
  15. package/intelligence/main.tsp +19 -0
  16. package/intelligence/seed/patterns.tsp +172 -0
  17. package/intelligence/seed/rules.tsp +44 -0
  18. package/intelligence/seed/strategies.tsp +56 -0
  19. package/intelligence/signals.tsp +60 -0
  20. package/models/agent/agent-run.tsp +154 -0
  21. package/models/agent/tool-call.tsp +122 -0
  22. package/models/agent/workflow-checkpoint.tsp +50 -0
  23. package/models/agent/workflow-execution.tsp +136 -0
  24. package/models/alerting.tsp +436 -0
  25. package/models/configurator.tsp +433 -0
  26. package/models/control-graph.tsp +197 -0
  27. package/models/db.tsp +810 -0
  28. package/models/deployment.tsp +365 -0
  29. package/models/error.tsp +433 -0
  30. package/models/genai.tsp +1368 -0
  31. package/models/http.tsp +600 -0
  32. package/models/identity.tsp +213 -0
  33. package/models/issues.tsp +484 -0
  34. package/models/log.tsp +140 -0
  35. package/models/messaging.tsp +304 -0
  36. package/models/otel-config.tsp +455 -0
  37. package/models/retention.tsp +240 -0
  38. package/models/rpc.tsp +309 -0
  39. package/models/search.tsp +243 -0
  40. package/models/session.tsp +274 -0
  41. package/models/system.tsp +400 -0
  42. package/models/test.tsp +346 -0
  43. package/models/triage.tsp +113 -0
  44. package/models/workflow.tsp +396 -0
  45. package/models/workspace.tsp +435 -0
  46. package/otel/enums.tsp +392 -0
  47. package/otel/logs.tsp +135 -0
  48. package/otel/metrics.tsp +358 -0
  49. package/otel/otel-conventions.tsp +14 -0
  50. package/otel/profiles.tsp +335 -0
  51. package/otel/resource.tsp +257 -0
  52. package/otel/span.tsp +307 -0
  53. package/package.json +88 -0
  54. package/tspconfig.yaml +49 -0
@@ -0,0 +1,436 @@
1
+ // =============================================================================
2
+ // ANcpLua v2.0 - Alerting & Autofix Entities
3
+ // =============================================================================
4
+ // Alert rules, firings, fix runs, artifacts, policy gates.
5
+ // =============================================================================
6
+
7
+ import "@typespec/openapi";
8
+ import "../common/types.tsp";
9
+
10
+ using TypeSpec.OpenAPI;
11
+ using Qyl.Api.Contracts.Common;
12
+
13
+ namespace Qyl.Api.Contracts.Domains.Alerting;
14
+
15
+ // =============================================================================
16
+ // Alert Rule
17
+ // =============================================================================
18
+
19
+ @doc("Alert rule definition")
20
+ @extension("x-csharp-type", "AlertRuleEntity")
21
+ model AlertRuleEntity {
22
+ @doc("Rule ID")
23
+ @key
24
+ id: string;
25
+
26
+ @doc("Owning project")
27
+ @encodedName("application/json", "project_id")
28
+ projectId: string;
29
+
30
+ @doc("Rule name")
31
+ name: string;
32
+
33
+ @doc("Rule description")
34
+ description?: string;
35
+
36
+ @doc("Rule type")
37
+ @encodedName("application/json", "rule_type")
38
+ ruleType: AlertRuleType;
39
+
40
+ @doc("Condition definition")
41
+ @encodedName("application/json", "condition_json")
42
+ conditionJson: string;
43
+
44
+ @doc("Threshold definition")
45
+ @encodedName("application/json", "threshold_json")
46
+ thresholdJson?: string;
47
+
48
+ @doc("Target type for evaluation")
49
+ @encodedName("application/json", "target_type")
50
+ targetType: string;
51
+
52
+ @doc("Target filter")
53
+ @encodedName("application/json", "target_filter_json")
54
+ targetFilterJson?: string;
55
+
56
+ @doc("Alert severity")
57
+ severity: AlertSeverity;
58
+
59
+ @doc("Cooldown between firings in seconds")
60
+ @encodedName("application/json", "cooldown_seconds")
61
+ cooldownSeconds: int32;
62
+
63
+ @doc("Notification channels")
64
+ @encodedName("application/json", "notification_channels_json")
65
+ notificationChannelsJson?: string;
66
+
67
+ @doc("Whether rule is enabled")
68
+ enabled: boolean;
69
+
70
+ @doc("Last trigger timestamp")
71
+ @encodedName("application/json", "last_triggered_at")
72
+ lastTriggeredAt?: utcDateTime;
73
+
74
+ @doc("Total trigger count")
75
+ @encodedName("application/json", "trigger_count")
76
+ triggerCount: int64;
77
+
78
+ @doc("Creation timestamp")
79
+ @encodedName("application/json", "created_at")
80
+ createdAt: utcDateTime;
81
+
82
+ @doc("Last update timestamp")
83
+ @encodedName("application/json", "updated_at")
84
+ updatedAt: utcDateTime;
85
+ }
86
+
87
+ @doc("Alert rule types")
88
+ enum AlertRuleType {
89
+ @doc("Metric threshold alert")
90
+ threshold: "threshold",
91
+
92
+ @doc("Error rate alert")
93
+ errorRate: "error_rate",
94
+
95
+ @doc("New issue alert")
96
+ newIssue: "new_issue",
97
+
98
+ @doc("Regression alert")
99
+ regression: "regression",
100
+
101
+ @doc("SLO burn rate alert")
102
+ burnRate: "burn_rate",
103
+
104
+ @doc("Anomaly detection alert")
105
+ anomaly: "anomaly",
106
+
107
+ @doc("Custom query alert")
108
+ custom: "custom",
109
+ }
110
+
111
+ @doc("Alert severity levels")
112
+ enum AlertSeverity {
113
+ @doc("Critical alert")
114
+ critical: "critical",
115
+
116
+ @doc("Warning alert")
117
+ warning: "warning",
118
+
119
+ @doc("Informational alert")
120
+ info: "info",
121
+ }
122
+
123
+ // =============================================================================
124
+ // Alert Firing
125
+ // =============================================================================
126
+
127
+ @doc("Triggered alert instance")
128
+ @extension("x-csharp-type", "AlertFiringEntity")
129
+ model AlertFiringEntity {
130
+ @doc("Firing ID")
131
+ @key
132
+ id: string;
133
+
134
+ @doc("Source rule")
135
+ @encodedName("application/json", "rule_id")
136
+ ruleId: string;
137
+
138
+ @doc("Dedup fingerprint")
139
+ fingerprint: string;
140
+
141
+ @doc("Alert severity")
142
+ severity: AlertSeverity;
143
+
144
+ @doc("Alert title")
145
+ title: string;
146
+
147
+ @doc("Alert message")
148
+ message?: string;
149
+
150
+ @doc("Measured value that triggered the alert")
151
+ @encodedName("application/json", "trigger_value")
152
+ triggerValue?: float64;
153
+
154
+ @doc("Threshold value")
155
+ @encodedName("application/json", "threshold_value")
156
+ thresholdValue?: float64;
157
+
158
+ @doc("Additional context")
159
+ @encodedName("application/json", "context_json")
160
+ contextJson?: string;
161
+
162
+ @doc("Firing status")
163
+ status: AlertFiringStatus;
164
+
165
+ @doc("Acknowledgment timestamp")
166
+ @encodedName("application/json", "acknowledged_at")
167
+ acknowledgedAt?: utcDateTime;
168
+
169
+ @doc("Acknowledged by")
170
+ @encodedName("application/json", "acknowledged_by")
171
+ acknowledgedBy?: string;
172
+
173
+ @doc("Resolution timestamp")
174
+ @encodedName("application/json", "resolved_at")
175
+ resolvedAt?: utcDateTime;
176
+
177
+ @doc("Firing timestamp")
178
+ @encodedName("application/json", "fired_at")
179
+ firedAt: utcDateTime;
180
+
181
+ @doc("Dedup key for suppressing duplicates")
182
+ @encodedName("application/json", "dedup_key")
183
+ dedupKey?: string;
184
+ }
185
+
186
+ @doc("Alert firing status")
187
+ enum AlertFiringStatus {
188
+ @doc("Currently firing")
189
+ firing: "firing",
190
+
191
+ @doc("Acknowledged by operator")
192
+ acknowledged: "acknowledged",
193
+
194
+ @doc("Resolved (condition cleared)")
195
+ resolved: "resolved",
196
+
197
+ @doc("Suppressed by cooldown")
198
+ suppressed: "suppressed",
199
+ }
200
+
201
+ // =============================================================================
202
+ // Fix Run
203
+ // =============================================================================
204
+
205
+ @doc("AI-assisted fix attempt")
206
+ @extension("x-csharp-type", "FixRunEntity")
207
+ model FixRunEntity {
208
+ @doc("Fix run ID")
209
+ @key
210
+ id: string;
211
+
212
+ @doc("Target issue")
213
+ @encodedName("application/json", "issue_id")
214
+ issueId: string;
215
+
216
+ @doc("Triggering alert firing")
217
+ @encodedName("application/json", "alert_firing_id")
218
+ alertFiringId?: string;
219
+
220
+ @doc("What triggered the fix")
221
+ @encodedName("application/json", "trigger_type")
222
+ triggerType: FixTriggerType;
223
+
224
+ @doc("Fix strategy")
225
+ strategy: string;
226
+
227
+ @doc("AI model used")
228
+ @encodedName("application/json", "model_name")
229
+ modelName?: string;
230
+
231
+ @doc("AI provider")
232
+ @encodedName("application/json", "model_provider")
233
+ modelProvider?: string;
234
+
235
+ @doc("Fix run status")
236
+ status: FixRunStatus;
237
+
238
+ @doc("Error message if failed")
239
+ @encodedName("application/json", "error_message")
240
+ errorMessage?: string;
241
+
242
+ @doc("Tokens consumed")
243
+ @encodedName("application/json", "tokens_used")
244
+ tokensUsed?: int32;
245
+
246
+ @doc("Duration in milliseconds")
247
+ @encodedName("application/json", "duration_ms")
248
+ durationMs?: int32;
249
+
250
+ @doc("Creation timestamp")
251
+ @encodedName("application/json", "created_at")
252
+ createdAt: utcDateTime;
253
+
254
+ @doc("Start timestamp")
255
+ @encodedName("application/json", "started_at")
256
+ startedAt?: utcDateTime;
257
+
258
+ @doc("Completion timestamp")
259
+ @encodedName("application/json", "completed_at")
260
+ completedAt?: utcDateTime;
261
+ }
262
+
263
+ @doc("Fix trigger types")
264
+ enum FixTriggerType {
265
+ @doc("Triggered by alert")
266
+ alert: "alert",
267
+
268
+ @doc("Triggered manually")
269
+ manual: "manual",
270
+
271
+ @doc("Triggered by MCP tool")
272
+ mcp: "mcp",
273
+
274
+ @doc("Triggered by schedule")
275
+ scheduled: "scheduled",
276
+ }
277
+
278
+ @doc("Fix run status")
279
+ enum FixRunStatus {
280
+ @doc("Pending execution")
281
+ pending: "pending",
282
+
283
+ @doc("Running")
284
+ running: "running",
285
+
286
+ @doc("Awaiting approval")
287
+ awaitingApproval: "awaiting_approval",
288
+
289
+ @doc("Approved and applied")
290
+ applied: "applied",
291
+
292
+ @doc("Rejected")
293
+ rejected: "rejected",
294
+
295
+ @doc("Failed")
296
+ failed: "failed",
297
+ }
298
+
299
+ // =============================================================================
300
+ // Fix Artifact
301
+ // =============================================================================
302
+
303
+ @doc("Fix run output artifact")
304
+ @extension("x-csharp-type", "FixArtifactEntity")
305
+ model FixArtifactEntity {
306
+ @doc("Artifact ID")
307
+ @key
308
+ id: string;
309
+
310
+ @doc("Parent fix run")
311
+ @encodedName("application/json", "fix_run_id")
312
+ fixRunId: string;
313
+
314
+ @doc("Artifact type")
315
+ @encodedName("application/json", "artifact_type")
316
+ artifactType: FixArtifactType;
317
+
318
+ @doc("Artifact name")
319
+ name: string;
320
+
321
+ @doc("Content MIME type")
322
+ @encodedName("application/json", "content_type")
323
+ contentType: string;
324
+
325
+ @doc("Artifact content")
326
+ content?: string;
327
+
328
+ @doc("Content hash for dedup")
329
+ @encodedName("application/json", "content_hash")
330
+ contentHash?: string;
331
+
332
+ @doc("Size in bytes")
333
+ @encodedName("application/json", "size_bytes")
334
+ sizeBytes?: int64;
335
+
336
+ @doc("Artifact metadata")
337
+ @encodedName("application/json", "metadata_json")
338
+ metadataJson?: string;
339
+
340
+ @doc("Creation timestamp")
341
+ @encodedName("application/json", "created_at")
342
+ createdAt: utcDateTime;
343
+ }
344
+
345
+ @doc("Fix artifact types")
346
+ enum FixArtifactType {
347
+ @doc("Code patch (diff)")
348
+ patch: "patch",
349
+
350
+ @doc("Execution log")
351
+ log: "log",
352
+
353
+ @doc("Analysis report")
354
+ report: "report",
355
+
356
+ @doc("Prompt used for AI")
357
+ prompt: "prompt",
358
+
359
+ @doc("AI model response")
360
+ response: "response",
361
+
362
+ @doc("Test results")
363
+ testResults: "test_results",
364
+ }
365
+
366
+ // =============================================================================
367
+ // Fix Policy Gate
368
+ // =============================================================================
369
+
370
+ @doc("Autofix policy gate decision")
371
+ @extension("x-csharp-type", "FixPolicyGateEntity")
372
+ model FixPolicyGateEntity {
373
+ @doc("Gate ID")
374
+ @key
375
+ id: string;
376
+
377
+ @doc("Parent fix run")
378
+ @encodedName("application/json", "fix_run_id")
379
+ fixRunId: string;
380
+
381
+ @doc("Gate type")
382
+ @encodedName("application/json", "gate_type")
383
+ gateType: PolicyGateType;
384
+
385
+ @doc("Gate name")
386
+ @encodedName("application/json", "gate_name")
387
+ gateName: string;
388
+
389
+ @doc("Decision")
390
+ decision: GateDecision;
391
+
392
+ @doc("Decision reason")
393
+ reason?: string;
394
+
395
+ @doc("Gate input data")
396
+ @encodedName("application/json", "input_json")
397
+ inputJson?: string;
398
+
399
+ @doc("Gate output data")
400
+ @encodedName("application/json", "output_json")
401
+ outputJson?: string;
402
+
403
+ @doc("Evaluation timestamp")
404
+ @encodedName("application/json", "evaluated_at")
405
+ evaluatedAt: utcDateTime;
406
+ }
407
+
408
+ @doc("Policy gate types")
409
+ enum PolicyGateType {
410
+ @doc("Scope check (allowed files/directories)")
411
+ scope: "scope",
412
+
413
+ @doc("Safety check (no destructive changes)")
414
+ safety: "safety",
415
+
416
+ @doc("Test gate (tests must pass)")
417
+ test: "test",
418
+
419
+ @doc("Review gate (human approval)")
420
+ review: "review",
421
+
422
+ @doc("Budget gate (token/cost limit)")
423
+ budget: "budget",
424
+ }
425
+
426
+ @doc("Gate decision outcomes")
427
+ enum GateDecision {
428
+ @doc("Gate passed")
429
+ allow: "allow",
430
+
431
+ @doc("Gate blocked the fix")
432
+ deny: "deny",
433
+
434
+ @doc("Gate deferred to human")
435
+ defer: "defer",
436
+ }