Recommendations discovered during development. None of these are implemented — per the project rules, out-of-scope ideas are documented here and deliberately left alone (prompt §21–23).
diff_text.MAX_EDIT_COST (50M inner iterations) bounds the Myers search.
On adversarial inputs (two large files with almost nothing in common) the
engine burns the whole budget — tens of seconds of pure Python — before
falling back to the coarse replacement.
Also poll time.monotonic() every N steps and abort after e.g. 2 s, or
scale the budget by input size (as Git's diffcore heuristics do).
Bounded wall-clock latency on pathological inputs.
alternating_5mb (every 2nd line of a ~5 MiB file changed) burns the
full 50M-iteration budget: 49.4 s in A-Train vs 0.032 s GNU diff.
A time-based cutoff of ~1-2 s would cut this by an order of magnitude
while keeping the fallback correct.
Results become machine-dependent (a slow machine may coarsen a diff the fast machine computes minimally) — worse determinism.
High (upgraded from Medium after the v0.3 measurements).
Implemented — diff_text.MAX_DIFF_SECONDS (default 2 s, checked
every 65 536 work units) aborts the search and falls back to the coarse
interior REPLACE. Measured: alternating_5mb 49.4 s → 2.665 s
(benchmarks/RESULTS.md); fallback correctness verified by
tests/test_tui_cache.py::TestV04Optimizations. Moved out of this file's
"not implemented" scope accordingly; the machine-dependence downside is
accepted and documented in the module docstring.
Plain Myers produces minimal diffs; on code with repeated lines
(e.g. } or blank lines) the chosen match points can be less
human-friendly than GNU/Git output.
Git's histogram heuristic (or the simpler xdiff heuristics) to shift match points toward low-frequency lines after the minimal script is found.
More "natural" hunk boundaries, closer to git diff output.
Post-processing pass costs time; output is no longer guaranteed minimal.
Low (cosmetic).
ROADMAP lists it as optional ("در صورت نیاز"); correctness and minimality were the v0.1 goals.
All options are CLI flags.
Read per-project defaults from atrain.toml (context, ignore options,
format) when present; CLI flags override.
Teams get consistent diffs without retyping flags.
Configuration precedence and file discovery need careful specification and tests.
Low.
Listed under "User Interfaces, Phase 2" in the roadmap but absent from the §8 milestone checklist; not required to complete any milestone.
--mode must be given (currently only text exists; default text).
Sniff JSON/CSV/binary magic and pick the dedicated engine when --mode
is omitted.
python -m atrain a.json b.json "just works".
Ambiguous inputs (JSON-looking CSV); surprising mode switches in CI.
Low.
Implemented — atrain.core.detect.detect_mode; --mode auto is now the
default. Detection is conservative (both inputs must agree, structured
formats are confirmed by parsing/sniffing) and the chosen engine is echoed
on stderr when attached to a TTY. Explicit --mode still wins.
(v0.3 planning note) ROADMAP §3.6 prescribes ProcessPoolExecutor.
Benchmark both: hashing releases the GIL (threads win on large files and
avoid pickling DiffResults), while per-file text diffs are
pure-Python (processes win on many-core machines).
Possibly simpler + faster on the common case.
Divergence from the roadmap's literal wording if threads win.
Medium (decide during v0.3).
v0.3 milestone work has not started yet.
JSON arrays are compared index-wise: inserting an element at the front of a 1000-element array reports 1000 changes.
Match array elements by similarity or by key field (like CSV key columns) before reporting, so a single insertion is reported as one insertion.
Dramatically smaller change lists for list-heavy documents.
Heuristics can mis-pair elements; matching cost is super-linear.
Medium.
Index-wise comparison is deterministic and predictable; ROADMAP only requires "semantic comparison independent of key order" (objects), which is implemented.
small_change_100mb runs in 3.6 s. Phase profile: decode+split 1.9 s,
interning 1.4 s, Myers 0.19 s. The algorithm is fast; pure-Python
per-line text processing is the bottleneck. (identical_100mb already
meets the <1 s target via the hash early exit: 0.34 s.)
Index line offsets over the mmap buffer without materialising decoded strings; hash lines with BLAKE2b over byte slices; decode only the lines inside hunks. Alternatively accept a compiled helper (setuptools C module) — trading the "zero hard dependencies" principle.
Likely brings 100 MB small-change under ~1.5 s; possibly under 1 s.
Significant complexity in reader/diff_text; lazy decoding changes the
invariant that formatters receive decoded text eagerly.
High (this is the roadmap's headline target).
The current milestone plan (§8) does not include a compiled pipeline; re-architecting the reader exceeds the "improvement" boundary defined for this programme and is therefore documented, not implemented.