AI Autofix & Safe Actions¶
Autofix is Sentinel's AI-driven remediation pipeline. When a detector raises an incident, the LLM analyses the log context and proposes a concrete bash command to fix the problem. The command is shown to an admin with risk metadata and a dry-run preview. Nothing executes until an admin explicitly approves it.
How it actually works¶
Autofix is not magic β it is a tightly controlled pipeline:
- Trigger β admin clicks πͺ on an incident card, or the system auto-triggers for configured detectors
- AI analysis β the log context + incident metadata is sent to the Ollama LLM (NPU or CPU)
- Safety gate β
safety.classify()scores the proposed command against theallowed_commandsallowlist - Dry-run preview β
safety.simulate()runs a read-only preview of what the command would do - Admin approval β the proposal appears in the Web UI modal with risk score, dry-run output, and Approve/Reject buttons
- SSH execution β only after explicit approval,
actions.pyconnects to the target management node and runs the command - Verification β the incident enters
validatingstate; if the detector stops seeing the problem in the next cycle, it auto-resolves
Incident detected
β
ββ AI analyses log context
β ββ Ollama worker β { command, description, confidence }
β
ββ safety.classify() checks allowlist + risk rules
β ββ if BLOCKED β rejected immediately, no modal shown
β
ββ safety.simulate() generates dry-run preview
β
βΌ
Admin modal (Web UI or mobile app)
ββββββββββββββββββββββββββββββββββββββββββββββ
β Proposed: systemctl restart postgresql β
β Risk: LOW β Node: db-node-02 β
β Dry-run: would restart PostgreSQL service β
β β
β [β
Approve] [β Reject] β
ββββββββββββββββββββββββββββββββββββββββββββββ
β
ββ Approve β SSH exec β STDOUT/STDERR logged
β incident status: running β completed
β detector confirms fix β resolved β
What Autofix can and cannot do¶
Can do:
- Restart a failed service (
systemctl restart <svc>) - Re-mount a filesystem (
mount -a,mount /dev/... /mnt/...) - Rotate logs (
logrotate -f ...) - Run custom diagnostic scripts on the allowlist
- Reach nodes behind a bastion via ProxyJump
Cannot do (by design):
- Execute anything not on the
allowed_commandsallowlist - Run destructive commands (
rm -rf,mkfs,shutdown) β automatically blocked - Execute without admin approval unless
auto_execute: trueis explicitly set - Bypass the dry-run preview
- Act on nodes that aren't in the
infrastructuremapping
Safety Classifier¶
safety.classify() evaluates every proposed command before the modal is shown:
| Risk level | Examples | Behaviour |
|---|---|---|
| LOW | systemctl restart nginx, logrotate -f | Green β shown normally |
| MEDIUM | apt-get install, mount -a, sysctl -w | Yellow warning |
| HIGH | rm -rf, dd if=, mkfs, iptables -F | Red warning, extra confirmation required |
| BLOCKED | shutdown, reboot, halt, fork bombs | Rejected silently β never reaches admin |
Commands not matching any pattern in allowed_commands are also blocked, regardless of risk level.
Configuration¶
# /etc/sentinel/config.yaml
allowed_commands:
# Restart a specific service β low risk, requires approval
- pattern: "systemctl restart *"
auto_execute: false
risk: low
# Re-mount filesystems β medium risk, always manual
- pattern: "mount -a"
auto_execute: false
risk: medium
# Custom diagnostic β auto-execute safe read-only commands
- pattern: "journalctl -u * --since *"
auto_execute: true
risk: low
infrastructure:
- hostname: "db-node-02"
ssh_user: root
management_node: true
# Route through a bastion:
ssh_jump_host: "bastion.example.com"
ssh_jump_user: "jump"
Autonomous Execution¶
When auto_execute: true, Sentinel skips the approval modal and executes directly. Use only for safe, idempotent, read-only or known-safe commands.
Failures always create an AUTOFAIL issue with a red badge β even when auto_execute is on. You always know when something went wrong.
SSH Jump Host (ProxyJump)¶
Production clusters often place compute nodes behind a bastion. Autofix handles this transparently:
infrastructure:
- hostname: "hpc-node-01"
ssh_user: root
management_node: true
ssh_jump_host: "bastion.example.com"
ssh_jump_user: "jumpuser"
The generated SSH command:
SSH Modal (admin+)¶
For situations where Autofix isn't triggered but you need direct access, the SSH Modal lets admins run arbitrary (allowlisted) commands on any agent node from the Web UI:
- Click an agent β open agent detail modal
- Click SSH (requires
adminorsuperadmin) - Type commands β live output streams via SSE
- All commands logged in
ssh_execute_logtable with actor, timestamp, STDOUT/STDERR
Action Lifecycle¶
created (pending)
β
ββ auto_execute=true β running β completed β
β βββ failed β AUTOFAIL issue π΄
β
ββ admin modal
ββ Approve β running β completed β
β βββ failed β AUTOFAIL issue π΄
ββ Reject β rejected
Every transition is logged in action_audit with actor, timestamp, risk score, and details.
Escalation Rules¶
Issues that linger without resolution automatically escalate:
escalation_rules:
- channel: infra
after_hours: 4
raise_to: high
- channel: security
after_hours: 1
raise_to: critical
Escalated issues show a live timer badge: β± 3h active.
API¶
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /api/v1/actions | read | List pending/recent actions |
| POST | /api/v1/actions/<id>/approve | admin | Approve and execute |
| POST | /api/v1/actions/<id>/reject | admin | Reject proposal |
| GET | /api/v1/actions/<id>/output | read | Stream execution output (SSE) |
| GET | /api/v1/actions/<id>/audit | read | Full lifecycle audit trail |