cadrumo.adapters.persistence.storage.profile_persistence_composition module

The one composition of the ports a profile-bound host must bind together.

Custody, the login session, workflow persistence and the language resolver are one unit. A host that binds some and not the rest can open a capsule it cannot then read a record through, and application code says so by refusing rather than assuming: an unbound port raises InternalInvariantError instead of reporting an absent profile. Discharging that obligation is the host’s job, and this module is where every host discharges it.

Four hosts enter this scope – the shipped frontend composition root, the MCP server’s own root, the pytest session fixture, and the docs-sequence runner – and each used to restate the wiring. The copies had already drifted over which ports belong to the set, which is the failure mode this module removes: a port added here reaches all of them in the same change.

It lives beside the adapters it builds rather than in either process root because the MCP distribution is an outer root in its own right and does not import the CLI entrypoint, and because a test host must not have to reach into a tests package for shipped wiring. Importing this module pulls only the persistence tree, which is what entering the scope pulls in anyway.

composed_profile_persistence_ports()[source]

Bind the profile-persistence ports for one host scope, and unbind after.

The yielded custody port is the one that was bound, so a caller holding on to it does not build a second instance.

Return type:

Generator[ProfileCustodyPort]