@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
package/dist/index.js
CHANGED
|
@@ -11783,11 +11783,55 @@ var createEvidenceInputSchemaBase = z.object({
|
|
|
11783
11783
|
metadata: jsonRecordSchema.optional(),
|
|
11784
11784
|
trustedBypassAccessCheck: z.boolean().optional()
|
|
11785
11785
|
}).passthrough();
|
|
11786
|
-
|
|
11787
|
-
(
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
-
|
|
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
|
+
});
|
|
11791
11835
|
}
|
|
11792
11836
|
);
|
|
11793
11837
|
function compactRecord(input) {
|
|
@@ -11846,7 +11890,7 @@ function normalizeRelation(value, weight) {
|
|
|
11846
11890
|
if (value === "contradicts" || value === "contradicting") {
|
|
11847
11891
|
return "contradicts";
|
|
11848
11892
|
}
|
|
11849
|
-
if (weight === void 0) {
|
|
11893
|
+
if (weight === void 0 || !hasNonzeroWeight(weight)) {
|
|
11850
11894
|
return void 0;
|
|
11851
11895
|
}
|
|
11852
11896
|
return weight < 0 ? "contradicts" : "supports";
|
|
@@ -13355,14 +13399,18 @@ var createEvidenceArgs = z.object({
|
|
|
13355
13399
|
text: z.string().describe("Canonical evidence text."),
|
|
13356
13400
|
source: z.string().optional().describe("Source URL or source label."),
|
|
13357
13401
|
sourceUrl: z.string().optional().describe("Canonical source URL."),
|
|
13358
|
-
targetId: z.string().optional().describe(
|
|
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
|
+
),
|
|
13359
13405
|
linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
|
|
13360
|
-
evidenceRelation: evidenceRelationSchema2.optional().describe(
|
|
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
|
+
),
|
|
13361
13409
|
beliefRelations: z.array(beliefRelationSchema2).optional().describe(
|
|
13362
13410
|
"Additional belief relations for one evidence record. Use when the same evidence supports or contradicts multiple beliefs."
|
|
13363
13411
|
),
|
|
13364
13412
|
confidence: z.number().optional().describe("Confidence in the evidence relation."),
|
|
13365
|
-
weight: z.number().optional().describe("
|
|
13413
|
+
weight: z.number().optional().describe("Nonzero support weight from -1.0 to +1.0."),
|
|
13366
13414
|
metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
|
|
13367
13415
|
rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
|
|
13368
13416
|
reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
|
|
@@ -13404,13 +13452,18 @@ var createEvidenceInput = (input, context) => {
|
|
|
13404
13452
|
);
|
|
13405
13453
|
};
|
|
13406
13454
|
function relationWeight(input) {
|
|
13407
|
-
if (typeof input.weight === "number") {
|
|
13455
|
+
if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0) {
|
|
13408
13456
|
return input.weight;
|
|
13409
13457
|
}
|
|
13410
|
-
const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
|
|
13411
13458
|
const relation = String(
|
|
13412
13459
|
input.evidenceRelation ?? input.relation ?? input.type ?? ""
|
|
13413
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;
|
|
13414
13467
|
return relation === "contradicts" || relation === "contradicting" ? -confidence : confidence;
|
|
13415
13468
|
}
|
|
13416
13469
|
var linkEvidenceToBeliefInput = (input, context) => {
|
|
@@ -13437,7 +13490,7 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
|
|
|
13437
13490
|
)}:${String(
|
|
13438
13491
|
input.beliefNodeId ?? input.beliefId ?? input.targetId
|
|
13439
13492
|
)}:informs`,
|
|
13440
|
-
weight:
|
|
13493
|
+
weight: relationWeight(input),
|
|
13441
13494
|
context: input.rationale ?? input.context,
|
|
13442
13495
|
skipLayerValidation: true,
|
|
13443
13496
|
topicId: input.topicId,
|