@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/index.js CHANGED
@@ -572,7 +572,7 @@ var SEARCH_EVIDENCE = {
572
572
  };
573
573
  var CREATE_EVIDENCE = {
574
574
  name: "create_evidence",
575
- 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.",
575
+ 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.",
576
576
  parameters: {
577
577
  topicId: { type: "string", description: "Topic scope" },
578
578
  text: { type: "string", description: "Canonical evidence text" },
@@ -583,7 +583,20 @@ var CREATE_EVIDENCE = {
583
583
  },
584
584
  weight: {
585
585
  type: "number",
586
- description: "Support weight: -1.0 (contradicts) to +1.0 (supports)"
586
+ description: "Optional support weight: -1.0 (contradicts) to +1.0 (supports). If omitted, evidenceRelation + confidence determine the weight."
587
+ },
588
+ evidenceRelation: {
589
+ type: "string",
590
+ enum: ["supports", "contradicts"],
591
+ description: "Canonical relation to targetId/linkedBeliefNodeId. Prefer this over relying on signed weight inference."
592
+ },
593
+ confidence: {
594
+ type: "number",
595
+ description: "Confidence in the evidence relation, 0.0 to 1.0"
596
+ },
597
+ beliefRelations: {
598
+ type: "array",
599
+ 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."
587
600
  },
588
601
  metadata: {
589
602
  type: "object",
@@ -693,7 +706,7 @@ var LINK_EVIDENCE = {
693
706
  };
694
707
  var LINK_EVIDENCE_TO_BELIEF = {
695
708
  name: "link_evidence_to_belief",
696
- 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).",
709
+ 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.",
697
710
  parameters: {
698
711
  evidenceId: { type: "string", description: "The evidence node ID" },
699
712
  beliefId: { type: "string", description: "The belief node ID" },
@@ -701,9 +714,18 @@ var LINK_EVIDENCE_TO_BELIEF = {
701
714
  type: "number",
702
715
  description: "Support weight: -1.0 (contradicts) to +1.0 (supports)"
703
716
  },
717
+ evidenceRelation: {
718
+ type: "string",
719
+ enum: ["supports", "contradicts"],
720
+ description: "Canonical semantic relation. If omitted, the sign of weight is used."
721
+ },
722
+ confidence: {
723
+ type: "number",
724
+ description: "Confidence in this evidence-to-belief relation, 0.0 to 1.0"
725
+ },
704
726
  rationale: { type: "string", description: "Why this evidence is relevant" }
705
727
  },
706
- required: ["evidenceId", "beliefId", "weight"],
728
+ required: ["evidenceId", "beliefId"],
707
729
  response: {
708
730
  description: "The created edge linking evidence to belief",
709
731
  fields: {
@@ -721,7 +743,7 @@ var LINK_EVIDENCE_TO_BELIEF = {
721
743
  // ../contracts/src/tool-contracts.lifecycle.ts
722
744
  var CREATE_BELIEF = {
723
745
  name: "create_belief",
724
- 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.",
746
+ 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.",
725
747
  parameters: {
726
748
  canonicalText: {
727
749
  type: "string",
@@ -807,7 +829,7 @@ var REFINE_BELIEF = {
807
829
  };
808
830
  var MODULATE_CONFIDENCE = {
809
831
  name: "modulate_confidence",
810
- 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.",
832
+ 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.",
811
833
  parameters: {
812
834
  nodeId: { type: "string", description: "The belief to score" },
813
835
  belief: {
@@ -1497,10 +1519,11 @@ var LUCERN_ORIENT = {
1497
1519
  workflow: "array - recommended branch -> investigate -> prove gate -> merge workflow",
1498
1520
  grammarMap: "array - primitive-to-git-analogy map for topics, campaigns, worktrees, beliefs, questions, evidence, edges, contradictions, and gates",
1499
1521
  firstMoves: "array - recommended first tools for a cold-start agent",
1500
- receiptRules: "array - how to interpret candidateCounts, broadening, coverageWarning, and noDefaultGlobalScan",
1522
+ receiptRules: "array - how to interpret candidateCounts, broadening, coverageWarning, narrativeCoverage, synthesisLints, and noDefaultGlobalScan",
1501
1523
  safetyRules: "array - mutation and completion rules that preserve reasoning lineage",
1502
1524
  toolMap: "array | undefined - situation-to-tool routing map when requested",
1503
1525
  examples: "array | undefined - concrete tool-call examples when requested",
1526
+ futureCapabilities: "array | undefined - exemplar, gauntlet, trace-corpus, and native-model-training capabilities when requested",
1504
1527
  suggestedNextCalls: "array - safe next tool calls for the current situation"
1505
1528
  }
1506
1529
  },
@@ -4081,7 +4104,9 @@ var COMPILE_CONTEXT = {
4081
4104
  recentEvidence: "array \u2014 recent evidence ranked for this query",
4082
4105
  contradictions: "array \u2014 unresolved contradiction records",
4083
4106
  relatedEntities: "array | undefined \u2014 ranked ontological entities in scope",
4084
- contextNarrative: "array \u2014 guidance for prompt assembly",
4107
+ contextNarrative: "array \u2014 ordered synthesis blocks with kind/text, starting with executive_summary and canonical narrative blocks before raw objects",
4108
+ retrievalReceipt: "object \u2014 candidateCounts, coverageWarning, narrativeCoverage, synthesisLints, and suggestedNextActions",
4109
+ narrativeCoverage: "object \u2014 recordsSynthesized, recordsNamed, recordsOmitted, and blocksEmitted for the narrative",
4085
4110
  injectionPolicy: "object \u2014 token-budgeted section selections",
4086
4111
  diagnostics: "object \u2014 scoring and utilization telemetry"
4087
4112
  }
@@ -11711,6 +11736,23 @@ function defineProjection(def) {
11711
11736
 
11712
11737
  // ../contracts/src/projections/create-evidence.projection.ts
11713
11738
  var jsonRecordSchema = z.record(z.unknown());
11739
+ var evidenceRelationSchema = z.enum(["supports", "contradicts"]);
11740
+ var evidenceRelationAliasSchema = z.enum([
11741
+ "supports",
11742
+ "contradicts",
11743
+ "supporting",
11744
+ "contradicting"
11745
+ ]);
11746
+ var beliefRelationSchema = z.object({
11747
+ beliefId: z.string().optional(),
11748
+ beliefNodeId: z.string().optional(),
11749
+ targetId: z.string().optional(),
11750
+ relation: evidenceRelationAliasSchema.optional(),
11751
+ evidenceRelation: evidenceRelationSchema.optional(),
11752
+ confidence: z.number().optional(),
11753
+ weight: z.number().optional(),
11754
+ rationale: z.string().optional()
11755
+ });
11714
11756
  var createEvidenceInputSchemaBase = z.object({
11715
11757
  projectId: z.string().optional(),
11716
11758
  topicId: z.string().optional(),
@@ -11732,7 +11774,8 @@ var createEvidenceInputSchemaBase = z.object({
11732
11774
  targetId: z.string().optional(),
11733
11775
  targetNodeId: z.string().optional(),
11734
11776
  linkedBeliefNodeId: z.string().optional(),
11735
- evidenceRelation: z.enum(["supports", "contradicts"]).optional(),
11777
+ evidenceRelation: evidenceRelationSchema.optional(),
11778
+ beliefRelations: z.array(beliefRelationSchema).optional(),
11736
11779
  confidence: z.number().optional(),
11737
11780
  weight: z.number().optional(),
11738
11781
  reasoning: z.string().optional(),
@@ -11740,11 +11783,55 @@ var createEvidenceInputSchemaBase = z.object({
11740
11783
  metadata: jsonRecordSchema.optional(),
11741
11784
  trustedBypassAccessCheck: z.boolean().optional()
11742
11785
  }).passthrough();
11743
- var createEvidenceInputSchema = createEvidenceInputSchemaBase.refine(
11744
- (input) => Boolean(input.text ?? input.canonicalText),
11745
- {
11746
- message: "create_evidence requires text",
11747
- path: ["text"]
11786
+ function hasNonzeroWeight(value) {
11787
+ return typeof value === "number" && Number.isFinite(value) && value !== 0;
11788
+ }
11789
+ function hasRelationSignal(value, weight) {
11790
+ return Boolean(normalizeRelation(value, weight));
11791
+ }
11792
+ var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
11793
+ (input, ctx) => {
11794
+ if (!input.text && !input.canonicalText) {
11795
+ ctx.addIssue({
11796
+ code: z.ZodIssueCode.custom,
11797
+ message: "create_evidence requires text",
11798
+ path: ["text"]
11799
+ });
11800
+ }
11801
+ const target = input.targetId ?? input.targetNodeId;
11802
+ const kind = targetKind(target);
11803
+ const linksPrimaryBelief = Boolean(
11804
+ input.linkedBeliefNodeId || kind === "belief" || kind === "unknown" && target
11805
+ );
11806
+ const weight = typeof input.weight === "number" ? input.weight : void 0;
11807
+ if (linksPrimaryBelief && !hasRelationSignal(input.evidenceRelation, weight)) {
11808
+ ctx.addIssue({
11809
+ code: z.ZodIssueCode.custom,
11810
+ message: "belief-targeted evidence requires evidenceRelation='supports'|'contradicts' or a nonzero signed weight",
11811
+ path: ["evidenceRelation"]
11812
+ });
11813
+ }
11814
+ input.beliefRelations?.forEach((relation, index) => {
11815
+ const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
11816
+ if (!beliefNodeId) {
11817
+ ctx.addIssue({
11818
+ code: z.ZodIssueCode.custom,
11819
+ message: "beliefRelations entries require beliefId, beliefNodeId, or targetId",
11820
+ path: ["beliefRelations", index, "beliefNodeId"]
11821
+ });
11822
+ }
11823
+ const relationWeight2 = typeof relation.weight === "number" ? relation.weight : void 0;
11824
+ if (beliefNodeId && !hasRelationSignal(
11825
+ relation.evidenceRelation ?? relation.relation,
11826
+ relationWeight2
11827
+ )) {
11828
+ ctx.addIssue({
11829
+ code: z.ZodIssueCode.custom,
11830
+ message: "beliefRelations entries require evidenceRelation='supports'|'contradicts' or a nonzero signed weight",
11831
+ path: ["beliefRelations", index, "evidenceRelation"]
11832
+ });
11833
+ }
11834
+ });
11748
11835
  }
11749
11836
  );
11750
11837
  function compactRecord(input) {
@@ -11796,6 +11883,47 @@ function targetKind(targetId) {
11796
11883
  }
11797
11884
  return "unknown";
11798
11885
  }
11886
+ function normalizeRelation(value, weight) {
11887
+ if (value === "supports" || value === "supporting") {
11888
+ return "supports";
11889
+ }
11890
+ if (value === "contradicts" || value === "contradicting") {
11891
+ return "contradicts";
11892
+ }
11893
+ if (weight === void 0 || !hasNonzeroWeight(weight)) {
11894
+ return void 0;
11895
+ }
11896
+ return weight < 0 ? "contradicts" : "supports";
11897
+ }
11898
+ function normalizeConfidence(confidence, weight) {
11899
+ if (confidence !== void 0) {
11900
+ return Math.min(1, Math.max(0, confidence));
11901
+ }
11902
+ if (weight === void 0) {
11903
+ return void 0;
11904
+ }
11905
+ return Math.min(1, Math.max(0, Math.abs(weight)));
11906
+ }
11907
+ function normalizeBeliefRelation(relation) {
11908
+ const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
11909
+ if (!beliefNodeId) {
11910
+ return void 0;
11911
+ }
11912
+ const weight = typeof relation.weight === "number" ? relation.weight : void 0;
11913
+ const evidenceRelation = normalizeRelation(
11914
+ relation.evidenceRelation ?? relation.relation,
11915
+ weight
11916
+ );
11917
+ if (!evidenceRelation) {
11918
+ return void 0;
11919
+ }
11920
+ return compactRecord({
11921
+ beliefNodeId,
11922
+ relation: evidenceRelation,
11923
+ confidence: normalizeConfidence(relation.confidence, weight),
11924
+ rationale: relation.rationale
11925
+ });
11926
+ }
11799
11927
  var createEvidenceProjection = defineProjection({
11800
11928
  contractName: "create_evidence",
11801
11929
  inputSchema: createEvidenceInputSchema,
@@ -11806,6 +11934,11 @@ var createEvidenceProjection = defineProjection({
11806
11934
  const kind = targetKind(target);
11807
11935
  const linkedWorktreeId = kind === "worktree" ? normalizeWorktreeId(target) : void 0;
11808
11936
  const linkedBeliefNodeId = input.linkedBeliefNodeId ?? (kind === "belief" || kind === "unknown" ? input.targetNodeId ?? input.targetId : void 0);
11937
+ const evidenceRelation = linkedBeliefNodeId ? normalizeRelation(input.evidenceRelation, weight) : void 0;
11938
+ const confidence = evidenceRelation ? normalizeConfidence(input.confidence, weight) : void 0;
11939
+ const beliefRelations = input.beliefRelations?.map(normalizeBeliefRelation).filter(
11940
+ (relation) => relation !== void 0
11941
+ );
11809
11942
  return compactRecord({
11810
11943
  projectId: input.projectId,
11811
11944
  topicId: normalizeTopicIdForKernel(input.topicId),
@@ -11834,8 +11967,9 @@ var createEvidenceProjection = defineProjection({
11834
11967
  rationale: input.rationale
11835
11968
  }),
11836
11969
  linkedBeliefNodeId,
11837
- evidenceRelation: input.evidenceRelation ?? (weight === void 0 ? void 0 : weight < 0 ? "contradicts" : "supports"),
11838
- confidence: input.confidence ?? (weight === void 0 ? void 0 : Math.min(1, Math.max(0, Math.abs(weight)))),
11970
+ evidenceRelation,
11971
+ confidence,
11972
+ beliefRelations: beliefRelations && beliefRelations.length > 0 ? beliefRelations : void 0,
11839
11973
  rationale: input.rationale,
11840
11974
  trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
11841
11975
  });
@@ -11864,6 +11998,16 @@ var createEvidenceProjection = defineProjection({
11864
11998
  v.literal("contradicts")
11865
11999
  )
11866
12000
  ),
12001
+ beliefRelations: v.optional(
12002
+ v.array(
12003
+ v.object({
12004
+ beliefNodeId: v.string(),
12005
+ relation: v.union(v.literal("supports"), v.literal("contradicts")),
12006
+ confidence: v.optional(v.number()),
12007
+ rationale: v.optional(v.string())
12008
+ })
12009
+ )
12010
+ ),
11867
12011
  confidence: v.optional(v.number()),
11868
12012
  rationale: v.string(),
11869
12013
  trustedBypassAccessCheck: v.optional(v.boolean())
@@ -12097,6 +12241,12 @@ var internalSystem = {
12097
12241
  mcp: "internal",
12098
12242
  cli: "internal"
12099
12243
  };
12244
+ var internalSdkRestOnly = {
12245
+ sdk: "internal",
12246
+ rest: "internal",
12247
+ mcp: "none",
12248
+ cli: "none"
12249
+ };
12100
12250
  var publicWithInternalMcp = {
12101
12251
  sdk: "public",
12102
12252
  rest: "public",
@@ -12146,7 +12296,6 @@ var MCP_CORE_OPERATION_NAMES = [
12146
12296
  "get_belief",
12147
12297
  "list_beliefs",
12148
12298
  "refine_belief",
12149
- "modulate_confidence",
12150
12299
  "fork_belief",
12151
12300
  "archive_belief",
12152
12301
  "search_beliefs",
@@ -12414,6 +12563,13 @@ var LUCERN_OPERATION_MANIFEST = {
12414
12563
  internalSystem,
12415
12564
  "Lucern system/background operation. Available to platform code paths, hidden from public MCP discovery."
12416
12565
  ),
12566
+ modulate_confidence: {
12567
+ name: "modulate_confidence",
12568
+ surfaceClass: "platform_internal",
12569
+ surfaceIntent: "system",
12570
+ surfaces: internalSdkRestOnly,
12571
+ rationale: "Internal SL ledger append primitive. Public callers attach evidence or contradiction relations; confidence is derived algorithmically."
12572
+ },
12417
12573
  ...entries(
12418
12574
  LEGACY_COMPAT_OPERATION_NAMES,
12419
12575
  "legacy_compat",
@@ -13117,11 +13273,11 @@ var beliefsContracts = [
13117
13273
  name: "modulate_confidence",
13118
13274
  kind: "mutation",
13119
13275
  domain: "beliefs",
13120
- surfaceClass: "platform_public",
13276
+ surfaceClass: "platform_internal",
13121
13277
  path: "/beliefs/confidence",
13122
13278
  sdkNamespace: "beliefs",
13123
13279
  sdkMethod: "modulateConfidence",
13124
- summary: "Append a belief confidence modulation.",
13280
+ summary: "Internal SL ledger append. Public callers should attach evidence or contradiction relations instead.",
13125
13281
  convex: {
13126
13282
  module: "beliefs",
13127
13283
  functionName: "modulateConfidence",
@@ -13227,17 +13383,34 @@ var beliefsContracts = [
13227
13383
  })
13228
13384
  ];
13229
13385
  var jsonRecordSchema4 = z.record(z.unknown());
13230
- var evidenceRelationSchema = z.enum(["supports", "contradicts"]);
13386
+ var evidenceRelationSchema2 = z.enum(["supports", "contradicts"]);
13387
+ var beliefRelationSchema2 = z.object({
13388
+ beliefId: z.string().optional().describe("Belief ID this evidence bears on."),
13389
+ beliefNodeId: z.string().optional().describe("Belief node ID this evidence bears on."),
13390
+ targetId: z.string().optional().describe("Belief target ID alias for beliefId/beliefNodeId."),
13391
+ relation: z.enum(["supports", "contradicts", "supporting", "contradicting"]).optional().describe("Relation alias for how the evidence bears on the belief."),
13392
+ evidenceRelation: evidenceRelationSchema2.optional().describe("Canonical relation: supports or contradicts."),
13393
+ confidence: z.number().optional().describe("Confidence in this evidence-to-belief relation."),
13394
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0 for this belief."),
13395
+ rationale: z.string().optional().describe("Why this relation exists.")
13396
+ });
13231
13397
  var createEvidenceArgs = z.object({
13232
13398
  topicId: z.string().optional().describe("Topic scope for the evidence."),
13233
13399
  text: z.string().describe("Canonical evidence text."),
13234
13400
  source: z.string().optional().describe("Source URL or source label."),
13235
13401
  sourceUrl: z.string().optional().describe("Canonical source URL."),
13236
- targetId: z.string().optional().describe("Belief, question, or worktree identifier to link or preserve on the evidence record."),
13402
+ targetId: z.string().optional().describe(
13403
+ "Belief, question, or worktree identifier to link or preserve on the evidence record. Belief targets require evidenceRelation or a nonzero signed weight."
13404
+ ),
13237
13405
  linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
13238
- evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
13406
+ evidenceRelation: evidenceRelationSchema2.optional().describe(
13407
+ "How the evidence relates to the linked belief. Use supports for proof/fixes; use contradicts for bugs, regressions, or falsifying observations."
13408
+ ),
13409
+ beliefRelations: z.array(beliefRelationSchema2).optional().describe(
13410
+ "Additional belief relations for one evidence record. Use when the same evidence supports or contradicts multiple beliefs."
13411
+ ),
13239
13412
  confidence: z.number().optional().describe("Confidence in the evidence relation."),
13240
- weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
13413
+ weight: z.number().optional().describe("Nonzero support weight from -1.0 to +1.0."),
13241
13414
  metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
13242
13415
  rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
13243
13416
  reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
@@ -13278,6 +13451,35 @@ var createEvidenceInput = (input, context) => {
13278
13451
  context
13279
13452
  );
13280
13453
  };
13454
+ function relationWeight(input) {
13455
+ if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0) {
13456
+ return input.weight;
13457
+ }
13458
+ const relation = String(
13459
+ input.evidenceRelation ?? input.relation ?? input.type ?? ""
13460
+ );
13461
+ if (relation !== "supports" && relation !== "supporting" && relation !== "contradicts" && relation !== "contradicting") {
13462
+ throw new Error(
13463
+ "Belief evidence links require evidenceRelation='supports'|'contradicts' or a nonzero signed weight."
13464
+ );
13465
+ }
13466
+ const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
13467
+ return relation === "contradicts" || relation === "contradicting" ? -confidence : confidence;
13468
+ }
13469
+ var linkEvidenceToBeliefInput = (input, context) => {
13470
+ const weight = relationWeight(input);
13471
+ return withUserId(
13472
+ compactRecord4({
13473
+ beliefNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
13474
+ insightId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
13475
+ type: weight < 0 ? "contradicting" : "supporting",
13476
+ confidence: Math.min(1, Math.abs(weight)),
13477
+ rationale: input.rationale ?? input.context,
13478
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
13479
+ }),
13480
+ context
13481
+ );
13482
+ };
13281
13483
  var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
13282
13484
  compactRecord4({
13283
13485
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
@@ -13288,7 +13490,7 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
13288
13490
  )}:${String(
13289
13491
  input.beliefNodeId ?? input.beliefId ?? input.targetId
13290
13492
  )}:informs`,
13291
- weight: typeof input.weight === "number" ? input.weight : input.type === "contradicting" ? -1 : 1,
13493
+ weight: relationWeight(input),
13292
13494
  context: input.rationale ?? input.context,
13293
13495
  skipLayerValidation: true,
13294
13496
  topicId: input.topicId,
@@ -13420,10 +13622,10 @@ var evidenceContracts = [
13420
13622
  sdkMethod: "linkEvidenceToBelief",
13421
13623
  summary: "Link evidence to a belief.",
13422
13624
  convex: {
13423
- module: "edges",
13424
- functionName: "create",
13625
+ module: "beliefs",
13626
+ functionName: "linkEvidence",
13425
13627
  kind: "mutation",
13426
- inputProjection: linkEvidenceToBeliefEdgeInput
13628
+ inputProjection: linkEvidenceToBeliefInput
13427
13629
  }
13428
13630
  }),
13429
13631
  surfaceContract({