How s34tiwar/ghostshift works
GhostShift is a simulated-factory recovery agent with a browser dashboard, FastAPI control plane, separate durable worker, and MongoDB-backed factory state and audit ledger. Its main workflow detects machine faults, retrieves a recovery procedure, proposes and policy-checks an action, records intent, repairs and independently verifies the machine, then exposes run progress and audit history to the UI. The README documents UI polling and worker-to-factory behavior; some internal executor and route details are unsampled, so uncertain links are omitted.
Main entry points: ledger.py Run and audit ledger · page.tsx Dashboard page · read_routes.py Read routes · scenario_routes.py Run controls
Components 24
Dashboard
- Dashboard page
frontend/app/page.tsx - Progress views
frontend/components - API client
frontend/lib/api.ts - Activity mapping
frontend/lib/activity.ts - UI contracts
frontend/lib/types.ts
API control plane
- API application
backend/api/main.py - Read routes
backend/api/read_routes.py - Run controls
backend/api/scenario_routes.py - Factory client
backend/api/factory_client.py - API schemas
backend/api/schemas.py
Recovery planning
- Planner graph
backend/agent/graph.py - Procedure retrieval
backend/agent/retrieval.py - Recovery procedures
backend/agent/procedures.py
Durable execution
- Recovery worker
backend/reliability/worker.py - Action executor
backend/reliability/executor.py - Policy gate
backend/reliability/policies.py - Run and audit ledger
backend/reliability/ledger.py - Mongo persistence
backend/reliability/storage.py
Factory simulator
- Factory endpoints
backend/factory/main.py - Machine logic
backend/factory/state.py - Machine store
backend/factory/mongo_store.py
Other components
- Operator
- MongoDB Atlas
- Gemini API
Connections 34
- Operator → Dashboard page: uses
README.md - Dashboard page → API client: polls and submits
README.md - Dashboard page → Progress views: renders
frontend/app/page.tsx - Dashboard page → Activity mapping: formats activity
frontend/app/page.tsx - API client → UI contracts: uses contracts
frontend/lib/api.ts - Activity mapping → UI contracts: uses contracts
frontend/lib/activity.ts - API client → API application: HTTP requests
README.md - API application → Read routes: registers routes
backend/api/main.py - API application → Run controls: registers routes
backend/api/main.py - Read routes → Factory client: reads machine state
backend/api/read_routes.py - Read routes → Run and audit ledger: reads run history
backend/api/read_routes.py - Run controls → Factory client: breaks or resets
backend/api/scenario_routes.py - Run controls → Mongo persistence: enqueues runs
backend/api/scenario_routes.py - Run controls → Run and audit ledger: resumes or arms
backend/api/scenario_routes.py - Read routes → API schemas: validates responses
backend/api/read_routes.py - Recovery worker → Planner graph: requests plan
backend/reliability/worker.py - Planner graph → Procedure retrieval: retrieves procedures
backend/agent/graph.py - Planner graph → Recovery procedures: uses fallback
backend/agent/graph.py - Procedure retrieval → Recovery procedures: uses procedure model
backend/agent/retrieval.py - Procedure retrieval → MongoDB Atlas: vector search
backend/agent/retrieval.py - Planner graph → Gemini API: generates proposal
backend/agent/graph.py - Recovery worker → Action executor: executes run
backend/reliability/worker.py - Action executor → Run and audit ledger: records action
backend/reliability/executor.py - Action executor → Policy gate: checks proposal
backend/reliability/executor.py - Recovery worker → Run and audit ledger: claims and updates
backend/reliability/worker.py - Run and audit ledger → Mongo persistence: persists transitions
backend/reliability/ledger.py - Policy gate → Mongo persistence: loads policy data
backend/reliability/policies.py - Mongo persistence → MongoDB Atlas: stores runs and audit
backend/reliability/storage.py - Factory client → Factory endpoints: HTTP calls
backend/api/factory_client.py - Action executor → Factory endpoints: repairs and verifies
README.md - Factory endpoints → Machine logic: delegates machine actions
backend/factory/main.py - Factory endpoints → Machine store: uses store
backend/factory/main.py - Machine store → Machine logic: applies state logic
backend/factory/mongo_store.py - Machine store → MongoDB Atlas: persists machine state
README.md