<!-- task=m-external-integration/04+01,02,03_adapter_boundary plan=0 tag=BOUNDARY -->

# Adapter Boundary Audit Plan

## 이 파일을 읽는 구현 에이전트에게

이 dependent subtask는 sibling `01_plane_adapter`, `02_jira_adapter`, `03_mattermost_adapter`의 PASS `complete.log`가 있어야 구현을 시작한다. 완료 전에는 active `CODE_REVIEW-local-G06.md`의 구현 에이전트 소유 섹션을 채우고 리뷰 준비를 보고한다.

## 배경

External Integration의 마지막 남은 broad item은 provider 세부 구현이 adapter 경계 밖으로 새지 않는지 확인하는 것이다. 이 audit은 provider 구현들이 들어온 뒤에만 의미가 있으므로 선행 세 subtask 완료에 의존한다.

## 사용자 리뷰 요청 흐름

선행 `complete.log`가 없거나 ambiguous하면 구현하지 말고 `사용자 리뷰 요청`에 경로와 blocker를 기록한다. code-review가 user-review stop 여부를 판단한다.

## Roadmap Targets

- Milestone: `agent-roadmap/phase/external-integration/milestones/external-integration.md`
- Task ids:
  - `adapter-boundary`: 외부 provider별 구현 경계 점검
- Completion mode: check-on-pass

## 분석 결과

### 읽은 파일

- `agent-roadmap/current.md`
- `agent-roadmap/phase/external-integration/PHASE.md`
- `agent-roadmap/phase/external-integration/milestones/external-integration.md`
- `agent-test/local/rules.md`
- `agent-test/local/core-smoke.md`
- `agent-ops/rules/project/domain/core/rules.md`
- `services/core/internal/workitem/provider.go`
- `services/core/internal/workitempipeline/service.go`
- `services/core/internal/http/handlers.go`
- `services/core/internal/http/router.go`
- `services/core/internal/adapters/plane/client.go`
- `services/core/internal/adapters/mattermost/client.go`
- `services/core/internal/adapters/a2a/client.go`
- `services/core/internal/adapters/openai/client.go`
- `services/core/internal/scheduler/jobs.go`
- `services/core/internal/config/config.go`
- `services/core/cmd/server/main.go`
- `services/core/README.md`
- `README.md`

### 테스트 환경 규칙

- test_env: `local`
- `agent-test/local/rules.md` 있음, 읽음.
- matched profile: `agent-test/local/core-smoke.md` 읽음.
- 적용 명령: `cd services/core && go test ./...`, `cd services/core && go vet ./...`.
- 추가 deterministic search checks use `rg --sort path`.

### 테스트 커버리지 공백

- Boundary leakage is not a single unit behavior. The audit must use compile/tests plus deterministic searches for provider names and DTO types in non-adapter packages.
- If prior subtasks add provider registries or config, tests should already cover behavior. This subtask should add small tests only for gaps discovered by audit.

### 심볼 참조

- renamed/removed symbols: none expected.
- Search required for provider-specific packages/types in `internal/workflow`, `internal/scheduler`, `internal/http`, `internal/workitempipeline`.

### 분할 판단

- split decision policy evaluated.
- Directory name `04+01,02,03_adapter_boundary` declares dependencies on sibling indices 01, 02, and 03.
- Before implementation, resolve:
  - `agent-task/m-external-integration/01_plane_adapter/complete.log` or matching archive complete log.
  - `agent-task/m-external-integration/02_jira_adapter/complete.log` or matching archive complete log.
  - `agent-task/m-external-integration/03_mattermost_adapter/complete.log` or matching archive complete log.
- At planning time these predecessors are not complete, so this plan is pending.

### 범위 결정 근거

- Exclude new provider features. Only audit, small boundary fixes, docs/tests.
- Do not implement Plane/Jira/Mattermost missing behavior here; create follow-up if a predecessor left scope incomplete.
- Do not read roadmap/task archives except candidate predecessor `complete.log` files allowed by split dependency rules.

### 빌드 등급

- build lane/grade: `local-G06` - search-driven audit and small code fixes after provider subtasks.
- review lane/grade: `local-G06` - reviewer can rerun tests and deterministic searches.

## 구현 체크리스트

