@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 +229 -27
- package/dist/index.js.map +1 -1
- package/dist/outbox.js +229 -27
- package/dist/outbox.js.map +1 -1
- package/dist/proof-attestation.json +1 -1
- package/dist/types.js +229 -27
- package/dist/types.js.map +1 -1
- package/dist/webhook-delivery-machine.js +229 -27
- package/dist/webhook-delivery-machine.js.map +1 -1
- package/dist/webhooks.js +229 -27
- package/dist/webhooks.js.map +1 -1
- package/package.json +2 -2
|
@@ -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: "
|
|
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"
|
|
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)`;
|
|
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: "
|
|
807
|
+
description: "Internal-only subjective-logic ledger append. Like `git commit` to the credence log for the scoring engine \u2014 never an operator-facing way to assert confidence. Agents, SDK callers, CLI users, and MCP clients must instead create or link evidence with `evidenceRelation: supports|contradicts`; the kernel derives the next opinion from that evidence. This compatibility primitive is reserved for governed system scoring paths that already hold a full subjective-logic tuple and truth-bearing provenance.",
|
|
786
808
|
parameters: {
|
|
787
809
|
nodeId: { type: "string", description: "The belief to score" },
|
|
788
810
|
belief: {
|
|
@@ -1472,10 +1494,11 @@ var LUCERN_ORIENT = {
|
|
|
1472
1494
|
workflow: "array - recommended branch -> investigate -> prove gate -> merge workflow",
|
|
1473
1495
|
grammarMap: "array - primitive-to-git-analogy map for topics, campaigns, worktrees, beliefs, questions, evidence, edges, contradictions, and gates",
|
|
1474
1496
|
firstMoves: "array - recommended first tools for a cold-start agent",
|
|
1475
|
-
receiptRules: "array - how to interpret candidateCounts, broadening, coverageWarning, and noDefaultGlobalScan",
|
|
1497
|
+
receiptRules: "array - how to interpret candidateCounts, broadening, coverageWarning, narrativeCoverage, synthesisLints, and noDefaultGlobalScan",
|
|
1476
1498
|
safetyRules: "array - mutation and completion rules that preserve reasoning lineage",
|
|
1477
1499
|
toolMap: "array | undefined - situation-to-tool routing map when requested",
|
|
1478
1500
|
examples: "array | undefined - concrete tool-call examples when requested",
|
|
1501
|
+
futureCapabilities: "array | undefined - exemplar, gauntlet, trace-corpus, and native-model-training capabilities when requested",
|
|
1479
1502
|
suggestedNextCalls: "array - safe next tool calls for the current situation"
|
|
1480
1503
|
}
|
|
1481
1504
|
},
|
|
@@ -4056,7 +4079,9 @@ var COMPILE_CONTEXT = {
|
|
|
4056
4079
|
recentEvidence: "array \u2014 recent evidence ranked for this query",
|
|
4057
4080
|
contradictions: "array \u2014 unresolved contradiction records",
|
|
4058
4081
|
relatedEntities: "array | undefined \u2014 ranked ontological entities in scope",
|
|
4059
|
-
contextNarrative: "array \u2014
|
|
4082
|
+
contextNarrative: "array \u2014 ordered synthesis blocks with kind/text, starting with executive_summary and canonical narrative blocks before raw objects",
|
|
4083
|
+
retrievalReceipt: "object \u2014 candidateCounts, coverageWarning, narrativeCoverage, synthesisLints, and suggestedNextActions",
|
|
4084
|
+
narrativeCoverage: "object \u2014 recordsSynthesized, recordsNamed, recordsOmitted, and blocksEmitted for the narrative",
|
|
4060
4085
|
injectionPolicy: "object \u2014 token-budgeted section selections",
|
|
4061
4086
|
diagnostics: "object \u2014 scoring and utilization telemetry"
|
|
4062
4087
|
}
|
|
@@ -11556,6 +11581,23 @@ function defineProjection(def) {
|
|
|
11556
11581
|
|
|
11557
11582
|
// ../contracts/src/projections/create-evidence.projection.ts
|
|
11558
11583
|
var jsonRecordSchema = z.record(z.unknown());
|
|
11584
|
+
var evidenceRelationSchema = z.enum(["supports", "contradicts"]);
|
|
11585
|
+
var evidenceRelationAliasSchema = z.enum([
|
|
11586
|
+
"supports",
|
|
11587
|
+
"contradicts",
|
|
11588
|
+
"supporting",
|
|
11589
|
+
"contradicting"
|
|
11590
|
+
]);
|
|
11591
|
+
var beliefRelationSchema = z.object({
|
|
11592
|
+
beliefId: z.string().optional(),
|
|
11593
|
+
beliefNodeId: z.string().optional(),
|
|
11594
|
+
targetId: z.string().optional(),
|
|
11595
|
+
relation: evidenceRelationAliasSchema.optional(),
|
|
11596
|
+
evidenceRelation: evidenceRelationSchema.optional(),
|
|
11597
|
+
confidence: z.number().optional(),
|
|
11598
|
+
weight: z.number().optional(),
|
|
11599
|
+
rationale: z.string().optional()
|
|
11600
|
+
});
|
|
11559
11601
|
var createEvidenceInputSchemaBase = z.object({
|
|
11560
11602
|
projectId: z.string().optional(),
|
|
11561
11603
|
topicId: z.string().optional(),
|
|
@@ -11577,7 +11619,8 @@ var createEvidenceInputSchemaBase = z.object({
|
|
|
11577
11619
|
targetId: z.string().optional(),
|
|
11578
11620
|
targetNodeId: z.string().optional(),
|
|
11579
11621
|
linkedBeliefNodeId: z.string().optional(),
|
|
11580
|
-
evidenceRelation:
|
|
11622
|
+
evidenceRelation: evidenceRelationSchema.optional(),
|
|
11623
|
+
beliefRelations: z.array(beliefRelationSchema).optional(),
|
|
11581
11624
|
confidence: z.number().optional(),
|
|
11582
11625
|
weight: z.number().optional(),
|
|
11583
11626
|
reasoning: z.string().optional(),
|
|
@@ -11585,11 +11628,55 @@ var createEvidenceInputSchemaBase = z.object({
|
|
|
11585
11628
|
metadata: jsonRecordSchema.optional(),
|
|
11586
11629
|
trustedBypassAccessCheck: z.boolean().optional()
|
|
11587
11630
|
}).passthrough();
|
|
11588
|
-
|
|
11589
|
-
(
|
|
11590
|
-
|
|
11591
|
-
|
|
11592
|
-
|
|
11631
|
+
function hasNonzeroWeight(value) {
|
|
11632
|
+
return typeof value === "number" && Number.isFinite(value) && value !== 0;
|
|
11633
|
+
}
|
|
11634
|
+
function hasRelationSignal(value, weight) {
|
|
11635
|
+
return Boolean(normalizeRelation(value, weight));
|
|
11636
|
+
}
|
|
11637
|
+
var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
|
|
11638
|
+
(input, ctx) => {
|
|
11639
|
+
if (!input.text && !input.canonicalText) {
|
|
11640
|
+
ctx.addIssue({
|
|
11641
|
+
code: z.ZodIssueCode.custom,
|
|
11642
|
+
message: "create_evidence requires text",
|
|
11643
|
+
path: ["text"]
|
|
11644
|
+
});
|
|
11645
|
+
}
|
|
11646
|
+
const target = input.targetId ?? input.targetNodeId;
|
|
11647
|
+
const kind = targetKind(target);
|
|
11648
|
+
const linksPrimaryBelief = Boolean(
|
|
11649
|
+
input.linkedBeliefNodeId || kind === "belief" || kind === "unknown" && target
|
|
11650
|
+
);
|
|
11651
|
+
const weight = typeof input.weight === "number" ? input.weight : void 0;
|
|
11652
|
+
if (linksPrimaryBelief && !hasRelationSignal(input.evidenceRelation, weight)) {
|
|
11653
|
+
ctx.addIssue({
|
|
11654
|
+
code: z.ZodIssueCode.custom,
|
|
11655
|
+
message: "belief-targeted evidence requires evidenceRelation='supports'|'contradicts' or a nonzero signed weight",
|
|
11656
|
+
path: ["evidenceRelation"]
|
|
11657
|
+
});
|
|
11658
|
+
}
|
|
11659
|
+
input.beliefRelations?.forEach((relation, index) => {
|
|
11660
|
+
const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
|
|
11661
|
+
if (!beliefNodeId) {
|
|
11662
|
+
ctx.addIssue({
|
|
11663
|
+
code: z.ZodIssueCode.custom,
|
|
11664
|
+
message: "beliefRelations entries require beliefId, beliefNodeId, or targetId",
|
|
11665
|
+
path: ["beliefRelations", index, "beliefNodeId"]
|
|
11666
|
+
});
|
|
11667
|
+
}
|
|
11668
|
+
const relationWeight2 = typeof relation.weight === "number" ? relation.weight : void 0;
|
|
11669
|
+
if (beliefNodeId && !hasRelationSignal(
|
|
11670
|
+
relation.evidenceRelation ?? relation.relation,
|
|
11671
|
+
relationWeight2
|
|
11672
|
+
)) {
|
|
11673
|
+
ctx.addIssue({
|
|
11674
|
+
code: z.ZodIssueCode.custom,
|
|
11675
|
+
message: "beliefRelations entries require evidenceRelation='supports'|'contradicts' or a nonzero signed weight",
|
|
11676
|
+
path: ["beliefRelations", index, "evidenceRelation"]
|
|
11677
|
+
});
|
|
11678
|
+
}
|
|
11679
|
+
});
|
|
11593
11680
|
}
|
|
11594
11681
|
);
|
|
11595
11682
|
function compactRecord(input) {
|
|
@@ -11641,6 +11728,47 @@ function targetKind(targetId) {
|
|
|
11641
11728
|
}
|
|
11642
11729
|
return "unknown";
|
|
11643
11730
|
}
|
|
11731
|
+
function normalizeRelation(value, weight) {
|
|
11732
|
+
if (value === "supports" || value === "supporting") {
|
|
11733
|
+
return "supports";
|
|
11734
|
+
}
|
|
11735
|
+
if (value === "contradicts" || value === "contradicting") {
|
|
11736
|
+
return "contradicts";
|
|
11737
|
+
}
|
|
11738
|
+
if (weight === void 0 || !hasNonzeroWeight(weight)) {
|
|
11739
|
+
return void 0;
|
|
11740
|
+
}
|
|
11741
|
+
return weight < 0 ? "contradicts" : "supports";
|
|
11742
|
+
}
|
|
11743
|
+
function normalizeConfidence(confidence, weight) {
|
|
11744
|
+
if (confidence !== void 0) {
|
|
11745
|
+
return Math.min(1, Math.max(0, confidence));
|
|
11746
|
+
}
|
|
11747
|
+
if (weight === void 0) {
|
|
11748
|
+
return void 0;
|
|
11749
|
+
}
|
|
11750
|
+
return Math.min(1, Math.max(0, Math.abs(weight)));
|
|
11751
|
+
}
|
|
11752
|
+
function normalizeBeliefRelation(relation) {
|
|
11753
|
+
const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
|
|
11754
|
+
if (!beliefNodeId) {
|
|
11755
|
+
return void 0;
|
|
11756
|
+
}
|
|
11757
|
+
const weight = typeof relation.weight === "number" ? relation.weight : void 0;
|
|
11758
|
+
const evidenceRelation = normalizeRelation(
|
|
11759
|
+
relation.evidenceRelation ?? relation.relation,
|
|
11760
|
+
weight
|
|
11761
|
+
);
|
|
11762
|
+
if (!evidenceRelation) {
|
|
11763
|
+
return void 0;
|
|
11764
|
+
}
|
|
11765
|
+
return compactRecord({
|
|
11766
|
+
beliefNodeId,
|
|
11767
|
+
relation: evidenceRelation,
|
|
11768
|
+
confidence: normalizeConfidence(relation.confidence, weight),
|
|
11769
|
+
rationale: relation.rationale
|
|
11770
|
+
});
|
|
11771
|
+
}
|
|
11644
11772
|
var createEvidenceProjection = defineProjection({
|
|
11645
11773
|
contractName: "create_evidence",
|
|
11646
11774
|
inputSchema: createEvidenceInputSchema,
|
|
@@ -11651,6 +11779,11 @@ var createEvidenceProjection = defineProjection({
|
|
|
11651
11779
|
const kind = targetKind(target);
|
|
11652
11780
|
const linkedWorktreeId = kind === "worktree" ? normalizeWorktreeId(target) : void 0;
|
|
11653
11781
|
const linkedBeliefNodeId = input.linkedBeliefNodeId ?? (kind === "belief" || kind === "unknown" ? input.targetNodeId ?? input.targetId : void 0);
|
|
11782
|
+
const evidenceRelation = linkedBeliefNodeId ? normalizeRelation(input.evidenceRelation, weight) : void 0;
|
|
11783
|
+
const confidence = evidenceRelation ? normalizeConfidence(input.confidence, weight) : void 0;
|
|
11784
|
+
const beliefRelations = input.beliefRelations?.map(normalizeBeliefRelation).filter(
|
|
11785
|
+
(relation) => relation !== void 0
|
|
11786
|
+
);
|
|
11654
11787
|
return compactRecord({
|
|
11655
11788
|
projectId: input.projectId,
|
|
11656
11789
|
topicId: normalizeTopicIdForKernel(input.topicId),
|
|
@@ -11679,8 +11812,9 @@ var createEvidenceProjection = defineProjection({
|
|
|
11679
11812
|
rationale: input.rationale
|
|
11680
11813
|
}),
|
|
11681
11814
|
linkedBeliefNodeId,
|
|
11682
|
-
evidenceRelation
|
|
11683
|
-
confidence
|
|
11815
|
+
evidenceRelation,
|
|
11816
|
+
confidence,
|
|
11817
|
+
beliefRelations: beliefRelations && beliefRelations.length > 0 ? beliefRelations : void 0,
|
|
11684
11818
|
rationale: input.rationale,
|
|
11685
11819
|
trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
|
|
11686
11820
|
});
|
|
@@ -11709,6 +11843,16 @@ var createEvidenceProjection = defineProjection({
|
|
|
11709
11843
|
v.literal("contradicts")
|
|
11710
11844
|
)
|
|
11711
11845
|
),
|
|
11846
|
+
beliefRelations: v.optional(
|
|
11847
|
+
v.array(
|
|
11848
|
+
v.object({
|
|
11849
|
+
beliefNodeId: v.string(),
|
|
11850
|
+
relation: v.union(v.literal("supports"), v.literal("contradicts")),
|
|
11851
|
+
confidence: v.optional(v.number()),
|
|
11852
|
+
rationale: v.optional(v.string())
|
|
11853
|
+
})
|
|
11854
|
+
)
|
|
11855
|
+
),
|
|
11712
11856
|
confidence: v.optional(v.number()),
|
|
11713
11857
|
rationale: v.string(),
|
|
11714
11858
|
trustedBypassAccessCheck: v.optional(v.boolean())
|
|
@@ -11942,6 +12086,12 @@ var internalSystem = {
|
|
|
11942
12086
|
mcp: "internal",
|
|
11943
12087
|
cli: "internal"
|
|
11944
12088
|
};
|
|
12089
|
+
var internalSdkRestOnly = {
|
|
12090
|
+
sdk: "internal",
|
|
12091
|
+
rest: "internal",
|
|
12092
|
+
mcp: "none",
|
|
12093
|
+
cli: "none"
|
|
12094
|
+
};
|
|
11945
12095
|
var publicWithInternalMcp = {
|
|
11946
12096
|
sdk: "public",
|
|
11947
12097
|
rest: "public",
|
|
@@ -11991,7 +12141,6 @@ var MCP_CORE_OPERATION_NAMES = [
|
|
|
11991
12141
|
"get_belief",
|
|
11992
12142
|
"list_beliefs",
|
|
11993
12143
|
"refine_belief",
|
|
11994
|
-
"modulate_confidence",
|
|
11995
12144
|
"fork_belief",
|
|
11996
12145
|
"archive_belief",
|
|
11997
12146
|
"search_beliefs",
|
|
@@ -12259,6 +12408,13 @@ var LUCERN_OPERATION_MANIFEST = {
|
|
|
12259
12408
|
internalSystem,
|
|
12260
12409
|
"Lucern system/background operation. Available to platform code paths, hidden from public MCP discovery."
|
|
12261
12410
|
),
|
|
12411
|
+
modulate_confidence: {
|
|
12412
|
+
name: "modulate_confidence",
|
|
12413
|
+
surfaceClass: "platform_internal",
|
|
12414
|
+
surfaceIntent: "system",
|
|
12415
|
+
surfaces: internalSdkRestOnly,
|
|
12416
|
+
rationale: "Internal SL ledger append primitive. Public callers attach evidence or contradiction relations; confidence is derived algorithmically."
|
|
12417
|
+
},
|
|
12262
12418
|
...entries(
|
|
12263
12419
|
LEGACY_COMPAT_OPERATION_NAMES,
|
|
12264
12420
|
"legacy_compat",
|
|
@@ -12962,11 +13118,11 @@ var beliefsContracts = [
|
|
|
12962
13118
|
name: "modulate_confidence",
|
|
12963
13119
|
kind: "mutation",
|
|
12964
13120
|
domain: "beliefs",
|
|
12965
|
-
surfaceClass: "
|
|
13121
|
+
surfaceClass: "platform_internal",
|
|
12966
13122
|
path: "/beliefs/confidence",
|
|
12967
13123
|
sdkNamespace: "beliefs",
|
|
12968
13124
|
sdkMethod: "modulateConfidence",
|
|
12969
|
-
summary: "
|
|
13125
|
+
summary: "Internal SL ledger append. Public callers should attach evidence or contradiction relations instead.",
|
|
12970
13126
|
convex: {
|
|
12971
13127
|
module: "beliefs",
|
|
12972
13128
|
functionName: "modulateConfidence",
|
|
@@ -13072,17 +13228,34 @@ var beliefsContracts = [
|
|
|
13072
13228
|
})
|
|
13073
13229
|
];
|
|
13074
13230
|
var jsonRecordSchema4 = z.record(z.unknown());
|
|
13075
|
-
var
|
|
13231
|
+
var evidenceRelationSchema2 = z.enum(["supports", "contradicts"]);
|
|
13232
|
+
var beliefRelationSchema2 = z.object({
|
|
13233
|
+
beliefId: z.string().optional().describe("Belief ID this evidence bears on."),
|
|
13234
|
+
beliefNodeId: z.string().optional().describe("Belief node ID this evidence bears on."),
|
|
13235
|
+
targetId: z.string().optional().describe("Belief target ID alias for beliefId/beliefNodeId."),
|
|
13236
|
+
relation: z.enum(["supports", "contradicts", "supporting", "contradicting"]).optional().describe("Relation alias for how the evidence bears on the belief."),
|
|
13237
|
+
evidenceRelation: evidenceRelationSchema2.optional().describe("Canonical relation: supports or contradicts."),
|
|
13238
|
+
confidence: z.number().optional().describe("Confidence in this evidence-to-belief relation."),
|
|
13239
|
+
weight: z.number().optional().describe("Support weight from -1.0 to +1.0 for this belief."),
|
|
13240
|
+
rationale: z.string().optional().describe("Why this relation exists.")
|
|
13241
|
+
});
|
|
13076
13242
|
var createEvidenceArgs = z.object({
|
|
13077
13243
|
topicId: z.string().optional().describe("Topic scope for the evidence."),
|
|
13078
13244
|
text: z.string().describe("Canonical evidence text."),
|
|
13079
13245
|
source: z.string().optional().describe("Source URL or source label."),
|
|
13080
13246
|
sourceUrl: z.string().optional().describe("Canonical source URL."),
|
|
13081
|
-
targetId: z.string().optional().describe(
|
|
13247
|
+
targetId: z.string().optional().describe(
|
|
13248
|
+
"Belief, question, or worktree identifier to link or preserve on the evidence record. Belief targets require evidenceRelation or a nonzero signed weight."
|
|
13249
|
+
),
|
|
13082
13250
|
linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
|
|
13083
|
-
evidenceRelation:
|
|
13251
|
+
evidenceRelation: evidenceRelationSchema2.optional().describe(
|
|
13252
|
+
"How the evidence relates to the linked belief. Use supports for proof/fixes; use contradicts for bugs, regressions, or falsifying observations."
|
|
13253
|
+
),
|
|
13254
|
+
beliefRelations: z.array(beliefRelationSchema2).optional().describe(
|
|
13255
|
+
"Additional belief relations for one evidence record. Use when the same evidence supports or contradicts multiple beliefs."
|
|
13256
|
+
),
|
|
13084
13257
|
confidence: z.number().optional().describe("Confidence in the evidence relation."),
|
|
13085
|
-
weight: z.number().optional().describe("
|
|
13258
|
+
weight: z.number().optional().describe("Nonzero support weight from -1.0 to +1.0."),
|
|
13086
13259
|
metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
|
|
13087
13260
|
rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
|
|
13088
13261
|
reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
|
|
@@ -13123,6 +13296,35 @@ var createEvidenceInput = (input, context) => {
|
|
|
13123
13296
|
context
|
|
13124
13297
|
);
|
|
13125
13298
|
};
|
|
13299
|
+
function relationWeight(input) {
|
|
13300
|
+
if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0) {
|
|
13301
|
+
return input.weight;
|
|
13302
|
+
}
|
|
13303
|
+
const relation = String(
|
|
13304
|
+
input.evidenceRelation ?? input.relation ?? input.type ?? ""
|
|
13305
|
+
);
|
|
13306
|
+
if (relation !== "supports" && relation !== "supporting" && relation !== "contradicts" && relation !== "contradicting") {
|
|
13307
|
+
throw new Error(
|
|
13308
|
+
"Belief evidence links require evidenceRelation='supports'|'contradicts' or a nonzero signed weight."
|
|
13309
|
+
);
|
|
13310
|
+
}
|
|
13311
|
+
const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
|
|
13312
|
+
return relation === "contradicts" || relation === "contradicting" ? -confidence : confidence;
|
|
13313
|
+
}
|
|
13314
|
+
var linkEvidenceToBeliefInput = (input, context) => {
|
|
13315
|
+
const weight = relationWeight(input);
|
|
13316
|
+
return withUserId(
|
|
13317
|
+
compactRecord4({
|
|
13318
|
+
beliefNodeId: input.beliefNodeId ?? input.beliefId ?? input.targetId,
|
|
13319
|
+
insightId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
|
|
13320
|
+
type: weight < 0 ? "contradicting" : "supporting",
|
|
13321
|
+
confidence: Math.min(1, Math.abs(weight)),
|
|
13322
|
+
rationale: input.rationale ?? input.context,
|
|
13323
|
+
trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
|
|
13324
|
+
}),
|
|
13325
|
+
context
|
|
13326
|
+
);
|
|
13327
|
+
};
|
|
13126
13328
|
var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
|
|
13127
13329
|
compactRecord4({
|
|
13128
13330
|
fromNodeId: input.insightId ?? input.evidenceNodeId ?? input.evidenceId,
|
|
@@ -13133,7 +13335,7 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
|
|
|
13133
13335
|
)}:${String(
|
|
13134
13336
|
input.beliefNodeId ?? input.beliefId ?? input.targetId
|
|
13135
13337
|
)}:informs`,
|
|
13136
|
-
weight:
|
|
13338
|
+
weight: relationWeight(input),
|
|
13137
13339
|
context: input.rationale ?? input.context,
|
|
13138
13340
|
skipLayerValidation: true,
|
|
13139
13341
|
topicId: input.topicId,
|
|
@@ -13265,10 +13467,10 @@ var evidenceContracts = [
|
|
|
13265
13467
|
sdkMethod: "linkEvidenceToBelief",
|
|
13266
13468
|
summary: "Link evidence to a belief.",
|
|
13267
13469
|
convex: {
|
|
13268
|
-
module: "
|
|
13269
|
-
functionName: "
|
|
13470
|
+
module: "beliefs",
|
|
13471
|
+
functionName: "linkEvidence",
|
|
13270
13472
|
kind: "mutation",
|
|
13271
|
-
inputProjection:
|
|
13473
|
+
inputProjection: linkEvidenceToBeliefInput
|
|
13272
13474
|
}
|
|
13273
13475
|
}),
|
|
13274
13476
|
surfaceContract({
|