@lucern/events 1.0.11 → 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: {
@@ -1431,6 +1453,60 @@ var REMOVE_LENS_FROM_TOPIC = {
1431
1453
  tier: "workhorse"
1432
1454
  };
1433
1455
 
1456
+ // ../contracts/src/tool-contracts.context-orientation.ts
1457
+ var LUCERN_ORIENT = {
1458
+ name: "lucern_orient",
1459
+ description: "Load the Lucern reasoning grammar before operating. Like `git help` plus a repository CONTRIBUTING guide for reasoning state - teaches the git-shaped model of topics, campaigns, lanes, worktrees, beliefs, questions, evidence, receipts, gates, and merges.",
1460
+ parameters: {
1461
+ audience: {
1462
+ type: "string",
1463
+ description: "Audience for the primer: agent, human, operator, or developer.",
1464
+ enum: ["agent", "human", "operator", "developer"]
1465
+ },
1466
+ depth: {
1467
+ type: "string",
1468
+ description: "Orientation depth: quick, standard, or deep.",
1469
+ enum: ["quick", "standard", "deep"]
1470
+ },
1471
+ situation: {
1472
+ type: "string",
1473
+ description: "Optional task or query context used to tailor suggested next calls."
1474
+ },
1475
+ includeExamples: {
1476
+ type: "boolean",
1477
+ description: "Whether to include concrete tool-call examples."
1478
+ },
1479
+ includeToolMap: {
1480
+ type: "boolean",
1481
+ description: "Whether to include situation-to-tool routing guidance."
1482
+ },
1483
+ includeFuture: {
1484
+ type: "boolean",
1485
+ description: "Whether to include future exemplar, gauntlet, and training-data capabilities."
1486
+ }
1487
+ },
1488
+ required: [],
1489
+ response: {
1490
+ description: "Canonical operator primer for Lucern's git-shaped reasoning substrate.",
1491
+ fields: {
1492
+ schemaVersion: "string - lucern_orientation.v1",
1493
+ canonicalMentalModel: "object - concise model of Lucern as git-shaped reasoning state",
1494
+ workflow: "array - recommended branch -> investigate -> prove gate -> merge workflow",
1495
+ grammarMap: "array - primitive-to-git-analogy map for topics, campaigns, worktrees, beliefs, questions, evidence, edges, contradictions, and gates",
1496
+ firstMoves: "array - recommended first tools for a cold-start agent",
1497
+ receiptRules: "array - how to interpret candidateCounts, broadening, coverageWarning, narrativeCoverage, synthesisLints, and noDefaultGlobalScan",
1498
+ safetyRules: "array - mutation and completion rules that preserve reasoning lineage",
1499
+ toolMap: "array | undefined - situation-to-tool routing map when requested",
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",
1502
+ suggestedNextCalls: "array - safe next tool calls for the current situation"
1503
+ }
1504
+ },
1505
+ ownerModule: "reasoning-kernel",
1506
+ ontologyPrimitive: "graph",
1507
+ tier: "showcase"
1508
+ };
1509
+
1434
1510
  // ../contracts/src/tool-contracts.ontology.ts
1435
1511
  var MANAGE_WRITE_POLICY = {
1436
1512
  name: "manage_write_policy",
@@ -3940,10 +4016,34 @@ var COMPILE_CONTEXT = {
3940
4016
  type: "string",
3941
4017
  description: "Optional source kind used as a resolver signal, such as cli, worktree, commit, or docs."
3942
4018
  },
4019
+ campaign: {
4020
+ type: "number",
4021
+ description: "Optional campaign dimension seed. When supplied without topicId, the compiler fans out across all carrier topics for that campaign instead of resolving a single topic."
4022
+ },
4023
+ lane: {
4024
+ type: "string",
4025
+ description: "Optional lane dimension seed. When supplied without topicId, the compiler reads all matching worktrees and their carrier topics."
4026
+ },
4027
+ status: {
4028
+ type: "string",
4029
+ description: "Optional state/status dimension seed for worktrees and graph rows."
4030
+ },
4031
+ principalId: {
4032
+ type: "string",
4033
+ description: "Optional principal seed for work authored, touched, or owned by a human, agent, group, or service principal."
4034
+ },
4035
+ workspaceId: {
4036
+ type: "string",
4037
+ description: "Optional workspace seed used by hosted MCP and SDK clients when compiling tenant-scoped context."
4038
+ },
3943
4039
  budget: {
3944
4040
  type: "number",
3945
4041
  description: "Token budget for prompt injection planning"
3946
4042
  },
4043
+ tokenBudget: {
4044
+ type: "number",
4045
+ description: "Compatibility alias for budget. External MCP clients may send tokenBudget when requesting prompt injection planning."
4046
+ },
3947
4047
  ranking: {
3948
4048
  type: "string",
3949
4049
  description: "Ranking profile for context ordering",
@@ -3979,7 +4079,9 @@ var COMPILE_CONTEXT = {
3979
4079
  recentEvidence: "array \u2014 recent evidence ranked for this query",
3980
4080
  contradictions: "array \u2014 unresolved contradiction records",
3981
4081
  relatedEntities: "array | undefined \u2014 ranked ontological entities in scope",
3982
- 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",
3983
4085
  injectionPolicy: "object \u2014 token-budgeted section selections",
3984
4086
  diagnostics: "object \u2014 scoring and utilization telemetry"
3985
4087
  }
@@ -4634,6 +4736,7 @@ var MCP_TOOL_CONTRACTS = {
4634
4736
  update_worktree_metadata: UPDATE_WORKTREE_METADATA,
4635
4737
  identity_whoami: IDENTITY_WHOAMI,
4636
4738
  resolve_interactive_principal: RESOLVE_INTERACTIVE_PRINCIPAL,
4739
+ lucern_orient: LUCERN_ORIENT,
4637
4740
  compile_context: COMPILE_CONTEXT,
4638
4741
  record_scope_learning: RECORD_SCOPE_LEARNING,
4639
4742
  pipeline_snapshot: PIPELINE_SNAPSHOT,
@@ -10349,6 +10452,20 @@ GRAPH_INTELLIGENCE_QUERIES.map((query) => {
10349
10452
  var WEBHOOK_MAX_ATTEMPTS = 5;
10350
10453
  var WEBHOOK_RETRY_DELAYS_MS = [1e3, 5e3, 3e4, 3e5];
10351
10454
 
10455
+ // ../contracts/src/ids.contract.ts
10456
+ var PREFIXED_ID_PATTERN = /^([a-z][a-z0-9]*)_(.+)$/;
10457
+ function decodePrefixedId(id) {
10458
+ const normalized = id.trim();
10459
+ const match = PREFIXED_ID_PATTERN.exec(normalized);
10460
+ if (!match) {
10461
+ throw new Error(`Invalid prefixed ID: ${id}`);
10462
+ }
10463
+ return {
10464
+ prefix: match[1],
10465
+ value: match[2]
10466
+ };
10467
+ }
10468
+
10352
10469
  // ../contracts/src/schema-helpers/spine/tables/epistemicNodes.ts
10353
10470
  var NODE_TYPES = [
10354
10471
  "decision",
@@ -11464,6 +11581,23 @@ function defineProjection(def) {
11464
11581
 
11465
11582
  // ../contracts/src/projections/create-evidence.projection.ts
11466
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
+ });
11467
11601
  var createEvidenceInputSchemaBase = z.object({
11468
11602
  projectId: z.string().optional(),
11469
11603
  topicId: z.string().optional(),
@@ -11485,7 +11619,8 @@ var createEvidenceInputSchemaBase = z.object({
11485
11619
  targetId: z.string().optional(),
11486
11620
  targetNodeId: z.string().optional(),
11487
11621
  linkedBeliefNodeId: z.string().optional(),
11488
- evidenceRelation: z.enum(["supports", "contradicts"]).optional(),
11622
+ evidenceRelation: evidenceRelationSchema.optional(),
11623
+ beliefRelations: z.array(beliefRelationSchema).optional(),
11489
11624
  confidence: z.number().optional(),
11490
11625
  weight: z.number().optional(),
11491
11626
  reasoning: z.string().optional(),
@@ -11511,15 +11646,103 @@ function isRecord(value) {
11511
11646
  function recordValue(value) {
11512
11647
  return isRecord(value) ? value : {};
11513
11648
  }
11649
+ function normalizeTopicIdForKernel(topicId) {
11650
+ const normalized = topicId?.trim();
11651
+ if (!normalized) {
11652
+ return void 0;
11653
+ }
11654
+ try {
11655
+ const decoded = decodePrefixedId(normalized);
11656
+ return decoded.prefix === "top" ? decoded.value : normalized;
11657
+ } catch {
11658
+ return normalized;
11659
+ }
11660
+ }
11661
+ function normalizeWorktreeId(value) {
11662
+ const normalized = value?.trim();
11663
+ if (!normalized) {
11664
+ return void 0;
11665
+ }
11666
+ if (normalized.startsWith("wt_")) {
11667
+ return normalized.slice("wt_".length);
11668
+ }
11669
+ return normalized;
11670
+ }
11671
+ function targetKind(targetId) {
11672
+ const normalized = targetId?.trim();
11673
+ if (!normalized) {
11674
+ return "unknown";
11675
+ }
11676
+ if (normalized.startsWith("wt_") || /^tn[a-z0-9]+$/i.test(normalized)) {
11677
+ return "worktree";
11678
+ }
11679
+ if (normalized.startsWith("que_")) {
11680
+ return "question";
11681
+ }
11682
+ if (normalized.startsWith("bel_")) {
11683
+ return "belief";
11684
+ }
11685
+ return "unknown";
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
+ }
11514
11728
  var createEvidenceProjection = defineProjection({
11515
11729
  contractName: "create_evidence",
11516
11730
  inputSchema: createEvidenceInputSchema,
11517
11731
  project: (input) => {
11518
11732
  const text = input.text ?? input.canonicalText;
11519
11733
  const weight = typeof input.weight === "number" ? input.weight : void 0;
11734
+ const target = input.targetId ?? input.targetNodeId;
11735
+ const kind = targetKind(target);
11736
+ const linkedWorktreeId = kind === "worktree" ? normalizeWorktreeId(target) : void 0;
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
+ );
11520
11743
  return compactRecord({
11521
11744
  projectId: input.projectId,
11522
- topicId: input.topicId,
11745
+ topicId: normalizeTopicIdForKernel(input.topicId),
11523
11746
  text,
11524
11747
  title: input.title ?? text,
11525
11748
  content: input.content ?? text,
@@ -11538,13 +11761,16 @@ var createEvidenceProjection = defineProjection({
11538
11761
  source: input.source,
11539
11762
  targetId: input.targetId,
11540
11763
  targetNodeId: input.targetNodeId,
11764
+ targetKind: kind === "unknown" ? void 0 : kind,
11765
+ linkedWorktreeId,
11541
11766
  weight,
11542
11767
  reasoning: input.reasoning,
11543
11768
  rationale: input.rationale
11544
11769
  }),
11545
- linkedBeliefNodeId: input.linkedBeliefNodeId ?? input.targetNodeId ?? input.targetId,
11546
- evidenceRelation: input.evidenceRelation ?? (weight === void 0 ? void 0 : weight < 0 ? "contradicts" : "supports"),
11547
- confidence: input.confidence ?? (weight === void 0 ? void 0 : Math.min(1, Math.max(0, Math.abs(weight)))),
11770
+ linkedBeliefNodeId,
11771
+ evidenceRelation,
11772
+ confidence,
11773
+ beliefRelations: beliefRelations && beliefRelations.length > 0 ? beliefRelations : void 0,
11548
11774
  rationale: input.rationale,
11549
11775
  trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
11550
11776
  });
@@ -11573,6 +11799,16 @@ var createEvidenceProjection = defineProjection({
11573
11799
  v.literal("contradicts")
11574
11800
  )
11575
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
+ ),
11576
11812
  confidence: v.optional(v.number()),
11577
11813
  rationale: v.string(),
11578
11814
  trustedBypassAccessCheck: v.optional(v.boolean())
@@ -11806,6 +12042,12 @@ var internalSystem = {
11806
12042
  mcp: "internal",
11807
12043
  cli: "internal"
11808
12044
  };
12045
+ var internalSdkRestOnly = {
12046
+ sdk: "internal",
12047
+ rest: "internal",
12048
+ mcp: "none",
12049
+ cli: "none"
12050
+ };
11809
12051
  var publicWithInternalMcp = {
11810
12052
  sdk: "public",
11811
12053
  rest: "public",
@@ -11845,6 +12087,7 @@ function entries(names, surfaceClass, surfaceIntent, surfaces, rationale) {
11845
12087
  );
11846
12088
  }
11847
12089
  var MCP_CORE_OPERATION_NAMES = [
12090
+ "lucern_orient",
11848
12091
  "compile_context",
11849
12092
  "identity_whoami",
11850
12093
  "resolve_interactive_principal",
@@ -11854,7 +12097,6 @@ var MCP_CORE_OPERATION_NAMES = [
11854
12097
  "get_belief",
11855
12098
  "list_beliefs",
11856
12099
  "refine_belief",
11857
- "modulate_confidence",
11858
12100
  "fork_belief",
11859
12101
  "archive_belief",
11860
12102
  "search_beliefs",
@@ -12122,6 +12364,13 @@ var LUCERN_OPERATION_MANIFEST = {
12122
12364
  internalSystem,
12123
12365
  "Lucern system/background operation. Available to platform code paths, hidden from public MCP discovery."
12124
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
+ },
12125
12374
  ...entries(
12126
12375
  LEGACY_COMPAT_OPERATION_NAMES,
12127
12376
  "legacy_compat",
@@ -12473,6 +12722,14 @@ var observationContextArgs = z.object({
12473
12722
  limit: z.number().optional().describe("Maximum observations to return."),
12474
12723
  status: z.string().optional().describe("Observation status filter.")
12475
12724
  });
12725
+ var lucernOrientArgs = z.object({
12726
+ audience: z.enum(["agent", "human", "operator", "developer"]).optional().describe("Audience for the orientation primer."),
12727
+ depth: z.enum(["quick", "standard", "deep"]).optional().describe("How much orientation detail to include."),
12728
+ situation: z.string().optional().describe("Optional task or query context for suggested next calls."),
12729
+ includeExamples: z.boolean().optional().describe("Include concrete tool-call examples."),
12730
+ includeToolMap: z.boolean().optional().describe("Include situation-to-tool routing guidance."),
12731
+ includeFuture: z.boolean().optional().describe("Include future training and pedagogy capabilities.")
12732
+ });
12476
12733
  function isRecord2(value) {
12477
12734
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
12478
12735
  }
@@ -12500,6 +12757,20 @@ var observationInput = (input, context) => withUserId(
12500
12757
  context
12501
12758
  );
12502
12759
  var contextContracts = [
12760
+ surfaceContract({
12761
+ name: "lucern_orient",
12762
+ kind: "query",
12763
+ domain: "context",
12764
+ surfaceClass: "platform_public",
12765
+ path: "/context/orient",
12766
+ sdkNamespace: "context",
12767
+ sdkMethod: "lucernOrient",
12768
+ summary: "Return the canonical Lucern operator orientation primer.",
12769
+ gateway: {
12770
+ handler: "context.lucernOrient"
12771
+ },
12772
+ args: lucernOrientArgs
12773
+ }),
12503
12774
  surfaceContract({
12504
12775
  name: "compile_context",
12505
12776
  kind: "query",
@@ -12803,11 +13074,11 @@ var beliefsContracts = [
12803
13074
  name: "modulate_confidence",
12804
13075
  kind: "mutation",
12805
13076
  domain: "beliefs",
12806
- surfaceClass: "platform_public",
13077
+ surfaceClass: "platform_internal",
12807
13078
  path: "/beliefs/confidence",
12808
13079
  sdkNamespace: "beliefs",
12809
13080
  sdkMethod: "modulateConfidence",
12810
- summary: "Append a belief confidence modulation.",
13081
+ summary: "Internal SL ledger append. Public callers should attach evidence or contradiction relations instead.",
12811
13082
  convex: {
12812
13083
  module: "beliefs",
12813
13084
  functionName: "modulateConfidence",
@@ -12913,15 +13184,28 @@ var beliefsContracts = [
12913
13184
  })
12914
13185
  ];
12915
13186
  var jsonRecordSchema4 = z.record(z.unknown());
12916
- 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
+ });
12917
13198
  var createEvidenceArgs = z.object({
12918
13199
  topicId: z.string().optional().describe("Topic scope for the evidence."),
12919
13200
  text: z.string().describe("Canonical evidence text."),
12920
13201
  source: z.string().optional().describe("Source URL or source label."),
12921
13202
  sourceUrl: z.string().optional().describe("Canonical source URL."),
12922
- targetId: z.string().optional().describe("Belief or question identifier to link immediately."),
13203
+ targetId: z.string().optional().describe("Belief, question, or worktree identifier to link or preserve on the evidence record."),
12923
13204
  linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
12924
- 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
+ ),
12925
13209
  confidence: z.number().optional().describe("Confidence in the evidence relation."),
12926
13210
  weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
12927
13211
  metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
@@ -12952,11 +13236,6 @@ var addEvidenceArgs = z.object({
12952
13236
  contentType: z.string().optional().describe("Content format or MIME hint."),
12953
13237
  metadata: jsonRecordSchema4.optional().describe("Optional metadata merged into the evidence node.")
12954
13238
  });
12955
- var evidenceIdInput = (input) => compactRecord4({
12956
- evidenceId: input.evidenceId,
12957
- insightId: input.insightId,
12958
- nodeId: input.nodeId ?? input.id ?? input.evidenceId
12959
- });
12960
13239
  var createEvidenceInput = (input, context) => {
12961
13240
  const parsed = createEvidenceProjection.inputSchema.safeParse(input);
12962
13241
  if (!parsed.success) {
@@ -12969,6 +13248,30 @@ var createEvidenceInput = (input, context) => {
12969
13248
  context
12970
13249
  );
12971
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
+ };
12972
13275
  var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
12973
13276
  compactRecord4({
12974
13277
  fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
@@ -13070,11 +13373,8 @@ var evidenceContracts = [
13070
13373
  sdkNamespace: "evidence",
13071
13374
  sdkMethod: "getEvidence",
13072
13375
  summary: "Get evidence.",
13073
- convex: {
13074
- module: "evidence",
13075
- functionName: "getById",
13076
- kind: "query",
13077
- inputProjection: evidenceIdInput
13376
+ gateway: {
13377
+ handler: "evidence.get"
13078
13378
  }
13079
13379
  }),
13080
13380
  surfaceContract({
@@ -13100,17 +13400,8 @@ var evidenceContracts = [
13100
13400
  sdkNamespace: "evidence",
13101
13401
  sdkMethod: "searchEvidence",
13102
13402
  summary: "Search evidence.",
13103
- convex: {
13104
- module: "nodes",
13105
- functionName: "search",
13106
- kind: "query",
13107
- inputProjection: (input) => compactRecord4({
13108
- searchQuery: input.searchQuery ?? input.q ?? input.query,
13109
- projectId: input.projectId,
13110
- topicId: input.topicId,
13111
- nodeType: "evidence",
13112
- limit: input.limit
13113
- })
13403
+ gateway: {
13404
+ handler: "evidence.search"
13114
13405
  }
13115
13406
  }),
13116
13407
  surfaceContract({
@@ -13123,10 +13414,10 @@ var evidenceContracts = [
13123
13414
  sdkMethod: "linkEvidenceToBelief",
13124
13415
  summary: "Link evidence to a belief.",
13125
13416
  convex: {
13126
- module: "edges",
13127
- functionName: "create",
13417
+ module: "beliefs",
13418
+ functionName: "linkEvidence",
13128
13419
  kind: "mutation",
13129
- inputProjection: linkEvidenceToBeliefEdgeInput
13420
+ inputProjection: linkEvidenceToBeliefInput
13130
13421
  }
13131
13422
  }),
13132
13423
  surfaceContract({
@@ -13698,10 +13989,8 @@ var topicsContracts = [
13698
13989
  sdkNamespace: "topics",
13699
13990
  sdkMethod: "getTopicGraphSpine",
13700
13991
  summary: "Verify topic nodes and parent-child graph edges.",
13701
- convex: {
13702
- module: "topics",
13703
- functionName: "getTopicGraphSpine",
13704
- kind: "query"
13992
+ gateway: {
13993
+ handler: "topics.graphSpine"
13705
13994
  },
13706
13995
  args: getTopicGraphSpineArgs
13707
13996
  })
@@ -15408,10 +15697,8 @@ var graphContracts = [
15408
15697
  sdkNamespace: "graphAnalysis",
15409
15698
  sdkMethod: "listGraphIntelligenceQueries",
15410
15699
  summary: "List Graph Intelligence query catalog entries.",
15411
- convex: {
15412
- module: "contextCompiler",
15413
- functionName: "listGraphIntelligenceQueries",
15414
- kind: "query"
15700
+ gateway: {
15701
+ handler: "graph.listIntelligenceQueries"
15415
15702
  },
15416
15703
  args: graphIntelligenceCatalogArgs
15417
15704
  }),