← Back to Pull requests

chore(infra): manage every Functions runtime setting in Terraform and Deploy Infra #449

Closed
unknown closed this pull request without merging on Oct 23, 2026 16:27 UTC
View on GitHub
unknown unknown commented on Oct 23, 2026 15:36 UTC
Author

What

Every app setting the Functions code reads is now Terraform-managed and set by Deploy Infra from a GitHub environment variable of the same name.

  • New Terraform variables (infrastructure/variables.tf, default = code default) and Function App app settings (infrastructure/main.tf) for: CAPTURE_FRAME_SWEEP_SCHEDULE, CAPTURE_FRAME_RETENTION_SECONDS, CORS_ALLOWED_METHODS, CORS_ALLOWED_HEADERS, CORS_SUPPORT_CREDENTIALS, GALLERY_MAX_IMAGES_PER_SHADE, HEX_DETECTION_BATCH_MAX_IN_FLIGHT, HEX_DETECTION_CONCURRENCY, HEX_DETECTION_DELAY_MS, HEX_SNAP_MAX_DISTANCE, IMAGE_PROXY_ID_TTL_SECONDS, IMAGE_PROXY_PRIVATE_ID_TTL_SECONDS, IMAGE_PROXY_LEGACY_ID_ACCEPT_UNTIL, INGESTION_AI_IMAGE_PROXY_ORIGIN, INGESTION_JOB_LOG_MAX_ENTRIES, INGESTION_LOG_FLUSH_INTERVAL_MS, INGESTION_WORKER_TIME_BUDGET_MS, ORPHAN_MEDIA_SWEEP_, PG_ pool/retry settings, SHOPIFY_CONNECTOR_, SOURCE_IMAGE_CONTAINER, SOURCE_IMAGE_MAX_EDGE_PX, SOURCE_IMAGE_MAX_DOWNLOAD_BYTES, SUSPICIOUS_HEX_. AZURE_OPENAI_DEPLOYMENT is set to the hex deployment.

  • Deploy Infra (deploy-infra.yml) exports each as TF_VAR_<lowercase name> from vars.<NAME> with the default as fallback, and now also wires the existing Terraform variables it never passed (HEX_DETECTION_BATCH_MIN_IMAGES, INGESTION_JOB_QUEUE_NAME, INGESTION_AI_BATCH_POLL_SCHEDULE, INGESTION_AI_BATCH_MAX_POLL_JOBS, AZURE_OPENAI_BATCH_API_VERSION, AZURE_OPENAI_BATCH_COMPLETION_WINDOW, AZURE_OPENAI_VISION_DETAIL, OPENAI_LABEL_DEPLOYMENT_NAME).

  • CAPTURE_FRAME_SWEEP_SCHEDULE (hourly) / CAPTURE_FRAME_RETENTION_SECONDS (86400, validated 3600–604800) are provisioned ahead of the capture-frame sweep in the bottle recognition design (§9.1); nothing reads them until that code ships.

  • Docs: infrastructure/README.md variable list + table, CLAUDE.md Infra env section, Functions README note; CORS_ALLOWED_METHODS / CORS_ALLOWED_HEADERS added to local.settings.json.example (the code already read them).
  • Left out on purpose: eval/admin-script settings, the NEXT_PUBLIC_ convenience copies, Azure-managed AzureWebJobsStorage / APPLICATIONINSIGHTS_CONNECTION_STRING / WEBSITE_, the deprecated RAW_SNAPSHOT_CONTAINER.

    Rollout

  • The GitHub dev and prod environments already have every new variable at its default (plus AZURE_AD_B2C_TENANT on dev, ALERTS_ENABLED, OPENAI_BATCH_, NEXT_PUBLIC_APPINSIGHTS_SAMPLING). Variables with an empty default stay undefined (GitHub has no empty variables).

  • Live app settings on both Function Apps were checked before this change: only Terraform's settings plus Azure's own, so the next Deploy Infra adds the new settings with the values the code already uses. One deliberate change: INGESTION_AI_BATCH_POLL_SCHEDULE goes from Terraform's stale 0 /2 to the code/docs default 0 (the AI batch poller runs every minute instead of every two).

  • Run Deploy Infra after merge and don't overlap it with a code deploy (the settings check compares live vs Terraform state).
  • Verification

  • terraform fmt + terraform validate pass; workflow YAML parses.

  • Pre-commit npm test passes.
  • 🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Function App runtime settings can now be configured through deployment environment variables, with defaults when values aren’t provided. Options include CORS, image and gallery limits, processing schedules, and database and connector behavior.
    CORS preflight requests are handled by the application in both local and Azure environments. HTTP routes support preflight, and handler errors return a CORS-aware 500 response.
    Documentation
    Updated infrastructure and Functions guides with configuration options, defaults, and limits, and clarified application-level CORS setup.
    * Expanded the local settings example with CORS options.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 516 lines (+387 / -129) across 6 files Reviewer: mattmck Review duration: 50m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.76) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.76 · 516 lines diff across 6 files
    0.76
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.374
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.076
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #449"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 75.9% (HIGH) · Higher = larger blast radius
    75.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 30.0% · Safe to merge
    30.0%