lex-llm-azure-foundry 0.4.2 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +6 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +0 -1
  5. data/CHANGELOG.md +63 -0
  6. data/Gemfile +8 -5
  7. data/README.md +248 -149
  8. data/lex-llm-azure-foundry.gemspec +2 -4
  9. data/lib/legion/extensions/llm/azure_foundry/actors/discovery.rb +0 -4
  10. data/lib/legion/extensions/llm/azure_foundry/actors/fleet_worker.rb +4 -18
  11. data/lib/legion/extensions/llm/azure_foundry/authentication.rb +101 -0
  12. data/lib/legion/extensions/llm/azure_foundry/declared_catalog_parser.rb +93 -0
  13. data/lib/legion/extensions/llm/azure_foundry/deployment_catalog_parser.rb +93 -0
  14. data/lib/legion/extensions/llm/azure_foundry/endpoint.rb +70 -0
  15. data/lib/legion/extensions/llm/azure_foundry/helpers/endpoint_access.rb +122 -0
  16. data/lib/legion/extensions/llm/azure_foundry/helpers/offering_evidence.rb +93 -104
  17. data/lib/legion/extensions/llm/azure_foundry/helpers/project_catalog.rb +116 -0
  18. data/lib/legion/extensions/llm/azure_foundry/helpers/project_connection.rb +68 -0
  19. data/lib/legion/extensions/llm/azure_foundry/model_catalog_parser.rb +31 -95
  20. data/lib/legion/extensions/llm/azure_foundry/provider.rb +94 -151
  21. data/lib/legion/extensions/llm/azure_foundry/runners/discovery.rb +74 -137
  22. data/lib/legion/extensions/llm/azure_foundry/runners/fleet_worker.rb +1 -4
  23. data/lib/legion/extensions/llm/azure_foundry/settings.rb +31 -0
  24. data/lib/legion/extensions/llm/azure_foundry/version.rb +1 -1
  25. data/lib/legion/extensions/llm/azure_foundry.rb +70 -106
  26. metadata +11 -4
  27. data/lib/legion/extensions/llm/azure_foundry/helpers/callable.rb +0 -143
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1198fb2ce8ff987bdcde592fd99985fea88baf60104fa1424e240201ce26989
4
- data.tar.gz: ddc59cb92b40d93ffd687ae7fb0e833af86f2d8ea64f3080f709f2044e6f451b
3
+ metadata.gz: a8a8de79561aa047b730c51a625ea7fae9a1acb8825d6c52767c4da09069573a
4
+ data.tar.gz: 2d96e9474562236789c973fd7800802a20c88e86422dbc26f79e5ac99413d69a
5
5
  SHA512:
6
- metadata.gz: cd60624cc57ee1c7031f1a7392f01822be1abace9a94b2c0aaa9628c14a5801738f7bb2d4f00e717d7e760c5ead49918b72f07bc2a2185df5a329d65c1ef29b3
7
- data.tar.gz: 5c25b3e222403710aafe6d54dc6d91e83a6b1d8bd442b849a8f40da76af231bfcdf2e41ca2b7686245dcf1178494ea6aedc7bb44f96c2c892f216e4fcc0df787
6
+ metadata.gz: 72d7ca008c76373ceb1fe3bb0f171a31ab22968c82ededb00148454514e730167a1855ad35101783a512620cdf2e3bb9b4d3757104b4d113074948568cb9e93f
7
+ data.tar.gz: 77cc491ae1c8fc3d0890af213b1a580bdb8c32a156b2a12de967c4e66a86fb9353eee23531eee02f6c7c422ceb2a8bf97d580b9077fc2da79b157f87353debe7
@@ -7,12 +7,18 @@ on:
7
7
  jobs:
8
8
  ci:
9
9
  uses: LegionIO/.github/.github/workflows/ci.yml@main
10
+ with:
11
+ companion-gems: >-
12
+ {"lex-llm":{"repository":"LegionIO/lex-llm","ref":"c283d5e7db85a736cc9394d448dea98f32eee311"}}
10
13
 
11
14
  excluded-files:
12
15
  uses: LegionIO/.github/.github/workflows/excluded-files.yml@main
13
16
 
14
17
  security:
15
18
  uses: LegionIO/.github/.github/workflows/security-scan.yml@main
19
+ with:
20
+ companion-gems: >-
21
+ {"lex-llm":{"repository":"LegionIO/lex-llm","ref":"c283d5e7db85a736cc9394d448dea98f32eee311"}}
16
22
 
17
23
  version-changelog:
18
24
  uses: LegionIO/.github/.github/workflows/version-changelog.yml@main
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /.ci-dependencies/
2
3
  /coverage/
3
4
  /pkg/
4
5
  /tmp/
data/.rubocop.yml CHANGED
@@ -22,5 +22,4 @@ RSpec/MultipleMemoizedHelpers:
22
22
  Enabled: false
23
23
  RSpec/DescribeClass:
24
24
  Exclude:
25
- - spec/legion/extensions/llm/azure_foundry/capability_policy_spec.rb
26
25
  - spec/legion/extensions/llm/azure_foundry/context_window_spec.rb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,68 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.8] - 2026-11-20
