Skip to content

Tests for determine_project_for_conversation #87

@bradjin8

Description

@bradjin8

Problem

determine_project_for_conversation is the highest schema-drift-risk function in cppa-cursor-browser. Located in services/workspace_resolver.py (line 227), it takes 9 parameters and implements a multi-stage fallback chain: definitive per-workspace mapping → projectLayouts path matching → newlyCreatedFiles URI matching → codeBlockData file-path matching → bubble relevantFiles / attachedFileCodeChunksUris / context.fileSelections matching → last-resort path-segment substring matching. When Cursor changes its internal SQLite schema — and it has already migrated from workspace-specific to global storage — a renamed key silently returns None rather than raising an error, and the fallback chain silently degrades through progressively less reliable resolution stages with no diagnostic signal. The codebase has 34 test files with 344 test cases and CI running pytest, mypy, and gitleaks, but determine_project_for_conversation has only 1 direct test (tests/test_workspace_assignment_fallback.py — testing the invalid-workspace-alias bypass path). None of the 6 fallback stages (projectLayouts, newlyCreatedFiles, codeBlockData, bubble headers, path-segment matching, or the None terminal) have dedicated coverage, meaning schema drift in any stage is undetectable until it surfaces as silent misassignment in production.

Acceptance Criteria

  • Direct unit tests covering all 6 fallback stages individually
  • Property-based tests (Hypothesis, already in use) for edge cases
  • Covers: all 9 parameter combinations, None handling, schema drift scenarios
  • At least 15 test cases covering the multi-stage resolution
  • Tests pass in CI

Implementation Notes

References

  • services/workspace_resolver.py:227 — function definition (9 params, ~145 LOC)
  • tests/test_workspace_assignment_fallback.py — existing 1-test coverage

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions