@ancplua/qyl-api-schema 0.4.0 → 0.5.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.
- package/README.md +50 -64
- package/api/routes.tsp +90 -943
- package/api/runner.tsp +74 -0
- package/api/streaming.tsp +13 -299
- package/common/errors.tsp +14 -1
- package/common/pagination.tsp +1 -1
- package/common/types.tsp +2 -6
- package/generated/ts-runtime/api.d.ts +734 -0
- package/generated/ts-runtime/api.js +219 -0
- package/index.tsp +7 -34
- package/models/health.tsp +22 -0
- package/models/runner-mcp.tsp +47 -0
- package/models/runner.tsp +37 -0
- package/models/session.tsp +1 -1
- package/otel/enums.tsp +1 -1
- package/otel/logs.tsp +1 -1
- package/otel/otel-conventions.tsp +0 -1
- package/otel/profiles.tsp +1 -1
- package/otel/resource.tsp +1 -1
- package/otel/span.tsp +1 -1
- package/package.json +46 -34
- package/VERSIONING.md +0 -88
- package/generated/README.md +0 -35
- package/intelligence/causal-rules.tsp +0 -34
- package/intelligence/diagnostic-patterns.tsp +0 -54
- package/intelligence/investigation-strategies.tsp +0 -37
- package/intelligence/main.tsp +0 -17
- package/intelligence/seed/patterns.tsp +0 -171
- package/intelligence/seed/rules.tsp +0 -43
- package/intelligence/seed/strategies.tsp +0 -55
- package/intelligence/signals.tsp +0 -60
- package/models/agent/agent-run.tsp +0 -154
- package/models/agent/tool-call.tsp +0 -122
- package/models/agent/workflow-checkpoint.tsp +0 -50
- package/models/agent/workflow-execution.tsp +0 -136
- package/models/alerting.tsp +0 -436
- package/models/configurator.tsp +0 -433
- package/models/control-graph.tsp +0 -197
- package/models/db.tsp +0 -767
- package/models/deployment.tsp +0 -365
- package/models/error.tsp +0 -433
- package/models/genai.tsp +0 -1305
- package/models/http.tsp +0 -547
- package/models/identity.tsp +0 -213
- package/models/issues.tsp +0 -484
- package/models/log.tsp +0 -140
- package/models/messaging.tsp +0 -304
- package/models/otel-config.tsp +0 -455
- package/models/retention.tsp +0 -240
- package/models/rpc.tsp +0 -309
- package/models/search.tsp +0 -243
- package/models/system.tsp +0 -400
- package/models/test.tsp +0 -346
- package/models/triage.tsp +0 -113
- package/models/workflow.tsp +0 -396
- package/models/workspace.tsp +0 -435
- package/otel/metrics.tsp +0 -358
- package/tspconfig.yaml +0 -49
package/generated/README.md
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# generated
|
|
2
|
-
|
|
3
|
-
This directory holds the semconv TypeSpec key projection and the emitter
|
|
4
|
-
outputs. `otel-keys.gen.tsp` is Weaver-generated — **do not edit by hand**.
|
|
5
|
-
|
|
6
|
-
## Files
|
|
7
|
-
|
|
8
|
-
| File | Source | Regenerate via |
|
|
9
|
-
| --- | --- | --- |
|
|
10
|
-
| `otel-keys.gen.tsp` | OpenTelemetry semantic-conventions core **v1.43.0** + the GenAI dev registry (`open-telemetry/semantic-conventions-genai`, pinned commit), merged and projected by the `Qyl.OpenTelemetry.SemanticConventions` repo's Weaver pipeline | In that repo: `src/…SourceGeneration/scripts/generate.sh` (refresh `Resources/resolved-registry.json`), then `src/…SourceGeneration/scripts/emit_typespec_keys.py --write <path-to-this-file>` |
|
|
11
|
-
|
|
12
|
-
## What the key files provide
|
|
13
|
-
|
|
14
|
-
One TypeSpec namespace per OpenTelemetry root group, each declaring `const <Name>: string = "<dotted.key>"`. Extracted `.tsp` models reference these consts inside `@encodedName(...)` instead of hand-typing dotted attribute keys.
|
|
15
|
-
|
|
16
|
-
```tsp
|
|
17
|
-
@encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.GenAi.ProviderName)
|
|
18
|
-
providerName?: string;
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Deprecated upstream attributes are emitted with `#deprecated "..."` so models that reference them produce a TypeSpec compiler warning matching upstream's own deprecation notes.
|
|
22
|
-
|
|
23
|
-
## Pin
|
|
24
|
-
|
|
25
|
-
The checked-in projection is pinned to core semantic-conventions **v1.43.0**
|
|
26
|
-
(commit in the file header) plus the GenAI dev registry commit pinned in the
|
|
27
|
-
SemanticConventions repo's `generate.sh` (`SEMCONV_GENAI_REF`). The
|
|
28
|
-
`VerifyKeysLockstep` Nuke target asserts the header pin matches the
|
|
29
|
-
`OtelKeysVersion` parameter (`.nuke/parameters.json`).
|
|
30
|
-
|
|
31
|
-
Bumping the pin: update the refs in that repo's `generate.sh`, re-run it plus
|
|
32
|
-
`emit_typespec_keys.py --write`, replace this checked-in projection, and keep
|
|
33
|
-
`SemConvSchemaVersion` in that repo's `Version.props` in lockstep — the .NET
|
|
34
|
-
constants and this TypeSpec projection must cite the same registry versions.
|
|
35
|
-
Direction is one-way: this repo never invokes Weaver directly.
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// =============================================================================
|
|
2
|
-
// ANcpLua v2.0 - Causal Rules
|
|
3
|
-
// =============================================================================
|
|
4
|
-
// Directed relationship between two diagnostic patterns: if cause is observed,
|
|
5
|
-
// effect is likely. Causal rules build a directed graph. Given matched patterns,
|
|
6
|
-
// the engine traverses causal edges to identify root causes (patterns with no
|
|
7
|
-
// incoming causal edges).
|
|
8
|
-
// =============================================================================
|
|
9
|
-
|
|
10
|
-
import "@typespec/openapi";
|
|
11
|
-
|
|
12
|
-
using TypeSpec.OpenAPI;
|
|
13
|
-
|
|
14
|
-
namespace Qyl.Api.Contracts.Intelligence;
|
|
15
|
-
|
|
16
|
-
@doc("Directed causal relationship between two diagnostic patterns")
|
|
17
|
-
model CausalRule {
|
|
18
|
-
@doc("Unique rule identifier")
|
|
19
|
-
id: string;
|
|
20
|
-
|
|
21
|
-
@doc("ID of the cause DiagnosticPattern")
|
|
22
|
-
causePattern: string;
|
|
23
|
-
|
|
24
|
-
@doc("ID of the effect DiagnosticPattern")
|
|
25
|
-
effectPattern: string;
|
|
26
|
-
|
|
27
|
-
@doc("Causal confidence (0.0-1.0)")
|
|
28
|
-
@minValue(0.0)
|
|
29
|
-
@maxValue(1.0)
|
|
30
|
-
strength: float64;
|
|
31
|
-
|
|
32
|
-
@doc("Time window for correlation (e.g. 5m, 1h)")
|
|
33
|
-
temporalWindow?: string;
|
|
34
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// =============================================================================
|
|
2
|
-
// ANcpLua v2.0 - Diagnostic Patterns
|
|
3
|
-
// =============================================================================
|
|
4
|
-
// A named combination of signals that identifies a known failure mode.
|
|
5
|
-
// All signals in a pattern must match (conjunction). Multiple patterns can
|
|
6
|
-
// match the same telemetry — the engine returns all matches ranked by confidence.
|
|
7
|
-
// =============================================================================
|
|
8
|
-
|
|
9
|
-
import "@typespec/openapi";
|
|
10
|
-
|
|
11
|
-
using TypeSpec.OpenAPI;
|
|
12
|
-
|
|
13
|
-
namespace Qyl.Api.Contracts.Intelligence;
|
|
14
|
-
|
|
15
|
-
@doc("Classification category for diagnostic patterns")
|
|
16
|
-
enum PatternCategory {
|
|
17
|
-
@doc("Exception and error patterns")
|
|
18
|
-
error: "error",
|
|
19
|
-
|
|
20
|
-
@doc("Performance degradation")
|
|
21
|
-
latency: "latency",
|
|
22
|
-
|
|
23
|
-
@doc("Token/cost anomalies")
|
|
24
|
-
cost: "cost",
|
|
25
|
-
|
|
26
|
-
@doc("Service health patterns")
|
|
27
|
-
availability: "availability",
|
|
28
|
-
|
|
29
|
-
@doc("GenAI-specific failure modes")
|
|
30
|
-
genai: "genai",
|
|
31
|
-
|
|
32
|
-
@doc("Database and storage patterns")
|
|
33
|
-
data: "data",
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@doc("Named combination of signals identifying a known failure mode")
|
|
37
|
-
model DiagnosticPattern {
|
|
38
|
-
@doc("Unique pattern identifier (e.g. genai_rate_limit)")
|
|
39
|
-
id: string;
|
|
40
|
-
|
|
41
|
-
@doc("Pattern classification")
|
|
42
|
-
category: PatternCategory;
|
|
43
|
-
|
|
44
|
-
@doc("Signals that must all match (conjunction)")
|
|
45
|
-
signals: Signal[];
|
|
46
|
-
|
|
47
|
-
@doc("What this pattern means diagnostically")
|
|
48
|
-
hypothesis: string;
|
|
49
|
-
|
|
50
|
-
@doc("Base confidence weight (0.0-1.0)")
|
|
51
|
-
@minValue(0.0)
|
|
52
|
-
@maxValue(1.0)
|
|
53
|
-
confidence: float64;
|
|
54
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// =============================================================================
|
|
2
|
-
// ANcpLua v2.0 - Investigation Strategies
|
|
3
|
-
// =============================================================================
|
|
4
|
-
// A deterministic sequence of steps to investigate a matched pattern.
|
|
5
|
-
// The LLM does not invent investigation paths — it selects from known
|
|
6
|
-
// strategies and interprets results.
|
|
7
|
-
// =============================================================================
|
|
8
|
-
|
|
9
|
-
import "@typespec/openapi";
|
|
10
|
-
|
|
11
|
-
using TypeSpec.OpenAPI;
|
|
12
|
-
|
|
13
|
-
namespace Qyl.Api.Contracts.Intelligence;
|
|
14
|
-
|
|
15
|
-
@doc("Single step in an investigation strategy")
|
|
16
|
-
model InvestigationStep {
|
|
17
|
-
@doc("What to do (e.g. query_traces, get_code_location, compare_deployments)")
|
|
18
|
-
action: string;
|
|
19
|
-
|
|
20
|
-
@doc("Query template or tool name")
|
|
21
|
-
query: string;
|
|
22
|
-
|
|
23
|
-
@doc("Human-readable explanation of this step")
|
|
24
|
-
description: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@doc("Deterministic investigation sequence triggered by a matched pattern")
|
|
28
|
-
model InvestigationStrategy {
|
|
29
|
-
@doc("Unique strategy identifier")
|
|
30
|
-
id: string;
|
|
31
|
-
|
|
32
|
-
@doc("Trigger — pattern ID or category:X for category-wide triggers")
|
|
33
|
-
triggerPattern: string;
|
|
34
|
-
|
|
35
|
-
@doc("Ordered investigation steps")
|
|
36
|
-
steps: InvestigationStep[];
|
|
37
|
-
}
|
package/intelligence/main.tsp
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// =============================================================================
|
|
2
|
-
// ANcpLua v2.0 - Telemetry Intelligence Model
|
|
3
|
-
// =============================================================================
|
|
4
|
-
// Canonical reasoning model over telemetry data. Schema-driven, generated,
|
|
5
|
-
// deterministic. Defines diagnostic patterns, causal rules, and investigation
|
|
6
|
-
// strategies as typed data consumed by Loom, MCP, and dashboard.
|
|
7
|
-
// =============================================================================
|
|
8
|
-
|
|
9
|
-
import "@typespec/openapi";
|
|
10
|
-
|
|
11
|
-
import "./signals.tsp";
|
|
12
|
-
import "./diagnostic-patterns.tsp";
|
|
13
|
-
import "./causal-rules.tsp";
|
|
14
|
-
import "./investigation-strategies.tsp";
|
|
15
|
-
import "./seed/patterns.tsp";
|
|
16
|
-
import "./seed/rules.tsp";
|
|
17
|
-
import "./seed/strategies.tsp";
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
// =============================================================================
|
|
2
|
-
// ANcpLua v2.0 - Seed Diagnostic Patterns (v1)
|
|
3
|
-
// =============================================================================
|
|
4
|
-
// 19 initial diagnostic patterns (10 infra + 9 agent behavioral)
|
|
5
|
-
// Source: Microsoft Research AgentRx (March 2026)
|
|
6
|
-
//
|
|
7
|
-
// Signal attributes reference:
|
|
8
|
-
// - OTel semantic attributes (status_code, duration_ns, etc.)
|
|
9
|
-
// - qyl-derived attributes (gen_ai_provider_name, gen_ai_stop_reason, etc.)
|
|
10
|
-
// - Computed fields (occurrence_rate, span_count_under_parent, etc.)
|
|
11
|
-
// =============================================================================
|
|
12
|
-
|
|
13
|
-
namespace Qyl.Api.Contracts.Intelligence.Seed;
|
|
14
|
-
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// Pattern: genai_rate_limit
|
|
17
|
-
// Category: genai
|
|
18
|
-
// Signals: status_code=2, gen_ai_provider_name exists, error_type contains rate_limit
|
|
19
|
-
// Hypothesis: Provider throttling. Check quota, reduce concurrency, add backoff.
|
|
20
|
-
// Confidence: 0.9
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
|
|
23
|
-
// ---------------------------------------------------------------------------
|
|
24
|
-
// Pattern: genai_token_exhaustion
|
|
25
|
-
// Category: genai
|
|
26
|
-
// Signals: gen_ai_stop_reason=length
|
|
27
|
-
// Hypothesis: Context window exceeded. Reduce prompt size or switch to larger model.
|
|
28
|
-
// Confidence: 0.85
|
|
29
|
-
// ---------------------------------------------------------------------------
|
|
30
|
-
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
// Pattern: genai_content_filter
|
|
33
|
-
// Category: genai
|
|
34
|
-
// Signals: gen_ai_stop_reason contains content_filter
|
|
35
|
-
// Hypothesis: Content policy violation. Review prompt content.
|
|
36
|
-
// Confidence: 0.95
|
|
37
|
-
// ---------------------------------------------------------------------------
|
|
38
|
-
|
|
39
|
-
// ---------------------------------------------------------------------------
|
|
40
|
-
// Pattern: db_timeout
|
|
41
|
-
// Category: data
|
|
42
|
-
// Signals: exception_type=TimeoutException, db.system.name exists, duration_ns > 2000000000
|
|
43
|
-
// Hypothesis: Database query timeout. Check query plan, connection pool, lock contention.
|
|
44
|
-
// Confidence: 0.85
|
|
45
|
-
// ---------------------------------------------------------------------------
|
|
46
|
-
|
|
47
|
-
// ---------------------------------------------------------------------------
|
|
48
|
-
// Pattern: db_n_plus_one
|
|
49
|
-
// Category: data
|
|
50
|
-
// Signals: db.system.name exists, parent_span_id exists, span_count_under_parent > 10
|
|
51
|
-
// Hypothesis: N+1 query pattern. Batch or prefetch related data.
|
|
52
|
-
// Confidence: 0.80
|
|
53
|
-
// ---------------------------------------------------------------------------
|
|
54
|
-
|
|
55
|
-
// ---------------------------------------------------------------------------
|
|
56
|
-
// Pattern: http_5xx_cluster
|
|
57
|
-
// Category: error
|
|
58
|
-
// Signals: http.response.status_code gte 500, occurrence_rate > baseline * 3
|
|
59
|
-
// Hypothesis: Server error spike. Check recent deployments and upstream dependencies.
|
|
60
|
-
// Confidence: 0.75
|
|
61
|
-
// ---------------------------------------------------------------------------
|
|
62
|
-
|
|
63
|
-
// ---------------------------------------------------------------------------
|
|
64
|
-
// Pattern: deployment_regression
|
|
65
|
-
// Category: error
|
|
66
|
-
// Signals: error_type exists, first_seen_at > last_deployment_time
|
|
67
|
-
// Hypothesis: New error class after deployment. Compare with previous version.
|
|
68
|
-
// Confidence: 0.80
|
|
69
|
-
// ---------------------------------------------------------------------------
|
|
70
|
-
|
|
71
|
-
// ---------------------------------------------------------------------------
|
|
72
|
-
// Pattern: cascading_timeout
|
|
73
|
-
// Category: latency
|
|
74
|
-
// Signals: exception_type contains Timeout, downstream_service_error=true
|
|
75
|
-
// Hypothesis: Upstream failure causing downstream timeouts. Investigate root service first.
|
|
76
|
-
// Confidence: 0.70
|
|
77
|
-
// ---------------------------------------------------------------------------
|
|
78
|
-
|
|
79
|
-
// ---------------------------------------------------------------------------
|
|
80
|
-
// Pattern: memory_pressure_latency
|
|
81
|
-
// Category: latency
|
|
82
|
-
// Signals: process.runtime.dotnet.gc.duration gt 100, avg_latency > p99_baseline
|
|
83
|
-
// Hypothesis: GC pressure causing latency. Check memory allocation patterns.
|
|
84
|
-
// Confidence: 0.65
|
|
85
|
-
// ---------------------------------------------------------------------------
|
|
86
|
-
|
|
87
|
-
// ---------------------------------------------------------------------------
|
|
88
|
-
// Pattern: cost_spike
|
|
89
|
-
// Category: cost
|
|
90
|
-
// Signals: gen_ai_cost_usd > daily_average * 3
|
|
91
|
-
// Hypothesis: Abnormal cost increase. Identify the model, service, and session responsible.
|
|
92
|
-
// Confidence: 0.75
|
|
93
|
-
// ---------------------------------------------------------------------------
|
|
94
|
-
|
|
95
|
-
// =============================================================================
|
|
96
|
-
// Agent behavioral failure patterns (AgentRx taxonomy)
|
|
97
|
-
// Source: Microsoft Research AgentRx, March 2026
|
|
98
|
-
// 9 failure categories from Magentic-One and TAU-Retail benchmarks
|
|
99
|
-
// =============================================================================
|
|
100
|
-
|
|
101
|
-
// ---------------------------------------------------------------------------
|
|
102
|
-
// Pattern: agent_intent_plan_misalignment
|
|
103
|
-
// Category: agent
|
|
104
|
-
// Signals: gen_ai.agent.name exists, gen_ai.operation.name=invoke_agent, status_code=2
|
|
105
|
-
// Hypothesis: Agent plan diverges from user intent. Review task decomposition.
|
|
106
|
-
// Confidence: 0.70
|
|
107
|
-
// ---------------------------------------------------------------------------
|
|
108
|
-
|
|
109
|
-
// ---------------------------------------------------------------------------
|
|
110
|
-
// Pattern: agent_misinterpret_tool_info
|
|
111
|
-
// Category: agent
|
|
112
|
-
// Signals: gen_ai.tool.name exists, gen_ai.tool.call.id exists, error_type contains tool
|
|
113
|
-
// Hypothesis: Agent misinterpreted tool output or schema.
|
|
114
|
-
// Confidence: 0.75
|
|
115
|
-
// ---------------------------------------------------------------------------
|
|
116
|
-
|
|
117
|
-
// ---------------------------------------------------------------------------
|
|
118
|
-
// Pattern: agent_rai_policy_violation
|
|
119
|
-
// Category: agent
|
|
120
|
-
// Signals: gen_ai.agent.name exists, gen_ai.stop_reason contains content_filter
|
|
121
|
-
// Hypothesis: Agent triggered responsible AI policy violation.
|
|
122
|
-
// Confidence: 0.95
|
|
123
|
-
// ---------------------------------------------------------------------------
|
|
124
|
-
|
|
125
|
-
// ---------------------------------------------------------------------------
|
|
126
|
-
// Pattern: agent_plan_adherence_failure
|
|
127
|
-
// Category: agent
|
|
128
|
-
// Signals: gen_ai.agent.name exists, gen_ai.operation.name=invoke_agent, gen_ai.usage.output_tokens>0, child_span_count>20
|
|
129
|
-
// Hypothesis: Agent deviated from its own plan. Excessive tool calls suggest improvisation.
|
|
130
|
-
// Confidence: 0.65
|
|
131
|
-
// ---------------------------------------------------------------------------
|
|
132
|
-
|
|
133
|
-
// ---------------------------------------------------------------------------
|
|
134
|
-
// Pattern: agent_invent_new_info
|
|
135
|
-
// Category: agent
|
|
136
|
-
// Signals: gen_ai.agent.name exists, gen_ai.operation.name=invoke_agent
|
|
137
|
-
// Hypothesis: Agent fabricated information not in tool outputs. Cross-reference claims vs results.
|
|
138
|
-
// Confidence: 0.60
|
|
139
|
-
// ---------------------------------------------------------------------------
|
|
140
|
-
|
|
141
|
-
// ---------------------------------------------------------------------------
|
|
142
|
-
// Pattern: agent_invalid_invocation
|
|
143
|
-
// Category: agent
|
|
144
|
-
// Signals: gen_ai.tool.name exists, error_type contains invalid, gen_ai.agent.name exists
|
|
145
|
-
// Hypothesis: Agent called tool with invalid arguments or nonexistent name.
|
|
146
|
-
// Confidence: 0.85
|
|
147
|
-
// ---------------------------------------------------------------------------
|
|
148
|
-
|
|
149
|
-
// ---------------------------------------------------------------------------
|
|
150
|
-
// Pattern: agent_hallucination_doubt
|
|
151
|
-
// Category: agent
|
|
152
|
-
// Signals: gen_ai.agent.name exists, gen_ai.usage.output_tokens>500, gen_ai.tool.call.id not_exists
|
|
153
|
-
// Hypothesis: Long response without tool grounding. High hallucination risk.
|
|
154
|
-
// Confidence: 0.55
|
|
155
|
-
// ---------------------------------------------------------------------------
|
|
156
|
-
|
|
157
|
-
// ---------------------------------------------------------------------------
|
|
158
|
-
// Pattern: agent_instruction_adherence_failure
|
|
159
|
-
// Category: agent
|
|
160
|
-
// Signals: gen_ai.agent.name exists, gen_ai.operation.name=invoke_agent
|
|
161
|
-
// Hypothesis: Agent ignored or contradicted system prompt constraints.
|
|
162
|
-
// Confidence: 0.60
|
|
163
|
-
// ---------------------------------------------------------------------------
|
|
164
|
-
|
|
165
|
-
// ---------------------------------------------------------------------------
|
|
166
|
-
// Pattern: agent_underspecified_intent
|
|
167
|
-
// Category: agent
|
|
168
|
-
// Signals: gen_ai.agent.name exists, gen_ai.operation.name=invoke_agent, gen_ai.usage.input_tokens<50
|
|
169
|
-
// Hypothesis: Ambiguous request with insufficient context for reliable execution.
|
|
170
|
-
// Confidence: 0.65
|
|
171
|
-
// ---------------------------------------------------------------------------
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// =============================================================================
|
|
2
|
-
// ANcpLua v2.0 - Seed Causal Rules (v1)
|
|
3
|
-
// =============================================================================
|
|
4
|
-
// 6 initial causal rules.
|
|
5
|
-
// =============================================================================
|
|
6
|
-
|
|
7
|
-
namespace Qyl.Api.Contracts.Intelligence.Seed;
|
|
8
|
-
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Rule: deploy_causes_regression
|
|
11
|
-
// Cause: deployment_regression → Effect: http_5xx_cluster
|
|
12
|
-
// Strength: 0.85, Window: 1h
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
|
-
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// Rule: rate_limit_causes_cascade
|
|
17
|
-
// Cause: genai_rate_limit → Effect: cascading_timeout
|
|
18
|
-
// Strength: 0.70, Window: 5m
|
|
19
|
-
// ---------------------------------------------------------------------------
|
|
20
|
-
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
// Rule: db_timeout_causes_http_error
|
|
23
|
-
// Cause: db_timeout → Effect: http_5xx_cluster
|
|
24
|
-
// Strength: 0.80, Window: 1m
|
|
25
|
-
// ---------------------------------------------------------------------------
|
|
26
|
-
|
|
27
|
-
// ---------------------------------------------------------------------------
|
|
28
|
-
// Rule: n_plus_one_causes_db_timeout
|
|
29
|
-
// Cause: db_n_plus_one → Effect: db_timeout
|
|
30
|
-
// Strength: 0.75, Window: 30s
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
|
|
33
|
-
// ---------------------------------------------------------------------------
|
|
34
|
-
// Rule: memory_causes_timeout
|
|
35
|
-
// Cause: memory_pressure_latency → Effect: cascading_timeout
|
|
36
|
-
// Strength: 0.65, Window: 5m
|
|
37
|
-
// ---------------------------------------------------------------------------
|
|
38
|
-
|
|
39
|
-
// ---------------------------------------------------------------------------
|
|
40
|
-
// Rule: token_exhaustion_causes_cost
|
|
41
|
-
// Cause: genai_token_exhaustion → Effect: cost_spike
|
|
42
|
-
// Strength: 0.60, Window: 1h
|
|
43
|
-
// ---------------------------------------------------------------------------
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// =============================================================================
|
|
2
|
-
// ANcpLua v2.0 - Seed Investigation Strategies (v1)
|
|
3
|
-
// =============================================================================
|
|
4
|
-
// 4 initial investigation strategies.
|
|
5
|
-
//
|
|
6
|
-
// Trigger patterns use category:X syntax for category-wide triggers.
|
|
7
|
-
// Query templates are abstract qyl investigation hints; the runtime decides how to execute them.
|
|
8
|
-
// =============================================================================
|
|
9
|
-
|
|
10
|
-
namespace Qyl.Api.Contracts.Intelligence.Seed;
|
|
11
|
-
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
// Strategy: investigate_error_issue
|
|
14
|
-
// Trigger: category:error (any error category pattern)
|
|
15
|
-
// Steps:
|
|
16
|
-
// 1. get_issue — SELECT * FROM error_issues WHERE id = ?
|
|
17
|
-
// 2. get_events — SELECT * FROM error_issue_events WHERE issue_id = ? ORDER BY timestamp DESC LIMIT 10
|
|
18
|
-
// 3. get_traces — SELECT * FROM spans WHERE trace_id IN (?) ORDER BY start_time_unix_nano
|
|
19
|
-
// 4. get_code_location — SELECT code_filepath, code_function, code_lineno FROM spans WHERE span_id = ?
|
|
20
|
-
// 5. correlate_deployment — SELECT * FROM deployments WHERE service_name = ? AND start_time <= ? ORDER BY start_time DESC LIMIT 1
|
|
21
|
-
// 6. check_fix_history — SELECT * FROM fix_runs WHERE issue_id = ?
|
|
22
|
-
// ---------------------------------------------------------------------------
|
|
23
|
-
|
|
24
|
-
// ---------------------------------------------------------------------------
|
|
25
|
-
// Strategy: investigate_latency
|
|
26
|
-
// Trigger: category:latency (any latency category pattern)
|
|
27
|
-
// Steps:
|
|
28
|
-
// 1. identify_service — SELECT service_name, AVG(duration_ns), PERCENTILE_CONT(0.99) ... GROUP BY service_name
|
|
29
|
-
// 2. compare_distributions — SELECT duration_ns FROM spans WHERE service_name = ? AND start_time BETWEEN ? AND ?
|
|
30
|
-
// 3. find_regression_window — Time-series analysis of p99 latency
|
|
31
|
-
// 4. correlate_deployment — SELECT * FROM deployments WHERE service_name = ? AND start_time <= ? ORDER BY start_time DESC LIMIT 1
|
|
32
|
-
// 5. inspect_slow_spans — SELECT * FROM spans WHERE service_name = ? AND duration_ns > ? ORDER BY duration_ns DESC LIMIT 20
|
|
33
|
-
// ---------------------------------------------------------------------------
|
|
34
|
-
|
|
35
|
-
// ---------------------------------------------------------------------------
|
|
36
|
-
// Strategy: investigate_cost
|
|
37
|
-
// Trigger: category:cost (any cost category pattern)
|
|
38
|
-
// Steps:
|
|
39
|
-
// 1. identify_model — SELECT gen_ai_request_model, SUM(gen_ai_cost_usd) ... GROUP BY gen_ai_request_model
|
|
40
|
-
// 2. identify_service — SELECT service_name, SUM(gen_ai_cost_usd) ... GROUP BY service_name
|
|
41
|
-
// 3. identify_session — SELECT session_id, SUM(gen_ai_cost_usd) ... GROUP BY session_id ORDER BY 2 DESC
|
|
42
|
-
// 4. trace_to_root — Follow session → traces → spans
|
|
43
|
-
// 5. compare_to_baseline — Compare current period vs previous period
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
|
-
|
|
46
|
-
// ---------------------------------------------------------------------------
|
|
47
|
-
// Strategy: investigate_genai
|
|
48
|
-
// Trigger: category:genai (any genai category pattern)
|
|
49
|
-
// Steps:
|
|
50
|
-
// 1. get_error_details — SELECT * FROM spans WHERE status_code = 2 AND gen_ai_provider_name IS NOT NULL
|
|
51
|
-
// 2. check_provider_status — Evaluate gen_ai_provider_name + error frequency
|
|
52
|
-
// 3. analyze_token_usage — SELECT gen_ai_input_tokens, gen_ai_output_tokens FROM spans WHERE gen_ai_request_model = ?
|
|
53
|
-
// 4. check_prompt_patterns — Inspect spans around the error for prompt size trends
|
|
54
|
-
// 5. suggest_mitigation — Pattern-specific recommendation
|
|
55
|
-
// ---------------------------------------------------------------------------
|
package/intelligence/signals.tsp
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
// =============================================================================
|
|
2
|
-
// ANcpLua v2.0 - Signal Primitive
|
|
3
|
-
// =============================================================================
|
|
4
|
-
// The atomic unit of telemetry observation. A single attribute condition.
|
|
5
|
-
// Signals reference semconv attributes and qyl-derived attributes only.
|
|
6
|
-
// =============================================================================
|
|
7
|
-
|
|
8
|
-
import "@typespec/openapi";
|
|
9
|
-
|
|
10
|
-
using TypeSpec.OpenAPI;
|
|
11
|
-
|
|
12
|
-
namespace Qyl.Api.Contracts.Intelligence;
|
|
13
|
-
|
|
14
|
-
@doc("Comparison operator for signal evaluation")
|
|
15
|
-
enum SignalOperator {
|
|
16
|
-
@doc("Equals")
|
|
17
|
-
eq: "eq",
|
|
18
|
-
|
|
19
|
-
@doc("Not equals")
|
|
20
|
-
neq: "neq",
|
|
21
|
-
|
|
22
|
-
@doc("Greater than")
|
|
23
|
-
gt: "gt",
|
|
24
|
-
|
|
25
|
-
@doc("Greater than or equal")
|
|
26
|
-
gte: "gte",
|
|
27
|
-
|
|
28
|
-
@doc("Less than")
|
|
29
|
-
lt: "lt",
|
|
30
|
-
|
|
31
|
-
@doc("Less than or equal")
|
|
32
|
-
lte: "lte",
|
|
33
|
-
|
|
34
|
-
@doc("String contains")
|
|
35
|
-
contains: "contains",
|
|
36
|
-
|
|
37
|
-
@doc("Attribute is non-null")
|
|
38
|
-
exists: "exists",
|
|
39
|
-
|
|
40
|
-
@doc("Attribute is null")
|
|
41
|
-
not_exists: "not_exists",
|
|
42
|
-
|
|
43
|
-
@doc("Regex match")
|
|
44
|
-
matches: "matches",
|
|
45
|
-
|
|
46
|
-
@doc("Value in set (comma-separated)")
|
|
47
|
-
in_set: "in",
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@doc("Atomic telemetry observation — a single attribute condition")
|
|
51
|
-
model Signal {
|
|
52
|
-
@doc("Telemetry attribute name (semconv or promoted column)")
|
|
53
|
-
attribute: string;
|
|
54
|
-
|
|
55
|
-
@doc("Comparison operator")
|
|
56
|
-
operator: SignalOperator;
|
|
57
|
-
|
|
58
|
-
@doc("Expected value (type-coerced at evaluation time). Omit for exists/not_exists.")
|
|
59
|
-
value?: string;
|
|
60
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// =============================================================================
|
|
2
|
-
// ANcpLua v2.0 - Agent Run Contract Model
|
|
3
|
-
// =============================================================================
|
|
4
|
-
// Agent run records extracted from OTLP spans.
|
|
5
|
-
// Maps OTel GenAI semantic convention attributes to qyl API contract fields.
|
|
6
|
-
//
|
|
7
|
-
// OTel semconv mapping:
|
|
8
|
-
// gen_ai.agent.name → agent_name
|
|
9
|
-
// gen_ai.agent.id → agent_id
|
|
10
|
-
// gen_ai.agent.description → agent_description
|
|
11
|
-
// gen_ai.operation.name → operation_name
|
|
12
|
-
// gen_ai.request.model → gen_ai_request_model
|
|
13
|
-
// gen_ai.provider.name → gen_ai_provider_name
|
|
14
|
-
// gen_ai.usage.input_tokens → gen_ai_input_tokens
|
|
15
|
-
// gen_ai.usage.output_tokens → gen_ai_output_tokens
|
|
16
|
-
// =============================================================================
|
|
17
|
-
|
|
18
|
-
import "@typespec/openapi";
|
|
19
|
-
import "../../common/types.tsp";
|
|
20
|
-
import "../../otel/enums.tsp";
|
|
21
|
-
|
|
22
|
-
using TypeSpec.OpenAPI;
|
|
23
|
-
using Qyl.Api.Contracts.Common;
|
|
24
|
-
using Qyl.Api.Contracts.OTel.Enums;
|
|
25
|
-
|
|
26
|
-
namespace Qyl.Api.Contracts.Domains.Agent.Run;
|
|
27
|
-
|
|
28
|
-
// =============================================================================
|
|
29
|
-
// Agent Run Status
|
|
30
|
-
// =============================================================================
|
|
31
|
-
|
|
32
|
-
@doc("Agent run execution status")
|
|
33
|
-
enum AgentRunStatus {
|
|
34
|
-
@doc("Agent is currently executing")
|
|
35
|
-
running: "running",
|
|
36
|
-
|
|
37
|
-
@doc("Agent completed successfully")
|
|
38
|
-
completed: "completed",
|
|
39
|
-
|
|
40
|
-
@doc("Agent execution failed")
|
|
41
|
-
failed: "failed",
|
|
42
|
-
|
|
43
|
-
@doc("Agent execution was cancelled")
|
|
44
|
-
cancelled: "cancelled",
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// =============================================================================
|
|
48
|
-
// Agent Run Entity
|
|
49
|
-
// =============================================================================
|
|
50
|
-
|
|
51
|
-
@doc("Agent run entity materialized from OTLP spans with gen_ai.agent.* attributes")
|
|
52
|
-
@TypeSpec.OpenAPI.extension("x-csharp-type", "AgentRunEntity")
|
|
53
|
-
model AgentRunEntity {
|
|
54
|
-
// === Identifiers ===
|
|
55
|
-
|
|
56
|
-
@doc("Unique agent run identifier")
|
|
57
|
-
@key
|
|
58
|
-
runId: string;
|
|
59
|
-
|
|
60
|
-
@doc("Parent OTel trace identifier")
|
|
61
|
-
traceId: TraceId;
|
|
62
|
-
|
|
63
|
-
@doc("Root span ID of the agent invocation")
|
|
64
|
-
spanId?: SpanId;
|
|
65
|
-
|
|
66
|
-
@doc("Parent run ID for nested agent invocations")
|
|
67
|
-
parentRunId?: string;
|
|
68
|
-
|
|
69
|
-
@doc("Session identifier for grouping related runs")
|
|
70
|
-
sessionId?: SessionId;
|
|
71
|
-
|
|
72
|
-
// === Agent Identity (OTel gen_ai.agent.*) ===
|
|
73
|
-
|
|
74
|
-
@doc("Agent name - OTel: gen_ai.agent.name")
|
|
75
|
-
@TypeSpec.OpenAPI.extension("x-promoted", true)
|
|
76
|
-
agentName: string;
|
|
77
|
-
|
|
78
|
-
@doc("Agent identifier - OTel: gen_ai.agent.id")
|
|
79
|
-
@TypeSpec.OpenAPI.extension("x-promoted", true)
|
|
80
|
-
agentId?: string;
|
|
81
|
-
|
|
82
|
-
@doc("Agent description - OTel: gen_ai.agent.description")
|
|
83
|
-
@TypeSpec.OpenAPI.extension("x-promoted", true)
|
|
84
|
-
agentDescription?: string;
|
|
85
|
-
|
|
86
|
-
// === GenAI Attributes (OTel gen_ai.*) ===
|
|
87
|
-
|
|
88
|
-
@doc("Operation name - OTel: gen_ai.operation.name")
|
|
89
|
-
@TypeSpec.OpenAPI.extension("x-promoted", true)
|
|
90
|
-
operationName?: string;
|
|
91
|
-
|
|
92
|
-
@doc("LLM model used - OTel: gen_ai.request.model")
|
|
93
|
-
@TypeSpec.OpenAPI.extension("x-promoted", true)
|
|
94
|
-
genAiRequestModel?: string;
|
|
95
|
-
|
|
96
|
-
@doc("Provider name - OTel: gen_ai.provider.name")
|
|
97
|
-
@TypeSpec.OpenAPI.extension("x-promoted", true)
|
|
98
|
-
genAiProviderName?: string;
|
|
99
|
-
|
|
100
|
-
// === Execution State ===
|
|
101
|
-
|
|
102
|
-
@doc("Execution status")
|
|
103
|
-
status: AgentRunStatus;
|
|
104
|
-
|
|
105
|
-
// === Token Usage (OTel gen_ai.usage.*) ===
|
|
106
|
-
|
|
107
|
-
@doc("Input/prompt tokens - OTel: gen_ai.usage.input_tokens")
|
|
108
|
-
@TypeSpec.OpenAPI.extension("x-promoted", true)
|
|
109
|
-
genAiInputTokens?: TokenCount;
|
|
110
|
-
|
|
111
|
-
@doc("Output/completion tokens - OTel: gen_ai.usage.output_tokens")
|
|
112
|
-
@TypeSpec.OpenAPI.extension("x-promoted", true)
|
|
113
|
-
genAiOutputTokens?: TokenCount;
|
|
114
|
-
|
|
115
|
-
@doc("Estimated cost in USD")
|
|
116
|
-
@TypeSpec.OpenAPI.extension("x-promoted", true)
|
|
117
|
-
genAiCostUsd?: CostUsd;
|
|
118
|
-
|
|
119
|
-
@doc("Number of tool calls made")
|
|
120
|
-
toolCallCount?: int32;
|
|
121
|
-
|
|
122
|
-
// === Timing ===
|
|
123
|
-
|
|
124
|
-
@doc("Start timestamp in nanoseconds since epoch")
|
|
125
|
-
startTimeUnixNano: UnixNanos;
|
|
126
|
-
|
|
127
|
-
@doc("End timestamp in nanoseconds since epoch")
|
|
128
|
-
endTimeUnixNano?: UnixNanos;
|
|
129
|
-
|
|
130
|
-
@doc("Duration in nanoseconds")
|
|
131
|
-
durationNs?: DurationNs;
|
|
132
|
-
|
|
133
|
-
// === Service Info ===
|
|
134
|
-
|
|
135
|
-
@doc("Service name from resource attributes")
|
|
136
|
-
@TypeSpec.OpenAPI.extension("x-promoted", true)
|
|
137
|
-
serviceName?: string;
|
|
138
|
-
|
|
139
|
-
// === Error ===
|
|
140
|
-
|
|
141
|
-
@doc("Error message if failed")
|
|
142
|
-
errorMessage?: string;
|
|
143
|
-
|
|
144
|
-
// === Attributes (JSON Blobs) ===
|
|
145
|
-
|
|
146
|
-
@doc("Additional attributes as JSON")
|
|
147
|
-
attributesJson?: string;
|
|
148
|
-
|
|
149
|
-
// === Internal ===
|
|
150
|
-
|
|
151
|
-
@doc("Row creation timestamp")
|
|
152
|
-
@TypeSpec.OpenAPI.extension("x-internal", true)
|
|
153
|
-
createdAt?: utcDateTime;
|
|
154
|
-
}
|