diffengine

package
v0.8.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package diffengine ports src/pr_af/diff_engine.py — the deterministic (non-LLM) diff parser and clustering engine that feeds the anatomy phase.

It is a byte-for-byte behavioral port of the Python module. Where the Python implementation has quirks (see notes below) they are reproduced exactly rather than "fixed", because downstream golden comparisons and cluster/finding ordering depend on identical output:

  • parse_unified_diff never emits a "renamed" status. Git rename headers (`rename from`/`rename to`, `similarity index`) are not special-cased; a rename surfaces as status "modified" with the path taken from the `+++ b/` line (or "" for a pure content-free rename that has no `+++ b/`).
  • A deleted file (`+++ /dev/null`) never sets a path, so its Path is "".
  • Binary files (no `---`/`+++` lines) yield a FileChange with Path "" and no hunks.
  • Line splitting matches Python's str.splitlines() (not strings.Split on "\n"): all Unicode line boundaries split, and a trailing line break does NOT produce a final empty element. This keeps hunk `content` byte-exact.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClusterChanges

func ClusterChanges(files []schemas.FileChange) []schemas.ChangeCluster

ClusterChanges ports cluster_changes: group files by their directory (the path up to the last "/"; "root" when there is no "/"), then emit one cluster per directory in sorted-directory order with deterministic ids "cluster_0", "cluster_1", ... The primary language is the most frequent language in the group.

Divergence note: Python computes primary_language via `max(set(langs), key=langs.count)`, whose tie-break depends on set iteration order and is therefore non-deterministic across Python processes (str hash randomization). This port instead breaks ties deterministically by first-appearance order within the group. For a unique mode (the overwhelming common case, including single-language groups) both agree exactly.

func ComputeDiffStats

func ComputeDiffStats(files []schemas.FileChange) schemas.DiffStats

ComputeDiffStats ports compute_diff_stats: aggregate statistics over the parsed files. The test-to-code ratio divides the test-file count by max(code_files, 1) so it never divides by zero.

func ParseUnifiedDiff

func ParseUnifiedDiff(diffText string) []schemas.FileChange

ParseUnifiedDiff parses unified diff text into structured FileChange objects. It is a direct port of Python parse_unified_diff, preserving branch order and the accumulation quirks documented on the package.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL