verification
Assert that Output Protection (OP) actually took effect in vLLM, and refuse to serve if it did not.
The failure mode that matters here is not a crash, but a server that starts via vllm serve, skips OP, and thus
returns plaintext outputs.
This module closes that gap:
inject_verificationwrapsbuild_appand asserts every OP invariant against the application that was actually built, raising before the server accepts a single request.- Loads the declared
vllm.general_pluginsentry points exactly as vLLM does, but without vLLM'sexcept Exceptionaround the import, and asserts the process-wide invariants. This runs at image build time and catches the one case no runtime hook can: a plugin module that fails to import, which vLLM catches, logs, and skips at runtime.
Warning
Under almost no circumstances should you need to import this module directly. If stainedglass_output_protection is installed, vLLM
loads it automatically via the vllm.general_plugins entry point.
Functions:
| Name | Description |
|---|---|
assert_output_protection_active |
Verify that Output Protection is active on a freshly built FastAPI application. |
inject_verification |
Assert that Output Protection is active on the application. |
output_protection_plugins |
Find this package's |
self_check |
Load the declared vLLM plugins the way vLLM does and assert the process-wide patches are applied. |
assert_output_protection_active
¶
Verify that Output Protection is active on a freshly built FastAPI application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
FastAPI
|
The application returned by vLLM's |
required |
|
Namespace
|
The parsed command-line arguments the application was built from. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If any Output Protection invariant does not hold. |
inject_verification
¶
inject_verification(
build_app_func: BuildAppFunc,
) -> middleware.BuildAppFunc
Assert that Output Protection is active on the application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
BuildAppFunc
|
Function that builds the vLLM OpenAI-compatible FastAPI application. |
required |
Returns:
| Type | Description |
|---|---|
middleware.BuildAppFunc
|
A new function with the same signature as |
output_protection_plugins
¶
Find this package's vllm.general_plugins entry points.
Returns:
| Type | Description |
|---|---|
list[importlib.metadata.EntryPoint]
|
Every installed |
self_check
¶
Load the declared vLLM plugins the way vLLM does and assert the process-wide patches are applied.
Unlike vLLM's own plugin loader this does not swallow import errors. An unimportable plugin module is logged and skipped by vLLM, leaving a server that serves plaintext.
This check is intended for image build time.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no Stained Glass plugin entry points are installed. |
RuntimeError
|
If a patch that does not depend on a built application failed to apply. |