Calendar Day
Week 5 carryover from PR #113 (PR 1 of 2 — deferred review item 1c)
Planned Effort
5 story points (Medium–High) — sprint item #1c
Problem
When invalid_workspace_ids is non-empty, assemble_single_tab runs a full global scan (COMPOSER_ROWS_WITH_HEADERS_SQL) on every deep-link request solely to build invalid_workspace_aliases via infer_invalid_workspace_aliases. List, summary, and full /tabs paths already pay this cost once per request; single-tab loads repeat it for every GET /api/workspaces/<id>/tabs/<composer_id> call. On large Cursor installs this makes search deep-links and conversation URLs noticeably slow.
The same alias map is recomputed independently in list_workspace_tab_summaries, assemble_workspace_tabs, _load_search_workspace_assigner, workspace_listing, and export_engine whenever invalid workspaces exist.
Goal
Compute invalid_workspace_aliases once per storage fingerprint (same mtime scheme as summary_cache / composer-map cache) and expose it on WorkspaceContext (or a sibling cached field) so hot paths — especially assemble_single_tab — read a precomputed map instead of scanning all composerData:* rows.
Scope
Touch points
services/workspace_context.py — extend WorkspaceContext (or enrich helper) with invalid_workspace_aliases: dict[str, str]
services/summary_cache.py — fingerprint include/exclude rules consistent with existing composer-map cache
services/workspace_tabs.py — assemble_single_tab: consume cached aliases; remove per-request COMPOSER_ROWS_WITH_HEADERS_SQL roster scan
- Call sites that currently call
infer_invalid_workspace_aliases inline when invalid_workspace_ids — switch to context cache where fingerprint matches
- Tests:
tests/test_workspace_tabs_summary.py (scoped load assertions), new test that single-tab does not run full composer SQL when aliases are cached
Out of scope
Acceptance Criteria
Verification
cd C:\Users\Jasen\CppAliance\cppa-cursor-browser
.\.venv\Scripts\Activate.ps1
pytest tests/test_workspace_tabs_summary.py tests/test_workspace_list_count_alignment.py -q
pytest -q
mypy .
Calendar Day
Week 5 carryover from PR #113 (PR 1 of 2 — deferred review item 1c)
Planned Effort
5 story points (Medium–High) — sprint item #1c
Problem
When
invalid_workspace_idsis non-empty,assemble_single_tabruns a full global scan (COMPOSER_ROWS_WITH_HEADERS_SQL) on every deep-link request solely to buildinvalid_workspace_aliasesviainfer_invalid_workspace_aliases. List, summary, and full/tabspaths already pay this cost once per request; single-tab loads repeat it for everyGET /api/workspaces/<id>/tabs/<composer_id>call. On large Cursor installs this makes search deep-links and conversation URLs noticeably slow.The same alias map is recomputed independently in
list_workspace_tab_summaries,assemble_workspace_tabs,_load_search_workspace_assigner,workspace_listing, andexport_enginewhenever invalid workspaces exist.Goal
Compute
invalid_workspace_aliasesonce per storage fingerprint (same mtime scheme assummary_cache/ composer-map cache) and expose it onWorkspaceContext(or a sibling cached field) so hot paths — especiallyassemble_single_tab— read a precomputed map instead of scanning allcomposerData:*rows.Scope
Touch points
services/workspace_context.py— extendWorkspaceContext(or enrich helper) withinvalid_workspace_aliases: dict[str, str]services/summary_cache.py— fingerprint include/exclude rules consistent with existing composer-map cacheservices/workspace_tabs.py—assemble_single_tab: consume cached aliases; remove per-requestCOMPOSER_ROWS_WITH_HEADERS_SQLroster scaninfer_invalid_workspace_aliasesinline wheninvalid_workspace_ids— switch to context cache where fingerprint matchestests/test_workspace_tabs_summary.py(scoped load assertions), new test that single-tab does not run full composer SQL when aliases are cachedOut of scope
bubble_mapon list/summary (separate perf tradeoff, Project list and workspace details show different conversation counts; workspace load still slow on large installs #95)infer_invalid_workspace_aliasesAcceptance Criteria
assemble_single_tabno longer runsCOMPOSER_ROWS_WITH_HEADERS_SQLon every request when invalid workspaces exist and cache is warminvalid_id → replacement_idmap)test_scoped_mrc_load_with_invalid_workspacesand related tab tests still passmypy --strictand fullpytestpassVerification