Files
codebase-memory-mcp/internal/cbm/service_patterns.h
T
Martin Vogel b00e1f74c2 AST-based route registration + remove prescan infrastructure
Route registration detection during AST extraction: callee QN matched
against router frameworks (gin, chi, Express, Laravel, Ktor, etc.),
handler reference captured as second_arg_name, Route + HANDLES edges
created during resolution. Replaces disk-reading route discovery for
non-decorator frameworks.

Remove prescan infrastructure entirely (-350 net lines):
- cbm_prescan_t, cbm_prescan_http_site_t, cbm_prescan_route_t,
  cbm_prescan_config_ref_t structs removed from pipeline_internal.h
- prescan_http_sites, prescan_routes, prescan_config_refs,
  prescan_add_route removed from pass_parallel.c
- prescan fast-paths removed from pass_httplinks.c and pass_configlink.c
- prescan allocation/cleanup removed from pipeline.c

All post-passes now work without prescan:
- HTTP/async edges: service_patterns during resolution
- Route registration: CBM_SVC_ROUTE_REG during resolution
- Decorator routes: gbuf properties (no disk reads)
- Config file refs: disk fallback (few files)
2026-03-28 13:59:42 +01:00

46 lines
2.0 KiB
C

/*
* service_patterns.h — Allowlists for HTTP clients, async dispatch, and config accessors.
*
* Used during call resolution to classify CALLS edges as:
* HTTP_CALLS — synchronous HTTP client calls
* ASYNC_CALLS — async message/task dispatch
* CONFIGURES — config/env access
*
* Lookup is O(1) via hash table initialized once at startup.
*/
#ifndef CBM_SERVICE_PATTERNS_H
#define CBM_SERVICE_PATTERNS_H
/* Edge type returned by pattern match. */
typedef enum {
CBM_SVC_NONE = 0, /* Not a service pattern — use normal CALLS */
CBM_SVC_HTTP = 1, /* Synchronous HTTP client call */
CBM_SVC_ASYNC = 2, /* Async dispatch (message broker, task queue) */
CBM_SVC_CONFIG = 3, /* Config/env accessor */
CBM_SVC_ROUTE_REG = 4, /* Route registration (router.GET, app.get, Route::post) */
} cbm_svc_kind_t;
/* Initialize the pattern lookup tables. Call once at startup. Thread-safe after init. */
void cbm_service_patterns_init(void);
/* Check if a resolved QN contains a known service library identifier.
* Returns the pattern kind, or CBM_SVC_NONE if no match.
* Matches on library name substrings in the QN (e.g., "requests" in
* "project.venv.requests.api.get"). Import-alias transparent. */
cbm_svc_kind_t cbm_service_pattern_match(const char *resolved_qn);
/* Get the HTTP method from the callee name suffix (e.g., ".get" → "GET").
* Returns NULL if method cannot be inferred. */
const char *cbm_service_pattern_http_method(const char *callee_name);
/* Get the HTTP method from a route registration callee name suffix
* (e.g., "router.GET" → "GET", "app.post" → "POST").
* Returns NULL if not a known route registration method. */
const char *cbm_service_pattern_route_method(const char *callee_name);
/* Get the broker name for an async QN (e.g., "pubsub" from a Pub/Sub QN).
* Returns NULL if not an async pattern. */
const char *cbm_service_pattern_broker(const char *resolved_qn);
#endif /* CBM_SERVICE_PATTERNS_H */