@lucern/contracts 1.0.12 → 1.0.13

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.
Files changed (81) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/function-registry/beliefs.js +48 -11
  3. package/dist/function-registry/beliefs.js.map +1 -1
  4. package/dist/function-registry/coding.js +46 -9
  5. package/dist/function-registry/coding.js.map +1 -1
  6. package/dist/function-registry/context.js +46 -9
  7. package/dist/function-registry/context.js.map +1 -1
  8. package/dist/function-registry/contracts.js +46 -9
  9. package/dist/function-registry/contracts.js.map +1 -1
  10. package/dist/function-registry/coordination.js +46 -9
  11. package/dist/function-registry/coordination.js.map +1 -1
  12. package/dist/function-registry/edges.js +46 -9
  13. package/dist/function-registry/edges.js.map +1 -1
  14. package/dist/function-registry/evidence.js +166 -17
  15. package/dist/function-registry/evidence.js.map +1 -1
  16. package/dist/function-registry/graph.js +46 -9
  17. package/dist/function-registry/graph.js.map +1 -1
  18. package/dist/function-registry/helpers.js +46 -9
  19. package/dist/function-registry/helpers.js.map +1 -1
  20. package/dist/function-registry/identity.js +46 -9
  21. package/dist/function-registry/identity.js.map +1 -1
  22. package/dist/function-registry/index.js +46 -9
  23. package/dist/function-registry/index.js.map +1 -1
  24. package/dist/function-registry/judgments.js +46 -9
  25. package/dist/function-registry/judgments.js.map +1 -1
  26. package/dist/function-registry/legacy.js +46 -9
  27. package/dist/function-registry/legacy.js.map +1 -1
  28. package/dist/function-registry/lenses.js +46 -9
  29. package/dist/function-registry/lenses.js.map +1 -1
  30. package/dist/function-registry/manifest.d.ts +10 -4
  31. package/dist/function-registry/manifest.js +13 -1
  32. package/dist/function-registry/manifest.js.map +1 -1
  33. package/dist/function-registry/nodes.js +46 -9
  34. package/dist/function-registry/nodes.js.map +1 -1
  35. package/dist/function-registry/ontologies.js +46 -9
  36. package/dist/function-registry/ontologies.js.map +1 -1
  37. package/dist/function-registry/pipeline.js +46 -9
  38. package/dist/function-registry/pipeline.js.map +1 -1
  39. package/dist/function-registry/questions.js +46 -9
  40. package/dist/function-registry/questions.js.map +1 -1
  41. package/dist/function-registry/tasks.js +46 -9
  42. package/dist/function-registry/tasks.js.map +1 -1
  43. package/dist/function-registry/topics.js +46 -9
  44. package/dist/function-registry/topics.js.map +1 -1
  45. package/dist/function-registry/worktrees.js +46 -9
  46. package/dist/function-registry/worktrees.js.map +1 -1
  47. package/dist/index.js +111 -11
  48. package/dist/index.js.map +1 -1
  49. package/dist/manifests/invariants/index.js +24 -5
  50. package/dist/manifests/invariants/index.js.map +1 -1
  51. package/dist/manifests/invariants/inv-1-beliefs-append-only.js +24 -5
  52. package/dist/manifests/invariants/inv-1-beliefs-append-only.js.map +1 -1
  53. package/dist/projections/check-convex-args-shape.js +78 -3
  54. package/dist/projections/check-convex-args-shape.js.map +1 -1
  55. package/dist/projections/create-evidence.projection.d.ts +168 -0
  56. package/dist/projections/create-evidence.projection.js +78 -3
  57. package/dist/projections/create-evidence.projection.js.map +1 -1
  58. package/dist/projections/index.d.ts +28 -0
  59. package/dist/projections/index.js +78 -3
  60. package/dist/projections/index.js.map +1 -1
  61. package/dist/proof-attestation.json +1 -1
  62. package/dist/sdk-methods.contract.d.ts +3 -2
  63. package/dist/sdk-tools.contract.js +33 -8
  64. package/dist/sdk-tools.contract.js.map +1 -1
  65. package/dist/sdk-tools.contract.registry.js +33 -8
  66. package/dist/sdk-tools.contract.registry.js.map +1 -1
  67. package/dist/sdk-tools.contract.values.js +33 -8
  68. package/dist/sdk-tools.contract.values.js.map +1 -1
  69. package/dist/tool-contracts.context-orientation.js +2 -1
  70. package/dist/tool-contracts.context-orientation.js.map +1 -1
  71. package/dist/tool-contracts.intelligence-evidence.js +26 -4
  72. package/dist/tool-contracts.intelligence-evidence.js.map +1 -1
  73. package/dist/tool-contracts.js +33 -8
  74. package/dist/tool-contracts.js.map +1 -1
  75. package/dist/tool-contracts.lifecycle.js +2 -2
  76. package/dist/tool-contracts.lifecycle.js.map +1 -1
  77. package/dist/tool-contracts.questions-listing.js +3 -1
  78. package/dist/tool-contracts.questions-listing.js.map +1 -1
  79. package/dist/tool-contracts.values.js +33 -8
  80. package/dist/tool-contracts.values.js.map +1 -1
  81. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1527,7 +1527,7 @@ var SEARCH_EVIDENCE = {
1527
1527
  };
