本卡屬 FR-089,接 CM-1676(結構整理)之後。決策者 2026-09-12 要求「都查一下,能修就修,以後一定忘記」。首腦已查完七條,本卡收四條可在套件內修的;RLS 那條另開 CM(下一張)等放行;發版不在本卡。
jedi-asset 結構整理完後,首腦全包再看一遍找到四件「現在不修以後一定忘」的事:一支沒人呼叫的 upsert 方法還掛在 service 上;引用計數 adapter 遇到新資產型別會安靜回 0 沒任何訊號;34 支測試全是契約守衛、service 的業務行為零覆蓋(CM-1667 修過的三個 bug 修完沒留測試);README 的已知落差表漏了「設備用 status 0/1、資訊系統用 is_active+system_status」這條。
首腦核對:
upsert_by_name:唯一 caller domain/oscal/strategy/ssp_write_strategy.py 在主專案 commit b6ebf097(jedi-oscal v1 殘留清理)被刪;grep -rn upsert_by_name 五個 repo 現在只剩定義那一行。現行 docx/excel 匯入 (app/oscal/service/ssp_*_import_app_service.py、import_adapter/) 完全不碰資訊系統。infra/asset/asset_reference_adapter.py:46 if asset_type != AssetType.HARDWARE: return 0——enum 目前兩個值,加第三個時這行會靜默吃掉。DEV 實查指向 compliance.information_systems 的外鍵 0 條,所以資訊系統回 0 目前正確。tests/unittest/ 34 支:grep update_device|delete_device|_resolve_system_owner|get_all_by_fields_and_pager 零命中。monorepo 有 8 支套件帶 tests/integration/conftest.py(testcontainers 起 postgres:16-alpine),但全部 0 支測試——骨架有、沒人填。jedi-asset 連 integration 目錄都沒有。information_system_repo_impl.py:44-46 的 exact-match AND 只有一行註解在守;jedi-common base_repository_impl.py:235 確認是 or_(*string_conds) ILIKE。哪天有人刪 override,system_status=operational 會命中 under-development,無任何紅燈。DeviceManage.vue:427 用 data.status === 0 顯示 Tag;InformationSystemManage.vue:83 篩 is_active: true、:527 顯示 system_status。兩套都是活契約,不能統一,只能寫進 README。套件根:/Users/chouraymond/Projects/Jedicogy/module/jedi-python-package/jedi-asset/
jedi_asset/app/service/information_system_service.py:125-157 upsert_by_name 整支刪
jedi_asset/infra/repository/information_system_repo_impl.py:44 exact-match 邏輯,測試要守
tests/unittest/ 現有 34 支契約守衛
tests/integration/ 不存在,本卡建
harness/docker-compose.yml 可參考 port 5493 那顆
README.md 「已知落差」表 加一列
主專案:
infra/asset/asset_reference_adapter.py:45-52 count_references 改分派
test/test_asset_reference_count.py 既有測試,改完要仍綠
先例:
~/Projects/Jedicogy/module/jedi-python-package/jedi-bulletin/tests/integration/conftest.py testcontainers 骨架照抄
InformationSystemService.upsert_by_name 整支。動手前再 grep 一次五個 repo(BE/FE/test/license_center/jedi),確認仍零呼叫者。AssetReferenceAdapter.count_references 改成 dict dispatch:{AssetType.HARDWARE: self._count_device, AssetType.INFORMATION_SYSTEM: lambda _: 0},查表;查無型別時 logger.warning 並回 0,不再用 != 一刀切。test/test_asset_reference_count.py 加一個 case:傳一個不在 enum 的字串 → 回 0 且 caplog 有 warning。突變:把 warning 拿掉 → 紅。