Files
wehub-resource-sync 23f7624596
ADR-166 MCP Bridge Security Lock / Static-source security lock (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / Compose default binds loopback + Mongo has auth (push) Failing after 2s
CodeQL Advanced / Analyze (rust) (push) Failing after 0s
ADR-166 MCP Bridge Security Lock / plugin-agent-federation bindHost default (push) Failing after 1s
ADR-166 MCP Bridge Security Lock / Runtime behavior — 401 + terminal gate + fail-closed (push) Failing after 4s
business-pods-smoke / smoke (push) Failing after 1s
all-plugins-smoke / smoke-all (push) Failing after 2s
CI/CD Pipeline / Security & Code Quality (push) Failing after 1s
CI/CD Pipeline / Test Suite (ubuntu-latest) (push) Failing after 1s
CI/CD Pipeline / Build & Package (macos-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (ubuntu-latest) (push) Has been skipped
CI/CD Pipeline / Build & Package (windows-latest) (push) Has been skipped
CI/CD Pipeline / Documentation & Examples (push) Failing after 1s
Clone Tracker (14-day rolling) / Snapshot clones for ruflo ecosystem (push) Failing after 1s
CodeQL Advanced / Analyze (actions) (push) Failing after 1s
CodeQL Advanced / Analyze (javascript-typescript) (push) Failing after 1s
federation-peer-rust / stable-noop (push) Failing after 1s
metaharness-ci / score (push) Failing after 1s
metaharness-ci / router-compat (push) Failing after 0s
metaharness-ci / similarity-tests (push) Failing after 0s
no-agentbbs-smoke / smoke-without-agentbbs (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (windows-latest) (push) Has been skipped
codex-integration-audit / Codex integration audit (push) Failing after 1s
helpers-manifest-guard / guard (push) Failing after 1s
🔗 Cross-Agent Integration Tests / 🤝 Agent Coordination Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🧠 Memory Sharing Integration (push) Has been skipped
🔗 Cross-Agent Integration Tests / 🛡️ Fault Tolerance Tests (push) Has been skipped
🔗 Cross-Agent Integration Tests / ⚡ Performance Integration Tests (push) Has been skipped
metaharness-ci / mcp-scan (push) Failing after 1s
metaharness-ci / eject-dryrun (push) Failing after 1s
metaharness-ci / metaharness-real-data (push) Failing after 0s
no-cli-optdep-bloat-2561 / guard (push) Failing after 1s
no-metaharness-smoke / smoke-without-metaharness (push) Failing after 1s
no-phantom-agentic-flow-subpath / guard (push) Failing after 1s
🔄 Automated Rollback Manager / 🚨 Failure Detection (push) Failing after 1s
V3 CI/CD Pipeline / Plugin hooks smoke / ubuntu-latest / Node 22 (push) Failing after 1s
V3 CI/CD Pipeline / ruflo-graph-intelligence build + test smoke (#2044, ADR-123) (push) Failing after 1s
CVE Audit Gate / Audit root (critical-blocking) (push) Failing after 2s
cost-tracker-smoke / smoke (push) Failing after 3s
oia-audit-weekly / audit (push) Failing after 2s
ruflo-agent-smoke / ruflo-agent structural smoke (push) Failing after 1s
📊 Status Badges Update / 📊 Update Status Badges (push) Failing after 1s
V3 CI/CD Pipeline / Static regression guards (#2267 YAML + (push) Failing after 1s
V3 CI/CD Pipeline / Test V3 Packages (push) Failing after 0s
V3 CI/CD Pipeline / agent_execute provider routing smoke (#2042) (push) Failing after 0s
CVE Audit Gate / Audit v3 (critical-blocking) (push) Failing after 1s
federation-peer-rust / stable-native (push) Failing after 2s
🔗 Cross-Agent Integration Tests / 🚀 Integration Test Setup (push) Failing after 2s
neural-trader-smoke / runtime-smoke (push) Failing after 1s
V3 CI/CD Pipeline / Build V3 (macos-latest) (push) Has been skipped
V3 CI/CD Pipeline / Build V3 (ubuntu-latest) (push) Has been skipped
V3 CI/CD Pipeline / Type Check V3 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 24 (push) Failing after 1s
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / ubuntu-latest / Node 22 (push) Failing after 2s
V3 CI/CD Pipeline / browser rvf create flag smoke (#2015) (push) Failing after 0s
V3 CI/CD Pipeline / Dependency review (#2046) (push) Has been skipped
V3 CI/CD Pipeline / Supply-chain audit (#2046) (push) Failing after 0s
V3 CI/CD Pipeline / witness marker drift smoke (#2021) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader portfolio CG smoke (#2068, ADR-126 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / neural-trader backtest signing smoke (#2068, ADR-126 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / kg-extract type-import classification smoke (#2049) (push) Failing after 0s
V3 CI/CD Pipeline / witness verify precondition smoke (#1880) (push) Failing after 2s
V3 CI/CD Pipeline / neural-trader pipeline risk-gate smoke (#2068, ADR-126 Phase 5) (push) Failing after 0s
V3 CI/CD Pipeline / neural-trader feature attribution smoke (#2068, ADR-126 Phase 6) (push) Failing after 0s
V3 CI/CD Pipeline / plugin-registry signature verification smoke (#1922, CWE-347) (push) Failing after 4s
V3 CI/CD Pipeline / memory stats legacy-DB smoke (#2120) (push) Failing after 4s
V3 CI/CD Pipeline / github deprecated actions smoke (#2089, ADR-127 Phase 3) (push) Failing after 1s
V3 CI/CD Pipeline / graph query + pathfinder smoke (ADR-130 P2+P5) (push) Has been skipped
V3 CI/CD Pipeline / graph trajectory hooks smoke (ADR-130 P3) (push) Has been skipped
V3 CI/CD Pipeline / graph plugin adapter smoke (ADR-130 P4) (push) Has been skipped
V3 CI/CD Pipeline / graph benchmark (ADR-130 P6) (push) Has been skipped
V3 CI/CD Pipeline / statusline generator delegation smoke (#2195) (push) Failing after 1s
V3 CI/CD Pipeline / wizard init regression guard (#2206 (push) Failing after 1s
V3 CI/CD Pipeline / memory no-stray-db smoke (ADR-125 P7) (push) Failing after 1s
V3 CI/CD Pipeline / github-safe injection smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github actions pin smoke (#2089, ADR-127 Phase 1) (push) Failing after 1s
V3 CI/CD Pipeline / github attribution opt-in smoke (#2089, ADR-127 Phase 4) (push) Failing after 1s
V3 CI/CD Pipeline / pre-bash hook safety smoke (#2017) (push) Failing after 1s
V3 CI/CD Pipeline / Memory import smoke / ubuntu-latest (push) Failing after 0s
V3 CI/CD Pipeline / MCP protocol smoke / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / ruvllm WASM auto-init smoke (#2086) (push) Failing after 4s
V3 CI/CD Pipeline / MCP paired-tool round-trip smoke (#1889) (push) Failing after 1s
V3 CI/CD Pipeline / Plugin package install-safety (#1902/#1903/#1904) (push) Failing after 1s
V3 CI/CD Pipeline / Tool description discoverability (ADR-112) (push) Failing after 3s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (22) (push) Failing after 1s
V3 CI/CD Pipeline / CLI npx-install smoke (#1147 / (24) (push) Failing after 1s
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / ubuntu-latest (push) Failing after 2s
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / ubuntu-latest (push) Failing after 1s
V3 CI/CD Pipeline / Vector-index dimension audit (#1947) (push) Failing after 0s
V3 CI/CD Pipeline / Hook-command install safety (#1921) (push) Failing after 1s
V3 CI/CD Pipeline / ToolOutputGuardrail smoke (ADR-131, (push) Failing after 1s
V3 CI/CD Pipeline / init-bundle invariants smoke (#2095, ADR-128 Phase 5) (push) Failing after 1s
V3 CI/CD Pipeline / wasm provider bridge smoke (ADR-129 P1) (push) Failing after 2s
V3 CI/CD Pipeline / wasm gallery CRUD smoke (ADR-129 P3) (push) Failing after 1s
V3 CI/CD Pipeline / wasm plugin bridge smoke (ADR-129 P4) (push) Failing after 0s
V3 CI/CD Pipeline / wasm compose smoke (ADR-129 P2) (push) Failing after 4s
V3 CI/CD Pipeline / graph schema smoke (ADR-130 P1) (push) Failing after 0s
Validate Marketplace / validate (push) Failing after 1s
🔍 Verification Pipeline / 🚀 Setup Verification (push) Failing after 1s
🔍 Verification Pipeline / 🛡️ Security Verification (push) Has been skipped
🔍 Verification Pipeline / 📝 Code Quality (push) Has been skipped
🔍 Verification Pipeline / 🧪 Test Verification (${{ matrix.os }}, Node ${{ matrix.node }}) (push) Has been skipped
🔍 Verification Pipeline / 🏗️ Build Verification (push) Has been skipped
🔍 Verification Pipeline / 📚 Documentation Verification (push) Has been skipped
CVE Audit Gate / High-severity report (warn only) (push) Has been cancelled
🔄 Automated Rollback Manager / 🔄 Execute Rollback (push) Has been cancelled
🔄 Automated Rollback Manager / ✅ Post-Rollback Verification (push) Has been cancelled
🔄 Automated Rollback Manager / 📊 Rollback Monitoring (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook execution smoke (#2132) / windows-latest (push) Has been cancelled
🔄 Automated Rollback Manager / ⏳ Manual Rollback Approval (push) Has been cancelled
V3 CI/CD Pipeline / MCP protocol smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Memory import smoke / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows hook shim smoke (#2132) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Windows init hooks smoke (#2132) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / macos-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / ubuntu-latest (push) Has been cancelled
V3 CI/CD Pipeline / Witness verify (signed manifest) / windows-latest (push) Has been cancelled
V3 CI/CD Pipeline / Publish to npm (alpha) (push) Has been cancelled
V3 CI/CD Pipeline / Smoke (no better-sqlite3) / macos-latest / Node 22 (push) Has been cancelled
V3 CI/CD Pipeline / Plugin hooks smoke / macos-latest / Node 22 (push) Has been cancelled
CI/CD Pipeline / Deploy & Release (push) Has been cancelled
CI/CD Pipeline / CI Status (push) Has been cancelled
🔗 Cross-Agent Integration Tests / 📊 Integration Test Report (push) Has been cancelled
🔄 Automated Rollback Manager / 🔍 Pre-Rollback Validation (push) Has been cancelled
🔍 Verification Pipeline / ⚡ Performance Verification (push) Has been cancelled
🔍 Verification Pipeline / 📊 Verification Report (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:02:19 +08:00

13 KiB

Claude-Flow v3: Hooks & Learning Integration

Executive Summary

Key Finding: agentic-flow@alpha provides nearly everything needed for a self-optimizing learning system. Combined with Claude Code's hooks API, we have a complete solution.

What agentic-flow@alpha Already Provides

Capability Status Details
9 RL Algorithms ✓ Ready Double-Q, SARSA, Actor-Critic, PPO, etc.
Trajectory Tracking ✓ Ready SQLite-backed, cross-session
Pattern Storage ✓ Ready TensorCompress tiered storage
Parallel Learning ✓ Ready 7 workers, batch processing
Attention Mechanisms ✓ Ready MoE, Flash, Graph, Hyperbolic
Memory Compression ✓ Ready 50-97% memory savings

What Claude Code Provides

Capability Status Details
10 Hook Events ✓ Ready PreToolUse, PostToolUse, Session*, etc.
OpenTelemetry ✓ Ready Prometheus export, custom metrics
Extended Thinking ✓ Ready Up to 31,999 tokens for reasoning
MCP Integration ✓ Ready 50+ coordination tools

1. agentic-flow@alpha Hook Inventory

1.1 Original Hook Tools (10)

// MCP Tool Names
hook_pre_edit      // Before file edits
hook_post_edit     // After file edits (pattern extraction)
hook_pre_command   // Before bash commands (safety check)
hook_post_command  // After commands (outcome learning)
hook_route         // Intelligent task routing
hook_explain       // XAI explanations
hook_pretrain      // Pattern pre-training
hook_build_agents  // Agent construction
hook_metrics       // Performance tracking
hook_transfer      // Cross-task learning

1.2 Intelligence Bridge Tools (9)

// High-performance learning tools
intelligence_route               // SONA + MoE routing (~0.05ms)
intelligence_trajectory_start    // Begin trajectory tracking
intelligence_trajectory_step     // Record step with reward
intelligence_trajectory_end      // Complete with verdict
intelligence_pattern_store       // Store successful patterns
intelligence_pattern_search      // Find similar patterns (HNSW)
intelligence_stats               // Learning statistics
intelligence_learn               // Force learning cycle
intelligence_attention           // Attention similarity compute

1.3 Parallel Learning Functions (12)

// From intelligence-bridge.js
queueEpisode()              // Batch Q-learning (3-4x faster)
flushEpisodeBatch()         // Process with 7 workers
matchPatternsParallel()     // Parallel pattern matching
indexMemoriesBackground()   // Non-blocking memory indexing
searchParallel()            // Sharded similarity search
analyzeFilesParallel()      // Multi-file analysis
analyzeCommitsParallel()    // Git history learning
speculativeEmbed()          // Pre-embed likely files
analyzeAST()                // Parallel AST extraction
analyzeComplexity()         // Code quality metrics
buildDependencyGraph()      // Import graph building
securityScan()              // Parallel SAST

2. Multi-Algorithm Learning Engine

agentic-flow@alpha includes 9 specialized RL algorithms automatically selected by task type:

Task Type Algorithm Reason
agent-routing Double-Q Reduces overestimation bias
error-avoidance SARSA Conservative on-policy learning
confidence-scoring Actor-Critic Continuous 0-1 scores
context-ranking PPO Stable preference learning
trajectory-learning Decision Transformer Sequence patterns
memory-recall TD-Lambda Long-term credit assignment
pattern-matching Q-Learning Fast value-based matching
exploration REINFORCE Policy gradient for novel tasks
multi-agent A2C Advantage for coordination

Usage

import { learnFromEpisode, getAlgorithmForTask } from 'agentic-flow/hooks';

// Automatic algorithm selection
const { algorithm, reason } = getAlgorithmForTask('agent-routing');
// → { algorithm: 'double-q', reason: 'Reduces overestimation bias' }

// Learn from execution
await learnFromEpisode(
  'agent-routing',      // Task type
  stateEmbedding,       // Current state
  'select-coder',       // Action taken
  0.85,                 // Reward (success)
  nextStateEmbedding,   // Result state
  true                  // Episode done
);

3. Claude Code Hook Integration

3.1 Hook Event Mapping

Claude Code Event agentic-flow Tool Purpose
PreToolUse hook_pre_command, hook_pre_edit Predict & prevent errors
PostToolUse hook_post_command, hook_post_edit Learn from outcomes
SessionStart intelligence_trajectory_start Begin session trajectory
SessionEnd intelligence_trajectory_end Complete with verdict
UserPromptSubmit hook_route Intelligent task routing
Stop intelligence_pattern_store Store successful patterns

3.2 Complete Hook Configuration

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [{
          "type": "command",
          "command": "npx agentic-flow@alpha hooks pre-command --validate --predict --cache"
        }]
      },
      {
        "matcher": "Edit|Write",
        "hooks": [{
          "type": "command",
          "command": "npx agentic-flow@alpha hooks pre-edit --analyze-impact --check-patterns"
        }]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Bash",
        "hooks": [{
          "type": "command",
          "command": "npx agentic-flow@alpha hooks post-command --learn --store-pattern --batch"
        }]
      },
      {
        "matcher": "Edit|Write",
        "hooks": [{
          "type": "command",
          "command": "npx agentic-flow@alpha hooks post-edit --extract-patterns --train-neural"
        }]
      }
    ],
    "SessionStart": [
      {
        "hooks": [{
          "type": "command",
          "command": "npx agentic-flow@alpha hooks session-start --restore-memory --warm-cache"
        }]
      }
    ],
    "SessionEnd": [
      {
        "hooks": [{
          "type": "command",
          "command": "npx agentic-flow@alpha hooks session-end --consolidate --export-metrics"
        }]
      }
    ]
  }
}

4. TensorCompress Tiered Storage

agentic-flow@alpha includes automatic memory optimization:

Access Frequency Compression Tier Memory Savings
Hot (>0.8) none 0%
Warm (>0.4) half 50%
Cool (>0.1) pq8 87.5%
Cold (>0.01) pq4 93.75%
Archive (≤0.01) binary 96.9%

Automatic recompression every 5 minutes based on access patterns.


5. Self-Optimizing Learning Loop

5.1 Architecture

┌─────────────────────────────────────────────────────────────────┐
│                    Claude Code Hook Events                       │
│  PreToolUse → SessionStart → UserPrompt → PostToolUse → Stop    │
└───────────────────────────┬─────────────────────────────────────┘
                            │
┌───────────────────────────▼─────────────────────────────────────┐
│              agentic-flow@alpha Intelligence Bridge              │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐             │
│  │ 9 RL Algos  │  │ Trajectory  │  │ Pattern     │             │
│  │ Auto-Select │  │ Tracking    │  │ Storage     │             │
│  └─────────────┘  └─────────────┘  └─────────────┘             │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐             │
│  │ 7 Workers   │  │ HNSW Index  │  │ Tensor      │             │
│  │ Parallel    │  │ 150x faster │  │ Compress    │             │
│  └─────────────┘  └─────────────┘  └─────────────┘             │
└───────────────────────────┬─────────────────────────────────────┘
                            │
┌───────────────────────────▼─────────────────────────────────────┐
│                    SQLite Persistence                            │
│  Patterns │ Trajectories │ Episodes │ Metrics │ Compressions    │
└─────────────────────────────────────────────────────────────────┘

5.2 Learning Flow

// SessionStart: Restore context
SessionStart  {
  restoreMemory()           // Load relevant patterns
  warmCache()               // Pre-embed likely files
  beginTrajectory()         // Start session tracking
}

// PreToolUse: Predict & Prevent
PreToolUse  {
  findSimilarPatterns()     // Query past successes
  predictOutcome()          // RL prediction
  blockIfRisky()            // Safety gate (0.85 threshold)
}

// PostToolUse: Learn
PostToolUse  {
  recordTrajectoryStep()    // Track action/reward
  learnFromEpisode()        // Update RL policy
  queueEpisode()            // Batch for parallel learning
}

// SessionEnd: Consolidate
SessionEnd  {
  endTrajectory()           // Complete with verdict
  storePattern()            // Save successful patterns
  flushEpisodeBatch()       // Process queued episodes
  consolidateMemory()       // Compress cold patterns
}

6. Telemetry Integration

6.1 OpenTelemetry Metrics

# Enable export
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318

# Metrics available:
cf_learning_episodes_total      # Total episodes processed
cf_learning_success_rate        # Success percentage
cf_pattern_storage_bytes        # Pattern storage size
cf_compression_ratio            # Memory savings
cf_trajectory_duration_ms       # Learning latency
cf_rl_algorithm_usage           # Algorithm selection frequency

6.2 Built-in Dashboard

npx agentic-flow@alpha metrics --format prometheus
npx agentic-flow@alpha stats --learning

7. Installation & Setup

7.1 Minimal Setup (Learning Only)

npm install agentic-flow@alpha
npx agentic-flow@alpha hooks install --learning

7.2 Full Setup (All Features)

npm install agentic-flow@alpha
npx agentic-flow@alpha hooks install --all --parallel

# Configure Claude Code hooks
cat >> ~/.claude/settings.json << 'EOF'
{
  "hooks": {
    "PreToolUse": [{"matcher": "Bash|Edit", "hooks": [{"type": "command", "command": "npx agentic-flow@alpha hooks pre-task"}]}],
    "PostToolUse": [{"matcher": "Bash|Edit", "hooks": [{"type": "command", "command": "npx agentic-flow@alpha hooks post-task --learn"}]}]
  }
}
EOF

8. What agentic-flow@alpha Provides (Summary)

Already Implemented:

  • 19 hook tools (10 original + 9 intelligence)
  • 9 RL algorithms with auto-selection
  • Trajectory tracking with SQLite persistence
  • Pattern storage with tiered compression (50-97% savings)
  • Parallel learning with 7 workers (3-4x faster)
  • HNSW index for 150x faster pattern search
  • Attention mechanisms (MoE, Flash, Graph, Hyperbolic)
  • Extended worker pool for parallel operations
  • Speculative embedding for related files
  • AST analysis, complexity metrics, security scanning

Claude-Flow v3 Needs to Add:

  • Claude Code hook configuration adapter
  • OpenTelemetry metric export wrapper
  • Cross-session learning persistence
  • Swarm coordination integration
  • User-configurable learning parameters

9. Recommendation

Use agentic-flow@alpha as the learning backbone for Claude-Flow v3.

The package already provides:

  • Complete RL learning system (9 algorithms)
  • Efficient pattern storage (tiered compression)
  • Fast retrieval (HNSW 150x faster)
  • Parallel processing (7 workers)
  • SQLite persistence (cross-session)

Claude-Flow v3 should focus on:

  1. Thin integration layer - Connect Claude Code hooks to agentic-flow hooks
  2. Configuration UI - Let users customize learning parameters
  3. Swarm coordination - Use learning to optimize swarm topology selection
  4. Metrics dashboard - Visualize learning progress

Document created: 2026-01-03 agentic-flow version: 2.0.1-alpha.50