Skip to content

feat(thinkfleet-memory): seed plans + entitlements via Rake task - #3

Merged
rrader26 merged 1 commit into
mainfrom
feat/thinkfleet-memory-seed
Jun 10, 2026
Merged

feat(thinkfleet-memory): seed plans + entitlements via Rake task#3
rrader26 merged 1 commit into
mainfrom
feat/thinkfleet-memory-seed

Conversation

@rrader26

Copy link
Copy Markdown

Summary

  • Adds lib/tasks/thinkfleet_memory.rake with one idempotent task that provisions the four ThinkFleet Memory tiers, their billable metrics, features (+ privilege catalogs), entitlements, and a thinkfleet-memory billing entity for customer isolation.
  • Designed to be run against any organization in this Lago org by id: bin/rails 'thinkfleet_memory:seed[<organization_id>]'. Append ,dry_run to preview without persisting.
  • Idempotent: every create is find_or_create_by keyed by code. Entitlement values update in place — re-run anytime to bump quotas.

Why

Mirrors the EngageIt isolation pattern (billing entity per product) so Memory customers, subscriptions, and invoices live under thinkfleet-memory while plans share the org. The feature codes (memory.subjects, memory.predictions, etc.) are the wire contract with the memory-thinkfleet API consumer — the engine reads these at request time via /plans/<code>/entitlements to gate features and enforce limits.

What gets created

Type Codes
Billing entity thinkfleet-memory
Billable metrics memory.events_ingested.used, memory.predictions.used (sum_agg on amount)
Features memory.subjects, memory.active_triggers, memory.events_ingested, memory.predictions, memory.health_vertical, memory.finance_vertical, memory.on_device, memory.vpc_deployment, memory.audit_retention
Plans memory-dev (free), memory-team ($199/mo), memory-business ($1,499/mo), memory-enterprise (custom)

Privilege values per plan match the spec at `docs/memory-plan-spec.md` in the memory-thinkfleet repo.

Test plan

  • Pull the branch, run `bin/rails 'thinkfleet_memory:seed[<qa_org_id>,dry_run]'` against QA Lago — confirm the printed plan reflects intent
  • Run without `dry_run` → confirm all four plans exist with correct entitlement values
  • Re-run → confirm output shows only ✓ (no + / ~) — proves idempotency
  • Confirm `BillingEntity.find_by(code: "thinkfleet-memory")` exists
  • From the memory.thinkfleet.ai API: `GET /api/v1/plans/memory-dev/entitlements` returns the entitlements as expected

After merge

  1. Deploy this branch to the Lago environment
  2. From a deployed pod: `bin/rails 'thinkfleet_memory:seed[<your_org_id>]'`
  3. The memory-thinkfleet consumer API reads these via the existing Lago entitlement checker — no consumer-side changes needed

🤖 Generated with Claude Code

…ments

Adds `bin/rails 'thinkfleet_memory:seed[<org_id>]'` (with optional `,dry_run`
second arg) for provisioning the four ThinkFleet Memory tiers in this Lago org.

Provisions in one transactional pass:
- Billing entity `thinkfleet-memory` (customer-isolation, mirrors EngageIt)
- Billable metrics: memory.events_ingested.used, memory.predictions.used
- Features + privileges catalog (memory.subjects, memory.events_ingested, etc.)
- Plans: memory-dev, memory-team, memory-business, memory-enterprise
- Plan entitlements + entitlement values from the spec

Idempotent — re-running after success is a no-op. Existing entitlement values
are updated in-place (so you can bump quotas without touching subscriptions).
`dry_run` mode prints intended actions and rolls back the transaction.

Feature codes + privilege codes are the wire contract with memory.thinkfleet.ai:
see packages/server/api/src/app/chatbot/agent-memory/billing/memory-entitlements.ts
in the memory-thinkfleet repo for the consumer side.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@rrader26
rrader26 merged commit 3e85def into main Jun 10, 2026
2 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants