type: meta

slug: dev-mock-translation-provider

base_branch: master

gate0_mode: strict

preset: medium


type: goal

text: Add credential-selected deterministic mock translation to production-hosted API and worker without exposing a client-controlled provider selector.


type: methodology

text: TDD; additive schema migration; persisted trust state; event-driven assertions; exactly-once terminal accounting; strict lint, build, unit, integration, and E2E gates.


type: intent

text: Produce fast, repeatable translation tests for all lifecycle and provider outcomes without Gemini traffic, sleeps, production credential risk, or cross-test contamination.


type: direction

verbatim: need to create a dev mock provider with a mock translator, with all required states for testing, just to simulate for testing.


verbatim: its not jsut opt-in only, it must be secure since its a prod backend, and it must know dev calls somehow to know to give mock response with mock provider, it must be robust and simple, to be able to get real good and fast test results


type: task

seat: coder

tier: medium

desc: Read docs/plans/2026-08-01-dev-mock-translation-provider.md Task 1 (Persist credential mode and job scenario) for the full contract. Add backward-compatible license/job execution mode and scenario persistence. Acceptance: cd api && npx prisma validate && npx prisma generate && npm run build. Commit only: api/prisma/schema.prisma api/prisma/migrations/20260801120000_add_translation_execution_mode/migration.sql.


desc: Read docs/plans/2026-08-01-dev-mock-translation-provider.md Task 2 (Secure mock-license issuance and auth context) for the full contract. Restrict mock credentials and propagate trusted stored mode. Acceptance: cd api && npm test -- --runInBand src/__tests__/unit/middleware/licenseAuth.test.ts src/__tests__/unit/routes/adminLicenses.test.ts src/__tests__/unit/services/multilingualLicenseService.test.ts. Commit only: api/src/types/index.ts api/src/middleware/auth.ts api/src/routes/admin/licenses.ts api/src/services/multilingualLicenseService.ts api/src/__tests__/unit/middleware/licenseAuth.test.ts api/src/__tests__/unit/routes/adminLicenses.test.ts api/src/__tests__/unit/services/multilingualLicenseService.test.ts.


desc: Read docs/plans/2026-08-01-dev-mock-translation-provider.md Task 3 (Add provider contract and Gemini adapter) for the full contract. Add typed provider seam while preserving Gemini models and behavior. Acceptance: cd api && npm test -- --runInBand src/__tests__/unit/services/translationProvider.test.ts src/__tests__/unit/services/geminiThinkingTokens.test.ts. Commit only: api/src/services/translationProvider.ts api/src/services/geminiTranslationProvider.ts api/src/services/geminiClient.ts api/src/__tests__/unit/services/translationProvider.test.ts.


desc: Read docs/plans/2026-08-01-dev-mock-translation-provider.md Task 4 (Build deterministic mock provider and Redis store) for the full contract. Implement provider selection, eight scenarios, and cross-process gates without sleeps. Acceptance: cd api && npm test -- --runInBand src/__tests__/unit/services/mockTranslationStore.test.ts src/__tests__/unit/services/mockTranslationProvider.test.ts. Commit only: api/src/services/translationProvider.ts api/src/services/mockTranslationStore.ts api/src/services/mockTranslationProvider.ts api/src/__tests__/unit/services/mockTranslationStore.test.ts api/src/__tests__/unit/services/mockTranslationProvider.test.ts.


desc: Read docs/plans/2026-08-01-dev-mock-translation-provider.md Task 5 (Propagate trusted mode through API service paths) for the full contract. Snapshot credential mode and preserve live/mock accounting parity. Acceptance: cd api && npm test -- --runInBand src/__tests__/unit/services/translationService.test.ts src/__tests__/integration/routes/translate.test.ts src/__tests__/integration/routes/jobs.test.ts. Commit only: api/src/services/translationService.ts api/src/routes/translate.ts api/src/routes/jobs.ts api/src/__tests__/unit/services/translationService.test.ts api/src/__tests__/integration/routes/translate.test.ts api/src/__tests__/integration/routes/jobs.test.ts.


tier: high

desc: Read docs/plans/2026-08-01-dev-mock-translation-provider.md Task 6 (Make worker retries and terminal writes correct) for the full contract. Make retry, cancellation, credits, and webhooks terminal-safe and idempotent. Acceptance: cd api && npm test -- --runInBand src/__tests__/unit/workerProcessors.test.ts src/__tests__/unit/services/creditService.test.ts. Commit only: api/src/worker.ts api/src/services/creditService.ts api/src/__tests__/unit/workerProcessors.test.ts api/src/__tests__/unit/services/creditService.test.ts.


desc: Read docs/plans/2026-08-01-dev-mock-translation-provider.md Task 7 (Add credential-gated mock control API) for the full contract. Add owner-scoped mock job creation, observation, release, and reset. Acceptance: cd api && npm test -- --runInBand src/__tests__/integration/routes/mockTranslator.test.ts. Commit only: api/src/routes/dev/mockTranslator.ts api/src/server.ts api/src/__tests__/integration/routes/mockTranslator.test.ts.


desc: Read docs/plans/2026-08-01-dev-mock-translation-provider.md Task 8 (Prove real API + worker lifecycle without sleeps) for the full contract. Exercise live/mock concurrency and every lifecycle/failure path against isolated PostgreSQL and Redis. Acceptance: cd api && npm run test:e2e -- --runInBand src/__tests__/e2e/mockTranslationLifecycle.test.ts. Commit only: api/src/__tests__/e2e/mockTranslationLifecycle.test.ts api/src/__tests__/e2e/helpers/mockTranslationFixture.ts api/jest.config.js.


desc: Read docs/plans/2026-08-01-dev-mock-translation-provider.md Task 9 (Verify production safety and rollback) for the full contract. Run full clean gates, mixed live/mock probe, kill-switch proof, and rollback compatibility check. Acceptance: cd api && npx prisma validate && npm run lint && npm run build && npm test -- --runInBand. Commit only failure fixes in Task 1-8 file allow-lists.


Paused on explicit user request via /handoff: and stop working. Resume slug dev-mock-translation-provider in worktree /home/user/Projects/Press.zone/wordpress/wp-content/.worktrees/feat-dev-mock-translation-provider/press-zone-backend on branch feat/dev-mock-translation-provider. Landed commits so far: 5ef9e48, 06d6bdca, 591c5679. Task t3 provider boundary/Gemini adapter is still in progress in agent a1a201f6057c0887c; current uncommitted task-3 files include translationProvider.ts, geminiTranslationProvider.ts, and focused tests, with unrelated translationService.ts and worker.ts edits that must be reverted before commit. Latest diagnostic: translationProvider.ts validator has a declared non-void function path that does not return. api/node_modules and generated Prisma client were absent during diagnostics; restore dependencies and run Prisma generation before authoritative tests/build. No mock provider, control API, worker lifecycle tests, final review, landing, deployment, or production verification has completed. Do not claim completion; continue from t3, then t4-t9 in plan order.