Skip to content

fix(formatters): render backend function names in markdown diff (closes #299)#301

Merged
Wolfvin merged 2 commits into
mainfrom
fix/issue-299-md-diff-names
Jul 17, 2026
Merged

fix(formatters): render backend function names in markdown diff (closes #299)#301
Wolfvin merged 2 commits into
mainfrom
fix/issue-299-md-diff-names

Conversation

@Wolfvin

@Wolfvin Wolfvin commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Closes #299.

Masalah

impact --check diff --format markdown selalu mencetak nama fungsi backend kosong. Producer/consumer memakai key berbeda:

  • diff_engine._diff_backend() mengemit {"name": "freshFn", "file": "a.py", ...}
  • formatters/markdown.py:_md_diff() membaca node.get('fn', '') → selalu jatuh ke default ''

Sebelum:

### Backend — +1 / -1 / ~0
- + `` (a.py)
- - ``

Sesudah:

### Backend — +1 / -1 / ~0
- + `freshFn` (a.py)
- - `goneFn`

Jumlahnya benar, identitasnya kosong — tidak crash, jadi tak pernah ketahuan. Blok frontend di fungsi yang sama sudah benar (cls.get('name')); ini murni sisi backend.

Kenapa diperbaiki di consumer, bukan producer

commands/diff.py, dashboard, dan MCP sudah mengonsumsi name. Mengubah producer memecah mereka. Constraint ini ditulis di issue sebelum implementasi.

Verifikasi (dijalankan)

  • 5 test baru (tests/test_markdown_diff.py). Salah satunya merender output _diff_backend() asli, bukan dict tiruan — jadi kontrak producer↔consumer benar-benar terkunci, bukan cuma asumsi saya tentang bentuknya.
  • Terbukti gagal kalau fix dicabut: 4 dari 5 gagal (git stash → run → pop). Yang frontend tetap lolos, sesuai — memang tak pernah rusak.
  • Suite formatter: 176 lolos, nol regresi (test_formatters, test_formatters_base, test_formatters_phase2, test_graphml_formatter).

Konteks penemuan

Ditemukan saat navigasi untuk #297 (edge-diff), difile terpisah sesuai aturan Issue Radar dan tidak dicampur ke PR #298 agar scope-nya bersih.

Command count tetap 12. Bug fix → skip-design-doc.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

#299)

_md_diff() read `fn` from backend node entries, but _diff_backend() renames
the field to `name` on the way out, so every function name fell through to
the empty-string default. The diff reported correct counts with blank
identities: "- + `` (a.py)".

Fixed on the consumer side — commands/diff.py, dashboard and MCP already
consume `name`, so changing the producer would break them.

Tests pin the contract against real _diff_backend() output, not a
hand-written stand-in, and fail if the fix is reverted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Wolfvin
Wolfvin merged commit 34ea95b into main Jul 17, 2026
1 of 7 checks passed
@Wolfvin
Wolfvin deleted the fix/issue-299-md-diff-names branch July 17, 2026 06:22
@sonarqubecloud

Copy link
Copy Markdown

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.

fix(formatters): markdown registry-diff renders every function name empty (reads 'fn', producer emits 'name')

1 participant