@neat.is/types 0.9.8-dev.20260828 → 0.9.8
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/dist/index.cjs +332 -213
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +473 -30
- package/dist/index.d.ts +473 -30
- package/dist/index.js +322 -213
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -778,6 +778,101 @@ var AskResultSchema = z5.object({
|
|
|
778
778
|
provenance: z5.array(ProvenanceSchema)
|
|
779
779
|
});
|
|
780
780
|
|
|
781
|
+
// src/incident-card.ts
|
|
782
|
+
import { z as z6 } from "zod";
|
|
783
|
+
var IncidentKindSchema = z6.enum([
|
|
784
|
+
"exception",
|
|
785
|
+
"5xx",
|
|
786
|
+
"4xx-burst",
|
|
787
|
+
"status-error",
|
|
788
|
+
"connector"
|
|
789
|
+
]);
|
|
790
|
+
var IncidentChainHopSchema = z6.object({
|
|
791
|
+
node: z6.string(),
|
|
792
|
+
// 'service' | 'file' | 'symbol' | 'table' | 'column' | … — the node's own grain.
|
|
793
|
+
grain: z6.string(),
|
|
794
|
+
// The edge INTO this hop from the previous one, when cheaply known.
|
|
795
|
+
edgeType: z6.string().optional(),
|
|
796
|
+
provenance: ProvenanceSchema,
|
|
797
|
+
carriesSignal: z6.boolean().optional()
|
|
798
|
+
});
|
|
799
|
+
var IncidentLocusSchema = z6.object({
|
|
800
|
+
file: z6.string(),
|
|
801
|
+
lineStart: z6.number().int().optional(),
|
|
802
|
+
lineEnd: z6.number().int().optional(),
|
|
803
|
+
symbol: z6.string().optional(),
|
|
804
|
+
service: z6.string().optional(),
|
|
805
|
+
provenance: ProvenanceSchema
|
|
806
|
+
});
|
|
807
|
+
var IncidentRootCauseSchema = z6.object({
|
|
808
|
+
node: z6.string(),
|
|
809
|
+
classification: z6.string().optional(),
|
|
810
|
+
reason: z6.string(),
|
|
811
|
+
confidence: z6.number().min(0).max(1),
|
|
812
|
+
fix: z6.string().nullable().optional(),
|
|
813
|
+
chain: z6.array(IncidentChainHopSchema)
|
|
814
|
+
});
|
|
815
|
+
var IncidentBlastRadiusSchema = z6.object({
|
|
816
|
+
totalAffected: z6.number().int().nonnegative(),
|
|
817
|
+
nearest: z6.array(
|
|
818
|
+
z6.object({
|
|
819
|
+
node: z6.string(),
|
|
820
|
+
distance: z6.number().int().nonnegative(),
|
|
821
|
+
provenance: ProvenanceSchema
|
|
822
|
+
})
|
|
823
|
+
)
|
|
824
|
+
});
|
|
825
|
+
var IncidentPolicySchema = z6.object({
|
|
826
|
+
policyName: z6.string(),
|
|
827
|
+
severity: z6.string(),
|
|
828
|
+
message: z6.string().optional()
|
|
829
|
+
});
|
|
830
|
+
var IncidentDivergenceSchema = z6.object({
|
|
831
|
+
type: z6.string(),
|
|
832
|
+
summary: z6.string()
|
|
833
|
+
});
|
|
834
|
+
var IncidentCardSchema = z6.object({
|
|
835
|
+
kind: z6.literal("incident"),
|
|
836
|
+
id: z6.string(),
|
|
837
|
+
// ISO8601 — the incident's own time.
|
|
838
|
+
at: z6.string(),
|
|
839
|
+
incidentKind: IncidentKindSchema,
|
|
840
|
+
service: z6.string(),
|
|
841
|
+
affectedNode: z6.string(),
|
|
842
|
+
message: z6.string(),
|
|
843
|
+
exceptionType: z6.string().optional(),
|
|
844
|
+
httpStatusCode: z6.number().int().optional(),
|
|
845
|
+
// Coalesced burst size (ErrorEvent.incidentCount).
|
|
846
|
+
count: z6.number().int().positive().optional(),
|
|
847
|
+
window: z6.object({ first: z6.string(), last: z6.string() }).optional(),
|
|
848
|
+
traceId: z6.string().optional(),
|
|
849
|
+
spanId: z6.string().optional(),
|
|
850
|
+
locus: IncidentLocusSchema.nullable(),
|
|
851
|
+
rootCause: IncidentRootCauseSchema.nullable(),
|
|
852
|
+
blastRadius: IncidentBlastRadiusSchema.optional(),
|
|
853
|
+
policies: z6.array(IncidentPolicySchema).optional(),
|
|
854
|
+
divergence: z6.array(IncidentDivergenceSchema).optional(),
|
|
855
|
+
// The rendered one-line sentence — a human/loose-LLM read over the structured
|
|
856
|
+
// body, never the wire format.
|
|
857
|
+
headline: z6.string()
|
|
858
|
+
});
|
|
859
|
+
var IncidentEventPayloadSchema = z6.object({
|
|
860
|
+
incidentId: z6.string(),
|
|
861
|
+
affectedNode: z6.string(),
|
|
862
|
+
service: z6.string(),
|
|
863
|
+
incidentKind: IncidentKindSchema,
|
|
864
|
+
at: z6.string()
|
|
865
|
+
});
|
|
866
|
+
function incidentKindOf(ev) {
|
|
867
|
+
const et = ev.errorType;
|
|
868
|
+
if (et === "grpc-failure") return "status-error";
|
|
869
|
+
if (et === "http-failure") {
|
|
870
|
+
return ev.incidentCount && ev.incidentCount > 1 ? "4xx-burst" : "5xx";
|
|
871
|
+
}
|
|
872
|
+
if (et) return "connector";
|
|
873
|
+
return "exception";
|
|
874
|
+
}
|
|
875
|
+
|
|
781
876
|
// src/identity.ts
|
|
782
877
|
var SERVICE_PREFIX = "service:";
|
|
783
878
|
var DATABASE_PREFIX = "database:";
|
|
@@ -990,11 +1085,11 @@ var PROV_RANK = Object.freeze({
|
|
|
990
1085
|
});
|
|
991
1086
|
|
|
992
1087
|
// src/policy.ts
|
|
993
|
-
import { z as
|
|
994
|
-
var PolicySeveritySchema =
|
|
995
|
-
var PolicyActionSchema =
|
|
996
|
-
var StructuralRuleSchema =
|
|
997
|
-
type:
|
|
1088
|
+
import { z as z7 } from "zod";
|
|
1089
|
+
var PolicySeveritySchema = z7.enum(["info", "warning", "error", "critical"]);
|
|
1090
|
+
var PolicyActionSchema = z7.enum(["log", "alert", "block"]);
|
|
1091
|
+
var StructuralRuleSchema = z7.object({
|
|
1092
|
+
type: z7.literal("structural"),
|
|
998
1093
|
// Node type the rule applies to. Every node of this type must satisfy the
|
|
999
1094
|
// edge requirement below.
|
|
1000
1095
|
fromNodeType: NodeTypeSchema,
|
|
@@ -1003,61 +1098,61 @@ var StructuralRuleSchema = z6.object({
|
|
|
1003
1098
|
// Required target node type at the other end of the edge.
|
|
1004
1099
|
toNodeType: NodeTypeSchema
|
|
1005
1100
|
});
|
|
1006
|
-
var CompatibilityRuleSchema =
|
|
1007
|
-
type:
|
|
1101
|
+
var CompatibilityRuleSchema = z7.object({
|
|
1102
|
+
type: z7.literal("compatibility"),
|
|
1008
1103
|
// Optional kind narrowing. When omitted, all four compat shapes
|
|
1009
1104
|
// (driver-engine, node-engine, package-conflict, deprecated-api) run.
|
|
1010
|
-
kind:
|
|
1105
|
+
kind: z7.enum(["driver-engine", "node-engine", "package-conflict", "deprecated-api"]).optional()
|
|
1011
1106
|
});
|
|
1012
|
-
var ProvenanceRuleSchema =
|
|
1013
|
-
type:
|
|
1107
|
+
var ProvenanceRuleSchema = z7.object({
|
|
1108
|
+
type: z7.literal("provenance"),
|
|
1014
1109
|
// Edge type the rule applies to.
|
|
1015
1110
|
edgeType: EdgeTypeSchema,
|
|
1016
1111
|
// Target node id (e.g. 'service:payments') that incoming edges of edgeType
|
|
1017
1112
|
// must satisfy. Optional — when omitted, the rule runs against every edge
|
|
1018
1113
|
// of edgeType regardless of target.
|
|
1019
|
-
targetNodeId:
|
|
1114
|
+
targetNodeId: z7.string().optional(),
|
|
1020
1115
|
// Required provenance (single value or one-of). The audit fails if the
|
|
1021
1116
|
// observed edge's provenance is not in this set.
|
|
1022
|
-
required:
|
|
1117
|
+
required: z7.union([ProvenanceSchema, z7.array(ProvenanceSchema).min(1)])
|
|
1023
1118
|
});
|
|
1024
|
-
var OwnershipRuleSchema =
|
|
1025
|
-
type:
|
|
1119
|
+
var OwnershipRuleSchema = z7.object({
|
|
1120
|
+
type: z7.literal("ownership"),
|
|
1026
1121
|
// Node type the rule applies to. ServiceNode is the common case; the
|
|
1027
1122
|
// discriminator stays generic so future node types can opt in.
|
|
1028
1123
|
nodeType: NodeTypeSchema,
|
|
1029
1124
|
// Field name on the node attributes that must be non-empty. Defaults to
|
|
1030
1125
|
// 'owner' if omitted.
|
|
1031
|
-
field:
|
|
1126
|
+
field: z7.string().default("owner")
|
|
1032
1127
|
});
|
|
1033
|
-
var BlastRadiusRuleSchema =
|
|
1034
|
-
type:
|
|
1128
|
+
var BlastRadiusRuleSchema = z7.object({
|
|
1129
|
+
type: z7.literal("blast-radius"),
|
|
1035
1130
|
// Node type the rule applies to (ServiceNode is the common case).
|
|
1036
1131
|
nodeType: NodeTypeSchema,
|
|
1037
1132
|
// Cap on `totalAffected` from getBlastRadius. Inclusive — a node hitting
|
|
1038
1133
|
// exactly this number passes; > maxAffected fails.
|
|
1039
|
-
maxAffected:
|
|
1134
|
+
maxAffected: z7.number().int().positive(),
|
|
1040
1135
|
// Depth to evaluate against. Defaults to the contract's blast-radius
|
|
1041
1136
|
// default (10) when omitted.
|
|
1042
|
-
depth:
|
|
1137
|
+
depth: z7.number().int().positive().optional()
|
|
1043
1138
|
});
|
|
1044
|
-
var FieldGuardRuleSchema =
|
|
1045
|
-
type:
|
|
1139
|
+
var FieldGuardRuleSchema = z7.object({
|
|
1140
|
+
type: z7.literal("field-guard"),
|
|
1046
1141
|
// Node type the rule governs. InfraNode for the Firestore instance.
|
|
1047
1142
|
nodeType: NodeTypeSchema,
|
|
1048
1143
|
// Optional narrowing on InfraNode's free-string `kind` sub-type, so the rule
|
|
1049
1144
|
// applies to `firestore-collection` nodes without governing every InfraNode.
|
|
1050
|
-
nodeKind:
|
|
1145
|
+
nodeKind: z7.string().optional(),
|
|
1051
1146
|
// Set A — the named selector the evaluator resolves into the "must be covered"
|
|
1052
1147
|
// set. 'client-written-columns' reads ColumnAttr whose sdkWrites includes
|
|
1053
1148
|
// 'client'. A new instance adds a value here plus a resolver branch.
|
|
1054
|
-
subjectSet:
|
|
1149
|
+
subjectSet: z7.enum(["client-written-columns"]),
|
|
1055
1150
|
// Set B — the covering set: the node attribute (a string[]) whose members must
|
|
1056
1151
|
// include all of set A. 'guardedFields' for Firestore. Absent ⇒ indeterminate
|
|
1057
1152
|
// ⇒ silent.
|
|
1058
|
-
guardSet:
|
|
1153
|
+
guardSet: z7.string()
|
|
1059
1154
|
});
|
|
1060
|
-
var PolicyRuleSchema =
|
|
1155
|
+
var PolicyRuleSchema = z7.discriminatedUnion("type", [
|
|
1061
1156
|
StructuralRuleSchema,
|
|
1062
1157
|
CompatibilityRuleSchema,
|
|
1063
1158
|
ProvenanceRuleSchema,
|
|
@@ -1065,26 +1160,26 @@ var PolicyRuleSchema = z6.discriminatedUnion("type", [
|
|
|
1065
1160
|
BlastRadiusRuleSchema,
|
|
1066
1161
|
FieldGuardRuleSchema
|
|
1067
1162
|
]);
|
|
1068
|
-
var PolicySchema =
|
|
1163
|
+
var PolicySchema = z7.object({
|
|
1069
1164
|
// Unique within the file. Duplicates fail PolicyFileSchema.parse.
|
|
1070
|
-
id:
|
|
1071
|
-
name:
|
|
1072
|
-
description:
|
|
1165
|
+
id: z7.string().min(1),
|
|
1166
|
+
name: z7.string().min(1),
|
|
1167
|
+
description: z7.string().optional(),
|
|
1073
1168
|
severity: PolicySeveritySchema,
|
|
1074
1169
|
// When omitted, the engine derives a default from severity per ADR-044
|
|
1075
1170
|
// (info→log, warning→alert, error→alert, critical→block).
|
|
1076
1171
|
onViolation: PolicyActionSchema.optional(),
|
|
1077
1172
|
rule: PolicyRuleSchema
|
|
1078
1173
|
});
|
|
1079
|
-
var PolicyFileSchema =
|
|
1080
|
-
version:
|
|
1081
|
-
policies:
|
|
1174
|
+
var PolicyFileSchema = z7.object({
|
|
1175
|
+
version: z7.literal(1),
|
|
1176
|
+
policies: z7.array(PolicySchema)
|
|
1082
1177
|
}).superRefine((file, ctx) => {
|
|
1083
1178
|
const seen = /* @__PURE__ */ new Set();
|
|
1084
1179
|
for (const [i, p] of file.policies.entries()) {
|
|
1085
1180
|
if (seen.has(p.id)) {
|
|
1086
1181
|
ctx.addIssue({
|
|
1087
|
-
code:
|
|
1182
|
+
code: z7.ZodIssueCode.custom,
|
|
1088
1183
|
path: ["policies", i, "id"],
|
|
1089
1184
|
message: `duplicate policy id "${p.id}"`
|
|
1090
1185
|
});
|
|
@@ -1092,173 +1187,173 @@ var PolicyFileSchema = z6.object({
|
|
|
1092
1187
|
seen.add(p.id);
|
|
1093
1188
|
}
|
|
1094
1189
|
});
|
|
1095
|
-
var HypotheticalActionSchema =
|
|
1096
|
-
|
|
1097
|
-
kind:
|
|
1190
|
+
var HypotheticalActionSchema = z7.discriminatedUnion("kind", [
|
|
1191
|
+
z7.object({
|
|
1192
|
+
kind: z7.literal("promote-frontier"),
|
|
1098
1193
|
// The FrontierNode id that would be promoted.
|
|
1099
|
-
frontierId:
|
|
1194
|
+
frontierId: z7.string().min(1)
|
|
1100
1195
|
}),
|
|
1101
|
-
|
|
1102
|
-
kind:
|
|
1103
|
-
source:
|
|
1104
|
-
target:
|
|
1196
|
+
z7.object({
|
|
1197
|
+
kind: z7.literal("add-edge"),
|
|
1198
|
+
source: z7.string().min(1),
|
|
1199
|
+
target: z7.string().min(1),
|
|
1105
1200
|
edgeType: EdgeTypeSchema,
|
|
1106
1201
|
provenance: ProvenanceSchema
|
|
1107
1202
|
})
|
|
1108
1203
|
]);
|
|
1109
|
-
var PoliciesCheckBodySchema =
|
|
1204
|
+
var PoliciesCheckBodySchema = z7.object({
|
|
1110
1205
|
hypotheticalAction: HypotheticalActionSchema.optional()
|
|
1111
1206
|
});
|
|
1112
|
-
var CheckPoliciesScopeSchema =
|
|
1113
|
-
|
|
1114
|
-
|
|
1207
|
+
var CheckPoliciesScopeSchema = z7.union([
|
|
1208
|
+
z7.enum(["all", "unresolved"]),
|
|
1209
|
+
z7.object({ policyId: z7.string().min(1) })
|
|
1115
1210
|
]);
|
|
1116
|
-
var ApplicablePolicySchema =
|
|
1117
|
-
policyId:
|
|
1118
|
-
policyName:
|
|
1119
|
-
description:
|
|
1211
|
+
var ApplicablePolicySchema = z7.object({
|
|
1212
|
+
policyId: z7.string().min(1),
|
|
1213
|
+
policyName: z7.string().min(1),
|
|
1214
|
+
description: z7.string().optional(),
|
|
1120
1215
|
severity: PolicySeveritySchema,
|
|
1121
1216
|
// The action the post-launch kernel gate WOULD take (ADR-093) — resolved
|
|
1122
1217
|
// from policy.onViolation or the severity default. Shown for awareness only;
|
|
1123
1218
|
// the soft guardrail never acts on it.
|
|
1124
1219
|
onViolation: PolicyActionSchema,
|
|
1125
|
-
ruleType:
|
|
1126
|
-
match:
|
|
1220
|
+
ruleType: z7.enum(["structural", "compatibility", "provenance", "ownership", "blast-radius", "field-guard"]),
|
|
1221
|
+
match: z7.enum(["subject", "region"]),
|
|
1127
1222
|
// Human-readable reason the policy applies here — rides into agent context.
|
|
1128
|
-
reason:
|
|
1223
|
+
reason: z7.string().min(1)
|
|
1129
1224
|
});
|
|
1130
|
-
var ApplicablePoliciesResponseSchema =
|
|
1131
|
-
node:
|
|
1132
|
-
applicable:
|
|
1225
|
+
var ApplicablePoliciesResponseSchema = z7.object({
|
|
1226
|
+
node: z7.string().min(1),
|
|
1227
|
+
applicable: z7.array(ApplicablePolicySchema)
|
|
1133
1228
|
});
|
|
1134
|
-
var PolicyViolationSchema =
|
|
1229
|
+
var PolicyViolationSchema = z7.object({
|
|
1135
1230
|
// ${policy.id}:${violation-context}. The violation-context is shape-
|
|
1136
1231
|
// specific (e.g. nodeId for structural; edgeId for provenance).
|
|
1137
|
-
id:
|
|
1138
|
-
policyId:
|
|
1139
|
-
policyName:
|
|
1232
|
+
id: z7.string().min(1),
|
|
1233
|
+
policyId: z7.string().min(1),
|
|
1234
|
+
policyName: z7.string().min(1),
|
|
1140
1235
|
severity: PolicySeveritySchema,
|
|
1141
1236
|
// Resolved at evaluation time — either the explicit policy.onViolation or
|
|
1142
1237
|
// the severity-derived default per ADR-044.
|
|
1143
1238
|
onViolation: PolicyActionSchema,
|
|
1144
|
-
ruleType:
|
|
1145
|
-
subject:
|
|
1146
|
-
nodeId:
|
|
1147
|
-
edgeId:
|
|
1148
|
-
path:
|
|
1239
|
+
ruleType: z7.enum(["structural", "compatibility", "provenance", "ownership", "blast-radius", "field-guard"]),
|
|
1240
|
+
subject: z7.object({
|
|
1241
|
+
nodeId: z7.string().optional(),
|
|
1242
|
+
edgeId: z7.string().optional(),
|
|
1243
|
+
path: z7.array(z7.string()).optional()
|
|
1149
1244
|
}).refine(
|
|
1150
1245
|
(s) => s.nodeId !== void 0 || s.edgeId !== void 0 || s.path !== void 0,
|
|
1151
1246
|
{ message: "subject must carry at least one of nodeId, edgeId, path" }
|
|
1152
1247
|
),
|
|
1153
|
-
message:
|
|
1154
|
-
observedAt:
|
|
1248
|
+
message: z7.string().min(1),
|
|
1249
|
+
observedAt: z7.string().datetime()
|
|
1155
1250
|
});
|
|
1156
1251
|
|
|
1157
1252
|
// src/registry.ts
|
|
1158
|
-
import { z as
|
|
1159
|
-
var RegistryStatusSchema =
|
|
1160
|
-
var RegistryEntrySchema =
|
|
1253
|
+
import { z as z8 } from "zod";
|
|
1254
|
+
var RegistryStatusSchema = z8.enum(["active", "paused", "broken"]);
|
|
1255
|
+
var RegistryEntrySchema = z8.object({
|
|
1161
1256
|
// Unique within the registry. Project-scoped operations (`neat watch
|
|
1162
1257
|
// --project <name>`, `neatd reload <name>`) key on this. Collisions are a
|
|
1163
1258
|
// hard error at registration time.
|
|
1164
|
-
name:
|
|
1259
|
+
name: z8.string().min(1),
|
|
1165
1260
|
// Resolved absolute path on disk. Path normalisation is what keeps two
|
|
1166
1261
|
// `neat init` calls from different relative paths from creating two entries
|
|
1167
1262
|
// for the same directory.
|
|
1168
|
-
path:
|
|
1263
|
+
path: z8.string().min(1),
|
|
1169
1264
|
// ISO8601, set at first registration.
|
|
1170
|
-
registeredAt:
|
|
1265
|
+
registeredAt: z8.string(),
|
|
1171
1266
|
// ISO8601, updated whenever the daemon successfully sees the project.
|
|
1172
1267
|
// Optional because a freshly-registered project hasn't been seen yet.
|
|
1173
|
-
lastSeenAt:
|
|
1268
|
+
lastSeenAt: z8.string().optional(),
|
|
1174
1269
|
// Languages detected at `init` time. Free-form strings keyed off the
|
|
1175
1270
|
// installer modules — `'javascript'`, `'python'`, …
|
|
1176
|
-
languages:
|
|
1271
|
+
languages: z8.array(z8.string()),
|
|
1177
1272
|
status: RegistryStatusSchema
|
|
1178
1273
|
});
|
|
1179
|
-
var RegistryFileSchema =
|
|
1180
|
-
version:
|
|
1181
|
-
projects:
|
|
1274
|
+
var RegistryFileSchema = z8.object({
|
|
1275
|
+
version: z8.literal(1),
|
|
1276
|
+
projects: z8.array(RegistryEntrySchema)
|
|
1182
1277
|
});
|
|
1183
1278
|
var EMPTY_REGISTRY = { version: 1, projects: [] };
|
|
1184
1279
|
|
|
1185
1280
|
// src/divergence.ts
|
|
1186
|
-
import { z as
|
|
1281
|
+
import { z as z9 } from "zod";
|
|
1187
1282
|
var commonFields = {
|
|
1188
|
-
source:
|
|
1189
|
-
target:
|
|
1190
|
-
confidence:
|
|
1191
|
-
reason:
|
|
1192
|
-
recommendation:
|
|
1283
|
+
source: z9.string(),
|
|
1284
|
+
target: z9.string(),
|
|
1285
|
+
confidence: z9.number().min(0).max(1),
|
|
1286
|
+
reason: z9.string(),
|
|
1287
|
+
recommendation: z9.string()
|
|
1193
1288
|
};
|
|
1194
|
-
var MissingObservedDivergenceSchema =
|
|
1195
|
-
type:
|
|
1289
|
+
var MissingObservedDivergenceSchema = z9.object({
|
|
1290
|
+
type: z9.literal("missing-observed"),
|
|
1196
1291
|
...commonFields,
|
|
1197
1292
|
edgeType: EdgeTypeSchema.optional(),
|
|
1198
1293
|
extracted: GraphEdgeSchema.optional(),
|
|
1199
1294
|
// Column locus (ADR-157 §4): the `sql-table` node id and the declared-only column.
|
|
1200
|
-
table:
|
|
1201
|
-
column:
|
|
1295
|
+
table: z9.string().optional(),
|
|
1296
|
+
column: z9.string().optional()
|
|
1202
1297
|
});
|
|
1203
|
-
var MissingExtractedDivergenceSchema =
|
|
1204
|
-
type:
|
|
1298
|
+
var MissingExtractedDivergenceSchema = z9.object({
|
|
1299
|
+
type: z9.literal("missing-extracted"),
|
|
1205
1300
|
...commonFields,
|
|
1206
1301
|
edgeType: EdgeTypeSchema.optional(),
|
|
1207
1302
|
observed: GraphEdgeSchema.optional(),
|
|
1208
1303
|
// Column locus (ADR-157 §4): the `sql-table` node id and the observed-only column.
|
|
1209
|
-
table:
|
|
1210
|
-
column:
|
|
1304
|
+
table: z9.string().optional(),
|
|
1305
|
+
column: z9.string().optional()
|
|
1211
1306
|
});
|
|
1212
|
-
var CompatibilityVerdictSchema =
|
|
1213
|
-
var VersionMismatchDivergenceSchema =
|
|
1214
|
-
type:
|
|
1307
|
+
var CompatibilityVerdictSchema = z9.enum(["incompatible", "deprecated", "unknown"]);
|
|
1308
|
+
var VersionMismatchDivergenceSchema = z9.object({
|
|
1309
|
+
type: z9.literal("version-mismatch"),
|
|
1215
1310
|
...commonFields,
|
|
1216
|
-
extractedVersion:
|
|
1217
|
-
observedVersion:
|
|
1311
|
+
extractedVersion: z9.string(),
|
|
1312
|
+
observedVersion: z9.string(),
|
|
1218
1313
|
compatibility: CompatibilityVerdictSchema
|
|
1219
1314
|
});
|
|
1220
|
-
var HostMismatchDivergenceSchema =
|
|
1221
|
-
type:
|
|
1315
|
+
var HostMismatchDivergenceSchema = z9.object({
|
|
1316
|
+
type: z9.literal("host-mismatch"),
|
|
1222
1317
|
...commonFields,
|
|
1223
|
-
extractedHost:
|
|
1224
|
-
observedHost:
|
|
1225
|
-
});
|
|
1226
|
-
var CompatRuleRefSchema =
|
|
1227
|
-
kind:
|
|
1228
|
-
reason:
|
|
1229
|
-
package:
|
|
1230
|
-
driver:
|
|
1231
|
-
engine:
|
|
1232
|
-
});
|
|
1233
|
-
var CompatViolationDivergenceSchema =
|
|
1234
|
-
type:
|
|
1318
|
+
extractedHost: z9.string(),
|
|
1319
|
+
observedHost: z9.string()
|
|
1320
|
+
});
|
|
1321
|
+
var CompatRuleRefSchema = z9.object({
|
|
1322
|
+
kind: z9.string(),
|
|
1323
|
+
reason: z9.string(),
|
|
1324
|
+
package: z9.string().optional(),
|
|
1325
|
+
driver: z9.string().optional(),
|
|
1326
|
+
engine: z9.string().optional()
|
|
1327
|
+
});
|
|
1328
|
+
var CompatViolationDivergenceSchema = z9.object({
|
|
1329
|
+
type: z9.literal("compat-violation"),
|
|
1235
1330
|
...commonFields,
|
|
1236
1331
|
rule: CompatRuleRefSchema,
|
|
1237
1332
|
observed: GraphEdgeSchema
|
|
1238
1333
|
});
|
|
1239
|
-
var SymbolMismatchKindSchema =
|
|
1334
|
+
var SymbolMismatchKindSchema = z9.enum([
|
|
1240
1335
|
"missing-attribute",
|
|
1241
1336
|
"missing-field",
|
|
1242
1337
|
"missing-property",
|
|
1243
1338
|
"missing-column",
|
|
1244
1339
|
"undefined-method"
|
|
1245
1340
|
]);
|
|
1246
|
-
var ObservedSymbolMismatchDivergenceSchema =
|
|
1247
|
-
type:
|
|
1341
|
+
var ObservedSymbolMismatchDivergenceSchema = z9.object({
|
|
1342
|
+
type: z9.literal("observed-symbol-mismatch"),
|
|
1248
1343
|
...commonFields,
|
|
1249
1344
|
mismatchKind: SymbolMismatchKindSchema,
|
|
1250
|
-
symbol:
|
|
1251
|
-
location:
|
|
1345
|
+
symbol: z9.string().optional(),
|
|
1346
|
+
location: z9.string().optional(),
|
|
1252
1347
|
provenance: ProvenanceSchema,
|
|
1253
1348
|
// The OBSERVED incident this fuses — its id and the raw error text — so a
|
|
1254
1349
|
// consumer can trace the finding back to the recorded failure.
|
|
1255
|
-
incidentId:
|
|
1256
|
-
errorMessage:
|
|
1350
|
+
incidentId: z9.string().optional(),
|
|
1351
|
+
errorMessage: z9.string(),
|
|
1257
1352
|
// How many recorded incidents share this (node, member, mismatch) — the
|
|
1258
1353
|
// failure has usually fired more than once.
|
|
1259
|
-
incidentCount:
|
|
1354
|
+
incidentCount: z9.number().int().positive().optional()
|
|
1260
1355
|
});
|
|
1261
|
-
var ObservedFailureKindSchema =
|
|
1356
|
+
var ObservedFailureKindSchema = z9.enum([
|
|
1262
1357
|
"error-rate",
|
|
1263
1358
|
"connection-refused",
|
|
1264
1359
|
"deadline-exceeded",
|
|
@@ -1266,25 +1361,25 @@ var ObservedFailureKindSchema = z8.enum([
|
|
|
1266
1361
|
"unavailable",
|
|
1267
1362
|
"server-error"
|
|
1268
1363
|
]);
|
|
1269
|
-
var ObservedFailingDivergenceSchema =
|
|
1270
|
-
type:
|
|
1364
|
+
var ObservedFailingDivergenceSchema = z9.object({
|
|
1365
|
+
type: z9.literal("observed-failing"),
|
|
1271
1366
|
...commonFields,
|
|
1272
1367
|
failureKind: ObservedFailureKindSchema,
|
|
1273
1368
|
provenance: ProvenanceSchema,
|
|
1274
1369
|
// Edge locus (the observed dependency edge whose calls predominantly fail).
|
|
1275
1370
|
edgeType: EdgeTypeSchema.optional(),
|
|
1276
1371
|
observed: GraphEdgeSchema.optional(),
|
|
1277
|
-
spanCount:
|
|
1278
|
-
errorCount:
|
|
1279
|
-
errorRate:
|
|
1372
|
+
spanCount: z9.number().int().nonnegative().optional(),
|
|
1373
|
+
errorCount: z9.number().int().nonnegative().optional(),
|
|
1374
|
+
errorRate: z9.number().min(0).max(1).optional(),
|
|
1280
1375
|
// Incident locus (the declared external call whose incident shows a failure).
|
|
1281
|
-
location:
|
|
1282
|
-
incidentId:
|
|
1283
|
-
errorMessage:
|
|
1284
|
-
incidentCount:
|
|
1285
|
-
httpStatusCode:
|
|
1376
|
+
location: z9.string().optional(),
|
|
1377
|
+
incidentId: z9.string().optional(),
|
|
1378
|
+
errorMessage: z9.string().optional(),
|
|
1379
|
+
incidentCount: z9.number().int().positive().optional(),
|
|
1380
|
+
httpStatusCode: z9.number().int().optional()
|
|
1286
1381
|
});
|
|
1287
|
-
var DivergenceSchema =
|
|
1382
|
+
var DivergenceSchema = z9.discriminatedUnion("type", [
|
|
1288
1383
|
MissingObservedDivergenceSchema,
|
|
1289
1384
|
MissingExtractedDivergenceSchema,
|
|
1290
1385
|
VersionMismatchDivergenceSchema,
|
|
@@ -1293,14 +1388,14 @@ var DivergenceSchema = z8.discriminatedUnion("type", [
|
|
|
1293
1388
|
ObservedSymbolMismatchDivergenceSchema,
|
|
1294
1389
|
ObservedFailingDivergenceSchema
|
|
1295
1390
|
]);
|
|
1296
|
-
var DivergenceResultSchema =
|
|
1297
|
-
divergences:
|
|
1298
|
-
totalAffected:
|
|
1391
|
+
var DivergenceResultSchema = z9.object({
|
|
1392
|
+
divergences: z9.array(DivergenceSchema),
|
|
1393
|
+
totalAffected: z9.number().int().nonnegative(),
|
|
1299
1394
|
// ISO8601 timestamp the result was computed at. Each call re-derives from
|
|
1300
1395
|
// the live graph — there is no persisted divergence history.
|
|
1301
|
-
computedAt:
|
|
1396
|
+
computedAt: z9.string().datetime()
|
|
1302
1397
|
});
|
|
1303
|
-
var DivergenceTypeSchema =
|
|
1398
|
+
var DivergenceTypeSchema = z9.enum([
|
|
1304
1399
|
"missing-observed",
|
|
1305
1400
|
"missing-extracted",
|
|
1306
1401
|
"version-mismatch",
|
|
@@ -1317,6 +1412,10 @@ var MCP_TOOL_NAMES = [
|
|
|
1317
1412
|
"get_dependencies",
|
|
1318
1413
|
"get_observed_dependencies",
|
|
1319
1414
|
"get_incident_history",
|
|
1415
|
+
// One self-sufficient work order per incident (ADR-221): the incident fused
|
|
1416
|
+
// with its root-cause chain, blast radius, governing policies, and node
|
|
1417
|
+
// divergence, each claim provenance-stamped.
|
|
1418
|
+
"get_incident_card",
|
|
1320
1419
|
"semantic_search",
|
|
1321
1420
|
"get_graph_diff",
|
|
1322
1421
|
"get_recent_stale_edges",
|
|
@@ -1338,117 +1437,117 @@ var MCP_TOOL_NAMES = [
|
|
|
1338
1437
|
];
|
|
1339
1438
|
|
|
1340
1439
|
// src/responses.ts
|
|
1341
|
-
import { z as
|
|
1342
|
-
var listEnvelope = (itemSchema) =>
|
|
1343
|
-
count:
|
|
1344
|
-
total:
|
|
1345
|
-
events:
|
|
1440
|
+
import { z as z10 } from "zod";
|
|
1441
|
+
var listEnvelope = (itemSchema) => z10.object({
|
|
1442
|
+
count: z10.number().int().nonnegative(),
|
|
1443
|
+
total: z10.number().int().nonnegative(),
|
|
1444
|
+
events: z10.array(itemSchema)
|
|
1346
1445
|
});
|
|
1347
1446
|
var IncidentsResponseSchema = listEnvelope(ErrorEventSchema);
|
|
1348
1447
|
var StaleEventsResponseSchema = listEnvelope(StaleEventSchema);
|
|
1349
|
-
var LogsResponseSchema =
|
|
1350
|
-
count:
|
|
1351
|
-
total:
|
|
1352
|
-
logs:
|
|
1448
|
+
var LogsResponseSchema = z10.object({
|
|
1449
|
+
count: z10.number().int().nonnegative(),
|
|
1450
|
+
total: z10.number().int().nonnegative(),
|
|
1451
|
+
logs: z10.array(LogEntrySchema)
|
|
1353
1452
|
});
|
|
1354
|
-
var PoliciesViolationsResponseSchema =
|
|
1355
|
-
violations:
|
|
1453
|
+
var PoliciesViolationsResponseSchema = z10.object({
|
|
1454
|
+
violations: z10.array(PolicyViolationSchema)
|
|
1356
1455
|
});
|
|
1357
|
-
var GraphNodeResponseSchema =
|
|
1456
|
+
var GraphNodeResponseSchema = z10.object({
|
|
1358
1457
|
node: GraphNodeSchema
|
|
1359
1458
|
});
|
|
1360
|
-
var GraphEdgesResponseSchema =
|
|
1361
|
-
inbound:
|
|
1362
|
-
outbound:
|
|
1459
|
+
var GraphEdgesResponseSchema = z10.object({
|
|
1460
|
+
inbound: z10.array(GraphEdgeSchema),
|
|
1461
|
+
outbound: z10.array(GraphEdgeSchema)
|
|
1363
1462
|
});
|
|
1364
|
-
var ExtractionCoverageSchema =
|
|
1365
|
-
skippedFiles:
|
|
1366
|
-
byProducer:
|
|
1463
|
+
var ExtractionCoverageSchema = z10.object({
|
|
1464
|
+
skippedFiles: z10.number().int().nonnegative(),
|
|
1465
|
+
byProducer: z10.record(z10.number().int().nonnegative()),
|
|
1367
1466
|
// Up to a bounded sample of the files that failed to parse this pass.
|
|
1368
|
-
files:
|
|
1369
|
-
updatedAt:
|
|
1467
|
+
files: z10.array(z10.string()),
|
|
1468
|
+
updatedAt: z10.string()
|
|
1370
1469
|
});
|
|
1371
|
-
var HealthResponseSchema =
|
|
1372
|
-
ok:
|
|
1373
|
-
project:
|
|
1374
|
-
uptimeMs:
|
|
1470
|
+
var HealthResponseSchema = z10.object({
|
|
1471
|
+
ok: z10.boolean(),
|
|
1472
|
+
project: z10.string(),
|
|
1473
|
+
uptimeMs: z10.number().int().nonnegative(),
|
|
1375
1474
|
// Present when the most recent extraction pass recorded its coverage (#883).
|
|
1376
1475
|
coverage: ExtractionCoverageSchema.optional()
|
|
1377
1476
|
}).passthrough();
|
|
1378
|
-
var DaemonHealthResponseSchema =
|
|
1379
|
-
ok:
|
|
1380
|
-
uptimeMs:
|
|
1381
|
-
projects:
|
|
1382
|
-
|
|
1383
|
-
name:
|
|
1384
|
-
nodeCount:
|
|
1385
|
-
edgeCount:
|
|
1477
|
+
var DaemonHealthResponseSchema = z10.object({
|
|
1478
|
+
ok: z10.boolean(),
|
|
1479
|
+
uptimeMs: z10.number().int().nonnegative(),
|
|
1480
|
+
projects: z10.array(
|
|
1481
|
+
z10.object({
|
|
1482
|
+
name: z10.string(),
|
|
1483
|
+
nodeCount: z10.number().int().nonnegative(),
|
|
1484
|
+
edgeCount: z10.number().int().nonnegative()
|
|
1386
1485
|
}).passthrough()
|
|
1387
1486
|
)
|
|
1388
1487
|
}).passthrough();
|
|
1389
1488
|
var ProjectListEntrySchema = RegistryEntrySchema.extend({
|
|
1390
|
-
hostedHere:
|
|
1489
|
+
hostedHere: z10.boolean()
|
|
1391
1490
|
});
|
|
1392
|
-
var ProjectServedBySchema =
|
|
1393
|
-
path:
|
|
1394
|
-
restPort:
|
|
1395
|
-
live:
|
|
1491
|
+
var ProjectServedBySchema = z10.object({
|
|
1492
|
+
path: z10.string(),
|
|
1493
|
+
restPort: z10.number().int(),
|
|
1494
|
+
live: z10.boolean()
|
|
1396
1495
|
});
|
|
1397
|
-
var SingleProjectResponseSchema =
|
|
1496
|
+
var SingleProjectResponseSchema = z10.object({
|
|
1398
1497
|
project: ProjectListEntrySchema,
|
|
1399
1498
|
// Present only when this daemon does not host the project but another daemon
|
|
1400
1499
|
// on the machine does — names where it actually lives (#884).
|
|
1401
1500
|
servedBy: ProjectServedBySchema.optional()
|
|
1402
1501
|
});
|
|
1403
|
-
var ConnectorPollStateSchema =
|
|
1404
|
-
var ConnectorStatusSchema =
|
|
1502
|
+
var ConnectorPollStateSchema = z10.enum(["idle", "healthy", "error", "stale"]);
|
|
1503
|
+
var ConnectorStatusSchema = z10.object({
|
|
1405
1504
|
state: ConnectorPollStateSchema,
|
|
1406
|
-
lastPollAt:
|
|
1407
|
-
lastOutcome:
|
|
1408
|
-
lastError:
|
|
1409
|
-
signalsLastPoll:
|
|
1410
|
-
});
|
|
1411
|
-
var ConnectorStatusEntrySchema =
|
|
1412
|
-
id:
|
|
1413
|
-
provider:
|
|
1414
|
-
credentialRef:
|
|
1505
|
+
lastPollAt: z10.string().nullable(),
|
|
1506
|
+
lastOutcome: z10.enum(["ok", "error"]).nullable(),
|
|
1507
|
+
lastError: z10.string().nullable(),
|
|
1508
|
+
signalsLastPoll: z10.number().int().nonnegative()
|
|
1509
|
+
});
|
|
1510
|
+
var ConnectorStatusEntrySchema = z10.object({
|
|
1511
|
+
id: z10.string(),
|
|
1512
|
+
provider: z10.string(),
|
|
1513
|
+
credentialRef: z10.union([z10.string(), z10.record(z10.string(), z10.string())]),
|
|
1415
1514
|
status: ConnectorStatusSchema
|
|
1416
1515
|
});
|
|
1417
|
-
var ConnectorsStatusResponseSchema =
|
|
1418
|
-
connectors:
|
|
1419
|
-
});
|
|
1420
|
-
var SearchMatchSchema =
|
|
1421
|
-
var SearchResponseSchema =
|
|
1422
|
-
query:
|
|
1423
|
-
provider:
|
|
1424
|
-
matches:
|
|
1425
|
-
});
|
|
1426
|
-
var SerializedGraphSchema =
|
|
1427
|
-
nodes:
|
|
1428
|
-
edges:
|
|
1429
|
-
});
|
|
1430
|
-
var GraphDiffResultSchema =
|
|
1431
|
-
base:
|
|
1432
|
-
current:
|
|
1433
|
-
added:
|
|
1434
|
-
nodes:
|
|
1435
|
-
edges:
|
|
1516
|
+
var ConnectorsStatusResponseSchema = z10.object({
|
|
1517
|
+
connectors: z10.array(ConnectorStatusEntrySchema)
|
|
1518
|
+
});
|
|
1519
|
+
var SearchMatchSchema = z10.object({ score: z10.number() }).passthrough();
|
|
1520
|
+
var SearchResponseSchema = z10.object({
|
|
1521
|
+
query: z10.string(),
|
|
1522
|
+
provider: z10.string(),
|
|
1523
|
+
matches: z10.array(SearchMatchSchema)
|
|
1524
|
+
});
|
|
1525
|
+
var SerializedGraphSchema = z10.object({
|
|
1526
|
+
nodes: z10.array(GraphNodeSchema),
|
|
1527
|
+
edges: z10.array(GraphEdgeSchema)
|
|
1528
|
+
});
|
|
1529
|
+
var GraphDiffResultSchema = z10.object({
|
|
1530
|
+
base: z10.object({ exportedAt: z10.string().optional() }),
|
|
1531
|
+
current: z10.object({ exportedAt: z10.string() }),
|
|
1532
|
+
added: z10.object({
|
|
1533
|
+
nodes: z10.array(GraphNodeSchema),
|
|
1534
|
+
edges: z10.array(GraphEdgeSchema)
|
|
1436
1535
|
}),
|
|
1437
|
-
removed:
|
|
1438
|
-
nodes:
|
|
1439
|
-
edges:
|
|
1536
|
+
removed: z10.object({
|
|
1537
|
+
nodes: z10.array(GraphNodeSchema),
|
|
1538
|
+
edges: z10.array(GraphEdgeSchema)
|
|
1440
1539
|
}),
|
|
1441
|
-
changed:
|
|
1442
|
-
nodes:
|
|
1443
|
-
|
|
1444
|
-
id:
|
|
1540
|
+
changed: z10.object({
|
|
1541
|
+
nodes: z10.array(
|
|
1542
|
+
z10.object({
|
|
1543
|
+
id: z10.string(),
|
|
1445
1544
|
before: GraphNodeSchema,
|
|
1446
1545
|
after: GraphNodeSchema
|
|
1447
1546
|
})
|
|
1448
1547
|
),
|
|
1449
|
-
edges:
|
|
1450
|
-
|
|
1451
|
-
id:
|
|
1548
|
+
edges: z10.array(
|
|
1549
|
+
z10.object({
|
|
1550
|
+
id: z10.string(),
|
|
1452
1551
|
before: GraphEdgeSchema,
|
|
1453
1552
|
after: GraphEdgeSchema
|
|
1454
1553
|
})
|
|
@@ -1569,6 +1668,15 @@ export {
|
|
|
1569
1668
|
HealthResponseSchema,
|
|
1570
1669
|
HostMismatchDivergenceSchema,
|
|
1571
1670
|
HypotheticalActionSchema,
|
|
1671
|
+
IncidentBlastRadiusSchema,
|
|
1672
|
+
IncidentCardSchema,
|
|
1673
|
+
IncidentChainHopSchema,
|
|
1674
|
+
IncidentDivergenceSchema,
|
|
1675
|
+
IncidentEventPayloadSchema,
|
|
1676
|
+
IncidentKindSchema,
|
|
1677
|
+
IncidentLocusSchema,
|
|
1678
|
+
IncidentPolicySchema,
|
|
1679
|
+
IncidentRootCauseSchema,
|
|
1572
1680
|
IncidentsResponseSchema,
|
|
1573
1681
|
InfraNodeSchema,
|
|
1574
1682
|
LatencyMsSchema,
|
|
@@ -1637,6 +1745,7 @@ export {
|
|
|
1637
1745
|
frontierId,
|
|
1638
1746
|
graphqlOperationId,
|
|
1639
1747
|
grpcMethodId,
|
|
1748
|
+
incidentKindOf,
|
|
1640
1749
|
inferredEdgeId,
|
|
1641
1750
|
infraId,
|
|
1642
1751
|
localDatabaseId,
|