@suss/ir-core 0.8.0 → 0.9.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/schemas.cjs CHANGED
@@ -40,10 +40,10 @@ __export(schemas_exports, {
40
40
  withDefinitionsInlined: () => withDefinitionsInlined
41
41
  });
42
42
  module.exports = __toCommonJS(schemas_exports);
43
- var import_zod10 = require("zod");
43
+ var import_zod11 = require("zod");
44
44
 
45
45
  // src/semantics/registry.ts
46
- var import_zod9 = require("zod");
46
+ var import_zod10 = require("zod");
47
47
 
48
48
  // src/semantics/functionCall.ts
49
49
  var import_zod = require("zod");
@@ -58,6 +58,9 @@ function fnIdentityKey(packageName, exportPath) {
58
58
  function busIdentityKey(messageBus, subject) {
59
59
  return `bus:${messageBus} ${subject}`;
60
60
  }
61
+ function metricIdentityKey(metricSystem, metricType) {
62
+ return `metric:${metricSystem} ${metricType}`;
63
+ }
61
64
 
62
65
  // src/semantics/definition.ts
63
66
  function defineBoundarySemantics(definition) {
@@ -99,6 +102,9 @@ var FunctionCallSemanticsSchema = import_zod.z.object({
99
102
  var functionCallSemantics = defineBoundarySemantics({
100
103
  name: "function-call",
101
104
  schema: FunctionCallSemanticsSchema,
105
+ // A call that never leaves the process does not produce a span, and
106
+ // the conventions do not name one. All of it is ours.
107
+ semconv: {},
102
108
  behavior: {
103
109
  /** A call returns a value, which is not a status and a body. */
104
110
  exchangesHttpResponses: false,
@@ -134,6 +140,10 @@ var GraphqlOperationSemanticsSchema = import_zod2.z.object({
134
140
  var graphqlOperationSemantics = defineBoundarySemantics({
135
141
  name: "graphql-operation",
136
142
  schema: GraphqlOperationSemanticsSchema,
143
+ semconv: {
144
+ operationName: { name: "graphql.operation.name" },
145
+ operationType: { name: "graphql.operation.type" }
146
+ },
137
147
  behavior: {
138
148
  /**
139
149
  * An operation gets a data-and-errors document back, which the
@@ -167,6 +177,9 @@ var GraphqlResolverSemanticsSchema = import_zod3.z.object({
167
177
  var graphqlResolverSemantics = defineBoundarySemantics({
168
178
  name: "graphql-resolver",
169
179
  schema: GraphqlResolverSemanticsSchema,
180
+ // The conventions name the operation a client sent, not the
181
+ // resolver the server ran for one field of it.
182
+ semconv: {},
170
183
  behavior: {
171
184
  /** A resolver returns a field value, not a status and a body. */
172
185
  exchangesHttpResponses: false,
@@ -209,8 +222,11 @@ function channelsPair(a, b) {
209
222
  var MessageBusSemanticsSchema = import_zod4.z.object({
210
223
  name: import_zod4.z.literal("message-bus"),
211
224
  messageBus: import_zod4.z.enum([
212
- "sqs",
213
- "sns",
225
+ // The conventions spell the two AWS buses this way, one with an
226
+ // underscore and one with a dot, so these are their strings and
227
+ // not a typo.
228
+ "aws_sqs",
229
+ "aws.sns",
214
230
  "s3",
215
231
  "eventbridge",
216
232
  "bullmq",
@@ -231,6 +247,10 @@ var MessageBusSemanticsSchema = import_zod4.z.object({
231
247
  var messageBusSemantics = defineBoundarySemantics({
232
248
  name: "message-bus",
233
249
  schema: MessageBusSemanticsSchema,
250
+ semconv: {
251
+ messageBus: { name: "messaging.system" },
252
+ channel: { name: "messaging.destination.name" }
253
+ },
234
254
  behavior: {
235
255
  /** A message goes onto the channel and nothing comes back. */
236
256
  exchangesHttpResponses: false,
@@ -289,25 +309,58 @@ var messageBusSemantics = defineBoundarySemantics({
289
309
  }
290
310
  });
291
311
 
292
- // src/semantics/rest.ts
312
+ // src/semantics/metric.ts
293
313
  var import_zod5 = require("zod");
294
- var RestSemanticsSchema = import_zod5.z.object({
295
- name: import_zod5.z.literal("rest"),
314
+ var MetricSemanticsSchema = import_zod5.z.object({
315
+ name: import_zod5.z.literal("metric"),
316
+ /** Which system the series lives in: cloud-monitoring, cloudwatch. */
317
+ metricSystem: import_zod5.z.string(),
318
+ /**
319
+ * The type string the system knows the metric by, spelled the way
320
+ * both sides spell it. Null when the source states one this reader
321
+ * could not settle, as with a query it could not read: a metric
322
+ * nobody could name pairs with nothing rather than with whatever
323
+ * happens to share its source text.
324
+ */
325
+ metricType: import_zod5.z.string().nullable()
326
+ });
327
+ var metricSemantics = defineBoundarySemantics({
328
+ name: "metric",
329
+ schema: MetricSemanticsSchema,
330
+ // OpenTelemetry knows a metric by its instrument name, and has no
331
+ // attribute for the system it lives in or the type string it goes by.
332
+ semconv: {},
333
+ behavior: {
334
+ exchangesHttpResponses: false,
335
+ reportsUnpairedItself: false,
336
+ identityKey(semantics) {
337
+ if (semantics.metricType === null) {
338
+ return null;
339
+ }
340
+ return metricIdentityKey(semantics.metricSystem, semantics.metricType);
341
+ }
342
+ }
343
+ });
344
+
345
+ // src/semantics/rest.ts
346
+ var import_zod6 = require("zod");
347
+ var RestSemanticsSchema = import_zod6.z.object({
348
+ name: import_zod6.z.literal("rest"),
296
349
  /**
297
350
  * Uppercase HTTP method ("GET", "POST", …), `"*"` for a handler that
298
351
  * responds to every method, or null when this source does not say
299
352
  * which method.
300
353
  */
301
- method: import_zod5.z.string().min(1).nullable(),
354
+ method: import_zod6.z.string().min(1).nullable(),
302
355
  /** Normalized route path ("/users/{id}"), or null when this source does not give one. */
303
- path: import_zod5.z.string().min(1).nullable(),
356
+ path: import_zod6.z.string().min(1).nullable(),
304
357
  /**
305
358
  * Status codes the producing source explicitly declared (OpenAPI
306
359
  * responses, CFN MethodResponses, ts-rest router statuses). They are
307
360
  * kept here so the pairing layer can see them without unwrapping any
308
361
  * metadata. Absent, or empty, for a source that was inferred.
309
362
  */
310
- declaredResponses: import_zod5.z.array(import_zod5.z.number()).optional()
363
+ declaredResponses: import_zod6.z.array(import_zod6.z.number()).optional()
311
364
  });
312
365
  function normalizePath(path) {
313
366
  let normalized = path.replace(/:([a-zA-Z_]\w*)/g, "{$1}");
@@ -346,6 +399,14 @@ function routePathAdmits(declaredPath, requestPath) {
346
399
  var restSemantics = defineBoundarySemantics({
347
400
  name: "rest",
348
401
  schema: RestSemanticsSchema,
402
+ semconv: {
403
+ // A span states the one method a request used, so a route that
404
+ // responds to every method has nothing to compare.
405
+ method: { name: "http.request.method", placeholderValues: ["*"] },
406
+ path: { name: "http.route" }
407
+ // declaredResponses is a list, and http.response.status_code is
408
+ // the one status a request got back.
409
+ },
349
410
  behavior: {
350
411
  /** A request goes out, a status and a body come back. */
351
412
  exchangesHttpResponses: true,
@@ -418,12 +479,12 @@ var restSemantics = defineBoundarySemantics({
418
479
  });
419
480
 
420
481
  // src/semantics/runtimeConfig.ts
421
- var import_zod7 = require("zod");
482
+ var import_zod8 = require("zod");
422
483
 
423
484
  // src/deployableUnit.ts
424
- var import_zod6 = require("zod");
425
- var DeployableUnitSchema = import_zod6.z.object({
426
- deploymentTarget: import_zod6.z.enum([
485
+ var import_zod7 = require("zod");
486
+ var DeployableUnitSchema = import_zod7.z.object({
487
+ deploymentTarget: import_zod7.z.enum([
427
488
  "lambda",
428
489
  "ecs-task",
429
490
  "container",
@@ -432,16 +493,20 @@ var DeployableUnitSchema = import_zod6.z.object({
432
493
  ]),
433
494
  // An empty name would agree with every other empty name, so a unit
434
495
  // with no name has to leave the field off instead.
435
- instanceName: import_zod6.z.string().min(1)
496
+ instanceName: import_zod7.z.string().min(1)
436
497
  });
437
498
 
438
499
  // src/semantics/runtimeConfig.ts
439
500
  var RuntimeConfigSemanticsSchema = DeployableUnitSchema.extend({
440
- name: import_zod7.z.literal("runtime-config")
501
+ name: import_zod8.z.literal("runtime-config")
441
502
  });
442
503
  var runtimeConfigSemantics = defineBoundarySemantics({
443
504
  name: "runtime-config",
444
505
  schema: RuntimeConfigSemanticsSchema,
506
+ // service.name and cloud.resource_id name the same deployable, but
507
+ // instanceName is the deployment template's logical id, which is
508
+ // neither of those strings.
509
+ semconv: {},
445
510
  behavior: {
446
511
  /** A process reads its config at startup, and nothing replies. */
447
512
  exchangesHttpResponses: false,
@@ -451,28 +516,28 @@ var runtimeConfigSemantics = defineBoundarySemantics({
451
516
  });
452
517
 
453
518
  // src/semantics/storage.ts
454
- var import_zod8 = require("zod");
455
- var StorageSemanticsSchema = import_zod8.z.object({
456
- name: import_zod8.z.literal("storage"),
519
+ var import_zod9 = require("zod");
520
+ var StorageSemanticsSchema = import_zod9.z.object({
521
+ name: import_zod9.z.literal("storage"),
457
522
  /**
458
- * Which store this is: postgres, mysql, sqlite, dynamodb. Two
459
- * products' containers can share a name, so this keeps them apart,
460
- * and it is what a finding message calls the store.
523
+ * Which store this is: postgresql, mysql, aws.dynamodb, or our own
524
+ * word for one OpenTelemetry never named, such as s3. Two products'
525
+ * containers can share a name, so this keeps them apart.
461
526
  */
462
- storageSystem: import_zod8.z.string(),
527
+ storageSystem: import_zod9.z.string(),
463
528
  /**
464
529
  * The ORM, schema, or deployment scope. A single-database setup uses
465
530
  * `"default"`, and a monorepo with several schemas gives each one its
466
531
  * own value.
467
532
  */
468
- scope: import_zod8.z.string(),
533
+ scope: import_zod9.z.string(),
469
534
  /**
470
535
  * The table, bucket, collection, or index, as the source declares
471
536
  * it, or null when the source states one this reader could not
472
537
  * settle. A null container pairs with nothing, rather than with
473
538
  * whatever its source text happens to spell.
474
539
  */
475
- container: import_zod8.z.string().nullable(),
540
+ container: import_zod9.z.string().nullable(),
476
541
  /**
477
542
  * A secondary way into the container, a DynamoDB global secondary
478
543
  * index or an Elasticsearch alias, each with its own key fields.
@@ -480,11 +545,19 @@ var StorageSemanticsSchema = import_zod8.z.object({
480
545
  * index and a query through the table are different accesses, so
481
546
  * they pair separately.
482
547
  */
483
- accessPath: import_zod8.z.string().nullable()
548
+ accessPath: import_zod9.z.string().nullable()
484
549
  });
485
550
  var storageSemantics = defineBoundarySemantics({
486
551
  name: "storage",
487
552
  schema: StorageSemanticsSchema,
553
+ semconv: {
554
+ storageSystem: { name: "db.system.name" },
555
+ // "default" is our word for a source that named no database.
556
+ scope: { name: "db.namespace", placeholderValues: ["default"] },
557
+ container: { name: "db.collection.name" }
558
+ // A secondary index has no attribute of its own, so accessPath
559
+ // stays our word.
560
+ },
488
561
  behavior: {
489
562
  /** A query returns rows or items, not a status and a body. */
490
563
  exchangesHttpResponses: false,
@@ -494,14 +567,15 @@ var storageSemantics = defineBoundarySemantics({
494
567
  });
495
568
 
496
569
  // src/semantics/registry.ts
497
- var SemanticsSchema = import_zod9.z.discriminatedUnion("name", [
570
+ var SemanticsSchema = import_zod10.z.discriminatedUnion("name", [
498
571
  restSemantics.schema,
499
572
  functionCallSemantics.schema,
500
573
  graphqlResolverSemantics.schema,
501
574
  graphqlOperationSemantics.schema,
502
575
  runtimeConfigSemantics.schema,
503
576
  storageSemantics.schema,
504
- messageBusSemantics.schema
577
+ messageBusSemantics.schema,
578
+ metricSemantics.schema
505
579
  ]);
506
580
  var DEFINITIONS = [
507
581
  restSemantics,
@@ -510,38 +584,39 @@ var DEFINITIONS = [
510
584
  graphqlOperationSemantics,
511
585
  runtimeConfigSemantics,
512
586
  storageSemantics,
513
- messageBusSemantics
587
+ messageBusSemantics,
588
+ metricSemantics
514
589
  ];
515
590
  var BY_NAME = new Map(
516
591
  DEFINITIONS.map((d) => [d.name, d])
517
592
  );
518
593
 
519
594
  // src/schemas.ts
520
- var ConfidenceSourceSchema = import_zod10.z.enum([
595
+ var ConfidenceSourceSchema = import_zod11.z.enum([
521
596
  "inferred_static",
522
597
  "inferred_ai",
523
598
  "declared",
524
599
  "derived"
525
600
  ]);
526
- var ConfidenceLevelSchema = import_zod10.z.enum(["high", "medium", "low"]);
527
- var CorroborationSchema = import_zod10.z.object({
528
- outcome: import_zod10.z.enum(["observed", "refuted", "untested"]),
601
+ var ConfidenceLevelSchema = import_zod11.z.enum(["high", "medium", "low"]);
602
+ var CorroborationSchema = import_zod11.z.object({
603
+ outcome: import_zod11.z.enum(["observed", "refuted", "untested"]),
529
604
  /** Executions that produced a verdict for this claim. */
530
- runs: import_zod10.z.number(),
605
+ runs: import_zod11.z.number(),
531
606
  /** Present when refuted: the input and observation that disagreed. */
532
- counterexample: import_zod10.z.unknown().optional(),
607
+ counterexample: import_zod11.z.unknown().optional(),
533
608
  /** Present when untested: why no verdict was reachable. */
534
- reason: import_zod10.z.string().optional()
609
+ reason: import_zod11.z.string().optional()
535
610
  });
536
- var ConfidenceInfoSchema = import_zod10.z.object({
611
+ var ConfidenceInfoSchema = import_zod11.z.object({
537
612
  source: ConfidenceSourceSchema,
538
613
  level: ConfidenceLevelSchema,
539
614
  corroboration: CorroborationSchema.optional()
540
615
  });
541
- var SourceLocationSchema = import_zod10.z.object({
542
- file: import_zod10.z.string(),
543
- range: import_zod10.z.object({ start: import_zod10.z.number(), end: import_zod10.z.number() }),
544
- exportName: import_zod10.z.string().nullable(),
616
+ var SourceLocationSchema = import_zod11.z.object({
617
+ file: import_zod11.z.string(),
618
+ range: import_zod11.z.object({ start: import_zod11.z.number(), end: import_zod11.z.number() }),
619
+ exportName: import_zod11.z.string().nullable(),
545
620
  /**
546
621
  * The project the extract was pointed at, by the name that project
547
622
  * calls itself.
@@ -551,47 +626,47 @@ var SourceLocationSchema = import_zod10.z.object({
551
626
  * summaries puts them on top of each other. This field is what tells
552
627
  * them apart, and what a reader groups by.
553
628
  */
554
- workspace: import_zod10.z.string().optional()
629
+ workspace: import_zod11.z.string().optional()
555
630
  });
556
- var BoundaryBindingSchema = import_zod10.z.object({
557
- transport: import_zod10.z.string(),
631
+ var BoundaryBindingSchema = import_zod11.z.object({
632
+ transport: import_zod11.z.string(),
558
633
  semantics: SemanticsSchema,
559
- recognition: import_zod10.z.string()
634
+ recognition: import_zod11.z.string()
560
635
  });
561
636
  function typeDefinitionKey(ref) {
562
637
  return ref.def ?? null;
563
638
  }
564
- var TypeShapeSchema = import_zod10.z.lazy(
565
- () => import_zod10.z.discriminatedUnion("type", [
566
- import_zod10.z.object({
567
- type: import_zod10.z.literal("record"),
568
- properties: import_zod10.z.record(import_zod10.z.string(), TypeShapeSchema),
569
- spreads: import_zod10.z.array(import_zod10.z.object({ sourceText: import_zod10.z.string() })).optional()
639
+ var TypeShapeSchema = import_zod11.z.lazy(
640
+ () => import_zod11.z.discriminatedUnion("type", [
641
+ import_zod11.z.object({
642
+ type: import_zod11.z.literal("record"),
643
+ properties: import_zod11.z.record(import_zod11.z.string(), TypeShapeSchema),
644
+ spreads: import_zod11.z.array(import_zod11.z.object({ sourceText: import_zod11.z.string() })).optional()
570
645
  }),
571
- import_zod10.z.object({ type: import_zod10.z.literal("dictionary"), values: TypeShapeSchema }),
572
- import_zod10.z.object({ type: import_zod10.z.literal("array"), items: TypeShapeSchema }),
573
- import_zod10.z.object({
574
- type: import_zod10.z.literal("literal"),
575
- value: import_zod10.z.union([import_zod10.z.string(), import_zod10.z.number(), import_zod10.z.boolean()]),
576
- raw: import_zod10.z.string().optional()
646
+ import_zod11.z.object({ type: import_zod11.z.literal("dictionary"), values: TypeShapeSchema }),
647
+ import_zod11.z.object({ type: import_zod11.z.literal("array"), items: TypeShapeSchema }),
648
+ import_zod11.z.object({
649
+ type: import_zod11.z.literal("literal"),
650
+ value: import_zod11.z.union([import_zod11.z.string(), import_zod11.z.number(), import_zod11.z.boolean()]),
651
+ raw: import_zod11.z.string().optional()
577
652
  }),
578
- import_zod10.z.object({ type: import_zod10.z.literal("text") }),
579
- import_zod10.z.object({ type: import_zod10.z.literal("integer") }),
580
- import_zod10.z.object({ type: import_zod10.z.literal("number") }),
581
- import_zod10.z.object({ type: import_zod10.z.literal("boolean") }),
582
- import_zod10.z.object({ type: import_zod10.z.literal("null") }),
583
- import_zod10.z.object({ type: import_zod10.z.literal("undefined") }),
584
- import_zod10.z.object({
585
- type: import_zod10.z.literal("union"),
586
- variants: import_zod10.z.array(TypeShapeSchema)
653
+ import_zod11.z.object({ type: import_zod11.z.literal("text") }),
654
+ import_zod11.z.object({ type: import_zod11.z.literal("integer") }),
655
+ import_zod11.z.object({ type: import_zod11.z.literal("number") }),
656
+ import_zod11.z.object({ type: import_zod11.z.literal("boolean") }),
657
+ import_zod11.z.object({ type: import_zod11.z.literal("null") }),
658
+ import_zod11.z.object({ type: import_zod11.z.literal("undefined") }),
659
+ import_zod11.z.object({
660
+ type: import_zod11.z.literal("union"),
661
+ variants: import_zod11.z.array(TypeShapeSchema)
587
662
  }),
588
- import_zod10.z.object({
589
- type: import_zod10.z.literal("ref"),
590
- name: import_zod10.z.string(),
591
- from: import_zod10.z.string().optional(),
592
- def: import_zod10.z.string().optional()
663
+ import_zod11.z.object({
664
+ type: import_zod11.z.literal("ref"),
665
+ name: import_zod11.z.string(),
666
+ from: import_zod11.z.string().optional(),
667
+ def: import_zod11.z.string().optional()
593
668
  }),
594
- import_zod10.z.object({ type: import_zod10.z.literal("unknown") })
669
+ import_zod11.z.object({ type: import_zod11.z.literal("unknown") })
595
670
  ])
596
671
  );
597
672
  var MAX_DEFINITION_DEPTH = 6;
@@ -1,2 +1,2 @@
1
1
  import 'zod';
2
- export { B as BoundaryBindingSchema, C as ConfidenceInfoSchema, a as ConfidenceLevelSchema, b as ConfidenceSourceSchema, c as CorroborationSchema, f as DeployableUnitSchema, g as FunctionCallSemanticsSchema, h as GraphqlOperationSemanticsSchema, j as GraphqlResolverSemanticsSchema, k as MessageBusSemanticsSchema, l as RestSemanticsSchema, n as RuntimeConfigSemanticsSchema, o as SemanticsSchema, d as SourceLocationSchema, q as StorageSemanticsSchema, T as TypeShape, r as TypeShapeSchema, w as typeDefinitionKey, x as withDefinitionsInlined } from './schemas-BLS4PXwc.cjs';
2
+ export { B as BoundaryBindingSchema, C as ConfidenceInfoSchema, a as ConfidenceLevelSchema, b as ConfidenceSourceSchema, c as CorroborationSchema, f as DeployableUnitSchema, g as FunctionCallSemanticsSchema, h as GraphqlOperationSemanticsSchema, j as GraphqlResolverSemanticsSchema, k as MessageBusSemanticsSchema, l as RestSemanticsSchema, n as RuntimeConfigSemanticsSchema, o as SemanticsSchema, d as SourceLocationSchema, q as StorageSemanticsSchema, T as TypeShape, r as TypeShapeSchema, w as typeDefinitionKey, x as withDefinitionsInlined } from './schemas-CGR6qjFf.cjs';
package/dist/schemas.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import 'zod';
2
- export { B as BoundaryBindingSchema, C as ConfidenceInfoSchema, a as ConfidenceLevelSchema, b as ConfidenceSourceSchema, c as CorroborationSchema, f as DeployableUnitSchema, g as FunctionCallSemanticsSchema, h as GraphqlOperationSemanticsSchema, j as GraphqlResolverSemanticsSchema, k as MessageBusSemanticsSchema, l as RestSemanticsSchema, n as RuntimeConfigSemanticsSchema, o as SemanticsSchema, d as SourceLocationSchema, q as StorageSemanticsSchema, T as TypeShape, r as TypeShapeSchema, w as typeDefinitionKey, x as withDefinitionsInlined } from './schemas-BLS4PXwc.js';
2
+ export { B as BoundaryBindingSchema, C as ConfidenceInfoSchema, a as ConfidenceLevelSchema, b as ConfidenceSourceSchema, c as CorroborationSchema, f as DeployableUnitSchema, g as FunctionCallSemanticsSchema, h as GraphqlOperationSemanticsSchema, j as GraphqlResolverSemanticsSchema, k as MessageBusSemanticsSchema, l as RestSemanticsSchema, n as RuntimeConfigSemanticsSchema, o as SemanticsSchema, d as SourceLocationSchema, q as StorageSemanticsSchema, T as TypeShape, r as TypeShapeSchema, w as typeDefinitionKey, x as withDefinitionsInlined } from './schemas-CGR6qjFf.js';
package/dist/schemas.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  TypeShapeSchema,
18
18
  typeDefinitionKey,
19
19
  withDefinitionsInlined
20
- } from "./chunk-WRRENYBR.js";
20
+ } from "./chunk-XUXN6DIX.js";
21
21
  export {
22
22
  BoundaryBindingSchema,
23
23
  ConfidenceInfoSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suss/ir-core",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "description": "Shared IR primitives for suss — type shapes, boundary bindings, source locations, and confidence. Imported by both @suss/behavioral-ir and @suss/intent-ir so neither depends on the other.",
6
6
  "keywords": [