Rename planner and document rewrite: rewrite_documents moves qualified names of the renamed flow in every flow (ports, inputs, outputs) and dashboard binding (one key table, WIDGET_BINDINGS, shared with the WidgetDef accessors, legacy pages included), published and draft, as plain JSON with both variants above either version; plan_rename reports documents, counts, fingerprint, warnings and refusals; superuser plan routes for flows and dashboards; key residue classifies state as the mapper does; duplicate retargets inputs and outputs too; queue reports its Redis version and other consumers

This commit is contained in:
2026-11-02 21:06:39 +01:00
parent 81bd7c2724
commit fa2a213631
14 changed files with 1922 additions and 41 deletions
+10 -16
View File
@@ -39,6 +39,7 @@ from fluksio.flow.demand import demand
from fluksio.flow.events import EventBus
from fluksio.flow.executor import ExecutionService
from fluksio.flow.messages import MessageSpec, flow_of, qualify
from fluksio.flow.namespace import touches
from fluksio.flow.nodes import (
RESERVED_SETTINGS,
AssistantNode,
@@ -1894,20 +1895,21 @@ class FlowController:
if self.execution is not None:
self.execution.queue.clear_flow(flow)
with self.state.lock():
for key in [k for k in self.state.keys() if _in_namespace(k, flow)]:
for key in [k for k in self.state.keys() if touches(flow, k)]:
self.state.delete(key)
def key_residue(self, flow: str) -> list[str]:
"""What still lives under the flow key *flow*. Blocking.
State and live queue work in its namespace: left by a flow that held
the key before, or put there by anything still writing to it. A new
flow taking the key would inherit it, so creating one is refused while
this is not empty, and so is renaming a flow onto it. Work that was
acknowledged, dead-lettered or marked done is history and not counted.
Names what it found, state keys first.
State and live queue work in its namespace, judged as a rename maps
it (`namespace.touches`): left by a flow that held the key before, or
put there by anything still writing to it. A new flow taking the key
would inherit it, so creating one is refused while this is not empty,
and so is renaming a flow onto it. Work that was acknowledged,
dead-lettered or marked done is history and not counted. Names what it
found, state keys first.
"""
found = [key for key in self.state.keys() if _in_namespace(key, flow)]
found = [key for key in self.state.keys() if touches(flow, key)]
if self.execution is not None:
found += [
f"queued work of '{item.node}'"
@@ -2010,14 +2012,6 @@ class FlowController:
self.events.publish(event)
def _in_namespace(state_key: str, flow: str) -> bool:
"""Whether a state key is about the flow key *flow*: one of its messages,
or the engine's own bookkeeping on one of its messages or nodes, which is
keyed by those names too."""
prefix = f"{flow}."
return state_key.startswith(prefix) or f":{prefix}" in state_key
def _touches(item: WorkItem, flow: str) -> bool:
"""Whether a queued item names anything of the flow key *flow*: as its
flow, its node or one of the messages it carries."""