4
+
5
+ ### Fixed
6
+ - Use the shared `output_token_limit_key` protocol hook to render OpenAI v1 output allowances as `max_completion_tokens`; keep model-inference allowances as `max_tokens`. Preserve the canonical budget unchanged, emit only one native key, and omit absent limits in buffered and streaming requests.
7
+ - Publish documented GPT-5-mini 2025-08-07 GlobalStandard metadata: 400,000-token context, 128,000-token output allowance, and reasoning/tool/vision/streaming support. Explicit live facts retain precedence and unknown versions remain unknown.
8
+ - Require `lex-llm >= 0.8.11` for the shared output-token key hook. Native reasoning effort values remain unchanged; unsupported effort values are not silently reduced.
9
+
10
+ ## [0.4.7] - 2026-11-20
11
+
12
+ ### Fixed
13
+ - Publish documented unsupported thinking evidence for the exact GPT-4o-mini 2024-07-18 GlobalStandard and GPT-4.1 2025-04-14 GlobalStandard tuples, using `model_metadata` provenance instead of leaving their thinking capability unknown.
14
+ - Preserve explicit live catalog capability precedence, including positive thinking evidence. Other models, versions, and deployment types remain unknown unless their own evidence establishes support.
15
+
16
+ ## [0.4.6] - 2026-11-20
17
+
18
+ ### Fixed
19
+ - Replace unsupported project API-key discovery with explicit `model_info`, `project`, or `declared` discovery sources. Project discovery requires Entra bearer/broker authentication; there is no runtime fallback between sources.
20
+ - Support API-key access through declared deployment identity bindings joined to exact authenticated resource model-catalog records. Publish only declared names through the shared inventory with `declared: true` metadata and `provider_static_catalog` provenance; reject missing/conflicting model records, duplicate names, and capability/limit overrides.
21
+ - Preserve normal snapshot replacement, withdrawal, callable retirement, and last-good retention after failed observations. Readiness remains a non-inference catalog GET.
22
+ - Withdraw an explicitly empty declaration set without fetching remote model facts, even during a catalog outage. Keep startup and cadence readiness checks unchanged.
23
+ - Validate all catalog record identities, but check duplicate/conflicting records only for declared base-model IDs so unrelated catalog duplicates cannot block the selected deployments.
24
+ - Add one immutable vendor metadata owner for exact GPT-4o-mini 2024-07-18 GlobalStandard and GPT-4.1 2025-04-14 GlobalStandard facts. Live catalog facts take precedence, including false capabilities; unknown tuples remain unknown.
25
+ - Normalize observed project model version, SKU, and capability limit fields at the project parser boundary. Both project and declared sources select the same vendor metadata using one explicit tuple, while declared identity remains distinct from observed revision evidence.
26
+ - Require `lex-llm >= 0.8.10` for shared OpenAI-compatible streaming finish-reason preservation; Azure adds no separate completion handling.
27
+
28
+ ## [0.4.5] - 2026-11-20
29
+
30
+ ### Fixed
31
+ - Support an explicitly configured `credentials.project_api_key` for project deployment pages and connected-resource metadata lookup through the existing authentication and discovery pipeline.
32
+ - Keep project credentials isolated from resource inference/readiness credentials. Reject ambiguous project API-key, bearer-token, and broker combinations without falling back to another source.
33
+ - Verify real inventory publication, project-key pagination and connection lookup, resource credential isolation, malformed credentials, off-origin continuation rejection, and last-good snapshot retention after a project network-policy failure.
34
+
35
+ ## [0.4.4] - 2026-11-20
36
+
37
+ ### Fixed
38
+ - Register the actual Azure provider instance as the inventory callable. Delete the redundant callable wrapper, duplicate dispatch checks, lazy provider construction, and separate disconnect state; execution and connection disposal use the shared provider directly.
39
+ - Carry the configured instance name into that provider so registry reads and health attribution use the claimed instance instead of defaulting to `default`.
40
+ - Refine shared error classification only when a structured Azure error code and matching HTTP status establish the outcome. Preserve authentication and authorization failures, and stop treating generic 404s or error-message phrases as deployment or endpoint-health facts.
41
+ - Require `lex-llm >= 0.8.9` for canonical tools, thinking, and sampling parameters to be reconstructed at the shared fleet boundary. Remove Azure-specific parameter reconstruction.
42
+ - Load actors through the standard host actor loader. Remove guarded fleet requires, the unused chat URL alias and authentication hook, and unqualified fleet references.
43
+ - Replace fake actor/runtime and provider dispatch classes in specs with real host classes and real provider execution over controlled HTTP transport. Require the shared conformance kit without an optional-load guard.
44
+
45
+ ## [0.4.3] - 2026-11-20
46
+
47
+ ### Fixed
48
+ - Keep the shared `lex-llm` discovery lifecycle and registry as the sole inventory owner. Azure resource model catalogs no longer become deployed offerings merely because their catalog GET succeeds.
49
+ - Discover deployed model names through the Foundry project deployment API, including bounded pagination, distinct project authentication, and retention of the last good snapshot after malformed or partial responses.
50
+ - Support native and connected-resource deployments through normal configured instances. Bind connected instances with `provider.project_connection_name`, verify the connection's endpoint, and filter before duplicate checking. Preserve deployment names across distinct instance/callable identities. Conclusive retargeting removes stale offerings; transport failures retain the last complete snapshot.
51
+ - Resolve configured resource/project broker references through the real host identity broker on every provider call, page, connection lookup, and readiness request. Require one credential source per scope, reject unavailable/expired or unspecified leases, and leave token renewal to the existing broker.
52
+ - Snapshot credential-reference bindings and include endpoint/auth-reference changes in the physical binding fingerprint, reclaiming captured callables on configuration changes while retaining them across broker lease renewal.
53
+ - Accept the documented single-model `/models/info` response and share endpoint normalization between discovery and inference, including endpoints already ending in `/models`.
54
+ - Publish explicit operation and capability evidence. Missing facts remain unknown; model-name guesses and operator limits no longer masquerade as provider evidence.
55
+ - Remove invented quota-domain groupings based only on deployment names, which can repeat across unrelated resources.
56
+ - Preserve distinct deployments of a shared base model, deduplicate identical records, and reject contradictory duplicate records instead of silently choosing capabilities.
57
+
58
+ ### Changed
59
+ - Provider connection and discovery defaults live in `azure_foundry/settings.rb`.
60
+ - OpenAI-compatible resources exposing only a base-model catalog require `provider.project_endpoint` and a project bearer credential or explicit project broker reference for deployment discovery. Data-plane credentials are not forwarded to the project API.
61
+ - Use the native settings helper for configured instances and test broker integration against the actual LegionIO host lease service.
62
+ - Updated provider documentation to describe registry snapshot reads and the actual discovery actor and runner.
63
+ - Remove the custom completion/streaming/embedding funnel and legacy capability-name guesses. Inherit shared provider execution and preserve thinking, schemas, headers, and sampling controls through the standard callable contract; regression tests reproduce the previously dropped controls.
64
+ - Remove top-level/flat configuration aliases, model-object coercion, resource-catalog fallback, alternate catalog envelopes, and model-family guesses. Use the shared default merge/deep copy, explicit named-instance configuration, and documented Azure response fields.
65
+
3
66
  ## [0.4.2] - 2026-08-25
