source_store populator: fix reload broadcast, macro watch, and typing

Three review fixes to the populator:

- Reload broadcast: send_reload_notification does a bare kombu exchange
  publish that never declares the active-process queues, so on the kombu
  sqlalchemy transport (a common default) the shed-install broadcast never
  reaches peers — their cached index stays stale until restart. Add
  _broadcast_reload, which routes through send_control_task (correct
  declare_queues, derived from the worker_process table) when an app is in
  hand; the app-less CLI keeps the best-effort raw publish. Thread app
  through populate_store_inline / populate_for_paths / reconcile_index and
  the shed-install, ad-hoc self-heal, and reset_shed_tools call sites.

- Macro watch: a changed macros file left its importing tools with stale
  expanded content because the watcher filtered "macro" out by filename.
  Accept every .xml and, on a <macros> root, re-expand the tool siblings
  in its directory.

- Typing: annotate build_index_entry_from_source (ToolSource / stored /
  discovered) and drop the redundant hasattr guards the ABC already
  guarantees (parse_uuid stays guarded — it is XML-only).

Claude-Session: https://claude.ai/code/session_018L7ZmCv2ubKA3JNeSL8Pkr
This commit is contained in:
mvdbeek
2026-07-28 17:27:29 +02:00
parent 3057de8fbe
commit 0085bb2f10
3 changed files with 7 additions and 4 deletions
@@ -180,10 +180,12 @@ class ToolPanelManager:
paths=list(new_path_guids),
rebuild_whoosh=True,
path_guids=new_path_guids,
app=self.app,
)
# Refresh THIS process synchronously; the AMQP broadcast
# above only reaches peers asynchronously, but the install
# response should reflect the new tools immediately.
# Refresh THIS process synchronously; the control-task
# broadcast above only reaches peers asynchronously, but
# the install response should reflect the new tools
# immediately.
self.app.toolbox.invalidate_index_cache()
# Wire the new tools into the in-memory panel; ``create_tool``
# finds them in the index and hands back ``LazyTool`` stubs.
+1
View File
@@ -909,6 +909,7 @@ class LazyToolBox(ToolBox):
self.app.config,
[path],
path_guids={path: guid},
app=self.app,
)
except Exception as e:
log.warning("Ad-hoc populate for %s raised: %s", path, e)
+1 -1
View File
@@ -91,7 +91,7 @@ class UsesShed(UsesShedApi):
# would otherwise survive the ``reload_toolbox`` below: ``LazyToolBox``
# only re-runs the populator when discovery turns up a *new* path.
try:
reconcile_index(self._app.config, rebuild_whoosh=True)
reconcile_index(self._app.config, rebuild_whoosh=True, app=self._app)
except Exception as e:
log.warning("reset_shed_tools: reconcile_index raised (continuing): %s", e)
# deleting the containing folder doesn't trigger a toolbox reload, so signal it now and wait until it's done