prevent Marten from truncating the shared mt_doc_principal table when rebuilding PersonProjection or GroupProjection
coordinate both event-sourced principal rebuilds, then prune only stale Person/Group rows while preserving directly stored ServiceAccounts
route the admin endpoint, recovery CLI, and integration-test helper through the same safe rebuild path
document the v0.9.1 recovery-command warning and the fixed operational contract
Root cause
Person, Group, and ServiceAccount share one polymorphic Marten document table. Marten's default single-projection teardown truncates that root table. Sequential Person/Group rebuilds therefore deleted the subtype rebuilt immediately before them, and ServiceAccounts could not be reconstructed from events.
Verification
dotnet build Modgud.slnx -c Release --no-restore
NuGet vulnerable-package audit: no vulnerable packages
dotnet test Modgud.slnx -c Release --no-build --verbosity normal: 1,509 unit + 601 integration tests passed
pnpm@10.13.1 build:all: public and in-app docs passed
focused rebuild coverage verifies all Principal subtypes, stale-row cleanup, repeatability, archived GDPR streams, and unlinked identities
local v0.9.1 database backup verified with pg_restore -l
fixed image rebuilt two real local realms twice through the recovery CLI
live https://modgud.localhost login -> admin rebuild -> same authenticated session -> readiness all returned 200
local principal counts remained scenar: person=13, group=1, service-account=1; system: person=6, group=1; no rebuild errors in container logs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
Person, Group, and ServiceAccount share one polymorphic Marten document table. Marten's default single-projection teardown truncates that root table. Sequential Person/Group rebuilds therefore deleted the subtype rebuilt immediately before them, and ServiceAccounts could not be reconstructed from events.
Verification