# FR-036 Phase 2 + P2c — 收尾 SUMMARY（2026-06-10）

| 項目 | 內容 |
|------|------|
| 範圍 | Phase 2（匯入/填值改源 + gate/copy 清理 + 模板層 Excel 改源）+ P2c（DROP 退役表 + 移除 inert 子系統） |
| branch | `feature/oscal-refactor`（BE）—— **7 commit 未 push** |
| 環境 | **DEV only**（已改源 + DROP + cleanup + 手測通過）；stg/poc 未碰 |
| 狀態 | dev 完整收口；stg/poc 留獨立遷移弧 |

## Commits（皆未 push）

```
57746a5b feat(FR-036): P2a-A 樣板下載填值改讀樣板 SSP
bee8946c feat(FR-036): P2a-B docx 匯入確認 + 控制項/AO strategy 改寫樣板 SSP
49c34073 feat(FR-036): P2a-C excel 匯入確認改寫樣板 SSP
dc39aa45 feat(FR-036): P2b 啟動專案 gate 改查 template_ssp_id + copy service 清理
22b19ee0 feat(FR-036): P2a-E 模板層控制項 Excel 匯入/匯出改源樣板 SSP
14719775 feat(FR-036): P2c DROP 退役 *_defaults 子系統（dev 已套）
538e8524 refactor(FR-036): P2c cleanup — 移除 inert *_defaults 子系統（56 檔）
```

> 註：`a3f0ccc5 docs(FR-037)` 夾在中間是 user 並行的另一 arc commit，非本期。

## 改動範圍

| 檔案 / 區域 | 改動 |
|------|------|
| `app/module_frame/service/ssp_import_template_app_service.py` | 填值下載讀 helper 改讀樣板 SSP；移除 inert MF-default 讀路徑 |
| `app/oscal/service/ssp_docx_import_app_service.py` | module_frame 匯入確認 + diff 現值改走 `template_ssp_id` → confirm_service；移除 `_run_mf_default_confirm` / `_load_mf_default_v3_lists` |
| `app/oscal/service/ssp_excel_import_app_service.py` | `_write_mf_defaults` 改走 confirm_service + sc_write_strategy（key=template_ssp_id） |
| `domain/oscal/strategy/module_frame_write_strategy.py` | 控制項/AO 改寫樣板 SSP；Excel delete-all → upsert；parties 維持 context='module_frame' |
| `app/module_frame/service/module_frame_template_import_service.py` | 模板層控制項 Excel 匯入/匯出全改源樣板 SSP + `ssp_document_pool_query` |
| `app/project/service/oscal_project_service.py` | `_mf_has_template_ssp` gate；略過舊式 profile-earliest-SSP clone |
| `app/module_frame/service/module_frame_template_copy_service.py` | 移除 4 個已不用的 `*_default` 注入（無參數建構） |
| DI（oscal_containers / module_frame_containers） | 移除 `*_default` repo/domain service 註冊與所有注入；strategy 改注入 control_impl/objective |
| `scripts/sql/2026-06-10-fr036-drop-defaults.sql` | DROP 8 表（dev 已套） |
| 刪除 56 檔 | model×8 / mapper×8 / repo_impl×8 / repo×8 / entity+query×16 / domain_service×8 |

## 行為差異（對 user）

- 資源庫所有讀寫（編輯 / 匯出 / docx+excel 匯入 / 模板層 Excel 批次 / 啟動專案帶入）底層 storage
  從 `compliance.module_frame_*_defaults` 換成樣板 SSP 的 `oscal.ssp_*` 子表 —— **FE / API 形狀不變，使用者無感**。
- 唯一語意變化：模板層 Excel control 匯入由「整份覆蓋」改為「upsert」（不再清掉人工維護的內容 + 程序書掛勾）。
- dev 上 8 張舊表已不存在。

## 規範文件齊全度

- ✅ changelog：`docs/changelog/2026-06-10-feat-fr036-phase2-template-ssp-merge.md`
- ✅ design.md：補 §9 Phase 2 + P2c 完工 reconciliation
- ✅ memory：`feedback_drop_table_find_all_live_consumers_and_orphan_audit.md`（+ MEMORY.md 索引）
- ✅ 本 SUMMARY
- ✅ 對話紀錄歸檔 → `docs/conversation-history/2026-06-10/fr036-phase2-template-ssp-merge/`
- ✅ Notion 任務（GuidantAI Issue 任務清單）
- analysis：本期決策（template-SSP 收斂 / Excel upsert / dev-only DROP）已涵蓋於 design §9 + changelog，未另開 analysis

## 已知 follow-up

1. **stg / poc 遷移 + FR-036 上線**（最重要）：兩環境連 `oscal.ssps` 都沒有，`*_defaults` 是未遷移
   live 資料。須 FR-035（ssps 改名）+ FR-036 M1（欄位）+ M3（資料遷移）+ 三方驗零丟失 + 備份，才能
   上 FR-036 code / 套 DROP migration。**未排程，需 user 規劃。**
2. excel service `__init__` 殘留少數 inert `mf_*_default` 參數（None default、無 caller、無 import 依賴）—— 低優先順手清。
3. push：7 個 BE commit（+ Phase 1 的 commit + jedi-oscal 3 個）皆未 push，等 user 明示。

## 部署 handover

- BE：改 service 層，無 hot reload → user 已重啟 dev 並驗過。
- DB：dev migration 已套（`2026-06-10-fr036-drop-defaults.sql`）。stg/poc **不要**直接套（見 follow-up 1）。
- 套件：jedi-oscal 本期未改，無發版需求；`pyproject.toml` dev path-dep 未 commit。
