Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
c0413f8
refactor(semantic): port src/semantic from C to Zig
professional-tester Nov 10, 2026
db959b0
build(zig): let the Zig modules read the pipeline headers
professional-tester Nov 11, 2026
b7e3945
refactor(pipeline): port worker_pool from C to Zig
professional-tester Nov 11, 2026
2f797d2
refactor(pipeline): port fqn, path_alias and registry from C to Zig
professional-tester Nov 11, 2026
53e91af
refactor(pipeline): port result_spill from C to Zig
professional-tester Nov 11, 2026
b6481b9
refactor(pipeline): port laravel_routing and service_bindings from C …
professional-tester Nov 11, 2026
2bf3f70
refactor(pipeline): port the semantic, tests, configures and enrichme…
professional-tester Nov 11, 2026
b472716
refactor(pipeline): port the complexity, importance, similarity and s…
professional-tester Nov 11, 2026
a61ed11
refactor(pipeline): port the gitdiff and githistory passes from C to Zig
professional-tester Nov 11, 2026
92fe231
refactor(pipeline): port the compile_commands, envscan and configlink…
professional-tester Nov 11, 2026
013ed83
refactor(pipeline): port the infrascan and k8s passes from C to Zig
professional-tester Nov 11, 2026
4c4d362
refactor(pipeline): port pass_route_nodes from C to Zig
professional-tester Nov 11, 2026
18d3806
refactor(pipeline): port pass_pkgmap from C to Zig
professional-tester Nov 11, 2026
7cc9dd3
refactor(pipeline): port pass_lsp_cross from C to Zig
professional-tester Nov 11, 2026
ad9f29b
refactor(pipeline): port pass_parallel from C to Zig
professional-tester Nov 11, 2026
d253cfd
refactor(pipeline): port pipeline_incremental from C to Zig
professional-tester Nov 11, 2026
89fe759
refactor(pipeline): port pipeline from C to Zig
professional-tester Nov 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions Makefile.cbm
Original file line number Diff line number Diff line change
Expand Up @@ -161,41 +161,15 @@ MCP_SRCS =

# Graph buffer module is Zig: see CBM_ZIG_SRC.

# Pipeline module (new)
PIPELINE_SRCS = \
src/pipeline/fqn.c \
src/pipeline/path_alias.c \
src/pipeline/laravel_routing.c \
src/pipeline/registry.c \
src/pipeline/pipeline.c \
src/pipeline/pipeline_incremental.c \
src/pipeline/worker_pool.c \
src/pipeline/pass_parallel.c \
src/pipeline/result_spill.c \
src/pipeline/service_bindings.c \
src/pipeline/pass_lsp_cross.c \
src/pipeline/pass_semantic.c \
src/pipeline/pass_tests.c \
src/pipeline/pass_githistory.c \
src/pipeline/pass_gitdiff.c \
src/pipeline/pass_configures.c \
src/pipeline/pass_configlink.c \
src/pipeline/pass_route_nodes.c \
src/pipeline/pass_enrichment.c \
src/pipeline/pass_envscan.c \
src/pipeline/pass_compile_commands.c \
src/pipeline/pass_infrascan.c \
src/pipeline/pass_k8s.c \
src/pipeline/pass_similarity.c \
src/pipeline/pass_semantic_edges.c \
src/pipeline/pass_complexity.c \
src/pipeline/pass_importance.c \
src/pipeline/pass_pkgmap.c
# Pipeline module: implemented in Zig (src/pipeline/*.zig, part of libcbm_zig).
# lsp_resolve_shim.c compiles one inline function of lsp_resolve.h that
# translate-c cannot hand to the Zig side.
PIPELINE_SRCS = src/pipeline/lsp_resolve_shim.c

# SimHash / MinHash, watcher and git context modules are Zig: see CBM_ZIG_SRC.

# Semantic embedding module
SEMANTIC_SRCS = src/semantic/semantic.c src/semantic/ast_profile.c src/semantic/rotsq.c
# Semantic embedding module: implemented in Zig (src/semantic/*.zig, part of libcbm_zig)
SEMANTIC_SRCS =

# nomic-embed-code pretrained vectors (assembler blob)
UNIXCODER_BLOB_SRC = vendored/nomic/code_vectors_blob.S
Expand Down Expand Up @@ -479,6 +453,28 @@ CBM_ZIG_SRCS = $(CBM_ZIG_SRC) src/cbm_zig_c.h src/cli_zig/cbm_cli_zig.zig src/cl
src/discover/discover.h src/discover/userconfig.h \
src/git/git_context.zig src/git/git_context.h \
src/graph_buffer/graph_buffer.zig src/graph_buffer/graph_buffer.h \
src/semantic/ast_profile.zig src/semantic/fp.zig src/semantic/rotsq.zig \
src/semantic/semantic.zig \
src/semantic/ast_profile.h src/semantic/rotsq.h src/semantic/semantic.h \
vendored/nomic/code_vectors.h vendored/nomic/code_tokens.h \
src/pipeline/fqn.zig src/pipeline/laravel_routing.zig \
src/pipeline/pass_compile_commands.zig src/pipeline/pass_complexity.zig \
src/pipeline/pass_configlink.zig src/pipeline/pass_configures.zig \
src/pipeline/pass_enrichment.zig src/pipeline/pass_envscan.zig \
src/pipeline/pass_gitdiff.zig src/pipeline/pass_githistory.zig \
src/pipeline/pass_importance.zig src/pipeline/pass_infrascan.zig \
src/pipeline/pass_k8s.zig src/pipeline/pass_lsp_cross.zig \
src/pipeline/pass_parallel.zig src/pipeline/pass_pkgmap.zig \
src/pipeline/pass_route_nodes.zig src/pipeline/pass_semantic.zig \
src/pipeline/pass_semantic_edges.zig src/pipeline/pass_similarity.zig \
src/pipeline/pass_tests.zig src/pipeline/path_alias.zig src/pipeline/pipeline.zig \
src/pipeline/pipeline_incremental.zig src/pipeline/registry.zig \
src/pipeline/result_spill.zig src/pipeline/service_bindings.zig \
src/pipeline/util.zig src/pipeline/worker_pool.zig src/pipeline/laravel_routing.h \
src/pipeline/lsp_resolve.h src/pipeline/pass_lsp_cross.h \
src/pipeline/path_alias.h src/pipeline/pipeline_internal.h \
src/pipeline/result_spill.h src/pipeline/worker_pool.h \
src/graph_buffer/graph_buffer.h \
src/simhash/minhash.zig src/simhash/minhash.h \
src/store/store.zig src/store/store.h \
src/watcher/watcher.zig src/watcher/watcher.h \
Expand Down
32 changes: 1 addition & 31 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -536,37 +536,7 @@ fn grammarSources(b: *std.Build) []const []const u8 {
const native_sources = [_][]const u8{
"src/foundation/hash_table.c",
"src/foundation/c_shim.c",
"src/pipeline/fqn.c",
"src/pipeline/path_alias.c",
"src/pipeline/laravel_routing.c",
"src/pipeline/registry.c",
"src/pipeline/pipeline.c",
"src/pipeline/pipeline_incremental.c",
"src/pipeline/worker_pool.c",
"src/pipeline/pass_parallel.c",
"src/pipeline/result_spill.c",
"src/pipeline/service_bindings.c",
"src/pipeline/pass_lsp_cross.c",
"src/pipeline/pass_semantic.c",
"src/pipeline/pass_tests.c",
"src/pipeline/pass_githistory.c",
"src/pipeline/pass_gitdiff.c",
"src/pipeline/pass_configures.c",
"src/pipeline/pass_configlink.c",
"src/pipeline/pass_route_nodes.c",
"src/pipeline/pass_enrichment.c",
"src/pipeline/pass_envscan.c",
"src/pipeline/pass_compile_commands.c",
"src/pipeline/pass_infrascan.c",
"src/pipeline/pass_k8s.c",
"src/pipeline/pass_similarity.c",
"src/pipeline/pass_semantic_edges.c",
"src/pipeline/pass_complexity.c",
"src/pipeline/pass_importance.c",
"src/pipeline/pass_pkgmap.c",
"src/semantic/semantic.c",
"src/semantic/ast_profile.c",
"src/semantic/rotsq.c",
"src/pipeline/lsp_resolve_shim.c",
"vendored/yyjson/yyjson.c",
"internal/cbm/cbm.c",
"internal/cbm/extract_defs.c",
Expand Down
2 changes: 1 addition & 1 deletion scripts/extract_nomic_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def main():
print()
print("next steps:")
print(f" 1. update Makefile.cbm: change UNIXCODER_BLOB_SRC path to vendored/nomic/")
print(f" 2. update #include in semantic.c: \"vendored/nomic/code_vectors.h\"")
print(f" 2. update #include in src/cbm_zig_c.h: \"nomic/code_vectors.h\"")
print(f" 3. arch -arm64 make -j12 -f Makefile.cbm clean-c && arch -arm64 make -j12 -f Makefile.cbm")


Expand Down
2 changes: 1 addition & 1 deletion scripts/security-allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ src/mcp/server.zig:cbm_popen:update check to api.github.com (hardcoded URL)
src/mcp/server.zig:popen:via cbm_popen wrapper calls

# ── Pipeline: git history parsing (git log) ────────────────────────────────
src/pipeline/pass_githistory.c:cbm_popen_git:git log for file history (path validated)
src/pipeline/pass_githistory.zig:cbm_popen_git:git log for file history (path validated)

# ── Allowed URLs ───────────────────────────────────────────────────────────
# Format: URL:justification
Expand Down
2 changes: 1 addition & 1 deletion scripts/security-audit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ while IFS= read -r match; do
file=$(echo "$match" | cut -d: -f1)
relfile="${file#"$ROOT/"}"
case "$relfile" in
src/cli/cli.zig|src/pipeline/*.c|src/foundation/diagnostics.zig|src/mcp/search_tools.zig|src/mcp/index_tools.zig)
src/cli/cli.zig|src/pipeline/*.zig|src/foundation/diagnostics.zig|src/mcp/search_tools.zig|src/mcp/index_tools.zig)
;; # Known safe (diagnostics.zig: atomic .tmp+rename metrics dump to configured path;
# search_tools.zig: search pattern/file-list temp files; index_tools.zig:
# index supervisor response/quarantine files)
Expand Down
31 changes: 31 additions & 0 deletions src/cbm_zig.zig
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,37 @@ comptime {
checkExports(@import("mcp/project_tools.zig"));
checkExports(@import("mcp/search_tools.zig"));
checkExports(@import("mcp/server.zig"));
checkExports(@import("pipeline/fqn.zig"));
checkExports(@import("pipeline/laravel_routing.zig"));
checkExports(@import("pipeline/pass_compile_commands.zig"));
checkExports(@import("pipeline/pass_complexity.zig"));
checkExports(@import("pipeline/pass_configlink.zig"));
checkExports(@import("pipeline/pass_configures.zig"));
checkExports(@import("pipeline/pass_enrichment.zig"));
checkExports(@import("pipeline/pass_envscan.zig"));
checkExports(@import("pipeline/pass_gitdiff.zig"));
checkExports(@import("pipeline/pass_githistory.zig"));
checkExports(@import("pipeline/pass_importance.zig"));
checkExports(@import("pipeline/pass_infrascan.zig"));
checkExports(@import("pipeline/pass_k8s.zig"));
checkExports(@import("pipeline/pass_lsp_cross.zig"));
checkExports(@import("pipeline/pass_parallel.zig"));
checkExports(@import("pipeline/pass_pkgmap.zig"));
checkExports(@import("pipeline/pass_route_nodes.zig"));
checkExports(@import("pipeline/pass_semantic.zig"));
checkExports(@import("pipeline/pass_semantic_edges.zig"));
checkExports(@import("pipeline/pass_similarity.zig"));
checkExports(@import("pipeline/pass_tests.zig"));
checkExports(@import("pipeline/path_alias.zig"));
checkExports(@import("pipeline/pipeline.zig"));
checkExports(@import("pipeline/pipeline_incremental.zig"));
checkExports(@import("pipeline/registry.zig"));
checkExports(@import("pipeline/result_spill.zig"));
checkExports(@import("pipeline/service_bindings.zig"));
checkExports(@import("pipeline/worker_pool.zig"));
checkExports(@import("semantic/ast_profile.zig"));
checkExports(@import("semantic/rotsq.zig"));
checkExports(@import("semantic/semantic.zig"));
checkExports(@import("simhash/minhash.zig"));
checkExports(@import("store/store.zig"));
checkExports(@import("watcher/watcher.zig"));
Expand Down
59 changes: 56 additions & 3 deletions src/cbm_zig_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,35 @@
#ifdef __linux__
#include <sys/sysinfo.h>
#endif

/* C11 atomics, as translate-c can read them. translate-c has no atomic
* types, so a declaration that names one (the pipeline context's cancel flag,
* the shared id counter) would be dropped together with everything that uses
* it. Here an atomic type is its plain type and the atomic operations are the
* compiler builtins, which keeps those declarations and their layout. The Zig
* side reads and writes such fields with @atomicLoad / @atomicStore /
* @atomicRmw. Only this translation unit sees the view: the C sources keep
* the real <stdatomic.h>. */
#define __CLANG_STDATOMIC_H /* keeps clang's <stdatomic.h> out */
#define _Atomic
typedef _Bool atomic_bool;
typedef int atomic_int;
typedef unsigned int atomic_uint;
typedef long atomic_long;
typedef unsigned long atomic_ulong;
typedef long long atomic_llong;
typedef unsigned long long atomic_ullong;
#define memory_order_relaxed __ATOMIC_RELAXED
#define memory_order_consume __ATOMIC_CONSUME
#define memory_order_acquire __ATOMIC_ACQUIRE
#define memory_order_release __ATOMIC_RELEASE
#define memory_order_acq_rel __ATOMIC_ACQ_REL
#define memory_order_seq_cst __ATOMIC_SEQ_CST
#define atomic_load(p) __atomic_load_n((p), __ATOMIC_SEQ_CST)
#define atomic_load_explicit(p, o) __atomic_load_n((p), (o))
#define atomic_fetch_add(p, v) __atomic_fetch_add((p), (v), __ATOMIC_SEQ_CST)
#define atomic_fetch_add_explicit(p, v, o) __atomic_fetch_add((p), (v), (o))

#include <mimalloc.h>

#include "foundation/arena.h"
Expand Down Expand Up @@ -91,12 +120,26 @@
#include "foundation/system_info_internal.h"
#include "foundation/compat_fs_internal.h"
#include "foundation/yaml.h"
#include "arena.h"
#include "cbm.h"
#include "helpers.h"
#include "lang_specs.h"
#include "lsp/c_lsp.h"
#include "lsp/go_lsp.h"
#include "lsp/java_lsp.h"
#include "lsp/kotlin_lsp.h"
#include "lsp/php_lsp.h"
#include "lsp/py_lsp.h"
#include "lsp/rust_cargo.h"
#include "lsp/rust_lsp.h"
#include "lsp/ts_lsp.h"
#include "lsp/zig_lsp.h"
#include "mcp/mcp.h"
#include "pipeline/pipeline.h"
#include "pipeline/worker_pool.h"
#include "semantic/semantic.h"
#include "nomic/code_vectors.h"
#include "service_patterns.h"
#include "store/store.h"
#include "tree_sitter/api.h"
#include "xxhash/xxhash.h"
#include "zova/cbm_zova.h"
#include "zova/cbm_zova_bridge.h"
#include "zova/cbm_zova_coordination.h"
Expand Down Expand Up @@ -139,6 +182,16 @@ static inline FILE *cbm_zig_stderr(void) {
#include "git/git_context.h"
#include "graph_buffer/graph_buffer.h"
#include "mcp/index_supervisor.h"
#include "pipeline/laravel_routing.h"
#include "pipeline/lsp_resolve.h"
#include "pipeline/pass_lsp_cross.h"
#include "pipeline/path_alias.h"
#include "pipeline/pipeline.h"
#include "pipeline/pipeline_internal.h"
#include "pipeline/result_spill.h"
#include "pipeline/worker_pool.h"
#include "semantic/ast_profile.h"
#include "semantic/semantic.h"
#include "simhash/minhash.h"
#include "watcher/watcher.h"

Expand Down
Loading