@neat.is/types 0.2.5

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 ADDED
@@ -0,0 +1,629 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ BlastRadiusAffectedNodeSchema: () => BlastRadiusAffectedNodeSchema,
24
+ BlastRadiusResultSchema: () => BlastRadiusResultSchema,
25
+ BlastRadiusRuleSchema: () => BlastRadiusRuleSchema,
26
+ CheckPoliciesScopeSchema: () => CheckPoliciesScopeSchema,
27
+ CompatibilityRuleSchema: () => CompatibilityRuleSchema,
28
+ CompatibleDriverSchema: () => CompatibleDriverSchema,
29
+ ConfigNodeSchema: () => ConfigNodeSchema,
30
+ DatabaseNodeSchema: () => DatabaseNodeSchema,
31
+ DiscoveredViaSchema: () => DiscoveredViaSchema,
32
+ EMPTY_REGISTRY: () => EMPTY_REGISTRY,
33
+ EdgeEvidenceSchema: () => EdgeEvidenceSchema,
34
+ EdgeSignalSchema: () => EdgeSignalSchema,
35
+ EdgeType: () => EdgeType,
36
+ EdgeTypeSchema: () => EdgeTypeSchema,
37
+ ErrorEventSchema: () => ErrorEventSchema,
38
+ FrontierNodeSchema: () => FrontierNodeSchema,
39
+ GraphEdgeSchema: () => GraphEdgeSchema,
40
+ GraphNodeSchema: () => GraphNodeSchema,
41
+ HypotheticalActionSchema: () => HypotheticalActionSchema,
42
+ InfraNodeSchema: () => InfraNodeSchema,
43
+ NodeType: () => NodeType,
44
+ NodeTypeSchema: () => NodeTypeSchema,
45
+ OwnershipRuleSchema: () => OwnershipRuleSchema,
46
+ PROV_RANK: () => PROV_RANK,
47
+ PoliciesCheckBodySchema: () => PoliciesCheckBodySchema,
48
+ PolicyActionSchema: () => PolicyActionSchema,
49
+ PolicyFileSchema: () => PolicyFileSchema,
50
+ PolicyRuleSchema: () => PolicyRuleSchema,
51
+ PolicySchema: () => PolicySchema,
52
+ PolicySeveritySchema: () => PolicySeveritySchema,
53
+ PolicyViolationSchema: () => PolicyViolationSchema,
54
+ Provenance: () => Provenance,
55
+ ProvenanceRuleSchema: () => ProvenanceRuleSchema,
56
+ ProvenanceSchema: () => ProvenanceSchema,
57
+ RegistryEntrySchema: () => RegistryEntrySchema,
58
+ RegistryFileSchema: () => RegistryFileSchema,
59
+ RegistryStatusSchema: () => RegistryStatusSchema,
60
+ RootCauseResultSchema: () => RootCauseResultSchema,
61
+ ServiceNodeSchema: () => ServiceNodeSchema,
62
+ StructuralRuleSchema: () => StructuralRuleSchema,
63
+ TransitiveDependenciesResultSchema: () => TransitiveDependenciesResultSchema,
64
+ TransitiveDependencySchema: () => TransitiveDependencySchema,
65
+ configId: () => configId,
66
+ databaseId: () => databaseId,
67
+ extractedEdgeId: () => extractedEdgeId,
68
+ frontierEdgeId: () => frontierEdgeId,
69
+ frontierId: () => frontierId,
70
+ inferredEdgeId: () => inferredEdgeId,
71
+ infraId: () => infraId,
72
+ observedEdgeId: () => observedEdgeId,
73
+ parseConfigId: () => parseConfigId,
74
+ parseDatabaseId: () => parseDatabaseId,
75
+ parseEdgeId: () => parseEdgeId,
76
+ parseFrontierId: () => parseFrontierId,
77
+ parseInfraId: () => parseInfraId,
78
+ parseServiceId: () => parseServiceId,
79
+ serviceId: () => serviceId
80
+ });
81
+ module.exports = __toCommonJS(index_exports);
82
+
83
+ // src/constants.ts
84
+ var import_zod = require("zod");
85
+ var Provenance = {
86
+ EXTRACTED: "EXTRACTED",
87
+ INFERRED: "INFERRED",
88
+ OBSERVED: "OBSERVED",
89
+ STALE: "STALE",
90
+ FRONTIER: "FRONTIER"
91
+ };
92
+ var EdgeType = {
93
+ CALLS: "CALLS",
94
+ DEPENDS_ON: "DEPENDS_ON",
95
+ CONNECTS_TO: "CONNECTS_TO",
96
+ CONFIGURED_BY: "CONFIGURED_BY",
97
+ PUBLISHES_TO: "PUBLISHES_TO",
98
+ CONSUMES_FROM: "CONSUMES_FROM",
99
+ RUNS_ON: "RUNS_ON"
100
+ };
101
+ var NodeType = {
102
+ ServiceNode: "ServiceNode",
103
+ DatabaseNode: "DatabaseNode",
104
+ ConfigNode: "ConfigNode",
105
+ InfraNode: "InfraNode",
106
+ FrontierNode: "FrontierNode"
107
+ };
108
+ var NodeTypeSchema = import_zod.z.enum([
109
+ NodeType.ServiceNode,
110
+ NodeType.DatabaseNode,
111
+ NodeType.ConfigNode,
112
+ NodeType.InfraNode,
113
+ NodeType.FrontierNode
114
+ ]);
115
+
116
+ // src/nodes.ts
117
+ var import_zod2 = require("zod");
118
+ var CompatibleDriverSchema = import_zod2.z.object({
119
+ name: import_zod2.z.string(),
120
+ minVersion: import_zod2.z.string()
121
+ });
122
+ var DiscoveredViaSchema = import_zod2.z.enum(["static", "otel", "merged"]);
123
+ var ServiceNodeSchema = import_zod2.z.object({
124
+ id: import_zod2.z.string(),
125
+ type: import_zod2.z.literal(NodeType.ServiceNode),
126
+ name: import_zod2.z.string(),
127
+ language: import_zod2.z.string(),
128
+ discoveredVia: DiscoveredViaSchema.optional(),
129
+ version: import_zod2.z.string().optional(),
130
+ dbConnectionTarget: import_zod2.z.string().optional(),
131
+ repoPath: import_zod2.z.string().optional(),
132
+ dependencies: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.string()).optional(),
133
+ // Hostnames OTel spans might mention for this service: compose service
134
+ // names, k8s metadata.name (and the cluster-DNS variants), Dockerfile
135
+ // labels, etc. resolveServiceId in ingest.ts checks these before falling
136
+ // back to a FRONTIER placeholder.
137
+ aliases: import_zod2.z.array(import_zod2.z.string()).optional(),
138
+ // Optional. If set, services declare their `engines.node` here so γ #74's
139
+ // node-engine compat check has something to test against.
140
+ nodeEngine: import_zod2.z.string().optional(),
141
+ incompatibilities: import_zod2.z.array(
142
+ // Discriminated by `kind`. `driver-engine` is the original shape and
143
+ // stays default for backward compatibility — older snapshots without a
144
+ // `kind` field still parse via the union's `.optional()` discriminator
145
+ // fallback. New kinds came in with γ #74.
146
+ import_zod2.z.union([
147
+ import_zod2.z.object({
148
+ kind: import_zod2.z.literal("driver-engine").optional(),
149
+ driver: import_zod2.z.string(),
150
+ driverVersion: import_zod2.z.string(),
151
+ engine: import_zod2.z.string(),
152
+ engineVersion: import_zod2.z.string(),
153
+ reason: import_zod2.z.string()
154
+ }),
155
+ import_zod2.z.object({
156
+ kind: import_zod2.z.literal("node-engine"),
157
+ package: import_zod2.z.string(),
158
+ packageVersion: import_zod2.z.string().optional(),
159
+ requiredNodeVersion: import_zod2.z.string(),
160
+ declaredNodeEngine: import_zod2.z.string().optional(),
161
+ reason: import_zod2.z.string()
162
+ }),
163
+ import_zod2.z.object({
164
+ kind: import_zod2.z.literal("package-conflict"),
165
+ package: import_zod2.z.string(),
166
+ packageVersion: import_zod2.z.string().optional(),
167
+ requires: import_zod2.z.object({
168
+ name: import_zod2.z.string(),
169
+ minVersion: import_zod2.z.string()
170
+ }),
171
+ foundVersion: import_zod2.z.string().optional(),
172
+ reason: import_zod2.z.string()
173
+ }),
174
+ import_zod2.z.object({
175
+ kind: import_zod2.z.literal("deprecated-api"),
176
+ package: import_zod2.z.string(),
177
+ packageVersion: import_zod2.z.string().optional(),
178
+ reason: import_zod2.z.string()
179
+ })
180
+ ])
181
+ ).optional()
182
+ });
183
+ var DatabaseNodeSchema = import_zod2.z.object({
184
+ id: import_zod2.z.string(),
185
+ type: import_zod2.z.literal(NodeType.DatabaseNode),
186
+ name: import_zod2.z.string(),
187
+ engine: import_zod2.z.string(),
188
+ engineVersion: import_zod2.z.string(),
189
+ compatibleDrivers: import_zod2.z.array(CompatibleDriverSchema),
190
+ host: import_zod2.z.string().optional(),
191
+ port: import_zod2.z.number().optional(),
192
+ discoveredVia: DiscoveredViaSchema.optional()
193
+ });
194
+ var ConfigNodeSchema = import_zod2.z.object({
195
+ id: import_zod2.z.string(),
196
+ type: import_zod2.z.literal(NodeType.ConfigNode),
197
+ name: import_zod2.z.string(),
198
+ path: import_zod2.z.string(),
199
+ fileType: import_zod2.z.string()
200
+ });
201
+ var InfraNodeSchema = import_zod2.z.object({
202
+ id: import_zod2.z.string(),
203
+ type: import_zod2.z.literal(NodeType.InfraNode),
204
+ name: import_zod2.z.string(),
205
+ provider: import_zod2.z.string(),
206
+ region: import_zod2.z.string().optional(),
207
+ kind: import_zod2.z.string().optional()
208
+ });
209
+ var FrontierNodeSchema = import_zod2.z.object({
210
+ id: import_zod2.z.string(),
211
+ type: import_zod2.z.literal(NodeType.FrontierNode),
212
+ name: import_zod2.z.string(),
213
+ host: import_zod2.z.string(),
214
+ firstObserved: import_zod2.z.string().datetime().optional(),
215
+ lastObserved: import_zod2.z.string().datetime().optional()
216
+ });
217
+ var GraphNodeSchema = import_zod2.z.discriminatedUnion("type", [
218
+ ServiceNodeSchema,
219
+ DatabaseNodeSchema,
220
+ ConfigNodeSchema,
221
+ InfraNodeSchema,
222
+ FrontierNodeSchema
223
+ ]);
224
+
225
+ // src/edges.ts
226
+ var import_zod3 = require("zod");
227
+ var ProvenanceSchema = import_zod3.z.enum([
228
+ Provenance.EXTRACTED,
229
+ Provenance.INFERRED,
230
+ Provenance.OBSERVED,
231
+ Provenance.STALE,
232
+ Provenance.FRONTIER
233
+ ]);
234
+ var EdgeTypeSchema = import_zod3.z.enum([
235
+ EdgeType.CALLS,
236
+ EdgeType.DEPENDS_ON,
237
+ EdgeType.CONNECTS_TO,
238
+ EdgeType.CONFIGURED_BY,
239
+ EdgeType.PUBLISHES_TO,
240
+ EdgeType.CONSUMES_FROM,
241
+ EdgeType.RUNS_ON
242
+ ]);
243
+ var EdgeEvidenceSchema = import_zod3.z.object({
244
+ file: import_zod3.z.string(),
245
+ line: import_zod3.z.number().int().nonnegative(),
246
+ snippet: import_zod3.z.string()
247
+ });
248
+ var EdgeSignalSchema = import_zod3.z.object({
249
+ spanCount: import_zod3.z.number().int().nonnegative(),
250
+ errorCount: import_zod3.z.number().int().nonnegative(),
251
+ lastObservedAgeMs: import_zod3.z.number().nonnegative().optional()
252
+ });
253
+ var GraphEdgeSchema = import_zod3.z.object({
254
+ id: import_zod3.z.string(),
255
+ source: import_zod3.z.string(),
256
+ target: import_zod3.z.string(),
257
+ type: EdgeTypeSchema,
258
+ provenance: ProvenanceSchema,
259
+ confidence: import_zod3.z.number().min(0).max(1).optional(),
260
+ lastObserved: import_zod3.z.string().datetime().optional(),
261
+ callCount: import_zod3.z.number().int().nonnegative().optional(),
262
+ evidence: EdgeEvidenceSchema.optional(),
263
+ signal: EdgeSignalSchema.optional()
264
+ });
265
+
266
+ // src/events.ts
267
+ var import_zod4 = require("zod");
268
+ var ErrorEventSchema = import_zod4.z.object({
269
+ id: import_zod4.z.string(),
270
+ timestamp: import_zod4.z.string().datetime(),
271
+ service: import_zod4.z.string(),
272
+ traceId: import_zod4.z.string(),
273
+ spanId: import_zod4.z.string(),
274
+ errorType: import_zod4.z.string().optional(),
275
+ errorMessage: import_zod4.z.string(),
276
+ // OTLP span events with name="exception" carry richer error data than
277
+ // status.message. When present, these fields capture the exception type
278
+ // and stacktrace from the SDK that recorded the error. ADR-031 schema
279
+ // growth — added without a shape change because both fields are optional.
280
+ exceptionType: import_zod4.z.string().optional(),
281
+ exceptionStacktrace: import_zod4.z.string().optional(),
282
+ affectedNode: import_zod4.z.string()
283
+ });
284
+
285
+ // src/results.ts
286
+ var import_zod5 = require("zod");
287
+ var RootCauseResultSchema = import_zod5.z.object({
288
+ rootCauseNode: import_zod5.z.string(),
289
+ rootCauseReason: import_zod5.z.string(),
290
+ traversalPath: import_zod5.z.array(import_zod5.z.string()),
291
+ edgeProvenances: import_zod5.z.array(ProvenanceSchema),
292
+ confidence: import_zod5.z.number().min(0).max(1),
293
+ fixRecommendation: import_zod5.z.string().optional()
294
+ });
295
+ var BlastRadiusAffectedNodeSchema = import_zod5.z.object({
296
+ nodeId: import_zod5.z.string(),
297
+ // Distance from the origin in BFS hops. The origin itself is never in
298
+ // affectedNodes, so distance 0 has no meaning — the BFS at traverse.ts
299
+ // already skips frame 0. Tightening to positive() locks that invariant
300
+ // mechanically (ADR-038, issue #138).
301
+ distance: import_zod5.z.number().int().positive(),
302
+ edgeProvenance: ProvenanceSchema,
303
+ // path: origin → ... → nodeId. Length === distance + 1. Surfaced from the
304
+ // BFS predecessor chain so consumers don't have to reconstruct it from
305
+ // distance + the graph (ADR-038, issue #137).
306
+ path: import_zod5.z.array(import_zod5.z.string()).min(2),
307
+ // confidence: confidenceFromMix(...edgesAlongPath). Multiplicative cascade —
308
+ // each hop is independent evidence and uncertainty compounds. ADR-036.
309
+ confidence: import_zod5.z.number().min(0).max(1)
310
+ });
311
+ var BlastRadiusResultSchema = import_zod5.z.object({
312
+ origin: import_zod5.z.string(),
313
+ affectedNodes: import_zod5.z.array(BlastRadiusAffectedNodeSchema),
314
+ totalAffected: import_zod5.z.number().int().nonnegative()
315
+ });
316
+ var TransitiveDependencySchema = import_zod5.z.object({
317
+ nodeId: import_zod5.z.string(),
318
+ // Distance from the origin in BFS hops. The origin itself is never in
319
+ // dependencies, so distance is positive (>= 1).
320
+ distance: import_zod5.z.number().int().positive(),
321
+ // Type of the edge that brought traversal to this node (CALLS,
322
+ // CONNECTS_TO, DEPENDS_ON, etc.).
323
+ edgeType: EdgeTypeSchema,
324
+ // Provenance of that edge.
325
+ provenance: ProvenanceSchema
326
+ });
327
+ var TransitiveDependenciesResultSchema = import_zod5.z.object({
328
+ origin: import_zod5.z.string(),
329
+ depth: import_zod5.z.number().int().positive(),
330
+ dependencies: import_zod5.z.array(TransitiveDependencySchema),
331
+ total: import_zod5.z.number().int().nonnegative()
332
+ });
333
+
334
+ // src/identity.ts
335
+ var SERVICE_PREFIX = "service:";
336
+ var DATABASE_PREFIX = "database:";
337
+ var CONFIG_PREFIX = "config:";
338
+ var INFRA_PREFIX = "infra:";
339
+ var FRONTIER_PREFIX = "frontier:";
340
+ function serviceId(name) {
341
+ return `${SERVICE_PREFIX}${name}`;
342
+ }
343
+ function parseServiceId(id) {
344
+ return id.startsWith(SERVICE_PREFIX) ? id.slice(SERVICE_PREFIX.length) : null;
345
+ }
346
+ function databaseId(host) {
347
+ return `${DATABASE_PREFIX}${host}`;
348
+ }
349
+ function parseDatabaseId(id) {
350
+ return id.startsWith(DATABASE_PREFIX) ? id.slice(DATABASE_PREFIX.length) : null;
351
+ }
352
+ function configId(relPath) {
353
+ return `${CONFIG_PREFIX}${relPath}`;
354
+ }
355
+ function parseConfigId(id) {
356
+ return id.startsWith(CONFIG_PREFIX) ? id.slice(CONFIG_PREFIX.length) : null;
357
+ }
358
+ function infraId(kind, name) {
359
+ return `${INFRA_PREFIX}${kind}:${name}`;
360
+ }
361
+ function parseInfraId(id) {
362
+ if (!id.startsWith(INFRA_PREFIX)) return null;
363
+ const rest = id.slice(INFRA_PREFIX.length);
364
+ const colon = rest.indexOf(":");
365
+ if (colon === -1) return null;
366
+ return { kind: rest.slice(0, colon), name: rest.slice(colon + 1) };
367
+ }
368
+ function frontierId(host) {
369
+ return `${FRONTIER_PREFIX}${host}`;
370
+ }
371
+ function parseFrontierId(id) {
372
+ return id.startsWith(FRONTIER_PREFIX) ? id.slice(FRONTIER_PREFIX.length) : null;
373
+ }
374
+ var EDGE_ARROW = "->";
375
+ function extractedEdgeId(source, target, type) {
376
+ return `${type}:${source}${EDGE_ARROW}${target}`;
377
+ }
378
+ function observedEdgeId(source, target, type) {
379
+ return `${type}:OBSERVED:${source}${EDGE_ARROW}${target}`;
380
+ }
381
+ function inferredEdgeId(source, target, type) {
382
+ return `${type}:INFERRED:${source}${EDGE_ARROW}${target}`;
383
+ }
384
+ function frontierEdgeId(source, target, type) {
385
+ return `${type}:FRONTIER:${source}${EDGE_ARROW}${target}`;
386
+ }
387
+ function parseEdgeId(id) {
388
+ const arrowIdx = id.lastIndexOf(EDGE_ARROW);
389
+ if (arrowIdx === -1) return null;
390
+ const left = id.slice(0, arrowIdx);
391
+ const target = id.slice(arrowIdx + EDGE_ARROW.length);
392
+ if (!left || !target) return null;
393
+ const firstColon = left.indexOf(":");
394
+ if (firstColon === -1) return null;
395
+ const type = left.slice(0, firstColon);
396
+ const rest = left.slice(firstColon + 1);
397
+ for (const prov of ["OBSERVED", "INFERRED", "FRONTIER"]) {
398
+ if (rest.startsWith(`${prov}:`)) {
399
+ return { type, provenance: prov, source: rest.slice(prov.length + 1), target };
400
+ }
401
+ }
402
+ return { type, provenance: "EXTRACTED", source: rest, target };
403
+ }
404
+ var PROV_RANK = Object.freeze({
405
+ OBSERVED: 3,
406
+ INFERRED: 2,
407
+ EXTRACTED: 1,
408
+ STALE: 0,
409
+ FRONTIER: 0
410
+ });
411
+
412
+ // src/policy.ts
413
+ var import_zod6 = require("zod");
414
+ var PolicySeveritySchema = import_zod6.z.enum(["info", "warning", "error", "critical"]);
415
+ var PolicyActionSchema = import_zod6.z.enum(["log", "alert", "block"]);
416
+ var StructuralRuleSchema = import_zod6.z.object({
417
+ type: import_zod6.z.literal("structural"),
418
+ // Node type the rule applies to. Every node of this type must satisfy the
419
+ // edge requirement below.
420
+ fromNodeType: NodeTypeSchema,
421
+ // Required outbound edge type from each fromNodeType node.
422
+ edgeType: EdgeTypeSchema,
423
+ // Required target node type at the other end of the edge.
424
+ toNodeType: NodeTypeSchema
425
+ });
426
+ var CompatibilityRuleSchema = import_zod6.z.object({
427
+ type: import_zod6.z.literal("compatibility"),
428
+ // Optional kind narrowing. When omitted, all four compat shapes
429
+ // (driver-engine, node-engine, package-conflict, deprecated-api) run.
430
+ kind: import_zod6.z.enum(["driver-engine", "node-engine", "package-conflict", "deprecated-api"]).optional()
431
+ });
432
+ var ProvenanceRuleSchema = import_zod6.z.object({
433
+ type: import_zod6.z.literal("provenance"),
434
+ // Edge type the rule applies to.
435
+ edgeType: EdgeTypeSchema,
436
+ // Target node id (e.g. 'service:payments') that incoming edges of edgeType
437
+ // must satisfy. Optional — when omitted, the rule runs against every edge
438
+ // of edgeType regardless of target.
439
+ targetNodeId: import_zod6.z.string().optional(),
440
+ // Required provenance (single value or one-of). The audit fails if the
441
+ // observed edge's provenance is not in this set.
442
+ required: import_zod6.z.union([ProvenanceSchema, import_zod6.z.array(ProvenanceSchema).min(1)])
443
+ });
444
+ var OwnershipRuleSchema = import_zod6.z.object({
445
+ type: import_zod6.z.literal("ownership"),
446
+ // Node type the rule applies to. ServiceNode is the common case; the
447
+ // discriminator stays generic so future node types can opt in.
448
+ nodeType: NodeTypeSchema,
449
+ // Field name on the node attributes that must be non-empty. Defaults to
450
+ // 'owner' if omitted.
451
+ field: import_zod6.z.string().default("owner")
452
+ });
453
+ var BlastRadiusRuleSchema = import_zod6.z.object({
454
+ type: import_zod6.z.literal("blast-radius"),
455
+ // Node type the rule applies to (ServiceNode is the common case).
456
+ nodeType: NodeTypeSchema,
457
+ // Cap on `totalAffected` from getBlastRadius. Inclusive — a node hitting
458
+ // exactly this number passes; > maxAffected fails.
459
+ maxAffected: import_zod6.z.number().int().positive(),
460
+ // Depth to evaluate against. Defaults to the contract's blast-radius
461
+ // default (10) when omitted.
462
+ depth: import_zod6.z.number().int().positive().optional()
463
+ });
464
+ var PolicyRuleSchema = import_zod6.z.discriminatedUnion("type", [
465
+ StructuralRuleSchema,
466
+ CompatibilityRuleSchema,
467
+ ProvenanceRuleSchema,
468
+ OwnershipRuleSchema,
469
+ BlastRadiusRuleSchema
470
+ ]);
471
+ var PolicySchema = import_zod6.z.object({
472
+ // Unique within the file. Duplicates fail PolicyFileSchema.parse.
473
+ id: import_zod6.z.string().min(1),
474
+ name: import_zod6.z.string().min(1),
475
+ description: import_zod6.z.string().optional(),
476
+ severity: PolicySeveritySchema,
477
+ // When omitted, the engine derives a default from severity per ADR-044
478
+ // (info→log, warning→alert, error→alert, critical→block).
479
+ onViolation: PolicyActionSchema.optional(),
480
+ rule: PolicyRuleSchema
481
+ });
482
+ var PolicyFileSchema = import_zod6.z.object({
483
+ version: import_zod6.z.literal(1),
484
+ policies: import_zod6.z.array(PolicySchema)
485
+ }).superRefine((file, ctx) => {
486
+ const seen = /* @__PURE__ */ new Set();
487
+ for (const [i, p] of file.policies.entries()) {
488
+ if (seen.has(p.id)) {
489
+ ctx.addIssue({
490
+ code: import_zod6.z.ZodIssueCode.custom,
491
+ path: ["policies", i, "id"],
492
+ message: `duplicate policy id "${p.id}"`
493
+ });
494
+ }
495
+ seen.add(p.id);
496
+ }
497
+ });
498
+ var HypotheticalActionSchema = import_zod6.z.discriminatedUnion("kind", [
499
+ import_zod6.z.object({
500
+ kind: import_zod6.z.literal("promote-frontier"),
501
+ // The FrontierNode id that would be promoted.
502
+ frontierId: import_zod6.z.string().min(1)
503
+ }),
504
+ import_zod6.z.object({
505
+ kind: import_zod6.z.literal("add-edge"),
506
+ source: import_zod6.z.string().min(1),
507
+ target: import_zod6.z.string().min(1),
508
+ edgeType: EdgeTypeSchema,
509
+ provenance: ProvenanceSchema
510
+ })
511
+ ]);
512
+ var PoliciesCheckBodySchema = import_zod6.z.object({
513
+ hypotheticalAction: HypotheticalActionSchema.optional()
514
+ });
515
+ var CheckPoliciesScopeSchema = import_zod6.z.union([
516
+ import_zod6.z.enum(["all", "unresolved"]),
517
+ import_zod6.z.object({ policyId: import_zod6.z.string().min(1) })
518
+ ]);
519
+ var PolicyViolationSchema = import_zod6.z.object({
520
+ // ${policy.id}:${violation-context}. The violation-context is shape-
521
+ // specific (e.g. nodeId for structural; edgeId for provenance).
522
+ id: import_zod6.z.string().min(1),
523
+ policyId: import_zod6.z.string().min(1),
524
+ policyName: import_zod6.z.string().min(1),
525
+ severity: PolicySeveritySchema,
526
+ // Resolved at evaluation time — either the explicit policy.onViolation or
527
+ // the severity-derived default per ADR-044.
528
+ onViolation: PolicyActionSchema,
529
+ ruleType: import_zod6.z.enum(["structural", "compatibility", "provenance", "ownership", "blast-radius"]),
530
+ subject: import_zod6.z.object({
531
+ nodeId: import_zod6.z.string().optional(),
532
+ edgeId: import_zod6.z.string().optional(),
533
+ path: import_zod6.z.array(import_zod6.z.string()).optional()
534
+ }).refine(
535
+ (s) => s.nodeId !== void 0 || s.edgeId !== void 0 || s.path !== void 0,
536
+ { message: "subject must carry at least one of nodeId, edgeId, path" }
537
+ ),
538
+ message: import_zod6.z.string().min(1),
539
+ observedAt: import_zod6.z.string().datetime()
540
+ });
541
+
542
+ // src/registry.ts
543
+ var import_zod7 = require("zod");
544
+ var RegistryStatusSchema = import_zod7.z.enum(["active", "paused", "broken"]);
545
+ var RegistryEntrySchema = import_zod7.z.object({
546
+ // Unique within the registry. Project-scoped operations (`neat watch
547
+ // --project <name>`, `neatd reload <name>`) key on this. Collisions are a
548
+ // hard error at registration time.
549
+ name: import_zod7.z.string().min(1),
550
+ // Resolved absolute path on disk. Path normalisation is what keeps two
551
+ // `neat init` calls from different relative paths from creating two entries
552
+ // for the same directory.
553
+ path: import_zod7.z.string().min(1),
554
+ // ISO8601, set at first registration.
555
+ registeredAt: import_zod7.z.string(),
556
+ // ISO8601, updated whenever the daemon successfully sees the project.
557
+ // Optional because a freshly-registered project hasn't been seen yet.
558
+ lastSeenAt: import_zod7.z.string().optional(),
559
+ // Languages detected at `init` time. Free-form strings keyed off the
560
+ // installer modules — `'javascript'`, `'python'`, …
561
+ languages: import_zod7.z.array(import_zod7.z.string()),
562
+ status: RegistryStatusSchema
563
+ });
564
+ var RegistryFileSchema = import_zod7.z.object({
565
+ version: import_zod7.z.literal(1),
566
+ projects: import_zod7.z.array(RegistryEntrySchema)
567
+ });
568
+ var EMPTY_REGISTRY = { version: 1, projects: [] };
569
+ // Annotate the CommonJS export names for ESM import in node:
570
+ 0 && (module.exports = {
571
+ BlastRadiusAffectedNodeSchema,
572
+ BlastRadiusResultSchema,
573
+ BlastRadiusRuleSchema,
574
+ CheckPoliciesScopeSchema,
575
+ CompatibilityRuleSchema,
576
+ CompatibleDriverSchema,
577
+ ConfigNodeSchema,
578
+ DatabaseNodeSchema,
579
+ DiscoveredViaSchema,
580
+ EMPTY_REGISTRY,
581
+ EdgeEvidenceSchema,
582
+ EdgeSignalSchema,
583
+ EdgeType,
584
+ EdgeTypeSchema,
585
+ ErrorEventSchema,
586
+ FrontierNodeSchema,
587
+ GraphEdgeSchema,
588
+ GraphNodeSchema,
589
+ HypotheticalActionSchema,
590
+ InfraNodeSchema,
591
+ NodeType,
592
+ NodeTypeSchema,
593
+ OwnershipRuleSchema,
594
+ PROV_RANK,
595
+ PoliciesCheckBodySchema,
596
+ PolicyActionSchema,
597
+ PolicyFileSchema,
598
+ PolicyRuleSchema,
599
+ PolicySchema,
600
+ PolicySeveritySchema,
601
+ PolicyViolationSchema,
602
+ Provenance,
603
+ ProvenanceRuleSchema,
604
+ ProvenanceSchema,
605
+ RegistryEntrySchema,
606
+ RegistryFileSchema,
607
+ RegistryStatusSchema,
608
+ RootCauseResultSchema,
609
+ ServiceNodeSchema,
610
+ StructuralRuleSchema,
611
+ TransitiveDependenciesResultSchema,
612
+ TransitiveDependencySchema,
613
+ configId,
614
+ databaseId,
615
+ extractedEdgeId,
616
+ frontierEdgeId,
617
+ frontierId,
618
+ inferredEdgeId,
619
+ infraId,
620
+ observedEdgeId,
621
+ parseConfigId,
622
+ parseDatabaseId,
623
+ parseEdgeId,
624
+ parseFrontierId,
625
+ parseInfraId,
626
+ parseServiceId,
627
+ serviceId
628
+ });
629
+ //# sourceMappingURL=index.cjs.map