@suss/ir-core 0.20.0 → 0.21.1

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_zod11 = require("zod");
43
+ var import_zod12 = require("zod");
44
44
 
45
45
  // src/semantics/registry.ts
46
- var import_zod10 = require("zod");
46
+ var import_zod11 = 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 unitIdentityKey(deploymentTarget, instanceName) {
62
+ return `unit:${deploymentTarget} ${instanceName}`;
63
+ }
61
64
  function metricIdentityKey(metricSystem, metricType) {
62
65
  return `metric:${metricSystem} ${metricType}`;
63
66
  }
@@ -355,6 +358,44 @@ var metricSemantics = defineBoundarySemantics({
355
358
  // src/semantics/rest.ts
356
359
  var import_zod6 = require("zod");
357
360
 
361
+ // src/boundaryName.ts
362
+ var HOLE_SPLIT = /(\{[^}]*\})/;
363
+ function isHole(piece) {
364
+ return piece.startsWith("{") && piece.endsWith("}");
365
+ }
366
+ function parseBoundaryName(name) {
367
+ const parts = name.split(HOLE_SPLIT).filter((piece) => piece !== "").map(
368
+ (piece) => isHole(piece) ? { type: "hole", label: piece.slice(1, -1) } : { type: "text", text: piece }
369
+ );
370
+ const only = parts.length === 1 ? parts[0] : void 0;
371
+ if (only !== void 0 && only.type === "hole") {
372
+ return { type: "reference", path: only.label.split(".") };
373
+ }
374
+ if (parts.some((part) => part.type === "hole")) {
375
+ return { type: "pattern", parts };
376
+ }
377
+ return { type: "literal", value: name };
378
+ }
379
+ function patternHole(label) {
380
+ return `{${label}}`;
381
+ }
382
+ function namesNothing(name) {
383
+ return parseBoundaryName(name).type === "reference";
384
+ }
385
+ function referenceOf(name) {
386
+ if (name.type !== "reference") {
387
+ return null;
388
+ }
389
+ const root = name.path[0];
390
+ if (root === void 0 || name.path.some((part) => part === "")) {
391
+ return null;
392
+ }
393
+ return { root, fields: name.path.slice(1) };
394
+ }
395
+ function referenceFromName(name) {
396
+ return referenceOf(parseBoundaryName(name));
397
+ }
398
+
358
399
  // src/urlPath.ts
359
400
  var SCHEME_ORIGIN = /^[a-zA-Z][a-zA-Z\d+.-]*:\/\/[^/]*/;
360
401
  var PROTOCOL_RELATIVE_ORIGIN = /^\/\/[^/]*/;
@@ -384,9 +425,9 @@ var RestSemanticsSchema = import_zod6.z.object({
384
425
  declaredResponses: import_zod6.z.array(import_zod6.z.number()).optional()
385
426
  });
386
427
  var OPENING_HOLE = /^\{([^{}]+)\}(.*)$/;
387
- function variableOf(label) {
388
- const parts = label.split(".");
389
- return parts[parts.length - 1] ?? label;
428
+ function baseUrlReference(semantics) {
429
+ const label = OPENING_HOLE.exec(semantics.path ?? "")?.[1];
430
+ return label === void 0 ? null : referenceFromName(patternHole(label));
390
431
  }
391
432
  function normalizePath(path) {
392
433
  let normalized = path.replace(/:([a-zA-Z_]\w*)/g, "{$1}");
@@ -497,6 +538,14 @@ var restSemantics = defineBoundarySemantics({
497
538
  }
498
539
  return routePathAdmits(semantics.path, path) ? "match" : "nomatch";
499
540
  },
541
+ /**
542
+ * A route the registration pattern admits is inside it. A route
543
+ * whose path this source never gave is left outside, because
544
+ * nothing here can show it is one the pattern covers.
545
+ */
546
+ withinScope(semantics, scope) {
547
+ return semantics.path !== null && routePathAdmits(scope, semantics.path);
548
+ },
500
549
  /**
501
550
  * A call whose base URL the deployment fills in, resolved to the
502
551
  * path it reaches.
@@ -512,22 +561,20 @@ var restSemantics = defineBoundarySemantics({
512
561
  * route parameter, and `/orders/{id}` means every id rather than a
513
562
  * variable somebody set.
514
563
  */
515
- groundName(semantics, deployedAs) {
516
- if (semantics.path === null) {
564
+ groundName(semantics, deployment) {
565
+ const reference = baseUrlReference(semantics);
566
+ if (reference === null) {
517
567
  return null;
518
568
  }
519
- const opening = OPENING_HOLE.exec(semantics.path);
520
- if (opening === null) {
521
- return null;
522
- }
523
- const [, label, rest] = opening;
524
- const base = deployedAs(variableOf(label));
569
+ const base = deployment.setTo(reference);
525
570
  if (base === null) {
526
571
  return null;
527
572
  }
573
+ const rest = OPENING_HOLE.exec(semantics.path ?? "")?.[2] ?? "";
528
574
  const grounded = pathAfterOrigin(`${base}${rest}`);
529
575
  return { ...semantics, path: grounded === "" ? "/" : grounded };
530
576
  },
577
+ nameReference: baseUrlReference,
531
578
  ruleBoundary: {
532
579
  // "METHOD /path": one leading token, then an absolute path.
533
580
  claims(raw) {
@@ -614,6 +661,9 @@ var StorageSemanticsSchema = import_zod9.z.object({
614
661
  */
615
662
  accessPath: import_zod9.z.string().nullable()
616
663
  });
664
+ function containerReference(semantics) {
665
+ return semantics.container === null ? null : referenceFromName(semantics.container);
666
+ }
617
667
  var storageSemantics = defineBoundarySemantics({
618
668
  name: "storage",
619
669
  schema: StorageSemanticsSchema,
@@ -629,12 +679,108 @@ var storageSemantics = defineBoundarySemantics({
629
679
  /** A query returns rows or items, not a status and a body. */
630
680
  exchangesHttpResponses: false,
631
681
  reportsUnpairedItself: false,
632
- identityKey: () => null
682
+ identityKey: () => null,
683
+ displayLabel: storageLabel,
684
+ /**
685
+ * A container the source states as a variable is whatever the
686
+ * deployment sets that variable to. `{SUBSCRIBERS_TABLE}` in the
687
+ * code and `prod-subscribers-v1` in the manifest are one table.
688
+ */
689
+ groundName(semantics, deployment) {
690
+ const reference = containerReference(semantics);
691
+ if (reference === null) {
692
+ return null;
693
+ }
694
+ const name = deployment.setTo(reference);
695
+ return name === null ? null : { ...semantics, container: name };
696
+ },
697
+ nameReference: containerReference
698
+ }
699
+ });
700
+ function storageLabel(semantics) {
701
+ return `${semantics.storageSystem}:${storageContainerLabel(semantics)}`;
702
+ }
703
+ function storageContainerLabel(semantics) {
704
+ const container = semantics.container ?? "<unnamed container>";
705
+ const addressed = semantics.accessPath === null ? container : `${container}#${semantics.accessPath}`;
706
+ return semantics.scope === "default" ? addressed : `${semantics.scope}/${addressed}`;
707
+ }
708
+
709
+ // src/semantics/unitInvocation.ts
710
+ var import_zod10 = require("zod");
711
+ var UnitInvocationSemanticsSchema = DeployableUnitSchema.extend({
712
+ name: import_zod10.z.literal("unit-invocation"),
713
+ instanceName: DeployableUnitSchema.shape.instanceName.nullable()
714
+ });
715
+ function calleeReference(semantics) {
716
+ return semantics.instanceName === null ? null : referenceFromName(semantics.instanceName);
717
+ }
718
+ var unitInvocationSemantics = defineBoundarySemantics({
719
+ name: "unit-invocation",
720
+ schema: UnitInvocationSemanticsSchema,
721
+ // faas.name is the deployed function's own name and instanceName is
722
+ // the deployment template's logical id, which is a different string.
723
+ // Runtime config leaves the pair off for the same reason.
724
+ semconv: {},
725
+ behavior: {
726
+ /**
727
+ * A synchronous invoke gives back whatever the handler returned,
728
+ * which is a value rather than a status and a body. A handler's
729
+ * return only becomes an HTTP response under a proxy integration,
730
+ * and that route gets a REST binding instead of this one.
731
+ */
732
+ exchangesHttpResponses: false,
733
+ /**
734
+ * A unit nothing in the run invokes is the ordinary case, since
735
+ * most services are reached from a stack suss never read. So an
736
+ * uninvoked unit stays in the generic unmatched list rather than
737
+ * being reported as a problem here.
738
+ */
739
+ reportsUnpairedItself: false,
740
+ /**
741
+ * A callee the source states only as a variable is not a name for
742
+ * anything until the deployment fills it in, so it keys as nothing
743
+ * rather than as a bucket that would agree with itself alone.
744
+ */
745
+ identityKey(semantics) {
746
+ if (semantics.instanceName === null || namesNothing(semantics.instanceName)) {
747
+ return null;
748
+ }
749
+ return unitIdentityKey(
750
+ semantics.deploymentTarget,
751
+ semantics.instanceName
752
+ );
753
+ },
754
+ displayLabel(semantics) {
755
+ if (semantics.instanceName === null) {
756
+ return `unit:${semantics.deploymentTarget} (named at runtime)`;
757
+ }
758
+ return unitIdentityKey(
759
+ semantics.deploymentTarget,
760
+ semantics.instanceName
761
+ );
762
+ },
763
+ /**
764
+ * A call that reads its callee's name out of the environment
765
+ * reaches whichever resource the template wires that variable to.
766
+ * The logical id is the answer rather than the deployed name,
767
+ * because the invoked unit's own summary is keyed by the logical
768
+ * id and neither side ever writes the other's string.
769
+ */
770
+ groundName(semantics, deployment) {
771
+ const reference = calleeReference(semantics);
772
+ if (reference === null) {
773
+ return null;
774
+ }
775
+ const logicalId = deployment.pointsAt(reference);
776
+ return logicalId === null ? null : { ...semantics, instanceName: logicalId };
777
+ },
778
+ nameReference: calleeReference
633
779
  }
634
780
  });
635
781
 
636
782
  // src/semantics/registry.ts
637
- var SemanticsSchema = import_zod10.z.discriminatedUnion("name", [
783
+ var SemanticsSchema = import_zod11.z.discriminatedUnion("name", [
638
784
  restSemantics.schema,
639
785
  functionCallSemantics.schema,
640
786
  graphqlResolverSemantics.schema,
@@ -642,7 +788,8 @@ var SemanticsSchema = import_zod10.z.discriminatedUnion("name", [
642
788
  runtimeConfigSemantics.schema,
643
789
  storageSemantics.schema,
644
790
  messageBusSemantics.schema,
645
- metricSemantics.schema
791
+ metricSemantics.schema,
792
+ unitInvocationSemantics.schema
646
793
  ]);
647
794
  var DEFINITIONS = [
648
795
  restSemantics,
@@ -652,38 +799,39 @@ var DEFINITIONS = [
652
799
  runtimeConfigSemantics,
653
800
  storageSemantics,
654
801
  messageBusSemantics,
655
- metricSemantics
802
+ metricSemantics,
803
+ unitInvocationSemantics
656
804
  ];
657
805
  var BY_NAME = new Map(
658
806
  DEFINITIONS.map((d) => [d.name, d])
659
807
  );
660
808
 
661
809
  // src/schemas.ts
662
- var ConfidenceSourceSchema = import_zod11.z.enum([
810
+ var ConfidenceSourceSchema = import_zod12.z.enum([
663
811
  "inferred_static",
664
812
  "inferred_ai",
665
813
  "declared",
666
814
  "derived"
667
815
  ]);
668
- var ConfidenceLevelSchema = import_zod11.z.enum(["high", "medium", "low"]);
669
- var CorroborationSchema = import_zod11.z.object({
670
- outcome: import_zod11.z.enum(["observed", "refuted", "untested"]),
816
+ var ConfidenceLevelSchema = import_zod12.z.enum(["high", "medium", "low"]);
817
+ var CorroborationSchema = import_zod12.z.object({
818
+ outcome: import_zod12.z.enum(["observed", "refuted", "untested"]),
671
819
  /** Executions that produced a verdict for this claim. */
672
- runs: import_zod11.z.number(),
820
+ runs: import_zod12.z.number(),
673
821
  /** Present when refuted: the input and observation that disagreed. */
674
- counterexample: import_zod11.z.unknown().optional(),
822
+ counterexample: import_zod12.z.unknown().optional(),
675
823
  /** Present when untested: why no verdict was reachable. */
676
- reason: import_zod11.z.string().optional()
824
+ reason: import_zod12.z.string().optional()
677
825
  });
678
- var ConfidenceInfoSchema = import_zod11.z.object({
826
+ var ConfidenceInfoSchema = import_zod12.z.object({
679
827
  source: ConfidenceSourceSchema,
680
828
  level: ConfidenceLevelSchema,
681
829
  corroboration: CorroborationSchema.optional()
682
830
  });
683
- var SourceLocationSchema = import_zod11.z.object({
684
- file: import_zod11.z.string(),
831
+ var SourceLocationSchema = import_zod12.z.object({
832
+ file: import_zod12.z.string(),
685
833
  /** Line numbers, for a person reading the summary or an editor link. */
686
- range: import_zod11.z.object({ start: import_zod11.z.number(), end: import_zod11.z.number() }),
834
+ range: import_zod12.z.object({ start: import_zod12.z.number(), end: import_zod12.z.number() }),
687
835
  /**
688
836
  * Character offsets of the unit in its file. Identity and joins
689
837
  * measure with these, since two functions can share a line and never
@@ -691,8 +839,8 @@ var SourceLocationSchema = import_zod11.z.object({
691
839
  * same place. Absent on summaries no source position backs, a
692
840
  * contract artifact's say.
693
841
  */
694
- span: import_zod11.z.object({ start: import_zod11.z.number(), end: import_zod11.z.number() }).optional(),
695
- exportName: import_zod11.z.string().nullable(),
842
+ span: import_zod12.z.object({ start: import_zod12.z.number(), end: import_zod12.z.number() }).optional(),
843
+ exportName: import_zod12.z.string().nullable(),
696
844
  /**
697
845
  * The project the extract was pointed at, by the name that project
698
846
  * calls itself.
@@ -702,47 +850,47 @@ var SourceLocationSchema = import_zod11.z.object({
702
850
  * summaries puts them on top of each other. This field is what tells
703
851
  * them apart, and what a reader groups by.
704
852
  */
705
- workspace: import_zod11.z.string().optional()
853
+ workspace: import_zod12.z.string().optional()
706
854
  });
707
- var BoundaryBindingSchema = import_zod11.z.object({
708
- transport: import_zod11.z.string(),
855
+ var BoundaryBindingSchema = import_zod12.z.object({
856
+ transport: import_zod12.z.string(),
709
857
  semantics: SemanticsSchema,
710
- recognition: import_zod11.z.string()
858
+ recognition: import_zod12.z.string()
711
859
  });
712
860
  function typeDefinitionKey(ref) {
713
861
  return ref.def ?? null;
714
862
  }
715
- var TypeShapeSchema = import_zod11.z.lazy(
716
- () => import_zod11.z.discriminatedUnion("type", [
717
- import_zod11.z.object({
718
- type: import_zod11.z.literal("record"),
719
- properties: import_zod11.z.record(import_zod11.z.string(), TypeShapeSchema),
720
- spreads: import_zod11.z.array(import_zod11.z.object({ sourceText: import_zod11.z.string() })).optional()
863
+ var TypeShapeSchema = import_zod12.z.lazy(
864
+ () => import_zod12.z.discriminatedUnion("type", [
865
+ import_zod12.z.object({
866
+ type: import_zod12.z.literal("record"),
867
+ properties: import_zod12.z.record(import_zod12.z.string(), TypeShapeSchema),
868
+ spreads: import_zod12.z.array(import_zod12.z.object({ sourceText: import_zod12.z.string() })).optional()
721
869
  }),
722
- import_zod11.z.object({ type: import_zod11.z.literal("dictionary"), values: TypeShapeSchema }),
723
- import_zod11.z.object({ type: import_zod11.z.literal("array"), items: TypeShapeSchema }),
724
- import_zod11.z.object({
725
- type: import_zod11.z.literal("literal"),
726
- value: import_zod11.z.union([import_zod11.z.string(), import_zod11.z.number(), import_zod11.z.boolean()]),
727
- raw: import_zod11.z.string().optional()
870
+ import_zod12.z.object({ type: import_zod12.z.literal("dictionary"), values: TypeShapeSchema }),
871
+ import_zod12.z.object({ type: import_zod12.z.literal("array"), items: TypeShapeSchema }),
872
+ import_zod12.z.object({
873
+ type: import_zod12.z.literal("literal"),
874
+ value: import_zod12.z.union([import_zod12.z.string(), import_zod12.z.number(), import_zod12.z.boolean()]),
875
+ raw: import_zod12.z.string().optional()
728
876
  }),
729
- import_zod11.z.object({ type: import_zod11.z.literal("text") }),
730
- import_zod11.z.object({ type: import_zod11.z.literal("integer") }),
731
- import_zod11.z.object({ type: import_zod11.z.literal("number") }),
732
- import_zod11.z.object({ type: import_zod11.z.literal("boolean") }),
733
- import_zod11.z.object({ type: import_zod11.z.literal("null") }),
734
- import_zod11.z.object({ type: import_zod11.z.literal("undefined") }),
735
- import_zod11.z.object({
736
- type: import_zod11.z.literal("union"),
737
- variants: import_zod11.z.array(TypeShapeSchema)
877
+ import_zod12.z.object({ type: import_zod12.z.literal("text") }),
878
+ import_zod12.z.object({ type: import_zod12.z.literal("integer") }),
879
+ import_zod12.z.object({ type: import_zod12.z.literal("number") }),
880
+ import_zod12.z.object({ type: import_zod12.z.literal("boolean") }),
881
+ import_zod12.z.object({ type: import_zod12.z.literal("null") }),
882
+ import_zod12.z.object({ type: import_zod12.z.literal("undefined") }),
883
+ import_zod12.z.object({
884
+ type: import_zod12.z.literal("union"),
885
+ variants: import_zod12.z.array(TypeShapeSchema)
738
886
  }),
739
- import_zod11.z.object({
740
- type: import_zod11.z.literal("ref"),
741
- name: import_zod11.z.string(),
742
- from: import_zod11.z.string().optional(),
743
- def: import_zod11.z.string().optional()
887
+ import_zod12.z.object({
888
+ type: import_zod12.z.literal("ref"),
889
+ name: import_zod12.z.string(),
890
+ from: import_zod12.z.string().optional(),
891
+ def: import_zod12.z.string().optional()
744
892
  }),
745
- import_zod11.z.object({ type: import_zod11.z.literal("unknown") })
893
+ import_zod12.z.object({ type: import_zod12.z.literal("unknown") })
746
894
  ])
747
895
  );
748
896
  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, x as typeDefinitionKey, y as withDefinitionsInlined } from './schemas-Dt93kAZT.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, z as typeDefinitionKey, A as withDefinitionsInlined } from './schemas-Dn1AzzWd.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, x as typeDefinitionKey, y as withDefinitionsInlined } from './schemas-Dt93kAZT.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, z as typeDefinitionKey, A as withDefinitionsInlined } from './schemas-Dn1AzzWd.js';
package/dist/schemas.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  TypeShapeSchema,
18
18
  typeDefinitionKey,
19
19
  withDefinitionsInlined
20
- } from "./chunk-52CH76PE.js";
20
+ } from "./chunk-PPQWK62O.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.20.0",
3
+ "version": "0.21.1",
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": [