{
 "id": "13.3",
 "title": "Spend caps",
 "department": "Finance",
 "department_slug": "finance",
 "direction": null,
 "branded": false,
 "status": "draft",
 "owner": "Param",
 "last_verified": "Mon Oct 26",
 "holds": "Every cap in the product, and why",
 "urls": {
  "html": "https://handbook.joinsquareup.com/finance/spend-caps",
  "markdown": "https://handbook.joinsquareup.com/finance/spend-caps.md",
  "json": "https://handbook.joinsquareup.com/finance/spend-caps.json"
 },
 "other_directions": [],
 "tldr": {
  "headline": "Every tripwire that stops Brew spending too much, and where it lives",
  "points": [
   {
    "icon": "lock",
    "text": "Production sets most caps in one place, tools/prod-env.sh."
   },
   {
    "icon": "money",
    "text": "Daily caps: treg $40, first builds $250, pictures about $58 at worst."
   },
   {
    "icon": "people",
    "text": "One brand may use only a third of each daily cap."
   },
   {
    "icon": "check",
    "text": "Every paid make needs a confirmed price before it runs."
   },
   {
    "icon": "warn",
    "text": "Code default build cap is $60 but production runs $45."
   }
  ],
  "stat": {
   "value": "250",
   "label": "first builds cap, USD"
  },
  "decide": "Set a monthly ceiling of $50 a brand across all sources during the partnership?",
  "mood": "solid"
 },
 "sources": [
  "brew origin/main a559de6: tools/prod-env.sh:9, deploy.sh:21 and 41, build.js:113-115 and 1069-1076, budget.js:12-16, rewrite-pot.js:14-24 and 71, drafts-bg.js:13 and 142, moves-cadence.js:406, social-feed.js:274, listen-watch.js:10 and 684, market-pulse.js:318, brand-enrich.js:9, treg.js:45 and 82, shelf.js:6 and 69, apify.js:4 and 42, server.js:564-566, jam2/routes.js:238 and 310-317",
  "memory: brew-pro-switch-and-flush, brew-connect-refresh, brew-move-freshness, brew-sloosh-finals, brew-viral-remakes, brew-apify-watch, treg-usage-rules"
 ],
 "open_questions": [
  "**Is $250 a day of first builds right for production?** Proposal: keep it; five partners at $45 a build fit, and a new brand waits a day past that.",
  "**The build cap default in code is $60 but production runs $45.** Proposal: set the code default to $45 so a missing env var never spends more.",
  "**A monthly ceiling per brand.** Proposal: $50 a brand a month across all sources during the partnership, raised only by Param."
 ],
 "parts": {
  "Answer": "Every limit in Brew that stops money being spent, its value on production, its default in the code and why it exists; production sets most of them in one place, `tools/prod-env.sh`.",
  "Today": "### Whole server, per day\n\n| Cap | Production | Code default | What it stops | Source |\n|---|---|---|---|---|\n| `TREG_DAY_CAP_USD` | $40 | $25 | All outside data calls through treg in a day, across instances | [src: brew/tools/prod-env.sh:9] [src: brew/treg.js:45] [src: brew/treg.js:82] |\n| `DAILY_BUILD_CAP_USD` | $250 | $200 | All first builds of Plays in a day, across brands | [src: brew/tools/prod-env.sh:9] [src: brew/build.js:114] |\n| `DAILY_TEXT_CAP` | 1,500 units | 400 | AI writing calls in a day | [src: brew/tools/prod-env.sh:9] [src: brew/budget.js:13] |\n| `DAILY_IMAGE_CAP` | 1,500 | 60 | Pictures in a day; about $58 at worst on Flash | [src: brew/tools/prod-env.sh:9] [src: brew/budget.js:13] [src: brew/deploy.sh:21] |\n| `DAILY_VIDEO_CAP` | 60 | 15 | Videos in a day | [src: brew/tools/prod-env.sh:9] [src: brew/budget.js:13] |\n| `DAILY_VOICE_CAP` | not set, so 60 | 60 | Voice clips in a day | [src: brew/budget.js:13] |\n| `DAILY_CREDITS_CAP` | not set, so 300 | 300 | Sloosh credits for finals in a day | [src: brew/budget.js:13] [src: memory brew-sloosh-finals] |\n\n### Per brand\n\n| Cap | Production | Code default | What it stops | Source |\n|---|---|---|---|---|\n| Brand share of each daily cap | a third | a third, `DAILY_BRAND_SHARE` | One brand using the whole day | [src: brew/budget.js:14-15] |\n| `BRAND_VIDEO_CAP` | 20 a day | a third of the video cap | Videos for one brand | [src: brew/tools/prod-env.sh:9] |\n| Pictures kept for the team | 40 a day | `BG_RESERVE_IMAGE` 40, video 8, voice 10 | Background drafts using the team's last pictures | [src: brew/server.js:564-566] |\n| `BUILD_CAP_USD` | $45 a build | $60 | One brand's first build of every Play | [src: brew/tools/prod-env.sh:9] [src: brew/build.js:113] |\n| Pro brand build | $150 | the larger of $150 and 2.5 times the build cap | A brand marked Pro | [src: brew/build.js:115] |\n| `BRAND_WEEK_CAP_USD`, the rewrite pot | $40 a week on Pro Plays | $10 Flash, $40 Pro, $50 Claude | Weekly rewrites that keep Plays fresh | [src: brew/rewrite-pot.js:20-21] [src: brew/rewrite-pot.js:71] |\n| `CONNECT_CAP_USD` | $40 a run | $40 | Rewrites after a first connected account | [src: brew/build.js:1070] [src: memory brew-connect-refresh] |\n| `LEARN_CAP_USD` | $30 an upload | $30 | Rewrites after a learnings drop | [src: brew/build.js:1075] |\n| `LIVE_CAP_USD` | $30 a run, weekly | $30 | Rewrites after connected numbers move 10% | [src: brew/build.js:1076] [src: memory brew-move-freshness] |\n| `REFRESH_CAP_USD`, `REFRESH_AUTO_CAP_USD` | $60 by hand, $10 automatic | same | A site check refresh | [src: brew/build.js:1069] |\n| `DRAFTS_DAY_CAP_USD` | $4 a day | $4 | Background first drafts | [src: brew/drafts-bg.js:13] [src: brew/drafts-bg.js:142] |\n| `MOVES_WEEK_CAP_USD` | $3 a week | $3 | Weekly listening, automation and learn Plays | [src: brew/moves-cadence.js:406] |\n| `SOCIAL_DAY_CAP_USD` | $3 a day | $3 | Listening and the ideas stream | [src: brew/social-feed.js:274] |\n| `APIFY_BRAND_MONTH_CAP_USD` | $10 a month | $10 | Apify scrapers for one brand | [src: brew/tools/prod-env.sh:9] [src: brew/shelf.js:69] |\n\n### Per run\n\n| Cap | Value | What it stops | Source |\n|---|---|---|---|\n| `LISTEN_RUN_CAP_USD` | $0.60, lite $0.15 | One listening run | [src: brew/listen-watch.js:684] [src: brew/social-feed.js:274] |\n| `PULSE_CAP_USD` | $3 | One market pulse run | [src: brew/market-pulse.js:318] |\n| Brand Book enrichment | $0.50 | One enrichment run | [src: brew/brand-enrich.js:9] |\n| Apify `maxTotalChargeUsd` | per actor, such as $0.45 for Trustpilot | One scraper run | [src: brew/apify.js:4] [src: brew/apify.js:42] |\n\n### Paid makes\n\n| Rule | Source |\n|---|---|\n| Every Studio make, redo, extend and final needs a confirmed price; a higher price than confirmed stops the make | [src: brew/jam2/routes.js:238] [src: brew/jam2/routes.js:310-317] |\n| Sloosh's own daily agent limit, raised from 50 to 200 credits on 21 Oct; a brand's share of finals is 100 credits a day | [src: memory brew-viral-remakes] [src: brew/budget.js:13-15] |",
  "Tomorrow": "| Item | Version | Tag |\n|---|---|---|\n| Every cap above | v1 | Stays |\n| One monthly ceiling per brand across every source | v1 | New, proposed in [cost per brand](/ai-and-models/cost-per-brand) |\n| Caps follow the brand's plan once pricing exists | v1, after pricing | Changes |\n| Ad spend caps the owner sets per area and channel | v4 | New |",
  "How we do it": "1. Change a production cap only in `tools/prod-env.sh`, with a comment saying why, then promote.\n2. Before moving Plays to a dearer model, raise the caps that follow it: `BUILD_CAP_USD`, `BRAND_WEEK_CAP_USD` [src: memory brew-pro-switch-and-flush].\n3. Any new paid call gets three things: a cap in env, a per brand share and a tag that books it to the brand.\n4. When a cap is hit, the product says so in plain words and carries the work to the next day; it never fails silently.\n5. Check the treg balance live before blaming treg for a stop [src: memory treg-usage-rules].",
  "Numbers": "| Metric | Definition | Where measured | Status |\n|---|---|---|---|\n| Cap hits a week | Times any cap stopped work, by cap | Server logs and ops alerts | Proposed |\n| Worst case daily spend | Sum of the daily dollar caps | This page | Proposed: about $348 from treg $40, builds $250 and pictures about $58, before per brand caps |",
  "Open": "1. **Is $250 a day of first builds right for production?** Proposal: keep it; five partners at $45 a build fit, and a new brand waits a day past that.\n2. **The build cap default in code is $60 but production runs $45.** Proposal: set the code default to $45 so a missing env var never spends more.\n3. **A monthly ceiling per brand.** Proposal: $50 a brand a month across all sources during the partnership, raised only by Param."
 }
}