Skip to content

refactor: AI prompt extraction + narrow sync/API-key interfaces - #5

Merged
jdluu merged 1 commit into
mainfrom
refactor/ai-provider
Aug 26, 2026
Merged

refactor: AI prompt extraction + narrow sync/API-key interfaces#5
jdluu merged 1 commit into
mainfrom
refactor/ai-provider

Conversation

@jdluu

@jdluu jdluu commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Summary

Phase 4 of the refactor plan (AI layer extensibility).

  • domain/ai/PromptBuilder: all prompt assembly extracted from HevyAiDataAccessor as a pure class (no Android imports). The accessor keeps data-fetching/failure-isolation only (SRP). Output verified byte-identical against the pre-refactor implementation, including formatWeight truncation (102 kg) and RPE rendering (@RPE8.0).
  • Narrow interface segregation: AITrainerViewModel now depends on ApiKeyStatusSource, ManualSyncScheduler, SyncCompleteListener instead of three concrete framework-tied classes - each faked in unit tests without WorkManager or encrypted storage. Bound via new SyncModule.

Test Plan

  • All pre-existing tests pass unchanged (senior review fixed junior test fixtures that contradicted real behavior, not the code)
  • +31 tests: 20 PromptBuilder characterization + 11 ViewModel Turbine tests = 318 total
  • ./gradlew testDebugUnitTest lintDebug assembleDebug exit 0, 0 lint errors
  • CI green on this PR

- Move all prompt assembly from HevyAiDataAccessor into a pure
  domain/ai/PromptBuilder (no Android imports); accessor now only
  fetches data and delegates formatting. Output strings byte-identical.
- Extract ApiKeyStatusSource, ManualSyncScheduler, SyncCompleteListener
  interfaces so AITrainerViewModel depends on abstractions instead of
  ApiKeyManager/SyncManager/SyncCoordinator concrete classes; bound in
  new SyncModule Hilt module.
- Add PromptBuilder characterization tests (20) and AITrainerViewModel
  Turbine state tests (11); suite grows to 318 tests.
@jdluu
jdluu merged commit eaea0dc into main Aug 26, 2026
3 checks passed
@jdluu
jdluu deleted the refactor/ai-provider branch August 26, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant