feat(stage2): run S2_00 through inline MCP

Replace the unresolved host-loader invocation with one hash-bound Code Executor task so deterministic ingress has a concrete Agent execution path.\n\nBREAKING CHANGE: S2_00 no longer invokes stage2_loader.py. The legacy loader binding is reference-only and cannot authorize or provide fallback.
This commit is contained in:
2026-08-30 16:37:43 +09:00
parent 388a6c0179
commit 1b7d2d3a09
30 changed files with 21903 additions and 711 deletions
@@ -0,0 +1,142 @@
# Stage 2 v5 MCP Code Executor 전환
## Objective
Stage 2 v4의 5-workflow 법률·IO 구조를 보존하면서 deterministic task의 실행 방식을
외부 native `.py` adapter(O-06)에서 AgentBackend가 이미 지원하는 MCP Code Executor
inline Python으로 전환한다. `stage_2_optimal_update_strategy_v.5.md`,
`S_00_SOW_v.1.md`, `S2_00_assets_v.1.md`, `Stage_2_S2_00_v.1.yml`과 필요한
`Default_Agent/Stage_2_Clean/` 자산을 일관되게 생성·개정한다.
## Deliverables
- `YAML_Prompts/2. Stage_2/stage_2_optimal_update_strategy_v.5.md`
- `YAML_Prompts/2. Stage_2/S_00_SOW_v.1.md`
- `YAML_Prompts/2. Stage_2/S2_00_assets_v.1.md`
- `YAML_Prompts/2. Stage_2/Stage_2_S2_00_v.1.yml`
- 위 inventory가 지정하는 version-free `Default_Agent/Stage_2_Clean/` 개정·신규 자산
- `YAML_Prompts/2. Stage_2/MEMORY.md` 압축 기록
## Scope and Non-Scope
- 범위: S2_00 inline deterministic code, localdocs session/격리, release/hash contract,
schema·manifest·test·workflow 자산, S2_10/S2_40 handoff 계약.
- 비범위: S2_10 이후 LLM 법률판단의 실제 실행, 외부 Code Executor live 호출,
Stage 1 live case run, canary/production 서명·법률가 승인.
- 기존 v4/SOW/assets/YAML은 변경하지 않고 새 버전 파일을 만든다.
- 기존 Stage 2 v.0~v.3 runtime dependency는 계속 0으로 유지한다.
## Known Inputs
- `YAML_Prompts/2. Stage_2/stage_2_optimal_update_strategy_v.4.md`
- `YAML_Prompts/2. Stage_2/S_00_SOW.md`
- `YAML_Prompts/2. Stage_2/S2_00_assets.md`
- `YAML_Prompts/2. Stage_2/Stage_2_S2_00.yml`
- `YAML_Prompts/2. Stage_2/S2_00_yaml_구현_QA.txt`
- `YAML_Prompts/2. Stage_2/SKILL.md`
- `YAML_Prompts/2. Stage_2/test_code_executor.ipynb`
- `YAML_Prompts/1. Stage_1/v.8/stage_1_part_{1..4}_v.8.yml`
- `YAML_Prompts/2. Stage_2/Default_Agent/Stage_2_Clean/`
## Material Assumptions
- 사용자의 이번 지시는 기존 SOW의 inline code-executor 기각 결정을 명시적으로
대체한다.
- AgentBackend가 문서화한 `mcp: code-executor`, `tool_name: run_code` task는
실행 가능한 승인 primitive로 취급한다.
- localdocs 접근은 `{{__user_hash__}}`와 `{{__workspace_hash__}}`를 포함한
`SKILL.md` 전체 boilerplate를 사용한다.
- 외부 live MCP 실행은 별도 네트워크·운영 권한과 실제 workspace 입력이 필요하므로
이번 완료 조건은 strict static validation과 local/mock regression이다.
## Questions That Could Change the Outcome
- inline source를 단일 task에 완전 삽입할지 C00/C05/C10/C15 여러 task로 나눌지는
Stage 1 실물 grammar, output 전달 한계와 atomic publish 계약을 대조한 뒤 확정한다.
- 기존 `stage2_loader.py`와 `runtime/s2_00_ingress.py`는 runtime dependency에서
제거하되, test oracle/migration source로 유지할지 manifest에서 완전히 제외할지
자산 delta 조사 후 결정한다.
## Workstreams and Dependencies
1. Stage 1 code-executor grammar와 현행 S2_00 계약·자산 delta 조사.
2. v5 → SOW_v1/assets_v1 순서의 문서 초안.
3. 서로 다른 evaluator 2개를 사용한 문서 평가→main 개정, 정확히 2회.
4. inventory 기반 자산 구현과 실행 YAML 구현을 병렬 진행.
5. 생성·개정 자산별 독립 검증 정확히 1회; YAML 독립 검증→개정 정확히 2회.
6. syntax/schema/mock/regression/hash/경로/금지 edge 검증과 MEMORY 기록.
## Source and Tool Plan
- 로컬 정본과 실제 Stage 1 YAML을 우선한다.
- `rg`, strict YAML/JSON parser, AST compile, existing unittest, mock localdocs harness를
사용한다.
- 파일 편집은 `apply_patch`만 사용한다.
- sub-agent는 독립 조사·평가·자산별 검증에만 사용하고 최종 설계 병합은 main이 한다.
## Validation Plan
- YAML duplicate-key parse와 AgentBackend grammar/task DAG 확인
- 모든 code-executor task의 `language/python`, full code, timeout, network,
user/workspace binding, stdout single-JSON 확인
- inline Python 추출 후 AST compile 및 금지 import/call 검사
- localdocs mock을 통한 read/write/overwrite/path/NFC/SSE/Extra-data 처리 검사
- S2_00 16+1 ingress, C00→C05→C10→C15, normal 12/diagnostic 5,
route mutual exclusion, S2_40 single-writer 보존
- manifest/schema/hash closure와 구 v.0~v.3 dependency 0 확인
- 기존 `tests/s2_00` 및 신규 inline adapter regression 실행
## Approval Boundaries
- 요청된 로컬 문서·YAML·Default_Agent 자산만 변경한다.
- commit/push, 외부 MCP 호출, production admission·서명은 수행하지 않는다.
- dirty worktree의 무관 변경은 건드리지 않는다.
## Progress
- [x] MEMORY·AGENTS·PLANS·SKILL·notebook 확인
- [ ] Stage 1 grammar와 현행 asset delta 조사
- [ ] v5/SOW_v1/assets_v1 초안
- [ ] 문서 평가·개정 Round 1
- [ ] 문서 평가·개정 Round 2
- [ ] Default_Agent 자산 구현
- [ ] Stage_2_S2_00_v.1 YAML 구현
- [ ] 자산 1회·YAML 2회 검증
- [ ] 최종 회귀검사·MEMORY
## Decision Log
- 2026-08-30: v5 execution TCB is `AgentBackend -> code-executor.run_code -> static inline Python -> user/workspace-bound localdocs`; O-06 native loader is superseded.
- 2026-08-30: One Code Executor task owns C00→C05→C10→C15. Splitting is deferred because intermediate artifacts would enlarge transport and weaken one-receipt semantics.
- 2026-08-30: The current filesystem core is retained as a test/parity oracle only. Runtime execution must not read/import `runtime/s2_00_ingress.py` or call `stage2_loader.py`.
- 2026-08-30: localdocs lacks a documented atomic directory rename contract. v1 uses byte write/read-back plus `ingress_status.json` last as a logical commit barrier.
- 2026-08-30: New YAML must not duplicate the plaintext bearer credential found in historical Stage 1/notebook sources. Live status remains pending backend secret binding.
- 2026-08-30: Timeout target is 300 seconds, subject to live representative benchmark and request-size admission.
| Date/Stage | Decision | Basis | Consequence |
|---|---|---|---|
| 2026-08-30 / 착수 | O-06 native adapter 방식을 MCP Code Executor inline task로 대체 | 사용자 명시적 목표와 `SKILL.md`의 지원 grammar | v5가 이전 SOW의 inline-code 기각을 명시적으로 supersede해야 함 |
| 2026-08-30 / 착수 | 외부 live 실행과 production-ready 주장은 완료 범위에서 제외 | 실제 user workspace와 운영 Code Executor admission 증거 부재 | static/mock 검증과 live E2E 경계를 문서마다 명시 |
## Evidence Ledger
| Claim/Issue | Source or Test | Status | Notes |
|---|---|---|---|
| AgentBackend inline task grammar | `SKILL.md` §3.3 | 확인 | `mcp: code-executor`, `tool_name: run_code`, `parameters.code` |
| workspace 격리 | `SKILL.md` §5·§5.2 | 확인 | hash template 포함 full localdocs init 필요 |
| prior inline rejection | `S_00_SOW.md` §14 | superseded 예정 | 사용자 지시로 v1에서 대체 |
| current YAML non-executable | `Stage_2_S2_00.yml` | 확인 | `tasks: []`, O-06 OPEN |
| fixed runtime 규모 | `runtime/s2_00_ingress.py` | 확인 | 5,134행; inline 구조 최적화 필요 |
## Risks and Failure Modes
- YAML source와 기존 `.py`가 이중 정본이 되는 drift
- code-executor가 local filesystem을 공유한다고 잘못 가정하는 오류
- localdocs text transport가 raw-byte digest 의미를 바꾸는 오류
- YAML parser/template renderer가 Python braces를 오인하는 오류
- 인라인 코드가 너무 커져 AgentBackend payload·timeout 한도를 넘는 위험
- mock PASS를 live Code Executor E2E로 과장하는 위험
## Results and Residual Uncertainty
작업 완료 시 파일 수·hash·검증 결과와 live 경계를 기록한다.