mirror of
https://github.com/element-hq/synapse.git
synced 2026-08-14 09:20:49 +00:00
`_Sentinel` and its `SENTINEL_CONTEXT` singleton — the root "no logcontext" marker — are now a native pyclass owned by the Rust logcontext module, which already owns the "current context" storage. Rust both defines the type and creates the one instance lazily, so the `register_sentinel` bootstrap (Python constructing the sentinel and pushing it into the Rust slot to dodge a circular import) is gone: the module exports `SENTINEL_CONTEXT` directly. Kept as a separate class from `LoggingContext` (the Null Object pattern, as upstream has it): the sentinel is falsy, inert (all methods no-op), and thread-agnostic, the opposite of an active thread-affine context. Merging would scatter `is_sentinel` branches through `__bool__` and every accounting method. Invariants preserved: `current_context() is SENTINEL_CONTEXT`, `bool()` is False, `str()` is "sentinel", and `server_name` is "unknown_server_from_sentinel_context" (read by the log filter). Verified via 95 trial tests + a Rust≡Python identity/bool/round-trip script; full lint clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JFbRtswu7rsHrttJFauUUb