@lucern/contracts 0.3.0-alpha.8 → 0.3.0-alpha.9

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.
@@ -1,2 +1,2 @@
1
1
  import 'zod';
2
- export { E as EdgePolicyEntry, a as EdgePolicyEntrySchema, b as EdgePolicyManifest, c as EdgePolicyManifestSchema, d as EdgePolicyViolation, h as assertEdgePolicyAllowed, i as findEdgePolicy } from '../edge-policy-manifest-Byv6cQPP.js';
2
+ export { E as EdgePolicyEntry, a as EdgePolicyEntrySchema, b as EdgePolicyManifest, c as EdgePolicyManifestSchema, d as EdgePolicyViolation, i as assertEdgePolicyAllowed, j as findEdgePolicy } from '../edge-policy-manifest-Dw5IhT1L.js';
@@ -1,27 +1,13 @@
1
1
  declare const edgePolicyManifest: {
2
2
  manifestVersion: "1.0.0";
3
- policies: ({
4
- edgeType: string;
5
- fromKinds: "epistemic_node"[];
6
- fromNodeTypes: "evidence"[];
7
- toKinds: "epistemic_node"[];
8
- toNodeTypes: "evidence"[];
9
- description: string;
10
- } | {
11
- edgeType: string;
12
- fromKinds: "epistemic_node"[];
13
- fromNodeTypes: "evidence"[];
14
- toKinds: "epistemic_node"[];
15
- toNodeTypes: "belief"[];
3
+ policies: {
16
4
  description: string;
17
- } | {
18
5
  edgeType: string;
19
- fromKinds: "epistemic_node"[];
20
- fromNodeTypes: "evidence"[];
21
- toKinds: "epistemic_node"[];
22
- toNodeTypes: "question"[];
23
- description: string;
24
- })[];
6
+ fromKinds: ("epistemic_node" | "external_belief")[];
7
+ toKinds: ("epistemic_node" | "external_belief")[];
8
+ fromNodeTypes?: ("function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain")[] | undefined;
9
+ toNodeTypes?: ("function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain")[] | undefined;
10
+ }[];
25
11
  };
26
12
 
27
13
  export { edgePolicyManifest };
@@ -1,32 +1,24 @@
1
+ import { z } from 'zod';
2
+
3
+ // src/schemas/enums.ts
4
+ z.enum(["decision", "belief", "question", "theme", "deal", "topic", "claim", "evidence", "synthesis", "answer", "atomic_fact", "excerpt", "source", "company", "person", "investor", "function", "value_chain"]);
5
+ var EDGE_TYPE_VALUES = ["supports", "informs", "depends_on", "derived_from", "contains", "tests", "supersedes", "responds_to", "belongs_to", "relates_to_thesis", "works_at", "invested_in", "competes_with", "participates_in", "founded_by", "evaluates", "performs", "function_in", "impacts", "raised_from", "mentioned_in", "perspective_on", "plays_theme", "answers", "explores", "qualifies", "based_on", "based_on_belief", "based_on_question", "blocked_by_contradiction", "informed_by_theme", "same_as", "reinforces", "parent_of", "child_of", "falsified_by", "exclusive_with", "collapses_if", "cascade_from", "counterfactual_of", "cascade_to", "mutually_exclusive", "correlates_with", "amplifies", "precondition_for", "in_tension_with", "strengthened_by", "weakened_by", "alternative_to", "subsumes", "validated_by", "required_for", "blocks", "prerequisite_for", "parallel_to", "corroborates", "extends", "same_source_as", "same_theme_as", "assumes", "would_predict", "analogous_to", "independent_of", "implements", "violates", "co_changes_with", "migrating_from", "migrating_to", "scoped_by", "about_entity", "entity_referenced_in", "contradicts", "cites", "summarizes", "related_to", "partially_answers", "refines", "branches_from"];
6
+ var STORAGE_EDGE_TYPE_VALUES = [...EDGE_TYPE_VALUES, "extracted_from"];
7
+ z.enum(EDGE_TYPE_VALUES);
8
+ z.enum(STORAGE_EDGE_TYPE_VALUES);
9
+ z.enum(["active", "archived", "watching"]);
10
+ z.enum(["private", "team", "firm", "external", "public"]);
11
+
1
12
  // src/manifests/edge-policy-manifest.data.ts
