Audit ID: audit-9a6a8f98 · Commit: f8a92c104e71b3d0 · Files: 6 (63 LOC) · Architecture: Clean / Hexagonal Layered Architecture
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.
### 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).
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
| 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) |
[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
use sqlx::PgPool; (line 1)
sqlx:: (line 1)
String interpolation via `format!` constructs a dynamic SQL query from user input, enabling SQL injection. Use parameterized queries with `.bind($1)`.
let raw_sql = format!("SELECT id, status FROM orders WHERE user_email = '{}'", user_email); (line 6)
sqlx::query(&raw_sql).execute(pool).await.ok(); (line 7)
sqlx::query("SELECT id, status FROM orders WHERE user_email = $1").bind(user_email)
Holding a Mutex lock guard across an `.await` suspension point can stall Tokio worker threads and cause cyclic deadlocks under concurrent load.
let mut guard = self.shared_ledger.lock().await; (line 21)
process_order_payment(order_id).await?; (line 23)
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(())
}
}
[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
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel(); (line 8)
tokio::sync::mpsc::unbounded_channel (line 8)
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");
}
[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
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel(); (line 8)
mpsc::unbounded_channel (line 8)
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");
}
Using `mpsc::unbounded_channel()` disables backpressure and risks Out-Of-Memory termination during traffic spikes.
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel(); (line 8)
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel(); (line 8)
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");
}
[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
use sqlx::PgPool; (line 1)
sqlx:: (line 1)
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>,
}
Adding a `NOT NULL` column without a `DEFAULT` clause forces a full table lock/rewrite or fails on existing rows during zero-downtime deployments.
ALTER TABLE ledger_entries ADD COLUMN settlement_tier VARCHAR(32) NOT NULL; (line 2)
ALTER TABLE ledger_entries ADD COLUMN settlement_tier VARCHAR(32) NOT NULL; (line 2)
-- Migration: Add settlement_tier to ledger_entries ALTER TABLE ledger_entries ADD COLUMN settlement_tier VARCHAR(32) DEFAULT '' NOT NULL;