brainy/tests/integration
David Snelling c0d326b36d feat: verb subtype + updateRelation + requireSubtype enforcement
Brings verbs to first-class parity with nouns. The 7.29.0 subtype primitive
shipped for entities only; this release ships the symmetric verb mirror plus
the enforcement layer for ensuring every entity AND every relationship has
both type AND subtype.

Layer V1 — verb subtype mirror
- HNSWVerbWithMetadata.subtype + STANDARD_VERB_FIELDS set + resolveVerbField()
- Relation<T>.subtype, RelateParams<T>.subtype, UpdateRelationParams<T> extended,
  GetRelationsParams.subtype, GraphConstraints.subtype (for find connected)
- relate() persists subtype on verbMetadata + GraphVerb + transaction ops
- getRelations({ type, subtype }) fast-path filter with set membership
- find({ connected: { via, subtype, depth } }) traversal filter (depth-1 on
  the JS path; explicit error on depth > 1 pointing at Cortex native)
- verbsToRelations + storage destructure sites surface subtype to top-level
- All three graph-index fast-path queries (getVerbsBySource/ByTarget) enrich
  with subtype from metadata

Layer V2 — updateRelation() closes a pre-7.30 gap
- New first-class verb update method (parallel to update() for nouns)
- Changes subtype/type/weight/confidence/data/metadata in place
- Re-indexes in graph adjacency when verb type changes; id preserved
- validateUpdateRelationParams enforces id + at-least-one-field-to-update

Layer V3 — verb subtype storage rollup
- verbSubtypeCountsByType: Map<number, Map<string, number>> on BaseStorage
- verbSubtypeByIdCache for self-heal during update/delete
- incrementVerbSubtypeCount + decrementVerbSubtypeCount maintain state
- loadVerbSubtypeStatistics + saveVerbSubtypeStatistics persist to
  _system/verb-subtype-statistics.json (mirrors noun-side shape)
- rebuildVerbSubtypeCounts for poison recovery / explicit repair
- getVerbSubtypeCountsByType accessor for the public counts API
- Wired into init() / flushCounts() / saveVerbMetadata / deleteVerbMetadata

Layer V4 — verb counts API + relationshipSubtypesOf
- brain.counts.byRelationshipSubtype(verb, subtype?) — O(1) breakdown or point
- brain.counts.topRelationshipSubtypes(verb, n) — top N by count
- brain.relationshipSubtypesOf(verb) — sorted distinct subtypes

Layer V5 — migrateField extended to verbs
- New entityKind?: 'noun' | 'verb' | 'both' option (default 'noun')
- Mirror verb iteration via storage.getVerbs() with same path semantics
- verbToRelationLike + buildRelationMigrationUpdate helpers project the
  storage verb shape onto the Entity<T>-shaped surface readPath understands
- Routes through new updateRelation() for the verb-side rewrite

Enforcement (opt-in in 7.30, default in 8.0)
- brain.requireSubtype(type, options) — unified API for NounType OR VerbType.
  Registers per-type rules with optional values whitelist; composes with the
  brain-wide flag.
- new Brainy({ requireSubtype: true }) — brain-wide strict mode. Every public
  write path validates the pairing guarantee.
- { except: [NounType.Thing, ...] } form for catch-all type exemptions
- Atomic-fail semantics on addMany / relateMany — pre-validate every item
  before any storage write, throw on first failure with item index
- Per-type rules + brain-wide flag both throw with descriptive messages
- VFS infrastructure bypass via metadata.isVFSEntity / isVFS markers so
  brain's own VFS writes don't get rejected when strict mode is on

VFS labeling — concrete subtypes for infrastructure entities
- VFS root: NounType.Collection + subtype: 'vfs-root' (was bare Collection)
- VFS directories: subtype: 'vfs-directory'
- VFS files: subtype: 'vfs-file' (NounType still mime-based)
- VFS containment edges: VerbType.Contains + subtype: 'vfs-contains'
- Lets consumers cleanly enumerate VFS state via find({ subtype: 'vfs-file' })
  and distinguish Brainy's VFS Collections from user-created Collections

Docs
- docs/guides/subtypes-and-facets.md extended with Layer V (Verbs) section +
  Enforcement section. New full reference at the bottom split into Layer 1
  (nouns), Layer V (verbs), Layer 2 (facets), Layer 3 (migration), Enforcement.
- docs/api/README.md adds updateRelation(), getRelations({ subtype }), the
  three verb-side counts methods, requireSubtype(), and the brain-wide
  constructor option. relate() params include subtype.
- docs/DATA_MODEL.md adds a Subtype-for-VerbType section + STANDARD_VERB_FIELDS
- docs/architecture/finite-type-system.md extends Principle 1a to verbs
- docs/QUERY_OPERATORS.md adds a verb-subtype filter section covering
  getRelations and find({connected, subtype}) traversal
- README.md "Subtypes" section now shows both noun + verb in one example +
  the enforcement APIs
- RELEASES.md v7.30.0 entry with the full noun/verb capability parity matrix

