@lucern/contracts 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/CHANGELOG.md +6 -0
- package/dist/function-registry/evidence.js +65 -12
- package/dist/function-registry/evidence.js.map +1 -1
- package/dist/index.js +50 -6
- package/dist/index.js.map +1 -1
- package/dist/projections/check-convex-args-shape.js +50 -6
- package/dist/projections/check-convex-args-shape.js.map +1 -1
- package/dist/projections/create-evidence.projection.js +50 -6
- package/dist/projections/create-evidence.projection.js.map +1 -1
- package/dist/projections/index.js +50 -6
- package/dist/projections/index.js.map +1 -1
- package/dist/proof-attestation.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -46,3 +46,9 @@ All notable changes to `@lucern/contracts` are tracked in this repository.
|
|
|
46
46
|
## [1.0.13] - 2026-06-01
|
|
47
47
|
- Publishes the evidence-relation contract, MCP output-schema metadata, and
|
|
48
48
|
retrieval/synthesis receipt fields used by the Campaign 1 closeout surfaces.
|
|
49
|
+
|
|
50
|
+
## [1.0.14] - 2026-06-01
|
|
51
|
+
- Release notes pending.
|
|
52
|
+
|
|
53
|
+
## [1.0.15] - 2026-06-01
|
|
54
|
+
- Release notes pending.
|
|
@@ -5513,11 +5513,55 @@ var createEvidenceInputSchemaBase = z.object({
|
|
|
5513
5513
|
metadata: jsonRecordSchema.optional(),
|
|
5514
5514
|
trustedBypassAccessCheck: z.boolean().optional()
|
|
5515
5515
|
}).passthrough();
|
|
5516
|
-
|
|
5517
|
-
(
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5516
|
+
function hasNonzeroWeight(value) {
|
|
5517
|
+
return typeof value === "number" && Number.isFinite(value) && value !== 0;
|
|
5518
|
+
}
|
|
5519
|
+
function hasRelationSignal(value, weight) {
|
|
5520
|
+
return Boolean(normalizeRelation(value, weight));
|
|
5521
|
+
}
|
|
5522
|
+
var createEvidenceInputSchema = createEvidenceInputSchemaBase.superRefine(
|
|
5523
|
+
(input, ctx) => {
|
|
5524
|
+
if (!input.text && !input.canonicalText) {
|
|
5525
|
+
ctx.addIssue({
|
|
5526
|
+
code: z.ZodIssueCode.custom,
|
|
5527
|
+
message: "create_evidence requires text",
|
|
5528
|
+
path: ["text"]
|
|
5529
|
+
});
|
|
5530
|
+
}
|
|
5531
|
+
const target = input.targetId ?? input.targetNodeId;
|
|
5532
|
+
const kind = targetKind(target);
|
|
5533
|
+
const linksPrimaryBelief = Boolean(
|
|
5534
|
+
input.linkedBeliefNodeId || kind === "belief" || kind === "unknown" && target
|
|
5535
|
+
);
|
|
5536
|
+
const weight = typeof input.weight === "number" ? input.weight : void 0;
|
|
5537
|
+
if (linksPrimaryBelief && !hasRelationSignal(input.evidenceRelation, weight)) {
|
|
5538
|
+
ctx.addIssue({
|
|
5539
|
+
code: z.ZodIssueCode.custom,
|
|
5540
|
+
message: "belief-targeted evidence requires evidenceRelation='supports'|'contradicts' or a nonzero signed weight",
|
|
5541
|
+
path: ["evidenceRelation"]
|
|
5542
|
+
});
|
|
5543
|
+
}
|
|
5544
|
+
input.beliefRelations?.forEach((relation, index) => {
|
|
5545
|
+
const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
|
|
5546
|
+
if (!beliefNodeId) {
|
|
5547
|
+
ctx.addIssue({
|
|
5548
|
+
code: z.ZodIssueCode.custom,
|
|
5549
|
+
message: "beliefRelations entries require beliefId, beliefNodeId, or targetId",
|
|
5550
|
+
path: ["beliefRelations", index, "beliefNodeId"]
|
|
5551
|
+
});
|
|
5552
|
+
}
|
|
5553
|
+
const relationWeight2 = typeof relation.weight === "number" ? relation.weight : void 0;
|
|
5554
|
+
if (beliefNodeId && !hasRelationSignal(
|
|
5555
|
+
relation.evidenceRelation ?? relation.relation,
|
|
5556
|
+
relationWeight2
|
|
5557
|
+
)) {
|
|
5558
|
+
ctx.addIssue({
|
|
5559
|
+
code: z.ZodIssueCode.custom,
|
|
5560
|
+
message: "beliefRelations entries require evidenceRelation='supports'|'contradicts' or a nonzero signed weight",
|
|
5561
|
+
path: ["beliefRelations", index, "evidenceRelation"]
|
|
5562
|
+
});
|
|
5563
|
+
}
|
|
5564
|
+
});
|
|
5521
5565
|
}
|
|
5522
5566
|
);
|
|
5523
5567
|
function compactRecord2(input) {
|
|
@@ -5576,7 +5620,7 @@ function normalizeRelation(value, weight) {
|
|
|
5576
5620
|
if (value === "contradicts" || value === "contradicting") {
|
|
5577
5621
|
return "contradicts";
|
|
5578
5622
|
}
|
|
5579
|
-
if (weight === void 0) {
|
|
5623
|
+
if (weight === void 0 || !hasNonzeroWeight(weight)) {
|
|
5580
5624
|
return void 0;
|
|
5581
5625
|
}
|
|
5582
5626
|
return weight < 0 ? "contradicts" : "supports";
|
|
@@ -5716,14 +5760,18 @@ var createEvidenceArgs = z.object({
|
|
|
5716
5760
|
text: z.string().describe("Canonical evidence text."),
|
|
5717
5761
|
source: z.string().optional().describe("Source URL or source label."),
|
|
5718
5762
|
sourceUrl: z.string().optional().describe("Canonical source URL."),
|
|
5719
|
-
targetId: z.string().optional().describe(
|
|
5763
|
+
targetId: z.string().optional().describe(
|
|
5764
|
+
"Belief, question, or worktree identifier to link or preserve on the evidence record. Belief targets require evidenceRelation or a nonzero signed weight."
|
|
5765
|
+
),
|
|
5720
5766
|
linkedBeliefNodeId: z.string().optional().describe("Belief node this evidence bears on."),
|
|
5721
|
-
evidenceRelation: evidenceRelationSchema2.optional().describe(
|
|
5767
|
+
evidenceRelation: evidenceRelationSchema2.optional().describe(
|
|
5768
|
+
"How the evidence relates to the linked belief. Use supports for proof/fixes; use contradicts for bugs, regressions, or falsifying observations."
|
|
5769
|
+
),
|
|
5722
5770
|
beliefRelations: z.array(beliefRelationSchema2).optional().describe(
|
|
5723
5771
|
"Additional belief relations for one evidence record. Use when the same evidence supports or contradicts multiple beliefs."
|
|
5724
5772
|
),
|
|
5725
5773
|
confidence: z.number().optional().describe("Confidence in the evidence relation."),
|
|
5726
|
-
weight: z.number().optional().describe("
|
|
5774
|
+
weight: z.number().optional().describe("Nonzero support weight from -1.0 to +1.0."),
|
|
5727
5775
|
metadata: jsonRecordSchema2.optional().describe("Metadata merged into the canonical evidence node."),
|
|
5728
5776
|
rationale: z.string().describe("Why this evidence should enter the reasoning graph."),
|
|
5729
5777
|
reasoning: z.string().optional().describe("Reasoning note preserved in evidence metadata."),
|
|
@@ -5765,13 +5813,18 @@ var createEvidenceInput = (input, context) => {
|
|
|
5765
5813
|
);
|
|
5766
5814
|
};
|
|
5767
5815
|
function relationWeight(input) {
|
|
5768
|
-
if (typeof input.weight === "number") {
|
|
5816
|
+
if (typeof input.weight === "number" && Number.isFinite(input.weight) && input.weight !== 0) {
|
|
5769
5817
|
return input.weight;
|
|
5770
5818
|
}
|
|
5771
|
-
const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
|
|
5772
5819
|
const relation = String(
|
|
5773
5820
|
input.evidenceRelation ?? input.relation ?? input.type ?? ""
|
|
5774
5821
|
);
|
|
5822
|
+
if (relation !== "supports" && relation !== "supporting" && relation !== "contradicts" && relation !== "contradicting") {
|
|
5823
|
+
throw new Error(
|
|
5824
|
+
"Belief evidence links require evidenceRelation='supports'|'contradicts' or a nonzero signed weight."
|
|
5825
|
+
);
|
|
5826
|
+
}
|
|
5827
|
+
const confidence = typeof input.confidence === "number" ? Math.max(0, Math.min(1, input.confidence)) : 0.7;
|
|
5775
5828
|
return relation === "contradicts" || relation === "contradicting" ? -confidence : confidence;
|
|
5776
5829
|
}
|
|
5777
5830
|
var linkEvidenceToBeliefInput = (input, context) => {
|
|
@@ -5798,7 +5851,7 @@ var linkEvidenceToBeliefEdgeInput = (input, context) => withCreatedBy(
|
|
|
5798
5851
|
)}:${String(
|
|
5799
5852
|
input.beliefNodeId ?? input.beliefId ?? input.targetId
|
|
5800
5853
|
)}:informs`,
|
|
5801
|
-
weight:
|
|
5854
|
+
weight: relationWeight(input),
|
|
5802
5855
|
context: input.rationale ?? input.context,
|
|
5803
5856
|
skipLayerValidation: true,
|
|
5804
5857
|
topicId: input.topicId,
|