本卡屬 FR-181(母卡 FR-181 母案(同清單上一張)),卡 A-4,批 5。只改 jedi-python-package。依賴:A-1、F-1。

這張卡做什麼(白話)

檢測功能在 jedi-detection 套件裡,它有三支自己打 Agent 8443 的小 client:測試連線(probe)、存工具帳密、取消檢測。本案這三支不再自己發 HTTP,改成呼叫主系統注入進來的 ask/fire(A-1 的插槽)——套件不認識 Redis,只認識一個「有 ask 和 fire 兩個方法」的介面。測試連線與存帳密要等答案用 ask,取消用 fire 不等。既有 HTTP 路徑在套件裡刪掉(主系統側直推留著已夠 D6,套件不留兩套)。錯誤碼對映:逾時→既有 AGENT_UNREACHABLE、插槽滿→新 AGENT_BUSY。做完發版。

reuse/extend/new

extend:agent_probe_client.py→probe(agent, target) 改 self._channel.ask(agent, KIND_PROBE, {target}) 回 result;agent_credential_client.py→ask(KIND_CREDENTIALS_SET, …)(存好才算,要等);agent_cancel_client.py→fire(KIND_DETECTION_CANCEL, {job_uid})。三支的建構子改收 channel port(ask/fire 兩個方法的 Protocol,放 jedi_detection/app/ports/agent_channel.py);主系統 DI 注入 A-1 的 service。既有 HTTP 路徑刪(套件不留開關——主系統開關關閉時這三條本來就打不到,留兩套在套件裡沒意義;主系統側 AgentCommandService 留著已足夠 D6)。錯誤碼對映:ask 504→既有 AGENT_UNREACHABLE、503→新 AGENT_BUSY。發版

在哪裡

repo:~/Projects/Jedicogy/module/jedi-python-package
改既有:jedi-detection/jedi_detection/infra/detection_tools/connector/agent_probe_client.py
改既有:jedi-detection/jedi_detection/infra/detection_tools/connector/agent_credential_client.py
改既有:jedi-detection/jedi_detection/infra/detection_tools/connector/agent_cancel_client.py
改既有:jedi-detection/jedi_detection/app/service/detection_dispatch_guard.py(probe 呼叫點)
改既有:jedi-detection/pyproject.toml
新開:jedi-detection/jedi_detection/app/ports/agent_channel.py
新開:jedi-detection/tests/test_agent_channel_clients.py

怎麼做

驗收(首腦照這個驗)

pytest:假 channel 回 {reachable: true} → probe 回 True;ask 拋 timeout → 既有 AGENT_UNREACHABLE;cancel 只叫 fire 不叫 ask;grep -rn 'httpx\|requests' connector/agent_*_client.py 為 0。發版推 Nexus 回寫版號

必讀