feat(strategy): implement DefineStrategyVersion slice - #2
Merged
Merged
Conversation
Persist immutable StrategyVersion definitions through the Strategy Store and expose the define endpoint. Related: ADR-001, ADR-002, ADR-013, ADR-018; Use Case DefineStrategyVersion.
There was a problem hiding this comment.
Pull request overview
Implements the “DefineStrategyVersion” vertical slice for the strategy feature (Web → Inbound Port → Application → Persistence/Snowflake adapters) and extends strategy retrieval to return version details.
Changes:
- Add
DefineStrategyVersioninbound port + application service + web endpoint (POST /strategies/{id}/versions) and response/request DTOs. - Persist and read
StrategyVersion(and its conditions) via new JPA entities + updated store/reader adapters; introduceStrategyVersionIdGeneratorwith Snowflake implementation. - Expand “GetStrategy” read/result/HTTP response to include
versionsandlatestVersionId; add unit + HTTP integration tests.
Reviewed changes
Copilot reviewed 19 out of 25 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| strategy/port/src/main/kotlin/com/refinvest/core/strategy/port/outbound/StrategyStore.kt | Extend outbound store contract to support findById for command-side aggregate load. |
| strategy/port/src/main/kotlin/com/refinvest/core/strategy/port/outbound/StrategyReader.kt | Expand read model to include versions and version details. |
| strategy/port/src/main/kotlin/com/refinvest/core/strategy/port/outbound/StrategyIdGenerator.kt | Add StrategyVersionIdGenerator outbound port. |
| strategy/port/src/main/kotlin/com/refinvest/core/strategy/port/inbound/strategy/get/GetStrategyResult.kt | Extend inbound result DTOs to include version details. |
| strategy/port/src/main/kotlin/com/refinvest/core/strategy/port/inbound/strategy/define/DefineStrategyVersionUseCase.kt | New inbound use case interface for defining versions. |
| strategy/port/src/main/kotlin/com/refinvest/core/strategy/port/inbound/strategy/define/DefineStrategyVersionResult.kt | New inbound result for version definition. |
| strategy/port/src/main/kotlin/com/refinvest/core/strategy/port/inbound/strategy/define/DefineStrategyVersionCommand.kt | New inbound command for version definition. |
| strategy/application/src/test/kotlin/com/refinvest/core/strategy/application/strategy/get/GetStrategyServiceTest.kt | Update unit test for expanded read model shape. |
| strategy/application/src/test/kotlin/com/refinvest/core/strategy/application/strategy/define/DefineStrategyVersionServiceTest.kt | New unit tests for DefineStrategyVersion application service. |
| strategy/application/src/test/kotlin/com/refinvest/core/strategy/application/strategy/create/CreateStrategyServiceTest.kt | Update unit test to match new StrategyStore interface. |
| strategy/application/src/main/kotlin/com/refinvest/core/strategy/application/strategy/get/GetStrategyService.kt | Map versions from read model into inbound result DTOs. |
| strategy/application/src/main/kotlin/com/refinvest/core/strategy/application/strategy/define/DefineStrategyVersionService.kt | New transactional application service implementing DefineStrategyVersion. |
| strategy/application/build.gradle.kts | Add Spring TX dependency for @Transactional. |
| strategy/adapter/web/src/main/kotlin/com/refinvest/core/strategy/adapter/web/strategy/StrategyController.kt | Add HTTP endpoint for defining versions; include versions in GetStrategy response. |
| strategy/adapter/web/src/main/kotlin/com/refinvest/core/strategy/adapter/web/strategy/get/GetStrategyResponse.kt | Define typed versions response model and mapping helper. |
| strategy/adapter/web/src/main/kotlin/com/refinvest/core/strategy/adapter/web/strategy/define/DefineStrategyVersionResponse.kt | New response DTOs for DefineStrategyVersion (including condition/exit representations). |
| strategy/adapter/web/src/main/kotlin/com/refinvest/core/strategy/adapter/web/strategy/define/DefineStrategyVersionRequest.kt | New request DTOs and request→domain mapping logic. |
| strategy/adapter/snowflake/src/main/kotlin/com/refinvest/core/strategy/adapter/out/id/SnowflakeStrategyVersionIdGenerator.kt | Snowflake-backed generator for StrategyVersionId. |
| strategy/adapter/persistence/src/main/kotlin/com/refinvest/core/strategy/adapter/out/persistence/StrategyVersionJpaEntity.kt | New JPA entity for strategy versions and version conditions relation. |
| strategy/adapter/persistence/src/main/kotlin/com/refinvest/core/strategy/adapter/out/persistence/StrategyJpaEntity.kt | Add versions collection to strategy JPA entity. |
| strategy/adapter/persistence/src/main/kotlin/com/refinvest/core/strategy/adapter/out/persistence/JpaStrategyStoreAdapter.kt | Update store adapter to load/save versions + conditions. |
| strategy/adapter/persistence/src/main/kotlin/com/refinvest/core/strategy/adapter/out/persistence/JpaStrategyReaderAdapter.kt | Update reader adapter to return versions and compute latest version id. |
| strategy/adapter/persistence/src/main/kotlin/com/refinvest/core/strategy/adapter/out/persistence/ConditionJpaEntity.kt | New JPA entity for version conditions. |
| gradle/libs.versions.toml | Add spring-tx library coordinate. |
| app/src/test/kotlin/com/refinvest/RefinvestApplicationTests.kt | Add HTTP-level tests for defining and retrieving versions + validation failure case. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Persistence/Snowflake Adapter 흐름으로 구현했습니다.
PENDING상태로 생성하는 최소 RunBacktest slice와 Compute outbound port를추가했습니다.
Implemented Use Cases
CreateStrategy: Snowflake 기반 Strategy ID 생성, 테스트용 MemberId 공급, PostgreSQL 저장.GetStrategy: StrategyReader를 통한 단건 조회와 Web 응답 매핑.RunBacktest: StrategyVersionId로BacktestRun(PENDING)생성. Compute 호출/폴링 구현은이번 범위에서 제외하고 outbound port만 정의.
Related ADR
Core ↔ Compute API Contract
없습니다.