@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.
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(),
@@ -11796,6 +11839,47 @@ function targetKind(targetId) {
11796
11839
  }
11797
11840
  return "unknown";
11798
11841
  }
11842
+ function normalizeRelation(value, weight) {
11843
+ if (value === "supports" || value === "supporting") {
11844
+ return "supports";
11845
+ }
11846
+ if (value === "contradicts" || value === "contradicting") {
11847
+ return "contradicts";
11848
+ }
11849
+ if (weight === void 0) {
11850
+ return void 0;
11851
+ }
11852
+ return weight < 0 ? "contradicts" : "supports";
11853
+ }
11854
+ function normalizeConfidence(confidence, weight) {
11855
+ if (confidence !== void 0) {
11856
+ return Math.min(1, Math.max(0, confidence));
11857
+ }
11858
+ if (weight === void 0) {
11859
+ return void 0;
11860
+ }
11861
+ return Math.min(1, Math.max(0, Math.abs(weight)));
11862
+ }
11863
+ function normalizeBeliefRelation(relation) {
11864
+ const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
11865
+ if (!beliefNodeId) {
11866
+ return void 0;
11867
+ }
11868
+ const weight = typeof relation.weight === "number" ? relation.weight : void 0;
11869
+ const evidenceRelation = normalizeRelation(
11870
+ relation.evidenceRelation ?? relation.relation,
11871
+ weight
11872
+ );
11873
+ if (!evidenceRelation) {
11874
+ return void 0;
11875
+ }
11876
+ return compactRecord({
11877
+ beliefNodeId,
11878
+ relation: evidenceRelation,
11879
+ confidence: normalizeConfidence(relation.confidence, weight),
11880
+ rationale: relation.rationale
11881
+ });
11882
+ }
11799
11883
  var createEvidenceProjection = defineProjection({
11800
11884
  contractName: "create_evidence",
11801
11885
  inputSchema: createEvidenceInputSchema,
@@ -11806,6 +11890,11 @@ var createEvidenceProjection = defineProjection({
11806
11890
  const kind = targetKind(target);
11807
11891
  const linkedWorktreeId = kind === "worktree" ? normalizeWorktreeId(target) : void 0;
11808
11892
  const linkedBeliefNodeId = input.linkedBeliefNodeId ?? (kind === "belief" || kind === "unknown" ? input.targetNodeId ?? input.targetId : void 0);
11893
+ const evidenceRelation = linkedBeliefNodeId ? normalizeRelation(input.evidenceRelation, weight) : void 0;
11894
+ const confidence = evidenceRelation ? normalizeConfidence(input.confidence, weight) : void 0;
11895
+ const beliefRelations = input.beliefRelations?.map(normalizeBeliefRelation).filter(
11896
+ (relation) => relation !== void 0
11897
+ );
11809
11898
  return compactRecord({
11810
11899
  projectId: input.projectId,
11811
11900
  topicId: normalizeTopicIdForKernel(input.topicId),
@@ -11834,8 +11923,9 @@ var createEvidenceProjection = defineProjection({
11834
11923
  rationale: input.rationale
11835
11924
  }),
11836
11925
  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)))),
11926
+ evidenceRelation,
11927
+ confidence,
11928
+ beliefRelations: beliefRelations && beliefRelations.length > 0 ? beliefRelations : void 0,
11839
11929
  rationale: input.rationale,
11840
11930
  trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
11841
11931
  });
@@ -11864,6 +11954,16 @@ var createEvidenceProjection = defineProjection({
11864
11954
  v.literal("contradicts")
11865
11955
  )
11866
11956
  ),
11957
+ beliefRelations: v.optional(
11958
+ v.array(
11959
+ v.object({
11960
+ beliefNodeId: v.string(),
11961
+ relation: v.union(v.literal("supports"), v.literal("contradicts")),
11962
+ confidence: v.optional(v.number()),
11963
+ rationale: v.optional(v.string())
11964
+ })
11965
+ )
11966
+ ),
11867
11967
  confidence: v.optional(v.number()),
11868
11968
  rationale: v.string(),
11869
11969
  trustedBypassAccessCheck: v.optional(v.boolean())
@@ -12097,6 +12197,12 @@ var internalSystem = {
12097
12197
  mcp: "internal",
12098
12198
  cli: "internal"
12099
12199
  };
