Repository navigation
Closed
Copy link
Milestone
Description
Problem
A Typhon database is multi-file but is presented as a single file, and the conventions don't agree across surfaces:
- Data:
{name}.bin— generic/vague extension; magic-signed header; in-file checkpoint (no separate file). - Lock:
{name}.lock. - WAL:
{segmentId:D16}.walin awal/directory whose default is a bare relative"wal"(cwd-relative — breaks off-cwd), and segments are named by segment id, not DB → two DBs sharing a directory collide. - Workbench "marker":
{name}.typhonis an empty 0-byte decoy; the real data is the sibling{name}.bin. The Shell doesn't use a marker at all — it strips the extension and writes.bin.
Net: split identity (nice extension is fake), WAL collisions, .bin vagueness, and no ubiquity.
Decision — Option B: a database is a .typhon bundle directory
One path = one database. The extension lives on the directory; everything lives inside with fixed internal names:
game.typhon/
├── data # primary paged data file (was {name}.bin); magic-signed; in-file checkpoint
├── db.lock # single-writer lock
└── wal/ # WAL segments — PRIVATE to this DB (collision gone by construction)
Deliverables — ✅ Merged in PR #451 (2026-07-04)
-
PagedMMFOptions/ManagedPagedMMF: open/create the{name}.typhon/bundle;data+db.lockinside; header validation unchanged -
WalWriterOptions.WalDirectorydefaults to null; the engine derives{bundle}/wal(early in the ctor — see the CRITICAL note in the comment); the bare-"wal"default removed; no caller override needed - Recovery scans
{bundle}/wal - Shell (
ShellSession.OpenDatabase) opens/creates a bundle (no.binhardcode, no marker) - Workbench:
FileBrowserServiceshows a.typhondirectory as one openable DB row;EngineLifecycledrops the manual WAL-dir override;FixtureDatabasegenerates bundles; client file filter →['.typhon'] - Legacy artifact at the bundle path → typed
StorageException(InvalidDatabaseBundle=2008)(+EnsureFileDeletedclears it) -
typhon migrate-legacyimporter moves a validated legacy.bininto{bundle}/data(magic-checked; refuses if a bundle or non-emptywal/exists) - Full engine hard-reject of the legacy
.bin+marker layout on open — still DEFERRED (pre-alpha: a non-bundle path just creates a fresh bundle;migrate-legacycovers the migration path; see design §6 Q4) - Tests: create/open/reopen; lock semantics; two DBs in one parent dir don't collide (by construction); crash-recovery from
{bundle}/walwith the null default (BundleWalRecoveryTests); legacy-artifact rejection (LegacyBundleArtifactTests) - Docs: design doc + engine doc comments; engine overview (
03-storage.md), user guide, anddoc/feature-set(Storage + Hosting) prose swept to the bundle layout
Related Documents
- Design: claude/design/Storage/typhon-bundle-format.md
- Sibling: Simplified setup: AddTyphon(), DatabaseEngine.Open(), component registration #147 (Simplified setup) —
TyphonOptions.DatabaseFile(path)is the single swing point; adopted.typhonalready.
Parent Epic: #146 (Developer Experience & Adoption)
Activity
nockawa commentedon Jul 3, 2026
✅ Implemented + verified (2026-07-03)
Core:
PagedMMFOptions.BundleDirectory({dir}/{name}.typhon),data/db.lockinside,EnsureFileDeleteddeletes the bundle;PagedMMFcreates the dir before lock/data;WalWriterOptions.WalDirectory→ null with the engine deriving{bundle}/wal.Verification:
smoketest.typhon/{data, wal/…}(WAL derived inside the bundle) ✅ReadsSnapshot<Genetics>crash is pre-existing (confirmed identical on cleanmain) ✅GetPage_*failures are pre-existing (stale v4-layout expectation, confirmed failing on cleanmain); my 2 regressions (File.Existson the now-directory path) fixed ✅🔴 Code review caught a CRITICAL durability bug — fixed. The WAL-dir derivation was sequenced after the reopen path reads
WalDirectoryto gateWalFilesPresentAtOpen→ with the new null default, a crash-reopen silently skipped WAL replay (committed data lost). The full suite hid it because every crash fixture setsWalDirectoryexplicitly. Fix: derive the WAL dir early in the ctor (beforeInitializeUowRegistry). NewBundleWalRecoveryTests(crash + reopen with nullWalDirectory, independent providers = a real process restart) fails without the fix, passes with it — verified by reverting.Test-harness lesson: any test that hand-rolled
Directory.GetFiles(dir).Delete()cleanup left a stale bundle the engine reopened (deterministically brokeSingleThreadedParallelFence— 1 entity counted as 3 — and looked like a spatial-migration bug until bisected + baselined). Fixed inParallelFenceTests/AdaptiveFenceCostTests/TestBase.Deferred (noted):
typhon migrateimporter + explicit legacy-.binrejection; overview/guide/CLI doc prose. Ready for review + commit (not committed).nockawa commentedon Jul 4, 2026
AC #8 (docs) completed 2026-07-04 — pending review + commit
The four doc surfaces now describe a Typhon database as a
.typhondirectory, not a file:claude/overview/03-storage.mdgains a bundle-directory note (data/db.lock/wal/inside), linking the bundle-format design.doc/guide/06-operating.md: "database file (.typhon)" → "database (a.typhondirectory)" (3 spots).tools/Typhon.Workbench/CLAUDE.md: ".typhonfile" → ".typhondatabase (a directory)"; authority-order line reworded.tsh/typhonopencommand help: "Opens a database file" → "Opens a.typhondatabase (a directory)".Shell builds clean. Still deferred (unchanged): the
typhon migrateimporter + its CLI help — see the design doc §8b. AC #6's rejection half was already done (legacy-artifact hardening, 2026-07-03).nockawa commentedon Jul 4, 2026
Legacy importer (AC #6 importer half) shipped 2026-07-04 — pending review + commit
tsh migrate-legacy <path>.binimports a pre-bundle database into a{name}.typhonbundle. Since the v4 data-file format is byte-identical between the legacy.binand the bundle's innerdata(the #450 change was container-only), this is a file move, not a conversion:.bincarries the"TyphonDatabase"header signature (page-0 scan, offset-independent).{name}.typhonalready exists, or if a non-empty adjacentwal/is present (the legacy shared WAL can't be attributed to one DB — the user must cleanly close/checkpoint first; the importer never replays a WAL).{name}.typhon/, moves{name}.bin→{bundle}/data. The.binfilename must be the original database name (the header embeds it; the engine verifies on open).Named
migrate-legacybecausemigrateis already the schema-migration verb in tsh; the top-leveltyphon migratename awaits thetsh→typhonrename (#435). Implementation:CommandExecutor.ExecuteMigrateLegacy+ help entries.Verified end-to-end via tsh: seed a real v4 DB → relocate to
.bin→migrate-legacy→ reopen succeeds (Opened legacydb); plus all three refusal paths (bad magic / target exists / non-empty wal). Shell builds clean.With this, AC #6 is fully done (rejection 2026-07-03 + importer 2026-07-04) and AC #8 docs were updated. Design doc §7 (AC #6/#8) + §8b ("Legacy importer") updated.
#147 #148 #450 Simplified setup, .typhon bundle, options validation (PR
nockawa commentedon Jul 4, 2026
The one remaining deferred deliverable — the full engine hard-reject of a legacy
.bin+marker layout on open — is now tracked separately in #452 (Feature under Epic #146, pre-alpha milestone). Everything else in this issue shipped in PR #451.