@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
@@ -40,4 +40,4 @@ declare namespace beliefLifecycle {
40
40
  export { type beliefLifecycle_BeliefLifecycleStatus as BeliefLifecycleStatus, beliefLifecycle_hasResolvedPredictionOutcome as hasResolvedPredictionOutcome, beliefLifecycle_isBeliefLifecycleStatus as isBeliefLifecycleStatus, beliefLifecycle_isPreValidationBeliefStatus as isPreValidationBeliefStatus, beliefLifecycle_isPropagationEligibleBeliefStatus as isPropagationEligibleBeliefStatus, beliefLifecycle_isResolvedByConfidence as isResolvedByConfidence, beliefLifecycle_promoteBeliefStatusAfterScoring as promoteBeliefStatusAfterScoring, beliefLifecycle_resolveBeliefLifecycleStatus as resolveBeliefLifecycleStatus, beliefLifecycle_shouldTreatBeliefAsFact as shouldTreatBeliefAsFact };
41
41
  }
42
42
 
43
- export { type BeliefLifecycleStatus as B, isResolvedByConfidence as a, beliefLifecycle as b, isPreValidationBeliefStatus as c, isPropagationEligibleBeliefStatus as d, hasResolvedPredictionOutcome as h, isBeliefLifecycleStatus as i, promoteBeliefStatusAfterScoring as p, resolveBeliefLifecycleStatus as r, shouldTreatBeliefAsFact as s };
43
+ export { type BeliefLifecycleStatus as B, isPreValidationBeliefStatus as a, beliefLifecycle as b, isPropagationEligibleBeliefStatus as c, isResolvedByConfidence as d, hasResolvedPredictionOutcome as h, isBeliefLifecycleStatus as i, promoteBeliefStatusAfterScoring as p, resolveBeliefLifecycleStatus as r, shouldTreatBeliefAsFact as s };
@@ -1 +1 @@
1
- export { B as BeliefLifecycleStatus, h as hasResolvedPredictionOutcome, i as isBeliefLifecycleStatus, c as isPreValidationBeliefStatus, d as isPropagationEligibleBeliefStatus, a as isResolvedByConfidence, p as promoteBeliefStatusAfterScoring, r as resolveBeliefLifecycleStatus, s as shouldTreatBeliefAsFact } from './beliefLifecycle-C-AehZgF.js';
1
+ export { B as BeliefLifecycleStatus, h as hasResolvedPredictionOutcome, i as isBeliefLifecycleStatus, a as isPreValidationBeliefStatus, c as isPropagationEligibleBeliefStatus, d as isResolvedByConfidence, p as promoteBeliefStatusAfterScoring, r as resolveBeliefLifecycleStatus, s as shouldTreatBeliefAsFact } from './beliefLifecycle-y8WLXqQj.js';
@@ -1,5 +1,5 @@
1
- import { Opinion, SLOperator } from '@lucern/confidence';
2
- import { PropagationEdgeRecord, PropagationEdgeType, PropagationTraversalDirection, EdgePropagationSpec } from './edges/propagationTypes.js';
1
+ import { SLOpinion, SLOperator } from '@lucern/confidence';
2
+ import { PropagationEdgeType, PropagationTraversalDirection, PropagationEdgeRecord, EdgePropagationSpec } from './edges/propagationTypes.js';
3
3
 
