A deterministic state-machine system for enforcing safety protocol compliance.
This project models the "Permit-to-Work" (PTW) process as a Finite State Machine (FSM). Unlike standard databases, this system uses formal transition rules to ensure that a permit cannot reach an ACTIVE state without passing through mandatory SAFETY_CHECK and APPROVAL states. This prevents "process skipping," a common cause of industrial accidents.
(Figure 1: Visual tracking of the permit lifecycle. Transitions are strictly enforced by the backend logic.)
- Deterministic Logic:
- Implements a strict FSM using the
transitionslibrary. - Invalid transitions (e.g., jumping from
IdletoActive) raise immediateFormalViolationerrors.
- Implements a strict FSM using the
- Process Enforcement:
- Safety Check Constraint: Work cannot begin until the safety verification state is successfully resolved.
- Auditability: Every state change is tracked and validated against the logic model.
- Visual Status Tracking:
- Provides a clear, linear view of the safety workflow for site managers.
| Component | Technology | Purpose |
|---|---|---|
| Logic Engine | Python transitions |
Formal State Machine implementation |
| Backend | Flask | Web Interface & API |
| Frontend | Bootstrap 5 | Visual State Diagram |
# Logic Sample: Strict Transition Rules
transitions = [
{'trigger': 'verify_safety', 'source': 'requested', 'dest': 'safety_check'},
{'trigger': 'manager_approve', 'source': 'safety_check', 'dest': 'approved'},
# If a user tries to skip 'safety_check', the system rejects the action.
]# Create Virtual Environment (Sandbox)
python -m venv venv
# Activate (Windows)
.\venv\Scripts\activate
# Install Dependencies (Flask + Transitions)
pip install -r requirements.txt# Navigate to the Source Folder
cd src
# Start the Logic Engine
python app.pyAccess the system at: http://127.0.0.1:5002
If you see a "running scripts is disabled" error when trying to activate the environment, run this command in PowerShell to allow script execution:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope ProcessThen try running .\venv\Scripts\activate again.
Gaurav Dev
- Focus: Safety-Critical Systems, Process Automation, Formal Methods.