Module

_config_schema

ServerConfig introspection — JSON Schema export and redacted view.

Two entry points, both consumed by thepounce configsubcommands:

  • build_schema() / build_toml_template() — emit a JSON Schema (Draft 2020-12) or commentedpounce.tomltemplate from the ServerConfigdataclass. Enables agents and humans to discover the config surface without reading source.
  • redacted_config_view() + INFO_ALLOWLIST— produce the fail-closed redacted view used bypounce config showand the Sprint 4 /_pounce/infoendpoint. Every field must appear in the allowlist; absent fields are implicitly redacted.

Design notes:

  • No new runtime dependencies. Stdlib-only (dataclasses, typing, json).
  • Deterministic output: properties are emitted in sorted order so golden snapshots remain stable.
  • Internal / callable / opaque fields (the_IIC_SKIP_FIELDSset in config.py) are skipped in both schema and redacted view.

Functions

_strip_none 1 tuple[Any, bool]
For ``X | None``, return ``(X, True)``. Else ``(tp, False)``.
def _strip_none(tp: Any) -> tuple[Any, bool]
Parameters
Name Type Description
tp Any
Returns
tuple[Any, bool]
_map_type 1 dict[str, Any] | None
Return a JSON Schema fragment for *tp*, or None to drop the field.
def _map_type(tp: Any) -> dict[str, Any] | None
Parameters
Name Type Description
tp Any
Returns
dict[str, Any] | None
_collect_enum_fields 1 dict[str, frozenset[str]]
Harvest enum constraints from ``_VALID_S`` dataclass fields. ``_VALID_LOG_LEVE…
def _collect_enum_fields(cls: type) -> dict[str, frozenset[str]]

Harvest enum constraints from_VALID_<NAME>Sdataclass fields.

_VALID_LOG_LEVELSlog_level.

Parameters
Name Type Description
cls type
Returns
dict[str, frozenset[str]]
build_schema 1 dict[str, Any]
Build a JSON Schema Draft 2020-12 document for a dataclass. The schema is dete…
def build_schema(cls: type = ServerConfig) -> dict[str, Any]

Build a JSON Schema Draft 2020-12 document for a dataclass.

The schema is deterministic: properties are sorted alphabetically so golden-snapshot tests stay stable across runs.

Parameters
Name Type Description
cls type Default:ServerConfig
Returns
dict[str, Any]
_toml_value 1 str
Render a Python default as a TOML literal.
def _toml_value(v: Any) -> str
Parameters
Name Type Description
v Any
Returns
str
build_toml_template 1 str
Emit a commented TOML template for *cls*, one field per line. ``pounce.toml`` …
def build_toml_template(cls: type = ServerConfig) -> str

Emit a commented TOML template for cls, one field per line.

pounce.tomlputs config keys at the top level (no section header) — the loader in_config_file.pytreats the whole file as config. Users who want[tool.pounce]for pyproject.toml can copy the same commented lines under that heading.

Parameters
Name Type Description
cls type Default:ServerConfig
Returns
str
_is_set 1 bool
Interpret ``REDACT_TO_BOOL`` — True when the field has a meaningful value.
def _is_set(value: Any) -> bool
Parameters
Name Type Description
value Any
Returns
bool
redacted_config_view 1 dict[str, Any]
Return a redacted dict view of *cfg* suitable for ``/info`` or ``config show``.…
def redacted_config_view(cfg: ServerConfig) -> dict[str, Any]

Return a redacted dict view of cfg suitable for/info or config show.

EXPOSE fields keep their values; REDACT_TO_BOOL fields become <field>_set: bool; every other field is omitted entirely.

Parameters
Name Type Description
cfg ServerConfig
Returns
dict[str, Any]
_coerce_for_json 1 Any
Coerce a ServerConfig value into JSON-serializable form.
def _coerce_for_json(value: Any) -> Any
Parameters
Name Type Description
value Any
Returns
Any
assert_allowlist_covers_config 0 list[str]
Return a list of ServerConfig fields missing from INFO_ALLOWLIST. Used by ``te…
def assert_allowlist_covers_config() -> list[str]

Return a list of ServerConfig fields missing from INFO_ALLOWLIST.

Used bytests/unit/test_config_schema.pyto guarantee that adding a new field to ServerConfig without updating the allowlist fails CI.

Returns
list[str]