12200
+ var internalSdkRestOnly = {
12201
+ sdk: "internal",
12202
+ rest: "internal",
12203
+ mcp: "none",
12204
+ cli: "none"
12205
+ };
12100
12206
  var publicWithInternalMcp = {
12101
12207
  sdk: "public",
12102
12208
  rest: "public",
@@ -12146,7 +12252,6 @@ var MCP_CORE_OPERATION_NAMES = [
12146
12252
  "get_belief",
12147
12253
  "list_beliefs",
12148
12254
  "refine_belief",
12149
- "modulate_confidence",
12150
12255
  "fork_belief",
12151
12256
  "archive_belief",
12152
12257
  "search_beliefs",
@@ -12414,6 +12519,13 @@ var LUCERN_OPERATION_MANIFEST = {
12414
12519
  internalSystem,
12415
12520
  "Lucern system/background operation. Available to platform code paths, hidden from public MCP discovery."
12416
12521
  ),
12522
+ modulate_confidence: {
12523
+ name: "modulate_confidence",
12524
+ surfaceClass: "platform_internal",
12525
+ surfaceIntent: "system",
12526
+ surfaces: internalSdkRestOnly,
12527
+ rationale: "Internal SL ledger append primitive. Public callers attach evidence or contradiction relations; confidence is derived algorithmically."
12528
+ },
12417
12529
  ...entries(
12418
12530
  LEGACY_COMPAT_OPERATION_NAMES,
12419
12531
  "legacy_compat",
@@ -13117,11 +13229,11 @@ var beliefsContracts = [
13117
13229
  name: "modulate_confidence",
13118
13230
  kind: "mutation",
13119
13231
  domain: "beliefs",
13120
- surfaceClass: "platform_public",
13232
+ surfaceClass: "platform_internal",
13121
13233
  path: "/beliefs/confidence",
13122
13234
  sdkNamespace: "beliefs",
13123
13235
  sdkMethod: "modulateConfidence",
13124
- summary: "Append a belief confidence modulation.",
13236
+ summary: "Internal SL ledger append. Public callers should attach evidence or contradiction relations instead.",
13125
13237
  convex: {
13126
13238
  module: "beliefs",
13127
13239
  functionName: "modulateConfidence",
@@ -13227,7 +13339,17 @@ var beliefsContracts = [
13227
13339
  })
13228
13340
  ];
13229
13341
  var jsonRecordSchema4 = z.record(z.unknown());
13230
- var evidenceRelationSchema = z.enum(["supports", "contradicts"]);
13342
+ var evidenceRelationSchema2 = z.enum(["supports", "contradicts"]);
13343
+ var beliefRelationSchema2 = z.object({
13344
+ beliefId: z.string().optional().describe("Belief ID this evidence bears on."),
13345
+ beliefNodeId: z.string().optional().describe("Belief node ID this evidence bears on."),
13346
+ targetId: z.string().optional().describe("Belief target ID alias for beliefId/beliefNodeId."),
13347
+ relation: z.enum(["supports", "contradicts", "supporting", "contradicting"]).optional().describe("Relation alias for how the evidence bears on the belief."),
13348
+ evidenceRelation: evidenceRelationSchema2.optional().describe("Canonical relation: supports or contradicts."),
13349
+ confidence: z.number().optional().describe("Confidence in this evidence-to-belief relation."),
13350
+ weight: z.number().optional().describe("Support weight from -1.0 to +1.0 for this belief."),
13351
+ rationale: z.string().optional().describe("Why this relation exists.")
13352
+ });
13231
13353
  var createEvidenceArgs = z.object({
13232
13354
  topicId: z.string().optional().describe("Topic scope for the evidence."),
13233
13355
  text: z.string().describe("Canonical evidence text."),
@@ -13235,7 +13357,10 @@ var createEvidenceArgs = z.object({
13235
13357
  sourceUrl: z.string().optional().describe("Canonical source URL."),
13236
13358
  targetId: z.string().optional().describe("Belief, question, or worktree identifier to link or preserve on the evidence record."),
13237
13359
  linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
13238
- evidenceRelation: evidenceRelationSchema.optional().describe("How the evidence relates to the linked belief."),
13360
+ evidenceRelation: evidenceRelationSchema2.optional().describe("How the evidence relates to the linked belief."),
13361
+ beliefRelations: z.array(beliefRelationSchema2).optional().describe(
13362
+ "Additional belief relations for one evidence record. Use when the same evidence supports or contradicts multiple beliefs."
13363
+ ),
13239
13364
  confidence: z.number().optional().describe("Confidence in the evidence relation."),
13240
13365
  weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
13241
13366
  metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
@@ -13278,6 +13403,30 @@ var createEvidenceInput = (input, context) => {
13278
13403
  context
13279
13404
  );
13280
13405
  };
13406
+ function relationWeight(input) {
13407
+ if (typeof input.weight === "number") {
13408
+ return input.weight;
13409
+ }
13410
+ const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
13411
+ const relation = String(
13412
+ input.evidenceRelation ?? input.relation ?? input.type ?? ""
13413
+ );
13414
+ return relation === "contradicts" || relation === "contradicting" ? -confidence : confidence;
13415
+ }
13416
+ var linkEvidenceToBeliefInput = (input, context) => {
13417
+ const weight = relationWeight(input);
13418
+ return withUserId(
13419
+ compactRecord4({
13420
+ beliefNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
13421
+ insightId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
13422
+ type: weight < 0 ? "contradicting" : "supporting",
13423
+ confidence: Math.min(1, Math.abs(weight)),
13424
+ rationale: input.rationale ?? input.context,
13425
+ trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
13426
+ }),
13427
+ context
13428
+ );
13429
+ };
13281
13430
  var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
13282
13431
  compactRecord4({
13283
13432
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
@@ -13420,10 +13569,10 @@ var evidenceContracts = [
13420
13569
  sdkMethod: "linkEvidenceToBelief",
13421
13570
  summary: "Link evidence to a belief.",
13422
13571
  convex: {
13423
- module: "edges",
13424
- functionName: "create",
13572
+ module: "beliefs",
13573
+ functionName: "linkEvidence",
13425
13574
  kind: "mutation",
13426
- inputProjection: linkEvidenceToBeliefEdgeInput
13575
+ inputProjection: linkEvidenceToBeliefInput
13427
13576
  }
13428
13577
  }),
13429
13578
  surfaceContract({