Skip to content

feat: add floop derive-edges CLI subcommand#129

Merged
nvandessel merged 5 commits intomainfrom
chore/capture-corrections-feb18
Feb 20, 2026
Merged

feat: add floop derive-edges CLI subcommand#129
nvandessel merged 5 commits intomainfrom
chore/capture-corrections-feb18

Conversation

@nvandessel
Copy link
Owner

Summary

  • Add floop derive-edges command to derive similar-to and overrides edges from behavior analysis
  • Extract IsMoreSpecific to public similarity.IsMoreSpecific() for reuse
  • Add similarity.CountSharedTags() for tag co-occurrence counting
  • Tag-overlap rule: behaviors sharing >= 2 tags get connected regardless of similarity score — essential for spreading activation (e.g., git + worktree should associate related concepts)

Flags

  • --scope (local/global/both, default "both")
  • --dry-run — preview without creating edges
  • --clear — remove existing similar-to/overrides edges before re-deriving

Results on current data

Store Behaviors Edges created Connected Islands
Local 19 8 11 8
Global 147 172 62 85

Global validation: 0 errors.

Test plan

  • go test ./internal/similarity/...IsMoreSpecific + CountSharedTags tests pass
  • go 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 flags
  • floop derive-edges --dry-run --scope both — preview looks correct
  • floop derive-edges --clear --scope both — edges created, connectivity improved
  • floop validate --scope global — 0 errors

🤖 Generated with Claude Code

nvandessel and others added 4 commits February 18, 2026 18:02
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-apps
Copy link

greptile-apps bot commented Feb 19, 2026

Greptile Summary

Adds floop derive-edges CLI command to automatically derive similar-to and overrides edges from behavior similarity analysis. The implementation extracts IsMoreSpecific() to a public function in the similarity package for reuse, adds CountSharedTags() helper, and refactors place.go to use the shared implementation.

Key changes:

  • Tag-overlap rule: Behaviors sharing >= 2 tags get connected via similar-to edges regardless of score (line 228-229 in cmd_derive_edges.go) — essential for spreading activation between related concepts like git + worktree
  • Score-based edges: similarity in [0.5, 0.9) creates similar-to edges; when-condition supersets create overrides edges
  • Flags: --dry-run for preview, --clear to remove existing derived edges, --scope for local/global/both
  • Proper resource cleanup: Uses defer graphStore.Close() (lines 67, 91)
  • Comprehensive tests: 7 test functions covering proposals, deduplication, connectivity, histogram, clear, and tag-overlap

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

  • Safe to merge - well-tested feature with comprehensive coverage and proper resource management
  • Score reflects solid implementation quality: proper defer usage for resource cleanup, comprehensive test coverage (7 test functions), clean refactoring to extract shared logic, and successful validation on real data. The tag-overlap rule addresses a real spreading-activation limitation. No logical errors, security issues, or untested edge cases found.
  • No files require special attention

Important Files Changed

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
Loading

Last reviewed commit: 8cb5e41

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

11 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

…ions-feb18

# Conflicts:
#	.floop/corrections.jsonl
@nvandessel nvandessel merged commit 4ba81ff into main Feb 20, 2026
9 checks passed
@nvandessel nvandessel deleted the chore/capture-corrections-feb18 branch February 20, 2026 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments