# Meta Connect Publish Runbook

> SHARED / meta-runbook / active

이 문서는 `citidel-upload-tool`에서 Meta reconnect와 publish smoke를 다시 밟을 때 쓰는 짧은 실행선이다.

## Goal

아래 한 줄을 다시 밟는다.

`access -> callback success -> handoff token -> local binding write -> live publish smoke`

## Preconditions

- production domain: `https://upload.citidel-app.com`
- local repo: `C:\dev\front-template\make newthing\citidel-upload-tool`
- `.env`에 아래 값 존재
  - `META_APP_ID`
  - `META_APP_SECRET`
  - `CONNECT_STATE_SECRET`
  - `OPERATOR_CONNECT_KEY`

## 1. Browser Connect

열기:

- `https://upload.citidel-app.com/api/connect/meta/access`

진행:

- operator key 입력
- Meta login / approval 진행
- callback success 페이지 도착

callback success에서 확인할 것:

- granted scopes
- managed page summary
- `Persist command`
- `Encrypted handoff token`

## 2. Local Persistence

callback에서 받은 command를 로컬 repo에서 실행한다.

형태:

```powershell
node scripts/create-meta-binding.mjs --handoff-token "<token>" --write
```

기대 결과:

- `.env` 갱신
  - `META_DEFAULT_PAGE_ID`
  - `META_PAGE_ACCESS_TOKEN_MAIN`
  - `META_USER_ACCESS_TOKEN_MAIN`
- `bindings/manual/facebook-pages.binding.json` 갱신
- 첫 write 전 `.env.backup-before-connect` 생성

## 3. Live Publish Smoke

실제 smoke 입력물을 하나 만든 뒤 publish 실행:

```powershell
node scripts/publish-package.mjs packages/incoming/<live-smoke>.json bindings/manual/facebook-pages.binding.json
```

성공 기준:

- `result.status = succeeded`
- `publish_result.status = published`
- `external_post_id` 존재
- `live_url` 존재

## 4. Cleanup

runtime 흔적은 repo에 오래 남기지 않는다.

치울 것:

- `packages/incoming/*.json`
- `attempts/*.json`
- `results/*.json`

남길 것:

- `.gitkeep`
- `README.md`

## 5. Docs To Touch

성공 후 갱신:

- `README.md`
- `docs/sprints/SPRINT-UP-01B-meta-reset-checklist.md`
- `docs/sprints/SPRINT-UP-01D-meta-connect-hardening.md`
- 필요하면 중앙 daylog

## Rule

- raw token을 callback body에 직접 복사하지 않는다
- handoff token은 operator-only local persistence에만 쓴다
- publish smoke 후 runtime artifact는 다시 치운다
