@suss/ir-core 0.7.2 → 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,13 +222,19 @@ 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",
217
233
  "kafka",
218
- "nats"
234
+ "nats",
235
+ "cloudflare-queues",
236
+ "cloudflare-cron",
237
+ "cloudflare-tail"
219
238
  ]),
220
239
  /**
221
240
  * Stable channel identifier: a CFN logical id, a queue or topic name,
@@ -228,6 +247,10 @@ var MessageBusSemanticsSchema = import_zod4.z.object({
228
247
  var messageBusSemantics = defineBoundarySemantics({
229
248
  name: "message-bus",
230
249
  schema: MessageBusSemanticsSchema,
250
+ semconv: {
251
+ messageBus: { name: "messaging.system" },
252
+ channel: { name: "messaging.destination.name" }
253
+ },
231
254
  behavior: {
232
255
  /** A message goes onto the channel and nothing comes back. */
233
256
  exchangesHttpResponses: false,
@@ -286,25 +309,58 @@ var messageBusSemantics = defineBoundarySemantics({
286
309
  }
287
310
  });
288
311
 
289
- // src/semantics/rest.ts
312
+ // src/semantics/metric.ts
290
313
  var import_zod5 = require("zod");
291
- var RestSemanticsSchema = import_zod5.z.object({
292
- 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"),
293
349
  /**
294
350
  * Uppercase HTTP method ("GET", "POST", …), `"*"` for a handler that
295
351
  * responds to every method, or null when this source does not say
296
352
  * which method.
297
353
  */
298
- method: import_zod5.z.string().min(1).nullable(),
354
+ method: import_zod6.z.string().min(1).nullable(),
299
355
  /** Normalized route path ("/users/{id}"), or null when this source does not give one. */
300
- path: import_zod5.z.string().min(1).nullable(),
356
+ path: import_zod6.z.string().min(1).nullable(),
301
357
  /**
302
358
  * Status codes the producing source explicitly declared (OpenAPI
303
359
  * responses, CFN MethodResponses, ts-rest router statuses). They are
304
360
  * kept here so the pairing layer can see them without unwrapping any
305
361
  * metadata. Absent, or empty, for a source that was inferred.
306
362
  */
307
- declaredResponses: import_zod5.z.array(import_zod5.z.number()).optional()
363
+ declaredResponses: import_zod6.z.array(import_zod6.z.number()).optional()
308
364
  });
