# Complete - m-milestone-work-item-creation-sync/13+12_slot_terminal_state

## 완료 일시

2026-06-16

## 요약

slot terminal state 정책 helper와 scheduler 연결 구현, 루프 1회, PASS.

## 루프 이력

| Plan | Review | Verdict | 메모 |
|------|--------|---------|------|
| `plan_cloud_G06_0.log` | `code_review_cloud_G06_0.log` | PASS | SlotStateForAuthoringOutcome + applyTaskSlotTerminalState 완전 구현, 모든 테스트 통과 |

## 구현/정리 내용

- `services/core/internal/authoring/result.go` — `SlotStateForAuthoringOutcome(Decision) (SlotState, bool)` 추가: succeeded→available, dirty_workspace/conflict/push_failed→dirty, 기타 failure→error, non-terminal→("",false)
- `services/core/internal/authoring/result_test.go` — `TestSlotStateForAuthoringOutcome` table test 추가 (6 케이스)
- `services/core/internal/scheduler/slot_finalizer.go` — `WorkspaceSlotStateUpdater` 인터페이스와 `applyTaskSlotTerminalState` 내부 helper 추가 (nil updater, missing slot_id, invalid state 모두 non-fatal)
- `services/core/internal/scheduler/jobs.go` — `TaskWorker.SlotUpdater` 필드 추가, `markFailedWithTask`에서 authoring failure path에 slot terminal state 연결
- `services/core/internal/scheduler/roadmap_sync_jobs.go` — `RoadmapCreationSyncWorker.SlotUpdater` 필드 추가, `CompleteTaskByExternalRef` 반환 task로 `applyTaskSlotTerminalState` 호출 (projected/complete 양쪽)
- `services/core/internal/scheduler/river.go` — `scheduler.New` 시그니처에 `slotUpdater WorkspaceSlotStateUpdater` 추가, TaskWorker/RoadmapCreationSyncWorker wiring
- `services/core/internal/scheduler/jobs_test.go` — authoring failure path slot update, missing slot_id skip, generic task no-slot-update 테스트 추가
- `services/core/internal/scheduler/river_test.go` — projected 경로 slot update 검증 추가 (`fakeTaskFinalizer` + `fakeWorkspaceSlotUpdater`)
- `services/core/cmd/server/main.go` — `scheduler.New` 호출에 `workflowService`(TaskFinalizer), `store`(WorkspaceSlotStateUpdater) 주입
- `services/core/internal/workflow/service.go` — `CompleteTaskByExternalRef`가 완료된 `storage.Task`를 반환하도록 확인 (이미 `(storage.Task, error)` 반환, `TaskFinalizer` 인터페이스 선언에 맞춤)
- `services/core/internal/workflow/service_test.go` — `TestServiceCompleteTaskByExternalRefPromotesAuthoringMetadata` 추가 (반환 task 검증)

## 최종 검증

- `cd services/core && go test -count=1 ./internal/projectsync ./internal/storage ./internal/authoring ./internal/scheduler ./internal/workflow` - PASS; 모든 5개 패키지 통과
- `cd services/core && go test ./...` - PASS
- `cd services/core && go vet ./...` - PASS; 출력 없음
- `git diff --check` - PASS; 출력 없음

## Roadmap Completion

- Milestone: `agent-roadmap/phase/agent-ops-mcp-control-plane/milestones/milestone-work-item-creation-sync.md`
- Completed task ids:
  - `slot-terminal-state`: PASS; evidence=`plan_cloud_G06_0.log`, `code_review_cloud_G06_0.log`; verification=`cd services/core && go test -count=1 ./internal/projectsync ./internal/storage ./internal/authoring ./internal/scheduler ./internal/workflow`
- Not completed task ids: 없음

## 잔여 Nit

- `river_test.go:160` `TestRoadmapCreationSyncWorkerFinalizesExternalTaskOnComplete`가 `SlotUpdater`를 주입하지 않아 complete 경로의 slot update를 검증하지 않음 (projected 경로와 동일 코드 경로라 정확성 영향 없음)

## 후속 작업

- 없음
