Skip to content

cppa-cursor-browser: Cache invalid-workspace alias inference on workspace context #116

Description

@clean6378-max-it

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.pyassemble_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

  • assemble_single_tab no longer runs COMPOSER_ROWS_WITH_HEADERS_SQL on every request when invalid workspaces exist and cache is warm
  • Alias map invalidates when workspace storage fingerprint changes (same as other summary-cache entries)
  • Existing alias-resolution behavior unchanged (same inputs → same invalid_id → replacement_id map)
  • test_scoped_mrc_load_with_invalid_workspaces and related tab tests still pass
  • New or updated test proves single-tab path avoids full composer scan when cache hit
  • mypy --strict and full pytest pass
  • PR approved by at least 1 reviewer

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 .

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions