feat: operation event outbox milestone implementation and updates

This commit is contained in:
toki 2026-06-14 06:52:08 +09:00
parent 07b4e63366
commit a8687dff06
7 changed files with 426 additions and 6 deletions

View file

@ -69,6 +69,8 @@ operation 결과를 durable event로 남기고 fanout 대상이 읽을 수 있
- 관련 경로: `services/core/internal/events/`, `services/core/internal/storage/`, `services/core/internal/worker/`, `services/core/migrations/`
- 표준선(선택): Postgres outbox가 event source of truth이며 Redis는 optional acceleration이다.
- 현재 작업현황: `event-store` 구현은 `storage.OperationEventStore`, `pgOperationEventStore`, `operation_events` migration에 반영되어 있다.
- 검증 대기: DB 연결 없는 현재 환경에서는 `TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates`가 skip되어 event order와 publish retry 상태 검증을 완료 체크하지 않았다.
- 선행 작업: Platformless Git Operation Engine
- 후속 작업: Agent Shell Runtime Channel
- 확인 필요: 없음
- 확인 필요: DB-backed storage test runner에서 `event-store` 검증 후 `[event-store]` 완료 체크와 Milestone `[검토중]` 전환을 판단한다.

View file

@ -0,0 +1,71 @@
# User Review Required - m-operation-event-outbox
## 요청 일시
2026-06-14
## 상태
RESOLVED
## 사유
- 유형: environment-blocked
- 현재 리뷰 회차: 1
- 최종 판정: PASS
- 요약: 원격 code-server compose의 `code-server-postgres``gito_test` DB를 만들고, code-server 컨테이너 내부에서 `GITO_TEST_DATABASE_URL`을 주입해 필수 DB-backed 검증을 skip 없이 통과했다.
## 루프 이력
| Plan | Review | Verdict | 메모 |
|------|--------|---------|------|
| `agent-task/m-operation-event-outbox/plan_local_G04_0.log` | `agent-task/m-operation-event-outbox/code_review_local_G03_0.log` | FAIL | `GITO_TEST_DATABASE_URL` 부재로 targeted storage integration test가 SKIP되어 필수 검증 미충족 |
| `agent-task/m-operation-event-outbox/USER_REVIEW.md` | user decision | PASS/RESOLVED | 원격 code-server compose의 Postgres DB 사용 지시를 반영해 `gito_test` DB를 만들고 검증을 완료 |
## 차단 근거
- 문제: `event-store` Roadmap Target은 `TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates`와 core 전체 fresh 검증이 skip 없이 PASS해야 하지만, 현재 환경에는 PostgreSQL DSN이 없다.
- 현재 archive plan: `agent-task/m-operation-event-outbox/plan_local_G04_0.log`
- 현재 archive review: `agent-task/m-operation-event-outbox/code_review_local_G03_0.log`
- 검증 명령: `cd services/core && go test ./internal/storage -run TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates -count=1 -v`
- 실제 출력:
```text
=== RUN TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates
postgres_test.go:747: GITO_TEST_DATABASE_URL not set; skipping Postgres integration test
--- SKIP: TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates (0.00s)
PASS
ok git.toki-labs.com/toki/gito/services/core/internal/storage 0.004s
```
- 차단 판단 근거: 리뷰 재실행에서도 `GITO_TEST_DATABASE_URL`은 비어 있었고, `docker`, `postgres`, `initdb`, `psql` 실행 파일도 PATH에서 확인되지 않았다. 저장소 코드 수정이나 단순 명령 재실행만으로는 skip 없는 DB integration 증거를 만들 수 없다.
## 해소 근거
- 사용자 결정: 원격 `~/docker/services/code-server/compose/docker-compose.yml`의 code-server compose를 기준으로, 함께 올라간 `code-server-postgres`에 DB를 만들어 검증한다.
- 조치: 원격 host에서 `/usr/local/bin/docker`를 사용해 `code-server-postgres``gito_test` DB를 만들고, `code-server` 컨테이너의 `/config/workspace/gito` checkout에서 `DATABASE_URL`의 DB 이름만 `gito_test`로 바꿔 `GITO_TEST_DATABASE_URL`을 주입했다.
- 추가 수정: core 전체 DB 검증 중 `PickQueuedOperation``RETURNING id`가 CTE의 `candidate.id`와 ambiguous한 실제 storage 버그를 발견해 `services/core/internal/storage/postgres.go`에서 `op.` alias로 한정했다.
- 검증:
- `cd /config/workspace/gito/services/core && GITO_TEST_DATABASE_URL=<redacted> go test ./internal/storage -run TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates -count=1 -v` - PASS, `SKIP` 없음.
- `cd /config/workspace/gito/services/core && GITO_TEST_DATABASE_URL=<redacted> go test ./... -count=1` - PASS.
## 사용자 결정 필요
- [ ] 자동 follow-up plan/review를 계속 진행한다.
- [ ] 계획을 재작성한다.
- [x] 테스트 환경, secret, 외부 서비스, SDK, 장비 조건을 준비한 뒤 재시도한다.
- [ ] 작업 범위를 줄이거나 보류/폐기한다.
## 재개 조건
- 완료됨: 원격 code-server compose의 `code-server-postgres``gito_test` DB를 사용해 `GITO_TEST_DATABASE_URL`을 주입했다.
- 완료됨: targeted command와 `go test ./... -count=1`이 skip 없이 PASS했다.
## 다음 실행 힌트
- 재개 검증 후보:
- `cd services/core && test -n "$GITO_TEST_DATABASE_URL" && go test ./internal/storage -run TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates -count=1 -v`
- `cd services/core && test -n "$GITO_TEST_DATABASE_URL" && go test ./... -count=1`
## 종료 규칙
- 사용자가 이 stop state를 완료/PASS로 해소하면 `USER_REVIEW.md`를 해소 상태로 갱신하고, `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준 `complete.log`를 작성한 뒤 task directory를 archive로 이동한다.
- 새 구현이 필요하면 `plan` 스킬이 `USER_REVIEW.md``user_review_N.log`로 아카이브한 뒤 새 `PLAN-*-G??.md` / `CODE_REVIEW-*-G??.md`를 작성한다.

View file

@ -0,0 +1,165 @@
<!-- task=m-operation-event-outbox plan=0 tag=TEST -->
# Code Review Reference - TEST
> **[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-14
task=m-operation-event-outbox, plan=0, tag=TEST
## Roadmap Targets
- Milestone: `agent-roadmap/phase/control-plane-foundation/milestones/operation-event-outbox.md`
- Task ids:
- `event-store`: event append/list/mark-published boundary를 만든다. 검증: event order와 retry 가능한 publish 상태를 확인한다.
- Completion mode: check-on-pass
## 이 파일을 읽는 리뷰 에이전트에게
> **[REVIEW AGENT ONLY]** 아래 종결 절차는 코드리뷰 에이전트 전용이다. 구현 에이전트는 이 섹션을 실행하지 않는다.
각 항목의 구현을 실제 소스 파일과 대조하고, `검증 결과` 섹션의 출력이 코드와 일치하는지 확인하세요.
리뷰 완료는 아래 순서까지 끝난 상태를 의미합니다.
1. 판정을 append한다.
2. `CODE_REVIEW-local-G03.md` -> `code_review_local_G03_N.log`, `PLAN-local-G04.md` -> `plan_local_G04_M.log`로 아카이브한다.
3. PASS이면 `complete.log` 작성 후 active task 디렉터리를 `agent-task/archive/YYYY/MM/m-operation-event-outbox/`로 이동한다. 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` 위치에서 체크한 뒤 보고한다.
---
## 구현 항목별 완료 여부
| 항목 | 완료 여부 |
|------|---------|
| [TEST-1] event-store DB 검증 | [ ] |
## 구현 체크리스트
- [ ] `GITO_TEST_DATABASE_URL`이 설정되어 있음을 값 출력 없이 확인한다.
- [ ] `TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates`를 `-count=1 -v`로 실행하고 `PASS`이며 `SKIP`이 아님을 기록한다.
- [ ] `cd services/core && test -n "$GITO_TEST_DATABASE_URL" && go test ./... -count=1`로 core 전체 fresh 검증을 실행한다.
- [x] DB 환경이 없어서 검증할 수 없으면 `CODE_REVIEW-*-G??.md`의 `사용자 리뷰 요청`에 실행 명령, 실제 출력, 필요한 준비 조건을 기록한다.
- [x] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.
## 코드리뷰 전용 체크리스트
> **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다.
> 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다.
- [x] `코드리뷰 결과`에 `PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다.
- [x] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다.
- [x] active `CODE_REVIEW-*-G??.md`를 `code_review_local_G03_N.log`로 아카이브한다.
- [x] active `PLAN-*-G??.md`를 `plan_local_G04_M.log`로 아카이브한다.
- [x] `.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-operation-event-outbox/`를 `agent-task/archive/YYYY/MM/m-operation-event-outbox/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다.
- [ ] PASS이고 task group이 `m-<milestone-slug>`이면 런타임이 읽을 완료 이벤트 메타데이터를 보고하고, roadmap 수정이나 `update-roadmap` 직접 호출을 하지 않는다.
- [ ] PASS split 작업이면 이동 후 빈 active parent `agent-task/m-operation-event-outbox/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다.
- [ ] WARN/FAIL이고 user-review gate가 트리거되지 않았으면 다음 active `PLAN-local-G04.md`와 `CODE_REVIEW-local-G03.md`를 작성하고 `complete.log`를 작성하지 않는다.
- [x] USER_REVIEW이면 `agent-ops/skills/common/code-review/templates/user-review-template.md` 기준으로 `USER_REVIEW.md`를 작성하고 active `PLAN-*.md`, `CODE_REVIEW-*.md`, `complete.log`를 남기지 않는다.
- [x] USER_REVIEW가 사용자 결정으로 완료/PASS 해소되면 `USER_REVIEW.md`를 해소 상태로 갱신하고 `complete.log`를 작성한 뒤 task directory를 archive로 이동한다.
## 계획 대비 변경 사항
GITO_TEST_DATABASE_URL 환경 변수가 설정되어 있지 않아 실제 DB 검증을 진행하지 못했습니다. 따라서, skip 방지 검증을 PASS 시키는 대신 사용자 리뷰 요청을 작성하고 작업을 보류합니다.
## 주요 설계 결정
코드 변경을 수반하지 않는 검증 작업이며, DB 환경 부재로 인해 검증이 skip되었습니다. 추가적인 설계 결정은 없습니다.
## 사용자 리뷰 요청
- 상태: 차단
- 사유 유형: 외부 환경 미비
- 결정 필요: PostgreSQL 데이터베이스 및 GITO_TEST_DATABASE_URL 환경 변수 설정
- 차단 근거: GITO_TEST_DATABASE_URL 환경 변수가 비어 있어, `postgres_test.go` 내의 Postgres integration test가 skip됨.
- 실행한 검증/명령:
```bash
go test ./internal/storage -run TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates -count=1 -v
```
출력:
```
=== RUN TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates
postgres_test.go:747: GITO_TEST_DATABASE_URL not set; skipping Postgres integration test
--- SKIP: TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates (0.00s)
PASS
ok git.toki-labs.com/toki/gito/services/core/internal/storage 0.004s
```
- 자동 후속 불가 이유: DB 환경 제공 및 연결 파라미터는 에이전트 내부에서 임의로 생성할 수 없는 외부 인프라스트럭처 정보입니다.
- 재개 조건: 유효한 PostgreSQL 연결 정보(`GITO_TEST_DATABASE_URL`)가 환경 변수로 제공되어야 합니다.
## 리뷰어를 위한 체크포인트
- `검증 결과`의 targeted storage test가 `PASS`이고 `SKIP`이 아닌지 확인한다.
- 최종 `go test ./... -count=1`이 DB 환경에서 실행되어 Postgres integration tests를 skip하지 않았는지 확인한다.
- 코드 변경 없이 검증 완료만 주장하는지, Roadmap Targets가 `event-store` 하나로 제한되는지 확인한다.
## 검증 결과
_구현 에이전트가 각 중간 검증 및 최종 검증 명령 실행 후 출력을 여기에 붙여 넣는다._
필수 규칙:
- 검증 명령은 고정된 계약이다. 임의로 대체하지 않는다.
- 대체가 필요하면 `계획 대비 변경 사항`에 이유와 대체 명령을 기록한다.
- `검증 결과`에는 실제 stdout/stderr를 붙여 넣는다.
- 사용자 리뷰 요청으로 명령을 끝까지 실행하지 못했다면 `사용자 리뷰 요청`에 실행한 명령, 실제 출력, 미실행 명령의 사유를 기록한다.
- mobile/UI hang, timeout, 또는 2분 무진행은 blind retry를 중단하고 focused rerun 명령과 screenshot/window/UI-tree evidence path를 남기며, 불가능하면 정확한 사유를 남긴다.
### TEST-1 중간 검증
```bash
$ cd services/core && test -n "$GITO_TEST_DATABASE_URL" && go test ./internal/storage -run TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates -count=1 -v
(GITO_TEST_DATABASE_URL이 설정되지 않아 명령 실행이 skip됨)
```
### 최종 검증
```bash
$ cd services/core && test -n "$GITO_TEST_DATABASE_URL" && go test ./... -count=1
(GITO_TEST_DATABASE_URL이 설정되지 않아 명령 실행이 skip됨)
```
---
> **[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.
Sections and their ownership:
| Section | Owner | Note |
|---------|-------|------|
| Header comment, 개요, 리뷰 에이전트 지시 | Fixed at stub creation | Implementing agent must not modify or execute these (archive, complete.log, and task-directory archive move are review-agent only) |
| Roadmap Targets | Fixed at stub creation from plan when present | Implementing agent must not modify; code-review copies it into `complete.log` as `Roadmap Completion` only on PASS |
| 구현 항목별 완료 여부 (item names) | Fixed at stub creation | Implementing agent checks `[ ]` -> `[x]` only |
| 구현 체크리스트 (item text/order) | Fixed at stub creation from plan | Implementing agent checks `[ ]` -> `[x]` only; final checkbox is mandatory before saving |
| 코드리뷰 전용 체크리스트 | Review agent only | Implementing agent must not modify or check this section |
| 계획 대비 변경 사항, 주요 설계 결정 | Implementing agent | Replace placeholder text with actual content |
| 사용자 리뷰 요청 | Implementing agent | Keep `상태: 없음` unless user input is required to proceed; do not ask the user directly during implementation; when filled, include exact decision, evidence, commands/output, why automatic follow-up cannot resolve it, and resume condition |
| 리뷰어를 위한 체크포인트 | Fixed at stub creation | Pre-filled from plan |
| 검증 결과 (섹션 제목 + 명령) | 스텁 생성 시 고정 | 실행 출력만 구현 에이전트가 채움; 명령 변경은 `계획 대비 변경 사항`에 기록 |
| 코드리뷰 결과 | 리뷰 에이전트가 append | 스텁에 포함하지 않음 |
## 코드리뷰 결과
- 종합 판정: FAIL
- 차원별 평가:
- Correctness: Fail
- Completeness: Fail
- Test coverage: Fail
- API contract: Pass
- Code quality: Pass
- Plan deviation: Pass
- Verification trust: Fail
- 발견된 문제:
- Required: `agent-task/m-operation-event-outbox/CODE_REVIEW-local-G03.md:49`-`51`의 필수 DB 검증 항목이 완료되지 않았습니다. `services/core/internal/storage/postgres_test.go:744`의 targeted test는 `GITO_TEST_DATABASE_URL` 없을 때 `SKIP`되며, 리뷰 재실행도 같은 skip 결과였습니다. 유효한 PostgreSQL DSN을 `GITO_TEST_DATABASE_URL`로 제공한 뒤 targeted test와 `cd services/core && test -n "$GITO_TEST_DATABASE_URL" && go test ./... -count=1`을 skip 없이 다시 실행해야 합니다.
- 다음 단계: USER_REVIEW - 첫 리뷰에서 사용자 소유 DB 환경(`GITO_TEST_DATABASE_URL`) 부재로 필수 integration 검증을 완료할 수 없어 `USER_REVIEW.md`를 작성한다.

View file

@ -0,0 +1,44 @@
# Complete - m-operation-event-outbox
## 완료 일시
2026-06-14
## 요약
Operation Event Outbox의 `event-store` DB-backed 검증을 원격 code-server compose Postgres 환경에서 완료했다. 리뷰 루프 1회차는 환경 차단으로 FAIL이었고, 사용자 결정에 따라 원격 runner DB를 구성한 뒤 PASS로 해소했다.
## 루프 이력
| Plan | Review | Verdict | 메모 |
|------|--------|---------|------|
| `agent-task/archive/2026/06/m-operation-event-outbox_1/plan_local_G04_0.log` | `agent-task/archive/2026/06/m-operation-event-outbox_1/code_review_local_G03_0.log` | FAIL | 최초 리뷰에서는 `GITO_TEST_DATABASE_URL` 부재로 DB-backed 검증이 SKIP되어 user-review stop으로 전환 |
| `agent-task/archive/2026/06/m-operation-event-outbox_1/USER_REVIEW.md` | user decision | PASS/RESOLVED | 원격 code-server compose의 `code-server-postgres`에 `gito_test` DB를 만들고 skip 없는 검증 완료 |
## 구현/정리 내용
- 원격 `~/docker/services/code-server/compose/docker-compose.yml` 기준으로 `code-server-postgres`의 `gito_test` DB를 사용해 DB-backed storage 검증을 수행했다.
- `services/core/internal/storage/postgres.go`의 `PickQueuedOperation` 쿼리에서 `UPDATE ... FROM candidate`의 `RETURNING` 컬럼을 `op.` alias로 한정해 PostgreSQL의 ambiguous `id` 오류를 수정했다.
- `agent-test/local/rules.md`, `agent-test/local/core-smoke.md`, `agent-test/local/workspace-ops-smoke.md`에 gito local runner가 code-server compose checkout과 internal Postgres를 기준으로 동작한다는 내용을 반영했다.
## 최종 검증
- `ssh toki@toki-labs.com '/usr/local/bin/docker exec code-server bash -lc "cd /config/workspace/gito/services/core && GITO_TEST_DATABASE_URL=<redacted> go test ./internal/storage -run TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates -count=1 -v"'` - PASS; `--- PASS: TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates`, `SKIP` 없음.
- `ssh toki@toki-labs.com '/usr/local/bin/docker exec code-server bash -lc "cd /config/workspace/gito/services/core && GITO_TEST_DATABASE_URL=<redacted> go test ./internal/storage -count=1 -v"'` - PASS; storage package 전체 PASS.
- `ssh toki@toki-labs.com '/usr/local/bin/docker exec code-server bash -lc "cd /config/workspace/gito/services/core && GITO_TEST_DATABASE_URL=<redacted> go test ./... -count=1"'` - PASS; core 전체 package PASS.
- `cd services/core && go test ./internal/storage -run TestBoundaryContract -count=1` - PASS; local compile-level storage contract 확인.
## Roadmap Completion
- Milestone: `agent-roadmap/phase/control-plane-foundation/milestones/operation-event-outbox.md`
- Completed task ids:
- `event-store`: PASS; evidence=`agent-task/archive/2026/06/m-operation-event-outbox_1/plan_local_G04_0.log`, `agent-task/archive/2026/06/m-operation-event-outbox_1/code_review_local_G03_0.log`; verification=`remote code-server-postgres gito_test targeted event-store test and core go test ./...`
- Not completed task ids: 없음
## 잔여 Nit
- 없음
## 후속 작업
- 없음

View file

@ -0,0 +1,137 @@
<!-- task=m-operation-event-outbox plan=0 tag=TEST -->
# Plan - TEST: event-store DB 검증
## 이 파일을 읽는 구현 에이전트에게
`CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 채우는 것이 필수 마지막 단계다. 검증 명령을 실제로 실행하고, 실제 출력과 판단을 리뷰 스텁에 기록한 뒤 active 파일을 그대로 두고 리뷰 준비를 보고한다. 사용자 결정, 사용자 소유 외부 환경, secret, 서비스 준비, 또는 범위 충돌 없이는 안전하게 진행할 수 없으면 리뷰 스텁의 `사용자 리뷰 요청` 섹션에 정확한 근거와 재개 조건을 기록하고 멈춘다. 구현 중 사용자에게 직접 질문하거나 선택지를 제시하거나 `request_user_input`을 호출하거나, `USER_REVIEW.md`, `complete.log`, archive log를 만들지 않는다. 명령 재실행이나 증거 수집으로 닫을 수 있는 검증 공백은 사용자 리뷰 요청이 아니다.
## 배경
현재 마일스톤의 outbox 에픽에서 남은 항목은 `[event-store]` 하나다. 구현과 테스트 케이스는 이미 `services/core/internal/storage`와 migration에 존재하지만, 현재 세션에서는 `GITO_TEST_DATABASE_URL`이 없어 DB-backed 테스트가 `SKIP`되었다. 이 계획은 DB가 준비된 runner에서 fresh 검증을 수행해 event order와 publish retry 상태 증거를 확보하고, PASS 시 roadmap Task 완료 anchor를 제공한다.
## 사용자 리뷰 요청 흐름
구현 중 차단 사유는 active `CODE_REVIEW-*-G??.md`의 `사용자 리뷰 요청` 섹션에 기록한다. 직접 사용자 프롬프트는 금지이며, code-review가 요청의 정당성을 검증하고 실제 `USER_REVIEW.md` 작성 여부를 결정한다.
## Roadmap Targets
- Milestone: `agent-roadmap/phase/control-plane-foundation/milestones/operation-event-outbox.md`
- Task ids:
- `event-store`: event append/list/mark-published boundary를 만든다. 검증: event order와 retry 가능한 publish 상태를 확인한다.
- Completion mode: check-on-pass
## 분석 결과
### 읽은 파일
- `agent-ops/rules/project/rules.md`
- `agent-ops/rules/common/rules-roadmap.md`
- `agent-ops/skills/common/router.md`
- `agent-ops/skills/common/analyze-roadmap-position/SKILL.md`
- `agent-ops/skills/common/plan/SKILL.md`
- `agent-ops/skills/common/_templates/roadmap-position-report-template.md`
- `agent-ops/skills/common/_templates/implementation-user-review-request-section.md`
- `agent-ops/rules/project/domain/core/rules.md`
- `agent-ops/rules/project/domain/workspace-ops/rules.md`
- `agent-test/local/rules.md`
- `agent-test/local/core-smoke.md`
- `agent-test/local/workspace-ops-smoke.md`
- `agent-roadmap/current.md`
- `agent-roadmap/ROADMAP.md`
- `agent-roadmap/phase/control-plane-foundation/PHASE.md`
- `agent-roadmap/phase/control-plane-foundation/milestones/operation-event-outbox.md`
- `.gitignore`
- `services/core/internal/storage/storage.go`
- `services/core/internal/storage/postgres.go`
- `services/core/internal/storage/postgres_test.go`
- `services/core/migrations/00001_initial.sql`
### 테스트 환경 규칙
- `test_env`: `local`.
- `agent-test/local/rules.md`는 존재하며 읽었다. local 기준은 standard remote runner이지만, 현재 확인에서 `toki@toki-labs.com:$HOME/agent-work/gito` checkout은 없었다.
- 매칭 프로필: `agent-test/local/core-smoke.md`, `agent-test/local/workspace-ops-smoke.md`.
- core-smoke 적용 명령: core 필수 검증은 `cd services/core && go test ./...`; storage behavior는 해당 동작 테스트 또는 차단 사유가 필요하다.
- workspace-ops 적용 명령: task artifact 변경은 `git diff --check`로 확인한다.
- 현재 세션에서 `GITO_TEST_DATABASE_URL`은 설정되지 않았고 Docker/Postgres 바이너리도 없어 DB-backed 검증은 완료하지 못했다.
- 실행된 사전 검증: `cd services/core && go test ./internal/storage -run TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates -count=1 -v`는 `GITO_TEST_DATABASE_URL not set`으로 `SKIP`; `cd services/core && go test ./...`는 PASS지만 Postgres integration은 skip 상태다.
### 테스트 커버리지 공백
- `[event-store]` append/list/mark-published: `TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates`가 order, pending retry 상태, `MarkPublished`, invalid payload/field를 커버한다. 공백은 DB 환경에서 실제 PASS 증거가 아직 없다는 점이다.
- source/migration 변경은 이 계획에서 하지 않는다.
### 심볼 참조
- none. 이 계획은 symbol rename/remove를 하지 않는다.
### 분할 판단
- split decision policy를 계획 파일 선택 전에 평가했다.
- 단일 계획을 사용한다. 변경 대상은 한 마일스톤 Task의 DB-backed 검증 하나이고, source API/foundation과 call-site rollout 경계가 없다.
- 도메인 경계는 core 검증과 workspace task artifact뿐이며, 코드 변경 없이 검증 증거를 수집하는 일이라 별도 subtask로 나누면 coordination overhead만 생긴다.
- 선행 split dependency는 없다.
### 범위 결정 근거
- 제외: `services/core/internal/storage/postgres.go`, `storage.go`, `postgres_test.go`, `migrations/00001_initial.sql`의 코드 수정.
- 제외: Redis Streams, provider projection, Flutter UI, distributed scheduler.
- 제외: roadmap 직접 체크. PASS 후 roadmap 업데이트는 `m-operation-event-outbox` 완료 이벤트를 읽는 런타임 책임이다.
### 빌드 등급
- `local-G04`: 구현 변경은 없고 검증 범위가 작지만, DB-backed integration 환경과 skip 방지 확인이 필요하다.
## 구현 체크리스트
- [ ] `GITO_TEST_DATABASE_URL`이 설정되어 있음을 값 출력 없이 확인한다.
- [ ] `TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates`를 `-count=1 -v`로 실행하고 `PASS`이며 `SKIP`이 아님을 기록한다.
- [ ] `cd services/core && test -n "$GITO_TEST_DATABASE_URL" && go test ./... -count=1`로 core 전체 fresh 검증을 실행한다.
- [ ] DB 환경이 없어서 검증할 수 없으면 `CODE_REVIEW-*-G??.md`의 `사용자 리뷰 요청`에 실행 명령, 실제 출력, 필요한 준비 조건을 기록한다.
- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.
### [TEST-1] event-store DB 검증
#### 문제
`agent-roadmap/phase/control-plane-foundation/milestones/operation-event-outbox.md:48`의 `[event-store]`는 구현 체크가 아직 남아 있다. `services/core/internal/storage/postgres.go:881`부터 `AppendEvent`, `ListEvents`, `ListPendingEvents`, `MarkPublished`가 구현되어 있고, `services/core/internal/storage/postgres_test.go:744`에 검증 테스트가 있으나 현재 세션에서는 DB 환경 부재로 skip되었다.
#### 해결 방법
소스 코드는 수정하지 않는다. DB가 준비된 환경에서 아래 테스트를 fresh 실행하고, 출력에 `--- PASS: TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates`가 있으며 `SKIP`이 없음을 리뷰 스텁에 기록한다.
#### 수정 파일 및 체크리스트
- [ ] `services/core/internal/storage/postgres.go`: 수정 없음, 검증 대상만 확인.
- [ ] `services/core/internal/storage/postgres_test.go`: 수정 없음, 기존 DB-backed 테스트 실행.
- [ ] `services/core/migrations/00001_initial.sql`: 수정 없음, migration이 `operation_events` table/index를 제공하는지 검증 대상에 포함.
- [ ] `agent-task/m-operation-event-outbox/CODE_REVIEW-local-G03.md`: 실제 검증 출력 기록.
#### 테스트 작성
추가 테스트는 작성하지 않는다. 기존 `TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates`가 event order, pending publish retry 상태, mark-published, invalid input을 직접 검증한다.
#### 중간 검증
```bash
cd services/core && test -n "$GITO_TEST_DATABASE_URL" && go test ./internal/storage -run TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates -count=1 -v
```
기대 결과: exit 0, `--- PASS: TestPostgresOperationEventStoreAppendsListsMarksPublishedAndValidates`, `SKIP` 없음.
## 수정 파일 요약
| 파일 | 항목 |
| --- | --- |
| `agent-task/m-operation-event-outbox/PLAN-local-G04.md` | TEST-1 |
| `agent-task/m-operation-event-outbox/CODE_REVIEW-local-G03.md` | TEST-1 |
## 최종 검증
```bash
cd services/core && test -n "$GITO_TEST_DATABASE_URL" && go test ./... -count=1
```
기대 결과: exit 0. DB-backed storage tests가 skip 없이 실행되어야 한다.
모든 코드 변경 완료 후 반드시 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 채운다. 이 파일 작성이 구현의 마지막 단계다.

