Skip to content

refactor: add usecase layer for staging operations#3

Merged
mpyw merged 2 commits intorefactor/usecase-layerfrom
refactor/usecase-staging
Jan 2, 2026
Merged

refactor: add usecase layer for staging operations#3
mpyw merged 2 commits intorefactor/usecase-layerfrom
refactor/usecase-staging

Conversation

@mpyw
Copy link
Owner

@mpyw mpyw commented Jan 2, 2026

Summary

  • Add internal/usecase/staging/ package with structured input/output types
  • Create usecases for: status, apply, add, edit, delete, reset, diff
  • Foundation for supporting both CLI and future GUI (Wails) interfaces

This is Step 2 of the usecase layer architecture refactoring plan.

Note: The existing runners are not yet modified to use these usecases. That integration will be done in a subsequent PR.

Data Flow (Target)

Before:
  CLI Command → Runner → io.Writer (formatted text)

After:
  CLI Command → UseCase → Structured Data → CLI formats to text
  GUI         → UseCase → Structured Data → GUI renders to UI

Test plan

  • Build passes
  • Lint passes
  • Integration with runners (future PR)

🤖 Generated with Claude Code

Add usecase layer that returns structured data instead of formatting output.
This is the foundation for supporting both CLI and future GUI (Wails) interfaces.

New usecases:
- StatusUseCase: returns StatusOutput with entries
- ApplyUseCase: returns ApplyOutput with results and conflicts
- AddUseCase: stages new items with structured input/output
- EditUseCase: stages edits with structured input/output
- DeleteUseCase: stages deletions with structured input/output
- ResetUseCase: unstages or restores with structured output
- DiffUseCase: compares staged vs AWS with structured diff entries

The existing runners are not yet modified to use these usecases.
That integration will be done in a subsequent PR.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Jan 2, 2026

Codecov Report

❌ Patch coverage is 89.22156% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.84%. Comparing base (4da01a2) to head (ff46ddd).

Files with missing lines Patch % Lines
internal/usecase/staging/reset.go 84.37% 5 Missing and 5 partials ⚠️
internal/usecase/staging/diff.go 90.24% 6 Missing and 2 partials ⚠️
internal/usecase/staging/edit.go 81.39% 4 Missing and 4 partials ⚠️
internal/usecase/staging/add.go 90.62% 2 Missing and 1 partial ⚠️
internal/usecase/staging/status.go 91.42% 2 Missing and 1 partial ⚠️
internal/usecase/staging/apply.go 95.91% 1 Missing and 1 partial ⚠️
internal/usecase/staging/delete.go 93.10% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                    Coverage Diff                     @@
##           refactor/usecase-layer       #3      +/-   ##
==========================================================
+ Coverage                   88.81%   88.84%   +0.03%     
==========================================================
  Files                          58       65       +7     
  Lines                        4059     4393     +334     
==========================================================
+ Hits                         3605     3903     +298     
- Misses                        304      325      +21     
- Partials                      150      165      +15     
Flag Coverage Δ
e2e 66.97% <ø> (ø)
unittests 78.96% <89.22%> (+0.84%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mpyw mpyw changed the base branch from main to refactor/usecase-layer January 2, 2026 23:18
- Move DeleteStrategy and VersionFetcher interfaces to staging package
- Rename GetStagedValue to Draft, GetCurrentValue to Baseline
- Fix apply order: check name filter before empty check
- Add comprehensive tests (91.9% coverage)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mpyw
Copy link
Owner Author

mpyw commented Jan 2, 2026

レビュー結果

修正済み

  • ✅ インターフェース移動: DeleteStrategy, VersionFetcherstaging package
  • ✅ メソッドリネーム: GetStagedValueDraft, GetCurrentValueBaseline
  • apply.go: name filterのチェック順序を修正(空チェックより前に)
  • ✅ テスト追加(カバレッジ 91.9%)

確認事項

  • エラーラッピングは現状で一貫性あり(修正不要)
  • _ context.Context の使用は将来使う時に変更でOK

残課題(別PR予定)

  • staging.Store のインターフェース化(テストでモック可能にする)
    • 現在のカバレッジ91.9%の残り8%はStore操作のエラーパス
    • 実ファイルシステムを使うためモック不可

@mpyw mpyw merged commit 20d62c6 into refactor/usecase-layer Jan 2, 2026
5 checks passed
@mpyw mpyw deleted the refactor/usecase-staging branch January 2, 2026 23:43
@mpyw mpyw added the staging Staging workflow functionality label Jan 15, 2026
mpyw added a commit that referenced this pull request Jan 20, 2026
Migrate all write use cases (create, update, delete, restore) from
AWS-specific API interfaces to cloud-agnostic provider interfaces.

Changes:
- Update provider interfaces with write result types
- Migrate param/create, param/update, param/delete use cases
- Migrate secret/create, secret/update, secret/delete, secret/restore
- Update CLI commands to use AWS adapters
- Update GUI to use AWS adapters
- Update all related tests with new mock implementations

This completes PR #3 of the multi-cloud refactoring roadmap.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
mpyw added a commit that referenced this pull request Jan 20, 2026
)

Migrate all write use cases (create, update, delete, restore) from
AWS-specific API interfaces to cloud-agnostic provider interfaces.

Changes:
- Update provider interfaces with write result types
- Migrate param/create, param/update, param/delete use cases
- Migrate secret/create, secret/update, secret/delete, secret/restore
- Update CLI commands to use AWS adapters
- Update GUI to use AWS adapters
- Update all related tests with new mock implementations

This completes PR #3 of the multi-cloud refactoring roadmap.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

staging Staging workflow functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant