@lucern/graph-primitives 0.3.0-alpha.0 → 0.3.0-alpha.10

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 (141) hide show
  1. package/dist/{beliefDecay-Q_26RTc-.d.ts → beliefDecay-DZ6tkLYq.d.ts} +1 -1
  2. package/dist/beliefDecay.d.ts +1 -1
  3. package/dist/beliefDecay.js +188 -1144
  4. package/dist/beliefDecay.js.map +1 -1
  5. package/dist/{beliefEvidenceLinks-42FlR48t.d.ts → beliefEvidenceLinks-CWOXxxJg.d.ts} +1 -1
  6. package/dist/beliefEvidenceLinks.d.ts +1 -1
  7. package/dist/beliefEvidenceLinks.js +186 -871
  8. package/dist/beliefEvidenceLinks.js.map +1 -1
  9. package/dist/{beliefLifecycle-C-AehZgF.d.ts → beliefLifecycle-y8WLXqQj.d.ts} +1 -1
  10. package/dist/beliefLifecycle.d.ts +1 -1
  11. package/dist/confidencePropagationDispatch.d.ts +4 -4
  12. package/dist/confidencePropagationDispatch.js +31 -311
  13. package/dist/confidencePropagationDispatch.js.map +1 -1
  14. package/dist/{contradictions-Hdwl7zid.d.ts → contradictions-51VLsESq.d.ts} +1 -1
  15. package/dist/contradictions.d.ts +1 -1
  16. package/dist/contradictions.js +67 -800
  17. package/dist/contradictions.js.map +1 -1
  18. package/dist/debug.d.ts +4 -0
  19. package/dist/debug.js +34 -0
  20. package/dist/debug.js.map +1 -0
  21. package/dist/edges/contradicts.js +1 -122
  22. package/dist/edges/contradicts.js.map +1 -1
  23. package/dist/edges/dependsOn.js +14 -172
  24. package/dist/edges/dependsOn.js.map +1 -1
  25. package/dist/edges/elaborates.js +1 -49
  26. package/dist/edges/elaborates.js.map +1 -1
  27. package/dist/edges/index.js +15 -280
  28. package/dist/edges/index.js.map +1 -1
  29. package/dist/edges/informs.js +2 -65
  30. package/dist/edges/informs.js.map +1 -1
  31. package/dist/edges/propagationTypes.d.ts +2 -2
  32. package/dist/edges/propagationTypes.js.map +1 -1
  33. package/dist/edges/refutes.js +2 -65
  34. package/dist/edges/refutes.js.map +1 -1
  35. package/dist/edges/supports.js +1 -122
  36. package/dist/edges/supports.js.map +1 -1
  37. package/dist/edges/utils.d.ts +7 -7
  38. package/dist/edges/utils.js +2 -133
  39. package/dist/edges/utils.js.map +1 -1
  40. package/dist/embeddingTrigger.js +21 -1
  41. package/dist/embeddingTrigger.js.map +1 -1
  42. package/dist/entityBridge.js +3 -18
  43. package/dist/entityBridge.js.map +1 -1
  44. package/dist/{entityLifecycle-BkhRJ-XI.d.ts → entityLifecycle-CvgSK5FV.d.ts} +1 -1
  45. package/dist/entityLifecycle.d.ts +1 -1
  46. package/dist/entityLifecycle.js +193 -892
  47. package/dist/entityLifecycle.js.map +1 -1
  48. package/dist/{epistemicAnswers-DSP1slZ9.d.ts → epistemicAnswers-C5ib4z6_.d.ts} +1 -1
  49. package/dist/epistemicAnswers.d.ts +1 -1
  50. package/dist/epistemicAnswers.js +73 -810
  51. package/dist/epistemicAnswers.js.map +1 -1
  52. package/dist/{epistemicBeliefs-DtFVTp-k.d.ts → epistemicBeliefs-DzKjZAeC.d.ts} +3 -3
  53. package/dist/epistemicBeliefs.d.ts +2 -2
  54. package/dist/epistemicBeliefs.js +404 -1698
  55. package/dist/epistemicBeliefs.js.map +1 -1
  56. package/dist/epistemicContractHelpers.js +1 -318
  57. package/dist/epistemicContractHelpers.js.map +1 -1
  58. package/dist/epistemicContracts.d.ts +1 -1
  59. package/dist/epistemicContracts.js +417 -1980
  60. package/dist/epistemicContracts.js.map +1 -1
  61. package/dist/{epistemicEdges-DcA8ErUG.d.ts → epistemicEdges-CD5vxmlH.d.ts} +3 -3
  62. package/dist/epistemicEdges.d.ts +1 -1
  63. package/dist/epistemicEdges.js +248 -919
  64. package/dist/epistemicEdges.js.map +1 -1
  65. package/dist/{epistemicEvidence-Bo638XDP.d.ts → epistemicEvidence-xw6UUrwh.d.ts} +1 -1
  66. package/dist/epistemicEvidence.d.ts +1 -1
  67. package/dist/epistemicEvidence.js +229 -1087
  68. package/dist/epistemicEvidence.js.map +1 -1
  69. package/dist/{epistemicHelpers-Bd9xbaib.d.ts → epistemicHelpers-DevrYgPN.d.ts} +1 -1
  70. package/dist/epistemicHelpers.d.ts +1 -1
  71. package/dist/{epistemicLinking-CyeLOIzN.d.ts → epistemicLinking-CfE00tHJ.d.ts} +1 -1
  72. package/dist/epistemicLinking.d.ts +1 -1
  73. package/dist/epistemicLinking.js +3 -786
  74. package/dist/epistemicLinking.js.map +1 -1
  75. package/dist/{epistemicNodes-BpD6Koud.d.ts → epistemicNodes-NBrPW7fk.d.ts} +2 -2
  76. package/dist/epistemicNodes.d.ts +1 -1
  77. package/dist/epistemicNodes.js +172 -899
  78. package/dist/epistemicNodes.js.map +1 -1
  79. package/dist/{epistemicQuestions-CmEeY6zQ.d.ts → epistemicQuestions-B_nUclrH.d.ts} +1 -1
  80. package/dist/epistemicQuestions.d.ts +1 -1
  81. package/dist/epistemicQuestions.js +369 -1125
  82. package/dist/epistemicQuestions.js.map +1 -1
  83. package/dist/{epistemicSources-ZazxHOK1.d.ts → epistemicSources-dlKj58Jp.d.ts} +1 -1
  84. package/dist/epistemicSources.d.ts +1 -1
  85. package/dist/epistemicSources.js +86 -886
  86. package/dist/epistemicSources.js.map +1 -1
  87. package/dist/evaluators/index.js +417 -1980
  88. package/dist/evaluators/index.js.map +1 -1
  89. package/dist/evaluators/lintCheckerEvaluator.js.map +1 -1
  90. package/dist/evaluators/sentryCheckerEvaluator.js.map +1 -1
  91. package/dist/evaluators/shared.js +20 -1
  92. package/dist/evaluators/shared.js.map +1 -1
  93. package/dist/evaluators/testRunnerEvaluator.js +20 -1
  94. package/dist/evaluators/testRunnerEvaluator.js.map +1 -1
  95. package/dist/evaluators/tscCheckerEvaluator.js.map +1 -1
  96. package/dist/index.d.ts +20 -20
  97. package/dist/index.js +965 -3004
  98. package/dist/index.js.map +1 -1
  99. package/dist/{ontology-matching-Buhu23ss.d.ts → ontology-matching-C6rrz2VP.d.ts} +1 -1
  100. package/dist/ontology-matching.d.ts +1 -1
  101. package/dist/ontology-matching.js +1 -344
  102. package/dist/ontology-matching.js.map +1 -1
  103. package/dist/{ontologyApproval-Ba0Jjk1k.d.ts → ontologyApproval-CFYmqKmk.d.ts} +1 -1
  104. package/dist/ontologyApproval.d.ts +1 -1
  105. package/dist/ontologyApproval.js +1 -13
  106. package/dist/ontologyApproval.js.map +1 -1
  107. package/dist/ontologyDefinitions.js +6 -20
  108. package/dist/ontologyDefinitions.js.map +1 -1
  109. package/dist/ontologyHelpers.d.ts +1 -1
  110. package/dist/ontologyHelpers.js +4 -3
  111. package/dist/ontologyHelpers.js.map +1 -1
  112. package/dist/ontologyRegistry.js +2 -17
  113. package/dist/ontologyRegistry.js.map +1 -1
  114. package/dist/{projectionReconciliation-CxrXYGaB.d.ts → projectionReconciliation-jww2fBI0.d.ts} +1 -1
  115. package/dist/projectionReconciliation.d.ts +1 -1
  116. package/dist/projectionReconciliation.js +16 -37
  117. package/dist/projectionReconciliation.js.map +1 -1
  118. package/dist/{projectionStaleness-CAdpIsaW.d.ts → projectionStaleness-CmdbpjVK.d.ts} +1 -1
  119. package/dist/projectionStaleness.d.ts +1 -1
  120. package/dist/{questionEvidenceLinks-BdQD0TkM.d.ts → questionEvidenceLinks-DFlyPpAj.d.ts} +1 -1
  121. package/dist/questionEvidenceLinks.d.ts +1 -1
  122. package/dist/questionEvidenceLinks.js +199 -881
  123. package/dist/questionEvidenceLinks.js.map +1 -1
  124. package/dist/resolvers.js +86 -37
  125. package/dist/resolvers.js.map +1 -1
  126. package/dist/scopeResolverCompat.js +64 -7
  127. package/dist/scopeResolverCompat.js.map +1 -1
  128. package/dist/{text-matching-CMn2WnVD.d.ts → text-matching-DNg4M5Wd.d.ts} +1 -1
  129. package/dist/text-matching.d.ts +1 -1
  130. package/dist/text-matching.js +1 -244
  131. package/dist/text-matching.js.map +1 -1
  132. package/dist/topicProjectOverlay.js +56 -13
  133. package/dist/topicProjectOverlay.js.map +1 -1
  134. package/dist/topicScope.js +55 -6
  135. package/dist/topicScope.js.map +1 -1
  136. package/dist/workflowBridge.d.ts +27 -0
  137. package/dist/workflowBridge.js +352 -0
  138. package/dist/workflowBridge.js.map +1 -0
  139. package/dist/workspaceIsolation.js +56 -57
  140. package/dist/workspaceIsolation.js.map +1 -1
  141. package/package.json +6 -5
@@ -1,125 +1,4 @@
1
- // ../confidence/src/v1/operations/subjectiveLogic/index.ts
2
- function opinion(belief, disbelief, uncertainty, baseRate = 0.5) {
3
- const b = Math.max(0, Math.min(1, belief));
4
- const d = Math.max(0, Math.min(1, disbelief));
5
- const u = Math.max(0, Math.min(1, uncertainty));
6
- const a = Math.max(0, Math.min(1, baseRate));
7
- const sum = b + d + u;
8
- if (sum === 0) {
9
- return { b: 0, d: 0, u: 1, a };
10
- }
11
- return {
12
- b: b / sum,
13
- d: d / sum,
14
- u: u / sum,
15
- a
16
- };
17
- }
18
- function vacuous(baseRate = 0.5) {
19
- return { b: 0, d: 0, u: 1, a: baseRate };
20
- }
21
- function project(o) {
22
- return o.b + o.a * o.u;
23
- }
24
- function cumulativeFusion(left, right) {
25
- if (left.u === 0 && right.u === 0) {
26
- return opinion(
27
- (left.b + right.b) / 2,
28
- (left.d + right.d) / 2,
29
- 0,
30
- (left.a + right.a) / 2
31
- );
32
- }
33
- const k = left.u + right.u - left.u * right.u;
34
- if (k === 0) {
35
- return vacuous((left.a + right.a) / 2);
36
- }
37
- return opinion(
38
- (left.b * right.u + right.b * left.u) / k,
39
- (left.d * right.u + right.d * left.u) / k,
40
- left.u * right.u / k,
41
- (left.a + right.a) / 2
42
- );
43
- }
44
- function trustDiscount(sourceOpinion, trust) {
45
- const weight = Math.max(0, Math.min(1, Math.abs(trust)));
46
- return opinion(
47
- weight * sourceOpinion.b,
48
- weight * sourceOpinion.d,
49
- 1 - weight * (sourceOpinion.b + sourceOpinion.d),
50
- sourceOpinion.a
51
- );
52
- }
53
- function negate(o) {
54
- return { b: o.d, d: o.b, u: o.u, a: 1 - o.a };
55
- }
56
- function constraintFusion(left, right, mode = "pressure") {
57
- if (mode === "redistribute") {
58
- const leftProjected = project(left);
59
- const rightProjected = project(right);
60
- const total = leftProjected + rightProjected;
61
- if (total <= 1) {
62
- return { o1: left, o2: right };
63
- }
64
- const scale = 1 / total;
65
- return {
66
- o1: opinion(
67
- left.b * scale,
68
- left.d + left.b * (1 - scale),
69
- left.u,
70
- left.a
71
- ),
72
- o2: opinion(
73
- right.b * scale,
74
- right.d + right.b * (1 - scale),
75
- right.u,
76
- right.a
77
- )
78
- };
79
- }
80
- const pressureLeft = right.b * 0.5;
81
- const pressureRight = left.b * 0.5;
82
- return {
83
- o1: opinion(
84
- left.b - pressureLeft * 0.3,
85
- left.d + pressureLeft * 0.3,
86
- left.u,
87
- left.a
88
- ),
89
- o2: opinion(
90
- right.b - pressureRight * 0.3,
91
- right.d + pressureRight * 0.3,
92
- right.u,
93
- right.a
94
- )
95
- };
96
- }
97
-
98
- // ../confidence/src/v1/operations/dynamics/defeat.ts
99
- function applyNegativeSupport(source, target, weight, metadata = {}) {
100
- if (metadata.constraint === "xor") {
101
- const result = constraintFusion(
102
- source,
103
- target,
104
- metadata.normalization ?? "pressure"
105
- );
106
- return {
107
- opinion: result.o2,
108
- operator: "constraint_fusion",
109
- rationale: `XOR constraint: source belief at ${project(source).toFixed(
110
- 2
111
- )} pressures target`
112
- };
113
- }
114
- const discounted = trustDiscount(negate(source), Math.abs(weight));
115
- return {
116
- opinion: cumulativeFusion(target, discounted),
117
- operator: "cumulative_fusion",
118
- rationale: `Contradicting evidence (weight=${weight.toFixed(
119
- 2
120
- )}) from source at ${project(source).toFixed(2)}`
121
- };
122
- }
1
+ import { trustDiscount, applyNegativeSupport } from '@lucern/confidence';
123
2
 
124
3
  // src/edges/utils.ts
125
4
  function readEdgeMetadata(edge) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../confidence/src/v1/operations/subjectiveLogic/index.ts","../../../confidence/src/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AA;AAAA,EACV,SAAA,EAAW,eAAA;AAAA,EACX,YAAA,EAAc,MAAA;AAAA,EACd,OAAA,EAAS,IAAA;AAAA,EACT,OAAA,EAAS,CAAA;AAAA,EACT,QAAA,EAAU,CAAC,aAAA,EAAe,aAAA,EAAe,MAAM,OAAA,KAAY;AACzD,IAAA,MAAM,YAAA,GAAe,kBAAA;AAAA,MACnB,aAAA;AAAA,MACA,QAAQ,IAAA,CAAK;AAAA,KACf;AACA,IAAA,MAAM,iBAAiB,CAAC,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,UAAU,CAAC,CAAA;AACjD,IAAA,MAAM,MAAA,GAAS,oCAAA;AAAA,MACb,YAAA;AAAA,MACA,aAAA;AAAA,MACA,cAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,OAAO,iBAAA,CAAkB,MAAA,EAAQ,OAAA,CAAQ,IAAA,EAAM,QAAQ,GAAG,CAAA;AAAA,EAC5D,CAAA;AAAA,EACA,WAAA,EACE;AACJ","file":"contradicts.js","sourcesContent":["import type { Opinion } from \"../../types\";\n\nexport function opinion(\n belief: number,\n disbelief: number,\n uncertainty: number,\n baseRate: number = 0.5\n): Opinion {\n const b = Math.max(0, Math.min(1, belief));\n const d = Math.max(0, Math.min(1, disbelief));\n const u = Math.max(0, Math.min(1, uncertainty));\n const a = Math.max(0, Math.min(1, baseRate));\n const sum = b + d + u;\n\n if (sum === 0) {\n return { b: 0, d: 0, u: 1, a };\n }\n\n return {\n b: b / sum,\n d: d / sum,\n u: u / sum,\n a,\n };\n}\n\nexport function vacuous(baseRate: number = 0.5): Opinion {\n return { b: 0, d: 0, u: 1, a: baseRate };\n}\n\nexport function dogmatic(probability: number, baseRate: number = 0.5): Opinion {\n const p = Math.max(0, Math.min(1, probability));\n return { b: p, d: 1 - p, u: 0, a: baseRate };\n}\n\nexport function project(o: Opinion): number {\n return o.b + o.a * o.u;\n}\n\nexport function confidenceLevel(o: Opinion): \"high\" | \"medium\" | \"low\" {\n const projected = project(o);\n if (o.u > 0.5) {\n return \"low\";\n }\n if (projected >= 0.8 && o.u < 0.2) {\n return \"high\";\n }\n if (projected >= 0.6) {\n return \"medium\";\n }\n return \"low\";\n}\n\nexport function cumulativeFusion(left: Opinion, right: Opinion): Opinion {\n if (left.u === 0 && right.u === 0) {\n return opinion(\n (left.b + right.b) / 2,\n (left.d + right.d) / 2,\n 0,\n (left.a + right.a) / 2\n );\n }\n\n const k = left.u + right.u - left.u * right.u;\n if (k === 0) {\n return vacuous((left.a + right.a) / 2);\n }\n\n return opinion(\n (left.b * right.u + right.b * left.u) / k,\n (left.d * right.u + right.d * left.u) / k,\n (left.u * right.u) / k,\n (left.a + right.a) / 2\n );\n}\n\nexport function averagingFusion(left: Opinion, right: Opinion): Opinion {\n if (left.u === 0 && right.u === 0) {\n return opinion(\n (left.b + right.b) / 2,\n (left.d + right.d) / 2,\n 0,\n (left.a + right.a) / 2\n );\n }\n\n const k = left.u + right.u;\n if (k === 0) {\n return vacuous((left.a + right.a) / 2);\n }\n\n return opinion(\n (left.b * right.u + right.b * left.u) / k,\n (left.d * right.u + right.d * left.u) / k,\n (2 * left.u * right.u) / k,\n (left.a + right.a) / 2\n );\n}\n\nexport function trustDiscount(sourceOpinion: Opinion, trust: number): Opinion {\n const weight = Math.max(0, Math.min(1, Math.abs(trust)));\n return opinion(\n weight * sourceOpinion.b,\n weight * sourceOpinion.d,\n 1 - weight * (sourceOpinion.b + sourceOpinion.d),\n sourceOpinion.a\n );\n}\n\nconst EPSILON = 1e-9;\n\nfunction childBaseRateFallback(\n ifTrue: Opinion,\n ifFalse: Opinion,\n fallbackBaseRate: number | undefined\n): number {\n if (fallbackBaseRate !== undefined) {\n return Math.max(0, Math.min(1, fallbackBaseRate));\n }\n\n if (Math.abs(ifTrue.a - ifFalse.a) <= EPSILON) {\n return ifTrue.a;\n }\n\n return (ifTrue.a + ifFalse.a) / 2;\n}\n\nfunction computeConditionalDeductionBaseRate(\n opinionA: Opinion,\n ifTrue: Opinion,\n ifFalse: Opinion,\n fallbackBaseRate: number\n): number {\n const denominator =\n 1 - opinionA.a * ifTrue.u - (1 - opinionA.a) * ifFalse.u;\n\n if (ifTrue.u + ifFalse.u < 2 - EPSILON && Math.abs(denominator) > EPSILON) {\n const baseRate =\n (opinionA.a * ifTrue.b + (1 - opinionA.a) * ifFalse.b) / denominator;\n if (baseRate >= -EPSILON && baseRate <= 1 + EPSILON) {\n return Math.max(0, Math.min(1, baseRate));\n }\n }\n\n return fallbackBaseRate;\n}\n\nfunction safeCorrectionTerm(\n numerator: number,\n denominator: number\n): number | undefined {\n if (Math.abs(denominator) <= EPSILON) {\n return undefined;\n }\n\n const value = numerator / denominator;\n if (!Number.isFinite(value)) {\n return undefined;\n }\n\n return Math.max(0, value);\n}\n\nexport function conditionalDeduction(\n opinionA: Opinion,\n ifTrue: Opinion,\n ifFalse: Opinion,\n fallbackBaseRate?: number\n): Opinion {\n const fallbackChildBaseRate = childBaseRateFallback(\n ifTrue,\n ifFalse,\n fallbackBaseRate\n );\n const childBaseRate = computeConditionalDeductionBaseRate(\n opinionA,\n ifTrue,\n ifFalse,\n fallbackChildBaseRate\n );\n const projectedAntecedent = project(opinionA);\n const projectedAntecedentComplement = 1 - projectedAntecedent;\n const intermediateBelief =\n opinionA.b * ifTrue.b +\n opinionA.d * ifFalse.b +\n opinionA.u * (ifTrue.b * opinionA.a + ifFalse.b * (1 - opinionA.a));\n const intermediateDisbelief =\n opinionA.b * ifTrue.d +\n opinionA.d * ifFalse.d +\n opinionA.u * (ifTrue.d * opinionA.a + ifFalse.d * (1 - opinionA.a));\n const intermediateUncertainty =\n opinionA.b * ifTrue.u +\n opinionA.d * ifFalse.u +\n opinionA.u * (ifTrue.u * opinionA.a + ifFalse.u * (1 - opinionA.a));\n const projectedVacuousDeduction =\n ifTrue.b * opinionA.a +\n ifFalse.b * (1 - opinionA.a) +\n childBaseRate *\n (ifTrue.u * opinionA.a + ifFalse.u * (1 - opinionA.a));\n const projectedConditionalA =\n ifTrue.b + childBaseRate * (1 - ifTrue.b - ifTrue.d);\n let correction = 0;\n\n if (\n (ifTrue.b > ifFalse.b && ifTrue.d > ifFalse.d) ||\n (ifTrue.b <= ifFalse.b && ifTrue.d <= ifFalse.d)\n ) {\n correction = 0;\n } else if (ifTrue.b > ifFalse.b && ifTrue.d <= ifFalse.d) {\n const beliefGap = ifTrue.b - ifFalse.b;\n const disbeliefGap = ifFalse.d - ifTrue.d;\n\n if (\n projectedVacuousDeduction <= projectedConditionalA &&\n projectedAntecedent <= opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n opinionA.a * opinionA.u * (intermediateBelief - ifTrue.b),\n projectedAntecedent * childBaseRate\n ) ?? 0;\n } else if (\n projectedVacuousDeduction <= projectedConditionalA &&\n projectedAntecedent > opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n opinionA.a * opinionA.u * (intermediateDisbelief - ifTrue.d) * beliefGap,\n projectedAntecedentComplement * childBaseRate * disbeliefGap\n ) ?? 0;\n } else if (\n projectedVacuousDeduction > projectedConditionalA &&\n projectedAntecedent <= opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n (1 - opinionA.a) *\n opinionA.u *\n (intermediateBelief - ifTrue.b) *\n disbeliefGap,\n projectedAntecedent * (1 - childBaseRate) * beliefGap\n ) ?? 0;\n } else {\n correction =\n safeCorrectionTerm(\n (1 - opinionA.a) * opinionA.u * (intermediateDisbelief - ifTrue.d),\n projectedAntecedentComplement * (1 - childBaseRate)\n ) ?? 0;\n }\n } else {\n const beliefGap = ifFalse.b - ifTrue.b;\n const disbeliefGap = ifTrue.d - ifFalse.d;\n\n if (\n projectedVacuousDeduction <= projectedConditionalA &&\n projectedAntecedent <= opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n (1 - opinionA.a) *\n opinionA.u *\n (intermediateDisbelief - ifTrue.d) *\n beliefGap,\n projectedAntecedent * childBaseRate * disbeliefGap\n ) ?? 0;\n } else if (\n projectedVacuousDeduction <= projectedConditionalA &&\n projectedAntecedent > opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n (1 - opinionA.a) * opinionA.u * (intermediateBelief - ifTrue.b),\n projectedAntecedentComplement * childBaseRate\n ) ?? 0;\n } else if (\n projectedVacuousDeduction > projectedConditionalA &&\n projectedAntecedent <= opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n opinionA.a * opinionA.u * (intermediateDisbelief - ifTrue.d),\n projectedAntecedent * (1 - childBaseRate)\n ) ?? 0;\n } else {\n correction =\n safeCorrectionTerm(\n opinionA.a *\n opinionA.u *\n (intermediateBelief - ifTrue.b) *\n disbeliefGap,\n projectedAntecedentComplement * (1 - childBaseRate) * beliefGap\n ) ?? 0;\n }\n }\n\n return opinion(\n intermediateBelief - childBaseRate * correction,\n intermediateDisbelief - (1 - childBaseRate) * correction,\n intermediateUncertainty + correction,\n childBaseRate\n );\n}\n\n/**\n * Abductive inference over a conditional.\n * Given an opinion on Y and conditionals P(Y|X), P(Y|~X), infer an opinion on X.\n */\nexport function conditionalAbduction(\n opinionY: Opinion,\n ifTrue: Opinion,\n ifFalse: Opinion,\n baseRateX: number\n): Opinion {\n const priorX = Math.max(0, Math.min(1, baseRateX));\n const probabilityY = project(opinionY);\n const probabilityGivenTrue = project(ifTrue);\n const probabilityGivenFalse = project(ifFalse);\n\n const posteriorIfYDenominator =\n probabilityGivenTrue * priorX +\n probabilityGivenFalse * (1 - priorX);\n const posteriorIfY =\n posteriorIfYDenominator === 0\n ? priorX\n : (probabilityGivenTrue * priorX) / posteriorIfYDenominator;\n\n const posteriorIfNotYDenominator =\n (1 - probabilityGivenTrue) * priorX +\n (1 - probabilityGivenFalse) * (1 - priorX);\n const posteriorIfNotY =\n posteriorIfNotYDenominator === 0\n ? priorX\n : ((1 - probabilityGivenTrue) * priorX) / posteriorIfNotYDenominator;\n\n const projectedX =\n probabilityY * posteriorIfY + (1 - probabilityY) * posteriorIfNotY;\n const uncertainty = Math.max(\n opinionY.u * 0.5,\n probabilityY * ifTrue.u + (1 - probabilityY) * ifFalse.u\n );\n\n return opinion(\n projectedX * (1 - uncertainty),\n (1 - projectedX) * (1 - uncertainty),\n uncertainty,\n priorX\n );\n}\n\nexport function negate(o: Opinion): Opinion {\n return { b: o.d, d: o.b, u: o.u, a: 1 - o.a };\n}\n\nexport function constraintFusion(\n left: Opinion,\n right: Opinion,\n mode: \"pressure\" | \"redistribute\" = \"pressure\"\n): { o1: Opinion; o2: Opinion } {\n if (mode === \"redistribute\") {\n const leftProjected = project(left);\n const rightProjected = project(right);\n const total = leftProjected + rightProjected;\n\n if (total <= 1) {\n return { o1: left, o2: right };\n }\n\n const scale = 1 / total;\n return {\n o1: opinion(\n left.b * scale,\n left.d + left.b * (1 - scale),\n left.u,\n left.a\n ),\n o2: opinion(\n right.b * scale,\n right.d + right.b * (1 - scale),\n right.u,\n right.a\n ),\n };\n }\n\n const pressureLeft = right.b * 0.5;\n const pressureRight = left.b * 0.5;\n\n return {\n o1: opinion(\n left.b - pressureLeft * 0.3,\n left.d + pressureLeft * 0.3,\n left.u,\n left.a\n ),\n o2: opinion(\n right.b - pressureRight * 0.3,\n right.d + pressureRight * 0.3,\n right.u,\n right.a\n ),\n };\n}\n\nexport function evidenceBalance(o: Opinion): number {\n const total = o.b + o.d;\n if (total === 0) {\n return 0;\n }\n return (o.b - o.d) / total;\n}\n\nexport function areTensioned(left: Opinion, right: Opinion): boolean {\n return (\n project(left) > 0.5 &&\n project(right) > 0.5 &&\n (left.d > 0.2 || right.d > 0.2)\n );\n}\n\nexport function informationGain(o: Opinion): number {\n if (o.u === 0) {\n return 0;\n }\n if (o.u === 1) {\n return 1;\n }\n return o.u * (1 - Math.abs(o.b - o.d));\n}\n","import type { EdgeMetadata, Opinion, PropagationResult } from \"../../types\";\nimport {\n constraintFusion,\n cumulativeFusion,\n negate,\n project,\n trustDiscount,\n} from \"../subjectiveLogic\";\n\nexport function applyNegativeSupport(\n source: Opinion,\n target: Opinion,\n weight: number,\n metadata: EdgeMetadata = {}\n): PropagationResult {\n if (metadata.constraint === \"xor\") {\n const result = constraintFusion(\n source,\n target,\n metadata.normalization ?? \"pressure\"\n );\n return {\n opinion: result.o2,\n operator: \"constraint_fusion\",\n rationale: `XOR constraint: source belief at ${project(source).toFixed(\n 2\n )} pressures target`,\n };\n }\n\n const discounted = trustDiscount(negate(source), Math.abs(weight));\n return {\n opinion: cumulativeFusion(target, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Contradicting evidence (weight=${weight.toFixed(\n 2\n )}) from source at ${project(source).toFixed(2)}`,\n };\n}\n\nexport function applyNegativeEvidence(\n source: Opinion,\n target: Opinion,\n weight: number\n): PropagationResult {\n const discounted = trustDiscount(negate(source), Math.abs(weight));\n return {\n opinion: cumulativeFusion(target, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Contradicting evidence (weight=${weight.toFixed(2)})`,\n };\n}\n","import {\n applyNegativeEvidence,\n applyNegativeSupport,\n cumulativeFusion,\n project,\n trustDiscount,\n type EdgeMetadata,\n type Opinion,\n type PropagationResult,\n} from \"@lucern/confidence\";\nimport type {\n EdgePropagationSpec,\n PropagationEdgeRecord,\n} from \"./propagationTypes\";\n\nexport function readEdgeMetadata<TNodeId extends string>(\n edge: PropagationEdgeRecord<TNodeId>\n): EdgeMetadata {\n return {\n constraint: edge.constraint ?? undefined,\n normalization: edge.normalization ?? undefined,\n propagation: edge.propagation ?? undefined,\n conditionalA: edge.conditionalA ?? undefined,\n conditionalNotA: edge.conditionalNotA ?? undefined,\n };\n}\n\nexport function applyPerHopDamping(\n sourceOpinion: Opinion,\n damping: number\n): Opinion {\n if (damping >= 1) {\n return sourceOpinion;\n }\n\n return trustDiscount(sourceOpinion, Math.max(0, damping));\n}\n\nexport function annotateRationale(\n result: PropagationResult,\n spec: EdgePropagationSpec,\n hop: number\n): PropagationResult {\n return {\n ...result,\n rationale: `hop=${hop} edge=${spec.edgeType} damping=${spec.damping.toFixed(\n 2\n )} :: ${result.rationale}`,\n };\n}\n\nexport function propagatePositiveSupport(\n sourceOpinion: Opinion,\n targetOpinion: Opinion,\n edgeWeight: number\n): PropagationResult {\n const discounted = trustDiscount(sourceOpinion, Math.abs(edgeWeight));\n return {\n opinion: cumulativeFusion(targetOpinion, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Supporting evidence (weight=${edgeWeight.toFixed(\n 2\n )}) from source at ${project(sourceOpinion).toFixed(2)}`,\n };\n}\n\nexport function propagatePositiveInform(\n sourceOpinion: Opinion,\n targetOpinion: Opinion,\n edgeWeight: number\n): PropagationResult {\n const discounted = trustDiscount(sourceOpinion, Math.abs(edgeWeight));\n return {\n opinion: cumulativeFusion(targetOpinion, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Supporting evidence (weight=${edgeWeight.toFixed(2)})`,\n };\n}\n\nexport function propagateNegativeSupportWithMetadata(\n sourceOpinion: Opinion,\n targetOpinion: Opinion,\n edgeWeight: number,\n edge: PropagationEdgeRecord\n): PropagationResult {\n return applyNegativeSupport(\n sourceOpinion,\n targetOpinion,\n edgeWeight,\n readEdgeMetadata(edge)\n );\n}\n\nexport function propagateNegativeInform(\n sourceOpinion: Opinion,\n targetOpinion: Opinion,\n edgeWeight: number\n): PropagationResult {\n return applyNegativeEvidence(sourceOpinion, targetOpinion, edgeWeight);\n}\n\n","import type { EdgePropagationSpec } from \"./propagationTypes\";\nimport {\n annotateRationale,\n applyPerHopDamping,\n propagateNegativeSupportWithMetadata,\n} from \"./utils\";\n\nexport const contradictsPropagationSpec: EdgePropagationSpec = {\n edgeType: \"contradicts\",\n direction: \"bidirectional\",\n transitivity: \"none\",\n damping: 0.85,\n maxHops: 1,\n operator: (sourceOpinion, targetOpinion, edge, context) => {\n const dampedSource = applyPerHopDamping(\n sourceOpinion,\n context.spec.damping\n );\n const negativeWeight = -Math.abs(edge.weight ?? 1);\n const result = propagateNegativeSupportWithMetadata(\n dampedSource,\n targetOpinion,\n negativeWeight,\n edge\n );\n\n return annotateRationale(result, context.spec, context.hop);\n },\n description:\n \"Legacy contradiction edges move negative pressure in either direction, but never beyond one hop.\",\n};\n\n"]}
1
+ {"version":3,"sources":["../../src/edges/utils.ts","../../src/edges/contradicts.ts"],"names":[],"mappings":";;;AAeO,SAAS,iBACd,IAAA,EACc;AACd,EAAA,OAAO;AAAA,IACL,UAAA,EAAY,KAAK,UAAA,IAAc,MAAA;AAAA,IAC/B,aAAA,EAAe,KAAK,aAAA,IAAiB,MAAA;AAAA,IACrC,WAAA,EAAa,KAAK,WAAA,IAAe,MAAA;AAAA,IACjC,YAAA,EAAc,KAAK,YAAA,IAAgB,MAAA;AAAA,IACnC,eAAA,EAAiB,KAAK,eAAA,IAAmB;AAAA,GAC3C;AACF;AAEO,SAAS,kBAAA,CACd,eACA,OAAA,EACW;AACX,EAAA,IAAI,WAAW,CAAA,EAAG;AAChB,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,OAAO,cAAc,aAAA,EAAe,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,OAAO,CAAC,CAAA;AAC1D;AAEO,SAAS,iBAAA,CACd,MAAA,EACA,IAAA,EACA,GAAA,EACmB;AACnB,EAAA,OAAO;AAAA,IACL,GAAG,MAAA;AAAA,IACH,SAAA,EAAW,OAAO,GAAG,CAAA,MAAA,EAAS,KAAK,QAAQ,CAAA,SAAA,EAAY,KAAK,OAAA,CAAQ,OAAA;AAAA,MAClE;AAAA,KACD,CAAA,IAAA,EAAO,MAAA,CAAO,SAAS,CAAA;AAAA,GAC1B;AACF;AA8BO,SAAS,oCAAA,CACd,aAAA,EACA,aAAA,EACA,UAAA,EACA,IAAA,EACmB;AACnB,EAAA,OAAO,oBAAA;AAAA,IACL,aAAA;AAAA,IACA,aAAA;AAAA,IACA,UAAA;AAAA,IACA,iBAAiB,IAAI;AAAA,GACvB;AACF;;;ACpFO,IAAM,0BAAA,GAAkD;AAAA,EAC7D,QAAA,EAAU,aAAA;AAAA,EACV,SAAA,EAAW,eAAA;AAAA,EACX,YAAA,EAAc,MAAA;AAAA,EACd,OAAA,EAAS,IAAA;AAAA,EACT,OAAA,EAAS,CAAA;AAAA,EACT,QAAA,EAAU,CAAC,aAAA,EAAe,aAAA,EAAe,MAAM,OAAA,KAAY;AACzD,IAAA,MAAM,YAAA,GAAe,kBAAA;AAAA,MACnB,aAAA;AAAA,MACA,QAAQ,IAAA,CAAK;AAAA,KACf;AACA,IAAA,MAAM,iBAAiB,CAAC,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,UAAU,CAAC,CAAA;AACjD,IAAA,MAAM,MAAA,GAAS,oCAAA;AAAA,MACb,YAAA;AAAA,MACA,aAAA;AAAA,MACA,cAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,OAAO,iBAAA,CAAkB,MAAA,EAAQ,OAAA,CAAQ,IAAA,EAAM,QAAQ,GAAG,CAAA;AAAA,EAC5D,CAAA;AAAA,EACA,WAAA,EACE;AACJ","file":"contradicts.js","sourcesContent":["import {\n applyNegativeEvidence,\n applyNegativeSupport,\n cumulativeFusion,\n project,\n trustDiscount,\n type EdgeMetadata,\n type PropagationResult,\n type SLOpinion,\n} from \"@lucern/confidence\";\nimport type {\n EdgePropagationSpec,\n PropagationEdgeRecord,\n} from \"./propagationTypes\";\n\nexport function readEdgeMetadata<TNodeId extends string>(\n edge: PropagationEdgeRecord<TNodeId>\n): EdgeMetadata {\n return {\n constraint: edge.constraint ?? undefined,\n normalization: edge.normalization ?? undefined,\n propagation: edge.propagation ?? undefined,\n conditionalA: edge.conditionalA ?? undefined,\n conditionalNotA: edge.conditionalNotA ?? undefined,\n };\n}\n\nexport function applyPerHopDamping(\n sourceOpinion: SLOpinion,\n damping: number\n): SLOpinion {\n if (damping >= 1) {\n return sourceOpinion;\n }\n\n return trustDiscount(sourceOpinion, Math.max(0, damping));\n}\n\nexport function annotateRationale(\n result: PropagationResult,\n spec: EdgePropagationSpec,\n hop: number\n): PropagationResult {\n return {\n ...result,\n rationale: `hop=${hop} edge=${spec.edgeType} damping=${spec.damping.toFixed(\n 2\n )} :: ${result.rationale}`,\n };\n}\n\nexport function propagatePositiveSupport(\n sourceOpinion: SLOpinion,\n targetOpinion: SLOpinion,\n edgeWeight: number\n): PropagationResult {\n const discounted = trustDiscount(sourceOpinion, Math.abs(edgeWeight));\n return {\n opinion: cumulativeFusion(targetOpinion, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Supporting evidence (weight=${edgeWeight.toFixed(\n 2\n )}) from source at ${project(sourceOpinion).toFixed(2)}`,\n };\n}\n\nexport function propagatePositiveInform(\n sourceOpinion: SLOpinion,\n targetOpinion: SLOpinion,\n edgeWeight: number\n): PropagationResult {\n const discounted = trustDiscount(sourceOpinion, Math.abs(edgeWeight));\n return {\n opinion: cumulativeFusion(targetOpinion, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Supporting evidence (weight=${edgeWeight.toFixed(2)})`,\n };\n}\n\nexport function propagateNegativeSupportWithMetadata(\n sourceOpinion: SLOpinion,\n targetOpinion: SLOpinion,\n edgeWeight: number,\n edge: PropagationEdgeRecord\n): PropagationResult {\n return applyNegativeSupport(\n sourceOpinion,\n targetOpinion,\n edgeWeight,\n readEdgeMetadata(edge)\n );\n}\n\nexport const propagateNegativeInform = applyNegativeEvidence;\n","import type { EdgePropagationSpec } from \"./propagationTypes\";\nimport {\n annotateRationale,\n applyPerHopDamping,\n propagateNegativeSupportWithMetadata,\n} from \"./utils\";\n\nexport const contradictsPropagationSpec: EdgePropagationSpec = {\n edgeType: \"contradicts\",\n direction: \"bidirectional\",\n transitivity: \"none\",\n damping: 0.85,\n maxHops: 1,\n operator: (sourceOpinion, targetOpinion, edge, context) => {\n const dampedSource = applyPerHopDamping(\n sourceOpinion,\n context.spec.damping\n );\n const negativeWeight = -Math.abs(edge.weight ?? 1);\n const result = propagateNegativeSupportWithMetadata(\n dampedSource,\n targetOpinion,\n negativeWeight,\n edge\n );\n\n return annotateRationale(result, context.spec, context.hop);\n },\n description:\n \"Legacy contradiction edges move negative pressure in either direction, but never beyond one hop.\",\n};\n\n"]}
@@ -1,174 +1,6 @@
1
- // ../confidence/src/v1/operations/subjectiveLogic/index.ts
2
- function opinion(belief, disbelief, uncertainty, baseRate = 0.5) {
3
- const b = Math.max(0, Math.min(1, belief));
4
- const d = Math.max(0, Math.min(1, disbelief));
5
- const u = Math.max(0, Math.min(1, uncertainty));
6
- const a = Math.max(0, Math.min(1, baseRate));
7
- const sum = b + d + u;
8
- if (sum === 0) {
9
- return { b: 0, d: 0, u: 1, a };
10
- }
11
- return {
12
- b: b / sum,
13
- d: d / sum,
14
- u: u / sum,
15
- a
16
- };
17
- }
18
- function project(o) {
19
- return o.b + o.a * o.u;
20
- }
21
- function trustDiscount(sourceOpinion, trust) {
22
- const weight = Math.max(0, Math.min(1, Math.abs(trust)));
23
- return opinion(
24
- weight * sourceOpinion.b,
25
- weight * sourceOpinion.d,
26
- 1 - weight * (sourceOpinion.b + sourceOpinion.d),
27
- sourceOpinion.a
28
- );
29
- }
30
- var EPSILON = 1e-9;
31
- function childBaseRateFallback(ifTrue, ifFalse, fallbackBaseRate) {
32
- if (fallbackBaseRate !== void 0) {
33
- return Math.max(0, Math.min(1, fallbackBaseRate));
34
- }
35
- if (Math.abs(ifTrue.a - ifFalse.a) <= EPSILON) {
36
- return ifTrue.a;
37
- }
38
- return (ifTrue.a + ifFalse.a) / 2;
39
- }
40
- function computeConditionalDeductionBaseRate(opinionA, ifTrue, ifFalse, fallbackBaseRate) {
41
- const denominator = 1 - opinionA.a * ifTrue.u - (1 - opinionA.a) * ifFalse.u;
42
- if (ifTrue.u + ifFalse.u < 2 - EPSILON && Math.abs(denominator) > EPSILON) {
43
- const baseRate = (opinionA.a * ifTrue.b + (1 - opinionA.a) * ifFalse.b) / denominator;
44
- if (baseRate >= -EPSILON && baseRate <= 1 + EPSILON) {
45
- return Math.max(0, Math.min(1, baseRate));
46
- }
47
- }
48
- return fallbackBaseRate;
49
- }
50
- function safeCorrectionTerm(numerator, denominator) {
51
- if (Math.abs(denominator) <= EPSILON) {
52
- return void 0;
53
- }
54
- const value = numerator / denominator;
55
- if (!Number.isFinite(value)) {
56
- return void 0;
57
- }
58
- return Math.max(0, value);
59
- }
60
- function conditionalDeduction(opinionA, ifTrue, ifFalse, fallbackBaseRate) {
61
- const fallbackChildBaseRate = childBaseRateFallback(
62
- ifTrue,
63
- ifFalse,
64
- fallbackBaseRate
65
- );
66
- const childBaseRate = computeConditionalDeductionBaseRate(
67
- opinionA,
68
- ifTrue,
69
- ifFalse,
70
- fallbackChildBaseRate
71
- );
72
- const projectedAntecedent = project(opinionA);
73
- const projectedAntecedentComplement = 1 - projectedAntecedent;
74
- const intermediateBelief = opinionA.b * ifTrue.b + opinionA.d * ifFalse.b + opinionA.u * (ifTrue.b * opinionA.a + ifFalse.b * (1 - opinionA.a));
75
- const intermediateDisbelief = opinionA.b * ifTrue.d + opinionA.d * ifFalse.d + opinionA.u * (ifTrue.d * opinionA.a + ifFalse.d * (1 - opinionA.a));
76
- const intermediateUncertainty = opinionA.b * ifTrue.u + opinionA.d * ifFalse.u + opinionA.u * (ifTrue.u * opinionA.a + ifFalse.u * (1 - opinionA.a));
77
- const projectedVacuousDeduction = ifTrue.b * opinionA.a + ifFalse.b * (1 - opinionA.a) + childBaseRate * (ifTrue.u * opinionA.a + ifFalse.u * (1 - opinionA.a));
78
- const projectedConditionalA = ifTrue.b + childBaseRate * (1 - ifTrue.b - ifTrue.d);
79
- let correction = 0;
80
- if (ifTrue.b > ifFalse.b && ifTrue.d > ifFalse.d || ifTrue.b <= ifFalse.b && ifTrue.d <= ifFalse.d) {
81
- correction = 0;
82
- } else if (ifTrue.b > ifFalse.b && ifTrue.d <= ifFalse.d) {
83
- const beliefGap = ifTrue.b - ifFalse.b;
84
- const disbeliefGap = ifFalse.d - ifTrue.d;
85
- if (projectedVacuousDeduction <= projectedConditionalA && projectedAntecedent <= opinionA.a) {
86
- correction = safeCorrectionTerm(
87
- opinionA.a * opinionA.u * (intermediateBelief - ifTrue.b),
88
- projectedAntecedent * childBaseRate
89
- ) ?? 0;
90
- } else if (projectedVacuousDeduction <= projectedConditionalA && projectedAntecedent > opinionA.a) {
91
- correction = safeCorrectionTerm(
92
- opinionA.a * opinionA.u * (intermediateDisbelief - ifTrue.d) * beliefGap,
93
- projectedAntecedentComplement * childBaseRate * disbeliefGap
94
- ) ?? 0;
95
- } else if (projectedVacuousDeduction > projectedConditionalA && projectedAntecedent <= opinionA.a) {
96
- correction = safeCorrectionTerm(
97
- (1 - opinionA.a) * opinionA.u * (intermediateBelief - ifTrue.b) * disbeliefGap,
98
- projectedAntecedent * (1 - childBaseRate) * beliefGap
99
- ) ?? 0;
100
- } else {
101
- correction = safeCorrectionTerm(
102
- (1 - opinionA.a) * opinionA.u * (intermediateDisbelief - ifTrue.d),
103
- projectedAntecedentComplement * (1 - childBaseRate)
104
- ) ?? 0;
105
- }
106
- } else {
107
- const beliefGap = ifFalse.b - ifTrue.b;
108
- const disbeliefGap = ifTrue.d - ifFalse.d;
109
- if (projectedVacuousDeduction <= projectedConditionalA && projectedAntecedent <= opinionA.a) {
110
- correction = safeCorrectionTerm(
111
- (1 - opinionA.a) * opinionA.u * (intermediateDisbelief - ifTrue.d) * beliefGap,
112
- projectedAntecedent * childBaseRate * disbeliefGap
113
- ) ?? 0;
114
- } else if (projectedVacuousDeduction <= projectedConditionalA && projectedAntecedent > opinionA.a) {
115
- correction = safeCorrectionTerm(
116
- (1 - opinionA.a) * opinionA.u * (intermediateBelief - ifTrue.b),
117
- projectedAntecedentComplement * childBaseRate
118
- ) ?? 0;
119
- } else if (projectedVacuousDeduction > projectedConditionalA && projectedAntecedent <= opinionA.a) {
120
- correction = safeCorrectionTerm(
121
- opinionA.a * opinionA.u * (intermediateDisbelief - ifTrue.d),
122
- projectedAntecedent * (1 - childBaseRate)
123
- ) ?? 0;
124
- } else {
125
- correction = safeCorrectionTerm(
126
- opinionA.a * opinionA.u * (intermediateBelief - ifTrue.b) * disbeliefGap,
127
- projectedAntecedentComplement * (1 - childBaseRate) * beliefGap
128
- ) ?? 0;
129
- }
130
- }
131
- return opinion(
132
- intermediateBelief - childBaseRate * correction,
133
- intermediateDisbelief - (1 - childBaseRate) * correction,
134
- intermediateUncertainty + correction,
135
- childBaseRate
136
- );
137
- }
138
-
139
- // ../confidence/src/v1/operations/dynamics/cascade.ts
140
- function dampedDependencyOpinion(dependencyOpinion, beliefOpinion, mode = "continuous", threshold = 0.3) {
141
- const dependencyProjection = project(dependencyOpinion);
142
- if (mode === "threshold") {
143
- if (dependencyProjection < threshold) {
144
- return opinion(
145
- 0,
146
- beliefOpinion.d + beliefOpinion.b * 0.5,
147
- 0.5,
148
- beliefOpinion.a
149
- );
150
- }
151
- return beliefOpinion;
152
- }
153
- const dampingFactor = Math.pow(dependencyProjection, 0.5);
154
- return opinion(
155
- beliefOpinion.b * dampingFactor,
156
- beliefOpinion.d + beliefOpinion.b * (1 - dampingFactor) * 0.3,
157
- beliefOpinion.u + beliefOpinion.b * (1 - dampingFactor) * 0.7,
158
- beliefOpinion.a
159
- );
160
- }
161
- function dampedDependencyCascade(dependencyOpinion, beliefOpinion, mode = "continuous") {
162
- return {
163
- opinion: dampedDependencyOpinion(dependencyOpinion, beliefOpinion, mode),
164
- operator: "dependency_cascade",
165
- rationale: `Damped dependency cascade (${mode}): prerequisite at ${project(
166
- dependencyOpinion
167
- ).toFixed(2)}`
168
- };
169
- }
1
+ import { conditionalDeduction, mkOpinion, project, dampedDependencyCascade, trustDiscount } from '@lucern/confidence';
170
2
 
171
- // src/edges/utils.ts
3
+ // src/edges/dependsOn.ts
172
4
  function readEdgeMetadata(edge) {
173
5
  return {
174
6
  constraint: edge.constraint ?? void 0,
@@ -209,8 +41,18 @@ var dependsOnPropagationSpec = {
209
41
  if (metadata.conditionalA && metadata.conditionalNotA) {
210
42
  const deducedOpinion = conditionalDeduction(
211
43
  dampedSource,
212
- metadata.conditionalA,
213
- metadata.conditionalNotA,
44
+ mkOpinion(
45
+ metadata.conditionalA.b,
46
+ metadata.conditionalA.d,
47
+ metadata.conditionalA.u,
48
+ metadata.conditionalA.a
49
+ ),
50
+ mkOpinion(
51
+ metadata.conditionalNotA.b,
52
+ metadata.conditionalNotA.d,
53
+ metadata.conditionalNotA.u,
54
+ metadata.conditionalNotA.a
55
+ ),
214
56
  targetOpinion.a
215
57
  );
216
58
  return annotateRationale(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../confidence/src/v1/operations/subjectiveLogic/index.ts","../../../confidence/src/v1/operations/dynamics/cascade.ts","../../src/edges/utils.ts","../../src/edges/dependsOn.ts"],"names":[],"mappings":";AAEO,SAAS,OAAA,CACd,MAAA,EACA,SAAA,EACA,WAAA,EACA,WAAmB,GAAA,EACV;AACT,EAAA,MAAM,CAAA,GAAI,KAAK,GAAA,CAAI,CAAA,EAAG,KAAK,GAAA,CAAI,CAAA,EAAG,MAAM,CAAC,CAAA;AACzC,EAAA,MAAM,CAAA,GAAI,KAAK,GAAA,CAAI,CAAA,EAAG,KAAK,GAAA,CAAI,CAAA,EAAG,SAAS,CAAC,CAAA;AAC5C,EAAA,MAAM,CAAA,GAAI,KAAK,GAAA,CAAI,CAAA,EAAG,KAAK,GAAA,CAAI,CAAA,EAAG,WAAW,CAAC,CAAA;AAC9C,EAAA,MAAM,CAAA,GAAI,KAAK,GAAA,CAAI,CAAA,EAAG,KAAK,GAAA,CAAI,CAAA,EAAG,QAAQ,CAAC,CAAA;AAC3C,EAAA,MAAM,GAAA,GAAM,IAAI,CAAA,GAAI,CAAA;AAEpB,EAAA,IAAI,QAAQ,CAAA,EAAG;AACb,IAAA,OAAO,EAAE,CAAA,EAAG,CAAA,EAAG,GAAG,CAAA,EAAG,CAAA,EAAG,GAAG,CAAA,EAAE;AAAA,EAC/B;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,CAAA,GAAI,GAAA;AAAA,IACP,GAAG,CAAA,GAAI,GAAA;AAAA,IACP,GAAG,CAAA,GAAI,GAAA;AAAA,IACP;AAAA,GACF;AACF;AAWO,SAAS,QAAQ,CAAA,EAAoB;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AAU,CAAC,aAAA,EAAe,aAAA,EAAe,MAAM,OAAA,KAAY;AACzD,IAAA,MAAM,YAAA,GAAe,kBAAA;AAAA,MACnB,aAAA;AAAA,MACA,QAAQ,IAAA,CAAK;AAAA,KACf;AACA,IAAA,MAAM,QAAA,GAAW,iBAAiB,IAAI,CAAA;AAEtC,IAAA,IAAI,QAAA,CAAS,YAAA,IAAgB,QAAA,CAAS,eAAA,EAAiB;AACrD,MAAA,MAAM,cAAA,GAAiB,oBAAA;AAAA,QACrB,YAAA;AAAA,QACA,QAAA,CAAS,YAAA;AAAA,QACT,QAAA,CAAS,eAAA;AAAA,QACT,aAAA,CAAc;AAAA,OAChB;AAEA,MAAA,OAAO,iBAAA;AAAA,QACL;AAAA,UACE,OAAA,EAAS,cAAA;AAAA,UACT,QAAA,EAAU,uBAAA;AAAA,UACV,WAAW,CAAA,uCAAA,EAA0C,OAAA;AAAA,YACnD;AAAA,WACF,CAAE,OAAA,CAAQ,CAAC,CAAC,CAAA;AAAA,SACd;AAAA,QACA,OAAA,CAAQ,IAAA;AAAA,QACR,OAAA,CAAQ;AAAA,OACV;AAAA,IACF;AAEA,IAAA,MAAM,MAAA,GAAS,uBAAA;AAAA,MACb,YAAA;AAAA,MACA,aAAA;AAAA,MACA,SAAS,WAAA,IAAe;AAAA,KAC1B;AAEA,IAAA,OAAO,iBAAA,CAAkB,MAAA,EAAQ,OAAA,CAAQ,IAAA,EAAM,QAAQ,GAAG,CAAA;AAAA,EAC5D,CAAA;AAAA,EACA,WAAA,EACE;AACJ","file":"dependsOn.js","sourcesContent":["import type { Opinion } from \"../../types\";\n\nexport function opinion(\n belief: number,\n disbelief: number,\n uncertainty: number,\n baseRate: number = 0.5\n): Opinion {\n const b = Math.max(0, Math.min(1, belief));\n const d = Math.max(0, Math.min(1, disbelief));\n const u = Math.max(0, Math.min(1, uncertainty));\n const a = Math.max(0, Math.min(1, baseRate));\n const sum = b + d + u;\n\n if (sum === 0) {\n return { b: 0, d: 0, u: 1, a };\n }\n\n return {\n b: b / sum,\n d: d / sum,\n u: u / sum,\n a,\n };\n}\n\nexport function vacuous(baseRate: number = 0.5): Opinion {\n return { b: 0, d: 0, u: 1, a: baseRate };\n}\n\nexport function dogmatic(probability: number, baseRate: number = 0.5): Opinion {\n const p = Math.max(0, Math.min(1, probability));\n return { b: p, d: 1 - p, u: 0, a: baseRate };\n}\n\nexport function project(o: Opinion): number {\n return o.b + o.a * o.u;\n}\n\nexport function confidenceLevel(o: Opinion): \"high\" | \"medium\" | \"low\" {\n const projected = project(o);\n if (o.u > 0.5) {\n return \"low\";\n }\n if (projected >= 0.8 && o.u < 0.2) {\n return \"high\";\n }\n if (projected >= 0.6) {\n return \"medium\";\n }\n return \"low\";\n}\n\nexport function cumulativeFusion(left: Opinion, right: Opinion): Opinion {\n if (left.u === 0 && right.u === 0) {\n return opinion(\n (left.b + right.b) / 2,\n (left.d + right.d) / 2,\n 0,\n (left.a + right.a) / 2\n );\n }\n\n const k = left.u + right.u - left.u * right.u;\n if (k === 0) {\n return vacuous((left.a + right.a) / 2);\n }\n\n return opinion(\n (left.b * right.u + right.b * left.u) / k,\n (left.d * right.u + right.d * left.u) / k,\n (left.u * right.u) / k,\n (left.a + right.a) / 2\n );\n}\n\nexport function averagingFusion(left: Opinion, right: Opinion): Opinion {\n if (left.u === 0 && right.u === 0) {\n return opinion(\n (left.b + right.b) / 2,\n (left.d + right.d) / 2,\n 0,\n (left.a + right.a) / 2\n );\n }\n\n const k = left.u + right.u;\n if (k === 0) {\n return vacuous((left.a + right.a) / 2);\n }\n\n return opinion(\n (left.b * right.u + right.b * left.u) / k,\n (left.d * right.u + right.d * left.u) / k,\n (2 * left.u * right.u) / k,\n (left.a + right.a) / 2\n );\n}\n\nexport function trustDiscount(sourceOpinion: Opinion, trust: number): Opinion {\n const weight = Math.max(0, Math.min(1, Math.abs(trust)));\n return opinion(\n weight * sourceOpinion.b,\n weight * sourceOpinion.d,\n 1 - weight * (sourceOpinion.b + sourceOpinion.d),\n sourceOpinion.a\n );\n}\n\nconst EPSILON = 1e-9;\n\nfunction childBaseRateFallback(\n ifTrue: Opinion,\n ifFalse: Opinion,\n fallbackBaseRate: number | undefined\n): number {\n if (fallbackBaseRate !== undefined) {\n return Math.max(0, Math.min(1, fallbackBaseRate));\n }\n\n if (Math.abs(ifTrue.a - ifFalse.a) <= EPSILON) {\n return ifTrue.a;\n }\n\n return (ifTrue.a + ifFalse.a) / 2;\n}\n\nfunction computeConditionalDeductionBaseRate(\n opinionA: Opinion,\n ifTrue: Opinion,\n ifFalse: Opinion,\n fallbackBaseRate: number\n): number {\n const denominator =\n 1 - opinionA.a * ifTrue.u - (1 - opinionA.a) * ifFalse.u;\n\n if (ifTrue.u + ifFalse.u < 2 - EPSILON && Math.abs(denominator) > EPSILON) {\n const baseRate =\n (opinionA.a * ifTrue.b + (1 - opinionA.a) * ifFalse.b) / denominator;\n if (baseRate >= -EPSILON && baseRate <= 1 + EPSILON) {\n return Math.max(0, Math.min(1, baseRate));\n }\n }\n\n return fallbackBaseRate;\n}\n\nfunction safeCorrectionTerm(\n numerator: number,\n denominator: number\n): number | undefined {\n if (Math.abs(denominator) <= EPSILON) {\n return undefined;\n }\n\n const value = numerator / denominator;\n if (!Number.isFinite(value)) {\n return undefined;\n }\n\n return Math.max(0, value);\n}\n\nexport function conditionalDeduction(\n opinionA: Opinion,\n ifTrue: Opinion,\n ifFalse: Opinion,\n fallbackBaseRate?: number\n): Opinion {\n const fallbackChildBaseRate = childBaseRateFallback(\n ifTrue,\n ifFalse,\n fallbackBaseRate\n );\n const childBaseRate = computeConditionalDeductionBaseRate(\n opinionA,\n ifTrue,\n ifFalse,\n fallbackChildBaseRate\n );\n const projectedAntecedent = project(opinionA);\n const projectedAntecedentComplement = 1 - projectedAntecedent;\n const intermediateBelief =\n opinionA.b * ifTrue.b +\n opinionA.d * ifFalse.b +\n opinionA.u * (ifTrue.b * opinionA.a + ifFalse.b * (1 - opinionA.a));\n const intermediateDisbelief =\n opinionA.b * ifTrue.d +\n opinionA.d * ifFalse.d +\n opinionA.u * (ifTrue.d * opinionA.a + ifFalse.d * (1 - opinionA.a));\n const intermediateUncertainty =\n opinionA.b * ifTrue.u +\n opinionA.d * ifFalse.u +\n opinionA.u * (ifTrue.u * opinionA.a + ifFalse.u * (1 - opinionA.a));\n const projectedVacuousDeduction =\n ifTrue.b * opinionA.a +\n ifFalse.b * (1 - opinionA.a) +\n childBaseRate *\n (ifTrue.u * opinionA.a + ifFalse.u * (1 - opinionA.a));\n const projectedConditionalA =\n ifTrue.b + childBaseRate * (1 - ifTrue.b - ifTrue.d);\n let correction = 0;\n\n if (\n (ifTrue.b > ifFalse.b && ifTrue.d > ifFalse.d) ||\n (ifTrue.b <= ifFalse.b && ifTrue.d <= ifFalse.d)\n ) {\n correction = 0;\n } else if (ifTrue.b > ifFalse.b && ifTrue.d <= ifFalse.d) {\n const beliefGap = ifTrue.b - ifFalse.b;\n const disbeliefGap = ifFalse.d - ifTrue.d;\n\n if (\n projectedVacuousDeduction <= projectedConditionalA &&\n projectedAntecedent <= opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n opinionA.a * opinionA.u * (intermediateBelief - ifTrue.b),\n projectedAntecedent * childBaseRate\n ) ?? 0;\n } else if (\n projectedVacuousDeduction <= projectedConditionalA &&\n projectedAntecedent > opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n opinionA.a * opinionA.u * (intermediateDisbelief - ifTrue.d) * beliefGap,\n projectedAntecedentComplement * childBaseRate * disbeliefGap\n ) ?? 0;\n } else if (\n projectedVacuousDeduction > projectedConditionalA &&\n projectedAntecedent <= opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n (1 - opinionA.a) *\n opinionA.u *\n (intermediateBelief - ifTrue.b) *\n disbeliefGap,\n projectedAntecedent * (1 - childBaseRate) * beliefGap\n ) ?? 0;\n } else {\n correction =\n safeCorrectionTerm(\n (1 - opinionA.a) * opinionA.u * (intermediateDisbelief - ifTrue.d),\n projectedAntecedentComplement * (1 - childBaseRate)\n ) ?? 0;\n }\n } else {\n const beliefGap = ifFalse.b - ifTrue.b;\n const disbeliefGap = ifTrue.d - ifFalse.d;\n\n if (\n projectedVacuousDeduction <= projectedConditionalA &&\n projectedAntecedent <= opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n (1 - opinionA.a) *\n opinionA.u *\n (intermediateDisbelief - ifTrue.d) *\n beliefGap,\n projectedAntecedent * childBaseRate * disbeliefGap\n ) ?? 0;\n } else if (\n projectedVacuousDeduction <= projectedConditionalA &&\n projectedAntecedent > opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n (1 - opinionA.a) * opinionA.u * (intermediateBelief - ifTrue.b),\n projectedAntecedentComplement * childBaseRate\n ) ?? 0;\n } else if (\n projectedVacuousDeduction > projectedConditionalA &&\n projectedAntecedent <= opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n opinionA.a * opinionA.u * (intermediateDisbelief - ifTrue.d),\n projectedAntecedent * (1 - childBaseRate)\n ) ?? 0;\n } else {\n correction =\n safeCorrectionTerm(\n opinionA.a *\n opinionA.u *\n (intermediateBelief - ifTrue.b) *\n disbeliefGap,\n projectedAntecedentComplement * (1 - childBaseRate) * beliefGap\n ) ?? 0;\n }\n }\n\n return opinion(\n intermediateBelief - childBaseRate * correction,\n intermediateDisbelief - (1 - childBaseRate) * correction,\n intermediateUncertainty + correction,\n childBaseRate\n );\n}\n\n/**\n * Abductive inference over a conditional.\n * Given an opinion on Y and conditionals P(Y|X), P(Y|~X), infer an opinion on X.\n */\nexport function conditionalAbduction(\n opinionY: Opinion,\n ifTrue: Opinion,\n ifFalse: Opinion,\n baseRateX: number\n): Opinion {\n const priorX = Math.max(0, Math.min(1, baseRateX));\n const probabilityY = project(opinionY);\n const probabilityGivenTrue = project(ifTrue);\n const probabilityGivenFalse = project(ifFalse);\n\n const posteriorIfYDenominator =\n probabilityGivenTrue * priorX +\n probabilityGivenFalse * (1 - priorX);\n const posteriorIfY =\n posteriorIfYDenominator === 0\n ? priorX\n : (probabilityGivenTrue * priorX) / posteriorIfYDenominator;\n\n const posteriorIfNotYDenominator =\n (1 - probabilityGivenTrue) * priorX +\n (1 - probabilityGivenFalse) * (1 - priorX);\n const posteriorIfNotY =\n posteriorIfNotYDenominator === 0\n ? priorX\n : ((1 - probabilityGivenTrue) * priorX) / posteriorIfNotYDenominator;\n\n const projectedX =\n probabilityY * posteriorIfY + (1 - probabilityY) * posteriorIfNotY;\n const uncertainty = Math.max(\n opinionY.u * 0.5,\n probabilityY * ifTrue.u + (1 - probabilityY) * ifFalse.u\n );\n\n return opinion(\n projectedX * (1 - uncertainty),\n (1 - projectedX) * (1 - uncertainty),\n uncertainty,\n priorX\n );\n}\n\nexport function negate(o: Opinion): Opinion {\n return { b: o.d, d: o.b, u: o.u, a: 1 - o.a };\n}\n\nexport function constraintFusion(\n left: Opinion,\n right: Opinion,\n mode: \"pressure\" | \"redistribute\" = \"pressure\"\n): { o1: Opinion; o2: Opinion } {\n if (mode === \"redistribute\") {\n const leftProjected = project(left);\n const rightProjected = project(right);\n const total = leftProjected + rightProjected;\n\n if (total <= 1) {\n return { o1: left, o2: right };\n }\n\n const scale = 1 / total;\n return {\n o1: opinion(\n left.b * scale,\n left.d + left.b * (1 - scale),\n left.u,\n left.a\n ),\n o2: opinion(\n right.b * scale,\n right.d + right.b * (1 - scale),\n right.u,\n right.a\n ),\n };\n }\n\n const pressureLeft = right.b * 0.5;\n const pressureRight = left.b * 0.5;\n\n return {\n o1: opinion(\n left.b - pressureLeft * 0.3,\n left.d + pressureLeft * 0.3,\n left.u,\n left.a\n ),\n o2: opinion(\n right.b - pressureRight * 0.3,\n right.d + pressureRight * 0.3,\n right.u,\n right.a\n ),\n };\n}\n\nexport function evidenceBalance(o: Opinion): number {\n const total = o.b + o.d;\n if (total === 0) {\n return 0;\n }\n return (o.b - o.d) / total;\n}\n\nexport function areTensioned(left: Opinion, right: Opinion): boolean {\n return (\n project(left) > 0.5 &&\n project(right) > 0.5 &&\n (left.d > 0.2 || right.d > 0.2)\n );\n}\n\nexport function informationGain(o: Opinion): number {\n if (o.u === 0) {\n return 0;\n }\n if (o.u === 1) {\n return 1;\n }\n return o.u * (1 - Math.abs(o.b - o.d));\n}\n","import type { Opinion, PropagationMode, PropagationResult } from \"../../types\";\nimport { opinion, project } from \"../subjectiveLogic\";\n\nexport function dampedDependencyOpinion(\n dependencyOpinion: Opinion,\n beliefOpinion: Opinion,\n mode: PropagationMode = \"continuous\",\n threshold: number = 0.3\n): Opinion {\n const dependencyProjection = project(dependencyOpinion);\n\n if (mode === \"threshold\") {\n if (dependencyProjection < threshold) {\n return opinion(\n 0,\n beliefOpinion.d + beliefOpinion.b * 0.5,\n 0.5,\n beliefOpinion.a\n );\n }\n return beliefOpinion;\n }\n\n const dampingFactor = Math.pow(dependencyProjection, 0.5);\n return opinion(\n beliefOpinion.b * dampingFactor,\n beliefOpinion.d + beliefOpinion.b * (1 - dampingFactor) * 0.3,\n beliefOpinion.u + beliefOpinion.b * (1 - dampingFactor) * 0.7,\n beliefOpinion.a\n );\n}\n\nexport function dampedDependencyCascade(\n dependencyOpinion: Opinion,\n beliefOpinion: Opinion,\n mode: PropagationMode = \"continuous\"\n): PropagationResult {\n return {\n opinion: dampedDependencyOpinion(dependencyOpinion, beliefOpinion, mode),\n operator: \"dependency_cascade\",\n rationale: `Damped dependency cascade (${mode}): prerequisite at ${project(\n dependencyOpinion\n ).toFixed(2)}`,\n };\n}\n","import {\n applyNegativeEvidence,\n applyNegativeSupport,\n cumulativeFusion,\n project,\n trustDiscount,\n type EdgeMetadata,\n type Opinion,\n type PropagationResult,\n} from \"@lucern/confidence\";\nimport type {\n EdgePropagationSpec,\n PropagationEdgeRecord,\n} from \"./propagationTypes\";\n\nexport function readEdgeMetadata<TNodeId extends string>(\n edge: PropagationEdgeRecord<TNodeId>\n): EdgeMetadata {\n return {\n constraint: edge.constraint ?? undefined,\n normalization: edge.normalization ?? undefined,\n propagation: edge.propagation ?? undefined,\n conditionalA: edge.conditionalA ?? undefined,\n conditionalNotA: edge.conditionalNotA ?? undefined,\n };\n}\n\nexport function applyPerHopDamping(\n sourceOpinion: Opinion,\n damping: number\n): Opinion {\n if (damping >= 1) {\n return sourceOpinion;\n }\n\n return trustDiscount(sourceOpinion, Math.max(0, damping));\n}\n\nexport function annotateRationale(\n result: PropagationResult,\n spec: EdgePropagationSpec,\n hop: number\n): PropagationResult {\n return {\n ...result,\n rationale: `hop=${hop} edge=${spec.edgeType} damping=${spec.damping.toFixed(\n 2\n )} :: ${result.rationale}`,\n };\n}\n\nexport function propagatePositiveSupport(\n sourceOpinion: Opinion,\n targetOpinion: Opinion,\n edgeWeight: number\n): PropagationResult {\n const discounted = trustDiscount(sourceOpinion, Math.abs(edgeWeight));\n return {\n opinion: cumulativeFusion(targetOpinion, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Supporting evidence (weight=${edgeWeight.toFixed(\n 2\n )}) from source at ${project(sourceOpinion).toFixed(2)}`,\n };\n}\n\nexport function propagatePositiveInform(\n sourceOpinion: Opinion,\n targetOpinion: Opinion,\n edgeWeight: number\n): PropagationResult {\n const discounted = trustDiscount(sourceOpinion, Math.abs(edgeWeight));\n return {\n opinion: cumulativeFusion(targetOpinion, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Supporting evidence (weight=${edgeWeight.toFixed(2)})`,\n };\n}\n\nexport function propagateNegativeSupportWithMetadata(\n sourceOpinion: Opinion,\n targetOpinion: Opinion,\n edgeWeight: number,\n edge: PropagationEdgeRecord\n): PropagationResult {\n return applyNegativeSupport(\n sourceOpinion,\n targetOpinion,\n edgeWeight,\n readEdgeMetadata(edge)\n );\n}\n\nexport function propagateNegativeInform(\n sourceOpinion: Opinion,\n targetOpinion: Opinion,\n edgeWeight: number\n): PropagationResult {\n return applyNegativeEvidence(sourceOpinion, targetOpinion, edgeWeight);\n}\n\n","import {\n conditionalDeduction,\n dampedDependencyCascade,\n project,\n} from \"@lucern/confidence\";\nimport type { EdgePropagationSpec } from \"./propagationTypes\";\nimport { annotateRationale, applyPerHopDamping, readEdgeMetadata } from \"./utils\";\n\nexport const dependsOnPropagationSpec: EdgePropagationSpec = {\n edgeType: \"depends_on\",\n direction: \"incoming\",\n transitivity: \"damped\",\n damping: 0.8,\n maxHops: \"unbounded\",\n operator: (sourceOpinion, targetOpinion, edge, context) => {\n const dampedSource = applyPerHopDamping(\n sourceOpinion,\n context.spec.damping\n );\n const metadata = readEdgeMetadata(edge);\n\n if (metadata.conditionalA && metadata.conditionalNotA) {\n const deducedOpinion = conditionalDeduction(\n dampedSource,\n metadata.conditionalA,\n metadata.conditionalNotA,\n targetOpinion.a\n );\n\n return annotateRationale(\n {\n opinion: deducedOpinion,\n operator: \"conditional_deduction\",\n rationale: `Conditional deduction: prerequisite at ${project(\n dampedSource\n ).toFixed(2)}`,\n },\n context.spec,\n context.hop\n );\n }\n\n const result = dampedDependencyCascade(\n dampedSource,\n targetOpinion,\n metadata.propagation ?? \"continuous\"\n );\n\n return annotateRationale(result, context.spec, context.hop);\n },\n description:\n \"Structural gating. Textbook conditional deduction when edge conditionals exist, otherwise damped dependency cascade through downstream chains.\",\n};\n\n"]}
1
+ {"version":3,"sources":["../../src/edges/utils.ts","../../src/edges/dependsOn.ts"],"names":["project"],"mappings":";;;AAeO,SAAS,iBACd,IAAA,EACc;AACd,EAAA,OAAO;AAAA,IACL,UAAA,EAAY,KAAK,UAAA,IAAc,MAAA;AAAA,IAC/B,aAAA,EAAe,KAAK,aAAA,IAAiB,MAAA;AAAA,IACrC,WAAA,EAAa,KAAK,WAAA,IAAe,MAAA;AAAA,IACjC,YAAA,EAAc,KAAK,YAAA,IAAgB,MAAA;AAAA,IACnC,eAAA,EAAiB,KAAK,eAAA,IAAmB;AAAA,GAC3C;AACF;AAEO,SAAS,kBAAA,CACd,eACA,OAAA,EACW;AACX,EAAA,IAAI,WAAW,CAAA,EAAG;AAChB,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,OAAO,cAAc,aA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AAA,CAAc;AAAA,OAChB;AAEA,MAAA,OAAO,iBAAA;AAAA,QACL;AAAA,UACE,OAAA,EAAS,cAAA;AAAA,UACT,QAAA,EAAU,uBAAA;AAAA,UACV,WAAW,CAAA,uCAAA,EAA0CA,OAAAA;AAAA,YACnD;AAAA,WACF,CAAE,OAAA,CAAQ,CAAC,CAAC,CAAA;AAAA,SACd;AAAA,QACA,OAAA,CAAQ,IAAA;AAAA,QACR,OAAA,CAAQ;AAAA,OACV;AAAA,IACF;AAEA,IAAA,MAAM,MAAA,GAAS,uBAAA;AAAA,MACb,YAAA;AAAA,MACA,aAAA;AAAA,MACA,SAAS,WAAA,IAAe;AAAA,KAC1B;AAEA,IAAA,OAAO,iBAAA,CAAkB,MAAA,EAAQ,OAAA,CAAQ,IAAA,EAAM,QAAQ,GAAG,CAAA;AAAA,EAC5D,CAAA;AAAA,EACA,WAAA,EACE;AACJ","file":"dependsOn.js","sourcesContent":["import {\n applyNegativeEvidence,\n applyNegativeSupport,\n cumulativeFusion,\n project,\n trustDiscount,\n type EdgeMetadata,\n type PropagationResult,\n type SLOpinion,\n} from \"@lucern/confidence\";\nimport type {\n EdgePropagationSpec,\n PropagationEdgeRecord,\n} from \"./propagationTypes\";\n\nexport function readEdgeMetadata<TNodeId extends string>(\n edge: PropagationEdgeRecord<TNodeId>\n): EdgeMetadata {\n return {\n constraint: edge.constraint ?? undefined,\n normalization: edge.normalization ?? undefined,\n propagation: edge.propagation ?? undefined,\n conditionalA: edge.conditionalA ?? undefined,\n conditionalNotA: edge.conditionalNotA ?? undefined,\n };\n}\n\nexport function applyPerHopDamping(\n sourceOpinion: SLOpinion,\n damping: number\n): SLOpinion {\n if (damping >= 1) {\n return sourceOpinion;\n }\n\n return trustDiscount(sourceOpinion, Math.max(0, damping));\n}\n\nexport function annotateRationale(\n result: PropagationResult,\n spec: EdgePropagationSpec,\n hop: number\n): PropagationResult {\n return {\n ...result,\n rationale: `hop=${hop} edge=${spec.edgeType} damping=${spec.damping.toFixed(\n 2\n )} :: ${result.rationale}`,\n };\n}\n\nexport function propagatePositiveSupport(\n sourceOpinion: SLOpinion,\n targetOpinion: SLOpinion,\n edgeWeight: number\n): PropagationResult {\n const discounted = trustDiscount(sourceOpinion, Math.abs(edgeWeight));\n return {\n opinion: cumulativeFusion(targetOpinion, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Supporting evidence (weight=${edgeWeight.toFixed(\n 2\n )}) from source at ${project(sourceOpinion).toFixed(2)}`,\n };\n}\n\nexport function propagatePositiveInform(\n sourceOpinion: SLOpinion,\n targetOpinion: SLOpinion,\n edgeWeight: number\n): PropagationResult {\n const discounted = trustDiscount(sourceOpinion, Math.abs(edgeWeight));\n return {\n opinion: cumulativeFusion(targetOpinion, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Supporting evidence (weight=${edgeWeight.toFixed(2)})`,\n };\n}\n\nexport function propagateNegativeSupportWithMetadata(\n sourceOpinion: SLOpinion,\n targetOpinion: SLOpinion,\n edgeWeight: number,\n edge: PropagationEdgeRecord\n): PropagationResult {\n return applyNegativeSupport(\n sourceOpinion,\n targetOpinion,\n edgeWeight,\n readEdgeMetadata(edge)\n );\n}\n\nexport const propagateNegativeInform = applyNegativeEvidence;\n","import {\n conditionalDeduction,\n dampedDependencyCascade,\n mkOpinion,\n project,\n} from \"@lucern/confidence\";\nimport type { EdgePropagationSpec } from \"./propagationTypes\";\nimport { annotateRationale, applyPerHopDamping, readEdgeMetadata } from \"./utils\";\n\nexport const dependsOnPropagationSpec: EdgePropagationSpec = {\n edgeType: \"depends_on\",\n direction: \"incoming\",\n transitivity: \"damped\",\n damping: 0.8,\n maxHops: \"unbounded\",\n operator: (sourceOpinion, targetOpinion, edge, context) => {\n const dampedSource = applyPerHopDamping(\n sourceOpinion,\n context.spec.damping\n );\n const metadata = readEdgeMetadata(edge);\n\n if (metadata.conditionalA && metadata.conditionalNotA) {\n const deducedOpinion = conditionalDeduction(\n dampedSource,\n mkOpinion(\n metadata.conditionalA.b,\n metadata.conditionalA.d,\n metadata.conditionalA.u,\n metadata.conditionalA.a\n ),\n mkOpinion(\n metadata.conditionalNotA.b,\n metadata.conditionalNotA.d,\n metadata.conditionalNotA.u,\n metadata.conditionalNotA.a\n ),\n targetOpinion.a\n );\n\n return annotateRationale(\n {\n opinion: deducedOpinion,\n operator: \"conditional_deduction\",\n rationale: `Conditional deduction: prerequisite at ${project(\n dampedSource\n ).toFixed(2)}`,\n },\n context.spec,\n context.hop\n );\n }\n\n const result = dampedDependencyCascade(\n dampedSource,\n targetOpinion,\n metadata.propagation ?? \"continuous\"\n );\n\n return annotateRationale(result, context.spec, context.hop);\n },\n description:\n \"Structural gating. Textbook conditional deduction when edge conditionals exist, otherwise damped dependency cascade through downstream chains.\",\n};\n"]}
@@ -1,52 +1,4 @@
1
- // ../confidence/src/v1/operations/subjectiveLogic/index.ts
2
- function opinion(belief, disbelief, uncertainty, baseRate = 0.5) {
3
- const b = Math.max(0, Math.min(1, belief));
4
- const d = Math.max(0, Math.min(1, disbelief));
5
- const u = Math.max(0, Math.min(1, uncertainty));
6
- const a = Math.max(0, Math.min(1, baseRate));
7
- const sum = b + d + u;
8
- if (sum === 0) {
9
- return { b: 0, d: 0, u: 1, a };
10
- }
11
- return {
12
- b: b / sum,
13
- d: d / sum,
14
- u: u / sum,
15
- a
16
- };
17
- }
18
- function vacuous(baseRate = 0.5) {
19
- return { b: 0, d: 0, u: 1, a: baseRate };
20
- }
21
- function cumulativeFusion(left, right) {
22
- if (left.u === 0 && right.u === 0) {
23
- return opinion(
24
- (left.b + right.b) / 2,
25
- (left.d + right.d) / 2,
26
- 0,
27
- (left.a + right.a) / 2
28
- );
29
- }
30
- const k = left.u + right.u - left.u * right.u;
31
- if (k === 0) {
32
- return vacuous((left.a + right.a) / 2);
33
- }
34
- return opinion(
35
- (left.b * right.u + right.b * left.u) / k,
36
- (left.d * right.u + right.d * left.u) / k,
37
- left.u * right.u / k,
38
- (left.a + right.a) / 2
39
- );
40
- }
41
- function trustDiscount(sourceOpinion, trust) {
42
- const weight = Math.max(0, Math.min(1, Math.abs(trust)));
43
- return opinion(
44
- weight * sourceOpinion.b,
45
- weight * sourceOpinion.d,
46
- 1 - weight * (sourceOpinion.b + sourceOpinion.d),
47
- sourceOpinion.a
48
- );
49
- }
1
+ import { trustDiscount, cumulativeFusion } from '@lucern/confidence';
50
2
 
51
3
  // src/edges/utils.ts
52
4
  function applyPerHopDamping(sourceOpinion, damping) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../confidence/src/v1/operations/subjectiveLogic/index.ts","../../src/edges/utils.ts","../../src/edges/elaborates.ts"],"names":[],"mappings":";AAEO,SAAS,OAAA,CACd,MAAA,EACA,SAAA,EACA,WAAA,EACA,WAAmB,GAAA,EACV;AACT,EAAA,MAAM,CAAA,GAAI,KAAK,GAAA,CAAI,CAAA,EAAG,KAAK,GAAA,CAAI,CAAA,EAAG,MAAM,CAAC,CAAA;AACzC,EAAA,MAAM,CAAA,GAAI,KAAK,GAAA,CAAI,CAAA,EAAG,KAAK,GAAA,CAAI,CAAA,EAAG,SAAS,CAAC,CAAA;AAC5C,EAAA,MAAM,CAAA,GAAI,KAAK,GAAA,CAAI,CAAA,EAAG,KAAK,GAAA,CAAI,CAAA,EAAG,WAAW,CAAC,CAAA;AAC9C,EAAA,MAAM,CAAA,GAAI,KAAK,GAAA,CAAI,CAAA,EAAG,KAAK,GAAA,CAAI,CAAA,EAAG,QAAQ,CAAC,CAAA;AAC3C,EAAA,MAAM,GAAA,GAAM,IAAI,CAAA,GAAI,CAAA;AAEpB,EAAA,IAAI,QAAQ,CAAA,EAAG;AACb,IAAA,OAAO,EAAE,CAAA,EAAG,CAAA,EAAG,GAAG,CAAA,EAAG,CAAA,EAAG,GAAG,CAAA,EAAE;AAAA,EAC/B;AAEA,EAAA,OAAO;AAAA,IACL,GAAG,CAAA,GAAI,GAAA;AAAA,IACP,GAAG,CAAA,GAAI,GAAA;AAAA,IACP,GAAG,CAAA,GAAI,GAAA;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AAA,CAAA;AAAA,GACjE;AACF;;;ACtEO,IAAM,yBAAA,GAAiD;AAAA,EAC5D,QAAA,EAAU,YAAA;AAAA,EACV,SAAA,EAAW,UAAA;AAAA,EACX,YAAA,EAAc,QAAA;AAAA,EACd,OAAA,EAAS,GAAA;AAAA,EACT,OAAA,EAAS,CAAA;AAAA,EACT,QAAA,EAAU,CAAC,aAAA,EAAe,aAAA,EAAe,MAAM,OAAA,KAAY;AACzD,IAAA,MAAM,YAAA,GAAe,kBAAA;AAAA,MACnB,aAAA;AAAA,MACA,QAAQ,IAAA,CAAK;AAAA,KACf;AACA,IAAA,MAAM,gBAAA,GAAmB,KAAK,GAAA,CAAI,IAAA,CAAK,IAAI,IAAA,CAAK,MAAA,IAAU,IAAI,CAAA,EAAG,IAAI,CAAA;AACrE,IAAA,MAAM,MAAA,GAAS,uBAAA;AAAA,MACb,YAAA;AAAA,MACA,aAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,OAAO,iBAAA,CAAkB,MAAA,EAAQ,OAAA,CAAQ,IAAA,EAAM,QAAQ,GAAG,CAAA;AAAA,EAC5D,CAAA;AAAA,EACA,WAAA,EACE;AACJ","file":"elaborates.js","sourcesContent":["import type { Opinion } from \"../../types\";\n\nexport function opinion(\n belief: number,\n disbelief: number,\n uncertainty: number,\n baseRate: number = 0.5\n): Opinion {\n const b = Math.max(0, Math.min(1, belief));\n const d = Math.max(0, Math.min(1, disbelief));\n const u = Math.max(0, Math.min(1, uncertainty));\n const a = Math.max(0, Math.min(1, baseRate));\n const sum = b + d + u;\n\n if (sum === 0) {\n return { b: 0, d: 0, u: 1, a };\n }\n\n return {\n b: b / sum,\n d: d / sum,\n u: u / sum,\n a,\n };\n}\n\nexport function vacuous(baseRate: number = 0.5): Opinion {\n return { b: 0, d: 0, u: 1, a: baseRate };\n}\n\nexport function dogmatic(probability: number, baseRate: number = 0.5): Opinion {\n const p = Math.max(0, Math.min(1, probability));\n return { b: p, d: 1 - p, u: 0, a: baseRate };\n}\n\nexport function project(o: Opinion): number {\n return o.b + o.a * o.u;\n}\n\nexport function confidenceLevel(o: Opinion): \"high\" | \"medium\" | \"low\" {\n const projected = project(o);\n if (o.u > 0.5) {\n return \"low\";\n }\n if (projected >= 0.8 && o.u < 0.2) {\n return \"high\";\n }\n if (projected >= 0.6) {\n return \"medium\";\n }\n return \"low\";\n}\n\nexport function cumulativeFusion(left: Opinion, right: Opinion): Opinion {\n if (left.u === 0 && right.u === 0) {\n return opinion(\n (left.b + right.b) / 2,\n (left.d + right.d) / 2,\n 0,\n (left.a + right.a) / 2\n );\n }\n\n const k = left.u + right.u - left.u * right.u;\n if (k === 0) {\n return vacuous((left.a + right.a) / 2);\n }\n\n return opinion(\n (left.b * right.u + right.b * left.u) / k,\n (left.d * right.u + right.d * left.u) / k,\n (left.u * right.u) / k,\n (left.a + right.a) / 2\n );\n}\n\nexport function averagingFusion(left: Opinion, right: Opinion): Opinion {\n if (left.u === 0 && right.u === 0) {\n return opinion(\n (left.b + right.b) / 2,\n (left.d + right.d) / 2,\n 0,\n (left.a + right.a) / 2\n );\n }\n\n const k = left.u + right.u;\n if (k === 0) {\n return vacuous((left.a + right.a) / 2);\n }\n\n return opinion(\n (left.b * right.u + right.b * left.u) / k,\n (left.d * right.u + right.d * left.u) / k,\n (2 * left.u * right.u) / k,\n (left.a + right.a) / 2\n );\n}\n\nexport function trustDiscount(sourceOpinion: Opinion, trust: number): Opinion {\n const weight = Math.max(0, Math.min(1, Math.abs(trust)));\n return opinion(\n weight * sourceOpinion.b,\n weight * sourceOpinion.d,\n 1 - weight * (sourceOpinion.b + sourceOpinion.d),\n sourceOpinion.a\n );\n}\n\nconst EPSILON = 1e-9;\n\nfunction childBaseRateFallback(\n ifTrue: Opinion,\n ifFalse: Opinion,\n fallbackBaseRate: number | undefined\n): number {\n if (fallbackBaseRate !== undefined) {\n return Math.max(0, Math.min(1, fallbackBaseRate));\n }\n\n if (Math.abs(ifTrue.a - ifFalse.a) <= EPSILON) {\n return ifTrue.a;\n }\n\n return (ifTrue.a + ifFalse.a) / 2;\n}\n\nfunction computeConditionalDeductionBaseRate(\n opinionA: Opinion,\n ifTrue: Opinion,\n ifFalse: Opinion,\n fallbackBaseRate: number\n): number {\n const denominator =\n 1 - opinionA.a * ifTrue.u - (1 - opinionA.a) * ifFalse.u;\n\n if (ifTrue.u + ifFalse.u < 2 - EPSILON && Math.abs(denominator) > EPSILON) {\n const baseRate =\n (opinionA.a * ifTrue.b + (1 - opinionA.a) * ifFalse.b) / denominator;\n if (baseRate >= -EPSILON && baseRate <= 1 + EPSILON) {\n return Math.max(0, Math.min(1, baseRate));\n }\n }\n\n return fallbackBaseRate;\n}\n\nfunction safeCorrectionTerm(\n numerator: number,\n denominator: number\n): number | undefined {\n if (Math.abs(denominator) <= EPSILON) {\n return undefined;\n }\n\n const value = numerator / denominator;\n if (!Number.isFinite(value)) {\n return undefined;\n }\n\n return Math.max(0, value);\n}\n\nexport function conditionalDeduction(\n opinionA: Opinion,\n ifTrue: Opinion,\n ifFalse: Opinion,\n fallbackBaseRate?: number\n): Opinion {\n const fallbackChildBaseRate = childBaseRateFallback(\n ifTrue,\n ifFalse,\n fallbackBaseRate\n );\n const childBaseRate = computeConditionalDeductionBaseRate(\n opinionA,\n ifTrue,\n ifFalse,\n fallbackChildBaseRate\n );\n const projectedAntecedent = project(opinionA);\n const projectedAntecedentComplement = 1 - projectedAntecedent;\n const intermediateBelief =\n opinionA.b * ifTrue.b +\n opinionA.d * ifFalse.b +\n opinionA.u * (ifTrue.b * opinionA.a + ifFalse.b * (1 - opinionA.a));\n const intermediateDisbelief =\n opinionA.b * ifTrue.d +\n opinionA.d * ifFalse.d +\n opinionA.u * (ifTrue.d * opinionA.a + ifFalse.d * (1 - opinionA.a));\n const intermediateUncertainty =\n opinionA.b * ifTrue.u +\n opinionA.d * ifFalse.u +\n opinionA.u * (ifTrue.u * opinionA.a + ifFalse.u * (1 - opinionA.a));\n const projectedVacuousDeduction =\n ifTrue.b * opinionA.a +\n ifFalse.b * (1 - opinionA.a) +\n childBaseRate *\n (ifTrue.u * opinionA.a + ifFalse.u * (1 - opinionA.a));\n const projectedConditionalA =\n ifTrue.b + childBaseRate * (1 - ifTrue.b - ifTrue.d);\n let correction = 0;\n\n if (\n (ifTrue.b > ifFalse.b && ifTrue.d > ifFalse.d) ||\n (ifTrue.b <= ifFalse.b && ifTrue.d <= ifFalse.d)\n ) {\n correction = 0;\n } else if (ifTrue.b > ifFalse.b && ifTrue.d <= ifFalse.d) {\n const beliefGap = ifTrue.b - ifFalse.b;\n const disbeliefGap = ifFalse.d - ifTrue.d;\n\n if (\n projectedVacuousDeduction <= projectedConditionalA &&\n projectedAntecedent <= opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n opinionA.a * opinionA.u * (intermediateBelief - ifTrue.b),\n projectedAntecedent * childBaseRate\n ) ?? 0;\n } else if (\n projectedVacuousDeduction <= projectedConditionalA &&\n projectedAntecedent > opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n opinionA.a * opinionA.u * (intermediateDisbelief - ifTrue.d) * beliefGap,\n projectedAntecedentComplement * childBaseRate * disbeliefGap\n ) ?? 0;\n } else if (\n projectedVacuousDeduction > projectedConditionalA &&\n projectedAntecedent <= opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n (1 - opinionA.a) *\n opinionA.u *\n (intermediateBelief - ifTrue.b) *\n disbeliefGap,\n projectedAntecedent * (1 - childBaseRate) * beliefGap\n ) ?? 0;\n } else {\n correction =\n safeCorrectionTerm(\n (1 - opinionA.a) * opinionA.u * (intermediateDisbelief - ifTrue.d),\n projectedAntecedentComplement * (1 - childBaseRate)\n ) ?? 0;\n }\n } else {\n const beliefGap = ifFalse.b - ifTrue.b;\n const disbeliefGap = ifTrue.d - ifFalse.d;\n\n if (\n projectedVacuousDeduction <= projectedConditionalA &&\n projectedAntecedent <= opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n (1 - opinionA.a) *\n opinionA.u *\n (intermediateDisbelief - ifTrue.d) *\n beliefGap,\n projectedAntecedent * childBaseRate * disbeliefGap\n ) ?? 0;\n } else if (\n projectedVacuousDeduction <= projectedConditionalA &&\n projectedAntecedent > opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n (1 - opinionA.a) * opinionA.u * (intermediateBelief - ifTrue.b),\n projectedAntecedentComplement * childBaseRate\n ) ?? 0;\n } else if (\n projectedVacuousDeduction > projectedConditionalA &&\n projectedAntecedent <= opinionA.a\n ) {\n correction =\n safeCorrectionTerm(\n opinionA.a * opinionA.u * (intermediateDisbelief - ifTrue.d),\n projectedAntecedent * (1 - childBaseRate)\n ) ?? 0;\n } else {\n correction =\n safeCorrectionTerm(\n opinionA.a *\n opinionA.u *\n (intermediateBelief - ifTrue.b) *\n disbeliefGap,\n projectedAntecedentComplement * (1 - childBaseRate) * beliefGap\n ) ?? 0;\n }\n }\n\n return opinion(\n intermediateBelief - childBaseRate * correction,\n intermediateDisbelief - (1 - childBaseRate) * correction,\n intermediateUncertainty + correction,\n childBaseRate\n );\n}\n\n/**\n * Abductive inference over a conditional.\n * Given an opinion on Y and conditionals P(Y|X), P(Y|~X), infer an opinion on X.\n */\nexport function conditionalAbduction(\n opinionY: Opinion,\n ifTrue: Opinion,\n ifFalse: Opinion,\n baseRateX: number\n): Opinion {\n const priorX = Math.max(0, Math.min(1, baseRateX));\n const probabilityY = project(opinionY);\n const probabilityGivenTrue = project(ifTrue);\n const probabilityGivenFalse = project(ifFalse);\n\n const posteriorIfYDenominator =\n probabilityGivenTrue * priorX +\n probabilityGivenFalse * (1 - priorX);\n const posteriorIfY =\n posteriorIfYDenominator === 0\n ? priorX\n : (probabilityGivenTrue * priorX) / posteriorIfYDenominator;\n\n const posteriorIfNotYDenominator =\n (1 - probabilityGivenTrue) * priorX +\n (1 - probabilityGivenFalse) * (1 - priorX);\n const posteriorIfNotY =\n posteriorIfNotYDenominator === 0\n ? priorX\n : ((1 - probabilityGivenTrue) * priorX) / posteriorIfNotYDenominator;\n\n const projectedX =\n probabilityY * posteriorIfY + (1 - probabilityY) * posteriorIfNotY;\n const uncertainty = Math.max(\n opinionY.u * 0.5,\n probabilityY * ifTrue.u + (1 - probabilityY) * ifFalse.u\n );\n\n return opinion(\n projectedX * (1 - uncertainty),\n (1 - projectedX) * (1 - uncertainty),\n uncertainty,\n priorX\n );\n}\n\nexport function negate(o: Opinion): Opinion {\n return { b: o.d, d: o.b, u: o.u, a: 1 - o.a };\n}\n\nexport function constraintFusion(\n left: Opinion,\n right: Opinion,\n mode: \"pressure\" | \"redistribute\" = \"pressure\"\n): { o1: Opinion; o2: Opinion } {\n if (mode === \"redistribute\") {\n const leftProjected = project(left);\n const rightProjected = project(right);\n const total = leftProjected + rightProjected;\n\n if (total <= 1) {\n return { o1: left, o2: right };\n }\n\n const scale = 1 / total;\n return {\n o1: opinion(\n left.b * scale,\n left.d + left.b * (1 - scale),\n left.u,\n left.a\n ),\n o2: opinion(\n right.b * scale,\n right.d + right.b * (1 - scale),\n right.u,\n right.a\n ),\n };\n }\n\n const pressureLeft = right.b * 0.5;\n const pressureRight = left.b * 0.5;\n\n return {\n o1: opinion(\n left.b - pressureLeft * 0.3,\n left.d + pressureLeft * 0.3,\n left.u,\n left.a\n ),\n o2: opinion(\n right.b - pressureRight * 0.3,\n right.d + pressureRight * 0.3,\n right.u,\n right.a\n ),\n };\n}\n\nexport function evidenceBalance(o: Opinion): number {\n const total = o.b + o.d;\n if (total === 0) {\n return 0;\n }\n return (o.b - o.d) / total;\n}\n\nexport function areTensioned(left: Opinion, right: Opinion): boolean {\n return (\n project(left) > 0.5 &&\n project(right) > 0.5 &&\n (left.d > 0.2 || right.d > 0.2)\n );\n}\n\nexport function informationGain(o: Opinion): number {\n if (o.u === 0) {\n return 0;\n }\n if (o.u === 1) {\n return 1;\n }\n return o.u * (1 - Math.abs(o.b - o.d));\n}\n","import {\n applyNegativeEvidence,\n applyNegativeSupport,\n cumulativeFusion,\n project,\n trustDiscount,\n type EdgeMetadata,\n type Opinion,\n type PropagationResult,\n} from \"@lucern/confidence\";\nimport type {\n EdgePropagationSpec,\n PropagationEdgeRecord,\n} from \"./propagationTypes\";\n\nexport function readEdgeMetadata<TNodeId extends string>(\n edge: PropagationEdgeRecord<TNodeId>\n): EdgeMetadata {\n return {\n constraint: edge.constraint ?? undefined,\n normalization: edge.normalization ?? undefined,\n propagation: edge.propagation ?? undefined,\n conditionalA: edge.conditionalA ?? undefined,\n conditionalNotA: edge.conditionalNotA ?? undefined,\n };\n}\n\nexport function applyPerHopDamping(\n sourceOpinion: Opinion,\n damping: number\n): Opinion {\n if (damping >= 1) {\n return sourceOpinion;\n }\n\n return trustDiscount(sourceOpinion, Math.max(0, damping));\n}\n\nexport function annotateRationale(\n result: PropagationResult,\n spec: EdgePropagationSpec,\n hop: number\n): PropagationResult {\n return {\n ...result,\n rationale: `hop=${hop} edge=${spec.edgeType} damping=${spec.damping.toFixed(\n 2\n )} :: ${result.rationale}`,\n };\n}\n\nexport function propagatePositiveSupport(\n sourceOpinion: Opinion,\n targetOpinion: Opinion,\n edgeWeight: number\n): PropagationResult {\n const discounted = trustDiscount(sourceOpinion, Math.abs(edgeWeight));\n return {\n opinion: cumulativeFusion(targetOpinion, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Supporting evidence (weight=${edgeWeight.toFixed(\n 2\n )}) from source at ${project(sourceOpinion).toFixed(2)}`,\n };\n}\n\nexport function propagatePositiveInform(\n sourceOpinion: Opinion,\n targetOpinion: Opinion,\n edgeWeight: number\n): PropagationResult {\n const discounted = trustDiscount(sourceOpinion, Math.abs(edgeWeight));\n return {\n opinion: cumulativeFusion(targetOpinion, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Supporting evidence (weight=${edgeWeight.toFixed(2)})`,\n };\n}\n\nexport function propagateNegativeSupportWithMetadata(\n sourceOpinion: Opinion,\n targetOpinion: Opinion,\n edgeWeight: number,\n edge: PropagationEdgeRecord\n): PropagationResult {\n return applyNegativeSupport(\n sourceOpinion,\n targetOpinion,\n edgeWeight,\n readEdgeMetadata(edge)\n );\n}\n\nexport function propagateNegativeInform(\n sourceOpinion: Opinion,\n targetOpinion: Opinion,\n edgeWeight: number\n): PropagationResult {\n return applyNegativeEvidence(sourceOpinion, targetOpinion, edgeWeight);\n}\n\n","import type { EdgePropagationSpec } from \"./propagationTypes\";\nimport {\n annotateRationale,\n applyPerHopDamping,\n propagatePositiveInform,\n} from \"./utils\";\n\nexport const elaboratesPropagationSpec: EdgePropagationSpec = {\n edgeType: \"elaborates\",\n direction: \"outgoing\",\n transitivity: \"damped\",\n damping: 0.7,\n maxHops: 2,\n operator: (sourceOpinion, targetOpinion, edge, context) => {\n const dampedSource = applyPerHopDamping(\n sourceOpinion,\n context.spec.damping\n );\n const contextualWeight = Math.min(Math.abs(edge.weight ?? 0.35), 0.35);\n const result = propagatePositiveInform(\n dampedSource,\n targetOpinion,\n contextualWeight\n );\n\n return annotateRationale(result, context.spec, context.hop);\n },\n description:\n \"Context-rich supporting detail. Elaborates carries a small positive effect with short, damped chaining.\",\n};\n\n"]}
1
+ {"version":3,"sources":["../../src/edges/utils.ts","../../src/edges/elaborates.ts"],"names":[],"mappings":";;;AA2BO,SAAS,kBAAA,CACd,eACA,OAAA,EACW;AACX,EAAA,IAAI,WAAW,CAAA,EAAG;AAChB,IAAA,OAAO,aAAA;AAAA,EACT;AAEA,EAAA,OAAO,cAAc,aAAA,EAAe,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,OAAO,CAAC,CAAA;AAC1D;AAEO,SAAS,iBAAA,CACd,MAAA,EACA,IAAA,EACA,GAAA,EACmB;AACnB,EAAA,OAAO;AAAA,IACL,GAAG,MAAA;AAAA,IACH,SAAA,EAAW,OAAO,GAAG,CAAA,MAAA,EAAS,KAAK,QAAQ,CAAA,SAAA,EAAY,KAAK,OAAA,CAAQ,OAAA;AAAA,MAClE;AAAA,KACD,CAAA,IAAA,EAAO,MAAA,CAAO,SAAS,CAAA;AAAA,GAC1B;AACF;AAiBO,SAAS,uBAAA,CACd,aAAA,EACA,aAAA,EACA,UAAA,EACmB;AACnB,EAAA,MAAM,aAAa,aAAA,CAAc,aAAA,EAAe,IAAA,CAAK,GAAA,CAAI,UAAU,CAAC,CAAA;AACpE,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,gBAAA,CAAiB,aAAA,EAAe,UAAU,CAAA;AAAA,IACnD,QAAA,EAAU,mBAAA;AAAA,IACV,SAAA,EAAW,CAAA,4BAAA,EAA+B,UAAA,CAAW,OAAA,CAAQ,CAAC,CAAC,CAAA,CAAA;AAAA,GACjE;AACF;;;ACtEO,IAAM,yBAAA,GAAiD;AAAA,EAC5D,QAAA,EAAU,YAAA;AAAA,EACV,SAAA,EAAW,UAAA;AAAA,EACX,YAAA,EAAc,QAAA;AAAA,EACd,OAAA,EAAS,GAAA;AAAA,EACT,OAAA,EAAS,CAAA;AAAA,EACT,QAAA,EAAU,CAAC,aAAA,EAAe,aAAA,EAAe,MAAM,OAAA,KAAY;AACzD,IAAA,MAAM,YAAA,GAAe,kBAAA;AAAA,MACnB,aAAA;AAAA,MACA,QAAQ,IAAA,CAAK;AAAA,KACf;AACA,IAAA,MAAM,gBAAA,GAAmB,KAAK,GAAA,CAAI,IAAA,CAAK,IAAI,IAAA,CAAK,MAAA,IAAU,IAAI,CAAA,EAAG,IAAI,CAAA;AACrE,IAAA,MAAM,MAAA,GAAS,uBAAA;AAAA,MACb,YAAA;AAAA,MACA,aAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,OAAO,iBAAA,CAAkB,MAAA,EAAQ,OAAA,CAAQ,IAAA,EAAM,QAAQ,GAAG,CAAA;AAAA,EAC5D,CAAA;AAAA,EACA,WAAA,EACE;AACJ","file":"elaborates.js","sourcesContent":["import {\n applyNegativeEvidence,\n applyNegativeSupport,\n cumulativeFusion,\n project,\n trustDiscount,\n type EdgeMetadata,\n type PropagationResult,\n type SLOpinion,\n} from \"@lucern/confidence\";\nimport type {\n EdgePropagationSpec,\n PropagationEdgeRecord,\n} from \"./propagationTypes\";\n\nexport function readEdgeMetadata<TNodeId extends string>(\n edge: PropagationEdgeRecord<TNodeId>\n): EdgeMetadata {\n return {\n constraint: edge.constraint ?? undefined,\n normalization: edge.normalization ?? undefined,\n propagation: edge.propagation ?? undefined,\n conditionalA: edge.conditionalA ?? undefined,\n conditionalNotA: edge.conditionalNotA ?? undefined,\n };\n}\n\nexport function applyPerHopDamping(\n sourceOpinion: SLOpinion,\n damping: number\n): SLOpinion {\n if (damping >= 1) {\n return sourceOpinion;\n }\n\n return trustDiscount(sourceOpinion, Math.max(0, damping));\n}\n\nexport function annotateRationale(\n result: PropagationResult,\n spec: EdgePropagationSpec,\n hop: number\n): PropagationResult {\n return {\n ...result,\n rationale: `hop=${hop} edge=${spec.edgeType} damping=${spec.damping.toFixed(\n 2\n )} :: ${result.rationale}`,\n };\n}\n\nexport function propagatePositiveSupport(\n sourceOpinion: SLOpinion,\n targetOpinion: SLOpinion,\n edgeWeight: number\n): PropagationResult {\n const discounted = trustDiscount(sourceOpinion, Math.abs(edgeWeight));\n return {\n opinion: cumulativeFusion(targetOpinion, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Supporting evidence (weight=${edgeWeight.toFixed(\n 2\n )}) from source at ${project(sourceOpinion).toFixed(2)}`,\n };\n}\n\nexport function propagatePositiveInform(\n sourceOpinion: SLOpinion,\n targetOpinion: SLOpinion,\n edgeWeight: number\n): PropagationResult {\n const discounted = trustDiscount(sourceOpinion, Math.abs(edgeWeight));\n return {\n opinion: cumulativeFusion(targetOpinion, discounted),\n operator: \"cumulative_fusion\",\n rationale: `Supporting evidence (weight=${edgeWeight.toFixed(2)})`,\n };\n}\n\nexport function propagateNegativeSupportWithMetadata(\n sourceOpinion: SLOpinion,\n targetOpinion: SLOpinion,\n edgeWeight: number,\n edge: PropagationEdgeRecord\n): PropagationResult {\n return applyNegativeSupport(\n sourceOpinion,\n targetOpinion,\n edgeWeight,\n readEdgeMetadata(edge)\n );\n}\n\nexport const propagateNegativeInform = applyNegativeEvidence;\n","import type { EdgePropagationSpec } from \"./propagationTypes\";\nimport {\n annotateRationale,\n applyPerHopDamping,\n propagatePositiveInform,\n} from \"./utils\";\n\nexport const elaboratesPropagationSpec: EdgePropagationSpec = {\n edgeType: \"elaborates\",\n direction: \"outgoing\",\n transitivity: \"damped\",\n damping: 0.7,\n maxHops: 2,\n operator: (sourceOpinion, targetOpinion, edge, context) => {\n const dampedSource = applyPerHopDamping(\n sourceOpinion,\n context.spec.damping\n );\n const contextualWeight = Math.min(Math.abs(edge.weight ?? 0.35), 0.35);\n const result = propagatePositiveInform(\n dampedSource,\n targetOpinion,\n contextualWeight\n );\n\n return annotateRationale(result, context.spec, context.hop);\n },\n description:\n \"Context-rich supporting detail. Elaborates carries a small positive effect with short, damped chaining.\",\n};\n\n"]}