@neat.is/types 0.6.4 → 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.cjs CHANGED
@@ -106,6 +106,9 @@ __export(index_exports, {
106
106
  StaleEventSchema: () => StaleEventSchema,
107
107
  StaleEventsResponseSchema: () => StaleEventsResponseSchema,
108
108
  StructuralRuleSchema: () => StructuralRuleSchema,
109
+ SymbolKindSchema: () => SymbolKindSchema,
110
+ SymbolNodeSchema: () => SymbolNodeSchema,
111
+ SymbolSpanSchema: () => SymbolSpanSchema,
109
112
  TransitiveDependenciesResultSchema: () => TransitiveDependenciesResultSchema,
110
113
  TransitiveDependencySchema: () => TransitiveDependencySchema,
111
114
  VersionMismatchDivergenceSchema: () => VersionMismatchDivergenceSchema,
@@ -134,10 +137,12 @@ __export(index_exports, {
134
137
  parseInfraId: () => parseInfraId,
135
138
  parseRouteId: () => parseRouteId,
136
139
  parseServiceId: () => parseServiceId,
140
+ parseSymbolId: () => parseSymbolId,
137
141
  parseWebsocketChannelId: () => parseWebsocketChannelId,
138
142
  passesExtractedFloor: () => passesExtractedFloor,
139
143
  routeId: () => routeId,
140
144
  serviceId: () => serviceId,
145
+ symbolId: () => symbolId,
141
146
  websocketChannelId: () => websocketChannelId
142
147
  });
143
148
  module.exports = __toCommonJS(index_exports);
@@ -166,7 +171,16 @@ var EdgeType = {
166
171
  // Static module dependency between two FileNodes within a service (ADR-092,
167
172
  // file-awareness.md §10). Compile-time, not runtime — represents one file
168
173
  // importing another. Distinct from CALLS which records runtime invocations.
169
- IMPORTS: "IMPORTS"
174
+ IMPORTS: "IMPORTS",
175
+ // Static heritage between two SymbolNodes (ADR-158 §3). `INHERITS` records a
176
+ // class's `extends` clause (`class ──INHERITS──▶ superclass`); `IMPLEMENTS`
177
+ // records an `implements` clause (`class ──IMPLEMENTS──▶ implemented`). Both
178
+ // are symbol→symbol, EXTRACTED, minted only when the parent name resolves to
179
+ // exactly one known SymbolNode — same-file or through the import graph — never
180
+ // fuzzy-matched. A parent that resolves to nothing (external package,
181
+ // re-export chain, an interface, which is not a SymbolNode) emits no edge.
182
+ INHERITS: "INHERITS",
183
+ IMPLEMENTS: "IMPLEMENTS"
170
184
  };
171
185
  var NodeType = {
172
186
  ServiceNode: "ServiceNode",
@@ -216,7 +230,18 @@ var NodeType = {
216
230
  // edge that carries `lastObserved` and decays OBSERVED → STALE on CONNECTS_TO's
217
231
  // own staleness threshold when the channel goes quiet. See
218
232
  // docs/contracts/otel-ingest.md.
219
- WebSocketChannelNode: "WebSocketChannelNode"
233
+ WebSocketChannelNode: "WebSocketChannelNode",
234
+ // A symbol under a file — a function, method, constructor, or class
235
+ // definition — at definition-span granularity (ADR-158). Static-first: the
236
+ // extractor mints one per definition and the file owns it through a
237
+ // `file ──CONTAINS──▶ symbol` edge, one containment level below
238
+ // `service ──CONTAINS──▶ file`. It carries its `{ startLine, endLine }`
239
+ // definition span, which is the fusion key ingest joins a span's `code.line`
240
+ // against to land an OBSERVED edge on the calling symbol rather than only its
241
+ // file (observed-first edges, one grain finer than §4 file grain). The node is
242
+ // language-neutral; the per-language tree-sitter extractor is the adapter. See
243
+ // docs/contracts/static-extraction.md and docs/contracts/file-awareness.md §1.
244
+ SymbolNode: "SymbolNode"
220
245
  };
221
246
  var NodeTypeSchema = import_zod.z.enum([
222
247
  NodeType.ServiceNode,
@@ -228,7 +253,8 @@ var NodeTypeSchema = import_zod.z.enum([
228
253
  NodeType.RouteNode,
229
254
  NodeType.GraphQLOperationNode,
230
255
  NodeType.GrpcMethodNode,
231
- NodeType.WebSocketChannelNode
256
+ NodeType.WebSocketChannelNode,
257
+ NodeType.SymbolNode
232
258
  ]);
233
259
 
234
260
  // src/nodes.ts
@@ -419,6 +445,21 @@ var WebSocketChannelNodeSchema = import_zod2.z.object({
419
445
  line: import_zod2.z.number().int().nonnegative().optional(),
420
446
  discoveredVia: DiscoveredViaSchema.optional()
421
447
  });
448
+ var SymbolKindSchema = import_zod2.z.enum(["function", "method", "constructor", "class"]);
449
+ var SymbolSpanSchema = import_zod2.z.object({
450
+ startLine: import_zod2.z.number().int().nonnegative(),
451
+ endLine: import_zod2.z.number().int().nonnegative()
452
+ });
453
+ var SymbolNodeSchema = import_zod2.z.object({
454
+ id: import_zod2.z.string(),
455
+ type: import_zod2.z.literal(NodeType.SymbolNode),
456
+ kind: SymbolKindSchema,
457
+ qualname: import_zod2.z.string(),
458
+ span: SymbolSpanSchema,
459
+ service: import_zod2.z.string(),
460
+ relPath: import_zod2.z.string(),
461
+ discoveredVia: DiscoveredViaSchema.optional()
462
+ });
422
463
  var GraphNodeSchema = import_zod2.z.discriminatedUnion("type", [
423
464
  ServiceNodeSchema,
424
465
  DatabaseNodeSchema,
@@ -429,7 +470,8 @@ var GraphNodeSchema = import_zod2.z.discriminatedUnion("type", [
429
470
  RouteNodeSchema,
430
471
  GraphQLOperationNodeSchema,
431
472
  GrpcMethodNodeSchema,
432
- WebSocketChannelNodeSchema
473
+ WebSocketChannelNodeSchema,
474
+ SymbolNodeSchema
433
475
  ]);
434
476
 
435
477
  // src/edges.ts
@@ -449,7 +491,9 @@ var EdgeTypeSchema = import_zod3.z.enum([
449
491
  EdgeType.CONSUMES_FROM,
450
492
  EdgeType.RUNS_ON,
451
493
  EdgeType.CONTAINS,
452
- EdgeType.IMPORTS
494
+ EdgeType.IMPORTS,
495
+ EdgeType.INHERITS,
496
+ EdgeType.IMPLEMENTS
453
497
  ]);
454
498
  var EdgeEvidenceSchema = import_zod3.z.object({
455
499
  file: import_zod3.z.string(),
@@ -637,6 +681,7 @@ var ROUTE_PREFIX = "route:";
637
681
  var GRAPHQL_OP_PREFIX = "graphql:";
638
682
  var GRPC_METHOD_PREFIX = "grpc:";
639
683
  var WEBSOCKET_CHANNEL_PREFIX = "ws:";
684
+ var SYMBOL_PREFIX = "symbol:";
640
685
  var ENV_UNKNOWN = "unknown";
641
686
  function serviceId(name, env) {
642
687
  if (env === void 0 || env === ENV_UNKNOWN) return `${SERVICE_PREFIX}${name}`;
@@ -756,6 +801,34 @@ function parseWebsocketChannelId(id) {
756
801
  if (service.length === 0 || channel.length === 0) return null;
757
802
  return { service, channel };
758
803
  }
804
+ function symbolId(service, relPath, qualname, disambiguator) {
805
+ const base = `${SYMBOL_PREFIX}${service}:${relPath}#${qualname}`;
806
+ return disambiguator === void 0 ? base : `${base}~${disambiguator}`;
807
+ }
808
+ function parseSymbolId(id) {
809
+ if (!id.startsWith(SYMBOL_PREFIX)) return null;
810
+ const rest = id.slice(SYMBOL_PREFIX.length);
811
+ const colon = rest.indexOf(":");
812
+ if (colon === -1) return null;
813
+ const service = rest.slice(0, colon);
814
+ const tail = rest.slice(colon + 1);
815
+ const hash = tail.lastIndexOf("#");
816
+ if (hash === -1) return null;
817
+ const relPath = tail.slice(0, hash);
818
+ let qualname = tail.slice(hash + 1);
819
+ if (service.length === 0 || relPath.length === 0 || qualname.length === 0) return null;
820
+ let disambiguator;
821
+ const tilde = qualname.lastIndexOf("~");
822
+ if (tilde !== -1) {
823
+ const suffix = qualname.slice(tilde + 1);
824
+ if (suffix.length > 0 && /^\d+$/.test(suffix)) {
825
+ disambiguator = Number(suffix);
826
+ qualname = qualname.slice(0, tilde);
827
+ }
828
+ }
829
+ if (qualname.length === 0) return null;
830
+ return { service, relPath, qualname, ...disambiguator !== void 0 ? { disambiguator } : {} };
831
+ }
759
832
  var EDGE_ARROW = "->";
760
833
  function extractedEdgeId(source, target, type) {
761
834
  return `${type}:${source}${EDGE_ARROW}${target}`;
@@ -1319,6 +1392,9 @@ function passesExtractedFloor(confidence) {
1319
1392
  StaleEventSchema,
1320
1393
  StaleEventsResponseSchema,
1321
1394
  StructuralRuleSchema,
1395
+ SymbolKindSchema,
1396
+ SymbolNodeSchema,
1397
+ SymbolSpanSchema,
1322
1398
  TransitiveDependenciesResultSchema,
1323
1399
  TransitiveDependencySchema,
1324
1400
  VersionMismatchDivergenceSchema,
@@ -1347,10 +1423,12 @@ function passesExtractedFloor(confidence) {
1347
1423
  parseInfraId,
1348
1424
  parseRouteId,
1349
1425
  parseServiceId,
1426
+ parseSymbolId,
1350
1427
  parseWebsocketChannelId,
1351
1428
  passesExtractedFloor,
1352
1429
  routeId,
1353
1430
  serviceId,
1431
+ symbolId,
1354
1432
  websocketChannelId
1355
1433
  });
1356
1434
  //# sourceMappingURL=index.cjs.map