4
67
 
5
68
  ### Fixed
data/Gemfile CHANGED
@@ -15,10 +15,13 @@ group :development do
15
15
  end
16
16
 
17
17
  group :test do
18
- # The published lex-llm (>= 0.8.0, declared in the gemspec) provides the
19
- # WeightSchema/WeightReconciler and Canonical types these specs require.
20
- # Use the local checkout when present (development); CI resolves the
21
- # published gem via the gemspec dependency.
22
- lex_llm_path = File.expand_path('../lex-llm', __dir__)
18
+ # Broker integration is exercised against the actual host lease service.
19
+ legionio_path = File.expand_path('../../LegionIO', __dir__)
20
+ legionio_options = File.directory?(legionio_path) ? { path: legionio_path } : {}
21
+ gem 'legionio', **legionio_options
22
+
23
+ # Use the standard immutable CI companion or adjacent development checkout.
24
+ lex_llm_path = File.expand_path('.ci-dependencies/lex-llm', __dir__)
25
+ lex_llm_path = File.expand_path('../lex-llm', __dir__) unless Dir.exist?(lex_llm_path)
23
26
  gem 'lex-llm', path: lex_llm_path if Dir.exist?(lex_llm_path)
24
27
  end
data/README.md CHANGED
@@ -1,180 +1,279 @@
1
1
  # lex-llm-azure-foundry
2
2
 
3
- LegionIO LLM provider extension for Azure AI Foundry Models and Azure OpenAI hosted deployments.
3
+ Azure AI Foundry and Azure OpenAI provider adapter for LegionIO. Requests use the
4
+ shared `lex-llm` canonical types, OpenAI-compatible wire translator, discovery
5
+ pipeline, and inventory registry.
4
6
 
5
- This gem lives under `Legion::Extensions::Llm::AzureFoundry`. It depends on `lex-llm >= 0.4.3` for provider contracts, routing metadata, registry publishing helpers, and provider-owned fleet request handling. It does not require or depend on `legion-llm` at runtime; Legion LLM orchestration can load this provider gem and consume its discovery metadata.
6
-
7
- Load it with:
7
+ ## Install
8
8
 
9
9
  ```ruby
10
- require 'legion/extensions/llm/azure_foundry'
10
+ gem 'lex-llm-azure-foundry'
11
11
  ```
12
12
 
13
- ## What It Provides
14
-
15
- - Provider family `:azure_foundry`
16
- - Azure AI Foundry model inference chat completions through `POST /models/chat/completions?api-version=...`
17
- - Azure AI Foundry model inference embeddings through `POST /models/embeddings?api-version=...`
18
- - Live model catalog discovery through the surface's discovery endpoint
19
- (`GET /models/info?api-version=...` on the model-inference surface, `GET /models` on the
20
- OpenAI-compatible surface) — the same endpoint doubles as the readiness probe
21
- - Azure OpenAI v1-compatible endpoint support through `/openai/v1/chat/completions` and `/openai/v1/embeddings`
22
- - Standard lex-llm offering discovery: `list_models` fetches the live catalog and
23
- `discover_offerings` derives offerings through the shared base-class flow,
24
- exactly like every other provider
25
- - Shared `ModelCatalogParser` — the single module both the Provider's `list_models`
26
- and the SSOT v3 `DiscoveryRefresh` actor parse the wire catalog through
27
- - Shared OpenAI-compatible request and response mapping through `Legion::Extensions::Llm::Provider::OpenAICompatible`
28
- - Shared registry availability publishing through `Legion::Extensions::Llm::RegistryPublisher` when transport is available
29
- - Provider-owned fleet request handling through `Legion::Extensions::Llm::Fleet::ProviderResponder`
30
-
31
- ## Architecture
13
+ Ruby 3.4+ and `lex-llm >= 0.8.11` are required. LegionIO loads the extension and
14
+ runs its discovery actor. The adapter implements chat, streamed chat, and text
15
+ embeddings; a model is eligible only when its published evidence supports the
16
+ requested operation and capabilities.
17
+
18
+ ## One inventory owner
32
19
 
