@lucern/graph-primitives 0.1.0-alpha.4 → 0.3.0-alpha.0
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.js +199 -18
- package/dist/beliefDecay.js.map +1 -1
- package/dist/beliefEvidenceLinks.js.map +1 -1
- package/dist/confidencePropagationDispatch.js.map +1 -1
- package/dist/contradictions.js.map +1 -1
- package/dist/entityBridge.js.map +1 -1
- package/dist/entityLifecycle.js.map +1 -1
- package/dist/epistemicAnswers.js +21 -36
- package/dist/epistemicAnswers.js.map +1 -1
- package/dist/epistemicBeliefs.js +92 -651
- package/dist/epistemicBeliefs.js.map +1 -1
- package/dist/epistemicContracts.js +65 -624
- package/dist/epistemicContracts.js.map +1 -1
- package/dist/epistemicEdges.js.map +1 -1
- package/dist/epistemicEvidence.js +71 -630
- package/dist/epistemicEvidence.js.map +1 -1
- package/dist/epistemicHelpers.js +3 -2
- package/dist/epistemicHelpers.js.map +1 -1
- package/dist/epistemicLinking.js.map +1 -1
- package/dist/epistemicNodes.js +49 -585
- package/dist/epistemicNodes.js.map +1 -1
- package/dist/epistemicQuestions.js +46 -590
- package/dist/epistemicQuestions.js.map +1 -1
- package/dist/epistemicSources.js +29 -565
- package/dist/epistemicSources.js.map +1 -1
- package/dist/evaluators/index.js +65 -624
- package/dist/evaluators/index.js.map +1 -1
- package/dist/index.js +304 -905
- package/dist/index.js.map +1 -1
- package/dist/ontologyApproval.js.map +1 -1
- package/dist/ontologyDefinitions.js.map +1 -1
- package/dist/ontologyRegistry.js.map +1 -1
- package/dist/projectionReconciliation.js.map +1 -1
- package/dist/questionEvidenceLinks.js +188 -2
- package/dist/questionEvidenceLinks.js.map +1 -1
- package/dist/workspaceIsolation.js +30 -581
- package/dist/workspaceIsolation.js.map +1 -1
- package/package.json +5 -6
package/dist/epistemicSources.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v } from 'convex/values';
|
|
2
|
-
import { componentsGeneric,
|
|
2
|
+
import { componentsGeneric, mutationGeneric, anyApi, queryGeneric } from 'convex/server';
|
|
3
3
|
|
|
4
4
|
// src/epistemicSources.ts
|
|
5
5
|
var api = anyApi;
|
|
@@ -1031,567 +1031,31 @@ async function resolveTopicProjectScope(ctx, args) {
|
|
|
1031
1031
|
projectId: v.optional(v.string()),
|
|
1032
1032
|
topicId: v.optional(v.string())
|
|
1033
1033
|
});
|
|
1034
|
-
v.number();
|
|
1035
|
-
v.union(
|
|
1036
|
-
v.literal("very_high"),
|
|
1037
|
-
// 0.9+
|
|
1038
|
-
v.literal("high"),
|
|
1039
|
-
// 0.7-0.9
|
|
1040
|
-
v.literal("medium"),
|
|
1041
|
-
// 0.4-0.7
|
|
1042
|
-
v.literal("low"),
|
|
1043
|
-
// 0.2-0.4
|
|
1044
|
-
v.literal("very_low")
|
|
1045
|
-
// 0-0.2
|
|
1046
|
-
);
|
|
1047
|
-
v.union(
|
|
1048
|
-
v.literal(1),
|
|
1049
|
-
// Critical
|
|
1050
|
-
v.literal(2),
|
|
1051
|
-
// High
|
|
1052
|
-
v.literal(3),
|
|
1053
|
-
// Medium
|
|
1054
|
-
v.literal(4),
|
|
1055
|
-
// Low
|
|
1056
|
-
v.literal(5)
|
|
1057
|
-
// Backlog
|
|
1058
|
-
);
|
|
1059
|
-
v.union(
|
|
1060
|
-
v.literal("critical"),
|
|
1061
|
-
v.literal("high"),
|
|
1062
|
-
v.literal("medium"),
|
|
1063
|
-
v.literal("low"),
|
|
1064
|
-
v.literal("backlog")
|
|
1065
|
-
);
|
|
1066
|
-
v.union(
|
|
1067
|
-
v.literal("active"),
|
|
1068
|
-
v.literal("paused"),
|
|
1069
|
-
v.literal("completed"),
|
|
1070
|
-
v.literal("archived")
|
|
1071
|
-
);
|
|
1072
|
-
v.union(
|
|
1073
|
-
v.literal("pending"),
|
|
1074
|
-
v.literal("processing"),
|
|
1075
|
-
v.literal("completed"),
|
|
1076
|
-
v.literal("failed")
|
|
1077
|
-
);
|
|
1078
|
-
v.object({
|
|
1079
|
-
crunchbaseId: v.optional(v.string()),
|
|
1080
|
-
linkedinUrl: v.optional(v.string()),
|
|
1081
|
-
pitchbookId: v.optional(v.string()),
|
|
1082
|
-
twitterUrl: v.optional(v.string()),
|
|
1083
|
-
domain: v.optional(v.string())
|
|
1084
|
-
});
|
|
1085
|
-
var sourceType = v.union(
|
|
1086
|
-
v.literal("proprietary"),
|
|
1087
|
-
// Internal Stack research
|
|
1088
|
-
v.literal("primary"),
|
|
1089
|
-
// Direct interviews, calls
|
|
1090
|
-
v.literal("secondary"),
|
|
1091
|
-
// Published sources
|
|
1092
|
-
v.literal("ai_generated"),
|
|
1093
|
-
// AI-synthesized
|
|
1094
|
-
v.literal("user_input"),
|
|
1095
|
-
// Manual user entry
|
|
1096
|
-
v.literal("inferred")
|
|
1097
|
-
// System inference
|
|
1098
|
-
);
|
|
1099
|
-
v.object({
|
|
1100
|
-
sourceType: v.optional(sourceType),
|
|
1101
|
-
sourceId: v.optional(v.string()),
|
|
1102
|
-
// Reference to source entity
|
|
1103
|
-
sourceUrl: v.optional(v.string()),
|
|
1104
|
-
sourceDate: v.optional(v.number()),
|
|
1105
|
-
sourceName: v.optional(v.string())
|
|
1106
|
-
});
|
|
1107
|
-
v.object({
|
|
1108
|
-
cursor: v.optional(v.string()),
|
|
1109
|
-
limit: v.optional(v.number())
|
|
1110
|
-
});
|
|
1111
|
-
v.object({
|
|
1112
|
-
hasMore: v.boolean(),
|
|
1113
|
-
nextCursor: v.optional(v.string()),
|
|
1114
|
-
totalCount: v.optional(v.number())
|
|
1115
|
-
});
|
|
1116
|
-
var richTextContent = v.object({
|
|
1117
|
-
type: v.literal("doc"),
|
|
1118
|
-
content: looseJsonArray
|
|
1119
|
-
});
|
|
1120
|
-
v.union(v.string(), richTextContent);
|
|
1121
|
-
v.object({
|
|
1122
|
-
promptTokens: v.optional(v.number()),
|
|
1123
|
-
completionTokens: v.optional(v.number()),
|
|
1124
|
-
totalTokens: v.optional(v.number())
|
|
1125
|
-
});
|
|
1126
|
-
v.object({
|
|
1127
|
-
fileName: v.optional(v.string()),
|
|
1128
|
-
fileSize: v.optional(v.number()),
|
|
1129
|
-
mimeType: v.optional(v.string()),
|
|
1130
|
-
storageId: v.optional(v.id("_storage")),
|
|
1131
|
-
externalUrl: v.optional(v.string())
|
|
1132
|
-
});
|
|
1133
1034
|
|
|
1134
|
-
//
|
|
1135
|
-
var
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
// Immutable answer snapshot for a question
|
|
1159
|
-
// --- L1: Terminal Leaves (non-traversable, grounding) ---
|
|
1160
|
-
v.literal("atomic_fact"),
|
|
1161
|
-
// Raw fact from source (not interpreted)
|
|
1162
|
-
v.literal("excerpt"),
|
|
1163
|
-
// Direct quote from source document
|
|
1164
|
-
v.literal("source"),
|
|
1165
|
-
// News, documents, transcripts
|
|
1166
|
-
// --- Ontological Entities (things in the world) ---
|
|
1167
|
-
v.literal("company"),
|
|
1168
|
-
// Organization (subtype: private, corporate, portfolio)
|
|
1169
|
-
v.literal("person"),
|
|
1170
|
-
// Individual (founder, expert, LP, contact)
|
|
1171
|
-
v.literal("investor"),
|
|
1172
|
-
// Investment entity (subtype: vc, lp, cvc, pe, family_office, angel)
|
|
1173
|
-
v.literal("function"),
|
|
1174
|
-
// What a company does (from classifier)
|
|
1175
|
-
v.literal("value_chain")
|
|
1176
|
-
// Market structure / value flow
|
|
1177
|
-
);
|
|
1178
|
-
var epistemicLayer = v.union(
|
|
1179
|
-
v.literal("L4"),
|
|
1180
|
-
// Decisions, outcomes - audit targets
|
|
1181
|
-
v.literal("L3"),
|
|
1182
|
-
// Beliefs, questions, themes - traversal anchors
|
|
1183
|
-
v.literal("L2"),
|
|
1184
|
-
// Claims, evidence, synthesis - compression boundary
|
|
1185
|
-
v.literal("L1"),
|
|
1186
|
-
// Atomic facts, excerpts, sources - terminal leaves
|
|
1187
|
-
v.literal("ontological"),
|
|
1188
|
-
// Companies, people, etc - not epistemic
|
|
1189
|
-
v.literal("organizational")
|
|
1190
|
-
// Topics, lenses, worktrees — structural containers
|
|
1191
|
-
);
|
|
1192
|
-
var nodeStatus = v.union(
|
|
1193
|
-
v.literal("active"),
|
|
1194
|
-
v.literal("superseded"),
|
|
1195
|
-
// Replaced by newer version
|
|
1196
|
-
v.literal("archived"),
|
|
1197
|
-
v.literal("deleted")
|
|
1198
|
-
);
|
|
1199
|
-
var sourceType2 = v.union(
|
|
1200
|
-
v.literal("human"),
|
|
1201
|
-
// User created directly
|
|
1202
|
-
v.literal("ai_extracted"),
|
|
1203
|
-
// LLM extracted from a source
|
|
1204
|
-
v.literal("ai_generated"),
|
|
1205
|
-
// LLM synthesized/created
|
|
1206
|
-
v.literal("imported"),
|
|
1207
|
-
// External system import
|
|
1208
|
-
v.literal("system"),
|
|
1209
|
-
// System-generated (migrations, classifiers)
|
|
1210
|
-
v.literal("verified"),
|
|
1211
|
-
// Human-verified source
|
|
1212
|
-
v.literal("proprietary")
|
|
1213
|
-
// Proprietary/internal data
|
|
1214
|
-
);
|
|
1215
|
-
var verificationStatus = v.union(
|
|
1216
|
-
v.literal("unverified"),
|
|
1217
|
-
v.literal("human_verified"),
|
|
1218
|
-
v.literal("ai_verified"),
|
|
1219
|
-
v.literal("contradicted"),
|
|
1220
|
-
v.literal("outdated")
|
|
1221
|
-
);
|
|
1222
|
-
var syncStatus = v.union(
|
|
1223
|
-
v.literal("synced"),
|
|
1224
|
-
// Node and edges fully synced to Neo4j
|
|
1225
|
-
v.literal("pending_edges"),
|
|
1226
|
-
// Node created, edges being created
|
|
1227
|
-
v.literal("edge_creation_failed")
|
|
1228
|
-
// Edge creation failed, needs retry
|
|
1229
|
-
);
|
|
1230
|
-
var audienceLabel = v.string();
|
|
1231
|
-
var sensitivityTier = v.union(
|
|
1232
|
-
v.literal("low"),
|
|
1233
|
-
v.literal("medium"),
|
|
1234
|
-
v.literal("high"),
|
|
1235
|
-
v.literal("restricted")
|
|
1236
|
-
);
|
|
1237
|
-
var exportClass = v.union(
|
|
1238
|
-
v.literal("internal_only"),
|
|
1239
|
-
v.literal("client_safe"),
|
|
1240
|
-
v.literal("public_safe"),
|
|
1241
|
-
v.literal("restricted")
|
|
1242
|
-
);
|
|
1243
|
-
var anonymizationClass = v.union(
|
|
1244
|
-
v.literal("none"),
|
|
1245
|
-
v.literal("standard"),
|
|
1246
|
-
v.literal("strict")
|
|
1247
|
-
);
|
|
1248
|
-
var epistemicStatus = v.union(
|
|
1249
|
-
v.literal("hypothesis"),
|
|
1250
|
-
// Initial conjecture, low evidence
|
|
1251
|
-
v.literal("emerging"),
|
|
1252
|
-
// Building evidence, gaining traction
|
|
1253
|
-
v.literal("established"),
|
|
1254
|
-
// Well-evidenced, core to thesis
|
|
1255
|
-
v.literal("challenged"),
|
|
1256
|
-
// Contradicting evidence appeared
|
|
1257
|
-
v.literal("assumption"),
|
|
1258
|
-
// Taken as given, not actively tested
|
|
1259
|
-
v.literal("deprecated")
|
|
1260
|
-
// Superseded or abandoned
|
|
1261
|
-
);
|
|
1262
|
-
var beliefStatus = v.union(
|
|
1263
|
-
v.literal("assumption"),
|
|
1264
|
-
v.literal("hypothesis"),
|
|
1265
|
-
v.literal("belief"),
|
|
1266
|
-
v.literal("fact")
|
|
1267
|
-
);
|
|
1268
|
-
var reversibility = v.union(
|
|
1269
|
-
v.literal("irreversible"),
|
|
1270
|
-
// One-way door decision
|
|
1271
|
-
v.literal("hard_to_reverse"),
|
|
1272
|
-
// Significant cost to undo
|
|
1273
|
-
v.literal("reversible"),
|
|
1274
|
-
// Can change course with moderate effort
|
|
1275
|
-
v.literal("trivial")
|
|
1276
|
-
// Easy to adjust
|
|
1277
|
-
);
|
|
1278
|
-
var predictionOutcome = v.union(
|
|
1279
|
-
v.literal("pending"),
|
|
1280
|
-
v.literal("confirmed"),
|
|
1281
|
-
v.literal("disconfirmed"),
|
|
1282
|
-
v.literal("partial"),
|
|
1283
|
-
v.literal("expired")
|
|
1284
|
-
);
|
|
1285
|
-
var predictionMeta = v.object({
|
|
1286
|
-
isPrediction: v.boolean(),
|
|
1287
|
-
registeredAt: v.number(),
|
|
1288
|
-
// When prediction was made
|
|
1289
|
-
expectedBy: v.optional(v.number()),
|
|
1290
|
-
// When we expect resolution
|
|
1291
|
-
outcome: v.optional(predictionOutcome),
|
|
1292
|
-
outcomeRecordedAt: v.optional(v.number()),
|
|
1293
|
-
outcomeEvidenceId: v.optional(v.string()),
|
|
1294
|
-
// globalId of confirming evidence
|
|
1295
|
-
confidenceAtPrediction: v.optional(v.number()),
|
|
1296
|
-
// 0-1
|
|
1297
|
-
actualVsPredicted: v.optional(v.string())
|
|
1298
|
-
// Notes on how outcome compared
|
|
1299
|
-
});
|
|
1300
|
-
var methodology = v.union(
|
|
1301
|
-
// Primary Research (high value)
|
|
1302
|
-
v.literal("primary_research"),
|
|
1303
|
-
// Direct investigation
|
|
1304
|
-
v.literal("expert_interview"),
|
|
1305
|
-
// Expert call/interview
|
|
1306
|
-
v.literal("customer_interview"),
|
|
1307
|
-
// Customer research
|
|
1308
|
-
v.literal("field_observation"),
|
|
1309
|
-
// On-site observation
|
|
1310
|
-
v.literal("proprietary_data"),
|
|
1311
|
-
// Internal data analysis
|
|
1312
|
-
// Secondary Research
|
|
1313
|
-
v.literal("desk_research"),
|
|
1314
|
-
// Public sources
|
|
1315
|
-
v.literal("regulatory_filing"),
|
|
1316
|
-
// SEC, regulatory docs
|
|
1317
|
-
v.literal("news_article"),
|
|
1318
|
-
// News/press
|
|
1319
|
-
v.literal("academic_paper"),
|
|
1320
|
-
// Academic research
|
|
1321
|
-
// AI-Assisted
|
|
1322
|
-
v.literal("ai_synthesis"),
|
|
1323
|
-
// AI-generated synthesis
|
|
1324
|
-
v.literal("ai_extraction")
|
|
1325
|
-
// AI-extracted from source
|
|
1326
|
-
);
|
|
1327
|
-
var informationAsymmetry = v.union(
|
|
1328
|
-
v.literal("proprietary"),
|
|
1329
|
-
// Only we have this
|
|
1330
|
-
v.literal("early"),
|
|
1331
|
-
// We're early but others will get it
|
|
1332
|
-
v.literal("common")
|
|
1333
|
-
// Everyone has access
|
|
1334
|
-
);
|
|
1335
|
-
var temporalNature = v.union(
|
|
1336
|
-
v.literal("factual"),
|
|
1337
|
-
// Resolved outcome. Grounded in reality.
|
|
1338
|
-
v.literal("forecast"),
|
|
1339
|
-
// Prediction. Will resolve. Discounted weight.
|
|
1340
|
-
v.literal("unknown")
|
|
1341
|
-
// Not yet classified.
|
|
1342
|
-
);
|
|
1343
|
-
var questionType = v.union(
|
|
1344
|
-
v.literal("validation"),
|
|
1345
|
-
// Does evidence support this belief?
|
|
1346
|
-
v.literal("falsification"),
|
|
1347
|
-
// What would prove this belief wrong?
|
|
1348
|
-
v.literal("assumption_probe"),
|
|
1349
|
-
// Is this unstated assumption true?
|
|
1350
|
-
v.literal("prediction_test"),
|
|
1351
|
-
// Will this predicted outcome occur?
|
|
1352
|
-
v.literal("counterfactual"),
|
|
1353
|
-
// What would we expect if X were false?
|
|
1354
|
-
v.literal("discovery"),
|
|
1355
|
-
// What don't we know yet?
|
|
1356
|
-
v.literal("clarification"),
|
|
1357
|
-
// What does X actually mean?
|
|
1358
|
-
v.literal("comparison"),
|
|
1359
|
-
// How does X compare to Y?
|
|
1360
|
-
v.literal("causal"),
|
|
1361
|
-
// What caused X?
|
|
1362
|
-
v.literal("mechanism"),
|
|
1363
|
-
// How does X work?
|
|
1364
|
-
v.literal("general")
|
|
1365
|
-
// Unclassified
|
|
1366
|
-
);
|
|
1367
|
-
var questionPriority = v.union(
|
|
1368
|
-
v.literal("critical"),
|
|
1369
|
-
// Blocks decision-making
|
|
1370
|
-
v.literal("high"),
|
|
1371
|
-
// Important for thesis
|
|
1372
|
-
v.literal("medium"),
|
|
1373
|
-
// Would be nice to know
|
|
1374
|
-
v.literal("low")
|
|
1375
|
-
// Background/curiosity
|
|
1376
|
-
);
|
|
1377
|
-
var answerQuality = v.union(
|
|
1378
|
-
v.literal("definitive"),
|
|
1379
|
-
// Clear, well-supported
|
|
1380
|
-
v.literal("strong"),
|
|
1381
|
-
// Good evidence, high confidence
|
|
1382
|
-
v.literal("moderate"),
|
|
1383
|
-
// Some evidence
|
|
1384
|
-
v.literal("weak"),
|
|
1385
|
-
// Limited evidence
|
|
1386
|
-
v.literal("speculative"),
|
|
1387
|
-
// Mostly conjecture
|
|
1388
|
-
v.literal("unanswered")
|
|
1389
|
-
// No answer yet
|
|
1390
|
-
);
|
|
1391
|
-
var consensusView = v.union(
|
|
1392
|
-
v.literal("aligned"),
|
|
1393
|
-
// We agree with market consensus
|
|
1394
|
-
v.literal("ahead_of"),
|
|
1395
|
-
// We see this before consensus does
|
|
1396
|
-
v.literal("contrarian"),
|
|
1397
|
-
// We actively disagree with consensus
|
|
1398
|
-
v.literal("orthogonal"),
|
|
1399
|
-
// We're looking at something consensus isn't discussing
|
|
1400
|
-
v.literal("unknown")
|
|
1401
|
-
// We don't know what consensus thinks
|
|
1402
|
-
);
|
|
1403
|
-
var themeConviction = v.union(
|
|
1404
|
-
v.literal("high"),
|
|
1405
|
-
// Strong conviction, actively deploying
|
|
1406
|
-
v.literal("medium"),
|
|
1407
|
-
// Building conviction
|
|
1408
|
-
v.literal("low"),
|
|
1409
|
-
// Exploring, not convicted
|
|
1410
|
-
v.literal("negative")
|
|
1411
|
-
// Actively avoiding
|
|
1412
|
-
);
|
|
1413
|
-
var decisionType = v.union(
|
|
1414
|
-
v.literal("invest"),
|
|
1415
|
-
v.literal("pass"),
|
|
1416
|
-
v.literal("follow_on"),
|
|
1417
|
-
v.literal("exit"),
|
|
1418
|
-
v.literal("deep_dive"),
|
|
1419
|
-
v.literal("monitor"),
|
|
1420
|
-
v.literal("deprioritize"),
|
|
1421
|
-
v.literal("thesis_adopt"),
|
|
1422
|
-
v.literal("thesis_revise"),
|
|
1423
|
-
v.literal("thesis_abandon")
|
|
1424
|
-
);
|
|
1425
|
-
var decisionOutcome = v.union(
|
|
1426
|
-
v.literal("pending"),
|
|
1427
|
-
v.literal("successful"),
|
|
1428
|
-
v.literal("unsuccessful"),
|
|
1429
|
-
v.literal("mixed"),
|
|
1430
|
-
v.literal("unknown")
|
|
1431
|
-
);
|
|
1432
|
-
var externalIds2 = v.object({
|
|
1433
|
-
crunchbase: v.optional(v.string()),
|
|
1434
|
-
linkedin: v.optional(v.string()),
|
|
1435
|
-
pitchbook: v.optional(v.string()),
|
|
1436
|
-
twitter: v.optional(v.string()),
|
|
1437
|
-
website: v.optional(v.string())
|
|
1438
|
-
});
|
|
1439
|
-
defineTable({
|
|
1440
|
-
// === IDENTITY ===
|
|
1441
|
-
globalId: v.string(),
|
|
1442
|
-
// UUID - survives migration to Neo4j
|
|
1443
|
-
// === TYPE ===
|
|
1444
|
-
nodeType,
|
|
1445
|
-
// === EPISTEMIC LAYER ===
|
|
1446
|
-
epistemicLayer: v.optional(epistemicLayer),
|
|
1447
|
-
// === SUBTYPE (for typed entities) ===
|
|
1448
|
-
subtype: v.optional(v.string()),
|
|
1449
|
-
// company: private|corporate|portfolio, investor: vc|lp|cvc|pe|family_office|angel
|
|
1450
|
-
// === CONTENT ===
|
|
1451
|
-
canonicalText: v.string(),
|
|
1452
|
-
// The core content (belief statement, company name, etc.)
|
|
1453
|
-
contentHash: v.string(),
|
|
1454
|
-
// SHA256(nodeType + canonicalText) for deduplication
|
|
1455
|
-
// Extended content (for sources/syntheses)
|
|
1456
|
-
content: v.optional(v.string()),
|
|
1457
|
-
// Full text for documents/articles
|
|
1458
|
-
contentType: v.optional(v.string()),
|
|
1459
|
-
// "markdown", "html", "pdf", "text"
|
|
1460
|
-
// === METADATA ===
|
|
1461
|
-
title: v.optional(v.string()),
|
|
1462
|
-
// Display title
|
|
1463
|
-
tags: v.optional(v.array(v.string())),
|
|
1464
|
-
domain: v.optional(v.string()),
|
|
1465
|
-
// For companies: website domain
|
|
1466
|
-
// Type-specific metadata (flexible object - LEGACY)
|
|
1467
|
-
// New code should use the typed fields below when available
|
|
1468
|
-
metadata: v.optional(looseJsonObject),
|
|
1469
|
-
// === POLICY / ENTITLEMENT ===
|
|
1470
|
-
tenantId: v.optional(v.string()),
|
|
1471
|
-
workspaceId: v.optional(v.string()),
|
|
1472
|
-
ownerPrincipalId: v.optional(v.string()),
|
|
1473
|
-
audienceLabel: v.optional(audienceLabel),
|
|
1474
|
-
policyTags: v.optional(v.array(v.string())),
|
|
1475
|
-
sensitivityTier: v.optional(sensitivityTier),
|
|
1476
|
-
exportClass: v.optional(exportClass),
|
|
1477
|
-
anonymizationClass: v.optional(anonymizationClass),
|
|
1478
|
-
// === PUBLICATION (visibility-based, not copy-based) ===
|
|
1479
|
-
// Publication expands who can see a workspace-local node — the node stays
|
|
1480
|
-
// in its workspace, like a microservice exposing part of its API surface.
|
|
1481
|
-
// Rules-based: pack/tenant-level publicationRules auto-evaluate on
|
|
1482
|
-
// confidence changes and node creation. No manual click-by-click.
|
|
1483
|
-
publicationStatus: v.optional(
|
|
1484
|
-
v.union(
|
|
1485
|
-
v.literal("unpublished"),
|
|
1486
|
-
// Default: workspace-local only
|
|
1487
|
-
v.literal("published"),
|
|
1488
|
-
// Visible at tenant scope (rules matched)
|
|
1489
|
-
v.literal("suppressed")
|
|
1490
|
-
// Manually blocked even if rules match
|
|
1491
|
-
)
|
|
1492
|
-
),
|
|
1493
|
-
publishedAt: v.optional(v.number()),
|
|
1494
|
-
// When publication status last changed to published
|
|
1495
|
-
publishedBy: v.optional(v.string()),
|
|
1496
|
-
// userId or "system:publication_rules" for auto-publish
|
|
1497
|
-
// === TYPED METADATA FIELDS ===
|
|
1498
|
-
// --- Belief ---
|
|
1499
|
-
// Belief type — validated against schemaEnumConfig category "belief_type"
|
|
1500
|
-
// Platform core: hypothesis, belief, principle, invariant, assumption,
|
|
1501
|
-
// tenet, prior, preference, goal, forecast
|
|
1502
|
-
beliefType: v.optional(v.string()),
|
|
1503
|
-
beliefStatus: v.optional(beliefStatus),
|
|
1504
|
-
epistemicStatus: v.optional(epistemicStatus),
|
|
1505
|
-
reversibility: v.optional(reversibility),
|
|
1506
|
-
predictionMeta: v.optional(predictionMeta),
|
|
1507
|
-
// Consensus tracking (for non-consensus detection)
|
|
1508
|
-
consensusView: v.optional(consensusView),
|
|
1509
|
-
consensusConfidence: v.optional(v.number()),
|
|
1510
|
-
// 0-1: What we think consensus confidence is
|
|
1511
|
-
consensusSource: v.optional(v.string()),
|
|
1512
|
-
// Where we got the consensus view (twitter, reports, etc.)
|
|
1513
|
-
// --- Evidence ---
|
|
1514
|
-
methodology: v.optional(methodology),
|
|
1515
|
-
informationAsymmetry: v.optional(informationAsymmetry),
|
|
1516
|
-
temporalNature: v.optional(temporalNature),
|
|
1517
|
-
// --- Question ---
|
|
1518
|
-
questionType: v.optional(questionType),
|
|
1519
|
-
questionPriority: v.optional(questionPriority),
|
|
1520
|
-
answerQuality: v.optional(answerQuality),
|
|
1521
|
-
// --- Theme ---
|
|
1522
|
-
themeConviction: v.optional(themeConviction),
|
|
1523
|
-
// Market timing (for "early on theme" detection)
|
|
1524
|
-
marketAwarenessDate: v.optional(v.number()),
|
|
1525
|
-
// When this theme became broadly discussed
|
|
1526
|
-
marketAwarenessSource: v.optional(v.string()),
|
|
1527
|
-
// How we know (first major report, twitter volume spike, etc.)
|
|
1528
|
-
earlySignalIds: v.optional(v.array(v.string())),
|
|
1529
|
-
// globalIds of evidence we had before market awareness
|
|
1530
|
-
// --- Decision ---
|
|
1531
|
-
decisionType: v.optional(decisionType),
|
|
1532
|
-
decisionOutcome: v.optional(decisionOutcome),
|
|
1533
|
-
// === EXTERNAL IDS (for ontological entities) ===
|
|
1534
|
-
externalIds: v.optional(externalIds2),
|
|
1535
|
-
// === PROVENANCE ===
|
|
1536
|
-
sourceType: sourceType2,
|
|
1537
|
-
aiProvider: v.optional(v.string()),
|
|
1538
|
-
// "claude", "gemini", "gpt-4", etc.
|
|
1539
|
-
extractedFromNodeId: v.optional(v.id("epistemicNodes")),
|
|
1540
|
-
// Quick reference to source
|
|
1541
|
-
// === EXTRACTION CONTEXT ===
|
|
1542
|
-
extractionModel: v.optional(v.string()),
|
|
1543
|
-
// "claude-sonnet-4-20250514"
|
|
1544
|
-
extractionPromptName: v.optional(v.string()),
|
|
1545
|
-
// "lucern/extract-evidence"
|
|
1546
|
-
extractionPromptVersion: v.optional(v.number()),
|
|
1547
|
-
extractionTemperature: v.optional(v.number()),
|
|
1548
|
-
extractionLangfuseTraceId: v.optional(v.string()),
|
|
1549
|
-
// === GROUNDING VERIFICATION ===
|
|
1550
|
-
groundingVerified: v.optional(v.boolean()),
|
|
1551
|
-
groundingConfidence: v.optional(v.number()),
|
|
1552
|
-
// 0-1 match quality
|
|
1553
|
-
groundingMatchedText: v.optional(v.string()),
|
|
1554
|
-
// Actual text from source
|
|
1555
|
-
groundingStartOffset: v.optional(v.number()),
|
|
1556
|
-
groundingEndOffset: v.optional(v.number()),
|
|
1557
|
-
groundingRejectionReason: v.optional(v.string()),
|
|
1558
|
-
// === CONFIDENCE & VERIFICATION ===
|
|
1559
|
-
confidence: v.optional(v.number()),
|
|
1560
|
-
// 0-1 projected probability P(x) = b + a*u
|
|
1561
|
-
verificationStatus: v.optional(verificationStatus),
|
|
1562
|
-
// === SL OPINION (Subjective Logic — Kernel v2) ===
|
|
1563
|
-
// Replaces scalar confidence with rich epistemic state.
|
|
1564
|
-
// b + d + u = 1. P(x) = b + a*u is stored in `confidence` for backward compat.
|
|
1565
|
-
opinion_b: v.optional(v.number()),
|
|
1566
|
-
// Belief: evidence FOR (0-1)
|
|
1567
|
-
opinion_d: v.optional(v.number()),
|
|
1568
|
-
// Disbelief: evidence AGAINST (0-1)
|
|
1569
|
-
opinion_u: v.optional(v.number()),
|
|
1570
|
-
// Uncertainty: absence of evidence (0-1)
|
|
1571
|
-
opinion_a: v.optional(v.number()),
|
|
1572
|
-
// Base rate / prior probability (0-1)
|
|
1573
|
-
tupleContradicted: v.optional(v.boolean()),
|
|
1574
|
-
// Single-belief tuple-space contradiction flag
|
|
1575
|
-
// === LIFECYCLE ===
|
|
1576
|
-
status: nodeStatus,
|
|
1577
|
-
supersededBy: v.optional(v.id("epistemicNodes")),
|
|
1578
|
-
// === OWNERSHIP ===
|
|
1579
|
-
topicId: v.optional(v.string()),
|
|
1580
|
-
// Canonical scope container (topic-first model)
|
|
1581
|
-
projectId: v.optional(v.string()),
|
|
1582
|
-
// DEPRECATED: Use belongs_to edges
|
|
1583
|
-
createdBy: v.string(),
|
|
1584
|
-
// Clerk user ID
|
|
1585
|
-
createdAt: v.number(),
|
|
1586
|
-
updatedAt: v.number(),
|
|
1587
|
-
// === NEO4J SYNC STATUS ===
|
|
1588
|
-
syncStatus: v.optional(syncStatus),
|
|
1589
|
-
syncError: v.optional(v.string())
|
|
1590
|
-
// Error message if sync failed
|
|
1591
|
-
}).index("by_globalId", ["globalId"]).index("by_contentHash", ["contentHash"]).index("by_nodeType", ["nodeType"]).index("by_subtype", ["nodeType", "subtype"]).index("by_domain", ["domain"]).index("by_project", ["projectId"]).index("by_project_type", ["projectId", "nodeType"]).index("by_topic", ["topicId"]).index("by_topic_type", ["topicId", "nodeType"]).index("by_tenantId", ["tenantId"]).index("by_workspaceId", ["workspaceId"]).index("by_tenant_workspace", ["tenantId", "workspaceId"]).index("by_audienceLabel", ["audienceLabel"]).index("by_sensitivityTier", ["sensitivityTier"]).index("by_exportClass", ["exportClass"]).index("by_status", ["status"]).index("by_sourceType", ["sourceType"]).index("by_verification", ["verificationStatus"]).index("by_layer", ["epistemicLayer"]).index("by_layer_type", ["epistemicLayer", "nodeType"]).index("by_syncStatus", ["syncStatus"]).index("by_publicationStatus", ["publicationStatus"]).index("by_tenant_publicationStatus", ["tenantId", "publicationStatus"]).index("by_belief_status", ["nodeType", "beliefStatus"]).index("by_epistemic_status", ["nodeType", "epistemicStatus"]).index("by_temporal_nature", ["nodeType", "temporalNature"]).index("by_methodology", ["nodeType", "methodology"]).index("by_reversibility", ["nodeType", "reversibility"]).index("by_questionType", ["nodeType", "questionType"]).index("by_questionPriority", ["nodeType", "questionPriority"]).searchIndex("search_canonicalText", {
|
|
1592
|
-
searchField: "canonicalText",
|
|
1593
|
-
filterFields: ["nodeType", "projectId", "topicId", "status"]
|
|
1594
|
-
});
|
|
1035
|
+
// ../../packages/contracts/src/schema-helpers/spine/tables/epistemicNodes.ts
|
|
1036
|
+
var NODE_TYPES = [
|
|
1037
|
+
"decision",
|
|
1038
|
+
"belief",
|
|
1039
|
+
"question",
|
|
1040
|
+
"theme",
|
|
1041
|
+
"deal",
|
|
1042
|
+
"topic",
|
|
1043
|
+
"claim",
|
|
1044
|
+
"evidence",
|
|
1045
|
+
"synthesis",
|
|
1046
|
+
"answer",
|
|
1047
|
+
"atomic_fact",
|
|
1048
|
+
"excerpt",
|
|
1049
|
+
"source",
|
|
1050
|
+
"company",
|
|
1051
|
+
"person",
|
|
1052
|
+
"investor",
|
|
1053
|
+
"function",
|
|
1054
|
+
"value_chain"
|
|
1055
|
+
];
|
|
1056
|
+
function isNodeType(value) {
|
|
1057
|
+
return NODE_TYPES.includes(value);
|
|
1058
|
+
}
|
|
1595
1059
|
function getLayerForNodeType(type) {
|
|
1596
1060
|
switch (type) {
|
|
1597
1061
|
case "decision":
|
|
@@ -1639,7 +1103,7 @@ function throwWorkspaceIsolationError(args) {
|
|
|
1639
1103
|
throw error;
|
|
1640
1104
|
}
|
|
1641
1105
|
function assertWorkspaceScopedEpistemicNodeScope(args) {
|
|
1642
|
-
const layer = getLayerForNodeType(args.nodeType);
|
|
1106
|
+
const layer = isNodeType(args.nodeType) ? getLayerForNodeType(args.nodeType) : void 0;
|
|
1643
1107
|
if (layer === "ontological") {
|
|
1644
1108
|
return;
|
|
1645
1109
|
}
|
|
@@ -1689,10 +1153,10 @@ function normalizeMetadata(metadata) {
|
|
|
1689
1153
|
return rest;
|
|
1690
1154
|
}
|
|
1691
1155
|
function generateSourceContentHash(identity) {
|
|
1692
|
-
const
|
|
1156
|
+
const content = `source:${identity.trim().toLowerCase()}`;
|
|
1693
1157
|
let hash = 5381;
|
|
1694
|
-
for (let index = 0; index <
|
|
1695
|
-
hash = (hash << 5) + hash +
|
|
1158
|
+
for (let index = 0; index < content.length; index += 1) {
|
|
1159
|
+
hash = (hash << 5) + hash + content.charCodeAt(index);
|
|
1696
1160
|
hash &= hash;
|
|
1697
1161
|
}
|
|
1698
1162
|
return Math.abs(hash).toString(16).padStart(8, "0");
|