feat: add floop derive-edges CLI subcommand#129
Merged
nvandessel merged 5 commits intomainfrom Feb 20, 2026
Merged
Conversation
Two new corrections learned: - Stacked PR rebase: after base squash-merge, rebase with --onto - Satellite table dirty tracking: each table needs its own trigger Edges discarded — over-aggressive overrides pattern (54 new edges at weight 1.0 from 2 behaviors). Will re-derive with tag-enhanced scoring in a follow-up pass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a reusable command to derive similar-to and overrides edges from behavior similarity analysis. Edges are proposed via two criteria: - Score-based: weighted similarity in [0.5, 0.9) using when/content/tags - Tag-based: behaviors sharing >= 2 tags get connected for spreading activation (e.g., git + worktree should associate related concepts) Also extracts IsMoreSpecific to public similarity.IsMoreSpecific() and adds CountSharedTags for tag co-occurrence counting. Flags: --scope (local/global/both), --dry-run, --clear Output: per-store stats, score histogram, connectivity counts Results on current data: 172 global edges created, connected nodes 62/147 (up from 29), 0 validation errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address self-review findings: - Use defer graphStore.Close() matching cmd_dedup/cmd_connect patterns - Drop always-nil error from clearDerivedEdges return signature Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryAdds Key changes:
Results: Local store created 8 edges (11/19 connected), global store created 172 edges (62/147 connected). Validation passed with 0 errors. Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| cmd/floop/cmd_derive_edges.go | New CLI command that derives similar-to and overrides edges via all-pairs similarity analysis. Implements dry-run, clear, and scope flags with proper defer for store.Close() |
| cmd/floop/cmd_derive_edges_test.go | Comprehensive test coverage with 7 test functions covering edge proposals, deduplication, connectivity, histogram, clear flag, and tag-overlap rule |
| internal/similarity/specificity.go | Extracted IsMoreSpecific() as public function to enable reuse across packages for determining when-condition supersets |
| internal/similarity/similarity.go | Added CountSharedTags() helper for tag co-occurrence counting to support the tag-overlap rule in edge derivation |
| internal/learning/place.go | Refactored isMoreSpecific() to delegate to public similarity.IsMoreSpecific() for code reuse, removing 24 lines of duplicate logic |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User runs: floop derive-edges] --> B{Check scope flag}
B -->|local| C[Open local .floop store]
B -->|global| D[Open global ~/.floop store]
B -->|both| E[Open both stores]
C --> F[deriveEdgesForStore]
D --> F
E --> F
F --> G[Load all behaviors from store]
G --> H{--clear flag?}
H -->|yes| I[clearDerivedEdges: Remove existing similar-to/overrides edges]
H -->|no| J[Build existing edge set for dedup]
I --> J
J --> K[All-pairs comparison loop]
K --> L[For each pair: Compute similarity score]
L --> M[Record in histogram bucket]
M --> N{Check specificity}
N -->|a when ⊃ b when| O[Propose overrides edge]
N -->|b when ⊃ a when| O
M --> P{Check similarity}
P -->|score in 0.5-0.9| Q[Propose similar-to edge]
P -->|shared tags >= 2| Q
O --> R{Edge exists?}
Q --> R
R -->|yes| S[Skip: increment SkippedExisting]
R -->|no| T[Add to ProposedEdges]
T --> U{--dry-run?}
U -->|yes| V[Return result without creating edges]
U -->|no| W[Create edges in store]
W --> X[graphStore.AddEdge for each proposal]
X --> Y[graphStore.Sync]
Y --> Z[Refresh PageRank]
Z --> AA[Compute connectivity stats]
AA --> AB[Return result]
V --> AA
Last reviewed commit: 8cb5e41
…ions-feb18 # Conflicts: # .floop/corrections.jsonl
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.
Summary
floop derive-edgescommand to derivesimilar-toandoverridesedges from behavior analysisIsMoreSpecificto publicsimilarity.IsMoreSpecific()for reusesimilarity.CountSharedTags()for tag co-occurrence countinggit+worktreeshould associate related concepts)Flags
--scope(local/global/both, default "both")--dry-run— preview without creating edges--clear— remove existingsimilar-to/overridesedges before re-derivingResults on current data
Global validation: 0 errors.
Test plan
go test ./internal/similarity/...—IsMoreSpecific+CountSharedTagstests passgo test ./internal/learning/...— existing place tests pass (refactor safe)go test ./cmd/floop/...— 7 new test functions: proposals, skip-existing, connectivity, histogram, clear, tag-overlap, command flagsfloop derive-edges --dry-run --scope both— preview looks correctfloop derive-edges --clear --scope both— edges created, connectivity improvedfloop validate --scope global— 0 errors🤖 Generated with Claude Code