Skip to content

Commit 548bb3a

Browse files
author
Your Name
committed
merge: resolve conflicts with upstream/main (dependabot CI updates)
Upstream changes: dependabot CI action version bumps (checkout, cache, upload-artifact, attest-build-provenance, codeql-action). Conflict resolutions: - mcp.c (3 regions): Kept our fuzzy fallback + added upstream's new 'mode' and 'param_name' free() calls. Kept our matched_file/candidates/ zero-edge check + integrated upstream's mode-based edge_types parsing. Kept our strcpy comment. - pass_parallel.c (1 region): Removed dead prescan functions (extract_lines, prescan_http_sites, prescan_routes, prescan_config_refs, prescan_add_route, is_route_source_lang) — these were added by our branch but upstream removed the calling code and type definitions. They're now unused dead code.
2 parents 9225087 + 148d951 commit 548bb3a

36 files changed

+6561
-1087
lines changed

CONTRIBUTING.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,32 @@ Examples: `fix(store): set busy_timeout before WAL`, `feat(cli): add --progress
118118

119119
## Pull Request Guidelines
120120

121-
- **One issue per PR.** Each PR must address exactly one bug, one feature, or one refactor. Do not bundle multiple fixes or feature additions into a single PR. If your change touches multiple areas, split it into separate PRs.
122-
- **Open an issue first.** Every PR should reference a tracking issue (`Fixes #N` or `Closes #N`). This ensures the change is discussed before code is written.
121+
### Before You Write Code
122+
123+
- **Open an issue first — always.** Every PR must reference a tracking issue (`Fixes #N` or `Closes #N`). Describe what you want to change and why. Wait for maintainer feedback before implementing. PRs without a prior issue discussion will be closed.
124+
- **Bug fixes and test additions** are the exception — these are welcome without prior discussion, as long as they're focused.
125+
126+
### What Requires Explicit Maintainer Approval
127+
128+
The following changes will not be merged without prior design discussion in an issue:
129+
130+
- **API surface changes** — adding, removing, renaming, or changing defaults of MCP tools
131+
- **New pipeline passes or indexing algorithms** — anything that changes what gets extracted or how
132+
- **Build system / Makefile changes** — beyond trivial fixes
133+
- **Project configuration** — CLAUDE.md, skill files, .mcp.json, CI workflows
134+
- **New dependencies** — vendored or otherwise
135+
- **Breaking changes** of any kind
136+
137+
If in doubt, open an issue and ask.
138+
139+
### PR Scope and Size
140+
141+
- **One issue per PR.** Each PR must address exactly one bug, one feature, or one refactor. Do not bundle multiple fixes or feature additions into a single PR. Kitchen-sink PRs will be closed with a request to split.
142+
- **Keep PRs small.** A good PR is under 500 lines. If your change is larger, split it into reviewable increments that each stand on their own.
143+
- **Don't mix features with fixes.** If you find a bug while implementing a feature, submit the bug fix as a separate PR.
144+
145+
### Code Requirements
146+
123147
- **C code only** — this project was rewritten from Go to pure C in v0.5.0. Go PRs will be acknowledged and potentially ported, but cannot be merged directly.
124148
- Include tests for new functionality
125149
- Run `scripts/test.sh` and `scripts/lint.sh` before submitting

Makefile.cbm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ EXTRACTION_SRCS = \
118118
$(CBM_DIR)/extract_env_accesses.c \
119119
$(CBM_DIR)/extract_k8s.c \
120120
$(CBM_DIR)/helpers.c \
121-
$(CBM_DIR)/lang_specs.c
121+
$(CBM_DIR)/lang_specs.c \
122+
$(CBM_DIR)/service_patterns.c
122123

