alt/agent-roadmap/archive/phase/backtest-loop/milestones/backtest-scenario-automation.md

6.1 KiB

Milestone: Backtest Scenario Automation

위치

  • Roadmap: agent-roadmap/ROADMAP.md
  • Phase: agent-roadmap/phase/backtest-loop/PHASE.md

목표

선택 universe, 기간, frequency, strategy 조합을 headless scenario로 반복 실행하고, run lifecycle과 결과 요약을 안정적인 CLI/YAML/JSONL 산출물로 남긴다. 이 마일스톤은 화면 없이 백테스트 반복 운영을 자동화하고 후속 데이터 품질/운영 UI 작업이 소비할 검증 표면을 만든다.

상태

[완료]

승격 조건

  • 없음

구현 잠금

  • 상태: 해제
  • 결정 필요: 없음

범위

  • named universe와 selector 기반 backtest scenario matrix 정의
  • 여러 backtest run의 순차 실행, polling, terminal status 확인 흐름
  • 결과 summary, 실패/timeout, expectation mismatch를 stable text/JSONL로 남기는 headless handoff
  • 기존 API/worker/contracts 경계를 유지한 CLI/operator workflow 보강
  • 반복 실행 가능한 fixture와 local smoke test
  • 원격 runner에서 migration, worker/API runtime, KIS secret 주입, CLI scenario 실행 순서를 검증 가능한 handoff로 정리

기능

Epic: [scenario] Scenario automation

백테스트 실행 조합을 사람이 반복 입력하지 않아도 재현 가능한 headless scenario로 관리한다.

  • [scenario-matrix] universe, 기간, frequency, strategy 조합을 YAML scenario에서 표현하고 검증할 수 있게 한다. 검증: go test -count=1 ./apps/cli/internal/operator ./apps/cli/internal/cli
  • [batch-runner] 여러 backtest run을 순차 실행하고 각 run의 polling 결과를 stable text/JSONL로 출력한다. 검증: go test -count=1 ./apps/cli/internal/operator ./services/api/internal/socket ./services/worker/internal/socket ./services/worker/internal/jobs
  • [result-handoff] 성공, 실패, timeout, expectation mismatch 결과를 fixture와 headless_validation.md에 남겨 후속 운영 표면이 소비할 수 있게 한다. 검증: go test -count=1 ./apps/cli/internal/operator ./apps/cli/internal/clirg --sort path -n "backtest" apps/cli/testdata/operator/headless_validation.md apps/cli/testdata/operator

Epic: [remote-test] Remote test readiness

원격 runner에서 백테스트 smoke를 실제 API/worker/DB/KIS 경계로 실행할 수 있게 선행 조건과 실행 순서를 고정한다.

  • [remote-env-sync] 원격 테스트 checkout과 실제 실행 checkout을 하나로 맞추고, DB/Redis health와 현재 checkout의 worker migration이 적용되는지 확인하는 절차를 남긴다. 검증: 원격 runner에서 bin/infra-check 또는 동등한 DB/Redis health check, services/worker 기준 go run ./cmd/alt-worker-migrate 실행 결과, 최신 migration version 확인 결과를 sanitized evidence로 기록
  • [runtime-startup] 원격 worker/API 실행 순서를 migration -> worker -> API -> CLI scenario로 정리하고, ALT_WORKER_SOCKET_URL, bind host/port, KIS SOPS env 주입이 worker 프로세스까지 전달되는지 검증한다. 검증: api_connection_smokeworker-available capability를 포함하고 backtest import step이 typed success를 반환
  • [matrix-seed] matrix scenario가 신규 원격 DB에서도 결정적으로 통과하도록 선행 import/seed 조건을 YAML 또는 handoff 문서에 반영한다. 검증: 원격 runner에서 backtest_matrix_success.yaml이 import/seed 선행 조건 충족 후 exit code 0
  • [result-poll] backtest_result_summary.yaml이 start 직후 result를 즉시 조회하지 않고 terminal status 도달 후 result를 조회하도록 flaky 구간을 제거한다. 검증: 원격 runner에서 backtest_result_summary.yaml --output jsonl이 exit code 0이고 run_status=succeeded와 result summary key를 함께 기록

완료 리뷰

  • 상태: 승인됨
  • 요청일: 2026-06-17
  • 완료 근거:
    • scenario-matrix, batch-runner, result-handoff가 각 complete.logRoadmap Completion 섹션에서 PASS로 확인되었다.
    • remote-env-sync, runtime-startup, matrix-seed, result-poll이 archive된 complete.logRoadmap Completion 섹션에서 PASS로 확인되었다.
    • 명시된 local Go test, scoped rg, remote migration/runtime/API smoke/matrix/result JSONL 검증이 완료 로그에 기록되어 있다.
  • 사용자 최종 확인:
    • Backtest Scenario Automation 마일스톤 완료 승인 및 archive 진행 여부
  • 작업 현황 동기화:
    • 현재 active agent-task/에는 m-backtest-scenario-automation 작업 그룹이 없다.
    • remote-env-sync: agent-task/archive/2026/06/m-backtest-scenario-automation/04_remote_env_sync/complete.log
    • runtime-startup: agent-task/archive/2026/06/m-backtest-scenario-automation/05+04_runtime_startup/complete.log
    • matrix-seed: agent-task/archive/2026/06/m-backtest-scenario-automation/06+05_matrix_seed/complete.log
    • result-poll: agent-task/archive/2026/06/m-backtest-scenario-automation/07+05_result_poll_remote/complete.log
  • 리뷰 코멘트: 코드 레벨 검토와 local smoke 검증에서 종료 차단 이슈가 발견되지 않아 마일스톤을 완료 처리하고 archive한다.

범위 제외

  • 새 strategy 판단 로직 또는 투자 의사결정 알고리즘 설계
  • Flutter 운영 화면 구현
  • 실시간 전략 실행, paper/live order routing, 실거래 adapter 변경
  • 외부 provider credential 값이나 개인 secret 문서화
  • 에이전트 도입, agent runtime 연결

작업 컨텍스트

  • 관련 경로: apps/cli/, services/api/, services/worker/, packages/contracts/, packages/domain/
  • 표준선(선택): 백테스트 반복 운영은 먼저 CLI, YAML fixture, JSONL/text output, Go tests로 검증한다.
  • 표준선(선택): API는 얇은 control plane으로 유지하고 run 실행과 결과 저장은 worker 경계를 따른다.
  • 표준선(선택): 원격 테스트 evidence에는 raw host, token, account number, secret 값을 남기지 않고 sanitized status와 exit code만 남긴다.
  • 선행 작업: Backtest Data Collection Infrastructure
  • 후속 작업: Data Quality Monitoring, Agent Tooling Bridge 후보
  • 확인 필요: 없음