# Source Control 遷移矩陣

| 項目 | 內容 |
|------|------|
| 日期 | 2026-06-04 |
| 狀態 | 第二版，依本機可見 remote inventory 與 current refs truth refresh 更新 |
| 上游 snapshot | `docs/security/LOCAL-GIT-REMOTE-INVENTORY-SNAPSHOT.md`、`docs/security/GITEA-REPO-INVENTORY-SNAPSHOT.md`、`docs/security/GITEA-PUBLIC-REPO-SEARCH-SNAPSHOT.md` |
| Gitea server-side inventory runbook | `docs/security/GITEA-SERVER-SIDE-INVENTORY-RUNBOOK.md` |
| Gitea read-only inventory approval | `docs/security/GITEA-READONLY-INVENTORY-APPROVAL-PACKAGE.md` |
| GitHub target probe | `docs/security/GITHUB-TARGET-PROBE-SNAPSHOT.md` |
| GitHub target 決策 | `docs/security/GITHUB-TARGET-VISIBILITY-DECISION-TABLE.md` |
| GitHub target repo approval | `docs/security/GITHUB-TARGET-REPO-APPROVAL-PACKAGE.md` |
| Source Control draft reconcile plan | `docs/security/SOURCE-CONTROL-RECONCILE-PLAN.md` |
| Source Control branch/tag detail diff | `docs/security/SOURCE-CONTROL-REF-DETAIL-DIFF.md` |
| Source Control ref truth classification | `docs/security/SOURCE-CONTROL-REF-TRUTH-CLASSIFICATION.md` |
| Workflow / secret name owner response | `docs/security/SOURCE-CONTROL-WORKFLOW-SECRET-NAME-OWNER-RESPONSE.md` |
| Owner response validation rollup | `docs/security/SOURCE-CONTROL-OWNER-RESPONSE-VALIDATION-ROLLUP.md` |
| 原則 | 只做盤點與分類，不做同步、不刪除、不切 primary |

## 0. 核心結論

GitHub primary 可以作為長期方向，但目前還不能切換。

原因不是只有 `awoooi` 的 Gitea/GitHub `main` SHA 不一致；本機可見 source-control 拓撲還顯示：

- 有 Gitea-only 專案，例如 `wooo/ewoooc`。
- 有 110 internal-only remote，例如 `bitan-pharmacy`、`tsenyang-website`。
- 有 GitLab 類 110 remote，例如 `root/momo-pro-system`。
- 有 GitHub + 110 internal 雙 remote，例如 `wooo-infra-config`。
- 有 local-only Git working tree，尚未判定是否需要納入 GitHub。

因此遷移工作不能只處理 Gitea `wooo/awoooi`，必須先建立完整 source-control target matrix。

2026-05-12 追加確認：Gitea `users/wooo/repos` 未提供 token 時可見 `wooo/awoooi` 與 `wooo/ewoooc`，`gitea_repo_inventory_v1.status=partial`。這補強 server-side public evidence，但仍不能代表 private/internal 全量。

## 1. 優先級矩陣

| 優先級 | 類型 | Repo / working tree | 目前狀態 | 下一步 |
|--------|------|---------------------|----------|--------|
| P0 | Mapped but blocked | `wooo/awoooi` -> `owenhytsai/awoooi` | Gitea/GitHub `main` SHA、branches、tags 未對齊 | 確認部署真相來源，產生 full refs diff，禁止 primary switch |
| P0 | Gitea-only / canonical blocked | `wooo/ewoooc` | 本機兩份 `momo-pro-system` working tree 指向 Gitea，但 lineage probe 顯示 `no_shared_history`；`owenhytsai/ewoooc` 未授權 probe 看不到 | 決定 canonical repo 與 GitHub target 前，不得同步 |
| P0 | Internal 110-only / source aligned | `bitan-pharmacy` | 110 remote `main` 與本機 `main` 對齊，1 head / 0 tags；`owenhytsai/bitan-pharmacy` 未授權 probe 看不到 | 確認是否 active，建立或指定 GitHub target |
| P0 | Internal 110-only / source aligned | `tsenyang-website` | 110 remote `main` 與本機 `main` 對齊，1 head / 0 tags；`owenhytsai/tsenyang-website` 未授權 probe 看不到 | 確認是否仍 active，建立或指定 GitHub target |
| P0 | GitLab 110-only / canonical blocked | `root/momo-pro-system` | 指向 `192.168.0.110:8929` GitLab 類 remote；與兩份 Gitea working tree 近期 sample 無共同 commit | 與 `wooo/ewoooc` 做 server-side 判定，不得直接合併或刪除 |
| P1 | Mapped but blocked | `wooo/clawbot-v5` -> `owenhytsai/clawbot-v5` | Gitea/GitHub `main` SHA 不一致，GitHub 缺 Gitea tag | 確認哪一端是真相來源，再同步 refs |
| P1 | Mapped but blocked | `wooo/wooo-aiops` -> `owenhytsai/wooo-aiops` | Gitea/GitHub `main` SHA 不一致，GitHub tags 比 Gitea 多，GitHub 多 1 條 branch | 釐清雙端分歧來源與部署控制面 |
| P1 | GitHub aligned / internal 110 unreadable | `wooo-infra-config` | GitHub `main` 與本機 `main` 對齊；110 internal remote 因 SSH 權限不足或不可讀，mirror 方向未確認 | 確認 110 remote 用途與權限；若為舊 remote，降級或移除 |
| P2 | GitHub-only | `nexu-io/open-design` | GitHub-only，可能非 AWOOOI 主線 | 標記 owner 與 scope，決定是否納入資安網 |
| P2 | Local-only | `aider-watch`、`stockPlatform` | 本機 Git working tree 無 remote | 判定是否為草稿、封存或需建立 GitHub repo |
| P2 | Local-only / no clear remote | `momo_pro_system` | 另有 GitLab 類 remote，但名稱與 `momo-pro-system` 重疊 | 需人工釐清 canonical repo |

