application tier

application-dlp

Forge module for DLP: the dlp_captures table (idempotent on tenant/device/event, tiered retention via confirmed+expires_at), masked-only capture persistence, retention purge, and RBAC codes. Consumes infrastructure-dlp envelopes; masked data only, never raw.

Forge module for DLP: the dlp_captures table (idempotent on tenant/device/event, tiered retention via confirmed+expires_at), masked-only capture persistence, retention purge, and RBAC codes. Consumes infrastructure-dlp envelopes; masked data only, never raw.

Tierapplication
Roleunclassified (baselined)
Pathcrates/application/dlp
Edition2021
Targetsapplication_dlp, pg_agents, pg_live, pg_tenant_pool
Public items20 across 3 modules
Tests7

What it is for

application-dlp — Forge module for masked DLP captures.

Owns the dlp_captures + dlp_outbox tables in each tenant's OWN business DB (the per-tenant DB is the isolation boundary — no RLS here; sprint 2.6). Stores masked data only, never raw.

Two-database atomicity via a transactional outbox (Gate-1.5 consensus): record_capture writes the capture AND an outbox row in ONE business-DB transaction; deliver_outbox (run by a infrastructure-jobs relay) delivers dlp.detected to the SHARED-INFRA audit log and marks the outbox row delivered. No committed capture is ever permanently left un-audited.

Capabilities

crate root

application-dlp — Forge module for masked DLP captures.

Item
async fn record_capture(business_pool : & PgPool, tenant_id : Uuid, actor_id : Uuid, env : & DlpFindingEnvelope, expires_at : Option <chrono::DateTime <chrono::Utc>>,) -> Result <Option <Uuid>, sqlx::Error>
async fn deliver_outbox(business_pool : & PgPool, audit_pool : & PgPool, batch : i64,) -> Result <u64, sqlx::Error>
pub const CONTROL_PLANE_MIGRATION: & str
pub const AUDIT_DEDUP_MIGRATION: & str

DlpModule

application-dlp — Forge module for masked DLP captures.

Item
pub struct DlpModule
DlpModule :: fn new() -> Self
DlpModule :: async fn migrate_audit_dedup(& self, pool : & PgPool) -> Result <u32, MigrationError>
DlpModule :: async fn migrate_control_plane(& self, pool : & PgPool) -> Result <u32, MigrationError>
DlpModule :: fn name(& self) -> & 'static str
DlpModule :: fn version(& self) -> & 'static str
DlpModule :: fn migrations(& self) -> Vec <MigrationSet>
DlpModule :: async fn migrate_pending(& self, pool : & PgPool) -> Result <u32, MigrationError>
DlpModule :: fn permission_codes(& self) -> Vec <String>

api (other)

