wm-tools 9.1.9

Curated tool implementations for the WhiteMagic MCP server.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
//! Expansion tools — 77 tool implementations organized by category.
//!
//! Modules:
//! - `memory_ops`: consolidate, decay, batch_read, update, tag, stats, hybrid_recall, sort, filter, deduplicate, export
//! - `session`: start, checkpoint, recall, end
//! - `consciousness`: citta.status, citta.reflect, dream.status, dream.trigger
//! - `tools_mgmt`: usage_report, effectiveness_report, retire
//! - `patterns`: pattern.search, salience.spotlight, serendipity.surface
//! - `constellation`: detect, list
//! - `galaxy`: stats, export, import, transfer, merge, snapshot, restore, dashboard, backup, taxonomy, purge, health
//! - `karma`: history, clear
//! - `dharma`: rules, audit
//! - `agents`: register, list, heartbeat, trust, descriptions, capabilities, heartbeat.history, deregister
//! - `tasks`: distribute, status
//! - `system`: health, config, flush
//! - `association`: associate_mine
//! - `network`: association.mine, pattern.detect, emergence.report, network.stats, network.centrality, network.clusters
//! - `additional`: count, tags, session_list, citta_coherence, dharma_profiles, nearby
//! - `autonomous`: spiral.report, consolidation.connect/compress, emergence.scan, retention.prune
//! - `knowledge_graph`: kg.extract, kg.query, kg.top
//! - `graph`: graph.walk, graph.community, graph.propagate
//! - `archaeology`: archaeology.search, learning.pattern, learning.suggest
//! - `reasoning`: reasoning.bicameral, think, explain
//! - `pipeline`: pipeline.create/list/status, skill.invoke/list
//! - `anomaly`: anomaly.detect, state.snapshot, state.revert
//! - `correlation`: correlation.analyze, god.nodes, kaizen.correlate
//! - `geneseed`: geneseed.mine, geneseed.stats
//! - `boundary`: anti_loop.check, boundary.enforce
//! - `homeostasis`: homeostasis.check, homeostasis.adjust, homeostasis.history, homeostasis.alerts
//! - `transaction`: transaction.begin, transaction.commit, transaction.rollback

#![forbid(unsafe_code)]

pub mod additional;
pub mod agents;
pub mod anomaly;
pub mod archaeology;
pub mod army;
pub mod association;
pub mod autonomous;
pub mod bagua;
pub mod bayesian_tools;
pub mod bicameral;
pub mod boundary;
pub mod bounty_connector;
pub mod bounty_evidence;
pub mod bounty_ledger;
pub mod breaker_tools;
pub mod captains;
pub mod claims_tools;
pub mod code;
pub mod common;
pub mod conformal;
pub mod consciousness;
pub mod constellation;
pub mod coordination;
pub mod correlation;
pub mod dharma;
pub mod drive;
pub mod firewall;
pub mod galaxy;
pub mod geneseed;
pub mod glyph;
pub mod governance_tools;
pub mod graph;
pub mod homeostasis;
pub mod imagination;
pub mod karma;
pub mod knowledge_graph;
pub mod lkep;
pub mod memory_ops;
pub mod mesh_tools;
pub mod network;
pub mod nlu_tools;
pub mod oss_bounty;
pub mod patterns;
pub mod pipeline;
pub mod pray;
pub mod reasoning;
pub mod research;
pub mod resonance;
pub mod rsi;
pub mod sandbox;
pub mod sangha_tools;
pub mod security_breaker;
pub mod security_probe;
pub mod self_play;
pub mod selfmodel;
pub mod sensorimotor_tools;
pub mod session;
pub mod session_ops;
pub mod simulation_tools;
pub mod system;
pub mod tasks;
pub mod telemetry_tools;
pub mod tools_mgmt;
pub mod transaction;
pub mod v4;
pub mod violet;
pub mod web;