## 2. 去重後 target group

### Gitea candidates

| Gitea repo | GitHub candidate | 目前狀態 |
|------------|------------------|----------|
| `wooo/awoooi` | `owenhytsai/awoooi` | 已 mapped，但 refs blocked |
| `wooo/clawbot-v5` | `owenhytsai/clawbot-v5` | 已 mapped，但 refs blocked |
| `wooo/ewoooc` | 待定 | Gitea-only，P0 |
| `wooo/wooo-aiops` | `owenhytsai/wooo-aiops` | 已 mapped，但 refs blocked |

### Gitea server-side public inventory summary

| Source | Status | Visibility | Repo count | Evidence |
|--------|--------|------------|------------|----------|
| `users/wooo/repos` | `partial` | `public_only` | `2` | `docs/security/GITEA-REPO-INVENTORY-SNAPSHOT.md` |
| `orgs/wooo/repos` | `blocked` | `public_only` | `0` | `docs/security/GITEA-ORG-REPO-INVENTORY-BLOCKED-SNAPSHOT.md` |

完整 private/internal list 仍需只讀 token 或管理匯出 JSON，且必須先通過 `docs/security/gitea-readonly-inventory-approval.snapshot.json`。

### 110 internal candidates

| Internal repo | GitHub candidate | 目前狀態 |
|---------------|------------------|----------|
| `bitan-pharmacy` | 待定 | 110 SSH 類 remote |
| `root/momo-pro-system` | 待定 | 110 GitLab 類 remote |
| `tsenyang-website` | 待定 | 110 SSH 類 remote |
| `wooo/wooo-infra-config` | `owenhytsai/wooo-infra-config` | GitHub aligned；110 internal remote unreadable，需判斷用途 |

### GitHub-only candidates

| GitHub repo | 判定 |
|-------------|------|
| `nexu-io/open-design` | 可能是外部設計 repo，需 owner/scope 判定 |
| `owenhytsai/wooo-infra-config` | 已在 GitHub，但需處理 110 internal remote |

### Canonical lineage probe summary

| 群組 | Status | 結論 | Evidence |
|------|--------|------|----------|
| `ewoooc-momo-pro-system` | `unrelated` | 三個本機 working tree 近期 sample 內無共同 commit；不能自動視為複本或同 repo 分支 | `docs/security/LOCAL-REPO-CANONICAL-EWOOOC-MOMO-SNAPSHOT.md` |

### Internal 110 refs probe summary

| Repo | Status | Heads | Tags | Local HEAD | Remote main | Evidence |
|------|--------|-------|------|------------|-------------|----------|
| `bitan-pharmacy` | `aligned_current_branch` | `1` | `0` | `7423a08` | `7423a08` | `docs/security/GIT-REMOTE-REFS-BITAN-TSENYANG-SNAPSHOT.md` |
| `tsenyang-website` | `aligned_current_branch` | `1` | `0` | `b103112` | `b103112` | `docs/security/GIT-REMOTE-REFS-BITAN-TSENYANG-SNAPSHOT.md` |
| `wooo-infra-config` GitHub | `aligned_current_branch` | `1` | `0` | `866b5aa` | `866b5aa` | `docs/security/GIT-REMOTE-REFS-WOOO-INFRA-CONFIG-SNAPSHOT.md` |
| `wooo-infra-config` 110 internal | `unreachable` | `0` | `0` | `866b5aa` | 無 | `docs/security/GIT-REMOTE-REFS-WOOO-INFRA-CONFIG-SNAPSHOT.md` |

### GitHub target probe summary

| 類型 | 數量 | 說明 |
|------|------|------|
| 候選 GitHub repo | `8` | 以本機 remote 與候選 target 建立 |
| 可 read-only probe | `5` | `awoooi`、`clawbot-v5`、`wooo-aiops`、`wooo-infra-config`、`nexu-io/open-design` |
| not found or private | `3` | `ewoooc`、`bitan-pharmacy`、`tsenyang-website` |

### GitHub target decision summary

| 狀態 | 數量 | 說明 |
|------|------|------|
| target candidates | `8` | 以 read-only probe 與本機 remote inventory 彙整 |
| approval required | `7` | 除 `nexu-io/open-design` scope review 外，其餘皆需人工 gate |
| create / grant access after approval | `3` | `ewoooc`、`bitan-pharmacy`、`tsenyang-website` |
| refs reconcile blocked | `3` | `awoooi`、`clawbot-v5`、`wooo-aiops` |
| internal remote purpose pending | `1` | `wooo-infra-config` |

此決策表仍是 draft。它只把 target visibility / repo creation 變成 approval evidence，不授權任何自動 repo 建立、visibility 修改、refs sync 或 GitHub primary 切換。

Repo-by-repo approval package 已建立，9 個 approval-required targets 皆為 `pending`。Approval scope 採低摩擦原則：只處理高風險執行邊界，不阻擋 read-only inventory、evidence mirror 與草案規劃。

Ref truth classification 已重產為 current queue，將 `awoooi`、`clawbot-v5`、`wooo-aiops` 的 194 個 refs 差異拆成 review lane。`main` / `dev` 屬真相來源判定，`drift/adopt-*` 先列 deprecated candidate，release / UAT tags 先列保留判定；S4.11 已補 owner response request packet、template status ledger、audit event templates、redaction examples、collection checks、intake preflight checks 與收件包，5 個 templates、received / accepted response 皆為 0、audit events emitted 仍為 0。不得把分類結果、request packet、template status ledger、audit event templates、redaction examples、collection checks、intake preflight checks 或 response packet 直接執行成同步、刪除、force push 或 primary switch。

Workflow / secret name owner response 已建立，S4.12 補 1 個 request packet、5 個 template statuses、3 個 audit event templates、5 個 redaction examples、6 個 collection checks、6 個 intake preflight checks 與 5 個 templates，對應 webhook、runner、deploy key、branch protection / CODEOWNERS 與 repository secret name parity；received / accepted response 皆為 0、audit events emitted 仍為 0。不得把 request packet、template status ledger、audit event templates、redaction examples、collection checks、intake preflight checks 或 response packet 當成 secret value collection、workflow modification、GitHub hosted runner enablement 或 primary approval。

Owner response validation rollup 已建立，S4.13 彙整 S4.9 / S4.10 / S4.11 / S4.12 四包 response packets，24 個 templates、10 個 cross-packet checks、6 條 evidence routing rules、8 個 display sections、7 條 state transition rules、9 個 reviewer checklist items、7 條 reviewer outcome lanes、4 個 reviewer audit event templates、5 個 reviewer audit display sections、6 個 reviewer audit collection checks、5 個 reviewer audit redaction examples、5 條 reviewer audit retention rules、6 個 reviewer audit retention checks、6 個 reviewer audit handoff packets、6 個 reviewer audit handoff checks、6 個 parallel session sync checks、6 條 parallel session conflict lanes、6 個 parallel session recovery checks、7 條 parallel session recovery outcome lanes，received / accepted response 皆為 0，reviewer audit emitted 仍為 0。不得把 rollup、routing、sections、transition rules、reviewer checklist、reviewer outcome lanes、reviewer audit templates、reviewer audit display sections、reviewer audit collection checks、reviewer audit redaction examples、reviewer audit retention rules、reviewer audit retention checks、reviewer audit handoff packets / checks、parallel session sync checks、parallel session conflict lanes、parallel session recovery checks 或 parallel session recovery outcome lanes 當成 approval、runtime gate、production ingestion 或 execution authorization。

## 3. 必要驗收 gate

任何 repo 進入「已可切 GitHub primary」之前，都必須通過：

