Skip to content

dream(swarm): #3122 fix TopologyManager.rebalanceHybrid() one-directional adjacency (evaluated, ACCEPT) - #3123

Merged
ruvnet merged 1 commit into
mainfrom
dream/2026-08-29-swarm
Sep 14, 2026
Merged

ruvnet merged 1 commit into
mainfrom
dream/2026-08-29-swarm

Conversation

@ruvnet

@ruvnet ruvnet commented Aug 29, 2026

Copy link
Copy Markdown
Owner

1. Hypothesis

Given TopologyManager configured with type: 'hybrid', when rebalanceHybrid()'s worker-mesh loop is patched to mirror each edge onto the target node (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)), subject to: (1) 'mesh'/'hierarchical'/'centralized' paths byte-identical; (2) the coordinator half of rebalanceHybrid() unchanged; (3) existing test suite green; (4) $0 cost.

Frozen before evaluation; not modified after seeing results.

2. Candidate

v3/@claude-flow/swarm/src/topology-manager.ts (+10 lines): rebalanceHybrid()'s worker-mesh loop now mirrors each edge onto the target (target.connections.push(worker.agentId) guarded against duplicates, plus the reciprocal adjacencyList update) — exactly matching the pattern already used 8 lines below (the coordinator loop) and in rebalanceMesh()/rebalanceHierarchical()/rebalanceCentralized().

v3/@claude-flow/swarm/__tests__/topology.test.ts (+52 lines): 1 new deterministic regression test. Math.random() is mocked to always return 0, making candidate selection fully deterministic; 5 workers reset to empty connections via the public updateNode() API isolate rebalanceHybrid()'s loop from addNode()'s own, separate, out-of-scope initial-connection wiring. Hand-traced and verified by execution (not a probabilistic sample) to reliably reproduce the asymmetric edge agent-6 → agent-2 pre-fix, symmetric post-fix.

Not bundled (deliberately, to keep this patch one conceptual change): createEdgesForNode()'s parallel one-directional initial-connection wiring for hybrid topology (bidirectional: this.config.type === 'mesh') — same bug class, different code path, confirmed still live, flagged as a follow-up.

3. Evaluation Receipt

evaluated: accepted. Real evaluator: Vitest, deterministic, zero LLM calls, $0 cost. Baseline via git stash on topology-manager.ts only (test kept): new test fails exactly as predicted (agent2.connections missing 'agent-6', isConnected('agent-2','agent-6') false). Candidate: passes, both directions symmetric.

4. Baseline Comparison

Full @claude-flow/swarm suite: 221/221 passing (220 pre-existing + 1 new), identically 0 failures with the candidate applied. tsc --noEmit from the package directory: 0 errors.

5. Darwin Lineage

Skipped — scope mismatch, confirmed via npx ruvector harness darwin --help: real interface evolves routing/topology/prompt/memory/tool/tier/context/coordination genome 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.

6. Flywheel Evidence

No signed @metaharness/flywheel bundle — deterministic Vitest evidence, same class as every accepted night since 08-18. OBSERVATION/MEASUREMENT/INFERENCE/DECISION/REJECTION breakdown in the linked issue §7.

7. Reward Hack Check

No reward-hack CLI reachable this session. Manual checklist clear, independently re-verified by the adversarial critic: no test weakened, no threshold tuned, no cherry-picking, $0 cost, discriminating test independently reproduced by reverting only the source fix. Full checklist in the issue §8.

8. Security Review

Pure in-memory graph bookkeeping (arrays/Sets). No new I/O, network, credential, or MCP-authority surface. No concerns — confirmed explicitly by the adversarial critic.

9. Regression Analysis

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. A node ending up with more than its own targetConnections=3 via other workers' reciprocal picks (observed) is pre-existing soft-cap behavior identical to rebalanceMesh(), not a new regression.

10. ADR

None — scoped correctness/wiring fix, matches repo convention (08-18/19/24/25/26/27/28 all shipped without an ADR).

11. Research Gist

docs/dream-cycle/dream-gist-2026-08-29.md (committed on this branch) — fresh 2026 literature search (explicit negative result on the narrow bug class, real adjacent-area papers, primary-source competitor check across LangGraph/AutoGen/CrewAI/OpenAI Agents SDK/kyegomez-swarms), plus a light re-verification of the ruview/ruvector integration scans from 5 nights ago (nothing material changed, one npm version bump noted).

12. Issue

Closes evaluation tracking in #3122 (full 15-section report: ledger check incl. 08-20..28 backfill, research, adversarial critique, scan findings, competitor table, witness).

13. Witness

Field Value
Session commit d33ef4bf8ab27a8f9ef08352c9c293b53312a861
Gist SHA-256 (pre-witness content) ba1ddf4029655f99d700c54c12401be167cd1a5e1784f47c8208b73e9e970f5f
Witness stamp 9c1e9cd46b0eaab7a9ec3d9c93d747f46a53c1a2f532303ccc81d1af7fd76f5e

14. Merge Policy

Human review required. Do not self-merge. Do not autonomously promote Flywheel state.


Generated by Claude Code

ruvnet commented Aug 29, 2026

Copy link
Copy Markdown
Owner Author

CI investigation for the initial batch of failures (Smoke (no better-sqlite3) ×3, Static regression guards, memory stats legacy-DB smoke, neural-trader feature attribution smoke, MCP paired-tool round-trip smoke, ToolOutputGuardrail smoke, CLI npx-install smoke ×2, Windows init hooks smoke):

Not this PR's failure. Confirmed identical on main's own tip commit (d33ef4bf8..., the base this PR branches from) via its latest V3 CI/CD Pipeline run — same job names failing there too. Root cause: v3/pnpm-lock.yaml still records @claude-flow/mcp at ^3.0.0-alpha.9 while v3/@claude-flow/cli/package.json pins it at 3.0.0-alpha.10, so every pnpm install --frozen-lockfile job aborts with ERR_PNPM_OUTDATED_LOCKFILE. Tracked in #3101, with an existing fix already open at #3104 (still unmerged).

Ported #3104's 1-line change into this branch (79df9913b) rather than wait on it to merge separately — verified locally with pnpm install --frozen-lockfile, which now succeeds. This should turn the affected checks green on the next CI run without touching anything in this PR's actual candidate (topology-manager.ts / topology.test.ts).

memory stats legacy-DB smoke may still fail independently — it's also currently failing on an unrelated recent PR (#3119) checked as a same-shape comparison, so it looks like a second, separate pre-existing issue unrelated to the lockfile drift; will re-check after this push and follow up separately if it's still red once the lockfile fix lands.


Generated by Claude Code

ruvnet commented Aug 29, 2026

Copy link
Copy Markdown
Owner Author

Follow-up: after the lockfile port (79df9913b), most of the earlier batch is expected to clear (the v3/pnpm-lock.yaml frozen-lockfile checks specifically), but several checks are still red for a second, distinct, unrelated root cause: npm ci/npm install at the repo root fails outright —

npm error code ETARGET
npm error notarget No matching version found for @claude-flow/mcp@3.0.0-alpha.10.

@claude-flow/mcp@3.0.0-alpha.10 was pinned but never published to the npm registry. This is tracked in #3095 ("Unpublished @claude-flow/mcp alpha.10 pin blocks install-dependent CI"), still open, with no fix PR against it. Any check whose setup runs a root-level npm ci/npm install (Audit root, plugin-registry signature verification smoke, neural-trader backtest signing smoke, and others sharing that same install step) will fail identically regardless of this PR's diff — reproduced locally, same error.

Not portable the way #3104 was: the only real fix is publishing the missing version (or repinning to a published one), and per this repo's own publishing rules that's a separately-authorized action requiring signing keys/credentials this session doesn't hold — not something to do from a scoped swarm-topology candidate. Flagging here rather than widening this PR. This PR's own @claude-flow/swarm test suite (221/221) and typecheck are unaffected by either CI issue, since neither touches the swarm package's own build path.