// Re-export all tool structs for registration
pub use additional::{
    CittaCoherenceTool, DharmaProfilesTool, MemoryCountTool, MemoryNearbyTool, MemoryTagsTool,
    SessionListTool,
};
pub use agents::{
    AgentCapabilitiesTool, AgentDeregisterTool, AgentDescriptionsTool, AgentHeartbeatHistoryTool,
    AgentHeartbeatTool, AgentListTool, AgentRegisterTool, AgentTrustTool,
};
pub use anomaly::{AnomalyDetectTool, StateRevertTool, StateSnapshotTool};
pub use archaeology::{ArchaeologySearchTool, LearningPatternTool, LearningSuggestTool};
pub use army::{ArmyDeployTool, GalacticColdRotateTool, GalacticTriageTool};
pub use association::{MemoryAssociateMineTool, MemoryCorroborateTool, MemoryRelateTool};
pub use autonomous::{
    ConsolidationCompressTool, ConsolidationConnectTool, EmergenceScanTool, RetentionPruneTool,
    SensorimotorScanTool, SpiralReportTool,
};
pub use bagua::BaguaDispatchTool;
pub use bayesian_tools::{McOptimizeTool, McSurrogateTool};
pub use bicameral::{BicameralReasonTool, BicameralStatusTool};
pub use boundary::{AntiLoopCheckTool, BoundaryEnforceTool};
pub use captains::{CaptainDeployTool, HologramQueryTool, HologramRebalanceTool};
pub use claims_tools::{ClaimsTool, register_claims};
pub use consciousness::{
    ApotheosisCheckTool, CittaHistoryTool, CittaReflectTool, CittaStatusTool,
    ConsciousnessDepthTool, DreamAnalyzeTool, DreamStatusTool, DreamTriggerTool, SmaranaStatusTool,
    SmaranaTraceTool,
};
pub use constellation::{ConstellationDetectTool, ConstellationListTool};
pub use coordination::{
    CodeCheckTool, CodeClaimTool, CodeListTool, CodeReleaseTool, Lease, LeaseLedger,
    register_coordination,
};
pub use correlation::{CorrelationAnalyzeTool, GodNodesTool, KaizenCorrelateTool};
pub use dharma::{
    DharmaAcsTool, DharmaAuditTool, DharmaEscalateTool, DharmaResolveReviewTool,
    DharmaReviewQueueTool, DharmaRulesTool,
};
pub use drive::{DriveEventTool, DriveSnapshotTool};
pub use galaxy::{
    GalaxyBackupTool, GalaxyDashboardTool, GalaxyExportTool, GalaxyHealthTool, GalaxyImportTool,
    GalaxyMergeTool, GalaxyPurgeTool, GalaxyRestoreTool, GalaxySnapshotTool, GalaxyStatsTool,
    GalaxyTaxonomyTool, GalaxyTransferTool,
};
pub use geneseed::{GeneseedMineTool, GeneseedStatsTool};
pub use governance_tools::{
    CouncilDeliberateTool, HermitMediateTool, HermitResolveTool, HermitStatusTool,
    HermitWithdrawTool, register_governance_tools,
};
pub use graph::{GraphCommunityTool, GraphPropagateTool, GraphWalkTool};
pub use homeostasis::{
    HomeostasisAdjustTool, HomeostasisAlertsTool, HomeostasisCheckTool, HomeostasisHistoryTool,
};
pub use imagination::{
    ImaginePredictTool, ImagineReflectTool, ImagineScenarioTool, register_imagination,
};
pub use karma::{KarmaAnchorTool, KarmaClearTool, KarmaHistoryTool, KarmaVerifyChainTool};
pub use knowledge_graph::{KgExtractTool, KgQueryTool, KgTopTool};
pub use memory_ops::{
    MemoryAggregateTool, MemoryBatchReadTool, MemoryConsolidateTool, MemoryDecayTool,
    MemoryDeduplicateTool, MemoryEpisodicSearchTool, MemoryExportTool, MemoryFilterTool,
    MemoryHybridRecallTool, MemoryRecallFeedbackTool, MemoryReembedTool, MemoryRevisionsTool,
    MemorySortTool, MemoryStatsTool, MemoryTagTool, MemoryUpdateTool,
};
pub use mesh_tools::{
    MeshChatTool, MeshJoinTool, MeshQuarantineTool, MeshReadTool, MeshStatusTool,
    register_sangha_mesh,
};
pub use network::{
    AssociationMineTool, EmergenceReportTool, NetworkCentralityTool, NetworkClustersTool,
    NetworkStatsTool, PatternDetectTool,
};
pub use nlu_tools::NluShadowReportTool;
pub use patterns::{PatternSearchTool, SalienceSpotlightTool, SerendipitySurfaceTool};
pub use pipeline::{
    PipelineCreateTool, PipelineListTool, PipelineStatusTool, SkillInvokeTool, SkillListTool,
};
pub use pray::{HongmenRank, PrayMetaTool, WhiteLotusLodge};
pub use reasoning::{ExplainTool, ReasoningBicameralTool, ThinkTool};
pub use research::{
    ResearchRabbitHoleTool, ResearchRepoTool, ResearchTopicTool, register_research,
};
pub use resonance::{BusEmitTool, BusRecentTool, BusStatsTool};
pub use rsi::{
    ActiveProposalsTool, DispatchTelemetry, FrictionAutoLogTool, FrictionLogTool,
    FrictionResolveTool, FrictionReviewTool, ImproveProposalsTool, RedteamCoverageReportTool,
    RedteamFromFrictionTool, RedteamProposalsTool, friction_hash, friction_hash_exists,
};
pub use sangha_tools::{
    SanghaChatTool, SanghaDiscoverTool, SanghaLocksTool, SanghaPeersTool, SanghaQuarantineTool,
    SanghaSignalTool,
};
pub use self_play::{
    SelfPlayExportTool, SelfPlayRunTool, SelfPlayStatusTool, SharedSelfPlayLoop,
    build_self_play_loop, new_shared_loop, register_self_play,
};
pub use sensorimotor_tools::{
    ActuatorCommandTool, ActuatorEStopTool, ActuatorListTool, ReflexAddTool, ReflexEvaluateTool,
    ReflexListTool, SensorHistoryTool, SensorListTool, SensorPollTool, SensorReadTool,
};
pub use session::{
    SessionCheckpointNodiscoveryTool, SessionCheckpointTool, SessionEndTool, SessionRecallTool,
    SessionStartTool, SessionVerifyTool,
};
pub use session_ops::{
    SessionContinuityTool, SessionDigestTool, SessionExportTool, SessionHandoffTool,
    SessionImportTool, SessionRecordTool, SessionReplayTool, register_session_ops,
};
pub use simulation_tools::{SimCounterfactualTool, SimForecastTool, SimMcTool};
pub use system::{SystemConfigTool, SystemFlushTool, SystemHealthTool};
pub use tasks::{TaskDistributeTool, TaskStatusTool};
pub use tools_mgmt::{ToolsEffectivenessReportTool, ToolsRetireTool, ToolsUsageReportTool};
pub use transaction::{
    TransactionBeginTool, TransactionCommitTool, TransactionRollbackTool, TransactionState,
};
pub use v4::{
    ReflexDispatchTool, ReflexStatusTool, TimescaleHooksTool, TimescaleStatusTool,
    WorkspaceEventsTool, WorkspacePublishTool, WorkspaceSpotlightTool, WorkspaceStatsTool,
};
pub use web::{WebDeepFetchTool, WebFetchTool, WebSearchAndReadTool, WebSearchTool, register_web};

use std::sync::Arc;
use wm_cognitive::GanYingBus;
use wm_governance::KarmaLedger;
use wm_memory::{AssociationStore, MemoryStore, RecallEngine, SearchEngine};
use wm_substrate::SubstrateMonitor;
use wm_substrate::anomaly::AnomalyDetector;
use wm_substrate::homeostatic::HomeostaticLoop;
use wm_substrate::sensorimotor::{ReflexLoop, SensorimotorBus};

/// Build the PRAY meta-tool with the same cleanup wiring its cold-rotation
/// child receives standalone, so the wrapper never silently degrades it.
fn pray_meta_tool(
    store: &Arc<MemoryStore>,
    search: Option<Arc<SearchEngine>>,
    associations: Arc<AssociationStore>,
) -> Arc<PrayMetaTool> {
    let mut tool = PrayMetaTool::new(store.clone()).with_associations(associations);
    if let Some(search) = search {
        tool = tool.with_search(search);
    }
    Arc::new(tool)
}

/// Build the cold-rotation tool with full cleanup wiring: Tantivy
/// de-indexing plus association cleanup (mirrors `memory.deduplicate`).
fn cold_rotate_tool(
    store: &Arc<MemoryStore>,
    search: Option<Arc<SearchEngine>>,
    associations: Arc<AssociationStore>,
) -> Arc<GalacticColdRotateTool> {
    let mut tool = GalacticColdRotateTool::new(store.clone()).with_associations(associations);
    if let Some(search) = search {
        tool = tool.with_search(search);
    }
    Arc::new(tool)
}