- [ ] [BOUNDARY-1] 선행 complete.log 3개를 확인한다.
- [ ] [BOUNDARY-2] provider-specific leakage를 검색하고 필요한 작은 경계 수정을 적용한다.
- [ ] [BOUNDARY-3] README/domain consistency를 확인하고 필요한 문서 보정을 한다.
- [ ] `cd services/core && go test ./...`를 실행한다.
- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.

## 의존 관계 및 구현 순서

`04+01,02,03_adapter_boundary` depends on sibling subtask indices `01`, `02`, and `03`. Do not implement until each predecessor has `complete.log`.

## [BOUNDARY-1] Predecessor completion

문제: Boundary audit before provider implementation would only audit old stubs.

해결 방법:

- Check active and archive candidate patterns allowed by plan skill for predecessors 01, 02, 03.
- If any is missing or ambiguous, fill `사용자 리뷰 요청` and stop.

수정 파일 및 체크리스트:

- [ ] No source change.
- [ ] Record exact complete.log paths in review stub.

테스트 작성:

- None.

중간 검증:

```bash
test -f agent-task/m-external-integration/01_plane_adapter/complete.log
test -f agent-task/m-external-integration/02_jira_adapter/complete.log
test -f agent-task/m-external-integration/03_mattermost_adapter/complete.log
```

기대: active complete logs exist, or equivalent archive complete logs are cited.

## [BOUNDARY-2] Provider leakage audit

문제: Core rule requires provider details to stay under `internal/adapters/<provider>` and provider-neutral contracts in `internal/workitem`.

해결 방법:

- Run deterministic searches:

```bash
rg --sort path -n "plane\\.|jira\\.|mattermost\\.|WorkItemRef|IssueRef|comment_html|/api/v4/posts|/rest/api/3" services/core/internal --glob '!adapters/**'
```

- Expected exceptions: `cmd/server/main.go` wiring and config names may mention providers. `internal/http` may contain route names but not provider DTO details unless explicitly justified.
- Move provider-specific DTO parsing into adapters or provider-neutral request structs.

수정 파일 및 체크리스트:

- [ ] `services/core/internal/workitem/**`: provider-neutral only.
- [ ] `services/core/internal/workitempipeline/**`: provider-neutral only.
- [ ] `services/core/internal/http/**`: no adapter DTO imports.
- [ ] `services/core/internal/scheduler/**`: no provider-specific projection details.

테스트 작성:

- Add small tests only if a boundary fix changes behavior.
- Otherwise record search output as evidence.

중간 검증:

```bash
rg --sort path -n "plane\\.|jira\\.|mattermost\\.|WorkItemRef|IssueRef|comment_html|/api/v4/posts|/rest/api/3" services/core/internal --glob '!adapters/**'
```

기대: no unexpected leakage; every remaining hit is listed as intentional.

## [BOUNDARY-3] Docs and final verification

문제: README may lag provider implementation and overstate stubs.

해결 방법:

- Update README only for implemented behavior.
- Ensure A2A remains future delegation, not current default execution path.
- Ensure roadmap is not modified directly by implementation PASS; runtime handles task completion update.

수정 파일 및 체크리스트:

- [ ] `services/core/README.md`: current implementation range matches code.
- [ ] `README.md`: environment table/current status matches code.
- [ ] No roadmap direct completion update.

테스트 작성:

- None for docs-only updates.

중간 검증:

```bash
cd services/core && go test ./...
```

기대: tests pass.

## 수정 파일 요약

| 파일 | 항목 |
|------|------|
| `services/core/internal/workitem/**` | BOUNDARY-2 |
| `services/core/internal/workitempipeline/**` | BOUNDARY-2 |
| `services/core/internal/http/**` | BOUNDARY-2 |
| `services/core/internal/scheduler/**` | BOUNDARY-2 |
| `services/core/README.md` | BOUNDARY-3 |
| `README.md` | BOUNDARY-3 |

## 최종 검증

```bash
cd services/core && go test ./...
cd services/core && go vet ./...
rg --sort path -n "plane\\.|jira\\.|mattermost\\.|WorkItemRef|IssueRef|comment_html|/api/v4/posts|/rest/api/3" services/core/internal --glob '!adapters/**'
```

기대: Go commands exit 0. Search output contains only intentional wiring/provider-neutral exceptions documented in `CODE_REVIEW-local-G06.md`.

모든 코드 변경 완료 후 반드시 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 채운다. 이 파일 작성이 구현의 마지막 단계다.
