Skip to content

feat(persistence): one-call RegisterPersistence and managed directories#71

Merged
tgiachi merged 4 commits into
developfrom
feature/directories-persistence
Jul 7, 2026
Merged

feat(persistence): one-call RegisterPersistence and managed directories#71
tgiachi merged 4 commits into
developfrom
feature/directories-persistence

Conversation

@tgiachi

@tgiachi tgiachi commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Managed directories: SquidStdOptions.Directories = ["scripts", "save"] creates them at bootstrap creation; DirectoriesConfig.RegisterDirectory(string|enum) adds and creates a managed directory imperatively (idempotent, snake_case, returns the path) - usable from plugins and modules.
  • RegisterPersistence(PersistenceConfig? config = null): one call wires the whole persistence stack - entity registry (recorded RegisterPersistedEntity entries applied automatically on first resolution, no more manual ApplyPersistedEntityRegistrations), journal and snapshot services resolved from the effective config, and IPersistenceService as a lifecycle service (snapshot load + journal replay at start, autosave loop, final snapshot at stop - all pre-existing behavior, now just wired). Config-first: persistence YAML section or explicit instance (file ignored). SaveDirectory defaults to the managed save directory. Fail-fast guard when no IDataSerializer is registered.
  • RegisterMessagePackSerializer() in SquidStd.Persistence.MessagePack (Keep semantics, mirrors RegisterDataSerializer).
  • Docs: persistence bootstrap quickstart, managed directories in the bootstrap-lifecycle article, and the stale pre-config-first "UsePlugins before ConfigureLogging" claims corrected in the plugin docs.

Test plan

  • 11 new tests; the key one is the round-trip across two bootstraps on the same root (upsert -> stop -> new bootstrap -> replay)
  • Full suite green locally except the 41 machine-wide Testcontainers failures (host kernel pending reboot); CI validates the full suite
  • Release builds clean

tgiachi added 4 commits July 7, 2026 12:44
SquidStdOptions.Directories declares directories created at bootstrap
creation; DirectoriesConfig.RegisterDirectory (string and enum overloads)
adds and creates a managed directory imperatively, idempotently, and
returns its path.
…lizer registration

RegisterPersistence wires registry (with recorded entity registrations
applied on first resolution), journal, snapshot service and the
persistence lifecycle service, config-first style: explicit instance or
eager persistence YAML section, save directory defaulting to the managed
save directory. RegisterMessagePackSerializer registers the MessagePack
serializer for both serialization interfaces.
… ordering fix

Documents RegisterPersistence and the managed save directory, the
Directories options and RegisterDirectory API, and corrects the stale
UsePlugins-before-ConfigureLogging constraint left over from the
pre-config-first flow.
var effective = resolver.Resolve<PersistenceConfig>();

return new BinaryJournalService(
Path.Combine(ResolveSaveDirectory(resolver, effective), effective.JournalFileName),

var path = config.RegisterDirectory("scripts");

Assert.Equal(Path.Combine(root.Path, "scripts"), path);

var path = config.RegisterDirectory("SavedGames");

Assert.Equal(Path.Combine(root.Path, "saved_games"), path);
@tgiachi
tgiachi merged commit fb0f8a2 into develop Jul 7, 2026
3 checks passed
@tgiachi
tgiachi deleted the feature/directories-persistence branch July 7, 2026 12:14
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.

2 participants