fix: #412/#413/#414 runtime stability and PR governance preflight #415

Merged
jihoson merged 2 commits from feature/issue-412-413-414-runtime-and-governance into main 2026-03-04 23:43:36 +09:00
Collaborator

Linked Issue

Scope

  • REQ: REQ-OPS-001 (운영 안정성 및 프로세스 무결성)
  • TASK: TASK-OPS-001 (runtime 모니터 안정화 및 거버넌스 preflight 추가)
  • TEST: TEST-OPS-001 (monitor pipefail 회귀 테스트 + governance ID 검증 테스트)

Ticket Stage

  • Current stage: Implemented
  • Previous stage evidence link: N/A (신규 이슈)

Summary

#413 — runtime_verify_monitor.sh pipefail 수정

  • find_live_pids() 에서 pgrep이 no-match(exit 1)를 반환할 때 set -euo pipefail 에 의해 스크립트 전체가 조기 종료되는 버그 수정
  • local raw; raw=$(pgrep ...) || true 패턴으로 pipefail 트리거 방지
  • 회귀 테스트 추가: MAX_LOOPS=1 실행 후 HEARTBEAT 로그 확인

#412 — 스타트업 CancelledError 로깅 추가

  • sync_positions_from_broker 호출부에 asyncio.CancelledError 캐치 추가
  • except ExceptionBaseException 하위의 CancelledError를 잡지 못하므로 별도 핸들러 추가
  • 향후 동일 패턴의 크래시 발생 시 run log에 증거가 남도록 보강

#414 — PR 거버넌스 preflight 추가

  • scripts/validate_pr_body.py: REQ-ID/TASK-ID/TEST-ID 패턴 검증 추가 (--no-governance 플래그로 비활성화 가능)
  • docs/workflow.md: "PR Governance Preflight (Mandatory)" 섹션 추가
  • docs/commands.md: tea pulls create 전에 실행할 preflight 명령 문서화

Main -> Verifier Directive Contract

  • Scope: scripts/runtime_verify_monitor.sh, src/main.py, scripts/validate_pr_body.py, docs/
  • Method: pytest test suite (1081 tests), validate_docs_sync.py
  • PASS criteria: 1081 tests pass, docs sync validates
  • FAIL criteria: any test failure or docs sync error
  • NOT_OBSERVED criteria: N/A
  • Evidence format: test output below

Verifier Coverage Matrix (Required)

Item Evidence Status (PASS/FAIL/NOT_OBSERVED)
REQ-OPS-001 test_runtime_verify_monitor_survives_when_no_live_pid PASS PASS
TASK-OPS-001 1081 tests passed, docs sync OK PASS
TEST-OPS-001 4 new governance tests + 1 pipefail regression test PASS

NOT_OBSERVED가 1개라도 있으면 승인/머지 금지.

Gitea Preflight

  • docs/commands.mddocs/workflow.md 트러블슈팅 선확인
  • tea 사용 (gh 미사용)

Session Handover Gate

  • python3 scripts/session_handover_check.py --strict 통과
  • workflow/session-handover.md 최신 엔트리 갱신
  • 최신 handover 엔트리 heading: ### 2026-03-04 | session=claude-issues412-413-414

Docs Sync Gate (docs 파일 변경 시 필수)

  • python3 scripts/validate_docs_sync.py 통과

Runtime Evidence

READ-ONLY Approval (Required when touching READ-ONLY files)

  • Touched READ-ONLY files: N/A (src/core/risk_manager.py 미변경)
  • Human approval: N/A
  • Test suite 1: N/A
  • Test suite 2: N/A

Approval Gate

  • Static Verifier approval comment linked
  • Runtime Verifier approval comment linked
## Linked Issue - Closes #412 - Closes #413 - Closes #414 ## Scope - REQ: `REQ-OPS-001` (운영 안정성 및 프로세스 무결성) - TASK: `TASK-OPS-001` (runtime 모니터 안정화 및 거버넌스 preflight 추가) - TEST: `TEST-OPS-001` (monitor pipefail 회귀 테스트 + governance ID 검증 테스트) ## Ticket Stage - Current stage: `Implemented` - Previous stage evidence link: N/A (신규 이슈) ## Summary ### #413 — runtime_verify_monitor.sh pipefail 수정 - `find_live_pids()` 에서 `pgrep`이 no-match(exit 1)를 반환할 때 `set -euo pipefail` 에 의해 스크립트 전체가 조기 종료되는 버그 수정 - `local raw; raw=$(pgrep ...) || true` 패턴으로 pipefail 트리거 방지 - 회귀 테스트 추가: MAX_LOOPS=1 실행 후 HEARTBEAT 로그 확인 ### #412 — 스타트업 CancelledError 로깅 추가 - `sync_positions_from_broker` 호출부에 `asyncio.CancelledError` 캐치 추가 - `except Exception` 은 `BaseException` 하위의 `CancelledError`를 잡지 못하므로 별도 핸들러 추가 - 향후 동일 패턴의 크래시 발생 시 run log에 증거가 남도록 보강 ### #414 — PR 거버넌스 preflight 추가 - `scripts/validate_pr_body.py`: REQ-ID/TASK-ID/TEST-ID 패턴 검증 추가 (`--no-governance` 플래그로 비활성화 가능) - `docs/workflow.md`: "PR Governance Preflight (Mandatory)" 섹션 추가 - `docs/commands.md`: `tea pulls create` 전에 실행할 preflight 명령 문서화 ## Main -> Verifier Directive Contract - Scope: scripts/runtime_verify_monitor.sh, src/main.py, scripts/validate_pr_body.py, docs/ - Method: pytest test suite (1081 tests), validate_docs_sync.py - PASS criteria: 1081 tests pass, docs sync validates - FAIL criteria: any test failure or docs sync error - NOT_OBSERVED criteria: N/A - Evidence format: test output below ## Verifier Coverage Matrix (Required) | Item | Evidence | Status (PASS/FAIL/NOT_OBSERVED) | |---|---|---| | REQ-OPS-001 | test_runtime_verify_monitor_survives_when_no_live_pid PASS | PASS | | TASK-OPS-001 | 1081 tests passed, docs sync OK | PASS | | TEST-OPS-001 | 4 new governance tests + 1 pipefail regression test | PASS | `NOT_OBSERVED`가 1개라도 있으면 승인/머지 금지. ## Gitea Preflight - [x] `docs/commands.md`와 `docs/workflow.md` 트러블슈팅 선확인 - [x] `tea` 사용 (`gh` 미사용) ## Session Handover Gate - [x] `python3 scripts/session_handover_check.py --strict` 통과 - [x] `workflow/session-handover.md` 최신 엔트리 갱신 - 최신 handover 엔트리 heading: `### 2026-03-04 | session=claude-issues412-413-414` ## Docs Sync Gate (docs 파일 변경 시 필수) - [x] `python3 scripts/validate_docs_sync.py` 통과 ## Runtime Evidence - 시스템 실제 구동 커맨드: `pytest -q` (1081 passed) - 모니터링 로그 경로: N/A (unit tests) - 이상 징후/이슈 링크: #412, #413, #414 ## READ-ONLY Approval (Required when touching READ-ONLY files) - Touched READ-ONLY files: N/A (src/core/risk_manager.py 미변경) - Human approval: N/A - Test suite 1: N/A - Test suite 2: N/A ## Approval Gate - [ ] Static Verifier approval comment linked - [ ] Runtime Verifier approval comment linked
agentson added 1 commit 2026-03-04 23:27:49 +09:00
fix: #412/#413/#414 runtime stability and PR governance preflight
All checks were successful
Gitea CI / test (push) Successful in 38s
Gitea CI / test (pull_request) Successful in 38s
4200575c8e
## #413 — runtime_verify_monitor.sh pipefail fix
- find_live_pids() now captures pgrep output via local variable with || true
  so pipefail never triggers on no-match (pgrep exit 1)
- Regression test added: monitor survives MAX_LOOPS=1 without crash

## #412 — startup crash logging improvement
- Add asyncio.CancelledError catch in sync_positions_from_broker call
  so BaseException-level cancellations are logged before propagating
- Provides evidence in run log if CancelledError causes future startup aborts

## #414 — PR governance preflight
- validate_pr_body.py: add REQ-ID/TASK-ID/TEST-ID pattern checks (--no-governance flag to skip)
- docs/workflow.md: new "PR Governance Preflight (Mandatory)" section
- docs/commands.md: "PR Body Governance Preflight" section before tea pulls create
- Tests: 4 new governance traceability tests in test_validate_pr_body.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
jihoson approved these changes 2026-03-04 23:28:41 +09:00
Author
Collaborator

리뷰 코멘트 남깁니다.

  • Severity: Medium
  • 파일: scripts/validate_pr_body.py (거버넌스 ID 검사)
  • 이슈: REQ/TASK/TEST ID를 코드블록/인라인 코드에만 넣어도 검증이 통과합니다.

재현:

cat >/tmp/pr_body_spoof.md <<'EOT'
## Summary
- no governance IDs in narrative

```text
REQ-FAKE-999
TASK-FAKE-999
TEST-FAKE-999

EOT
python3 scripts/validate_pr_body.py --body-file /tmp/pr_body_spoof.md

[OK] PR body validation passed


의도대로 traceability를 강제하려면, ID 매칭도 `_strip_code_segments()` 결과(코드 영역 제외 텍스트) 기준으로 검사하는 것이 안전합니다.
리뷰 코멘트 남깁니다. - Severity: Medium - 파일: `scripts/validate_pr_body.py` (거버넌스 ID 검사) - 이슈: REQ/TASK/TEST ID를 코드블록/인라인 코드에만 넣어도 검증이 통과합니다. 재현: ```bash cat >/tmp/pr_body_spoof.md <<'EOT' ## Summary - no governance IDs in narrative ```text REQ-FAKE-999 TASK-FAKE-999 TEST-FAKE-999 ``` EOT python3 scripts/validate_pr_body.py --body-file /tmp/pr_body_spoof.md # [OK] PR body validation passed ``` 의도대로 traceability를 강제하려면, ID 매칭도 `_strip_code_segments()` 결과(코드 영역 제외 텍스트) 기준으로 검사하는 것이 안전합니다.
Author
Collaborator

