Skip to content

Public/Internal API classification & namespace split #329

Closed

Description

@nockawa

Summary

Multi-phase initiative to enforce a clean PUBLIC / INTERNAL boundary across Typhon.Engine, Typhon.Protocol, and Typhon.Schema.Definition. Every top-level type gets classified as either:

  • PUBLIC — needed by a consumer that embeds Typhon as a database (exceptions, configuration types, DatabaseEngine / Transaction / UnitOfWork / TyphonRuntime parameters, system author base classes, schema attributes).

  • INTERNAL — implementation detail (primitives, allocators, WAL records, B+Tree nodes, profiler codecs, etc.). Lives in Typhon.Engine.Internals namespace at internal accessibility, enforced by the TYPHON008 Roslyn analyzer.

Result: each engine subsystem folder splits into public/ and internals/ subdirectories, with one consumer-facing namespace per assembly and one internal-implementation namespace.

📄 Design doc: PublicVsInternalApiClassification.md — 2026-04-13 original, refreshed 2026-05-09/10. Methodology, classification rules, per-subsystem tables, open-question resolutions, phase-by-phase audit.

Why

  • Discoverability. Consumers shouldn't have to grep 600 types to find the ~180 they're allowed to use.

  • Refactor safety. Internal types can be reshaped without breaking downstream codebases.

  • Compile-time enforcement. TYPHON008 blocks new public types from leaking internal types in their surface — no more drift.

  • Namespace clarity. Two namespaces per assembly (Typhon.Engine / Typhon.Engine.Internals) replace the previous freeform nesting.

What landed (2026-05-10)

  • Phase 2a — Namespace migration. 17 features moved to feature-tree layout under src/Typhon.Engine/. ~241 file renames (history preserved via git mv), ~424 internal-namespace type moves, ~181 public-namespace type moves. Types stay at original accessibility during this phase.

  • Phase 2b — Accessibility flips. Solution-wide sweep: every type in */internals/*.cs flipped from public → internal. 488 cascade errors resolved iteratively (either flip the leaking member or promote the leaked type back to public when too entangled).

  • InternalApiLeakAnalyzer (TYPHON008) live. Dual condition (internal namespace + internal accessibility) — see src/Typhon.Analyzers/README.md.

  • 12 friend assemblies wired via GlobalUsings.cs (tests, AntHill, Workbench, Shell, etc.).

  • Source generators updated — SourceLocationGenerator + TraceEventGenerator emit the right namespace + accessibility.

  • §10.3 D — durability exception folder split. 5 separate files under Errors/public/.

  • Engine csproj stale <Compile Update> cleanup.

  • 5 promotions codified as PUBLIC where doc was wrong (ClusterSpatialAabb, SystemAccessDescriptor, ProfilerSessionMetadata, TraceRecordBatch, ExporterQueue).

Verification at landing: solution clean, 0 errors, 3833 engine tests pass + 33 skipped. 241 renames detected via git diff -M.

What remains

  • Leak-tightening pass — Foundation/Memory + Foundation/Concurrency cluster. ✅ Done 2026-05-11. Flipped to internal: IMemoryAllocator, MemoryAllocator, MemoryBlockArray, MemoryBlockBase, PinnedMemoryBlock, DeadlineWatchdog, HighResolutionSharedTimerService, ITimerRegistration. DatabaseEngine ctor flipped to internal (friends construct via InternalsVisibleTo, public DI extensions still work). Held PUBLIC: EpochManager (entangled via IPageStore.EpochManager accessed by 30+ generic-constrained hot-path callers — flipping IPageStore cascades through all storage/indexing generics), HighResolutionTimerServiceBase (DagScheduler inheritance), MemoryAllocatorOptions + IMemoryResource (config bag + base list). Storage cluster + ClientConnection not in this scope. Engine 3550/3550 + Workbench 266/266 green.

    Remaining promotions (Storage cluster, deferred per Public/Internal API classification & namespace split #329 scope):

    • DatabaseEngine ctor — Foundation/Memory (IMemoryAllocator, MemoryAllocator, etc.), Foundation/Concurrency (EpochManager, DeadlineWatchdog, timer services), Storage (PagedMMF, ManagedPagedMMF, ChangeSet, PersistentStore, segments/accessors), Durability (IWalFileIO) ✅ done 2026-05-11 — IWalFileIO flipped to internal; engine constructs WalFileIO itself when DatabaseEngineOptions.Wal is set; ctor parameter dropped; AntHill DI registration removed. Engine 3550/3550 green.

    • Subscription admin API — ClientConnection ✅ done 2026-05-11 — SetSubscriptions(ClientConnection, …) → SetSubscriptions(ClientContext, …); runtime looks up the connection internally by ConnectionId; ClientConnection flipped to internal. Tests updated. Engine 3550/3550 green.

    • Tightening these requires builder/factory façades that hide the internal types from the ctor signatures. Real refactor work, not a one-line flip.

  • §10.3 E — InternalsVisibleTo friend-list audit. ✅ Done 2026-05-11. Mechanical audit dropped the list from 13 to 8: removed Typhon.Shell (redundant — AssemblyName is tsh), Typhon.Shell.Extensibility, Typhon.Workbench.Fixtures, Typhon.ARPG.Shell, Typhon.Workbench.Tests (all build clean against the public surface). Engine 3550/3550 + Workbench 266/266 green.

  • §3.2 per-feature subfolder split — Won't do (2026-05-11). The flat public/ + internals/ layout is good enough; the proposed subfolder split would be churn without changing the surface. §3.2 is now historical.

  • Carveout in Querying/public/ViewBase.cs. ✅ Done 2026-05-11. Promoted IView to PUBLIC (the trio ViewId / FieldDependencies / IsDisposed is consumer-facing). Reworked the internal delta-buffer contract: ViewRegistry.RegisterView(IView, ViewDeltaRingBuffer, …) now takes the buffer as an explicit parameter instead of exposing it via an interface, so the public surface never references ViewDeltaRingBuffer. Suppression removed; TYPHON008 analyzer is fully active without carveouts.

  • Extend doc coverage to out-of-scope assemblies — Typhon.Analyzers, Typhon.Client, Typhon.Generators, Typhon.Profiler, Typhon.Shell, Typhon.Shell.Extensibility. Currently the doc only covers Engine + Protocol + Schema.Definition.

Final counts (post-Phase 2b)

| Project | Total | PUBLIC | INTERNAL | %PUBLIC |

|---|---:|---:|---:|---:|

| Typhon.Schema.Definition | ~35 | ~35 | 0 | 100% |

| Typhon.Protocol | 8 | 8 | 0 | 100% |

| Typhon.Engine | ~605 | ~181 | ~424 | 30% |

| Total | ~648 | ~224 | ~424 | 35% |

Out of scope

  • Renaming or re-shaping the public API itself — this initiative classifies and gates, it doesn't redesign.

  • Cross-assembly type moves between Typhon.Engine and the satellite assemblies — separate cleanup.

Activity

  1. added
    refactoring
    technical-debt
    on May 10, 2026
  2. moved this to In Progress in Typhon devon May 10, 2026
  3. moved this from In Progress to Done in Typhon devon May 11, 2026
  4. added a commit that references this issue on Sep 13, 2026
    0f0bcf7
  5. added a commit that references this issue on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactoringtechnical-debt

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions