CORE DIRECTORY // SYSTEM.USER.DIANA_ISMAIL
Labs by Diana — Experiments that ship.
Side projects that got out of hand. AI tools built for problems I kept tripping over — now live, now yours.
Agent Spend Dashboard
MODULE_010
TECHNICAL_OVERVIEW
The attribution gap is structural: shared API keys pool all calls under a single project in the provider's billing console. The Agent Spend Dashboard closes this by instrumenting at the call level. @diabolicallabs/agent-sdk emits a CallRecord on every LLM call - capturing agent name, model, provider, token counts, and a UTC timestamp - and ships it to the dashboard's /api/ingest endpoint. A ±5-minute timestamp window enforces ingestion recency; there is no route for historical backfill, which is an intentional constraint.
The dashboard aggregates CallRecord data by agent identity, model tier, provider, and time range. Recharts surfaces the breakdown: per-agent cost over time, model distribution, and a model-tier compliance audit log that flags any agent operating outside its assigned tier. The schema is backed by Drizzle ORM on Railway Postgres. Diana's twelve-agent fleet - spanning Sonnet, Haiku, and GPT-tier assignments - is the live data source, so the compliance audit runs against real production assignments, not synthetic test data.
Building this made the cost of deferred observability concrete: aggregate data can tell you that spend increased, but not which agent caused it, or why. The gap between “spend is up” and a traceable cause is invisible until you instrument for it - and by the time you need the attribution, there is no retroactive path to get it.
PROJECT_LEARNINGS_LOG
KEY_LEARNING_01
Fleet data fetch was unscoped before PR #12 - all agents' records were returned unfiltered by ownerId. This was invisible in single-owner development and only became a live issue when GEOAudit onboarded as the first cross-project consumer. Multi-tenant isolation that is never exercised is indistinguishable from isolation that does not exist; the schema decision made at scaffold time had a silent blast radius that only landed when the second consumer arrived.
KEY_LEARNING_02
A flat AgentSdkConfig shape produces a silent mis-ingest - identity must be nested inside the config object, not passed at the top level. Correct TypeScript types and passing tests did not catch this structural contract violation; it only surfaced during GEOAudit's integration gate review. The structural contract was in the shape, not the types.
KEY_LEARNING_03
The ±5-minute timestamp window on /api/ingest makes route-based historical backfill architecturally impossible - every integration starts its cost history from the first call after it is wired up. This is an intentional constraint, not an oversight, but it means any assumption about being able to reconstruct prior spend is wrong by design.