You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
✅ Shipped:AddPagedMemoryMappedFile() correct spelling exists (Hosting/public/TyphonBuilderExtensions.cs:166); old AddPagedMemoryMappedFiled typo removed.
✅ Implemented & merged in PR #451 (2026-07-04) — the one-line-setup surface:
TyphonOptions fluent class with Register<T>() + RegisterArchetype<TArch>() (AOT-safe: concrete generic instantiations, no reflection / MakeGenericType)
services.AddTyphon(Action<TyphonOptions>) extension (wraps the ~7 internal Add* calls)
services.AddTyphon(o =>o.DatabaseFile("game.typhon").Register<Position>().RegisterArchetype<Player>());usingvardbe=DatabaseEngine.Open("game.typhon", o =>o.Register<Position>().RegisterArchetype<Player>());
Design decisions (Q1–Q4) + the RegisterArchetype finding resolved 2026-07-03 — see design doc §9–§11.
Scope: the #147 core surface (TyphonOptions + AddTyphon + Open). Options.Validate() (#148) and the .typhon bundle format (#450) are out of scope; DatabaseFile adopts .typhon as canonical now, mapping to today's .bin behavior (design §Q2). Decisions Q1–Q4 per design doc §9.
Acceptance criteria
TyphonOptions fluent class — AOT-safe Register<T>() where T:unmanaged (static closed-generic delegate to RegisterComponentFromAccessor<T>, no MakeGenericType/MakeGenericMethod); DatabaseFile(path); forwarders to the real sub-option types (no duplicate fields).
services.AddTyphon(Action<TyphonOptions>) — composes the 7 internal Add* calls.
DatabaseEngine.Open(string, Action<TyphonOptions>, ILoggerFactory) — owns + disposes a private ServiceProvider; using var dbe = Open(...) is leak-free.
Component registration wired into engine init — AddTyphon decorates the DatabaseEngine descriptor; fires once at first resolve; power-user AddDatabaseEngine path untouched.
AOT:Register<T> uses static dbe => dbe.RegisterComponentFromAccessor<T>() — one closed generic per T, zero captured state.
Post-build hook (§4a): decorate the DatabaseEngineServiceDescriptor inside AddTyphon (capture inner factory → build → ApplyComponentRegistrations → return). Register-once (the method is not idempotent beyond its type HashSet).
Owned-provider disposal: engine's Dispose disposes _ownedProviderlast, after IsDisposed = true — the provider's re-entrant dispose of the singleton engine short-circuits at the guard. MMF double-dispose is already idempotent (same as host-DI path today).
Static closed-generic delegates (RegisterComponentFromAccessor<T>, Archetype<TArch>.Touch()); no MakeGeneric*. Verified by review.
2. AddTyphon composes the 7 Add*
AddTyphon_DiPath_ResolvesWorkingEngine_WithRegisteredComponent — resolves a working engine, CompA round-trips.
3. Open() owns + disposes its provider
Open_FactoryPath_OwnsAndDisposesItsPrivateProvider — asserts the owned ServiceProvider throws ObjectDisposedException after Dispose (not just the .bin handle).
4. Registration + InitializeArchetypes wired into engine init
Descriptor decoration runs component reg → archetype touch → InitializeArchetypes, once at first resolve. Proven by the DI/multi-register tests spawning with no manual init.
New fixture: 4/4 green (~200 ms). Full suite: 3977 passed, 34 skipped-by-design; the only failures are 4 pre-existing parallel-flaky lock-timeout tests (*WhenLockTimeout_DoesNotLeak*, UpdateField_EntryInRingBuffer_*) that pass in isolation — no code-path overlap with this change.
Design decision surfaced + approved during impl:RegisterArchetype<TArch>() — registering components alone doesn't make user archetypes spawnable (InitializeArchetypes only wires archetypes in the registry). See design doc §10.
Code review: independent pass — no Critical/High. Fixed: a false-positive AC3 test (asserted the .bin handle, which the engine releases regardless) → now asserts the owned provider is disposed; guarded the init-failure cleanup so it can't mask the original exception. Documented one deferred LOW: owned-provider disposal isn't exception-guarded against a throw during engine teardown (pre-existing Dispose structure; §11).
Ready for review + commit. Not committed (per convention).
Two robustness items from the §11 as-built review:
6a — owned-provider disposal is now exception-guarded.DatabaseEngine.Dispose previously disposed _ownedProvider as its last statement, so a throw from an earlier teardown step (e.g. PersistEngineState on a full disk during the final checkpoint) skipped it and leaked the private container (watchdog + timer threads, allocator native memory) on the Open() path. Fixed: teardown is extracted to DisposeCore and runs inside a try; _ownedProvider is released in a finally (after IsDisposed = true, preserving the re-entrancy short-circuit; the provider disposal is itself guarded so it can't mask the original teardown exception, which still propagates). New test TyphonSetupTests.Open_TeardownThrows_StillDisposesOwnedProvider forces the throw via an internal ThrowInDisposeCoreForTest seam and asserts the provider is disposed anyway.
5 — PagedMMF.Dispose is now null-safe against half-construction. An early ctor throw (e.g. options.Validate before Logger/_backpressureStrategy are assigned) still registers the node in the resource tree, so Dispose can run on a partially-built instance. Null-guarded Logger?. and _backpressureStrategy?. (the latter was already needed for the #450 legacy-artifact rejection path). Defense-in-depth — the #148 DI validator now preempts the reachable invalid-options path, but "Dispose never NREs on a half-constructed object" is a clean invariant to hold unconditionally.
6b (AOT smoke test) — dropped, not deferred. On closer look it can't be isolated to the registration path: a minimal app still pulls in the whole engine, which isn't AOT-clean overall (e.g. Activator.CreateInstance in the MMF factory), so the test would fail for unrelated reasons. It only makes sense as the capstone of a broader "make Typhon AOT/trim-ready" effort. The Register<T>/RegisterArchetype<T> code stays structurally AOT-safe by construction (closed generics, no MakeGeneric*), verified by inspection.
Full suite 3992 passed, 0 real failures (only the known lock-timeout parallel-flakes). Design doc §11 updated.
Activity
nockawa commentedon Jul 3, 2026
Implementation plan (accepted — autonomous build)
Scope: the #147 core surface (
TyphonOptions+AddTyphon+Open).Options.Validate()(#148) and the.typhonbundle format (#450) are out of scope;DatabaseFileadopts.typhonas canonical now, mapping to today's.binbehavior (design §Q2). Decisions Q1–Q4 per design doc §9.Acceptance criteria
TyphonOptionsfluent class — AOT-safeRegister<T>() where T:unmanaged(static closed-generic delegate toRegisterComponentFromAccessor<T>, noMakeGenericType/MakeGenericMethod);DatabaseFile(path); forwarders to the real sub-option types (no duplicate fields).services.AddTyphon(Action<TyphonOptions>)— composes the 7 internalAdd*calls.DatabaseEngine.Open(string, Action<TyphonOptions>, ILoggerFactory)— owns + disposes a privateServiceProvider;using var dbe = Open(...)is leak-free.AddTyphondecorates theDatabaseEnginedescriptor; fires once at first resolve; power-userAddDatabaseEnginepath untouched.Register<T>, AOT-safety, power-user regression; individualAdd*retained.Order of implementation
TyphonOptions→AddTyphon+ descriptor decoration →Open()+ owned-provider disposal → tests → full-suite + code-review gate.Key implementation notes
Register<T>usesstatic dbe => dbe.RegisterComponentFromAccessor<T>()— one closed generic perT, zero captured state.DatabaseEngineServiceDescriptorinsideAddTyphon(capture inner factory → build →ApplyComponentRegistrations→ return). Register-once (the method is not idempotent beyond its type HashSet).Disposedisposes_ownedProviderlast, afterIsDisposed = true— the provider's re-entrant dispose of the singleton engine short-circuits at the guard. MMF double-dispose is already idempotent (same as host-DI path today).Design: claude/design/Hosting/simplified-setup.md
nockawa commentedon Jul 3, 2026
✅ Implemented — AC evidence (2026-07-03)
Files:
Hosting/public/TyphonOptions.cs(new),Hosting/public/DatabaseEngine.Open.cs(new),Hosting/public/TyphonBuilderExtensions.cs(AddTyphon+ descriptor decoration),Ecs/public/DatabaseEngine.cs(owned-provider disposal inDispose),test/…/Hosting/TyphonSetupTests.cs(new).TyphonOptions+ AOT-safeRegister<T>/RegisterArchetype<TArch>RegisterComponentFromAccessor<T>,Archetype<TArch>.Touch()); noMakeGeneric*. Verified by review.AddTyphoncomposes the 7Add*AddTyphon_DiPath_ResolvesWorkingEngine_WithRegisteredComponent— resolves a working engine, CompA round-trips.Open()owns + disposes its providerOpen_FactoryPath_OwnsAndDisposesItsPrivateProvider— asserts the ownedServiceProviderthrowsObjectDisposedExceptionafterDispose(not just the.binhandle).InitializeArchetypeswired into engine initInitializeArchetypes, once at first resolve. Proven by the DI/multi-register tests spawning with no manual init.PowerUser_ManualAddStarChain_StillBuildsEngine— manualAdd*chain unaffected.AddTyphon_MultipleRegister_AllComponentsUsable.New fixture: 4/4 green (~200 ms). Full suite: 3977 passed, 34 skipped-by-design; the only failures are 4 pre-existing parallel-flaky lock-timeout tests (
*WhenLockTimeout_DoesNotLeak*,UpdateField_EntryInRingBuffer_*) that pass in isolation — no code-path overlap with this change.Design decision surfaced + approved during impl:
RegisterArchetype<TArch>()— registering components alone doesn't make user archetypes spawnable (InitializeArchetypesonly wires archetypes in the registry). See design doc §10.Code review: independent pass — no Critical/High. Fixed: a false-positive AC3 test (asserted the
.binhandle, which the engine releases regardless) → now asserts the owned provider is disposed; guarded the init-failure cleanup so it can't mask the original exception. Documented one deferred LOW: owned-provider disposal isn't exception-guarded against a throw during engine teardown (pre-existingDisposestructure; §11).Ready for review + commit. Not committed (per convention).
nockawa commentedon Jul 4, 2026
Dispose-hardening follow-ups 2026-07-04 (same branch, pending review + commit)
Two robustness items from the §11 as-built review:
6a — owned-provider disposal is now exception-guarded.
DatabaseEngine.Disposepreviously disposed_ownedProvideras its last statement, so a throw from an earlier teardown step (e.g.PersistEngineStateon a full disk during the final checkpoint) skipped it and leaked the private container (watchdog + timer threads, allocator native memory) on theOpen()path. Fixed: teardown is extracted toDisposeCoreand runs inside atry;_ownedProvideris released in afinally(afterIsDisposed = true, preserving the re-entrancy short-circuit; the provider disposal is itself guarded so it can't mask the original teardown exception, which still propagates). New testTyphonSetupTests.Open_TeardownThrows_StillDisposesOwnedProviderforces the throw via an internalThrowInDisposeCoreForTestseam and asserts the provider is disposed anyway.5 —
PagedMMF.Disposeis now null-safe against half-construction. An early ctor throw (e.g.options.ValidatebeforeLogger/_backpressureStrategyare assigned) still registers the node in the resource tree, soDisposecan run on a partially-built instance. Null-guardedLogger?.and_backpressureStrategy?.(the latter was already needed for the #450 legacy-artifact rejection path). Defense-in-depth — the #148 DI validator now preempts the reachable invalid-options path, but "Dispose never NREs on a half-constructed object" is a clean invariant to hold unconditionally.6b (AOT smoke test) — dropped, not deferred. On closer look it can't be isolated to the registration path: a minimal app still pulls in the whole engine, which isn't AOT-clean overall (e.g.
Activator.CreateInstancein the MMF factory), so the test would fail for unrelated reasons. It only makes sense as the capstone of a broader "make Typhon AOT/trim-ready" effort. TheRegister<T>/RegisterArchetype<T>code stays structurally AOT-safe by construction (closed generics, noMakeGeneric*), verified by inspection.Full suite 3992 passed, 0 real failures (only the known lock-timeout parallel-flakes). Design doc §11 updated.
Log2n-io#147 Log2n-io#148 Log2n-io#450 Simplified setup, .typhon bund…