How nostidus4/cordon works
Cordon is a spending-control product that models company spending keys and districts, simulates exposure, and enforces limits and emergency controls through a Guardian chain. Its principal workflow runs from the interactive city and scenario experience through backend policy services to chain checks; policy changes additionally pass through Council approval and execution. The README also documents incident response, read-only AI assistance, and a rebalance agent. Edges use README statements or SOURCE INDEX references; unsampled subsystems are shown without guessed internal call paths.
Main entry points: runtime.py Runtime coordinator · client.ts REST client · proposal_service.py Proposal lifecycle · base.py Chain port
Components 25
User experience
- City and scenes
Frontend/src/stage/StagePage.tsx - Exposure simulation
Frontend/src/pages/simulate/SimulatePage.tsx - Policy requests
Frontend/src/pages/requests/RequestsPage.tsx - Incident response
Frontend/src/pages/incident/IncidentPage.tsx - Assistant panel
Frontend/src/components/assistant/AssistantPanel.tsx - REST client
Frontend/src/lib/api/client.ts
Policy services
- FastAPI routes
Backend/src/guardian/api/routes - Runtime coordinator
Backend/src/guardian/services/runtime.py - Policy snapshot
Backend/src/guardian/domain/snapshot.py - Graph simulation
Backend/src/guardian/graph/simulate.py - Risk findings
Backend/src/guardian/graph/findings.py - Proposal lifecycle
Backend/src/guardian/services/proposal_service.py - Read-only assistant
Backend/src/guardian/assistant/service.py - Rebalance agent
Backend/src/guardian/agent_rebalance/runner.py
Chain enforcement
- Chain port
Backend/src/guardian/chain/base.py - Simulated chain
Backend/src/guardian/chain/sim/engine.py - Guardian L1 adapter
Backend/src/guardian/chain/l1/startup.py - Council and timelock
Backend/src/guardian/chain - Tx AllowList
Backend/src/guardian/chain/precompiles.py
Indexing and state
- Chain indexer
Backend/src/guardian/workers/indexer.py - Postgres stores
Backend/src/guardian/repositories/pg.py
Other components
- Company operator
- Fuji C-Chain
- Guardian L1
- LLM provider
Connections 30
- Company operator → City and scenes: explores
README.md - Company operator → Exposure simulation: tests exposure
README.md - Company operator → Policy requests: requests policy
README.md - Company operator → Incident response: responds to incident
README.md - City and scenes → REST client: loads state
- Exposure simulation → REST client: requests simulation
- Policy requests → REST client: submits proposal
- Incident response → REST client: requests controls
- Assistant panel → REST client: asks questions
- REST client → FastAPI routes: REST / SSE
README.md - FastAPI routes → Runtime coordinator: serves requests
- Runtime coordinator → Chain port: uses chain
Backend/src/guardian/services/runtime.py - Runtime coordinator → Policy snapshot: reads policy state
Backend/src/guardian/services/runtime.py - Graph simulation → Policy snapshot: simulates changes
- Risk findings → Policy snapshot: evaluates risk
- Proposal lifecycle → Runtime coordinator: uses stores and chain
Backend/src/guardian/services/proposal_service.py - Proposal lifecycle → Graph simulation: simulates proposal
Backend/src/guardian/services/proposal_service.py - Proposal lifecycle → Risk findings: uses findings
Backend/src/guardian/services/proposal_service.py - Read-only assistant → Runtime coordinator: reads runtime
Backend/src/guardian/assistant/service.py - Read-only assistant → LLM provider: generates responses
- Rebalance agent → Runtime coordinator: uses runtime
Backend/src/guardian/agent_rebalance/main.py - Chain port → Simulated chain: implemented by
Backend/src/guardian/chain/sim/engine.py - Chain port → Guardian L1 adapter: implemented by
- Simulated chain → Guardian L1: simulates policies
README.md - Guardian L1 adapter → Guardian L1: calls contracts
README.md - Guardian L1 → Council and timelock: enforces Council
README.md - Guardian L1 → Tx AllowList: rejects locked keys
README.md - Chain indexer → Guardian L1 adapter: indexes events
Backend/src/guardian/workers/main.py - Chain indexer → Postgres stores: persists events
Backend/src/guardian/workers/main.py - Fuji C-Chain → Runtime coordinator: provides top-up events