Download source/schema.py from ARotting/kernelmind-model-machine: direct link, hf CLI and curl.
- Browser
- Download file 2.2 kB
-
https://huggingface.co/ARotting/kernelmind-model-machine/resolve/main/source/schema.py
- Command line
-
hf download hf://ARotting/kernelmind-model-machine/source/schema.py
-
curl -L -o schema.py https://huggingface.co/ARotting/kernelmind-model-machine/resolve/main/source/schema.py
2.2 kB
| from __future__ import annotations | |
| ACTIONS = [ | |
| "PAD", | |
| "REPORT", | |
| "OPEN_APP", | |
| "READ_FILE", | |
| "WRITE_FILE", | |
| "DELETE_FILE", | |
| "INSTALL_PACKAGE", | |
| "SEARCH_LOCAL", | |
| "SEARCH_WEB", | |
| "RESTART_SERVICE", | |
| "WRITE_BACKUP", | |
| "ASK_CONFIRMATION", | |
| "REFUSE", | |
| ] | |
| STATE_NAMES = [ | |
| "file_exists", | |
| "app_open", | |
| "package_installed", | |
| "service_running", | |
| "backup_exists", | |
| "report_available", | |
| "confirmation_pending", | |
| "refusal_logged", | |
| ] | |
| CAPABILITY_NAMES = ["administrator", "network", "confirmed", "sensitive_target"] | |
| def reference_transition( | |
| state: list[int], | |
| capabilities: list[int], | |
| action: str, | |
| ) -> tuple[list[int], int]: | |
| next_state = list(state) | |
| administrator, network, confirmed, sensitive = map(bool, capabilities) | |
| blocked = 0 | |
| if action == "REPORT": | |
| next_state[5] = 1 | |
| elif action == "OPEN_APP": | |
| next_state[1] = 1 | |
| elif action == "READ_FILE": | |
| if not state[0] or (sensitive and not administrator): | |
| blocked = 1 | |
| else: | |
| next_state[5] = 1 | |
| elif action == "WRITE_FILE": | |
| if sensitive and not administrator: | |
| blocked = 1 | |
| else: | |
| next_state[0] = 1 | |
| elif action == "DELETE_FILE": | |
| if not confirmed or sensitive or not state[0]: | |
| blocked = 1 | |
| else: | |
| next_state[0] = 0 | |
| elif action == "INSTALL_PACKAGE": | |
| if not (confirmed and administrator and network): | |
| blocked = 1 | |
| else: | |
| next_state[2] = 1 | |
| elif action == "SEARCH_LOCAL": | |
| next_state[5] = 1 | |
| elif action == "SEARCH_WEB": | |
| if not network: | |
| blocked = 1 | |
| else: | |
| next_state[5] = 1 | |
| elif action == "RESTART_SERVICE": | |
| if not (confirmed and administrator): | |
| blocked = 1 | |
| else: | |
| next_state[3] = 1 | |
| elif action == "WRITE_BACKUP": | |
| if not state[0] or (sensitive and not administrator): | |
| blocked = 1 | |
| else: | |
| next_state[4] = 1 | |
| elif action == "ASK_CONFIRMATION": | |
| next_state[6] = 1 | |
| elif action == "REFUSE": | |
| next_state[7] = 1 | |
| return next_state, blocked | |