refactor: Untangle Context contracts and shared API helpers

SI
14d ago
+223-425

Summary

Separate Context schemas from execution; unify chat-title and AbortError policy; retire duplicate billing validator and superseded unused image adapter. Public request schema bytes and wire behavior are unchanged.

Verification

2,334 tests pass before obsolete adapter retirement; 239 active Sites/Higgsfield tests pass afterward. Repository lint and response-contract typecheck pass. Full TypeScript check retains exactly the same 214 baseline diagnostics, with zero additions. Independent review completed.

Scope and review

Part of the user-requested Recoup monorepo untangle-codebase workflow. Audit and decision log preceded implementation. Changes stay in this owning repository; no production deployment or main-branch merge requested. No broad comment/test-pruning sweep. Existing local work and retired checkouts preserved.

Each repository PR is independently reviewable; the Mono report will collect the coordinated audit, retained cases and check limitations.


Summary by cubic

Separates Context request schemas from execution logic and consolidates shared API helpers without changing any public request schema or wire behavior.

  • Moves contextOperationSchema into its own module so contract consumers no longer load authenticated execution services; a new boundary test enforces this.
  • Consolidates isAbortError into lib/errors/ and relocates generateChatTitle to lib/chats/.
  • Removes duplicate billing validation, the superseded Higgsfield image adapter, and their tests.