feat(ai): centralize durable usage
Add a content-free usage ledger with legacy backfill. Reserve Workspace and durable Strategy/CV work before execution so deleted history or duplicate admission cannot reset limits.
This commit is contained in:
@@ -56,6 +56,7 @@ namespace JobTrackerApi.Data
|
||||
public DbSet<CvVariant> CvVariants => Set<CvVariant>();
|
||||
public DbSet<CvVariantVersion> CvVariantVersions => Set<CvVariantVersion>();
|
||||
public DbSet<AiInteraction> AiInteractions => Set<AiInteraction>();
|
||||
public DbSet<AiUsageRecord> AiUsageRecords => Set<AiUsageRecord>();
|
||||
public DbSet<ApplicationChecklistItem> ApplicationChecklistItems => Set<ApplicationChecklistItem>();
|
||||
public DbSet<CoverLetterVersion> CoverLetterVersions => Set<CoverLetterVersion>();
|
||||
public DbSet<InterviewPrepItem> InterviewPrepItems => Set<InterviewPrepItem>();
|
||||
@@ -482,6 +483,18 @@ namespace JobTrackerApi.Data
|
||||
.HasForeignKey(x => x.JobApplicationId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<AiUsageRecord>()
|
||||
.HasQueryFilter(x => CurrentUserId != null && x.OwnerUserId == CurrentUserId);
|
||||
modelBuilder.Entity<AiUsageRecord>().Property(x => x.OwnerUserId).HasMaxLength(255);
|
||||
modelBuilder.Entity<AiUsageRecord>().Property(x => x.SourceType).HasMaxLength(32);
|
||||
modelBuilder.Entity<AiUsageRecord>().Property(x => x.SourceId).HasMaxLength(64);
|
||||
modelBuilder.Entity<AiUsageRecord>().Property(x => x.TaskType).HasMaxLength(64);
|
||||
modelBuilder.Entity<AiUsageRecord>()
|
||||
.HasIndex(x => new { x.OwnerUserId, x.SourceType, x.SourceId })
|
||||
.IsUnique();
|
||||
modelBuilder.Entity<AiUsageRecord>()
|
||||
.HasIndex(x => new { x.OwnerUserId, x.CreatedAtUtc });
|
||||
|
||||
// Phase 5 Milestone 2: the application checklist — a workflow guidance layer over the existing
|
||||
// readiness signals, not a second store of truth. Same deny-on-null tenant filter; cascades with
|
||||
// the application. docs/architecture/application-workspace.md.
|
||||
|
||||
Reference in New Issue
Block a user