Workflows Overview & Developer Guide
HieraChain is an enterprise-grade, pure Python hierarchical blockchain ledger designed as a Plugin Layer for existing Web2 infrastructure. Instead of replacing the enterprise network stack (which already handles TLS/SSL, firewalls, and WAF at the API Gateway level), HieraChain focuses exclusively on providing Immutability, Distributed Trust, Tamper Evidence, and Non-repudiation.
This document serves as the central developer reference for HieraChain's 16 system workflows, organized into 6 functional groups. It details the runtime interaction model, quick-reference lookups, and developer guidelines for reading, maintaining, or adding new system workflows.
1. Core Development Guardrails
When working on HieraChain workflows, developers must strictly adhere to the following architectural guardrails defined in the project's consensus rules:
-
Strict Term Censorship: HieraChain is designed for business-process ledger tracking, not cryptocurrency. Do not use crypto terms in event payloads, variable names, database keys, or comments.
- β Forbidden terms:
transaction,mining,coin,token,wallet,address,sender,receiver,amount,fee. - Required terms:
event(for ledger entries),node(for peers),msp_id(for identity),entity_id(for domain assets). - Note: The
CrossChainValidatorautomatically scans commits and rejects any code containing forbidden terms.
- β Forbidden terms:
-
Minimal Latency Constraint: HieraChain enforces a 10-20ms base latency. Keep workflow code minimal, fast, and highly optimized. Avoid adding transport-level encryption or nested wrappers that cause unnecessary CPU overhead.
- No Direct Storage Access: Workflows must never make direct SQL or Redis queries. All data access must use storage adapters under the
adapters/storage/namespace.
2. All Workflows β Quick Reference
This table provides a comprehensive overview of HieraChain's workflows for quick developer lookup:
| Workflow | Group | Trigger | Output | Key Module |
|---|---|---|---|---|
| Event Submission | A | POST /v1/chains/{name}/events |
Block appended to Sub-Chain | hierarchical/sub_chain.py |
| Proof Anchoring | A | Block finalized on Sub-Chain | Proof hash on Main Chain | hierarchical/main_chain.py |
| Cross-Chain 2PC | A | initiate_cross_chain_transaction() |
COMMITTED or ROLLED_BACK |
hierarchical/hierarchy_manager.py |
| BFT Consensus | B | HRC_CONSENSUS_TYPE=byzantine_fault_tolerant |
Block committed by 2f+1 validators | consensus/bft/consensus.py |
| Cluster Lockdown | C | Anomaly exceeds risk threshold | All nodes frozen / resumed | cluster/lockdown_protocol.py |
| Error Mitigation | C | Network fail / leader timeout / integrity error | State restored from snapshot | error_mitigation/recovery_engine.py |
| Entity Tracing | D | trace_entity_across_chains(entity_id) |
Complete cross-chain audit trail | domains/generic/utils/entity_tracer.py |
| Chain Rehydration | D | Node restart or hash divergence | In-memory chain synced to DB | hierarchical/sub_chain.py |
| Integrity Validation | D | Periodic / manual / Risk Alerts anomaly | IntegrityReport (HEALTHY / DEGRADED) |
security/verify/block_verifier.py |
| Policy Enforcement | E | Any access-sensitive operation | allow or deny with decision path |
security/policy_engine.py |
| WebSocket Streaming | E | Client connects to /ws/{chain_name} |
Real-time block/event push | api/websocket/manager.py |
| IPFS Encrypted Storage | E | IPFSClient.upload_json() |
CID returned; ciphertext on IPFS | api/storage/ipfs_client.py |
| Risk Analysis & Alerts | E | PerformanceMonitor schedule |
Alerts dispatched; escalation on no-ack | monitoring/alert_system.py |
| ERP Integration Sync | E | SyncScheduler timer |
ERP events submitted to Sub-Chain | integration/erp_ledger.py |
| MSP Identity & Auth | F | Entity registration / API auth | Identity confirmed + action authorized | security/msp.py |
| Key Backup & Restoration | F | Key generation / rotation / disaster recovery | Encrypted backup distributed; keys restored | security/key_backup_manager.py |
3. Functional Groups & Subsystems
To streamline architectural understanding, workflows are organized into six functional areas. Developers can use the dashboard below to navigate to the respective group when debugging or modifying core subsystems:
-
Group A β Core Chain Operations
Handles the fundamental ingestion, cryptographic validation, and persistence data paths.
-
Group B β Consensus Finalization
Block finalization mechanisms. For PoA/PoF alternatives, see Consensus Mechanisms.
-
Group C β Cluster Management
Automated governance, state lockdown triggers, and disaster recovery processes.
-
Group D β Integrity & Traceability
Lifecycle auditing tools, cold-start rehydration, and system integrity verification.
-
Group E β Operational & Integration
Security policy gates, real-time WebSocket push, encrypted IPFS offloading, and ERP sync.
-
Group F β Identity & Key Management
X.509 lifecycle enrolment, participant authorization, and encrypted validator key backups.
4. How Workflows Interact
The diagram below shows the runtime relationships and event triggers between all system workflows. Solid lines indicate synchronous/blocking operations, while dashed lines represent asynchronous or event-driven triggers.
flowchart TD
ERP["π’ ERP System\n(SAP / Oracle)"]
CLIENT["π₯οΈ Client / SDK"]
WF14["ERP Sync"] -->|add_event| WF1
CLIENT -->|POST /events| WF1
WF15["πͺͺ MSP Identity"] -->|authorize_action| WF1
WF15 -->|validate_identity| WF10["βοΈ Policy Enforcement"]
WF10 -->|allow/deny gate| WF1
WF1["π¦ Event Submission"] -->|block finalized| WF2["Proof Anchoring"]
WF1 -->|broadcast_new_block| WF11["π WebSocket"]
WF1 -->|upload large data| WF12["ποΈ IPFS Storage"]
WF1 -->|cross-chain op| WF3["2PC Cross-Chain"]
WF1 -->|BFT mode| WF4["π BFT Consensus"]
WF9["π Integrity Scan"] -->|DEGRADED| WF13["π¨ Risk & Alerts"]
WF13 -->|critical threshold| WF5["π Cluster Lockdown"]
WF5 -.->|after lockdown| WF6["π§ Error Recovery"]
WF6 -.->|snapshot fail| WF8["β»οΈ Rehydration"]
WF8 -.->|restore state| WF1
WF5 -.->|key rotation| WF16["π Key Backup"]
WF15 -.->|cert issued| WF16
WF7["ποΈ Entity Tracing"] -.->|reads| WF1
ERP --> WF14
Core Developer Integration Paths
| Ingestion & Security Chain | Description |
|---|---|
| ERP β ERP Sync β Event Submission β Proof Anchoring | Ingestion pipeline: business change β local event β Sub-Chain block β proof hash anchored to root chain. |
| MSP Identity β Policy Enforcement β Event Submission | Security validation path: verify X.509 cert β check ABAC policies β accept/reject event. |
| Integrity Scan β Risk & Alerts β Cluster Lockdown β Error Recovery | Anomaly detection path: audit fail β alert dispatch β gossip lockdown state freeze β auto-recovery restore. |
| Cluster Lockdown β Key Backup | High-security rotation: freeze triggers automated validator private key rotation and encrypted backup. |
| Error Recovery β Rehydration | State sync fallback: local snapshot validation fail triggers in-memory chain rebuild from DB journal. |
5. Developer Guide: How to Maintain Workflows
When implementing new features or correcting system operations, keep HieraChain's workflow documentation synchronous and correct:
Anatomy of a Workflow Document
Each individual workflow page (e.g., event-submission.md) has a strict, highly stylized layout. It must contain:
- Zensical Front-Matter: Standard YAML metadata including
title,description, and a descriptiveicon. (No "WF-number" prefixes allowed). - Clean H1 Header:
# [Title]matching the front-matter. - Overview: Clear description of what the workflow accomplishes, including business context.
- Flow Diagram: High-resolution Mermaid sequence or flowchart visualizing runtime interactions.
- Step-by-Step Breakdown: A detailed Markdown table mapping out sequence numbers to developer-level actions.
- Error Handling: A table mapping failures (e.g., node offline, verification failure) to concrete mitigation steps.
- Key Classes & Methods: Code-level pointers mapping workflow steps directly to implementation code (e.g.,
SubChain.add_event()). - Related: Links to immediate sibling or downstream workflows.
Process for Adding or Modifying a Workflow
- Write Clean Markdown: Save new flows under
docs/en/workflows/name.mdusing the exact design system. - Register in mkdocs.yml: Add your new workflow to the
Workflowstree in mkdocs.yml using a clean, polished name. - Run Term Scanner: Ensure that no forbidden cryptocurrency vocabulary is introduced.
-
Compile and Verify: Run the Zensical build command in the HieraChain environment to confirm formatting and link integrity: