Skip to content

Fix clippy issues and handle duplicate graph nodes - #112

Merged
geekgonecrazy merged 6 commits into
devfrom
bug/duplicate-graph-nodes
Jul 13, 2026
Merged

geekgonecrazy merged 6 commits into
devfrom
bug/duplicate-graph-nodes

Conversation

@leefaus

@leefaus leefaus commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

This pull request addresses two critical issues related to session view handling and file diffing in the presence of graph forks or cycles. It ensures that missing session views are created just-in-time to prevent content duplication, and that file diffs avoid corruption by falling back to whole-file replacements when necessary. The changes also clarify and harden the logic for deleting all file content in complex graph states, and introduce robust tests to prevent regressions.

Session View Handling and Duplication Prevention:

  • record_turn() now detects when a session view is missing (often due to a failed or skipped SessionStart) and proactively forks the view from its intended parent or the current view as a last resort. This prevents recording onto the wrong view, which previously led to content duplication when merging views.
  • A comprehensive regression test (test_orphaned_session_view_duplicates_content_on_merge) simulates the orphaned session view scenario and verifies that content is not duplicated after merging, ensuring the fix remains effective.

File Diffing and Whole-file Replace Safety:

  • When the old file content was derived from a semantic merge (e.g., resolving forks or cycles), the code now forces a whole-file replace instead of attempting a positional diff. This prevents corrupted hunks that could arise from mismatched file structures. [1] [2]
  • The file output function (output_file_to_buffer_with_options) now returns a flag indicating whether semantic merge resolution was required, allowing callers to make safe decisions about diffing. [1] [2] [3] [4] [5]

Content Deletion Logic Improvements:

  • The logic for deleting all file content (delete_all_content) is refactored to always use a thorough, SCC-aware traversal, ensuring all content vertices are deleted even in the presence of forks (as produced by the orphan-view duplication bug). This replaces previous fallback mechanisms that could leave orphaned content alive. [1] [2] [3]
  • The now-unnecessary find_content_vertices_cached function is removed, further simplifying the code and reducing the risk of incomplete deletions.

Diff Heuristic Clarification:

  • The diffing heuristic in the CLI is updated to clarify that adds are only pulled forward, never backward, and that intervening Added lines are now allowed for better readability in diffs.

These changes collectively make the system more robust against subtle bugs caused by missing session views and complex file histories, while also improving code clarity and maintainability.

leefaus and others added 6 commits July 13, 2026 13:36
These referenced intents created in a different (pomodoro) project and
aren't relevant to atomic. Rewrote each comment to describe the bug/fix
directly (orphan-view duplication, whole-file-replace safety) while
preserving the technical explanation.
@geekgonecrazy
geekgonecrazy merged commit 73125e7 into dev Jul 13, 2026
8 checks passed
@geekgonecrazy
geekgonecrazy deleted the bug/duplicate-graph-nodes branch July 13, 2026 20:37
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.

2 participants