@lucern/events 1.0.12 → 1.0.14

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/webhooks.js CHANGED
@@ -546,7 +546,7 @@ var SEARCH_EVIDENCE = {
546
546
  };
547
547
  var CREATE_EVIDENCE = {
548
548
  name: "create_evidence",
549
- 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.",
549
+ 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.",
550
550
  parameters: {
551
551
  topicId: { type: "string", description: "Topic scope" },
552
552
  text: { type: "string", description: "Canonical evidence text" },
@@ -557,7 +557,20 @@ var CREATE_EVIDENCE = {
557
557
  },
558
558
  weight: {
559
559
  type: "number",
560
- description: "Support weight: -1.0 (contradicts) to +1.0 (supports)"
560
+ description: "Optional support weight: -1.0 (contradicts) to +1.0 (supports). If omitted, evidenceRelation + confidence determine the weight."
561
+ },
562
+ evidenceRelation: {
563
+ type: "string",
564
+ enum: ["supports", "contradicts"],
565
+ description: "Canonical relation to targetId/linkedBeliefNodeId. Prefer this over relying on signed weight inference."
566
+ },
567
+ confidence: {
568
+ type: "number",
569
+ description: "Confidence in the evidence relation, 0.0 to 1.0"
570
+ },
571
+ beliefRelations: {
572
+ type: "array",
573
+ 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."
561
574
  },
562
575
  metadata: {
563
576
  type: "object",
@@ -667,7 +680,7 @@ var LINK_EVIDENCE = {
667
680
  };
668
681
  var LINK_EVIDENCE_TO_BELIEF = {
669
682
  name: "link_evidence_to_belief",
670
- 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).",
683
+ 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.",
671
684
  parameters: {
672
685
  evidenceId: { type: "string", description: "The evidence node ID" },
673
686
  beliefId: { type: "string", description: "The belief node ID" },
@@ -675,9 +688,18 @@ var LINK_EVIDENCE_TO_BELIEF = {
675
688
  type: "number",
676
689
  description: "Support weight: -1.0 (contradicts) to +1.0 (supports)"
677
690
  },
691
+ evidenceRelation: {
692
+ type: "string",
693
+ enum: ["supports", "contradicts"],
694
+ description: "Canonical semantic relation. If omitted, the sign of weight is used."
695
+ },
696
+ confidence: {
697
+ type: "number",
698
+ description: "Confidence in this evidence-to-belief relation, 0.0 to 1.0"
699
+ },
678
700
  rationale: { type: "string", description: "Why this evidence is relevant" }
679
701
  },
680
- required: ["evidenceId", "beliefId", "weight"],
702
+ required: ["evidenceId", "beliefId"],
681
703
  response: {
682
704
  description: "The created edge linking evidence to belief",
683
705
  fields: {
@@ -695,7 +717,7 @@ var LINK_EVIDENCE_TO_BELIEF = {
695
717
  // ../contracts/src/tool-contracts.lifecycle.ts
696
718
  var CREATE_BELIEF = {
697
719
  name: "create_belief",
698
- 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.",
720
+ 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.",
699
721
  parameters: {
700
722
  canonicalText: {
701
723
  type: "string",
@@ -781,7 +803,7 @@ var REFINE_BELIEF = {
781
803
  };
782
804
  var MODULATE_CONFIDENCE = {
783
805
  name: "modulate_confidence",
784
- 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.",
806
+ 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.",
785
807
  parameters: {
786
808
  nodeId: { type: "string", description: "The belief to score" },
787
809
  belief: {
@@ -1471,10 +1493,11 @@ var LUCERN_ORIENT = {
1471
1493
  workflow: "array - recommended branch -> investigate -> prove gate -> merge workflow",
1472
1494
  grammarMap: "array - primitive-to-git-analogy map for topics, campaigns, worktrees, beliefs, questions, evidence, edges, contradictions, and gates",
1473
1495
  firstMoves: "array - recommended first tools for a cold-start agent",
1474
- receiptRules: "array - how to interpret candidateCounts, broadening, coverageWarning, and noDefaultGlobalScan",
1496
+ receiptRules: "array - how to interpret candidateCounts, broadening, coverageWarning, narrativeCoverage, synthesisLints, and noDefaultGlobalScan",
1475
1497
  safetyRules: "array - mutation and completion rules that preserve reasoning lineage",
1476
1498
  toolMap: "array | undefined - situation-to-tool routing map when requested",
1477
1499
  examples: "array | undefined - concrete tool-call examples when requested",
1500
+ futureCapabilities: "array | undefined - exemplar, gauntlet, trace-corpus, and native-model-training capabilities when requested",
1478
1501
  suggestedNextCalls: "array - safe next tool calls for the current situation"
1479
1502
  }
1480
1503
  },
@@ -4055,7 +4078,9 @@ var COMPILE_CONTEXT = {
4055
4078
  recentEvidence: "array \u2014 recent evidence ranked for this query",
4056
4079
  contradictions: "array \u2014 unresolved contradiction records",
4057
4080
  relatedEntities: "array | undefined \u2014 ranked ontological entities in scope",
4058
- contextNarrative: "array \u2014 guidance for prompt assembly",
4081
+ contextNarrative: "array \u2014 ordered synthesis blocks with kind/text, starting with executive_summary and canonical narrative blocks before raw objects",
4082
+ retrievalReceipt: "object \u2014 candidateCounts, coverageWarning, narrativeCoverage, synthesisLints, and suggestedNextActions",
4083
+ narrativeCoverage: "object \u2014 recordsSynthesized, recordsNamed, recordsOmitted, and blocksEmitted for the narrative",
4059
4084
  injectionPolicy: "object \u2014 token-budgeted section selections",
4060
4085
  diagnostics: "object \u2014 scoring and utilization telemetry"
4061
4086
  }
@@ -11555,6 +11580,23 @@ function defineProjection(def) {
11555
11580
 
11556
11581
  // ../contracts/src/projections/create-evidence.projection.ts
11557
11582
  var jsonRecordSchema = z.record(z.unknown());
11583
+ var evidenceRelationSchema = z.enum(["supports", "contradicts"]);
11584
+ var evidenceRelationAliasSchema = z.enum([
11585
+ "supports",
11586
+ "contradicts",
11587
+ "supporting",
11588
+ "contradicting"
11589
+ ]);
11590
+ var beliefRelationSchema = z.object({
11591
+ beliefId: z.string().optional(),
11592
+ beliefNodeId: z.string().optional(),
11593
+ targetId: z.string().optional(),
11594
+ relation: evidenceRelationAliasSchema.optional(),
11595
+ evidenceRelation: evidenceRelationSchema.optional(),
11596
+ confidence: z.number().optional(),
11597
+ weight: z.number().optional(),
11598
+ rationale: z.string().optional()
11599
+ });
11558
11600
  var createEvidenceInputSchemaBase = z.object({
11559
11601
  projectId: z.string().optional(),
11560
11602
  topicId: z.string().optional(),
@@ -11576,7 +11618,8 @@ var createEvidenceInputSchemaBase = z.object({
11576
11618
  targetId: z.string().optional(),
11577
11619
  targetNodeId: z.string().optional(),
11578
11620
  linkedBeliefNodeId: z.string().optional(),
11579
- evidenceRelation: z.enum(["supports", "contradicts"]).optional(),
11621
+ evidenceRelation: evidenceRelationSchema.optional(),
11622
+ beliefRelations: z.array(beliefRelationSchema).optional(),
11580
11623
  confidence: z.number().optional(),
11581
11624
  weight: z.number().optional(),
11582
11625
  reasoning: z.string().optional(),
@@ -11584,11 +11627,55 @@ var createEvidenceInputSchemaBase = z.object({
11584
11627
  metadata: jsonRecordSchema.optional(),
11585
11628
  trustedBypassAccessCheck: z.boolean().optional()
11586
11629
  }).passthrough();
11587
- var createEvidenceInputSchema = createEvidenceInputSchemaBase.refine(
11588
- (input) => Boolean(input.text ?? input.canonicalText),
11589
- {
11590
- message: "create_evidence requires text",
11591
- path: ["text"]
11630
+ function hasNonzeroWeight(value) {
11631
+ return typeof value === "number" && Number.isFinite(value) && value !== 0;
11632
+ }
11633
+ function hasRelationSignal(value, weight) {
11634
+ return Boolean(normalizeRelation(value, weight));
11635
+ }
11636
+ var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
11637
+ (input, ctx) => {
11638
+ if (!input.text && !input.canonicalText) {
11639
+ ctx.addIssue({
11640
+ code: z.ZodIssueCode.custom,
11641
+ message: "create_evidence requires text",
11642
+ path: ["text"]
11643
+ });
11644
+ }
11645
+ const target = input.targetId ?? input.targetNodeId;
11646
+ const kind = targetKind(target);
11647
+ const linksPrimaryBelief = Boolean(
11648
+ input.linkedBeliefNodeId || kind === "belief" || kind === "unknown" && target
11649
+ );
11650
+ const weight = typeof input.weight === "number" ? input.weight : void 0;
11651
+ if (linksPrimaryBelief && !hasRelationSignal(input.evidenceRelation, weight)) {
11652
+ ctx.addIssue({
11653
+ code: z.ZodIssueCode.custom,
11654
+ message: "belief-targeted evidence requires evidenceRelation='supports'|'contradicts' or a nonzero signed weight",
11655
+ path: ["evidenceRelation"]
11656
+ });
11657
+ }
11658
+ input.beliefRelations?.forEach((relation, index) => {
11659
+ const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
11660
+ if (!beliefNodeId) {
11661
+ ctx.addIssue({
11662
+ code: z.ZodIssueCode.custom,
11663
+ message: "beliefRelations entries require beliefId, beliefNodeId, or targetId",
11664
+ path: ["beliefRelations", index, "beliefNodeId"]
11665
+ });
11666
+ }
11667
+ const relationWeight2 = typeof relation.weight === "number" ? relation.weight : void 0;
11668
+ if (beliefNodeId && !hasRelationSignal(
11669
+ relation.evidenceRelation ?? relation.relation,
11670
+ relationWeight2
11671
+ )) {
11672
+ ctx.addIssue({
11673
+ code: z.ZodIssueCode.custom,
11674
+ message: "beliefRelations entries require evidenceRelation='supports'|'contradicts' or a nonzero signed weight",
11675
+ path: ["beliefRelations", index, "evidenceRelation"]
11676
+ });
11677
+ }
11678
+ });
11592
11679
  }
11593
11680
  );
11594
11681
  function compactRecord(input) {
@@ -11640,6 +11727,47 @@ function targetKind(targetId) {
11640
11727
  }
11641
11728
  return "unknown";
11642
11729
  }
11730
+ function normalizeRelation(value, weight) {
11731
+ if (value === "supports" || value === "supporting") {
11732
+ return "supports";
11733
+ }
11734
+ if (value === "contradicts" || value === "contradicting") {
11735
+ return "contradicts";
11736
+ }
11737
+ if (weight === void 0 || !hasNonzeroWeight(weight)) {
11738
+ return void 0;
11739
+ }
11740
+ return weight < 0 ? "contradicts" : "supports";
11741
+ }
11742
+ function normalizeConfidence(confidence, weight) {
11743
+ if (confidence !== void 0) {
11744
+ return Math.min(1, Math.max(0, confidence));
11745
+ }
11746
+ if (weight === void 0) {
11747
+ return void 0;
11748
+ }
11749
+ return Math.min(1, Math.max(0, Math.abs(weight)));
11750
+ }
11751
+ function normalizeBeliefRelation(relation) {
11752
+ const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
11753
+ if (!beliefNodeId) {
11754
+ return void 0;
11755
+ }
11756
+ const weight = typeof relation.weight === "number" ? relation.weight : void 0;
11757
+ const evidenceRelation = normalizeRelation(
11758
+ relation.evidenceRelation ?? relation.relation,
11759
+ weight
11760
+ );
11761
+ if (!evidenceRelation) {
11762
+ return void 0;
11763
+ }
11764
+ return compactRecord({
11765
+ beliefNodeId,
11766
+ relation: evidenceRelation,
11767
+ confidence: normalizeConfidence(relation.confidence, weight),
11768
+ rationale: relation.rationale
11769
+ });
11770
+ }
11643
11771
  var createEvidenceProjection = defineProjection({
11644
11772
  contractName: "create_evidence",
11645
11773
  inputSchema: createEvidenceInputSchema,
@@ -11650,6 +11778,11 @@ var createEvidenceProjection = defineProjection({
11650
11778
  const kind = targetKind(target);
11651
11779
  const linkedWorktreeId = kind === "worktree" ? normalizeWorktreeId(target) : void 0;
11652
11780
  const linkedBeliefNodeId = input.linkedBeliefNodeId ?? (kind === "belief" || kind === "unknown" ? input.targetNodeId ?? input.targetId : void 0);
11781
+ const evidenceRelation = linkedBeliefNodeId ? normalizeRelation(input.evidenceRelation, weight) : void 0;
11782
+ const confidence = evidenceRelation ? normalizeConfidence(input.confidence, weight) : void 0;
11783
+ const beliefRelations = input.beliefRelations?.map(normalizeBeliefRelation).filter(
11784
+ (relation) => relation !== void 0
11785
+ );
11653
11786
  return compactRecord({
11654
11787
  projectId: input.projectId,
11655
11788
  topicId: normalizeTopicIdForKernel(input.topicId),
@@ -11678,8 +11811,9 @@ var createEvidenceProjection = defineProjection({
11678
11811
  rationale: input.rationale
11679
11812
  }),
11680
11813
  linkedBeliefNodeId,
11681
- evidenceRelation: input.evidenceRelation ?? (weight === void 0 ? void 0 : weight < 0 ? "contradicts" : "supports"),
11682
- confidence: input.confidence ?? (weight === void 0 ? void 0 : Math.min(1, Math.max(0, Math.abs(weight)))),
11814
+ evidenceRelation,
11815
+ confidence,
11816
+ beliefRelations: beliefRelations && beliefRelations.length > 0 ? beliefRelations : void 0,
11683
11817
  rationale: input.rationale,
11684
11818
  trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
11685
11819
  });
@@ -11708,6 +11842,16 @@ var createEvidenceProjection = defineProjection({
11708
11842
  v.literal("contradicts")
11709
11843
  )
11710
11844
  ),
11845
+ beliefRelations: v.optional(
11846
+ v.array(
11847
+ v.object({
11848
+ beliefNodeId: v.string(),
11849
+ relation: v.union(v.literal("supports"), v.literal("contradicts")),
11850
+ confidence: v.optional(v.number()),
11851
+ rationale: v.optional(v.string())
11852
+ })
11853
+ )
11854
+ ),
11711
11855
  confidence: v.optional(v.number()),
11712
11856
  rationale: v.string(),
11713
11857
  trustedBypassAccessCheck: v.optional(v.boolean())
@@ -11941,6 +12085,12 @@ var internalSystem = {
11941
12085
  mcp: "internal",
11942
12086
  cli: "internal"
11943
12087
  };
12088
+ var internalSdkRestOnly = {
12089
+ sdk: "internal",
12090
+ rest: "internal",
12091
+ mcp: "none",
12092
+ cli: "none"
12093
+ };
11944
12094
  var publicWithInternalMcp = {
11945
12095
  sdk: "public",
11946
12096
  rest: "public",
@@ -11990,7 +12140,6 @@ var MCP_CORE_OPERATION_NAMES = [
11990
12140
  "get_belief",
11991
12141
  "list_beliefs",
11992
12142
  "refine_belief",
11993
- "modulate_confidence",
11994
12143
  "fork_belief",
11995
12144
  "archive_belief",
11996
12145
  "search_beliefs",
@@ -12258,6 +12407,13 @@ var LUCERN_OPERATION_MANIFEST = {
12258
12407
  internalSystem,
12259
12408
  "Lucern system/background operation. Available to platform code paths, hidden from public MCP discovery."
12260
12409
  ),
12410
+ modulate_confidence: {
12411
+ name: "modulate_confidence",
12412
+ surfaceClass: "platform_internal",
12413
+ surfaceIntent: "system",
12414
+ surfaces: internalSdkRestOnly,
12415
+ rationale: "Internal SL ledger append primitive. Public callers attach evidence or contradiction relations; confidence is derived algorithmically."
12416
+ },
12261
12417
  ...entries(
12262
12418
  LEGACY_COMPAT_OPERATION_NAMES,
12263
12419
  "legacy_compat",
@@ -12961,11 +13117,11 @@ var beliefsContracts = [
12961
13117
  name: "modulate_confidence",
12962
13118
  kind: "mutation",
12963
13119
  domain: "beliefs",
12964
- surfaceClass: "platform_public",
13120
+ surfaceClass: "platform_internal",
12965
13121
  path: "/beliefs/confidence",
12966
13122
  sdkNamespace: "beliefs",
12967
13123
  sdkMethod: "modulateConfidence",
12968
- summary: "Append a belief confidence modulation.",
13124
+ summary: "Internal SL ledger append. Public callers should attach evidence or contradiction relations instead.",
12969
13125
  convex: {
12970
13126
  module: "beliefs",
12971
13127
  functionName: "modulateConfidence",
@@ -13071,17 +13227,34 @@ var beliefsContracts = [
13071
13227
  })
13072
13228
  ];
13073
13229
  var jsonRecordSchema4 = z.record(z.unknown());
13074
- var evidenceRelationSchema = z.enum(["supports", "contradicts"]);
13230
+ var evidenceRelationSchema2 = z.enum(["supports", "contradicts"]);
13231
+ var beliefRelationSchema2 = z.object({
13232
+ beliefId: z.string().optional().describe("Belief ID this evidence bears on."),
13233
+ beliefNodeId: z.string().optional().describe("Belief node ID this evidence bears on."),
13234
+ targetId: z.string().optional().describe("Belief target ID alias for beliefId/beliefNodeId."),
13235
+ relation: z.enum(["supports", "contradicts", "supporting", "contradicting"]).optional().describe("Relation alias for how the evidence bears on the belief."),
13236
+ evidenceRelation: evidenceRelationSchema2.optional().describe("Canonical relation: supports or contradicts."),
13237
+ confidence: z.number().optional().describe("Confidence in this evidence-to-belief relation."),
13238
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0 for this belief."),
13239
+ rationale: z.string().optional().describe("Why this relation exists.")
13240
+ });
13075
13241
  var createEvidenceArgs = z.object({
13076
13242
  topicId: z.string().optional().describe("Topic scope for the evidence."),
13077
13243
  text: z.string().describe("Canonical evidence text."),
13078
13244
  source: z.string().optional().describe("Source URL or source label."),
13079
13245
  sourceUrl: z.string().optional().describe("Canonical source URL."),
13080
- targetId: z.string().optional().describe("Belief, question, or worktree identifier to link or preserve on the evidence record."),
13246
+ targetId: z.string().optional().describe(
13247
+ "Belief, question, or worktree identifier to link or preserve on the evidence record. Belief targets require evidenceRelation or a nonzero signed weight."
13248
+ ),
13081
13249
  linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
13082
- evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
13250
+ evidenceRelation: evidenceRelationSchema2.optional().describe(
13251
+ "How the evidence relates to the linked belief. Use supports for proof/fixes; use contradicts for bugs, regressions, or falsifying observations."
13252
+ ),
13253
+ beliefRelations: z.array(beliefRelationSchema2).optional().describe(
13254
+ "Additional belief relations for one evidence record. Use when the same evidence supports or contradicts multiple beliefs."
13255
+ ),
13083
13256
  confidence: z.number().optional().describe("Confidence in the evidence relation."),
13084
- weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
13257
+ weight: z.number().optional().describe("Nonzero support weight from -1.0 to +1.0."),
13085
13258
  metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
13086
13259
  rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
13087
13260
  reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
@@ -13122,6 +13295,35 @@ var createEvidenceInput = (input, context) => {
13122
13295
  context
13123
13296
  );
13124
13297
  };
13298
+ function relationWeight(input) {
13299
+ if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0) {
13300
+ return input.weight;
13301
+ }
13302
+ const relation = String(
13303
+ input.evidenceRelation ?? input.relation ?? input.type ?? ""
13304
+ );
13305
+ if (relation !== "supports" && relation !== "supporting" && relation !== "contradicts" && relation !== "contradicting") {
13306
+ throw new Error(
13307
+ "Belief evidence links require evidenceRelation='supports'|'contradicts' or a nonzero signed weight."
13308
+ );
13309
+ }
13310
+ const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
13311
+ return relation === "contradicts" || relation === "contradicting" ? -confidence : confidence;
13312
+ }
13313
+ var linkEvidenceToBeliefInput = (input, context) => {
13314
+ const weight = relationWeight(input);
13315
+ return withUserId(
13316
+ compactRecord4({
13317
+ beliefNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
13318
+ insightId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
13319
+ type: weight < 0 ? "contradicting" : "supporting",
13320
+ confidence: Math.min(1, Math.abs(weight)),
13321
+ rationale: input.rationale ?? input.context,
13322
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
13323
+ }),
13324
+ context
13325
+ );
13326
+ };
13125
13327
  var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
13126
13328
  compactRecord4({
13127
13329
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
@@ -13132,7 +13334,7 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
13132
13334
  )}:${String(
13133
13335
  input.beliefNodeId ?? input.beliefId ?? input.targetId
13134
13336
  )}:informs`,
13135
- weight: typeof input.weight === "number" ? input.weight : input.type === "contradicting" ? -1 : 1,
13337
+ weight: relationWeight(input),
13136
13338
  context: input.rationale ?? input.context,
13137
13339
  skipLayerValidation: true,
13138
13340
  topicId: input.topicId,
@@ -13264,10 +13466,10 @@ var evidenceContracts = [
13264
13466
  sdkMethod: "linkEvidenceToBelief",
13265
13467
  summary: "Link evidence to a belief.",
13266
13468
  convex: {
13267
- module: "edges",
13268
- functionName: "create",
13469
+ module: "beliefs",
13470
+ functionName: "linkEvidence",
13269
13471
  kind: "mutation",
13270
- inputProjection: linkEvidenceToBeliefEdgeInput
13472
+ inputProjection: linkEvidenceToBeliefInput
13271
13473
  }
13272
13474
  }),
13273
13475
  surfaceContract({