13
+ var publicEpistemicNodeEdgePolicy = (edgeType) => ({
14
+ edgeType,
15
+ fromKinds: ["epistemic_node"],
16
+ toKinds: ["epistemic_node"],
17
+ description: "Canonical public create_edge policy for graph-node relationships. The policy layer gates edge-type membership, not endpoint semantics."
18
+ });
2
19
  var edgePolicyManifest = {
3
20
  manifestVersion: "1.0.0",
4
- policies: [
5
- {
6
- edgeType: "evidence_derived_from_evidence",
7
- fromKinds: ["epistemic_node"],
8
- fromNodeTypes: ["evidence"],
9
- toKinds: ["epistemic_node"],
10
- toNodeTypes: ["evidence"],
11
- description: "Evidence E2 was synthesized from evidence E1 by a transformation. Provides chain-of-evidence lineage."
12
- },
13
- {
14
- edgeType: "evidence_supports_belief",
15
- fromKinds: ["epistemic_node"],
16
- fromNodeTypes: ["evidence"],
17
- toKinds: ["epistemic_node"],
18
- toNodeTypes: ["belief"],
19
- description: "Existing link_evidence_to_belief semantics promoted to the create_edge policy source."
20
- },
21
- {
22
- edgeType: "evidence_supports_question",
23
- fromKinds: ["epistemic_node"],
24
- fromNodeTypes: ["evidence"],
25
- toKinds: ["epistemic_node"],
26
- toNodeTypes: ["question"],
27
- description: "Existing link_evidence_to_question semantics promoted to the create_edge policy source."
28
- }
29
- ]
21
+ policies: EDGE_TYPE_VALUES.map(publicEpistemicNodeEdgePolicy)
30
22
  };
31
23
 
32
24
  export { edgePolicyManifest };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/manifests/edge-policy-manifest.data.ts"],"names":[],"mappings":";AAEO,IAAM,kBAAA,GAAqB;AAAA,EAChC,eAAA,EAAiB,OAAA;AAAA,EACjB,QAAA,EAAU;AAAA,IACR;AAAA,MACE,QAAA,EAAU,gCAAA;AAAA,MACV,SAAA,EAAW,CAAC,gBAAgB,CAAA;AAAA,MAC5B,aAAA,EAAe,CAAC,UAAU,CAAA;AAAA,MAC1B,OAAA,EAAS,CAAC,gBAAgB,CAAA;AAAA,MAC1B,WAAA,EAAa,CAAC,UAAU,CAAA;AAAA,MACxB,WAAA,EACE;AAAA,KACJ;AAAA,IACA;AAAA,MACE,QAAA,EAAU,0BAAA;AAAA,MACV,SAAA,EAAW,CAAC,gBAAgB,CAAA;AAAA,MAC5B,aAAA,EAAe,CAAC,UAAU,CAAA;AAAA,MAC1B,OAAA,EAAS,CAAC,gBAAgB,CAAA;AAAA,MAC1B,WAAA,EAAa,CAAC,QAAQ,CAAA;AAAA,MACtB,WAAA,EACE;AAAA,KACJ;AAAA,IACA;AAAA,MACE,QAAA,EAAU,4BAAA;AAAA,MACV,SAAA,EAAW,CAAC,gBAAgB,CAAA;AAAA,MAC5B,aAAA,EAAe,CAAC,UAAU,CAAA;AAAA,MAC1B,OAAA,EAAS,CAAC,gBAAgB,CAAA;AAAA,MAC1B,WAAA,EAAa,CAAC,UAAU,CAAA;AAAA,MACxB,WAAA,EACE;AAAA;AACJ;AAEJ","file":"edge-policy-manifest.data.js","sourcesContent":["import type { EdgePolicyManifest } from \"./edge-policy-manifest.js\";\n\nexport const edgePolicyManifest = {\n manifestVersion: \"1.0.0\",\n policies: [\n {\n edgeType: \"evidence_derived_from_evidence\",\n fromKinds: [\"epistemic_node\"],\n fromNodeTypes: [\"evidence\"],\n toKinds: [\"epistemic_node\"],\n toNodeTypes: [\"evidence\"],\n description:\n \"Evidence E2 was synthesized from evidence E1 by a transformation. Provides chain-of-evidence lineage.\",\n },\n {\n edgeType: \"evidence_supports_belief\",\n fromKinds: [\"epistemic_node\"],\n fromNodeTypes: [\"evidence\"],\n toKinds: [\"epistemic_node\"],\n toNodeTypes: [\"belief\"],\n description:\n \"Existing link_evidence_to_belief semantics promoted to the create_edge policy source.\",\n },\n {\n edgeType: \"evidence_supports_question\",\n fromKinds: [\"epistemic_node\"],\n fromNodeTypes: [\"evidence\"],\n toKinds: [\"epistemic_node\"],\n toNodeTypes: [\"question\"],\n description:\n \"Existing link_evidence_to_question semantics promoted to the create_edge policy source.\",\n },\n ],\n} satisfies EdgePolicyManifest;\n"]}