보정 코멘트(포맷 정리):

  • Severity: Medium
  • 파일: scripts/validate_pr_body.py (거버넌스 ID 검사)
  • 이슈: REQ/TASK/TEST ID를 코드블록/인라인 코드에만 넣어도 검증 통과

재현:

cat >/tmp/pr_body_spoof.md <<'EOT'
## Summary
- no governance IDs in narrative

```text
REQ-FAKE-999
TASK-FAKE-999
TEST-FAKE-999
```
EOT
python3 scripts/validate_pr_body.py --body-file /tmp/pr_body_spoof.md
# [OK] PR body validation passed

권장 수정:

  • ID 매칭도 _strip_code_segments() 결과(코드 영역 제외 텍스트) 기준으로 수행
보정 코멘트(포맷 정리): - Severity: Medium - 파일: `scripts/validate_pr_body.py` (거버넌스 ID 검사) - 이슈: REQ/TASK/TEST ID를 코드블록/인라인 코드에만 넣어도 검증 통과 재현: ````bash cat >/tmp/pr_body_spoof.md <<'EOT' ## Summary - no governance IDs in narrative ```text REQ-FAKE-999 TASK-FAKE-999 TEST-FAKE-999 ``` EOT python3 scripts/validate_pr_body.py --body-file /tmp/pr_body_spoof.md # [OK] PR body validation passed ```` 권장 수정: - ID 매칭도 `_strip_code_segments()` 결과(코드 영역 제외 텍스트) 기준으로 수행
agentson added 1 commit 2026-03-04 23:37:13 +09:00
fix: governance ID check must ignore code blocks (review #415)
All checks were successful
Gitea CI / test (push) Successful in 38s
Gitea CI / test (pull_request) Successful in 38s
01e4e0f43f
REQ/TASK/TEST ID 패턴 매칭을 _strip_code_segments() 결과에 적용하여
코드 펜스/인라인 코드 안에만 ID를 넣어 검증을 우회하는 케이스를 차단.

회귀 테스트 추가: test_validate_pr_body_text_rejects_governance_ids_in_code_block_only

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
Collaborator

리뷰 반영 완료 (commit 01e4e0f)

  • 지적 사항: REQ/TASK/TEST ID가 코드블록/인라인 코드에만 있어도 검증 통과
  • 수정: ID 패턴 매칭을 _strip_code_segments() 결과 기준으로 변경
  • 테스트: test_validate_pr_body_text_rejects_governance_ids_in_code_block_only 추가 (1082 passed)
리뷰 반영 완료 (commit 01e4e0f) - **지적 사항**: REQ/TASK/TEST ID가 코드블록/인라인 코드에만 있어도 검증 통과 - **수정**: ID 패턴 매칭을 _strip_code_segments() 결과 기준으로 변경 - **테스트**: test_validate_pr_body_text_rejects_governance_ids_in_code_block_only 추가 (1082 passed)
Author
Collaborator

추가 리뷰 코멘트 남깁니다.

  • Severity: Medium
  • 파일: scripts/validate_pr_body.py
  • 이슈: 거버넌스 ID(REQ/TASK/TEST) 검증이 코드 블록/인라인 코드에 있는 값도 인정해서 우회 가능합니다.

재현 결과:

  • 본문 설명에는 ID가 없고 코드블록에만 REQ-FAKE-999/TASK-FAKE-999/TEST-FAKE-999를 넣어도 validate_pr_body.py --body-file ...가 통과합니다.

권장:

  • ID 검증도 _strip_code_segments() 결과(코드 영역 제외 텍스트) 기준으로 수행해주세요.
추가 리뷰 코멘트 남깁니다. - Severity: Medium - 파일: `scripts/validate_pr_body.py` - 이슈: 거버넌스 ID(REQ/TASK/TEST) 검증이 코드 블록/인라인 코드에 있는 값도 인정해서 우회 가능합니다. 재현 결과: - 본문 설명에는 ID가 없고 코드블록에만 `REQ-FAKE-999`/`TASK-FAKE-999`/`TEST-FAKE-999`를 넣어도 `validate_pr_body.py --body-file ...`가 통과합니다. 권장: - ID 검증도 `_strip_code_segments()` 결과(코드 영역 제외 텍스트) 기준으로 수행해주세요.
jihoson merged commit a60c14433a into main 2026-03-04 23:43:36 +09:00
jihoson deleted branch feature/issue-412-413-414-runtime-and-governance 2026-03-04 23:43:36 +09:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jihoson/The-Ouroboros#415