Commit Graph

62 Commits

Author SHA1 Message Date
iomgaa a65b504a3d fix: consolidate remaining assembly validation into GatewaySettings
Round two of the from_env-only validation problem. Fifteen checks still lived
in the env parsing functions: six enum domains, the redis_url requirement for
redis-backed limiter/breaker/cache, cache namespace and TTL, telemetry path and
DSN, non-negative structured retries and non-blank scope. from_settings and
direct construction bypassed all of them.

The five asserts in client.py that claimed config had already validated
redis_url and the telemetry targets now hold on every path, so they revert to
what CLAUDE.md permits: internal invariant declarations that also narrow the
Optional for type checkers. Their comments now name the method that guarantees
them, since the previous wording is exactly what went stale.

Postgres DSNs built by hand now get the SQLAlchemy +driver suffix stripped the
way from_env has always stripped it, with a warning so the rewrite is not
silent. The env path strips earlier, so it stays quiet.
2026-07-30 00:58:33 -04:00
iomgaa b8f738f8cb fix: enforce cross-field settings invariants on every construction path
The lease, stall and probe-TTL guards only ran inside GatewaySettings.from_env,
so from_settings() and direct construction could produce settings that violate
the class's own invariants: the permit lease could expire mid-request (silently
exceeding the concurrency quota), a normal slow first token could be killed as a
stall, and a half-open probe could be taken over while still in flight.

Guards move into __post_init__ as _validate_* methods, matching every frozen
dataclass in types.py, so all six factories plus dataclasses.replace are covered
by one check. Adds a non-empty sources invariant that previously only from_env
enforced. Messages now name fields instead of env keys, since callers who build
settings by hand never set those keys.
2026-07-30 00:04:33 -04:00
iomgaa 91671a77df test: pin OCR live tests to trust_env=false
httpx reads the macOS system proxy config (not just env vars) when
trust_env is on, and the proxy answers 403 for the LAN service at
10.77.0.20. The raw-httpx case in this file already passed
trust_env=False; the OcrClient cases relied on the default and failed on
any machine with a system proxy enabled.
2026-07-29 23:57:44 -04:00
iomgaa 6380ba7514 fix: sync __version__ with pyproject and pin test to single source 2026-07-22 11:28:20 -04:00
iomgaa 8559f10403 chore: bump version to 1.0.0 with changelog 2026-07-22 11:18:50 -04:00
iomgaa 3846305634 fix: scope postgres telemetry test to run-prefixed rows
The fixture used to DROP the shared llm_calls table on every run, wiping
concurrent migration-batch telemetry (and its own count assertion was
polluted in return). Assertions now filter by a per-run call_id prefix
and teardown deletes only its own rows.
2026-07-22 10:32:15 -04:00
iomgaa 3c9f306ea3 fix: address M3 verifier findings on soak invariants and probe tests 2026-07-22 02:21:33 -04:00
iomgaa fdd36e0e1f style: apply ruff format to OCR modules 2026-07-22 01:43:55 -04:00
iomgaa bb1600c0f1 feat: add P7 OCR soak scenario and scoreboard 2026-07-21 23:22:12 -04:00
iomgaa d2138e535f test: add MonkeyOCR live integration suite 2026-07-21 23:08:33 -04:00
iomgaa 26e0e72926 feat: export OCR public API surface 2026-07-21 23:02:34 -04:00
iomgaa 89e86448b0 feat: add OcrClient governed loop with dual ports 2026-07-21 22:55:03 -04:00
iomgaa 1231226205 feat: add OcrSettings scope configuration 2026-07-21 22:45:12 -04:00
iomgaa dfbb2f8f10 feat: add MonkeyOCR dual-endpoint transport 2026-07-21 22:36:14 -04:00
iomgaa 31f83e380f feat: add OCR port family protocols 2026-07-21 22:28:03 -04:00
iomgaa 2fdd14f64b feat: add OCR result and transport types 2026-07-21 22:24:51 -04:00
iomgaa a06761917e fix: address M2.5 verifier findings before merge
AIMD ceiling now respects per-source max_concurrency and the pacer is
assembled explicitly in the client; MIN_CALLS parses as strict int;
acceptance doc corrects source-5 attempt count to 549; design and
migration notes aligned with implemented 429/stall/suppression
semantics and AIMD constants documented.
2026-07-21 21:10:02 -04:00
iomgaa 121888a0eb feat: suppress consecutive-channel opening on evidently healthy sources
Round 8 forensics caught the healthy source circuit-opened by five
random empty completions (~20% ambient failure rate makes a 5-streak
land every ~3000 attempts), blacking out the only good source for 60s.
When the window holds min_calls samples below the failure-rate
threshold, a streak is noise and no longer opens the gate; cold-start
and low-traffic semantics are unchanged and sudden death of a warm
source is still caught by the rate channel.
2026-07-21 15:28:34 -04:00
iomgaa 69968f2e8b feat: exempt 429 pushback from retry budget with stall ceiling
Round 6 hit account-level rate throttling the concurrency AIMD cannot
absorb: at 26 req/min the gateway still returned 16% 429s and each one
burned a third of the retry budget. Retry-After-guided 429s now back
off without consuming attempts (gRPC pushback semantics); the retry
loop gains a per-call ceiling using the same dual-condition stall
verdict as quota-wait (local window exceeded AND no global progress).
2026-07-21 13:19:16 -04:00
iomgaa 6b98a89bb3 feat: default two structured re-asks and sharper AIMD cut
Round 5 left three residual failure classes; ladder exhaustion (3.2%
of structured calls with a single re-ask) and 429 leakage (5.8%, AIMD
oscillating above the sustainable point) are addressable: re-ask
default goes 1 to 2 (conservative vs instructor's 3) and the AIMD cut
factor drops to 0.5.
2026-07-21 12:52:32 -04:00
iomgaa dcd386d4aa fix: insert demoted source after credible alternatives, not at tail
Round 4 showed tail placement routes the third attempt to junk sources
whenever the credible alternative is gate-skipped (tight-RPM source
admitted as credible, then skipped by the limiter, falling through to
the flapping watchdog source). Demoted sources now sit between credible
and non-credible candidates.
2026-07-21 12:08:37 -04:00
iomgaa 0e17f71482 feat: gate in-call demotion on credible alternative health
Round 3 showed unconditional yield-after-two-failures pushes the third
attempt onto known-bad sources in heterogeneous pools (83% vs 10%
expected success). OutcomeAwareSelector now exposes health(); a failed
source only yields when some untried candidate scores at least half its
health. Health-blind selectors keep the unconditional rule.
2026-07-21 11:24:52 -04:00
iomgaa 58061c7536 feat: add AIMD adaptive concurrency pacing per source
P6 round 2 showed routing convergence turns account-level 429s into
the binding constraint (62% throttle rate at full concurrency). Each
source now carries a local AIMD limit: multiplicative cut on 429,
additive growth on success. Over-limit picks queue via the existing
quota-wait poll instead of burning retry budget or tripping the
circuit-open verdict.
2026-07-21 10:38:48 -04:00
iomgaa 4c2a148db9 feat: feed selector health and demote in-call failed sources
RetryMW keeps a per-call failure map (local, never instance state):
a source failing twice in one call yields to the next candidate.
Attempt outcomes feed OutcomeAwareSelector behind a swallow-and-warn
guard; ResultInvalid and provider-rejected paths record success with
count_attempt=False so the breaker window stays clean. Same accounting
applied in EmbeddingClient.
2026-07-21 09:55:08 -04:00
iomgaa e69dc05fd5 feat: add health-aware P2C selector as default
Score is success-rate EWMA over (1 + inflight) with a 0.05 exploration
floor so quarantined sources can prove recovery; EWMA climb doubles as
slow-start. New optional OutcomeAwareSelector port feeds attempt
outcomes.
2026-07-21 09:22:37 -04:00
iomgaa e1678e4ff5 style: format M2.5 breaker changes 2026-07-21 09:11:56 -04:00
iomgaa c7ccb5798c feat: add failure-rate breaker channel with exponential reopen backoff
Dual-channel opening: consecutive failures (CHS-compatible, no streak
bump) plus windowed failure rate (two 30s buckets, min_calls guard).
429s bypass both channels as backpressure, and a probe hitting 429
releases instead of holding the lease. Open duration doubles per
rate/probe reopen up to max_cooldown_s, decaying after stable CLOSED.
record_success gains count_attempt so bad-result successes stay out of
the window.
2026-07-21 09:08:14 -04:00
iomgaa 72b25724d8 feat: add rate-channel breaker config and health_aware default
Threshold auto-raise now uses per-source concurrency only (the M2
global-concurrency formula neutered the breaker at scale). Four new
optional keys: MIN_CALLS, FAIL_RATE, WINDOW_S, MAX_COOLDOWN_S.
2026-07-21 08:49:36 -04:00
iomgaa 5dfd88c4d6 fix: make RPM jitter exemption side-aware with one-shot room
Verifier adversarial cases showed pooled-room exemption could hide real
breaches: edge rows may only borrow from the neighbor on their own side,
and neighbor room is consumed globally so two windows cannot claim the
same slot. Also parse SQLite created_at as UTC, guard the dispatch
semaphore on progress-callback failure, and print a caveat that rescore
live checks reflect current db3 state.
2026-07-21 07:42:54 -04:00
iomgaa 56defc88fb fix: align soak scoreboard metrics with limiter semantics
RPM invariant now buckets by admit time on the Redis server clock,
exempts +/-2s boundary jitter, and excludes cache-hit rows that never
consumed a limiter slot. RSS sampling reports current ps RSS instead of
the monotonic ru_maxrss peak. Dispatch is paced by the concurrency
semaphore so --max-hours stays live and memory stays bounded. Add
--rescore RUN_ID to re-judge a finished run offline.
2026-07-21 07:22:34 -04:00
iomgaa aecc5fa216 fix: assert global error presence for fault-mixed soak scenarios 2026-07-21 04:22:04 -04:00
iomgaa 326dd24dd1 fix: address M2 verifier findings in soak harness 2026-07-21 02:05:49 -04:00
iomgaa 724dc3c328 docs: backfill env template and migration notes for M2 2026-07-21 01:28:33 -04:00
iomgaa 9aa97a61ae feat: add soak runner with budget guards and invariant scoreboard 2026-07-21 01:23:40 -04:00
iomgaa cca7071dbd feat: add soak corpus loaders and scenario generators 2026-07-21 01:17:46 -04:00
iomgaa 5e01dc738f feat: add governed embedding client with batching 2026-07-21 01:11:48 -04:00
iomgaa 193d67da93 feat: add embedding types, port and openai-compat transport 2026-07-21 01:00:55 -04:00
iomgaa d66299210b feat: add pricing table and cost calculation in telemetry emitter 2026-07-21 00:54:10 -04:00
iomgaa abb65c2324 feat: add postgres telemetry recorder with two-tier degradation 2026-07-21 00:50:33 -04:00
iomgaa 0e22fcf433 feat: add dual-condition stall detection and quiet accounting degradation 2026-07-21 00:43:39 -04:00
iomgaa 63f2cc294e test: verify cross-connection shared governance state 2026-07-21 00:43:39 -04:00
iomgaa 7ceeab3366 test: add real-wait time-semantics variants for redis backends 2026-07-21 00:43:39 -04:00
iomgaa aae739cebe feat: add redis six-gate rate limiter backend 2026-07-21 00:27:16 -04:00
iomgaa acc1bcc18a feat: unlock redis/postgres backend config with assembly guards 2026-07-21 00:18:42 -04:00
iomgaa 0b8460b6d5 fix: address independent verification findings
Classify empty completions as transient per human ruling (fixes flaky
real-gateway smoke and prevents caching empty responses), rename the
factory injection parameter gate to breaker per the frozen design,
rewrite the probe-entry cleanup without except BaseException, declare
python-dotenv explicitly, add a mid-backoff cancellation test, and
record all implementation errata in the design and architecture docs.
2026-07-20 22:01:26 -04:00
iomgaa 0f4ae5ee8b feat: register minimax baseline provider profile 2026-07-20 21:33:24 -04:00
iomgaa 137f1ffa36 test: add real-gateway and dual-project onboarding smoke scaffolding 2026-07-20 07:56:09 -04:00
iomgaa 893707eb32 test: add integration suite for governance stack and redis cache 2026-07-20 07:53:08 -04:00
iomgaa 7b9815f4bc feat: add gateway client with env-driven assembly
Includes config aggregation for multi-source env keys, from_env and
from_settings factories with explicit shared-backend injection,
gather_bounded, top-level exports, tightened import-linter layers with
the gate removed from the Makefile, and the finalized .env.example.
2026-07-20 07:47:05 -04:00
iomgaa 936895919c feat: add structured output ladder with bounded feedback retries 2026-07-20 07:22:03 -04:00