@grafema/rfdb 0.2.1-beta → 0.2.5-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @grafema/rfdb
2
2
 
3
- > High-performance disk-backed graph database server for Grafema
3
+ > **RFDB** (Rega Flow Database) — high-performance disk-backed graph database server for Grafema
4
+
5
+ *Named after the author's wife Regina (Rega for short). The Hebrew word רגע (rega, "moment") conveniently fits the concept — a flow of discrete moments captured in the graph.*
4
6
 
5
7
  **Warning: This package is in early alpha stage and is not recommended for production use.**
6
8
 
@@ -29,11 +31,14 @@ cargo build --release
29
31
  ### As a CLI
30
32
 
31
33
  ```bash
32
- # Start the server
33
- npx rfdb-server --socket /tmp/rfdb.sock --data-dir ./my-graph
34
+ # Start the server (db-path is required, socket is optional)
35
+ npx rfdb-server ./my-graph.rfdb --socket /tmp/rfdb.sock
34
36
 
35
37
  # Or if installed globally
36
- rfdb-server --socket /tmp/rfdb.sock --data-dir ./my-graph
38
+ rfdb-server ./my-graph.rfdb --socket /tmp/rfdb.sock
39
+
40
+ # Using default socket path (/tmp/rfdb.sock)
41
+ rfdb-server ./my-graph.rfdb
37
42
  ```
38
43
 
39
44
  ### Programmatic usage
@@ -66,7 +71,7 @@ server.kill();
66
71
 
67
72
  ## With Grafema
68
73
 
69
- RFDB is optional for Grafema. By default, Grafema uses an in-memory backend. To use RFDB for persistent storage:
74
+ RFDB (Rega Flow Database) is optional for Grafema. By default, Grafema uses an in-memory backend. To use RFDB for persistent storage:
70
75
 
71
76
  ```javascript
72
77
  const { Orchestrator, RFDBServerBackend } = require('@grafema/core');
@@ -102,9 +107,72 @@ cargo build --release
102
107
 
103
108
  # Run tests
104
109
  cargo test
110
+ ```
111
+
112
+ ## Performance Benchmarks
113
+
114
+ RFDB includes Criterion-based benchmarks covering all core graph operations.
115
+
116
+ ### Running Locally
117
+
118
+ ```bash
119
+ cd packages/rfdb-server
120
+
121
+ # Run all benchmarks
122
+ cargo bench --bench graph_operations
123
+
124
+ # Run specific benchmark group
125
+ cargo bench --bench graph_operations -- 'add_nodes'
126
+ cargo bench --bench graph_operations -- 'get_node'
127
+
128
+ # Save baseline for future comparison
129
+ cargo bench --bench graph_operations -- --save-baseline my-baseline
130
+
131
+ # Compare against saved baseline
132
+ cargo bench --bench graph_operations -- --baseline my-baseline
133
+ ```
134
+
135
+ ### Benchmark Coverage
136
+
137
+ | Category | Operations |
138
+ |----------|-----------|
139
+ | **Node write** | add_nodes |
140
+ | **Edge write** | add_edges |
141
+ | **Node read** | get_node, find_by_type, find_by_type (wildcard), find_by_attr |
142
+ | **Edge read** | get_outgoing_edges, get_incoming_edges, neighbors |
143
+ | **Mutation** | delete_node, delete_edge |
144
+ | **Traversal** | bfs, reachability (forward/backward) |
145
+ | **Maintenance** | flush, compact |
146
+
147
+ ### CI Regression Detection
148
+
149
+ Benchmarks run on PRs with the `benchmark` label (comparing PR vs main branch).
150
+ Regressions >20% will fail the workflow.
151
+
152
+ To trigger on your PR: add the `benchmark` label.
153
+
154
+ ### What to Do If Benchmarks Regress
155
+
156
+ If CI reports a regression on your PR:
157
+
158
+ 1. **Check if it's noise** — re-run the workflow. CI runners have variable load; spurious regressions happen.
159
+ 2. **Reproduce locally** — save baselines before/after your change and compare with `critcmp`:
160
+ ```bash
161
+ git stash && cargo bench --bench graph_operations -- --save-baseline before
162
+ git stash pop && cargo bench --bench graph_operations -- --save-baseline after
163
+ cargo install critcmp && critcmp before after
164
+ ```
165
+ 3. **Identify the cause** — look at which operations regressed. A regression in `add_nodes` suggests storage overhead; `bfs`/`reachability` point to traversal changes.
166
+ 4. **Fix or justify** — if the regression is real, fix it. If it's an acceptable trade-off (e.g., +15% write latency for 10x better reads), document the trade-off in the PR description.
167
+
168
+ ### Comparing Before/After Changes
169
+
170
+ ```bash
171
+ # Before making changes
172
+ cargo bench --bench graph_operations -- --save-baseline before
105
173
 
106
- # Run benchmarks
107
- cargo bench
174
+ # Make changes, then compare
175
+ cargo bench --bench graph_operations -- --baseline before
108
176
  ```
109
177
 