4
4
  type PropagationDispatchScope = {
5
5
  tenantId?: string;
@@ -24,14 +24,14 @@ type ConfidencePropagationDispatch<TNodeId extends string = string> = {
24
24
  edgeType: PropagationEdgeType;
25
25
  traversedDirection: PropagationTraversalDirection;
26
26
  weight: number;
27
- opinion: Opinion;
27
+ opinion: SLOpinion;
28
28
  operator: SLOperator;
29
29
  rationale: string;
30
30
  hop: number;
31
31
  };
32
32
  declare function collectConfidencePropagationDispatches<TNodeId extends string = string>(args: {
33
33
  sourceNodeId: TNodeId;
34
- sourceOpinion: Opinion;
34
+ sourceOpinion: SLOpinion;
35
35
  sourceScope?: PropagationDispatchScope;
36
36
  traversalSpecs?: readonly EdgePropagationSpec<TNodeId>[];
37
37
  queryEdges: (args: {
@@ -1,296 +1,7 @@
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
- var EPSILON = 1e-9;
54
- function childBaseRateFallback(ifTrue, ifFalse, fallbackBaseRate) {
55
- if (fallbackBaseRate !== void 0) {
56
- return Math.max(0, Math.min(1, fallbackBaseRate));
57
- }
58
- if (Math.abs(ifTrue.a - ifFalse.a) <= EPSILON) {
59
- return ifTrue.a;
60
- }
61
- return (ifTrue.a + ifFalse.a) / 2;
62
- }
63
- function computeConditionalDeductionBaseRate(opinionA, ifTrue, ifFalse, fallbackBaseRate) {
64
- const denominator = 1 - opinionA.a * ifTrue.u - (1 - opinionA.a) * ifFalse.u;
65
- if (ifTrue.u + ifFalse.u < 2 - EPSILON && Math.abs(denominator) > EPSILON) {
66
- const baseRate = (opinionA.a * ifTrue.b + (1 - opinionA.a) * ifFalse.b) / denominator;
67
- if (baseRate >= -EPSILON && baseRate <= 1 + EPSILON) {
68
- return Math.max(0, Math.min(1, baseRate));
69
- }
70
- }
71
- return fallbackBaseRate;
72
- }
73
- function safeCorrectionTerm(numerator, denominator) {
74
- if (Math.abs(denominator) <= EPSILON) {
75
- return void 0;
76
- }
77
- const value = numerator / denominator;
78
- if (!Number.isFinite(value)) {
79
- return void 0;
80
- }
81
- return Math.max(0, value);
82
- }
83
- function conditionalDeduction(opinionA, ifTrue, ifFalse, fallbackBaseRate) {
84
- const fallbackChildBaseRate = childBaseRateFallback(
85
- ifTrue,
86
- ifFalse,
87
- fallbackBaseRate
88
- );
89
- const childBaseRate = computeConditionalDeductionBaseRate(
90
- opinionA,
91
- ifTrue,
92
- ifFalse,
93
- fallbackChildBaseRate
94
- );
95
- const projectedAntecedent = project(opinionA);
96
- const projectedAntecedentComplement = 1 - projectedAntecedent;
97
- const intermediateBelief = opinionA.b * ifTrue.b + opinionA.d * ifFalse.b + opinionA.u * (ifTrue.b * opinionA.a + ifFalse.b * (1 - opinionA.a));
98
- const intermediateDisbelief = opinionA.b * ifTrue.d + opinionA.d * ifFalse.d + opinionA.u * (ifTrue.d * opinionA.a + ifFalse.d * (1 - opinionA.a));
99
- const intermediateUncertainty = opinionA.b * ifTrue.u + opinionA.d * ifFalse.u + opinionA.u * (ifTrue.u * opinionA.a + ifFalse.u * (1 - opinionA.a));
100
- const projectedVacuousDeduction = ifTrue.b * opinionA.a + ifFalse.b * (1 - opinionA.a) + childBaseRate * (ifTrue.u * opinionA.a + ifFalse.u * (1 - opinionA.a));
101
- const projectedConditionalA = ifTrue.b + childBaseRate * (1 - ifTrue.b - ifTrue.d);
102
- let correction = 0;
103
- if (ifTrue.b > ifFalse.b && ifTrue.d > ifFalse.d || ifTrue.b <= ifFalse.b && ifTrue.d <= ifFalse.d) {
104
- correction = 0;
105
- } else if (ifTrue.b > ifFalse.b && ifTrue.d <= ifFalse.d) {
106
- const beliefGap = ifTrue.b - ifFalse.b;
107
- const disbeliefGap = ifFalse.d - ifTrue.d;
108
- if (projectedVacuousDeduction <= projectedConditionalA && projectedAntecedent <= opinionA.a) {
109
- correction = safeCorrectionTerm(
110
- opinionA.a * opinionA.u * (intermediateBelief - ifTrue.b),
111
- projectedAntecedent * childBaseRate
112
- ) ?? 0;
113
- } else if (projectedVacuousDeduction <= projectedConditionalA && projectedAntecedent > opinionA.a) {
114
- correction = safeCorrectionTerm(
115
- opinionA.a * opinionA.u * (intermediateDisbelief - ifTrue.d) * beliefGap,
116
- projectedAntecedentComplement * childBaseRate * disbeliefGap
117
- ) ?? 0;
118
- } else if (projectedVacuousDeduction > projectedConditionalA && projectedAntecedent <= opinionA.a) {
119
- correction = safeCorrectionTerm(
120
- (1 - opinionA.a) * opinionA.u * (intermediateBelief - ifTrue.b) * disbeliefGap,
121
- projectedAntecedent * (1 - childBaseRate) * beliefGap
122
- ) ?? 0;
123
- } else {
124
- correction = safeCorrectionTerm(
125
- (1 - opinionA.a) * opinionA.u * (intermediateDisbelief - ifTrue.d),
126
- projectedAntecedentComplement * (1 - childBaseRate)
127
- ) ?? 0;
128
- }
129
- } else {
130
- const beliefGap = ifFalse.b - ifTrue.b;
131
- const disbeliefGap = ifTrue.d - ifFalse.d;
132
- if (projectedVacuousDeduction <= projectedConditionalA && projectedAntecedent <= opinionA.a) {
133
- correction = safeCorrectionTerm(
134
- (1 - opinionA.a) * opinionA.u * (intermediateDisbelief - ifTrue.d) * beliefGap,
135
- projectedAntecedent * childBaseRate * disbeliefGap
136
- ) ?? 0;
137
- } else if (projectedVacuousDeduction <= projectedConditionalA && projectedAntecedent > opinionA.a) {
138
- correction = safeCorrectionTerm(
139
- (1 - opinionA.a) * opinionA.u * (intermediateBelief - ifTrue.b),
140
- projectedAntecedentComplement * childBaseRate
141
- ) ?? 0;
142
- } else if (projectedVacuousDeduction > projectedConditionalA && projectedAntecedent <= opinionA.a) {
143
- correction = safeCorrectionTerm(
144
- opinionA.a * opinionA.u * (intermediateDisbelief - ifTrue.d),
145
- projectedAntecedent * (1 - childBaseRate)
146
- ) ?? 0;
147
- } else {
148
- correction = safeCorrectionTerm(
149
- opinionA.a * opinionA.u * (intermediateBelief - ifTrue.b) * disbeliefGap,
150
- projectedAntecedentComplement * (1 - childBaseRate) * beliefGap
151
- ) ?? 0;
152
- }
153
- }
154
- return opinion(
155
- intermediateBelief - childBaseRate * correction,
156
- intermediateDisbelief - (1 - childBaseRate) * correction,
157
- intermediateUncertainty + correction,
158
- childBaseRate
159
- );
160
- }
161
- function negate(o) {
162
- return { b: o.d, d: o.b, u: o.u, a: 1 - o.a };
163
- }
164
- function constraintFusion(left, right, mode = "pressure") {
165
- if (mode === "redistribute") {
166
- const leftProjected = project(left);
167
- const rightProjected = project(right);
168
- const total = leftProjected + rightProjected;
169
- if (total <= 1) {
170
- return { o1: left, o2: right };
171
- }
172
- const scale = 1 / total;
173
- return {
174
- o1: opinion(
175
- left.b * scale,
176
- left.d + left.b * (1 - scale),
177
- left.u,
178
- left.a
179
- ),
180
- o2: opinion(
181
- right.b * scale,
182
- right.d + right.b * (1 - scale),
183
- right.u,
184
- right.a
185
- )
186
- };
187
- }
188
- const pressureLeft = right.b * 0.5;
189
- const pressureRight = left.b * 0.5;
190
- return {
191
- o1: opinion(
192
- left.b - pressureLeft * 0.3,
193
- left.d + pressureLeft * 0.3,
194
- left.u,
195
- left.a
196
- ),
197
- o2: opinion(
198
- right.b - pressureRight * 0.3,
199
- right.d + pressureRight * 0.3,
200
- right.u,
201
- right.a
202
- )
203
- };
204
- }
1
+ import { conditionalDeduction, mkOpinion, project, dampedDependencyCascade, trustDiscount, applyNegativeSupport, cumulativeFusion, applyNegativeEvidence, hasProjectedOpinionChanged, readOpinionFromRecord } from '@lucern/confidence';
2
+ import '@lucern/contracts/schema-helpers/spine/tables/epistemicNodes';
205
3
 
206
- // ../confidence/src/v1/operations/scoring.ts
207
- function finiteNumber(value) {
208
- return typeof value === "number" && Number.isFinite(value) ? value : void 0;
209
- }
210
- function clamp01(value) {
211
- return Math.max(0, Math.min(1, value));
212
- }
213
- function confidenceFromOpinion(opinion2) {
214
- return clamp01(opinion2.b + opinion2.a * opinion2.u);
215
- }
216
- function readOpinionFromRecord(source, fallback = {}) {
217
- const record = source && typeof source === "object" ? source : {};
218
- return {
219
- b: finiteNumber(record.b) ?? finiteNumber(record.belief) ?? finiteNumber(record.slBelief) ?? finiteNumber(record.opinion_b) ?? fallback.b ?? 0,
220
- d: finiteNumber(record.d) ?? finiteNumber(record.disbelief) ?? finiteNumber(record.slDisbelief) ?? finiteNumber(record.opinion_d) ?? fallback.d ?? 0,
221
- u: finiteNumber(record.u) ?? finiteNumber(record.uncertainty) ?? finiteNumber(record.slUncertainty) ?? finiteNumber(record.opinion_u) ?? fallback.u ?? 1,
222
- a: finiteNumber(record.a) ?? finiteNumber(record.baseRate) ?? finiteNumber(record.slBaseRate) ?? finiteNumber(record.opinion_a) ?? fallback.a ?? 0.5
223
- };
224
- }
225
- function hasProjectedOpinionChanged(current, next, tolerance = 0.01) {
226
- return Math.abs(confidenceFromOpinion(next) - confidenceFromOpinion(current)) >= tolerance;
227
- }
228
-
229
- // ../confidence/src/v1/operations/dynamics/cascade.ts
230
- function dampedDependencyOpinion(dependencyOpinion, beliefOpinion, mode = "continuous", threshold = 0.3) {
231
- const dependencyProjection = project(dependencyOpinion);
232
- if (mode === "threshold") {
233
- if (dependencyProjection < threshold) {
234
- return opinion(
235
- 0,
236
- beliefOpinion.d + beliefOpinion.b * 0.5,
237
- 0.5,
238
- beliefOpinion.a
239
- );
240
- }
241
- return beliefOpinion;
242
- }
243
- const dampingFactor = Math.pow(dependencyProjection, 0.5);
244
- return opinion(
245
- beliefOpinion.b * dampingFactor,
246
- beliefOpinion.d + beliefOpinion.b * (1 - dampingFactor) * 0.3,
247
- beliefOpinion.u + beliefOpinion.b * (1 - dampingFactor) * 0.7,
248
- beliefOpinion.a
249
- );
250
- }
251
- function dampedDependencyCascade(dependencyOpinion, beliefOpinion, mode = "continuous") {
252
- return {
253
- opinion: dampedDependencyOpinion(dependencyOpinion, beliefOpinion, mode),
254
- operator: "dependency_cascade",
255
- rationale: `Damped dependency cascade (${mode}): prerequisite at ${project(
256
- dependencyOpinion
257
- ).toFixed(2)}`
258
- };
259
- }
260
-
261
- // ../confidence/src/v1/operations/dynamics/defeat.ts
262
- function applyNegativeSupport(source, target, weight, metadata = {}) {
263
- if (metadata.constraint === "xor") {
264
- const result = constraintFusion(
265
- source,
266
- target,
267
- metadata.normalization ?? "pressure"
268
- );
269
- return {
270
- opinion: result.o2,
271
- operator: "constraint_fusion",
272
- rationale: `XOR constraint: source belief at ${project(source).toFixed(
273
- 2
274
- )} pressures target`
275
- };
276
- }
277
- const discounted = trustDiscount(negate(source), Math.abs(weight));
278
- return {
279
- opinion: cumulativeFusion(target, discounted),
280
- operator: "cumulative_fusion",
281
- rationale: `Contradicting evidence (weight=${weight.toFixed(
282
- 2
283
- )}) from source at ${project(source).toFixed(2)}`
284
- };
285
- }
286
- function applyNegativeEvidence(source, target, weight) {
287
- const discounted = trustDiscount(negate(source), Math.abs(weight));
288
- return {
289
- opinion: cumulativeFusion(target, discounted),
290
- operator: "cumulative_fusion",
291
- rationale: `Contradicting evidence (weight=${weight.toFixed(2)})`
292
- };
293
- }
4
+ // src/confidencePropagationDispatch.ts
294
5
 
295
6
  // src/edges/contains.ts
296
7
  var containsPropagationSpec = {
@@ -302,8 +13,6 @@ var containsPropagationSpec = {
302
13
  operator: () => null,
303
14
  description: "Structural containment only. Traversed for explicit semantics, but it never propagates opinions."
304
15
  };
305
-
306
- // src/edges/utils.ts
307
16
  function readEdgeMetadata(edge) {
308
17
  return {
309
18
  constraint: edge.constraint ?? void 0,
@@ -353,9 +62,7 @@ function propagateNegativeSupportWithMetadata(sourceOpinion, targetOpinion, edge
353
62
  readEdgeMetadata(edge)
354
63
  );
355
64
  }
356
- function propagateNegativeInform(sourceOpinion, targetOpinion, edgeWeight) {
357
- return applyNegativeEvidence(sourceOpinion, targetOpinion, edgeWeight);
358
- }
65
+ var propagateNegativeInform = applyNegativeEvidence;
359
66
 
360
67
  // src/edges/contradicts.ts
361
68
  var contradictsPropagationSpec = {
@@ -380,8 +87,6 @@ var contradictsPropagationSpec = {
380
87
  },
381
88
  description: "Legacy contradiction edges move negative pressure in either direction, but never beyond one hop."
382
89
  };
383
-
384
- // src/edges/dependsOn.ts
385
90
  var dependsOnPropagationSpec = {
386
91
  edgeType: "depends_on",
387
92
  direction: "incoming",
@@ -397,8 +102,18 @@ var dependsOnPropagationSpec = {
397
102
  if (metadata.conditionalA && metadata.conditionalNotA) {
398
103
  const deducedOpinion = conditionalDeduction(
399
104
  dampedSource,
400
- metadata.conditionalA,
401
- metadata.conditionalNotA,
105
+ mkOpinion(
106
+ metadata.conditionalA.b,
107
+ metadata.conditionalA.d,
108
+ metadata.conditionalA.u,
109
+ metadata.conditionalA.a
110
+ ),
111
+ mkOpinion(
112
+ metadata.conditionalNotA.b,
113
+ metadata.conditionalNotA.d,
114
+ metadata.conditionalNotA.u,
115
+ metadata.conditionalNotA.a
116
+ ),
402
117
  targetOpinion.a
403
118
  );
404
119
  return annotateRationale(
@@ -570,8 +285,6 @@ function getTraversalDirections(direction) {
570
285
  }
571
286
  return ["outgoing", "incoming"];
572
287
  }
573
-
574
- // src/workspaceIsolation.ts
575
288
  function normalizeScopeValue(value) {
576
289
  if (typeof value !== "string") {
577
290
  return;
@@ -626,16 +339,17 @@ function resolveTraversalTargetNodeId(edge, direction) {
626
339
  }
627
340
  function readNodeOpinion(node) {
628
341
  const metadata = node.metadata ?? {};
629
- return readOpinionFromRecord(
630
- {
342
+ try {
343
+ return readOpinionFromRecord({
631
344
  ...metadata,
632
345
  opinion_b: node.opinion_b,
633
346
  opinion_d: node.opinion_d,
634
347
  opinion_u: node.opinion_u,
635
348
  opinion_a: node.opinion_a
636
- },
637
- { b: 0, d: 0, u: 1, a: 0.5 }
638
- );
349
+ });
350
+ } catch {
351
+ return mkOpinion(0, 0, 1, 0.5);
352
+ }
639
353
  }
640
354
  async function collectConfidencePropagationDispatches(args) {
641
355
  const dispatchesByTargetId = /* @__PURE__ */ new Map();
@@ -704,14 +418,20 @@ async function collectConfidencePropagationDispatches(args) {
704
418
  if (!result || !hasProjectedOpinionChanged(targetOpinion, result.opinion)) {
705
419
  continue;
706
420
  }
707
- opinionCache.set(cacheKey, result.opinion);
421
+ const projectedOpinion = mkOpinion(
422
+ result.opinion.b,
423
+ result.opinion.d,
424
+ result.opinion.u,
425
+ result.opinion.a
426
+ );
427
+ opinionCache.set(cacheKey, projectedOpinion);
708
428
  const existingDispatch = dispatchesByTargetId.get(cacheKey);
709
429
  dispatchesByTargetId.set(cacheKey, {
710
430
  targetNodeId,
711
431
  edgeType: spec.edgeType,
712
432
  traversedDirection: direction,
713
433
  weight: edge.weight ?? 1,
714
- opinion: result.opinion,
434
+ opinion: projectedOpinion,
715
435
  operator: result.operator,
716
436
  rationale: existingDispatch ? `${existingDispatch.rationale}; ${result.rationale}` : result.rationale,
717
437
  hop: nextHop
@@ -719,7 +439,7 @@ async function collectConfidencePropagationDispatches(args) {
719
439
  if (canContinueTransitively(spec, nextHop)) {
720
440
  queue.push({
721
441
  nodeId: targetNodeId,
722
- opinion: result.opinion,
442
+ opinion: projectedOpinion,
723
443
  hop: nextHop,
724
444
  visitedNodeIds: /* @__PURE__ */ new Set([
725
445
  ...state.visitedNodeIds,