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:
@@ -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