@lucern/events 1.0.12 → 1.0.13

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.
@@ -547,7 +547,7 @@ var SEARCH_EVIDENCE = {
547
547
  };
548
548
  var CREATE_EVIDENCE = {
549
549
  name: "create_evidence",
550
- description: "Commit evidence to the reasoning graph. Like `git commit` \u2014 creates a traceable evidence record with canonical public IDs. Optionally links the evidence to a belief or question in the same operation.",
550
+ description: "Commit evidence to the reasoning graph. Like `git commit` \u2014 creates a traceable evidence record with canonical public IDs. Optionally links the evidence to a belief or question in the same operation. When evidence bears on beliefs, state whether it supports or contradicts; SL confidence is derived from these evidence relations.",
551
551
  parameters: {
552
552
  topicId: { type: "string", description: "Topic scope" },
553
553
  text: { type: "string", description: "Canonical evidence text" },
@@ -558,7 +558,20 @@ var CREATE_EVIDENCE = {
558
558
  },
559
559
  weight: {
560
560
  type: "number",
561
- description: "Support weight: -1.0 (contradicts) to +1.0 (supports)"
561
+ description: "Optional support weight: -1.0 (contradicts) to +1.0 (supports). If omitted, evidenceRelation + confidence determine the weight."
562
+ },
563
+ evidenceRelation: {
564
+ type: "string",
565
+ enum: ["supports", "contradicts"],
566
+ description: "Canonical relation to targetId/linkedBeliefNodeId. Prefer this over relying on signed weight inference."
567
+ },
568
+ confidence: {
569
+ type: "number",
570
+ description: "Confidence in the evidence relation, 0.0 to 1.0"
571
+ },
572
+ beliefRelations: {
573
+ type: "array",
574
+ description: "Optional additional belief relations: [{ beliefId|beliefNodeId|targetId, evidenceRelation|relation, confidence?, weight?, rationale? }]. Use one evidence node with multiple relations when the same fact supports or contradicts several beliefs."
562
575
  },
563
576
  metadata: {
564
577
  type: "object",
@@ -668,7 +681,7 @@ var LINK_EVIDENCE = {
668
681
  };
669
682
  var LINK_EVIDENCE_TO_BELIEF = {
670
683
  name: "link_evidence_to_belief",
671
- description: "Link evidence to a belief with a support weight. Like `git add` \u2014 stages evidence in support of (or against) a belief. The weight ranges from -1.0 (strongly contradicts) to +1.0 (strongly supports).",
684
+ description: "Link evidence to a belief with a support weight. Like `git add` \u2014 stages evidence in support of (or against) a belief. The weight ranges from -1.0 (strongly contradicts) to +1.0 (strongly supports). This relation appends to the SL confidence ledger; do not hand-write confidence separately.",
672
685
  parameters: {
673
686
  evidenceId: { type: "string", description: "The evidence node ID" },
674
687
  beliefId: { type: "string", description: "The belief node ID" },
@@ -676,9 +689,18 @@ var LINK_EVIDENCE_TO_BELIEF = {
676
689
  type: "number",
677
690
  description: "Support weight: -1.0 (contradicts) to +1.0 (supports)"
678
691
  },
692
+ evidenceRelation: {
693
+ type: "string",
694
+ enum: ["supports", "contradicts"],
695
+ description: "Canonical semantic relation. If omitted, the sign of weight is used."
696
+ },
697
+ confidence: {
698
+ type: "number",
699
+ description: "Confidence in this evidence-to-belief relation, 0.0 to 1.0"
700
+ },
679
701
  rationale: { type: "string", description: "Why this evidence is relevant" }
680
702
  },
681
- required: ["evidenceId", "beliefId", "weight"],
703
+ required: ["evidenceId", "beliefId"],
682
704
  response: {
683
705
  description: "The created edge linking evidence to belief",
684
706
  fields: {
@@ -696,7 +718,7 @@ var LINK_EVIDENCE_TO_BELIEF = {
696
718
  // ../contracts/src/tool-contracts.lifecycle.ts
697
719
  var CREATE_BELIEF = {
698
720
  name: "create_belief",
699
- description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object with a prior. Creation stores the vacuous opinion `(0, 0, 1, a)`; use modulate_confidence to record the first evidential update.",
721
+ description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object with a prior. Creation stores the vacuous opinion `(0, 0, 1, a)`; attach supporting or contradicting evidence with create_evidence or link_evidence_to_belief to record evidential updates.",
700
722
  parameters: {
701
723
  canonicalText: {
702
724
  type: "string",
@@ -782,7 +804,7 @@ var REFINE_BELIEF = {
782
804
  };
783
805
  var MODULATE_CONFIDENCE = {
784
806
  name: "modulate_confidence",
785
- 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. Every modulation must cite a truth-bearing artifact: triggeringEvidenceId, triggeringQuestionId, triggeringAnswerId, triggeringContradictionId, or triggeringWorktreeId. Triggers: evidence_added, evidence_removed, contradiction_detected, contradiction_resolved, agent_assessment, worktree_outcome, worktree_completed, fusion, discount, deduction.",
807
+ description: "Internal-only subjective-logic ledger append. Like `git commit` to the credence log for the scoring engine \u2014 never an operator-facing way to assert confidence. Agents, SDK callers, CLI users, and MCP clients must instead create or link evidence with `evidenceRelation: supports|contradicts`; the kernel derives the next opinion from that evidence. This compatibility primitive is reserved for governed system scoring paths that already hold a full subjective-logic tuple and truth-bearing provenance.",
786
808
  parameters: {
787
809
  nodeId: { type: "string", description: "The belief to score" },
788
810
  belief: {
@@ -1472,10 +1494,11 @@ var LUCERN_ORIENT = {
1472
1494
  workflow: "array - recommended branch -> investigate -> prove gate -> merge workflow",
1473
1495
  grammarMap: "array - primitive-to-git-analogy map for topics, campaigns, worktrees, beliefs, questions, evidence, edges, contradictions, and gates",
1474
1496
  firstMoves: "array - recommended first tools for a cold-start agent",
1475
- receiptRules: "array - how to interpret candidateCounts, broadening, coverageWarning, and noDefaultGlobalScan",
1497
+ receiptRules: "array - how to interpret candidateCounts, broadening, coverageWarning, narrativeCoverage, synthesisLints, and noDefaultGlobalScan",
1476
1498
  safetyRules: "array - mutation and completion rules that preserve reasoning lineage",
1477
1499
  toolMap: "array | undefined - situation-to-tool routing map when requested",
1478
1500
  examples: "array | undefined - concrete tool-call examples when requested",
1501
+ futureCapabilities: "array | undefined - exemplar, gauntlet, trace-corpus, and native-model-training capabilities when requested",
1479
1502
  suggestedNextCalls: "array - safe next tool calls for the current situation"
1480
1503
  }
1481
1504
  },
@@ -4056,7 +4079,9 @@ var COMPILE_CONTEXT = {
4056
4079
  recentEvidence: "array \u2014 recent evidence ranked for this query",
4057
4080
  contradictions: "array \u2014 unresolved contradiction records",
4058
4081
  relatedEntities: "array | undefined \u2014 ranked ontological entities in scope",
4059
- contextNarrative: "array \u2014 guidance for prompt assembly",
4082
+ contextNarrative: "array \u2014 ordered synthesis blocks with kind/text, starting with executive_summary and canonical narrative blocks before raw objects",
4083
+ retrievalReceipt: "object \u2014 candidateCounts, coverageWarning, narrativeCoverage, synthesisLints, and suggestedNextActions",
4084
+ narrativeCoverage: "object \u2014 recordsSynthesized, recordsNamed, recordsOmitted, and blocksEmitted for the narrative",
4060
4085
  injectionPolicy: "object \u2014 token-budgeted section selections",
4061
4086
  diagnostics: "object \u2014 scoring and utilization telemetry"
4062
4087
  }
@@ -11556,6 +11581,23 @@ function defineProjection(def) {
11556
11581
 
11557
11582
  // ../contracts/src/projections/create-evidence.projection.ts
11558
11583
  var jsonRecordSchema = z.record(z.unknown());
11584
+ var evidenceRelationSchema = z.enum(["supports", "contradicts"]);
11585
+ var evidenceRelationAliasSchema = z.enum([
11586
+ "supports",
11587
+ "contradicts",
11588
+ "supporting",
11589
+ "contradicting"
11590
+ ]);
11591
+ var beliefRelationSchema = z.object({
11592
+ beliefId: z.string().optional(),
11593
+ beliefNodeId: z.string().optional(),
11594
+ targetId: z.string().optional(),
11595
+ relation: evidenceRelationAliasSchema.optional(),
11596
+ evidenceRelation: evidenceRelationSchema.optional(),
11597
+ confidence: z.number().optional(),
11598
+ weight: z.number().optional(),
11599
+ rationale: z.string().optional()
11600
+ });
11559
11601
  var createEvidenceInputSchemaBase = z.object({
11560
11602
  projectId: z.string().optional(),
11561
11603
  topicId: z.string().optional(),
@@ -11577,7 +11619,8 @@ var createEvidenceInputSchemaBase = z.object({
11577
11619
  targetId: z.string().optional(),
11578
11620
  targetNodeId: z.string().optional(),
11579
11621
  linkedBeliefNodeId: z.string().optional(),
11580
- evidenceRelation: z.enum(["supports", "contradicts"]).optional(),
11622
+ evidenceRelation: evidenceRelationSchema.optional(),
11623
+ beliefRelations: z.array(beliefRelationSchema).optional(),
11581
11624
  confidence: z.number().optional(),
11582
11625
  weight: z.number().optional(),
11583
11626
  reasoning: z.string().optional(),
@@ -11641,6 +11684,47 @@ function targetKind(targetId) {
11641
11684
  }
11642
11685
  return "unknown";
11643
11686
  }
11687
+ function normalizeRelation(value, weight) {
11688
+ if (value === "supports" || value === "supporting") {
11689
+ return "supports";
11690
+ }
11691
+ if (value === "contradicts" || value === "contradicting") {
11692
+ return "contradicts";
11693
+ }
11694
+ if (weight === void 0) {
11695
+ return void 0;
11696
+ }
11697
+ return weight < 0 ? "contradicts" : "supports";
11698
+ }
11699
+ function normalizeConfidence(confidence, weight) {
11700
+ if (confidence !== void 0) {
11701
+ return Math.min(1, Math.max(0, confidence));
11702
+ }
11703
+ if (weight === void 0) {
11704
+ return void 0;
11705
+ }
11706
+ return Math.min(1, Math.max(0, Math.abs(weight)));
11707
+ }
11708
+ function normalizeBeliefRelation(relation) {
11709
+ const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
11710
+ if (!beliefNodeId) {
11711
+ return void 0;
11712
+ }
11713
+ const weight = typeof relation.weight === "number" ? relation.weight : void 0;
11714
+ const evidenceRelation = normalizeRelation(
11715
+ relation.evidenceRelation ?? relation.relation,
11716
+ weight
11717
+ );
11718
+ if (!evidenceRelation) {
11719
+ return void 0;
11720
+ }
11721
+ return compactRecord({
11722
+ beliefNodeId,
11723
+ relation: evidenceRelation,
11724
+ confidence: normalizeConfidence(relation.confidence, weight),
11725
+ rationale: relation.rationale
11726
+ });
11727
+ }
11644
11728
  var createEvidenceProjection = defineProjection({
11645
11729
  contractName: "create_evidence",
11646
11730
  inputSchema: createEvidenceInputSchema,
@@ -11651,6 +11735,11 @@ var createEvidenceProjection = defineProjection({
11651
11735
  const kind = targetKind(target);
11652
11736
  const linkedWorktreeId = kind === "worktree" ? normalizeWorktreeId(target) : void 0;
11653
11737
  const linkedBeliefNodeId = input.linkedBeliefNodeId ?? (kind === "belief" || kind === "unknown" ? input.targetNodeId ?? input.targetId : void 0);
11738
+ const evidenceRelation = linkedBeliefNodeId ? normalizeRelation(input.evidenceRelation, weight) : void 0;
11739
+ const confidence = evidenceRelation ? normalizeConfidence(input.confidence, weight) : void 0;
11740
+ const beliefRelations = input.beliefRelations?.map(normalizeBeliefRelation).filter(
11741
+ (relation) => relation !== void 0
11742
+ );
11654
11743
  return compactRecord({
11655
11744
  projectId: input.projectId,
11656
11745
  topicId: normalizeTopicIdForKernel(input.topicId),
@@ -11679,8 +11768,9 @@ var createEvidenceProjection = defineProjection({
11679
11768
  rationale: input.rationale
11680
11769
  }),
11681
11770
  linkedBeliefNodeId,
11682
- evidenceRelation: input.evidenceRelation ?? (weight === void 0 ? void 0 : weight < 0 ? "contradicts" : "supports"),
11683
- confidence: input.confidence ?? (weight === void 0 ? void 0 : Math.min(1, Math.max(0, Math.abs(weight)))),
11771
+ evidenceRelation,
11772
+ confidence,
11773
+ beliefRelations: beliefRelations && beliefRelations.length > 0 ? beliefRelations : void 0,
11684
11774
  rationale: input.rationale,
11685
11775
  trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
11686
11776
  });
@@ -11709,6 +11799,16 @@ var createEvidenceProjection = defineProjection({
11709
11799
  v.literal("contradicts")
11710
11800
  )
11711
11801
  ),
11802
+ beliefRelations: v.optional(
11803
+ v.array(
11804
+ v.object({
11805
+ beliefNodeId: v.string(),
11806
+ relation: v.union(v.literal("supports"), v.literal("contradicts")),
11807
+ confidence: v.optional(v.number()),
11808
+ rationale: v.optional(v.string())
11809
+ })
11810
+ )
11811
+ ),
11712
11812
  confidence: v.optional(v.number()),
11713
11813
  rationale: v.string(),
11714
11814
  trustedBypassAccessCheck: v.optional(v.boolean())
@@ -11942,6 +12042,12 @@ var internalSystem = {
11942
12042
  mcp: "internal",
11943
12043
  cli: "internal"
11944
12044
  };
12045
+ var internalSdkRestOnly = {
12046
+ sdk: "internal",
12047
+ rest: "internal",
12048
+ mcp: "none",
12049
+ cli: "none"
12050
+ };
11945
12051
  var publicWithInternalMcp = {
11946
12052
  sdk: "public",
11947
12053
  rest: "public",
@@ -11991,7 +12097,6 @@ var MCP_CORE_OPERATION_NAMES = [
11991
12097
  "get_belief",
11992
12098
  "list_beliefs",
11993
12099
  "refine_belief",
11994
- "modulate_confidence",
11995
12100
  "fork_belief",
11996
12101
  "archive_belief",
11997
12102
  "search_beliefs",
@@ -12259,6 +12364,13 @@ var LUCERN_OPERATION_MANIFEST = {
12259
12364
  internalSystem,
12260
12365
  "Lucern system/background operation. Available to platform code paths, hidden from public MCP discovery."
12261
12366
  ),
12367
+ modulate_confidence: {
12368
+ name: "modulate_confidence",
12369
+ surfaceClass: "platform_internal",
12370
+ surfaceIntent: "system",
12371
+ surfaces: internalSdkRestOnly,
12372
+ rationale: "Internal SL ledger append primitive. Public callers attach evidence or contradiction relations; confidence is derived algorithmically."
12373
+ },
12262
12374
  ...entries(
12263
12375
  LEGACY_COMPAT_OPERATION_NAMES,
12264
12376
  "legacy_compat",
@@ -12962,11 +13074,11 @@ var beliefsContracts = [
12962
13074
  name: "modulate_confidence",
12963
13075
  kind: "mutation",
12964
13076
  domain: "beliefs",
12965
- surfaceClass: "platform_public",
13077
+ surfaceClass: "platform_internal",
12966
13078
  path: "/beliefs/confidence",
12967
13079
  sdkNamespace: "beliefs",
12968
13080
  sdkMethod: "modulateConfidence",
12969
- summary: "Append a belief confidence modulation.",
13081
+ summary: "Internal SL ledger append. Public callers should attach evidence or contradiction relations instead.",
12970
13082
  convex: {
12971
13083
  module: "beliefs",
12972
13084
  functionName: "modulateConfidence",
@@ -13072,7 +13184,17 @@ var beliefsContracts = [
13072
13184
  })
13073
13185
  ];
13074
13186
  var jsonRecordSchema4 = z.record(z.unknown());
13075
- var evidenceRelationSchema = z.enum(["supports", "contradicts"]);
13187
+ var evidenceRelationSchema2 = z.enum(["supports", "contradicts"]);
13188
+ var beliefRelationSchema2 = z.object({
13189
+ beliefId: z.string().optional().describe("Belief ID this evidence bears on."),
13190
+ beliefNodeId: z.string().optional().describe("Belief node ID this evidence bears on."),
13191
+ targetId: z.string().optional().describe("Belief target ID alias for beliefId/beliefNodeId."),
13192
+ relation: z.enum(["supports", "contradicts", "supporting", "contradicting"]).optional().describe("Relation alias for how the evidence bears on the belief."),
13193
+ evidenceRelation: evidenceRelationSchema2.optional().describe("Canonical relation: supports or contradicts."),
13194
+ confidence: z.number().optional().describe("Confidence in this evidence-to-belief relation."),
13195
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0 for this belief."),
13196
+ rationale: z.string().optional().describe("Why this relation exists.")
13197
+ });
13076
13198
  var createEvidenceArgs = z.object({
13077
13199
  topicId: z.string().optional().describe("Topic scope for the evidence."),
13078
13200
  text: z.string().describe("Canonical evidence text."),
@@ -13080,7 +13202,10 @@ var createEvidenceArgs = z.object({
13080
13202
  sourceUrl: z.string().optional().describe("Canonical source URL."),
13081
13203
  targetId: z.string().optional().describe("Belief, question, or worktree identifier to link or preserve on the evidence record."),
13082
13204
  linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
13083
- evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
13205
+ evidenceRelation: evidenceRelationSchema2.optional().describe("How the evidence relates to the linked belief."),
13206
+ beliefRelations: z.array(beliefRelationSchema2).optional().describe(
13207
+ "Additional belief relations for one evidence record. Use when the same evidence supports or contradicts multiple beliefs."
13208
+ ),
13084
13209
  confidence: z.number().optional().describe("Confidence in the evidence relation."),
13085
13210
  weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
13086
13211
  metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
@@ -13123,6 +13248,30 @@ var createEvidenceInput = (input, context) => {
13123
13248
  context
13124
13249
  );
13125
13250
  };
13251
+ function relationWeight(input) {
13252
+ if (typeof input.weight === "number") {
13253
+ return input.weight;
13254
+ }
13255
+ const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
13256
+ const relation = String(
13257
+ input.evidenceRelation ?? input.relation ?? input.type ?? ""
13258
+ );
13259
+ return relation === "contradicts" || relation === "contradicting" ? -confidence : confidence;
13260
+ }
13261
+ var linkEvidenceToBeliefInput = (input, context) => {
13262
+ const weight = relationWeight(input);
13263
+ return withUserId(
13264
+ compactRecord4({
13265
+ beliefNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
13266
+ insightId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
13267
+ type: weight < 0 ? "contradicting" : "supporting",
13268
+ confidence: Math.min(1, Math.abs(weight)),
13269
+ rationale: input.rationale ?? input.context,
13270
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
13271
+ }),
13272
+ context
13273
+ );
13274
+ };
13126
13275
  var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
13127
13276
  compactRecord4({
13128
13277
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
@@ -13265,10 +13414,10 @@ var evidenceContracts = [
13265
13414
  sdkMethod: "linkEvidenceToBelief",
13266
13415
  summary: "Link evidence to a belief.",
13267
13416
  convex: {
13268
- module: "edges",
13269
- functionName: "create",
13417
+ module: "beliefs",
13418
+ functionName: "linkEvidence",
13270
13419
  kind: "mutation",
13271
- inputProjection: linkEvidenceToBeliefEdgeInput
13420
+ inputProjection: linkEvidenceToBeliefInput
13272
13421
  }
13273
13422
  }),
13274
13423
  surfaceContract({