refactor(uuid): resolve B-10 by deprecating agent_identities and removing PyYAML dependency
- Remove dead agent_identities read path and PyYAML import from workspace_uuid.py - Defer eager PyYAML import in verify_session.py to lazy YAML fallback branch - Simplify UUID resolution to 2-tier model (tier-1 own row ID -> tier-2 adapter scan) - Clean up unused Drift D and ghost cache clearing in reconcile.sh and stop_session.sh - Add 3 regression guards in tests/test_tier1_unit.py (266/266 PASS) - Update IMPROVEMENTS.md, VERSIONS.md, and SKILL.md files
This commit is contained in:
@@ -55,6 +55,10 @@ class BaseAgentAdapter:
|
||||
|
||||
@property
|
||||
def identity_cache_fields(self) -> tuple:
|
||||
"""agent_identities 캐시의 에이전트별 필드명.
|
||||
B-10(Option A)로 캐시 읽기 경로가 제거되어 현재 생산 소비자는 0건이지만,
|
||||
캐시 쓰기 경로가 도입되면 즉시 필요한 유일한 스키마 기술이므로 존치한다.
|
||||
임의 삭제 금지 — 삭제 시 4개 어댑터에 필드명을 다시 흩뿌려야 한다."""
|
||||
raise NotImplementedError
|
||||
|
||||
@property
|
||||
|
||||
@@ -7,7 +7,7 @@ def mam_orchestrator_uuids():
|
||||
global _MAM_ORC_CACHE
|
||||
if _MAM_ORC_CACHE is not None:
|
||||
return _MAM_ORC_CACHE
|
||||
import os, sys, json, sqlite3, yaml
|
||||
import os, sys, json, sqlite3
|
||||
override = os.environ.get("MAM_ORCHESTRATOR_UUIDS")
|
||||
if override is not None:
|
||||
if not override.strip():
|
||||
@@ -47,6 +47,7 @@ def mam_orchestrator_uuids():
|
||||
pass
|
||||
if (d_obj is None or "orchestrator_uuids" not in d_obj) and os.path.exists(yaml_p):
|
||||
try:
|
||||
import yaml
|
||||
with open(yaml_p) as f:
|
||||
d_obj = yaml.safe_load(f) or {}
|
||||
except Exception:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# workspace_uuid.py — workspace UUID discovery logic
|
||||
# Extracted from lib.sh find_workspace_uuid PYEOF block
|
||||
|
||||
import os, sys, json, sqlite3
|
||||
import os, sys, json
|
||||
from lib_py.verify_session import verify_session_uuid, mam_orchestrator_uuids, mam_row_own_uuid
|
||||
|
||||
OWN_KEY = {
|
||||
@@ -80,38 +80,6 @@ def find_workspace_uuid_main():
|
||||
for cand in adapter.discover(ctx):
|
||||
emit(cand)
|
||||
|
||||
ai = d.get('agent_identities') if isinstance(d, dict) else None
|
||||
if not isinstance(ai, dict) or not ai:
|
||||
ai = {}
|
||||
try:
|
||||
yaml_path = os.environ['YAML_PATH']
|
||||
db_path = os.path.splitext(yaml_path)[0] + '.db'
|
||||
if os.path.exists(db_path):
|
||||
conn = sqlite3.connect(db_path, timeout=60.0)
|
||||
conn.execute('PRAGMA busy_timeout = 60000')
|
||||
try:
|
||||
row = conn.execute('SELECT data FROM state WHERE id=1').fetchone()
|
||||
if row:
|
||||
ai = json.loads(row[0]).get('agent_identities') or {}
|
||||
except sqlite3.OperationalError:
|
||||
pass
|
||||
conn.close()
|
||||
elif os.path.exists(yaml_path):
|
||||
import yaml
|
||||
with open(yaml_path) as f:
|
||||
_ydoc = yaml.safe_load(f) or {}
|
||||
ai = _ydoc.get('agent_identities') or {}
|
||||
except Exception as e:
|
||||
print(f"WARN: tier-3 identity lookup failed: {e}", file=sys.stderr)
|
||||
if not isinstance(ai, dict):
|
||||
ai = {}
|
||||
|
||||
ai_agent = ai.get(agent) or {}
|
||||
if ai_agent.get('project_cwd') == ws:
|
||||
cand = ai_agent.get('session_id') or ai_agent.get('conversation_id')
|
||||
if cand and verify_session_uuid(ws, agent, cand, mode="revalidate"):
|
||||
emit(cand)
|
||||
|
||||
print('')
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user