Verify the AI dating path against the live Anthropic API #136
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
#3 built the whole AI dating path —
ClaudeVisionBackend, the structured-output schema, the Pydantic semantic validation, theapi_usage_logcost ledger, the daily/monthly budget ceilings, and theai_analysisjob handler. All of it is covered by tests, but every one of those tests uses a mocked SDK.TestAgainstTheRealAPIinbackend/tests/test_ai_backend.pyis the one place a real, billable call would be made, and it skips itself when no key is configured. No key has been configured, so the live path has never run.That is a deliberate position rather than an oversight: there is no Anthropic key set up for this project yet, and the rest of the work was worth finishing first. This issue exists so the gap is recorded rather than remembered.
What has and has not been proven
Proven, against a stub: the job lifecycle, evidence writing, reliability mapping from confidence, the budget check running before the call, the spend ledger recording failures and refusals as well as successes, permanent-vs-retryable failure classification, image downscaling through the #65 sandbox, and that a malformed estimate never reaches a date column.
Not proven, because it needs the real service:
output_config.formatschema, image block encoding,max_tokensstop_reason, the structured-output payload, and the refusal pathapi_usage_log.cost_usdis computed fromCIRCA_AI_INPUT_PRICE_PER_MTOK/CIRCA_AI_OUTPUT_PRICE_PER_MTOKagainst usage numbers no real response has ever suppliedThe third is the one with teeth: the budget ceilings (§5.5, $5/day and $30/month) are a sum over
api_usage_log, so if the cost arithmetic is wrong the ceiling is wrong, and it fails in the expensive direction without saying anything.How to verify
Then end to end through the worker, which is what actually exercises the ledger:
Done when
TestAgainstTheRealAPIruns (not skips) and passesai_analysisjob completes end to end against the real APIapi_usage_logholds a row whoseinput_tokens/output_tokens/cost_usdare checked by hand against the provider's own reported usage for that callReferences
backend/app/services/ai_claude.py,ai_budget.pybackend/app/workers/handlers/ai_analysis.pybackend/tests/test_ai_backend.py(TestAgainstTheRealAPI, marked@pytest.mark.network)009_api_usage_log.pydocs/circa-spec.md§5.5 (budgets), §10.1 (reliability)Deferred until a key is set up and live deployment is in scope. Nothing else depends on it:
CIRCA_AI_BACKEND=mockexercises the whole path for free, andautorefuses AI jobs with a clear message when no key is present.