ALTANIX FULL-REPOSITORY VERIFIED AUDIT · GRAPH-FIRST & HOTSPOT SLICING

demo/payment-platform

Audit ID: audit-9a6a8f98 · Commit: f8a92c104e71b3d0 · Files: 6 (63 LOC) · Architecture: Clean / Hexagonal Layered Architecture

BASELINE CACHED

Whole-repository SemanticCodeGraph (27 nodes, 25 edges) is persisted at data/repo_graphs/demo_payment-platform.json. Every future Pull Request on this repository will run incremental diff invalidation with full cross-project Blast Radius awareness.

Overall Health
69/100
Deterministic Composite
Architecture
44/100
Contracts & Layering
Concurrency
70/100
Async Locks & Queues
Security & Taint
80/100
7D Risk & Sanitization
Database DDL
82/100
Zero-Downtime Migrations

Project Architecture Profile

Discovered API Endpoints
/api/v1/payments/checkout
Database Tables & Migrations
accounts ledger_entries orders
Executive Summary
### Full-Repository Architectural & Security Audit (`demo/payment-platform` @ `f8a92c104e71b3d0`)

- **Overall Health Score:** **69/100** (Architecture: 44/100, Concurrency: 70/100, Security: 80/100, Database DDL: 82/100)
- **Semantic Graph Baseline:** `27` nodes and `25` edges indexed across `6` files (`63` LOC). Detected style: **Clean / Hexagonal Layered Architecture**.
- **First-PR Whole-Repo Baseline Cached:** Persisted to `data/repo_graphs/demo_payment-platform.json` so every subsequent PR review loads full project knowledge incrementally.
- **Evidence-Backed Findings:** `8` verified findings (`6` closed-loop 1-click fixes synthesized and sandbox-verified).

Semantic Code Graph Topology (Mermaid)

flowchart TD
    fn_src_controllers_checkout_controller_rs__checkout_handler["Function: checkout_handler"]
    fn_src_services_payment_service_rs__charge_with_lock["Function: charge_with_lock"]
    db_ledger_entries["DatabaseTable: ledger_entries"]
    db_accounts["DatabaseTable: accounts"]
    queue_billing_events_dispatched["Queue: billing.events.dispatched"]
    fn_src_ingest_event_bus_rs__spawn_event_dispatcher["Function: spawn_event_dispatcher"]
    api__api_v1_payments_checkout["ApiEndpoint: /api/v1/payments/checkout"]
    fn_src_services_payment_service_rs__process_order_payment["Function: process_order_payment"]
    ext_api_stripe_com["ExternalService: api.stripe.com"]
    db_orders["DatabaseTable: orders"]
    api__api_v1_payments_checkout -->|"Calls"| fn_src_controllers_checkout_controller_rs__checkout_handler
    fn_src_controllers_checkout_controller_rs__checkout_handler -->|"Reads"| db_orders
    fn_src_services_payment_service_rs__process_order_payment -->|"Calls"| ext_api_stripe_com
    fn_src_services_payment_service_rs__process_order_payment -->|"Reads"| db_accounts
    fn_src_services_payment_service_rs__process_order_payment -->|"Writes"| db_ledger_entries
    fn_src_services_payment_service_rs__charge_with_lock -->|"Calls"| fn_src_services_payment_service_rs__process_order_payment
    fn_src_controllers_checkout_controller_rs__checkout_handler -->|"Calls"| fn_src_services_payment_service_rs__process_order_payment
    fn_src_ingest_event_bus_rs__spawn_event_dispatcher -->|"Writes"| queue_billing_events_dispatched

Top Architectural & Risk Hotspots (Graph Coupling × Findings)

