Skip to content

Feature Request: Git-Aware Memory — Auto-Extraction from Git History & Stale Anchor Detection #147

Description

@Smitbafna

The Problem in 5 Lines

Greplica's memory is entirely session-driven repos with no prior agent sessions start empty, and existing memory is never automatically validated against the evolving codebase. Commit messages, PR descriptions, and co-change patterns in git history are rich sources of architectural knowledge that go completely untapped. Meanwhile, claims with code_anchors pointing to files that have been deleted, renamed, or refactored silently become stale, leading agents to act on outdated information. The current greplica graph audit anchors command only checks file existence on disk, not whether the code's behavior still matches the claim. This proposal solves both problems: bootstrapping memory from git history for cold-start repos, and continuously validating memory accuracy through a background watch daemon.


Proposed Features

1. greplica git ingest — Bootstrap Memory from Git History

Walk git history to auto-generate claims, components, flows, and edges from commit messages, diffs, and co-change patterns — all with deterministic heuristics (no LLM required).

greplica git ingest [--max-commits <n>] [--max-age <days>] [--prs] [--github-token <token>] [--dry-run]

The pipeline:

  1. Collect Commits — Single git log call with --format and --numstat
  2. Analyze Commits — Parse conventional commits (feat:, fix:, refactor:, etc.) + regex-based decision extraction
  3. Detect Co-Change Patterns — Statistical lift analysis to discover module boundaries and propose component + flow definitions
  4. Analyze PR Metadata (optional) — Fetch PR bodies via GitHub API for richer context
  5. Generate & Apply Proposal — Produces a standard MemoryCommitProposal with appropriate edges, sources, and deduplication

Sample output from 127 commits:

Claims to create: 42 (12 decision, 18 fact, 8 insight, 4 requirement)
Components to create: 7 (src/auth/, src/api/, src/db/, ...)
Flows to create: 3 (auth_flow, deployment, api_integration)
Sources to create: 127 (one git_history source per commit)

2. greplica git watch — Continuous Memory Validation

Background daemon that automatically re-validates claims when code changes.

greplica git watch [--daemon] [--interval <seconds>] [--anchor-threshold <days>]
  • Polls git rev-parse HEAD (fast, ~5ms) for new commits
  • On new commit: identifies affected claims whose code_anchors touch changed files
  • Re-resolves symbols via tree-sitter; if symbol no longer exists or file was deleted, adds a needs_review edge to the claim
  • Also runs periodic full anchor validation

3. Stale Anchor Detection & Validation

  • New edge kind: needs_review — attached to claims whose code anchors may be stale, with metadata explaining why (file_deleted, symbol_removed, file_content_changed)
  • New claim kind: insight — distinguishes auto-extracted claims from agent-written ones
  • New source kind: git_history — provenance pointing to git commits
  • Integration with proposal validate: rejects proposals that reference claims with stale anchors
  • Graph view integration: warning icons on stale claims, filterable view

Activity

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