judgevet.adapters.inbound.settings
Status: draft.
judgevet.adapters.inbound.settings
Configure credentials, gateway metadata, network options and logging without IO.
Settings nests ApiSettings and LogSettings under api and
log respectively. pydantic-settings splits the environment on __, so
JEV_API__BASE_URL and JEV_LOG__LEVEL reach the nested models.
Nothing else under src/ subclasses BaseSettings. An adapter takes its
configuration as arguments; only a composition root reads the environment.
That is what keeps the outbound adapter testable without touching
os.environ.
The configured key or command is a SecretStr. File and command sources
resolve only when resolve_key is called, not during Settings construction.
Its repr renders as **********, so a
traceback or a log line that carries the settings object does not carry the
key.
ApiSettings validates base_url to prevent plaintext HTTP to remote
hosts. Only https:// or loopback http://localhost and http://127.0.0.1
are accepted. This prevents the API key from being sent in the clear.
Attributes:
| Name | Type | Description |
|---|---|---|
ApiSettings |
Base URL, key, default model and timeout for the Jev API. |
|
LogSettings |
Log format, level and redaction configuration. |
|
Settings |
The root model. |
Examples:
settings = Settings()
adapter = HTTPSystemOneAdapter(
api_key=settings.api.key.get_secret_value() if settings.api.key else None,
base_url=settings.api.base_url,
)
See Also
- judgevet.adapters.outbound.http: Takes the values, never the environment.
- judgevet.adapters.inbound.cli: Reads it once per process.
- judgevet.adapters.inbound.logs: Configures structured logging.
ApiSettings
Bases: BaseSettings
Credential sources and connection settings for the Jev API.
Attributes:
| Name | Type | Description |
|---|---|---|
base_url |
str
|
Root of the Jev API. Defaults to the documented host.
Must use |
key |
SecretStr | None
|
The API key. |
key_file |
str | None
|
Optional mounted credential file. |
key_command_timeout |
float
|
Finite positive command deadline in seconds. |
has_key_source |
bool
|
Source presence without IO. |
default_model |
str
|
Model id sent when a call names none. |
max_attempts |
int
|
Total requests per call, including the first. |
retry_base_delay |
float
|
Initial delay ceiling in seconds. |
retry_max_delay |
float
|
Maximum delay ceiling in seconds. |
retry_transport |
bool
|
Permit retries of transport errors. |
retry_policy |
RetryPolicy
|
Validated policy passed to the adapter. |
proxy |
SecretStr | None
|
Explicit proxy URL; masks optional credentials. |
ca_bundle |
str | None
|
Explicit PEM trust bundle path. |
verify |
bool
|
Enable certificate and hostname verification. |
auth_header |
str
|
Credential header name. |
auth_scheme |
str
|
Credential prefix; empty sends a bare key. |
headers |
dict
|
Explicit gateway metadata, omitted from repr. |
request_id_header |
str | None
|
Opt-in field for scoped correlation. |
gateway_config |
GatewayConfig
|
Validated gateway options. |
network_config |
NetworkConfig
|
Network configuration for the adapter. |
timeout_seconds |
float
|
Read timeout in seconds. Defaults to 30.0.
Can be set via |
Examples:
api = ApiSettings()
assert api.base_url == "https://api.typesafe.ai"
See Also
- judgevet.adapters.inbound.settings.Settings: Nests this model.
gateway_config
property
Validate explicit gateway settings without expanding metadata values.
Returns:
| Type | Description |
|---|---|
GatewayConfig
|
Immutable configuration consumed by each composition root. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If authentication or metadata violates header rules. |
has_key_source
property
Check source presence without reading files or executing commands.
Returns:
| Type | Description |
|---|---|
bool
|
Whether a nonempty key/command or a file path is configured. |
network_config
property
Pass explicit proxy and TLS values to the outbound adapter.
Returns:
| Type | Description |
|---|---|
NetworkConfig
|
Immutable network options with proxy credentials omitted from repr. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If CA configuration conflicts with disabled verification. |
retry_policy
property
Build the shared retry policy from validated settings.
Returns:
| Type | Description |
|---|---|
RetryPolicy
|
Immutable policy consumed by the composition roots. |
resolve_key(explicit=None)
Resolve the selected credential source only when requested.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
explicit
|
str | None
|
Optional literal override, which wins over configured sources. |
None
|
Returns:
| Type | Description |
|---|---|
SecretStr | None
|
Wrapped key or None when no source is configured. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the selected file or command source fails. |
Settings
Bases: BaseSettings
Nest connection and logging settings with input-free validation diagnostics.
Attributes:
| Name | Type | Description |
|---|---|---|
api |
ApiSettings
|
Base URL, key, default model and timeout for the Jev API. |
log |
LogSettings
|
Log format, level and redaction configuration. |
Examples:
settings = Settings()
print(settings.api.base_url)
See Also
- judgevet.adapters.inbound.settings.ApiSettings: The nested model.
- judgevet.adapters.inbound.logs.LogSettings: Log configuration.