# Track B → A → C 收尾 SUMMARY

> Phase 收口報告：handoff `2026-05-23-track-bac-excel-roundtrip.md` 三 Track 全部落地
> Branch：`feature/ssp-import-export-phase3`
> 收尾日期：2026-05-23

---

## 1. 完成範圍

### Track B — SSP Excel SC 端到端 + leveraged 結構化欄位 (v2.2.0 → v2.4.0)

- 新 `01b_受評標的` sheet（per-SSP 單筆 system_characteristic vertical layout）
- Leveraged 結構化欄位（`provider / category / status / date_authorized / description`）— 從原本「title=provider 黑客」拆成獨立 entity column，Excel 鏈接通
- Parser → reconciler → write strategy → FE 預覽 全鏈打通
- Excel schema iteration：v2.1.0 → v2.2.0（初始）→ v2.3.0（拿掉前綴）→ v2.3.1（status enum 對齊）→ v2.4.0（leveraged 加 date_authorized + description）

### Track A — MF / SSP 結構對齊

- 抽 `SspSystemCharacteristicContextService` (mirror C2.1 抽法)
- 新 MF endpoint：`/module-frame/<uid>/system-characteristic` + `/module-frame/<uid>/leveraged`
- `SspBasicSection` / `SspLeveragedSection` 加 `apiBase` + `scopeUid` props — SSP-tab + MF template-edit 共用同 component
- MF template-edit 加「受評標的」+「外部利用服務」2 個 tab
- 啟動專案 `_setup_ssp_system_implementation` 擴 `_clone_system_characteristic_from_template` + 補 leveraged `provider/category` clone

### Track C — 專案 SSP tab Excel round-trip

- 新 `/ssp/<uid>/excel-template?mode=blank|filled` endpoint（`generate_for_ssp` 從 SSP 自身資料讀）
- `SspTabPanel.vue` 加「下載 Excel 匯入樣板」+「從 Excel 匯入」button（絕對定位疊在 sub-tab nav row 右側）
- 匯入 dialog 用 dropzone 樣式 mirror `ImportExcelPage.vue`
- Upload via SSP-scoped endpoint，預覽用既有 non-scoped endpoint，confirm 後跳回 `project-planning-ap`

### Testing iteration（Track B/A/C ship 後）

8 個 BE bug fix + 多個 FE polish：
- DI fix（document_repo 漏注入 module_frame_container）
- Person role 改 non-blocking + legacy code 向後相容
- ControlWriteStrategy upsert key 改 `control_identifier`
- Permission session_scope（C2.2 T9 ship 時就有的 bug，Track C 接通後暴露）
- filled-mode 設備/資訊系統/外部利用服務 sheet 空白（items 走 scope='ssp' 不是 'module_frame'）
- Leveraged write strategy: title + provider 修正
- 啟動專案 clone 補 category/provider
- SC + leveraged status enum 對齊 Billows convention
- Excel 預覽 UI iteration（status / owner Dropdown / Calendar / 描述用途 / 紅色 badge / dropzone / button 位置）

---

## 2. 規範文件清單

### Changelog（4 份）

| 主題 | 路徑 |
|------|------|
| Track B (feat) | `docs/changelog/2026-05-23-feat-ssp-excel-system-characteristic-and-leveraged-structured.md` |
| Track A (feat) | `docs/changelog/2026-05-23-feat-mf-ssp-structure-alignment.md` |
| Track C (feat) | `docs/changelog/2026-05-23-feat-project-ssp-excel-roundtrip.md` |
| Testing iteration (fix) | `docs/changelog/2026-05-23-fix-ssp-excel-testing-iteration.md` |

### Spec sync

- `design-C5.md` §11 加 Track A + C reconciliation（含 11.1~11.7：section generalize / MF endpoint mirror / 啟動專案 clone SC / SSP excel-template download / FE 接通 / session_scope + control upsert bug fix / 跟原 design 差異對照表）
- `design-C7.md` §11 加 Track B reconciliation（含 11.1~11.5：樣板版本 iteration / LeveragedWriteStrategy 修法 / ParsedLeveraged description / role validator non-blocking / filled-mode items 查詢修正）
- `README.md` tracker 加 4 row（Track B / A / C / Testing iteration）

