Production LTI Read-Only Monitor Pilot

Scope

This pilot restores a daily production monitoring signal without processing the historical ScheduledTask or ScheduledTest backlog. It does not test signing, donating, cancellation, email sending, or donor data synchronization. The existing lti-prod-cron Job remains untouched and unscheduled.

Preflight

  1. Confirm testing.product.citizengo.net still routes to lti-prod and the production runtime uses the lti-prod database. Record service revision, image digest, database instance and Cloud Scheduler inventory without printing secret values.
  2. Review the PR and build Dockerfile.production-monitor with cloudbuild.production-monitor.yaml. The public-service Dockerfile.prod entrypoint runs migrations and creates a superuser, so it must never be reused for this read-only Job. Keep the Job separate from the legacy production cron. Do not copy acceptance credentials or flags. Build with gcloud builds submit --config=cloudbuild.production-monitor.yaml --substitutions=_IMAGE_TAG=<reviewed-sha>. The candidate image must be pinned by digest when the Job is created.
  3. Configure only the production LTI DB, production Salesforce JWT and Django application secrets needed by the command. Use the existing Cloud SQL attachment. Set LTI_TARGET_ENVIRONMENT=production, LTI_PROD_MONITOR_DB_HOST to the exact verified DB host, and leave LTI_PROD_MONITOR_ENABLED=false initially. The production JWT was bound to a deactivated human user in October 2026. Do not reactivate that user or rotate the still-valid app certificate as a blind fix. Provision a dedicated Salesforce Integration user with the Minimum Access - API Only Integrations profile and only the permission needed for the read-only User ID query. The Organization query requires broader Setup visibility for this identity, so do not grant it just for a health check. Preauthorize that identity for the existing production LTI External Client App. Rebind only the production LTI JWT username for the initial probe; rotate the app certificate and paired Secret Manager private key only as a coordinated change after identifying every consumer and a rollback path. Keep sandbox and other services separate. Pin LTI_PROD_MONITOR_SF_ORG_ID and LTI_PROD_MONITOR_SF_USER_ID from the independently approved Salesforce org and dedicated integration-user record. Never copy them from the JWT response being tested. The monitor compares the trusted token response identity before making a query and reads only that user's ID. Existing deployments without these pins will fail closed after this upgrade; configure the approved pins before the manual probe.
  4. Configure the Job as one task, one worker, 120-second timeout, zero retries. Retain the monitor image's python manage.py run_production_readonly_monitor entrypoint; do not override it with a shell or the public-service entrypoint.
  5. Run --inventory first. Retain only the sanitized aggregate output and execution link. The pending rows remain preserved and excluded.

Command-only environment contract

Dockerfile.production-monitor selects main.settings_production_monitor. Remove any Job-level DJANGO_SETTINGS_MODULE=main.settings_cloudrun override when upgrading; keep web-service settings unchanged. Do not inject Asana, SMTP, Selenium, DonUI, FRAPI or other journey configuration into this Job.

Variable Required value/source
DJANGO_SECRET_KEY Secret Manager application key
DB_NAME lti-prod
DB_USER, DB_PASSWORD Existing approved production LTI DB identity; password from Secret Manager
DB_HOST, DB_PORT Verified Cloud SQL socket/host and PostgreSQL port
LTI_TARGET_ENVIRONMENT production (no default)
LTI_PROD_MONITOR_DB_HOST Independently verified exact DB host
LTI_PROD_MONITOR_ENABLED Exactly true only during approved bounded activation; default false
LTI_PROD_MONITOR_EXPIRES_AT Aware ISO timestamp, future and within 48 hours, for health cycles
LTI_PROD_MONITOR_SF_ORG_ID, LTI_PROD_MONITOR_SF_USER_ID Approved case-sensitive 15-character or checksum-valid 18-character IDs; health cycles only
SALESFORCE_PROD_AUTH_MODE jwt; health cycles only
SALESFORCE_PROD_AUTH_USERNAME Approved integration identity; health cycles only
SALESFORCE_PROD_AUTH_JWT_CLIENT_ID, SALESFORCE_PROD_AUTH_JWT_PRIVATE_KEY Existing production JWT app credentials from Secret Manager; health cycles only
SALESFORCE_PROD_AUTH_JWT_LOGIN_URL https://login.salesforce.com (default); no alternative login host/path
CLOUD_RUN_JOB Cloud Run injected lti-prod-readonly-cron; do not override
CLOUD_RUN_EXECUTION Cloud Run injected execution identifier
LTI_DEPLOY_SHA Optional reviewed commit for traceability

Missing/malformed identity, wrong org/user, redirects or a different returned User ID cannot pass. No identity endpoint call or Organization/Setup permission is added. The identity URL is part of the trusted Salesforce JWT token response: JWT flow, identity URL format.

Before deployment run python manage.py test test_interface.tests_production_health --settings=main.settings_ci, build the monitor image, then run python scripts/check_production_monitor_bootstrap.py <local-image-tag>. The latter uses only synthetic documented values, Docker --network none and the real entrypoint. It requires a sanitized disabled-gate exit with both checks not_run; it cannot connect to providers. CI performs the same container check. These tests do not substitute for the separately approved manual Cloud Run probe.

Bounded activation

Set LTI_PROD_MONITOR_ENABLED=true and a timezone-aware LTI_PROD_MONITOR_EXPIRES_AT within 48 hours after explicit approval. Execute the Job manually once. Confirm two passed checks, correct production DB and Salesforce JWT identity (including a successful non-mutating User ID read), aggregate backlog counts, no queue-row updates, and no external mutation. A zero recent legacy-test count means missing journey coverage, not a passing journey.

Only after that manual result, create a separate Cloud Scheduler trigger for 08:00 America/Belize daily. Observe the next scheduled execution and retain its Scheduler attempt and Cloud Run execution separately from the manual run. Do not point the trigger at lti-prod-cron or resume any old trigger.

Weekly evidence and email

Each week, summarize the seven-day aggregate counts and the actual daily Job executions in the restricted Asana task. Distinguish missed, failed, blocked and passed read-only cycles. Email report delivery remains paused; the old Email Reports task is not run. Authorize a sender and recipients separately before adding any outbound delivery. An Asana summary is not proof of email delivery.

Stop and rollback

Pause the new Scheduler trigger on auth failure, wrong database/Job, unexpected mutation, missing execution, excessive queue growth, or timeout. The approval expiry causes future invocations to fail closed but does not pause Scheduler; an operator must pause it before expiry to avoid repeated failures. Rollback is pause trigger, let the bounded execution end, then disable the new Job. Do not start lti-prod-cron, replay pending rows, or delete history as rollback.