Cost surface — where the money actually goes cost surface~$1.50/day

~$1.50/day · CostCapDO daily AI cap · most CF services free-tier

Where the money actually goes. AI spend is the largest variable cost (Council v2 chat ~$0.007/query × 50-200 queries/day = $0.35-1.50). Cloudflare per-request services (Workers, Queues, DOs, Workflows) within or just above free tier. Storage (D1, R2, KV, Vectorize) within free tiers. NetSuite API calls included in the NS account. CostCapDO is the gatekeeper that caps daily AI spend so a bug can't burn the budget.

0 · Visual flow 6 lanes · 16 nodes

System flow
01 / Variable AI spend (caps + caps-checked) 02 / NetSuite + integrations (rate-limited) 03 / Cloudflare per-request (workers + queues + DOs + workflows) 04 / Storage (D1, R2, KV, Vectorize) 05 / CostCapDO gatekeeper (caps daily AI spend) 06 / Total cost surface (estimated $/day) Each chat turn: Claude Sonnet lead + Kimi (free) + Llama (Workers AI, ~$0.0001) + Claude chairman synthesis ≈ $0.007. Volume from chat_decision_audit COUNT(*) WHERE date. COST: council_v2_chat per_query: ~$0.007 components: Claude lead $0.003 + Kimi $0 + Llama $0.0001 + Claude chairman $0.003 volume: ~50-200 queries/day i Council v2 chat ~$0.007/query gated by CostCapDO Training loop grader. Claude Haiku grades 5 questions × 6 runs/day. Total: ~$0.015/day. COST: haiku_grader per_run: ~$0.0005 × 5 questions daily: ~6 cron ticks total: ~$0.015/day i R285 Haiku grader ~$0.0005/run · 6 runs/day gated by CostCapDO Nightly wiki rebuild. Claude Haiku distills 24h of activity → docs/SYSTEM_WIKI.md. ~$0.05/day. COST: wiki_rebuild per_run: ~$0.05 daily: 1 run total: ~$0.05/day i R84 wiki rebuild ~$0.05/run · 1 run/day gated by CostCapDO Workers AI embedding (Vectorize) + classifier (out-of-scope guard). ~$0.005/day combined. COST: cron_ai per_day: ~$0.005 uses: embeddings (Vectorize), classifier (out-of-scope guard) i Cron AI calls misc embed + classify gated by CostCapDO Cron-driven syncs hit the custom RESTlet customscript_gfs_platform_query via TBA OAuth1. Rate-limited per NS account; we stay under by tiering. COST: ns_suiteql endpoint: customscript_gfs_platform_query calls_per_day: ~1500 rate_limit: 10/sec sustained billing: included in NS account i NS SuiteQL calls ~1500/day · TBA OAuth1 Cloudflare Browser Rendering used for PDF screenshots + spec sheet rendering. ~30 invocations/day. ~$0.01/day. COST: browser_rendering invocations: ~30/day per_call: ~$0.0003 total: ~$0.01/day i Browser Rendering PDF screenshots CF Email Routing: inbound message events (free) + outbound send via API (~$0/email free tier). COST: email_routing inbound: free outbound: free up to N/month current: well within free tier i Email Routing inbound + outbound Worker invocations. Free tier covers 100k/day. We're under except spike days. $0.30 per million after. COST: workers free_tier: 100k requests/day paid_rate: $0.30/million after current_volume: ~80k/day i Workers compute free 100k/day + paid NS_PUSH_QUEUE + NS_PUSH_QUEUE_DLQ. Within Queues free tier (1M messages/month). COST: queues free_tier: 1M messages/month current_volume: ~30k/month i Queues NS_PUSH_QUEUE + DLQ AnnualRollWorkflow (Pillar 4) Workflow class - durable execution; paid per step. CostCapDO + PushMutexDO durable objects. COST: workflows_dos AnnualRollWorkflow: ~$0.10 per full run (annual) DOs: CostCapDO + PushMutexDO per_request: $0.15/million i Workflows + DOs AnnualRollWorkflow + DOs 162 D1 tables, ~311k rows. Within D1 free tier (5GB storage, 5M reads/day, 100k writes/day). COST: D1 tables: 162 rows: ~311,000 storage: ~250MB (within free) reads: ~3M/day writes: ~50k/day i D1 162 tables · 311k rows KV used for query cache, kill-switch flags, mutex locks. Within free tier (100k reads/day, 1k writes/day). COST: KV free_tier: 100k reads/day, 1k writes/day uses: query cache, kill-switches, mutex i KV cache + flags R2 storage: nightly D1 backups (~250MB compressed × 30 days), spec sheets, raw emails, PDF attachments. Within free tier. COST: R2 storage: ~10GB cost: ~$0.15/month (well within free 10GB) contents: nightly backups, spec sheets, raw emails i R2 source docs + backups + specs ns_knowledge index with 3,360 chunks. Insert cost paid one-time at chunk ingest. Query cost per topK ~$0.0000004. Negligible. COST: Vectorize indexes: ns_knowledge (3,360), decision_corpus, suiteql_corpus insert_cost: ~$0.01 one-time per 1k vectors query_cost: ~$0.0000004/topK i Vectorize 3,360 chunks (R555) Durable Object that tracks cumulative AI spend per day. Every AI call increments via CostCapDO.increment(cost_usd). When daily cap exceeded, subsequent calls are short-circuited (chat falls back to deterministic tools-only mode). CAP: CostCapDO type: Durable Object scope: per-day cumulative daily_cap: configurable via env.AI_DAILY_CAP_USD failure_mode: chat fallback to tools-only i CostCapDO durable object · daily AI budget enforcement Halts AI calls when daily cap reached Rough daily total assuming 100 chat turns + scheduled cron load. Most CF services within free tier; main variable is Council v2 chat volume. ESTIMATE: total AI: ~$0.50/day CF compute + queues: ~$0.20/day storage (D1 + KV + R2 + Vectorize): ~$0.30/day NS: included in NS account total: ~$1.50/day = ~$45/month i Estimated total: ~$1.50 / day at current volume AI ~$0.50 · CF compute + queues ~$0.20 · storage ~$0.30 · NS included sub-$50/month — well below typical SaaS spend

