@lucern/graph-primitives 1.0.28 → 1.0.29
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/contradictions.js +3 -3
- package/dist/contradictions.js.map +1 -1
- package/dist/entityLifecycle.js +7 -39
- package/dist/entityLifecycle.js.map +1 -1
- package/dist/epistemicBeliefs.admin.js +6 -42
- package/dist/epistemicBeliefs.admin.js.map +1 -1
- package/dist/epistemicBeliefs.backfills.js +2 -21
- package/dist/epistemicBeliefs.backfills.js.map +1 -1
- package/dist/epistemicBeliefs.confidence.d.ts +1 -0
- package/dist/epistemicBeliefs.confidence.js +4 -40
- package/dist/epistemicBeliefs.confidence.js.map +1 -1
- package/dist/epistemicBeliefs.core.js +6 -44
- package/dist/epistemicBeliefs.core.js.map +1 -1
- package/dist/epistemicBeliefs.d.ts +1 -0
- package/dist/epistemicBeliefs.forkEvidence.js +2 -22
- package/dist/epistemicBeliefs.forkEvidence.js.map +1 -1
- package/dist/epistemicBeliefs.helpers.d.ts +3 -27
- package/dist/epistemicBeliefs.helpers.js +4 -40
- package/dist/epistemicBeliefs.helpers.js.map +1 -1
- package/dist/epistemicBeliefs.internal.js +2 -22
- package/dist/epistemicBeliefs.internal.js.map +1 -1
- package/dist/epistemicBeliefs.js +17 -55
- package/dist/epistemicBeliefs.js.map +1 -1
- package/dist/epistemicBeliefs.lifecycle.js +7 -45
- package/dist/epistemicBeliefs.lifecycle.js.map +1 -1
- package/dist/epistemicBeliefs.links.js +7 -43
- package/dist/epistemicBeliefs.links.js.map +1 -1
- package/dist/epistemicContracts.evaluators.js +4 -40
- package/dist/epistemicContracts.evaluators.js.map +1 -1
- package/dist/epistemicContracts.handlers.js +4 -40
- package/dist/epistemicContracts.handlers.js.map +1 -1
- package/dist/epistemicContracts.js +4 -40
- package/dist/epistemicContracts.js.map +1 -1
- package/dist/epistemicEdges.js +4 -4
- package/dist/epistemicEdges.js.map +1 -1
- package/dist/epistemicEdges.mutations.js +4 -4
- package/dist/epistemicEdges.mutations.js.map +1 -1
- package/dist/epistemicEvidence.js +5 -5
- package/dist/epistemicEvidence.js.map +1 -1
- package/dist/epistemicEvidenceMutations.js +5 -5
- package/dist/epistemicEvidenceMutations.js.map +1 -1
- package/dist/epistemicNodes.js +4 -4
- package/dist/epistemicNodes.js.map +1 -1
- package/dist/epistemicNodes.mutations.js +4 -4
- package/dist/epistemicNodes.mutations.js.map +1 -1
- package/dist/epistemicSources.js +2 -2
- package/dist/epistemicSources.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +50 -121
- package/dist/index.js.map +1 -1
- package/dist/proof-attestation.json +1 -1
- package/package.json +4 -4
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { v
|
|
1
|
+
import { v } from 'convex/values';
|
|
2
2
|
import { permissiveReturn } from '@lucern/contracts/schema-helpers/validators';
|
|
3
3
|
import { componentsGeneric, anyApi, internalMutationGeneric, mutationGeneric } from 'convex/server';
|
|
4
4
|
import '@lucern/contracts/schema-helpers/spine/tables/epistemicNodes';
|
|
5
5
|
import { normalizeTupleContradictionPolicy, mkOpinion, conditionalDeduction, project, dampedDependencyCascade, hasProjectedOpinionChanged, confidenceFromSL, detectTupleContradiction, evaluateTupleContradictionTransition, trustDiscount, applyNegativeSupport, cumulativeFusion, applyNegativeEvidence, readOpinionFromRecord } from '@lucern/confidence';
|
|
6
|
-
import {
|
|
6
|
+
import { requireScopeWriteAccess } from '@lucern/access-control/access';
|
|
7
|
+
import { throwStructuredMutationError } from '@lucern/access-control/structuredMutationError';
|
|
7
8
|
import '@lucern/access-control/audience';
|
|
8
9
|
import { getCurrentUserId } from '@lucern/access-control/auth';
|
|
9
10
|
|
|
@@ -961,26 +962,6 @@ var DEFAULT_CONFIDENCE_POLICY = {
|
|
|
961
962
|
scoringMode: "after_worktree",
|
|
962
963
|
tupleContradiction: normalizeTupleContradictionPolicy()
|
|
963
964
|
};
|
|
964
|
-
function throwStructuredMutationError(args) {
|
|
965
|
-
const data = {
|
|
966
|
-
structuredMutationError: true,
|
|
967
|
-
message: args.message,
|
|
968
|
-
status: args.status,
|
|
969
|
-
code: args.code,
|
|
970
|
-
invariantCode: args.invariantCode,
|
|
971
|
-
suggestion: args.suggestion,
|
|
972
|
-
details: args.details
|
|
973
|
-
};
|
|
974
|
-
const error = new ConvexError(
|
|
975
|
-
data
|
|
976
|
-
);
|
|
977
|
-
error.status = args.status;
|
|
978
|
-
error.code = args.code;
|
|
979
|
-
error.invariantCode = args.invariantCode;
|
|
980
|
-
error.suggestion = args.suggestion;
|
|
981
|
-
error.details = args.details;
|
|
982
|
-
throw error;
|
|
983
|
-
}
|
|
984
965
|
function buildBeliefConfidenceRow(args) {
|
|
985
966
|
return {
|
|
986
967
|
beliefId: args.beliefId,
|
|
@@ -1098,23 +1079,6 @@ async function requireAuthenticatedUserId(ctx) {
|
|
|
1098
1079
|
}
|
|
1099
1080
|
return userId;
|
|
1100
1081
|
}
|
|
1101
|
-
async function requireProjectWriteAccess(ctx, projectId, userId) {
|
|
1102
|
-
const hasAccess = await checkProjectAccess(
|
|
1103
|
-
ctx,
|
|
1104
|
-
projectId,
|
|
1105
|
-
userId
|
|
1106
|
-
);
|
|
1107
|
-
if (!hasAccess) {
|
|
1108
|
-
throwStructuredMutationError({
|
|
1109
|
-
message: `Project write access denied for topic ${projectId}.`,
|
|
1110
|
-
status: 403,
|
|
1111
|
-
code: "PROJECT_ACCESS_DENIED",
|
|
1112
|
-
invariantCode: "policy.scope_required",
|
|
1113
|
-
suggestion: "The acting principal lacks project-write access to this topic. Request a topic grant (or, if the principal created this topic, run the creator-grant backfill) and retry.",
|
|
1114
|
-
details: { topicId: projectId, principalId: userId }
|
|
1115
|
-
});
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
1082
|
|
|
1119
1083
|
// src/epistemicBeliefs.confidence.ts
|
|
1120
1084
|
async function applyBeliefConfidenceChange(ctx, args) {
|
|
@@ -1150,7 +1114,7 @@ async function applyBeliefConfidenceChange(ctx, args) {
|
|
|
1150
1114
|
details: { nodeId: args.nodeId }
|
|
1151
1115
|
});
|
|
1152
1116
|
}
|
|
1153
|
-
await
|
|
1117
|
+
await requireScopeWriteAccess(
|
|
1154
1118
|
ctx,
|
|
1155
1119
|
node.projectId,
|
|
1156
1120
|
args.authenticatedUserId
|
|
@@ -1424,8 +1388,6 @@ internalMutation({
|
|
|
1424
1388
|
};
|
|
1425
1389
|
}
|
|
1426
1390
|
});
|
|
1427
|
-
|
|
1428
|
-
// src/epistemicBeliefs.lifecycle.ts
|
|
1429
1391
|
var appendSlScoring = mutation({
|
|
1430
1392
|
args: {
|
|
1431
1393
|
nodeId: v.id("epistemicNodes"),
|
|
@@ -1531,7 +1493,7 @@ var updateStatus = mutation({
|
|
|
1531
1493
|
if (!node.projectId) {
|
|
1532
1494
|
throw new Error("Belief has no project scope");
|
|
1533
1495
|
}
|
|
1534
|
-
await
|
|
1496
|
+
await requireScopeWriteAccess(ctx, node.projectId, authenticatedUserId);
|
|
1535
1497
|
const previousStatus = node.status;
|
|
1536
1498
|
const metadata = node.metadata || {};
|
|
1537
1499
|
await ctx.db.patch(args.nodeId, {
|
|
@@ -1576,7 +1538,7 @@ var archive = mutation({
|
|
|
1576
1538
|
if (!node.projectId) {
|
|
1577
1539
|
throw new Error("Belief has no project scope");
|
|
1578
1540
|
}
|
|
1579
|
-
await
|
|
1541
|
+
await requireScopeWriteAccess(ctx, node.projectId, authenticatedUserId);
|
|
1580
1542
|
return await ctx.runMutation(
|
|
1581
1543
|
// Use updateStatus internally
|
|
1582
1544
|
internal.epistemicBeliefs.updateStatusInternal,
|
|
@@ -1606,7 +1568,7 @@ var updateRationale = mutation({
|
|
|
1606
1568
|
if (!node.projectId) {
|
|
1607
1569
|
throw new Error("Belief has no project scope");
|
|
1608
1570
|
}
|
|
1609
|
-
await
|
|
1571
|
+
await requireScopeWriteAccess(ctx, node.projectId, authenticatedUserId);
|
|
1610
1572
|
const metadata = node.metadata || {};
|
|
1611
1573
|
const previousRationale = typeof metadata.rationale === "string" ? metadata.rationale : void 0;
|
|
1612
1574
|
const nextRationale = args.rationale?.trim();
|