1528
1528
  var CREATE_EVIDENCE = {
1529
1529
  name: "create_evidence",
1530
- 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.",
1530
+ 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.",
1531
1531
  parameters: {
1532
1532
  topicId: { type: "string", description: "Topic scope" },
1533
1533
  text: { type: "string", description: "Canonical evidence text" },
@@ -1538,7 +1538,20 @@ var CREATE_EVIDENCE = {
1538
1538
  },
1539
1539
  weight: {
1540
1540
  type: "number",
1541
- description: "Support weight: -1.0 (contradicts) to +1.0 (supports)"
1541
+ description: "Optional support weight: -1.0 (contradicts) to +1.0 (supports). If omitted, evidenceRelation + confidence determine the weight."
1542
+ },
1543
+ evidenceRelation: {
1544
+ type: "string",
1545
+ enum: ["supports", "contradicts"],
1546
+ description: "Canonical relation to targetId/linkedBeliefNodeId. Prefer this over relying on signed weight inference."
1547
+ },
1548
+ confidence: {
1549
+ type: "number",
1550
+ description: "Confidence in the evidence relation, 0.0 to 1.0"
1551
+ },
1552
+ beliefRelations: {
1553
+ type: "array",
1554
+ 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."
1542
1555
  },
1543
1556
  metadata: {
1544
1557
  type: "object",
@@ -1648,7 +1661,7 @@ var LINK_EVIDENCE = {
1648
1661
  };
1649
1662
  var LINK_EVIDENCE_TO_BELIEF = {
1650
1663
  name: "link_evidence_to_belief",
1651
- 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).",
1664
+ 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.",
1652
1665
  parameters: {
1653
1666
  evidenceId: { type: "string", description: "The evidence node ID" },
1654
1667
  beliefId: { type: "string", description: "The belief node ID" },
@@ -1656,9 +1669,18 @@ var LINK_EVIDENCE_TO_BELIEF = {
1656
1669
  type: "number",
1657
1670
  description: "Support weight: -1.0 (contradicts) to +1.0 (supports)"
1658
1671
  },
1672
+ evidenceRelation: {
1673
+ type: "string",
1674
+ enum: ["supports", "contradicts"],
1675
+ description: "Canonical semantic relation. If omitted, the sign of weight is used."
1676
+ },
1677
+ confidence: {
1678
+ type: "number",
1679
+ description: "Confidence in this evidence-to-belief relation, 0.0 to 1.0"
1680
+ },
1659
1681
  rationale: { type: "string", description: "Why this evidence is relevant" }
1660
1682
  },
1661
- required: ["evidenceId", "beliefId", "weight"],
1683
+ required: ["evidenceId", "beliefId"],
1662
1684
  response: {
1663
1685
  description: "The created edge linking evidence to belief",
1664
1686
  fields: {
@@ -1676,7 +1698,7 @@ var LINK_EVIDENCE_TO_BELIEF = {
1676
1698
  // src/tool-contracts.lifecycle.ts
1677
1699
  var CREATE_BELIEF = {
1678
1700
  name: "create_belief",
1679
- 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)`; use modulate_confidence to record the first evidential update.",
1701
+ 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.",
1680
1702
  parameters: {
1681
1703
  canonicalText: {
1682
1704
  type: "string",
@@ -1762,7 +1784,7 @@ var REFINE_BELIEF = {
1762
1784
  };
1763
1785
  var MODULATE_CONFIDENCE = {
1764
1786
  name: "modulate_confidence",
1765
- description: "Record a confidence change for a belief. Like `git commit` to the credence log \u2014 an atomic, append-only write. Each modulation is a new entry in the history, not an overwrite. Scoring happens via merge; this tool records the individual data points. Pass the full subjective-logic tuple (`belief`, `disbelief`, `uncertainty`, `baseRate`) directly. If a caller only has a scalar probability, use `@lucern/sdk` helpers `opinionFromBaseRate`, `opinionFromDogmatic`, or `opinionFromProjected` to name the intended interpretation before calling this tool. Every modulation must cite a truth-bearing artifact: triggeringEvidenceId, triggeringQuestionId, triggeringAnswerId, triggeringContradictionId, or triggeringWorktreeId. Triggers: evidence_added, evidence_removed, contradiction_detected, contradiction_resolved, agent_assessment, worktree_outcome, worktree_completed, fusion, discount, deduction.",
1787
+ 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.",
1766
1788
  parameters: {
1767
1789
  nodeId: { type: "string", description: "The belief to score" },
1768
1790
  belief: {
@@ -2452,10 +2474,11 @@ var LUCERN_ORIENT = {
2452
2474
  workflow: "array - recommended branch -> investigate -> prove gate -> merge workflow",
2453
2475
  grammarMap: "array - primitive-to-git-analogy map for topics, campaigns, worktrees, beliefs, questions, evidence, edges, contradictions, and gates",
2454
2476
  firstMoves: "array - recommended first tools for a cold-start agent",
2455
- receiptRules: "array - how to interpret candidateCounts, broadening, coverageWarning, and noDefaultGlobalScan",
2477
+ receiptRules: "array - how to interpret candidateCounts, broadening, coverageWarning, narrativeCoverage, synthesisLints, and noDefaultGlobalScan",
2456
2478
  safetyRules: "array - mutation and completion rules that preserve reasoning lineage",
2457
2479
  toolMap: "array | undefined - situation-to-tool routing map when requested",
2458
2480
  examples: "array | undefined - concrete tool-call examples when requested",
2481
+ futureCapabilities: "array | undefined - exemplar, gauntlet, trace-corpus, and native-model-training capabilities when requested",
2459
2482
  suggestedNextCalls: "array - safe next tool calls for the current situation"
2460
2483
  }
2461
2484
  },
@@ -5036,7 +5059,9 @@ var COMPILE_CONTEXT = {
5036
5059
  recentEvidence: "array \u2014 recent evidence ranked for this query",
5037
5060
  contradictions: "array \u2014 unresolved contradiction records",
5038
5061
  relatedEntities: "array | undefined \u2014 ranked ontological entities in scope",
5039
- contextNarrative: "array \u2014 guidance for prompt assembly",
5062
+ contextNarrative: "array \u2014 ordered synthesis blocks with kind/text, starting with executive_summary and canonical narrative blocks before raw objects",
5063
+ retrievalReceipt: "object \u2014 candidateCounts, coverageWarning, narrativeCoverage, synthesisLints, and suggestedNextActions",
5064
+ narrativeCoverage: "object \u2014 recordsSynthesized, recordsNamed, recordsOmitted, and blocksEmitted for the narrative",
5040
5065
  injectionPolicy: "object \u2014 token-budgeted section selections",
5041
5066
  diagnostics: "object \u2014 scoring and utilization telemetry"
5042
5067
  }
@@ -48486,6 +48511,23 @@ function defineProjection(def) {
48486
48511
 
48487
48512
  // src/projections/create-evidence.projection.ts
48488
48513
  var jsonRecordSchema = z.record(z.unknown());
48514
+ var evidenceRelationSchema = z.enum(["supports", "contradicts"]);
48515
+ var evidenceRelationAliasSchema = z.enum([
48516
+ "supports",
48517
+ "contradicts",
48518
+ "supporting",
48519
+ "contradicting"
48520
+ ]);
48521
+ var beliefRelationSchema = z.object({
48522
+ beliefId: z.string().optional(),
48523
+ beliefNodeId: z.string().optional(),
48524
+ targetId: z.string().optional(),
48525
+ relation: evidenceRelationAliasSchema.optional(),
48526
+ evidenceRelation: evidenceRelationSchema.optional(),
48527
+ confidence: z.number().optional(),
48528
+ weight: z.number().optional(),
48529
+ rationale: z.string().optional()
48530
+ });
48489
48531
  var createEvidenceInputSchemaBase = z.object({
48490
48532
  projectId: z.string().optional(),
48491
48533
  topicId: z.string().optional(),
@@ -48507,7 +48549,8 @@ var createEvidenceInputSchemaBase = z.object({
48507
48549
  targetId: z.string().optional(),
48508
48550
  targetNodeId: z.string().optional(),
48509
48551
  linkedBeliefNodeId: z.string().optional(),
48510
- evidenceRelation: z.enum(["supports", "contradicts"]).optional(),
48552
+ evidenceRelation: evidenceRelationSchema.optional(),
48553
+ beliefRelations: z.array(beliefRelationSchema).optional(),
48511
48554
  confidence: z.number().optional(),
48512
48555
  weight: z.number().optional(),
48513
48556
  reasoning: z.string().optional(),
@@ -48571,6 +48614,47 @@ function targetKind(targetId) {
48571
48614
  }
48572
48615
  return "unknown";
48573
48616
  }
48617
+ function normalizeRelation(value, weight) {
48618
+ if (value === "supports" || value === "supporting") {
48619
+ return "supports";
48620
+ }
48621
+ if (value === "contradicts" || value === "contradicting") {
48622
+ return "contradicts";
48623
+ }
48624
+ if (weight === void 0) {
48625
+ return void 0;
48626
+ }
48627
+ return weight < 0 ? "contradicts" : "supports";
48628
+ }
48629
+ function normalizeConfidence(confidence, weight) {
48630
+ if (confidence !== void 0) {
48631
+ return Math.min(1, Math.max(0, confidence));
48632
+ }
48633
+ if (weight === void 0) {
48634
+ return void 0;
48635
+ }
48636
+ return Math.min(1, Math.max(0, Math.abs(weight)));
48637
+ }
48638
+ function normalizeBeliefRelation(relation) {
48639
+ const beliefNodeId = relation.beliefNodeId ?? relation.beliefId ?? relation.targetId;
48640
+ if (!beliefNodeId) {
48641
+ return void 0;
48642
+ }
48643
+ const weight = typeof relation.weight === "number" ? relation.weight : void 0;
48644
+ const evidenceRelation = normalizeRelation(
48645
+ relation.evidenceRelation ?? relation.relation,
48646
+ weight
48647
+ );
48648
+ if (!evidenceRelation) {
48649
+ return void 0;
48650
+ }
48651
+ return compactRecord({
48652
+ beliefNodeId,
48653
+ relation: evidenceRelation,
48654
+ confidence: normalizeConfidence(relation.confidence, weight),
48655
+ rationale: relation.rationale
48656
+ });
48657
+ }
48574
48658
  var createEvidenceProjection = defineProjection({
48575
48659
  contractName: "create_evidence",
48576
48660
  inputSchema: createEvidenceInputSchema,
@@ -48581,6 +48665,11 @@ var createEvidenceProjection = defineProjection({
48581
48665
  const kind = targetKind(target);
48582
48666
  const linkedWorktreeId = kind === "worktree" ? normalizeWorktreeId(target) : void 0;
48583
48667
  const linkedBeliefNodeId = input.linkedBeliefNodeId ?? (kind === "belief" || kind === "unknown" ? input.targetNodeId ?? input.targetId : void 0);
48668
+ const evidenceRelation = linkedBeliefNodeId ? normalizeRelation(input.evidenceRelation, weight) : void 0;
48669
+ const confidence = evidenceRelation ? normalizeConfidence(input.confidence, weight) : void 0;
48670
+ const beliefRelations = input.beliefRelations?.map(normalizeBeliefRelation).filter(
48671
+ (relation) => relation !== void 0
48672
+ );
48584
48673
  return compactRecord({
48585
48674
  projectId: input.projectId,
48586
48675
  topicId: normalizeTopicIdForKernel(input.topicId),
@@ -48609,8 +48698,9 @@ var createEvidenceProjection = defineProjection({
48609
48698
  rationale: input.rationale
48610
48699
  }),
48611
48700
  linkedBeliefNodeId,
48612
- evidenceRelation: input.evidenceRelation ?? (weight === void 0 ? void 0 : weight < 0 ? "contradicts" : "supports"),
48613
- confidence: input.confidence ?? (weight === void 0 ? void 0 : Math.min(1, Math.max(0, Math.abs(weight)))),
48701
+ evidenceRelation,
48702
+ confidence,
48703
+ beliefRelations: beliefRelations && beliefRelations.length > 0 ? beliefRelations : void 0,
48614
48704
  rationale: input.rationale,
48615
48705
  trustedBypassAccessCheck: input.trustedBypassAccessCheck ?? true
48616
48706
  });
@@ -48639,6 +48729,16 @@ var createEvidenceProjection = defineProjection({
48639
48729
  v.literal("contradicts")
48640
48730
  )
48641
48731
  ),
48732
+ beliefRelations: v.optional(
48733
+ v.array(
48734
+ v.object({
48735
+ beliefNodeId: v.string(),
48736
+ relation: v.union(v.literal("supports"), v.literal("contradicts")),
48737
+ confidence: v.optional(v.number()),
48738
+ rationale: v.optional(v.string())
48739
+ })
48740
+ )
48741
+ ),
48642
48742
  confidence: v.optional(v.number()),
48643
48743
  rationale: v.string(),
48644
48744
  trustedBypassAccessCheck: v.optional(v.boolean())