feat: messaging contract phase G06 completion - add PLAN and CODE_REVIEW docs, update roadmap

This commit is contained in:
toki 2026-05-30 21:29:07 +09:00
parent b362dfc354
commit 4a98eb0cc2
6 changed files with 437 additions and 4 deletions

View file

@ -7,7 +7,7 @@
## 활성 Milestone
- [계획] 메시징 계약 표준화
- [진행중] 메시징 계약 표준화
- Phase: `agent-roadmap/phase/messaging-runtime/PHASE.md`
- 경로: `agent-roadmap/phase/messaging-runtime/milestones/messaging-contract.md`

View file

@ -16,7 +16,7 @@ Mattermost server/webapp/push-proxy는 upstream-followable runtime으로 두고,
완료, 검토중, 진행중, 계획, 스케치 순서로 두어 아래로 갈수록 미래 작업에 가까워지게 정렬한다.
스케치 Milestone은 아직 구현 가능한 계획이 아니므로 계획 Milestone보다 아래에 둔다.
- [계획] 메시징 계약 표준화
- [진행중] 메시징 계약 표준화
- 경로: `agent-roadmap/phase/messaging-runtime/milestones/messaging-contract.md`
- 요약: 서버와 Flutter 플러그인이 공유할 메시징/알림 API, 이벤트, 저장 계약을 정리한다.
- [계획] 알림 파이프라인 고도화

View file

@ -12,7 +12,7 @@ upstream-followable server/push runtime과 nexo-owned Flutter SDK가 주고받
## 상태
[계획]
[진행중]
## 승격 조건
@ -40,7 +40,7 @@ upstream-followable server/push runtime과 nexo-owned Flutter SDK가 주고받
앱이 의존할 수 있는 최소 메시징/알림 API 표면을 정리한다.
- [ ] [dart-api] Dart public API에서 유지할 이름, deprecated 후보, nexo wrapper 후보를 분리한다.
- [x] [dart-api] Dart public API에서 유지할 이름, deprecated 후보, nexo wrapper 후보를 분리한다.
- [ ] [event-shape] notification event, opened event, token event의 payload shape와 backward compatibility 기준을 문서화한다.
- [ ] [token-flow] device token 저장, auth token 저장, signing key 저장 책임과 호출 순서를 정리한다.
- [ ] [sdk-runtime-boundary] Flutter SDK가 server/push contract를 추적하되 Mattermost mobile implementation을 팔로잉하지 않는 경계를 문서화한다.
@ -74,6 +74,7 @@ upstream-followable server/push runtime과 nexo-owned Flutter SDK가 주고받
- 관련 경로: `packages/messaging_flutter/lib/`, `packages/messaging_flutter/android/`, `services/core/server/`, `services/core/webapp/`, `services/core/compose/`, `apps/flutter-test/`
- 표준선(선택): SDK public API는 nexo-owned wrapper로 유지하고, server/webapp/push-proxy compatibility는 얇은 layer로 흡수한다
- 진행 근거: 2026-05-30 `packages/messaging_flutter/README.md`에 Public API Contract 섹션을 추가해 유지 API, compatibility/deprecated 후보, nexo wrapper 후보를 분리했다.
- 선행 작업: 정체성 기준선, 업스트림 팔로잉 기준선, 클라이언트 검증 기준선
- 후속 작업: 알림 파이프라인 고도화, 멀티앱 채널 모델
- 확인 필요: Flutter 앱 우선 노출 범위

View file

