diff --git a/internal/cbm/extract_url_fold.c b/internal/cbm/extract_url_fold.c index 63f8b4bb5..ee3b438f8 100644 --- a/internal/cbm/extract_url_fold.c +++ b/internal/cbm/extract_url_fold.c @@ -401,10 +401,22 @@ static bool is_interpolated_string(TSNode node) { return false; } +/* A Python string whose opening token is more than one quote -- a prefix + * (r"", b"", u"", an f"" with no field) or a triple quote -- cannot go down + * the literal path: that strips exactly one quote from each end, so the + * prefix and the extra quotes stayed in the URL and it never matched a route + * (#523). Folding reads the content pieces instead. JS/TS strings have no + * string_start, so this is Python only. */ +static bool is_wrapped_string(TSNode node) { + TSNode start = ts_node_child(node, 0); + return !ts_node_is_null(start) && strcmp(ts_node_type(start), "string_start") == 0 && + ts_node_end_byte(start) - ts_node_start_byte(start) > SKIP_ONE; +} + static bool is_foldable_arg(TSNode arg) { const char *k = ts_node_type(arg); if (strcmp(k, "string") == 0) { - return is_interpolated_string(arg); + return is_interpolated_string(arg) || is_wrapped_string(arg); } return strcmp(k, "template_string") == 0 || strcmp(k, "binary_expression") == 0 || strcmp(k, "binary_operator") == 0 || strcmp(k, "identifier") == 0 || diff --git a/src/mcp/mcp.c b/src/mcp/mcp.c index 8e9970800..3f9d83d8c 100644 --- a/src/mcp/mcp.c +++ b/src/mcp/mcp.c @@ -4024,6 +4024,7 @@ enum { BM25_BIND_EXACT = 8, BM25_BIND_KIND = 9, BM25_BIND_NS = 10, + BM25_BIND_LABEL_WEIGHT = 11, BM25_SQL_AUTO_LEN = -1, /* Inner FTS5 candidate cap. SQLite can early-terminate a plain FTS5 query * (no JOIN/WHERE on outer table) of the form: @@ -4032,6 +4033,11 @@ enum { * and then joining/filtering/re-ranking those, we bound all work to O(N) where * N = BM25_INNER_LIMIT rather than the full match set size. */ BM25_INNER_LIMIT = 2000, + /* Longest label spliced into the MATCH pre-filter; real labels are short + * identifiers, so anything longer simply skips the pre-filter. */ + BM25_LABEL_MAX = 64, + /* Room for "() AND label : \"