1 · Cost centers ranked top spend → tail

RankCenterEst $/dayCap
1Council v2 chat (Claude + Kimi + Llama)$0.50CostCapDO
2CF Workers compute (after free tier)$0.15
3D1 reads/writes$0.05within free tier
4R2 storage (backups + docs)$0.05within free tier
5Wiki + grader Haiku$0.07CostCapDO
6Workflows + DOs$0.02
7Browser Rendering$0.01
8Vectorize~$0.001
9Queues$0free tier
10KV$0free tier
11NS API calls(included)
Totalfull stack~$1.50/day~$45/month

2 · CostCapDO — the gatekeeper

CostCapDO is a Durable Object that tracks cumulative AI spend per day across the entire platform. Every AI call (chat council, grader, wiki rebuild) increments via CostCapDO.increment(cost_usd). When the daily cap is exceeded, subsequent AI calls short-circuit and chat falls back to deterministic tools-only mode (no LLM call).

Daily cap is configurable via env.AI_DAILY_CAP_USD. Default in development: $5/day. Production: unlimited (cap relied on as soft signal + alerting only).

3 · How to read it

ColorMeaning
frontendUser-facing surface (chat UI, admin HTML pages)
backendWorker logic / agent code / business rules
databaseD1 table / R2 object / KV key / Vectorize index
cloudExternal system (NetSuite, Anthropic, etc.)
securityGate / policy / HITL approval / kill switch
messagebusEvent ledger, Queues, async fan-out
externalInbound source (email, webhook, cron tick, user input)
→ solidSynchronous call (request → response)
→ greenApproved / happy-path
→ red dashedPolicy or security check
→ grey dashedOptional / conditional / async