@lucern/events 1.0.13 → 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.
@@ -41,5 +41,5 @@
41
41
  "convex-validators",
42
42
  "proof-attestation"
43
43
  ],
44
- "signedAt": 1780290788497
44
+ "signedAt": 1780303941512
45
45
  }
package/dist/types.js CHANGED
@@ -11666,11 +11666,55 @@ var createEvidenceInputSchemaBase = z.object({
11666
11666
  metadata: jsonRecordSchema.optional(),
11667
11667
  trustedBypassAccessCheck: z.boolean().optional()
11668
11668
  }).passthrough();
11669
- var createEvidenceInputSchema = createEvidenceInputSchemaBase.refine(
11670
- (input) => Boolean(input.text ?? input.canonicalText),
11671
- {
11672
- message: "create_evidence requires text",
11673
- path: ["text"]
11669
+ function hasNonzeroWeight(value) {
11670
+ return typeof value === "number" && Number.isFinite(value) && value !== 0;
11671
+ }
11672
+ function hasRelationSignal(value, weight) {
11673
+ return Boolean(normalizeRelation(value, weight));
11674
+ }
11675
+ var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
11676
+ (input, ctx) => {
11677
+ if (!input.text && !input.canonicalText) {
11678
+ ctx.addIssue({
11679
+ code: z.ZodIssueCode.custom,
11680
+ message: "create_evidence requires text",
11681
+ path: ["text"]
11682
+ });
11683
+ }
11684
+ const target = input.targetId ?? input.targetNodeId;
11685
+ const kind = targetKind(target);
11686
+ const linksPrimaryBelief = Boolean(
11687
+ input.linkedBeliefNodeId || kind === "belief" || kind === "unknown" && target
11688
+ );
11689
+ const weight = typeof input.weight === "number" ? input.weight : void 0;
11690
+ if (linksPrimaryBelief && !hasRelationSignal(input.evidenceRelation, weight)) {
11691
+ ctx.addIssue({
11692
+ code: z.ZodIssueCode.custom,
11693
+ message: "belief-targeted evidence requires evidenceRelation='supports'|'contradicts' or a nonzero signed weight",
11694
+ path: ["evidenceRelation"]
11695
+ });
11696
+ }
11697
+ input.beliefRelations?.forEach((relation, index) => {
11698
+ const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
11699
+ if (!beliefNodeId) {
11700
+ ctx.addIssue({
11701
+ code: z.ZodIssueCode.custom,
11702
+ message: "beliefRelations entries require beliefId, beliefNodeId, or targetId",
11703
+ path: ["beliefRelations", index, "beliefNodeId"]
11704
+ });
11705
+ }
11706
+ const relationWeight2 = typeof relation.weight === "number" ? relation.weight : void 0;
11707
+ if (beliefNodeId && !hasRelationSignal(
11708
+ relation.evidenceRelation ?? relation.relation,
11709
+ relationWeight2
11710
+ )) {
11711
+ ctx.addIssue({
11712
+ code: z.ZodIssueCode.custom,
11713
+ message: "beliefRelations entries require evidenceRelation='supports'|'contradicts' or a nonzero signed weight",
11714
+ path: ["beliefRelations", index, "evidenceRelation"]
11715
+ });
11716
+ }
11717
+ });
11674
11718
  }
11675
11719
  );
11676
11720
  function compactRecord(input) {
@@ -11729,7 +11773,7 @@ function normalizeRelation(value, weight) {
11729
11773
  if (value === "contradicts" || value === "contradicting") {
11730
11774
  return "contradicts";
11731
11775
  }
11732
- if (weight === void 0) {
11776
+ if (weight === void 0 || !hasNonzeroWeight(weight)) {
11733
11777
  return void 0;
11734
11778
  }
11735
11779
  return weight < 0 ? "contradicts" : "supports";
@@ -13238,14 +13282,18 @@ var createEvidenceArgs = z.object({
13238
13282
  text: z.string().describe("Canonical evidence text."),
13239
13283
  source: z.string().optional().describe("Source URL or source label."),
13240
13284
  sourceUrl: z.string().optional().describe("Canonical source URL."),
13241
- targetId: z.string().optional().describe("Belief, question, or worktree identifier to link or preserve on the evidence record."),
13285
+ targetId: z.string().optional().describe(
13286
+ "Belief, question, or worktree identifier to link or preserve on the evidence record. Belief targets require evidenceRelation or a nonzero signed weight."
13287
+ ),
13242
13288
  linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
13243
- evidenceRelation: evidenceRelationSchema2.optional().describe("How the evidence relates to the linked belief."),
13289
+ evidenceRelation: evidenceRelationSchema2.optional().describe(
13290
+ "How the evidence relates to the linked belief. Use supports for proof/fixes; use contradicts for bugs, regressions, or falsifying observations."
13291
+ ),
13244
13292
  beliefRelations: z.array(beliefRelationSchema2).optional().describe(
13245
13293
  "Additional belief relations for one evidence record. Use when the same evidence supports or contradicts multiple beliefs."
13246
13294
  ),
13247
13295
  confidence: z.number().optional().describe("Confidence in the evidence relation."),
13248
- weight: z.number().optional().describe("Support weight from -1.0 to +1.0."),
13296
+ weight: z.number().optional().describe("Nonzero support weight from -1.0 to +1.0."),
13249
13297
  metadata: jsonRecordSchema4.optional().describe("Metadata merged into the canonical evidence node."),
13250
13298
  rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
13251
13299
  reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
@@ -13287,13 +13335,18 @@ var createEvidenceInput = (input, context) => {
13287
13335
  );
13288
13336
  };
13289
13337
  function relationWeight(input) {
13290
- if (typeof input.weight === "number") {
13338
+ if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0) {
13291
13339
  return input.weight;
13292
13340
  }
13293
- const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
13294
13341
  const relation = String(
13295
13342
  input.evidenceRelation ?? input.relation ?? input.type ?? ""
13296
13343
  );
13344
+ if (relation !== "supports" && relation !== "supporting" && relation !== "contradicts" && relation !== "contradicting") {
13345
+ throw new Error(
13346
+ "Belief evidence links require evidenceRelation='supports'|'contradicts' or a nonzero signed weight."
13347
+ );
13348
+ }
13349
+ const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
13297
13350
  return relation === "contradicts" || relation === "contradicting" ? -confidence : confidence;
13298
13351
  }
13299
13352
  var linkEvidenceToBeliefInput = (input, context) => {
@@ -13320,7 +13373,7 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
13320
13373
  )}:${String(
13321
13374
  input.beliefNodeId ?? input.beliefId ?? input.targetId
13322
13375
  )}:informs`,
13323
- weight: typeof input.weight === "number" ? input.weight : input.type === "contradicting" ? -1 : 1,
13376
+ weight: relationWeight(input),
13324
13377
  context: input.rationale ?? input.context,
13325
13378
  skipLayerValidation: true,
13326
13379
  topicId: input.topicId,