{"id":51319838,"url":"https://github.com/solirius/stairs-response-agent","last_synced_at":"2026-07-01T12:02:01.769Z","repository":{"id":357847803,"uuid":"1237876075","full_name":"Solirius/stairs-response-agent","owner":"Solirius","description":null,"archived":false,"fork":false,"pushed_at":"2026-05-14T14:09:06.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-14T15:35:56.673Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Solirius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-13T15:37:37.000Z","updated_at":"2026-05-14T14:09:10.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Solirius/stairs-response-agent","commit_stats":null,"previous_names":["solirius/stairs-response-agent"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Solirius/stairs-response-agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Solirius%2Fstairs-response-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Solirius%2Fstairs-response-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Solirius%2Fstairs-response-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Solirius%2Fstairs-response-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Solirius","download_url":"https://codeload.github.com/Solirius/stairs-response-agent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Solirius%2Fstairs-response-agent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35005413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-01T02:00:05.325Z","response_time":130,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-01T12:01:56.660Z","updated_at":"2026-07-01T12:02:01.760Z","avatar_url":"https://github.com/Solirius.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stairs Response Agent — Azure Infrastructure\n\n## Architecture\n\nTarget state follows the **Azure AI Foundry** pattern:\n\n```text\nUser → Container App (FastAPI) → Azure AI Foundry Agent\n                                      ├── AI Services / GPT-4o (swedencentral)\n                                      ├── Azure AI Search (vector + keyword)\n                                      └── PostgreSQL Flexible Server\n                                            ↑\n                                  Blob Storage (document indexing)\n```\n\nSecrets (`postgresql-password`, `openai-api-key`, `search-api-key`) are stored in Key Vault. The Container App has a system-assigned managed identity with `Get`/`List` access; only `AZURE_KEYVAULT_URI` is passed as an env var, and the app fetches secrets from Key Vault at startup.\n\n## Provisioned resources\n\n| Resource | Name pattern | Region |\n| --- | --- | --- |\n| Resource Group | `rg-\u003cproject\u003e-\u003cenv\u003e-uksouth` | uksouth |\n| PostgreSQL Flexible Server | `psql-\u003cproject\u003e-\u003cenv\u003e` | uksouth |\n| Storage Account + container | `st\u003cproject\u003e\u003cenv\u003e` | uksouth |\n| Azure Container Registry (Basic) | `acr\u003cproject\u003e\u003cenv\u003e` | uksouth |\n| Container App Environment | `app-\u003cproject\u003e-\u003cenv\u003e-env` | uksouth |\n| Container App | `app-\u003cproject\u003e-\u003cenv\u003e` | uksouth |\n| Log Analytics Workspace | `app-\u003cproject\u003e-\u003cenv\u003e-logs` | uksouth |\n| Azure AI Search | `srch-\u003cproject\u003e-\u003cenv\u003e` | uksouth |\n| AI Services (AIServices kind) | `aif-\u003cproject\u003e-\u003cenv\u003e` | swedencentral |\n| GPT-4o deployment | `gpt-4o` (Standard, 30K TPM) | swedencentral |\n| text-embedding-3-small deployment | `text-embedding-3-small` (GlobalStandard, 30K TPM) | swedencentral |\n| Azure AI Foundry Hub | `aif-\u003cproject\u003e-\u003cenv\u003e-hub` | swedencentral |\n| Azure AI Foundry Project | `aif-\u003cproject\u003e-\u003cenv\u003e-project` | swedencentral |\n| Key Vault | `kv-\u003cproject\u003e-\u003cenv\u003e` | uksouth |\n\n\u003e **Why swedencentral for AI?** `gpt-4o` with Standard SKU is not available in `uksouth`. AI Services, the Foundry Hub and Project are all co-located in `swedencentral` for this reason.\n\n## Deployment steps\n\n### 1. Prerequisites\n\n- [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) installed\n- [Terraform](https://developer.hashicorp.com/terraform/install) \u003e= 1.5.0 installed\n- Access to the target Azure subscription\n\n### 2. Log in to Azure\n\n```bash\naz login\naz account set --subscription \"\u003cyour-subscription-name\u003e\"\n```\n\n### 3. Create the remote Terraform backend (once per environment)\n\nRun the commands in the [Create remote backend](#to-create-the-remote-backend) section below.\nNote the storage account name printed at the end — you'll need it in the next step.\n\n### 4. Configure backend.tf\n\nEdit `terraform/backend.tf` — uncomment the `terraform` block and set your storage account name:\n\n```hcl\nterraform {\n  backend \"azurerm\" {\n    resource_group_name  = \"rg-fabric-tfstate-uksouth\"\n    storage_account_name = \"\u003cyour-storage-account-name\u003e\"\n    container_name       = \"tfstate\"\n    key                  = \"compliance-discovery.tfstate\"\n  }\n}\n```\n\n### 5. Set the PostgreSQL password\n\nThe password is **never committed** — set it via `.env` (copied from the template) or as an environment variable.\n\n**Option A — `.env` file (recommended for local development):**\n\n```bash\ncp .env.example .env   # if an example exists, otherwise create .env\n# Edit .env and set:\n# TF_VAR_postgresql_admin_password=YourSecurePassword123!\n```\n\nThe Makefile reads `.env` automatically via `-include .env` + `export`.\n\n**Option B — environment variable:**\n\n```fish\n# Fish shell\nset -x TF_VAR_postgresql_admin_password \"YourSecurePassword123!\"\n```\n\n```bash\n# Bash / zsh\nexport TF_VAR_postgresql_admin_password=\"YourSecurePassword123!\"\n```\n\n### 6. Review terraform.tfvars\n\nKey values to check in `terraform/terraform.tfvars`:\n\n```hcl\nproject_name         = \"cmplianz\"      # max 8 chars — used in all resource names\nenvironment          = \"hack\"\nlocation             = \"uksouth\"       # main region for most resources\nopenai_location      = \"swedencentral\" # AI Services + Foundry must be here for gpt-4o\nopenai_model         = \"gpt-4o\"\nopenai_model_version = \"2024-11-20\"\n```\n\n### 7. Deploy\n\nRun these from the **project root** (where the `Makefile` lives):\n\n```bash\nmake init    # initialise backend and providers\nmake plan    # format, validate, and preview all changes\nmake apply   # provision the infrastructure\n```\n\nIf `make` cannot find the target (e.g. running from a subdirectory), run Terraform directly:\n\n```bash\ncd terraform\nterraform init\nTF_VAR_postgresql_admin_password=\"...\" terraform plan -out=tfplan\nterraform apply tfplan\n```\n\n### 8. Known subscription quota constraints\n\nThese issues were encountered on the hackathon subscription and are fixed in the current config:\n\n| Error | Cause | Fix applied |\n| --- | --- | --- |\n| App Service 401 quota (`Total VMs: 0`) | Subscription-level App Service limit | Switched to Azure Container Apps (no VM quota required) |\n| `gpt-4o-mini` not available in `uksouth` | Regional model restriction | Moved AI Services to `swedencentral` |\n| `gpt-4o-mini 2024-07-18` deprecated | Model retired 31/03/2026 | Switched to `gpt-4o 2024-11-20` |\n| `gpt-4o GlobalStandard` quota 0 | No GlobalStandard quota on subscription | Switched to `Standard` SKU |\n| `text-embedding-3-small Standard` not in `swedencentral` | SKU not available in region | Switched embedding deployment to `GlobalStandard` |\n| PostgreSQL zone change blocked | Can't modify zone without HA pairing | Restored `zone = \"1\"` to match deployed state |\n| `Microsoft.App` provider not registered | Container Apps namespace not registered | `az provider register --namespace Microsoft.App` |\n\n### 9. Redeploying the container image\n\nAfter code changes, rebuild and push the image, then trigger a new revision:\n\n```bash\n# From the housing-association-compliance-db directory\naz acr build \\\n  --registry acrcmplianzhack \\\n  --image compliance-api:latest \\\n  .\n\n# Update the running Container App\naz containerapp update \\\n  --name app-cmplianz-hack \\\n  --resource-group rg-cmplianz-hack-uksouth \\\n  --image acrcmplianzhack.azurecr.io/compliance-api:latest\n```\n\nTerraform uses `ignore_changes` on the container image so it won't revert CLI-driven image updates on the next `terraform apply`.\n\n### 10. Destroy (when done)\n\n```bash\nmake destroy\n```\n\n---\n\n## To create the remote backend\n\n```bash\n# Log in to Azure\naz login\n\n# Set variables (replace with your naming standard/region)\nRG_NAME=\"rg-fabric-tfstate-uksouth\"\nSTORAGE_NAME=\"stfabrictfstate$(date +%s)\" # unique name\nCONTAINER_NAME=\"tfstate\"\nLOCATION=\"uksouth\"\n\n# Create Resource Group for State\naz group create --name $RG_NAME --location $LOCATION\n\n# Create Storage Account with versioning enabled (crucial for recovery during hackdays)\naz storage account create \\\n  --name $STORAGE_NAME \\\n  --resource-group $RG_NAME \\\n  --location $LOCATION \\\n  --sku Standard_LRS \\\n  --encryption-services blob\n\n# Enable Blob Versioning for safety\naz storage account blob-service-properties update \\\n  --account-name $STORAGE_NAME \\\n  --resource-group $RG_NAME \\\n  --enable-versioning true\n\n# Create Blob Container\naz storage container create \\\n  --name $CONTAINER_NAME \\\n  --account-name $STORAGE_NAME \\\n  --auth-mode login\n\necho \"Save this storage account name for your backend.tf: $STORAGE_NAME\"\n```\n\n\u003e **Fish shell note:** Replace `VAR=\"value\"` assignments with `set VAR \"value\"` and run the\n\u003e `az` commands individually using the literal values, as Fish does not support `VAR=value` syntax.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolirius%2Fstairs-response-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolirius%2Fstairs-response-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolirius%2Fstairs-response-agent/lists"}