Skip to content

docs(adr): adr-0026 + reference sample for foundry ai gateway pdp (RFC #2470)#2536

Merged
imran-siddique merged 4 commits into
mainfrom
feat/rfc-2470-foundry-ai-gateway-adr
May 24, 2026
Merged

docs(adr): adr-0026 + reference sample for foundry ai gateway pdp (RFC #2470)#2536
imran-siddique merged 4 commits into
mainfrom
feat/rfc-2470-foundry-ai-gateway-adr

Conversation

@Ricky-G
Copy link
Copy Markdown
Contributor

@Ricky-G Ricky-G commented May 23, 2026

Summary

Implements the "🟢 Proposing to do now" plan from RFC #2470: lands an ADR documenting the recommended PEP/PDP architecture for closing the Foundry prompt-based agent MCP governance gap, and a runnable reference sample under examples/ that adopters can deploy today with APIM + Azure Functions.

Closes the "do now" half of #2470. The integrations/foundry-ai-gateway/ package remains tracked as a separate follow-up pending Foundry product-team alignment.

Problem

Foundry prompt-based agents invoke MCP tools from the Foundry backend. Because that path is backend-initiated, MCP tool calls do not naturally traverse the same AI Gateway policy boundary that mediates model traffic. This creates an asymmetric posture: model requests pass through centralized policy enforcement, while MCP tool calls can bypass it. Customers need an Azure-native pattern they can adopt today (without waiting for native Foundry support) that keeps both surfaces inside a unified PEP/PDP boundary with versioned, fail-closed semantics.

Changes

File What changed
docs/adr/0026-foundry-ai-gateway-functions-pdp.md New ADR. Records the limitation, the APIM-as-PEP / Azure-Functions-as-PDP decision, the v1.0 decision contract (allow / deny / allow_with_conditions / require_approval), fail-closed default with explicit opt-in fail-open, managed identity + Easy Auth posture, SHA-256 inputDigest (no raw prompts by default), ttlSeconds cache hint, and schemaVersion from day one.
docs/adr/index.md Adds ADR-0026 to the Proposed table.
examples/foundry-ai-gateway-pdp/README.md Sample overview, architecture diagram, decision contract, failure semantics, run steps, security posture, and explicit "not in scope" follow-ups.
examples/foundry-ai-gateway-pdp/azure.yaml azd config wiring the pdp service to the Bicep template.
examples/foundry-ai-gateway-pdp/infra/main.bicep Provisions Storage, Log Analytics, App Insights, Linux Consumption Function App with system-assigned MI, Easy Auth (authsettingsV2) requiring Entra ID, and APIM (Developer SKU) with the named values consumed by the policy fragment. pdpAadAppId is a required parameter.
examples/foundry-ai-gateway-pdp/policy/pdp-callout.xml APIM <fragment> policy: builds the v1.0 request envelope, calls the PDP via authentication-managed-identity, fails closed on transport / schema errors, whitelists allow / allow_with_conditions and rejects every other decision (including malformed/unknown).
examples/foundry-ai-gateway-pdp/function/decide/__init__.py Minimal Python PDP implementing the v1.0 contract. Validates schemaVersion, required fields, and sha256: digest shape. Emits structured audit logs (no reserved LogRecord keys via extra).
examples/foundry-ai-gateway-pdp/function/decide/function.json HTTP trigger, authLevel: function (defence in depth alongside Easy Auth).
examples/foundry-ai-gateway-pdp/function/host.json Standard Functions v4 host config with App Insights sampling.
examples/foundry-ai-gateway-pdp/function/requirements.txt Pins azure-functions==1.21.3.
examples/foundry-ai-gateway-pdp/load/harness.py Tiny stdlib-only latency harness. Reports p50/p95/p99 (nearest-rank) and decision distribution so adopters can validate their own SLO.

Testing

  • Docs + sample only, no production code paths touched.
  • ADR follows the standard Context / Decision / Consequences template and is linked from docs/adr/index.md.
  • Bicep, APIM policy XML, and the Python PDP were reviewed for contract consistency (field names, decision values, schemaVersion) end-to-end.
  • Python files pass local lint (no editor diagnostics).
  • Full azd up + Easy Auth provisioning intentionally deferred to adopters — production Entra app registration is a customer-owned artifact.

Follow-ups (separate issues)

  • First-class integrations/foundry-ai-gateway/ component with a typed PDP SDK — gated on Foundry product-team contract alignment.
  • Sidecar MCP proxy variant for environments where APIM cannot front MCP directly.
  • Multi-region active/active PDP with regional cache replication.

Implements the 'do now' plan from RFC #2470:

- New ADR-0026 documenting the recommended PEP/PDP architecture and the v1.0 decision contract (allow/deny/allow_with_conditions/require_approval, fail-closed default, managed identity + Easy Auth, sha256 input digest, ttlSeconds cache hint, schemaVersion from day one).

- New runnable reference sample under examples/foundry-ai-gateway-pdp/ with APIM PEP policy fragment, Python Function PDP, Bicep deployment (APIM + Function App + Easy Auth + named values), and a tiny latency harness.

Addresses peer-review blockers: function-level auth combined with Easy Auth (authsettingsV2) wired in Bicep, parameterized Entra app id, APIM policy whitelists allow/allow_with_conditions and denies everything else (including malformed/unknown decisions), set-body JSON built via JObject for correct escaping, README clarifies APIM API import is a deliberate manual step, PDP validates required fields and sha256 digest shape, harness uses nearest-rank percentile.

Signed-off-by: Ricky Gummadi <ricky.gummadi@outlook.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file labels May 23, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 23, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
pip/azure-functions 1.21.3 UnknownUnknown

Scanned Files

  • examples/foundry-ai-gateway-pdp/function/requirements.txt

@github-actions github-actions Bot added the size/XL Extra large PR (500+ lines) label May 23, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 23, 2026

🤖 AI Agent: breaking-change-detector — API Compatibility

API Compatibility

No breaking changes detected.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 23, 2026

🤖 AI Agent: security-scanner — View details

No security issues found.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 23, 2026

🤖 AI Agent: docs-sync-checker — Docs Sync

Docs Sync

Documentation is in sync.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 23, 2026

PR Review Summary

Check Status Details
🔍 Code Review ✅ Passed No issues found
🛡️ Security Scan ✅ Passed No issues found
🔄 Breaking Changes ✅ Passed No issues found
📝 Docs Sync ✅ Passed No issues found
🧪 Test Coverage ✅ Completed Analysis complete

Verdict: ✅ Ready for human review

@Ricky-G Ricky-G changed the title docs(adr): ADR-0026 + reference sample for Foundry AI Gateway PDP (RFC #2470) docs(adr): adr-0026 + reference sample for foundry ai gateway pdp (RFC #2470) May 23, 2026
Ricky-G added 2 commits May 24, 2026 00:36
- harness.py: drop hashlib import; use secrets.token_hex(32) to fabricate digest-shaped strings (the PDP only validates shape). Satisfies no-custom-crypto without expanding the allowlist.

- .cspell-repo-terms.txt: add APIM, fmean, traceparent.

- docs/dependency-audits/2026-05-23-foundry-ai-gateway-pdp-azure-functions.md: dep audit doc for the new azure-functions==1.21.3 pin.

Signed-off-by: Ricky Gummadi <ricky.gummadi@outlook.com>
azure-functions is the Microsoft-published Python Functions worker on PyPI (used by examples/foundry-ai-gateway-pdp/function/requirements.txt). Add both hyphen and underscore variants to REGISTERED_PACKAGES so the dependency-confusion scan recognises it.

Signed-off-by: Ricky Gummadi <ricky.gummadi@outlook.com>
@Ricky-G Ricky-G requested a review from imran-siddique as a code owner May 23, 2026 12:40
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 23, 2026

🤖 AI Agent: code-reviewer — View details

No issues found. Clean change.

@imran-siddique
Copy link
Copy Markdown
Member

Approved. Merge conflict from recent merges - can you rebase on main?

…-ai-gateway-adr

# Conflicts:
#	.cspell-repo-terms.txt
@github-actions
Copy link
Copy Markdown

🤖 AI Agent: test-generator — `examples/foundry-ai-gateway-pdp/function/decide/__init__.py`

examples/foundry-ai-gateway-pdp/function/decide/__init__.py

  • test_decision_schema_validation -- Validate that the PDP correctly rejects requests with missing or malformed schemaVersion or required fields.
  • test_input_digest_validation -- Ensure the PDP rejects requests with invalid or missing inputDigest values.
  • test_decision_response_format -- Verify that the PDP returns responses adhering to the specified v1.0 decision contract.
  • test_fail_closed_on_transport_error -- Confirm the PDP fails closed when encountering transport errors or timeouts.
  • test_fail_closed_on_invalid_decision -- Ensure the PDP fails closed for unknown or malformed decision values.

examples/foundry-ai-gateway-pdp/load/harness.py

  • test_latency_metrics_calculation -- Validate the accuracy of p50/p95/p99 latency calculations.
  • test_decision_distribution -- Ensure the harness correctly reports decision distribution across multiple requests.

@imran-siddique imran-siddique merged commit 15a08a1 into main May 24, 2026
223 of 226 checks passed
@imran-siddique imran-siddique deleted the feat/rfc-2470-foundry-ai-gateway-adr branch May 24, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants