From f65afda0df9cfef9fd6f990f80b10344843542df Mon Sep 17 00:00:00 2001 From: Matthew Prock <122550757+map588@users.noreply.github.com> Date: Fri, 8 May 2026 15:36:04 -0400 Subject: [PATCH] feat(pipeline): emit USAGE edges for decorator applications (#208) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Decorators previously only created DECORATES edges. References like @login_required were invisible to find-references queries that walk CALLS/USAGE relationships. Both sequential (resolve_decorator) and parallel (resolve_def_decorators) paths now emit a USAGE edge alongside DECORATES. Empty {} properties avoid clobbering richer metadata from pass_calls when a function both has @decorator and calls decorator() directly. Using USAGE instead of CALLS keeps pass_tests' CALLS-scan from inferring false TESTS edges (decorated test function → decorator). --- src/pipeline/pass_parallel.c | 3 +++ src/pipeline/pass_semantic.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/pipeline/pass_parallel.c b/src/pipeline/pass_parallel.c index 9eb24a75c..684f93e27 100644 --- a/src/pipeline/pass_parallel.c +++ b/src/pipeline/pass_parallel.c @@ -1615,6 +1615,9 @@ static void resolve_def_decorators(resolve_ctx_t *rc, resolve_worker_state_t *ws char dp[CBM_SZ_256]; snprintf(dp, sizeof(dp), "{\"decorator\":\"%s\"}", def->decorators[dc]); cbm_gbuf_insert_edge(ws->local_edge_buf, node->id, dn->id, "DECORATES", dp); + /* Ensure a reference-style edge exists so the decorator appears in queries + * without being misclassified as a real call by downstream passes. */ + cbm_gbuf_insert_edge(ws->local_edge_buf, node->id, dn->id, "USAGE", "{}"); ws->semantic_resolved++; } } diff --git a/src/pipeline/pass_semantic.c b/src/pipeline/pass_semantic.c index ef3278010..423375c7c 100644 --- a/src/pipeline/pass_semantic.c +++ b/src/pipeline/pass_semantic.c @@ -321,6 +321,9 @@ static void resolve_decorator(cbm_pipeline_ctx_t *ctx, const cbm_gbuf_node_t *no char props[CBM_SZ_256]; snprintf(props, sizeof(props), "{\"decorator\":\"%s\"}", decorator); cbm_gbuf_insert_edge(ctx->gbuf, node->id, dec->id, "DECORATES", props); + /* Ensure a reference edge exists so the decorator appears in usage queries + * without being misclassified as a real call by downstream passes. */ + cbm_gbuf_insert_edge(ctx->gbuf, node->id, dec->id, "USAGE", "{}"); (*count)++; } }