crumbs library

Magic ↔ crumbs integration adapter barrel.

Import this file when your app uses both magic and crumbs and wants the MagicCrumbsIntegration watchers wired into CrumbsPlugin. Consumers MUST add magic_devtools as a regular dependency (lib/main.dart imports it under !kReleaseMode, so a dev_dependency would trip depend_on_referenced_packages); it depends on magic and crumbs, so transitive resolution does not happen through magic itself.

Host integration (debug-only in lib/main.dart). MagicCrumbsIntegration MUST run AFTER Magic.init() because MagicHttpFacadeAdapter resolves the NetworkDriver via the IoC container. CrumbsPlugin itself installs BEFORE Magic.init(), and so does the opt-in ExceptionWatcher that catches Magic boot errors:

if (!kReleaseMode) {
  CrumbsPlugin.install();
  CrumbsPlugin.registerWatcher(ExceptionWatcher());
  CrumbsPlugin.registerWatcher(DumpWatcher());
}
await Magic.init(configFactories: [...]);
if (!kReleaseMode) {
  MagicCrumbsIntegration.install();
}

See src/crumbs_integration.dart for the concrete MagicCrumbsIntegration class, its 6 Magic watchers, and MagicHttpFacadeAdapter.

Classes

MagicCacheWatcher
CrumbsWatcher for Magic's cache facade.
MagicCrumbsIntegration
Glues magic's Http / Model / Cache / Log facades into the crumbs store.
MagicEventWatcher
CrumbsWatcher for magic's app-event surface (auth, db, gate definitions). Excludes model lifecycle events (owned by MagicModelWatcher) and the gate-result event (owned by MagicGateWatcher) to keep each record on a single channel.
MagicGateWatcher
CrumbsWatcher for magic's gate-result event. Subscribes to the canonical GateAccessChecked (covers both allow and deny outcomes via allowed: bool); the convenience GateAccessDenied event is NOT subscribed to because it would double-record every denial.
MagicHttpFacadeAdapter
CrumbsHttpAdapter that captures every request flowing through Magic's network driver and feeds CrumbsStore.recordHttp.
MagicLogWatcher
CrumbsWatcher for magic's Log facade, feeding CrumbsStore.recordLog.
MagicModelWatcher
CrumbsWatcher that subscribes to ModelCreated, ModelSaved, ModelDeleted and feeds CrumbsStore.recordModel.
MagicQueryWatcher
CrumbsWatcher for magic's QueryExecuted event (dispatched by QueryBuilder after every SQL run). Captures sql + bindings + timeMs + connection into a QueryRecord; surfaces via crumbs:queries CLI / crumbs_queries MCP tool.