Commit 944c6f98 authored by Shouib's avatar Shouib

docs: establish project constitution

parents
<!--
Sync Impact Report
Version change: N/A -> 1.0.0
Modified principles: N/A (Initial Creation)
Added sections: Core Principles, Technical Constraints, Engineering Workflow, Governance
Removed sections: N/A
Follow-up TODOs: None
-->
# Fault-Tolerant Distributed Banking Transaction Constitution
## Core Principles
### I. Effectively-Once Execution
Every financial transaction MUST be executed exactly once, despite network failures, server crashes, or client retries. Duplicate withdrawals or deposits under any failure scenario are strictly prohibited.
**Rationale**: In financial systems, idempotency is the primary defense against monetary loss and data corruption during distributed failures.
### II. Atomic State Transitions
Balance modifications, sequence key updates, and transaction result persistence MUST occur within a single atomic database transaction. No financial operation may rely solely on in-memory synchronization.
**Rationale**: Ensures that the system never reaches a partial state where a balance is updated but the transaction record is lost (or vice versa).
### III. Deterministic Fault Tolerance
The system MUST explicitly handle and be testable against bounded retries, request timeouts, and exponential backoff. Fault injection for request loss, server crashes, and timeouts is a mandatory verification step.
**Rationale**: Reliability cannot be assumed; it must be engineered and verified through simulated failure modes.
### IV. Monetary Precision
All financial calculations MUST use `BigDecimal`. The use of `float` or `double` for monetary amounts is strictly forbidden.
**Rationale**: Floating-point arithmetic introduces rounding errors that are unacceptable in banking applications.
### V. Specification-Driven Development (SDD)
The specification is the single source of truth. No implementation may proceed without an approved constitution, specification, architecture plan, and task list. Every line of code MUST be traceable to a specification requirement.
**Rationale**: Prevents "feature creep" and ensures the implementation precisely matches the agreed-upon fault-tolerance requirements.
## Technical Constraints
### Technology Stack
- **Language**: Java 27
- **Build System**: Maven
- **Database**: Embedded H2 via JDBC
- **Communication**: JDK HTTP Server API & Jackson (JSON)
- **Environment**: Cross-platform compatibility (Windows/IntelliJ IDEA / WSL)
### Reliability Requirements
- **Idempotency**: Monotonically increasing sequence keys per transaction; server-side persistent transaction ledger.
- **Concurrency**: Thread-safe account modifications via atomic DB transactions.
- **Error Handling**: Explicit validation of all incoming requests; explicit handling of insufficient balance and duplicate transactions.
## Engineering Workflow
### Development Cycle
1. **Constitution**: Establish governance and core principles.
2. **Specification**: Define detailed feature behavior.
3. **Architecture Plan**: Design the technical solution.
4. **Task Generation**: Create actionable, dependency-ordered tasks.
5. **Implementation**: Execute tasks following TDD.
### Quality Gates
- **Test Suite**: Mandatory JUnit 5 tests covering unit, integration, concurrency, and fault injection scenarios.
- **Completion Criteria**: All tests must pass.
- **Final Verification**: `mvn clean verify` must succeed without failure.
- **Git Policy**: Meaningful commits mapped to each development phase.
## Governance
This constitution supersedes all other development practices within the project. Any amendments to these principles require a formal review and a version bump. All PRs and reviews must verify compliance with these core principles.
**Version**: 1.0.0 | **Ratified**: 2026-11-02 | **Last Amended**: 2026-11-02
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment