feat(thinkfleet-memory): seed plans + entitlements via Rake task - #3
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lib/tasks/thinkfleet_memory.rakewith one idempotent task that provisions the four ThinkFleet Memory tiers, their billable metrics, features (+ privilege catalogs), entitlements, and athinkfleet-memorybilling entity for customer isolation.bin/rails 'thinkfleet_memory:seed[<organization_id>]'. Append,dry_runto preview without persisting.find_or_create_bykeyed bycode. 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-memorywhile 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>/entitlementsto gate features and enforce limits.What gets created
Privilege values per plan match the spec at `docs/memory-plan-spec.md` in the memory-thinkfleet repo.
Test plan
After merge
🤖 Generated with Claude Code