File Path Primary Symbol Graph Edges Findings Hotspot Score Analysis Reason
src/ingest/event_bus.rs AuditEvent 3 3 99/99 High graph coupling (3 edges) combined with 3 verified risk finding(s)
src/controllers/checkout_controller.rs checkout_handler 7 2 99/99 High graph coupling (7 edges) combined with 2 verified risk finding(s)
src/services/payment_service.rs process_order_payment 10 1 99/99 High graph coupling (10 edges) combined with 1 verified risk finding(s)
src/domain/order_entity.rs OrderEntity 1 1 33/99 Contains 1 verified architectural/safety finding(s)
migrations/20261120_add_settlement_tier.sql migrations/20261120_add_settlement_tier.sql 1 1 33/99 Contains 1 verified architectural/safety finding(s)

Proof-Carrying Findings & Closed-Loop Verified 1-Click Fixes (8)

CRITICAL controller-no-database lifecycle: path_confirmed
src/controllers/checkout_controller.rs:1

Architectural Contract Violation: controller-no-database

[mode=enforce] Architectural contract 'controller-no-database' (v1, owner: platform-architecture) violated in 'src/controllers/checkout_controller.rs': forbidden dependency 'sqlx::' detected (`use sqlx::PgPool;`). HTTP/API controllers must not directly access database drivers or infrastructure persistence layers

Evidence Chain (Invariant: CLEAN_ARCH_BOUNDARY · SHA-256: aa39c6992cd0)
Step 1 · ArchitecturalScope
Module 'src/controllers/checkout_controller.rs' evaluated against contract 'controller-no-database'
use sqlx::PgPool; (line 1)
Step 2 · ContractViolation
[mode=enforce] Architectural contract 'controller-no-database' (v1, owner: platform-architecture) violated in 'src/controllers/checkout_controller.rs': forbidden dependency 'sqlx::' detected (`use sqlx::PgPool;`). HTTP/API controllers must not directly access database drivers or infrastructure persistence layers
sqlx:: (line 1)
CRITICAL TAINT_SQL_INJECTION lifecycle: path_confirmed
src/controllers/checkout_controller.rs:6

Taint Flow: Unsanitized Input Interpolated into SQL Query (CWE-89)

String interpolation via `format!` constructs a dynamic SQL query from user input, enabling SQL injection. Use parameterized queries with `.bind($1)`.

Evidence Chain (Invariant: TAINT_UNSANITIZED_SINK · SHA-256: bb4a6d727b59)
Step 1 · Source
Untrusted caller parameter interpolated directly into SQL string via format!()
let raw_sql = format!("SELECT id, status FROM orders WHERE user_email = '{}'", user_email); (line 6)
Step 2 · Sink
Dynamically formatted SQL string passed to database query executor (CWE-89)
sqlx::query(&raw_sql).execute(pool).await.ok(); (line 7)
Closed-Loop Verified 1-Click Fix (4/4 Sandbox Stages Passed) Status: path_confirmed
sqlx::query("SELECT id, status FROM orders WHERE user_email = $1").bind(user_email)
CRITICAL NO_MUTEX_ACROSS_AWAIT lifecycle: regression_tested
src/services/payment_service.rs:21

Mutex Lock Guard Held Across .await Suspension Point

Holding a Mutex lock guard across an `.await` suspension point can stall Tokio worker threads and cause cyclic deadlocks under concurrent load.

Evidence Chain (Invariant: NO_MUTEX_ACROSS_AWAIT · SHA-256: 47118ab5a04a)
Step 1 · LockAcquire
Async/Sync Mutex lock guard acquired and bound in function scope
let mut guard = self.shared_ledger.lock().await; (line 21)
Step 2 · SuspensionPoint
Future yields at .await while lock guard remains alive, risking Tokio executor deadlock
process_order_payment(order_id).await?; (line 23)
Closed-Loop Verified 1-Click Fix (4/4 Sandbox Stages Passed) Status: regression_tested
use std::sync::Arc;
use tokio::sync::Mutex;

pub struct SharedLedger {
    pub active_orders: Vec<u64>,
}