HTTP routes for application-dlp (free-function routers, staff-host pattern — there is

Item
fn admin_router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, Arc <TenantPoolManager> : FromRef <S>,
fn ingest_router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, Arc <TenantPoolManager> : FromRef <S>,

ingest (other)

Ingest authorization — the security core of the /api/dlp/ingest handler.

Item
fn authorize_ingest(agent : & AgentIdentity, env : & DlpFindingEnvelope,) -> Result <(Uuid, String), IngestReject>

AgentIdentity

Ingest authorization — the security core of the /api/dlp/ingest handler.

Item
pub struct AgentIdentity
async fn resolve_agent <'e, E>(control : E, presented_key : & str,) -> Result <Option <AgentIdentity>, sqlx::Error> where E : PgExecutor <'e>,

IngestReject

Ingest authorization — the security core of the /api/dlp/ingest handler.

Item
pub enum IngestReject

notify (other)

Operator notification on DLP detection (sprint 2.7, best-effort).

Item
async fn notify_capture(control : & PgPool, tenant_id : Uuid, env : & DlpFindingEnvelope)

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

application_dlp

flowchart TD
  n_application_dlp["application_dlp"]
  n_application_dlp --> n_api["api"]
  n_application_dlp --> n_ingest["ingest"]
  n_application_dlp --> n_notify["notify"]

Public surface

`crate root`

ItemWhat it is
async fn record_capture(business_pool : & PgPool, tenant_id : Uuid, actor_id : Uuid, env : & DlpFindingEnvelope, expires_at : Option <chrono::DateTime <chrono::Utc>>,) -> Result <Option <Uuid>, sqlx::Error>Persist a masked capture + its outbox row in ONE business-DB transaction
async fn deliver_outbox(business_pool : & PgPool, audit_pool : & PgPool, batch : i64,) -> Result <u64, sqlx::Error>Relay: deliver undelivered outbox rows to the SHARED-INFRA audit log, then mark them delivered
pub const CONTROL_PLANE_MIGRATION: & strThe control-plane migration (sensor-agent registration)
pub const AUDIT_DEDUP_MIGRATION: & strThe audit-side dedup migration (dlp_audit_delivered)
pub struct DlpModuleThe mountable Forge DLP module.
DlpModule :: fn new() -> SelfConstruct the module.
DlpModule :: async fn migrate_audit_dedup(& self, pool : & PgPool) -> Result <u32, MigrationError>Apply the audit-side dedup migration (dlp_audit_delivered) to the SHARED audit pool
DlpModule :: async fn migrate_control_plane(& self, pool : & PgPool) -> Result <u32, MigrationError>Apply the control-plane migration (dlp_agents) to the SHARED control-plane pool
DlpModule :: fn name(& self) -> & 'static str
DlpModule :: fn version(& self) -> & 'static str
DlpModule :: fn migrations(& self) -> Vec <MigrationSet>
DlpModule :: async fn migrate_pending(& self, pool : & PgPool) -> Result <u32, MigrationError>
DlpModule :: fn permission_codes(& self) -> Vec <String>

`api`

ItemWhat it is
fn admin_router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, Arc <TenantPoolManager> : FromRef <S>,Masked-alert viewer routes
fn ingest_router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, Arc <TenantPoolManager> : FromRef <S>,Agent ingest routes

`ingest`

ItemWhat it is
pub struct AgentIdentityThe tenant + device a presented agent credential is bound to (resolved from the agent registration by the handler, before authorization).
pub enum IngestRejectWhy an ingest was rejected (maps to HTTP 403).
fn authorize_ingest(agent : & AgentIdentity, env : & DlpFindingEnvelope,) -> Result <(Uuid, String), IngestReject>Authorize an envelope against the authenticated agent identity
async fn resolve_agent <'e, E>(control : E, presented_key : & str,) -> Result <Option <AgentIdentity>, sqlx::Error> where E : PgExecutor <'e>,Resolve a presented plaintext agent key to its bound AgentIdentity via the control-plane api_keys + dlp_agents tables

`notify`

ItemWhat it is
async fn notify_capture(control : & PgPool, tenant_id : Uuid, env : & DlpFindingEnvelope)Alert the tenant's active owners about a detection

Re-exports. Exported here, defined elsewhere.

ExportDefined in
notify_capturenotify::notify_capture
{authorize_ingest,resolve_agent,AgentIdentity,IngestReject}ingest::{authorize_ingest,resolve_agent,AgentIdentity,IngestReject}
{fetch_undelivered_outbox,insert_capture,insert_outbox,list_recent,mark_outbox_delivered,purge_expired_unconfirmed,CaptureRow,OutboxRow,}repo::{fetch_undelivered_outbox,insert_capture,insert_outbox,list_recent,mark_outbox_delivered,purge_expired_unconfirmed,CaptureRow,OutboxRow,}

Boundary

Reaches into identity, infrastructure.

Shares tier application with 120 other crates: application-agreements, application-ai, application-analytics, application-approvals, application-assessments, application-audit-log, application-auth, application-billing, … (120 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)application
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/application/dlp
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_application["application"] --> n_identity["identity"]
  n_application["application"] --> n_infrastructure["infrastructure"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`application-audit-log`applicationnoalways
`application-core`applicationnoalways
`application-notifications`applicationnoalways
`application-rbac`applicationnoalways
`identity-auth`identitynoalways
`identity-tenant`identitynoalways
`infrastructure-dlp`infrastructurenoalways
`infrastructure-tenant-pool`infrastructurenoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways
axum^0.7multipartnoalways
chrono^0.4serde, serdenoalways
serde^1derive, derivenoalways
serde_json^1noalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, json, migratenoalways
tracing^0.1noalways
uuid^1v4, v7, serde, js, v4, serdenoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio^1full, macros, rt-multi-threadnoalways
uuid^1v4, v7, serde, js, v4noalways

Build. None.

Depended on by. 1 workspace crate.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_platform_privacy_scan_api["platform-privacy-scan-api"] -->|uses| SELF
  SELF["application-dlp"]
  SELF -->|runtime| n_application_audit_log["application-audit-log"]
  SELF -->|runtime| n_application_core["application-core"]
  SELF -->|runtime| n_application_notifications["application-notifications"]
  SELF -->|runtime| n_application_rbac["application-rbac"]
  SELF -->|runtime| n_identity_auth["identity-auth"]
  SELF -->|runtime| n_identity_tenant["identity-tenant"]
  SELF -->|runtime| n_infrastructure_dlp["infrastructure-dlp"]
  SELF -->|runtime| n_infrastructure_tenant_pool["infrastructure-tenant-pool"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
libapplication_dlp`src/lib.rs`
testpg_agents`tests/pg_agents.rs`
testpg_live`tests/pg_live.rs`
testpg_tenant_pool`tests/pg_tenant_pool.rs`

Error model

No public error type was detected: no public item declares a type named *Error, and no public signature returns one.

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimenone detected
database accessyes
network I/Oyes
unsafe codenone detected
environment variablesyes

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

VariableRead in
CARGO_PKG_VERSIONsrc/lib.rs

1 workspace crate depends on this one: platform-privacy-scan-api.

Verification

KindCount
Unit tests4
Integration tests3
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root501
api200
ingest400
notify100

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc1520
Public modules with a //! block33
pie showData
    title Public items with rustdoc
    "Documented" : 15
    "No rustdoc detected" : 5

Metrics

MetricValue
Rust source files5
Source lines723
Code lines511
Public API items20
Public modules3
Tests7
Examples0
Cargo features0
Direct runtime dependencies16
Workspace reverse dependencies1
pie showData
    title Public API by kind
    "constant" : 2
    "enum" : 1
    "function" : 7
    "method" : 8
    "struct" : 2
pie showData
    title Rust source composition
    "Code" : 511
    "Blank or comment" : 212

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

All application · Manual