lex-llm-bedrock 0.4.9 → 0.5.4
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +63 -0
- data/Gemfile +2 -0
- data/lex-llm-bedrock.gemspec +2 -2
- data/lib/legion/extensions/llm/bedrock/actors/discovery_refresh.rb +750 -87
- data/lib/legion/extensions/llm/bedrock/actors/fleet_worker.rb +9 -1
- data/lib/legion/extensions/llm/bedrock/callable.rb +182 -0
- data/lib/legion/extensions/llm/bedrock/credential_discovery.rb +176 -0
- data/lib/legion/extensions/llm/bedrock/instance_identity.rb +58 -0
- data/lib/legion/extensions/llm/bedrock/provider/class_methods.rb +60 -0
- data/lib/legion/extensions/llm/bedrock/provider/client_helpers.rb +132 -0
- data/lib/legion/extensions/llm/bedrock/provider/constants.rb +53 -0
- data/lib/legion/extensions/llm/bedrock/provider/converse_helpers.rb +507 -0
- data/lib/legion/extensions/llm/bedrock/provider/dispatch_helpers.rb +184 -0
- data/lib/legion/extensions/llm/bedrock/provider/invoke_model_helpers.rb +425 -0
- data/lib/legion/extensions/llm/bedrock/provider/model_catalog_helpers.rb +299 -0
- data/lib/legion/extensions/llm/bedrock/provider.rb +26 -1631
- data/lib/legion/extensions/llm/bedrock/runners/fleet_worker.rb +13 -13
- data/lib/legion/extensions/llm/bedrock/thinking_modes.rb +68 -0
- data/lib/legion/extensions/llm/bedrock/translator/chunk_parsing.rb +116 -0
- data/lib/legion/extensions/llm/bedrock/translator/message_rendering.rb +189 -0
- data/lib/legion/extensions/llm/bedrock/translator/read_helpers.rb +143 -0
- data/lib/legion/extensions/llm/bedrock/translator/request_rendering.rb +172 -0
- data/lib/legion/extensions/llm/bedrock/translator/response_parsing.rb +168 -0
- data/lib/legion/extensions/llm/bedrock/translator.rb +36 -815
- data/lib/legion/extensions/llm/bedrock/version.rb +1 -1
- data/lib/legion/extensions/llm/bedrock.rb +12 -176
- metadata +21 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0457af083b20a03a506e162791bb8e460483dd05da16c6f208e4411af673315d
|
|
4
|
+
data.tar.gz: 13c7ac1b8ecc5737f141dc5c3327baf9068eb955a6d5d57fefc8688939322521
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2334dbb6abcd57924ba64329fc1691fada8190d84acc3e7cb98d6fdc60b4b202e53a57258c356e2385e32da3379f81083dfd1f3ffb307291a2cd208b31e0da11
|
|
7
|
+
data.tar.gz: d3d290e0b54de08ae5d2fbf517fe0b5a448faa8d568f849c3dbde381f21b2461fc9aa9c688482181bf1be4ff1e105579392b75eebd43b02ffb86258fa840bbf9
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.4] - 2026-08-18
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **Synthetic default is claimable** — Removed the discovery skip branch and once-per-boot warning for the synthetic `instances.default` configuration; normal credential validation now decides whether it can be activated.
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **Config-name instance identity (fail-forward)** — the discovery actor now claims instances under the operator's CONFIG NAME (`InstanceKey.instance_id`, the key the router looks up in `instances.<name>`); the derived `region/<credential>` id becomes the SECONDARY `InstanceKey.physical_id` (dedup/diagnostics only — it never participates in identity, tuning, or routing). `InstanceIdentity.derive_instance_id` is renamed `derive_physical_id`; every `Publisher` call carries `physical_id:`; the state map and tick reconciliation are keyed by the config name; a config literally named `default` (the reserved `InstanceKey` identity) is skipped with a loud warn instead of an every-tick `ValidationError`. Offering metadata records `instance_id` (name) + `physical_id` (derived). Conformance harness + actor/actor-lifecycle specs assert the name-based identity with the secondary physical id. Embedding models already publish `chat: :unsupported` (authoritative operation evidence — unchanged). The gemspec floor rises to `lex-llm >= 0.7.1` (the `physical_id` InstanceKey contract is 0.7.1-only).
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- **Synthetic-default skip warn fires once per boot** — the unmodified `instances.default` template skip WARN now fires exactly once per actor lifetime (a provider with no claimed instance is the normal state; a per-tick WARN was permanent log noise). The operator signal — "default is still the unmodified template; set real credentials to publish it" — is preserved at first occurrence.
|
|
15
|
+
- **Single actor registration** — the provider module no longer extends Core at file level, so the boot-time submodule walk skips it (its `autobuild` gate) and the gem's own top-level extension load is the sole actor registration (eliminates the double-claim / `FencedPublisherError`).
|
|
16
|
+
- **Real fleet dispatch (D1)** — `BedrockCallable` now implements `chat` / `stream_chat` / `embed` / `count_tokens` with `**` passthrough, delegating to a per-instance `Bedrock::Provider` built from the instance config; provider/AWS errors propagate unchanged for `normalize_dispatch_error`. `disconnect` closes the wrapped provider; dispatching a disconnected callable raises. Conformance harness now uses the PRODUCTION callable (the `TrackingBedrockCallable` stub is gone) and the exact fleet dispatch test drives a real `callable -> Provider -> stubbed Converse` round-trip.
|
|
17
|
+
- **No fallback identity (D3)** — credential-less instance configs (including the synthetic `instances.default`) are never claimed; `Bedrock::InstanceIdentity.derive_instance_id` returns `nil` instead of a `default-chain` id. The `credentials:` sub-hash is flattened in `normalize_instance_config`, and `enabled: false` instances are skipped. The conformance spec no longer asserts the forbidden `ap-southeast-1/default-chain` identity.
|
|
18
|
+
- **Initial-failure recovery (D4)** — an instance stuck in `:initializing` after a failed startup probe is re-probed each tick and re-activated (fresh offerings + `activate_instance_snapshot`) on the first passing probe. Ticks also reconcile the instance set: instances configured after boot are claimed, instances whose configuration disappeared (or changed) are removed/re-claimed. Offering comparison is on identity/status, not `Data#==`, so an unchanged catalog no longer forces a replace every tick.
|
|
19
|
+
- **Mixed-version bridge (D2)** — the actor's `Inventory::Publisher` injects `LegacyCoordinatorAdapter` so SSOT publications are projected to the old coordinator store during the mixed-version window.
|
|
20
|
+
- **Single discovery universe (P2-3)** — the actor and the fleet worker/runner both source instances from `Bedrock.discover_instances` (settings + env + claude + sigv4 + broker, deduped), so an env-credentialed node publishes SSOT lanes and can answer fleet requests.
|
|
21
|
+
- **Security setting path (P2-2)** — `security.block_static_aws_credentials` is read at its registered path (`extensions.llm.bedrock.security`) via explicit `dig`; the silent `rescue NoMethodError, TypeError` is gone.
|
|
22
|
+
- **Fleet Subscription dispatch (D13)** — `Actor::FleetWorker#runner_class` returns the runner constant (a String cannot be `send`-ed by the Subscription path) and `Runners::FleetWorker#handle_fleet_request(**message)` accepts the decoded message exactly as the framework invokes it.
|
|
23
|
+
- **Provider dispatch surface** — `chat` / `stream` / `embed` / `count_tokens` merge `**opts` passthrough params into the API payload instead of silently dropping them; `complete` accepts the base contract's `headers:` via accept-and-ignore `**` (it was `_headers:`, an `ArgumentError` on the inherited `stream_chat` path).
|
|
24
|
+
- **Discovery cadence (D9)** — the actor `time` reads the registered `discovery.interval_seconds` (never nil; falls back to the registered default) and the dead `self.every_seconds` is removed. The shadow top-level `discovery_interval` default is dropped in favor of the single standard knob.
|
|
25
|
+
- **Health display (D14)** — after every registry commit (initial readiness, recovery activation, replace, probe, removal) the actor writes `settings[:instances][<config_name>][:health]` (legacy 4-key shape + display keys) and `[:capabilities]`; removal clears them. Routing authority remains the in-memory availability state.
|
|
26
|
+
- **Standards sweep** — `require` instead of `require_relative` across lib; the hard-dep `NameError` guard in `BedrockCallable#overloaded_error?` and the silent settings rescue in `ClientHelpers` are removed; `**_provider_options` / `_headers:` kwargs replaced per the kwarg signature rule.
|
|
27
|
+
- **Conformance kit load** — spec_helper requires the kit's `conformance.rb` + `ssot_provider_examples.rb` instead of globbing the whole directory, which was executing lex-llm's own self-test specs inside this gem's suite. New actor lifecycle spec covers claimability, `enabled: false`, D4 recovery, tick reconciliation, shutdown, D14 health shape, and D9 cadence.
|
|
28
|
+
- **Raw-string model (D15)** — verified: bedrock's render path normalizes the model through `Capabilities#model_id` (string-safe: `model.respond_to?(:id) ? model.id.to_s : model.to_s`) at every dispatch op (chat/stream/count_tokens/embed/invoke-model paths), so no `Model::Info` wrap is needed at the callable boundary. Pinned by new conformance tests driving the production callable with a raw string model. (Note: offline `stub_responses` clients cannot exercise `converse_stream`/`invoke_model` — an upstream aws-sdk-core stubbing limitation, verified against the raw SDK; the model-handling path is the same `model_id` chokepoint.)
|
|
29
|
+
- **Discovery fail-loud (D16)** — `discover_offerings_for_instance` and `check_health` re-raise `NameError`/`NoMethodError`/`ArgumentError` instead of converting them into "no offerings"/"readiness failed" (which would leave every instance invisibly empty); only network/runtime errors yield `[]`/a failed probe. The conformance harness now delegates draft-building and safe-readiness to the PRODUCTION actor methods (`build_offering_draft`, `check_health`) — the duplicated harness evidence builders are deleted. No class constant is referenced from an included helper module (`DEFAULT_DISCOVERY_INTERVAL_SECONDS` is class-local to `time`; `CONTEXT_WINDOWS` lives in its own module).
|
|
30
|
+
- **Stale lock (D10)** — `Gemfile.lock` regenerated against `lex-llm >= 0.7.0` (was pinned to 0.6.9, which cannot load the SSOT inventory layer).
|
|
31
|
+
|
|
32
|
+
## [0.5.2] - 2026-08-13
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
- **Genuine rubocop compliance** — Removed every `# rubocop:disable` inline directive and all `.rubocop.yml` weakening. Added `Metrics/ClassLength: Max: 1500` / `Metrics/ModuleLength: Max: 1500` matching the project-wide shared standard used by all other `lex-llm-*` gems. Extracted provider helpers into seven modules under `provider/` and translator helpers into five modules under `translator/` to achieve real separation, not suppression.
|
|
36
|
+
- **Superclass mismatch** — `provider/constants.rb` now specifies `class Provider < Legion::Extensions::Llm::Provider` and requires `legion/extensions/llm` so the first file to open the class always sets the correct superclass.
|
|
37
|
+
- **`resolve_model_id` kwargs** — Changed `_config: nil` (wrong name) to `**` so the method correctly absorbs the `config:` keyword that `lex-llm` passes via `provider_resolved_model_id`.
|
|
38
|
+
- **`known_non_thinking?` semantics** — Now returns `false` for non-Claude/non-Anthropic model IDs (including test fixtures). Thinking is only suppressed for models that positively match the Claude family but are not in the budgeted-thinking list, preventing 500s on Bedrock without over-restricting unknown models.
|
|
39
|
+
- **Secondary publication engine removed** — `publish_readiness_async` and `publish_models_async` calls removed from provider instance methods (§2/§5). Corresponding test expectations removed from `bedrock_spec.rb`.
|
|
40
|
+
- **Stale/superseded probe tests** — Rewrote conformance spec stale and superseded probe tests to use the correct `readiness_succeeded` probe lifecycle rather than `activate_instance_snapshot` (which requires `:initializing` state). The stale probe check relies on `started_availability_revision < unavailable_revision`; superseded probe correctness is verified by showing a double `readiness_succeeded` leaves the instance intact.
|
|
41
|
+
- **Spec path alignment** — Moved `provider/capability_policy_spec.rb` and `provider/thinking_capability_spec.rb` to `bedrock/provider_*_spec.rb` to satisfy `RSpec/SpecFilePathFormat`. Renamed `thinking_payload_spec.rb` to `provider_thinking_payload_spec.rb` and removed the non-method second `describe` argument to fix `RSpec/DescribeMethod`.
|
|
42
|
+
|
|
43
|
+
## [0.5.1] - 2026-08-13
|
|
44
|
+
|
|
45
|
+
### Fixed
|
|
46
|
+
- **SSOT v3 compliance sweep** — Removed all `# rubocop:disable` directives from source and specs. Replaced swallowed `rescue nil` in probe cleanup with `handle_exception` logging. Removed `|| default` settings guards by registering `discovery_interval:` in `default_settings`. Removed `:default` instance_id fallbacks from `offering_for` and `build_offering`. Split `DiscoveryRefresh` into six focused private modules to satisfy `Metrics/ClassLength` and `Metrics/ModuleLength` without inline disables.
|
|
47
|
+
- **Health firewall** — `connection_failure` / timeout / overload / generic-5xx remain request-local; only `Aws::BedrockRuntime::Errors::ServiceUnavailableException` maps to `:instance_unavailable`. Conformance harness mapping corrected.
|
|
48
|
+
|
|
49
|
+
## [0.5.0] - 2026-08-13
|
|
50
|
+
|
|
51
|
+
### Changed
|
|
52
|
+
- **SSOT v3 provider migration** — Discovery actor completely rewritten to use `Inventory::Publisher`, `ProbeCoordinator`, and `BedrockCallable`. Each credential/region pair publishes as an exact instance with full operation evidence per model. No default model, no Legion::LLM reverse dependency.
|
|
53
|
+
- **Dependency floor** — `lex-llm >= 0.7.0` (Inventory v3 API).
|
|
54
|
+
- **Removed** `DEFAULT_MODEL` constant, `resolve_default_model`, and default model injection from `discover_instances`. SSOT v3 forbids provider-level model defaults — the router selects models from published offerings.
|
|
55
|
+
|
|
56
|
+
### Added
|
|
57
|
+
- **BedrockCallable** — Implements `disconnect` and `normalize_dispatch_error` with full AWS error classification. Only `Aws::BedrockRuntime::Errors::ServiceUnavailableException` maps to `:instance_unavailable`; all other 5xx/transient errors map to `:overloaded`.
|
|
58
|
+
- **Conformance spec** — `it_behaves_like 'an SSOT v3 provider adapter'` plus Bedrock-specific identity derivation, error classification, and isolation tests.
|
|
59
|
+
|
|
60
|
+
## [0.4.10] - 2026-08-04
|
|
61
|
+
|
|
62
|
+
### Fixed
|
|
63
|
+
- **Claude models now advertise the `:thinking` capability.** Discovery passed `provider_catalog: {}` to `CapabilityPolicy.resolve`, so per-model capabilities from the shared lex-llm catalog (which correctly tags Claude 3.7 / 4+ models `reasoning` → `:thinking`) were ignored — every Bedrock Claude model reported no thinking capability, so the router's thinking filter could not route thinking requests correctly. `offering_from_model` now consults the shared catalog via `catalog_capabilities`.
|
|
64
|
+
- **Thinking payload no longer sends unsupported `adaptive` mode.** `invoke_model_thinking` / `build_invoke_thinking` (and the converse-path `bedrock_additional_fields` / `build_additional_fields`) previously emitted `{type: 'adaptive'}` for every non-`claude-sonnet-4` model, which Bedrock rejects with `ValidationException: adaptive thinking is not supported on this model` (HTTP 500, e.g. claude-opus-4-5). A new `ThinkingModes` module is the single source of truth shared by provider and translator: budgeted-thinking models emit `{type: 'enabled', budget_tokens: N}`; known non-thinking models omit thinking entirely. `adaptive` is never emitted.
|
|
65
|
+
|
|
3
66
|
## [0.4.9] - 2026-06-20
|
|
4
67
|
|
|
5
68
|
### Fixed
|
data/Gemfile
CHANGED
data/lex-llm-bedrock.gemspec
CHANGED
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
spec.add_dependency 'aws-sdk-bedrockruntime'
|
|
28
28
|
spec.add_dependency 'legion-json', '>= 1.2.1'
|
|
29
29
|
spec.add_dependency 'legion-logging', '>= 1.3.2'
|
|
30
|
-
spec.add_dependency 'legion-settings', '>= 1.
|
|
30
|
+
spec.add_dependency 'legion-settings', '>= 1.4.2'
|
|
31
31
|
spec.add_dependency 'legion-transport', '>= 1.4.14'
|
|
32
|
-
spec.add_dependency 'lex-llm', '>= 0.
|
|
32
|
+
spec.add_dependency 'lex-llm', '>= 0.7.1'
|
|
33
33
|
end
|