1. Server-side repo inventory 已完成，不能只靠本機 working tree。
2. Branch count 與 branch SHA diff 已完成。
3. Tag count 與 tag SHA diff 已完成。
4. Release / artifact / deploy marker inventory 已完成。
5. Workflow / webhook / runner / secret 名稱 inventory 已完成。
6. GitHub target repo、owner、branch protection、CODEOWNERS 已確認。
7. Secrets 只盤名稱，不搬 value。
8. AwoooP 只收到 evidence，不直接觸發 sync、merge、deploy 或 primary switch。

## 4. 已產生 refs diff 的 mapped repos

| Repo | Status | Gitea branches | GitHub branches | Gitea tags | GitHub tags | Gitea main | GitHub main | Evidence |
|------|--------|----------------|-----------------|------------|-------------|------------|-------------|----------|
| `wooo/awoooi` -> `owenhytsai/awoooi` | `blocked` | `170` | `2` | `2` | `0` | `64490d32c67d24ed123cbd4e2261c69e17913e38` | `202071f7a8724d5e8c29de441c3f380575a0ea94` | `docs/security/SOURCE-CONTROL-REF-DETAIL-DIFF.md` |
| `wooo/clawbot-v5` -> `owenhytsai/clawbot-v5` | `blocked` | `1` | `1` | `1` | `0` | `22074fbe4d6ec6c11c86f76139eea55756d1d160` | `7a769de46450087f9d6a8ef0d2ac23ed15565d2c` | `docs/security/SOURCE-CONTROL-CLAWBOT-V5-SNAPSHOT.md` |
| `wooo/wooo-aiops` -> `owenhytsai/wooo-aiops` | `blocked` | `2` | `3` | `0` | `19` | `507384a2e1943f4183942bf17d7b52e223067853` | `7c7aa109d93da6d75d687d6ee5131151afee37e8` | `docs/security/SOURCE-CONTROL-WOOO-AIOPS-SNAPSHOT.md` |

這三個 mapped repos 都不能直接視為 GitHub primary ready。

Ref truth classification 補充：完整 review lane 見 `docs/security/SOURCE-CONTROL-REF-TRUTH-CLASSIFICATION.md`，S4.11 owner response request packet / template status ledger / audit event templates / redaction examples / collection checks / intake preflight checks / 收件包見 `docs/security/SOURCE-CONTROL-REF-TRUTH-OWNER-RESPONSE.md`。目前分類結果是 4 個 `manual_truth_required`、142 個 `manual_review_deprecated_candidate`、3 個 `manual_review_release_tag`、20 個 `manual_review_github_only`。

## 5. 下一波建議

1. 先批准 Gitea read-only inventory package，再用只讀 token 或管理匯出補齊 Gitea server repo list。
2. 依 GitHub target repo-by-repo approval package 處理 9 個 approval-required target。
3. 依 S4.11 ref truth owner response request packet / template status ledger / audit event templates / redaction examples / collection checks / intake preflight checks / 收件包與 classification 釐清 `wooo/awoooi`、`wooo/clawbot-v5`、`wooo/wooo-aiops` 的雙端分歧來源；仍不得 push/delete refs。
4. 依 S4.12 workflow / secret name owner response request packet / template status ledger / audit event templates / redaction examples / collection checks / intake preflight checks / 收件包補 webhook、runner、deploy key、branch protection / CODEOWNERS、repository secret name parity 的 redacted disposition；仍不得收 secret value、改 workflow 或啟用 hosted runner。
5. 依 S4.13 owner response validation rollup 集中檢查 S4.9-S4.12 四包 response validation、evidence routing、display sections、state transition rules、reviewer checklist、reviewer outcome lanes、reviewer audit event templates、reviewer audit display sections、reviewer audit collection checks、reviewer audit redaction examples、reviewer audit retention rules、reviewer audit retention checks、reviewer audit handoff packets、handoff checks、parallel session sync checks、parallel session conflict lanes、parallel session recovery checks 與 parallel session recovery outcome lanes；仍不得把 rollup、routing、sections、transition rules、reviewer checklist、reviewer outcome lanes、reviewer audit templates、reviewer audit display sections、reviewer audit collection checks、reviewer audit redaction examples、reviewer audit retention rules、reviewer audit retention checks、reviewer audit handoff packets / checks、parallel session sync checks、parallel session conflict lanes、parallel session recovery checks 或 parallel session recovery outcome lanes 當 approval、production ingestion 或 execution authorization。
6. 釐清 `wooo/ewoooc`、`root/momo-pro-system`、`momo-pro-system`、`momo_pro_system` 的 canonical 關係。
7. 釐清 `bitan-pharmacy`、`tsenyang-website` 是否仍 active，並決定 GitHub owner / visibility。
8. 產出 GitHub primary ADR 前，不做主控切換。
