Files
MoFin/scripts/validate_fixes.py
T
hmo 57377e9dd3 feat(auto_heal): multi-profile key switching + fix two error classes
Error investigation (from restored monitoring) found 2 root causes:

1. 'Blocked: script path resolves outside scripts dir' (5+ cron jobs):
   Jul 17 symlink refactor replaced real scripts with symlinks; the hermes
   cron scheduler's security check (Path.resolve + relative_to) rejects
   symlink escape. ALL no_agent script jobs blocked since Jul 17 23:12.
   FIX: converted 102 symlinks to hardlinks (same inode, resolve() stays
   inside scripts_dir, single-source still works). Permanent structural fix.

2. HTTP 429 on default profile (知识研究/梦境循环/wiki-self-growth/
   evolution-pulse/大脑任务执行): default gateway used ocg-key1 (weekly
   100%). FIX: switched default profile to ocg-key6 + added missing
   provider block. LLM verified working (3.1s).

auto_heal extended to actually cover these automatically next time:
- PROFILES registry: zhiwei (8643, system svc) + default (8642, user svc)
- current_provider/switch_key/_scan_agent_log parameterized by profile
- health() now reports llm_provider_default (agent.log scan)
- auto_heal: per-profile 429 detection -> best_key -> switch_key(profile)
- _ensure_provider_block: injects missing provider credentials from
  zhiwei config (single source of truth) into target config
2026-07-20 01:12:38 +08:00

37 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import json, urllib.request
from pathlib import Path
print("=== 验证1: 5个被 Blocked 的脚本现在是否通过调度器路径检查 ===")
scripts_dir = Path('/home/hmo/.hermes/profiles/position-analyst/scripts')
resolved = scripts_dir.resolve()
files = ['meta_growth.py', 'macro_context_collector.py', 'divergence_detector.py',
'memory_guardian.py', 'fix_gateway_port.py']
all_ok = True
for f in files:
p = (scripts_dir / f).resolve()
try:
p.relative_to(resolved)
exists = p.exists()
print(f" PASS {f} (exists={exists})")
if not exists:
all_ok = False
except ValueError:
all_ok = False
print(f" FAIL {f} still blocked")
print(' =>', 'ALL PASS' if all_ok else 'STILL FAILING')
print()
print("=== 验证2: default gateway (8642) LLM 调用(原 key1 429,现 key6===")
payload = json.dumps({'model': 'deepseek-v4-flash',
'messages': [{'role': 'user', 'content': 'reply with one word: ok'}],
'max_tokens': 10}).encode()
req = urllib.request.Request('http://127.0.0.1:8642/v1/chat/completions', data=payload,
headers={'Content-Type': 'application/json',
'Authorization': 'Bearer hermes123'})
try:
resp = urllib.request.urlopen(req, timeout=90)
d = json.loads(resp.read().decode())
content = d.get('choices', [{}])[0].get('message', {}).get('content', '')
print(' LLM OK:', content[:100])
except Exception as e:
print(' LLM FAIL:', e)