feat(clustering): campaign-clusterer worker + bus topics + CLI
The campaign clusterer worker mirrors the identity-side worker shell (bus connect, heartbeat, control listener, slow-tick fallback) but wakes on identity.> instead of attacker.> — campaign-level work is gated on identity-layer changes, not raw observations. The connected-components implementation reads identities via list_identities_for_clustering, projects them with from_identity_row, runs union-find over combined_campaign_weight, writes campaigns rows, sets attacker_identities.campaign_id, and runs the same revocable- merge pass as the identity layer (a merged-out campaign whose identities no longer co-cluster with the winner gets revoked). Bus: adds campaign.> family (formed / identity.assigned / merged / unmerged) plus the cross-family identity.campaign.assigned so existing identity-stream subscribers see the badge update without having to subscribe to campaign.>. Wiki Service-Bus.md updated in wiki-checkout in the same wave per the project's bus-signals discipline. CLI: decnet campaign-clusterer registered as master-only via MASTER_ONLY_COMMANDS; --poll-interval / --daemon mirror the identity clusterer command surface.
This commit is contained in:
31
decnet/clustering/campaign/factory.py
Normal file
31
decnet/clustering/campaign/factory.py
Normal file
@@ -0,0 +1,31 @@
|
||||
"""Campaign-clusterer factory.
|
||||
|
||||
Mirrors :mod:`decnet.clustering.factory` for the campaign layer.
|
||||
Configuration knob ``DECNET_CAMPAIGN_CLUSTERER_TYPE``; default
|
||||
``"connected_components"``.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
from decnet.clustering.campaign.base import CampaignClusterer
|
||||
|
||||
_KNOWN: tuple[str, ...] = ("connected_components",)
|
||||
_DEFAULT = "connected_components"
|
||||
|
||||
|
||||
def get_campaign_clusterer() -> CampaignClusterer:
|
||||
name = os.environ.get(
|
||||
"DECNET_CAMPAIGN_CLUSTERER_TYPE", _DEFAULT,
|
||||
).strip().lower()
|
||||
if name == "connected_components":
|
||||
from decnet.clustering.campaign.impl.connected_components import (
|
||||
ConnectedComponentsCampaignClusterer,
|
||||
)
|
||||
return ConnectedComponentsCampaignClusterer()
|
||||
raise ValueError(
|
||||
f"Unknown campaign clusterer: {name!r}. Known: {_KNOWN}"
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["get_campaign_clusterer"]
|
||||
Reference in New Issue
Block a user