pub struct PaymentProcessor {
    pub shared_ledger: Arc<Mutex<SharedLedger>>,
}

pub async fn process_order_payment(order_id: u64) -> Result<(), String> {
    let gateway_url = "https://api.stripe.com/v1/charges";
    let select_q = "SELECT id, balance FROM accounts WHERE id = $1";
    let update_q = "UPDATE ledger_entries SET status = 'CAPTURED' WHERE order_id = $1";
    Ok(())
}

impl PaymentProcessor {
    pub async fn charge_with_lock(&self, order_id: u64) -> Result<(), String> {
        {
            let mut guard = self.shared_ledger.lock().await;
            guard.active_orders.push(order_id);
        }
        process_order_payment(order_id).await?;
        {
            let mut guard = self.shared_ledger.lock().await;
            guard.active_orders.retain(|id| *id != order_id);
        }
        Ok(())
    }
}
HIGH async-bounded-channels-only lifecycle: regression_tested
src/ingest/event_bus.rs:8

Architectural Contract Violation: async-bounded-channels-only

[mode=enforce] Architectural contract 'async-bounded-channels-only' (v1, owner: reliability-engineering) violated in 'src/ingest/event_bus.rs': forbidden dependency 'tokio::sync::mpsc::unbounded_channel' detected (`let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();`). Production services must not allocate unbounded MPSC channels susceptible to OOM under backpressure

Evidence Chain (Invariant: CLEAN_ARCH_BOUNDARY · SHA-256: 6bbb4586f255)
Step 1 · ArchitecturalScope
Module 'src/ingest/event_bus.rs' evaluated against contract 'async-bounded-channels-only'
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel(); (line 8)
Step 2 · ContractViolation
[mode=enforce] Architectural contract 'async-bounded-channels-only' (v1, owner: reliability-engineering) violated in 'src/ingest/event_bus.rs': forbidden dependency 'tokio::sync::mpsc::unbounded_channel' detected (`let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();`). Production services must not allocate unbounded MPSC channels susceptible to OOM under backpressure
tokio::sync::mpsc::unbounded_channel (line 8)
Closed-Loop Verified 1-Click Fix (4/4 Sandbox Stages Passed) Status: regression_tested
use tokio::sync::mpsc;

pub struct AuditEvent {
    pub payload: String,
}

pub fn spawn_event_dispatcher() {
    let (tx, mut rx) = tokio::sync::mpsc::channel(1024);
    publish("billing.events.dispatched");
}
HIGH async-bounded-channels-only lifecycle: regression_tested
src/ingest/event_bus.rs:8

Architectural Contract Violation: async-bounded-channels-only

[mode=enforce] Architectural contract 'async-bounded-channels-only' (v1, owner: reliability-engineering) violated in 'src/ingest/event_bus.rs': forbidden dependency 'mpsc::unbounded_channel' detected (`let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();`). Production services must not allocate unbounded MPSC channels susceptible to OOM under backpressure

Evidence Chain (Invariant: CLEAN_ARCH_BOUNDARY · SHA-256: b6a7c9c5a618)
Step 1 · ArchitecturalScope
Module 'src/ingest/event_bus.rs' evaluated against contract 'async-bounded-channels-only'
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel(); (line 8)
Step 2 · ContractViolation
[mode=enforce] Architectural contract 'async-bounded-channels-only' (v1, owner: reliability-engineering) violated in 'src/ingest/event_bus.rs': forbidden dependency 'mpsc::unbounded_channel' detected (`let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel();`). Production services must not allocate unbounded MPSC channels susceptible to OOM under backpressure
mpsc::unbounded_channel (line 8)
Closed-Loop Verified 1-Click Fix (4/4 Sandbox Stages Passed) Status: regression_tested
use tokio::sync::mpsc;

pub struct AuditEvent {
    pub payload: String,
}

