feat(service): P5.2 adapter tables (raw_event, outbound_command, delivery_attempt, rate_limit_bucket) + resetDb

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-01 13:39:22 +05:30
parent d70c7ea47b
commit b4a1832a5c
3 changed files with 135 additions and 0 deletions
@@ -517,3 +517,63 @@ model IiosCallbackRequest {
@@index([scopeId, status])
}
// ─── P5: Adapters (anti-corruption layer, simulation mode) ────────
/// Raw inbound provider payload (claim-check / replay). Verified before storing.
model IiosInboundRawEvent {
id String @id @default(cuid())
channelType String
externalEventId String?
signatureStatus String // VERIFIED | INVALID | UNSIGNED
status String @default("RECEIVED") // RECEIVED | NORMALIZED | REJECTED | FAILED
headers Json?
payload Json
traceId String?
interactionId String?
createdAt DateTime @default(now())
@@unique([channelType, externalEventId])
@@index([status])
}
/// A signed command to send on an external channel — executed by the sandbox sink.
model IiosOutboundCommand {
id String @id @default(cuid())
channelType String
target String
payload Json
status String @default("PENDING") // PENDING | SENT | FAILED | RATE_LIMITED
idempotencyKey String @unique
providerRef String?
createdAt DateTime @default(now())
attempts IiosDeliveryAttempt[]
@@index([channelType, status])
}
model IiosDeliveryAttempt {
id String @id @default(cuid())
commandId String
command IiosOutboundCommand @relation(fields: [commandId], references: [id], onDelete: Cascade)
attemptNo Int
status String
providerRef String?
latencyMs Int?
errorCode String?
at DateTime @default(now())
@@index([commandId])
}
/// Per-(channelType, key) token/window bucket for outbound throttling.
model IiosRateLimitBucket {
channelType String
bucketKey String
windowStart DateTime @default(now())
count Int @default(0)
resetAt DateTime
@@id([channelType, bucketKey])
}