mirror of
https://github.com/hoshikawa2/compass_backoffice.git
synced 2026-07-09 13:54:20 +00:00
first commit
This commit is contained in:
BIN
tools/__pycache__/validate_parity.cpython-313.pyc
Normal file
BIN
tools/__pycache__/validate_parity.cpython-313.pyc
Normal file
Binary file not shown.
157
tools/validate_parity.py
Normal file
157
tools/validate_parity.py
Normal file
@@ -0,0 +1,157 @@
|
||||
from pathlib import Path
|
||||
|
||||
REQUIRED = [
|
||||
'app/main.py',
|
||||
'app/workflows/agent_graph.py',
|
||||
'app/workflows/backoffice_native_runtime.py',
|
||||
'app/agents/backoffice_agent.py',
|
||||
'src/agent/nodes/fetch_ticket_node.py',
|
||||
'src/agent/nodes/validation_node.py',
|
||||
'src/agent/nodes/imdb_enrichment_node.py',
|
||||
'src/agent/nodes/speech_enrichment_node.py',
|
||||
'src/agent/nodes/knowledge_base_enrichment_node.py',
|
||||
'src/agent/nodes/treatment_decision_node.py',
|
||||
'src/agent/nodes/siebel_sr_opening_node.py',
|
||||
'src/agent/nodes/emulator/generate_response_node.py',
|
||||
'src/components/clients/imdb_client.py',
|
||||
'src/components/clients/siebel_client.py',
|
||||
'src/components/clients/speech_analytics_client.py',
|
||||
'src/components/clients/tais_kb_client.py',
|
||||
'src/components/clients/abrt_client.py',
|
||||
'src/components/clients/portability_client.py',
|
||||
'src/agent/local_prompts/canceling_analysis.py',
|
||||
'src/agent/local_prompts/tim_complaint_analysis.py',
|
||||
'src/agent/local_prompts/treatment_decision_prompt.py',
|
||||
'src/agent/local_prompts/emulator/response_emulator_generation.py',
|
||||
'config/agents/backoffice_anatel/guardrails.yaml',
|
||||
'config/agents/backoffice_anatel/judges.yaml',
|
||||
'legacy_reference_disabled/original_develop/src_agent_graphs/main_graph.py',
|
||||
'legacy_reference_disabled/original_develop/src_agent_graphs/emulator_graph.py',
|
||||
]
|
||||
|
||||
FORBIDDEN_ACTIVE_TEXT = [
|
||||
'from src.agent.graphs',
|
||||
'import src.agent.graphs',
|
||||
'from src.api.executors',
|
||||
'import src.api.executors',
|
||||
'include_router(original_',
|
||||
'GRAPH_FACTORIES',
|
||||
'get_or_create_graph("checklist")',
|
||||
]
|
||||
|
||||
missing = [p for p in REQUIRED if not Path(p).exists()]
|
||||
if missing:
|
||||
print('MISSING')
|
||||
for p in missing:
|
||||
print('-', p)
|
||||
raise SystemExit(1)
|
||||
|
||||
for py in [p for p in Path('app').rglob('*.py') if '__pycache__' not in str(p)]:
|
||||
text = py.read_text(errors='ignore')
|
||||
for token in FORBIDDEN_ACTIVE_TEXT:
|
||||
if token in text:
|
||||
print(f'FORBIDDEN ACTIVE TOKEN in {py}: {token}')
|
||||
raise SystemExit(1)
|
||||
|
||||
main = Path('app/main.py').read_text()
|
||||
needles = [
|
||||
'BackofficeNativeRuntime',
|
||||
'execute_workflow(',
|
||||
'backoffice_checklist',
|
||||
'backoffice_response_emulator',
|
||||
'legacy_router_registration": False',
|
||||
]
|
||||
for n in needles:
|
||||
if n not in main:
|
||||
print('MISSING MAIN NEEDLE:', n)
|
||||
raise SystemExit(1)
|
||||
|
||||
|
||||
# Guardrails must be bound from the backoffice agent profile, not only from global config.
|
||||
runtime = Path('app/workflows/backoffice_native_runtime.py').read_text(errors='ignore')
|
||||
for needle in [
|
||||
'_resolve_agent_profile("backoffice_anatel")',
|
||||
'self.agent_profile["guardrails_config_path"]',
|
||||
'_build_guardrail_pipeline(',
|
||||
'active_input_rails',
|
||||
'active_output_rails',
|
||||
'guardrails_config_path',
|
||||
]:
|
||||
if needle not in runtime:
|
||||
print('MISSING GUARDRAIL BINDING NEEDLE:', needle)
|
||||
raise SystemExit(1)
|
||||
|
||||
agent_guardrails = Path('config/agents/backoffice_anatel/guardrails.yaml').read_text(errors='ignore')
|
||||
for rail_code in ['INPUT_SIZE', 'MSK', 'PINJ', 'TOX', 'DLEX_IN', 'RAGSEC', 'VLOOP', 'REVPREC', 'DLEX_OUT', 'OOS', 'CMP', 'AOFERTA']:
|
||||
if rail_code not in agent_guardrails:
|
||||
print('MISSING BACKOFFICE GUARDRAIL CODE:', rail_code)
|
||||
raise SystemExit(1)
|
||||
|
||||
print('OK: backoffice framework-native structural validation passed')
|
||||
print('python_files=', len(list(Path('.').rglob('*.py'))))
|
||||
|
||||
# IC/NOC/GRL observability must be framework-native in the backoffice runtime.
|
||||
runtime = Path('app/workflows/backoffice_native_runtime.py').read_text(errors='ignore')
|
||||
for needle in [
|
||||
'_safe_emit_ic',
|
||||
'_safe_emit_noc',
|
||||
'_safe_emit_grl',
|
||||
'_bridge_legacy_ics',
|
||||
'IC.BACKOFFICE_WORKFLOW_STARTED',
|
||||
'IC.BACKOFFICE_WORKFLOW_COMPLETED',
|
||||
'NOC.001',
|
||||
'NOC.006',
|
||||
'NOC.009',
|
||||
'GRL.001',
|
||||
'GRL.002',
|
||||
'GRL.003',
|
||||
'GRL.004',
|
||||
'GRL.005',
|
||||
'GRL.006',
|
||||
'GRL.007',
|
||||
'GRL.008',
|
||||
'GRL.009',
|
||||
]:
|
||||
if needle not in runtime:
|
||||
print('MISSING OBSERVABILITY NEEDLE:', needle)
|
||||
raise SystemExit(1)
|
||||
|
||||
# LLM provider must accept and default to OCI OpenAI-compatible.
|
||||
core_cfg = Path('src/core/config.py').read_text(errors='ignore')
|
||||
env_example = Path('.env.example').read_text(errors='ignore')
|
||||
if 'oci_openai' not in core_cfg or 'LLM_PROVIDER=oci_openai' not in env_example:
|
||||
print('MISSING OCI_OPENAI PROVIDER SUPPORT')
|
||||
raise SystemExit(1)
|
||||
|
||||
# Must not reference modules that do not exist in agent_framework(7).zip.
|
||||
FORBIDDEN_FRAMEWORK_IMPORTS = [
|
||||
'agent_framework.' + 'core',
|
||||
'agent_framework.' + 'components',
|
||||
'agent_framework.llm.' + 'factory',
|
||||
'agent_framework.observer.' + 'application_log',
|
||||
'agent_framework.observer.' + 'publishers',
|
||||
'agent_framework.observer.' + 'types',
|
||||
]
|
||||
for folder in ['app', 'src']:
|
||||
for py in Path(folder).rglob('*.py'):
|
||||
text = py.read_text(errors='ignore')
|
||||
for token in FORBIDDEN_FRAMEWORK_IMPORTS:
|
||||
if token in text:
|
||||
print(f'FORBIDDEN FRAMEWORK IMPORT in {py}: {token}')
|
||||
raise SystemExit(1)
|
||||
print('OK: no forbidden agent_framework imports')
|
||||
|
||||
# Backend must not implement/monkey-patch LLM generation telemetry (option B).
|
||||
_generation_offenders = []
|
||||
for _folder in ['app', 'src']:
|
||||
for _py in Path(_folder).rglob('*.py'):
|
||||
_text = _py.read_text(errors='ignore')
|
||||
for _pattern in ['with generation', 'def generation', 'observer.generation', 'import generation']:
|
||||
if _pattern in _text:
|
||||
_generation_offenders.append(f'{_py}: {_pattern}')
|
||||
if _generation_offenders:
|
||||
print('BACKEND_GENERATION_TELEMETRY_FORBIDDEN')
|
||||
for _item in _generation_offenders:
|
||||
print('-', _item)
|
||||
raise SystemExit(1)
|
||||
print('OK: no backend generation telemetry; LLM telemetry is delegated to agent_framework.llm.providers')
|
||||
Reference in New Issue
Block a user