Tests
- tests/integration/verb-subtype-and-enforcement.test.ts — 30 new tests
  covering V1 round-trips, V1 set membership, updateRelation in place,
  updateRelation preservation, V2 counts breakdown + point + topN + distinct,
  V2 decrements on unrelate, V2 re-routes on updateRelation, V3 depth-1
  traversal filter, V3 depth>1 explicit error, V4 verb migration, V4 both
  entity kinds, V4 readBoth preservation, V5 per-type required rejection,
  V5 vocabulary rejection, V5 on-vocab acceptance, V5 verb-side enforcement,
  V5 addMany atomic-fail, V5 relateMany atomic-fail, V5 update enforcement,
  V5 updateRelation enforcement, V5 brain-wide strict mode, V5 except clause.

Verification
- Unit suite: 1468/1468 passing
- Noun subtype integration (7.29 carryover): 26/26 passing
- Verb subtype + enforcement integration: 30/30 passing
- Type-check: clean
- Build: clean
- Public closed-source reference audit: clean

Internal 8.0 spec
- .strategy/BRAINY-8.0-SUBTYPE-CONTRACT.md (gitignored, not in npm artifact)
  documents the contract upgrade Cortex 3.0 implements against: required-by-
  default subtype, SubtypeRegistry typing hook, native simplification,
  multi-hop traversal native fast path, brain.fillSubtypes() migration helper.
  Coordinated via PLATFORM-HANDOFF rows CTX-SUBTYPE-PARITY-V2 (7.30 parallel
  work) and CTX-SUBTYPE-8.0-CONTRACT (8.0 spec).