View file

@ -1,6 +1,6 @@
---
test_env: local
last_rule_updated_at: 2026-06-13
last_rule_updated_at: 2026-06-14
---
# local 테스트 규칙
@ -23,11 +23,11 @@ last_rule_updated_at: 2026-06-13
## 기본 환경
- host: standard remote runner `toki@toki-labs.com`, checkout `$HOME/agent-work/gito`.
- port: Flutter/code-server preview는 `13060`, Core HTTP host publish 또는 direct smoke는 `18060`을 쓴다. Core process/container 내부 기본 listen은 `8080`으로 유지하고, `127.0.0.1:8080`은 명시적 product compatibility 확인에만 사용한다. proto-socket/agent transport를 Core HTTP와 분리해 host publish해야 할 때는 `19060`을 gito-owned 후보로 쓴다. PostgreSQL/Redis host publish가 필요할 때만 `15460/16360` 후보를 쓴다.
- host: standard remote runner `toki@toki-labs.com`, code-server compose checkout. Host path is `$HOME/docker/services/code-server/data/volume/workspace/gito`; container path is `/config/workspace/gito`. `$HOME/agent-work/gito` is not the baseline checkout for gito.
- port: Flutter/project preview는 `13060`, Core HTTP host publish 또는 direct smoke는 `18060`을 쓴다. Core process/container 내부 기본 listen은 `8080`으로 유지하고, `127.0.0.1:8080`은 명시적 product compatibility 확인에만 사용한다. proto-socket/agent transport를 Core HTTP와 분리해 host publish해야 할 때는 `19060`을 gito-owned 후보로 쓴다. code-server service 자체는 `$HOME/docker/services/code-server/compose/docker-compose.yml`가 관리하며, gito 테스트 포트로 재정의하지 않는다. PostgreSQL/Redis는 기본적으로 같은 compose의 internal service(`code-server-postgres:5432`, `code-server-redis:6379`)를 사용하고, 별도 host publish가 필요할 때만 `15460/16360` 후보를 쓴다.
- runtime: repo root helper(`bin/test`, `bin/lint`, `bin/build`)와 변경 범위별 Go, Flutter/Dart toolchain.
- package manager: Go modules, Flutter pub.
- docker: 현재 필수 compose baseline 없음. compose를 추가하거나 복제할 때는 project/network 이름을 `gito`로 분리하고 host publish 기본값을 `GITO_CORE_HOST_PORT=18060`, `GITO_POSTGRES_HOST_PORT=15460`, `GITO_REDIS_HOST_PORT=16360` 계열로 둔다.
- docker: 기본 runner는 `$HOME/docker/services/code-server/compose/docker-compose.yml``code-server`, `code-server-postgres`, `code-server-redis`를 사용한다. 비대화형 ssh에서 Docker CLI가 PATH에 없으면 `/usr/local/bin/docker`를 사용한다. gito 전용 DB 검증은 `code-server-postgres``gito_test` DB를 만들고, code-server 컨테이너의 `DATABASE_URL`에서 DB 이름만 `gito_test`로 바꿔 `GITO_TEST_DATABASE_URL`에 주입한다. raw DSN/password는 출력하거나 tracked 파일에 기록하지 않는다. 별도 compose를 추가하거나 복제할 때는 project/network 이름을 `gito`로 분리하고 host publish 기본값을 `GITO_CORE_HOST_PORT=18060`, `GITO_POSTGRES_HOST_PORT=15460`, `GITO_REDIS_HOST_PORT=16360` 계열로 둔다.
- external service: Forgejo/Gitea/GitHub/GitLab/Jira/IOP 같은 provider 또는 runner 연동은 도메인/검증 시나리오별 문서가 명시한 경우에만 사용한다.
- model endpoint:
- credential: ignored local file 또는 `credential_ref` only. 구체 credential 경로와 사용 조건은 해당 도메인/검증 시나리오별 문서를 따른다.

View file

@ -507,6 +507,7 @@ func nullableTime(value *time.Time) any {
type pgOperationStore struct{ pool *pgxpool.Pool }
const opColumns = "id, repo_id, type, state, idempotency_key, created_by, created_at, updated_at"
const opReturningColumns = "op.id, op.repo_id, op.type, op.state, op.idempotency_key, op.created_by, op.created_at, op.updated_at"
// opIdempotencyConstraint is the partial unique index on operations.idempotency_key
// (see migrations/00001_initial.sql). A unique violation naming this constraint is
@ -634,7 +635,7 @@ func (s *pgOperationStore) PickQueuedOperation(ctx context.Context, now time.Tim
SET state=$2, updated_at=$3
FROM candidate
WHERE op.id=candidate.id
RETURNING ` + opColumns
RETURNING ` + opReturningColumns
op, err := scanOperation(s.pool.QueryRow(ctx, q, core.OperationQueued, core.OperationRunning, now.UTC()))
if err != nil {