### Conversation history

- `docs/conversation-history/2026-05-23/ssp-edit-in-project/`
  - `b7da6369-...` (796 KB, 早上 session)
  - `426af2a6-...` (2083 KB, 下午 session — Track B/A/C 主體)
  - `be2c27cc-...` (1713 KB, 晚上 session — Track C + testing iteration + 收尾)

### Issue

無新建 issue — Track B/A/C 內遇到的 bug 都是 testing-time 直接修，無「需要單獨 root cause 分析」級別的故障。

---

## 3. Commits 清單

### compliance-manager-be (15 commits)

```
1baba65 fix(ssp-excel-confirm): ControlWriteStrategy 改用 control_identifier upsert key
3e5e176 fix(ssp-scoped-excel): permission_checker 包 session_scope 修「沒有 session」錯誤
0eda729 fix(project-start): clone leveraged 補 category + provider 欄位
72dd7e7 fix(ssp-excel): filled-mode 設備/資訊系統/外部利用服務 sheet 空白 — 改走 ssp_id 查 items
ee8426c feat(ssp-excel): leveraged Excel 補 date_authorized + description (v2.4.0)
efdc176 fix(ssp-excel): leveraged 寫到 title + 不要 fallback provider 到 service_name
faccd5c fix(ssp-excel): confirm 對 legacy blocking code (INVALID_ROLE) 向後相容
34efb29 fix(ssp-excel): person role 改 non-blocking warning (相容 OSCAL 角色)
04b4185 feat(ssp-excel): leveraged row-level overrides + delete (純資料 inline edit)
872bced fix(ssp-excel): SC + leveraged status enum 對齊 Billows UI 慣例 (v2.3.1)
edde76f tweak(ssp-excel): 拿掉 sheet 名稱數字前綴 (v2.3.0)
deb2fa5 fix(di): module_frame_container ssp_domain_service 補 document_repo 注入
c86f71c feat(ssp-excel): Track C BE — /ssp/<uid>/excel-template download endpoint
447fb40 feat(mf): Track A BE — MF SC + leveraged endpoint + 啟動專案 clone SC
474ae0e feat(ssp-excel): Track B — system_characteristic 端到端 + leveraged 結構化欄位
```

### compliance-manager-fe (16 commits)

```
cf34650 tweak(ssp-tab): Excel button 微推上去對齊 sub-tab label baseline
e342be7 tweak(ssp-tab): Excel 匯出/匯入 button 移到 sub-tab nav 同 row 右側 (Option A)
b59d1a5 tweak(ssp-tab): 匯入 SSP Excel dialog 改用 dropzone 樣式對齊既有匯入頁
2052490 tweak(ssp-leveraged): table 補齊 edit dialog 全部欄位 (提供者 + 狀態)
ca0565b tweak(ssp-excel-preview): 授權日期改 Calendar 日期套件
a98d2f9 feat(ssp-excel-preview): leveraged 預覽 + Excel 同步加 date_authorized + description
f749dc2 tweak(ssp-leveraged): table 「服務名稱」改單欄
a7fd630 fix(ssp-leveraged): 描述 / 用途 column 顯示優先讀 purpose
8392801 fix(ssp-excel-preview): leveraged 紅色 badge 拿掉 + 類別 i18n 修正
1c59c2a fix(ssp-excel-preview): SC owner Dropdown 抽 login_name + leveraged 加 inline edit / 刪除
79e6522 fix(ssp-excel-preview): SC 狀態對齊 + owner Dropdown + leveraged 拿掉配對狀態
4fd178f fix(ssp-tab): 下載失敗 + 對齊 template-edit 文案
f5c1fcd tweak(mf-template-edit): 受評標的 tab 移到「責任單位」前
e997ac4 feat(ssp-excel): Track C FE — SSP tab 加下載 / 匯入 SSP Excel 按鈕
0b87884 feat(mf): Track A FE — MF template-edit 加受評標的 + 外部利用服務 2 tab
7b4abf2 feat(ssp-excel): Track B FE — Excel 匯入預覽頁加 SC tab + leveraged 結構化欄位
```

