Skip to content

fix(parser): Python module-level calls not extracted → false dead-code + rc undercount #291

Description

@Wolfvin

Mengapa (falsifiable — repro dijalankan 2026-07-13)

Fungsi Python yang dipanggil HANYA di module top-level dapat ref_count=0 / status=dead — panggilan module-level TIDAK menghasilkan edge di call graph. Ini bug #219 (module-level call extraction) tapi untuk parser Python; fix #219 hanya menyentuh js_backend/ts_backend parser (synthetic <file>:0:<module> source id), Python tak ikut.

Repro (scan file ini, cek backend.json):

def setup_app(): return 1
def helper(): return 2
def caller(): return helper()
setup_app()   # module-level call
caller()      # module-level call

Hasil aktual:

  • setup_app: rc=0 status=dead (SALAH — dipanggil module-level)
  • helper: rc=1 active (benar — dipanggil dari caller())
  • caller: rc=0 status=dead (SALAH — dipanggil module-level)
  • edges: HANYA caller->helper. Panggilan setup_app() & caller() di module-level → nol edge.

Konteks

Python core language CodeLens (proyek ini sendiri Python). Banyak script/bootstrap pakai module-level call (main(), app.run(), dsb). Semua false-flagged dead + rc undercount. Analog persis #219 yang sudah fixed untuk TS/JS via synthetic <file>:0:<module>.

Tujuan

Python parser extract module-level call (top-level statement yang memanggil fungsi) sebagai edge dgn synthetic source id <file>:0:<module> — FORMAT SAMA dgn TS/JS (is_module_level_source_id() di graph_model kenal), supaya trace --direction up juga tampilkan module-level caller (spt #223) dan rc benar.

Constraint

Definition of Done

  • setup_app/caller (dipanggil module-level) → rc>=1, NOT dead
  • trace --direction up setup_app tampilkan module-level caller (module_level=True)
  • Golden test Python di test_graph_accuracy_golden.py (assert rc konkret + caller)
  • Constraint anti-pollution: nol fake <module> node di graph_nodes
  • Fungsi genuinely-dead Python TETAP terdeteksi (control)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions