Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 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

fix(ci): deterministic browser pattern ids; macOS node-gyp Python for Build V3

ruv07fc94197a65
diff --git a/.github/workflows/v3-ci.yml b/.github/workflows/v3-ci.yml
index 896981f401..83857d3ceb 100644
--- a/.github/workflows/v3-ci.yml
+++ b/.github/workflows/v3-ci.yml
@@ -459,6 +459,14 @@ jobs:
cache: 'pnpm'
cache-dependency-path: v3/pnpm-lock.yaml
+ # When a better-sqlite3/hnswlib-node prebuild download times out, node-gyp
+ # compiles from source, and macos-latest's Python 3.12 has no distutils.
+ - name: Setup Python for node-gyp (macOS)
+ if: runner.os == 'macOS'
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3.11'
+
- name: Install dependencies
working-directory: v3
run: pnpm install --frozen-lockfile
diff --git a/v3/@claude-flow/browser/src/infrastructure/reasoningbank-adapter.ts b/v3/@claude-flow/browser/src/infrastructure/reasoningbank-adapter.ts
index f4b50dde11..e21137a7bd 100644
--- a/v3/@claude-flow/browser/src/infrastructure/reasoningbank-adapter.ts
+++ b/v3/@claude-flow/browser/src/infrastructure/reasoningbank-adapter.ts
@@ -150,10 +150,14 @@ export class ReasoningBankAdapter {
* Generate pattern ID from goal
*/
private generatePatternId(goal: string): string {
- return `pattern-${goal
- .toLowerCase()
- .replace(/[^a-z0-9]+/g, '-')
- .slice(0, 50)}-${Date.now().toString(36)}`;
+ // Must be a pure function of the goal: extractPattern() merges a repeated
+ // trajectory into its existing pattern by looking this id up.
+ const normalized = goal.toLowerCase().replace(/[^a-z0-9]+/g, '-');
+ let hash = 0x811c9dc5;
+ for (let i = 0; i < normalized.length; i++) {
+ hash = Math.imul(hash ^ normalized.charCodeAt(i), 0x01000193);
+ }
+ return `pattern-${normalized.slice(0, 50)}-${(hash >>> 0).toString(36)}`;
}
/**
diff --git a/v3/@claude-flow/browser/tests/reasoningbank-adapter.test.ts b/v3/@claude-flow/browser/tests/reasoningbank-adapter.test.ts
index 5d535f29cc..5d07f6f5b0 100644
--- a/v3/@claude-flow/browser/tests/reasoningbank-adapter.test.ts
+++ b/v3/@claude-flow/browser/tests/reasoningbank-adapter.test.ts
@@ -2,7 +2,7 @@
* @claude-flow/browser - ReasoningBank Adapter Tests
*/
-import { describe, it, expect, beforeEach } from 'vitest';
+import { describe, it, expect, beforeEach, vi } from 'vitest';
import { ReasoningBankAdapter, getReasoningBank } from '../src/infrastructure/reasoningbank-adapter.js';
import type { BrowserTrajectory } from '../src/domain/types.js';
@@ -90,6 +90,22 @@ describe('ReasoningBankAdapter', () => {
expect(pattern).toBeDefined();
expect(pattern?.usageCount).toBeGreaterThan(1);
});
+
+ it('merges repeated success even when the calls land in different milliseconds', async () => {
+ const now = vi.spyOn(Date, 'now');
+ try {
+ now.mockReturnValue(1_000_000);
+ await adapter.storeTrajectory(mockTrajectory);
+ now.mockReturnValue(1_000_007);
+ await adapter.storeTrajectory(mockTrajectory);
+ } finally {
+ now.mockRestore();
+ }
+
+ const patterns = adapter.exportPatterns().filter(p => p.goal === mockTrajectory.goal);
+ expect(patterns).toHaveLength(1);
+ expect(patterns[0].usageCount).toBe(2);
+ });
});
describe('pattern matching', () => {