@lucern/graph-primitives 1.0.15 → 1.0.17
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/beliefEvidenceLinks.js +144 -99
- package/dist/beliefEvidenceLinks.js.map +1 -1
- package/dist/beliefEvidenceLinks.operational.d.ts +29 -0
- package/dist/beliefEvidenceLinks.operational.js +157 -0
- package/dist/beliefEvidenceLinks.operational.js.map +1 -0
- package/dist/{beliefLifecycle-y8WLXqQj.d.ts → beliefLifecycle-CXwdDw5e.d.ts} +7 -4
- package/dist/beliefLifecycle.d.ts +1 -1
- package/dist/beliefLifecycle.js +75 -18
- package/dist/beliefLifecycle.js.map +1 -1
- package/dist/epistemicBeliefs.admin.js.map +1 -1
- package/dist/epistemicBeliefs.backfills.d.ts +1 -1
- package/dist/epistemicBeliefs.backfills.js +63 -35
- package/dist/epistemicBeliefs.backfills.js.map +1 -1
- package/dist/epistemicBeliefs.confidence.d.ts +1 -1
- package/dist/epistemicBeliefs.confidence.js +70 -41
- package/dist/epistemicBeliefs.confidence.js.map +1 -1
- package/dist/epistemicBeliefs.core.js +957 -566
- package/dist/epistemicBeliefs.core.js.map +1 -1
- package/dist/epistemicBeliefs.d.ts +2 -2
- package/dist/epistemicBeliefs.forkEvidence.d.ts +18 -0
- package/dist/epistemicBeliefs.forkEvidence.js +121 -0
- package/dist/epistemicBeliefs.forkEvidence.js.map +1 -0
- package/dist/epistemicBeliefs.helpers.d.ts +2 -2
- package/dist/epistemicBeliefs.helpers.js +60 -32
- package/dist/epistemicBeliefs.helpers.js.map +1 -1
- package/dist/epistemicBeliefs.internal.js +174 -39
- package/dist/epistemicBeliefs.internal.js.map +1 -1
- package/dist/epistemicBeliefs.js +436 -72
- package/dist/epistemicBeliefs.js.map +1 -1
- package/dist/epistemicBeliefs.lifecycle.d.ts +2 -2
- package/dist/epistemicBeliefs.lifecycle.js +75 -47
- package/dist/epistemicBeliefs.lifecycle.js.map +1 -1
- package/dist/epistemicBeliefs.links.js +46 -1
- package/dist/epistemicBeliefs.links.js.map +1 -1
- package/dist/epistemicBeliefs.topicAnchor.d.ts +29 -0
- package/dist/epistemicBeliefs.topicAnchor.js +105 -0
- package/dist/epistemicBeliefs.topicAnchor.js.map +1 -0
- package/dist/epistemicContracts.evaluators.js +71 -42
- package/dist/epistemicContracts.evaluators.js.map +1 -1
- package/dist/epistemicContracts.handlers.js +71 -42
- package/dist/epistemicContracts.handlers.js.map +1 -1
- package/dist/epistemicContracts.js +71 -42
- package/dist/epistemicContracts.js.map +1 -1
- package/dist/epistemicContracts.metrics.js +1 -1
- package/dist/epistemicContracts.metrics.js.map +1 -1
- package/dist/epistemicContracts.types.d.ts +1 -1
- package/dist/epistemicEdges.helpers.d.ts +1 -1
- package/dist/epistemicEvidence.js +172 -81
- package/dist/epistemicEvidence.js.map +1 -1
- package/dist/epistemicEvidenceMutations.js +172 -81
- package/dist/epistemicEvidenceMutations.js.map +1 -1
- package/dist/epistemicNodes.internal.js.map +1 -1
- package/dist/epistemicNodes.js +2 -2
- package/dist/epistemicNodes.js.map +1 -1
- package/dist/epistemicNodes.mutations.js +2 -2
- package/dist/epistemicNodes.mutations.js.map +1 -1
- package/dist/evaluators/index.js +1 -1
- package/dist/evaluators/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +767 -236
- package/dist/index.js.map +1 -1
- package/dist/invariantEnforcement.js +2 -2
- package/dist/invariantEnforcement.js.map +1 -1
- package/dist/proof-attestation.json +3 -3
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Split belief confidence and lifecycle mutations out of epistemicBeliefs.ts. */
|
|
2
|
-
declare const
|
|
2
|
+
declare const appendSlScoring: any;
|
|
3
3
|
/**
|
|
4
4
|
* Update a belief's status.
|
|
5
5
|
*/
|
|
@@ -16,4 +16,4 @@ declare const archive: any;
|
|
|
16
16
|
declare const updateRationale: any;
|
|
17
17
|
declare const updateStatusInternal: any;
|
|
18
18
|
|
|
19
|
-
export {
|
|
19
|
+
export { appendSlScoring, archive, updateRationale, updateStatus, updateStatusInternal };
|
|
@@ -384,18 +384,32 @@ function assertTenantPackWorkspaceMutationAllowed(args) {
|
|
|
384
384
|
var BELIEF_STATUS_VALUES = [
|
|
385
385
|
"assumption",
|
|
386
386
|
"hypothesis",
|
|
387
|
-
"
|
|
388
|
-
"
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
"confirmed",
|
|
392
|
-
"disconfirmed",
|
|
393
|
-
"partial",
|
|
394
|
-
"expired"
|
|
387
|
+
"active",
|
|
388
|
+
"superseded",
|
|
389
|
+
"resolved_true",
|
|
390
|
+
"resolved_false"
|
|
395
391
|
];
|
|
396
392
|
function isBeliefLifecycleStatus(value) {
|
|
397
393
|
return typeof value === "string" && BELIEF_STATUS_VALUES.includes(value);
|
|
398
394
|
}
|
|
395
|
+
function normalizeLegacyBeliefStatus(value) {
|
|
396
|
+
if (isBeliefLifecycleStatus(value)) {
|
|
397
|
+
return value;
|
|
398
|
+
}
|
|
399
|
+
if (value === "belief" || value === "established" || value === "emerging") {
|
|
400
|
+
return "active";
|
|
401
|
+
}
|
|
402
|
+
if (value === "fact" || value === "confirmed") {
|
|
403
|
+
return "resolved_true";
|
|
404
|
+
}
|
|
405
|
+
if (value === "disconfirmed" || value === "expired") {
|
|
406
|
+
return "resolved_false";
|
|
407
|
+
}
|
|
408
|
+
if (value === "deprecated") {
|
|
409
|
+
return "superseded";
|
|
410
|
+
}
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
399
413
|
function normalizeBeliefConfidence(confidence) {
|
|
400
414
|
if (typeof confidence !== "number" || !Number.isFinite(confidence)) {
|
|
401
415
|
return null;
|
|
@@ -415,47 +429,61 @@ function isResolvedByConfidence(confidence) {
|
|
|
415
429
|
}
|
|
416
430
|
return normalized <= 0 || normalized >= 1;
|
|
417
431
|
}
|
|
418
|
-
function
|
|
432
|
+
function getPredictionMetaFromMetadata(metadata) {
|
|
433
|
+
return metadata?.predictionMeta;
|
|
434
|
+
}
|
|
435
|
+
function resolvedPredictionStatus(predictionMeta) {
|
|
419
436
|
if (!predictionMeta || typeof predictionMeta !== "object") {
|
|
420
|
-
return
|
|
437
|
+
return null;
|
|
421
438
|
}
|
|
422
439
|
const outcome = predictionMeta.outcome;
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
440
|
+
if (outcome === "confirmed") {
|
|
441
|
+
return "resolved_true";
|
|
442
|
+
}
|
|
443
|
+
if (outcome === "disconfirmed" || outcome === "expired") {
|
|
444
|
+
return "resolved_false";
|
|
445
|
+
}
|
|
446
|
+
return null;
|
|
427
447
|
}
|
|
428
|
-
function
|
|
448
|
+
function shouldTreatBeliefAsResolved(opts) {
|
|
429
449
|
if (isResolvedByConfidence(opts.confidence)) {
|
|
430
|
-
|
|
450
|
+
const normalized = normalizeBeliefConfidence(opts.confidence);
|
|
451
|
+
return normalized === 0 ? "resolved_false" : "resolved_true";
|
|
431
452
|
}
|
|
432
|
-
|
|
433
|
-
|
|
453
|
+
const directPredictionStatus = resolvedPredictionStatus(opts.predictionMeta);
|
|
454
|
+
if (directPredictionStatus) {
|
|
455
|
+
return directPredictionStatus;
|
|
434
456
|
}
|
|
435
|
-
|
|
436
|
-
|
|
457
|
+
const metadataPredictionStatus = resolvedPredictionStatus(
|
|
458
|
+
getPredictionMetaFromMetadata(opts.metadata)
|
|
459
|
+
);
|
|
460
|
+
if (metadataPredictionStatus) {
|
|
461
|
+
return metadataPredictionStatus;
|
|
437
462
|
}
|
|
438
|
-
return
|
|
463
|
+
return null;
|
|
439
464
|
}
|
|
440
465
|
function resolveBeliefLifecycleStatus(opts) {
|
|
441
|
-
|
|
442
|
-
|
|
466
|
+
const resolvedStatus = shouldTreatBeliefAsResolved(opts);
|
|
467
|
+
if (resolvedStatus) {
|
|
468
|
+
return resolvedStatus;
|
|
443
469
|
}
|
|
444
470
|
const direct = opts.beliefStatus;
|
|
445
|
-
|
|
471
|
+
const normalizedDirect = normalizeLegacyBeliefStatus(direct);
|
|
472
|
+
if (normalizedDirect) {
|
|
446
473
|
const normalized = normalizeBeliefConfidence(opts.confidence);
|
|
447
|
-
if (normalized !== null && isPreValidationBeliefStatus(
|
|
448
|
-
return "
|
|
474
|
+
if (normalized !== null && isPreValidationBeliefStatus(normalizedDirect)) {
|
|
475
|
+
return "active";
|
|
449
476
|
}
|
|
450
|
-
return
|
|
477
|
+
return normalizedDirect;
|
|
451
478
|
}
|
|
452
479
|
const metaStatus = opts.metadata?.beliefStatus;
|
|
453
|
-
|
|
480
|
+
const normalizedMetaStatus = normalizeLegacyBeliefStatus(metaStatus);
|
|
481
|
+
if (normalizedMetaStatus) {
|
|
454
482
|
const normalized = normalizeBeliefConfidence(opts.confidence);
|
|
455
|
-
if (normalized !== null && isPreValidationBeliefStatus(
|
|
456
|
-
return "
|
|
483
|
+
if (normalized !== null && isPreValidationBeliefStatus(normalizedMetaStatus)) {
|
|
484
|
+
return "active";
|
|
457
485
|
}
|
|
458
|
-
return
|
|
486
|
+
return normalizedMetaStatus;
|
|
459
487
|
}
|
|
460
488
|
return "assumption";
|
|
461
489
|
}
|
|
@@ -463,13 +491,14 @@ function isPreValidationBeliefStatus(status) {
|
|
|
463
491
|
return status === "assumption" || status === "hypothesis";
|
|
464
492
|
}
|
|
465
493
|
function promoteBeliefStatusAfterScoring(status, opts) {
|
|
466
|
-
|
|
467
|
-
|
|
494
|
+
const resolvedStatus = shouldTreatBeliefAsResolved({ ...opts });
|
|
495
|
+
if (resolvedStatus) {
|
|
496
|
+
return resolvedStatus;
|
|
468
497
|
}
|
|
469
498
|
if (isPreValidationBeliefStatus(status)) {
|
|
470
|
-
return "
|
|
499
|
+
return "active";
|
|
471
500
|
}
|
|
472
|
-
return status
|
|
501
|
+
return status;
|
|
473
502
|
}
|
|
474
503
|
|
|
475
504
|
// src/edges/contains.ts
|
|
@@ -908,7 +937,7 @@ function buildBeliefConfidenceRow(args) {
|
|
|
908
937
|
disbelief: args.disbelief,
|
|
909
938
|
uncertainty: args.uncertainty,
|
|
910
939
|
baseRate: args.baseRate,
|
|
911
|
-
slOperator: args.slOperator ?? "
|
|
940
|
+
slOperator: args.slOperator ?? "prior_seed",
|
|
912
941
|
trigger: args.trigger,
|
|
913
942
|
...args.rationale ? { rationale: args.rationale } : {},
|
|
914
943
|
assessedBy: args.assessedBy,
|
|
@@ -1040,17 +1069,17 @@ async function applyBeliefConfidenceChange(ctx, args) {
|
|
|
1040
1069
|
status: 404,
|
|
1041
1070
|
code: "NOT_FOUND",
|
|
1042
1071
|
invariantCode: "belief.exists",
|
|
1043
|
-
suggestion: "Verify nodeId points to an existing node before
|
|
1072
|
+
suggestion: "Verify nodeId points to an existing node before appending SL scoring.",
|
|
1044
1073
|
details: { nodeId: args.nodeId }
|
|
1045
1074
|
});
|
|
1046
1075
|
}
|
|
1047
1076
|
if (node.nodeType !== "belief") {
|
|
1048
1077
|
throwStructuredMutationError({
|
|
1049
|
-
message: `
|
|
1078
|
+
message: `appendSlScoring only applies to belief nodes. Received nodeType "${node.nodeType}". Entity nodes (company, person, investor, etc.) do not have confidence \u2014 use entityLifecycle.updateEntityAttributes for mutable entity data.`,
|
|
1050
1079
|
status: 400,
|
|
1051
1080
|
code: "INVALID_ARGUMENT",
|
|
1052
1081
|
invariantCode: "entity.no_confidence",
|
|
1053
|
-
suggestion: "Use entityLifecycle.updateEntityAttributes for entity mutations.
|
|
1082
|
+
suggestion: "Use entityLifecycle.updateEntityAttributes for entity mutations. appendSlScoring is for belief nodes only.",
|
|
1054
1083
|
details: { nodeId: args.nodeId, nodeType: node.nodeType }
|
|
1055
1084
|
});
|
|
1056
1085
|
}
|
|
@@ -1060,7 +1089,7 @@ async function applyBeliefConfidenceChange(ctx, args) {
|
|
|
1060
1089
|
status: 400,
|
|
1061
1090
|
code: "MISSING_SCOPE",
|
|
1062
1091
|
invariantCode: "belief.project_required",
|
|
1063
|
-
suggestion: "Belief must have a projectId
|
|
1092
|
+
suggestion: "Belief must have a projectId before SL scoring can be appended.",
|
|
1064
1093
|
details: { nodeId: args.nodeId }
|
|
1065
1094
|
});
|
|
1066
1095
|
}
|
|
@@ -1083,7 +1112,7 @@ async function applyBeliefConfidenceChange(ctx, args) {
|
|
|
1083
1112
|
status: 409,
|
|
1084
1113
|
code: "CONFLICT",
|
|
1085
1114
|
invariantCode: "belief.confidence_append_only",
|
|
1086
|
-
suggestion: "Complete a worktree linked to this belief before recording
|
|
1115
|
+
suggestion: "Complete a worktree linked to this belief before recording SL scoring.",
|
|
1087
1116
|
details: { nodeId: args.nodeId }
|
|
1088
1117
|
});
|
|
1089
1118
|
}
|
|
@@ -1339,7 +1368,7 @@ internalMutation({
|
|
|
1339
1368
|
});
|
|
1340
1369
|
|
|
1341
1370
|
// src/epistemicBeliefs.lifecycle.ts
|
|
1342
|
-
var
|
|
1371
|
+
var appendSlScoring = mutation({
|
|
1343
1372
|
args: {
|
|
1344
1373
|
nodeId: v.id("epistemicNodes"),
|
|
1345
1374
|
// SL opinion — the ONLY confidence input (EK-7)
|
|
@@ -1356,8 +1385,6 @@ var modulateConfidence = mutation({
|
|
|
1356
1385
|
v.literal("evidence_removed"),
|
|
1357
1386
|
v.literal("contradiction_detected"),
|
|
1358
1387
|
v.literal("contradiction_resolved"),
|
|
1359
|
-
v.literal("manual"),
|
|
1360
|
-
v.literal("decay"),
|
|
1361
1388
|
v.literal("agent_assessment"),
|
|
1362
1389
|
v.literal("worktree_outcome"),
|
|
1363
1390
|
v.literal("worktree_completed"),
|
|
@@ -1369,7 +1396,7 @@ var modulateConfidence = mutation({
|
|
|
1369
1396
|
),
|
|
1370
1397
|
rationale: v.optional(v.string()),
|
|
1371
1398
|
userId: v.string(),
|
|
1372
|
-
// SL operator provenance (optional — defaults
|
|
1399
|
+
// SL operator provenance (optional — defaults inside the SL scorer)
|
|
1373
1400
|
slOperator: v.optional(
|
|
1374
1401
|
v.union(
|
|
1375
1402
|
v.literal("cumulative_fusion"),
|
|
@@ -1379,7 +1406,8 @@ var modulateConfidence = mutation({
|
|
|
1379
1406
|
v.literal("dependency_cascade"),
|
|
1380
1407
|
v.literal("negation"),
|
|
1381
1408
|
v.literal("constraint_fusion"),
|
|
1382
|
-
v.literal("
|
|
1409
|
+
v.literal("no_op"),
|
|
1410
|
+
v.literal("prior_seed")
|
|
1383
1411
|
)
|
|
1384
1412
|
),
|
|
1385
1413
|
triggeringEvidenceId: v.optional(v.id("epistemicNodes")),
|
|
@@ -1603,6 +1631,6 @@ var updateStatusInternal = internalMutation({
|
|
|
1603
1631
|
}
|
|
1604
1632
|
});
|
|
1605
1633
|
|
|
1606
|
-
export {
|
|
1634
|
+
export { appendSlScoring, archive, updateRationale, updateStatus, updateStatusInternal };
|
|
1607
1635
|
//# sourceMappingURL=epistemicBeliefs.lifecycle.js.map
|
|
1608
1636
|
//# sourceMappingURL=epistemicBeliefs.lifecycle.js.map
|