This plan outlines the surgical steps to implement the proactive PDF generation flow described in specs/puppeteer-control-flow.spec.md (v1.5.0).
MANDATORY: All shell actions must be run as ysg user from bnc-cpt-utl/.
Goal: Provision the new service identity, internal secret, and networking.
pdf-api Service Account.objectCreator and objectViewer roles to the pdf-api SA on the reports bucket.bnc-cpt-internal-secret in Secret Manager.pdf-api service (internal-only) and attach it to the existing VPC connector.Prompt 1: Apply the Terraform changes for the PDF-API identity, storage permissions, and internal secrets across all environments.
Goal: Prepare the Vue 3 frontend for "clean" rendering.
ReportContentBasic.vue and ReportContentPro.vue from existing Dashboard components.App.vue to recognize /report/print/:vin and render the Content components without navigation/menus.GET /api/v1/tesla/print-report/{vin} support in the frontend to use the print token.Prompt 2: Refactor the WUI to extract core report content into pure components and implement the headless-ready print route.
Goal: Build the co-located rendering service.
bnc-cpt-api/src/nodejs/pdf-api/ with Express and Puppeteer.X-Internal-Secret middleware./generate endpoint with generic-pool and 3-retry logic.pdf-api to docker-compose-app.yaml and create the production Dockerfile.Prompt 3: Implement the Node.js pdf-api service inside the bnc-cpt-api repository, including the worker pool and retry logic.
Goal: Connect the Python backend to the new rendering pipeline.
pdf:hook:* and pdf:report:* keys.app/services/auth.py.asyncio.create_task call in the Tesla fetch flow to hit pdf-api./api/v1/internal/pdf-render-* endpoints.GET /api/v1/tesla/pdf/{random_id} endpoint.Prompt 4: Integrate the Python backend with the pdf-api, implementing the proactive trigger and the opaque download hook mechanism.
Goal: Ensure data privacy and resource optimization.
cpt-api to scan and delete expired GCS objects and Redis keys.Prompt 5: Implement the 30-minute post-OAuth cleanup task for GCS objects and Redis metadata.
Goal: Ensure end-to-end correctness.
pdf-api failure and verify WeasyPrint fallback.Prompt 6: Perform end-to-end verification of the Puppeteer control flow, including fallback and cleanup scenarios.