Skip to content

Feature/graph time travel - #17

Merged
mohanagy merged 14 commits into
mainfrom
feature/graph-time-travel
Apr 27, 2026
Merged

mohanagy merged 14 commits into
mainfrom
feature/graph-time-travel

Conversation

@mohanagy

@mohanagy mohanagy commented Apr 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Testing

  • npm run test:run
  • npm run typecheck
  • npm run build
  • npm pack --dry-run (if packaging or install behavior changed)

Checklist

  • I updated docs for any user-visible change
  • I added or updated tests when behavior changed
  • I did not commit secrets, private corpora, or accidental generated artifacts
  • I kept this PR focused on a single change or tightly related set of changes

Related issues

Summary by CodeRabbit

  • New Features

    • Added graphify-ts time-travel command to compare Git refs with multiple analysis views: summary, risk, drift, and timeline.
    • Added MCP tool for time-travel comparisons using cached graph snapshots with optional refresh and limit parameters.
    • Snapshot generation runs on-demand and is cached for reuse.
  • Documentation

    • Updated CLI and MCP documentation with time-travel workflow details and available view modes.

mohanagy and others added 14 commits April 27, 2026 01:27
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use node id fallback semantics when building the after-graph lookup for riskView, and cover the unlabeled-node regression with a targeted test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Apr 27, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR introduces a comprehensive "time travel" feature for comparing graph snapshots between two Git references. It adds a new CLI command (graphify-ts time-travel <from> <to>), an MCP tool (time_travel_compare), infrastructure for on-demand snapshot caching per commit SHA, and runtime logic for analyzing graph differences with configurable views (summary, risk, drift, timeline).

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md, README.md
Adds documentation for the new time-travel feature, including CLI command syntax, view modes, snapshot caching behavior, and MCP tool integration with examples.
CLI Command Implementation
src/cli/main.ts, src/cli/parser.ts
Introduces parseTimeTravelArgs parser and TimeTravelCliOptions interface to handle time-travel <from> <to> command with --view, --json, --refresh, and --limit flags; wires dependency injection hook runTimeTravel into CLI execution.
Infrastructure Layer
src/infrastructure/cache.ts, src/infrastructure/generate.ts, src/infrastructure/time-travel.ts
Extends cacheDir for path segmentation; exports loadGraphExtractorVersion; adds new loadOrBuildSnapshot and compareRefs functions with atomic snapshot creation, concurrent deduplication via inflight map, and Git worktree-based graph generation for target commits.
Runtime & MCP Integration
src/runtime/stdio-server.ts, src/runtime/stdio/definitions.ts, src/runtime/stdio/tools.ts, src/runtime/time-travel.ts
Adds time_travel_compare MCP tool definition and handler; implements compareTimeTravelGraphs and formatTimeTravelResult for graph diff analysis, community drift detection, risk ranking, and event timeline construction; extends handleStdioRequest/handleToolCall signatures to support async and tool overrides.
Test Coverage
tests/unit/cli.test.ts, tests/unit/stdio-server.test.ts, tests/unit/time-travel-infrastructure.test.ts, tests/unit/time-travel.review-regressions.test.ts, tests/unit/time-travel.test.ts
Adds comprehensive unit tests for CLI parsing and routing, MCP tool validation, snapshot lifecycle and concurrent deduplication, graph comparison logic, impact analysis, and view-specific result formatting.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant CLI as CLI Parser
    participant Exec as CLI Executor
    participant Cache as Cache Layer
    participant Git as Git/Worktree
    participant Graph as Graph Generator
    participant Runtime as Comparison Runtime
    participant Output as Formatter

    User->>CLI: time-travel <from> <to> --view=risk
    CLI->>Exec: parseTimeTravelArgs() returns options
    Exec->>Cache: loadOrBuildSnapshot(from_ref, refresh=false)
    alt Snapshot Cache Hit
        Cache-->>Runtime: return cached TimeTravelSnapshot
    else Cache Miss or Refresh
        Cache->>Git: git rev-parse (resolve ref to SHA)
        Cache->>Git: git worktree add (create detached worktree)
        Git->>Graph: generateGraph(worktreeDir)
        Graph->>Cache: return graph + report artifacts
        Cache->>Cache: write metadata.json atomically
        Cache-->>Runtime: return new TimeTravelSnapshot
    end
    Exec->>Cache: loadOrBuildSnapshot(to_ref, refresh=false)
    Cache-->>Runtime: return second TimeTravelSnapshot
    Exec->>Runtime: compareTimeTravelGraphs(beforeGraph, afterGraph, {view: 'risk'})
    Runtime->>Runtime: compute graphDiff
    Runtime->>Runtime: detect community drift & impact analysis
    Runtime->>Runtime: rank top risks by limit
    Runtime-->>Output: return TimeTravelResult
    Exec->>Output: formatTimeTravelResult(result)
    Output-->>User: display risk-ranked comparison
Loading
sequenceDiagram
    participant Client as MCP Client
    participant StdioServer as Stdio Server
    participant ToolCall as Tool Handler
    participant Infra as time-travel Infra
    participant Runtime as Runtime Compare
    participant Response as Response Builder

    Client->>StdioServer: tools/call time_travel_compare {from_ref, to_ref, view}
    StdioServer->>ToolCall: handleToolCall(..., time_travel_compare)
    ToolCall->>ToolCall: validate from_ref, to_ref, view ∈ {summary|risk|drift|timeline}
    ToolCall->>Infra: compareRefs({fromRef, toRef, view, refresh, limit})
    Infra->>Infra: loadOrBuildSnapshot(fromRef)
    Infra->>Infra: loadOrBuildSnapshot(toRef)
    Infra->>Runtime: compareTimeTravelGraphs(beforeGraph, afterGraph, {view, limit})
    Runtime->>Runtime: analyze graph differences by view type
    Runtime-->>Infra: return TimeTravelResult
    Infra-->>ToolCall: return result
    ToolCall->>Response: serialize result as JSON text
    Response-->>Client: tools/call response with text content
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 Hop forward, hop back through the git timeline so neat,
Two refs compared, their graphs compete,
Snapshots cached where communities drift and dance,
Risk and impact in a time-travel glance, ✨
Whisker-blessed diffs reveal all we seek!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete; the Summary section and Testing sections are empty with only template placeholders, and no actual change details or verification steps are provided. Complete the Summary with details about the time-travel feature, fill in the Testing section with verification steps, and check the relevant checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Feature/graph time travel' is too vague and uses a generic feature branch prefix format rather than describing the actual change. Consider using a more descriptive title like 'Add graph time-travel ref comparison feature' that clearly conveys what was added.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/graph-time-travel

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mohanagy
mohanagy merged commit e2723b2 into main Apr 27, 2026
6 checks passed
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