@lucern/graph-primitives 0.1.0-alpha.3 → 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v } from 'convex/values';
|
|
2
|
-
import { componentsGeneric,
|
|
2
|
+
import { componentsGeneric, mutationGeneric, anyApi, queryGeneric, internalQueryGeneric, internalMutationGeneric } from 'convex/server';
|
|
3
3
|
|
|
4
4
|
// src/epistemicQuestions.ts
|
|
5
5
|
var api = anyApi;
|
|
@@ -1443,567 +1443,31 @@ var optionalScopeArgs = {
|
|
|
1443
1443
|
projectId: v.optional(v.string()),
|
|
1444
1444
|
topicId: v.optional(v.string())
|
|
1445
1445
|
};
|
|
1446
|
-
v.number();
|
|
1447
|
-
v.union(
|
|
1448
|
-
v.literal("very_high"),
|
|
1449
|
-
// 0.9+
|
|
1450
|
-
v.literal("high"),
|
|
1451
|
-
// 0.7-0.9
|
|
1452
|
-
v.literal("medium"),
|
|
1453
|
-
// 0.4-0.7
|
|
1454
|
-
v.literal("low"),
|
|
1455
|
-
// 0.2-0.4
|
|
1456
|
-
v.literal("very_low")
|
|
1457
|
-
// 0-0.2
|
|
1458
|
-
);
|
|
1459
|
-
v.union(
|
|
1460
|
-
v.literal(1),
|
|
1461
|
-
// Critical
|
|
1462
|
-
v.literal(2),
|
|
1463
|
-
// High
|
|
1464
|
-
v.literal(3),
|
|
1465
|
-
// Medium
|
|
1466
|
-
v.literal(4),
|
|
1467
|
-
// Low
|
|
1468
|
-
v.literal(5)
|
|
1469
|
-
// Backlog
|
|
1470
|
-
);
|
|
1471
|
-
v.union(
|
|
1472
|
-
v.literal("critical"),
|
|
1473
|
-
v.literal("high"),
|
|
1474
|
-
v.literal("medium"),
|
|
1475
|
-
v.literal("low"),
|
|
1476
|
-
v.literal("backlog")
|
|
1477
|
-
);
|
|
1478
|
-
v.union(
|
|
1479
|
-
v.literal("active"),
|
|
1480
|
-
v.literal("paused"),
|
|
1481
|
-
v.literal("completed"),
|
|
1482
|
-
v.literal("archived")
|
|
1483
|
-
);
|
|
1484
|
-
v.union(
|
|
1485
|
-
v.literal("pending"),
|
|
1486
|
-
v.literal("processing"),
|
|
1487
|
-
v.literal("completed"),
|
|
1488
|
-
v.literal("failed")
|
|
1489
|
-
);
|
|
1490
|
-
v.object({
|
|
1491
|
-
crunchbaseId: v.optional(v.string()),
|
|
1492
|
-
linkedinUrl: v.optional(v.string()),
|
|
1493
|
-
pitchbookId: v.optional(v.string()),
|
|
1494
|
-
twitterUrl: v.optional(v.string()),
|
|
1495
|
-
domain: v.optional(v.string())
|
|
1496
|
-
});
|
|
1497
|
-
var sourceType = v.union(
|
|
1498
|
-
v.literal("proprietary"),
|
|
1499
|
-
// Internal Stack research
|
|
1500
|
-
v.literal("primary"),
|
|
1501
|
-
// Direct interviews, calls
|
|
1502
|
-
v.literal("secondary"),
|
|
1503
|
-
// Published sources
|
|
1504
|
-
v.literal("ai_generated"),
|
|
1505
|
-
// AI-synthesized
|
|
1506
|
-
v.literal("user_input"),
|
|
1507
|
-
// Manual user entry
|
|
1508
|
-
v.literal("inferred")
|
|
1509
|
-
// System inference
|
|
1510
|
-
);
|
|
1511
|
-
v.object({
|
|
1512
|
-
sourceType: v.optional(sourceType),
|
|
1513
|
-
sourceId: v.optional(v.string()),
|
|
1514
|
-
// Reference to source entity
|
|
1515
|
-
sourceUrl: v.optional(v.string()),
|
|
1516
|
-
sourceDate: v.optional(v.number()),
|
|
1517
|
-
sourceName: v.optional(v.string())
|
|
1518
|
-
});
|
|
1519
|
-
v.object({
|
|
1520
|
-
cursor: v.optional(v.string()),
|
|
1521
|
-
limit: v.optional(v.number())
|
|
1522
|
-
});
|
|
1523
|
-
v.object({
|
|
1524
|
-
hasMore: v.boolean(),
|
|
1525
|
-
nextCursor: v.optional(v.string()),
|
|
1526
|
-
totalCount: v.optional(v.number())
|
|
1527
|
-
});
|
|
1528
|
-
var richTextContent = v.object({
|
|
1529
|
-
type: v.literal("doc"),
|
|
1530
|
-
content: looseJsonArray
|
|
1531
|
-
});
|
|
1532
|
-
v.union(v.string(), richTextContent);
|
|
1533
|
-
v.object({
|
|
1534
|
-
promptTokens: v.optional(v.number()),
|
|
1535
|
-
completionTokens: v.optional(v.number()),
|
|
1536
|
-
totalTokens: v.optional(v.number())
|
|
1537
|
-
});
|
|
1538
|
-
v.object({
|
|
1539
|
-
fileName: v.optional(v.string()),
|
|
1540
|
-
fileSize: v.optional(v.number()),
|
|
1541
|
-
mimeType: v.optional(v.string()),
|
|
1542
|
-
storageId: v.optional(v.id("_storage")),
|
|
1543
|
-
externalUrl: v.optional(v.string())
|
|
1544
|
-
});
|
|
1545
1446
|
|
|
1546
|
-
//
|
|
1547
|
-
var
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
// Immutable answer snapshot for a question
|
|
1571
|
-
// --- L1: Terminal Leaves (non-traversable, grounding) ---
|
|
1572
|
-
v.literal("atomic_fact"),
|
|
1573
|
-
// Raw fact from source (not interpreted)
|
|
1574
|
-
v.literal("excerpt"),
|
|
1575
|
-
// Direct quote from source document
|
|
1576
|
-
v.literal("source"),
|
|
1577
|
-
// News, documents, transcripts
|
|
1578
|
-
// --- Ontological Entities (things in the world) ---
|
|
1579
|
-
v.literal("company"),
|
|
1580
|
-
// Organization (subtype: private, corporate, portfolio)
|
|
1581
|
-
v.literal("person"),
|
|
1582
|
-
// Individual (founder, expert, LP, contact)
|
|
1583
|
-
v.literal("investor"),
|
|
1584
|
-
// Investment entity (subtype: vc, lp, cvc, pe, family_office, angel)
|
|
1585
|
-
v.literal("function"),
|
|
1586
|
-
// What a company does (from classifier)
|
|
1587
|
-
v.literal("value_chain")
|
|
1588
|
-
// Market structure / value flow
|
|
1589
|
-
);
|
|
1590
|
-
var epistemicLayer = v.union(
|
|
1591
|
-
v.literal("L4"),
|
|
1592
|
-
// Decisions, outcomes - audit targets
|
|
1593
|
-
v.literal("L3"),
|
|
1594
|
-
// Beliefs, questions, themes - traversal anchors
|
|
1595
|
-
v.literal("L2"),
|
|
1596
|
-
// Claims, evidence, synthesis - compression boundary
|
|
1597
|
-
v.literal("L1"),
|
|
1598
|
-
// Atomic facts, excerpts, sources - terminal leaves
|
|
1599
|
-
v.literal("ontological"),
|
|
1600
|
-
// Companies, people, etc - not epistemic
|
|
1601
|
-
v.literal("organizational")
|
|
1602
|
-
// Topics, lenses, worktrees — structural containers
|
|
1603
|
-
);
|
|
1604
|
-
var nodeStatus = v.union(
|
|
1605
|
-
v.literal("active"),
|
|
1606
|
-
v.literal("superseded"),
|
|
1607
|
-
// Replaced by newer version
|
|
1608
|
-
v.literal("archived"),
|
|
1609
|
-
v.literal("deleted")
|
|
1610
|
-
);
|
|
1611
|
-
var sourceType2 = v.union(
|
|
1612
|
-
v.literal("human"),
|
|
1613
|
-
// User created directly
|
|
1614
|
-
v.literal("ai_extracted"),
|
|
1615
|
-
// LLM extracted from a source
|
|
1616
|
-
v.literal("ai_generated"),
|
|
1617
|
-
// LLM synthesized/created
|
|
1618
|
-
v.literal("imported"),
|
|
1619
|
-
// External system import
|
|
1620
|
-
v.literal("system"),
|
|
1621
|
-
// System-generated (migrations, classifiers)
|
|
1622
|
-
v.literal("verified"),
|
|
1623
|
-
// Human-verified source
|
|
1624
|
-
v.literal("proprietary")
|
|
1625
|
-
// Proprietary/internal data
|
|
1626
|
-
);
|
|
1627
|
-
var verificationStatus = v.union(
|
|
1628
|
-
v.literal("unverified"),
|
|
1629
|
-
v.literal("human_verified"),
|
|
1630
|
-
v.literal("ai_verified"),
|
|
1631
|
-
v.literal("contradicted"),
|
|
1632
|
-
v.literal("outdated")
|
|
1633
|
-
);
|
|
1634
|
-
var syncStatus = v.union(
|
|
1635
|
-
v.literal("synced"),
|
|
1636
|
-
// Node and edges fully synced to Neo4j
|
|
1637
|
-
v.literal("pending_edges"),
|
|
1638
|
-
// Node created, edges being created
|
|
1639
|
-
v.literal("edge_creation_failed")
|
|
1640
|
-
// Edge creation failed, needs retry
|
|
1641
|
-
);
|
|
1642
|
-
var audienceLabel = v.string();
|
|
1643
|
-
var sensitivityTier = v.union(
|
|
1644
|
-
v.literal("low"),
|
|
1645
|
-
v.literal("medium"),
|
|
1646
|
-
v.literal("high"),
|
|
1647
|
-
v.literal("restricted")
|
|
1648
|
-
);
|
|
1649
|
-
var exportClass = v.union(
|
|
1650
|
-
v.literal("internal_only"),
|
|
1651
|
-
v.literal("client_safe"),
|
|
1652
|
-
v.literal("public_safe"),
|
|
1653
|
-
v.literal("restricted")
|
|
1654
|
-
);
|
|
1655
|
-
var anonymizationClass = v.union(
|
|
1656
|
-
v.literal("none"),
|
|
1657
|
-
v.literal("standard"),
|
|
1658
|
-
v.literal("strict")
|
|
1659
|
-
);
|
|
1660
|
-
var epistemicStatus = v.union(
|
|
1661
|
-
v.literal("hypothesis"),
|
|
1662
|
-
// Initial conjecture, low evidence
|
|
1663
|
-
v.literal("emerging"),
|
|
1664
|
-
// Building evidence, gaining traction
|
|
1665
|
-
v.literal("established"),
|
|
1666
|
-
// Well-evidenced, core to thesis
|
|
1667
|
-
v.literal("challenged"),
|
|
1668
|
-
// Contradicting evidence appeared
|
|
1669
|
-
v.literal("assumption"),
|
|
1670
|
-
// Taken as given, not actively tested
|
|
1671
|
-
v.literal("deprecated")
|
|
1672
|
-
// Superseded or abandoned
|
|
1673
|
-
);
|
|
1674
|
-
var beliefStatus = v.union(
|
|
1675
|
-
v.literal("assumption"),
|
|
1676
|
-
v.literal("hypothesis"),
|
|
1677
|
-
v.literal("belief"),
|
|
1678
|
-
v.literal("fact")
|
|
1679
|
-
);
|
|
1680
|
-
var reversibility = v.union(
|
|
1681
|
-
v.literal("irreversible"),
|
|
1682
|
-
// One-way door decision
|
|
1683
|
-
v.literal("hard_to_reverse"),
|
|
1684
|
-
// Significant cost to undo
|
|
1685
|
-
v.literal("reversible"),
|
|
1686
|
-
// Can change course with moderate effort
|
|
1687
|
-
v.literal("trivial")
|
|
1688
|
-
// Easy to adjust
|
|
1689
|
-
);
|
|
1690
|
-
var predictionOutcome = v.union(
|
|
1691
|
-
v.literal("pending"),
|
|
1692
|
-
v.literal("confirmed"),
|
|
1693
|
-
v.literal("disconfirmed"),
|
|
1694
|
-
v.literal("partial"),
|
|
1695
|
-
v.literal("expired")
|
|
1696
|
-
);
|
|
1697
|
-
var predictionMeta = v.object({
|
|
1698
|
-
isPrediction: v.boolean(),
|
|
1699
|
-
registeredAt: v.number(),
|
|
1700
|
-
// When prediction was made
|
|
1701
|
-
expectedBy: v.optional(v.number()),
|
|
1702
|
-
// When we expect resolution
|
|
1703
|
-
outcome: v.optional(predictionOutcome),
|
|
1704
|
-
outcomeRecordedAt: v.optional(v.number()),
|
|
1705
|
-
outcomeEvidenceId: v.optional(v.string()),
|
|
1706
|
-
// globalId of confirming evidence
|
|
1707
|
-
confidenceAtPrediction: v.optional(v.number()),
|
|
1708
|
-
// 0-1
|
|
1709
|
-
actualVsPredicted: v.optional(v.string())
|
|
1710
|
-
// Notes on how outcome compared
|
|
1711
|
-
});
|
|
1712
|
-
var methodology = v.union(
|
|
1713
|
-
// Primary Research (high value)
|
|
1714
|
-
v.literal("primary_research"),
|
|
1715
|
-
// Direct investigation
|
|
1716
|
-
v.literal("expert_interview"),
|
|
1717
|
-
// Expert call/interview
|
|
1718
|
-
v.literal("customer_interview"),
|
|
1719
|
-
// Customer research
|
|
1720
|
-
v.literal("field_observation"),
|
|
1721
|
-
// On-site observation
|
|
1722
|
-
v.literal("proprietary_data"),
|
|
1723
|
-
// Internal data analysis
|
|
1724
|
-
// Secondary Research
|
|
1725
|
-
v.literal("desk_research"),
|
|
1726
|
-
// Public sources
|
|
1727
|
-
v.literal("regulatory_filing"),
|
|
1728
|
-
// SEC, regulatory docs
|
|
1729
|
-
v.literal("news_article"),
|
|
1730
|
-
// News/press
|
|
1731
|
-
v.literal("academic_paper"),
|
|
1732
|
-
// Academic research
|
|
1733
|
-
// AI-Assisted
|
|
1734
|
-
v.literal("ai_synthesis"),
|
|
1735
|
-
// AI-generated synthesis
|
|
1736
|
-
v.literal("ai_extraction")
|
|
1737
|
-
// AI-extracted from source
|
|
1738
|
-
);
|
|
1739
|
-
var informationAsymmetry = v.union(
|
|
1740
|
-
v.literal("proprietary"),
|
|
1741
|
-
// Only we have this
|
|
1742
|
-
v.literal("early"),
|
|
1743
|
-
// We're early but others will get it
|
|
1744
|
-
v.literal("common")
|
|
1745
|
-
// Everyone has access
|
|
1746
|
-
);
|
|
1747
|
-
var temporalNature = v.union(
|
|
1748
|
-
v.literal("factual"),
|
|
1749
|
-
// Resolved outcome. Grounded in reality.
|
|
1750
|
-
v.literal("forecast"),
|
|
1751
|
-
// Prediction. Will resolve. Discounted weight.
|
|
1752
|
-
v.literal("unknown")
|
|
1753
|
-
// Not yet classified.
|
|
1754
|
-
);
|
|
1755
|
-
var questionType = v.union(
|
|
1756
|
-
v.literal("validation"),
|
|
1757
|
-
// Does evidence support this belief?
|
|
1758
|
-
v.literal("falsification"),
|
|
1759
|
-
// What would prove this belief wrong?
|
|
1760
|
-
v.literal("assumption_probe"),
|
|
1761
|
-
// Is this unstated assumption true?
|
|
1762
|
-
v.literal("prediction_test"),
|
|
1763
|
-
// Will this predicted outcome occur?
|
|
1764
|
-
v.literal("counterfactual"),
|
|
1765
|
-
// What would we expect if X were false?
|
|
1766
|
-
v.literal("discovery"),
|
|
1767
|
-
// What don't we know yet?
|
|
1768
|
-
v.literal("clarification"),
|
|
1769
|
-
// What does X actually mean?
|
|
1770
|
-
v.literal("comparison"),
|
|
1771
|
-
// How does X compare to Y?
|
|
1772
|
-
v.literal("causal"),
|
|
1773
|
-
// What caused X?
|
|
1774
|
-
v.literal("mechanism"),
|
|
1775
|
-
// How does X work?
|
|
1776
|
-
v.literal("general")
|
|
1777
|
-
// Unclassified
|
|
1778
|
-
);
|
|
1779
|
-
var questionPriority = v.union(
|
|
1780
|
-
v.literal("critical"),
|
|
1781
|
-
// Blocks decision-making
|
|
1782
|
-
v.literal("high"),
|
|
1783
|
-
// Important for thesis
|
|
1784
|
-
v.literal("medium"),
|
|
1785
|
-
// Would be nice to know
|
|
1786
|
-
v.literal("low")
|
|
1787
|
-
// Background/curiosity
|
|
1788
|
-
);
|
|
1789
|
-
var answerQuality = v.union(
|
|
1790
|
-
v.literal("definitive"),
|
|
1791
|
-
// Clear, well-supported
|
|
1792
|
-
v.literal("strong"),
|
|
1793
|
-
// Good evidence, high confidence
|
|
1794
|
-
v.literal("moderate"),
|
|
1795
|
-
// Some evidence
|
|
1796
|
-
v.literal("weak"),
|
|
1797
|
-
// Limited evidence
|
|
1798
|
-
v.literal("speculative"),
|
|
1799
|
-
// Mostly conjecture
|
|
1800
|
-
v.literal("unanswered")
|
|
1801
|
-
// No answer yet
|
|
1802
|
-
);
|
|
1803
|
-
var consensusView = v.union(
|
|
1804
|
-
v.literal("aligned"),
|
|
1805
|
-
// We agree with market consensus
|
|
1806
|
-
v.literal("ahead_of"),
|
|
1807
|
-
// We see this before consensus does
|
|
1808
|
-
v.literal("contrarian"),
|
|
1809
|
-
// We actively disagree with consensus
|
|
1810
|
-
v.literal("orthogonal"),
|
|
1811
|
-
// We're looking at something consensus isn't discussing
|
|
1812
|
-
v.literal("unknown")
|
|
1813
|
-
// We don't know what consensus thinks
|
|
1814
|
-
);
|
|
1815
|
-
var themeConviction = v.union(
|
|
1816
|
-
v.literal("high"),
|
|
1817
|
-
// Strong conviction, actively deploying
|
|
1818
|
-
v.literal("medium"),
|
|
1819
|
-
// Building conviction
|
|
1820
|
-
v.literal("low"),
|
|
1821
|
-
// Exploring, not convicted
|
|
1822
|
-
v.literal("negative")
|
|
1823
|
-
// Actively avoiding
|
|
1824
|
-
);
|
|
1825
|
-
var decisionType = v.union(
|
|
1826
|
-
v.literal("invest"),
|
|
1827
|
-
v.literal("pass"),
|
|
1828
|
-
v.literal("follow_on"),
|
|
1829
|
-
v.literal("exit"),
|
|
1830
|
-
v.literal("deep_dive"),
|
|
1831
|
-
v.literal("monitor"),
|
|
1832
|
-
v.literal("deprioritize"),
|
|
1833
|
-
v.literal("thesis_adopt"),
|
|
1834
|
-
v.literal("thesis_revise"),
|
|
1835
|
-
v.literal("thesis_abandon")
|
|
1836
|
-
);
|
|
1837
|
-
var decisionOutcome = v.union(
|
|
1838
|
-
v.literal("pending"),
|
|
1839
|
-
v.literal("successful"),
|
|
1840
|
-
v.literal("unsuccessful"),
|
|
1841
|
-
v.literal("mixed"),
|
|
1842
|
-
v.literal("unknown")
|
|
1843
|
-
);
|
|
1844
|
-
var externalIds2 = v.object({
|
|
1845
|
-
crunchbase: v.optional(v.string()),
|
|
1846
|
-
linkedin: v.optional(v.string()),
|
|
1847
|
-
pitchbook: v.optional(v.string()),
|
|
1848
|
-
twitter: v.optional(v.string()),
|
|
1849
|
-
website: v.optional(v.string())
|
|
1850
|
-
});
|
|
1851
|
-
defineTable({
|
|
1852
|
-
// === IDENTITY ===
|
|
1853
|
-
globalId: v.string(),
|
|
1854
|
-
// UUID - survives migration to Neo4j
|
|
1855
|
-
// === TYPE ===
|
|
1856
|
-
nodeType,
|
|
1857
|
-
// === EPISTEMIC LAYER ===
|
|
1858
|
-
epistemicLayer: v.optional(epistemicLayer),
|
|
1859
|
-
// === SUBTYPE (for typed entities) ===
|
|
1860
|
-
subtype: v.optional(v.string()),
|
|
1861
|
-
// company: private|corporate|portfolio, investor: vc|lp|cvc|pe|family_office|angel
|
|
1862
|
-
// === CONTENT ===
|
|
1863
|
-
canonicalText: v.string(),
|
|
1864
|
-
// The core content (belief statement, company name, etc.)
|
|
1865
|
-
contentHash: v.string(),
|
|
1866
|
-
// SHA256(nodeType + canonicalText) for deduplication
|
|
1867
|
-
// Extended content (for sources/syntheses)
|
|
1868
|
-
content: v.optional(v.string()),
|
|
1869
|
-
// Full text for documents/articles
|
|
1870
|
-
contentType: v.optional(v.string()),
|
|
1871
|
-
// "markdown", "html", "pdf", "text"
|
|
1872
|
-
// === METADATA ===
|
|
1873
|
-
title: v.optional(v.string()),
|
|
1874
|
-
// Display title
|
|
1875
|
-
tags: v.optional(v.array(v.string())),
|
|
1876
|
-
domain: v.optional(v.string()),
|
|
1877
|
-
// For companies: website domain
|
|
1878
|
-
// Type-specific metadata (flexible object - LEGACY)
|
|
1879
|
-
// New code should use the typed fields below when available
|
|
1880
|
-
metadata: v.optional(looseJsonObject),
|
|
1881
|
-
// === POLICY / ENTITLEMENT ===
|
|
1882
|
-
tenantId: v.optional(v.string()),
|
|
1883
|
-
workspaceId: v.optional(v.string()),
|
|
1884
|
-
ownerPrincipalId: v.optional(v.string()),
|
|
1885
|
-
audienceLabel: v.optional(audienceLabel),
|
|
1886
|
-
policyTags: v.optional(v.array(v.string())),
|
|
1887
|
-
sensitivityTier: v.optional(sensitivityTier),
|
|
1888
|
-
exportClass: v.optional(exportClass),
|
|
1889
|
-
anonymizationClass: v.optional(anonymizationClass),
|
|
1890
|
-
// === PUBLICATION (visibility-based, not copy-based) ===
|
|
1891
|
-
// Publication expands who can see a workspace-local node — the node stays
|
|
1892
|
-
// in its workspace, like a microservice exposing part of its API surface.
|
|
1893
|
-
// Rules-based: pack/tenant-level publicationRules auto-evaluate on
|
|
1894
|
-
// confidence changes and node creation. No manual click-by-click.
|
|
1895
|
-
publicationStatus: v.optional(
|
|
1896
|
-
v.union(
|
|
1897
|
-
v.literal("unpublished"),
|
|
1898
|
-
// Default: workspace-local only
|
|
1899
|
-
v.literal("published"),
|
|
1900
|
-
// Visible at tenant scope (rules matched)
|
|
1901
|
-
v.literal("suppressed")
|
|
1902
|
-
// Manually blocked even if rules match
|
|
1903
|
-
)
|
|
1904
|
-
),
|
|
1905
|
-
publishedAt: v.optional(v.number()),
|
|
1906
|
-
// When publication status last changed to published
|
|
1907
|
-
publishedBy: v.optional(v.string()),
|
|
1908
|
-
// userId or "system:publication_rules" for auto-publish
|
|
1909
|
-
// === TYPED METADATA FIELDS ===
|
|
1910
|
-
// --- Belief ---
|
|
1911
|
-
// Belief type — validated against schemaEnumConfig category "belief_type"
|
|
1912
|
-
// Platform core: hypothesis, belief, principle, invariant, assumption,
|
|
1913
|
-
// tenet, prior, preference, goal, forecast
|
|
1914
|
-
beliefType: v.optional(v.string()),
|
|
1915
|
-
beliefStatus: v.optional(beliefStatus),
|
|
1916
|
-
epistemicStatus: v.optional(epistemicStatus),
|
|
1917
|
-
reversibility: v.optional(reversibility),
|
|
1918
|
-
predictionMeta: v.optional(predictionMeta),
|
|
1919
|
-
// Consensus tracking (for non-consensus detection)
|
|
1920
|
-
consensusView: v.optional(consensusView),
|
|
1921
|
-
consensusConfidence: v.optional(v.number()),
|
|
1922
|
-
// 0-1: What we think consensus confidence is
|
|
1923
|
-
consensusSource: v.optional(v.string()),
|
|
1924
|
-
// Where we got the consensus view (twitter, reports, etc.)
|
|
1925
|
-
// --- Evidence ---
|
|
1926
|
-
methodology: v.optional(methodology),
|
|
1927
|
-
informationAsymmetry: v.optional(informationAsymmetry),
|
|
1928
|
-
temporalNature: v.optional(temporalNature),
|
|
1929
|
-
// --- Question ---
|
|
1930
|
-
questionType: v.optional(questionType),
|
|
1931
|
-
questionPriority: v.optional(questionPriority),
|
|
1932
|
-
answerQuality: v.optional(answerQuality),
|
|
1933
|
-
// --- Theme ---
|
|
1934
|
-
themeConviction: v.optional(themeConviction),
|
|
1935
|
-
// Market timing (for "early on theme" detection)
|
|
1936
|
-
marketAwarenessDate: v.optional(v.number()),
|
|
1937
|
-
// When this theme became broadly discussed
|
|
1938
|
-
marketAwarenessSource: v.optional(v.string()),
|
|
1939
|
-
// How we know (first major report, twitter volume spike, etc.)
|
|
1940
|
-
earlySignalIds: v.optional(v.array(v.string())),
|
|
1941
|
-
// globalIds of evidence we had before market awareness
|
|
1942
|
-
// --- Decision ---
|
|
1943
|
-
decisionType: v.optional(decisionType),
|
|
1944
|
-
decisionOutcome: v.optional(decisionOutcome),
|
|
1945
|
-
// === EXTERNAL IDS (for ontological entities) ===
|
|
1946
|
-
externalIds: v.optional(externalIds2),
|
|
1947
|
-
// === PROVENANCE ===
|
|
1948
|
-
sourceType: sourceType2,
|
|
1949
|
-
aiProvider: v.optional(v.string()),
|
|
1950
|
-
// "claude", "gemini", "gpt-4", etc.
|
|
1951
|
-
extractedFromNodeId: v.optional(v.id("epistemicNodes")),
|
|
1952
|
-
// Quick reference to source
|
|
1953
|
-
// === EXTRACTION CONTEXT ===
|
|
1954
|
-
extractionModel: v.optional(v.string()),
|
|
1955
|
-
// "claude-sonnet-4-20250514"
|
|
1956
|
-
extractionPromptName: v.optional(v.string()),
|
|
1957
|
-
// "lucern/extract-evidence"
|
|
1958
|
-
extractionPromptVersion: v.optional(v.number()),
|
|
1959
|
-
extractionTemperature: v.optional(v.number()),
|
|
1960
|
-
extractionLangfuseTraceId: v.optional(v.string()),
|
|
1961
|
-
// === GROUNDING VERIFICATION ===
|
|
1962
|
-
groundingVerified: v.optional(v.boolean()),
|
|
1963
|
-
groundingConfidence: v.optional(v.number()),
|
|
1964
|
-
// 0-1 match quality
|
|
1965
|
-
groundingMatchedText: v.optional(v.string()),
|
|
1966
|
-
// Actual text from source
|
|
1967
|
-
groundingStartOffset: v.optional(v.number()),
|
|
1968
|
-
groundingEndOffset: v.optional(v.number()),
|
|
1969
|
-
groundingRejectionReason: v.optional(v.string()),
|
|
1970
|
-
// === CONFIDENCE & VERIFICATION ===
|
|
1971
|
-
confidence: v.optional(v.number()),
|
|
1972
|
-
// 0-1 projected probability P(x) = b + a*u
|
|
1973
|
-
verificationStatus: v.optional(verificationStatus),
|
|
1974
|
-
// === SL OPINION (Subjective Logic — Kernel v2) ===
|
|
1975
|
-
// Replaces scalar confidence with rich epistemic state.
|
|
1976
|
-
// b + d + u = 1. P(x) = b + a*u is stored in `confidence` for backward compat.
|
|
1977
|
-
opinion_b: v.optional(v.number()),
|
|
1978
|
-
// Belief: evidence FOR (0-1)
|
|
1979
|
-
opinion_d: v.optional(v.number()),
|
|
1980
|
-
// Disbelief: evidence AGAINST (0-1)
|
|
1981
|
-
opinion_u: v.optional(v.number()),
|
|
1982
|
-
// Uncertainty: absence of evidence (0-1)
|
|
1983
|
-
opinion_a: v.optional(v.number()),
|
|
1984
|
-
// Base rate / prior probability (0-1)
|
|
1985
|
-
tupleContradicted: v.optional(v.boolean()),
|
|
1986
|
-
// Single-belief tuple-space contradiction flag
|
|
1987
|
-
// === LIFECYCLE ===
|
|
1988
|
-
status: nodeStatus,
|
|
1989
|
-
supersededBy: v.optional(v.id("epistemicNodes")),
|
|
1990
|
-
// === OWNERSHIP ===
|
|
1991
|
-
topicId: v.optional(v.string()),
|
|
1992
|
-
// Canonical scope container (topic-first model)
|
|
1993
|
-
projectId: v.optional(v.string()),
|
|
1994
|
-
// DEPRECATED: Use belongs_to edges
|
|
1995
|
-
createdBy: v.string(),
|
|
1996
|
-
// Clerk user ID
|
|
1997
|
-
createdAt: v.number(),
|
|
1998
|
-
updatedAt: v.number(),
|
|
1999
|
-
// === NEO4J SYNC STATUS ===
|
|
2000
|
-
syncStatus: v.optional(syncStatus),
|
|
2001
|
-
syncError: v.optional(v.string())
|
|
2002
|
-
// Error message if sync failed
|
|
2003
|
-
}).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", {
|
|
2004
|
-
searchField: "canonicalText",
|
|
2005
|
-
filterFields: ["nodeType", "projectId", "topicId", "status"]
|
|
2006
|
-
});
|
|
1447
|
+
// ../../packages/contracts/src/schema-helpers/spine/tables/epistemicNodes.ts
|
|
1448
|
+
var NODE_TYPES = [
|
|
1449
|
+
"decision",
|
|
1450
|
+
"belief",
|
|
1451
|
+
"question",
|
|
1452
|
+
"theme",
|
|
1453
|
+
"deal",
|
|
1454
|
+
"topic",
|
|
1455
|
+
"claim",
|
|
1456
|
+
"evidence",
|
|
1457
|
+
"synthesis",
|
|
1458
|
+
"answer",
|
|
1459
|
+
"atomic_fact",
|
|
1460
|
+
"excerpt",
|
|
1461
|
+
"source",
|
|
1462
|
+
"company",
|
|
1463
|
+
"person",
|
|
1464
|
+
"investor",
|
|
1465
|
+
"function",
|
|
1466
|
+
"value_chain"
|
|
1467
|
+
];
|
|
1468
|
+
function isNodeType(value) {
|
|
1469
|
+
return NODE_TYPES.includes(value);
|
|
1470
|
+
}
|
|
2007
1471
|
function getLayerForNodeType(type) {
|
|
2008
1472
|
switch (type) {
|
|
2009
1473
|
case "decision":
|
|
@@ -2051,7 +1515,7 @@ function throwWorkspaceIsolationError(args) {
|
|
|
2051
1515
|
throw error;
|
|
2052
1516
|
}
|
|
2053
1517
|
function assertWorkspaceScopedEpistemicNodeScope(args) {
|
|
2054
|
-
const layer = getLayerForNodeType(args.nodeType);
|
|
1518
|
+
const layer = isNodeType(args.nodeType) ? getLayerForNodeType(args.nodeType) : void 0;
|
|
2055
1519
|
if (layer === "ontological") {
|
|
2056
1520
|
return;
|
|
2057
1521
|
}
|
|
@@ -2079,11 +1543,11 @@ function nodeMatchesWorkspaceReasoningScope(node, scope) {
|
|
|
2079
1543
|
const scopeWorkspaceId = normalizeScopeValue2(scope.workspaceId);
|
|
2080
1544
|
const nodeTenantId = normalizeScopeValue2(node.tenantId);
|
|
2081
1545
|
const nodeWorkspaceId = normalizeScopeValue2(node.workspaceId);
|
|
2082
|
-
const
|
|
1546
|
+
const epistemicLayer = typeof node.epistemicLayer === "string" ? node.epistemicLayer : void 0;
|
|
2083
1547
|
if (scopeTenantId && nodeTenantId && scopeTenantId !== nodeTenantId) {
|
|
2084
1548
|
return false;
|
|
2085
1549
|
}
|
|
2086
|
-
if (
|
|
1550
|
+
if (epistemicLayer === "ontological" && nodeWorkspaceId === void 0) {
|
|
2087
1551
|
return true;
|
|
2088
1552
|
}
|
|
2089
1553
|
if (!scopeWorkspaceId && node.publicationStatus === "published") {
|
|
@@ -2095,11 +1559,11 @@ function nodeMatchesWorkspaceReasoningScope(node, scope) {
|
|
|
2095
1559
|
return scopeWorkspaceId === nodeWorkspaceId;
|
|
2096
1560
|
}
|
|
2097
1561
|
async function resolveNodeScopeForWorkspaceIsolation(ctx, node) {
|
|
2098
|
-
const
|
|
1562
|
+
const epistemicLayer = typeof node?.epistemicLayer === "string" ? node.epistemicLayer : void 0;
|
|
2099
1563
|
const resolved = {
|
|
2100
1564
|
tenantId: normalizeScopeValue2(node?.tenantId),
|
|
2101
1565
|
workspaceId: normalizeScopeValue2(node?.workspaceId),
|
|
2102
|
-
epistemicLayer
|
|
1566
|
+
epistemicLayer,
|
|
2103
1567
|
nodeType: typeof node?.nodeType === "string" ? node.nodeType : void 0
|
|
2104
1568
|
};
|
|
2105
1569
|
if (!node) {
|
|
@@ -2299,10 +1763,10 @@ async function resolveWorkflowBridgeDoc(ctx, workflowId) {
|
|
|
2299
1763
|
|
|
2300
1764
|
// src/epistemicQuestions.ts
|
|
2301
1765
|
function generateContentHash(text) {
|
|
2302
|
-
const
|
|
1766
|
+
const content = `question:${text.trim().toLowerCase().replace(/\s+/g, " ")}`;
|
|
2303
1767
|
let hash = 5381;
|
|
2304
|
-
for (let i = 0; i <
|
|
2305
|
-
hash = (hash << 5) + hash +
|
|
1768
|
+
for (let i = 0; i < content.length; i++) {
|
|
1769
|
+
hash = (hash << 5) + hash + content.charCodeAt(i);
|
|
2306
1770
|
hash &= hash;
|
|
2307
1771
|
}
|
|
2308
1772
|
return Math.abs(hash).toString(16).padStart(8, "0");
|
|
@@ -2406,21 +1870,13 @@ async function resolveQuestionScopeOrNull(ctx, args) {
|
|
|
2406
1870
|
}
|
|
2407
1871
|
async function getQuestionNodesForScope(ctx, scope, args) {
|
|
2408
1872
|
const fetchNodes = (query2) => typeof args?.scanLimit === "number" ? query2.order("desc").take(args.scanLimit) : query2.collect();
|
|
2409
|
-
const
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
scope.projectId ? fetchNodes(
|
|
2417
|
-
ctx.db.query("epistemicNodes").withIndex(
|
|
2418
|
-
"by_project_type",
|
|
2419
|
-
(q) => q.eq("projectId", scope.projectId).eq("nodeType", "question")
|
|
2420
|
-
)
|
|
2421
|
-
) : Promise.resolve([])
|
|
2422
|
-
]);
|
|
2423
|
-
return dedupeQuestionNodes([...topicNodes, ...projectNodes]).filter(
|
|
1873
|
+
const topicNodes = await fetchNodes(
|
|
1874
|
+
ctx.db.query("epistemicNodes").withIndex(
|
|
1875
|
+
"by_topic_type",
|
|
1876
|
+
(q) => q.eq("topicId", scope.topicId).eq("nodeType", "question")
|
|
1877
|
+
)
|
|
1878
|
+
);
|
|
1879
|
+
return dedupeQuestionNodes(topicNodes).filter(
|
|
2424
1880
|
(node) => questionMatchesScope(node, scope)
|
|
2425
1881
|
);
|
|
2426
1882
|
}
|
|
@@ -4586,8 +4042,8 @@ var getByPillar = query({
|
|
|
4586
4042
|
return { questions: [], beliefs: [] };
|
|
4587
4043
|
}
|
|
4588
4044
|
const allBeliefNodes = await ctx.db.query("epistemicNodes").withIndex(
|
|
4589
|
-
|
|
4590
|
-
(q) =>
|
|
4045
|
+
"by_topic_type",
|
|
4046
|
+
(q) => q.eq("topicId", scope.topicId).eq("nodeType", "belief")
|
|
4591
4047
|
).collect();
|
|
4592
4048
|
const beliefs = allBeliefNodes.filter((n) => {
|
|
4593
4049
|
const meta = n.metadata || {};
|
|
@@ -4953,8 +4409,8 @@ var getQuestionClusterPositions = query({
|
|
|
4953
4409
|
};
|
|
4954
4410
|
}
|
|
4955
4411
|
const questionNodes = await ctx.db.query("epistemicNodes").withIndex(
|
|
4956
|
-
|
|
4957
|
-
(q) =>
|
|
4412
|
+
"by_topic_type",
|
|
4413
|
+
(q) => q.eq("topicId", scope.topicId).eq("nodeType", "question")
|
|
4958
4414
|
).collect();
|
|
4959
4415
|
const activeQuestionNodes = questionNodes.filter(isActiveQuestionNode);
|
|
4960
4416
|
const positions = {};
|
|
@@ -4964,8 +4420,8 @@ var getQuestionClusterPositions = query({
|
|
|
4964
4420
|
for (const question of activeQuestionNodes) {
|
|
4965
4421
|
const id = question._id.toString();
|
|
4966
4422
|
const meta = question.metadata || {};
|
|
4967
|
-
const
|
|
4968
|
-
if (
|
|
4423
|
+
const questionType = typeof question.questionType === "string" ? question.questionType : typeof meta.questionType === "string" ? meta.questionType : void 0;
|
|
4424
|
+
if (questionType === "belief_test" || meta.testType) {
|
|
4969
4425
|
positions[id] = "cluster";
|
|
4970
4426
|
clusterCount++;
|
|
4971
4427
|
} else if (resolveLinkedWorktreeId(meta)) {
|