Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

test(doc_links_pdf): receiver-qualified Go method nodes (#1913)

Martin Vogelaa4775f56690
diff --git a/src/pipeline/doc_links_pdf.c b/src/pipeline/doc_links_pdf.c
index a667fb6c7..1eaf057ae 100644
--- a/src/pipeline/doc_links_pdf.c
+++ b/src/pipeline/doc_links_pdf.c
@@ -328,9 +328,10 @@ static void qn_candidate(const pdfr_index_t *x, const cbm_gbuf_node_t *n, const
const char *rel = rel_qn(x, n->qualified_name);
char alt[PDFR_KEY_CAP];
bool owned = owner_name(x, n, alt, sizeof(alt));
- /* A member whose QN leaves its owner out (a Go method's has no receiver)
- * is named through the owner: `time.Now` is package time's function,
- * never the method Now of a type that package time declares. */
+ /* A member whose QN leaves its owner out (a templ method's keeps the flat
+ * package QN; a Go method's did before index format 4) is named through
+ * the owner: `time.Now` is package time's function, never the method Now
+ * of a type that package time declares. */
bool ownerless_qn = owned && !comp_suffix(rel, alt);
bool via_rel = !ownerless_qn && comp_suffix(rel, s);
bool via_alt = !via_rel && owned && strcmp(alt, rel) != 0 && comp_suffix(alt, s);
diff --git a/tests/test_doc_links_pdf.c b/tests/test_doc_links_pdf.c
index 1a78b7254..9c7bf90ff 100644
--- a/tests/test_doc_links_pdf.c
+++ b/tests/test_doc_links_pdf.c
@@ -1087,8 +1087,9 @@ TEST(pdf_links_pipeline) {
ASSERT_NOT_NULL(strstr(props, "\"line\":1"));
/* qualified names (pdf_qn) passed a second held-out audit (97 of 99
* correct, Wilson 95 % low 0.929) once a member whose QN leaves its owner
- * out binds only through the owner. A Go method through its receiver: */
- dm_edge(db, "docs.design.page_1", "pkg.server.Serve", props, sizeof(props), &n);
+ * out binds only through the owner. A Go method through its receiver
+ * (receiver-qualified QN since index format 4): */
+ dm_edge(db, "docs.design.page_1", "pkg.server.Handler.Serve", props, sizeof(props), &n);
ASSERT_EQ(n, 1);
ASSERT_NOT_NULL(strstr(props, "\"syntax\":\"pdf_qn\""));
ASSERT_NOT_NULL(strstr(props, "\"tier\":\"unique\""));
@@ -1142,10 +1143,12 @@ TEST(pdf_links_pipeline) {
PASS();
}
-/* A held-out finding of the PDF audit: a Go method's QN has no receiver, so
+/* A held-out finding of the PDF audit: a Go method's QN had no receiver, so
* `time.Now` (the standard library's function, in a spec) matched the method
* Now of a type that the repository's own package time declares. A method is
- * named through its owner: `time.Provider.Now` still binds it. */
+ * named through its owner: `time.Provider.Now` still binds it. Since index
+ * format 4 the QN carries the receiver (pkg.time.Provider.Now), and both
+ * directions are checked against that node. */
TEST(pdf_qn_method_through_owner) {
cbm_doclink_test_set_ships(CBM_DOCLINK_PDF_QN, true);
char tmp[256];
@@ -1169,9 +1172,9 @@ TEST(pdf_qn_method_through_owner) {
ASSERT_EQ(dm_index(repo, db, NULL), 0);
char props[512];
int n;
- dm_edge(db, "docs.spec.page_1", "pkg.time.Now", props, sizeof(props), &n);
+ dm_edge(db, "docs.spec.page_1", "pkg.time.Provider.Now", props, sizeof(props), &n);
ASSERT_EQ(n, 0);
- dm_edge(db, "docs.spec.page_2", "pkg.time.Now", props, sizeof(props), &n);
+ dm_edge(db, "docs.spec.page_2", "pkg.time.Provider.Now", props, sizeof(props), &n);
ASSERT_EQ(n, 1);
ASSERT_NOT_NULL(strstr(props, "\"syntax\":\"pdf_qn\""));
th_cleanup(tmp);