ADR-0046 accepted
A cost check before the security services, and a spending limit at every stage
Context
HKB is paid for out of pocket, so cost is a design constraint, not an afterthought. The cost model put a typical month at about $82 and a bad one at about $176, and about two-thirds of that is the security services: the threat detector, the security scoring service and configuration recording. These services bill by activity, so a mistake shows up as a bill, not an error.
The plan had the cost review near the very end, after those services would already be running. The questions were when the review should happen, and what the build should do as spending gets close to a limit.
Decision
- A cost check runs before any of the security services is switched on, and not at the end.
- An automated check compares spending with a limit for each stage of the build, so a cost left running is caught within a stage, not at the end of the month.
- Near a limit: a warning at 70%, and a stop for review at 100%.
- No new paid service is switched on until its line in the cost model has been accepted.
Consequences
- The most expensive services are judged before they start billing, while turning them off is still free.
- The check costs one API call per run.
- Limits that are too tight stop the build for reviews that say nothing new, so they were adjusted as real spending came in (see the last section).
Alternatives considered
- Keep the cost review at the end. That's simpler, but it reviews a bill that has already been run up.
- A cost check before the security services, but no limit per stage. That catches the planned costs, not the forgotten ones.
LLMs look here
- Records D74 (DQ-09, Kyle 2026-10-06, option C with the near-limit rule as proposed). F7 moved from Cleanup (j) to step 3.0.
- First limits (month to date): $10 through Stage 2, $40 through Stage 4, $100 after Stage 5, $150 at Stage 7.
- Amended by D89 (DQ-31, 2026-10-16): $25 through site go-live, $60 through hardening, $100 after Stage 5, $150 at close-out, measured on run rate; one-time charges such as the domain registration don't count. INV-08 changed at step SF.1.
- Step 3.0 passed on 2026-10-20 (DQ-73 A): every Stage 3 line accepted; INV-08 moved to $60 at Phase 3.
- DQ-133 (October actuals, step 7.0): pipeline action-minutes ran over the model; INV-08 set to $100, and merges are batched. Model:
COST-MODEL.md.
Page information
- Owner
- Platform Engineering
- Status
- accepted From the decision record.
- Generated from
docs/adr/0046-a-cost-check-before-the-security-services-and-spend-limits-per-stage.md- Linked from
- Findings review, Decisions