Skip to content

Commit 7a9fe6d

Browse files
types: thread RuleTokens through exclusion-rules consumers
1 parent 1dbf635 commit 7a9fe6d

11 files changed

Lines changed: 47 additions & 38 deletions

api/flask_config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
from flask import Response, current_app, jsonify
88

9+
from utils.exclusion_rules import RuleTokens
910

10-
def exclusion_rules() -> list[list[Any]]:
11+
12+
def exclusion_rules() -> list[RuleTokens]:
1113
"""Return loaded exclusion rules from app config (empty list when unset)."""
1214
return current_app.config.get("EXCLUSION_RULES") or []
1315

services/cli_tabs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
from api.flask_config import json_response
1010

1111
from utils.cli_chat_reader import list_cli_projects, messages_to_bubbles, traverse_blobs
12-
from utils.exclusion_rules import build_searchable_text, is_excluded_by_rules
12+
from utils.exclusion_rules import RuleTokens, build_searchable_text, is_excluded_by_rules
1313
from utils.workspace_path import get_cli_chats_path
1414

1515
_logger = logging.getLogger(__name__)
1616

1717

1818
def get_cli_workspace_tabs(
19-
workspace_id: str, rules: list[Any],
19+
workspace_id: str, rules: list[RuleTokens],
2020
) -> Response | tuple[Response, int]:
2121
"""Return Flask JSON response with tabs for a Cursor CLI project.
2222

services/export_engine.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
cursor_cli_session_to_markdown,
4141
cursor_ide_chat_to_markdown,
4242
)
43-
from utils.exclusion_rules import build_searchable_text, is_excluded_by_rules
43+
from utils.exclusion_rules import RuleTokens, build_searchable_text, is_excluded_by_rules
4444
from utils.path_helpers import to_epoch_ms
4545
from utils.text_extract import extract_text_from_bubble, slug
4646
from utils.workspace_path import get_cli_chats_path
@@ -130,7 +130,7 @@ def build_workspace_display_maps(
130130

131131
def prepare_workspace_orchestration(
132132
workspace_path: str,
133-
rules: list[Any],
133+
rules: list[RuleTokens],
134134
*,
135135
nocache: bool = False,
136136
workspace_entries: list[dict[str, Any]] | None = None,
@@ -169,7 +169,7 @@ def prepare_workspace_orchestration(
169169

170170
def load_global_db_export_data(
171171
orch: WorkspaceOrchestration,
172-
rules: list[Any],
172+
rules: list[RuleTokens],
173173
*,
174174
nocache: bool = False,
175175
) -> GlobalDbExportData | None:
@@ -222,7 +222,7 @@ def _collect_ide_export_entries(
222222
*,
223223
orch: WorkspaceOrchestration,
224224
db_data: GlobalDbExportData,
225-
exclusion_rules: list[Any],
225+
exclusion_rules: list[RuleTokens],
226226
since: SinceMode,
227227
last_export_ms: int,
228228
today: str,
@@ -363,7 +363,7 @@ def _collect_ide_export_entries(
363363

364364
def _collect_cli_export_entries(
365365
*,
366-
exclusion_rules: list[Any],
366+
exclusion_rules: list[RuleTokens],
367367
since: SinceMode,
368368
last_export_ms: int,
369369
today: str,
@@ -487,7 +487,7 @@ def _collect_cli_export_entries(
487487
def collect_export_entries(
488488
*,
489489
workspace_path: str,
490-
exclusion_rules: list[Any],
490+
exclusion_rules: list[RuleTokens],
491491
since: SinceMode,
492492
last_export_ms: int,
493493
out_dir: str,

services/search.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
)
5252
from services.workspace_resolver import infer_invalid_workspace_aliases
5353
from utils.cli_chat_reader import list_cli_projects, messages_to_bubbles, traverse_blobs
54-
from utils.exclusion_rules import build_searchable_text, is_excluded_by_rules
54+
from utils.exclusion_rules import RuleTokens, build_searchable_text, is_excluded_by_rules
5555
from utils.text_extract import extract_text_from_bubble
5656
from utils.path_helpers import (
5757
get_workspace_display_name,
@@ -368,7 +368,7 @@ def workspace_for_composer(self, composer: Composer) -> str:
368368

369369
def _load_search_workspace_assigner(
370370
workspace_path: str,
371-
rules: list[Any],
371+
rules: list[RuleTokens],
372372
workspace_entries: list[dict[str, Any]],
373373
) -> _SearchWorkspaceAssigner | None:
374374
ctx = resolve_workspace_context_cached(
@@ -428,7 +428,7 @@ def search_global_storage(
428428
workspace_path: str,
429429
query: str,
430430
query_lower: str,
431-
rules: list[Any],
431+
rules: list[RuleTokens],
432432
parse_warnings: ParseWarningCollector,
433433
*,
434434
since_ms: int | None = None,
@@ -478,7 +478,7 @@ def _search_global_storage_via_index(
478478
workspace_path: str,
479479
query: str,
480480
query_lower: str,
481-
rules: list[Any],
481+
rules: list[RuleTokens],
482482
parse_warnings: ParseWarningCollector,
483483
*,
484484
since_ms: int | None = None,
@@ -651,7 +651,7 @@ def _search_global_storage_live_scan(
651651
workspace_path: str,
652652
query: str,
653653
query_lower: str,
654-
rules: list[Any],
654+
rules: list[RuleTokens],
655655
parse_warnings: ParseWarningCollector,
656656
*,
657657
since_ms: int | None = None,
@@ -828,7 +828,7 @@ def search_legacy_workspaces(
828828
query: str,
829829
query_lower: str,
830830
search_type: str,
831-
rules: list[Any],
831+
rules: list[RuleTokens],
832832
*,
833833
since_ms: int | None = None,
834834
) -> list[SearchResult]:
@@ -961,7 +961,7 @@ def search_cli_sessions(
961961
cli_chats_path: str,
962962
query: str,
963963
query_lower: str,
964-
rules: list[Any],
964+
rules: list[RuleTokens],
965965
parse_warnings: ParseWarningCollector | None = None,
966966
*,
967967
since_ms: int | None = None,

services/search_index.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
open_global_db,
4040
)
4141
from utils.path_helpers import to_epoch_ms
42+
from utils.exclusion_rules import RuleTokens
4243
from utils.workspace_path import get_cli_chats_path
4344

4445
__all__ = [
@@ -127,7 +128,7 @@ def index_search_enabled() -> bool:
127128
)
128129

129130

130-
def _storage_fingerprint(workspace_path: str, rules: list[Any]) -> dict[str, Any]:
131+
def _storage_fingerprint(workspace_path: str, rules: list[RuleTokens]) -> dict[str, Any]:
131132
entries = collect_workspace_entries(workspace_path)
132133
gdb = global_storage_db_path(workspace_path)
133134
cli_path = get_cli_chats_path()
@@ -228,7 +229,7 @@ def _create_schema(conn: sqlite3.Connection) -> None:
228229

229230
def build_search_index(
230231
workspace_path: str,
231-
rules: list[Any],
232+
rules: list[RuleTokens],
232233
*,
233234
force: bool = False,
234235
) -> bool:
@@ -358,7 +359,7 @@ def build_search_index(
358359
return False
359360

360361

361-
def ensure_search_index(workspace_path: str, rules: list[Any]) -> None:
362+
def ensure_search_index(workspace_path: str, rules: list[RuleTokens]) -> None:
362363
"""Build index synchronously if missing or stale."""
363364
if not index_search_enabled():
364365
return
@@ -377,7 +378,7 @@ def ensure_search_index(workspace_path: str, rules: list[Any]) -> None:
377378

378379
def start_search_index_background(
379380
workspace_path: str,
380-
rules: list[Any],
381+
rules: list[RuleTokens],
381382
*,
382383
poll_seconds: int = 60,
383384
) -> None:
@@ -549,7 +550,7 @@ def query_composer_rows_in_window(
549550
return {row["composer_id"]: row for row in rows}
550551

551552

552-
def index_is_usable(workspace_path: str, rules: list[Any]) -> bool:
553+
def index_is_usable(workspace_path: str, rules: list[RuleTokens]) -> bool:
553554
"""True when the on-disk index matches the current Cursor storage fingerprint."""
554555
if not index_search_enabled() or _resolve_active_index_db_path() is None:
555556
return False

services/summary_cache.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
from pathlib import Path
1818
from typing import Any
1919

20+
from utils.exclusion_rules import RuleTokens
21+
2022
_logger = logging.getLogger(__name__)
2123

2224
CACHE_VERSION = 1
@@ -46,7 +48,7 @@ def nocache_enabled(*, request_nocache: bool = False) -> bool:
4648
)
4749

4850

49-
def _rules_digest(rules: list[Any]) -> str:
51+
def _rules_digest(rules: list[RuleTokens]) -> str:
5052
try:
5153
payload = json.dumps(rules, sort_keys=True, ensure_ascii=False)
5254
except (TypeError, ValueError):
@@ -68,7 +70,7 @@ def fingerprint_workspace_storage(
6870
workspace_entries: list[dict[str, Any]],
6971
*,
7072
global_db_path: str | None,
71-
rules: list[Any],
73+
rules: list[RuleTokens],
7274
cli_chats_path: str | None = None,
7375
) -> dict[str, Any]:
7476
"""Build a fingerprint dict for cache invalidation."""

services/workspace_composer_scan.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from typing import Any
1313

1414
from models import Bubble, Composer, ParseWarningCollector, SchemaError
15-
from utils.exclusion_rules import build_searchable_text, is_excluded_by_rules
15+
from utils.exclusion_rules import RuleTokens, build_searchable_text, is_excluded_by_rules
1616
from services.workspace_resolver import determine_project_for_conversation
1717

1818
_logger = logging.getLogger(__name__)
@@ -81,7 +81,7 @@ def composer_chat_title(composer: Composer) -> str:
8181

8282

8383
def is_composer_excluded(
84-
rules: list[Any],
84+
rules: list[RuleTokens],
8585
*,
8686
project_name: str,
8787
composer: Composer,

services/workspace_context.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from dataclasses import dataclass, replace
88
from typing import Any
99

10+
from utils.exclusion_rules import RuleTokens
11+
1012
from models import Bubble
1113
from services.workspace_db import (
1214
COMPOSER_ROWS_WITH_HEADERS_SQL,
@@ -86,7 +88,7 @@ def resolve_workspace_context(
8688

8789
def resolve_workspace_context_cached(
8890
workspace_path: str,
89-
rules: list[Any],
91+
rules: list[RuleTokens],
9092
*,
9193
workspace_entries: list[dict[str, Any]] | None = None,
9294
nocache: bool = False,
@@ -147,7 +149,7 @@ def resolve_invalid_workspace_aliases_cached(
147149
ctx: WorkspaceContext,
148150
global_db: sqlite3.Connection,
149151
workspace_path: str,
150-
rules: list[Any],
152+
rules: list[RuleTokens],
151153
*,
152154
nocache: bool = False,
153155
project_layouts_map: dict[str, list[str]] | None = None,
@@ -223,7 +225,7 @@ def with_invalid_workspace_aliases(
223225
ctx: WorkspaceContext,
224226
global_db: sqlite3.Connection,
225227
workspace_path: str,
226-
rules: list[Any],
228+
rules: list[RuleTokens],
227229
*,
228230
nocache: bool = False,
229231
project_layouts_map: dict[str, list[str]] | None = None,

services/workspace_db.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from pathlib import Path
1111
from typing import Any, cast
1212

13+
from utils.exclusion_rules import RuleTokens
14+
1315
_logger = logging.getLogger(__name__)
1416

1517
from models import Bubble, ParseWarningCollector, SchemaError
@@ -428,7 +430,7 @@ def build_composer_id_to_workspace_id(
428430
def build_composer_id_to_workspace_id_cached(
429431
workspace_path: str,
430432
workspace_entries: list[dict[str, Any]],
431-
rules: list[Any],
433+
rules: list[RuleTokens],
432434
*,
433435
nocache: bool = False,
434436
) -> dict[str, str]:

services/workspace_listing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
_logger = logging.getLogger(__name__)
99

1010
from utils.cli_chat_reader import list_cli_projects
11-
from utils.exclusion_rules import build_searchable_text, is_excluded_by_rules
11+
from utils.exclusion_rules import RuleTokens, build_searchable_text, is_excluded_by_rules
1212
from utils.path_helpers import (
1313
get_workspace_folder_paths,
1414
normalize_file_path,
@@ -49,7 +49,7 @@
4949

5050
def list_workspace_projects(
5151
workspace_path: str,
52-
rules: list[Any],
52+
rules: list[RuleTokens],
5353
*,
5454
nocache: bool = False,
5555
) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]:
@@ -102,7 +102,7 @@ def list_workspace_projects(
102102

103103
def _build_workspace_projects_uncached(
104104
workspace_path: str,
105-
rules: list[Any],
105+
rules: list[RuleTokens],
106106
orch: WorkspaceOrchestration,
107107
*,
108108
nocache: bool = False,

0 commit comments

Comments
 (0)