Generated by Claude Code

@ruvnet ruvnet left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dream evidence review — exact head 79df9913b829d2605aef765ac427c462e10191fd

Frozen hypothesis: hybrid topology rebalancing is symmetric, preserves topology invariants, and passes the repository's required validation gates.

The focused evidence is useful: the V3 type-check and package-test jobs pass, and the new deterministic test exercises both promotion and demotion. CodeQL also passes.

Portfolio acceptance is blocked because Verification, Cross-Agent, CI/CD, CVE, and V3 CI are red on this exact head. Several failures occur during root installation before signing/security/integration smoke tests execute, so those gates have no result. Existing dependency/reproducibility blockers should be reused rather than duplicated.

Acceptance remains: reproduce the committed dependency graph, run the signing, witness, graph-schema, security, and cross-agent gates on this exact head, and preserve the focused topology tests.

INCONCLUSIVE

ruvnet commented Aug 29, 2026

Copy link
Copy Markdown
Owner Author

Re: the INCONCLUSIVE review — confirms the same two blockers already diagnosed and reported above on this thread, not a finding against the topology candidate itself:

  1. v3 workspace lockfile drift — fixed and pushed (79df9913b, ported from chore: sync pnpm lockfile for mcp alpha.10 #3104). This is what let Type Check V3, package tests, and the smoke suites that only need the v3 pnpm workspace go green.
  2. Root dependency graph — @claude-flow/mcp@3.0.0-alpha.10 unpublished to npm (ETARGET) — this is what's still blocking Verification, Cross-Agent, CI/CD, CVE, and the signing/witness/graph-schema/security gates from producing a result at all, since they fail during root npm install before any of those steps run. Tracked in Unpublished @claude-flow/mcp alpha.10 pin blocks install-dependent CI #3095, no fix PR exists yet, and reproducing the dependency graph means either publishing that exact version or repinning to one that is published — both outside what a scoped swarm-topology candidate should do unilaterally (publishing in particular needs credentials/authorization this session doesn't hold, per this repo's own publishing rules).

Not duplicating either blocker — just confirming they're the same ones, reused rather than re-diagnosed. Once #3095 resolves, the blocked gates should run cleanly against this head without any further change here; the topology fix and its regression test are unaffected either way. Keeping this PR watched.


Generated by Claude Code

…onal adjacency (evaluated, ACCEPT)

rebalanceHybrid()'s worker-mesh loop added edges only on the initiating
worker's side (connections array + adjacencyList), never reciprocating on
the target. Every sibling rebalance*() method, and this same function's
own coordinator loop 8 lines below, update both sides. Flagged by
2026-08-24's dream-cycle night and deferred; fixed here with a 6-line
mirrored-edge patch plus a deterministic (Math.random mocked) regression
test. Independently adversarially reviewed (CONFIRMED). Full package
suite 221/221, 0 regressions. Backfills docs/dream-cycle/LEDGER.md for
2026-08-20 through 2026-08-28 (merge-cadence backlog, not lost work) and
adds tonight's row.

Co-Authored-By: RuFlo <ruv@ruv.net>
Claude-Session: https://claude.ai/code/session_019nSbi8hkZdmwK2kaBXRj5J
@ruvnet
ruvnet force-pushed the dream/2026-08-29-swarm branch from 79df991 to 570726e Compare September 14, 2026 21:11

ruvnet commented Sep 14, 2026

Copy link
Copy Markdown
Owner Author

Picking this back up after the rebase onto current main (branch was force-pushed to 570726e1, base moved to 1bd734e27 — the topology fix itself is still absent from main, confirmed, so this candidate is still needed).

CLI npx-install smoke (#1147 / (22) failed on this head. Investigated: reproduces cleanly and passes locally (node scripts/smoke-cli-npx-install.mjs → ok — installed cleanly, no "Invalid Version" regression). The CI log shows the real cause — npm error code ECONNRESET / network read ECONNRESET while installing the packed tarball, a transient network failure on the runner, not a real regression from this diff (which touches only topology-manager.ts, its test file, and the ledger/gist docs). A rerun of this run is already in progress (attempt 2) — will confirm green once it lands rather than re-triggering again.


Generated by Claude Code

ruvnet commented Sep 14, 2026

Copy link
Copy Markdown
Owner Author

Test Suite (ubuntu-latest) also failed on this head — CI test ratchet: FAILED — 4 unexpected failing file(s):

  • plugins/ruflo-chatgpt-federation/test/oauth.test.mjs
  • plugins/ruflo-chatgpt-federation/test/publisher.test.mjs
  • plugins/ruflo-x-gateway/test/oauth.test.mjs
  • v3/@claude-flow/plugins/__tests__/ruvector-streaming.test.ts

Not this PR's failure — confirmed by main's own tip commit. main's current HEAD (1bd734e27, the just-merged #3103) has a commit message that explicitly states: "confirmed by diffing main's own Test Suite ratchet failures (3, pre-existing, unrelated oauth/publisher plugin tests) against this branch's (5: the same 3 plus these 2)" — first-party confirmation from the repo owner that 3 of these 4 are pre-existing on main itself, unrelated to any candidate's diff. This PR's diff touches only topology-manager.ts, its test file, and docs — zero overlap with the chatgpt-federation/x-gateway/ruvector-streaming plugin code, so the 4th (ruvector-streaming.test.ts) is the same class by the same logic (nothing in this diff could affect it).

Not attempting a fix: scripts/ci-test-baseline.txt's own header explicitly forbids adding entries "to make a regression green," and actually fixing 3 unrelated plugins' OAuth/publisher tests plus a ruvector-streaming test would badly widen this PR's scope beyond a scoped swarm-topology candidate. This is a pre-existing maintenance gap in the ratchet baseline for main, not something to fix from here.

Between this and the earlier CLI npx-install smoke network flake (rerun in progress), the topology candidate itself — 221/221 @claude-flow/swarm tests, tsc --noEmit clean, adversarially reviewed — remains unaffected by either issue.


Generated by Claude Code

@ruvnet
ruvnet marked this pull request as ready for review September 14, 2026 21:28
@ruvnet
ruvnet merged commit 9f67bb7 into main Sep 14, 2026
180 of 183 checks passed
ruvnet added a commit that referenced this pull request Sep 26, 2026
Ships the swarm fixes merged since alpha.8 (#3357 hierarchical leader
edges, #3378 event-driven UnifiedSwarmCoordinator wait, #3123, #3086,
#3243, #3062). The CLI does not depend on @claude-flow/swarm, so they
reach users only through this standalone publish.

Publishability fixes found while preparing the tarball:
- coordination/{agent-registry,task-orchestrator,swarm-hub}.ts used
  extensionless relative imports, so a plain `tsc` build of main
  throws ERR_MODULE_NOT_FOUND on `import('@claude-flow/swarm')`.
  Add the `.js` suffixes (the package is "type": "module").
- Restore the ADR-095 G2.2 transport re-exports on the root entry.
  alpha.8 was published from main@f8ab5a325 plus uncommitted work
  (later dacbe0e, never merged) that exported LocalTransport,
  FederationTransport, signMessage, etc. from the root. Without this,
  alpha.9 would silently drop 9 runtime exports alpha.8 users have.
- Add a `files` allowlist (dist, README.md, MIGRATION.md). alpha.8
  shipped src/, __tests__/, tmp.json, tsconfig.tsbuildinfo, a 1.5 MB
  ruvector.db and .claude-flow/ runtime state from a contributor's
  machine.
- Record the repo version as alpha.9 (repo was stuck at alpha.7 while
  npm had alpha.8).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants