@lucern/contracts 0.1.2-alpha.1 → 0.1.2-alpha.3

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/index.js CHANGED
@@ -20,14 +20,28 @@ var FORK_REASONS = [
20
20
  var CONFIDENCE_TRIGGERS = [
21
21
  "evidence_added",
22
22
  // New evidence bore on the belief
23
+ "evidence_removed",
24
+ // Evidence was removed or invalidated
23
25
  "contradiction_detected",
24
26
  // A contradiction was flagged involving this belief
25
- "merge_outcome",
26
- // Merge scoring determined this confidence
27
+ "contradiction_resolved",
28
+ // A contradiction was resolved
27
29
  "manual",
28
30
  // User manually adjusted confidence
29
- "decay"
31
+ "decay",
30
32
  // Time-based confidence erosion
33
+ "agent_assessment",
34
+ // An agent provided a structured assessment
35
+ "worktree_outcome",
36
+ // Worktree outcome determined this confidence
37
+ "worktree_completed",
38
+ // Worktree completed and closed this scoring loop
39
+ "fusion",
40
+ // Confidence came from subjective-logic fusion
41
+ "discount",
42
+ // Confidence came from trust discounting
43
+ "deduction"
44
+ // Confidence came from conditional deduction
31
45
  ];
32
46
  var BELIEF_STATUSES = [
33
47
  "unscored",
@@ -352,15 +366,16 @@ var DOMAIN_EVENT_TYPES = [
352
366
  "identity.key_revoked",
353
367
  "webhook.test"
354
368
  ];
369
+ var RUNTIME_BUFFER = globalThis.Buffer;
355
370
  function toBase64(value) {
356
- if (typeof Buffer !== "undefined") {
357
- return Buffer.from(value, "utf8").toString("base64url");
371
+ if (typeof RUNTIME_BUFFER !== "undefined") {
372
+ return RUNTIME_BUFFER.from(value, "utf8").toString("base64url");
358
373
  }
359
374
  return btoa(unescape(encodeURIComponent(value))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/g, "");
360
375
  }
361
376
  function fromBase64(value) {
362
- if (typeof Buffer !== "undefined") {
363
- return Buffer.from(value, "base64url").toString("utf8");
377
+ if (typeof RUNTIME_BUFFER !== "undefined") {
378
+ return RUNTIME_BUFFER.from(value, "base64url").toString("utf8");
364
379
  }
365
380
  const normalized = value.replace(/-/g, "+").replace(/_/g, "/");
366
381
  return decodeURIComponent(escape(atob(normalized)));
@@ -580,13 +595,17 @@ var LENS_PERSPECTIVE_TYPES = [
580
595
  // src/mcp-tools.contract.ts
581
596
  var CREATE_BELIEF = {
582
597
  name: "create_belief",
583
- description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object. The belief starts as unscored (draft). Score it with modulate_confidence to freeze the formulation.",
598
+ description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object with a mandatory prior. Creation stores the vacuous opinion `(0, 0, 1, a)`; use modulate_confidence to record the first evidential update.",
584
599
  parameters: {
585
600
  canonicalText: {
586
601
  type: "string",
587
602
  description: "The belief statement \u2014 what the agent holds to be true"
588
603
  },
589
604
  topicId: { type: "string", description: "Topic scope for the belief" },
605
+ baseRate: {
606
+ type: "number",
607
+ description: "Required prior probability used to seed the vacuous opinion `(0, 0, 1, a)` at creation time."
608
+ },
590
609
  beliefType: {
591
610
  type: "string",
592
611
  description: "Belief type (e.g., hypothesis, belief, principle, invariant, tenet, forecast). Validated against schemaEnumConfig."
@@ -596,7 +615,7 @@ var CREATE_BELIEF = {
596
615
  description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'] } for coding intelligence)"
597
616
  }
598
617
  },
599
- required: ["canonicalText", "topicId"],
618
+ required: ["canonicalText", "topicId", "baseRate"],
600
619
  response: {
601
620
  description: "The created canonical belief record",
602
621
  fields: {
@@ -659,17 +678,43 @@ var REFINE_BELIEF = {
659
678
  };
660
679
  var MODULATE_CONFIDENCE = {
661
680
  name: "modulate_confidence",
662
- description: "Record a confidence change for a belief. Like `git commit` to the credence log \u2014 an atomic, append-only write. Each modulation is a new entry in the history, not an overwrite. Scoring happens via merge; this tool records the individual data points. Triggers: evidence_added, contradiction_detected, merge_outcome, manual, decay.",
681
+ description: "Record a confidence change for a belief. Like `git commit` to the credence log \u2014 an atomic, append-only write. Each modulation is a new entry in the history, not an overwrite. Scoring happens via merge; this tool records the individual data points. Pass the full subjective-logic tuple (`belief`, `disbelief`, `uncertainty`, `baseRate`) directly. If a caller only has a scalar probability, use `@lucern/sdk` helpers `opinionFromBaseRate`, `opinionFromDogmatic`, or `opinionFromProjected` to name the intended interpretation before calling this tool. Triggers: evidence_added, evidence_removed, contradiction_detected, contradiction_resolved, agent_assessment, worktree_outcome, worktree_completed, fusion, discount, deduction, manual, decay.",
663
682
  parameters: {
664
683
  nodeId: { type: "string", description: "The belief to score" },
665
- confidence: { type: "number", description: "Confidence level in [0, 1]" },
684
+ belief: {
685
+ type: "number",
686
+ description: "Subjective-logic belief mass `b` in [0, 1]"
687
+ },
688
+ disbelief: {
689
+ type: "number",
690
+ description: "Subjective-logic disbelief mass `d` in [0, 1]"
691
+ },
692
+ uncertainty: {
693
+ type: "number",
694
+ description: "Subjective-logic uncertainty mass `u` in [0, 1]"
695
+ },
696
+ baseRate: {
697
+ type: "number",
698
+ description: "Subjective-logic base rate `a` in [0, 1]. Required for tuple payloads."
699
+ },
700
+ confidence: {
701
+ type: "number",
702
+ description: "Deprecated scalar confidence value in [0, 1]. Scalar-only payloads are rejected as AMBIGUOUS_SCALAR."
703
+ },
666
704
  trigger: {
667
705
  type: "string",
668
706
  description: "What caused this confidence change",
669
707
  enum: [
670
708
  "evidence_added",
709
+ "evidence_removed",
671
710
  "contradiction_detected",
672
- "merge_outcome",
711
+ "contradiction_resolved",
712
+ "agent_assessment",
713
+ "worktree_outcome",
714
+ "worktree_completed",
715
+ "fusion",
716
+ "discount",
717
+ "deduction",
673
718
  "manual",
674
719
  "decay"
675
720
  ]
@@ -679,7 +724,7 @@ var MODULATE_CONFIDENCE = {
679
724
  description: "Human-readable explanation of why confidence changed"
680
725
  }
681
726
  },
682
- required: ["nodeId", "confidence", "trigger", "rationale"],
727
+ required: ["nodeId", "trigger", "rationale"],
683
728
  response: {
684
729
  description: "Confidence modulation result",
685
730
  fields: {
@@ -1321,7 +1366,7 @@ var RECORD_JUDGMENT = {
1321
1366
  status: "string \u2014 'issued'"
1322
1367
  }
1323
1368
  },
1324
- ownerModule: "decision-state",
1369
+ ownerModule: "decisions",
1325
1370
  ontologyPrimitive: "judgment",
1326
1371
  tier: "showcase"
1327
1372
  };
@@ -2590,7 +2635,7 @@ var INGEST_OBSERVATION = {
2590
2635
  contextResourceUri: "string"
2591
2636
  }
2592
2637
  },
2593
- ownerModule: "agent-harness",
2638
+ ownerModule: "agent-frameworks",
2594
2639
  ontologyPrimitive: "graph",
2595
2640
  tier: "workhorse"
2596
2641
  };
@@ -2620,7 +2665,7 @@ var GET_OBSERVATION_CONTEXT = {
2620
2665
  generatedAt: "number"
2621
2666
  }
2622
2667
  },
2623
- ownerModule: "agent-harness",
2668
+ ownerModule: "agent-frameworks",
2624
2669
  ontologyPrimitive: "graph",
2625
2670
  tier: "workhorse"
2626
2671
  };
@@ -4559,7 +4604,7 @@ var CREATE_BELIEF_CONDITIONAL = {
4559
4604
  targetBeliefId: "string"
4560
4605
  }
4561
4606
  },
4562
- ownerModule: "graph-primitives",
4607
+ ownerModule: "edges",
4563
4608
  ontologyPrimitive: "edge",
4564
4609
  tier: "sdk-only"
4565
4610
  };