Repository navigation
Closed
Description
Goal
An integrator or the web page asks for a suggestion with one HTTP call and gets either the suggestion or a JSON error with a code. The service refuses to start with an invalid knowledge base. This is task T7 in specs/001-reply-and-upsell/tasks.md.
Acceptance criteria
-
create_app(kb: KnowledgeBase | None = None, client: ModelClient | None = None)insrc/reply_assistant/app.py. With both given, the application uses them and reads no settings. With either missing, it readsSettingswhen it starts, loads the knowledge base fromsettings.kb_pathand buildsOpenAICompatibleClient.from_settings(settings)for what is missing. - An invalid knowledge base stops the start with the
KnowledgeBaseErrorof the loader, which names the field (R4). -
POST /api/suggesttakes{"message": "..."}, validated bySuggestionRequest, callssuggestand returns theSuggestionas JSON (R18, R7). - Every error is a JSON object with exactly the keys
codeandmessage(R21): an invalid body gives 422invalid_request;SuggestionRejectedErrorgives 502suggestion_rejectedwith a message that names the check; aProviderErrorof kindtimeoutgives 504provider_timeout; any otherProviderErrorgives 502provider_error. The application writes the message itself: the text of a provider error never reaches the response. -
GET /healthkeeps its answer. Theclientfixture intests/conftest.pybuilds the application from the English example andFakeModelClient([])oftests/acceptance/fakes.py, so the health tests read no settings. - The acceptance tests in
tests/acceptance/test_api.pypass with thepytestmarkline removed. - Every command from Commands in
AGENTS.mdpasses, and the pull request names the defect behind each new test.
Specification
specs/001-reply-and-upsell/spec.md, requirements R4, R18 and R21.
Files in scope
src/reply_assistant/app.pytests/conftest.pytests/test_app.py, new, only for behaviour the acceptance tests do not covertests/acceptance/test_api.py, thepytestmarkline only
Out of scope
- The web page (T8), the CRM webhook (T10) and the second provider (T9).
- Any new dependency.
Acceptance test
tests/acceptance/test_api.py
Metadata
Metadata
Assignees
Labels
No labels
Activity
test: acceptance tests for the web page (#31)
test: acceptance tests for the suggest endpoint (#30)
test: acceptance tests for the web page (#31)