@@ -314,6 +314,93 @@ TEST(cross_repo_wildcard_keeps_projects_containing_internal_tokens) {
314314 PASS ();
315315}
316316
317+ /* A project store written before the #768 edges.local_name_gen column: it
318+ * still answers read-only queries (list_projects shows it), but the
319+ * read-write open every cross-repo target needs refuses it until a reindex. */
320+ static bool cross_repo_create_pre768_project (const cross_repo_fixture_t * fixture ,
321+ const char * project ) {
322+ char path [512 ];
323+ if (!cross_repo_project_path (fixture , project , path , sizeof (path ))) {
324+ return false;
325+ }
326+ sqlite3 * db = NULL ;
327+ if (sqlite3_open (path , & db ) != SQLITE_OK ) {
328+ sqlite3_close (db );
329+ return false;
330+ }
331+ char sql [1024 ];
332+ snprintf (sql , sizeof (sql ),
333+ "CREATE TABLE projects(name TEXT PRIMARY KEY, indexed_at TEXT NOT NULL,"
334+ " root_path TEXT NOT NULL);"
335+ "CREATE TABLE nodes(id INTEGER PRIMARY KEY AUTOINCREMENT, project TEXT NOT NULL,"
336+ " label TEXT NOT NULL, name TEXT NOT NULL, qualified_name TEXT NOT NULL,"
337+ " file_path TEXT DEFAULT '', start_line INTEGER DEFAULT 0,"
338+ " end_line INTEGER DEFAULT 0, properties TEXT DEFAULT '{}',"
339+ " UNIQUE(project, qualified_name));"
340+ "CREATE TABLE edges(id INTEGER PRIMARY KEY AUTOINCREMENT, project TEXT NOT NULL,"
341+ " source_id INTEGER NOT NULL, target_id INTEGER NOT NULL, type TEXT NOT NULL,"
342+ " properties TEXT DEFAULT '{}', UNIQUE(source_id, target_id, type));"
343+ "INSERT INTO projects VALUES('%s', '2026-06-01T00:00:00Z', '/pre768');" ,
344+ project );
345+ bool ok = sqlite3_exec (db , sql , NULL , NULL , NULL ) == SQLITE_OK ;
346+ sqlite3_close (db );
347+ return ok ;
348+ }
349+
350+ /* #2133: ["*"] enumerated every store a read-only open accepts, then aborted
351+ * the whole run on the first one the matcher's read-write open refused — a
352+ * single pre-#768 index anywhere in the cache made the wildcard fail with
353+ * "missing, invalid, or not indexed" while naming the same live targets
354+ * worked. A store the matcher cannot use is not a wildcard target. */
355+ TEST (cross_repo_wildcard_skips_pre768_store_issue2133 ) {
356+ cross_repo_fixture_t fixture ;
357+ bool setup = cross_repo_fixture_begin (& fixture ) &&
358+ cross_repo_seed_http_pair (& fixture , "wild-src" , "wild-api" , "/orders" , "w" ) &&
359+ cross_repo_create_pre768_project (& fixture , "aa-pre768-store" );
360+ if (!setup ) {
361+ cross_repo_fixture_end (& fixture );
362+ FAIL ("failed to seed pre-#768 wildcard fixture" );
363+ }
364+
365+ const char * targets [] = {"*" };
366+ cbm_cross_repo_result_t result = cbm_cross_repo_match ("wild-src" , targets , 1 );
367+ int edges = cross_repo_count_edges (& fixture , "wild-src" , "CROSS_HTTP_CALLS" );
368+ cross_repo_fixture_end (& fixture );
369+
370+ ASSERT_FALSE (result .failed );
371+ ASSERT_EQ (result .projects_scanned , 1 );
372+ ASSERT_EQ (result .http_edges , 1 );
373+ ASSERT_EQ (edges , 1 );
374+ PASS ();
375+ }
376+
377+ /* Naming an unusable store stays an error, but it must be refused during
378+ * validation, before the source's previous CROSS_* generation is deleted. */
379+ TEST (cross_repo_named_pre768_target_fails_before_cleanup_issue2133 ) {
380+ cross_repo_fixture_t fixture ;
381+ bool setup = cross_repo_fixture_begin (& fixture ) &&
382+ cross_repo_seed_http_pair (& fixture , "named-src" , "named-api" , "/orders" , "n" ) &&
383+ cross_repo_create_pre768_project (& fixture , "aa-pre768-store" );
384+ if (!setup ) {
385+ cross_repo_fixture_end (& fixture );
386+ FAIL ("failed to seed pre-#768 named fixture" );
387+ }
388+
389+ const char * live [] = {"named-api" };
390+ cbm_cross_repo_result_t initial = cbm_cross_repo_match ("named-src" , live , 1 );
391+ int before = cross_repo_count_edges (& fixture , "named-src" , "CROSS_HTTP_CALLS" );
392+ const char * with_pre768 [] = {"named-api" , "aa-pre768-store" };
393+ cbm_cross_repo_result_t result = cbm_cross_repo_match ("named-src" , with_pre768 , 2 );
394+ int after = cross_repo_count_edges (& fixture , "named-src" , "CROSS_HTTP_CALLS" );
395+ cross_repo_fixture_end (& fixture );
396+
397+ ASSERT_FALSE (initial .failed );
398+ ASSERT_EQ (before , 1 );
399+ ASSERT_TRUE (result .failed );
400+ ASSERT_EQ (after , before );
401+ PASS ();
402+ }
403+
317404static bool cross_repo_seed_bounded_scan (const cross_repo_fixture_t * fixture ,
318405 const char * source_project , const char * target_project ) {
319406 enum { TEST_SCAN_ROWS = 4097 };
@@ -747,6 +834,8 @@ SUITE(cross_repo) {
747834 RUN_TEST (cross_repo_accepts_project_with_missed_shadow_row_issue1609 );
748835 RUN_TEST (cross_repo_null_target_fails_without_dereference );
749836 RUN_TEST (cross_repo_wildcard_keeps_projects_containing_internal_tokens );
837+ RUN_TEST (cross_repo_wildcard_skips_pre768_store_issue2133 );
838+ RUN_TEST (cross_repo_named_pre768_target_fails_before_cleanup_issue2133 );
750839 RUN_TEST (cross_repo_scan_bound_counts_examined_rows_not_matches );
751840 RUN_TEST (cross_repo_propagates_delete_failure );
752841 RUN_TEST (cross_repo_failed_bidirectional_insert_is_not_counted );
0 commit comments