Module 02 Activity
Scenario
Before the first real call, set up so that a mistake costs nothing and a leaked key is survivable.
What you build
A reproducible setup with secrets in the environment, a spend ceiling enforced in code, and a test suite that runs with no key.
Steps
- Move every key to the environment. Confirm no key is in any object you log.
- Search your git history for anything resembling a key. If you find one, rotate it first, then worry about the history.
- Cost your feature at realistic volume, including a retry multiplier and a 10x growth case.
- Implement a spend ceiling checked before each call, with a user-facing message when it fires.
- Default the model to a fake so a misconfigured environment fails in tests.
- Clone the repo fresh into a new directory with no environment set and confirm the tests pass.
Evidence to hand in
- Evidence that no key is in a loggable object.
- The history search result and any rotation performed.
- The cost table with both multipliers.
- The spend ceiling and its refusal message.
- A fresh-clone test run with no key.
Review checklist
- Secrets are read into their own variable, never into a config dict.
- Any key found in history was rotated, not just removed.
- The cost estimate includes retries.
- The ceiling is checked before the call, not after.
- The tests pass on a fresh clone with no key set.
