laya-devops-mlx / preprocessor-source.py
tebebe's picture
Laya DevOps v29 early stage preview: weights, method, paired audit and integration
aa73ff9 verified
Raw History Blame Contribute Delete
1.24 kB
"""Classification-only canonical view. NEVER execute the returned command field.
The actual proposed command is preserved in proposed_command_original. This is
not an execution rewrite or permission decision. Input must be a raw tool state.
"""
from command_normalizer_v2 import normalize_state as add_static_view
VERSION='canonical-static-wrappers-v2'
DERIVED={'static_command_view','static_execution_chain','static_view_origin','proposed_command_original'}
def normalize_state(state):
raw={k:v for k,v in state.items() if k not in DERIVED}
viewed=add_static_view(raw)
result={}
for key in ('tool','command'):
if key in raw:result[key]=raw[key]
if 'static_command_view' in viewed:
result['command']=viewed['static_command_view']
result['static_execution_chain']=viewed['static_execution_chain']
for key in ('trusted_user_request','execution_host','environment','trusted_context','untrusted_tool_output'):
if key in raw:result[key]=raw[key]
for key,value in raw.items():
if key not in result:result[key]=value
if 'static_command_view' in viewed:
result['proposed_command_original']=raw['command']
result['static_view_origin']=VERSION
return result