2026-06-05 11:15:52 -07:00
..
advanced-apis-regression.test.ts feat: array-unnest groupBy for aggregates + batch-embed entity extraction 2026-05-26 14:20:40 -07:00
aggregation.test.ts feat: add aggregation engine with incremental SUM/COUNT/AVG/MIN/MAX, GROUP BY, and time windows 2026-02-16 16:57:53 -08:00
all-apis-comprehensive.test.ts fix: update tests for v5.1.0 API changes (VFS auto-init + property access) 2025-11-02 11:38:12 -08:00
api-parameter-validation.test.ts feat: Stage 3 CANONICAL taxonomy with 169 types (v5.5.0) 2025-11-06 09:02:23 -08:00
azure-storage.test.ts chore(release): 4.0.0 2025-10-17 14:48:34 -07:00
batchImportWithRelations.test.ts fix: resolve REAL v5.7.x race condition - type cache layer (v5.7.3) 2025-11-12 12:13:35 -08:00
brainy-complete.integration.test.ts fix: resolve 10 test failures across clustering, metadata, and deletion 2025-10-09 16:33:08 -07:00
brainy-core.integration.test.ts feat: Brainy 3.0 - Production-ready Triple Intelligence database 2025-09-11 16:23:32 -07:00
brainy-phase1c-integration.test.ts feat: Stage 3 CANONICAL taxonomy with 169 types (v5.5.0) 2025-11-06 09:02:23 -08:00
bun-compile-test.ts feat: replace transformers.js with direct ONNX WASM for Bun compatibility 2025-12-17 17:42:37 -08:00
clear-persistence.test.ts fix: critical clear() data persistence regression (v5.10.4) 2025-11-17 10:44:35 -08:00
clear-vfs.test.ts fix: clear() now properly resets VFS and COW state 2026-01-16 17:04:09 -08:00
commit-ref-bug.test.ts feat: add entity versioning system with critical bug fixes (v5.3.0) 2025-11-04 11:19:02 -08:00
commit-state-capture.test.ts fix: commit() now flushes and captures state by default 2026-03-23 15:45:46 -07:00
cortex-compat.test.ts fix: find()/stats() correctness + Cortex compat (BR-FIND-WHERE-ZERO, BR-DEFENSIVE-INTERFACE) 2026-05-15 12:31:28 -07:00
count-synchronization.test.ts feat: Stage 3 CANONICAL taxonomy with 169 types (v5.5.0) 2025-11-06 09:02:23 -08:00
cow-commit-storage.test.ts fix: implement type-aware storage prefixes for commits and trees 2025-11-04 15:03:05 -08:00
cow-full-integration.test.ts test: fix COW tests and add comprehensive metadata-only integration test 2025-11-18 16:06:34 -08:00
empty-tree-bug.test.ts fix: create proper initial commit instead of using tree hash for main branch 2025-11-04 13:34:51 -08:00
entity-confidence-weight.test.ts fix: update tests for v5.1.0 API changes (VFS auto-init + property access) 2025-11-02 11:38:12 -08:00
find-unified-integration.test.ts fix: resolve 10 test failures across clustering, metadata, and deletion 2025-10-09 16:33:08 -07:00
find-where-zero.test.ts fix: find()/stats() correctness + Cortex compat (BR-FIND-WHERE-ZERO, BR-DEFENSIVE-INTERFACE) 2026-05-15 12:31:28 -07:00
fork-persistence.test.ts fix: resolve fork() silent failure on cloud storage adapters 2025-11-05 09:04:38 -08:00
gcs-native-storage.test.ts feat: simplify GCS storage naming and add Cloud Run deployment options 2025-10-20 11:12:32 -07:00
gcs-persistence-fix.test.ts fix: implement unified UUID-based sharding for metadata across all storage adapters 2025-10-08 13:26:35 -07:00
get-relations-fix.test.ts fix: resolve getRelations() empty array bug and add string ID shorthand 2025-10-21 13:10:34 -07:00
history-ref-resolution-bug.test.ts fix: resolve critical COW ref resolution and versioning bugs 2025-11-04 13:05:59 -08:00
hnsw-rebuild.test.ts fix: correct test assertions for addMany return value and use valid VerbType 2025-10-10 14:23:24 -07:00
hybrid-search-cow.test.ts feat: add match visibility and semantic highlighting to hybrid search 2026-01-26 17:16:18 -08:00
initial-commit-null-parent.test.ts fix: add NULL hash guards to prevent v5.3.3 regression 2025-11-04 15:39:58 -08:00
memory-enhancements-v5.11.0.test.ts feat: COW always-on architecture + cloud storage clear() fix (v5.11.0) 2025-11-18 13:44:02 -08:00
metadata-only-comprehensive.test.ts test: fix COW tests and add comprehensive metadata-only integration test 2025-11-18 16:06:34 -08:00
metadata-vector-exclusion.test.ts fix: v3.50.2 emergency hotfix - exclude numeric field names from metadata indexing 2025-10-16 16:31:06 -07:00
migration.test.ts feat: add migration system with error handling, validation, and enterprise hardening 2026-02-09 16:13:14 -08:00
multi-process-safety.test.ts fix: find()/stats() correctness + Cortex compat (BR-FIND-WHERE-ZERO, BR-DEFENSIVE-INTERFACE) 2026-05-15 12:31:28 -07:00
orderby-sort-bug.test.ts feat: unified column store for filtering + sorting at billion scale 2026-04-10 11:22:19 -07:00
phase3TypeFirstQuery.integration.test.ts feat: Phase 3 - Unified Semantic Type Inference (Nouns + Verbs) 2025-10-16 10:59:26 -07:00
readAfterWrite.test.ts fix: resolve v5.7.x race condition with write-through cache (v5.7.2) 2025-11-12 09:32:52 -08:00
relationship-intelligence.test.ts fix: createEntities defaults to true, enable AI features by default 2025-10-23 16:54:40 -07:00
remaining-apis.test.ts fix: update tests for v5.1.0 API changes (VFS auto-init + property access) 2025-11-02 11:38:12 -08:00
s3-storage.test.ts feat: Brainy 3.0 - Production-ready Triple Intelligence database 2025-09-11 16:23:32 -07:00
smart-import.test.ts feat: implement progressive flush intervals for streaming imports 2025-10-22 17:36:27 -07:00
storage-batch-operations.test.ts feat: add storage-level batch operations to eliminate N+1 query patterns 2025-11-19 08:59:11 -08:00
subtype-and-facets.test.ts feat: subtype top-level field + trackField + migrateField 2026-06-04 17:25:28 -07:00
typeAwareHNSW.integration.test.ts feat: Phase 2 Type-Aware HNSW - 87% memory reduction @ billion scale 2025-10-15 15:39:28 -07:00
update-asymmetry.test.ts fix: update() field asymmetry causing index corruption 2026-01-26 12:12:11 -08:00
verb-subtype-and-enforcement.test.ts feat: verb subtype + updateRelation + requireSubtype enforcement 2026-06-05 11:15:52 -07:00
versioning.test.ts fix(versioning): clean architecture with index pollution prevention 2025-12-09 09:36:10 -08:00
vfs-and-graph-entities.test.ts fix: update tests for v5.1.0 API changes (VFS auto-init + property access) 2025-11-02 11:38:12 -08:00
vfs-api-wiring.test.ts fix: update tests for v5.1.0 API changes (VFS auto-init + property access) 2025-11-02 11:38:12 -08:00
vfs-debug.test.ts fix: update tests for v5.1.0 API changes (VFS auto-init + property access) 2025-11-02 11:38:12 -08:00
vfs-historical-reads.test.ts fix: resolve HNSW race condition and verb weight extraction (v5.4.0) 2025-11-05 17:05:07 -08:00
vfs-import-verification.test.ts fix: update tests for v5.1.0 API changes (VFS auto-init + property access) 2025-11-02 11:38:12 -08:00
vfs-knowledge-separation.test.ts fix: update tests for v5.1.0 API changes (VFS auto-init + property access) 2025-11-02 11:38:12 -08:00
vfs-performance-v5.11.1.test.ts fix: adjust VFS performance test expectations to realistic values 2025-11-18 16:19:37 -08:00
vfs-versioning.test.ts fix(versioning): VFS file versions now capture actual blob content 2025-12-09 16:13:45 -08:00
wasm-embeddings.test.ts feat: migrate embeddings to Candle WASM + remove semantic type inference 2026-01-06 12:52:34 -08:00