feat: iop-agent-run-bridge milestone implementation
- Add agent-task directory for m-iop-agent-run-bridge with plan and code review docs - Update PHASE.md for agent-shell-iop-execution - Add worker runner and test implementations
This commit is contained in:
parent
144a5e1561
commit
cdf7007a3a
7 changed files with 861 additions and 1 deletions
|
|
@ -18,7 +18,7 @@ workspace 상위 sibling 프로젝트 `../agent-shell`을 제품 비종속 Flutt
|
|||
- 경로: `agent-roadmap/archive/phase/agent-shell-iop-execution/milestones/agent-shell-package-iop-backend-boundary.md`
|
||||
- 요약: `../agent-shell`은 Flutter agent UI/package로 사용하고, backend/runtime owner는 `../iop` 프로젝트로 지정한다.
|
||||
|
||||
- [계획] IOP Agent Run Bridge
|
||||
- [진행중] IOP Agent Run Bridge
|
||||
- 경로: `agent-roadmap/phase/agent-shell-iop-execution/milestones/iop-agent-run-bridge.md`
|
||||
- 요약: IOP backend가 수행한 agent run 결과를 Gito의 Git operation과 event 원장으로 수렴시키는 계약을 만든다.
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,147 @@
|
|||
<!-- task=m-iop-agent-run-bridge/03_commit_push_policy plan=0 tag=API -->
|
||||
|
||||
# Code Review Reference - API
|
||||
|
||||
> **[IMPLEMENTING AGENT — READ FIRST] Filling in this file is the mandatory final step of implementation.**
|
||||
> The task is NOT complete until every implementation-owned section below is filled in.
|
||||
> Complete the `구현 체크리스트`; the final checklist item is mandatory before saving.
|
||||
> Fill implementation-owned sections, then stop with active files in place and report ready for review.
|
||||
> If implementation is blocked by a user-only decision, user-owned external environment prerequisite, or scope conflict, fill `사용자 리뷰 요청` with evidence and stop with active files in place; code-review decides whether to write `USER_REVIEW.md`. Evidence gaps that a follow-up agent can close by rerunning commands or collecting artifacts are normal follow-up issues, not user-review blockers by themselves.
|
||||
> Do not ask the user directly, present choices in chat, or call `request_user_input` during implementation; record the needed decision in `사용자 리뷰 요청` and stop for code-review.
|
||||
> Finalization (`코드리뷰 결과`, log rename, `complete.log`, archive moves, `코드리뷰 전용 체크리스트`) is review-agent-only, even after compaction/resume.
|
||||
> Follow the ownership table at the bottom of this file for which sections you own.
|
||||
|
||||
## 개요
|
||||
|
||||
date=2026-06-16
|
||||
task=m-iop-agent-run-bridge/03_commit_push_policy, plan=0, tag=API
|
||||
|
||||
## Roadmap Targets
|
||||
|
||||
- Milestone: `agent-roadmap/phase/agent-shell-iop-execution/milestones/iop-agent-run-bridge.md`
|
||||
- Task ids:
|
||||
- `commit-push`: policy가 허용한 경우 commit/push operation으로 연결한다.
|
||||
- Completion mode: check-on-pass
|
||||
|
||||
## 이 파일을 읽는 리뷰 에이전트에게
|
||||
|
||||
> **[REVIEW AGENT ONLY]** 아래 종결 절차는 코드리뷰 에이전트 전용이다. 구현 에이전트는 이 섹션을 실행하지 않는다.
|
||||
|
||||
각 항목의 구현을 실제 소스 파일과 대조하고, `검증 결과` 섹션의 출력이 코드와 일치하는지 확인하세요.
|
||||
리뷰 완료는 아래 순서까지 끝난 상태를 의미합니다.
|
||||
|
||||
1. 판정을 append한다.
|
||||
2. `CODE_REVIEW-local-G06.md` → `code_review_local_G06_N.log`, `PLAN-local-G06.md` → `plan_local_G06_M.log`로 아카이브한다.
|
||||
3. PASS이면 `complete.log` 작성 후 active task 디렉터리를 `agent-task/archive/YYYY/MM/m-iop-agent-run-bridge/03_commit_push_policy/`로 이동한다. WARN/FAIL이면 user-review gate를 확인한 뒤 다음 active plan/review 파일 또는 `USER_REVIEW.md`를 작성한다. `USER_REVIEW.md`가 사용자 결정으로 완료/PASS 해소되면 code-review가 `USER_REVIEW.md`를 해소 상태로 갱신하고 `complete.log` 작성 후 archive 이동한다.
|
||||
4. PASS이고 task group이 `m-<milestone-slug>`이면 완료 이벤트 메타데이터를 보고한다. roadmap 상태 체크와 `update-roadmap` 호출은 런타임 책임이다.
|
||||
5. 적용 가능한 `코드리뷰 전용 체크리스트` 항목을 최종 `.log` 위치에서 체크한 뒤 보고한다.
|
||||
|
||||
---
|
||||
|
||||
## 구현 항목별 완료 여부
|
||||
|
||||
| 항목 | 완료 여부 |
|
||||
|------|---------|
|
||||
| [API-1] Agent run git result policy parsing | [ ] |
|
||||
| [API-2] Commit and push execution from worker | [ ] |
|
||||
|
||||
## 구현 체크리스트
|
||||
|
||||
- [ ] AgentRunInput `PolicyContext`에서 commit/push 허용 여부와 commit message/remote/branch를 안전하게 해석한다.
|
||||
- [ ] policy가 허용한 경우에만 `gitengine.Commit`과 `gitengine.Push`를 순서대로 호출하고, 실패 시 operation failed payload를 남긴다.
|
||||
- [ ] push 미허용 또는 dirty 상태에서는 기존 dirty guard 실패 동작을 유지한다.
|
||||
- [ ] worker unit test로 commit+push 성공, commit 실패, push 실패, push 미허용을 검증한다.
|
||||
- [ ] 계약 노트에 policy key를 추가했다면 contracts smoke를 실행한다.
|
||||
- [ ] `cd services/core && go test ./internal/worker`를 실행한다.
|
||||
- [ ] `cd services/core && go test ./...`를 실행한다.
|
||||
- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.
|
||||
|
||||
## 코드리뷰 전용 체크리스트
|
||||
|
||||
> **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다.
|
||||
> 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다.
|
||||
|
||||
- [ ] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다.
|
||||
- [ ] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다.
|
||||
- [ ] active `CODE_REVIEW-*-G??.md`를 `code_review_local_G06_N.log`로 아카이브한다.
|
||||
- [ ] active `PLAN-*-G??.md`를 `plan_local_G06_M.log`로 아카이브한다.
|
||||
- [ ] `.gitignore`의 Agent-Ops 관리 block이 `agent-task/**/*.md`와 `agent-task/**/*.log`를 unignore하고 `agent-roadmap/current.md`를 ignore하는지 확인한다.
|
||||
- [ ] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다.
|
||||
- [ ] PASS이면 active task 디렉터리 `agent-task/m-iop-agent-run-bridge/03_commit_push_policy/`를 `agent-task/archive/YYYY/MM/m-iop-agent-run-bridge/03_commit_push_policy/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다.
|
||||
- [ ] PASS이고 task group이 `m-<milestone-slug>`이면 런타임이 읽을 완료 이벤트 메타데이터를 보고하고, roadmap 수정이나 `update-roadmap` 직접 호출을 하지 않는다.
|
||||
- [ ] PASS split 작업이면 이동 후 빈 active parent `agent-task/m-iop-agent-run-bridge/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다.
|
||||
- [ ] WARN/FAIL이고 user-review gate가 트리거되지 않았으면 다음 active `PLAN-local-G06.md`와 `CODE_REVIEW-local-G06.md`를 작성하고 `complete.log`를 작성하지 않는다.
|
||||
- [ ] USER_REVIEW이면 `agent-ops/skills/common/code-review/templates/user-review-template.md` 기준으로 `USER_REVIEW.md`를 작성하고 active `PLAN-*.md`, `CODE_REVIEW-*.md`, `complete.log`를 남기지 않는다.
|
||||
- [ ] USER_REVIEW가 사용자 결정으로 완료/PASS 해소되면 `USER_REVIEW.md`를 해소 상태로 갱신하고 `complete.log`를 작성한 뒤 task directory를 archive로 이동한다.
|
||||
|
||||
## 계획 대비 변경 사항
|
||||
|
||||
_구현 에이전트가 계획과 다르게 구현한 부분을 이유와 함께 기록한다._
|
||||
|
||||
## 주요 설계 결정
|
||||
|
||||
_구현 에이전트가 주요 설계 결정 사항을 기록한다._
|
||||
|
||||
## 사용자 리뷰 요청
|
||||
|
||||
_기본값은 `없음`이다. 구현 중 사용자 결정, 사용자 소유 외부 환경/secret/서비스 준비, 또는 계획 범위 변경 없이는 안전하게 진행할 수 없으면 아래 항목을 실제 내용으로 교체하고, 구현을 중단한 뒤 active 파일을 그대로 둔 채 리뷰를 요청한다. 구현 에이전트는 사용자에게 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. 후속 에이전트가 명령 재실행이나 산출물 수집으로 해소할 수 있는 검증 증거 공백만으로는 사용자 리뷰 요청을 작성하지 않는다._
|
||||
|
||||
- 상태: 없음
|
||||
- 사유 유형: 없음
|
||||
- 결정 필요: 없음
|
||||
- 차단 근거: 없음
|
||||
- 실행한 검증/명령: 없음
|
||||
- 자동 후속 불가 이유: 없음
|
||||
- 재개 조건: 없음
|
||||
|
||||
## 리뷰어를 위한 체크포인트
|
||||
|
||||
- commit/push가 policy 허용 시에만 실행되는지 확인한다.
|
||||
- dirty guard 실패가 commit/push보다 먼저 적용되는지 확인한다.
|
||||
- payload가 credential, raw token, private endpoint를 기록하지 않는지 확인한다.
|
||||
- fake git call order가 실제 구현과 일치하는지 확인한다.
|
||||
|
||||
## 검증 결과
|
||||
|
||||
_구현 에이전트가 각 중간 검증 및 최종 검증 명령 실행 후 출력을 여기에 붙여 넣는다._
|
||||
|
||||
필수 규칙:
|
||||
- 검증 명령은 고정된 계약이다. 임의로 대체하지 않는다.
|
||||
- 대체가 필요하면 `계획 대비 변경 사항`에 이유와 대체 명령을 기록한다.
|
||||
- `검증 결과`에는 실제 stdout/stderr를 붙여 넣는다.
|
||||
- 사용자 리뷰 요청으로 명령을 끝까지 실행하지 못했다면 `사용자 리뷰 요청`에 실행한 명령, 실제 출력, 미실행 명령의 사유를 기록한다.
|
||||
- mobile/UI hang, timeout, 또는 2분 무진행은 blind retry를 중단하고 focused rerun 명령과 screenshot/window/UI-tree evidence path를 남기며, 불가능하면 정확한 사유를 남긴다.
|
||||
|
||||
### API-1 중간 검증
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./internal/worker
|
||||
```
|
||||
|
||||
### API-2 중간 검증
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./internal/worker
|
||||
```
|
||||
|
||||
### 최종 검증
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./internal/worker
|
||||
```
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./...
|
||||
```
|
||||
|
||||
계약 노트를 수정했다면 추가 실행:
|
||||
|
||||
```bash
|
||||
rg --sort path -n "proto-socket|REST|gRPC|ChangeRequest|Operation|Event|agent_shell|agent-shell|iop" packages/contracts README.md docs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section: completion table, implementation checklist, changes from plan, design decisions, and verification output?**
|
||||
> If anything is blank, go back and fill it in before saving this file.
|
||||
> Leave review-agent-only sections unchanged.
|
||||
|
|
@ -0,0 +1,228 @@
|
|||
<!-- task=m-iop-agent-run-bridge/03_commit_push_policy plan=0 tag=API -->
|
||||
|
||||
# Plan - API
|
||||
|
||||
## 이 파일을 읽는 구현 에이전트에게
|
||||
|
||||
이 계획은 구현 후 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 실제 내용과 검증 출력으로 채우는 것까지가 작업이다. 구현 에이전트는 검증을 실행하고 active 파일을 유지한 채 리뷰 준비 상태를 보고한다. 사용자만 결정할 수 있는 정책, 외부 secret, scope 충돌로 막히면 active review stub의 `사용자 리뷰 요청` 섹션에 정확한 결정, 근거, 실행 명령, 재개 조건을 남기고 멈춘다. 구현 중 채팅으로 사용자에게 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. 후속 에이전트가 재실행이나 산출물 수집으로 해소할 수 있는 검증 공백은 사용자 리뷰 요청이 아니다. 최종 archive, `complete.log`, roadmap 갱신은 code-review/runtime 책임이다.
|
||||
|
||||
## 배경
|
||||
|
||||
현재 agent run 성공 판정은 Git status와 revision evidence까지 수집하지만, policy가 허용한 commit/push 결과를 operation 흐름에 연결하지 않는다. `git-result` Epic의 `[commit-push]`는 IOP 실행 결과가 실제 Git operation 결과로 수렴되는 핵심 경계다. 이 계획은 concrete IOP CLI나 secret 주입 방식을 확정하지 않고, 이미 주입된 worktree/credential 환경에서 commit/push를 수행하는 최소 control-plane 정책을 구현한다.
|
||||
|
||||
## 사용자 리뷰 요청 흐름
|
||||
|
||||
구현 중 차단은 active `CODE_REVIEW-*-G??.md`의 `사용자 리뷰 요청` 섹션에 기록한다. 직접 사용자 프롬프트는 금지이며, code-review가 요청 타당성을 검증하고 실제 `USER_REVIEW.md` 작성을 소유한다.
|
||||
|
||||
## Roadmap Targets
|
||||
|
||||
- Milestone: `agent-roadmap/phase/agent-shell-iop-execution/milestones/iop-agent-run-bridge.md`
|
||||
- Task ids:
|
||||
- `commit-push`: policy가 허용한 경우 commit/push operation으로 연결한다.
|
||||
- Completion mode: check-on-pass
|
||||
|
||||
## 분석 결과
|
||||
|
||||
### 읽은 파일
|
||||
|
||||
- `agent-roadmap/current.md`
|
||||
- `agent-roadmap/phase/agent-shell-iop-execution/PHASE.md`
|
||||
- `agent-roadmap/phase/agent-shell-iop-execution/milestones/iop-agent-run-bridge.md`
|
||||
- `agent-ops/rules/project/rules.md`
|
||||
- `agent-ops/rules/project/domain/core/rules.md`
|
||||
- `agent-ops/rules/project/domain/contracts/rules.md`
|
||||
- `agent-ops/rules/project/domain/workspace-ops/rules.md`
|
||||
- `agent-ops/skills/common/plan/SKILL.md`
|
||||
- `agent-ops/skills/common/_templates/implementation-user-review-request-section.md`
|
||||
- `agent-test/local/rules.md`
|
||||
- `agent-test/local/core-smoke.md`
|
||||
- `agent-test/local/contracts-smoke.md`
|
||||
- `agent-test/local/workspace-ops-smoke.md`
|
||||
- `agent-contract/index.md`
|
||||
- `services/core/internal/worker/runner.go`
|
||||
- `services/core/internal/worker/runner_test.go`
|
||||
- `services/core/internal/gitengine/command.go`
|
||||
- `services/core/internal/storage/storage.go`
|
||||
- `services/core/internal/core/model.go`
|
||||
- `services/core/internal/events/events.go`
|
||||
- `services/core/internal/controlplane/runtime.go`
|
||||
- `services/core/internal/controlplane/runtime_test.go`
|
||||
- `packages/contracts/notes/gito-control-plane.md`
|
||||
|
||||
### 테스트 환경 규칙
|
||||
|
||||
- `test_env=local`; `agent-test/local/rules.md` 있음, 읽음.
|
||||
- 적용 profile: `agent-test/local/core-smoke.md`, `agent-test/local/contracts-smoke.md`, `agent-test/local/workspace-ops-smoke.md`.
|
||||
- core 필수 명령: `cd services/core && go test ./...`.
|
||||
- 계약 노트를 수정하면 필수 smoke: `rg --sort path -n "proto-socket|REST|gRPC|ChangeRequest|Operation|Event|agent_shell|agent-shell|iop" packages/contracts README.md docs`.
|
||||
- task artifact만 수정하는 workspace-ops 검증은 `rg --sort path -n "Gito|agent-shell|agent_shell|iop|gito-shell|control plane" README.md docs packages/contracts agent-roadmap -g '!agent-roadmap/archive/**'`.
|
||||
- 구조적 공백 없음. `<확인 필요>` 값 없음.
|
||||
|
||||
### 테스트 커버리지 공백
|
||||
|
||||
- `worker.Runner`가 policy 허용 시 commit/push를 호출하는 테스트가 없다. 새 fake git runner 기반 unit test가 필요하다.
|
||||
- commit 실패, push 실패, push 미허용 정책 테스트가 없다. 실패 경로는 operation failed와 sanitized payload를 검증해야 한다.
|
||||
- 실제 remote push integration은 secret/remote가 필요하므로 이 계획 범위에서는 unit smoke로 제한한다.
|
||||
|
||||
### 심볼 참조
|
||||
|
||||
- none. 기존 심볼 rename/remove 계획 없음.
|
||||
|
||||
### 분할 판단
|
||||
|
||||
- split decision policy를 적용했다.
|
||||
- 공유 task group: `m-iop-agent-run-bridge`.
|
||||
- `03_commit_push_policy`: commit/push policy와 worker/gitengine 연동. predecessor 없음.
|
||||
- `04+03_revision_scan_event`: push 후 revision scan event 연결. predecessor `03_commit_push_policy`의 `complete.log` 필요.
|
||||
- 두 작업은 push 성공 산출물이 scan event의 선행 조건이므로 분리한다. 기존 archive에 `01`, `02` 번호가 있어 dependency ambiguity를 피하려고 새 번호를 `03`, `04`로 잡았다.
|
||||
|
||||
### 범위 결정 근거
|
||||
|
||||
- IOP CLI 명령, profile/model, stdin/input-file 계약은 Milestone의 구현 잠금 결정 항목이라 제외한다.
|
||||
- IOP credential과 workspace별 secret 주입 방식은 제외한다. 이 계획은 이미 worktree에 Git credential이 준비된 상태에서 `git push`를 실행하는 경계만 다룬다.
|
||||
- provider PR/MR 생성, Flutter UI, Plane/Jira lifecycle은 Milestone 범위 제외에 따라 제외한다.
|
||||
- push 후 revision scan event는 다음 subtask `04+03_revision_scan_event`로 분리한다.
|
||||
|
||||
### 빌드 등급
|
||||
|
||||
- build=`local-G06`, review=`local-G06`. core worker 정책과 git command 호출이지만 변경 범위가 작고 fake runner unit test로 검증 가능하다.
|
||||
|
||||
## 구현 체크리스트
|
||||
|
||||
- [ ] AgentRunInput `PolicyContext`에서 commit/push 허용 여부와 commit message/remote/branch를 안전하게 해석한다.
|
||||
- [ ] policy가 허용한 경우에만 `gitengine.Commit`과 `gitengine.Push`를 순서대로 호출하고, 실패 시 operation failed payload를 남긴다.
|
||||
- [ ] push 미허용 또는 dirty 상태에서는 기존 dirty guard 실패 동작을 유지한다.
|
||||
- [ ] worker unit test로 commit+push 성공, commit 실패, push 실패, push 미허용을 검증한다.
|
||||
- [ ] 계약 노트에 policy key를 추가했다면 contracts smoke를 실행한다.
|
||||
- [ ] `cd services/core && go test ./internal/worker`를 실행한다.
|
||||
- [ ] `cd services/core && go test ./...`를 실행한다.
|
||||
- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.
|
||||
|
||||
### [API-1] Agent run git result policy parsing
|
||||
|
||||
#### 문제
|
||||
|
||||
[services/core/internal/worker/runner.go](/config/workspace/gito/services/core/internal/worker/runner.go:32)의 `AgentRunInput.PolicyContext`는 allowed result actions를 담을 수 있지만, 현재 [services/core/internal/worker/runner.go](/config/workspace/gito/services/core/internal/worker/runner.go:218)는 Git evidence만 수집하고 commit/push 허용 여부를 해석하지 않는다.
|
||||
|
||||
#### 해결 방법
|
||||
|
||||
`PolicyContext`에서 다음 transport-independent keys를 해석하는 작은 helper를 추가한다.
|
||||
|
||||
```go
|
||||
// before: runner.go:218
|
||||
completionExtra := map[string]any{"message": completionMessage}
|
||||
if terminalState == core.OperationSucceeded {
|
||||
evidence, evidenceErr := r.collectAgentRunGitEvidence(input)
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
```go
|
||||
// after
|
||||
policy := agentRunGitResultPolicyFrom(input.PolicyContext, input.Branch)
|
||||
completionExtra := map[string]any{"message": completionMessage}
|
||||
if terminalState == core.OperationSucceeded {
|
||||
evidence, evidenceErr := r.collectAgentRunGitEvidence(input)
|
||||
...
|
||||
completionExtra, terminalState, completionMessage = r.applyAgentRunGitResultPolicy(input, policy, evidence, completionMessage)
|
||||
}
|
||||
```
|
||||
|
||||
Suggested policy shape:
|
||||
|
||||
```go
|
||||
type agentRunGitResultPolicy struct {
|
||||
CommitPushAllowed bool
|
||||
CommitMessage string
|
||||
Remote string
|
||||
Branch string
|
||||
}
|
||||
```
|
||||
|
||||
Accept boolean `commit_push` or string list `allowed_result_actions` containing `commit_push`. Trim all strings. Default remote to `origin`, branch to `input.Branch`, and message to `agent run result: <operation_id>` when commit/push is allowed and no message is supplied.
|
||||
|
||||
#### 수정 파일 및 체크리스트
|
||||
|
||||
- [ ] `services/core/internal/worker/runner.go`: policy helper와 validation 추가.
|
||||
- [ ] `services/core/internal/worker/runner_test.go`: policy parsing이 observable한 success/failure 테스트 추가.
|
||||
- [ ] `packages/contracts/notes/gito-control-plane.md`: 새 policy keys를 사용하면 `AgentRunInput.policy_context` 설명 아래에 transport-independent 의미만 기록.
|
||||
|
||||
#### 테스트 작성
|
||||
|
||||
작성한다. `TestRunnerRunOnceAgentRunCommitPushesWhenPolicyAllows`에서 policy key, default remote, branch fallback, commit message를 검증한다.
|
||||
|
||||
#### 중간 검증
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./internal/worker
|
||||
```
|
||||
|
||||
기대: worker 패키지 테스트가 0 exit로 통과한다.
|
||||
|
||||
### [API-2] Commit and push execution from worker
|
||||
|
||||
#### 문제
|
||||
|
||||
[services/core/internal/gitengine/command.go](/config/workspace/gito/services/core/internal/gitengine/command.go:164)는 `Commit`, [services/core/internal/gitengine/command.go](/config/workspace/gito/services/core/internal/gitengine/command.go:177)는 `Push`를 이미 제공하지만, worker가 agent run result에 연결하지 않는다. [services/core/internal/storage/storage.go](/config/workspace/gito/services/core/internal/storage/storage.go:64)의 OperationStore는 별도 queued commit/push operation 생성을 지원하지만, worker는 현재 active agent_run의 terminal state만 처리한다.
|
||||
|
||||
#### 해결 방법
|
||||
|
||||
이번 subtask에서는 별도 queued operation을 만들지 말고, agent_run terminal handling 안에서 policy-allowed commit/push를 실행하고 payload에 결과를 남긴다. 별도 operation queue 생성은 durable orchestration을 키우므로 후속 확장으로 남긴다.
|
||||
|
||||
```go
|
||||
// after policy and clean evidence
|
||||
if policy.CommitPushAllowed {
|
||||
if err := gitengine.Commit(r.gitRunner, input.WorkspacePath, gitengine.CommitOptions{Message: policy.CommitMessage, All: true}); err != nil {
|
||||
return failedGitResultPayload(evidence, "git commit failed")
|
||||
}
|
||||
if err := gitengine.Push(r.gitRunner, input.WorkspacePath, policy.Remote, policy.Branch); err != nil {
|
||||
return failedGitResultPayload(evidence, "git push failed")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Payload fields should be boring and reviewable: `commit_push_allowed`, `commit_attempted`, `push_attempted`, `push_remote`, `push_branch`, `message`. Do not record raw credential values or command stderr that may contain secrets.
|
||||
|
||||
#### 수정 파일 및 체크리스트
|
||||
|
||||
- [ ] `services/core/internal/worker/runner.go`: commit/push execution path 추가.
|
||||
- [ ] `services/core/internal/worker/runner_test.go`: git call order 검증.
|
||||
- [ ] `packages/contracts/notes/gito-control-plane.md`: payload/policy wording이 필요하면 갱신.
|
||||
|
||||
#### 테스트 작성
|
||||
|
||||
작성한다. fake git runner call order는 `status`, `rev-parse`, `diff --name-status`, `add -A`, `commit -m`, `push` 순서를 기대한다. commit/push 실패 각각 operation failed와 sanitized message를 검증한다.
|
||||
|
||||
#### 중간 검증
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./internal/worker
|
||||
```
|
||||
|
||||
기대: worker 패키지 테스트가 0 exit로 통과한다.
|
||||
|
||||
## 수정 파일 요약
|
||||
|
||||
| 파일 | 항목 |
|
||||
| --- | --- |
|
||||
| `services/core/internal/worker/runner.go` | API-1, API-2 |
|
||||
| `services/core/internal/worker/runner_test.go` | API-1, API-2 |
|
||||
| `packages/contracts/notes/gito-control-plane.md` | API-1, API-2 |
|
||||
|
||||
## 최종 검증
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./internal/worker
|
||||
```
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./...
|
||||
```
|
||||
|
||||
계약 노트를 수정했다면 추가 실행:
|
||||
|
||||
```bash
|
||||
rg --sort path -n "proto-socket|REST|gRPC|ChangeRequest|Operation|Event|agent_shell|agent-shell|iop" packages/contracts README.md docs
|
||||
```
|
||||
|
||||
모든 코드 변경 완료 후 반드시 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 채운다. 이 파일 작성이 구현의 마지막 단계다.
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
<!-- task=m-iop-agent-run-bridge/04+03_revision_scan_event plan=0 tag=API -->
|
||||
|
||||
# Code Review Reference - API
|
||||
|
||||
> **[IMPLEMENTING AGENT — READ FIRST] Filling in this file is the mandatory final step of implementation.**
|
||||
> The task is NOT complete until every implementation-owned section below is filled in.
|
||||
> Complete the `구현 체크리스트`; the final checklist item is mandatory before saving.
|
||||
> Fill implementation-owned sections, then stop with active files in place and report ready for review.
|
||||
> If implementation is blocked by a user-only decision, user-owned external environment prerequisite, or scope conflict, fill `사용자 리뷰 요청` with evidence and stop with active files in place; code-review decides whether to write `USER_REVIEW.md`. Evidence gaps that a follow-up agent can close by rerunning commands or collecting artifacts are normal follow-up issues, not user-review blockers by themselves.
|
||||
> Do not ask the user directly, present choices in chat, or call `request_user_input` during implementation; record the needed decision in `사용자 리뷰 요청` and stop for code-review.
|
||||
> Finalization (`코드리뷰 결과`, log rename, `complete.log`, archive moves, `코드리뷰 전용 체크리스트`) is review-agent-only, even after compaction/resume.
|
||||
> Follow the ownership table at the bottom of this file for which sections you own.
|
||||
|
||||
## 개요
|
||||
|
||||
date=2026-06-16
|
||||
task=m-iop-agent-run-bridge/04+03_revision_scan_event, plan=0, tag=API
|
||||
|
||||
## Roadmap Targets
|
||||
|
||||
- Milestone: `agent-roadmap/phase/agent-shell-iop-execution/milestones/iop-agent-run-bridge.md`
|
||||
- Task ids:
|
||||
- `revision-event`: push 이후 revision scan event를 발행한다.
|
||||
- Completion mode: check-on-pass
|
||||
|
||||
## 이 파일을 읽는 리뷰 에이전트에게
|
||||
|
||||
> **[REVIEW AGENT ONLY]** 아래 종결 절차는 코드리뷰 에이전트 전용이다. 구현 에이전트는 이 섹션을 실행하지 않는다.
|
||||
|
||||
각 항목의 구현을 실제 소스 파일과 대조하고, `검증 결과` 섹션의 출력이 코드와 일치하는지 확인하세요.
|
||||
리뷰 완료는 아래 순서까지 끝난 상태를 의미합니다.
|
||||
|
||||
1. 판정을 append한다.
|
||||
2. `CODE_REVIEW-local-G06.md` → `code_review_local_G06_N.log`, `PLAN-local-G06.md` → `plan_local_G06_M.log`로 아카이브한다.
|
||||
3. PASS이면 `complete.log` 작성 후 active task 디렉터리를 `agent-task/archive/YYYY/MM/m-iop-agent-run-bridge/04+03_revision_scan_event/`로 이동한다. WARN/FAIL이면 user-review gate를 확인한 뒤 다음 active plan/review 파일 또는 `USER_REVIEW.md`를 작성한다. `USER_REVIEW.md`가 사용자 결정으로 완료/PASS 해소되면 code-review가 `USER_REVIEW.md`를 해소 상태로 갱신하고 `complete.log` 작성 후 archive 이동한다.
|
||||
4. PASS이고 task group이 `m-<milestone-slug>`이면 완료 이벤트 메타데이터를 보고한다. roadmap 상태 체크와 `update-roadmap` 호출은 런타임 책임이다.
|
||||
5. 적용 가능한 `코드리뷰 전용 체크리스트` 항목을 최종 `.log` 위치에서 체크한 뒤 보고한다.
|
||||
|
||||
---
|
||||
|
||||
## 구현 항목별 완료 여부
|
||||
|
||||
| 항목 | 완료 여부 |
|
||||
|------|---------|
|
||||
| [API-1] Revision scan interface after push | [ ] |
|
||||
| [API-2] Revision scan payload and failure behavior | [ ] |
|
||||
|
||||
## 구현 체크리스트
|
||||
|
||||
- [ ] 구현 시작 전 `03_commit_push_policy`의 `complete.log`가 active 또는 archive에 있는지 확인한다.
|
||||
- [ ] worker가 push 성공 후 revision scan을 요청할 수 있는 interface 또는 adapter 경계를 추가한다.
|
||||
- [ ] scan 요청에는 provider, repo_id, branch, workdir, runner, observed_at을 넘기고 default provider는 기존 scan 기본값과 충돌하지 않게 둔다.
|
||||
- [ ] revision scan 결과를 agent run completion payload에 `revision_scan_attempted`, `revision_event_matched`, `revision_event_id` 형태로 남긴다.
|
||||
- [ ] scanner 실패 시 operation failed로 전환할지, push 성공은 유지하고 scan failure만 payload화할지 계획의 범위 안에서 명시적으로 결정하고 테스트한다.
|
||||
- [ ] worker unit test로 push 성공 후 scan 호출, scan matched payload, scan failure 경로를 검증한다.
|
||||
- [ ] `cd services/core && go test ./internal/worker ./internal/controlplane`를 실행한다.
|
||||
- [ ] `cd services/core && go test ./...`를 실행한다.
|
||||
- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.
|
||||
|
||||
## 코드리뷰 전용 체크리스트
|
||||
|
||||
> **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다.
|
||||
> 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다.
|
||||
|
||||
- [ ] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다.
|
||||
- [ ] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다.
|
||||
- [ ] active `CODE_REVIEW-*-G??.md`를 `code_review_local_G06_N.log`로 아카이브한다.
|
||||
- [ ] active `PLAN-*-G??.md`를 `plan_local_G06_M.log`로 아카이브한다.
|
||||
- [ ] `.gitignore`의 Agent-Ops 관리 block이 `agent-task/**/*.md`와 `agent-task/**/*.log`를 unignore하고 `agent-roadmap/current.md`를 ignore하는지 확인한다.
|
||||
- [ ] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다.
|
||||
- [ ] PASS이면 active task 디렉터리 `agent-task/m-iop-agent-run-bridge/04+03_revision_scan_event/`를 `agent-task/archive/YYYY/MM/m-iop-agent-run-bridge/04+03_revision_scan_event/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다.
|
||||
- [ ] PASS이고 task group이 `m-<milestone-slug>`이면 런타임이 읽을 완료 이벤트 메타데이터를 보고하고, roadmap 수정이나 `update-roadmap` 직접 호출을 하지 않는다.
|
||||
- [ ] PASS split 작업이면 이동 후 빈 active parent `agent-task/m-iop-agent-run-bridge/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다.
|
||||
- [ ] WARN/FAIL이고 user-review gate가 트리거되지 않았으면 다음 active `PLAN-local-G06.md`와 `CODE_REVIEW-local-G06.md`를 작성하고 `complete.log`를 작성하지 않는다.
|
||||
- [ ] USER_REVIEW이면 `agent-ops/skills/common/code-review/templates/user-review-template.md` 기준으로 `USER_REVIEW.md`를 작성하고 active `PLAN-*.md`, `CODE_REVIEW-*.md`, `complete.log`를 남기지 않는다.
|
||||
- [ ] USER_REVIEW가 사용자 결정으로 완료/PASS 해소되면 `USER_REVIEW.md`를 해소 상태로 갱신하고 `complete.log`를 작성한 뒤 task directory를 archive로 이동한다.
|
||||
|
||||
## 계획 대비 변경 사항
|
||||
|
||||
_구현 에이전트가 계획과 다르게 구현한 부분을 이유와 함께 기록한다._
|
||||
|
||||
## 주요 설계 결정
|
||||
|
||||
_구현 에이전트가 주요 설계 결정 사항을 기록한다._
|
||||
|
||||
## 사용자 리뷰 요청
|
||||
|
||||
_기본값은 `없음`이다. 구현 중 사용자 결정, 사용자 소유 외부 환경/secret/서비스 준비, 또는 계획 범위 변경 없이는 안전하게 진행할 수 없으면 아래 항목을 실제 내용으로 교체하고, 구현을 중단한 뒤 active 파일을 그대로 둔 채 리뷰를 요청한다. 구현 에이전트는 사용자에게 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. 후속 에이전트가 명령 재실행이나 산출물 수집으로 해소할 수 있는 검증 증거 공백만으로는 사용자 리뷰 요청을 작성하지 않는다._
|
||||
|
||||
- 상태: 없음
|
||||
- 사유 유형: 없음
|
||||
- 결정 필요: 없음
|
||||
- 차단 근거: 없음
|
||||
- 실행한 검증/명령: 없음
|
||||
- 자동 후속 불가 이유: 없음
|
||||
- 재개 조건: 없음
|
||||
|
||||
## 리뷰어를 위한 체크포인트
|
||||
|
||||
- `04+03` dependency가 `03` complete.log로 충족된 뒤 구현되었는지 확인한다.
|
||||
- worker가 controlplane concrete type에 과하게 결합하지 않았는지 확인한다.
|
||||
- push 성공 후에만 revision scan이 호출되는지 확인한다.
|
||||
- scanner error가 숨겨지지 않고 테스트로 고정됐는지 확인한다.
|
||||
|
||||
## 검증 결과
|
||||
|
||||
_구현 에이전트가 각 중간 검증 및 최종 검증 명령 실행 후 출력을 여기에 붙여 넣는다._
|
||||
|
||||
필수 규칙:
|
||||
- 검증 명령은 고정된 계약이다. 임의로 대체하지 않는다.
|
||||
- 대체가 필요하면 `계획 대비 변경 사항`에 이유와 대체 명령을 기록한다.
|
||||
- `검증 결과`에는 실제 stdout/stderr를 붙여 넣는다.
|
||||
- 사용자 리뷰 요청으로 명령을 끝까지 실행하지 못했다면 `사용자 리뷰 요청`에 실행한 명령, 실제 출력, 미실행 명령의 사유를 기록한다.
|
||||
- mobile/UI hang, timeout, 또는 2분 무진행은 blind retry를 중단하고 focused rerun 명령과 screenshot/window/UI-tree evidence path를 남기며, 불가능하면 정확한 사유를 남긴다.
|
||||
|
||||
### API-1 중간 검증
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./internal/worker ./internal/controlplane
|
||||
```
|
||||
|
||||
### API-2 중간 검증
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./internal/worker ./internal/controlplane
|
||||
```
|
||||
|
||||
### 최종 검증
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./internal/worker ./internal/controlplane
|
||||
```
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./...
|
||||
```
|
||||
|
||||
계약 노트를 수정했다면 추가 실행:
|
||||
|
||||
```bash
|
||||
rg --sort path -n "proto-socket|REST|gRPC|ChangeRequest|Operation|Event|agent_shell|agent-shell|iop" packages/contracts README.md docs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
> **[IMPLEMENTING AGENT — BEFORE SAVING] Have you filled in every implementation-owned section: completion table, implementation checklist, changes from plan, design decisions, and verification output?**
|
||||
> If anything is blank, go back and fill it in before saving this file.
|
||||
> Leave review-agent-only sections unchanged.
|
||||
|
|
@ -0,0 +1,231 @@
|
|||
<!-- task=m-iop-agent-run-bridge/04+03_revision_scan_event plan=0 tag=API -->
|
||||
|
||||
# Plan - API
|
||||
|
||||
## 이 파일을 읽는 구현 에이전트에게
|
||||
|
||||
이 계획은 구현 후 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 실제 내용과 검증 출력으로 채우는 것까지가 작업이다. 구현 에이전트는 검증을 실행하고 active 파일을 유지한 채 리뷰 준비 상태를 보고한다. 사용자만 결정할 수 있는 정책, 외부 secret, scope 충돌로 막히면 active review stub의 `사용자 리뷰 요청` 섹션에 정확한 결정, 근거, 실행 명령, 재개 조건을 남기고 멈춘다. 구현 중 채팅으로 사용자에게 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하지 않는다. 후속 에이전트가 재실행이나 산출물 수집으로 해소할 수 있는 검증 공백은 사용자 리뷰 요청이 아니다. 최종 archive, `complete.log`, roadmap 갱신은 code-review/runtime 책임이다.
|
||||
|
||||
## 배경
|
||||
|
||||
`Runtime.ScanBranchRevision`은 revision cursor와 `branch.updated` event 발행 흐름을 이미 제공한다. 하지만 agent run의 policy-allowed push 이후 이 scan이 연결되어 있지 않아 Git 결과가 operation event와 revision event로 완전히 수렴하지 않는다. 이 계획은 `03_commit_push_policy`가 만든 push 성공 경계를 전제로, push 이후 revision scan을 호출하고 결과를 agent run completion payload에 남기는 작업이다.
|
||||
|
||||
## 사용자 리뷰 요청 흐름
|
||||
|
||||
구현 중 차단은 active `CODE_REVIEW-*-G??.md`의 `사용자 리뷰 요청` 섹션에 기록한다. 직접 사용자 프롬프트는 금지이며, code-review가 요청 타당성을 검증하고 실제 `USER_REVIEW.md` 작성을 소유한다.
|
||||
|
||||
## Roadmap Targets
|
||||
|
||||
- Milestone: `agent-roadmap/phase/agent-shell-iop-execution/milestones/iop-agent-run-bridge.md`
|
||||
- Task ids:
|
||||
- `revision-event`: push 이후 revision scan event를 발행한다.
|
||||
- Completion mode: check-on-pass
|
||||
|
||||
## 분석 결과
|
||||
|
||||
### 읽은 파일
|
||||
|
||||
- `agent-roadmap/current.md`
|
||||
- `agent-roadmap/phase/agent-shell-iop-execution/PHASE.md`
|
||||
- `agent-roadmap/phase/agent-shell-iop-execution/milestones/iop-agent-run-bridge.md`
|
||||
- `agent-ops/rules/project/rules.md`
|
||||
- `agent-ops/rules/project/domain/core/rules.md`
|
||||
- `agent-ops/rules/project/domain/contracts/rules.md`
|
||||
- `agent-ops/rules/project/domain/workspace-ops/rules.md`
|
||||
- `agent-ops/skills/common/plan/SKILL.md`
|
||||
- `agent-ops/skills/common/_templates/implementation-user-review-request-section.md`
|
||||
- `agent-test/local/rules.md`
|
||||
- `agent-test/local/core-smoke.md`
|
||||
- `agent-test/local/contracts-smoke.md`
|
||||
- `agent-test/local/workspace-ops-smoke.md`
|
||||
- `agent-contract/index.md`
|
||||
- `services/core/internal/worker/runner.go`
|
||||
- `services/core/internal/worker/runner_test.go`
|
||||
- `services/core/internal/gitengine/command.go`
|
||||
- `services/core/internal/storage/storage.go`
|
||||
- `services/core/internal/core/model.go`
|
||||
- `services/core/internal/events/events.go`
|
||||
- `services/core/internal/controlplane/runtime.go`
|
||||
- `services/core/internal/controlplane/runtime_test.go`
|
||||
- `packages/contracts/notes/gito-control-plane.md`
|
||||
|
||||
### 테스트 환경 규칙
|
||||
|
||||
- `test_env=local`; `agent-test/local/rules.md` 있음, 읽음.
|
||||
- 적용 profile: `agent-test/local/core-smoke.md`, `agent-test/local/contracts-smoke.md`, `agent-test/local/workspace-ops-smoke.md`.
|
||||
- core 필수 명령: `cd services/core && go test ./...`.
|
||||
- 계약 노트를 수정하면 필수 smoke: `rg --sort path -n "proto-socket|REST|gRPC|ChangeRequest|Operation|Event|agent_shell|agent-shell|iop" packages/contracts README.md docs`.
|
||||
- task artifact만 수정하는 workspace-ops 검증은 `rg --sort path -n "Gito|agent-shell|agent_shell|iop|gito-shell|control plane" README.md docs packages/contracts agent-roadmap -g '!agent-roadmap/archive/**'`.
|
||||
- 구조적 공백 없음. `<확인 필요>` 값 없음.
|
||||
|
||||
### 테스트 커버리지 공백
|
||||
|
||||
- `controlplane.Runtime.ScanBranchRevision` 자체 테스트는 있다. agent run push 이후 scan을 호출하는 worker-level 테스트가 없다.
|
||||
- worker가 controlplane package에 직접 의존하면 ownership 경계가 흐려질 수 있다. interface/adapter 테스트가 필요하다.
|
||||
- real remote push 후 scan integration은 secret/remote 준비가 필요하므로 이 계획 범위에서는 fake scanner unit test와 existing runtime tests로 제한한다.
|
||||
|
||||
### 심볼 참조
|
||||
|
||||
- none. 기존 심볼 rename/remove 계획 없음.
|
||||
|
||||
### 분할 판단
|
||||
|
||||
- split decision policy를 적용했다.
|
||||
- 공유 task group: `m-iop-agent-run-bridge`.
|
||||
- `03_commit_push_policy`: predecessor 없음. 이 계획의 필수 선행 작업이다.
|
||||
- `04+03_revision_scan_event`: predecessor `03`; 현재 시점에는 active sibling `agent-task/m-iop-agent-run-bridge/03_commit_push_policy/complete.log`가 아직 없으므로 구현 시작 전 완료되어야 한다.
|
||||
- push 성공 후 revision scan event가 의미 있으므로 이 task는 `03` 완료 전 구현하지 않는다.
|
||||
|
||||
### 범위 결정 근거
|
||||
|
||||
- commit/push policy 구현은 `03_commit_push_policy`에 있다.
|
||||
- revision scan cursor/event 생성은 기존 `controlplane.Runtime.ScanBranchRevision`을 재사용하거나 얇은 adapter로 연결한다. 새 provider webhook 경로는 만들지 않는다.
|
||||
- IOP CLI, secret injection, provider PR/MR, Flutter UI, external remote integration smoke는 제외한다.
|
||||
- Runtime/store migration은 기존 `revision_cursors`, `branch_watches`, `provider_deliveries` 구조로 충분하면 건드리지 않는다.
|
||||
|
||||
### 빌드 등급
|
||||
|
||||
- build=`local-G06`, review=`local-G06`. worker와 runtime 경계가 걸리지만 interface injection과 existing fake tests로 검증 가능한 범위다.
|
||||
|
||||
## 구현 체크리스트
|
||||
|
||||
- [ ] 구현 시작 전 `03_commit_push_policy`의 `complete.log`가 active 또는 archive에 있는지 확인한다.
|
||||
- [ ] worker가 push 성공 후 revision scan을 요청할 수 있는 interface 또는 adapter 경계를 추가한다.
|
||||
- [ ] scan 요청에는 provider, repo_id, branch, workdir, runner, observed_at을 넘기고 default provider는 기존 scan 기본값과 충돌하지 않게 둔다.
|
||||
- [ ] revision scan 결과를 agent run completion payload에 `revision_scan_attempted`, `revision_event_matched`, `revision_event_id` 형태로 남긴다.
|
||||
- [ ] scanner 실패 시 operation failed로 전환할지, push 성공은 유지하고 scan failure만 payload화할지 계획의 범위 안에서 명시적으로 결정하고 테스트한다.
|
||||
- [ ] worker unit test로 push 성공 후 scan 호출, scan matched payload, scan failure 경로를 검증한다.
|
||||
- [ ] `cd services/core && go test ./internal/worker ./internal/controlplane`를 실행한다.
|
||||
- [ ] `cd services/core && go test ./...`를 실행한다.
|
||||
- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.
|
||||
|
||||
## 의존 관계 및 구현 순서
|
||||
|
||||
- 이 subtask 디렉터리 이름은 `04+03_revision_scan_event`이며 predecessor는 같은 task group의 `03_commit_push_policy`뿐이다.
|
||||
- 구현 전 다음 중 하나가 있어야 한다.
|
||||
- active: `agent-task/m-iop-agent-run-bridge/03_commit_push_policy/complete.log`
|
||||
- archive: `agent-task/archive/*/*/m-iop-agent-run-bridge/03_commit_push_policy/complete.log`
|
||||
- predecessor가 없으면 구현하지 말고 active review stub의 `사용자 리뷰 요청`이 아니라 "predecessor pending" 상태로 보고한다.
|
||||
|
||||
### [API-1] Revision scan interface after push
|
||||
|
||||
#### 문제
|
||||
|
||||
[services/core/internal/controlplane/runtime.go](/config/workspace/gito/services/core/internal/controlplane/runtime.go:324)의 `ScanBranchRevision`은 revision cursor와 event 발행을 제공하지만, [services/core/internal/worker/runner.go](/config/workspace/gito/services/core/internal/worker/runner.go:218)의 agent run terminal flow는 이를 호출할 경계가 없다. worker가 controlplane concrete type에 직접 붙으면 package boundary가 커진다.
|
||||
|
||||
#### 해결 방법
|
||||
|
||||
worker package에 small interface를 두고, controlplane/runtime 쪽 또는 cmd wiring에서 adapter를 주입한다. interface는 worker가 필요한 최소 DTO만 알게 한다.
|
||||
|
||||
```go
|
||||
// before: runner.go has no revision scanner dependency.
|
||||
type RunnerDependencies struct {
|
||||
OperationStore storage.OperationStore
|
||||
OperationEventStore storage.OperationEventStore
|
||||
AgentRunInputLoader AgentRunInputLoader
|
||||
AgentRunInvoker AgentRunInvoker
|
||||
GitRunner gitengine.CommandRunner
|
||||
}
|
||||
```
|
||||
|
||||
```go
|
||||
// after
|
||||
type RevisionScanner interface {
|
||||
ScanAgentRunRevision(ctx context.Context, req RevisionScanRequest) (RevisionScanResult, error)
|
||||
}
|
||||
|
||||
type RunnerDependencies struct {
|
||||
OperationStore storage.OperationStore
|
||||
OperationEventStore storage.OperationEventStore
|
||||
AgentRunInputLoader AgentRunInputLoader
|
||||
AgentRunInvoker AgentRunInvoker
|
||||
GitRunner gitengine.CommandRunner
|
||||
RevisionScanner RevisionScanner
|
||||
}
|
||||
```
|
||||
|
||||
Keep request/result structs free of provider-specific secrets.
|
||||
|
||||
#### 수정 파일 및 체크리스트
|
||||
|
||||
- [ ] `services/core/internal/worker/runner.go`: `RevisionScanner` interface와 dependency 추가.
|
||||
- [ ] `services/core/internal/worker/runner_test.go`: fake scanner 추가.
|
||||
- [ ] 연결 adapter가 필요하면 `services/core/internal/controlplane/` 또는 `services/core/cmd/worker/` 중 기존 wiring에 맞춰 최소 추가.
|
||||
|
||||
#### 테스트 작성
|
||||
|
||||
작성한다. fake scanner가 request fields를 캡처하고 push 성공 후 정확히 한 번 호출되는지 검증한다.
|
||||
|
||||
#### 중간 검증
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./internal/worker ./internal/controlplane
|
||||
```
|
||||
|
||||
기대: worker/controlplane 테스트가 0 exit로 통과한다.
|
||||
|
||||
### [API-2] Revision scan payload and failure behavior
|
||||
|
||||
#### 문제
|
||||
|
||||
[services/core/internal/controlplane/runtime.go](/config/workspace/gito/services/core/internal/controlplane/runtime.go:388)는 matched event record를 반환하지만, agent run completion payload에는 scan 시도/결과를 남기는 필드가 없다. [packages/contracts/notes/gito-control-plane.md](/config/workspace/gito/packages/contracts/notes/gito-control-plane.md:93)는 Git workspace와 이후 commit/push result를 source of truth로 둔다고만 설명한다.
|
||||
|
||||
#### 해결 방법
|
||||
|
||||
`03_commit_push_policy`의 push success signal이 있을 때만 scanner를 호출한다. payload에는 최소 필드를 추가한다.
|
||||
|
||||
```go
|
||||
completionExtra["revision_scan_attempted"] = true
|
||||
completionExtra["revision_event_matched"] = matched
|
||||
if record.ID != "" {
|
||||
completionExtra["revision_event_id"] = record.ID
|
||||
}
|
||||
```
|
||||
|
||||
Failure behavior는 구현 전에 코드상 한 가지로 고정한다. 추천 기본값은 "push succeeded but scan failed => operation failed"이다. 이유는 `[revision-event]` Task의 성공 기준이 push 이후 event convergence라서 scan 실패를 숨기면 roadmap target을 닫을 수 없다.
|
||||
|
||||
#### 수정 파일 및 체크리스트
|
||||
|
||||
- [ ] `services/core/internal/worker/runner.go`: scan 호출과 payload fields 추가.
|
||||
- [ ] `services/core/internal/worker/runner_test.go`: matched/unmatched/failure 경로 테스트.
|
||||
- [ ] `packages/contracts/notes/gito-control-plane.md`: payload 의미를 문서화할 필요가 있으면 transport-independent wording으로 추가.
|
||||
|
||||
#### 테스트 작성
|
||||
|
||||
작성한다. fake scanner가 matched record를 반환하면 completion payload에 `revision_event_id`가 들어가는지 검증한다. scanner error는 operation failed와 sanitized message를 검증한다.
|
||||
|
||||
#### 중간 검증
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./internal/worker ./internal/controlplane
|
||||
```
|
||||
|
||||
기대: worker/controlplane 테스트가 0 exit로 통과한다.
|
||||
|
||||
## 수정 파일 요약
|
||||
|
||||
| 파일 | 항목 |
|
||||
| --- | --- |
|
||||
| `services/core/internal/worker/runner.go` | API-1, API-2 |
|
||||
| `services/core/internal/worker/runner_test.go` | API-1, API-2 |
|
||||
| `services/core/internal/controlplane/runtime.go` | API-1 |
|
||||
| `services/core/cmd/worker/main.go` | API-1 |
|
||||
| `packages/contracts/notes/gito-control-plane.md` | API-2 |
|
||||
|
||||
## 최종 검증
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./internal/worker ./internal/controlplane
|
||||
```
|
||||
|
||||
```bash
|
||||
cd services/core && go test ./...
|
||||
```
|
||||
|
||||
계약 노트를 수정했다면 추가 실행:
|
||||
|
||||
```bash
|
||||
rg --sort path -n "proto-socket|REST|gRPC|ChangeRequest|Operation|Event|agent_shell|agent-shell|iop" packages/contracts README.md docs
|
||||
```
|
||||
|
||||
모든 코드 변경 완료 후 반드시 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 채운다. 이 파일 작성이 구현의 마지막 단계다.
|
||||
|
|
@ -225,6 +225,10 @@ func (r *Runner) runAgentRunOperation(ctx context.Context, op core.Operation) er
|
|||
completionExtra = map[string]any{"message": completionMessage}
|
||||
} else {
|
||||
completionExtra = agentRunGitEvidencePayload(evidence)
|
||||
if !evidence.StatusClean {
|
||||
terminalState = core.OperationFailed
|
||||
completionMessage = "workspace dirty after agent run"
|
||||
}
|
||||
completionExtra["message"] = completionMessage
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -472,6 +472,108 @@ func TestRunnerRunOnceAgentRunRecordsGitEvidence(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestRunnerRunOnceAgentRunFailsWhenGitEvidenceIsDirty(t *testing.T) {
|
||||
cfg := config.Config{WorkerEnabled: true}
|
||||
logger := slog.New(slog.NewTextHandler(io.Discard, nil))
|
||||
now := time.Now().UTC().Truncate(time.Microsecond)
|
||||
op := runningAgentRunOperation("agent-run-dirty")
|
||||
picker := &fakePicker{
|
||||
pickFn: func(ctx context.Context, now time.Time) (core.Operation, bool, error) {
|
||||
return op, true, nil
|
||||
},
|
||||
}
|
||||
clock := fakeClock{now: now}
|
||||
opStore := &fakeOperationStore{operation: op}
|
||||
eventStore := &fakeOperationEventStore{}
|
||||
loader := &fakeAgentRunInputLoader{
|
||||
input: worker.AgentRunInput{
|
||||
Branch: "main",
|
||||
WorkspacePath: "/repo/worktree",
|
||||
ExpectedRevision: "before-revision",
|
||||
},
|
||||
}
|
||||
invoker := &fakeAgentRunInvoker{
|
||||
result: worker.AgentRunResult{
|
||||
State: worker.AgentRunStateSucceeded,
|
||||
Message: "done",
|
||||
},
|
||||
}
|
||||
gitRunner := &fakeGitRunner{
|
||||
outputs: []string{
|
||||
" M README.md\n?? scratch.txt\n",
|
||||
"after-revision\n",
|
||||
"M\tREADME.md\n",
|
||||
},
|
||||
}
|
||||
runner := worker.NewRunnerWithDependencies(cfg, logger, picker, clock, worker.RunnerDependencies{
|
||||
OperationStore: opStore,
|
||||
OperationEventStore: eventStore,
|
||||
AgentRunInputLoader: loader,
|
||||
AgentRunInvoker: invoker,
|
||||
GitRunner: gitRunner,
|
||||
})
|
||||
|
||||
err := runner.RunOnce(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if opStore.succeededCalls != 0 || opStore.failedCalls != 1 {
|
||||
t.Fatalf("expected no succeed and one fail call, got succeed=%d fail=%d", opStore.succeededCalls, opStore.failedCalls)
|
||||
}
|
||||
if opStore.operation.State != core.OperationFailed {
|
||||
t.Fatalf("operation state mismatch: got %q want %q", opStore.operation.State, core.OperationFailed)
|
||||
}
|
||||
if len(eventStore.events) != 4 {
|
||||
t.Fatalf("expected 4 events, got %d", len(eventStore.events))
|
||||
}
|
||||
if eventStore.events[2].Event.Type != events.OperationFailed {
|
||||
t.Fatalf("completion event type: got %q want %q", eventStore.events[2].Event.Type, events.OperationFailed)
|
||||
}
|
||||
|
||||
completedPayload := decodePayload(t, eventStore.events[2].Event.Payload)
|
||||
if completedPayload["state"] != string(core.OperationFailed) {
|
||||
t.Fatalf("completion state mismatch: got %v want %q", completedPayload["state"], core.OperationFailed)
|
||||
}
|
||||
if completedPayload["message"] != "workspace dirty after agent run" {
|
||||
t.Fatalf("message: got %v want %q", completedPayload["message"], "workspace dirty after agent run")
|
||||
}
|
||||
if completedPayload["status_clean"] != false {
|
||||
t.Fatalf("status_clean: got %v want false", completedPayload["status_clean"])
|
||||
}
|
||||
if completedPayload["status_output"] != " M README.md\n?? scratch.txt\n" {
|
||||
t.Fatalf("status_output: got %q", completedPayload["status_output"])
|
||||
}
|
||||
if completedPayload["before_revision"] != "before-revision" {
|
||||
t.Fatalf("before_revision: got %v want %q", completedPayload["before_revision"], "before-revision")
|
||||
}
|
||||
if completedPayload["after_revision"] != "after-revision" {
|
||||
t.Fatalf("after_revision: got %v want %q", completedPayload["after_revision"], "after-revision")
|
||||
}
|
||||
changedFiles, ok := completedPayload["changed_files"].([]any)
|
||||
if !ok {
|
||||
t.Fatalf("changed_files has type %T, want []any", completedPayload["changed_files"])
|
||||
}
|
||||
if len(changedFiles) != 1 {
|
||||
t.Fatalf("changed_files len: got %d want 1", len(changedFiles))
|
||||
}
|
||||
firstFile, ok := changedFiles[0].(map[string]any)
|
||||
if !ok {
|
||||
t.Fatalf("changed_files[0] has type %T, want map[string]any", changedFiles[0])
|
||||
}
|
||||
if firstFile["path"] != "README.md" || firstFile["change_type"] != "modified" {
|
||||
t.Fatalf("changed_files[0]: got %#v", firstFile)
|
||||
}
|
||||
|
||||
wantCalls := []fakeGitCall{
|
||||
{workdir: "/repo/worktree", args: []string{"status", "--porcelain"}},
|
||||
{workdir: "/repo/worktree", args: []string{"rev-parse", "HEAD"}},
|
||||
{workdir: "/repo/worktree", args: []string{"diff", "--name-status", "before-revision..after-revision"}},
|
||||
}
|
||||
if !reflect.DeepEqual(gitRunner.calls, wantCalls) {
|
||||
t.Fatalf("git calls:\n got %#v\nwant %#v", gitRunner.calls, wantCalls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunnerRunOnceAgentRunFailsWhenGitEvidenceFails(t *testing.T) {
|
||||
cfg := config.Config{WorkerEnabled: true}
|
||||
logger := slog.New(slog.NewTextHandler(io.Discard, nil))
|
||||
|
|
|
|||
Loading…
Reference in a new issue