@ancplua/qyl-api-schema 0.4.0 → 0.5.1
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 +52 -64
- package/api/routes.tsp +90 -943
- package/api/runner.tsp +99 -0
- package/api/streaming.tsp +13 -299
- package/common/errors.tsp +14 -1
- package/common/pagination.tsp +1 -1
- package/common/types.tsp +2 -41
- package/generated/json-schema/qyl-api-schema.json +3868 -0
- package/generated/openapi/qyl.openapi.json +6919 -0
- package/generated/ts-runtime/api.d.ts +886 -0
- package/generated/ts-runtime/api.js +237 -0
- package/index.tsp +8 -34
- package/models/health.tsp +22 -0
- package/models/mcp-tools.tsp +217 -0
- package/models/runner-mcp.tsp +76 -0
- package/models/runner.tsp +67 -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 +9 -6
- package/package.json +56 -36
- 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/otel/profiles.tsp
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// =============================================================================
|
|
2
|
-
//
|
|
2
|
+
// OpenTelemetry profiles JSON projection (v1development)
|
|
3
3
|
// =============================================================================
|
|
4
4
|
// Continuous profiling signal following OTel Profiles proto specification.
|
|
5
5
|
// Proto package: opentelemetry.proto.profiles.v1development
|
package/otel/resource.tsp
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// =============================================================================
|
|
2
|
-
//
|
|
2
|
+
// OpenTelemetry resource JSON projection
|
|
3
3
|
// =============================================================================
|
|
4
4
|
// Resource attributes identifying the entity producing telemetry.
|
|
5
5
|
// =============================================================================
|
package/otel/span.tsp
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// =============================================================================
|
|
2
|
-
//
|
|
2
|
+
// OpenTelemetry span JSON projection
|
|
3
3
|
// =============================================================================
|
|
4
4
|
// Distributed tracing span representation following OTel specification.
|
|
5
5
|
// =============================================================================
|
|
@@ -147,16 +147,13 @@ model SpanLink {
|
|
|
147
147
|
// Trace Model (Collection of Spans)
|
|
148
148
|
// =============================================================================
|
|
149
149
|
|
|
150
|
-
@doc("
|
|
151
|
-
model
|
|
150
|
+
@doc("Trace summary without the full span collection")
|
|
151
|
+
model TraceSummary {
|
|
152
152
|
@doc("Trace identifier")
|
|
153
153
|
@key
|
|
154
154
|
@encodedName("application/json", "trace_id")
|
|
155
155
|
traceId: TraceId;
|
|
156
156
|
|
|
157
|
-
@doc("All spans in this trace")
|
|
158
|
-
spans: Span[];
|
|
159
|
-
|
|
160
157
|
@doc("Root span of the trace")
|
|
161
158
|
@encodedName("application/json", "root_span")
|
|
162
159
|
rootSpan?: Span;
|
|
@@ -185,6 +182,12 @@ model Trace {
|
|
|
185
182
|
hasError: boolean;
|
|
186
183
|
}
|
|
187
184
|
|
|
185
|
+
@doc("Complete trace containing all related spans")
|
|
186
|
+
model Trace extends TraceSummary {
|
|
187
|
+
@doc("All spans in this trace")
|
|
188
|
+
spans: Span[];
|
|
189
|
+
}
|
|
190
|
+
|
|
188
191
|
// =============================================================================
|
|
189
192
|
// Span Query Filters
|
|
190
193
|
// =============================================================================
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancplua/qyl-api-schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "TypeSpec source of truth for qyl API contracts. Emits OpenAPI, JSON Schema, Qyl.Api.Contracts DTOs, and TypeScript contract types; not an OpenTelemetry package, storage schema, or server implementation.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -19,29 +19,57 @@
|
|
|
19
19
|
"openapi"
|
|
20
20
|
],
|
|
21
21
|
"type": "module",
|
|
22
|
+
"tspMain": "index.tsp",
|
|
22
23
|
"exports": {
|
|
23
|
-
".":
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"./
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"./generated/otel-keys":
|
|
24
|
+
".": {
|
|
25
|
+
"typespec": "./index.tsp",
|
|
26
|
+
"default": "./index.tsp"
|
|
27
|
+
},
|
|
28
|
+
"./otel": {
|
|
29
|
+
"typespec": "./otel/otel-conventions.tsp",
|
|
30
|
+
"default": "./otel/otel-conventions.tsp"
|
|
31
|
+
},
|
|
32
|
+
"./generated/otel-keys": {
|
|
33
|
+
"typespec": "./generated/otel-keys.gen.tsp",
|
|
34
|
+
"default": "./generated/otel-keys.gen.tsp"
|
|
35
|
+
},
|
|
36
|
+
"./types": {
|
|
37
|
+
"types": "./generated/ts-runtime/api.d.ts",
|
|
38
|
+
"import": "./generated/ts-runtime/api.js",
|
|
39
|
+
"default": "./generated/ts-runtime/api.js"
|
|
40
|
+
},
|
|
41
|
+
"./openapi": {
|
|
42
|
+
"default": "./generated/openapi/qyl.openapi.json"
|
|
43
|
+
},
|
|
44
|
+
"./json-schema": {
|
|
45
|
+
"default": "./generated/json-schema/qyl-api-schema.json"
|
|
46
|
+
}
|
|
32
47
|
},
|
|
33
48
|
"files": [
|
|
34
49
|
"index.tsp",
|
|
35
|
-
"api
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
50
|
+
"api/routes.tsp",
|
|
51
|
+
"api/runner.tsp",
|
|
52
|
+
"api/streaming.tsp",
|
|
53
|
+
"common/errors.tsp",
|
|
54
|
+
"common/pagination.tsp",
|
|
55
|
+
"common/types.tsp",
|
|
56
|
+
"models/health.tsp",
|
|
57
|
+
"models/runner-mcp.tsp",
|
|
58
|
+
"models/runner.tsp",
|
|
59
|
+
"models/mcp-tools.tsp",
|
|
60
|
+
"models/session.tsp",
|
|
61
|
+
"otel/enums.tsp",
|
|
62
|
+
"otel/logs.tsp",
|
|
63
|
+
"otel/otel-conventions.tsp",
|
|
64
|
+
"otel/profiles.tsp",
|
|
65
|
+
"otel/resource.tsp",
|
|
66
|
+
"otel/span.tsp",
|
|
67
|
+
"generated/otel-keys.gen.tsp",
|
|
68
|
+
"generated/ts-runtime/api.d.ts",
|
|
69
|
+
"generated/ts-runtime/api.js",
|
|
70
|
+
"generated/openapi/qyl.openapi.json",
|
|
71
|
+
"generated/json-schema/qyl-api-schema.json",
|
|
43
72
|
"README.md",
|
|
44
|
-
"VERSIONING.md",
|
|
45
73
|
"LICENSE"
|
|
46
74
|
],
|
|
47
75
|
"publishConfig": {
|
|
@@ -50,9 +78,13 @@
|
|
|
50
78
|
"registry": "https://registry.npmjs.org"
|
|
51
79
|
},
|
|
52
80
|
"scripts": {
|
|
53
|
-
"
|
|
81
|
+
"clean:generated": "node scripts/clean-generated.mjs",
|
|
82
|
+
"build:emitters": "tsc -p emitters/csharp && tsc -p emitters/ts-types",
|
|
83
|
+
"build:ts-runtime": "tsc -p tsconfig.contracts.json",
|
|
84
|
+
"build:json-schema": "node scripts/openapi-to-json-schema.mjs",
|
|
54
85
|
"prepare": "npm run build:emitters",
|
|
55
|
-
"
|
|
86
|
+
"prepack": "npm run compile",
|
|
87
|
+
"compile": "npm run clean:generated && npm run build:emitters && tsp compile main.tsp && npm run build:json-schema && npm run build:ts-runtime",
|
|
56
88
|
"watch": "tsp compile main.tsp --watch",
|
|
57
89
|
"format": "tsp format **/*.tsp",
|
|
58
90
|
"lint": "npm run build:emitters && tsp compile main.tsp --no-emit --warn-as-error",
|
|
@@ -62,31 +94,19 @@
|
|
|
62
94
|
"@typespec/compiler": "^1.13.0 || >=1.13.0-dev.0",
|
|
63
95
|
"@typespec/events": "^0.83.0",
|
|
64
96
|
"@typespec/http": "^1.13.0",
|
|
65
|
-
"@typespec/json-schema": "^1.13.0",
|
|
66
97
|
"@typespec/openapi": "^1.13.0",
|
|
67
|
-
"@typespec/
|
|
68
|
-
"@typespec/rest": "^0.83.0",
|
|
69
|
-
"@typespec/sse": "^0.83.0",
|
|
70
|
-
"@typespec/streams": "^0.83.0",
|
|
71
|
-
"@typespec/versioning": "^0.83.0"
|
|
98
|
+
"@typespec/sse": "^0.83.0"
|
|
72
99
|
},
|
|
73
100
|
"devDependencies": {
|
|
74
101
|
"@ancplua/typespec-emit-csharp": "file:./emitters/csharp",
|
|
75
102
|
"@ancplua/typespec-emit-ts-types": "file:./emitters/ts-types",
|
|
76
|
-
"@
|
|
77
|
-
"@qyl/telemetry-control-graph": "file:./emitters/telemetry-control-graph",
|
|
78
|
-
"@types/node": "25.9.4",
|
|
103
|
+
"@types/node": "25.9.5",
|
|
79
104
|
"@typespec/compiler": "1.13.0",
|
|
80
105
|
"@typespec/events": "0.83.0",
|
|
81
106
|
"@typespec/http": "1.13.0",
|
|
82
|
-
"@typespec/json-schema": "1.13.0",
|
|
83
107
|
"@typespec/openapi": "1.13.0",
|
|
84
108
|
"@typespec/openapi3": "1.13.0",
|
|
85
|
-
"@typespec/rest": "0.83.0",
|
|
86
109
|
"@typespec/sse": "0.83.0",
|
|
87
|
-
"
|
|
88
|
-
"@typespec/versioning": "0.83.0",
|
|
89
|
-
"typescript": "6.0.3",
|
|
90
|
-
"vitest": "4.1.9"
|
|
110
|
+
"typescript": "6.0.3"
|
|
91
111
|
}
|
|
92
112
|
}
|
package/VERSIONING.md
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# TypeSpec Versioning In qyl-api-schema
|
|
2
|
-
|
|
3
|
-
This repository uses `@typespec/versioning` to record when schema elements were added or removed across qyl API versions and OpenTelemetry compatibility-model pins. The annotations live in TypeSpec so schema evolution is reviewable at the contract source.
|
|
4
|
-
|
|
5
|
-
## Release versioning (the package version)
|
|
6
|
-
|
|
7
|
-
Separate from the `@typespec/versioning` schema annotations below: the published **package** version
|
|
8
|
-
(npm `@ancplua/qyl-api-schema` and NuGet `Qyl.Api.Contracts`) is **CI-owned and tag-derived** — no
|
|
9
|
-
hand-bumped version lives in any committed file. To cut a release, publish a GitHub Release whose tag
|
|
10
|
-
is `vMAJOR.MINOR.PATCH[-prerelease]`; `publish.yml` strips the leading `v` and stamps that single
|
|
11
|
-
version onto both npm and NuGet (no build metadata — npm rejects it and NuGet strips it), so the two
|
|
12
|
-
registries are lockstep by construction. The committed `package.json` version is the non-authoritative
|
|
13
|
-
placeholder `0.0.0-development`, and `packaging/Qyl.Api.Contracts.csproj` carries no `<Version>`.
|
|
14
|
-
|
|
15
|
-
## Where it is used
|
|
16
|
-
|
|
17
|
-
- `models/genai.tsp` for GenAI semantic-convention shaped models
|
|
18
|
-
- `models/db.tsp` for DB semantic-convention shaped models
|
|
19
|
-
- `models/http.tsp` for HTTP semantic-convention shaped models
|
|
20
|
-
- `api/routes.tsp` for API versioning
|
|
21
|
-
|
|
22
|
-
## Pattern: version registry + annotations
|
|
23
|
-
|
|
24
|
-
```tsp
|
|
25
|
-
import "@typespec/versioning";
|
|
26
|
-
using TypeSpec.Versioning;
|
|
27
|
-
|
|
28
|
-
@versioned(GenAiVersions)
|
|
29
|
-
namespace Qyl.Api.Contracts.Domains.AI.GenAi;
|
|
30
|
-
|
|
31
|
-
enum GenAiVersions {
|
|
32
|
-
v1_27: "1.27.0",
|
|
33
|
-
v1_38: "1.38.0",
|
|
34
|
-
v1_40: "1.40.0",
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Keep version enums **minimal**: only the baseline plus versions actually
|
|
39
|
-
referenced by an `@added`/`@removed` annotation. Unreferenced members are
|
|
40
|
-
dead timeline points that rot (an axis with no annotations at all should
|
|
41
|
-
lose `@versioned` entirely — that happened to `HttpVersions`/`DbVersions`
|
|
42
|
-
in 0.4.0).
|
|
43
|
-
|
|
44
|
-
```tsp
|
|
45
|
-
|
|
46
|
-
model GenAiSpanAttributes {
|
|
47
|
-
@encodedName("application/json", ANcpLua.OpenTelemetry.SemanticConventions.Keys.GenAi.UsageInputTokens)
|
|
48
|
-
usageInputTokens?: TokenCount;
|
|
49
|
-
|
|
50
|
-
@encodedName("application/json", "gen_ai.usage.input_tokens.cached")
|
|
51
|
-
@added(GenAiVersions.v1_38)
|
|
52
|
-
usageInputTokensCached?: TokenCount;
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Note (v0.3.0): the pre-migration `gen_ai.*` fields that carried upstream-deleted
|
|
57
|
-
wire keys (`gen_ai.system`, `gen_ai.prompt`, `gen_ai.completion`,
|
|
58
|
-
`gen_ai.usage.prompt_tokens` / `.completion_tokens`, and the
|
|
59
|
-
`gen_ai.openai.*` vendor keys) were **removed from the contract surface**
|
|
60
|
-
when the OTel 1.42 GenAI-registry split was adopted. Old-key telemetry is a
|
|
61
|
-
collector *ingestion normalization* concern (mapping below), not a contract
|
|
62
|
-
field.
|
|
63
|
-
|
|
64
|
-
## Ingestion mapping (deprecated -> current)
|
|
65
|
-
|
|
66
|
-
Consumers can keep ingestion backward-compatible by normalizing deprecated attribute keys. Keep any downstream mapping aligned with the TypeSpec history.
|
|
67
|
-
|
|
68
|
-
```csharp
|
|
69
|
-
public static readonly FrozenDictionary<string, string> DeprecatedMappings =
|
|
70
|
-
new Dictionary<string, string>(StringComparer.Ordinal)
|
|
71
|
-
{
|
|
72
|
-
["gen_ai.system"] = "gen_ai.provider.name",
|
|
73
|
-
["gen_ai.usage.prompt_tokens"] = "gen_ai.usage.input_tokens",
|
|
74
|
-
["gen_ai.usage.completion_tokens"] = "gen_ai.usage.output_tokens",
|
|
75
|
-
["agents.tool.call_id"] = "gen_ai.tool.call.id",
|
|
76
|
-
["db.system"] = "db.system.name"
|
|
77
|
-
}.ToFrozenDictionary(StringComparer.Ordinal);
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Downstream consumers should cover these mappings in ingestion tests.
|
|
81
|
-
|
|
82
|
-
## Workflow for schema evolution
|
|
83
|
-
|
|
84
|
-
- Add a new version entry to the enum in the owning namespace.
|
|
85
|
-
- Mark additions and removals with `@added` and `@removed`.
|
|
86
|
-
- Update downstream normalization mappings to keep ingestion compatibility.
|
|
87
|
-
- Extend downstream ingestion tests to cover the new mapping.
|
|
88
|
-
- Run `npm run compile` after TypeSpec changes.
|
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
|
-
// ---------------------------------------------------------------------------
|