309
365
  function normalizePath(path) {
310
366
  let normalized = path.replace(/:([a-zA-Z_]\w*)/g, "{$1}");
@@ -343,6 +399,14 @@ function routePathAdmits(declaredPath, requestPath) {
343
399
  var restSemantics = defineBoundarySemantics({
344
400
  name: "rest",
345
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
+ },
346
410
  behavior: {
347
411
  /** A request goes out, a status and a body come back. */
348
412
  exchangesHttpResponses: true,
@@ -415,29 +479,34 @@ var restSemantics = defineBoundarySemantics({
415
479
  });
416
480
 
417
481
  // src/semantics/runtimeConfig.ts
418
- var import_zod7 = require("zod");
482
+ var import_zod8 = require("zod");
419
483
 
420
484
  // src/deployableUnit.ts
421
- var import_zod6 = require("zod");
422
- var DeployableUnitSchema = import_zod6.z.object({
423
- deploymentTarget: import_zod6.z.enum([
485
+ var import_zod7 = require("zod");
486
+ var DeployableUnitSchema = import_zod7.z.object({
487
+ deploymentTarget: import_zod7.z.enum([
424
488
  "lambda",
425
489
  "ecs-task",
426
490
  "container",
427
- "k8s-deployment"
491
+ "k8s-deployment",
492
+ "worker"
428
493
  ]),
429
494
  // An empty name would agree with every other empty name, so a unit
430
495
  // with no name has to leave the field off instead.
431
- instanceName: import_zod6.z.string().min(1)
496
+ instanceName: import_zod7.z.string().min(1)
432
497
  });
433
498
 
434
499
  // src/semantics/runtimeConfig.ts
435
500
  var RuntimeConfigSemanticsSchema = DeployableUnitSchema.extend({
436
- name: import_zod7.z.literal("runtime-config")
501
+ name: import_zod8.z.literal("runtime-config")
437
502
  });
438
503
  var runtimeConfigSemantics = defineBoundarySemantics({
439
504
  name: "runtime-config",
440
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: {},
441
510
  behavior: {
442
511
  /** A process reads its config at startup, and nothing replies. */
443
512
  exchangesHttpResponses: false,
@@ -447,28 +516,28 @@ var runtimeConfigSemantics = defineBoundarySemantics({
447
516
  });
448
517
 
449
518
  // src/semantics/storage.ts
450
- var import_zod8 = require("zod");
451
- var StorageSemanticsSchema = import_zod8.z.object({
452
- 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"),
453
522
  /**
454
- * Which store this is: postgres, mysql, sqlite, dynamodb. Two
455
- * products' containers can share a name, so this keeps them apart,
456
- * 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.
457
526
  */
458
- storageSystem: import_zod8.z.string(),
527
+ storageSystem: import_zod9.z.string(),
459
528
  /**
460
529
  * The ORM, schema, or deployment scope. A single-database setup uses
461
530
  * `"default"`, and a monorepo with several schemas gives each one its
462
531
  * own value.
463
532
  */
464
- scope: import_zod8.z.string(),
533
+ scope: import_zod9.z.string(),
465
534
  /**
466
535
  * The table, bucket, collection, or index, as the source declares
467
536
  * it, or null when the source states one this reader could not
468
537
  * settle. A null container pairs with nothing, rather than with
469
538
  * whatever its source text happens to spell.
470
539
  */
471
- container: import_zod8.z.string().nullable(),
540
+ container: import_zod9.z.string().nullable(),
472
541
  /**
473
542
  * A secondary way into the container, a DynamoDB global secondary
474
543
  * index or an Elasticsearch alias, each with its own key fields.
@@ -476,11 +545,19 @@ var StorageSemanticsSchema = import_zod8.z.object({
476
545
  * index and a query through the table are different accesses, so
477
546
  * they pair separately.
478
547
  */
479
- accessPath: import_zod8.z.string().nullable()
548
+ accessPath: import_zod9.z.string().nullable()
480
549
  });
481
550
  var storageSemantics = defineBoundarySemantics({
482
551
  name: "storage",
483
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
+ },
484
561
  behavior: {
485
562
  /** A query returns rows or items, not a status and a body. */
486
563
  exchangesHttpResponses: false,
@@ -490,14 +567,15 @@ var storageSemantics = defineBoundarySemantics({
490
567
  });
491
568
 
492
569
  // src/semantics/registry.ts
493
- var SemanticsSchema = import_zod9.z.discriminatedUnion("name", [
570
+ var SemanticsSchema = import_zod10.z.discriminatedUnion("name", [
494
571
  restSemantics.schema,
495
572
  functionCallSemantics.schema,
496
573
  graphqlResolverSemantics.schema,
497
574
  graphqlOperationSemantics.schema,
498
575
  runtimeConfigSemantics.schema,
499
576
  storageSemantics.schema,
500
- messageBusSemantics.schema
577
+ messageBusSemantics.schema,
578
+ metricSemantics.schema
501
579
  ]);
502
580
  var DEFINITIONS = [
503
581
  restSemantics,
@@ -506,38 +584,39 @@ var DEFINITIONS = [
506
584
  graphqlOperationSemantics,
507
585
  runtimeConfigSemantics,
508
586
  storageSemantics,
509
- messageBusSemantics
587
+ messageBusSemantics,
588
+ metricSemantics
510
589
  ];
511
590
  var BY_NAME = new Map(
512
591
  DEFINITIONS.map((d) => [d.name, d])
513
592
  );
514
593
 
515
594
  // src/schemas.ts
516
- var ConfidenceSourceSchema = import_zod10.z.enum([
595
+ var ConfidenceSourceSchema = import_zod11.z.enum([
517
596
  "inferred_static",
518
597
  "inferred_ai",
519
598
  "declared",
520
599
  "derived"
521
600
  ]);
522
- var ConfidenceLevelSchema = import_zod10.z.enum(["high", "medium", "low"]);
523
- var CorroborationSchema = import_zod10.z.object({
524
- 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"]),
525
604
  /** Executions that produced a verdict for this claim. */
526
- runs: import_zod10.z.number(),
605
+ runs: import_zod11.z.number(),
527
606
  /** Present when refuted: the input and observation that disagreed. */
528
- counterexample: import_zod10.z.unknown().optional(),
607
+ counterexample: import_zod11.z.unknown().optional(),
529
608
  /** Present when untested: why no verdict was reachable. */
530
- reason: import_zod10.z.string().optional()
609
+ reason: import_zod11.z.string().optional()
531
610
  });
532
- var ConfidenceInfoSchema = import_zod10.z.object({
611
+ var ConfidenceInfoSchema = import_zod11.z.object({
533
612
  source: ConfidenceSourceSchema,
534
613
  level: ConfidenceLevelSchema,
535
614
  corroboration: CorroborationSchema.optional()
536
615
  });
537
- var SourceLocationSchema = import_zod10.z.object({
538
- file: import_zod10.z.string(),
539
- range: import_zod10.z.object({ start: import_zod10.z.number(), end: import_zod10.z.number() }),
540
- 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(),
541
620
  /**
542
621
  * The project the extract was pointed at, by the name that project
543
622
  * calls itself.
@@ -547,47 +626,47 @@ var SourceLocationSchema = import_zod10.z.object({
547
626
  * summaries puts them on top of each other. This field is what tells
548
627
  * them apart, and what a reader groups by.
549
628
  */
550
- workspace: import_zod10.z.string().optional()
629
+ workspace: import_zod11.z.string().optional()
551
630
  });
552
- var BoundaryBindingSchema = import_zod10.z.object({
553
- transport: import_zod10.z.string(),
631
+ var BoundaryBindingSchema = import_zod11.z.object({
632
+ transport: import_zod11.z.string(),
554
633
  semantics: SemanticsSchema,
555
- recognition: import_zod10.z.string()
634
+ recognition: import_zod11.z.string()
556
635
  });
557
636
  function typeDefinitionKey(ref) {
558
637
  return ref.def ?? null;
559
638
  }
560
- var TypeShapeSchema = import_zod10.z.lazy(
561
- () => import_zod10.z.discriminatedUnion("type", [
562
- import_zod10.z.object({
563
- type: import_zod10.z.literal("record"),
564
- properties: import_zod10.z.record(import_zod10.z.string(), TypeShapeSchema),
565
- 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()
566
645
  }),
567
- import_zod10.z.object({ type: import_zod10.z.literal("dictionary"), values: TypeShapeSchema }),
568
- import_zod10.z.object({ type: import_zod10.z.literal("array"), items: TypeShapeSchema }),
569
- import_zod10.z.object({
570
- type: import_zod10.z.literal("literal"),
571
- value: import_zod10.z.union([import_zod10.z.string(), import_zod10.z.number(), import_zod10.z.boolean()]),
572
- 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()
573
652
  }),
574
- import_zod10.z.object({ type: import_zod10.z.literal("text") }),
575
- import_zod10.z.object({ type: import_zod10.z.literal("integer") }),
576
- import_zod10.z.object({ type: import_zod10.z.literal("number") }),
577
- import_zod10.z.object({ type: import_zod10.z.literal("boolean") }),
578
- import_zod10.z.object({ type: import_zod10.z.literal("null") }),
579
- import_zod10.z.object({ type: import_zod10.z.literal("undefined") }),
580
- import_zod10.z.object({
581
- type: import_zod10.z.literal("union"),
582
- 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)
583
662
  }),
584
- import_zod10.z.object({
585
- type: import_zod10.z.literal("ref"),
586
- name: import_zod10.z.string(),
587
- from: import_zod10.z.string().optional(),
588
- 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()
589
668
  }),
590
- import_zod10.z.object({ type: import_zod10.z.literal("unknown") })
669
+ import_zod11.z.object({ type: import_zod11.z.literal("unknown") })
591
670
  ])
592
671
  );
593
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-D6hKT-zV.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-D6hKT-zV.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-TEXSN75M.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.7.2",
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": [