@lucern/events 1.0.13 → 1.0.15
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 +65 -12
- package/dist/index.js.map +1 -1
- package/dist/outbox.js +65 -12
- package/dist/outbox.js.map +1 -1
- package/dist/proof-attestation.json +1 -1
- package/dist/types.js +65 -12
- package/dist/types.js.map +1 -1
- package/dist/webhook-delivery-machine.js +65 -12
- package/dist/webhook-delivery-machine.js.map +1 -1
- package/dist/webhooks.js +65 -12
- package/dist/webhooks.js.map +1 -1
- package/package.json +2 -2
|
@@ -11628,11 +11628,55 @@ var createEvidenceInputSchemaBase = z.object({
|
|
|
11628
11628
|
metadata: jsonRecordSchema.optional(),
|
|
11629
11629
|
trustedBypassAccessCheck: z.boolean().optional()
|
|
11630
11630
|
}).passthrough();
|
|
11631
|
-
|
|
11632
|
-
(
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
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
|
+
});
|
|
11636
11680
|
}
|
|
11637
11681
|
);
|
|
11638
11682
|
function compactRecord(input) {
|
|
@@ -11691,7 +11735,7 @@ function normalizeRelation(value, weight) {
|
|
|
11691
11735
|
if (value === "contradicts" || value === "contradicting") {
|
|
11692
11736
|
return "contradicts";
|
|
11693
11737
|
}
|
|
11694
|
-
if (weight === void 0) {
|
|
11738
|
+
if (weight === void 0 || !hasNonzeroWeight(weight)) {
|
|
11695
11739
|
return void 0;
|
|
11696
11740
|
}
|
|
11697
11741
|
return weight < 0 ? "contradicts" : "supports";
|
|
@@ -13200,14 +13244,18 @@ var createEvidenceArgs = z.object({
|
|
|
13200
13244
|
text: z.string().describe("Canonical evidence text."),
|
|
13201
13245
|
source: z.string().optional().describe("Source URL or source label."),
|
|
13202
13246
|
sourceUrl: z.string().optional().describe("Canonical source URL."),
|
|
13203
|
-
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
|
+
),
|
|
13204
13250
|
linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
|
|
13205
|
-
evidenceRelation: evidenceRelationSchema2.optional().describe(
|
|
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
|
+
),
|
|
13206
13254
|
beliefRelations: z.array(beliefRelationSchema2).optional().describe(
|
|
13207
13255
|
"Additional belief relations for one evidence record. Use when the same evidence supports or contradicts multiple beliefs."
|
|
13208
13256
|
),
|
|
13209
13257
|
confidence: z.number().optional().describe("Confidence in the evidence relation."),
|
|
13210
|
-
weight: z.number().optional().describe("
|
|
13258
|
+
weight: z.number().optional().describe("Nonzero support weight from -1.0 to +1.0."),
|
|
13211
13259
|
metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
|
|
13212
13260
|
rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
|
|
13213
13261
|
reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
|
|
@@ -13249,13 +13297,18 @@ var createEvidenceInput = (input, context) => {
|
|
|
13249
13297
|
);
|
|
13250
13298
|
};
|
|
13251
13299
|
function relationWeight(input) {
|
|
13252
|
-
if (typeof input.weight === "number") {
|
|
13300
|
+
if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0) {
|
|
13253
13301
|
return input.weight;
|
|
13254
13302
|
}
|
|
13255
|
-
const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
|
|
13256
13303
|
const relation = String(
|
|
13257
13304
|
input.evidenceRelation ?? input.relation ?? input.type ?? ""
|
|
13258
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;
|
|
13259
13312
|
return relation === "contradicts" || relation === "contradicting" ? -confidence : confidence;
|
|
13260
13313
|
}
|
|
13261
13314
|
var linkEvidenceToBeliefInput = (input, context) => {
|
|
@@ -13282,7 +13335,7 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
|
|
|
13282
13335
|
)}:${String(
|
|
13283
13336
|
input.beliefNodeId ?? input.beliefId ?? input.targetId
|
|
13284
13337
|
)}:informs`,
|
|
13285
|
-
weight:
|
|
13338
|
+
weight: relationWeight(input),
|
|
13286
13339
|
context: input.rationale ?? input.context,
|
|
13287
13340
|
skipLayerValidation: true,
|
|
13288
13341
|
topicId: input.topicId,
|