chore(localdb): adopt LocalDb 0.1.1 and drop the directory shim

LocalDb 0.1.1 creates the parent directory of LocalDb:Path itself, so the
SiteLocalDbDirectory shim this repo carried through Phase 2 is deleted along
with its call site. The gap was found here but was never ScadaBridge's alone —
every LocalDb consumer had it — so the fix moved to the library.

SiteLocalDbDirectoryTests is RETAINED and retargeted rather than deleted with
the shim. It was already written against the site registration path, not the
mechanism, so it needed only its Ensure() call removed: what a site node
requires is that resolving ILocalDb not fail on a fresh machine, regardless of
who provides that. Verified it still earns its place — pinned back to LocalDb
0.1.0 it fails inside SqliteLocalDb..ctor -> SqliteConnection.Open(), so it
genuinely depends on the library behaviour and not on a coincidence.

Also corrects the coverage-split note in StoreAndForwardStorageTests, which
asserted that directory creation is "NOT LocalDb's" — true when written, wrong
as of 0.1.1.

Build 0 warnings; Host 330, StoreAndForward 130, LocalDb integration 20 pass.

Claude-Session: https://claude.ai/code/session_01BL2Vu1ESDQ9SCN4gVKkdts
This commit is contained in:
Joseph Doherty
2026-07-20 04:58:20 -04:00
parent 9ec7966dac
commit 166f07fa68
5 changed files with 26 additions and 87 deletions
@@ -82,17 +82,13 @@ public static class SiteServiceRegistration
//
// Design: scadaproj docs/plans/2026-07-19-scadabridge-localdb-design.md
//
// Create the parent directory FIRST. SQLite creates the database file on demand
// but not its directory, and neither the LocalDb library nor its options
// validation does this — SqliteLocalDb's constructor opens the file eagerly, so a
// missing directory is a hard boot failure ("SQLite Error 14: unable to open
// database file"), not a degraded start. The default site path is the relative
// "./data/site-localdb.db", so this bites any site node whose data directory has
// not been pre-created; the docker rig only escapes it because the volume mount
// creates /app/data. StoreAndForwardStorage used to do this for its own file
// (EnsureDatabaseDirectoryExists) and that guarantee has to keep existing
// somewhere now that LocalDb owns the file.
SiteLocalDbDirectory.Ensure(config);
// The parent directory of LocalDb:Path is created by the library as of 0.1.1.
// ScadaBridge carried a SiteLocalDbDirectory shim for it during Phase 2, because
// SQLite creates the database file on demand but not its directory and
// SqliteLocalDb opens the file eagerly — a missing directory was a hard boot
// failure, and the default site path is the relative "./data/site-localdb.db".
// The shim is gone; SiteLocalDbDirectoryTests still pins the outcome here, since
// what this host needs is the guarantee, not any particular owner of it.
services.AddZbLocalDb(config, db => SiteLocalDbSetup.OnReady(db, config));
// The replication engine, likewise unconditional but INERT by default: with no