@neat.is/types 0.6.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -22,7 +22,16 @@ var EdgeType = {
22
22
  // Static module dependency between two FileNodes within a service (ADR-092,
23
23
  // file-awareness.md §10). Compile-time, not runtime — represents one file
24
24
  // importing another. Distinct from CALLS which records runtime invocations.
25
- IMPORTS: "IMPORTS"
25
+ IMPORTS: "IMPORTS",
26
+ // Static heritage between two SymbolNodes (ADR-158 §3). `INHERITS` records a
27
+ // class's `extends` clause (`class ──INHERITS──▶ superclass`); `IMPLEMENTS`
28
+ // records an `implements` clause (`class ──IMPLEMENTS──▶ implemented`). Both
29
+ // are symbol→symbol, EXTRACTED, minted only when the parent name resolves to
30
+ // exactly one known SymbolNode — same-file or through the import graph — never
31
+ // fuzzy-matched. A parent that resolves to nothing (external package,
32
+ // re-export chain, an interface, which is not a SymbolNode) emits no edge.
33
+ INHERITS: "INHERITS",
34
+ IMPLEMENTS: "IMPLEMENTS"
26
35
  };
27
36
  var NodeType = {
28
37
  ServiceNode: "ServiceNode",
@@ -72,7 +81,18 @@ var NodeType = {
72
81
  // edge that carries `lastObserved` and decays OBSERVED → STALE on CONNECTS_TO's
73
82
  // own staleness threshold when the channel goes quiet. See
74
83
  // docs/contracts/otel-ingest.md.
75
- WebSocketChannelNode: "WebSocketChannelNode"
84
+ WebSocketChannelNode: "WebSocketChannelNode",
85
+ // A symbol under a file — a function, method, constructor, or class
86
+ // definition — at definition-span granularity (ADR-158). Static-first: the
87
+ // extractor mints one per definition and the file owns it through a
88
+ // `file ──CONTAINS──▶ symbol` edge, one containment level below
89
+ // `service ──CONTAINS──▶ file`. It carries its `{ startLine, endLine }`
90
+ // definition span, which is the fusion key ingest joins a span's `code.line`
91
+ // against to land an OBSERVED edge on the calling symbol rather than only its
92
+ // file (observed-first edges, one grain finer than §4 file grain). The node is
93
+ // language-neutral; the per-language tree-sitter extractor is the adapter. See
94
+ // docs/contracts/static-extraction.md and docs/contracts/file-awareness.md §1.
95
+ SymbolNode: "SymbolNode"
76
96
  };
77
97
  var NodeTypeSchema = z.enum([
78
98
  NodeType.ServiceNode,
@@ -84,7 +104,8 @@ var NodeTypeSchema = z.enum([
84
104
  NodeType.RouteNode,
85
105
  NodeType.GraphQLOperationNode,
86
106
  NodeType.GrpcMethodNode,
87
- NodeType.WebSocketChannelNode
107
+ NodeType.WebSocketChannelNode,
108
+ NodeType.SymbolNode
88
109
  ]);
89
110
 
90
111
  // src/nodes.ts
@@ -275,6 +296,21 @@ var WebSocketChannelNodeSchema = z2.object({
275
296
  line: z2.number().int().nonnegative().optional(),
276
297
  discoveredVia: DiscoveredViaSchema.optional()
277
298
  });
299
+ var SymbolKindSchema = z2.enum(["function", "method", "constructor", "class"]);
300
+ var SymbolSpanSchema = z2.object({
301
+ startLine: z2.number().int().nonnegative(),
302
+ endLine: z2.number().int().nonnegative()
303
+ });
304
+ var SymbolNodeSchema = z2.object({
305
+ id: z2.string(),
306
+ type: z2.literal(NodeType.SymbolNode),
307
+ kind: SymbolKindSchema,
308
+ qualname: z2.string(),
309
+ span: SymbolSpanSchema,
310
+ service: z2.string(),
311
+ relPath: z2.string(),
312
+ discoveredVia: DiscoveredViaSchema.optional()
313
+ });
278
314
  var GraphNodeSchema = z2.discriminatedUnion("type", [
279
315
  ServiceNodeSchema,
280
316
  DatabaseNodeSchema,
@@ -285,7 +321,8 @@ var GraphNodeSchema = z2.discriminatedUnion("type", [
285
321
  RouteNodeSchema,
286
322
  GraphQLOperationNodeSchema,
287
323
  GrpcMethodNodeSchema,
288
- WebSocketChannelNodeSchema
324
+ WebSocketChannelNodeSchema,
325
+ SymbolNodeSchema
289
326
  ]);
290
327
 
291
328
  // src/edges.ts
@@ -305,7 +342,9 @@ var EdgeTypeSchema = z3.enum([
305
342
  EdgeType.CONSUMES_FROM,
306
343
  EdgeType.RUNS_ON,
307
344
  EdgeType.CONTAINS,
308
- EdgeType.IMPORTS
345
+ EdgeType.IMPORTS,
346
+ EdgeType.INHERITS,
347
+ EdgeType.IMPLEMENTS
309
348
  ]);
310
349
  var EdgeEvidenceSchema = z3.object({
311
350
  file: z3.string(),
@@ -493,6 +532,7 @@ var ROUTE_PREFIX = "route:";
493
532
  var GRAPHQL_OP_PREFIX = "graphql:";
494
533
  var GRPC_METHOD_PREFIX = "grpc:";
495
534
  var WEBSOCKET_CHANNEL_PREFIX = "ws:";
535
+ var SYMBOL_PREFIX = "symbol:";
496
536
  var ENV_UNKNOWN = "unknown";
497
537
  function serviceId(name, env) {
498
538
  if (env === void 0 || env === ENV_UNKNOWN) return `${SERVICE_PREFIX}${name}`;
@@ -612,6 +652,34 @@ function parseWebsocketChannelId(id) {
612
652
  if (service.length === 0 || channel.length === 0) return null;
613
653
  return { service, channel };
614
654
  }
655
+ function symbolId(service, relPath, qualname, disambiguator) {
656
+ const base = `${SYMBOL_PREFIX}${service}:${relPath}#${qualname}`;
657
+ return disambiguator === void 0 ? base : `${base}~${disambiguator}`;
658
+ }
659
+ function parseSymbolId(id) {
660
+ if (!id.startsWith(SYMBOL_PREFIX)) return null;
661
+ const rest = id.slice(SYMBOL_PREFIX.length);
662
+ const colon = rest.indexOf(":");
663
+ if (colon === -1) return null;
664
+ const service = rest.slice(0, colon);
665
+ const tail = rest.slice(colon + 1);
666
+ const hash = tail.lastIndexOf("#");
667
+ if (hash === -1) return null;
668
+ const relPath = tail.slice(0, hash);
669
+ let qualname = tail.slice(hash + 1);
670
+ if (service.length === 0 || relPath.length === 0 || qualname.length === 0) return null;
671
+ let disambiguator;
672
+ const tilde = qualname.lastIndexOf("~");
673
+ if (tilde !== -1) {
674
+ const suffix = qualname.slice(tilde + 1);
675
+ if (suffix.length > 0 && /^\d+$/.test(suffix)) {
676
+ disambiguator = Number(suffix);
677
+ qualname = qualname.slice(0, tilde);
678
+ }
679
+ }
680
+ if (qualname.length === 0) return null;
681
+ return { service, relPath, qualname, ...disambiguator !== void 0 ? { disambiguator } : {} };
682
+ }
615
683
  var EDGE_ARROW = "->";
616
684
  function extractedEdgeId(source, target, type) {
617
685
  return `${type}:${source}${EDGE_ARROW}${target}`;
@@ -937,10 +1005,19 @@ var GraphEdgesResponseSchema = z9.object({
937
1005
  inbound: z9.array(GraphEdgeSchema),
938
1006
  outbound: z9.array(GraphEdgeSchema)
939
1007
  });
1008
+ var ExtractionCoverageSchema = z9.object({
1009
+ skippedFiles: z9.number().int().nonnegative(),
1010
+ byProducer: z9.record(z9.number().int().nonnegative()),
1011
+ // Up to a bounded sample of the files that failed to parse this pass.
1012
+ files: z9.array(z9.string()),
1013
+ updatedAt: z9.string()
1014
+ });
940
1015
  var HealthResponseSchema = z9.object({
941
1016
  ok: z9.boolean(),
942
1017
  project: z9.string(),
943
- uptimeMs: z9.number().int().nonnegative()
1018
+ uptimeMs: z9.number().int().nonnegative(),
1019
+ // Present when the most recent extraction pass recorded its coverage (#883).
1020
+ coverage: ExtractionCoverageSchema.optional()
944
1021
  }).passthrough();
945
1022
  var DaemonHealthResponseSchema = z9.object({
946
1023
  ok: z9.boolean(),
@@ -953,8 +1030,19 @@ var DaemonHealthResponseSchema = z9.object({
953
1030
  }).passthrough()
954
1031
  )
955
1032
  }).passthrough();
1033
+ var ProjectListEntrySchema = RegistryEntrySchema.extend({
1034
+ hostedHere: z9.boolean()
1035
+ });
1036
+ var ProjectServedBySchema = z9.object({
1037
+ path: z9.string(),
1038
+ restPort: z9.number().int(),
1039
+ live: z9.boolean()
1040
+ });
956
1041
  var SingleProjectResponseSchema = z9.object({
957
- project: RegistryEntrySchema
1042
+ project: ProjectListEntrySchema,
1043
+ // Present only when this daemon does not host the project but another daemon
1044
+ // on the machine does — names where it actually lives (#884).
1045
+ servedBy: ProjectServedBySchema.optional()
958
1046
  });
959
1047
  var ConnectorPollStateSchema = z9.enum(["idle", "healthy", "error", "stale"]);
960
1048
  var ConnectorStatusSchema = z9.object({
@@ -1101,6 +1189,7 @@ export {
1101
1189
  EdgeType,
1102
1190
  EdgeTypeSchema,
1103
1191
  ErrorEventSchema,
1192
+ ExtractionCoverageSchema,
1104
1193
  FileNodeSchema,
1105
1194
  FrontierNodeSchema,
1106
1195
  GraphDiffResultSchema,
@@ -1134,6 +1223,8 @@ export {
1134
1223
  PolicySchema,
1135
1224
  PolicySeveritySchema,
1136
1225
  PolicyViolationSchema,
1226
+ ProjectListEntrySchema,
1227
+ ProjectServedBySchema,
1137
1228
  Provenance,
1138
1229
  ProvenanceRuleSchema,
1139
1230
  ProvenanceSchema,
@@ -1151,6 +1242,9 @@ export {
1151
1242
  StaleEventSchema,
1152
1243
  StaleEventsResponseSchema,
1153
1244
  StructuralRuleSchema,
1245
+ SymbolKindSchema,
1246
+ SymbolNodeSchema,
1247
+ SymbolSpanSchema,
1154
1248
  TransitiveDependenciesResultSchema,
1155
1249
  TransitiveDependencySchema,
1156
1250
  VersionMismatchDivergenceSchema,
@@ -1179,10 +1273,12 @@ export {
1179
1273
  parseInfraId,
1180
1274
  parseRouteId,
1181
1275
  parseServiceId,
1276
+ parseSymbolId,
1182
1277
  parseWebsocketChannelId,
1183
1278
  passesExtractedFloor,
1184
1279
  routeId,
1185
1280
  serviceId,
1281
+ symbolId,
1186
1282
  websocketChannelId
1187
1283
  };
1188
1284
  //# sourceMappingURL=index.js.map