@lucern/confidence 0.1.0-alpha.4 → 0.3.0-alpha.1
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/README.md +5 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +214 -87
- package/dist/index.js.map +1 -1
- package/dist/v1/codec.d.ts +42 -0
- package/dist/v1/codec.js +62 -0
- package/dist/v1/codec.js.map +1 -0
- package/dist/v1/index.d.ts +5 -3
- package/dist/v1/index.js +214 -87
- package/dist/v1/index.js.map +1 -1
- package/dist/v1/operations/approximation.js +30 -21
- package/dist/v1/operations/approximation.js.map +1 -1
- package/dist/v1/operations/bridge/index.d.ts +3 -3
- package/dist/v1/operations/bridge/index.js +27 -13
- package/dist/v1/operations/bridge/index.js.map +1 -1
- package/dist/v1/operations/canonical.d.ts +2 -2
- package/dist/v1/operations/canonical.js +16 -19
- package/dist/v1/operations/canonical.js.map +1 -1
- package/dist/v1/operations/contradiction/detectTupleContradiction.js.map +1 -1
- package/dist/v1/operations/contradiction/index.js.map +1 -1
- package/dist/v1/operations/dynamics/cascade.js +19 -6
- package/dist/v1/operations/dynamics/cascade.js.map +1 -1
- package/dist/v1/operations/dynamics/decay.js +5 -4
- package/dist/v1/operations/dynamics/decay.js.map +1 -1
- package/dist/v1/operations/dynamics/defeat.js +22 -17
- package/dist/v1/operations/dynamics/defeat.js.map +1 -1
- package/dist/v1/operations/dynamics/propagation.js +66 -33
- package/dist/v1/operations/dynamics/propagation.js.map +1 -1
- package/dist/v1/operations/dynamics/revision.d.ts +6 -6
- package/dist/v1/operations/dynamics/revision.js +31 -19
- package/dist/v1/operations/dynamics/revision.js.map +1 -1
- package/dist/v1/operations/index.js +9 -5
- package/dist/v1/operations/index.js.map +1 -1
- package/dist/v1/operations/lucern.d.ts +4 -2
- package/dist/v1/operations/lucern.js +179 -76
- package/dist/v1/operations/lucern.js.map +1 -1
- package/dist/v1/operations/operatorTaxonomy.d.ts +23 -1
- package/dist/v1/operations/operatorTaxonomy.js +28 -0
- package/dist/v1/operations/operatorTaxonomy.js.map +1 -1
- package/dist/v1/operations/scoring.d.ts +30 -12
- package/dist/v1/operations/scoring.js +82 -40
- package/dist/v1/operations/scoring.js.map +1 -1
- package/dist/v1/operations/subjectiveLogic/index.d.ts +20 -19
- package/dist/v1/operations/subjectiveLogic/index.js +11 -10
- package/dist/v1/operations/subjectiveLogic/index.js.map +1 -1
- package/dist/v1/operations/temporalDecay.js +9 -5
- package/dist/v1/operations/temporalDecay.js.map +1 -1
- package/dist/v1/types.d.ts +5 -1
- package/package.json +5 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/v1/operations/subjectiveLogic/index.ts","../../../src/v1/operations/temporalDecay.ts"],"names":[],"mappings":"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","file":"index.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","/**\n * LKC-3 decision note:\n * 1. Lucern already persists posterior opinions in `beliefConfidence`.\n * 2. It does not persist a full per-observation Beta event stream on every path.\n * 3. Reweighting raw observations would therefore force new schema + replay logic.\n * 4. This operator decays the formed opinion instead of reconstructing old evidence.\n * 5. The decay is exponential over epistemic age with a configurable half-life.\n * 6. Belief/disbelief mass shrinks over time and returns to uncertainty.\n * 7. Base rate `a` stays fixed, so the projection moves back toward the prior.\n * 8. The reference clock is \"when this posterior became knowable\" (`assessedAt`).\n * 9. That makes Invariant 9 operational with the smallest implementation surface.\n * 10. Per-observation decay can be layered later without breaking this API.\n */\n\nimport type { Opinion } from \"../types\";\nimport { trustDiscount } from \"./subjectiveLogic\";\n\nexport const DEFAULT_TEMPORAL_DECAY_HALF_LIFE_MS =\n 90 * 24 * 60 * 60 * 1000;\n\nexport type TemporalDecayParams = {\n referenceTime: Date | number;\n halfLifeMs?: number;\n};\n\nfunction toEpochMs(value: Date | number): number | undefined {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return value;\n }\n\n if (value instanceof Date) {\n const epochMs = value.getTime();\n return Number.isFinite(epochMs) ? epochMs : undefined;\n }\n\n return undefined;\n}\n\nfunction normalizeHalfLifeMs(halfLifeMs?: number): number {\n if (halfLifeMs === undefined || !Number.isFinite(halfLifeMs)) {\n return 0;\n }\n\n return Math.max(0, halfLifeMs);\n}\n\nexport function temporalDecay(\n sourceOpinion: Opinion,\n now: Date | number,\n decayParams: TemporalDecayParams\n): Opinion {\n const halfLifeMs = normalizeHalfLifeMs(decayParams.halfLifeMs);\n if (halfLifeMs === 0) {\n return { ...sourceOpinion };\n }\n\n const nowMs = toEpochMs(now);\n const referenceTimeMs = toEpochMs(decayParams.referenceTime);\n if (nowMs === undefined || referenceTimeMs === undefined) {\n return { ...sourceOpinion };\n }\n\n const ageMs = Math.max(0, nowMs - referenceTimeMs);\n if (ageMs === 0) {\n return { ...sourceOpinion };\n }\n\n const retainedEvidenceWeight = Math.pow(0.5, ageMs / halfLifeMs);\n return trustDiscount(sourceOpinion, retainedEvidenceWeight);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/v1/operations/subjectiveLogic/index.ts","../../../src/v1/operations/temporalDecay.ts"],"names":[],"mappings":"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","file":"index.js","sourcesContent":["import type { SLOpinion } from \"../../types\";\n\nexport function mkOpinion(\n belief: number,\n disbelief: number,\n uncertainty: number,\n baseRate: number\n): SLOpinion {\n const b = Number.isFinite(belief) ? Math.max(0, belief) : 0;\n const d = Number.isFinite(disbelief) ? Math.max(0, disbelief) : 0;\n const u = Number.isFinite(uncertainty) ? Math.max(0, uncertainty) : 0;\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 } as SLOpinion;\n }\n\n return {\n b: b / sum,\n d: d / sum,\n u: u / sum,\n a,\n } as SLOpinion;\n}\n\nexport const opinion = mkOpinion;\n\nexport function vacuous(baseRate: number): SLOpinion {\n return mkOpinion(0, 0, 1, baseRate);\n}\n\nexport function dogmatic(probability: number, baseRate: number): SLOpinion {\n const p = Math.max(0, Math.min(1, probability));\n return mkOpinion(p, 1 - p, 0, baseRate);\n}\n\nexport function project(o: SLOpinion): number {\n return o.b + o.a * o.u;\n}\n\nexport function confidenceLevel(o: SLOpinion): \"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: SLOpinion, right: SLOpinion): SLOpinion {\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: SLOpinion, right: SLOpinion): SLOpinion {\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: SLOpinion, trust: number): SLOpinion {\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: SLOpinion,\n ifFalse: SLOpinion,\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: SLOpinion,\n ifTrue: SLOpinion,\n ifFalse: SLOpinion,\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: SLOpinion,\n ifTrue: SLOpinion,\n ifFalse: SLOpinion,\n fallbackBaseRate?: number\n): SLOpinion {\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: SLOpinion,\n ifTrue: SLOpinion,\n ifFalse: SLOpinion,\n baseRateX: number\n): SLOpinion {\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: SLOpinion): SLOpinion {\n return mkOpinion(o.d, o.b, o.u, 1 - o.a);\n}\n\nexport function constraintFusion(\n left: SLOpinion,\n right: SLOpinion,\n mode: \"pressure\" | \"redistribute\" = \"pressure\"\n): { o1: SLOpinion; o2: SLOpinion } {\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: SLOpinion): 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: SLOpinion, right: SLOpinion): 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: SLOpinion): 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","/**\n * LKC-3 decision note:\n * 1. Lucern already persists posterior opinions in `beliefConfidence`.\n * 2. It does not persist a full per-observation Beta event stream on every path.\n * 3. Reweighting raw observations would therefore force new schema + replay logic.\n * 4. This operator decays the formed opinion instead of reconstructing old evidence.\n * 5. The decay is exponential over epistemic age with a configurable half-life.\n * 6. Belief/disbelief mass shrinks over time and returns to uncertainty.\n * 7. Base rate `a` stays fixed, so the projection moves back toward the prior.\n * 8. The reference clock is \"when this posterior became knowable\" (`assessedAt`).\n * 9. That makes Invariant 9 operational with the smallest implementation surface.\n * 10. Per-observation decay can be layered later without breaking this API.\n */\n\nimport type { Opinion } from \"../types\";\nimport { mkOpinion, trustDiscount } from \"./subjectiveLogic\";\n\nexport const DEFAULT_TEMPORAL_DECAY_HALF_LIFE_MS =\n 90 * 24 * 60 * 60 * 1000;\n\nexport type TemporalDecayParams = {\n referenceTime: Date | number;\n halfLifeMs?: number;\n};\n\nfunction toEpochMs(value: Date | number): number | undefined {\n if (typeof value === \"number\" && Number.isFinite(value)) {\n return value;\n }\n\n if (value instanceof Date) {\n const epochMs = value.getTime();\n return Number.isFinite(epochMs) ? epochMs : undefined;\n }\n\n return undefined;\n}\n\nfunction normalizeHalfLifeMs(halfLifeMs?: number): number {\n if (halfLifeMs === undefined || !Number.isFinite(halfLifeMs)) {\n return 0;\n }\n\n return Math.max(0, halfLifeMs);\n}\n\nexport function temporalDecay(\n sourceOpinion: Opinion,\n now: Date | number,\n decayParams: TemporalDecayParams\n): Opinion {\n const halfLifeMs = normalizeHalfLifeMs(decayParams.halfLifeMs);\n if (halfLifeMs === 0) {\n return { ...sourceOpinion };\n }\n\n const nowMs = toEpochMs(now);\n const referenceTimeMs = toEpochMs(decayParams.referenceTime);\n if (nowMs === undefined || referenceTimeMs === undefined) {\n return { ...sourceOpinion };\n }\n\n const ageMs = Math.max(0, nowMs - referenceTimeMs);\n if (ageMs === 0) {\n return { ...sourceOpinion };\n }\n\n const retainedEvidenceWeight = Math.pow(0.5, ageMs / halfLifeMs);\n return trustDiscount(\n mkOpinion(sourceOpinion.b, sourceOpinion.d, sourceOpinion.u, sourceOpinion.a),\n retainedEvidenceWeight\n );\n}\n"]}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export { clamp01, hasProjectedOpinionChanged, opinionFromScalar, readOpinionFromRecord, toDogmaticOpinion, toStoredOpinionFields } from './scoring.js';
|
|
2
|
+
export { fromStorage, toStorage } from '../codec.js';
|
|
2
3
|
export { temporalDecay } from './temporalDecay.js';
|
|
3
4
|
export { detectTupleContradiction, evaluateTupleContradictionTransition, normalizeTupleContradictionPolicy } from './contradiction/detectTupleContradiction.js';
|
|
4
5
|
export { areTensioned, confidenceLevel, constraintFusion, evidenceBalance, informationGain } from './subjectiveLogic/index.js';
|
|
5
6
|
export { getPropagationTraversalSpecs, isPropagationEdgeType, propagateAllEdges, propagateThroughEdge } from './dynamics/propagation.js';
|
|
6
|
-
export { bayesianUpdate, reviseConfidence } from './dynamics/revision.js';
|
|
7
|
+
export { bayesianUpdate, reviseConfidence, reviseConfidenceOpinion } from './dynamics/revision.js';
|
|
7
8
|
export { computeBaseDecay, computeDeadlineUrgency, computeEffectiveDecay, decay, getRescoringSchedule } from './dynamics/decay.js';
|
|
8
9
|
export { applyNegativeEvidence, applyNegativeSupport } from './dynamics/defeat.js';
|
|
9
10
|
export { buildComparisonRationale, buildEvidentialRationale, compareMetricValue, createInheritedContractRecord, deriveContractModulationPlan, deriveContractStatus, deriveVerificationTrigger, getEvaluatorInputRecord, normalizeEvidentialAction, parseComparisonOperator, parseEvidentialEvaluatorConfig, parseMarketIndexComparatorConfig, parseMetricCheckerConfig, parseNumericThreshold, parseReferenceCheckCounterConfig, parseTemporalDeadlineConfig, pickFiniteNumber, resolveComparisonResult } from './contracts/epistemicContract.js';
|
|
10
11
|
import '../types.js';
|
|
12
|
+
import 'zod';
|
|
11
13
|
|
|
12
|
-
declare const LUCERN_SPECIFIC_OPERATOR_NAMES: readonly ["clamp01", "toStoredOpinionFields", "readOpinionFromRecord", "opinionFromScalar", "temporalDecay", "toDogmaticOpinion", "hasProjectedOpinionChanged", "normalizeTupleContradictionPolicy", "detectTupleContradiction", "evaluateTupleContradictionTransition", "confidenceLevel", "constraintFusion", "evidenceBalance", "areTensioned", "informationGain", "isPropagationEdgeType", "getPropagationTraversalSpecs", "propagateThroughEdge", "propagateAllEdges", "bayesianUpdate", "reviseConfidence", "computeBaseDecay", "computeDeadlineUrgency", "computeEffectiveDecay", "getRescoringSchedule", "decay", "applyNegativeSupport", "applyNegativeEvidence", "deriveContractStatus", "deriveVerificationTrigger", "deriveContractModulationPlan", "createInheritedContractRecord", "normalizeEvidentialAction", "parseComparisonOperator", "parseNumericThreshold", "pickFiniteNumber", "getEvaluatorInputRecord", "parseEvidentialEvaluatorConfig", "compareMetricValue", "resolveComparisonResult", "buildComparisonRationale", "buildEvidentialRationale", "parseMetricCheckerConfig", "parseReferenceCheckCounterConfig", "parseTemporalDeadlineConfig", "parseMarketIndexComparatorConfig"];
|
|
14
|
+
declare const LUCERN_SPECIFIC_OPERATOR_NAMES: readonly ["clamp01", "fromStorage", "toStorage", "toStoredOpinionFields", "readOpinionFromRecord", "opinionFromScalar", "temporalDecay", "toDogmaticOpinion", "hasProjectedOpinionChanged", "normalizeTupleContradictionPolicy", "detectTupleContradiction", "evaluateTupleContradictionTransition", "confidenceLevel", "constraintFusion", "evidenceBalance", "areTensioned", "informationGain", "isPropagationEdgeType", "getPropagationTraversalSpecs", "propagateThroughEdge", "propagateAllEdges", "bayesianUpdate", "reviseConfidence", "reviseConfidenceOpinion", "computeBaseDecay", "computeDeadlineUrgency", "computeEffectiveDecay", "getRescoringSchedule", "decay", "applyNegativeSupport", "applyNegativeEvidence", "deriveContractStatus", "deriveVerificationTrigger", "deriveContractModulationPlan", "createInheritedContractRecord", "normalizeEvidentialAction", "parseComparisonOperator", "parseNumericThreshold", "pickFiniteNumber", "getEvaluatorInputRecord", "parseEvidentialEvaluatorConfig", "compareMetricValue", "resolveComparisonResult", "buildComparisonRationale", "buildEvidentialRationale", "parseMetricCheckerConfig", "parseReferenceCheckCounterConfig", "parseTemporalDeadlineConfig", "parseMarketIndexComparatorConfig"];
|
|
13
15
|
|
|
14
16
|
export { LUCERN_SPECIFIC_OPERATOR_NAMES };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
1
3
|
// src/v1/operations/subjectiveLogic/index.ts
|
|
2
|
-
function
|
|
3
|
-
const b =
|
|
4
|
-
const d =
|
|
5
|
-
const u =
|
|
4
|
+
function mkOpinion(belief, disbelief, uncertainty, baseRate) {
|
|
5
|
+
const b = Number.isFinite(belief) ? Math.max(0, belief) : 0;
|
|
6
|
+
const d = Number.isFinite(disbelief) ? Math.max(0, disbelief) : 0;
|
|
7
|
+
const u = Number.isFinite(uncertainty) ? Math.max(0, uncertainty) : 0;
|
|
6
8
|
const a = Math.max(0, Math.min(1, baseRate));
|
|
7
9
|
const sum = b + d + u;
|
|
8
10
|
if (sum === 0) {
|
|
@@ -15,8 +17,9 @@ function opinion(belief, disbelief, uncertainty, baseRate = 0.5) {
|
|
|
15
17
|
a
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
var opinion = mkOpinion;
|
|
21
|
+
function vacuous(baseRate) {
|
|
22
|
+
return mkOpinion(0, 0, 1, baseRate);
|
|
20
23
|
}
|
|
21
24
|
function project(o) {
|
|
22
25
|
return o.b + o.a * o.u;
|
|
@@ -172,7 +175,7 @@ function conditionalDeduction(opinionA, ifTrue, ifFalse, fallbackBaseRate) {
|
|
|
172
175
|
);
|
|
173
176
|
}
|
|
174
177
|
function negate(o) {
|
|
175
|
-
return
|
|
178
|
+
return mkOpinion(o.d, o.b, o.u, 1 - o.a);
|
|
176
179
|
}
|
|
177
180
|
function constraintFusion(left, right, mode = "pressure") {
|
|
178
181
|
if (mode === "redistribute") {
|
|
@@ -239,6 +242,15 @@ function informationGain(o) {
|
|
|
239
242
|
function finiteNumber(value) {
|
|
240
243
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
241
244
|
}
|
|
245
|
+
function requiredOpinionNumber(label, ...values) {
|
|
246
|
+
for (const value of values) {
|
|
247
|
+
const numberValue = finiteNumber(value);
|
|
248
|
+
if (numberValue !== void 0) {
|
|
249
|
+
return numberValue;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
throw new Error(`Opinion record is missing required ${label}.`);
|
|
253
|
+
}
|
|
242
254
|
function clamp01(value) {
|
|
243
255
|
return Math.max(0, Math.min(1, value));
|
|
244
256
|
}
|
|
@@ -253,34 +265,56 @@ function toStoredOpinionFields(opinion2) {
|
|
|
253
265
|
baseRate: opinion2.a
|
|
254
266
|
};
|
|
255
267
|
}
|
|
256
|
-
function readOpinionFromRecord(source
|
|
268
|
+
function readOpinionFromRecord(source) {
|
|
257
269
|
const record = source && typeof source === "object" ? source : {};
|
|
258
|
-
return
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
270
|
+
return mkOpinion(
|
|
271
|
+
requiredOpinionNumber(
|
|
272
|
+
"belief",
|
|
273
|
+
record.b,
|
|
274
|
+
record.belief,
|
|
275
|
+
record.slBelief,
|
|
276
|
+
record.opinion_b
|
|
277
|
+
),
|
|
278
|
+
requiredOpinionNumber(
|
|
279
|
+
"disbelief",
|
|
280
|
+
record.d,
|
|
281
|
+
record.disbelief,
|
|
282
|
+
record.slDisbelief,
|
|
283
|
+
record.opinion_d
|
|
284
|
+
),
|
|
285
|
+
requiredOpinionNumber(
|
|
286
|
+
"uncertainty",
|
|
287
|
+
record.u,
|
|
288
|
+
record.uncertainty,
|
|
289
|
+
record.slUncertainty,
|
|
290
|
+
record.opinion_u
|
|
291
|
+
),
|
|
292
|
+
requiredOpinionNumber(
|
|
293
|
+
"baseRate",
|
|
294
|
+
record.a,
|
|
295
|
+
record.baseRate,
|
|
296
|
+
record.slBaseRate,
|
|
297
|
+
record.opinion_a
|
|
298
|
+
)
|
|
299
|
+
);
|
|
264
300
|
}
|
|
265
301
|
function opinionFromScalar(value, mode, options) {
|
|
266
302
|
const clampedValue = clamp01(value);
|
|
267
|
-
const baseRate =
|
|
303
|
+
const baseRate = options?.baseRate === void 0 ? void 0 : clamp01(options.baseRate);
|
|
268
304
|
switch (mode) {
|
|
269
305
|
case "base_rate":
|
|
270
|
-
return
|
|
271
|
-
b: 0,
|
|
272
|
-
d: 0,
|
|
273
|
-
u: 1,
|
|
274
|
-
a: clampedValue
|
|
275
|
-
};
|
|
306
|
+
return mkOpinion(0, 0, 1, clampedValue);
|
|
276
307
|
case "dogmatic":
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
a: baseRate
|
|
282
|
-
};
|
|
308
|
+
if (baseRate === void 0) {
|
|
309
|
+
throw new Error('opinionFromScalar(value, "dogmatic") requires options.baseRate.');
|
|
310
|
+
}
|
|
311
|
+
return mkOpinion(clampedValue, 1 - clampedValue, 0, baseRate);
|
|
283
312
|
case "projected_with_u": {
|
|
313
|
+
if (baseRate === void 0) {
|
|
314
|
+
throw new Error(
|
|
315
|
+
'opinionFromScalar(value, "projected_with_u") requires options.baseRate.'
|
|
316
|
+
);
|
|
317
|
+
}
|
|
284
318
|
const uncertainty = options?.uncertainty;
|
|
285
319
|
if (uncertainty === void 0) {
|
|
286
320
|
throw new Error(
|
|
@@ -289,22 +323,57 @@ function opinionFromScalar(value, mode, options) {
|
|
|
289
323
|
}
|
|
290
324
|
const clampedUncertainty = clamp01(uncertainty);
|
|
291
325
|
const evidenceWeight = 1 - clampedUncertainty;
|
|
292
|
-
return
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
326
|
+
return mkOpinion(
|
|
327
|
+
clampedValue * evidenceWeight,
|
|
328
|
+
(1 - clampedValue) * evidenceWeight,
|
|
329
|
+
clampedUncertainty,
|
|
330
|
+
baseRate
|
|
331
|
+
);
|
|
298
332
|
}
|
|
299
333
|
}
|
|
300
334
|
throw new Error(`Unsupported opinionFromScalar mode: ${mode}`);
|
|
301
335
|
}
|
|
302
|
-
function toDogmaticOpinion(confidence, baseRate
|
|
336
|
+
function toDogmaticOpinion(confidence, baseRate) {
|
|
303
337
|
return opinionFromScalar(confidence, "dogmatic", { baseRate });
|
|
304
338
|
}
|
|
305
339
|
function hasProjectedOpinionChanged(current, next, tolerance = 0.01) {
|
|
306
340
|
return Math.abs(confidenceFromOpinion(next) - confidenceFromOpinion(current)) >= tolerance;
|
|
307
341
|
}
|
|
342
|
+
var SL_EPSILON = 1e-9;
|
|
343
|
+
z.object({
|
|
344
|
+
b: z.number(),
|
|
345
|
+
d: z.number(),
|
|
346
|
+
u: z.number(),
|
|
347
|
+
a: z.number()
|
|
348
|
+
}).refine((o) => Math.abs(o.b + o.d + o.u - 1) < SL_EPSILON, {
|
|
349
|
+
message: "SL invariant b+d+u=1 violated"
|
|
350
|
+
});
|
|
351
|
+
function fromStorage(fields) {
|
|
352
|
+
const sum = fields.belief + fields.disbelief + fields.uncertainty;
|
|
353
|
+
const opinion2 = mkOpinion(
|
|
354
|
+
fields.belief,
|
|
355
|
+
fields.disbelief,
|
|
356
|
+
fields.uncertainty,
|
|
357
|
+
fields.baseRate
|
|
358
|
+
);
|
|
359
|
+
if (Math.abs(sum - 1) < SL_EPSILON) {
|
|
360
|
+
return { ok: true, opinion: opinion2 };
|
|
361
|
+
}
|
|
362
|
+
return {
|
|
363
|
+
ok: false,
|
|
364
|
+
opinion: opinion2,
|
|
365
|
+
repairNeeded: true,
|
|
366
|
+
reason: `Stored fields sum to ${sum.toFixed(6)}, not 1; normalized on read`
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
function toStorage(opinion2) {
|
|
370
|
+
return {
|
|
371
|
+
belief: opinion2.b,
|
|
372
|
+
disbelief: opinion2.d,
|
|
373
|
+
uncertainty: opinion2.u,
|
|
374
|
+
baseRate: opinion2.a
|
|
375
|
+
};
|
|
376
|
+
}
|
|
308
377
|
function toEpochMs(value) {
|
|
309
378
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
310
379
|
return value;
|
|
@@ -336,7 +405,10 @@ function temporalDecay(sourceOpinion, now, decayParams) {
|
|
|
336
405
|
return { ...sourceOpinion };
|
|
337
406
|
}
|
|
338
407
|
const retainedEvidenceWeight = Math.pow(0.5, ageMs / halfLifeMs);
|
|
339
|
-
return trustDiscount(
|
|
408
|
+
return trustDiscount(
|
|
409
|
+
mkOpinion(sourceOpinion.b, sourceOpinion.d, sourceOpinion.u, sourceOpinion.a),
|
|
410
|
+
retainedEvidenceWeight
|
|
411
|
+
);
|
|
340
412
|
}
|
|
341
413
|
|
|
342
414
|
// src/v1/operations/contradiction/detectTupleContradiction.ts
|
|
@@ -373,7 +445,14 @@ function evaluateTupleContradictionTransition(args) {
|
|
|
373
445
|
|
|
374
446
|
// src/v1/operations/dynamics/cascade.ts
|
|
375
447
|
function dampedDependencyOpinion(dependencyOpinion, beliefOpinion, mode = "continuous", threshold = 0.3) {
|
|
376
|
-
const dependencyProjection = project(
|
|
448
|
+
const dependencyProjection = project(
|
|
449
|
+
mkOpinion(
|
|
450
|
+
dependencyOpinion.b,
|
|
451
|
+
dependencyOpinion.d,
|
|
452
|
+
dependencyOpinion.u,
|
|
453
|
+
dependencyOpinion.a
|
|
454
|
+
)
|
|
455
|
+
);
|
|
377
456
|
if (mode === "threshold") {
|
|
378
457
|
if (dependencyProjection < threshold) {
|
|
379
458
|
return opinion(
|
|
@@ -398,40 +477,49 @@ function dampedDependencyCascade(dependencyOpinion, beliefOpinion, mode = "conti
|
|
|
398
477
|
opinion: dampedDependencyOpinion(dependencyOpinion, beliefOpinion, mode),
|
|
399
478
|
operator: "dependency_cascade",
|
|
400
479
|
rationale: `Damped dependency cascade (${mode}): prerequisite at ${project(
|
|
401
|
-
|
|
480
|
+
mkOpinion(
|
|
481
|
+
dependencyOpinion.b,
|
|
482
|
+
dependencyOpinion.d,
|
|
483
|
+
dependencyOpinion.u,
|
|
484
|
+
dependencyOpinion.a
|
|
485
|
+
)
|
|
402
486
|
).toFixed(2)}`
|
|
403
487
|
};
|
|
404
488
|
}
|
|
405
489
|
|
|
406
490
|
// src/v1/operations/dynamics/defeat.ts
|
|
407
491
|
function applyNegativeSupport(source, target, weight, metadata = {}) {
|
|
492
|
+
const sourceOpinion = mkOpinion(source.b, source.d, source.u, source.a);
|
|
493
|
+
const targetOpinion = mkOpinion(target.b, target.d, target.u, target.a);
|
|
408
494
|
if (metadata.constraint === "xor") {
|
|
409
495
|
const result = constraintFusion(
|
|
410
|
-
|
|
411
|
-
|
|
496
|
+
sourceOpinion,
|
|
497
|
+
targetOpinion,
|
|
412
498
|
metadata.normalization ?? "pressure"
|
|
413
499
|
);
|
|
414
500
|
return {
|
|
415
501
|
opinion: result.o2,
|
|
416
502
|
operator: "constraint_fusion",
|
|
417
|
-
rationale: `XOR constraint: source belief at ${project(
|
|
418
|
-
|
|
419
|
-
)} pressures target`
|
|
503
|
+
rationale: `XOR constraint: source belief at ${project(
|
|
504
|
+
sourceOpinion
|
|
505
|
+
).toFixed(2)} pressures target`
|
|
420
506
|
};
|
|
421
507
|
}
|
|
422
|
-
const discounted = trustDiscount(negate(
|
|
508
|
+
const discounted = trustDiscount(negate(sourceOpinion), Math.abs(weight));
|
|
423
509
|
return {
|
|
424
|
-
opinion: cumulativeFusion(
|
|
510
|
+
opinion: cumulativeFusion(targetOpinion, discounted),
|
|
425
511
|
operator: "cumulative_fusion",
|
|
426
512
|
rationale: `Contradicting evidence (weight=${weight.toFixed(
|
|
427
513
|
2
|
|
428
|
-
)}) from source at ${project(
|
|
514
|
+
)}) from source at ${project(sourceOpinion).toFixed(2)}`
|
|
429
515
|
};
|
|
430
516
|
}
|
|
431
517
|
function applyNegativeEvidence(source, target, weight) {
|
|
432
|
-
const
|
|
518
|
+
const sourceOpinion = mkOpinion(source.b, source.d, source.u, source.a);
|
|
519
|
+
const targetOpinion = mkOpinion(target.b, target.d, target.u, target.a);
|
|
520
|
+
const discounted = trustDiscount(negate(sourceOpinion), Math.abs(weight));
|
|
433
521
|
return {
|
|
434
|
-
opinion: cumulativeFusion(
|
|
522
|
+
opinion: cumulativeFusion(targetOpinion, discounted),
|
|
435
523
|
operator: "cumulative_fusion",
|
|
436
524
|
rationale: `Contradicting evidence (weight=${weight.toFixed(2)})`
|
|
437
525
|
};
|
|
@@ -442,28 +530,32 @@ var EDGE_PROPAGATION_RULES = {
|
|
|
442
530
|
supports: {
|
|
443
531
|
direction: "outgoing",
|
|
444
532
|
handler: (source, target, weight, metadata) => {
|
|
533
|
+
const sourceOpinion = mkOpinion(source.b, source.d, source.u, source.a);
|
|
534
|
+
const targetOpinion = mkOpinion(target.b, target.d, target.u, target.a);
|
|
445
535
|
if (weight < 0) {
|
|
446
|
-
return applyNegativeSupport(
|
|
536
|
+
return applyNegativeSupport(sourceOpinion, targetOpinion, weight, metadata);
|
|
447
537
|
}
|
|
448
|
-
const discounted = trustDiscount(
|
|
538
|
+
const discounted = trustDiscount(sourceOpinion, weight);
|
|
449
539
|
return {
|
|
450
|
-
opinion: cumulativeFusion(
|
|
540
|
+
opinion: cumulativeFusion(targetOpinion, discounted),
|
|
451
541
|
operator: "cumulative_fusion",
|
|
452
542
|
rationale: `Supporting evidence (weight=${weight.toFixed(
|
|
453
543
|
2
|
|
454
|
-
)}) from source at ${project(
|
|
544
|
+
)}) from source at ${project(sourceOpinion).toFixed(2)}`
|
|
455
545
|
};
|
|
456
546
|
}
|
|
457
547
|
},
|
|
458
548
|
informs: {
|
|
459
549
|
direction: "outgoing",
|
|
460
550
|
handler: (source, target, weight) => {
|
|
551
|
+
const sourceOpinion = mkOpinion(source.b, source.d, source.u, source.a);
|
|
552
|
+
const targetOpinion = mkOpinion(target.b, target.d, target.u, target.a);
|
|
461
553
|
if (weight < 0) {
|
|
462
|
-
return applyNegativeEvidence(
|
|
554
|
+
return applyNegativeEvidence(sourceOpinion, targetOpinion, weight);
|
|
463
555
|
}
|
|
464
|
-
const discounted = trustDiscount(
|
|
556
|
+
const discounted = trustDiscount(sourceOpinion, Math.abs(weight));
|
|
465
557
|
return {
|
|
466
|
-
opinion: cumulativeFusion(
|
|
558
|
+
opinion: cumulativeFusion(targetOpinion, discounted),
|
|
467
559
|
operator: "cumulative_fusion",
|
|
468
560
|
rationale: `Supporting evidence (weight=${weight.toFixed(2)})`
|
|
469
561
|
};
|
|
@@ -472,23 +564,35 @@ var EDGE_PROPAGATION_RULES = {
|
|
|
472
564
|
depends_on: {
|
|
473
565
|
direction: "incoming",
|
|
474
566
|
handler: (source, target, _weight, metadata) => {
|
|
567
|
+
const sourceOpinion = mkOpinion(source.b, source.d, source.u, source.a);
|
|
568
|
+
const targetOpinion = mkOpinion(target.b, target.d, target.u, target.a);
|
|
475
569
|
if (metadata.conditionalA && metadata.conditionalNotA) {
|
|
476
570
|
return {
|
|
477
571
|
opinion: conditionalDeduction(
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
572
|
+
sourceOpinion,
|
|
573
|
+
mkOpinion(
|
|
574
|
+
metadata.conditionalA.b,
|
|
575
|
+
metadata.conditionalA.d,
|
|
576
|
+
metadata.conditionalA.u,
|
|
577
|
+
metadata.conditionalA.a
|
|
578
|
+
),
|
|
579
|
+
mkOpinion(
|
|
580
|
+
metadata.conditionalNotA.b,
|
|
581
|
+
metadata.conditionalNotA.d,
|
|
582
|
+
metadata.conditionalNotA.u,
|
|
583
|
+
metadata.conditionalNotA.a
|
|
584
|
+
),
|
|
585
|
+
targetOpinion.a
|
|
482
586
|
),
|
|
483
587
|
operator: "conditional_deduction",
|
|
484
588
|
rationale: `Conditional deduction: prerequisite at ${project(
|
|
485
|
-
|
|
589
|
+
sourceOpinion
|
|
486
590
|
).toFixed(2)}`
|
|
487
591
|
};
|
|
488
592
|
}
|
|
489
593
|
return dampedDependencyCascade(
|
|
490
|
-
|
|
491
|
-
|
|
594
|
+
sourceOpinion,
|
|
595
|
+
targetOpinion,
|
|
492
596
|
metadata.propagation ?? "continuous"
|
|
493
597
|
);
|
|
494
598
|
}
|
|
@@ -580,10 +684,6 @@ function normalizeBaseRateVector(baseRate, size) {
|
|
|
580
684
|
if (size === 0) {
|
|
581
685
|
return [];
|
|
582
686
|
}
|
|
583
|
-
const fallback = Array.from({ length: size }, () => 1 / size);
|
|
584
|
-
if (!baseRate) {
|
|
585
|
-
return fallback;
|
|
586
|
-
}
|
|
587
687
|
if (baseRate.length !== size) {
|
|
588
688
|
throw new Error(
|
|
589
689
|
`Base-rate vector length ${baseRate.length} must match evidence vector length ${size}.`
|
|
@@ -592,11 +692,11 @@ function normalizeBaseRateVector(baseRate, size) {
|
|
|
592
692
|
const normalized = baseRate.map((value) => clampNonNegative(value));
|
|
593
693
|
const total = normalized.reduce((sum, value) => sum + value, 0);
|
|
594
694
|
if (total === 0) {
|
|
595
|
-
|
|
695
|
+
throw new Error("Base-rate vector must contain at least one positive value.");
|
|
596
696
|
}
|
|
597
697
|
return normalized.map((value) => value / total);
|
|
598
698
|
}
|
|
599
|
-
function opinionFromDirichlet(alpha, nonInformativeWeight
|
|
699
|
+
function opinionFromDirichlet(alpha, nonInformativeWeight, baseRate) {
|
|
600
700
|
const evidence = alpha.map((value) => clampNonNegative(value));
|
|
601
701
|
const safeWeight = normalizeNonInformativeWeight(nonInformativeWeight);
|
|
602
702
|
const normalizedBaseRate = normalizeBaseRateVector(baseRate, evidence.length);
|
|
@@ -615,18 +715,18 @@ function opinionFromDirichlet(alpha, nonInformativeWeight = DEFAULT_NON_INFORMAT
|
|
|
615
715
|
a: normalizedBaseRate
|
|
616
716
|
};
|
|
617
717
|
}
|
|
618
|
-
function opinionFromBeta(alpha, beta, nonInformativeWeight
|
|
718
|
+
function opinionFromBeta(alpha, beta, nonInformativeWeight, baseRate) {
|
|
619
719
|
const dirichlet = opinionFromDirichlet(
|
|
620
720
|
[alpha, beta],
|
|
621
721
|
nonInformativeWeight,
|
|
622
722
|
[clamp012(baseRate), 1 - clamp012(baseRate)]
|
|
623
723
|
);
|
|
624
|
-
return
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
724
|
+
return mkOpinion(
|
|
725
|
+
dirichlet.b[0] ?? 0,
|
|
726
|
+
dirichlet.b[1] ?? 0,
|
|
727
|
+
dirichlet.u,
|
|
728
|
+
dirichlet.a[0] ?? clamp012(baseRate)
|
|
729
|
+
);
|
|
630
730
|
}
|
|
631
731
|
|
|
632
732
|
// src/v1/operations/dynamics/revision.ts
|
|
@@ -661,7 +761,7 @@ function reviseConfidenceOpinion(args) {
|
|
|
661
761
|
priorEvidence.alpha + newEvidence.alpha,
|
|
662
762
|
priorEvidence.beta + newEvidence.beta,
|
|
663
763
|
args.nonInformativeWeight ?? DEFAULT_NON_INFORMATIVE_WEIGHT,
|
|
664
|
-
args.baseRate
|
|
764
|
+
args.baseRate
|
|
665
765
|
);
|
|
666
766
|
}
|
|
667
767
|
|
|
@@ -1228,6 +1328,8 @@ function parseMarketIndexComparatorConfig(value) {
|
|
|
1228
1328
|
// src/v1/operations/lucern.ts
|
|
1229
1329
|
var LUCERN_SPECIFIC_OPERATOR_NAMES = [
|
|
1230
1330
|
"clamp01",
|
|
1331
|
+
"fromStorage",
|
|
1332
|
+
"toStorage",
|
|
1231
1333
|
"toStoredOpinionFields",
|
|
1232
1334
|
"readOpinionFromRecord",
|
|
1233
1335
|
"opinionFromScalar",
|
|
@@ -1248,6 +1350,7 @@ var LUCERN_SPECIFIC_OPERATOR_NAMES = [
|
|
|
1248
1350
|
"propagateAllEdges",
|
|
1249
1351
|
"bayesianUpdate",
|
|
1250
1352
|
"reviseConfidence",
|
|
1353
|
+
"reviseConfidenceOpinion",
|
|
1251
1354
|
"computeBaseDecay",
|
|
1252
1355
|
"computeDeadlineUrgency",
|
|
1253
1356
|
"computeEffectiveDecay",
|
|
@@ -1275,6 +1378,6 @@ var LUCERN_SPECIFIC_OPERATOR_NAMES = [
|
|
|
1275
1378
|
"parseMarketIndexComparatorConfig"
|
|
1276
1379
|
];
|
|
1277
1380
|
|
|
1278
|
-
export { LUCERN_SPECIFIC_OPERATOR_NAMES, applyNegativeEvidence, applyNegativeSupport, areTensioned, bayesianUpdate, buildComparisonRationale, buildEvidentialRationale, clamp01, compareMetricValue, computeBaseDecay, computeDeadlineUrgency, computeEffectiveDecay, confidenceLevel, constraintFusion, createInheritedContractRecord, decay, deriveContractModulationPlan, deriveContractStatus, deriveVerificationTrigger, detectTupleContradiction, evaluateTupleContradictionTransition, evidenceBalance, getEvaluatorInputRecord, getPropagationTraversalSpecs, getRescoringSchedule, hasProjectedOpinionChanged, informationGain, isPropagationEdgeType, normalizeEvidentialAction, normalizeTupleContradictionPolicy, opinionFromScalar, parseComparisonOperator, parseEvidentialEvaluatorConfig, parseMarketIndexComparatorConfig, parseMetricCheckerConfig, parseNumericThreshold, parseReferenceCheckCounterConfig, parseTemporalDeadlineConfig, pickFiniteNumber, propagateAllEdges, propagateThroughEdge, readOpinionFromRecord, resolveComparisonResult, reviseConfidence, temporalDecay, toDogmaticOpinion, toStoredOpinionFields };
|
|
1381
|
+
export { LUCERN_SPECIFIC_OPERATOR_NAMES, applyNegativeEvidence, applyNegativeSupport, areTensioned, bayesianUpdate, buildComparisonRationale, buildEvidentialRationale, clamp01, compareMetricValue, computeBaseDecay, computeDeadlineUrgency, computeEffectiveDecay, confidenceLevel, constraintFusion, createInheritedContractRecord, decay, deriveContractModulationPlan, deriveContractStatus, deriveVerificationTrigger, detectTupleContradiction, evaluateTupleContradictionTransition, evidenceBalance, fromStorage, getEvaluatorInputRecord, getPropagationTraversalSpecs, getRescoringSchedule, hasProjectedOpinionChanged, informationGain, isPropagationEdgeType, normalizeEvidentialAction, normalizeTupleContradictionPolicy, opinionFromScalar, parseComparisonOperator, parseEvidentialEvaluatorConfig, parseMarketIndexComparatorConfig, parseMetricCheckerConfig, parseNumericThreshold, parseReferenceCheckCounterConfig, parseTemporalDeadlineConfig, pickFiniteNumber, propagateAllEdges, propagateThroughEdge, readOpinionFromRecord, resolveComparisonResult, reviseConfidence, reviseConfidenceOpinion, temporalDecay, toDogmaticOpinion, toStorage, toStoredOpinionFields };
|
|
1279
1382
|
//# sourceMappingURL=lucern.js.map
|
|
1280
1383
|
//# sourceMappingURL=lucern.js.map
|