Skip to content

refactor(pipeline): port lsp_resolve from C to Zig, drop dead vmem - #170

Merged
ata-sesli merged 1 commit into
mainfrom
refactor/lsp-resolve-zig
Nov 11, 2026
Merged

ata-sesli merged 1 commit into
mainfrom
refactor/lsp-resolve-zig

Conversation

@ata-sesli

Copy link
Copy Markdown
Member

What does this PR do?

Finishes the pipeline port: lsp_resolve.h was the last pipeline module whose logic was still C. Also removes the unused vmem allocator.

Before: src/pipeline/lsp_resolve.h held the LSP-override join (the code that decides which LSP-resolved calls and callable references become CALLS / CALL_REFERENCE edges) as static inline C functions. The Zig pipeline used them through translate-c. One function, cbm_pipeline_lsp_target_node, uses C11 atomics, which translate-c cannot express. So lsp_resolve_shim.c compiled that function separately, and pass_parallel.zig defined its two counters.

After: the logic lives in src/pipeline/lsp_resolve.zig.

  • Three functions are exported because tests/test_parallel.c calls them: cbm_pipeline_find_lsp_resolution, cbm_pipeline_lsp_allow_tail_match and cbm_pipeline_lsp_target_node. lsp_resolve.h now only declares those three and keeps CBM_LSP_CONFIDENCE_FLOOR. cbm_zig.zig checks their signatures against the header.
  • The CALL_REFERENCE join, the row counts and nodeIsCallableTarget are Zig-only. pass_parallel.zig and pipeline_incremental.zig import them directly.
  • The tail-match cost counters move into the module as std.atomic.Value(u64). They still use relaxed ordering and are still logged as parallel.resolve.scan_cost.
  • lsp_resolve_shim.c is deleted.

Behavior is unchanged:

  • The same match order and confidence floor.
  • The same qsort order of reference rows, including the pointer tie-break.
  • The same retry order for <project>.<qn> and #macro.
  • The same snprintf edge-property format (%.2f).

Dead code removed: src/foundation/vmem.c, vmem.h and tests/test_vmem.c. No build list compiles them and nothing includes vmem.h. mem.h replaced it.

Verification (local)

  • libcbm_zig built (ReleaseFast) for native macOS arm64, x86_64-linux-gnu and x86_64-windows-gnu (the last two with Zova). The native library exports the three functions.
  • tests/test_parallel.c and lsp_resolve.h pass clang -fsyntax-only against the new header.
  • zig fmt --check src build.zig and scripts/check-build-sources.sh pass.
  • The test suite and lint were not run locally; CI will run them.

Checklist

  • Every commit is signed off (git commit -s) — required, CI rejects
    unsigned commits (DCO, see CONTRIBUTING.md)
  • Tests pass locally (make -f Makefile.cbm test) — not run locally, left to CI
  • Lint passes (make -f Makefile.cbm lint-ci) — not run locally, left to CI
  • New behavior is covered by a test (reproduce-first for bug fixes) — no new behavior; existing test_parallel.c LSP-resolution tests cover the exported functions

lsp_resolve.h held the LSP-override join as static inline C functions.
The Zig pipeline reached them through translate-c, except
cbm_pipeline_lsp_target_node: its C11 atomic counters cannot be
translated, so lsp_resolve_shim.c compiled that one function for the
Zig side, and the counters were defined in pass_parallel.zig.

The logic now lives in src/pipeline/lsp_resolve.zig:
- cbm_pipeline_find_lsp_resolution, cbm_pipeline_lsp_allow_tail_match
  and cbm_pipeline_lsp_target_node are exported, because
  tests/test_parallel.c calls them; lsp_resolve.h now only declares
  them and keeps CBM_LSP_CONFIDENCE_FLOOR.
- The CALL_REFERENCE join (RefIndex, joinLspReference, referenceProps,
  referenceFallbackAllowed), the row counts and nodeIsCallableTarget are
  Zig-only and imported by pass_parallel.zig and
  pipeline_incremental.zig.
- The tail-match cost counters move here as std.atomic.Value(u64).

The matching rules, confidence comparisons, sort order and edge
property format are unchanged. lsp_resolve_shim.c is removed.

src/foundation/vmem.c, vmem.h and tests/test_vmem.c are removed: no
build list compiles them and nothing includes vmem.h (mem.h replaced
it).

Signed-off-by: ata-sesli <atasesli@protonmail.com>
@ata-sesli
ata-sesli merged commit 88f8d40 into main Nov 11, 2026
10 checks passed
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.

1 participant