Complete snapshot of /opt/microdao-daarion/ from NODE1 (144.76.224.179).
This represents the actual running production code that has diverged
significantly from the previous main branch.
Key changes from old main:
- Gateway (http_api.py): expanded from ~40KB to 164KB with full agent support
- Router: new /v1/agents/{id}/infer endpoint with vision + DeepSeek routing
- Behavior Policy: SOWA v2.2 (3-level: FULL/ACK/SILENT)
- Agent Registry: config/agent_registry.yml as single source of truth
- 13 agents configured (was 3)
- Memory service integration
- CrewAI teams and roles
Excluded from snapshot: venv/, .env, data/, backups, .tgz archives
Co-authored-by: Cursor <cursoragent@cursor.com>
66 lines
2.2 KiB
Python
66 lines
2.2 KiB
Python
import sys
|
|
from pathlib import Path
|
|
root = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(root))
|
|
sys.path.insert(0, str(root / 'packages' / 'agromatrix-tools'))
|
|
|
|
from crews.agromatrix_crew import operator_commands as oc
|
|
|
|
|
|
def test_parse():
|
|
cmd = oc.parse_operator_command('/pending --limit 5 --category field')
|
|
assert cmd['cmd'] == 'pending'
|
|
|
|
|
|
def test_gating(monkeypatch):
|
|
monkeypatch.setenv('AGX_OPERATOR_IDS', '123')
|
|
assert oc.is_operator('123', None)
|
|
assert not oc.is_operator('999', None)
|
|
|
|
|
|
def test_pending_list_flags(monkeypatch):
|
|
monkeypatch.setenv('AGX_OPERATOR_IDS', '1')
|
|
res = oc.route_operator_command('/pending --limit 5 --category unit', '1', None)
|
|
assert res['status'] == 'ok'
|
|
|
|
|
|
def test_approve_apply_guard(monkeypatch):
|
|
monkeypatch.setenv('AGX_OPERATOR_IDS', '1')
|
|
# no apply allowed by default
|
|
res = oc.route_operator_command('/approve pending.jsonl:1 map_to crop_wheat_winter --apply', '1', None)
|
|
assert res['summary'] == 'apply_not_allowed'
|
|
|
|
|
|
def test_whoami_operator(monkeypatch):
|
|
monkeypatch.setenv('AGX_OPERATOR_IDS', '1')
|
|
res = oc.route_operator_command('/whoami', '1', '2')
|
|
assert res['status'] == 'ok'
|
|
assert 'user_id: 1' in res['summary']
|
|
assert 'chat_id: 2' in res['summary']
|
|
|
|
|
|
def test_whoami_non_operator(monkeypatch):
|
|
monkeypatch.setenv('AGX_OPERATOR_IDS', '1')
|
|
res = oc.route_operator_command('/whoami', '9', '2')
|
|
assert res['status'] == 'error'
|
|
|
|
|
|
def test_pending_show(monkeypatch):
|
|
monkeypatch.setenv('AGX_OPERATOR_IDS', '1')
|
|
def _fake_detail(_ref):
|
|
return {
|
|
'ref': 'pending.jsonl:1',
|
|
'category': 'crop',
|
|
'raw_term': 'пшениця',
|
|
'ts': '2026-01-01T00:00:00Z',
|
|
'suggestions': [{'id': 'crop_wheat', 'score': 0.92}],
|
|
'status': 'approved',
|
|
'decision': 'approved',
|
|
'reason': 'match'
|
|
}
|
|
monkeypatch.setattr(oc.review, 'get_pending_detail', _fake_detail)
|
|
res = oc.route_operator_command('/pending_show pending.jsonl:1', '1', None)
|
|
assert res['status'] == 'ok'
|
|
assert 'ref: pending.jsonl:1' in res['summary']
|
|
assert 'suggestions:' in res['summary']
|