@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.
- package/dist/{beliefDecay-Q_26RTc-.d.ts → beliefDecay-DZ6tkLYq.d.ts} +1 -1
- package/dist/beliefDecay.d.ts +1 -1
- package/dist/beliefDecay.js +188 -1144
- package/dist/beliefDecay.js.map +1 -1
- package/dist/{beliefEvidenceLinks-42FlR48t.d.ts → beliefEvidenceLinks-CWOXxxJg.d.ts} +1 -1
- package/dist/beliefEvidenceLinks.d.ts +1 -1
- package/dist/beliefEvidenceLinks.js +186 -871
- package/dist/beliefEvidenceLinks.js.map +1 -1
- package/dist/{beliefLifecycle-C-AehZgF.d.ts → beliefLifecycle-y8WLXqQj.d.ts} +1 -1
- package/dist/beliefLifecycle.d.ts +1 -1
- package/dist/confidencePropagationDispatch.d.ts +4 -4
- package/dist/confidencePropagationDispatch.js +31 -311
- package/dist/confidencePropagationDispatch.js.map +1 -1
- package/dist/{contradictions-Hdwl7zid.d.ts → contradictions-51VLsESq.d.ts} +1 -1
- package/dist/contradictions.d.ts +1 -1
- package/dist/contradictions.js +67 -800
- package/dist/contradictions.js.map +1 -1
- package/dist/debug.d.ts +4 -0
- package/dist/debug.js +34 -0
- package/dist/debug.js.map +1 -0
- package/dist/edges/contradicts.js +1 -122
- package/dist/edges/contradicts.js.map +1 -1
- package/dist/edges/dependsOn.js +14 -172
- package/dist/edges/dependsOn.js.map +1 -1
- package/dist/edges/elaborates.js +1 -49
- package/dist/edges/elaborates.js.map +1 -1
- package/dist/edges/index.js +15 -280
- package/dist/edges/index.js.map +1 -1
- package/dist/edges/informs.js +2 -65
- package/dist/edges/informs.js.map +1 -1
- package/dist/edges/propagationTypes.d.ts +2 -2
- package/dist/edges/propagationTypes.js.map +1 -1
- package/dist/edges/refutes.js +2 -65
- package/dist/edges/refutes.js.map +1 -1
- package/dist/edges/supports.js +1 -122
- package/dist/edges/supports.js.map +1 -1
- package/dist/edges/utils.d.ts +7 -7
- package/dist/edges/utils.js +2 -133
- package/dist/edges/utils.js.map +1 -1
- package/dist/embeddingTrigger.js +21 -1
- package/dist/embeddingTrigger.js.map +1 -1
- package/dist/entityBridge.js +3 -18
- package/dist/entityBridge.js.map +1 -1
- package/dist/{entityLifecycle-BkhRJ-XI.d.ts → entityLifecycle-CvgSK5FV.d.ts} +1 -1
- package/dist/entityLifecycle.d.ts +1 -1
- package/dist/entityLifecycle.js +193 -892
- package/dist/entityLifecycle.js.map +1 -1
- package/dist/{epistemicAnswers-DSP1slZ9.d.ts → epistemicAnswers-C5ib4z6_.d.ts} +1 -1
- package/dist/epistemicAnswers.d.ts +1 -1
- package/dist/epistemicAnswers.js +73 -810
- package/dist/epistemicAnswers.js.map +1 -1
- package/dist/{epistemicBeliefs-DtFVTp-k.d.ts → epistemicBeliefs-DzKjZAeC.d.ts} +3 -3
- package/dist/epistemicBeliefs.d.ts +2 -2
- package/dist/epistemicBeliefs.js +404 -1698
- package/dist/epistemicBeliefs.js.map +1 -1
- package/dist/epistemicContractHelpers.js +1 -318
- package/dist/epistemicContractHelpers.js.map +1 -1
- package/dist/epistemicContracts.d.ts +1 -1
- package/dist/epistemicContracts.js +417 -1980
- package/dist/epistemicContracts.js.map +1 -1
- package/dist/{epistemicEdges-DcA8ErUG.d.ts → epistemicEdges-CD5vxmlH.d.ts} +3 -3
- package/dist/epistemicEdges.d.ts +1 -1
- package/dist/epistemicEdges.js +248 -919
- package/dist/epistemicEdges.js.map +1 -1
- package/dist/{epistemicEvidence-Bo638XDP.d.ts → epistemicEvidence-xw6UUrwh.d.ts} +1 -1
- package/dist/epistemicEvidence.d.ts +1 -1
- package/dist/epistemicEvidence.js +229 -1087
- package/dist/epistemicEvidence.js.map +1 -1
- package/dist/{epistemicHelpers-Bd9xbaib.d.ts → epistemicHelpers-DevrYgPN.d.ts} +1 -1
- package/dist/epistemicHelpers.d.ts +1 -1
- package/dist/{epistemicLinking-CyeLOIzN.d.ts → epistemicLinking-CfE00tHJ.d.ts} +1 -1
- package/dist/epistemicLinking.d.ts +1 -1
- package/dist/epistemicLinking.js +3 -786
- package/dist/epistemicLinking.js.map +1 -1
- package/dist/{epistemicNodes-BpD6Koud.d.ts → epistemicNodes-NBrPW7fk.d.ts} +2 -2
- package/dist/epistemicNodes.d.ts +1 -1
- package/dist/epistemicNodes.js +172 -899
- package/dist/epistemicNodes.js.map +1 -1
- package/dist/{epistemicQuestions-CmEeY6zQ.d.ts → epistemicQuestions-B_nUclrH.d.ts} +1 -1
- package/dist/epistemicQuestions.d.ts +1 -1
- package/dist/epistemicQuestions.js +369 -1125
- package/dist/epistemicQuestions.js.map +1 -1
- package/dist/{epistemicSources-ZazxHOK1.d.ts → epistemicSources-dlKj58Jp.d.ts} +1 -1
- package/dist/epistemicSources.d.ts +1 -1
- package/dist/epistemicSources.js +86 -886
- package/dist/epistemicSources.js.map +1 -1
- package/dist/evaluators/index.js +417 -1980
- package/dist/evaluators/index.js.map +1 -1
- package/dist/evaluators/lintCheckerEvaluator.js.map +1 -1
- package/dist/evaluators/sentryCheckerEvaluator.js.map +1 -1
- package/dist/evaluators/shared.js +20 -1
- package/dist/evaluators/shared.js.map +1 -1
- package/dist/evaluators/testRunnerEvaluator.js +20 -1
- package/dist/evaluators/testRunnerEvaluator.js.map +1 -1
- package/dist/evaluators/tscCheckerEvaluator.js.map +1 -1
- package/dist/index.d.ts +20 -20
- package/dist/index.js +965 -3004
- package/dist/index.js.map +1 -1
- package/dist/{ontology-matching-Buhu23ss.d.ts → ontology-matching-C6rrz2VP.d.ts} +1 -1
- package/dist/ontology-matching.d.ts +1 -1
- package/dist/ontology-matching.js +1 -344
- package/dist/ontology-matching.js.map +1 -1
- package/dist/{ontologyApproval-Ba0Jjk1k.d.ts → ontologyApproval-CFYmqKmk.d.ts} +1 -1
- package/dist/ontologyApproval.d.ts +1 -1
- package/dist/ontologyApproval.js +1 -13
- package/dist/ontologyApproval.js.map +1 -1
- package/dist/ontologyDefinitions.js +6 -20
- package/dist/ontologyDefinitions.js.map +1 -1
- package/dist/ontologyHelpers.d.ts +1 -1
- package/dist/ontologyHelpers.js +4 -3
- package/dist/ontologyHelpers.js.map +1 -1
- package/dist/ontologyRegistry.js +2 -17
- package/dist/ontologyRegistry.js.map +1 -1
- package/dist/{projectionReconciliation-CxrXYGaB.d.ts → projectionReconciliation-jww2fBI0.d.ts} +1 -1
- package/dist/projectionReconciliation.d.ts +1 -1
- package/dist/projectionReconciliation.js +16 -37
- package/dist/projectionReconciliation.js.map +1 -1
- package/dist/{projectionStaleness-CAdpIsaW.d.ts → projectionStaleness-CmdbpjVK.d.ts} +1 -1
- package/dist/projectionStaleness.d.ts +1 -1
- package/dist/{questionEvidenceLinks-BdQD0TkM.d.ts → questionEvidenceLinks-DFlyPpAj.d.ts} +1 -1
- package/dist/questionEvidenceLinks.d.ts +1 -1
- package/dist/questionEvidenceLinks.js +199 -881
- package/dist/questionEvidenceLinks.js.map +1 -1
- package/dist/resolvers.js +86 -37
- package/dist/resolvers.js.map +1 -1
- package/dist/scopeResolverCompat.js +64 -7
- package/dist/scopeResolverCompat.js.map +1 -1
- package/dist/{text-matching-CMn2WnVD.d.ts → text-matching-DNg4M5Wd.d.ts} +1 -1
- package/dist/text-matching.d.ts +1 -1
- package/dist/text-matching.js +1 -244
- package/dist/text-matching.js.map +1 -1
- package/dist/topicProjectOverlay.js +56 -13
- package/dist/topicProjectOverlay.js.map +1 -1
- package/dist/topicScope.js +55 -6
- package/dist/topicScope.js.map +1 -1
- package/dist/workflowBridge.d.ts +27 -0
- package/dist/workflowBridge.js +352 -0
- package/dist/workflowBridge.js.map +1 -0
- package/dist/workspaceIsolation.js +56 -57
- package/dist/workspaceIsolation.js.map +1 -1
- 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,
|
|
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,
|
|
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 {
|
|
2
|
-
import {
|
|
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:
|
|
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:
|
|
34
|
+
sourceOpinion: SLOpinion;
|
|
35
35
|
sourceScope?: PropagationDispatchScope;
|
|
36
36
|
traversalSpecs?: readonly EdgePropagationSpec<TNodeId>[];
|
|
37
37
|
queryEdges: (args: {
|
|
@@ -1,296 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
-
|
|
401
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
442
|
+
opinion: projectedOpinion,
|
|
723
443
|
hop: nextHop,
|
|
724
444
|
visitedNodeIds: /* @__PURE__ */ new Set([
|
|
725
445
|
...state.visitedNodeIds,
|