refactor: make ClassifiedTimeline.cluster_severities immutable (MappingProxyType) #33

Closed
opened 2026-05-25 18:57:19 -07:00 by pyr0ball · 0 comments
Owner

Context

ClassifiedTimeline is a frozen=True dataclass, but its cluster_severities: dict[str, SeverityLabel] field is a mutable dict. frozen=True only prevents field reassignment — the dict contents can be mutated after construction.

Fix

Wrap with types.MappingProxyType at construction time in classifier.py, and update the field type annotation accordingly.

from types import MappingProxyType

# in classifier.py build site:
return ClassifiedTimeline(
    cluster_severities=MappingProxyType(cluster_severities),
    ...
)

Found by

Post-implementation code review of feat/29-multi-agent-diagnose.

## Context `ClassifiedTimeline` is a `frozen=True` dataclass, but its `cluster_severities: dict[str, SeverityLabel]` field is a mutable dict. `frozen=True` only prevents field *reassignment* — the dict contents can be mutated after construction. ## Fix Wrap with `types.MappingProxyType` at construction time in `classifier.py`, and update the field type annotation accordingly. ```python from types import MappingProxyType # in classifier.py build site: return ClassifiedTimeline( cluster_severities=MappingProxyType(cluster_severities), ... ) ``` ## Found by Post-implementation code review of feat/29-multi-agent-diagnose.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Circuit-Forge/turnstone#33
No description provided.