110
178
  ## License
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@grafema/rfdb",
3
- "version": "0.2.1-beta",
4
- "description": "High-performance disk-backed graph database server for Grafema",
3
+ "version": "0.2.5-beta",
4
+ "description": "RFDB (Rega Flow Database) — high-performance disk-backed graph database server for Grafema",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "bin": {
@@ -9,14 +9,17 @@
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/Disentinel/rfdb.git"
12
+ "url": "https://github.com/Disentinel/grafema.git",
13
+ "directory": "packages/rfdb-server"
13
14
  },
14
15
  "keywords": [
15
16
  "graph",
16
17
  "database",
17
18
  "semantic-analysis",
18
19
  "code-analysis",
19
- "rust"
20
+ "rust",
21
+ "rega-flow",
22
+ "rfdb"
20
23
  ],
21
24
  "author": "Vadim Reshetnikov",
22
25
  "license": "Apache-2.0",
Binary file
Binary file
Binary file
@@ -2,8 +2,10 @@
2
2
  /**
3
3
  * RFDB postinstall script
4
4
  *
5
- * Validates that a prebuilt binary exists for the current platform,
6
- * or provides instructions for building from source.
5
+ * Ensures the RFDB server binary is available:
6
+ * 1. Check for prebuilt binary (fastest)
7
+ * 2. Check ~/.local/bin/rfdb-server (user-installed)
8
+ * 3. Provide clear instructions for unsupported platforms
7
9
  */
8
10
 
9
11
  const path = require('path');
@@ -12,31 +14,58 @@ const fs = require('fs');
12
14
  const platform = process.platform;
13
15
  const arch = process.arch;
14
16
 
17
+ // Determine platform directory name
15
18
  let platformDir;
16
19
  if (platform === 'darwin') {
17
20
  platformDir = arch === 'arm64' ? 'darwin-arm64' : 'darwin-x64';
18
21
  } else if (platform === 'linux') {
19
22
  platformDir = arch === 'arm64' ? 'linux-arm64' : 'linux-x64';
20
23
  } else {
21
- console.warn(`\n⚠️ @grafema/rfdb: No prebuilt binary for ${platform}-${arch}`);
22
- console.warn(' Build from source with: cargo build --release\n');
24
+ console.warn(`\n⚠️ @grafema/rfdb: Platform ${platform} is not supported yet.\n`);
23
25
  process.exit(0);
24
26
  }
25
27
 
26
- const binaryPath = path.join(__dirname, '..', 'prebuilt', platformDir, 'rfdb-server');
28
+ const prebuiltDir = path.join(__dirname, '..', 'prebuilt', platformDir);
29
+ const binaryPath = path.join(prebuiltDir, 'rfdb-server');
30
+ const homeBinaryPath = path.join(process.env.HOME || '', '.local', 'bin', 'rfdb-server');
27
31
 
28
- if (!fs.existsSync(binaryPath)) {
29
- console.warn(`\n⚠️ @grafema/rfdb: No prebuilt binary for ${platform}-${arch}`);
30
- console.warn(' Build from source with: cargo build --release');
31
- console.warn(' Or download from: https://github.com/Disentinel/rfdb/releases\n');
32
+ // 1. Check for prebuilt binary
33
+ if (fs.existsSync(binaryPath)) {
34
+ try {
35
+ fs.chmodSync(binaryPath, 0o755);
36
+ } catch (e) {
37
+ // Ignore chmod errors
38
+ }
39
+ console.log(`✓ @grafema/rfdb: Binary ready for ${platform}-${arch}`);
32
40
  process.exit(0);
33
41
  }
34
42
 
35
- // Make binary executable
36
- try {
37
- fs.chmodSync(binaryPath, 0o755);
38
- } catch (e) {
39
- // Ignore chmod errors on Windows
43
+ // 2. Check if user already has binary in ~/.local/bin
44
+ if (fs.existsSync(homeBinaryPath)) {
45
+ console.log(`✓ @grafema/rfdb: Found user binary at ${homeBinaryPath}`);
46
+ process.exit(0);
40
47
  }
41
48
 
42
- console.log(`✓ @grafema/rfdb: Binary ready for ${platform}-${arch}`);
49
+ // 3. No binary available - provide instructions
50
+ console.log(`
51
+ ⚠️ @grafema/rfdb: No prebuilt binary for ${platform}-${arch}
52
+
53
+ To use Grafema, build the server binary from source:
54
+
55
+ # Clone and build
56
+ git clone https://github.com/Disentinel/grafema.git
57
+ cd grafema/packages/rfdb-server
58
+ cargo build --release
59
+
60
+ # Install to ~/.local/bin (Grafema will find it automatically)
61
+ mkdir -p ~/.local/bin
62
+ cp target/release/rfdb-server ~/.local/bin/
63
+
64
+ # Or specify in config.yaml:
65
+ # server:
66
+ # binaryPath: /path/to/rfdb-server
67
+
68
+ Requires Rust: https://rustup.rs
69
+ `);
70
+
71
+ process.exit(0);