### jedi-oscal (套件)

無新增 commit — Track B/A/C 用到的 `provider / category` 欄位已在前期（`8de7991`）加進 `SspSystemImplementationItemEntity`，不需再動套件。

---

## 4. 行為差異（部署 handover 用）

### Excel 樣板

- **新版本 v2.4.0**：使用者下載新 Excel 會看到 7 個 leveraged 欄位（含 date_authorized / description）+ 新「受評標的」sheet + sheet 名拿掉「01_」前綴
- **舊版本 backward compat**：v2.0 ~ v2.3.x 舊 Excel 上傳仍可解析（parser 加 legacy alias）

### SSP UI

- 「外部利用服務」table 顯示 7 個 column（類別 / 服務名稱 / 提供者 / 授權日期 / 狀態 / 描述用途 / 操作）
- MF template-edit 多 2 個 tab（受評標的 + 外部利用服務）；受評標的 tab 位於「責任單位」之前
- 專案 SSP tab 右上角多 2 個 button（下載 Excel 匯入樣板 / 從 Excel 匯入）

### 啟動專案

- 新建專案 / 新 round AP 時，新 SSP 會 clone template SSP 的 system_characteristic + leveraged 結構化欄位（provider / category）

### 既有 DB row 影響

- **既有專案 SSP** 的 leveraged row 仍缺 `provider / category`（前期 clone 流程沒帶）— 本期 fix 只對之後啟動的新專案 / 新 AP round 有效。要補可在 SSP UI edit dialog 內手動填，或重新建一個新 round / 新專案測
- **既有 parse_job** 內 stored `blocking=True / INVALID_ROLE` 仍會被 confirm 守門認回去（加了 legacy 名單過濾）

---

## 5. 部署 handover

### 重啟 BE

DI / route / write strategy 等改動需重啟 BE：
```bash
lsof -ti :8000 | xargs kill -9 && python main_socketio.py
```

### pyproject.toml 狀態

仍是 jedi-oscal path dependency（dev 期間規範要求不 commit）。未來若 jedi-oscal 需推 Nexus 正式發版時：
1. jedi-oscal repo 內 bump version + commit + push Nexus
2. 主專案 `pyproject.toml` 改回 pin 新 version + `poetry update jedi-oscal`
3. 該還原 commit 跟其他 dev 改動分開

本期 Track B/A/C 沒新動 jedi-oscal source，path dep 跟前期 `8de7991` 同步即可。

### Migration

無新 migration SQL — Track B/A/C 不動 DB schema（所有需要的欄位 jedi-oscal `8de7991` 已加）。

---

## 6. 已知 follow-up

- **既有專案 leveraged row 缺 provider / category**：見上方「行為差異」段，靠新 round 自然汰換
- **MF SC / leveraged endpoint 沒有 BE unit test**：A1/A2 是 thin delegate；context service 既有測試覆蓋邏輯主體，wrapper 層 test 留下一輪補
- **預覽頁 confirm 後 `?section=ssp` deep-link 沒實作**：跳回 `project-planning-ap` route 但 SSP tab 切換需 user 手動點。要做的話在 `ProjectPlanningView.vue` `applyDeepLink` 加 section query 監聽

---

## 7. 不在本期範圍 / 未動

- ❌ AP 評鑑計畫層級的資料模型（user 早期討論過「SC + leveraged 是否在 AP 層共用」— 確認後維持 per-SSP，不重構）
- ❌ `authorization_boundary` 欄位（jedi-oscal SC entity 沒對應，Track B 沒加進 Excel — 等套件擴充再補）
- ❌ Excel preview 頁的 `?return_to=ssp` deep-link 完整自動切 tab（手動點即可）

---

## 8. 連結

- Handoff prompt：`2026-05-23-track-bac-excel-roundtrip.md`
- Spec 文件：`design-C5.md` §11 / `design-C7.md` §11
- Tracker：`docs/features/FR-011.3-2605-ssp-edit-in-project/README.md`
- 對話原始 dump：`docs/conversation-history/2026-05-23/ssp-edit-in-project/`