/// Register all expansion tools into a registry.
///
/// Registry persistence is an explicit construction input so evaluator
/// preservation never depends on mutable process-global state.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum RegistryPersistenceMode {
    /// Ordinary writable and readonly servers retain stable Violet identity.
    #[default]
    Normal,
    /// Frozen evaluators use process-local Violet identity and write no keys.
    EvaluatorPreservation,
}

#[allow(clippy::too_many_arguments)]
pub fn register_expansion(
    registry: &wm_dispatch::ToolRegistry,
    store: &Arc<MemoryStore>,
    search: Option<Arc<SearchEngine>>,
    recall: Option<Arc<RecallEngine>>,
    associations: Arc<AssociationStore>,
    spiral_tracker: Arc<std::sync::Mutex<wm_cognitive::SpiralTracker>>,
    karma: Option<Arc<KarmaLedger>>,
    substrate: Option<Arc<SubstrateMonitor>>,
    homeostatic_loop: Option<Arc<std::sync::Mutex<HomeostaticLoop>>>,
    anomaly_detector: Option<Arc<std::sync::Mutex<AnomalyDetector>>>,
    sensorimotor_bus: Option<Arc<std::sync::Mutex<SensorimotorBus>>>,
    reflex_loop: Option<Arc<std::sync::Mutex<ReflexLoop>>>,
    gan_ying_bus: Option<&Arc<std::sync::Mutex<GanYingBus>>>,
    transaction_state: TransactionState,
    resource_rules: Option<&Arc<wm_governance::ResourceRules>>,
    escalation_queue: Option<&Arc<std::sync::Mutex<wm_governance::EscalationQueue>>>,
    dharma_gate: Option<&Arc<wm_governance::DharmaGate>>,
    firewall: Option<&Arc<crate::expansion::firewall::TxFirewall>>,
    code_graph: Option<&Arc<std::sync::Mutex<crate::expansion::code::CodeGraph>>>,
    registry_persistence: RegistryPersistenceMode,
) -> wm_dispatch::ToolRegistry {
    let reg = registry
        // Memory ops (7)
        .register(Arc::new(MemoryConsolidateTool::new(
            store.clone(),
            search.clone(),
        )))
        .register(Arc::new(MemoryDecayTool::new(store.clone())))
        .register(Arc::new(MemoryBatchReadTool::new(store.clone())))
        .register(Arc::new(MemoryUpdateTool::new(store.clone(), search.clone())))
        .register(Arc::new(MemoryRevisionsTool::new(store.clone())))
        .register(Arc::new(MemoryTagTool::new(store.clone())))
        .register(Arc::new(MemoryStatsTool::new(store.clone())))
        .register(Arc::new(
            MemoryHybridRecallTool::new(store.clone(), search.clone(), recall.clone())
                .with_associations(Some(associations.clone())),
        ))
        .register(Arc::new(MemoryRecallFeedbackTool::new(recall)))
        .register(Arc::new(MemoryEpisodicSearchTool::new(store.clone())))
        .register(Arc::new(MemoryAggregateTool::new(
            search.clone(),
            store.clone(),
        )))        // Memory ops Tier 7 (4) — WinnowingBasket
        .register(Arc::new(MemorySortTool::new(store.clone())))
        .register(Arc::new(MemoryFilterTool::new(store.clone())))
        .register(Arc::new(MemoryDeduplicateTool::new(store.clone(), search.clone())))
        .register(Arc::new(MemoryExportTool::new(store.clone())))
        // Session (6)
        .register(Arc::new(
            SessionStartTool::new(store.clone()).with_search(search.clone()),
        ))
        .register(Arc::new(
            SessionCheckpointTool::new(store.clone()).with_search(search.clone()),
        ))
        .register(Arc::new(
            SessionCheckpointNodiscoveryTool::new(store.clone()).with_search(search.clone()),
        ))
        .register(Arc::new(SessionVerifyTool::new(store.clone())))
        .register(Arc::new(SessionRecallTool::new(store.clone())))
        .register(Arc::new(SessionDigestTool::new(store.clone())))
        .register(Arc::new(
            SessionEndTool::new(store.clone()).with_search(search.clone()),
        ))
        // Coordination (4) — advisory claim leases (Phase 2, full surface)
        ;
    let reg = register_coordination(&reg, gan_ying_bus);
    let mut reg = reg
        // Consciousness (4)
        .register(Arc::new(CittaStatusTool::new()))
        .register(Arc::new(CittaReflectTool::new(store.clone())))
        .register(Arc::new(DreamStatusTool::new(store.clone())))
        .register(Arc::new(DreamTriggerTool::new(store.clone())))
        // Tools management (2)
        .register(Arc::new(ToolsEffectivenessReportTool::new()))
        .register(Arc::new(ToolsRetireTool::new()))
        // Patterns (3)
        .register(Arc::new(PatternSearchTool::new(store.clone())))
        .register(Arc::new(SalienceSpotlightTool::new(store.clone())))
        .register(Arc::new(SerendipitySurfaceTool::new(store.clone())))
        // Constellation (2)
        .register(Arc::new(ConstellationDetectTool::new(store.clone())))
        .register(Arc::new(ConstellationListTool::new(store.clone())))
        // Galaxy (12)
        .register(Arc::new(GalaxyStatsTool::new(store.clone())))
        .register(Arc::new(GalaxyExportTool::new(store.clone())))
        .register(Arc::new(GalaxyImportTool::new(store.clone())))
        .register(Arc::new(GalaxyTransferTool::new(
            store.clone(),
            search.clone(),
        )))
        .register(Arc::new(GalaxyMergeTool::new(store.clone())))
        .register(Arc::new(GalaxySnapshotTool::new(store.clone())))
        .register(Arc::new(GalaxyRestoreTool::new(
            store.clone(),
            search.clone(),
        )))
        .register(Arc::new(GalaxyDashboardTool::new(store.clone())))
        .register(Arc::new(GalaxyBackupTool::new(store.clone())))
        .register(Arc::new(GalaxyTaxonomyTool::new(store.clone())))
        .register(Arc::new(GalaxyPurgeTool::new(store.clone(), search.clone())))
        .register(Arc::new(GalaxyHealthTool::new(store.clone())))
        // Tokio Army & Galactic Triage & Cold Rotate (3)
        .register(Arc::new(ArmyDeployTool::new(store.clone())))
        .register(Arc::new(GalacticTriageTool::new(store.clone())))
        .register(cold_rotate_tool(store, search.clone(), associations.clone()))
        // Subagent Captains, 5D Hologram, Bagua Dispatch & PRAY Universal Meta-Tool (5)
        .register(pray_meta_tool(store, search.clone(), associations.clone()))
        .register(Arc::new(CaptainDeployTool::new(store.clone())))
        .register(Arc::new(HologramRebalanceTool::new(store.clone())))
        .register(Arc::new(HologramQueryTool::new(store.clone())))
        .register(Arc::new(BaguaDispatchTool::new(store.clone())))
        // Geneseed pattern miner & stats (2)
        .register(Arc::new(GeneseedMineTool::new(store.clone())))
        .register(Arc::new(GeneseedStatsTool::new(store.clone())))
        // Knowledge graph (3)
        .register(Arc::new(KgExtractTool::new(store.clone())))
        .register(Arc::new(KgQueryTool::new(store.clone())))
        .register(Arc::new(KgTopTool::new(store.clone())))
        // Graph traversal (3)
        .register(Arc::new(GraphWalkTool::new(store.clone())))
        .register(Arc::new(GraphCommunityTool::new(store.clone())))
        .register(Arc::new(GraphPropagateTool::new(store.clone())))
        // Archaeology & learning (3)
        .register(Arc::new(ArchaeologySearchTool::new(store.clone())))
        .register(Arc::new(LearningPatternTool::new(store.clone())))
        .register(Arc::new(LearningSuggestTool::new(store.clone())))
        // Reasoning (3)
        .register(Arc::new(ReasoningBicameralTool::new(store.clone())))
        .register(Arc::new(ThinkTool::new(store.clone())))
        .register(Arc::new(ExplainTool::new(store.clone())))
        // Pipeline & skills (5)
        .register(Arc::new(PipelineCreateTool::new(store.clone())))
        .register(Arc::new(PipelineListTool::new(store.clone())))
        .register(Arc::new(PipelineStatusTool::new(store.clone())))
        .register(Arc::new(SkillInvokeTool::new(store.clone())))
        .register(Arc::new(SkillListTool::new(store.clone())))
        // Anomaly & state (3)
        .register(Arc::new(AnomalyDetectTool::new(store.clone())))
        .register(Arc::new(StateSnapshotTool::new(store.clone())))
        .register(Arc::new(StateRevertTool::new(store.clone())))
        // Correlation & god nodes & Kaizen engine (3)
        .register(Arc::new(CorrelationAnalyzeTool::new(store.clone())))
        .register(Arc::new(GodNodesTool::new(store.clone())))
        .register(Arc::new(KaizenCorrelateTool::new(store.clone())))
        // Anti-loop & boundary (2)
        .register(Arc::new(AntiLoopCheckTool::new(store.clone())))
        .register(Arc::new(BoundaryEnforceTool::new(store.clone())))
        // Karma (2) — only if karma ledger is available
        ;
    if let Some(k) = karma {
        reg = reg
            .register(Arc::new(KarmaHistoryTool::new(k.clone())))
            .register(Arc::new(KarmaVerifyChainTool::new(k.clone())))
            .register(Arc::new(KarmaClearTool::new(k.clone())))
            .register(Arc::new(KarmaAnchorTool::new(k)));
    }
    let mut reg = reg
        // Dharma (3)
        .register(Arc::new(DharmaRulesTool::new()))
        .register(Arc::new(DharmaAuditTool::new(store.clone())))
        .register(Arc::new(DharmaAcsTool::new()))
        // Agents (8)
        .register(Arc::new(AgentRegisterTool::new(store.clone())))
        .register(Arc::new(AgentListTool::new(store.clone())))
        .register(Arc::new(AgentHeartbeatTool::new(store.clone())))
        .register(Arc::new(AgentTrustTool::new(store.clone())))
        .register(Arc::new(AgentDescriptionsTool::new(store.clone())))
        .register(Arc::new(AgentCapabilitiesTool::new(store.clone())))
        .register(Arc::new(AgentHeartbeatHistoryTool::new(store.clone())))
        .register(Arc::new(AgentDeregisterTool::new(
            store.clone(),
            search.clone(),
        )))
        // Tasks (2)
        .register(Arc::new(TaskDistributeTool::new(store.clone())))
        .register(Arc::new(TaskStatusTool::new(store.clone())))
        // System (3)
        .register(Arc::new(
            if let Some(ref se) = search {
                SystemHealthTool::with_search(store.clone(), se.clone())
            } else {
                SystemHealthTool::new(store.clone())
            },
        ))
        .register(Arc::new(SystemConfigTool::new()))
        .register(Arc::new(SystemFlushTool::new(store.clone(), search.clone())))
        // Association mining (1)
        .register(Arc::new(MemoryAssociateMineTool::new(store.clone())))
        // Typed relation tool (V8 S6) — relate + derive_follows
        .register(Arc::new(MemoryRelateTool::new(store.clone())))
        // Bridging consensus counter (2nd PR after Slice B) — corroborate
        .register(Arc::new(MemoryCorroborateTool::new(store.clone())))
        // Additional (5)
        .register(Arc::new(MemoryCountTool::new(store.clone())))
        .register(Arc::new(MemoryTagsTool::new(store.clone())))
        .register(Arc::new(SessionListTool::new(store.clone())))
        .register(Arc::new(CittaCoherenceTool::new()))
        .register(Arc::new(DharmaProfilesTool::new()))
        // Spatial queries (1)
        .register(Arc::new(MemoryNearbyTool::new(store.clone())))
        // Autonomous cycles (4) — Phase E
        .register(Arc::new(ConsolidationConnectTool::new(
            store.clone(),
            associations.clone(),
            spiral_tracker.clone(),
        )))
        .register(Arc::new(ConsolidationCompressTool::new(
            store.clone(),
            associations.clone(),
            spiral_tracker.clone(),
        )))
        .register(Arc::new(EmergenceScanTool::new(
            store.clone(),
            associations.clone(),
            spiral_tracker.clone(),
        )))
        .register(Arc::new(RetentionPruneTool::new(
            store.clone(),
            associations.clone(),
            spiral_tracker.clone(),
        )))
        // Spiral tracker (1) — Phase F
        .register(Arc::new(SpiralReportTool::new(spiral_tracker.clone())))
        // Tier 5: Net tools (6)
        .register(Arc::new(AssociationMineTool::new(store.clone())))
        .register(Arc::new(PatternDetectTool::new(store.clone())))
        .register(Arc::new(EmergenceReportTool::new(store.clone())))
        .register(Arc::new(NetworkStatsTool::new(store.clone())))
        .register(Arc::new(NetworkCentralityTool::new(store.clone())))
        .register(Arc::new(NetworkClustersTool::new(store.clone())))
        // Tier 5: Ghost tools (6)
        .register(Arc::new(SmaranaStatusTool::new(store.clone())))
        .register(Arc::new(SmaranaTraceTool::new(store.clone())))
        .register(Arc::new(ApotheosisCheckTool::new(store.clone())))
        .register(Arc::new(CittaHistoryTool::new(store.clone())))
        .register(Arc::new(DreamAnalyzeTool::new(store.clone())))
        .register(Arc::new(ConsciousnessDepthTool::new(store.clone())));

    // Homeostasis (4) — Tier 7 Dipper — only if substrate monitor is available
    if let Some(sm) = substrate {
        let loop_ = homeostatic_loop
            .unwrap_or_else(|| Arc::new(std::sync::Mutex::new(HomeostaticLoop::default())));
        let detector = anomaly_detector
            .unwrap_or_else(|| Arc::new(std::sync::Mutex::new(AnomalyDetector::default())));
        reg = reg
            .register(Arc::new(HomeostasisCheckTool::new(
                sm.clone(),
                loop_,
                detector.clone(),
            )))
            .register(Arc::new(HomeostasisAdjustTool::new(sm.clone())))
            .register(Arc::new(HomeostasisHistoryTool::new(sm.clone())))
            .register(Arc::new(HomeostasisAlertsTool::new(sm, detector)));
    }

    let _ = &mut reg; // suppress unused_mut warning

    // RSI: Friction logging + improvement + redteam + resolve (7) — Phase 1-3
    reg = rsi::register_rsi(&reg, store, None, &associations, None, None);

    // Sensorimotor tools (10) — Embodiment I/O
    let bus = sensorimotor_bus.unwrap_or_else(|| {
        Arc::new(std::sync::Mutex::new(
            wm_substrate::sensorimotor::linux_hardware_bus(),
        ))
    });
    let reflex = reflex_loop.unwrap_or_else(|| Arc::new(std::sync::Mutex::new(ReflexLoop::new())));
    reg =
        sensorimotor_tools::register_sensorimotor(&reg, bus.clone(), reflex.clone(), gan_ying_bus);

    // Sensorimotor autonomous cycle (1) — Embodiment
    reg = reg.register(Arc::new(SensorimotorScanTool::new(
        store.clone(),
        associations,
        spiral_tracker,
        bus,
        reflex,
    )));

    // Transaction tools (3) — snapshot/rollback for multi-tool sequences
    reg = reg
        .register(Arc::new(TransactionBeginTool::new(
            store.clone(),
            transaction_state.clone(),
        )))
        .register(Arc::new(TransactionCommitTool::new(
            store.clone(),
            transaction_state.clone(),
            search.clone(),
        )))
        .register(Arc::new(TransactionRollbackTool::new(
            store.clone(),
            transaction_state,
            search.clone(),
        )));

    // Imagination tools (3) — scenario generation, prediction, reflection
    reg = register_imagination(&reg, store);

    // Self-play tools (3) — training loop, status, export
    reg = register_self_play(&reg, store, new_shared_loop());

    // Web research tools (4) — fetch, deep_fetch, search, search_and_read
    reg = register_web(&reg);

    // Research tools (3) — topic, repo, rabbit_hole (bus-wired Gan Ying loop)
    reg = register_research(&reg, store, gan_ying_bus);

    // Session ops (4) — record, replay, continuity, handoff
    let telemetry_search = search.clone();
    reg = register_session_ops(&reg, store, search);

    // Dharma escalation (3) — escalate, review_queue, resolve_review
    if let (Some(queue), Some(gate)) = (escalation_queue, dharma_gate) {
        reg = reg
            .register(Arc::new(DharmaEscalateTool::new(
                gate.clone(),
                queue.clone(),
            )))
            .register(Arc::new(DharmaReviewQueueTool::new(queue.clone())))
            .register(Arc::new(DharmaResolveReviewTool::new(queue.clone())));
    }

    // Sandbox tools (2) — set_limits, limits
    reg = crate::expansion::sandbox::register_sandbox(&reg, resource_rules);

    // Transaction firewall (2) — set_policy, status
    if let Some(fw) = firewall {
        reg = crate::expansion::firewall::register_firewall(&reg, fw.clone());
    }

    // Code graph tools (4) — graph, query, affected_by, fragment.search
    if let Some(cg) = code_graph {
        reg = crate::expansion::code::register_code(&reg, cg.clone());
    }

    // Violet security tools (5) — ordinary construction retains stable
    // identities; evaluator preservation keeps the same route topology with
    // fresh process-local keys and no filesystem fallback.
    reg = match registry_persistence {
        RegistryPersistenceMode::Normal => {
            crate::expansion::violet::register_violet_persistent(&reg, &store.path().join("violet"))
        }
        RegistryPersistenceMode::EvaluatorPreservation => {
            crate::expansion::violet::register_violet(&reg)
        }
    };

    // Security circuit breaker (4) — runtime tool-call anomaly monitor
    reg = crate::expansion::security_breaker::register_security_breaker(&reg);

    // Security probe planning (3) — authorized-testing technique plans + triage
    reg = crate::expansion::security_probe::register_security_probe(&reg);

    // Bounty connector (2) — bounty.scan, bounty.import; static-JSON fixture
    // platform is opt-in via WM_BOUNTY_STATIC_JSON (real adapters are follow-ups).
    let board_path = store.path().join("bounty_board.json");
    match crate::expansion::bounty_connector::BountyBoard::open(board_path) {
        Ok(board) => {
            let mut connector =
                crate::expansion::bounty_connector::BountyConnector::new(Arc::new(board));
            if let Ok(fixture) = std::env::var("WM_BOUNTY_STATIC_JSON") {
                connector = connector.with_platform(Arc::new(
                    crate::expansion::bounty_connector::StaticJsonPlatform::new(
                        "static",
                        std::path::PathBuf::from(fixture),
                    ),
                ));
            }
            reg = crate::expansion::bounty_connector::register_bounty(&reg, Arc::new(connector));
        }
        Err(e) => tracing::warn!("bounty board unavailable: {e}"),
    }

    // Bounty ledger (4) — submission tracking + compounding stats
    reg = crate::expansion::bounty_ledger::register_bounty_ledger(
        &reg,
        store.path().join("bounty_ledger.jsonl"),
    );

    // Bounty evidence packager (2) — structured packs + preflight
    reg = crate::expansion::bounty_evidence::register_bounty_evidence(
        &reg,
        store.path().join("evidence"),
    );

    // OSS bounty scanner (2) — GitHub bounty issues via gh (read-only)
    reg = crate::expansion::oss_bounty::register_oss_bounty(&reg);

    // Edge-galaxy telemetry (4) — typed record, hourly rollup, retention prune, read-only planner
    reg = crate::expansion::telemetry_tools::register_telemetry(&reg, store, telemetry_search);

    // Governance & Hermit defense tools (5) — hermit.status, hermit.withdraw, hermit.mediate, hermit.resolve, council.deliberate
    let hermit = Arc::new(std::sync::RwLock::new(
        wm_governance::HermitProtection::new(),
    ));
    reg = crate::expansion::governance_tools::register_governance_tools(&reg, hermit);

    reg
}