Skip to content

feat(cleanup): add --dedup-facts for near-duplicate fact supersession #245

Closed

Description

@hurttlocker

Summary

Add a focused v1.0.x cleanup feature to deduplicate near-duplicate facts without full canonicalization.

CLI

  • cortex cleanup --dedup-facts [--dry-run] [--agent <id>] [--dedup-threshold <0-1>]
  • Default threshold: 0.90

Behavior

  • Scope to active facts (superseded_by IS NULL), optional --agent.
  • Group by normalized (subject, predicate).
  • Within each group, compare object similarity and merge near-duplicates.
  • Keep highest-confidence fact as winner (tie-break: newest reinforcement, then lowest id).
  • Supersede losers via SupersedeFact(...) (tombstone), not hard-delete.

Dry-run output

Must print actual candidate pairs:

  • subject
  • predicate
  • winner object vs loser object
  • similarity score

Implementation

  • Add store API for dedup operation and report output.
  • Wire into runCleanup with flags and summary output.
  • Add tests for dry-run pair reporting + live supersede behavior.

Acceptance

  • No behavior changes unless --dedup-facts is passed.
  • go test ./... passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions