flowstate-flowstate-platform-epicdm-platform-db
Package-local agent skill for @epicdm/platform-db.
Tags
Publisher
Versions
1 version published — latest: 0.1.0
- 0.1.0publishedInvalid Date
Skill
platform-db Package Skill
Package: @epicdm/platform-db
Repository: flowstate-platform
Path: packages/shared/platform-db
Version: 0.1.0
Use this published Dojo skill as the package-level entrypoint. For detailed workflows, use the package-local skills listed below.
Primary Package Workflow
Platform DB Billing Credits
Status: Active
Purpose: Preserve billing credit math and D1 query contracts.
Scope: packages/shared/platform-db/src/credit-math.ts, src/schema-billing.ts, and src/queries/billing.ts
Trigger: Credit conversion, rate lookup, top-up, usage aggregation, or notification work.
Input: Event type, amount in cents or credits, timestamp, tenant ID, and query requirements.
Output: Correct credit math and tested billing query behavior.
Workflow
- Use
usdcToCredits(amountCents)for cent-to-credit conversion; it rejects negative amounts. - Use
creditsToUsdc(credits)when converting back to cents; it floors fractional cents. - Use
lookupRate(rates, eventType, timestamp)to select the active rate with the latesteffectiveFrom. - Use
prorateStorage(bytes, intervalMs, creditsPerMbMonth, monthMs)for storage intervals. - For persisted billing behavior, update
src/schema-billing.tsandsrc/queries/billing.tstogether. - Verify with the billing test files, not only generic schema tests.
Contracts
| Contract | Detail |
|---|---|
| Rate constant | CREDITS_PER_USDC = 100 credits per USDC cent |
| Active rate | effectiveFrom <= timestamp and effectiveTo is null or greater than timestamp |
| Storage proration | Returns integer credits via Math.floor |
| Amount validation | UsdcAmountSchema accepts non-negative integer strings |
Verification
- Run
yarn workspace @epicdm/platform-db test -- credit-math. - Run
yarn workspace @epicdm/platform-db test -- billing. - Run full
yarn workspace @epicdm/platform-db testbefore handing off schema changes.
Package Skill Inventory
Skill Inventory: @epicdm/platform-db
Package Role
@epicdm/platform-db centralizes FlowState platform D1 schema, typed Drizzle access, validation schemas, ID prefixes, query helpers, and billing credit math.
Skills
| Skill | Type | Use When | Source Backing |
|---|---|---|---|
platform-db-schema-queries | Workflow/reference | Adding or consuming shared D1 schema, IDs, validation, or query helpers. | src/index.ts, src/schema.ts, src/id.ts, src/validation.ts, src/queries/* |
platform-db-billing-credits | Reference/pattern | Working on credits, rates, top-ups, usage aggregation, or billing notifications. | src/credit-math.ts, src/schema-billing.ts, src/queries/billing.ts, billing tests |
Composition Notes
- Compose with worker skills that use platform D1 data.
- Use package queries before duplicating SQL in workers.
- Keep Drizzle schema, migrations, tests, and exported query namespaces aligned.
Review Gate
Review Gate: @epicdm/platform-db Skills
Result
Pass.
Checks
- Skills are source-backed by schema, query, validation, ID, credit math, and tests.
- Inventory separates broad schema/query work from billing credit workflows.
- Verification commands are package-local.
Residual Risk
Schema changes can require Drizzle migrations and downstream worker updates. These skills call out the alignment requirement but do not replace migration review.
Usage
Start with this skill to understand the package purpose, then use the package-local focused skills for specific workflows. Keep this Dojo version aligned with packages/shared/platform-db/package.json. Do not treat generated feature lists as lessons; use workflow evidence from CODE-REVIEW.md, SKILL-INVENTORY.md, and REVIEW.md.
Install
Run this in your project to install via CLI:
fscloud dojo skill install flowstate-flowstate-platform-epicdm-platform-db --target <target> --out ./skillsReplace <target> with your agent target identifier. See the CLI docs for details.