License model — CRUD, DLID generation, validation logic #618

Open
opened 2026-06-12 07:57:39 +00:00 by jmiller · 0 comments
Owner

Phase 1.2 — License Model

Parent: #616 | Depends on: #617 | Blocks: #621, #622, #623

Files to create

models/licensing/license.go:

  • CreateLicense(userID, tier) -> License — generates 32-char hex DLID with CRC32 checksum in last 4 chars
  • GetLicenseByDLID(dlid) -> License — primary lookup method
  • GetLicensesByUser(userID) -> []License — user dashboard
  • UpdateLicenseTier(licenseID, newTier) — tier upgrade/downgrade, auto-recalculate entitlements
  • RevokeLicense(licenseID) / SuspendLicense / ReactivateLicense
  • IsExpired(license) -> bool — check expiry
  • ValidateDLID(dlid) -> bool — format check (hex + CRC32) without database hit

DLID Format

  • 32 hex characters in 4 groups: a1b2c3d4-e5f6a7b8-c9d0e1f2-CHECKSUM
  • Last 4 chars = CRC32 of first 28 chars (client-side validation)
  • Generated via crypto/rand for uniqueness

Acceptance criteria

  • DLID generation produces unique, checksummed keys
  • Client-side validation catches typos without server round-trip
  • Tier changes auto-rebuild entitlements from product_tier table
  • Status transitions are logged for audit
## Phase 1.2 — License Model Parent: #616 | Depends on: #617 | Blocks: #621, #622, #623 ### Files to create `models/licensing/license.go`: - `CreateLicense(userID, tier) -> License` — generates 32-char hex DLID with CRC32 checksum in last 4 chars - `GetLicenseByDLID(dlid) -> License` — primary lookup method - `GetLicensesByUser(userID) -> []License` — user dashboard - `UpdateLicenseTier(licenseID, newTier)` — tier upgrade/downgrade, auto-recalculate entitlements - `RevokeLicense(licenseID)` / `SuspendLicense` / `ReactivateLicense` - `IsExpired(license) -> bool` — check expiry - `ValidateDLID(dlid) -> bool` — format check (hex + CRC32) without database hit ### DLID Format - 32 hex characters in 4 groups: `a1b2c3d4-e5f6a7b8-c9d0e1f2-CHECKSUM` - Last 4 chars = CRC32 of first 28 chars (client-side validation) - Generated via `crypto/rand` for uniqueness ### Acceptance criteria - [ ] DLID generation produces unique, checksummed keys - [ ] Client-side validation catches typos without server round-trip - [ ] Tier changes auto-rebuild entitlements from product_tier table - [ ] Status transitions are logged for audit
Sign in to join this conversation.