-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Phase 2 telemetry hardening + Phase 3 Docker/CI publish #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # cas-reference-product | ||
|
|
||
| Production-oriented CAS reference application demonstrating a complete workload integrated with **Microsoft Foundry Next Gen Agents** on a Container Apps foundation. Runs locally without Azure, deploys unmodified through the `cas-platform` interface. | ||
|
|
||
| ## Project Context | ||
|
|
||
| See `.planning/PROJECT.md` for goals and requirements. This project is in early initialization. | ||
|
|
||
| **Core mandate**: Demonstrate canonical CAS lifecycle events, managed identity, observability, probes, and a safe local workflow — without embedding any Azure credentials. | ||
|
|
||
| ## Tech Stack | ||
|
|
||
| | Layer | Technology | | ||
| |---|---| | ||
| | Language | Python 3.12+ | | ||
| | API framework | FastAPI + Pydantic | | ||
| | Azure identity | `ManagedIdentityCredential` (system-assigned; no embedded secrets) | | ||
| | Azure AI | Foundry Next Gen Agents (`WorkflowAgentService`) — never Classic Assistants | | ||
| | Observability | OpenTelemetry + Azure Application Insights | | ||
| | Container | Linux AMD64, port 8080 | | ||
| | Tests | pytest (in `tests/`) | | ||
| | Local dev | `scripts/run-local.ps1` | | ||
|
|
||
| ## Key Files | ||
|
|
||
| | File | Purpose | | ||
| |---|---| | ||
| | `src/cas_reference_product/identity.py` | Identity/credential resolution (local vs. managed) | | ||
| | `.foundry/agent-metadata.yaml` | Foundry Next Gen Agent configuration | | ||
| | `.foundry/datasets/` | Seed data for local testing | | ||
| | `.env.example` | All required environment variable docs | | ||
| | `scripts/run-local.ps1` | Local run without Azure | | ||
|
|
||
| ## Local Development | ||
|
|
||
| ```powershell | ||
| .\scripts\run-local.ps1 | ||
| ``` | ||
|
|
||
| Or manually: | ||
| ```bash | ||
| cd portfolio/cas-reference-product | ||
| python -m venv .venv && .\.venv\Scripts\Activate.ps1 | ||
| pip install -r requirements.txt # if present, else pip install -e . | ||
| python -m pytest tests/ | ||
| ``` | ||
|
|
||
| ## Constraints | ||
|
|
||
| - **No embedded credentials** — use `DefaultAzureCredential` / `ManagedIdentityCredential` only | ||
| - **No Azure resource deployment** — local adapter runs without provisioning | ||
| - **Foundry Next Gen only** — reject any Classic Assistants (`asst_*`) usage | ||
| - **Public repo** — no sensitive data in examples or defaults | ||
|
|
||
| ## GSD Workflow | ||
|
|
||
| Use `/gsd:plan-phase` before any multi-file change. Use `/gsd:quick` for single-file fixes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,49 @@ | ||
| FROM python:3.12-slim AS runtime | ||
| # --------------------------------------------------------------------------- # | ||
| # Stage 1 — builder: install dependencies into an isolated wheel cache # | ||
| # --------------------------------------------------------------------------- # | ||
| FROM python:3.12-slim AS builder | ||
|
|
||
| ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
| PYTHONUNBUFFERED=1 \ | ||
| PIP_DISABLE_PIP_VERSION_CHECK=1 \ | ||
| PORT=8080 | ||
| PIP_NO_CACHE_DIR=1 | ||
|
|
||
| WORKDIR /build | ||
|
|
||
| COPY pyproject.toml README.md ./ | ||
| COPY src ./src | ||
|
|
||
| RUN pip install --no-cache-dir --no-compile --prefix=/install . | ||
|
|
||
| # --------------------------------------------------------------------------- # | ||
| # Stage 2 — runtime: minimal image, non-root user, port 8080 # | ||
| # --------------------------------------------------------------------------- # | ||
| FROM python:3.12-slim AS runtime | ||
|
|
||
| ENV PYTHONDONTWRITEBYTECODE=1 \ | ||
| PYTHONUNBUFFERED=1 \ | ||
| PORT=8080 \ | ||
| PYTHONPATH=/app/src | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| RUN addgroup --system app && adduser --system --ingroup app app | ||
| # Create non-root user and group | ||
| RUN groupadd --system app && useradd --system --gid app --no-create-home app | ||
|
|
||
| COPY pyproject.toml README.md ./ | ||
| # Copy installed packages from builder stage | ||
| COPY --from=builder /install /usr/local | ||
|
|
||
| # Copy application source | ||
| COPY src ./src | ||
| RUN pip install --no-cache-dir --no-compile . | ||
|
|
||
| USER app | ||
|
|
||
| EXPOSE 8080 | ||
|
|
||
| STOPSIGNAL SIGTERM | ||
| HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \ | ||
| CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/live', timeout=2)" | ||
|
|
||
| # Health check via /health/ready — verifies app is truly ready (DOCK-01) | ||
| HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \ | ||
| CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=4)" | ||
|
|
||
| CMD ["uvicorn", "cas_reference_product.app:app", "--host", "0.0.0.0", "--port", "8080"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Local dev stack — mirrors the cas-platform container interface (DOCK-02) | ||
| # Usage: docker compose up --build | ||
| # Env: copy .env.example to .env and populate values as needed. | ||
|
|
||
| services: | ||
| cas-ref: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| target: runtime | ||
| platforms: | ||
| - linux/amd64 | ||
| image: cas-reference-product:local | ||
| ports: | ||
| - "8080:8080" | ||
| env_file: | ||
| - .env.example | ||
| environment: | ||
| # Override any .env.example defaults here for local dev | ||
| ENVIRONMENT: local | ||
| WORKFLOW_BACKEND: local | ||
| healthcheck: | ||
| test: | ||
| - CMD | ||
| - python | ||
| - -c | ||
| - "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=4)" | ||
| interval: 30s | ||
| timeout: 5s | ||
| start_period: 15s | ||
| retries: 3 | ||
| restart: unless-stopped |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the workflow service or orchestrator raises anything other than
WorkflowAgentServiceError—for example a local adapter bug or result-validation failure—the exception bypasses this handler, leaving the API span withworkflow.startedbut noworkflow.failedevent.WorkflowOrchestrator.executeexplicitly rethrows all exceptions, so the failure event should be added for the general exception path while preserving the existing 502 translation only forWorkflowAgentServiceError.Useful? React with 👍 / 👎.