1
+ {"version":3,"sources":["../../src/schemas/enums.ts","../../src/manifests/edge-policy-manifest.data.ts"],"names":[],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AA;AAErD,CAAA,CAAE,IAAA,CAAK,gBAAgB;AAIf,CAAA,CAAE,IAAA,CAAK,wBAAwB;AAEpC,CAAA,CAAE,IAAA,CAAK,CAAC,QAAA,EAAU,UAAA,EAAY,UAAU,CAAC;AAErC,EAAE,IAAA,CAAK,CAAC,WAAW,MAAA,EAAQ,MAAA,EAAQ,UAAA,EAAY,QAAQ,CAAC;;;ACdxF,IAAM,6BAAA,GAAgC,CACpC,QAAA,MACqB;AAAA,EACrB,QAAA;AAAA,EACA,SAAA,EAAW,CAAC,gBAAgB,CAAA;AAAA,EAC5B,OAAA,EAAS,CAAC,gBAAgB,CAAA;AAAA,EAC1B,WAAA,EACE;AACJ,CAAA,CAAA;AAEO,IAAM,kBAAA,GAAqB;AAAA,EAChC,eAAA,EAAiB,OAAA;AAAA,EACjB,QAAA,EAAU,gBAAA,CAAiB,GAAA,CAAI,6BAA6B;AAC9D","file":"edge-policy-manifest.data.js","sourcesContent":["/**\n * Shared schema enums referenced by the initial table manifest.\n */\n\nimport { z } from 'zod';\n\nexport const NODE_TYPE = z.enum([\"decision\", \"belief\", \"question\", \"theme\", \"deal\", \"topic\", \"claim\", \"evidence\", \"synthesis\", \"answer\", \"atomic_fact\", \"excerpt\", \"source\", \"company\", \"person\", \"investor\", \"function\", \"value_chain\"]);\n\nexport const EDGE_TYPE_VALUES = [\"supports\", \"informs\", \"depends_on\", \"derived_from\", \"contains\", \"tests\", \"supersedes\", \"responds_to\", \"belongs_to\", \"relates_to_thesis\", \"works_at\", \"invested_in\", \"competes_with\", \"participates_in\", \"founded_by\", \"evaluates\", \"performs\", \"function_in\", \"impacts\", \"raised_from\", \"mentioned_in\", \"perspective_on\", \"plays_theme\", \"answers\", \"explores\", \"qualifies\", \"based_on\", \"based_on_belief\", \"based_on_question\", \"blocked_by_contradiction\", \"informed_by_theme\", \"same_as\", \"reinforces\", \"parent_of\", \"child_of\", \"falsified_by\", \"exclusive_with\", \"collapses_if\", \"cascade_from\", \"counterfactual_of\", \"cascade_to\", \"mutually_exclusive\", \"correlates_with\", \"amplifies\", \"precondition_for\", \"in_tension_with\", \"strengthened_by\", \"weakened_by\", \"alternative_to\", \"subsumes\", \"validated_by\", \"required_for\", \"blocks\", \"prerequisite_for\", \"parallel_to\", \"corroborates\", \"extends\", \"same_source_as\", \"same_theme_as\", \"assumes\", \"would_predict\", \"analogous_to\", \"independent_of\", \"implements\", \"violates\", \"co_changes_with\", \"migrating_from\", \"migrating_to\", \"scoped_by\", \"about_entity\", \"entity_referenced_in\", \"contradicts\", \"cites\", \"summarizes\", \"related_to\", \"partially_answers\", \"refines\", \"branches_from\"] as const;\n\nexport const STORAGE_EDGE_TYPE_VALUES = [...EDGE_TYPE_VALUES, \"extracted_from\"] as const;\n\nexport const EDGE_TYPE = z.enum(EDGE_TYPE_VALUES);\n\n// Storage accepts the legacy provenance spelling while existing rows migrate.\n// Public surfaces should continue to expose EDGE_TYPE only.\nexport const STORAGE_EDGE_TYPE = z.enum(STORAGE_EDGE_TYPE_VALUES);\n\nexport const TOPIC_STATUS = z.enum([\"active\", \"archived\", \"watching\"]);\n\nexport const TOPIC_VISIBILITY = z.enum([\"private\", \"team\", \"firm\", \"external\", \"public\"]);\n","import { EDGE_TYPE_VALUES } from \"../schemas/enums.js\";\nimport type {\n EdgePolicyEntry,\n EdgePolicyManifest,\n} from \"./edge-policy-manifest.js\";\n\nconst publicEpistemicNodeEdgePolicy = (\n edgeType: (typeof EDGE_TYPE_VALUES)[number]\n): EdgePolicyEntry => ({\n edgeType,\n fromKinds: [\"epistemic_node\"],\n toKinds: [\"epistemic_node\"],\n description:\n \"Canonical public create_edge policy for graph-node relationships. The policy layer gates edge-type membership, not endpoint semantics.\",\n});\n\nexport const edgePolicyManifest = {\n manifestVersion: \"1.0.0\",\n policies: EDGE_TYPE_VALUES.map(publicEpistemicNodeEdgePolicy),\n} satisfies EdgePolicyManifest;\n"]}
@@ -1,17 +1,44 @@
1
1
  import { z } from 'zod';
2
2
 
3
3
  // src/manifests/edge-policy-manifest.ts
4
- var EpistemicNodeTypeSchema = z.enum([
4
+
5
+ // src/schema-helpers/spine/tables/epistemicNodes.ts
6
+ var NODE_TYPES = [
7
+ "decision",
5
8
  "belief",
6
- "evidence",
7
9
  "question",
8
- "answer",
10
+ "theme",
11
+ "deal",
9
12
  "topic",
13
+ "claim",
14
+ "evidence",
15
+ "synthesis",
16
+ "answer",
17
+ "atomic_fact",
18
+ "excerpt",
19
+ "source",
20
+ "company",
21
+ "person",
22
+ "investor",
23
+ "function",
24
+ "value_chain"
25
+ ];
26
+ new Set(NODE_TYPES);
27
+
28
+ // src/types/graph-ref.ts
29
+ var GRAPH_REF_EXTRA_NODE_TYPES = [
10
30
  "edge",
11
31
  "ontology",
12
32
  "lens",
13
33
  "contradiction"
14
- ]);
34
+ ];
35
+ var GRAPH_REF_NODE_TYPES = [
36
+ ...NODE_TYPES,
37
+ ...GRAPH_REF_EXTRA_NODE_TYPES
38
+ ];
39
+ var EpistemicNodeTypeSchema = z.enum(
40
+ GRAPH_REF_NODE_TYPES
41
+ );
15
42
  z.discriminatedUnion("kind", [
16
43
  z.object({
17
44
  kind: z.literal("epistemic_node"),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/graph-ref.ts","../../src/manifests/edge-policy-manifest.ts"],"names":["z"],"mappings":";;;AAEO,IAAM,uBAAA,GAA0B,EAAE,IAAA,CAAK;AAAA,EAC5C,QAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAC,CAAA;AAQ6B,CAAA,CAAE,kBAAA,CAAmB,MAAA,EAAQ;AAAA,EACzD,EAAE,MAAA,CAAO;AAAA,IACP,IAAA,EAAM,CAAA,CAAE,OAAA,CAAQ,gBAAgB,CAAA;AAAA,IAChC,MAAA,EAAQ,EAAE,MAAA,EAAO;AAAA,IACjB,QAAA,EAAU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Q,CAAA;AAEjC;AAEO,SAAS,uBAAA,CACd,QAAA,EACA,QAAA,EACA,IAAA,EACA,EAAA,EACM;AACN,EAAA,MAAM,MAAA,GAAS,cAAA,CAAe,QAAA,EAAU,QAAQ,CAAA;AAChD,EAAA,MAAM,OAAA,GACJ,OAAA,CAAQ,MAAM,CAAA,IACd,MAAA,CAAQ,UAAU,QAAA,CAAS,IAAA,CAAK,IAAI,CAAA,IACpC,MAAA,CAAQ,OAAA,CAAQ,SAAS,EAAA,CAAG,IAAI,CAAA,IAChC,eAAA,CAAgB,MAAA,CAAQ,aAAA,EAAe,IAAI,CAAA,IAC3C,eAAA,CAAgB,MAAA,CAAQ,WAAA,EAAa,EAAE,CAAA;AAEzC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,QAAQ,IAAI,KAAA;AAAA,MAChB,6BAA6B,QAAQ,CAAA,EAAA,EAAK,KAAK,IAAI,CAAA,IAAA,EAAO,GAAG,IAAI,CAAA;AAAA,KACnE;AACA,IAAA,KAAA,CAAM,IAAA,GAAO,kBAAA;AACb,IAAA,KAAA,CAAM,UAAU,EAAE,IAAA,EAAM,kBAAA,EAAoB,QAAA,EAAU,MAAM,EAAA,EAAG;AAC/D,IAAA,MAAM,KAAA;AAAA,EACR;AACF","file":"edge-policy-manifest.js","sourcesContent":["import { z } from \"zod\";\n\nexport const EpistemicNodeTypeSchema = z.enum([\n \"belief\",\n \"evidence\",\n \"question\",\n \"answer\",\n \"topic\",\n \"edge\",\n \"ontology\",\n \"lens\",\n \"contradiction\",\n]);\n\nexport type EpistemicNodeType = z.infer<typeof EpistemicNodeTypeSchema>;\n\nexport type GraphRef =\n | { kind: \"epistemic_node\"; nodeId: string; nodeType: EpistemicNodeType }\n | { kind: \"external_belief\"; ref: { tenantId: string; beliefId: string } };\n\nexport const GraphRefSchema = z.discriminatedUnion(\"kind\", [\n z.object({\n kind: z.literal(\"epistemic_node\"),\n nodeId: z.string(),\n nodeType: EpistemicNodeTypeSchema,\n }),\n z.object({\n kind: z.literal(\"external_belief\"),\n ref: z.object({\n tenantId: z.string(),\n beliefId: z.string(),\n }),\n }),\n]);\n","import { z } from \"zod\";\nimport {\n EpistemicNodeTypeSchema,\n type EpistemicNodeType,\n type GraphRef,\n} from \"../types/graph-ref.js\";\n\nconst graphRefKind = z.enum([\"epistemic_node\", \"external_belief\"]);\n\nexport const EdgePolicyEntrySchema = z.object({\n edgeType: z.string(),\n fromKinds: z.array(graphRefKind),\n fromNodeTypes: z.array(EpistemicNodeTypeSchema).optional(),\n toKinds: z.array(graphRefKind),\n toNodeTypes: z.array(EpistemicNodeTypeSchema).optional(),\n description: z.string(),\n});\n\nexport const EdgePolicyManifestSchema = z.object({\n manifestVersion: z.literal(\"1.0.0\"),\n policies: z.array(EdgePolicyEntrySchema),\n});\n\nexport type EdgePolicyEntry = z.infer<typeof EdgePolicyEntrySchema>;\nexport type EdgePolicyManifest = z.infer<typeof EdgePolicyManifestSchema>;\n\nexport type EdgePolicyViolation = {\n code: \"POLICY_VIOLATION\";\n edgeType: string;\n from: GraphRef;\n to: GraphRef;\n};\n\nexport function findEdgePolicy(\n manifest: EdgePolicyManifest,\n edgeType: string\n): EdgePolicyEntry | undefined {\n return manifest.policies.find((policy) => policy.edgeType === edgeType);\n}\n\nfunction nodeTypeAllowed(\n allowed: EpistemicNodeType[] | undefined,\n ref: GraphRef\n): boolean {\n return (\n ref.kind !== \"epistemic_node\" ||\n !allowed ||\n allowed.includes(ref.nodeType)\n );\n}\n\nexport function assertEdgePolicyAllowed(\n manifest: EdgePolicyManifest,\n edgeType: string,\n from: GraphRef,\n to: GraphRef\n): void {\n const policy = findEdgePolicy(manifest, edgeType);\n const allowed =\n Boolean(policy) &&\n policy!.fromKinds.includes(from.kind) &&\n policy!.toKinds.includes(to.kind) &&\n nodeTypeAllowed(policy!.fromNodeTypes, from) &&\n nodeTypeAllowed(policy!.toNodeTypes, to);\n\n if (!allowed) {\n const error = new Error(\n `Edge policy violation for ${edgeType}: ${from.kind} -> ${to.kind}`\n ) as Error & { code: \"POLICY_VIOLATION\"; details: EdgePolicyViolation };\n error.code = \"POLICY_VIOLATION\";\n error.details = { code: \"POLICY_VIOLATION\", edgeType, from, to };\n throw error;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/schema-helpers/spine/tables/epistemicNodes.ts","../../src/types/graph-ref.ts","../../src/manifests/edge-policy-manifest.ts"],"names":["z"],"mappings":";;;;;AA4BO,IAAM,UAAA,GAAa;AAAA,EACxB,UAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EACA,WAAA;AAAA,EACA,QAAA;AAAA,EACA,aAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA;AAEsB,IAAI,GAAA,CAAY,UAAU;;;AC9ChD,IAAM,0BAAA,GAA6B;AAAA,EACjC,MAAA;AAAA,EACA,UAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAA;AAEO,IAAM,oBAAA,GAAuB;AAAA,EAClC,GAAG,UAAA;AAAA,EACH,GAAG;AACL,CAAA;AAIO,IAAM,0BAA0B,CAAA,CAAE,IAAA;AAAA,EACvC;AACF,CAAA;AAQ8B,CAAA,CAAE,kBAAA,CAAmB,MAAA,EAAQ;AAAA,EACzD,EAAE,MAAA,CAAO;AAAA,IACP,IAAA,EAAM,CAAA,CAAE,OAAA,CAAQ,gBAAgB,CAAA;AAAA,IAChC,MAAA,EAAQ,EAAE,MAAA,EAAO;AAAA,IACjB,QAAA,EAAU;AAAA,GACX,CAAA;AAAA,EACD,EAAE,MAAA,CAAO;AAAA,IACP,IAAA,EAAM,CAAA,CAAE,OAAA,CAAQ,iBAAiB,CAAA;AAAA,IACjC,GAAA,EAAK,EAAE,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AQ,CAAA;AAChD,EAAA,MAAM,OAAA,GACJ,OAAA,CAAQ,MAAM,CAAA,IACd,MAAA,CAAQ,UAAU,QAAA,CAAS,IAAA,CAAK,IAAI,CAAA,IACpC,MAAA,CAAQ,OAAA,CAAQ,SAAS,EAAA,CAAG,IAAI,CAAA,IAChC,eAAA,CAAgB,MAAA,CAAQ,aAAA,EAAe,IAAI,CAAA,IAC3C,eAAA,CAAgB,MAAA,CAAQ,WAAA,EAAa,EAAE,CAAA;AAEzC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,QAAQ,IAAI,KAAA;AAAA,MAChB,6BAA6B,QAAQ,CAAA,EAAA,EAAK,KAAK,IAAI,CAAA,IAAA,EAAO,GAAG,IAAI,CAAA;AAAA,KACnE;AACA,IAAA,KAAA,CAAM,IAAA,GAAO,kBAAA;AACb,IAAA,KAAA,CAAM,UAAU,EAAE,IAAA,EAAM,kBAAA,EAAoB,QAAA,EAAU,MAAM,EAAA,EAAG;AAC/D,IAAA,MAAM,KAAA;AAAA,EACR;AACF","file":"edge-policy-manifest.js","sourcesContent":["export type NodeType =\n | \"decision\"\n | \"belief\"\n | \"question\"\n | \"theme\"\n | \"deal\"\n | \"topic\"\n | \"claim\"\n | \"evidence\"\n | \"synthesis\"\n | \"answer\"\n | \"atomic_fact\"\n | \"excerpt\"\n | \"source\"\n | \"company\"\n | \"person\"\n | \"investor\"\n | \"function\"\n | \"value_chain\";\n\nexport type EpistemicLayer =\n | \"L4\"\n | \"L3\"\n | \"L2\"\n | \"L1\"\n | \"ontological\"\n | \"organizational\";\n\nexport const NODE_TYPES = [\n \"decision\",\n \"belief\",\n \"question\",\n \"theme\",\n \"deal\",\n \"topic\",\n \"claim\",\n \"evidence\",\n \"synthesis\",\n \"answer\",\n \"atomic_fact\",\n \"excerpt\",\n \"source\",\n \"company\",\n \"person\",\n \"investor\",\n \"function\",\n \"value_chain\",\n] as const satisfies readonly NodeType[];\n\nconst NODE_TYPE_SET = new Set<string>(NODE_TYPES);\nconst NODE_TYPE_TO_LAYER = new Map<NodeType, EpistemicLayer>([\n [\"decision\", \"L4\"],\n [\"belief\", \"L3\"],\n [\"question\", \"L3\"],\n [\"theme\", \"L3\"],\n [\"deal\", \"L3\"],\n [\"claim\", \"L2\"],\n [\"evidence\", \"L2\"],\n [\"synthesis\", \"L2\"],\n [\"answer\", \"L2\"],\n [\"atomic_fact\", \"L1\"],\n [\"excerpt\", \"L1\"],\n [\"source\", \"L1\"],\n [\"topic\", \"organizational\"],\n [\"company\", \"ontological\"],\n [\"person\", \"ontological\"],\n [\"investor\", \"ontological\"],\n [\"function\", \"ontological\"],\n [\"value_chain\", \"ontological\"],\n]);\n\n// Backward compatibility type guard: callers depend on the exported predicate.\nexport function isNodeType(value: string): value is NodeType {\n return NODE_TYPE_SET.has(value);\n}\n\nexport function getLayerForNodeType(type: NodeType): EpistemicLayer {\n const layer = NODE_TYPE_TO_LAYER.get(type);\n if (!layer) {\n throw new Error(`Unknown node type: ${type}`);\n }\n return layer;\n}\n\nexport function resolveKnownLayerForNodeType(\n type: string\n): EpistemicLayer | undefined {\n return isNodeType(type) ? NODE_TYPE_TO_LAYER.get(type) : undefined;\n}\n\nexport function isEpistemicNodeType(type: NodeType): boolean {\n return getLayerForNodeType(type) !== \"ontological\";\n}\n","import { z } from \"zod\";\nimport { NODE_TYPES } from \"../schema-helpers/spine/tables/epistemicNodes.js\";\n\nconst GRAPH_REF_EXTRA_NODE_TYPES = [\n \"edge\",\n \"ontology\",\n \"lens\",\n \"contradiction\",\n] as const;\n\nexport const GRAPH_REF_NODE_TYPES = [\n ...NODE_TYPES,\n ...GRAPH_REF_EXTRA_NODE_TYPES,\n] as const;\n\ntype GraphRefNodeType = (typeof GRAPH_REF_NODE_TYPES)[number];\n\nexport const EpistemicNodeTypeSchema = z.enum(\n GRAPH_REF_NODE_TYPES as unknown as [GraphRefNodeType, ...GraphRefNodeType[]]\n);\n\nexport type EpistemicNodeType = z.infer<typeof EpistemicNodeTypeSchema>;\n\nexport type GraphRef =\n | { kind: \"epistemic_node\"; nodeId: string; nodeType: EpistemicNodeType }\n | { kind: \"external_belief\"; ref: { tenantId: string; beliefId: string } };\n\nexport const GraphRefSchema = z.discriminatedUnion(\"kind\", [\n z.object({\n kind: z.literal(\"epistemic_node\"),\n nodeId: z.string(),\n nodeType: EpistemicNodeTypeSchema,\n }),\n z.object({\n kind: z.literal(\"external_belief\"),\n ref: z.object({\n tenantId: z.string(),\n beliefId: z.string(),\n }),\n }),\n]);\n","import { z } from \"zod\";\nimport {\n EpistemicNodeTypeSchema,\n type EpistemicNodeType,\n type GraphRef,\n} from \"../types/graph-ref.js\";\n\nconst graphRefKind = z.enum([\"epistemic_node\", \"external_belief\"]);\n\nexport const EdgePolicyEntrySchema = z.object({\n edgeType: z.string(),\n fromKinds: z.array(graphRefKind),\n fromNodeTypes: z.array(EpistemicNodeTypeSchema).optional(),\n toKinds: z.array(graphRefKind),\n toNodeTypes: z.array(EpistemicNodeTypeSchema).optional(),\n description: z.string(),\n});\n\nexport const EdgePolicyManifestSchema = z.object({\n manifestVersion: z.literal(\"1.0.0\"),\n policies: z.array(EdgePolicyEntrySchema),\n});\n\nexport type EdgePolicyEntry = z.infer<typeof EdgePolicyEntrySchema>;\nexport type EdgePolicyManifest = z.infer<typeof EdgePolicyManifestSchema>;\n\nexport type EdgePolicyViolation = {\n code: \"POLICY_VIOLATION\";\n edgeType: string;\n from: GraphRef;\n to: GraphRef;\n};\n\nexport function findEdgePolicy(\n manifest: EdgePolicyManifest,\n edgeType: string\n): EdgePolicyEntry | undefined {\n return manifest.policies.find((policy) => policy.edgeType === edgeType);\n}\n\nfunction nodeTypeAllowed(\n allowed: EpistemicNodeType[] | undefined,\n ref: GraphRef\n): boolean {\n return (\n ref.kind !== \"epistemic_node\" ||\n !allowed ||\n allowed.includes(ref.nodeType)\n );\n}\n\nexport function assertEdgePolicyAllowed(\n manifest: EdgePolicyManifest,\n edgeType: string,\n from: GraphRef,\n to: GraphRef\n): void {\n const policy = findEdgePolicy(manifest, edgeType);\n const allowed =\n Boolean(policy) &&\n policy!.fromKinds.includes(from.kind) &&\n policy!.toKinds.includes(to.kind) &&\n nodeTypeAllowed(policy!.fromNodeTypes, from) &&\n nodeTypeAllowed(policy!.toNodeTypes, to);\n\n if (!allowed) {\n const error = new Error(\n `Edge policy violation for ${edgeType}: ${from.kind} -> ${to.kind}`\n ) as Error & { code: \"POLICY_VIOLATION\"; details: EdgePolicyViolation };\n error.code = \"POLICY_VIOLATION\";\n error.details = { code: \"POLICY_VIOLATION\", edgeType, from, to };\n throw error;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucern/contracts",
3
- "version": "0.3.0-alpha.8",
3
+ "version": "0.3.0-alpha.9",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,132 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- declare const EpistemicNodeTypeSchema: z.ZodEnum<["belief", "evidence", "question", "answer", "topic", "edge", "ontology", "lens", "contradiction"]>;
4
- type EpistemicNodeType = z.infer<typeof EpistemicNodeTypeSchema>;
5
- type GraphRef = {
6
- kind: "epistemic_node";
7
- nodeId: string;
8
- nodeType: EpistemicNodeType;
9
- } | {
10
- kind: "external_belief";
11
- ref: {
12
- tenantId: string;
13
- beliefId: string;
14
- };
15
- };
16
- declare const GraphRefSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
17
- kind: z.ZodLiteral<"epistemic_node">;
18
- nodeId: z.ZodString;
19
- nodeType: z.ZodEnum<["belief", "evidence", "question", "answer", "topic", "edge", "ontology", "lens", "contradiction"]>;
20
- }, "strip", z.ZodTypeAny, {
21
- kind: "epistemic_node";
22
- nodeId: string;
23
- nodeType: "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer";
24
- }, {
25
- kind: "epistemic_node";
26
- nodeId: string;
27
- nodeType: "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer";
28
- }>, z.ZodObject<{
29
- kind: z.ZodLiteral<"external_belief">;
30
- ref: z.ZodObject<{
31
- tenantId: z.ZodString;
32
- beliefId: z.ZodString;
33
- }, "strip", z.ZodTypeAny, {
34
- tenantId: string;
35
- beliefId: string;
36
- }, {
37
- tenantId: string;
38
- beliefId: string;
39
- }>;
40
- }, "strip", z.ZodTypeAny, {
41
- kind: "external_belief";
42
- ref: {
43
- tenantId: string;
44
- beliefId: string;
45
- };
46
- }, {
47
- kind: "external_belief";
48
- ref: {
49
- tenantId: string;
50
- beliefId: string;
51
- };
52
- }>]>;
53
-
54
- declare const EdgePolicyEntrySchema: z.ZodObject<{
55
- edgeType: z.ZodString;
56
- fromKinds: z.ZodArray<z.ZodEnum<["epistemic_node", "external_belief"]>, "many">;
57
- fromNodeTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["belief", "evidence", "question", "answer", "topic", "edge", "ontology", "lens", "contradiction"]>, "many">>;
58
- toKinds: z.ZodArray<z.ZodEnum<["epistemic_node", "external_belief"]>, "many">;
59
- toNodeTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["belief", "evidence", "question", "answer", "topic", "edge", "ontology", "lens", "contradiction"]>, "many">>;
60
- description: z.ZodString;
61
- }, "strip", z.ZodTypeAny, {
62
- description: string;
63
- edgeType: string;
64
- fromKinds: ("epistemic_node" | "external_belief")[];
65
- toKinds: ("epistemic_node" | "external_belief")[];
66
- fromNodeTypes?: ("belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer")[] | undefined;
67
- toNodeTypes?: ("belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer")[] | undefined;
68
- }, {
69
- description: string;
70
- edgeType: string;
71
- fromKinds: ("epistemic_node" | "external_belief")[];
72
- toKinds: ("epistemic_node" | "external_belief")[];
73
- fromNodeTypes?: ("belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer")[] | undefined;
74
- toNodeTypes?: ("belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer")[] | undefined;
75
- }>;
76
- declare const EdgePolicyManifestSchema: z.ZodObject<{
77
- manifestVersion: z.ZodLiteral<"1.0.0">;
78
- policies: z.ZodArray<z.ZodObject<{
79
- edgeType: z.ZodString;
80
- fromKinds: z.ZodArray<z.ZodEnum<["epistemic_node", "external_belief"]>, "many">;
81
- fromNodeTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["belief", "evidence", "question", "answer", "topic", "edge", "ontology", "lens", "contradiction"]>, "many">>;
82
- toKinds: z.ZodArray<z.ZodEnum<["epistemic_node", "external_belief"]>, "many">;
83
- toNodeTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["belief", "evidence", "question", "answer", "topic", "edge", "ontology", "lens", "contradiction"]>, "many">>;
84
- description: z.ZodString;
85
- }, "strip", z.ZodTypeAny, {
86
- description: string;
87
- edgeType: string;
88
- fromKinds: ("epistemic_node" | "external_belief")[];
89
- toKinds: ("epistemic_node" | "external_belief")[];
90
- fromNodeTypes?: ("belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer")[] | undefined;
91
- toNodeTypes?: ("belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer")[] | undefined;
92
- }, {
93
- description: string;
94
- edgeType: string;
95
- fromKinds: ("epistemic_node" | "external_belief")[];
96
- toKinds: ("epistemic_node" | "external_belief")[];
97
- fromNodeTypes?: ("belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer")[] | undefined;
98
- toNodeTypes?: ("belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer")[] | undefined;
99
- }>, "many">;
100
- }, "strip", z.ZodTypeAny, {
101
- policies: {
102
- description: string;
103
- edgeType: string;
104
- fromKinds: ("epistemic_node" | "external_belief")[];
105
- toKinds: ("epistemic_node" | "external_belief")[];
106
- fromNodeTypes?: ("belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer")[] | undefined;
107
- toNodeTypes?: ("belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer")[] | undefined;
108
- }[];
109
- manifestVersion: "1.0.0";
110
- }, {
111
- policies: {
112
- description: string;
113
- edgeType: string;
114
- fromKinds: ("epistemic_node" | "external_belief")[];
115
- toKinds: ("epistemic_node" | "external_belief")[];
116
- fromNodeTypes?: ("belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer")[] | undefined;
117
- toNodeTypes?: ("belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "lens" | "answer")[] | undefined;
118
- }[];
119
- manifestVersion: "1.0.0";
120
- }>;
121
- type EdgePolicyEntry = z.infer<typeof EdgePolicyEntrySchema>;
122
- type EdgePolicyManifest = z.infer<typeof EdgePolicyManifestSchema>;
123
- type EdgePolicyViolation = {
124
- code: "POLICY_VIOLATION";
125
- edgeType: string;
126
- from: GraphRef;
127
- to: GraphRef;
128
- };
129
- declare function findEdgePolicy(manifest: EdgePolicyManifest, edgeType: string): EdgePolicyEntry | undefined;
130
- declare function assertEdgePolicyAllowed(manifest: EdgePolicyManifest, edgeType: string, from: GraphRef, to: GraphRef): void;
131
-
132
- export { type EdgePolicyEntry as E, type GraphRef as G, EdgePolicyEntrySchema as a, type EdgePolicyManifest as b, EdgePolicyManifestSchema as c, type EdgePolicyViolation as d, type EpistemicNodeType as e, EpistemicNodeTypeSchema as f, GraphRefSchema as g, assertEdgePolicyAllowed as h, findEdgePolicy as i };