feat: enforce data/metadata separation, numeric range queries, improved docs

- Store data opaquely in add() and update() instead of spreading object
  properties into top-level metadata. data is for semantic search (HNSW),
  metadata is for structured where-filter queries (MetadataIndex).
- Fix numeric range queries in MetadataIndex — use numeric-aware comparison
  instead of lexicographic string comparison for normalized values.
- Add data field to RelateParams and Relation types for relationship content.
- Add where.type → where.noun alias in metadata-only find() path.
- Rewrite README: focused ~350 lines from 791, quick start first, feature
  showcase with mini-snippets, organized doc links, no version callouts.
- Add DATA_MODEL.md and QUERY_OPERATORS.md reference docs.
- Remove 10 outdated/redundant doc files consolidated into API reference.
- Improve JSDoc on Entity, Relation, AddParams, FindParams, and core methods.
- Fix tests asserting data properties appear in metadata (data model violation).
- Deprecate verb.source/target in favor of from/to (public) and sourceId/targetId (storage).
This commit is contained in:
David Snelling 2026-02-09 12:06:59 -08:00
parent edb5ec4696
commit 0ddc05a5bb
30 changed files with 1356 additions and 7001 deletions

View file

@ -4,7 +4,7 @@
* This module defines a comprehensive, standardized set of noun and verb types
* that can be used to model any kind of graph, semantic network, or data model.
*
* **Stage 3 Coverage**: 95% domain coverage with 40 noun types and 88 verb types
* **Stage 3 Coverage**: 95% domain coverage with 42 noun types and 127 verb types
*
* ## Purpose and Design Philosophy
*
@ -15,7 +15,7 @@
* - **Semantic**: Types carry meaning that can be used for reasoning and inference
* - **Complete**: Covers foundational ontological primitives to advanced relationships
*
* ## Noun Types (40 Entities)
* ## Noun Types (42 Entities)
*
* Noun types represent entities in the graph and are organized into categories:
*
@ -91,7 +91,7 @@
* ### Meta-Level (1)
* - **Relationship**: Relationships as first-class entities for meta-level reasoning
*
* ## Verb Types (88 Relationships)
* ## Verb Types (127 Relationships)
*
* Verb types represent relationships between entities and are organized into categories:
*
@ -322,7 +322,7 @@
* succeeds (use inverse of precedes), belongsTo (use inverse of owns),
* createdBy (use inverse of creates), supervises (use inverse of reportsTo)
*
* **Net Change**: +9 nouns (31 40), +48 verbs (40 88) = +57 types total
* **Net Change**: +11 nouns (31 42), +87 verbs (40 127) = +98 types total
* **Coverage**: 60% 95% (Stage 3)
*/
@ -369,10 +369,12 @@ export interface GraphNoun {
*/
export interface GraphVerb {
id: string // Unique identifier for the verb
/** @deprecated Use `from` (public API) or `sourceId` (storage). Will be removed in next major. */
source: string // Entity UUID of the source noun
/** @deprecated Use `to` (public API) or `targetId` (storage). Will be removed in next major. */
target: string // Entity UUID of the target noun
sourceId?: string // Alias for source (coreTypes compatibility)
targetId?: string // Alias for target (coreTypes compatibility)
sourceId?: string // Entity UUID of the source noun (storage convention)
targetId?: string // Entity UUID of the target noun (storage convention)
label?: string // Optional descriptive label
verb: VerbType // Type of relationship
createdAt: Timestamp | number // When the verb was created
@ -562,7 +564,7 @@ export interface Relationship extends GraphNoun {
}
/**
* Defines valid noun types for graph entities (Stage 3: 40 types)
* Defines valid noun types for graph entities (Stage 3: 42 types)
* Used for categorizing different types of nodes
*/
export const NounType = {
@ -647,7 +649,7 @@ export const NounType = {
export type NounType = (typeof NounType)[keyof typeof NounType]
/**
* Defines valid verb types for relationships (Stage 3: 88 types)
* Defines valid verb types for relationships (Stage 3: 127 types)
* Used for categorizing different types of connections
*/
export const VerbType = {