Skip to content

ECS API: complete feature branch merge - #174

Merged
nockawa merged 28 commits into
mainfrom
feature/ecs-api
Mar 23, 2026
Merged

nockawa merged 28 commits into
mainfrom
feature/ecs-api

Conversation

@nockawa

@nockawa nockawa commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Complete ECS API implementation — merges the feature/ecs-api branch to main after 26 commits spanning the full ECS lifecycle, query migration, batch API, storage mode support, and hardening.

Key milestones in this branch

Test results

  • 2263 tests passing, 76.4% code coverage
  • 15 new Transient/SV stress tests, 8 new view coverage tests, 4 navigation tests (1 unignored)
  • No regressions on SV/Versioned hot paths (verified by dotTrace profiling)

Closes

Test plan

  • All 15 TransientIndex + SvStress tests pass
  • All 10 TickBoundary tests pass (SV regression check)
  • All 39 BatchOperation + EntitySpawn + CascadeDelete tests pass
  • All 105 EcsQuery + PipelineExecutor + EcsView tests pass
  • All 4 EcsNavigation tests pass (including unignored ToView test)
  • Storage mode benchmarks: V ~6-10ns, SV ~1.5ns, T ~1.5ns per read/write
  • dotTrace profiling confirms no SV/V hot-path regressions
  • Coverage stable at 76.4% with zero regressions in final run

🤖 Generated with Claude Code

nockawa added 28 commits March 15, 2026 08:03
…AllowMultiple tests + 8 dead method

  overloads

  Engine:
  - ArchetypeEngineState: per-engine data out of static metadata (parallel safety)
  - Destroy propagation: tombstone revisions in ComponentTable via PrepareEcsDestroys
  - DB reopen: rebuild entity maps + NextEntityKey from persisted PK indexes
  - Schema evolution: ComponentTypeId keyed by schema name, fallback slot connection
  - SchemaDowngradeException: refuse DB written by newer binary
  - Migration zero-fill: clear new chunks before field copy (stale memory bug)
  - ResolveEntity: idempotent Open() via cache check
  - ECS COW: increment ComponentCollection RefCounters
  - Delete CreateEntity (4), UpdateEntity (4), DeleteEntity (3), DeleteEntities, GetComponentRevision + 6
  private helpers
  - ReadEntity renamed to internal ReadComponent (query engine only)
  - Add WriteComponent, DestroyByPK, SpawnByArchetypeId bridge methods for Shell CLI
  - Add ComponentValue.CreateFromRaw + ArchetypeRegistry.FindArchetypeForComponent
  - Convert benchmark (6 files) and MonitoringDemo (4 files) to ECS Spawn/Open/Write/Destroy
  - Query engine: ReadEntity → ReadComponent (17 calls, same path, internal visibility)
  - Shell CLI: reflection dispatch updated to ECS bridge methods
  - Remove dead GetPage calls in ManagedPagedMMF
…x, EntityMap persistence, batch API

  Engine:
  - FindCascadeChildren uses FK B+Tree index instead of O(n) EntityMap scan
  - EntityLink<T> recognized as FieldType.Long in FromType() (was silently ignored)
  - Removed CascadeChildScanner full-scan struct
  - PersistArchetypeState: save EntityMap SPI + NextEntityKey on shutdown
  - InitializeArchetypes: reload EntityMap from persisted SPI (O(1) reopen)
  - SpawnBatch/DestroyBatch API for bulk entity operations
  - QueryRead rename (ReadComponent → QueryRead, query-engine primitive)
  - ThreadPool.SetMinThreads(96,32) in AssemblyWarmup (reduce parallel flakiness)
  - Heavy-threading fixtures marked [NonParallelizable]/[Explicit]
…sub-issue 1)

  EcsView<T> rewritten to inherit ViewBase with push-based incremental refresh
  via ViewDeltaRingBuffer (ported from View<T>). Three modes: pull (opaque
  WHERE), incremental (FieldEvaluators + ring buffer), and OR (DNF branch
  bitmaps). EcsQuery gains WhereField<T>(Expression) for indexed-field
  predicates, secondary index targeted scan via PipelineExecutor, OrderBy/
  Skip/Take, and NavigateField for FK joins.

  Deleted: View<T>, OrView<T>, ViewTwoComponent, QueryBuilder,
  QueryBuilderTwoComponent, dbe.Query<T>() entry points, old query tests
  (112), QueryViewBenchmarks (rewritten for ECS API).

  Kept: ViewBase, ViewDeltaRingBuffer, ViewRegistry, FieldEvaluator,
  PipelineExecutor, PlanBuilder, NavigationView/QueryBuilder (used by
  EcsNavigationQueryBuilder), infrastructure tests (75).
  - Remove PK B+Tree entirely: SystemCrud uses direct chunkId, EntityMap
    is sole authority for ECS entities, WAL replay uses CompRevTableSegment
    scan instead of PK lookup
  - Fix EnsureCapacity correctness: pre-allocate segment+directory only,
    don't advance linear hash state (was orphaning ~50% of entries)
  - Fix ExecuteSplit buffer safety: 8× capacity + runtime overflow guard
  - Optimize FinalizeSpawns: hoist EntityMap/SV-index accessors per-archetype,
    cache metadata+versionedMask, use InsertNew (skip duplicate check)
  - Optimize FlushPendingDestroys: hoist EntityMap accessor per-archetype
  - Optimize GetCompRevInfoFromIndex: cached TX-level EntityMap accessor,
    O(1) slot lookup via ComponentTypeId (was O(C) linear scan per call)
  - SpawnedContains/SpawnedIndexOf: lazy Dictionary for O(1) lookup
  - _pendingDestroys: List→HashSet for O(1) Contains
  - SpawnEntry: fixed int[] replaces 32 named fields
  - EcsCount: int→long return type (overflow fix)
  - Dead code removal: PKEntityEnumerator, ExecuteViaLegacy,
    ExecuteNavigationTargetFirst/SourceFirst, legacy query paths
  - Fix WalReplayHelper.ResetReplayState not called after recovery
  - New benchmarks: WriteHeavy_SvIndexed_Batch, EnsureCapacity tests
…o-alloc, Shell commands, benchmarks,

  55 new tests
…ents: shadow-before-overwrite capture

   in EntityRef.Write, ProcessShadowEntries in WriteTickFence, SV destroy index cleanup, 8 new tests
…cutor SV Count/Execute paths,

  Enable/Disable view notifications, fix ComponentOverhead desync
…yPK paths, two-component combined

  scan, IsEntityVisible fast path for primary-only, remove unused generics, dead batch code cleanup,
  FindFKIndex overhead fix, 29 new tests
…ll), make QueryRead/WriteComponent

  public, delete DestroyByPK bridge method
…tor SOA overload, tests, benchmarks, EcsMetricsExporter
@nockawa
nockawa merged commit 2eb4c06 into main Mar 23, 2026
5 checks passed
@nockawa
nockawa deleted the feature/ecs-api branch March 23, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ECS Phase 2 — Production pipeline, query migration, and persistence

1 participant