@ -0,0 +1,157 @@
<!-- task=m-messaging-contract 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.
> 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-05-30
task=m-messaging-contract, plan=0, tag=API
## Roadmap Targets
- Milestone: `agent-roadmap/phase/messaging-runtime/milestones/messaging-contract.md`
- Task ids:
- `event-shape`: notification event, opened event, token event의 payload shape와 backward compatibility 기준을 문서화한다.
- `token-flow`: device token 저장, auth token 저장, signing key 저장 책임과 호출 순서를 정리한다.
- `sdk-runtime-boundary`: Flutter SDK가 server/push contract를 추적하되 Mattermost mobile implementation을 팔로잉하지 않는 경계를 문서화한다.
- Completion mode: check-on-pass
## 이 파일을 읽는 리뷰 에이전트에게
> **[REVIEW AGENT ONLY]** 아래 종결 절차는 코드리뷰 에이전트 전용이다. 구현 에이전트는 이 섹션을 실행하지 않는다.
각 항목의 구현을 실제 소스 파일과 대조하고, `검증 결과` 섹션의 출력이 코드와 일치하는지 확인하세요.
리뷰 완료는 아래 순서까지 끝난 상태를 의미합니다.
1. 판정을 append한다.
2. `CODE_REVIEW-cloud-G06.md``code_review_cloud_G06_N.log`, `PLAN-cloud-G06.md``plan_cloud_G06_M.log`로 아카이브한다.
3. PASS이면 `complete.log` 작성 후 active task 디렉터리를 `agent-task/archive/YYYY/MM/m-messaging-contract/`로 이동한다. 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] Event Shape Contract | [ ] |
| [API-2] Token And Credential Flow | [ ] |
| [API-3] Runtime Tracking Boundary | [ ] |
## 구현 체크리스트
- [ ] README에 Event Shape Contract를 추가하고 notification/opened/token event payload shape와 backward compatibility 기준을 문서화한다.
- [ ] README에 Token and Credential Flow를 추가하고 device token, auth token, signing key 저장 책임과 호출 순서를 정리한다.
- [ ] README에 Runtime Tracking Boundary를 보강하고 Flutter SDK가 server/push contract를 추적하되 Mattermost mobile implementation을 팔로잉하지 않는 경계를 문서화한다.
- [ ] 최종 static verification 명령을 실행하고 출력 전체를 `CODE_REVIEW-cloud-G06.md`에 기록한다.
- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.
## 코드리뷰 전용 체크리스트
> **[REVIEW AGENT ONLY]** 이 체크리스트는 코드리뷰 에이전트만 사용한다.
> 구현 에이전트는 이 섹션을 수정하거나 체크하지 않는다.
- [ ] `코드리뷰 결과``PASS`, `WARN`, `FAIL` 중 하나의 판정을 append한다.
- [ ] 판정과 `차원별 평가`, Required/Suggested/Nit 분류가 서로 일치한다.
- [ ] active `CODE_REVIEW-*-G??.md``code_review_cloud_G06_N.log`로 아카이브한다.
- [ ] active `PLAN-*-G??.md``plan_cloud_G06_M.log`로 아카이브한다.
- [ ] PASS이면 `agent-ops/skills/common/code-review/templates/complete-log-template.md` 기준으로 `complete.log`를 작성하고 active `.md` 파일을 남기지 않는다.
- [ ] PASS이면 active task 디렉터리 `agent-task/m-messaging-contract/``agent-task/archive/YYYY/MM/m-messaging-contract/`로 이동하고 최종 archive 경로에서 이 체크리스트를 갱신한다.
- [ ] PASS이고 task group이 `m-<milestone-slug>`이면 런타임이 읽을 완료 이벤트 메타데이터를 보고하고, roadmap 수정이나 `update-roadmap` 직접 호출을 하지 않는다.
- [ ] PASS split 작업이면 이동 후 빈 active parent `agent-task/m-messaging-contract/`를 제거하거나, 남은 sibling/file이 있어 유지했다고 확인한다.
- [ ] WARN/FAIL이고 user-review gate가 트리거되지 않았으면 다음 active `PLAN-cloud-G06.md``CODE_REVIEW-cloud-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 파일을 그대로 둔 채 리뷰를 요청한다. 후속 에이전트가 명령 재실행이나 산출물 수집으로 해소할 수 있는 검증 증거 공백만으로는 사용자 리뷰 요청을 작성하지 않는다._
- 상태: 없음
- 사유 유형: 없음
- 결정 필요: 없음
- 차단 근거: 없음
- 실행한 검증/명령: 없음
- 자동 후속 불가 이유: 없음
- 재개 조건: 없음
## 리뷰어를 위한 체크포인트
- README의 event shape가 Dart parsing과 Android event emission behavior를 과장하지 않는지 확인한다.
- token/auth/signing key 흐름이 현재 native implementation과 맞고 secret 값을 문서에 남기지 않았는지 확인한다.
- runtime boundary가 Mattermost mobile implementation을 추적 대상으로 오해하게 만들지 않는지 확인한다.
## 검증 결과
_구현 에이전트가 각 중간 검증 및 최종 검증 명령 실행 후 출력을 여기에 붙여 넣는다._
필수 규칙:
- 검증 명령은 고정된 계약이다. 임의로 대체하지 않는다.
- 대체가 필요하면 `계획 대비 변경 사항`에 이유와 대체 명령을 기록한다.
- `검증 결과`에는 실제 stdout/stderr를 붙여 넣는다.
- 사용자 리뷰 요청으로 명령을 끝까지 실행하지 못했다면 `사용자 리뷰 요청`에 실행한 명령, 실제 출력, 미실행 명령의 사유를 기록한다.
### API-1 중간 검증
```
$ rg --sort path "Event Shape Contract|userInteraction|token_refresh|is_crt_enabled" packages/messaging_flutter/README.md
(output)
```
### API-2 중간 검증
```
$ rg --sort path "Token And Credential Flow|android_rn-v2|setAuthToken|setSigningKey|saveDeviceToken|clearAuthToken" packages/messaging_flutter/README.md
(output)
```
### API-3 중간 검증
```
$ rg --sort path "Runtime Tracking Boundary|server/push contract|Mattermost mobile|React Native|typed" packages/messaging_flutter/README.md
(output)
```
### 최종 검증
```
$ git diff --check
(output)
$ rg --sort path "Event Shape Contract|Token And Credential Flow|Runtime Tracking Boundary" packages/messaging_flutter/README.md
(output)
```
---
> **[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.
## 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; 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 |
| 검증 결과 (section headings + commands) | Fixed at stub creation | Implementing agent fills in command output only; command changes require a `계획 대비 변경 사항` entry |
| 코드리뷰 결과 | Review agent appends | Not included in stub |

View file

@ -0,0 +1,248 @@
<!-- task=m-messaging-contract plan=0 tag=API -->
# Plan - API Public Contract Docs
## 이 파일을 읽는 구현 에이전트에게
`CODE_REVIEW-cloud-G06.md`의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채우는 것이 필수입니다. 구현 후 검증을 실행하고, 실제 notes/output을 채우고, active 파일은 그대로 둔 뒤 리뷰 준비를 보고하세요. 최종 판정, log archive, `complete.log` 작성은 code-review-skill 전용입니다. 구현 중 사용자만 결정할 수 있는 범위 변경, 사용자 소유 외부 환경/secret/서비스 준비, 또는 계획 범위 충돌로 막히면 review stub의 `사용자 리뷰 요청` 섹션에 정확한 근거를 남기고 중단하세요. 후속 에이전트가 명령 재실행이나 산출물 수집으로 해결할 수 있는 evidence gap은 사용자 리뷰 요청이 아닙니다.
## 배경
첫 번째 Epic의 `dart-api`는 README의 Public API Contract로 정리되었지만, 나머지 공개 계약은 아직 raw event map, token/credential 저장 순서, runtime 추적 경계가 흩어져 있습니다. 이 작업은 코드 동작을 바꾸지 않고 `packages/messaging_flutter/README.md`에 남은 계약을 명시해 소비 앱과 후속 구현 계획의 기준선을 고정합니다. Milestone의 API rename 구현은 범위 제외이므로 문서 계약만 다룹니다.
## 사용자 리뷰 요청 흐름
Implementation-time blockers are recorded in the active review stub's `사용자 리뷰 요청` section, copied from `agent-ops/skills/common/_templates/implementation-user-review-request-section.md`; code-review owns validation and the actual `USER_REVIEW.md` file write.
## Roadmap Targets
- Milestone: `agent-roadmap/phase/messaging-runtime/milestones/messaging-contract.md`
- Task ids:
- `event-shape`: notification event, opened event, token event의 payload shape와 backward compatibility 기준을 문서화한다.
- `token-flow`: device token 저장, auth token 저장, signing key 저장 책임과 호출 순서를 정리한다.
- `sdk-runtime-boundary`: Flutter SDK가 server/push contract를 추적하되 Mattermost mobile implementation을 팔로잉하지 않는 경계를 문서화한다.
- Completion mode: check-on-pass
## 분석 결과
### 읽은 파일
- `agent-roadmap/current.md`
- `agent-roadmap/phase/messaging-runtime/PHASE.md`
- `agent-roadmap/phase/messaging-runtime/milestones/messaging-contract.md`
- `agent-ops/rules/project/domain/messaging-flutter/rules.md`
- `agent-ops/rules/project/domain/client-app/rules.md`
- `agent-ops/rules/project/domain/workspace-ops/rules.md`
- `agent-test/local/rules.md`
- `agent-test/local/messaging-flutter-smoke.md`
- `agent-test/local/client-app-smoke.md`
- `packages/messaging_flutter/README.md`
- `packages/messaging_flutter/lib/nexo_messaging.dart`
- `packages/messaging_flutter/lib/src/nexo_messaging_plugin.dart`
- `packages/messaging_flutter/lib/src/notification_opened_event.dart`
- `packages/messaging_flutter/lib/src/push_notification_type.dart`
- `packages/messaging_flutter/android/src/main/kotlin/com/tokilabs/nexo/messaging/NexoMessagingPlugin.kt`
- `packages/messaging_flutter/android/src/main/kotlin/com/tokilabs/nexo/messaging/PushNotificationEvents.kt`
- `packages/messaging_flutter/android/src/main/kotlin/com/tokilabs/nexo/messaging/NexoFirebaseMessagingService.kt`
- `packages/messaging_flutter/android/src/main/kotlin/com/tokilabs/nexo/messaging/LaunchIntentHelper.kt`
- `packages/messaging_flutter/android/src/main/kotlin/com/tokilabs/nexo/messaging/helpers/DatabaseHelper.kt`
- `packages/messaging_flutter/android/src/main/kotlin/com/tokilabs/nexo/messaging/helpers/PushNotificationDataHelper.kt`
- `packages/messaging_flutter/android/src/main/java/com/tokilabs/nexo/messaging/helpers/CustomPushNotificationHelper.java`
- `packages/messaging_flutter/android/src/main/java/com/tokilabs/nexo/messaging/ReceiptDelivery.java`
- `packages/messaging_flutter/android/src/main/java/com/tokilabs/nexo/messaging/NotificationReplyBroadcastReceiver.java`
- `packages/messaging_flutter/android/src/main/java/com/tokilabs/nexo/messaging/NotificationDismissService.java`
- `packages/messaging_flutter/test/nexo_messaging_test.dart`
- `packages/messaging_flutter/android/src/test/kotlin/com/tokilabs/nexo/messaging/NexoMessagingPluginTest.kt`
- `apps/flutter-test/lib/main.dart`
- `apps/flutter-test/test/widget_test.dart`
- `apps/flutter-test/integration_test/plugin_integration_test.dart`
### 테스트 환경 규칙
`test_env=local`을 선택했고 `agent-test/local/rules.md`를 읽었습니다. 이 파일은 현재 로컬 테스트 실행을 금지하고 기본 테스트 환경을 원격으로 보도록 요구합니다. `packages/messaging_flutter/**`에 해당해 `agent-test/local/messaging-flutter-smoke.md`를 읽었고, host routing coverage 확인을 위해 `agent-test/local/client-app-smoke.md`도 읽었습니다. Profile에는 `cd packages/messaging_flutter && flutter test`, `flutter analyze --no-fatal-infos`, `bin/test`가 적혀 있지만 이번 계획은 docs-only 변경이므로 final verification은 deterministic static checks와 `git diff --check`로 제한합니다. Flutter/Gradle test는 이 계획의 필수 명령으로 지정하지 않습니다.
### 테스트 커버리지 공백
- `event-shape`: 기존 Dart tests가 `NotificationOpenedEvent`, opened routing, raw `onNotification`, token_refresh save를 커버합니다. README 계약 추가 자체를 검증하는 테스트는 없으므로 `rg --sort path` 문서 확인으로 보완합니다.
- `token-flow`: Dart tests가 token_refresh formatting을 커버하고 Android unit tests가 method-channel invalid args를 커버합니다. 실제 native DB persistence, SharedPreferences signing-key fallback, FCM `onNewToken` end-to-end는 이 문서 작업에서 새 테스트를 추가하지 않습니다.
- `sdk-runtime-boundary`: README와 domain rule에 경계가 있고 자동 테스트는 없습니다. 문서 anchor 확인만 수행합니다.
### 심볼 참조
Renamed/removed symbols: none.
### 분할 판단
Split decision policy를 먼저 평가했습니다. 남은 세 roadmap Task는 모두 `packages/messaging_flutter/README.md`의 계약 문서 보강이며 코드, package manifest, test file 변경이 없습니다. API foundation과 call-site rollout이 분리되지 않고, ownership boundary도 `messaging-flutter` package docs 하나입니다. event/token/boundary가 서로 참조하는 같은 표면을 설명하므로 단일 plan이 중복 수정보다 안전합니다.
### 범위 결정 근거
수정 범위는 `packages/messaging_flutter/README.md`로 제한합니다. Dart API rename, typed event wrapper 구현, method-channel contract 변경, Android native storage 변경, server payload/ACK contract 문서화는 이 계획에서 제외합니다. `apps/flutter-test/**`는 coverage 참고만 했고 test host 변경은 하지 않습니다.
### 빌드 등급
Build lane `cloud-G06`, review lane `cloud-G06`. 코드 변경은 없지만 protocol/schema, storage, auth-token/signing-key 계약을 문서로 고정하므로 review 판단 난이도가 중간 이상입니다.
## 구현 체크리스트
- [ ] README에 Event Shape Contract를 추가하고 notification/opened/token event payload shape와 backward compatibility 기준을 문서화한다.
- [ ] README에 Token and Credential Flow를 추가하고 device token, auth token, signing key 저장 책임과 호출 순서를 정리한다.
- [ ] README에 Runtime Tracking Boundary를 보강하고 Flutter SDK가 server/push contract를 추적하되 Mattermost mobile implementation을 팔로잉하지 않는 경계를 문서화한다.
- [ ] 최종 static verification 명령을 실행하고 출력 전체를 `CODE_REVIEW-cloud-G06.md`에 기록한다.
- [ ] CODE_REVIEW-*-G??.md의 구현 에이전트 소유 섹션을 실제 구현 내용과 검증 출력으로 채운다. 이 항목이 완료되기 전에는 구현이 완료된 것이 아니다.
### [API-1] Event Shape Contract
문제: `packages/messaging_flutter/README.md:194`의 Event Types는 type 목록만 있고, native event map이 Flutter로 들어오는 shape, opened routing fields, `token_refresh` payload, `userInteraction` compatibility 기준을 한 곳에 고정하지 않습니다. Dart는 raw map을 `onNotification`으로 그대로 흘리고 `opened`만 typed event로 변환합니다(`packages/messaging_flutter/lib/src/nexo_messaging_plugin.dart:103`, `packages/messaging_flutter/lib/src/nexo_messaging_plugin.dart:148`). Android intent payload는 missing type을 `opened`로 보정하고 `userInteraction=true`를 붙입니다(`packages/messaging_flutter/android/src/main/kotlin/com/tokilabs/nexo/messaging/NexoMessagingPlugin.kt:123`).
해결 방법:
Before:
```markdown
packages/messaging_flutter/README.md:194
## Event Types
The Dart API currently recognizes these native event types:
```
After:
```markdown
## Event Shape Contract
Native events are delivered as codec-safe maps on `onNotification`. The stable
routing fields are ...
| Event | Required fields | Optional fields | Compatibility |
| --- | --- | --- | --- |
| `opened` | `type` | `server_url`, `channel_id`, `root_id`, `is_crt_enabled`, `userInteraction` | Missing native type from launch intents is treated as `opened`. |
| `message` | `type` | ... | `userInteraction: true` routes through opened handling. |
| `token_refresh` | `type`, `token` | none | `token` is raw FCM input; Dart formats before storage/callback. |
```
수정 파일 및 체크리스트:
- [ ] `packages/messaging_flutter/README.md`: `## Event Shape Contract``## Event Types` 앞 또는 바로 아래에 추가한다.
- [ ] `opened`, `message`, `clear`, `session`, `token_refresh`의 Dart-facing payload shape를 표로 정리한다.
- [ ] `is_crt_enabled`는 현재 string `"true"`만 true로 파싱된다고 명시한다.
- [ ] `server_url` 누락 시 Android가 `server_id` 또는 단일 저장 server URL로 보정할 수 있음을 compatibility note로 남긴다.
테스트 작성: skip. 문서-only 변경이며 기존 tests가 `NotificationOpenedEvent.fromMap`, opened routing, raw event forwarding, `token_refresh` formatting을 이미 커버합니다.
중간 검증:
```sh
rg --sort path "Event Shape Contract|userInteraction|token_refresh|is_crt_enabled" packages/messaging_flutter/README.md
```
기대 결과: 새 섹션명과 event compatibility keywords가 README에서 확인됩니다.
### [API-2] Token And Credential Flow
문제: README의 Host App Responsibilities와 Dart Usage에는 credential API 호출 예시가 있지만, `initialize()`의 FCM token 흐름, Dart-side `android_rn-v2:` formatting, native `saveDeviceToken`, auth token 저장, signing-key 저장, signature verification 의존 관계가 순서대로 연결되어 있지 않습니다. Dart는 `_saveDeviceToken`에서 formatted token을 method channel로 저장합니다(`packages/messaging_flutter/lib/src/nexo_messaging_plugin.dart:209`). Android는 `saveDeviceToken`, `setAuthToken`, `setSigningKey`, `clearAuthToken`을 method-channel action으로 처리합니다(`packages/messaging_flutter/android/src/main/kotlin/com/tokilabs/nexo/messaging/NexoMessagingPlugin.kt:186`). Native signature verification은 stored device token과 signing key를 사용합니다(`packages/messaging_flutter/android/src/main/java/com/tokilabs/nexo/messaging/helpers/CustomPushNotificationHelper.java:189`, `packages/messaging_flutter/android/src/main/java/com/tokilabs/nexo/messaging/helpers/CustomPushNotificationHelper.java:204`).
해결 방법:
Before:
```markdown
packages/messaging_flutter/README.md:137
Handle device-token registration:
...
packages/messaging_flutter/README.md:146
Store credentials and signing keys:
```
After:
```markdown
## Token And Credential Flow
1. Host app initializes Firebase and calls `initialize()`.
2. The SDK listens to FCM token refresh and requests permission/current token.
3. Dart formats raw FCM tokens as `android_rn-v2:<token>` before native storage.
4. Host app sends the formatted token to the server; native code uses the stored
token for signed push verification.
...
```
수정 파일 및 체크리스트:
- [ ] `packages/messaging_flutter/README.md`: `## Token And Credential Flow`를 추가한다.
- [ ] device token, auth token, signing key 흐름을 호출 순서로 정리한다.
- [ ] `setAuthToken`이 native ACK/reply HTTP token과 server URL identifier lookup을 준비한다고 명시한다.
- [ ] `setSigningKey`가 native signing-key fallback 저장소를 채우며, DB config signing key가 있으면 native verification이 우선 사용할 수 있음을 명시한다.
- [ ] `clearAuthToken`은 HTTP token clear 책임이고 server URL mapping 삭제 API가 아니라는 현재 contract를 명시한다.
테스트 작성: skip. 문서-only 변경입니다. 기존 Dart test는 formatted token callback을 확인하고 Android unit tests는 method-channel invalid arg paths를 확인합니다.
중간 검증:
```sh
rg --sort path "Token And Credential Flow|android_rn-v2|setAuthToken|setSigningKey|saveDeviceToken|clearAuthToken" packages/messaging_flutter/README.md
```
기대 결과: token/auth/signing key flow keywords가 README에서 확인됩니다.
### [API-3] Runtime Tracking Boundary
문제: README의 SDK Ownership Boundary는 패키지가 Mattermost mobile source tree를 mirror하지 않는다고 말하지만(`packages/messaging_flutter/README.md:11`), Public API Contract 아래 후보 wrapper와 runtime tracking 기준이 충분히 연결되어 있지 않습니다. Phase 경계도 `packages/messaging_flutter/android`가 Mattermost mobile merge 대상이 아니라 server/push 계약과 Android/FCM platform 변화를 추적한다고 정의합니다(`agent-roadmap/phase/messaging-runtime/PHASE.md:31`).
해결 방법:
Before:
```markdown
packages/messaging_flutter/README.md:11
## SDK Ownership Boundary
This package is the nexo-owned embedded messaging SDK. Its Android
implementation follows the nexo server/push contract, Android and FCM platform
changes, and Flutter plugin registration behavior.
```
After:
```markdown
## Runtime Tracking Boundary
The SDK tracks server/push payload fields, ACK/reply endpoints, signing-key and
device-token compatibility, Android/FCM behavior, and Flutter plugin
registration. It does not track Mattermost mobile screens, stores, navigation
state, or React Native implementation details.
```
수정 파일 및 체크리스트:
- [ ] `packages/messaging_flutter/README.md`: `## Runtime Tracking Boundary`를 추가하거나 `## SDK Ownership Boundary` 아래에 보강한다.
- [ ] 추적 대상: server/push payload fields, ACK/reply endpoints, signing-key/device-token compatibility, Android/FCM behavior, Flutter plugin registration.
- [ ] 추적 제외: Mattermost mobile source tree, React Native app screens/stores/navigation state, product UI/business logic.
- [ ] 첫 Epic의 Public API Contract와 연결해 typed wrapper 후보는 contract 문서화 이후 별도 구현으로 남긴다고 명시한다.
테스트 작성: skip. 문서-only boundary clarification입니다.
중간 검증:
```sh
rg --sort path "Runtime Tracking Boundary|server/push contract|Mattermost mobile|React Native|typed" packages/messaging_flutter/README.md
```
기대 결과: runtime tracking boundary와 excluded implementation details가 README에서 확인됩니다.
## 수정 파일 요약
| 파일 | 항목 |
| --- | --- |
| `packages/messaging_flutter/README.md` | API-1, API-2, API-3 |
## 최종 검증
```sh
git diff --check
rg --sort path "Event Shape Contract|Token And Credential Flow|Runtime Tracking Boundary" packages/messaging_flutter/README.md
```
기대 결과: `git diff --check` 출력 없이 exit code 0, `rg`는 세 섹션명을 모두 출력합니다.
모든 코드 변경 완료 후 반드시 `CODE_REVIEW-*-G??.md`의 구현 에이전트 소유 섹션을 채운다. 이 파일 작성이 구현의 마지막 단계다.

View file

@ -164,6 +164,33 @@ await NexoMessagingPlugin.instance.clearAuthToken(
final token = await NexoMessagingPlugin.instance.getDeviceToken();
```
## Public API Contract
Apps should import only `package:nexo_messaging/nexo_messaging.dart`. The
exported Dart surface is the nexo SDK contract; method-channel names, native
payload internals, and token formatting remain compatibility details unless
they are listed here.
| Surface | Status | Contract |
| --- | --- | --- |
| `NexoMessagingPlugin.instance` | Keep | Singleton entry point for host app startup, event subscription, credential storage, and token lookup. |
| `initialize()` / `dispose()` | Keep | Plugin lifecycle hooks. Host apps call `initialize()` during startup and `dispose()` only when intentionally tearing down the SDK instance. |
| `onNotification` | Keep, compatibility | Raw native event stream for advanced diagnostics and compatibility. Host apps should avoid product routing decisions that depend on untyped map fields. |
| `onNotificationOpened` | Keep | Typed stream for notification-open routing through `NotificationOpenedEvent`. |
| `onNavigateToChannel` / `onNavigateToThread` | Keep | Optional host-router callbacks. Screen ownership and product navigation remain outside this package. |
| `onDeviceTokenReady` / `getDeviceToken()` | Keep | Device-token handoff to the host app and server registration flow. The `android_rn-v2:` prefix is a server compatibility detail, not an app parsing contract. |
| `setAuthToken()` / `clearAuthToken()` | Keep | Auth-token persistence bridge for native ACK and reply delivery. |
| `setSigningKey()` | Keep | Server signing-key persistence bridge for native push verification. |
| `NotificationOpenedEvent` | Keep | Stable Dart value object for opened notification routing fields. |
| `PushNotificationType` | Compatibility | Native event string constants. Future typed event wrappers should reduce direct app branching on these constants. |
| `notificationChannelName`, `actionChannelName`, `listenNativeChannelForTesting()`, `debugSendNativeEventForTesting()`, `handleNativeEvent()` | Testing-only | Exposed for repository-owned tests through `@visibleForTesting`; consuming apps should not depend on them. |
Deprecated candidates are compatibility-only app dependencies on raw
`onNotification` maps, direct branching on `PushNotificationType`, and parsing
the formatted device-token prefix. Nexo wrapper candidates are typed
notification-event models and a token-registration facade, to be finalized after
the event-shape and token-flow contracts are documented.
## Event Types
The Dart API currently recognizes these native event types: