fix(ruflo-adr): adr-index upsert + deterministic edge keys (#2660)#2754
Open
michaelaperez-byte wants to merge 1 commit into
Open
fix(ruflo-adr): adr-index upsert + deterministic edge keys (#2660)#2754michaelaperez-byte wants to merge 1 commit into
michaelaperez-byte wants to merge 1 commit into
Conversation
Three defects in plugins/ruflo-adr/scripts/import.mjs prevented adr-index from updating changed ADRs (its documented purpose): 1. memoryStore() called 'memory store' without --upsert. The CLI default is declared true but not honored (ruvnet#2594); without explicit --upsert, re-running on an existing key fails UNIQUE → record frozen forever. 2. The 'exists' sentinel (UNIQUE constraint failure, line 231) was counted as a stored record/edge (lines 255, 261). A failed write silently became a success tally, errors stayed empty, summary reported full success while nothing was persisted. 3. Edge key had Date.now()+random suffix (line 259) → never collided → upsert couldn't dedup → edges duplicated 3→6→9 on repeated runs. Fix: add --upsert, count only 'ok' as stored, make edge key deterministic (relation:from->to — capturedAt already in the value). Issue: ruvnet#2660
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: ruflo-adr adr-index can't update changed ADRs (#2660)
Three defects in
plugins/ruflo-adr/scripts/import.mjspreventedadr-indexfrom updating changed ADRs — its documented purpose per SKILL.md ("rebuild the ADR index + dependency graph"):Defect 1 — Missing --upsert (line 224-228)
memoryStore()callednpx ... memory storewithout--upsert. The CLI help says--upsertdefaults to true, but #2594 shows the default is not honored. Without explicit--upsert, re-running on an existing key fails with UNIQUE constraint → the record stays frozen at its first-indexed value forever.Fix: Added
'--upsert'to the spawnSync argv.Defect 2 — 'exists' (UNIQUE failure) counted as success (lines 255, 261)
if (r === 'ok' || r === 'exists') storedRecords++— but'exists'is the sentinel for the UNIQUE constraint FAILURE (line 231). A failed write was silently counted as a stored record,errorsstayed empty, and the summary reported full success while nothing was persisted.Fix: Changed to
if (r === 'ok')for both patterns and edges;'exists'now pushed toerrors.Defect 3 — Non-deterministic edge key (line 259)
Edge key had
Date.now()+randomsuffix → never collided → upsert couldn't dedup → edges duplicated 3→6→9 on repeated runs. The edge's identity IS(relation, from, to)—capturedAtalready lives in the value.Fix: Made the key deterministic:
${e.relation}:${e.from}->${e.to}.Regression test
v3/@claude-flow/cli/__tests__/issue-2660-adr-index-upsert.test.mjs— standalone Node assertion runner (13/13 pass).Verification
node --check import.mjs→ SYNTAX OKreindex.mjs(separate file, not touched) has the same three bugs — should get its own ticket.Fixes #2660