|
| 1 | +# Architecture |
| 2 | + |
| 3 | +`cas-reference-product` implements a strictly typed request/response boundary using canonical |
| 4 | +`cas-contracts` data structures, with interchangeable local and Foundry Next Gen agent adapters |
| 5 | +behind the same `WorkflowAgentService` interface. |
| 6 | + |
| 7 | +```mermaid |
| 8 | +flowchart TD |
| 9 | + Client[Client] -->|"POST /api/v1/workflows\nPromptEnvelope"| FastAPI["FastAPI Server\napp.py"] |
| 10 | + FastAPI --> Middleware["W3CTraceContextMiddleware\ntelemetry.py"] |
| 11 | + Middleware --> Router[Workflow Router] |
| 12 | + Router --> Orchestrator["WorkflowOrchestrator\nworkflow.py"] |
| 13 | + Orchestrator --> AgentService{"WorkflowAgentService\nworkflow.py"} |
| 14 | + AgentService -->|Local Config| LocalAgent[LocalWorkflowAgentService] |
| 15 | + AgentService -->|Foundry Config| FoundryAgent[FoundryWorkflowAgentService] |
| 16 | + FoundryAgent -->|Managed Identity| AzureAuth["DefaultAzureCredential\nidentity.py"] |
| 17 | + AzureAuth -->|Responses API| AzureAI[Azure AI Projects API] |
| 18 | + AzureAI -->|Invoke Agent| FoundryNextGen[Foundry Next Gen Agent] |
| 19 | + LocalAgent -->|Deterministic Output| Orchestrator |
| 20 | + FoundryAgent -->|Agent Output| Orchestrator |
| 21 | + Orchestrator -->|"RunEvent"| Router |
| 22 | + Router -->|200 OK| Client |
| 23 | +``` |
| 24 | + |
| 25 | +<!-- codex:generate-image prompt="A single reference workbench with two interchangeable adapter modules plugged into the same socket, one glowing green labeled Local (deterministic, offline), the other labeled Foundry with a dotted cable running to a distant locked cloud icon; isometric, enterprise blue/graphite palette" style="isometric, enterprise, clean" replaces="mermaid-above" --> |
| 26 | + |
| 27 | +## Components |
| 28 | + |
| 29 | +- **FastAPI web layer (`app.py`)** — exposes `/api/v1/workflows`, `/health/live`, |
| 30 | + `/health/ready`; manages OpenTelemetry spans via `PromptEnvelope.correlationId`. |
| 31 | +- **Telemetry (`telemetry.py`)** — `W3CTraceContextMiddleware` parses and propagates |
| 32 | + `traceparent`/`tracestate` headers. |
| 33 | +- **Workflow Orchestrator (`workflow.py`)** — wraps agent execution, emits canonical `RunEvent` |
| 34 | + data points (`workflow.started`, `workflow.completed`, `workflow.failed`). |
| 35 | +- **Workflow Agent Service** — the application boundary for AI logic, with local (deterministic) |
| 36 | + and Foundry Next Gen (managed-identity, Responses API) adapters behind one interface. |
| 37 | + |
| 38 | +## Deployment lock (NO-AZURE posture) |
| 39 | + |
| 40 | +This project does not use Classic Assistants APIs and does not deploy Azure resources. Azure |
| 41 | +deployment is locked workspace-wide until a future milestone is deliberately reached — no |
| 42 | +service under this workspace may be provisioned or deployed from here. `cas-platform`, the |
| 43 | +Container Apps target this repo's interface (`deployment/cas-platform.interface.yaml`) is built |
| 44 | +for, is maintained "bicep-ready" (linted, parameterized, pinned per Phase 33) but is not itself |
| 45 | +deployed. The Foundry Next Gen adapter in this repo is exercised only through local runs and |
| 46 | +CI's Docker health-check smoke test (`ci.yml`'s `docker` job) — never a live Azure deploy. |
| 47 | + |
| 48 | +## Reference-product contract |
| 49 | + |
| 50 | +Deploys as a Linux container image on port `8080` (internal ingress by default), exposing |
| 51 | +`/health/live` and `/health/ready`. Workload configuration is non-secret and injected at |
| 52 | +runtime; Application Insights connection strings are injected securely from the platform's |
| 53 | +observability module outputs. |
| 54 | + |
| 55 | +<!-- docs-verified: 57c21b03a48332728105b72a90e8e89deda409af 2026-07-08 --> |
0 commit comments