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:
@@ -70,6 +70,12 @@ public sealed class AccountDataExportTests
|
||||
db.GmailConnections.Add(new GmailConnection { OwnerUserId = owner.Id, GmailAddress = owner.GoogleEmail!, Scope = "mail.read", EncryptedRefreshToken = "GMAIL_REFRESH_SECRET_MUST_NOT_EXPORT", EncryptedAccessToken = "GMAIL_ACCESS_SECRET_MUST_NOT_EXPORT" });
|
||||
db.ImapConnections.Add(new ImapConnection { OwnerUserId = owner.Id, Host = "mail.example.test", Username = "owner", EncryptedPassword = "IMAP_SECRET_MUST_NOT_EXPORT" });
|
||||
db.UserOperations.Add(new UserOperation { Id = Guid.NewGuid(), OwnerUserId = owner.Id, TaskType = "synthetic", Status = OperationStatuses.Running, LeaseToken = "LEASE_SECRET_MUST_NOT_EXPORT", CreatedAtUtc = DateTime.UtcNow, AvailableAtUtc = DateTime.UtcNow });
|
||||
db.AiUsageRecords.Add(new AiUsageRecord
|
||||
{
|
||||
OwnerUserId = owner.Id, SourceType = "workspace", SourceId = "export-proof",
|
||||
TaskType = "ai.workspace", InputCharacterCount = 120, OutputCharacterCount = 40,
|
||||
EstimatedTokenCount = 40, CreatedAtUtc = DateTimeOffset.UtcNow,
|
||||
});
|
||||
db.TwoFactorRecoveryCodes.Add(new TwoFactorRecoveryCode { UserId = owner.Id, CodeHash = "RECOVERY_HASH_MUST_NOT_EXPORT", CreatedAtUtc = DateTimeOffset.UtcNow });
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
@@ -102,6 +108,7 @@ public sealed class AccountDataExportTests
|
||||
.Select(ReadText));
|
||||
Assert.Contains("Synthetic Owner", readable);
|
||||
Assert.Contains("Readable application note", readable);
|
||||
Assert.Contains("export-proof", readable);
|
||||
Assert.DoesNotContain("OTHER_TENANT_PRIVATE", readable);
|
||||
Assert.DoesNotContain("PASSWORD_HASH_MUST_NOT_EXPORT", readable);
|
||||
Assert.DoesNotContain("SECURITY_STAMP_MUST_NOT_EXPORT", readable);
|
||||
|
||||
Reference in New Issue
Block a user