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(ruflo-adr): use a key separator the memory validator accepts for edges (#3633)

drakeo338839f1cd0863a
diff --git a/plugins/ruflo-adr/scripts/__tests__/index-idempotency-2660.test.mjs b/plugins/ruflo-adr/scripts/__tests__/index-idempotency-2660.test.mjs
index 8850c3e676..74f982a7e8 100644
--- a/plugins/ruflo-adr/scripts/__tests__/index-idempotency-2660.test.mjs
+++ b/plugins/ruflo-adr/scripts/__tests__/index-idempotency-2660.test.mjs
@@ -33,7 +33,7 @@ test('stable ADR keys are explicitly upserted when mutable metadata changes', ()
test('edge identity is deterministic and duplicate semantic triples collapse', () => {
const edge = { relation: 'depends-on', from: 'ADR-007', to: 'ADR-003' };
- assert.equal(edgeKey(edge), 'depends-on:ADR-007->ADR-003');
+ assert.equal(edgeKey(edge), 'depends-on:ADR-007__ADR-003');
assert.equal(edgeKey({ ...edge }), edgeKey(edge));
const unique = uniqueEdges([
@@ -42,19 +42,19 @@ test('edge identity is deterministic and duplicate semantic triples collapse', (
{ relation: 'related', from: 'ADR-007', to: 'ADR-003' },
]);
assert.deepEqual(unique.map(edgeKey), [
- 'depends-on:ADR-007->ADR-003',
- 'related:ADR-007->ADR-003',
+ 'depends-on:ADR-007__ADR-003',
+ 'related:ADR-007__ADR-003',
]);
const args = memoryStoreArgs('adr-edges', edgeKey(edge), edge);
assert.ok(args.includes('--upsert'));
- assert.ok(args.includes('--key=depends-on:ADR-007->ADR-003'));
+ assert.ok(args.includes('--key=depends-on:ADR-007__ADR-003'));
- assert.deepEqual(parseEdgeKey('depends-on:ADR-007->ADR-003'), {
+ assert.deepEqual(parseEdgeKey('depends-on:ADR-007__ADR-003'), {
relation: 'depends-on',
from: 'ADR-007',
to: 'ADR-003',
- key: 'depends-on:ADR-007->ADR-003',
+ key: 'depends-on:ADR-007__ADR-003',
});
assert.deepEqual(parseEdgeKey('depends-on:ADR-007->ADR-003:1721061000000-a1b2c3'), {
relation: 'depends-on',
@@ -63,3 +63,18 @@ test('edge identity is deterministic and duplicate semantic triples collapse', (
key: 'depends-on:ADR-007->ADR-003:1721061000000-a1b2c3',
});
});
+
+test('edge keys pass the memory key validator and legacy -> keys still parse', () => {
+ // Copy of DANGEROUS_KEY_PATTERN in @claude-flow/cli mcp-tools/memory-tools.
+ const dangerous = /[;&|`$(){}[\]<>!#\\\0]|\.\.[/\\]/;
+ const edge = { relation: 'related', from: 'ADR-002', to: 'ADR-001' };
+ assert.equal(dangerous.test(edgeKey(edge)), false);
+
+ assert.deepEqual(parseEdgeKey('related:ADR-002->ADR-001'), {
+ relation: 'related',
+ from: 'ADR-002',
+ to: 'ADR-001',
+ key: 'related:ADR-002->ADR-001',
+ });
+ assert.deepEqual(parseEdgeKey(edgeKey(edge)), { ...edge, key: edgeKey(edge) });
+});
diff --git a/plugins/ruflo-adr/scripts/lib/index-records.mjs b/plugins/ruflo-adr/scripts/lib/index-records.mjs
index 0b5dbe9192..c073dee7a1 100644
--- a/plugins/ruflo-adr/scripts/lib/index-records.mjs
+++ b/plugins/ruflo-adr/scripts/lib/index-records.mjs
@@ -23,13 +23,15 @@ export function adrRecordValue(adr) {
// an observation; they must not be part of identity or every index run creates
// another logically-identical edge (#2660).
export function edgeKey(edge) {
- return `${edge.relation}:${edge.from}->${edge.to}`;
+ // '->' is rejected by the memory key validator ('>' is in DANGEROUS_KEY_PATTERN).
+ return `${edge.relation}:${edge.from}__${edge.to}`;
}
-// Accept the deterministic #2660 key and the legacy timestamp-random suffix
-// so existing installations remain verifiable after upgrading.
+// Accept the deterministic #2660 key (also with the earlier '->' separator)
+// and the legacy timestamp-random suffix so existing installations remain
+// verifiable after upgrading.
export function parseEdgeKey(key) {
- const match = /^([\w-]+):([^:]+)->([^:]+?)(?::\d+-[a-z0-9]+)?$/i.exec(key);
+ const match = /^([\w-]+):([^:]+?)(?:->|__)([^:]+?)(?::\d+-[a-z0-9]+)?$/i.exec(key);
if (!match) return null;
return { relation: match[1], from: match[2], to: match[3], key };
}
diff --git a/plugins/ruflo-adr/scripts/verify.mjs b/plugins/ruflo-adr/scripts/verify.mjs
index 6ebed33845..cde74f1419 100755
--- a/plugins/ruflo-adr/scripts/verify.mjs
+++ b/plugins/ruflo-adr/scripts/verify.mjs
@@ -103,8 +103,8 @@ const adrIds = new Set(
const edges = [];
for (const e of edgeEntries) {
const k = e.key || '';
- // Current deterministic key: relation:FROM->TO. Keep reading the legacy
- // relation:FROM->TO:timestamp-rand shape for seamless upgrades (#2660).
+ // Current deterministic key: relation:FROM__TO. Keep reading the earlier
+ // relation:FROM->TO and relation:FROM->TO:timestamp-rand shape for seamless upgrades (#2660).
const parsed = parseEdgeKey(k);
if (parsed) edges.push(parsed);
}
diff --git a/plugins/ruflo-adr/skills/adr-index/SKILL.md b/plugins/ruflo-adr/skills/adr-index/SKILL.md
index 615758565c..ed970e1830 100644
--- a/plugins/ruflo-adr/skills/adr-index/SKILL.md
+++ b/plugins/ruflo-adr/skills/adr-index/SKILL.md
@@ -56,7 +56,7 @@ date: <ISO date>
tags: <comma-separated>
```
-`adr-edges` namespace, deterministic key `<relation>:<FROM>-><TO>`, value:
+`adr-edges` namespace, deterministic key `<relation>:<FROM>__<TO>`, value:
```json
{ "from": "ADR-097", "to": "ADR-086", "relation": "related", "capturedAt": "<ISO>" }