@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.
@@ -0,0 +1,133 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const GRAPH_REF_NODE_TYPES: readonly ["decision", "belief", "question", "theme", "deal", "topic", "claim", "evidence", "synthesis", "answer", "atomic_fact", "excerpt", "source", "company", "person", "investor", "function", "value_chain", "edge", "ontology", "lens", "contradiction"];
4
+ declare const EpistemicNodeTypeSchema: z.ZodEnum<["function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain", ...("function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain")[]]>;
5
+ type EpistemicNodeType = z.infer<typeof EpistemicNodeTypeSchema>;
6
+ type GraphRef = {
7
+ kind: "epistemic_node";
8
+ nodeId: string;
9
+ nodeType: EpistemicNodeType;
10
+ } | {
11
+ kind: "external_belief";
12
+ ref: {
13
+ tenantId: string;
14
+ beliefId: string;
15
+ };
16
+ };
17
+ declare const GraphRefSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
18
+ kind: z.ZodLiteral<"epistemic_node">;
19
+ nodeId: z.ZodString;
20
+ nodeType: z.ZodEnum<["function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain", ...("function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain")[]]>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ kind: "epistemic_node";
23
+ nodeId: string;
24
+ nodeType: "function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain";
25
+ }, {
26
+ kind: "epistemic_node";
27
+ nodeId: string;
28
+ nodeType: "function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain";
29
+ }>, z.ZodObject<{
30
+ kind: z.ZodLiteral<"external_belief">;
31
+ ref: z.ZodObject<{
32
+ tenantId: z.ZodString;
33
+ beliefId: z.ZodString;
34
+ }, "strip", z.ZodTypeAny, {
35
+ tenantId: string;
36
+ beliefId: string;
37
+ }, {
38
+ tenantId: string;
39
+ beliefId: string;
40
+ }>;
41
+ }, "strip", z.ZodTypeAny, {
42
+ kind: "external_belief";
43
+ ref: {
44
+ tenantId: string;
45
+ beliefId: string;
46
+ };
47
+ }, {
48
+ kind: "external_belief";
49
+ ref: {
50
+ tenantId: string;
51
+ beliefId: string;
52
+ };
53
+ }>]>;
54
+
55
+ declare const EdgePolicyEntrySchema: z.ZodObject<{
56
+ edgeType: z.ZodString;
57
+ fromKinds: z.ZodArray<z.ZodEnum<["epistemic_node", "external_belief"]>, "many">;
58
+ fromNodeTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain", ...("function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain")[]]>, "many">>;
59
+ toKinds: z.ZodArray<z.ZodEnum<["epistemic_node", "external_belief"]>, "many">;
60
+ toNodeTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain", ...("function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain")[]]>, "many">>;
61
+ description: z.ZodString;
62
+ }, "strip", z.ZodTypeAny, {
63
+ description: string;
64
+ edgeType: string;
65
+ fromKinds: ("epistemic_node" | "external_belief")[];
66
+ toKinds: ("epistemic_node" | "external_belief")[];
67
+ 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;
68
+ 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;
69
+ }, {
70
+ description: string;
71
+ edgeType: string;
72
+ fromKinds: ("epistemic_node" | "external_belief")[];
73
+ toKinds: ("epistemic_node" | "external_belief")[];
74
+ 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;
75
+ 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;
76
+ }>;
77
+ declare const EdgePolicyManifestSchema: z.ZodObject<{
78
+ manifestVersion: z.ZodLiteral<"1.0.0">;
79
+ policies: z.ZodArray<z.ZodObject<{
80
+ edgeType: z.ZodString;
81
+ fromKinds: z.ZodArray<z.ZodEnum<["epistemic_node", "external_belief"]>, "many">;
82
+ fromNodeTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain", ...("function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain")[]]>, "many">>;
83
+ toKinds: z.ZodArray<z.ZodEnum<["epistemic_node", "external_belief"]>, "many">;
84
+ toNodeTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain", ...("function" | "belief" | "evidence" | "question" | "edge" | "contradiction" | "topic" | "ontology" | "source" | "lens" | "decision" | "claim" | "answer" | "theme" | "deal" | "synthesis" | "atomic_fact" | "excerpt" | "company" | "person" | "investor" | "value_chain")[]]>, "many">>;
85
+ description: z.ZodString;
86
+ }, "strip", z.ZodTypeAny, {
87
+ description: string;
88
+ edgeType: string;
89
+ fromKinds: ("epistemic_node" | "external_belief")[];
90
+ toKinds: ("epistemic_node" | "external_belief")[];
91
+ 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;
92
+ 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;
93
+ }, {
94
+ description: string;
95
+ edgeType: string;
96
+ fromKinds: ("epistemic_node" | "external_belief")[];
97
+ toKinds: ("epistemic_node" | "external_belief")[];
98
+ 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;
99
+ 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;
100
+ }>, "many">;
101
+ }, "strip", z.ZodTypeAny, {
102
+ policies: {
103
+ description: string;
104
+ edgeType: string;
105
+ fromKinds: ("epistemic_node" | "external_belief")[];
106
+ toKinds: ("epistemic_node" | "external_belief")[];
107
+ 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;
108
+ 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;
109
+ }[];
110
+ manifestVersion: "1.0.0";
111
+ }, {
112
+ policies: {
113
+ description: string;
114
+ edgeType: string;
115
+ fromKinds: ("epistemic_node" | "external_belief")[];
116
+ toKinds: ("epistemic_node" | "external_belief")[];
117
+ 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;
118
+ 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;
119
+ }[];
120
+ manifestVersion: "1.0.0";
121
+ }>;
122
+ type EdgePolicyEntry = z.infer<typeof EdgePolicyEntrySchema>;
123
+ type EdgePolicyManifest = z.infer<typeof EdgePolicyManifestSchema>;
124
+ type EdgePolicyViolation = {
125
+ code: "POLICY_VIOLATION";
126
+ edgeType: string;
127
+ from: GraphRef;
128
+ to: GraphRef;
129
+ };
130
+ declare function findEdgePolicy(manifest: EdgePolicyManifest, edgeType: string): EdgePolicyEntry | undefined;
131
+ declare function assertEdgePolicyAllowed(manifest: EdgePolicyManifest, edgeType: string, from: GraphRef, to: GraphRef): void;
132
+
133
+ export { type EdgePolicyEntry as E, GRAPH_REF_NODE_TYPES as G, EdgePolicyEntrySchema as a, type EdgePolicyManifest as b, EdgePolicyManifestSchema as c, type EdgePolicyViolation as d, type EpistemicNodeType as e, EpistemicNodeTypeSchema as f, type GraphRef as g, GraphRefSchema as h, assertEdgePolicyAllowed as i, findEdgePolicy as j };
@@ -4531,17 +4531,44 @@ function surfaceContract(args) {
4531
4531
  }
