2026-04-21 20:08:49 +01:00
|
|
|
using Bifrost.Web.Domain;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
namespace Bifrost.Web.Data;
|
|
|
|
|
|
|
|
|
|
public sealed class BifrostDbContext(DbContextOptions<BifrostDbContext> options) : DbContext(options)
|
|
|
|
|
{
|
2026-10-27 04:57:16 +01:00
|
|
|
// The OpenIddict tables are part of this model for every way a context is built: the host, the concepts
|
|
|
|
|
// command, tests and the design-time factory that generates migrations.
|
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseOpenIddict();
|
|
|
|
|
|
2026-04-21 20:08:49 +01:00
|
|
|
public DbSet<UserAccount> UserAccounts => Set<UserAccount>();
|
|
|
|
|
|
|
|
|
|
public DbSet<MemberProfile> MemberProfiles => Set<MemberProfile>();
|
|
|
|
|
|
|
|
|
|
public DbSet<Membership> Memberships => Set<Membership>();
|
|
|
|
|
|
2026-04-22 09:50:31 +01:00
|
|
|
public DbSet<RoleAssignment> RoleAssignments => Set<RoleAssignment>();
|
|
|
|
|
|
|
|
|
|
public DbSet<TierSnapshot> TierSnapshots => Set<TierSnapshot>();
|
|
|
|
|
|
2026-04-21 20:08:49 +01:00
|
|
|
public DbSet<MembershipInvitation> MembershipInvitations => Set<MembershipInvitation>();
|
|
|
|
|
|
|
|
|
|
public DbSet<Project> Projects => Set<Project>();
|
|
|
|
|
|
|
|
|
|
public DbSet<WorkItem> WorkItems => Set<WorkItem>();
|
|
|
|
|
|
|
|
|
|
public DbSet<VolunteerClaim> VolunteerClaims => Set<VolunteerClaim>();
|
|
|
|
|
|
|
|
|
|
public DbSet<Assignment> Assignments => Set<Assignment>();
|
|
|
|
|
|
2026-04-22 09:50:31 +01:00
|
|
|
public DbSet<WorkLog> WorkLogs => Set<WorkLog>();
|
|
|
|
|
|
|
|
|
|
public DbSet<WorkReview> WorkReviews => Set<WorkReview>();
|
|
|
|
|
|
|
|
|
|
public DbSet<GitHubIssueLink> GitHubIssueLinks => Set<GitHubIssueLink>();
|
|
|
|
|
|
|
|
|
|
public DbSet<GitHubPullRequestLink> GitHubPullRequestLinks => Set<GitHubPullRequestLink>();
|
|
|
|
|
|
2026-04-21 20:08:49 +01:00
|
|
|
public DbSet<Motion> Motions => Set<Motion>();
|
|
|
|
|
|
|
|
|
|
public DbSet<Vote> Votes => Set<Vote>();
|
|
|
|
|
|
2026-11-09 20:24:49 +00:00
|
|
|
public DbSet<SealedBallot> SealedBallots => Set<SealedBallot>();
|
|
|
|
|
|
2026-11-11 10:15:46 +00:00
|
|
|
public DbSet<ConsentReceipt> ConsentReceipts => Set<ConsentReceipt>();
|
2026-11-09 20:37:47 +00:00
|
|
|
public DbSet<MindKey> MindKeys => Set<MindKey>();
|
2026-11-14 00:37:56 +00:00
|
|
|
public DbSet<PasskeyCredential> PasskeyCredentials => Set<PasskeyCredential>();
|
2026-11-09 20:37:47 +00:00
|
|
|
|
|
|
|
|
public DbSet<MindNonce> MindNonces => Set<MindNonce>();
|
|
|
|
|
|
2026-11-09 20:50:41 +00:00
|
|
|
public DbSet<MindPersona> MindPersonas => Set<MindPersona>();
|
|
|
|
|
|
2026-04-21 20:08:49 +01:00
|
|
|
public DbSet<LedgerEntry> LedgerEntries => Set<LedgerEntry>();
|
|
|
|
|
|
|
|
|
|
public DbSet<PayoutProposalBatch> PayoutProposalBatches => Set<PayoutProposalBatch>();
|
|
|
|
|
|
2026-04-22 09:50:31 +01:00
|
|
|
public DbSet<PointTransaction> PointTransactions => Set<PointTransaction>();
|
|
|
|
|
|
|
|
|
|
public DbSet<PatronSupportEvent> PatronSupportEvents => Set<PatronSupportEvent>();
|
|
|
|
|
|
|
|
|
|
public DbSet<DecayRun> DecayRuns => Set<DecayRun>();
|
|
|
|
|
|
|
|
|
|
public DbSet<RevenueEvent> RevenueEvents => Set<RevenueEvent>();
|
|
|
|
|
|
|
|
|
|
public DbSet<RevenueShareBatch> RevenueShareBatches => Set<RevenueShareBatch>();
|
|
|
|
|
|
|
|
|
|
public DbSet<RevenueShareLine> RevenueShareLines => Set<RevenueShareLine>();
|
|
|
|
|
|
2026-06-17 04:03:14 +01:00
|
|
|
public DbSet<BridgeAction> BridgeActions => Set<BridgeAction>();
|
|
|
|
|
|
|
|
|
|
public DbSet<AgentDispatchRun> AgentDispatchRuns => Set<AgentDispatchRun>();
|
|
|
|
|
|
2026-06-17 04:49:22 +01:00
|
|
|
public DbSet<AgentTransportReceipt> AgentTransportReceipts => Set<AgentTransportReceipt>();
|
|
|
|
|
|
2026-06-17 05:21:29 +01:00
|
|
|
public DbSet<GovernanceActivityReceipt> GovernanceActivityReceipts => Set<GovernanceActivityReceipt>();
|
|
|
|
|
|
2026-04-21 20:08:49 +01:00
|
|
|
public DbSet<AuditEvent> AuditEvents => Set<AuditEvent>();
|
|
|
|
|
|
2026-10-10 06:31:43 +02:00
|
|
|
public DbSet<ConceptSubject> ConceptSubjects => Set<ConceptSubject>();
|
|
|
|
|
|
|
|
|
|
public DbSet<ConceptAppraisal> ConceptAppraisals => Set<ConceptAppraisal>();
|
|
|
|
|
|
Account merge ledger: AccountMerge receipt, reductions, alias standing, undo and final sweep
AccountMergeLedger owns what a merge does to Bifrost records: PlanAsync (dry run, block codes),
CommitAsync (one save, total, idempotent), UndoLocalAsync (journal replay), FinalizeDueAsync
(AccountMergeSweeper) and StandingAsync/ResolveAsync. Votes and concept appraisals are voided by a
stamp that a model query filter hides from every tally. The actor accessor no longer ORs several
credentials under SingleOrDefault (a latent crash); a frozen or folded account resolves to no
account on every route, the OIDC authorize and chat refusal deny it, and patron intake follows the
alias. Migration AddAccountMerges is additive. No UI, no Heimdall call, nothing deployed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 02:31:51 +00:00
|
|
|
public DbSet<AccountMerge> AccountMerges => Set<AccountMerge>();
|
|
|
|
|
|
|
|
|
|
public DbSet<AccountMergeEntry> AccountMergeEntries => Set<AccountMergeEntry>();
|
|
|
|
|
|
2026-04-21 20:08:49 +01:00
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
modelBuilder.Entity<UserAccount>(entity =>
|
|
|
|
|
{
|
2026-06-22 15:07:22 +01:00
|
|
|
entity.HasIndex(x => x.NormalizedBifrostIdentity).IsUnique().HasFilter("\"NormalizedBifrostIdentity\" <> ''");
|
2026-06-08 21:04:51 +01:00
|
|
|
entity.HasIndex(x => x.GitHubUserId).IsUnique().HasFilter("\"GitHubUserId\" IS NOT NULL");
|
|
|
|
|
entity.HasIndex(x => x.HeimdallAccountId).IsUnique().HasFilter("\"HeimdallAccountId\" <> ''");
|
|
|
|
|
entity.HasIndex(x => x.NormalizedGitHubLogin).IsUnique().HasFilter("\"NormalizedGitHubLogin\" <> ''");
|
2026-06-22 15:07:22 +01:00
|
|
|
entity.Property(x => x.BifrostIdentity).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.NormalizedBifrostIdentity).HasMaxLength(120);
|
2026-06-08 21:04:51 +01:00
|
|
|
entity.Property(x => x.HeimdallAccountId).HasMaxLength(160);
|
2026-04-21 20:08:49 +01:00
|
|
|
entity.Property(x => x.GitHubLogin).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.NormalizedGitHubLogin).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.DisplayName).HasMaxLength(200);
|
|
|
|
|
entity.Property(x => x.AvatarUrl).HasMaxLength(500);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<MemberProfile>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasOne(x => x.UserAccount)
|
|
|
|
|
.WithOne(x => x.MemberProfile)
|
|
|
|
|
.HasForeignKey<MemberProfile>(x => x.UserAccountId);
|
2026-04-22 09:50:31 +01:00
|
|
|
|
|
|
|
|
entity.Property(x => x.Nickname).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.Headline).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.PortfolioUrl).HasMaxLength(500);
|
2026-04-21 20:08:49 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Membership>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasOne(x => x.UserAccount)
|
|
|
|
|
.WithOne(x => x.Membership)
|
|
|
|
|
.HasForeignKey<Membership>(x => x.UserAccountId);
|
|
|
|
|
|
|
|
|
|
entity.Property(x => x.Status).HasConversion<string>();
|
2026-04-22 09:50:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<RoleAssignment>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasIndex(x => new { x.MembershipId, x.Role }).IsUnique();
|
|
|
|
|
entity.Property(x => x.Role).HasConversion<string>();
|
|
|
|
|
entity.HasOne(x => x.Membership)
|
|
|
|
|
.WithMany(x => x.RoleAssignments)
|
|
|
|
|
.HasForeignKey(x => x.MembershipId);
|
|
|
|
|
entity.HasOne(x => x.AssignedByUserAccount)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.AssignedByUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<TierSnapshot>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.Kind).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.Label).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.Weight).HasPrecision(18, 2);
|
|
|
|
|
entity.HasIndex(x => new { x.MembershipId, x.Kind, x.IsCurrent });
|
2026-11-14 04:58:26 +00:00
|
|
|
entity.HasIndex(x => x.MembershipId)
|
|
|
|
|
.IsUnique()
|
|
|
|
|
.HasDatabaseName("UX_TierSnapshots_MembershipId_CurrentPatron")
|
|
|
|
|
.HasFilter("\"Kind\" = 'Patron' AND \"IsCurrent\"");
|
2026-04-22 09:50:31 +01:00
|
|
|
entity.HasOne(x => x.Membership)
|
|
|
|
|
.WithMany(x => x.TierSnapshots)
|
|
|
|
|
.HasForeignKey(x => x.MembershipId);
|
2026-04-21 20:08:49 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<MembershipInvitation>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasIndex(x => x.NormalizedGitHubLogin).IsUnique();
|
|
|
|
|
entity.Property(x => x.GitHubLogin).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.NormalizedGitHubLogin).HasMaxLength(120);
|
|
|
|
|
entity.HasOne(x => x.IssuedByUserAccount)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.IssuedByUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
entity.HasOne(x => x.AcceptedByUserAccount)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.AcceptedByUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Project>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasIndex(x => x.Slug).IsUnique();
|
2026-04-22 09:50:31 +01:00
|
|
|
entity.HasIndex(x => x.GitHubRepository);
|
2026-04-21 20:08:49 +01:00
|
|
|
entity.Property(x => x.Name).HasMaxLength(180);
|
|
|
|
|
entity.Property(x => x.Slug).HasMaxLength(120);
|
2026-04-22 09:50:31 +01:00
|
|
|
entity.Property(x => x.GitHubRepository).HasMaxLength(240);
|
2026-04-21 20:08:49 +01:00
|
|
|
entity.Property(x => x.Status).HasConversion<string>();
|
|
|
|
|
entity.HasOne(x => x.OwnerUserAccount)
|
|
|
|
|
.WithMany(x => x.OwnedProjects)
|
|
|
|
|
.HasForeignKey(x => x.OwnerUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<WorkItem>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.SourceType).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.Status).HasConversion<string>();
|
2026-04-22 09:50:31 +01:00
|
|
|
entity.Property(x => x.ReviewStatus).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.SkillLevel).HasConversion<string>();
|
2026-04-21 20:08:49 +01:00
|
|
|
entity.Property(x => x.Title).HasMaxLength(180);
|
2026-04-22 09:50:31 +01:00
|
|
|
entity.Property(x => x.Category).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.ExternalSourceId).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.EstimatedHours).HasPrecision(18, 2);
|
|
|
|
|
entity.Property(x => x.ContributionPoints).HasPrecision(18, 2);
|
2026-04-21 20:08:49 +01:00
|
|
|
entity.HasOne(x => x.Project)
|
|
|
|
|
.WithMany(x => x.WorkItems)
|
|
|
|
|
.HasForeignKey(x => x.ProjectId);
|
|
|
|
|
entity.HasOne(x => x.RequestedByUserAccount)
|
|
|
|
|
.WithMany(x => x.RequestedWorkItems)
|
|
|
|
|
.HasForeignKey(x => x.RequestedByUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
entity.HasOne(x => x.AssignedToUserAccount)
|
|
|
|
|
.WithMany(x => x.AssignedWorkItems)
|
|
|
|
|
.HasForeignKey(x => x.AssignedToUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<VolunteerClaim>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasIndex(x => new { x.WorkItemId, x.UserAccountId }).IsUnique();
|
|
|
|
|
entity.Property(x => x.Status).HasConversion<string>();
|
|
|
|
|
entity.HasOne(x => x.WorkItem)
|
|
|
|
|
.WithMany(x => x.VolunteerClaims)
|
|
|
|
|
.HasForeignKey(x => x.WorkItemId);
|
|
|
|
|
entity.HasOne(x => x.UserAccount)
|
|
|
|
|
.WithMany(x => x.VolunteerClaims)
|
|
|
|
|
.HasForeignKey(x => x.UserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Assignment>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasOne(x => x.WorkItem)
|
|
|
|
|
.WithMany(x => x.Assignments)
|
|
|
|
|
.HasForeignKey(x => x.WorkItemId);
|
|
|
|
|
entity.HasOne(x => x.UserAccount)
|
|
|
|
|
.WithMany(x => x.Assignments)
|
|
|
|
|
.HasForeignKey(x => x.UserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
entity.HasOne(x => x.AssignedByUserAccount)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.AssignedByUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-22 09:50:31 +01:00
|
|
|
modelBuilder.Entity<WorkLog>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.Hours).HasPrecision(18, 2);
|
|
|
|
|
entity.Property(x => x.ApprovalStatus).HasConversion<string>();
|
|
|
|
|
entity.HasOne(x => x.WorkItem)
|
|
|
|
|
.WithMany(x => x.WorkLogs)
|
|
|
|
|
.HasForeignKey(x => x.WorkItemId);
|
|
|
|
|
entity.HasOne(x => x.UserAccount)
|
|
|
|
|
.WithMany(x => x.WorkLogs)
|
|
|
|
|
.HasForeignKey(x => x.UserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
entity.HasOne(x => x.ReviewedByUserAccount)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.ReviewedByUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<WorkReview>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.Status).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.ReviewerName).HasMaxLength(200);
|
|
|
|
|
entity.HasOne(x => x.WorkItem)
|
|
|
|
|
.WithMany(x => x.WorkReviews)
|
|
|
|
|
.HasForeignKey(x => x.WorkItemId);
|
|
|
|
|
entity.HasOne(x => x.ReviewerUserAccount)
|
|
|
|
|
.WithMany(x => x.WorkReviews)
|
|
|
|
|
.HasForeignKey(x => x.ReviewerUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<GitHubIssueLink>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasIndex(x => x.WorkItemId).IsUnique();
|
|
|
|
|
entity.HasIndex(x => new { x.RepositoryFullName, x.IssueNumber }).IsUnique();
|
|
|
|
|
entity.Property(x => x.RepositoryFullName).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.State).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.IssueUrl).HasMaxLength(500);
|
|
|
|
|
entity.Property(x => x.TitleSnapshot).HasMaxLength(240);
|
|
|
|
|
entity.HasOne(x => x.WorkItem)
|
|
|
|
|
.WithOne(x => x.GitHubIssueLink)
|
|
|
|
|
.HasForeignKey<GitHubIssueLink>(x => x.WorkItemId);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<GitHubPullRequestLink>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasIndex(x => new { x.RepositoryFullName, x.PullRequestNumber }).IsUnique();
|
|
|
|
|
entity.Property(x => x.RepositoryFullName).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.State).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.ReviewDecision).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.PullRequestUrl).HasMaxLength(500);
|
|
|
|
|
entity.Property(x => x.TitleSnapshot).HasMaxLength(240);
|
|
|
|
|
entity.HasOne(x => x.WorkItem)
|
|
|
|
|
.WithMany(x => x.GitHubPullRequestLinks)
|
|
|
|
|
.HasForeignKey(x => x.WorkItemId);
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-21 20:08:49 +01:00
|
|
|
modelBuilder.Entity<Motion>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.Scope).HasConversion<string>();
|
2026-04-22 09:50:31 +01:00
|
|
|
entity.Property(x => x.Category).HasConversion<string>();
|
2026-04-21 20:08:49 +01:00
|
|
|
entity.Property(x => x.Status).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.ApprovalThreshold).HasPrecision(6, 3);
|
2026-11-09 20:24:49 +00:00
|
|
|
entity.Property(x => x.Kind).HasConversion<string>();
|
2026-11-09 20:40:54 +00:00
|
|
|
entity.Property(x => x.RevealSeq).IsConcurrencyToken();
|
2026-11-09 20:30:35 +00:00
|
|
|
entity.Property(x => x.Status).IsConcurrencyToken();
|
2026-04-21 20:08:49 +01:00
|
|
|
entity.HasOne(x => x.Project)
|
|
|
|
|
.WithMany(x => x.Motions)
|
|
|
|
|
.HasForeignKey(x => x.ProjectId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
entity.HasOne(x => x.CreatedByUserAccount)
|
|
|
|
|
.WithMany(x => x.CreatedMotions)
|
|
|
|
|
.HasForeignKey(x => x.CreatedByUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<Vote>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasIndex(x => new { x.MotionId, x.UserAccountId }).IsUnique();
|
Account merge ledger: AccountMerge receipt, reductions, alias standing, undo and final sweep
AccountMergeLedger owns what a merge does to Bifrost records: PlanAsync (dry run, block codes),
CommitAsync (one save, total, idempotent), UndoLocalAsync (journal replay), FinalizeDueAsync
(AccountMergeSweeper) and StandingAsync/ResolveAsync. Votes and concept appraisals are voided by a
stamp that a model query filter hides from every tally. The actor accessor no longer ORs several
credentials under SingleOrDefault (a latent crash); a frozen or folded account resolves to no
account on every route, the OIDC authorize and chat refusal deny it, and patron intake follows the
alias. Migration AddAccountMerges is additive. No UI, no Heimdall call, nothing deployed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 02:31:51 +00:00
|
|
|
// A merge voids a vote by stamping it; every tally reads through this filter, and only AccountMergeLedger ignores it.
|
|
|
|
|
entity.HasQueryFilter(x => x.VoidedByMergeId == null);
|
2026-04-21 20:08:49 +01:00
|
|
|
entity.Property(x => x.Choice).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.Weight).HasPrecision(18, 2);
|
|
|
|
|
entity.HasOne(x => x.Motion)
|
|
|
|
|
.WithMany(x => x.Votes)
|
|
|
|
|
.HasForeignKey(x => x.MotionId);
|
|
|
|
|
entity.HasOne(x => x.UserAccount)
|
|
|
|
|
.WithMany(x => x.Votes)
|
|
|
|
|
.HasForeignKey(x => x.UserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
});
|
|
|
|
|
|
2026-11-09 20:24:49 +00:00
|
|
|
modelBuilder.Entity<SealedBallot>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasIndex(x => new { x.MotionId, x.UserAccountId }).IsUnique();
|
|
|
|
|
entity.HasOne(x => x.Motion)
|
|
|
|
|
.WithMany(x => x.SealedBallots)
|
|
|
|
|
.HasForeignKey(x => x.MotionId);
|
|
|
|
|
entity.HasOne(x => x.UserAccount)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.UserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
});
|
|
|
|
|
|
2026-11-11 10:15:46 +00:00
|
|
|
modelBuilder.Entity<ConsentReceipt>(entity =>
|
|
|
|
|
{
|
2026-11-11 12:11:02 +00:00
|
|
|
// One live receipt per account and version; a withdrawn row stays as history and a later agreement is a new row.
|
|
|
|
|
entity.HasIndex(x => new { x.UserAccountId, x.NoticeVersion }).IsUnique().HasFilter("\"WithdrawnAtUtc\" IS NULL");
|
2026-11-11 10:15:46 +00:00
|
|
|
entity.HasOne(x => x.UserAccount)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.UserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
2026-11-14 00:37:56 +00:00
|
|
|
modelBuilder.Entity<PasskeyCredential>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasIndex(x => x.CredentialId).IsUnique();
|
|
|
|
|
entity.HasIndex(x => x.UserAccountId);
|
|
|
|
|
entity.HasOne(x => x.UserAccount)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.UserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
2026-11-09 20:37:47 +00:00
|
|
|
modelBuilder.Entity<MindKey>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasIndex(x => new { x.PersonaId, x.PublicKey }).IsUnique();
|
|
|
|
|
});
|
|
|
|
|
|
2026-11-09 20:50:41 +00:00
|
|
|
modelBuilder.Entity<MindPersona>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasIndex(x => x.PersonaId).IsUnique();
|
|
|
|
|
entity.HasIndex(x => x.UserAccountId).IsUnique();
|
|
|
|
|
});
|
|
|
|
|
|
2026-11-09 20:37:47 +00:00
|
|
|
modelBuilder.Entity<MindNonce>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasIndex(x => new { x.PersonaId, x.Nonce }).IsUnique();
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-21 20:08:49 +01:00
|
|
|
modelBuilder.Entity<LedgerEntry>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.EntryType).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.Status).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.Points).HasPrecision(18, 2);
|
|
|
|
|
entity.Property(x => x.NominalAmount).HasPrecision(18, 2);
|
|
|
|
|
entity.HasOne(x => x.UserAccount)
|
|
|
|
|
.WithMany(x => x.LedgerEntries)
|
|
|
|
|
.HasForeignKey(x => x.UserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
entity.HasOne(x => x.CreatedByUserAccount)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.CreatedByUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
entity.HasOne(x => x.Project)
|
|
|
|
|
.WithMany(x => x.LedgerEntries)
|
|
|
|
|
.HasForeignKey(x => x.ProjectId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
entity.HasOne(x => x.WorkItem)
|
|
|
|
|
.WithMany(x => x.LedgerEntries)
|
|
|
|
|
.HasForeignKey(x => x.WorkItemId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<PayoutProposalBatch>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.Status).HasConversion<string>();
|
|
|
|
|
entity.HasOne(x => x.CreatedByUserAccount)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.CreatedByUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-22 09:50:31 +01:00
|
|
|
modelBuilder.Entity<PointTransaction>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.Type).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.Amount).HasPrecision(18, 2);
|
|
|
|
|
entity.HasOne(x => x.UserAccount)
|
|
|
|
|
.WithMany(x => x.PointTransactions)
|
|
|
|
|
.HasForeignKey(x => x.UserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
entity.HasOne(x => x.Project)
|
|
|
|
|
.WithMany(x => x.PointTransactions)
|
|
|
|
|
.HasForeignKey(x => x.ProjectId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
entity.HasOne(x => x.WorkItem)
|
|
|
|
|
.WithMany(x => x.PointTransactions)
|
|
|
|
|
.HasForeignKey(x => x.WorkItemId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<PatronSupportEvent>(entity =>
|
|
|
|
|
{
|
2026-06-09 16:28:30 +01:00
|
|
|
entity.Property(x => x.Kind).HasConversion<string>();
|
2026-06-09 17:16:27 +01:00
|
|
|
entity.Property(x => x.Provider).HasConversion<string>();
|
2026-04-22 09:50:31 +01:00
|
|
|
entity.Property(x => x.Amount).HasPrecision(18, 2);
|
|
|
|
|
entity.Property(x => x.ExternalSupportId).HasMaxLength(240);
|
2026-06-09 17:16:27 +01:00
|
|
|
entity.Property(x => x.ProviderEventId).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.ProviderPayerId).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.ProviderSubscriptionId).HasMaxLength(240);
|
2026-04-22 09:50:31 +01:00
|
|
|
entity.Property(x => x.CurrencyCode).HasMaxLength(12);
|
2026-06-09 16:28:30 +01:00
|
|
|
entity.HasIndex(x => new { x.UserAccountId, x.Kind, x.IsCurrentRecurringSupport });
|
2026-06-09 17:16:27 +01:00
|
|
|
entity.HasIndex(x => new { x.Provider, x.ProviderEventId })
|
|
|
|
|
.IsUnique()
|
|
|
|
|
.HasFilter("\"ProviderEventId\" <> ''");
|
2026-04-22 09:50:31 +01:00
|
|
|
entity.HasOne(x => x.UserAccount)
|
|
|
|
|
.WithMany(x => x.PatronSupportEvents)
|
|
|
|
|
.HasForeignKey(x => x.UserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
2026-07-05 19:07:48 +01:00
|
|
|
entity.HasOne(x => x.Project)
|
|
|
|
|
.WithMany(x => x.PatronSupportEvents)
|
|
|
|
|
.HasForeignKey(x => x.ProjectId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
2026-04-22 09:50:31 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<DecayRun>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.Rate).HasPrecision(8, 4);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<RevenueEvent>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.Amount).HasPrecision(18, 2);
|
|
|
|
|
entity.Property(x => x.CurrencyCode).HasMaxLength(12);
|
|
|
|
|
entity.HasOne(x => x.Project)
|
|
|
|
|
.WithMany(x => x.RevenueEvents)
|
|
|
|
|
.HasForeignKey(x => x.ProjectId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<RevenueShareBatch>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.HasOne(x => x.RevenueEvent)
|
|
|
|
|
.WithMany(x => x.RevenueShareBatches)
|
|
|
|
|
.HasForeignKey(x => x.RevenueEventId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
entity.HasOne(x => x.CreatedByUserAccount)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.CreatedByUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<RevenueShareLine>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.Amount).HasPrecision(18, 2);
|
|
|
|
|
entity.Property(x => x.Basis).HasMaxLength(240);
|
|
|
|
|
entity.HasOne(x => x.RevenueShareBatch)
|
|
|
|
|
.WithMany(x => x.Lines)
|
|
|
|
|
.HasForeignKey(x => x.RevenueShareBatchId);
|
|
|
|
|
entity.HasOne(x => x.UserAccount)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.UserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
entity.HasOne(x => x.Project)
|
|
|
|
|
.WithMany(x => x.RevenueShareLines)
|
|
|
|
|
.HasForeignKey(x => x.ProjectId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
|
|
|
|
|
2026-06-17 04:03:14 +01:00
|
|
|
modelBuilder.Entity<BridgeAction>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.ActorKind).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.TargetSurface).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.ActionKind).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.Status).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.ActorName).HasMaxLength(160);
|
|
|
|
|
entity.Property(x => x.TargetRepositoryFullName).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.TargetLocator).HasMaxLength(500);
|
2026-06-22 16:44:14 +01:00
|
|
|
entity.Property(x => x.TargetSurfaceName).HasMaxLength(120);
|
2026-06-17 04:03:14 +01:00
|
|
|
entity.Property(x => x.SourceKind).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.SourceId).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.AuthorityReference).HasMaxLength(240);
|
2026-06-22 14:54:14 +01:00
|
|
|
entity.Property(x => x.BifrostIdentity).HasMaxLength(160);
|
|
|
|
|
entity.Property(x => x.HeimdallCapabilityReference).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.EpiphanyRunId).HasMaxLength(160);
|
|
|
|
|
entity.Property(x => x.EpiphanyLaneId).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.EpiphanyAgentIdentity).HasMaxLength(160);
|
2026-06-17 04:03:14 +01:00
|
|
|
entity.Property(x => x.PolicyDecision).HasMaxLength(500);
|
|
|
|
|
entity.Property(x => x.Title).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.ReceiptUrl).HasMaxLength(500);
|
|
|
|
|
entity.Property(x => x.ExternalReceiptId).HasMaxLength(240);
|
|
|
|
|
entity.HasIndex(x => x.Status);
|
|
|
|
|
entity.HasIndex(x => new { x.TargetSurface, x.ActionKind, x.Status });
|
2026-06-22 16:44:14 +01:00
|
|
|
entity.HasIndex(x => new { x.TargetSurface, x.TargetSurfaceName, x.Status });
|
2026-06-17 04:03:14 +01:00
|
|
|
entity.HasIndex(x => new { x.ActorKind, x.ActorName });
|
|
|
|
|
entity.HasIndex(x => new { x.SourceKind, x.SourceId });
|
2026-06-22 14:54:14 +01:00
|
|
|
entity.HasIndex(x => x.BifrostIdentity);
|
|
|
|
|
entity.HasIndex(x => x.HeimdallCapabilityReference);
|
2026-06-17 04:03:14 +01:00
|
|
|
entity.HasOne(x => x.ActorUserAccount)
|
|
|
|
|
.WithMany(x => x.BridgeActions)
|
|
|
|
|
.HasForeignKey(x => x.ActorUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
entity.HasOne(x => x.WorkItem)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.WorkItemId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
entity.HasOne(x => x.Motion)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.MotionId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<AgentDispatchRun>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.RequestId).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.TargetRepoName).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.TargetRepositoryFullName).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.TargetAgentIdentity).HasMaxLength(160);
|
|
|
|
|
entity.Property(x => x.LaunchMode).HasMaxLength(40);
|
|
|
|
|
entity.Property(x => x.Status).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.ThreadId).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.TurnId).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.LogPath).HasMaxLength(500);
|
|
|
|
|
entity.Property(x => x.ResultPath).HasMaxLength(500);
|
|
|
|
|
entity.HasIndex(x => x.RequestId);
|
|
|
|
|
entity.HasIndex(x => x.Status);
|
|
|
|
|
entity.HasIndex(x => new { x.TargetRepoName, x.TargetAgentIdentity, x.Status });
|
|
|
|
|
entity.HasOne(x => x.StartedByUserAccount)
|
|
|
|
|
.WithMany(x => x.AgentDispatchRuns)
|
|
|
|
|
.HasForeignKey(x => x.StartedByUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
|
|
|
|
|
2026-06-17 04:49:22 +01:00
|
|
|
modelBuilder.Entity<AgentTransportReceipt>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.RequestId).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.Title).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.TargetRepoName).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.TargetRepositoryFullName).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.TargetAgentIdentity).HasMaxLength(160);
|
|
|
|
|
entity.Property(x => x.ActivityKind).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.Status).HasMaxLength(40);
|
|
|
|
|
entity.Property(x => x.ActorName).HasMaxLength(160);
|
|
|
|
|
entity.HasIndex(x => x.RequestId);
|
|
|
|
|
entity.HasIndex(x => x.OccurredAtUtc);
|
|
|
|
|
entity.HasIndex(x => new { x.TargetRepoName, x.TargetAgentIdentity, x.ActivityKind });
|
|
|
|
|
entity.HasOne(x => x.ActorUserAccount)
|
|
|
|
|
.WithMany(x => x.AgentTransportReceipts)
|
|
|
|
|
.HasForeignKey(x => x.ActorUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
|
|
|
|
|
2026-06-17 05:21:29 +01:00
|
|
|
modelBuilder.Entity<GovernanceActivityReceipt>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.TopicId).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.CommentId).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.DispatchRequestId).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.Title).HasMaxLength(240);
|
|
|
|
|
entity.Property(x => x.JurisdictionRepoName).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.JurisdictionAgentIdentity).HasMaxLength(160);
|
|
|
|
|
entity.Property(x => x.ActivityKind).HasConversion<string>();
|
|
|
|
|
entity.Property(x => x.ActorKind).HasMaxLength(40);
|
|
|
|
|
entity.Property(x => x.ActorName).HasMaxLength(160);
|
|
|
|
|
entity.HasIndex(x => x.TopicId);
|
|
|
|
|
entity.HasIndex(x => x.OccurredAtUtc);
|
|
|
|
|
entity.HasIndex(x => new { x.JurisdictionRepoName, x.JurisdictionAgentIdentity, x.ActivityKind });
|
|
|
|
|
entity.HasOne(x => x.ActorUserAccount)
|
|
|
|
|
.WithMany(x => x.GovernanceActivityReceipts)
|
|
|
|
|
.HasForeignKey(x => x.ActorUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-21 20:08:49 +01:00
|
|
|
modelBuilder.Entity<AuditEvent>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.EntityType).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.EntityId).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.Action).HasMaxLength(120);
|
|
|
|
|
entity.HasOne(x => x.ActorUserAccount)
|
|
|
|
|
.WithMany(x => x.AuditEvents)
|
|
|
|
|
.HasForeignKey(x => x.ActorUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
2026-10-10 06:31:43 +02:00
|
|
|
|
|
|
|
|
modelBuilder.Entity<ConceptSubject>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.Collection).HasMaxLength(80);
|
|
|
|
|
entity.Property(x => x.Key).HasMaxLength(80);
|
|
|
|
|
entity.Property(x => x.Title).HasMaxLength(240);
|
|
|
|
|
entity.HasIndex(x => new { x.Collection, x.Key }).IsUnique();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<ConceptAppraisal>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.VoterKey).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.NetworkTag).HasMaxLength(64);
|
|
|
|
|
entity.Property(x => x.Stance).HasConversion<string>().HasMaxLength(16);
|
|
|
|
|
entity.Property(x => x.VoterClass).HasConversion<string>().HasMaxLength(16);
|
Account merge ledger: AccountMerge receipt, reductions, alias standing, undo and final sweep
AccountMergeLedger owns what a merge does to Bifrost records: PlanAsync (dry run, block codes),
CommitAsync (one save, total, idempotent), UndoLocalAsync (journal replay), FinalizeDueAsync
(AccountMergeSweeper) and StandingAsync/ResolveAsync. Votes and concept appraisals are voided by a
stamp that a model query filter hides from every tally. The actor accessor no longer ORs several
credentials under SingleOrDefault (a latent crash); a frozen or folded account resolves to no
account on every route, the OIDC authorize and chat refusal deny it, and patron intake follows the
alias. Migration AddAccountMerges is additive. No UI, no Heimdall call, nothing deployed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 02:31:51 +00:00
|
|
|
entity.HasQueryFilter(x => x.VoidedByMergeId == null);
|
2026-10-10 06:31:43 +02:00
|
|
|
entity.HasIndex(x => new { x.SubjectId, x.VoterKey }).IsUnique();
|
|
|
|
|
entity.HasIndex(x => new { x.NetworkTag, x.CastAtUtc });
|
|
|
|
|
entity.HasOne(x => x.Subject)
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.SubjectId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
entity.HasOne<UserAccount>()
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.UserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
|
});
|
Account merge ledger: AccountMerge receipt, reductions, alias standing, undo and final sweep
AccountMergeLedger owns what a merge does to Bifrost records: PlanAsync (dry run, block codes),
CommitAsync (one save, total, idempotent), UndoLocalAsync (journal replay), FinalizeDueAsync
(AccountMergeSweeper) and StandingAsync/ResolveAsync. Votes and concept appraisals are voided by a
stamp that a model query filter hides from every tally. The actor accessor no longer ORs several
credentials under SingleOrDefault (a latent crash); a frozen or folded account resolves to no
account on every route, the OIDC authorize and chat refusal deny it, and patron intake follows the
alias. Migration AddAccountMerges is additive. No UI, no Heimdall call, nothing deployed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 02:31:51 +00:00
|
|
|
|
|
|
|
|
modelBuilder.Entity<AccountMerge>(entity =>
|
|
|
|
|
{
|
2026-11-14 03:37:48 +00:00
|
|
|
// State is the token: a transition computed from a stale read (the sweeper's Final over a saga's UndoRequested) fails its save.
|
|
|
|
|
entity.Property(x => x.State).HasConversion<string>().HasMaxLength(24).IsConcurrencyToken();
|
Account merge ledger: AccountMerge receipt, reductions, alias standing, undo and final sweep
AccountMergeLedger owns what a merge does to Bifrost records: PlanAsync (dry run, block codes),
CommitAsync (one save, total, idempotent), UndoLocalAsync (journal replay), FinalizeDueAsync
(AccountMergeSweeper) and StandingAsync/ResolveAsync. Votes and concept appraisals are voided by a
stamp that a model query filter hides from every tally. The actor accessor no longer ORs several
credentials under SingleOrDefault (a latent crash); a frozen or folded account resolves to no
account on every route, the OIDC authorize and chat refusal deny it, and patron intake follows the
alias. Migration AddAccountMerges is additive. No UI, no Heimdall call, nothing deployed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 02:31:51 +00:00
|
|
|
entity.Property(x => x.FailureCode).HasMaxLength(64);
|
2026-11-14 06:48:43 +00:00
|
|
|
entity.Property(x => x.HeimdallMoveId).HasMaxLength(64);
|
|
|
|
|
entity.Property(x => x.HeimdallReverseMoveId).HasMaxLength(64);
|
|
|
|
|
entity.Property(x => x.PreviewDigest).HasMaxLength(64);
|
|
|
|
|
entity.Property(x => x.SurvivorProofProvider).HasMaxLength(32);
|
|
|
|
|
entity.Property(x => x.FoldedProofProviders).HasMaxLength(120);
|
|
|
|
|
entity.Property(x => x.ProofFromTier).HasMaxLength(8);
|
|
|
|
|
entity.Property(x => x.ProofToTier).HasMaxLength(8);
|
|
|
|
|
entity.Property(x => x.LastOutcome).HasMaxLength(64);
|
|
|
|
|
// Heimdall's idempotency keys: one merge, one forward key and one reverse key, and no key shared by two merges.
|
|
|
|
|
entity.HasIndex(x => x.HeimdallMoveId).IsUnique().HasFilter("\"HeimdallMoveId\" IS NOT NULL");
|
|
|
|
|
entity.HasIndex(x => x.HeimdallReverseMoveId).IsUnique().HasFilter("\"HeimdallReverseMoveId\" IS NOT NULL");
|
Account merge ledger: AccountMerge receipt, reductions, alias standing, undo and final sweep
AccountMergeLedger owns what a merge does to Bifrost records: PlanAsync (dry run, block codes),
CommitAsync (one save, total, idempotent), UndoLocalAsync (journal replay), FinalizeDueAsync
(AccountMergeSweeper) and StandingAsync/ResolveAsync. Votes and concept appraisals are voided by a
stamp that a model query filter hides from every tally. The actor accessor no longer ORs several
credentials under SingleOrDefault (a latent crash); a frozen or folded account resolves to no
account on every route, the OIDC authorize and chat refusal deny it, and patron intake follows the
alias. Migration AddAccountMerges is additive. No UI, no Heimdall call, nothing deployed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 02:31:51 +00:00
|
|
|
entity.HasIndex(x => new { x.FoldedUserAccountId, x.State });
|
2026-11-14 03:37:48 +00:00
|
|
|
// An account is folded once: the DB refuses a second live merge folding it. The cross-role case (a survivor that is also
|
|
|
|
|
// folded) cannot be one unique index; the migration's trigger refuses it.
|
|
|
|
|
entity.HasIndex(x => x.FoldedUserAccountId)
|
|
|
|
|
.IsUnique()
|
|
|
|
|
.HasDatabaseName("UX_AccountMerges_FoldedUserAccountId_Live")
|
|
|
|
|
.HasFilter("\"State\" IN ('Confirmed', 'HeimdallMoved', 'Committed', 'Final', 'UndoRequested', 'HeimdallReversed')");
|
Account merge ledger: AccountMerge receipt, reductions, alias standing, undo and final sweep
AccountMergeLedger owns what a merge does to Bifrost records: PlanAsync (dry run, block codes),
CommitAsync (one save, total, idempotent), UndoLocalAsync (journal replay), FinalizeDueAsync
(AccountMergeSweeper) and StandingAsync/ResolveAsync. Votes and concept appraisals are voided by a
stamp that a model query filter hides from every tally. The actor accessor no longer ORs several
credentials under SingleOrDefault (a latent crash); a frozen or folded account resolves to no
account on every route, the OIDC authorize and chat refusal deny it, and patron intake follows the
alias. Migration AddAccountMerges is additive. No UI, no Heimdall call, nothing deployed.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 02:31:51 +00:00
|
|
|
entity.HasIndex(x => new { x.SurvivorUserAccountId, x.State });
|
|
|
|
|
entity.HasIndex(x => new { x.State, x.GraceEndsUtc });
|
|
|
|
|
entity.HasOne<UserAccount>()
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.SurvivorUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
entity.HasOne<UserAccount>()
|
|
|
|
|
.WithMany()
|
|
|
|
|
.HasForeignKey(x => x.FoldedUserAccountId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modelBuilder.Entity<AccountMergeEntry>(entity =>
|
|
|
|
|
{
|
|
|
|
|
entity.Property(x => x.Kind).HasConversion<string>().HasMaxLength(24);
|
|
|
|
|
entity.Property(x => x.Action).HasConversion<string>().HasMaxLength(24);
|
|
|
|
|
entity.Property(x => x.PriorText).HasMaxLength(120);
|
|
|
|
|
entity.HasIndex(x => new { x.MergeId, x.Seq }).IsUnique();
|
|
|
|
|
entity.HasOne(x => x.Merge)
|
|
|
|
|
.WithMany(x => x.Entries)
|
|
|
|
|
.HasForeignKey(x => x.MergeId)
|
|
|
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
|
});
|
2026-04-21 20:08:49 +01:00
|
|
|
}
|
|
|
|
|
}
|