π The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
dream(swarm): #3122 fix TopologyManager.rebalanceHybrid() one-directional adjacency (evaluated, ACCEPT) (#3123)
rUv9f67bb7073a9
diff --git a/docs/dream-cycle/LEDGER.md b/docs/dream-cycle/LEDGER.mdindex 1291deea58..172993c700 100644--- a/docs/dream-cycle/LEDGER.md+++ b/docs/dream-cycle/LEDGER.md@@ -132,7 +132,6 @@ alerting.| 2026-08-18 | memory | hybridSearch controller reachable via explicit opt-in (was silently null-returning despite config flag) | #3056 | #3057 | yes | ACCEPT-scoped | overall recall@10 +0.267; category B (pure-paraphrase) regresses -0.133 | b28714fb... | recovered-live || 2026-08-19 | swarm | MessageBus retry-attempts silently reset to 0 on every re-queue, unbounded redelivery, message.failed unreachable | #3061 | #3062 | yes | ACCEPT | invocations 96-98/0-failed (baseline) β 3/2/1 stable (candidate); 220/220 tests | 62c4fdf7... | 08-14..08-18 all OPEN, none merged yet |-**Recovery note (2026-09-05):** rows for 2026-08-24 through 2026-09-03 wereagain never appended live β same failure class as the 2026-08-19 recoveryabove, now confirmed for a 3rd distinct occurrence. Verified via direct@@ -166,10 +165,10 @@ as a first-class, high-priority candidate, not a background note.| 2026-08-23 | β | **no-run gap** β no branch/PR/issue exists for this date | β | β | no | β | β | β | no-run gap (external, not diagnosed) || 2026-08-24 | swarm | weightedConsensus() trust weights now reach raft/byzantine/gossip vote tally (was architecturally unreachable β no field existed to carry them); [0,1] clamp preserves BFT safety margin | #3085 | #3086 | yes | ACCEPT | gossip flip: flat approved=false β weighted approved=true (0.905 vs 0.50); 226/226 tests, 0 regressions; adversarial critic CONFIRMED-WITH-CAVEATS | 08d44c58... | MERGED 2026-09-14 || 2026-08-25 | performance | HNSW product-quantization: productQuantizeDistance() correctly implemented but zero callers β generic distance ran on raw PQ centroid indices, numerically meaningless; now dispatched, with a disclosed residual isValidPQEncoding() plausibility-heuristic caveat | #3093 | #3094 | yes | ACCEPT | recall@10 0.097 (pre-fix) β 0.270 (post-fix) on deterministic synthetic corpus, ~2.8x; 461/462 tests, 0 regressions | 300da158... | MERGED 2026-09-14 (verified via main's own commit 2d62270) |-| 2026-08-26 | security | authorizeMcpTool() trusted unsigned CLAUDE_FLOW_PRINCIPAL_ID env var as caller identity (ASI07-class); bound already-built ADR-377 Ed25519 verifyInvocationToken into that live chokepoint for DualModeOrchestrator-spawned workers, off by default | #3102 | #3103 | yes | ACCEPT-with-caveats | 6/6 new scenarios pass post-fix, correctly fail/reject pre-fix; 583/583 security, 241/241 codex, 18/18 policy-runtime; 19 pre-existing CLI failures proven identical via stash-diff | fd944eae... | OPEN as of 2026-09-14; rebased onto main (post #3086/#3094/#3110/#3119) and root package-lock.json fixed to add the missing `@claude-flow/security` dep edge codex's CI needs, awaiting fresh CI |+| 2026-08-26 | security | authorizeMcpTool() trusted unsigned CLAUDE_FLOW_PRINCIPAL_ID env var as caller identity (ASI07-class); bound already-built ADR-377 Ed25519 verifyInvocationToken into that live chokepoint for DualModeOrchestrator-spawned workers, off by default | #3102 | #3103 | yes | ACCEPT-with-caveats | 6/6 new scenarios pass post-fix, correctly fail/reject pre-fix; 583/583 security, 241/241 codex, 18/18 policy-runtime; 19 pre-existing CLI failures proven identical via stash-diff | fd944eae... | MERGED 2026-09-14 || 2026-08-27 | intelligence | `distillLearning()`'s EWC forgetting-gate called `getPenalty([oldConf],[newConf])`, collapsing to 1 of 384 Fisher dims β wired in `computeConfidencePenalty`/`updateFisherFromConfidences` (already implemented, 0 prior callers). **Post-review correction (ruvnet):** original hypothesis overclaimed per-pattern discrimination; `computeConfidencePenalty` takes no embedding, so the real fix is "shared full-Fisher-average signal instead of one arbitrary dimension," not per-pattern weighting β hypothesis/gist/tests amended same night, new acceptance test added proving no per-pattern discrimination | #3109 | #3110 | yes | ACCEPT-scoped (narrowed post-review) | baseline: regression test fails (methods never called); candidate: passes. 153/153 tests (+5 new incl. acceptance test), tsc clean | 0df6bc4f... | MERGED 2026-09-14 (verified: PR state=MERGED, mergedAt=2026-09-14T20:46:20Z) || 2026-08-28 | memory | `HybridBackend.queryHybrid()`'s dead `weights` field (computed, never consumed by combineUnion) replaced with real weighted-RRF fusion (`combineWeighted`), matching Qdrant/Weaviate/Azure AI Search's weighted-RRF pattern | #3118 | #3119 | yes | ACCEPT | 461/462 suite green (1 pre-existing unrelated env failure, confirmed identical on baseline); weight-sensitivity test fails on baseline, passes on candidate (git-stash isolated); post-review: added finite/non-negative weight validation + deterministic id-based tie-break | 47e2f669... | MERGED 2026-09-14 (verified via main's own commit fde5b3b) |-| 2026-08-29 | swarm | TopologyManager.rebalanceHybrid() one-directional adjacency bug fixed | #3122 | #3123 | yes | ACCEPT | see issue #3122 | n/a (backfill) | unmerged draft as of 09-05 |+| 2026-08-29 | swarm | `TopologyManager.rebalanceHybrid()`'s worker-mesh loop added edges one-directionally (workerβtarget only, never reciprocated) β same function's coordinator loop and all 3 sibling rebalance*() methods do this correctly; flagged live by 08-24's own night, fixed tonight | #3122 | #3123 | yes | ACCEPT | deterministic (Math.random mocked) regression test: baseline missing reciprocal edge, candidate symmetric; full package 221/221 tests, 0 regressions; independent adversarial critic CONFIRMED | 9c1e9cd4... | rebased onto main (post #3086/#3094/#3103/#3110/#3119 merges), awaiting fresh CI as of 2026-09-14 || 2026-08-30 | performance | unwired diskann-backend.ts removed + stale 150x-12,500x HNSW claim in generated CLAUDE.md corrected | #3129 | #3130 | yes | ACCEPT | see issue #3129 | n/a (backfill) | unmerged draft as of 09-05 || 2026-08-31 | security | MCP governance policy (.harness/mcp-policy.json) was never enforced at runtime β opt-in enforcement wired in | #3138 | #3139 | yes | ACCEPT | see issue #3138 | n/a (backfill) | unmerged draft as of 09-05 || 2026-09-01 | security | maxToolCallsPerTurn was a session-lifetime cumulative cap that never reset β sliding-window reset implemented | #3151 | #3152 | yes | ACCEPT | see issue #3151 | n/a (backfill) | unmerged draft as of 09-05 |diff --git a/docs/dream-cycle/dream-gist-2026-08-29.md b/docs/dream-cycle/dream-gist-2026-08-29.mdnew file mode 100644index 0000000000..240e9bd570--- /dev/null+++ b/docs/dream-cycle/dream-gist-2026-08-29.md@@ -0,0 +1,86 @@+# Swarm SOTA Report β 2026-08-29++TL;DR: Tonight's swarm deep-dive closed the #2 recommendation from 2026-08-24's own night: `TopologyManager.rebalanceHybrid()`'s worker-mesh connection loop (`v3/@claude-flow/swarm/src/topology-manager.ts:524-541`) adds edges one-directionally β `worker.connections.push(target.agentId)` and `adjacencyList.get(worker.agentId)?.add(target.agentId)` β with no reciprocal update on the target's side. This same function's worker-to-coordinator loop, 8 lines below, and all three sibling methods (`rebalanceMesh`, `rebalanceHierarchical`, `rebalanceCentralized`) correctly update both sides. The result: choosing `type: 'hybrid'` silently degrades the intended undirected worker mesh into a random directed graph, where `isConnected(A, B)` and `isConnected(B, A)` can disagree for the same logical edge. Confirmed still live tonight by direct code read (not assumed from the 08-24 report), fixed with a 6-line reciprocal-update patch, and covered by a new deterministic (not probabilistic) regression test. Fresh 2026 literature search found no academic work on this narrow bug class (stated explicitly, not forced), but did surface an active adjacent research area (LLM multi-agent topology adaptation) and a real primary-source competitor check: none of the four major multi-agent frameworks expose a raw, hand-maintained adjacency structure like Ruflo's, making this Ruflo-specific implementation-hygiene work rather than a field-wide gap to catch up on.++## What's New in 2026++| Finding | Source | Confidence |+|---|---|---|+| No academic literature found addressing adjacency-symmetry correctness bugs in distributed/multi-agent topology code specifically β searched 4 query variants, only control-theory results (Laplacian/Fiedler-eigenvalue consensus analysis) returned, none about implementation-level edge-reciprocity defects | Searched arXiv/general web, 2026-08-29; stated as a genuine negative result, not a forced citation | β |+| Active, adjacent 2025-2026 research area: adaptive/dynamic topology reconfiguration for LLM multi-agent systems (AMAS task-conditioned topology selection; Autonomous Topology Mutation proposing safety invariants for runtime restructuring; graph-diffusion-model topology generation) | arXiv:2510.01617, arXiv:2607.20488, arXiv:2510.07799 | A (papers exist, checked directly) |+| None of LangGraph, AutoGen/AG2, CrewAI, or the OpenAI Agents SDK expose a raw, user-manipulable undirected adjacency structure a maintainer must update symmetrically by hand β LangGraph/AG2 edges are directed routing constructs by design, CrewAI/OpenAI SDK expose no graph primitive at all | Official docs for all 4, fetched 2026-08-29 | A/B (see Competitor Comparison) |+| kyegomez/swarms's `MeshSwarm` builds no adjacency structure at all underneath its name β round-robin task queue only, confirmed by direct source read | github.com/kyegomez/swarms `swarming_architectures.py`, fetched 2026-08-29 | A (primary source) |+| A real analog of "graph-construction code silently produces an asymmetric result vs. the intended undirected structure" exists in a graph *library* (not an agent framework): PyTorch Geometric issue #3873 (`to_networkx`/`to_undirected` inconsistency), closed via PR #3948 | github.com/pyg-team/pytorch_geometric#3873 | B (real, verified, different domain) |++## Ruflo Current Capability++`TopologyManager` (`v3/@claude-flow/swarm/src/topology-manager.ts`) maintains an explicit dual representation of the swarm graph: `TopologyNode.connections: string[]` (per-node) plus `adjacencyList: Map<string, Set<string>>` (global). Four `rebalance*()` methods populate it per topology type. Traced end-to-end (full-file read, not grep) before writing any code:++- `rebalanceMesh()` (438-457), `rebalanceHierarchical()` (465-486), `rebalanceCentralized()` (491-511): every edge addition updates **both** endpoints' `connections` array and `adjacencyList` entry.+- `rebalanceHybrid()` (516-541, pre-fix): the worker-mesh loop (524-541) updates **only** the initiating worker's side. Its own worker-to-coordinator loop 8 lines below (`543-557`) β and the analogous logic in the other three methods β updates both sides correctly. This is the one inconsistent code path in the file.++Independently confirmed the bug is exploitable in practice, not merely theoretical: `createEdgesForNode()` (called from `addNode()`) sets `bidirectional: this.config.type === 'mesh'` β so for `'hybrid'` topology, even a node's *initial* connections from `calculateInitialConnections()` are one-directional too. This is a related instance of the same asymmetry class in a different function; **not fixed tonight** (kept out of scope to keep this patch one conceptual change β flagged below).++Practical consequence: any caller that reasons about a hybrid worker's neighbors from `getNeighbors(workerId)`/`isConnected(A, B)` (e.g. `UnifiedCoordinator`'s task/message routing) can get a different answer than the same query from the other endpoint β a real, if narrow, correctness gap in graph-dependent logic, not just a cosmetic edge-count discrepancy.++## Competitor Comparison++| Framework | Explicit peer-mesh/graph construct? | Bidirectional-edge handling |+|---|---|---|+| LangGraph (v1.1.3) | `StateGraph` nodes/edges | Edges are directed control-flow routing transitions by design β not an undirected adjacency structure, so the reciprocal-update failure mode doesn't apply the same way |+| AutoGen/AG2 | `GroupChat` graph-based speaker transitions | Directional by nature (who may speak next); same reasoning as LangGraph |+| CrewAI | None β `Crews`/`Flows` only | No exposed mesh/adjacency structure to become asymmetric |+| OpenAI Agents SDK | None β explicitly documented as having no graph topology to author; handoffs are peer-to-peer directed tool calls | N/A |+| kyegomez/swarms | `MeshSwarm` exists **by name only** β direct source read confirms zero adjacency-list/edge structure, just a round-robin queue | N/A β no real graph underneath the name |++**Verdict**: this is Ruflo-specific implementation hygiene, not a field-wide gap. Every framework surveyed either keeps topology internal to a directed-routing abstraction where one-directional-by-design is correct, or exposes no explicit graph/mesh primitive at all β none maintains a hand-updated symmetric `Map<string, Set<string>>` the way Ruflo's `TopologyManager` does. The one real-world analog found (PyTorch Geometric #3873) confirms the general defect *pattern* (code that's supposed to produce a symmetric structure silently doesn't) is a recognized, recurring class in graph-construction code generally β supporting this as a legitimate correctness bug worth fixing, not a false alarm, even though no directly comparable multi-agent-framework precedent exists to benchmark against.++## Ruview / Ruvector Integration Scan++Both surfaces were scanned in depth 5 nights ago (2026-08-24, issue #3085 Β§10-11: RuView confirmed a "solved-but-unpublished front-end with no verified live back-end" per ADR-326's own text; `@ruvector/tiny-dancer`/`@ruvector/router` confirmed permanent, self-documented non-integrations). Re-verified tonight rather than re-scanned from scratch (nothing material changed, stated explicitly rather than reproducing the same table):++- `product-plane.ts` and ADR-326 last touched 2026-08-12 β no changes since the 08-24 scan.+- `semantic-router.ts`'s in-code comment ("fallback implementation since @ruvector/router's native VectorDb has bugs") is unchanged, same file, same wording.+- One material change found: `@ruvector/router` bumped 0.1.15 β 0.1.30 on npm since 08-24 (`@ruvector/tiny-dancer` also present at 0.1.22). Whether the underlying `VectorDb` bug motivating Ruflo's fork-around was fixed upstream is not verified from this repo alone β out of scope tonight, flagged as a cheap follow-up (bump + smoke-test the native path) for a future automation/ruvector-integration night.++## Hypothesis++> Given `TopologyManager` configured with `type: 'hybrid'`, when `rebalanceHybrid()`'s worker-mesh loop is patched to mirror each edge onto the target node (`connections` array and `adjacencyList` entry, matching the pattern already used by the same function's coordinator loop and all three sibling `rebalance*()` methods), then every worker-mesh edge created by `rebalance()` should be symmetric (`isConnected(A, B) === isConnected(B, A)` for every such edge), subject to: (1) `'mesh'`/`'hierarchical'`/`'centralized'` rebalance paths are byte-identical to today's; (2) the worker-to-coordinator half of `rebalanceHybrid()` is unchanged; (3) existing topology test suite remains green; (4) $0 evaluation cost.++Frozen before evaluation began; not modified after seeing results.++## Benchmarks++Deterministic, $0, zero-LLM vitest addition to `v3/@claude-flow/swarm/__tests__/topology.test.ts` (1 new test). `Math.random()` is mocked to always return `0`, making candidate selection (`candidates[Math.floor(Math.random() * candidates.length)]`) fully deterministic β every worker always picks the lowest-index remaining candidate. With 5 workers added in insertion order (`agent-2`..`agent-6`, `targetConnections = min(3, 4) = 3`) and each worker's connections reset to `[]` via the public `updateNode()` API first (isolating `rebalanceHybrid()`'s own loop from `addNode()`'s separate, out-of-scope initial-connection asymmetry noted above), this reliably reproduces β hand-traced and verified by direct test execution, not sampled probabilistically β the asymmetric edge `agent-6 β agent-2` with no reciprocal `agent-2 β agent-6` under the pre-fix code, and both directions present post-fix.++No bespoke external benchmark corpus applies: this is a scoped, deterministic graph-construction correctness fix, not a tunable parameter. `metaharness darwin`/`ruvector harness darwin --help` confirmed (again) that the real interface evolves routing/topology/prompt/memory/tool/tier/context/coordination *genome parameters* against an LLM-scored bench corpus β no analog for "mirror an edge onto its target." Same class of skip as every dream-cycle night since 2026-08-14.++## Evaluation++**evaluated: accepted.** Real evaluator: `vitest run` (deterministic, $0, zero LLM calls) + `tsc --noEmit`.++Baseline captured via `git stash` on `topology-manager.ts` only (test file kept in place): the new test fails exactly as predicted β `expect(agent2.connections).toContain('agent-6')` fails with `agent2.connections = ['agent-3','agent-4','agent-5']` (no `agent-6`), while `agent6.connections` does contain `agent-2` (the one-directional edge). Candidate (post-fix): full `@claude-flow/swarm` package suite **221/221 passing** (220 pre-existing + 1 new), 0 regressions. `tsc --noEmit` from the package directory: 0 errors.++**Independent adversarial critic** (fresh session, no authoring context) independently re-read the full source (not the diff alone), re-ran `vitest run` and `tsc --noEmit` itself rather than trusting reported numbers, byte-diffed the live working tree against the reviewed diff file (identical β no other file silently touched), and reproduced the baseline-fails/candidate-passes property itself by reverting only the 10-line source fix (keeping the new test) and rerunning β exact predicted failure, then reapplied and reran the full suite back to 221/221. **Verdict: CONFIRMED.** Also independently hand-traced the algorithm before running anything and predicted the exact pre-fix failure output, matching the actual run. No reward-hacking signal (assertions precise, diff matches what was reviewed, discriminating test independently reproduced). Grepped all consumers of `TopologyManager` connection/adjacency state (`unified-coordinator.ts`, rest of `topology.test.ts`) β nothing assumes an exact connection-count cap; existing hybrid tests already use `toBeGreaterThanOrEqual`, so a node ending up with more than its own `targetConnections=3` via other workers' reciprocal picks (observed: `agent-2` ends with 4) is pre-existing soft-cap behavior identical to `rebalanceMesh()`, not a new regression. Security: pure in-memory bookkeeping, no new I/O or external input path, no concerns. Two caveats flagged, both disclosed rather than fixed here: (1) `createEdgesForNode()`'s parallel hybrid-mode asymmetry (see Ruflo Current Capability) is correctly out of scope, not silently missed; (2) the new test's real 5.1s throttle-bypass sleep is a pre-existing pattern in this file (matches `'should emit topology.rebalanced event'`), not a new flakiness class, but worth eventually replacing with fake timers. The critic also caught that this session's local `pnpm install` (run to make the test runner available) left unrelated lockfile drift in the working tree β reverted before commit, not part of this candidate.++## Darwin Results++Skipped β scope mismatch, confirmed via `npx ruvector harness darwin --help` (real interface evolves genome-shaped parameters against an LLM-scored bench corpus; no analog for a 6-line graph-symmetry fix). Same skip class as 6 of the last 7 dream-cycle nights (08-14 through 08-28).++## SOTA Proof & Witness++| Field | Value |+|---|---|+| Session commit | `d33ef4bf8ab27a8f9ef08352c9c293b53312a861` |+| Gist SHA-256 (pre-witness content, i.e. this file before this table was filled in) | `ba1ddf4029655f99d700c54c12401be167cd1a5e1784f47c8208b73e9e970f5f` |+| Witness stamp | `9c1e9cd46b0eaab7a9ec3d9c93d747f46a53c1a2f532303ccc81d1af7fd76f5e` |++Verifier procedure: fetch `docs/dream-cycle/dream-gist-2026-08-29.md` from the `dream/2026-08-29-swarm` branch, strip this table's `Gist SHA-256`/`Witness stamp` values back to the placeholder line, SHA-256 the result, concatenate with the session commit above, SHA-256 again β result must equal the witness stamp.++## Recommended Next Steps++1. **Merge this candidate** (human review required) β closes a real, code-verified, previously-flagged-and-deferred correctness bug with a minimal, deterministic-test-covered diff.+2. **Fix `createEdgesForNode()`'s parallel asymmetry for hybrid initial connections** (`bidirectional: this.config.type === 'mesh'`, line ~375) β same underlying bug class, different code path, confirmed live tonight but deliberately not bundled into this patch to keep it one conceptual change.+3. **Follow up on 08-24's #3 recommendation**: thread `ConsensusVote.confidence` into byzantine.ts's tally β CP-WBFT (AAAI 2026, Grade A) is a peer-reviewed reference pattern for exactly this, still open.+4. **Smoke-test `@ruvector/router`'s current version (0.1.30, up from 0.1.15 at last scan)** against the documented `VectorDb` bug motivating `semantic-router.ts`'s permanent fork-around β cheap, could retire a maintenance burden if fixed upstream.+5. **The 2026-08-20..23 no-run gap remains undiagnosed after 6 consecutive nights of re-confirmation** (08-24 through 08-29) β worth a dedicated `automation`/`meta` night rather than another passive re-check.diff --git a/v3/@claude-flow/swarm/__tests__/topology.test.ts b/v3/@claude-flow/swarm/__tests__/topology.test.tsindex 9251a74db0..f659e833ea 100644--- a/v3/@claude-flow/swarm/__tests__/topology.test.ts+++ b/v3/@claude-flow/swarm/__tests__/topology.test.ts@@ -449,6 +449,58 @@ describe('TopologyManager', () => {expect(queen?.connections.length).toBeGreaterThanOrEqual(0);});+ it('should create symmetric edges when rebalancing a hybrid worker mesh (regression: Dream Cycle 2026-08-29)', async () => {+ topology = createTopologyManager({+ type: 'hybrid',+ maxAgents: 20,+ autoRebalance: true,+ });+ await topology.initialize();++ for (let i = 2; i <= 6; i++) {+ await topology.addNode(`agent-${i}`, 'worker');+ }++ // Isolate rebalanceHybrid()'s worker-mesh loop from addNode()'s own,+ // separate initial-connection wiring (a different, out-of-scope-tonight+ // asymmetry in createEdgesForNode's hybrid case) by resetting every+ // worker to a clean slate via the public updateNode() API first.+ for (let i = 2; i <= 6; i++) {+ await topology.updateNode(`agent-${i}`, { connections: [] });+ }++ // Math.random() mocked to always return 0 makes candidate selection+ // (candidates[Math.floor(Math.random() * candidates.length)])+ // deterministic: every worker always picks the lowest-index remaining+ // candidate. With workers processed in insertion order agent-2..agent-6+ // and targetConnections = min(3, 4) = 3, this reliably reproduces (hand+ // -verified, not a probabilistic sample) the asymmetric edge+ // agent-6 -> agent-2 with no reciprocal agent-2 -> agent-6 under the+ // pre-fix one-directional bug.+ const randomSpy = vi.spyOn(Math, 'random').mockReturnValue(0);++ // Bypass the 5s rebalance throttle by actually waiting it out, same+ // pattern as the 'should emit topology.rebalanced event' test above.+ await new Promise(resolve => setTimeout(resolve, 5100));+ await topology.rebalance();++ randomSpy.mockRestore();++ const agent2 = topology.getNode('agent-2')!;+ const agent6 = topology.getNode('agent-6')!;++ // agent-6 -> agent-2 edge exists (agent-6's own mesh pick).+ expect(agent6.connections).toContain('agent-2');+ expect(topology.isConnected('agent-6', 'agent-2')).toBe(true);++ // The reciprocal agent-2 -> agent-6 edge must also exist -- this is+ // exactly what the pre-fix one-directional bug omitted (agent-2's own+ // 3 picks never reach agent-6, so only a fix that mirrors the edge+ // onto the target produces it).+ expect(agent2.connections).toContain('agent-6');+ expect(topology.isConnected('agent-2', 'agent-6')).toBe(true);+ }, 10000);+it('should prevent too frequent rebalancing', async () => {topology = createTopologyManager({type: 'mesh',diff --git a/v3/@claude-flow/swarm/src/topology-manager.ts b/v3/@claude-flow/swarm/src/topology-manager.tsindex e2ffaa2018..08dd551906 100644--- a/v3/@claude-flow/swarm/src/topology-manager.ts+++ b/v3/@claude-flow/swarm/src/topology-manager.ts@@ -537,6 +537,16 @@ export class TopologyManager extends EventEmitter implements ITopologyManager {worker.connections.push(target.agentId);currentWorkerConnections.push(target.agentId);this.adjacencyList.get(worker.agentId)?.add(target.agentId);++ // Dream Cycle 2026-08-29 (swarm): mirror the edge onto the target so+ // the worker-mesh graph stays symmetric, matching every other+ // rebalance*() method (and this same function's coordinator loop+ // below) β without this, the mesh silently degrades into a random+ // directed graph instead of the undirected mesh it's meant to be.+ if (!target.connections.includes(worker.agentId)) {+ target.connections.push(worker.agentId);+ }+ this.adjacencyList.get(target.agentId)?.add(worker.agentId);}}