@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
package/dist/epistemicBeliefs.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { v
|
|
1
|
+
import { v } from 'convex/values';
|
|
2
|
+
import { throwStructuredMutationError } from '@lucern/access-control/structuredMutationError';
|
|
2
3
|
import { normalizeTupleContradictionPolicy, mkOpinion, createInheritedContractRecord, confidenceFromSL, conditionalDeduction, project, dampedDependencyCascade, hasProjectedOpinionChanged, detectTupleContradiction, evaluateTupleContradictionTransition, readOpinionFromRecord, trustDiscount, applyNegativeSupport, cumulativeFusion, applyNegativeEvidence } from '@lucern/confidence';
|
|
3
|
-
import { checkScopeAccess, checkProjectAccess } from '@lucern/access-control/access';
|
|
4
4
|
import { canAudienceClassAccess, normalizeAudienceKey, classFromAudienceKey } from '@lucern/access-control/audience';
|
|
5
5
|
import { getCurrentUserId } from '@lucern/access-control/auth';
|
|
6
6
|
import { componentsGeneric, anyApi, internalMutationGeneric, mutationGeneric, queryGeneric, internalQueryGeneric } from 'convex/server';
|
|
7
7
|
import { isNodeType, getLayerForNodeType } from '@lucern/contracts/schema-helpers/spine/tables/epistemicNodes';
|
|
8
|
+
import { requireScopeWriteAccess, checkScopeAccess } from '@lucern/access-control/access';
|
|
8
9
|
import { permissiveReturn } from '@lucern/contracts/schema-helpers/validators';
|
|
9
10
|
import { assertSchemaEnumValue } from '@lucern/contracts/schema-helpers/enumValidation';
|
|
10
11
|
import { generateGlobalId, assertUuidV7Identity, generateUuidV7, assertStorageEdgeVocabulary, assertUuidShapedEdgeEndpoint } from '@lucern/contracts/ids';
|
|
@@ -914,26 +915,6 @@ var DEFAULT_CONFIDENCE_POLICY = {
|
|
|
914
915
|
scoringMode: "after_worktree",
|
|
915
916
|
tupleContradiction: normalizeTupleContradictionPolicy()
|
|
916
917
|
};
|
|
917
|
-
function throwStructuredMutationError(args) {
|
|
918
|
-
const data = {
|
|
919
|
-
structuredMutationError: true,
|
|
920
|
-
message: args.message,
|
|
921
|
-
status: args.status,
|
|
922
|
-
code: args.code,
|
|
923
|
-
invariantCode: args.invariantCode,
|
|
924
|
-
suggestion: args.suggestion,
|
|
925
|
-
details: args.details
|
|
926
|
-
};
|
|
927
|
-
const error = new ConvexError(
|
|
928
|
-
data
|
|
929
|
-
);
|
|
930
|
-
error.status = args.status;
|
|
931
|
-
error.code = args.code;
|
|
932
|
-
error.invariantCode = args.invariantCode;
|
|
933
|
-
error.suggestion = args.suggestion;
|
|
934
|
-
error.details = args.details;
|
|
935
|
-
throw error;
|
|
936
|
-
}
|
|
937
918
|
function readFiniteNumber(value) {
|
|
938
919
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
939
920
|
}
|
|
@@ -1267,23 +1248,6 @@ async function requireAuthenticatedUserId(ctx) {
|
|
|
1267
1248
|
}
|
|
1268
1249
|
return userId;
|
|
1269
1250
|
}
|
|
1270
|
-
async function requireProjectWriteAccess(ctx, projectId, userId) {
|
|
1271
|
-
const hasAccess = await checkProjectAccess(
|
|
1272
|
-
ctx,
|
|
1273
|
-
projectId,
|
|
1274
|
-
userId
|
|
1275
|
-
);
|
|
1276
|
-
if (!hasAccess) {
|
|
1277
|
-
throwStructuredMutationError({
|
|
1278
|
-
message: `Project write access denied for topic ${projectId}.`,
|
|
1279
|
-
status: 403,
|
|
1280
|
-
code: "PROJECT_ACCESS_DENIED",
|
|
1281
|
-
invariantCode: "policy.scope_required",
|
|
1282
|
-
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.",
|
|
1283
|
-
details: { topicId: projectId, principalId: userId }
|
|
1284
|
-
});
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
1251
|
|
|
1288
1252
|
// src/edges/contains.ts
|
|
1289
1253
|
var containsPropagationSpec = {
|
|
@@ -1729,7 +1693,7 @@ async function applyBeliefConfidenceChange(ctx, args) {
|
|
|
1729
1693
|
details: { nodeId: args.nodeId }
|
|
1730
1694
|
});
|
|
1731
1695
|
}
|
|
1732
|
-
await
|
|
1696
|
+
await requireScopeWriteAccess(
|
|
1733
1697
|
ctx,
|
|
1734
1698
|
node.projectId,
|
|
1735
1699
|
args.authenticatedUserId
|
|
@@ -2285,8 +2249,6 @@ async function scheduleEmbeddingGeneration(args) {
|
|
|
2285
2249
|
);
|
|
2286
2250
|
}
|
|
2287
2251
|
}
|
|
2288
|
-
|
|
2289
|
-
// src/epistemicBeliefs.core.ts
|
|
2290
2252
|
var create = mutation({
|
|
2291
2253
|
args: {
|
|
2292
2254
|
...optionalBeliefScopeArgs,
|
|
@@ -2365,7 +2327,7 @@ var create = mutation({
|
|
|
2365
2327
|
context: "epistemicBeliefs.create"
|
|
2366
2328
|
});
|
|
2367
2329
|
if (scope.projectId) {
|
|
2368
|
-
await
|
|
2330
|
+
await requireScopeWriteAccess(
|
|
2369
2331
|
ctx,
|
|
2370
2332
|
scope.projectId,
|
|
2371
2333
|
authenticatedUserId
|
|
@@ -2605,7 +2567,7 @@ var refineBelief = mutation({
|
|
|
2605
2567
|
details: { nodeId: args.nodeId }
|
|
2606
2568
|
});
|
|
2607
2569
|
}
|
|
2608
|
-
await
|
|
2570
|
+
await requireScopeWriteAccess(ctx, node.projectId, authenticatedUserId);
|
|
2609
2571
|
if (typeof node.confidence === "number" && Number.isFinite(node.confidence)) {
|
|
2610
2572
|
throwStructuredMutationError({
|
|
2611
2573
|
message: "Scored beliefs are immutable. Use forkBelief to evolve a scored belief.",
|
|
@@ -2825,7 +2787,7 @@ var forkBelief = mutation({
|
|
|
2825
2787
|
details: { parentNodeId: args.parentNodeId }
|
|
2826
2788
|
});
|
|
2827
2789
|
}
|
|
2828
|
-
await
|
|
2790
|
+
await requireScopeWriteAccess(ctx, parent.projectId, authenticatedUserId);
|
|
2829
2791
|
const metadata = parent.metadata;
|
|
2830
2792
|
const forkBeliefStatus = "hypothesis";
|
|
2831
2793
|
const forkMode = args.forkMode ?? "supersede";
|
|
@@ -3123,7 +3085,7 @@ var updateStatus = mutation({
|
|
|
3123
3085
|
if (!node.projectId) {
|
|
3124
3086
|
throw new Error("Belief has no project scope");
|
|
3125
3087
|
}
|
|
3126
|
-
await
|
|
3088
|
+
await requireScopeWriteAccess(ctx, node.projectId, authenticatedUserId);
|
|
3127
3089
|
const previousStatus = node.status;
|
|
3128
3090
|
const metadata = node.metadata || {};
|
|
3129
3091
|
await ctx.db.patch(args.nodeId, {
|
|
@@ -3168,7 +3130,7 @@ var archive = mutation({
|
|
|
3168
3130
|
if (!node.projectId) {
|
|
3169
3131
|
throw new Error("Belief has no project scope");
|
|
3170
3132
|
}
|
|
3171
|
-
await
|
|
3133
|
+
await requireScopeWriteAccess(ctx, node.projectId, authenticatedUserId);
|
|
3172
3134
|
return await ctx.runMutation(
|
|
3173
3135
|
// Use updateStatus internally
|
|
3174
3136
|
internal.epistemicBeliefs.updateStatusInternal,
|
|
@@ -3198,7 +3160,7 @@ var updateRationale = mutation({
|
|
|
3198
3160
|
if (!node.projectId) {
|
|
3199
3161
|
throw new Error("Belief has no project scope");
|
|
3200
3162
|
}
|
|
3201
|
-
await
|
|
3163
|
+
await requireScopeWriteAccess(ctx, node.projectId, authenticatedUserId);
|
|
3202
3164
|
const metadata = node.metadata || {};
|
|
3203
3165
|
const previousRationale = typeof metadata.rationale === "string" ? metadata.rationale : void 0;
|
|
3204
3166
|
const nextRationale = args.rationale?.trim();
|
|
@@ -3457,7 +3419,7 @@ var updatePillar = mutation({
|
|
|
3457
3419
|
if (!existingNode.projectId) {
|
|
3458
3420
|
throw new Error("Belief has no project scope");
|
|
3459
3421
|
}
|
|
3460
|
-
await
|
|
3422
|
+
await requireScopeWriteAccess(
|
|
3461
3423
|
ctx,
|
|
3462
3424
|
existingNode.projectId,
|
|
3463
3425
|
authenticatedUserId
|
|
@@ -3563,7 +3525,7 @@ var linkBeliefs = mutation({
|
|
|
3563
3525
|
if (!fromNode.projectId) {
|
|
3564
3526
|
throw new Error("Belief has no project scope");
|
|
3565
3527
|
}
|
|
3566
|
-
await
|
|
3528
|
+
await requireScopeWriteAccess(
|
|
3567
3529
|
ctx,
|
|
3568
3530
|
fromNode.projectId,
|
|
3569
3531
|
authenticatedUserId
|
|
@@ -3619,7 +3581,7 @@ var linkEvidence = mutation({
|
|
|
3619
3581
|
if (!belief.projectId) {
|
|
3620
3582
|
throw new Error("Belief has no project scope");
|
|
3621
3583
|
}
|
|
3622
|
-
await
|
|
3584
|
+
await requireScopeWriteAccess(ctx, belief.projectId, authenticatedUserId);
|
|
3623
3585
|
const insight = await ctx.db.get(args.insightId);
|
|
3624
3586
|
if (!insight || insight.nodeType !== "evidence") {
|
|
3625
3587
|
throw new Error("Insight not found");
|
|
@@ -3710,7 +3672,7 @@ var unlinkEvidence = mutation({
|
|
|
3710
3672
|
if (!evidenceNode.projectId) {
|
|
3711
3673
|
throw new Error("Evidence has no project scope");
|
|
3712
3674
|
}
|
|
3713
|
-
await
|
|
3675
|
+
await requireScopeWriteAccess(
|
|
3714
3676
|
ctx,
|
|
3715
3677
|
evidenceNode.projectId,
|
|
3716
3678
|
authenticatedUserId
|
|
@@ -3891,7 +3853,7 @@ var deleteRelationship = mutation({
|
|
|
3891
3853
|
if (!edge.projectId) {
|
|
3892
3854
|
throw new Error("Edge has no project scope");
|
|
3893
3855
|
}
|
|
3894
|
-
await
|
|
3856
|
+
await requireScopeWriteAccess(ctx, edge.projectId, authenticatedUserId);
|
|
3895
3857
|
const previousState = {
|
|
3896
3858
|
fromNodeId: edge.fromNodeId,
|
|
3897
3859
|
toNodeId: edge.toNodeId,
|
|
@@ -3938,7 +3900,7 @@ var updateCriticality = mutation({
|
|
|
3938
3900
|
if (!node.projectId) {
|
|
3939
3901
|
throw new Error("Belief has no project scope");
|
|
3940
3902
|
}
|
|
3941
|
-
await
|
|
3903
|
+
await requireScopeWriteAccess(ctx, node.projectId, authenticatedUserId);
|
|
3942
3904
|
const metadata = node.metadata || {};
|
|
3943
3905
|
const previousCriticality = metadata.criticality;
|
|
3944
3906
|
await ctx.db.patch(args.nodeId, {
|
|
@@ -4007,7 +3969,7 @@ var batchUpdateCriticality = mutation({
|
|
|
4007
3969
|
results.push({ beliefId: update.beliefId, success: false });
|
|
4008
3970
|
continue;
|
|
4009
3971
|
}
|
|
4010
|
-
await
|
|
3972
|
+
await requireScopeWriteAccess(
|
|
4011
3973
|
ctx,
|
|
4012
3974
|
node.projectId,
|
|
4013
3975
|
authenticatedUserId
|