pub fn spawn_event_dispatcher() {
    let (tx, mut rx) = tokio::sync::mpsc::channel(1024);
    publish("billing.events.dispatched");
}
HIGH UNBOUNDED_CHANNEL_OOM lifecycle: regression_tested
src/ingest/event_bus.rs:8

Unbounded MPSC Channel Allocation Without Backpressure (OOM Hazard)

Using `mpsc::unbounded_channel()` disables backpressure and risks Out-Of-Memory termination during traffic spikes.

Evidence Chain (Invariant: BOUNDED_QUEUE_BACKPRESSURE · SHA-256: e30b200af66b)
Step 1 · Source
Unbounded MPSC queue allocated without backpressure capacity limit
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel(); (line 8)
Step 2 · Sink
Producer bursts can exhaust process heap memory (OOM) when consumer lags
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel(); (line 8)
Closed-Loop Verified 1-Click Fix (4/4 Sandbox Stages Passed) Status: regression_tested
use tokio::sync::mpsc;

pub struct AuditEvent {
    pub payload: String,
}

pub fn spawn_event_dispatcher() {
    let (tx, mut rx) = tokio::sync::mpsc::channel(1024);
    publish("billing.events.dispatched");
}
CRITICAL domain-pure-no-infra lifecycle: regression_tested
src/domain/order_entity.rs:1

Architectural Contract Violation: domain-pure-no-infra

[mode=enforce] Architectural contract 'domain-pure-no-infra' (v1, owner: domain-architecture) violated in 'src/domain/order_entity.rs': forbidden dependency 'sqlx::' detected (`use sqlx::PgPool;`). Domain layer must remain pure and independent of database, HTTP, or infrastructure modules

Evidence Chain (Invariant: CLEAN_ARCH_BOUNDARY · SHA-256: b5b56adfdefc)
Step 1 · ArchitecturalScope
Module 'src/domain/order_entity.rs' evaluated against contract 'domain-pure-no-infra'
use sqlx::PgPool; (line 1)
Step 2 · ContractViolation
[mode=enforce] Architectural contract 'domain-pure-no-infra' (v1, owner: domain-architecture) violated in 'src/domain/order_entity.rs': forbidden dependency 'sqlx::' detected (`use sqlx::PgPool;`). Domain layer must remain pure and independent of database, HTTP, or infrastructure modules
sqlx:: (line 1)
Closed-Loop Verified 1-Click Fix (4/4 Sandbox Stages Passed) Status: regression_tested
pub trait DomainRepository: Send + Sync {
    fn execute_domain_action(&self, entity_id: &str) -> Result<(), String>;
}

pub struct OrderEntity {
    pub id: u64,
    pub db_pool: std::sync::Arc<dyn DomainRepository>,
}
HIGH NOT_NULL_WITHOUT_DEFAULT lifecycle: regression_tested
migrations/20261120_add_settlement_tier.sql:2

Blocking DDL Migration: ADD COLUMN NOT NULL Without DEFAULT

Adding a `NOT NULL` column without a `DEFAULT` clause forces a full table lock/rewrite or fails on existing rows during zero-downtime deployments.

Evidence Chain (Invariant: ZERO_DOWNTIME_MIGRATION · SHA-256: 2e03ad4185df)
Step 1 · Source
DDL statement adds a NOT NULL column without a constant DEFAULT value
ALTER TABLE ledger_entries ADD COLUMN settlement_tier VARCHAR(32) NOT NULL; (line 2)
Step 2 · Sink
Acquires ACCESS EXCLUSIVE table lock and fails on non-empty production tables
ALTER TABLE ledger_entries ADD COLUMN settlement_tier VARCHAR(32) NOT NULL; (line 2)
Closed-Loop Verified 1-Click Fix (4/4 Sandbox Stages Passed) Status: regression_tested
-- Migration: Add settlement_tier to ledger_entries
ALTER TABLE ledger_entries ADD COLUMN settlement_tier VARCHAR(32) DEFAULT '' NOT NULL;