Files
FESADev/phases/mitc4-shell-feast-eigen-execution-prep/step0.md
T
2026-09-06 05:37:30 +09:00

143 lines
11 KiB
Markdown

# Step 0: 유한 실행시간 조정과 정상 검증 경로 보존
- Feature ID: `mitc4-shell-feast-eigen`
- Plan owner: `implementation-planning-agent`
- Execution owner: `implementation-agent`
- Input contract revision: `r2`
- Phase: `mitc4-shell-feast-eigen-execution-prep`
- Requirement: `FEM-REQ-MITC4-EIGEN-023/025`; `MFE-C27`, `IO-T11`
- 이 Step은 운영준비이고 solver physics/C++ 기능 변경이 아니다.
## 필수 입력
Feature 폴더 `docs/mitc4-shell-feast-eigen/`와 다음 management/approved bundle을 읽는다.
- [AGENTS.md](../../AGENTS.md)
- [docs/SOLVER_AGENT_DESIGN.md](../../docs/SOLVER_AGENT_DESIGN.md)
- [docs/FEATURE_DOCUMENTATION.md](../../docs/FEATURE_DOCUMENTATION.md)
- [docs/PRD.md](../../docs/PRD.md)
- [docs/ARCHITECTURE.md](../../docs/ARCHITECTURE.md)
- [docs/ADR.md](../../docs/ADR.md)
- [docs/CODINGSTYLE.md](../../docs/CODINGSTYLE.md)
- [docs/TOLERANCE.md](../../docs/TOLERANCE.md)
- [.codex/skills/fem-implementation-tdd/SKILL.md](../../.codex/skills/fem-implementation-tdd/SKILL.md)
- [.agents/skills/harness/SKILL.md](../../.agents/skills/harness/SKILL.md)
- [.codex/agents/implementation-agent.toml](../../.codex/agents/implementation-agent.toml)
- [docs/mitc4-shell-feast-eigen/FEATURED_AGENTS.md](../../docs/mitc4-shell-feast-eigen/FEATURED_AGENTS.md)
- [docs/mitc4-shell-feast-eigen/PRD.md](../../docs/mitc4-shell-feast-eigen/PRD.md)
- [docs/mitc4-shell-feast-eigen/ADR.md](../../docs/mitc4-shell-feast-eigen/ADR.md)
- [docs/mitc4-shell-feast-eigen/coordination.md](../../docs/mitc4-shell-feast-eigen/coordination.md)
- [docs/mitc4-shell-feast-eigen/requirements.md](../../docs/mitc4-shell-feast-eigen/requirements.md)
- [docs/mitc4-shell-feast-eigen/requirements-evidence.md](../../docs/mitc4-shell-feast-eigen/requirements-evidence.md)
- [docs/mitc4-shell-feast-eigen/research.md](../../docs/mitc4-shell-feast-eigen/research.md)
- [docs/mitc4-shell-feast-eigen/research-evidence.md](../../docs/mitc4-shell-feast-eigen/research-evidence.md)
- [docs/mitc4-shell-feast-eigen/formulation.md](../../docs/mitc4-shell-feast-eigen/formulation.md)
- [docs/mitc4-shell-feast-eigen/formulation-mass.md](../../docs/mitc4-shell-feast-eigen/formulation-mass.md)
- [docs/mitc4-shell-feast-eigen/formulation-eigen.md](../../docs/mitc4-shell-feast-eigen/formulation-eigen.md)
- [docs/mitc4-shell-feast-eigen/formulation-verification.md](../../docs/mitc4-shell-feast-eigen/formulation-verification.md)
- [docs/mitc4-shell-feast-eigen/formulation-stabilization.md](../../docs/mitc4-shell-feast-eigen/formulation-stabilization.md)
- [docs/mitc4-shell-feast-eigen/numerical-review.md](../../docs/mitc4-shell-feast-eigen/numerical-review.md)
- [docs/mitc4-shell-feast-eigen/numerical-review-evidence.md](../../docs/mitc4-shell-feast-eigen/numerical-review-evidence.md)
- [docs/mitc4-shell-feast-eigen/numerical-review-controls.md](../../docs/mitc4-shell-feast-eigen/numerical-review-controls.md)
- [docs/mitc4-shell-feast-eigen/numerical-review-cases.md](../../docs/mitc4-shell-feast-eigen/numerical-review-cases.md)
- [docs/mitc4-shell-feast-eigen/reference-model.md](../../docs/mitc4-shell-feast-eigen/reference-model.md)
- [docs/mitc4-shell-feast-eigen/io.md](../../docs/mitc4-shell-feast-eigen/io.md)
- [docs/mitc4-shell-feast-eigen/io-input.md](../../docs/mitc4-shell-feast-eigen/io-input.md)
- [docs/mitc4-shell-feast-eigen/io-schema.md](../../docs/mitc4-shell-feast-eigen/io-schema.md)
- [docs/mitc4-shell-feast-eigen/io-mapping.md](../../docs/mitc4-shell-feast-eigen/io-mapping.md)
- [docs/mitc4-shell-feast-eigen/implementation-plan.md](../../docs/mitc4-shell-feast-eigen/implementation-plan.md)
- [docs/mitc4-shell-feast-eigen/implementation-environment.md](../../docs/mitc4-shell-feast-eigen/implementation-environment.md)
- [docs/mitc4-shell-feast-eigen/implementation-interfaces.md](../../docs/mitc4-shell-feast-eigen/implementation-interfaces.md)
- [docs/mitc4-shell-feast-eigen/implementation-verification.md](../../docs/mitc4-shell-feast-eigen/implementation-verification.md)
추가 필수: [현재 Executor](../../scripts/execute.py), [등록 hooks](../../.codex/hooks.json),
[Stop](../../scripts/hooks/stop_validation.py), [CommandSpec](../../scripts/msvc_harness/models.py),
[process](../../scripts/msvc_harness/process.py), [config](../../scripts/msvc_harness/config.py),
[CMake adapter](../../scripts/msvc_harness/adapters/cmake.py), [HARNESS](../../docs/HARNESS.md),
[WORKFLOW](../../docs/HARNESS_WORKFLOW.md), [환경·activation 상세](../../docs/mitc4-shell-feast-eigen/implementation-environment.md).
현재 config schema에는 timeout option이 없다. 이번에 새 config field를 만들지 않는다.
## Owned paths
```json
[
"scripts/execute.py",
".codex/hooks.json",
"scripts/hooks/stop_validation.py",
"scripts/msvc_harness/models.py",
"scripts/msvc_harness/process.py",
"tests/test_execute.py",
"tests/test_harness_timeouts.py",
"docs/HARNESS_WORKFLOW.md",
"docs/mitc4-shell-feast-eigen/implementation-prep-evidence.md"
]
```
타 owner 변경을 보존한다. `docs/HARNESS_WORKFLOW.md`는 실제 deadline 값의 설명 문단만 수정하고 workflow/approval/Git/Hook 계약을 바꾸지 않는다.
## RED
먼저 `tests/test_harness_timeouts.py`를 작성한다. 실제 hook를 수동 실행하지 않고 기존 Python tests 방식으로 clock/subprocess/adapter를 주입한다.
1. `StepExecutor._invoke_codex`가 기본14400초를 전달함과 실제 TimeoutExpired가 terminal result 없을 때만 최대2번 재시도되는 것을 검사한다. 기존 `tests/test_execute.py`의1800 message 기대값은 승인 default14400으로 갱신하되 explicit injected1800 exception의 actual timeout message는 그대로 구분한다.
2. `stop_validation.run_validations`에서 새 shared deadline7200이 discovery/toolchain/execute_plan까지 같은 deadline으로 전달되는지 검사한다. Hook entry/reentry/doc-only 정책은 기존 tests로 보존한다.
3. `CommandSpec` default7200 및 `execute_plan` 자체 default7200을 검사한다. Fake elapsed2000 뒤 다음 command cap이 remaining5200이고 explicit cap5이면5를 유지하는지, deadline 만료·nonzero subprocess가 계속 failure인지 확인한다. 실제 대기는 하지 않는다.
4. 등록 Stop timeout7500이 shared7200보다 크며 command/matcher/PreToolUse timeout30이 그대로인지 검사한다. Executor14400>registered7500 관계와 finite positive 값을 확인한다.
5. One-time module invocation은 딱 `StepExecutor.CODEX_TIMEOUT_SECONDS`만 유한14400으로 지정하고 unchanged `execute.main()`을 호출한다는 계약을 mock entry로 검사한다. Sandbox modes/default, MAX_TRANSPORT_ATTEMPTS, ownership/preflight/branch/commit/terminal result는 기존 tests를 유지한다.
```powershell
uv run --with pytest python -B -m pytest -v -rs tests/test_harness_timeouts.py
```
Actual nonzero exit와 기존1800 기본값 때문에 실패한 assertions를 기록한다. Import/setup/인증 오류는 RED가 아니다.
## Minimal GREEN
변경은 아래 다섯 runtime 설정의 literal default와 필요한 설명에 한정한다.
| 파일 / symbol | 기존 | 새 값 |
| --- | ---: | ---: |
| scripts/execute.py / StepExecutor.CODEX_TIMEOUT_SECONDS | 1800 | 14400 |
| .codex/hooks.json / Stop command timeout | 1800 | 7500 |
| scripts/hooks/stop_validation.py / TOTAL_TIMEOUT_SECONDS | 1800 | 7200 |
| scripts/msvc_harness/models.py / CommandSpec.timeout_seconds | 1800 | 7200 |
| scripts/msvc_harness/process.py / execute_plan total_timeout_seconds default | 1800 | 7200 |
`min(command cap, shared remaining)` 알고리즘은 그대로 둔다. 다른 함수·sandbox·transport/Coordinator retry·Hook scope/active flags·ownership/Git/API를 변경하지 않는다. `docs/HARNESS_WORKFLOW.md`의 이전1800 설명은 위 유한 deadline/새 process activation을 정확히 반영한다. Config field/환경변수/새 public CLI timeout option은 만들지 않는다.
## Focused VERIFY
```powershell
uv run --with pytest python -B -m pytest -v -rs tests/test_harness_timeouts.py tests/test_execute.py tests/test_execute_ownership.py tests/test_hook_validation_scope.py tests/test_harness_preset_contract.py
```
Exit0, failures0, 현재 sandbox/terminal/ownership regressions 보존을 확인한다. PreToolUse/Stop unit tests는 mock 테스트이고 실제 등록 Stop 통과 evidence가 아니다.
## Full VERIFY
```powershell
cmake -S . -B .harness/build -A x64
if ($LASTEXITCODE -ne 0) { throw 'configure failed' }
cmake --build .harness/build --config Debug
if ($LASTEXITCODE -ne 0) { throw 'build failed' }
ctest --test-dir .harness/build -C Debug --show-only=json-v1
if ($LASTEXITCODE -ne 0) { throw 'discovery failed' }
ctest --test-dir .harness/build -C Debug --output-on-failure
if ($LASTEXITCODE -ne 0) { throw 'full CTest failed' }
uv run --with pytest python -B -m pytest -v -rs
if ($LASTEXITCODE -ne 0) { throw 'full pytest failed' }
```
C++는 수정하지 않는다. 기존 same-binary cache를 쓰는 helper와 항상 fresh solver를 호출하는 nonlinear helper를 구별한다. 모든 full CTest를 실제 실행하고 완결 count/exit/duration을 기록한다. Cached outputs를 이번 eigen 신규 검증이라고 부르지 않는다. 등록 Stop도 정상 수행하며 full VERIFY를 생략/분할 성공으로 대체하지 않는다.
현재 prep Executor와 Codex의 activation 경계는 [environment](../../docs/mitc4-shell-feast-eigen/implementation-environment.md)대로다. 이미 실행 중인 Executor timeout self-edit는 활성화되지 않으며 launch-time Stop outer1800이 유지될 수 있다. 성공을 가정하지 말고 actual registered Stop·Codex exit0을 gate로 확인한다. 등록 Stop 초과/실패 시 정상 terminal evidence와 원시 로그를 보존해 Coordinator에 반환한다. Hook 직접 실행, 재진입 flag/state 조작, 거짓 Markdown-only skip으로 우회하지 않는다.
## Evidence / result
`docs/mitc4-shell-feast-eigen/implementation-prep-evidence.md`에 feature/owner/r2, 각 RED/GREEN command/exit/duration, 전체 pytest/CTest counts, cap before/after, 실제 code diff 범위, current loaded wrapper14400과 등록 Stop launch1800 가능성, 그 시점에 관찰된 Stop/Codex exit 또는 아직 확인 대기인 항목을 기록한다. Raw logs는 ignored `.harness/build/mitc4-eigen-evidence/prep/`다. CTest log는 즉시 복사 보존한다.
보고서 작성 시점에는 마지막 registered Stop/Codex exit가 아직 발생하지 않을 수 있다. Implementation은 실제 완료된 manual 검증과 미관찰 Stop을 구분하고 미래 성공을 선기록하지 않는다. `completed` payload는 그 자체로 Stop 성공 증거가 아니다. Executor 종료 뒤 Coordinator가 raw output·등록 Hook evidence·actual exit를 management 문서에서 사후 감사한다. Specialist 보고서 본문은 Coordinator가 대신 수정하지 않는다.
이 Step의 manual AC가 통과하면 현재 phase index Step0의 `completed/summary`만 기록한다. 실패는 `error/error_message` 또는 `blocked/blocked_reason`이며 attempt_history/timestamps/다른Step/top index는 건드리지 않는다. 최종 phase commit/branch/checkpoint는 Executor가 수행한다. 마지막 응답은 common envelope다. Main invocation은 prep Executor의 실제 종료·completed·registered Stop 성공·actual Codex exit0·code/control commit·clean 및 Coordinator 사후 감사 완료 후 Coordinator가 새 process로 시작한다.