Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
8d4bc2e
test(benchmarks): derive ignored signals and pin the retry-after cloc…
ayhammouda Nov 4, 2026
dcb0bfd
feat(benchmarks): route SDK clients through an explicit egress proxy
ayhammouda Nov 4, 2026
548408b
feat(benchmarks): Ollama chat client, unmetered ledger units and the …
ayhammouda Nov 4, 2026
de4cace
feat(benchmarks): MCP servers reach the egress proxy; pin and audit m…
ayhammouda Nov 4, 2026
61b751c
feat(benchmarks): launcher seam with a stdin key bootstrap, prepare, …
ayhammouda Nov 4, 2026
521fdca
feat(benchmarks): live workers report model limits; the run summary l…
ayhammouda Nov 4, 2026
f6fee4e
feat(benchmarks): sandbox worker image pinned by digest
ayhammouda Nov 4, 2026
8b81037
feat(benchmarks): egress allowlists, proxy log parser and forbidden e…
ayhammouda Nov 4, 2026
794ded2
feat(benchmarks): Squid config with lookup-free allowlists and a file…
ayhammouda Nov 4, 2026
7ae2870
feat(benchmarks): container launcher with per-job egress proxy and ke…
ayhammouda Nov 4, 2026
540986e
fix(benchmarks): never follow a link in a proxy's 0777 log directory
ayhammouda Nov 4, 2026
05b7a39
feat(benchmarks): isolation probe gates every sandboxed job
ayhammouda Nov 4, 2026
4c4c23e
feat(benchmarks): write the C1 egress summary in the shape PR 5 reads
ayhammouda Nov 4, 2026
2f9f922
feat(benchmarks): one live authorization gate, per-cell reference rat…
ayhammouda Nov 4, 2026
d134307
feat(benchmarks): air-gapped arm host checks and Ollama preflight
ayhammouda Nov 4, 2026
0fc7593
feat(benchmarks): write the C3 air-gap evidence in the shape PR 5 reads
ayhammouda Nov 4, 2026
287903f
docs(benchmarks): sandbox run script, runbooks and the opt-in docker …
ayhammouda Nov 4, 2026
860df6d
fix(benchmarks): a failed env probe names the injected variables
ayhammouda Nov 4, 2026
05e2ff8
test(benchmarks): accept TCP_DENIED_ABORTED in the docker IP-literal …
ayhammouda Nov 4, 2026
ab4bee5
docs(benchmarks): record the keyless docker test results
ayhammouda Nov 4, 2026
1e89f56
fix(benchmarks): clear the CodeQL findings in the sandbox changes
ayhammouda Nov 4, 2026
a05806a
Merge remote-tracking branch 'refs/remotes/origin/main' into codex/ag…
ayhammouda Nov 4, 2026
cff3900
fix(benchmarks): use the Python security release in sandbox workers
ayhammouda Nov 4, 2026
76cc577
test(benchmarks): isolate signal and Docker cleanup checks
ayhammouda Nov 4, 2026
d198fdc
fix(benchmarks): isolate Docker build and pull environments
ayhammouda Nov 4, 2026
d912942
fix(benchmarks): enforce the offline arm boundary
ayhammouda Nov 4, 2026
1401923
fix(benchmarks): bind worker reports to planned output paths
ayhammouda Nov 4, 2026
1d0cfde
fix(benchmarks): fail closed on untrusted egress evidence
ayhammouda Nov 4, 2026
4164515
fix(benchmarks): require usable pilot measurements before live confir…
ayhammouda Nov 4, 2026
c5b5366
Merge remote-tracking branch 'refs/remotes/origin/main' into codex/ag…
ayhammouda Nov 4, 2026
457b60e
test(benchmarks): observe the docs cache inside the worker container
ayhammouda Nov 4, 2026
6e7bf1d
fix(benchmarks): require a readable macOS routing table
ayhammouda Nov 4, 2026
7680ba5
fix(benchmarks): clean up only owned Docker resources after interruption
ayhammouda Nov 4, 2026
dd9c719
fix(benchmarks): preserve failed evidence and wait for complete probe…
ayhammouda Nov 4, 2026
a1db561
fix(benchmarks): validate the whole run before starting workers
ayhammouda Nov 4, 2026
4755f2a
test(benchmarks): reach probe failure with a present index fixture
ayhammouda Nov 4, 2026
83c4f82
fix(benchmarks): align key and probe preflights with worker policy
ayhammouda Nov 4, 2026
cf0de10
fix(benchmarks): create and track workers before attaching stdin
ayhammouda Nov 4, 2026
d776257
fix(benchmarks): bind paid estimates to measured live model identity
ayhammouda Nov 4, 2026
01da4b8
docs(benchmarks): describe the attached worker lifecycle
ayhammouda Nov 4, 2026
669131a
fix(benchmarks): require matching local pilot timing when supplied
ayhammouda Nov 4, 2026
1162fd7
fix(benchmarks): export ledger activity from the current invocation
ayhammouda Nov 4, 2026
7de44e8
fix(benchmarks): wait for daemon removal of an owned container
ayhammouda Nov 4, 2026
e593d00
test(benchmarks): distinguish stalled auto-removal from success
ayhammouda Nov 4, 2026
213d071
fix(benchmarks): distinguish upstream replies from Squid errors
ayhammouda Nov 4, 2026
0317bca
docs(benchmarks): record Squid evidence fields and worker attach results
ayhammouda Nov 4, 2026
ac5ac7c
fix(benchmarks): validate evidence identities and preserve cancellation
ayhammouda Nov 4, 2026
08976b1
fix(benchmarks): preserve isolation for interrupted legacy responses
ayhammouda Nov 4, 2026
c723cd1
docs(benchmarks): record the observed partial HTTP 200 response
ayhammouda Nov 4, 2026
29f1b58
fix(benchmarks): preserve interrupted creation on Docker CLI errors
ayhammouda Nov 4, 2026
61da776
fix(benchmarks): finish owned cleanup without hiding the operator signal
ayhammouda Nov 4, 2026
edfee23
fix(benchmarks): isolate Docker helpers and latch the first host signal
ayhammouda Nov 4, 2026
6fa113e
fix(benchmarks): detach Docker management helpers from host stdin
ayhammouda Nov 4, 2026
ea8a1b1
fix(benchmarks): report each worker cleanup failure before draining t…
ayhammouda Nov 4, 2026
b3ce980
docs(benchmarks): identify interrupted resources by invocation and ID
ayhammouda Nov 4, 2026
18fab09
fix(benchmarks): retain stop and scrub diagnostics together
ayhammouda Nov 4, 2026
f9dd86c
Finish worker scrubbing across spawn and teardown failures
ayhammouda Nov 4, 2026
efcf2cc
Keep teardown and recovery evidence across secondary failures
ayhammouda Nov 4, 2026
0fe55d2
agent: preserve sandbox rollback IDs and recovery labels
ayhammouda Nov 4, 2026
ac55b13
agent: capture worker stderr privately before publishing redacted logs
Nov 4, 2026
ac76a9d
Apply the same key scan to scrubbed logs and diagnostics
ayhammouda Nov 4, 2026
5b027be
agent: Keep raw Squid logs outside published artifacts
ayhammouda Nov 4, 2026
463038d
Retain setup recovery IDs in a later leak diagnostic
ayhammouda Nov 4, 2026
7ffde18
Recover late resources after ambiguous Docker create errors
ayhammouda Nov 4, 2026
b38644c
Scan decoded strings and serialized benchmark evidence
ayhammouda Nov 4, 2026
11549a1
Bound proxy reads and finish collecting other jobs after failures
ayhammouda Nov 4, 2026
d8478ce
Scan Docker verification metadata before reporting or publishing it
ayhammouda Nov 4, 2026
e589f82
Check decoded snapshot inputs before writing run artifacts
ayhammouda Nov 4, 2026
34f83f4
Detect intact keys after escaped text boundaries
ayhammouda Nov 4, 2026
a0108c3
Retain leak detection and publish safe failed collection records
ayhammouda Nov 4, 2026
51d4f42
Plan and publish from the same scanned input bytes
ayhammouda Nov 4, 2026
61ccec1
Stop unsafe tool arguments before dispatch or transcript capture
ayhammouda Nov 4, 2026
9fa2682
Preserve the original leak verdict if artifact storage fails
ayhammouda Nov 4, 2026
2d63097
Pin the inspected Squid log inode for the entire Linux test
ayhammouda Nov 4, 2026
bf2a4e6
Always release the run ledger and preserve operator interrupts
ayhammouda Nov 4, 2026
0f9fca9
Report worker credential checks without guessing the key owner
ayhammouda Nov 4, 2026
121af0d
Require pilot transcripts to establish the API that actually ran
ayhammouda Nov 4, 2026
c421b9f
Check tool results and outgoing request content before a provider call
ayhammouda Nov 4, 2026
aa67209
Release the spend ledger when initialization or unlock is interrupted
ayhammouda Nov 4, 2026
4f9599a
Check worker-owned secret bytes before provider and MCP dispatch
ayhammouda Nov 4, 2026
dfcf5ca
Join pilot calls to their actual reservations and settlements
ayhammouda Nov 4, 2026
77ae4c3
Stop sibling grants when a worker reports a credential failure
ayhammouda Nov 4, 2026
844f247
Require the request model in recorded pilot attempts
ayhammouda Nov 4, 2026
4daced0
Publish the sibling reply atomically in the concurrency test
ayhammouda Nov 4, 2026
228f454
Scan the decoded job before creating a client or starting the MCP child
ayhammouda Nov 4, 2026
bd3ea62
Bind pilot timing and cost evidence to the transcripts the host publi…
ayhammouda Nov 4, 2026
3d33ca6
Retain recognized credential failures through worker cleanup
ayhammouda Nov 4, 2026
4bddf10
Scan incoming MCP replies before SDK result validation
ayhammouda Nov 4, 2026
9bc5771
Check shadowed JSON values at the MCP reply boundary
ayhammouda Nov 4, 2026
bb2651f
Preserve credential failures during SDK cancellation and bridge shutdown
ayhammouda Nov 4, 2026
abd0e59
Validate decoded tool arguments before native replay and after settle…
ayhammouda Nov 4, 2026
4479a8b
Exercise missing bootstrap through the real worker channel
ayhammouda Nov 4, 2026
c498e0f
Keep provider content tests independent of adapter fixture imports
ayhammouda Nov 4, 2026
ddd6933
Inspect a partial MCP reply when its stream disconnects
ayhammouda Nov 4, 2026
240773f
Raise the recorded MCP failure from a narrowed local value
ayhammouda Nov 4, 2026
d688070
Reproduce native replay after misaligned JSON quotes
ayhammouda Nov 4, 2026
d6cfc0d
Inspect recoverable JSON content and settle known provider usage
ayhammouda Nov 4, 2026
c06d290
Stop the active run when an MCP reply exceeds the frame limit
ayhammouda Nov 4, 2026
cdf7c98
Refuse ambiguous escapes outside inspected JSON strings
ayhammouda Nov 4, 2026
93f640b
Preserve clean malformed reply behavior when scanning recoverable str…
ayhammouda Nov 4, 2026
e59a9e2
Observe late MCP frame failures before another reservation
ayhammouda Nov 4, 2026
a3b875f
Retain recognized worker faults across sibling cleanup and missing er…
ayhammouda Nov 4, 2026
8a04b3f
Preserve frame-size failure when the worker report pipe is closed
ayhammouda Nov 4, 2026
47eb969
Document worker failure handling and exercise incomplete SDK responses
ayhammouda Nov 4, 2026
9a6f637
Verify sibling storage failures preserve the recognized frame-limit e…
ayhammouda Nov 4, 2026
8d98576
Preserve diagnostics from cancelled sibling cleanup
ayhammouda Nov 4, 2026
cb74db6
Report frame-limit failures consistently through the owned worker exi…
ayhammouda Nov 4, 2026
f4b677a
Stop the worker on undecodable MCP replies after inspecting the valid…
ayhammouda Nov 4, 2026
22e627c
Bound tool argument depth before recursive normalization
ayhammouda Nov 4, 2026
5e8c39d
Separate SDK reader cancellation from an operator interruption
ayhammouda Nov 4, 2026
847a3c1
Verify shadowed argument fields at the depth boundary
ayhammouda Nov 4, 2026
97ec278
Stop the benchmark on uninspectable Unicode strings after settlement
ayhammouda Nov 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,10 @@ jobs:
--no-deps \
--disable-pip \
--progress-spinner off
# The sandbox image's hashed mcp-server-fetch venv. A separate call: pip-audit
# refuses to mix a hashed requirements file with an unhashed one.
uvx pip-audit \
--requirement benchmarks/sandbox/fetch-requirements.txt \
--no-deps \
--disable-pip \
--progress-spinner off
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,26 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
worker processes. CI runs it end to end with scripted models and no network.
The provider SDKs join the `dev` dependency group at exact pins:
`anthropic` 1.15.0, `openai` 3.32.0 and `google-genai` 2.31.0.
- Benchmark sandbox (development tooling, not part of the package):
`benchmarks/sandbox/` builds a hardened worker container and runs each
(model, system) job in its own container behind its own logging Squid egress
proxy, after a keyless isolation probe.
- `agentic-run --launcher container`, a dry run by default, with `--live`, one
authorization gate (refused under `CI`, then an interactive confirmation of
each provider's spend, cap and estimate) and `--reference-run` for the
full-run gate.
- The Ollama client for the benchmark's air-gapped arm, with host offline checks
around every trajectory.
- The "Air-gapped install" README section.

### Changed

- The benchmark's `docs-fetch` and `python-docs` systems reach the network only
through the run's egress proxy.
- Benchmark keys reach a worker only as a bootstrap frame on its stdin, never
through a container's environment, `--env-file` or argv. This is a recorded
departure from the agentic design §7.3.

- The benchmark harness (development tooling, not part of the package) now
reports success latency and failed-cell latency separately, lists manifest
exclusions, keeps the real reason when a cell fails inside MCP task groups,
Expand All @@ -37,6 +54,12 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Security

- The Security workflow's dependency audit also covers
`benchmarks/sandbox/fetch-requirements.txt`, the hashed `mcp-server-fetch`
2026.10.19 environment of the benchmark sandbox image.
- The benchmark sandbox never follows a link in a proxy's world-writable log
directory: logs are read with `O_NOFOLLOW` and only as regular files, and the
host writes there only through new files renamed over the name.
- Updated locked Pydantic (2.14.2, pydantic-core 2.50.2, with the
typing-extensions 4.16.0 and typing-inspection 0.4.4 it requires) and
Platformdirs (4.14.0). Pydantic 2.14.2 fixes four validation advisories
Expand Down
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,42 @@ docs index, older entries are ignored automatically. Deleting
`retrieved-docs-cache.sqlite3` is safe; it removes cached retrieval results, not
the docs index.

## Air-gapped install

The server needs no network at query time. To install it on a machine with no
network:

1. On a connected machine with the same OS, CPU architecture and Python minor
version, download the wheels and build the index. Elsewhere, add pip's
`--platform`, `--python-version` and `--only-binary=:all:` options to
`pip download`.

```bash
pip download python-docs-mcp-server==<version> -d wheels/
pip install python-docs-mcp-server==<version>
python-docs-mcp-server build-index --versions 3.10,3.11,3.12,3.13,3.14
```

2. Copy `wheels/` and the built `index.db` to the target machine.
3. On the target, install from the copied wheels only:

```bash
pip install --no-index --find-links wheels/ python-docs-mcp-server==<version>
```

4. Put `index.db` at `~/Library/Caches/mcp-python-docs/index.db` on macOS, or
at `~/.cache/mcp-python-docs/index.db` on Linux
(`$XDG_CACHE_HOME/mcp-python-docs/index.db` when `XDG_CACHE_HOME` is set).
5. Set `PYTHON_DOCS_MCP_DISABLE_AUTO_INDEX=1`, so a missing index never starts
a network build, and check the install:

```bash
PYTHON_DOCS_MCP_DISABLE_AUTO_INDEX=1 python-docs-mcp-server doctor
```

`lookup_package_docs` needs PyPI. Offline, it returns a clear note instead of
package sources. There is no separate offline command.

## PyPI package docs lookup

`lookup_package_docs` queries the official PyPI JSON API documented at
Expand Down
87 changes: 80 additions & 7 deletions benchmarks/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import sys
from pathlib import Path
from typing import Any

from benchmarks.corpus import validate_corpus
from benchmarks.report import generate_readme_summary, generate_report
Expand Down Expand Up @@ -178,7 +179,33 @@ def _build_parser() -> argparse.ArgumentParser:
agentic.add_argument("--repeats", type=int, default=3)
agentic.add_argument("--seed", type=int)
agentic.add_argument("--run-id")
agentic.add_argument("--dry-run", action="store_true", help="Write the plan; no ledger.")
mode = agentic.add_mutually_exclusive_group()
mode.add_argument("--dry-run", action="store_true", help="Write the plan; no ledger.")
mode.add_argument(
"--live",
action="store_true",
help="Container launcher only: run for real, after the CI refusal and a typed 'yes'.",
)
agentic.add_argument(
"--launcher",
choices=("local", "container"),
default="local",
help="local: scripted models only. container: the sandbox, a dry run unless --live.",
)
agentic.add_argument("--image", help="The sandbox worker image ID (sha256:...).")
agentic.add_argument(
"--keys-file",
type=Path,
help="Mode-600 NAME=VALUE file; only the container launcher reads it, one key per worker.",
)
agentic.add_argument(
"--index", type=Path, help="The docs index for python-docs jobs (default: the cache's)."
)
agentic.add_argument(
"--reference-run",
type=Path,
help="A finished pilot run whose per-cell cost and time the full-run gate scales.",
)
agentic.add_argument(
"--acknowledge-overrun",
action="append",
Expand All @@ -191,11 +218,42 @@ def _build_parser() -> argparse.ArgumentParser:
subparsers.add_parser(
"agentic-worker", help="Internal: run one agentic (model, system) job for the host."
)
# Run by the container launcher in a keyless probe container, never by hand.
probe = subparsers.add_parser(
"agentic-probe", help="Internal: check a sandbox network's isolation from inside it."
)
probe.add_argument("--spec", required=True, help="The probe's checks, as JSON.")
return parser


def _container_launcher(args: argparse.Namespace, run_id: str) -> Any:
"""The production sandbox: the real image check, the real probes, docker on this host."""
from benchmarks.agentic.sandbox import ContainerLauncher, Sandbox, SandboxConfig
from benchmarks.runner import _repo_commit_sha
from mcp_server_python_docs.storage.db import get_index_path

config = SandboxConfig(
image=args.image,
run_id=run_id,
out_dir=args.out,
index_path=args.index or get_index_path(),
keys_file=args.keys_file,
repo_commit=_repo_commit_sha(),
)
return ContainerLauncher(Sandbox(config))


def main(argv: list[str] | None = None) -> int:
parser = _build_parser()
argv = sys.argv[1:] if argv is None else argv
if argv and argv[0] == "agentic-run":
# argparse itself quotes invalid values (e.g. --repeats) in its diagnostics.
from benchmarks.agentic.protocol import KeyLeakError, assert_no_key_shaped_json

try:
assert_no_key_shaped_json(argv[1:], where="agentic-run arguments")
except KeyLeakError as exc:
parser.exit(3, f"agentic run stopped on a key leak: {exc}\n")
args = parser.parse_args(argv)

if args.command == "agentic-worker":
Expand All @@ -204,11 +262,22 @@ def main(argv: list[str] | None = None) -> int:

return main_worker()

if args.command == "agentic-probe":
from benchmarks.agentic.probe import probe_main

return probe_main(["--spec", args.spec])

if args.command == "agentic-run":
# Lazy, like agentic-worker: only agentic commands load the provider SDKs.
from benchmarks.agentic import run as agentic_run
from benchmarks.agentic.protocol import KeyLeakError

from benchmarks.agentic.protocol import KeyLeakError, scanned_json_bytes
from benchmarks.runner import _default_run_id

if args.live and args.launcher != "container":
parser.error("--live needs --launcher container: the local launcher is scripted only")
if args.launcher == "container" and not args.image:
parser.error("--launcher container needs --image sha256:...")
run_id = args.run_id or _default_run_id() # one id for the run and its sandbox
config = agentic_run.AgenticConfig(
corpus_path=args.corpus,
matrix_path=args.matrix,
Expand All @@ -221,17 +290,21 @@ def main(argv: list[str] | None = None) -> int:
questions=args.questions,
repeats=args.repeats,
seed=args.seed,
run_id=args.run_id,
dry_run=args.dry_run,
run_id=run_id,
# The container launcher is a dry run unless --live is given.
dry_run=args.dry_run or (args.launcher == "container" and not args.live),
acknowledge_overrun=tuple(args.acknowledge_overrun),
reference_run=args.reference_run,
)
try:
summary = agentic_run.run_agentic(config)
launcher = _container_launcher(args, run_id) if args.launcher == "container" else None
summary = agentic_run.run_agentic(config, launcher=launcher)
output = scanned_json_bytes(summary, where="run summary", indent=2, sort_keys=True)
except KeyLeakError as exc: # before its base class
parser.exit(3, f"agentic run stopped on a key leak: {exc}\n")
except BenchmarkValidationError as exc:
parser.exit(2, f"agentic run failed: {exc}\n")
print(json.dumps(summary, indent=2, sort_keys=True))
print(output.decode())
return 0

if args.command == "run":
Expand Down
24 changes: 22 additions & 2 deletions benchmarks/adapters/guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#: case-insensitive) for any live-provider guard to pass.
LIVE_PROVIDERS_ENABLED_ENV = "BENCHMARK_LIVE_PROVIDERS_ENABLED"

#: The sandbox's egress proxy (``http://<host>:<port>``), the only proxy a live client uses.
EGRESS_URL_ENV = "BENCHMARK_EGRESS_URL"

#: Per-provider environment variable that must also be non-empty.
#:
#: ``anthropic`` (issue #89) is not a competitor/model-matrix provider --
Expand All @@ -51,6 +54,9 @@
#: The model providers' keys: they pay for every call, and no docs system ever receives one.
PAID_KEY_ENVS = tuple(PROVIDER_API_KEY_ENV[p] for p in ("anthropic", "openai", "google"))

#: Keyless live providers, and the variable that must be set instead of a key (#184 ruling 9).
LIVE_LATCH_ENV = {"ollama": "OLLAMA_BASE_URL"}

_TRUTHY = {"1", "true", "yes"}
#: Every provider key is made of these; anything else could be quoted by an HTTP error.
_KEY_CHARACTERS = re.compile(r"[A-Za-z0-9_.-]+")
Expand All @@ -67,14 +73,20 @@ class MalformedApiKeyError(LiveProviderDisabledError):
"""Raised when a provider API key is set but holds characters no HTTP header may carry."""


def valid_api_key(value: str) -> bool:
"""Use the same character policy for the keys file and the worker environment."""
return _KEY_CHARACTERS.fullmatch(value) is not None


def require_live_environment(provider: str) -> None:
"""Raise :class:`LiveProviderDisabledError` unless live calls are explicitly enabled.

Checks, in order:

1. ``BENCHMARK_LIVE_PROVIDERS_ENABLED`` is set to a truthy value.
2. The provider-specific API key environment variable (see
:data:`PROVIDER_API_KEY_ENV`) is set and non-empty.
:data:`PROVIDER_API_KEY_ENV`) is set and non-empty; for a keyless provider,
its :data:`LIVE_LATCH_ENV` variable instead, and nothing else.
3. That variable's raw value uses only ``[A-Za-z0-9_.-]`` (an HTTP client error
would quote any other character).

Expand All @@ -89,6 +101,14 @@ def require_live_environment(provider: str) -> None:
f"for provider {provider!r} (this does not by itself enable live calls; "
"see benchmarks/adapters/guard.py)"
)
latch = LIVE_LATCH_ENV.get(provider)
if latch is not None: # a keyless provider: its latch, and never a key
if not os.environ.get(latch, "").strip():
raise LiveProviderDisabledError(
f"live provider calls are disabled: missing required {latch} for "
f"provider {provider!r}"
)
return
key_env = PROVIDER_API_KEY_ENV.get(provider)
if key_env is None:
raise LiveProviderDisabledError(f"unknown provider for live guard: {provider!r}")
Expand All @@ -98,7 +118,7 @@ def require_live_environment(provider: str) -> None:
f"live provider calls are disabled: missing required {key_env} for "
f"provider {provider!r}"
)
if not _KEY_CHARACTERS.fullmatch(raw_key):
if not valid_api_key(raw_key):
raise MalformedApiKeyError(
f"live provider calls are disabled: {key_env} holds a character outside "
"[A-Za-z0-9_.-]"
Expand Down
Loading
Loading