fix(07): revise plans based on checker feedback
This commit is contained in:
@@ -14,6 +14,8 @@ files_modified:
|
||||
- packages/shared/shared/api/templates.py
|
||||
- packages/shared/shared/api/portal.py
|
||||
- tests/unit/test_system_prompt_builder.py
|
||||
- tests/integration/test_language_preference.py
|
||||
- tests/integration/test_templates_i18n.py
|
||||
autonomous: true
|
||||
requirements:
|
||||
- I18N-03
|
||||
@@ -44,6 +46,12 @@ must_haves:
|
||||
- path: "packages/shared/shared/api/templates.py"
|
||||
provides: "Locale-aware template list endpoint"
|
||||
contains: "locale"
|
||||
- path: "tests/integration/test_language_preference.py"
|
||||
provides: "Integration tests for PATCH language preference endpoint"
|
||||
contains: "test_"
|
||||
- path: "tests/integration/test_templates_i18n.py"
|
||||
provides: "Integration tests for locale-aware templates endpoint"
|
||||
contains: "test_"
|
||||
key_links:
|
||||
- from: "packages/shared/shared/prompts/system_prompt_builder.py"
|
||||
to: "AI Employee responses"
|
||||
@@ -59,7 +67,7 @@ must_haves:
|
||||
Backend multilanguage foundation: DB migration, system prompt language instruction, localized invitation emails, and locale-aware templates API.
|
||||
|
||||
Purpose: Provides the backend data layer and AI language behavior that all frontend i18n depends on. Without this, there is no language column to persist, no template translations to display, and no agent language instruction.
|
||||
Output: Migration 009, updated system prompt builder (Python + TS), localized email sender, locale-aware templates API, unit tests.
|
||||
Output: Migration 009, updated system prompt builder (Python + TS), localized email sender, locale-aware templates API, unit tests, integration tests.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@@ -194,11 +202,13 @@ From migrations/versions/ — latest is 008_web_chat.py, so next is 009.
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Localized invitation emails + locale-aware templates API + language preference endpoint</name>
|
||||
<name>Task 2: Localized invitation emails + locale-aware templates API + language preference endpoint + integration tests</name>
|
||||
<files>
|
||||
packages/shared/shared/email.py
|
||||
packages/shared/shared/api/templates.py
|
||||
packages/shared/shared/api/portal.py
|
||||
tests/integration/test_language_preference.py
|
||||
tests/integration/test_templates_i18n.py
|
||||
</files>
|
||||
<action>
|
||||
1. Update send_invite_email() in email.py:
|
||||
@@ -222,15 +232,32 @@ From migrations/versions/ — latest is 008_web_chat.py, so next is 009.
|
||||
- Guard: any authenticated user (get_portal_caller)
|
||||
|
||||
4. Update the verify auth endpoint (/api/portal/auth/verify) to include `language` in its response so Auth.js JWT can carry it.
|
||||
|
||||
5. Create tests/integration/test_language_preference.py (Wave 0 — I18N-02):
|
||||
- Use the existing integration test pattern (httpx AsyncClient against the FastAPI app)
|
||||
- test_patch_language_valid: PATCH /api/portal/users/me/language with {"language": "es"} returns 200 and {"language": "es"}
|
||||
- test_patch_language_invalid: PATCH with {"language": "fr"} returns 422 or 400
|
||||
- test_patch_language_persists: PATCH to "pt", then GET /api/portal/auth/verify includes language="pt"
|
||||
- test_patch_language_unauthenticated: PATCH without auth returns 401
|
||||
|
||||
6. Create tests/integration/test_templates_i18n.py (Wave 0 — I18N-04):
|
||||
- Use the existing integration test pattern (httpx AsyncClient against the FastAPI app)
|
||||
- test_list_templates_default_locale: GET /api/portal/templates returns English fields (no locale param)
|
||||
- test_list_templates_spanish: GET /api/portal/templates?locale=es returns Spanish-translated name/description/persona
|
||||
- test_list_templates_portuguese: GET /api/portal/templates?locale=pt returns Portuguese-translated fields
|
||||
- test_list_templates_unsupported_locale: GET /api/portal/templates?locale=fr falls back to English
|
||||
- test_template_translations_overlay: Verify translated fields overlay English, not replace — English base fields still accessible in DB
|
||||
</action>
|
||||
<verify>
|
||||
<automated>cd /home/adelorenzo/repos/konstruct && python -m pytest tests/unit -x -q</automated>
|
||||
<automated>cd /home/adelorenzo/repos/konstruct && python -m pytest tests/unit -x -q && python -m pytest tests/integration/test_language_preference.py tests/integration/test_templates_i18n.py -x -v</automated>
|
||||
</verify>
|
||||
<done>
|
||||
- send_invite_email() accepts language param and sends localized emails in en/es/pt
|
||||
- GET /api/portal/templates?locale=es returns Spanish-translated template fields
|
||||
- PATCH /api/portal/users/me/language persists language preference
|
||||
- /api/portal/auth/verify response includes user's language field
|
||||
- Integration tests for language preference endpoint pass (4 tests)
|
||||
- Integration tests for locale-aware templates endpoint pass (5 tests)
|
||||
</done>
|
||||
</task>
|
||||
|
||||
@@ -238,6 +265,7 @@ From migrations/versions/ — latest is 008_web_chat.py, so next is 009.
|
||||
|
||||
<verification>
|
||||
- All existing unit tests pass: `pytest tests/unit -x -q`
|
||||
- Integration tests pass: `pytest tests/integration/test_language_preference.py tests/integration/test_templates_i18n.py -x -v`
|
||||
- Migration 009 is syntactically valid (imports, upgrade/downgrade functions present)
|
||||
- system_prompt_builder.py contains LANGUAGE_INSTRUCTION
|
||||
- system-prompt-builder.ts contains LANGUAGE_INSTRUCTION
|
||||
@@ -252,6 +280,7 @@ From migrations/versions/ — latest is 008_web_chat.py, so next is 009.
|
||||
- Templates API merges translations by locale
|
||||
- Language preference PATCH endpoint works
|
||||
- All unit tests pass
|
||||
- All integration tests pass (language preference + templates i18n)
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
|
||||
@@ -15,7 +15,9 @@ files_modified:
|
||||
- packages/portal/components/language-switcher.tsx
|
||||
- packages/portal/components/nav.tsx
|
||||
- packages/portal/lib/auth.ts
|
||||
- packages/portal/lib/auth-types.ts
|
||||
- packages/portal/components/session-sync.tsx
|
||||
- packages/portal/app/(auth)/login/page.tsx
|
||||
autonomous: true
|
||||
requirements:
|
||||
- I18N-01
|
||||
|
||||
Reference in New Issue
Block a user