123124
# LSP resolvers (compiled as one unit via lsp_all.c)
124125
LSP_SRCS = $(CBM_DIR)/lsp_all.c
@@ -175,6 +176,7 @@ PIPELINE_SRCS = \
175176
src/pipeline/pass_gitdiff.c \
176177
src/pipeline/pass_configures.c \
177178
src/pipeline/pass_configlink.c \
179+
src/pipeline/pass_route_nodes.c \
178180
src/pipeline/pass_enrichment.c \
179181
src/pipeline/pass_envscan.c \
180182
src/pipeline/pass_compile_commands.c \
@@ -282,7 +284,7 @@ TEST_GO_LSP_SRCS = tests/test_go_lsp.c
282284

283285
TEST_C_LSP_SRCS = tests/test_c_lsp.c
284286

285-
TEST_INTEGRATION_SRCS = tests/test_integration.c
287+
TEST_INTEGRATION_SRCS = tests/test_integration.c tests/test_incremental.c
286288

287289
TEST_TRACES_SRCS = tests/test_traces.c
288290

internal/cbm/cbm.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ void cbm_typeassign_push(CBMTypeAssignArray *arr, CBMArena *a, CBMTypeAssign ta)
124124
arr->items[arr->count++] = ta;
125125
}
126126

127+
void cbm_stringref_push(CBMStringRefArray *arr, CBMArena *a, CBMStringRef sr) {
128+
GROW_ARRAY(arr, a);
129+
arr->items[arr->count++] = sr;
130+
}
131+
132+
void cbm_infrabinding_push(CBMInfraBindingArray *arr, CBMArena *a, CBMInfraBinding ib) {
133+
GROW_ARRAY(arr, a);
134+
arr->items[arr->count++] = ib;
135+
}
136+
127137
void cbm_impltrait_push(CBMImplTraitArray *arr, CBMArena *a, CBMImplTrait it) {
128138
GROW_ARRAY(arr, a);
129139
arr->items[arr->count++] = it;

internal/cbm/cbm.h

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,23 @@ typedef struct {
107107
bool is_entry_point;
108108
} CBMDefinition;
109109

110+
/* Argument captured from a call expression */
110111
typedef struct {
111-
const char *callee_name; // raw callee text ("pkg.Func", "foo")
112-
const char *enclosing_func_qn; // QN of enclosing function (or module QN)
112+
const char *expr; // raw expression text ("payload.info", "MY_URL", "'hello'")
113+
const char *value; // resolved string value or NULL (constant propagation)
114+
const char *keyword; // keyword name if keyword arg ("url", "topic_id"), NULL if positional
115+
int index; // positional index (0-based)
116+
} CBMCallArg;
117+
118+
#define CBM_MAX_CALL_ARGS 8
119+
120+
typedef struct {
121+
const char *callee_name; // raw callee text ("pkg.Func", "foo")
122+
const char *enclosing_func_qn; // QN of enclosing function (or module QN)
123+
const char *first_string_arg; // first string literal argument (URL, topic, key) or NULL
124+
const char *second_arg_name; // second argument identifier (handler ref) or NULL
125+
CBMCallArg args[CBM_MAX_CALL_ARGS]; // first N arguments with expressions
126+
int arg_count; // number of captured arguments
113127
} CBMCall;
114128

115129
typedef struct {
@@ -149,6 +163,29 @@ typedef struct {
149163
const char *enclosing_func_qn; // QN of enclosing function
150164
} CBMTypeAssign;
151165

166+
// String reference: URL, config key, or async target found in source.
167+
// Extracted from string literals during AST walk.
168+
typedef enum {
169+
CBM_STRREF_URL = 0, // REST path or full URL
170+
CBM_STRREF_CONFIG = 1, // config file path or env var key
171+
} CBMStringRefKind;
172+
173+
typedef struct {
174+
const char *value; // the string literal content
175+
const char *enclosing_func_qn; // QN of enclosing function
176+
const char *key_path; // dotted key path from YAML/JSON nesting (NULL if flat)
177+
CBMStringRefKind kind; // URL, CONFIG
178+
} CBMStringRef;
179+
180+
/* Infrastructure binding: topic/queue → endpoint URL.
181+
* Extracted from YAML/HCL/JSON subscription/scheduler configs.
182+
* Used by pass_route_nodes to connect async Route nodes to handler services. */
183+
typedef struct {
184+
const char *source_name; // topic, queue, or schedule name
185+
const char *target_url; // push_endpoint, uri, or http_target URL
186+
const char *broker; // "pubsub", "cloud_tasks", "cloud_scheduler", "sqs", "kafka"
187+
} CBMInfraBinding;
188+
152189
// Rust: impl Trait for Struct
153190
typedef struct {
154191
const char *trait_name; // trait name (raw text)
@@ -225,6 +262,18 @@ typedef struct {
225262
int cap;
226263
} CBMTypeAssignArray;
227264

265+
typedef struct {
266+
CBMStringRef *items;
267+
int count;
268+
int cap;
269+
} CBMStringRefArray;
270+
271+
typedef struct {
272+
CBMInfraBinding *items;
273+
int count;
274+
int cap;
275+
} CBMInfraBindingArray;
276+
228277
typedef struct {
229278
CBMImplTrait *items;
230279
int count;
@@ -246,6 +295,8 @@ typedef struct {
246295
CBMTypeAssignArray type_assigns;
247296
CBMImplTraitArray impl_traits; // Rust: impl Trait for Struct pairs
248297
CBMResolvedCallArray resolved_calls; // LSP-resolved calls (high confidence)
298+
CBMStringRefArray string_refs; // URL/config string literals from AST
299+
CBMInfraBindingArray infra_bindings; // topic→URL pairs from IaC configs
249300

250301
const char *module_qn; // module qualified name
251302
const char **exports; // NULL-terminated (NULL if none)
@@ -279,6 +330,14 @@ typedef struct {
279330

280331
// --- Extraction context passed to sub-extractors ---
281332

333+
// Module-level string constant map (for constant propagation)
334+
#define CBM_MAX_STRING_CONSTANTS 256
335+
typedef struct {
336+
const char *names[CBM_MAX_STRING_CONSTANTS];
337+
const char *values[CBM_MAX_STRING_CONSTANTS];
338+
int count;
339+
} CBMStringConstantMap;
340+
282341
typedef struct {
283342
CBMArena *arena;
284343
CBMFileResult *result;
@@ -289,8 +348,9 @@ typedef struct {
289348
const char *rel_path;
290349
const char *module_qn;
291350
TSNode root;
292-
EFCache ef_cache; // enclosing function cache
293-
const char *enclosing_class_qn; // for nested class QN computation
351+
EFCache ef_cache; // enclosing function cache
352+
const char *enclosing_class_qn; // for nested class QN computation
353+
CBMStringConstantMap string_constants; // module-level NAME = "value" pairs
294354
} CBMExtractCtx;
295355

296356
// --- Public API ---
@@ -346,6 +406,8 @@ void cbm_rw_push(CBMRWArray *arr, CBMArena *a, CBMReadWrite rw);
346406
void cbm_typerefs_push(CBMTypeRefArray *arr, CBMArena *a, CBMTypeRef tr);
347407
void cbm_envaccess_push(CBMEnvAccessArray *arr, CBMArena *a, CBMEnvAccess ea);
348408
void cbm_typeassign_push(CBMTypeAssignArray *arr, CBMArena *a, CBMTypeAssign ta);
409+
void cbm_stringref_push(CBMStringRefArray *arr, CBMArena *a, CBMStringRef sr);
410+
void cbm_infrabinding_push(CBMInfraBindingArray *arr, CBMArena *a, CBMInfraBinding ib);
349411
void cbm_impltrait_push(CBMImplTraitArray *arr, CBMArena *a, CBMImplTrait it);
350412
void cbm_resolvedcall_push(CBMResolvedCallArray *arr, CBMArena *a, CBMResolvedCall rc);
351413

0 commit comments

Comments
 (0)