From dac33611113e7963d82fe30bb8ab36c5b8ea35fa Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Tue, 21 Apr 2026 23:40:16 +0100 Subject: [PATCH] Added "reserved" workspaces will make it easier to have a workspace template --- .../trustgraph/config/service/service.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/trustgraph-flow/trustgraph/config/service/service.py b/trustgraph-flow/trustgraph/config/service/service.py index 56a54ee0..058f4e4b 100644 --- a/trustgraph-flow/trustgraph/config/service/service.py +++ b/trustgraph-flow/trustgraph/config/service/service.py @@ -24,6 +24,21 @@ logger = logging.getLogger(__name__) default_ident = "config-svc" + +def is_reserved_workspace(workspace): + """Reserved workspaces are storage-only. + + Any workspace id beginning with ``_`` is reserved for internal use + (e.g. ``__template__`` holding factory-default seed config). + Reads and writes work normally so bootstrap and provisioning code + can use the standard config API, but **change notifications for + reserved workspaces are suppressed**. Services subscribed to the + config push therefore never see reserved-workspace events and + cannot accidentally act on template content as if it were live + state. + """ + return workspace.startswith("_") + default_config_request_queue = config_request_queue default_config_response_queue = config_response_queue default_config_push_queue = config_push_queue @@ -130,6 +145,21 @@ class Processor(AsyncProcessor): async def push(self, changes=None): + # Suppress notifications from reserved workspaces (ids starting + # with "_", e.g. "__template__"). Stored config is preserved; + # only the broadcast is filtered. Keeps services oblivious to + # template / bootstrap state. + if changes: + filtered = {} + for type_name, workspaces in changes.items(): + visible = [ + w for w in workspaces + if not is_reserved_workspace(w) + ] + if visible: + filtered[type_name] = visible + changes = filtered + version = await self.config.get_version() resp = ConfigPush(