strategy: align model exit signal policy with v2 spec (#369) #388

Merged
jihoson merged 2 commits from feature/issue-369-model-exit-signal-spec-sync into feature/v3-session-policy-stream 2026-03-02 09:35:23 +09:00
Collaborator

Traceability

  • REQ-ID: REQ-V2-004
  • TASK-ID: TASK-V2-006
  • TEST-ID: TEST-ACC-011

Summary

  • model_exit_signal이 상태머신 EXITED 직접 조건으로 사용되던 경로를 제거해 보조 트리거 사양(단독 청산 금지)과 정합화했습니다.
  • evaluate_exit()에서 model_liquidity_exit 직접 청산 reason 분기를 제거했습니다.
  • 회귀 테스트를 갱신해 모델 신호 단독 발생 시 should_exit=False를 강제했습니다.
  • 구현 감사 문서의 REQ-V2-004 상태를 ✅ 완료로 동기화하고, requirements registry 버전을 갱신했습니다.

Validation

  • python3 scripts/session_handover_check.py --strict
  • ruff check src/strategy/position_state_machine.py src/strategy/exit_rules.py tests/test_strategy_state_machine.py tests/test_strategy_exit_rules.py
  • pytest -q tests/test_strategy_state_machine.py tests/test_strategy_exit_rules.py
  • python3 scripts/validate_ouroboros_docs.py
  • python3 scripts/validate_docs_sync.py
  • BASE=$(git merge-base origin/feature/v3-session-policy-stream HEAD); python3 scripts/validate_governance_assets.py "$BASE...HEAD"
## Traceability - REQ-ID: `REQ-V2-004` - TASK-ID: `TASK-V2-006` - TEST-ID: `TEST-ACC-011` ## Summary - `model_exit_signal`이 상태머신 `EXITED` 직접 조건으로 사용되던 경로를 제거해 보조 트리거 사양(단독 청산 금지)과 정합화했습니다. - `evaluate_exit()`에서 `model_liquidity_exit` 직접 청산 reason 분기를 제거했습니다. - 회귀 테스트를 갱신해 모델 신호 단독 발생 시 `should_exit=False`를 강제했습니다. - 구현 감사 문서의 `REQ-V2-004` 상태를 `✅ 완료`로 동기화하고, requirements registry 버전을 갱신했습니다. ## Validation - `python3 scripts/session_handover_check.py --strict` - `ruff check src/strategy/position_state_machine.py src/strategy/exit_rules.py tests/test_strategy_state_machine.py tests/test_strategy_exit_rules.py` - `pytest -q tests/test_strategy_state_machine.py tests/test_strategy_exit_rules.py` - `python3 scripts/validate_ouroboros_docs.py` - `python3 scripts/validate_docs_sync.py` - `BASE=$(git merge-base origin/feature/v3-session-policy-stream HEAD); python3 scripts/validate_governance_assets.py "$BASE...HEAD"`
agentson added 1 commit 2026-03-02 09:25:12 +09:00
strategy: align model exit signal as assist-only trigger (#369)
All checks were successful
Gitea CI / test (push) Successful in 32s
Gitea CI / test (pull_request) Successful in 32s
2332ba868f
Author
Collaborator

PR #388 코드 리뷰 — strategy: align model exit signal policy with v2 spec (#369)

범위: model_exit_signal을 직접 청산 트리거에서 제거 → "assist-only" 정책으로 재분류


통과 항목

1. 정책 변경 구현

  • exit_rules.py: model_liquidity_exit 분기 제거 (2줄 삭제)
  • position_state_machine.py: evaluate_exit_first()에서 model_exit_signal 제거 + 주석 명시

2. 테스트 커버리지

  • test_model_assist_signal_does_not_exit_directly: model_exit_signal=True 단독 → should_exit=False, reason="hold" 검증
  • test_model_signal_is_assist_only_not_direct_exit: promote_state(ARMED, model_exit_signal=True) → ARMED 유지 검증
  • 로컬 실행: 6 passed in 0.02s

3. 문서: REQ-V2-004 ⚠️, 버전 1.0.9


⚠️ 소견 1 — model_exit_signal이 현재 dead signal 상태 (Non-blocking)

변경 후 model_exit_signal의 수명 주기:

  1. exit_rules.py L67: 계산됨 (pred_down_prob >= threshold AND liquidity_weak)
  2. StateTransitionInput에 전달됨 (L77)
  3. evaluate_exit_first(): 사용 안 함 (이번 PR에서 제거됨)
  4. promote_state() 내부: 참조 코드 없음

즉 계산은 되지만 아무 효과가 없는 상태입니다.
주석에서 "assist-only"라고 명시했지만, 현재 "간접적 보조" 역할도 구현되어 있지 않습니다.

권장: StateTransitionInput에서 model_exit_signal 필드를 제거하거나, 실제 assist 역할(예: ATR 멀티플라이어 강화, arm_pct 하향 조정 등)을 구현하거나, 주석에 "미래 구현 예정 (placeholder)" 명시.


⚠️ 소견 2 — REQ-V2-004 완료 표시 타당성 (Non-blocking)

"4중 청산 로직 (Hard/BE/ATR Trailing/Model)"에서 Model 컴포넌트가
현재 동작하지 않는 상태인데 완료로 표시됩니다.

"스펙 정합화 완료"라는 의미라면 비고에 "Model = assist-only (직접 EXIT 미트리거)"를 추가해 향후 감사 시 혼선을 방지하기를 권장합니다.


결론

LGTM — 정책 변경 명확, 테스트 통과.
소견 1의 dead signal 처리 방향(제거/구현/주석)을 결정해 후속 PR로 추적하기를 권장합니다.

## PR #388 코드 리뷰 — strategy: align model exit signal policy with v2 spec (#369) **범위**: model_exit_signal을 직접 청산 트리거에서 제거 → "assist-only" 정책으로 재분류 --- ### ✅ 통과 항목 **1. 정책 변경 구현** - exit_rules.py: model_liquidity_exit 분기 제거 (2줄 삭제) - position_state_machine.py: evaluate_exit_first()에서 model_exit_signal 제거 + 주석 명시 **2. 테스트 커버리지** - test_model_assist_signal_does_not_exit_directly: model_exit_signal=True 단독 → should_exit=False, reason="hold" 검증 - test_model_signal_is_assist_only_not_direct_exit: promote_state(ARMED, model_exit_signal=True) → ARMED 유지 검증 - 로컬 실행: 6 passed in 0.02s ✅ **3. 문서**: REQ-V2-004 ⚠️ → ✅, 버전 1.0.9 --- ### ⚠️ 소견 1 — model_exit_signal이 현재 dead signal 상태 (Non-blocking) 변경 후 model_exit_signal의 수명 주기: 1. exit_rules.py L67: 계산됨 (pred_down_prob >= threshold AND liquidity_weak) 2. StateTransitionInput에 전달됨 (L77) 3. evaluate_exit_first(): 사용 안 함 (이번 PR에서 제거됨) 4. promote_state() 내부: 참조 코드 없음 즉 계산은 되지만 아무 효과가 없는 상태입니다. 주석에서 "assist-only"라고 명시했지만, 현재 "간접적 보조" 역할도 구현되어 있지 않습니다. **권장**: StateTransitionInput에서 model_exit_signal 필드를 제거하거나, 실제 assist 역할(예: ATR 멀티플라이어 강화, arm_pct 하향 조정 등)을 구현하거나, 주석에 "미래 구현 예정 (placeholder)" 명시. --- ### ⚠️ 소견 2 — REQ-V2-004 ✅ 완료 표시 타당성 (Non-blocking) "4중 청산 로직 (Hard/BE/ATR Trailing/Model)"에서 Model 컴포넌트가 현재 동작하지 않는 상태인데 ✅ 완료로 표시됩니다. "스펙 정합화 완료"라는 의미라면 비고에 "Model = assist-only (직접 EXIT 미트리거)"를 추가해 향후 감사 시 혼선을 방지하기를 권장합니다. --- ### 결론 **LGTM** — 정책 변경 명확, 테스트 통과. 소견 1의 dead signal 처리 방향(제거/구현/주석)을 결정해 후속 PR로 추적하기를 권장합니다.
agentson added 1 commit 2026-03-02 09:31:39 +09:00
strategy: implement model assist be-lock path and clarify audit note
All checks were successful
Gitea CI / test (push) Successful in 32s
Gitea CI / test (pull_request) Successful in 33s
5e4c94bfeb
Author
Collaborator

리뷰 반영했습니다. (비블로킹 소견 2건)

  1. dead signal 해소
  • model_exit_signal을 단순 전달값으로 두지 않고, assist-only 동작으로 연결했습니다.
  • 상태머신에서 model_exit_signal은 직접 EXIT를 유발하지 않고,
    HOLDING -> BE_LOCK 승격 보조로만 작동합니다.
  • evaluate_exit() reason에 model_assist_be_lock를 추가해 관측 가능하게 했습니다.
  1. 감사 문서 명확화
  • REQ-V2-004 항목 설명에 Model assist-only, 직접 EXIT 미트리거를 명시했습니다.
  • 정책 문서 변경 동기화를 위해 requirements registry 버전을 1.0.10으로 갱신했습니다.

검증:

  • ruff check src/strategy/position_state_machine.py src/strategy/exit_rules.py tests/test_strategy_state_machine.py tests/test_strategy_exit_rules.py
  • pytest -q tests/test_strategy_state_machine.py tests/test_strategy_exit_rules.py (7 passed)
  • python3 scripts/validate_ouroboros_docs.py
  • python3 scripts/validate_docs_sync.py
  • BASE=$(git merge-base origin/feature/v3-session-policy-stream HEAD); python3 scripts/validate_governance_assets.py "$BASE...HEAD"
리뷰 반영했습니다. (비블로킹 소견 2건) 1. dead signal 해소 - `model_exit_signal`을 단순 전달값으로 두지 않고, `assist-only` 동작으로 연결했습니다. - 상태머신에서 `model_exit_signal`은 직접 EXIT를 유발하지 않고, `HOLDING -> BE_LOCK` 승격 보조로만 작동합니다. - `evaluate_exit()` reason에 `model_assist_be_lock`를 추가해 관측 가능하게 했습니다. 2. 감사 문서 명확화 - `REQ-V2-004` 항목 설명에 `Model assist-only, 직접 EXIT 미트리거`를 명시했습니다. - 정책 문서 변경 동기화를 위해 requirements registry 버전을 `1.0.10`으로 갱신했습니다. 검증: - `ruff check src/strategy/position_state_machine.py src/strategy/exit_rules.py tests/test_strategy_state_machine.py tests/test_strategy_exit_rules.py` - `pytest -q tests/test_strategy_state_machine.py tests/test_strategy_exit_rules.py` (`7 passed`) - `python3 scripts/validate_ouroboros_docs.py` - `python3 scripts/validate_docs_sync.py` - `BASE=$(git merge-base origin/feature/v3-session-policy-stream HEAD); python3 scripts/validate_governance_assets.py "$BASE...HEAD"`
Author
Collaborator

추가 리뷰 — strategy: implement model assist be-lock path and clarify audit note

커밋: 5e4c94b


소견 반영 확인

소견 1 (dead signal 구현)

model_exit_signal의 실제 "assist" 동작 구현:

position_state_machine.py:
elif inp.model_exit_signal:
# Model signal assists risk posture by tightening to BE_LOCK.
target = PositionState.BE_LOCK

exit_rules.py:
elif model_exit_signal and next_state == PositionState.BE_LOCK:
reason = "model_assist_be_lock"

단조성(monotonic) 보장 확인

  • HOLDING + model_exit_signal=True → BE_LOCK 승격
  • BE_LOCK + model_exit_signal=True → BE_LOCK 유지
  • ARMED + model_exit_signal=True → ARMED 유지 (_STATE_RANK 비교로 downgrade 차단)

소견 2 (감사 문서 비고)

REQ-V2-004 설명이 "4중 청산 로직 (Hard/BE/ATR Trailing/Model assist-only, 직접 EXIT 미트리거)"로 업데이트됨


테스트 커버리지

테스트 검증 내용
test_model_assist_signal_promotes_be_lock_without_direct_exit HOLDING → BE_LOCK 승격, should_exit=False, reason="model_assist_be_lock"
test_model_signal_promotes_be_lock_as_assist promote_state(HOLDING, model=True) → BE_LOCK
test_model_signal_does_not_force_exit_directly promote_state(ARMED, model=True) → ARMED (downgrade 불가)

로컬 실행: 7 passed in 0.02s


결론

LGTM — 소견 모두 반영. 머지 준비 완료.

## 추가 리뷰 — strategy: implement model assist be-lock path and clarify audit note **커밋**: 5e4c94b --- ### ✅ 소견 반영 확인 **소견 1 (dead signal 구현)** model_exit_signal의 실제 "assist" 동작 구현: position_state_machine.py: elif inp.model_exit_signal: # Model signal assists risk posture by tightening to BE_LOCK. target = PositionState.BE_LOCK exit_rules.py: elif model_exit_signal and next_state == PositionState.BE_LOCK: reason = "model_assist_be_lock" **단조성(monotonic) 보장 확인** - HOLDING + model_exit_signal=True → BE_LOCK 승격 ✅ - BE_LOCK + model_exit_signal=True → BE_LOCK 유지 ✅ - ARMED + model_exit_signal=True → ARMED 유지 (_STATE_RANK 비교로 downgrade 차단) ✅ **소견 2 (감사 문서 비고)** REQ-V2-004 설명이 "4중 청산 로직 (Hard/BE/ATR Trailing/Model assist-only, 직접 EXIT 미트리거)"로 업데이트됨 ✅ --- ### ✅ 테스트 커버리지 | 테스트 | 검증 내용 | |--------|-----------| | test_model_assist_signal_promotes_be_lock_without_direct_exit | HOLDING → BE_LOCK 승격, should_exit=False, reason="model_assist_be_lock" | | test_model_signal_promotes_be_lock_as_assist | promote_state(HOLDING, model=True) → BE_LOCK | | test_model_signal_does_not_force_exit_directly | promote_state(ARMED, model=True) → ARMED (downgrade 불가) | 로컬 실행: 7 passed in 0.02s ✅ --- ### 결론 **LGTM** — 소견 모두 반영. 머지 준비 완료.
jihoson merged commit 1c41379815 into feature/v3-session-policy-stream 2026-03-02 09:35:23 +09:00
jihoson deleted branch feature/issue-369-model-exit-signal-spec-sync 2026-03-02 09:35:23 +09:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#388