From 13b3b21387f7cacd405c98d389eeccfc411257c9 Mon Sep 17 00:00:00 2001 From: w4ffl35 <25737761+w4ffl35@users.noreply.github.com> Date: Sat, 19 Sep 2026 12:37:15 -0600 Subject: [PATCH] test(observability): pin the identifier-field shape Guards the capsize_commons.logging adoption: the three correlation keys are carried and an unrelated extra= key cannot leak into the payload. Leaf-only change (tests/test_observability_*.py), used to exercise the CI fast lane added in #53. Refs Capsize-Games/hq#14 --- tests/test_observability_logging.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_observability_logging.py b/tests/test_observability_logging.py index 1c2fa6c..6db4d05 100644 --- a/tests/test_observability_logging.py +++ b/tests/test_observability_logging.py @@ -88,3 +88,28 @@ def test_reset_restores_logger_without_leaking() -> None: reset_logging() after = (_LOGGER.level, _LOGGER.propagate, len(_LOGGER.handlers)) assert after == before + + +def test_only_documented_identifier_fields_are_copied() -> None: + """`identifier_fields` copies the three correlation keys and nothing else. + + Pins the adoption of ``capsize_commons.logging.JsonFormatter``: an + unrelated ``extra=`` key must not leak into the payload, and all three + spikeforge identifiers must be carried. + """ + stream = io.StringIO() + configure_logging(json_mode=True, force=True, stream=stream) + _LOGGER.info( + "train.started", + extra={ + "run_id": "run-1", + "config_id": "cfg-9", + "config_hash": "abc", + "not_a_field": "leak", + }, + ) + payload = json.loads(stream.getvalue().strip()) + assert payload["run_id"] == "run-1" + assert payload["config_id"] == "cfg-9" + assert payload["config_hash"] == "abc" + assert "not_a_field" not in payload