Skip to content

Decouple API handlers from private _-prefixed internals #73

@bradjin8

Description

@bradjin8

Repository: cppa-cursor-browser
Assignee: Brad @bradjin8
Points: 3
Severity: Medium

Problem

API handlers in api/export_api.py and api/workspaces.py import _-prefixed internal functions from service modules (e.g., _get_cli_workspace_tabs from services/cli_tabs.py). The underscore prefix signals "private / not part of the public interface" in Python convention, but the API layer couples to these internals, creating a fragile dependency. These are the same functions where except Exception: pass operates — the silently-failing, privately-coupled, untested interior path identified by the eval. Refactoring the service internals requires updating API handler imports, and the private status provides a false sense of encapsulation.

Acceptance Criteria

  • All _-prefixed functions imported by api/ modules are either: (a) renamed to public (remove underscore) with proper docstrings, or (b) wrapped by public methods on the service module that delegate to the private implementation
  • No api/ file imports any _-prefixed symbol from services/
  • The service module's public API is documented with docstrings describing parameters, return types, and error conditions
  • All existing tests pass without modification
  • Tests pass in CI
  • PR approved by at least 1 reviewer

Implementation Notes

Audit api/export_api.py and api/workspaces.py for imports of _-prefixed symbols from services/. For each _-prefixed function that is genuinely needed by the API layer, decide: if it's a stable interface, promote it to public (remove the underscore, add a docstring). If it's an implementation detail that shouldn't be exposed, create a public wrapper function that delegates to it. The goal is a clean boundary: api/ imports only public symbols from services/, and services/ can freely refactor its _-prefixed internals. Also check services/workspace_resolver.py and services/cli_tabs.py as sources of _-prefixed exports.

References

  • Eval finding: Test 20 (Implementation Hiding) — part of the "Invisible Surface, Untestable Internals" compound (T20+T30+T31)
  • Related files: api/export_api.py, api/workspaces.py, services/cli_tabs.py, services/workspace_resolver.py

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