4532
4532
  });
4533
4533
  }
4534
- var EpistemicNodeTypeSchema = z.enum([
4534
+
4535
+ // src/schema-helpers/spine/tables/epistemicNodes.ts
4536
+ var NODE_TYPES = [
4537
+ "decision",
4535
4538
  "belief",
4536
- "evidence",
4537
4539
  "question",
4538
- "answer",
4540
+ "theme",
4541
+ "deal",
4539
4542
  "topic",
4543
+ "claim",
4544
+ "evidence",
4545
+ "synthesis",
4546
+ "answer",
4547
+ "atomic_fact",
4548
+ "excerpt",
4549
+ "source",
4550
+ "company",
4551
+ "person",
4552
+ "investor",
4553
+ "function",
4554
+ "value_chain"
4555
+ ];
4556
+ new Set(NODE_TYPES);
4557
+
4558
+ // src/types/graph-ref.ts
4559
+ var GRAPH_REF_EXTRA_NODE_TYPES = [
4540
4560
  "edge",
4541
4561
  "ontology",
4542
4562
  "lens",
4543
4563
  "contradiction"
4544
- ]);
4564
+ ];
4565
+ var GRAPH_REF_NODE_TYPES = [
4566
+ ...NODE_TYPES,
4567
+ ...GRAPH_REF_EXTRA_NODE_TYPES
4568
+ ];
4569
+ var EpistemicNodeTypeSchema = z.enum(
4570
+ GRAPH_REF_NODE_TYPES
4571
+ );
4545
4572
  var GraphRefSchema = z.discriminatedUnion("kind", [
4546
4573
  z.object({
4547
4574
  kind: z.literal("epistemic_node"),
@@ -4589,42 +4616,33 @@ function assertEdgePolicyAllowed(manifest, edgeType, from, to) {
4589
4616
  throw error;
4590
4617
  }
4591
4618
  }
4619
+ z.enum(["decision", "belief", "question", "theme", "deal", "topic", "claim", "evidence", "synthesis", "answer", "atomic_fact", "excerpt", "source", "company", "person", "investor", "function", "value_chain"]);
4620
+ 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"];
4621
+ var STORAGE_EDGE_TYPE_VALUES = [...EDGE_TYPE_VALUES, "extracted_from"];
4622
+ z.enum(EDGE_TYPE_VALUES);
4623
+ z.enum(STORAGE_EDGE_TYPE_VALUES);
4624
+ z.enum(["active", "archived", "watching"]);
4625
+ z.enum(["private", "team", "firm", "external", "public"]);
4592
4626
 
4593
4627
  // src/manifests/edge-policy-manifest.data.ts
4628
+ var publicEpistemicNodeEdgePolicy = (edgeType) => ({
4629
+ edgeType,
4630
+ fromKinds: ["epistemic_node"],
4631
+ toKinds: ["epistemic_node"],
4632
+ description: "Canonical public create_edge policy for graph-node relationships. The policy layer gates edge-type membership, not endpoint semantics."
4633
+ });
4594
4634
  var edgePolicyManifest = {
4595
- policies: [
4596
- {
4597
- edgeType: "evidence_derived_from_evidence",
4598
- fromKinds: ["epistemic_node"],
4599
- fromNodeTypes: ["evidence"],
4600
- toKinds: ["epistemic_node"],
4601
- toNodeTypes: ["evidence"],
4602
- description: "Evidence E2 was synthesized from evidence E1 by a transformation. Provides chain-of-evidence lineage."
4603
- },
4604
- {
4605
- edgeType: "evidence_supports_belief",
4606
- fromKinds: ["epistemic_node"],
4607
- fromNodeTypes: ["evidence"],
4608
- toKinds: ["epistemic_node"],
4609
- toNodeTypes: ["belief"],
4610
- description: "Existing link_evidence_to_belief semantics promoted to the create_edge policy source."
4611
- },
4612
- {
4613
- edgeType: "evidence_supports_question",
4614
- fromKinds: ["epistemic_node"],
4615
- fromNodeTypes: ["evidence"],
4616
- toKinds: ["epistemic_node"],
4617
- toNodeTypes: ["question"],
4618
- description: "Existing link_evidence_to_question semantics promoted to the create_edge policy source."
4619
- }
4620
- ]
4635
+ policies: EDGE_TYPE_VALUES.map(publicEpistemicNodeEdgePolicy)
4621
4636
  };
4622
4637
 
4623
4638
  // src/function-registry/edges.ts
4639
+ var CREATE_EDGE_TYPES = edgePolicyManifest.policies.map(
4640
+ (policy) => policy.edgeType
4641
+ );
4624
4642
  var createEdgeArgs = z.object({
4625
4643
  from: GraphRefSchema,
4626
4644
  to: GraphRefSchema,
4627
- edgeType: z.string(),
4645
+ edgeType: z.enum(CREATE_EDGE_TYPES),
4628
4646
  globalId: z.string().optional(),
4629
4647
  weight: z.number().optional(),
4630
4648
  confidence: z.number().optional(),