33
20
  ```text
34
- Legion::Extensions::Llm::AzureFoundry
35
- |-- Provider # Azure AI Foundry and Azure OpenAI hosted provider surface
36
- | |-- Capabilities # Capability predicates inferred from catalog metadata and model naming
37
- | `-- catalog discovery # live list_models through ModelCatalogParser
38
- |-- ModelCatalogParser # shared live-catalog envelope/entry parsing
39
- |-- Actor::DiscoveryRefresh # SSOT v3 periodic discovery (catalog fetch, OfferingDrafts, probes)
40
- |-- Actor::FleetWorker # Subscription actor for provider-owned fleet requests
41
- |-- Runners::FleetWorker # Runner entrypoint that delegates to lex-llm ProviderResponder
42
- `-- VERSION
21
+ model_info project declared
22
+ /models/info Entra project deployments bindings + resource catalog
23
+ \ | /
24
+ Azure discovery runner: parse identity and explicit evidence
25
+ |
26
+ lex-llm Discovery::Pipeline
27
+ claim -> readiness -> activate/replace -> Registry snapshot
28
+ |
29
+ router / fleet / discover_offerings
43
30
  ```
44
31
 
45
- `AzureFoundry.discover_instances` reads `extensions.llm.azure_foundry` settings and returns provider instance configs. The base Legion LLM runtime can use those configs to populate the provider registry and routing inventory; this gem does not write `legion-llm` registry state itself at require time.
46
-
47
- ## File Map
32
+ `AzureFoundry::Actor::Discovery` inherits the shared discovery actor.
33
+ `AzureFoundry::Runners::Discovery` includes the shared pipeline and supplies only
34
+ Azure protocol hooks and offering evidence. The shared pipeline owns instance
35
+ reconciliation, probes, replacement, removal, weights, and health publication.
36
+ The host actor builder loads the actor files; requiring the provider alone does
37
+ not preload or conditionally define host actors.
48
38
 
49
- | Path | Purpose |
50
- |------|---------|
51
- | `lib/legion/extensions/llm/azure_foundry.rb` | Entry point, provider defaults, instance discovery, shared registry publisher |
52
- | `lib/legion/extensions/llm/azure_foundry/provider.rb` | Provider implementation with chat, stream, embed, health, readiness, and live model listing |
53
- | `lib/legion/extensions/llm/azure_foundry/model_catalog_parser.rb` | Shared live-catalog envelope and entry parsing |
54
- | `lib/legion/extensions/llm/azure_foundry/actors/discovery_refresh.rb` | SSOT v3 periodic discovery actor (catalog fetch, OfferingDrafts, readiness probes) |
55
- | `lib/legion/extensions/llm/azure_foundry/actors/fleet_worker.rb` | Subscription actor gated by ProviderResponder fleet settings |
56
- | `lib/legion/extensions/llm/azure_foundry/runners/fleet_worker.rb` | Fleet request runner that delegates execution to `ProviderResponder.call` |
57
- | `lib/legion/extensions/llm/azure_foundry/version.rb` | `VERSION` constant |
39
+ Discovery registers `AzureFoundry::Provider` itself as the callable. There is no
40
+ Azure callable wrapper. The shared registry owns dispatch leases and retirement;
41
+ the shared provider owns execution and connection disposal.
58
42
 
59
- ## Configuration
43
+ `Provider#discover_offerings` reads activated lanes from that registry.
44
+ It does not fetch Azure or maintain another catalog. Its inherited `live:`
45
+ argument does not change that behavior.
60
46
 
61
- Configured instances can be supplied through Legion settings under `extensions.llm.azure_foundry`. A top-level endpoint creates a `:settings` instance; entries under `instances` create named instances.
47
+ ## Deployment identity and discovery sources
62
48
 
63
- Models are **discovered from the endpoint**, not configured: nothing about the model set lives in settings. The discovery actor (and `list_models`) fetches the model catalog from the instance's discovery endpoint and publishes whatever it reports.
64
-
65
- ```yaml
66
- extensions:
67
- llm:
68
- azure_foundry:
69
- endpoint: https://example.services.ai.azure.com
70
- api_key: env://AZURE_INFERENCE_CREDENTIAL
71
- bearer_token: env://AZURE_FOUNDRY_BEARER_TOKEN
72
- api_version: 2024-05-01-preview
73
- surface: model_inference
74
- instances:
75
- prod:
76
- endpoint: https://prod.services.ai.azure.com
77
- api_key: env://AZURE_INFERENCE_CREDENTIAL
78
- api_version: 2024-05-01-preview
79
- surface: model_inference
80
- fleet:
81
- enabled: true
82
- respond_to_requests: true
83
- capabilities:
84
- - chat
85
- - stream_chat
86
- - embed
87
- ```
49
+ Azure resource model catalogs describe base models, not deployed model names.
50
+ Microsoft's [key-authenticated endpoint ADR](https://github.com/microsoft/mosaic-apim/blob/main/docs/adr/0018-key-authenticated-backends.md)
51
+ states that API keys cannot list deployments. The authenticated resource model GET
52
+ checks access without inference, but does not prove that a deployment exists.
53
+ The project deployment API requires Entra authentication. The unsupported
54
+ `project_api_key` option introduced in 0.4.5 is removed and rejected explicitly.
88
55
 
89
- The provider also supports direct configuration through `Legion::Extensions::Llm.configure` for tests and embedded use:
56
+ Select `provider.discovery_source` explicitly for OpenAI v1 resources:
90
57
 
91
- ```ruby
92
- Legion::Extensions::Llm.configure do |config|
93
- config.azure_foundry_endpoint = ENV.fetch('AZURE_FOUNDRY_ENDPOINT')
94
- config.azure_foundry_api_key = ENV['AZURE_INFERENCE_CREDENTIAL']
95
- config.azure_foundry_bearer_token = ENV['AZURE_FOUNDRY_BEARER_TOKEN']
96
- config.azure_foundry_api_version = '2024-05-01-preview'
97
- config.azure_foundry_surface = :model_inference
98
- end
99
- ```
58
+ | Source | Identity source | Authentication |
59
+ | --- | --- | --- |
60
+ | `model_info` | Documented single-model `/models/info` response | Resource credential; requires `model_inference` surface |
61
+ | `project` | Foundry project `GET /deployments?api-version=v1` | Separate project bearer token or broker lease |
62
+ | `declared` | Operator deployment bindings joined to exact resource catalog model IDs | Resource credential; requires `openai_v1` surface |
100
63
 
101
- Use `:openai_v1` when the endpoint should be treated as the OpenAI v1-compatible Azure route. The provider appends `/openai/v1` when the configured endpoint does not already include it.
64
+ The default is `model_info`, matching the default `model_inference` surface.
65
+ There is no fallback between sources. A project failure never activates declared
66
+ bindings, and a resource catalog never becomes an inventory of deployments on its own.
102
67
 
103
- ## Default Settings
68
+ For API-key access, declare only deployment identity:
104
69
 
105
- ```ruby
106
- Legion::Extensions::Llm::AzureFoundry.default_settings
107
- # {
108
- # enabled: true,
109
- # provider_family: :azure_foundry,
110
- # instances: {
111
- # default: {
112
- # endpoint: nil,
113
- # tier: :frontier,
114
- # transport: :http,
115
- # credentials: {
116
- # api_key: nil,
117
- # bearer_token: nil
118
- # },
119
- # provider: {
120
- # api_version: "2024-05-01-preview",
121
- # surface: nil
122
- # },
123
- # usage: { inference: true, embedding: true, image: false },
124
- # limits: { concurrency: 4 },
125
- # fleet: {
126
- # enabled: false,
127
- # respond_to_requests: false,
128
- # capabilities: [:chat, :stream_chat, :embed],
129
- # lanes: [],
130
- # concurrency: 4,
131
- # queue_suffix: nil
132
- # }
133
- # }
134
- # }
135
- # }
70
+ ```yaml
71
+ instances:
72
+ primary:
73
+ endpoint: https://resource.example.openai.azure.com
74
+ credentials:
75
+ api_key: <resource-api-key>
76
+ provider:
77
+ surface: openai_v1
78
+ discovery_source: declared
79
+ deployments:
80
+ - name: production-chat
81
+ model: gpt-4o-mini
82
+ model_version: '2024-07-18'
83
+ deployment_type: GlobalStandard
84
+ - name: embeddings
85
+ model: text-embedding-3-small
136
86
  ```
137
87
 
138
- ## Provider Methods
88
+ Each binding requires `name` and `model`; `model_version` and `deployment_type`
89
+ are optional identity facts. Capabilities and numeric limits are not accepted.
90
+ Names must be unique within an instance. Missing or malformed bindings fail
91
+ configuration; an explicit empty array withdraws all declared offerings.
92
+ That withdrawal does not require a remote catalog read. Startup and cadence
93
+ readiness checks continue through the shared lifecycle.
94
+
95
+ Discovery authenticates `GET <resource>/openai/v1/models` and joins each binding
96
+ to an exact catalog ID. Every record's ID shape is validated, but duplicate/conflict
97
+ checks apply only to selected base-model IDs. Missing selected models, malformed
98
+ catalogs, or conflicting selected records fail the whole refresh. Only declared
99
+ names are published, unchanged, through the
100
+ shared pipeline with `publication_source: provider_static_catalog` and
101
+ `metadata.declared: true`. Multiple instances can use the same deployment name
102
+ without sharing credentials or callables. The selected binding supplies dispatch
103
+ identity; an incorrect deployment name can still produce a provider 404 at inference.
104
+
105
+ For project discovery, use a separately authorized project credential:
139
106
 
140
- ```ruby
141
- provider = Legion::Extensions::Llm::AzureFoundry.provider_class.new(Legion::Extensions::Llm.config)
142
-
143
- provider.list_models
144
- provider.discover_offerings(live: true)
145
- provider.health(live: false)
146
- provider.readiness(live: false)
147
- provider.chat(messages: messages, model: 'gpt-4o-prod')
148
- provider.stream(messages: messages, model: 'gpt-4o-prod') { |chunk| puts chunk.content }
149
- provider.embed(text: ['hello'], model: 'embedding-prod')
150
- provider.count_tokens(messages: messages, model: 'gpt-4o-prod')
107
+ ```yaml
108
+ instances:
109
+ connected:
110
+ endpoint: https://connected.example.openai.azure.com
111
+ credentials:
112
+ api_key: <resource-api-key>
113
+ project_broker:
114
+ provider: azure_identity
115
+ qualifier: foundry_project
116
+ provider:
117
+ surface: openai_v1
118
+ discovery_source: project
119
+ project_endpoint: https://resource.example.services.ai.azure.com/api/projects/primary
120
+ project_connection_name: connected-resource
151
121
  ```
152
122
 
153
- `list_models` and `discover_offerings(live: true)` fetch the model catalog from the instance's discovery endpoint. `discover_offerings(live: false)` returns the last cached discovery result without calling Azure — the periodic `DiscoveryRefresh` actor keeps that cache warm, exactly like the other providers.
154
-
155
- `health(live: true)` calls the surface's discovery endpoint (the non-billable readiness probe). Keep `live: false` for startup paths and tests that must not require Azure.
156
-
157
- `count_tokens` returns a structured unsupported result by default because the Microsoft REST contract used here does not define a portable token-counting endpoint across Azure AI Foundry deployments.
158
-
159
- ## Fleet Responder
160
-
161
- Provider instances can opt in to consuming Legion LLM fleet requests. The actor is enabled only when at least one discovered instance has `fleet.respond_to_requests: true`.
123
+ `project_bearer_token` is the alternative to `project_broker`; select exactly one.
124
+ Project tokens require the `https://ai.azure.com/.default` scope and deployment-read
125
+ authorization. Resource credentials are never implicitly sent to project APIs.
126
+ Without `project_connection_name`, project discovery selects native deployments.
127
+ With it, discovery verifies the named connection target before selecting that
128
+ connection's deployments. A conclusive retarget clears stale offerings; a failed
129
+ request preserves the last complete snapshot. No connection credentials are fetched.
162
130
 
163
- Fleet execution is delegated to `Legion::Extensions::Llm::Fleet::ProviderResponder` from `lex-llm`; this provider supplies the provider family, provider class, discovered instances, and delivery metadata.
131
+ The project parser normalizes observed `modelVersion` and `sku.name` together,
132
+ and reads positive `capabilities.maxContextToken` / `maxOutputToken` values as
133
+ catalog limits. Observed revisions retain `provider_catalog` provenance.
164
134
 
165
- ## Routing Metadata
135
+ `credentials.broker` and `credentials.project_broker` select existing host-owned
136
+ provider/qualifier leases. Identity issuers acquire scoped credentials; the broker
137
+ owns registered leases and renewal. Azure reads a current valid lease on each
138
+ outbound request and creates no token cache or renewal loop. These references do
139
+ not acquire OAuth consent, grant Azure permissions, or substitute the default
140
+ Graph credential. The broker names above are examples, not automatically registered
141
+ issuers. Missing or expired leases fail authentication.
166
142
 
167
- The catalog entry's model identity (`id` / `name` / `model_name` / `deployment_name` / `model`) becomes the offering `model` and `provider_native_key` — the same routable id the endpoint accepts. When the catalog reports a base model name distinct from the routable id, it rides along as `canonical_model_alias`; `model_family` is inferred from the model name as a routing hint (never as capability evidence).
143
+ For a single-model inference endpoint:
168
144
 
169
- Supported `model_family` values are intentionally open-ended symbols, including:
170
-
171
- - `:openai`
172
- - `:mistral`
173
- - `:meta`
174
- - `:xai`
175
- - `:anthropic`
176
- - `:microsoft`
145
+ ```yaml
146
+ instances:
147
+ serverless:
148
+ endpoint: https://resource.example.services.ai.azure.com/models
149
+ credentials:
150
+ api_key: <resource-api-key>
151
+ provider:
152
+ surface: model_inference
153
+ discovery_source: model_info
154
+ api_version: 2024-05-01-preview
155
+ ```
177
156
 
178
- ## Failure Behavior
157
+ Only named instances with nested `credentials` and `provider` fields are accepted.
158
+ The shared default-settings merge supplies defaults at that boundary. Source selection
159
+ does not rewrite hosts or infer project endpoints. Disabled or credential-less
160
+ instances are not claimed. Bindings refresh through normal snapshot replacement;
161
+ instance removal and endpoint/credential changes use shared callable retirement.
162
+
163
+ ## Vendor model metadata
164
+
165
+ Live catalog facts take precedence, including explicit false capabilities.
166
+ When an observed project record or a declared binding identifies an exact documented
167
+ model/version/deployment-type tuple, `Provider::MODEL_METADATA` supplies absent vendor facts with
168
+ `source: model_metadata`. This immutable table is not operator tuning, a second
169
+ inventory, or a model-name heuristic. Unknown versions or deployment types remain
170
+ unknown. Both parser boundaries construct one explicit lookup tuple; declared
171
+ identity fields remain declarations in metadata and never become observed revision evidence.
172
+
173
+ | Exact model | Version | Deployment type | Context | Max output | Thinking |
174
+ | --- | --- | --- | --- | --- | --- |
175
+ | `gpt-4o-mini` | `2024-07-18` | `GlobalStandard` | 128,000 | 16,384 | Unsupported |
176
+ | `gpt-4.1` | `2025-04-14` | `GlobalStandard` | 1,047,576 | 32,768 | Unsupported |
177
+ | `gpt-5-mini` | `2025-08-07` | `GlobalStandard` | 400,000 | 128,000 | Supported |
178
+
179
+ The same exact tuples document chat, streaming, tools, and vision support.
180
+ The GPT-4.1 GlobalStandard facts do not apply to regional Standard, provisioned,
181
+ batch, or unknown SKUs. Sources: [Microsoft model capability tables](https://learn.microsoft.com/en-us/azure/foundry/foundry-models/concepts/models-sold-directly-by-azure?pivots=azure-openai),
182
+ [deployment types](https://learn.microsoft.com/en-us/azure/foundry/foundry-models/concepts/deployment-types),
183
+ and [Azure GPT-4.1 launch](https://azure.microsoft.com/en-us/blog/announcing-the-gpt-4-1-model-series-for-azure-ai-foundry-developers/).
184
+
185
+ The two GPT-4 tuples publish unsupported thinking evidence with `model_metadata`
186
+ provenance. [OpenAI identifies GPT-4.1 as non-reasoning](https://developers.openai.com/api/docs/models/gpt-4.1),
187
+ and [Microsoft's Azure migration guidance identifies GPT-4o-mini as not supporting the reasoning parameter](https://github.com/Azure-Samples/azure-openai-to-responses/blob/main/skills/azure-openai-to-responses/references/troubleshooting.md#L59).
188
+ Explicit live catalog values retain precedence, including positive reasoning or
189
+ thinking evidence. Other model names, versions, and SKUs do not inherit this negative fact.
190
+
191
+ ## Native request controls
192
+
193
+ The shared payload builder keeps `Canonical::Params.max_tokens` unchanged and uses
194
+ the provider's protocol hook to choose its wire name: `max_completion_tokens` for
195
+ OpenAI v1, or `max_tokens` for model inference. It sends only that key, and omits
196
+ an absent limit. This applies equally to buffered and streaming requests.
197
+
198
+ Native reasoning effort values remain model- and API-specific. For GPT-5 mini,
199
+ the canonical `low`, `medium`, and `high` levels are supported; `max` is unsupported
200
+ on Chat Completions. Azure also documents a native `minimal` level, which the
201
+ canonical effort enum does not currently represent.
202
+ The canonical budget conversion maps 16,384 tokens to `high`, while budgets above
203
+ 24,576 resolve to `max`. This adapter does not silently lower an unsupported effort.
204
+ Callers must supply controls supported by their selected deployment and API.
205
+ See [Azure reasoning API constraints](https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/reasoning#api-and-feature-support).
206
+
207
+ ## Evidence and failure behavior
208
+
209
+ - Explicit catalog capability flags, including false values, become canonical
210
+ evidence. Names such as “embed” or “vision” do not establish capabilities.
211
+ - Facts absent from both the live catalog and exact vendor metadata remain unknown.
212
+ Operator permissions and configured limits are not relabeled as provider facts.
213
+ - Deployment names do not establish quota sharing across resources. Without
214
+ authoritative quota-domain evidence, offerings leave that mapping empty.
215
+ - Provider execution inherits `chat`, `stream_chat`, `complete`, `embed`, `health`,
216
+ and `discover_offerings` from `lex-llm`. The shared fleet worker reconstructs
217
+ serialized canonical controls before dispatch. Azure has no second execution
218
+ funnel, parameter-reconstruction path, or capability-name guesses.
219
+ - Error normalization starts with the shared classifier. Azure refines only
220
+ structured error codes paired with their HTTP status; free-text phrases and
221
+ generic 404s cannot establish endpoint health or deployment existence.
222
+ - Context and output limits use valid positive integer catalog fields first,
223
+ then the exact documented vendor tuple where available.
224
+ - Deployment names remain distinct even when several deployments share one base
225
+ model. Duplicate records with identical facts are collapsed; conflicting facts
226
+ fail the refresh.
227
+ - All deployment pages must succeed before replacement. Pagination is bounded,
228
+ cycles are rejected, and continuation URLs must stay on the same project
229
+ deployment endpoint.
230
+ - Failed or malformed refreshes retain the last good snapshot. A valid empty
231
+ deployment list can publish an empty snapshot.
232
+ - Readiness performs a non-generation data-plane GET. It proves connectivity and
233
+ authentication, not that every base model is deployed.
234
+ - The selected inventory model string reaches provider dispatch unchanged.
235
+ Fleet execution uses the shared `Fleet::ProviderResponder`.
236
+
237
+ The inherited token counter returns an estimate; Azure has no portable native
238
+ token-count endpoint, so authoritative native counting is not advertised.
239
+
240
+ ## Defaults
241
+
242
+ All Azure connection and discovery defaults are defined in
243
+ `lib/legion/extensions/llm/azure_foundry/settings.rb` and returned through the
244
+ standard provider `default_settings` contract.
245
+
246
+ | Setting under `extensions.llm.azure_foundry` | Default |
247
+ | --- | --- |
248
+ | `discovery.interval_seconds` | 3600 |
249
+ | `discovery.request_timeout` / `open_timeout` | 10 / 5 seconds |
250
+ | `discovery.health_timeout` / `health_open_timeout` | 5 / 3 seconds |
251
+ | `discovery.max_pages` | 100 |
252
+ | `instances.default.tier` | `cloud` |
253
+ | `instances.default.provider.surface` | `model_inference` |
254
+ | `instances.default.provider.discovery_source` | `model_info` |
255
+ | `instances.default.provider.deployments` | `nil` |
256
+ | `instances.default.provider.api_version` | `2024-05-01-preview` |
257
+ | `instances.default.provider.project_api_version` | `v1` |
258
+
259
+ ## Verification
260
+
261
+ Run the full suite and linter:
262
+
263
+ ```sh
264
+ bundle exec rspec --format json --out tmp/rspec_results.json --format progress --out tmp/rspec_progress.txt
265
+ bundle exec rubocop -A
266
+ ```
179
267
 
180
- Live discovery and health-check failures are reported with `handle_exception(e, level: :warn, handled: true, operation: ...)` before returning degraded metadata. A failed catalog fetch in the discovery actor keeps the last complete snapshot (it never replaces it with an empty set); provider configuration and fleet actor enablement do not require live Azure connectivity.
268
+ Specs exercise the shared SSOT conformance kit, real inventory publication,
269
+ canonical callable payloads, documented model-info parsing, project pagination,
270
+ authentication boundaries, failed-refresh retention, and explicit evidence.
271
+ Broker tests load the real host broker, lease, and renewer from the test dependency.
272
+ Actor tests load the actual host actors and helpers. Publication tests register
273
+ actual provider instances; only external HTTP transport and token issuance are
274
+ controlled fixtures.
275
+
276
+ Microsoft references:
277
+ [model-inference info](https://learn.microsoft.com/en-us/rest/api/microsoftfoundry/model-inference/get-model-info/get-model-info?view=rest-microsoftfoundry-model-inference-2024-05-01-preview),
278
+ [project deployments](https://learn.microsoft.com/en-us/rest/api/microsoft-foundry/aiproject#deployments---list),
279
+ [Azure endpoint and deployment naming](https://learn.microsoft.com/en-us/azure/ai-foundry/foundry-models/concepts/endpoints?view=foundry-classic).
@@ -27,8 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency 'legion-logging', '>= 1.3.2'
28
28
  spec.add_dependency 'legion-settings', '>= 1.4.2'
29
29
  spec.add_dependency 'legion-transport', '>= 1.4.14'
30
- # 0.8.0 is the SSOT v4 contract cut: Canonical is the only internal
31
- # language, the shared enforce_canonical_messages! boundary helper, and
32
- # the Registry-snapshot offering read path this gem conforms to.
33
- spec.add_dependency 'lex-llm', '>= 0.8.0'
30
+ # Shared canonical execution and protocol-specific output-token key hook.
31
+ spec.add_dependency 'lex-llm', '>= 0.8.11'
34
32
  end
@@ -2,10 +2,6 @@
2
2
 
3
3
  require 'legion/extensions/llm/discovery/actor'
4
4
 
5
- # The base discovery actor only exists inside the daemon (it inherits the
6
- # LegionIO time-based Every actor). In a standalone load, define nothing.
7
- return unless defined?(Legion::Extensions::Llm::Discovery::Actor)
8
-
9
5
  module Legion
10
6
  module Extensions
11
7
  module Llm
@@ -3,23 +3,7 @@
3
3
  require 'legion/extensions/llm/azure_foundry'
4
4
  require 'legion/extensions/llm/fleet/provider_responder'
5
5
  require 'legion/extensions/llm/azure_foundry/runners/fleet_worker'
6
-
7
- unless defined?(Legion::Extensions::Actors::Subscription)
8
- begin
9
- require 'legion/extensions/actors/subscription'
10
- rescue LoadError => e
11
- Legion::Extensions::Llm::AzureFoundry.handle_exception(
12
- e,
13
- level: :warn,
14
- handled: true,
15
- operation: 'azure_foundry.fleet_worker.load_subscription'
16
- )
17
- end
18
- end
19
-
20
- unless defined?(Legion::Extensions::Actors::Subscription)
21
- raise LoadError, 'LegionIO actor runtime is required for Azure Foundry fleet worker'
22
- end
6
+ require 'legion/extensions/actors/subscription'
23
7
 
24
8
  module Legion
25
9
  module Extensions
@@ -45,7 +29,9 @@ module Legion
45
29
  end
46
30
 
47
31
  def enabled?
48
- Legion::Extensions::Llm::Fleet::ProviderResponder.enabled_for?(AzureFoundry.discover_instances)
32
+ Legion::Extensions::Llm::Fleet::ProviderResponder.enabled_for?(
33
+ Legion::Extensions::Llm::AzureFoundry.discover_instances
34
+ )
49
35
  end
50
36
  end
51
37
  end