Workflows overview and developer guide
HieraChain is a pure Python hierarchical ledger that works as a plugin layer for existing Web2 infrastructure. It does not replace the enterprise network stack, which already handles TLS/SSL, firewalls and WAF at the API gateway. HieraChain is focused on immutability, distributed trust, tamper evidence and non-repudiation.
This document is the central reference for 16 system workflows in 6 functional groups. It describes how they interact at runtime and how to read, maintain or add workflows.
1. Core development guardrails
When you work on HieraChain workflows, follow these guardrails:
-
Strict term censorship: HieraChain tracks business process ledgers, 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:
eventfor ledger entries,nodefor peers,msp_idfor identity,entity_idfor domain assets. - Note:
CrossChainValidatorscans commits and rejects code that contains forbidden terms.
- Forbidden terms:
-
Minimal latency constraint: HieraChain keeps base latency at 10 to 20ms. Keep workflow code short and fast. Do not add transport level encryption or extra wrappers that add CPU overhead.
- No direct storage access: Do not query SQL or Redis directly. Use storage adapters under
adapters/database/(for exampleadapters/database/sqlite_adapter.py).
2. All workflows: quick reference
This table lists all workflows for quick lookup:
| Workflow | Group | Trigger | Output | Key Module |
|---|---|---|---|---|
| Event Submission | A | POST /api/ledger/chains/{name}/events |
Block appended to Sub-Chain | hierarchical/sub_chain/base.py (SubChain.add_event) |
| Proof Anchoring | A | Block finalized on Sub-Chain | Proof hash on Main Chain | hierarchical/main_chain/base.py + hierarchical/sub_chain/proof.py |
| Cross-Chain 2PC | A | HierarchyManager.transaction_manager |
COMMITTED or ROLLED_BACK |
hierarchical/hierarchy_manager/base.py + hierarchical/transaction_manager.py |
| BFT Consensus | B | HRC_MAINCHAIN_CONSENSUS / HRC_CONSENSUS_TYPE |
Block committed by 2f+1 validators | consensus/bft/consensus.py |
| Cluster Lockdown | C | Anomaly exceeds risk threshold | All nodes frozen / resumed | cluster/lockdown_types.py + cluster/lockdown_protocol.py |
| Error Mitigation | C | Network fail / leader timeout / integrity error | State restored from snapshot | error_mitigation/rollback_manager.py + consensus_recovery.py |
| Entity Tracing | D | EntityTracer.trace_entity() |
Complete cross-chain audit trail | domains/utils/entity_tracer.py |
| Chain Rehydration | D | Node restart or hash divergence | In-memory chain synced to DB | hierarchical/sub_chain/base.py + hierarchical/sub_chain/ordering.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 (cli/key.py) |
Key file / vault backed up; restored via CLI | cli/key.py + security/key_provider.py (no key_backup_manager.py) |
3. Functional groups and subsystems
Workflows are grouped into six areas. Use the dashboard to find the group that matches the subsystem you are debugging or changing:
-
Group A: Core chain operations
Handles ingestion, cryptographic validation and persistence.
-
Group B: Consensus finalization
Block finalization. For PoA/PoF alternatives, see Consensus Mechanisms.
-
Group C: Cluster management
Governance, lockdown triggers and recovery.
-
Group D: Integrity and traceability
Auditing, cold start rehydration and integrity verification.
-
Group E: Operational and integration
Policy gates, WebSocket push, encrypted IPFS offloading and ERP sync.
-
Group F: Identity and key management
Lightweight MSP enrolment (internal
Certificateinsecurity/msp.py), participant authorization and CLI-managed key backup (no X.509/mTLS).
4. How workflows interact
The diagram shows runtime relationships and triggers between workflows. Solid lines are synchronous or blocking operations. Dashed lines are asynchronous or event driven.
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 internal cert (msp.py:verify_certificate) β check ABAC policies β accept/reject event. |
| Integrity Scan β Risk & Alerts β Cluster Lockdown β Error Recovery | Anomaly detection path: block_verifier/risk_analyzer β alert dispatch β lockdown β rollback_manager restore. |
| Cluster Lockdown β Key Backup | No automatic coupling in code: key rotation/backup is manual via cli/key.py (not triggered by lockdown). |
| 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
Keep workflow documentation in sync with the code when you add features or fix behavior:
Anatomy of a workflow document
Each workflow page (for example event-submission.md) has this layout. It must contain:
- Zensical front-matter: YAML metadata with
title,descriptionandicon. No WF-number prefixes. - Clean H1 header:
# [Title]that matches front-matter. - Overview: What the workflow does and when it is used.
- Flow diagram: Mermaid sequence or flowchart that shows runtime interactions.
- Step-by-step breakdown: Table that maps sequence numbers to developer actions.
- Error handling: Table that maps failures (node offline, verification failure) to mitigations.
- Key classes and methods: Pointers from workflow steps to code (for example
SubChain.add_event()). - Related: Links to sibling or downstream workflows.
Process for adding or modifying a workflow
- Write clean Markdown: Save new flows under
docs/en/workflows/name.mdusing the design system. - Register in zensical.toml: Add the workflow to the
Workflowstree in zensical.toml with a clean name. - Run term scanner: Check that no forbidden cryptocurrency vocabulary was added.
-
Compile and verify: Run the Zensical build in the HieraChain environment to check formatting and links: