Forge module wrapping foundation-audit-log.
| Tier | application |
| Role | unclassified (baselined) |
| Path | crates/application/audit-log |
| Edition | 2024 |
| Targets | application_audit_log, pg_forge_audit_log |
| Public items | 24 across 2 modules |
| Tests | 13 |
What it is for
application-audit-log — wraps foundation-audit-log.
Capabilities
AuditLogModule
application-audit-log — wraps foundation-audit-log.
| Item |
|---|
pub struct AuditLogModule |
AuditLogModule :: fn new() -> Self |
AuditLogModule :: fn name(& self) -> & 'static str |
AuditLogModule :: fn version(& self) -> & 'static str |
AuditLogModule :: fn migrations(& self) -> Vec <MigrationSet> |
AuditLogModule :: async fn migrate_pending(& self, pool : & PgPool) -> std::result::Result <u32, MigrationError> |
failures (other)
Fail-loud accounting for best-effort audit writes (Sprint 0.55 T1 / F1).
| Item |
|---|
fn note_audit_write_failure(path : & str, action : & str, err : & sqlx::Error) |
fn audit_write_failures_total() -> u64 |
fn audit_write_failures_for(path : & str, action : & str) -> u64 |
repo (other)
Audit-log persistence over the append-only audit_logs table.
| Item |
|---|
fn action_category(action : & str) -> & 'static str |
async fn list_audit_page(pool : & PgPool, f : & AuditFilter) -> Result <AuditPage, sqlx::Error> |
async fn distinct_actors(pool : & PgPool) -> Result <Vec <(Uuid, String)>, sqlx::Error> |
async fn distinct_actions(pool : & PgPool) -> Result <Vec <String>, sqlx::Error> |
AuditFilter
Audit-log persistence over the append-only audit_logs table.
| Item |
|---|
pub struct AuditFilter |
async fn category_counts(pool : & PgPool, f : & AuditFilter,) -> Result <Vec <(String, i64)>, sqlx::Error> |
AuditPage
Audit-log persistence over the append-only audit_logs table.
| Item |
|---|
pub struct AuditPage |
AuditRepo
Audit-log persistence over the append-only audit_logs table.
| Item |
|---|
pub struct AuditRepo |
AuditRepo :: async fn record <'e, E>(executor : E, log : & AuditLog) -> Result <(), sqlx::Error> where E : Executor <'e, Database = Postgres>, |
AuditRepo :: async fn record_scoped(pool : & PgPool, log : & AuditLog) -> Result <(), sqlx::Error> |
AuditView
Audit-log persistence over the append-only audit_logs table.
| Item |
|---|
pub struct AuditView |
async fn list_audit(pool : & PgPool, actor_id : Option <Uuid>, action : Option <& str>, limit : i64,) -> Result <Vec <AuditView>, sqlx::Error> |
Cursor
Audit-log persistence over the append-only audit_logs table.
| Item |
|---|
pub struct Cursor |
Cursor :: fn encode(& self) -> String |
Cursor :: fn decode(s : & str) -> Option <Self> |
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_audit_log
failuresrepo
flowchart TD n_application_audit_log["application_audit_log"] n_application_audit_log --> n_failures["failures"] n_application_audit_log --> n_repo["repo"]
Public surface
`crate root`
| Item | What it is |
|---|---|
pub struct AuditLogModule | — |
AuditLogModule :: fn new() -> Self | — |
AuditLogModule :: fn name(& self) -> & 'static str | — |
AuditLogModule :: fn version(& self) -> & 'static str | — |
AuditLogModule :: fn migrations(& self) -> Vec <MigrationSet> | — |
AuditLogModule :: async fn migrate_pending(& self, pool : & PgPool) -> std::result::Result <u32, MigrationError> | — |
`failures`
| Item | What it is |
|---|---|
fn note_audit_write_failure(path : & str, action : & str, err : & sqlx::Error) | Record a failed best-effort audit write: bump audit_write_failures_total{path,action} and log at error level |
fn audit_write_failures_total() -> u64 | Headline counter: total best-effort audit-write failures since start. |
fn audit_write_failures_for(path : & str, action : & str) -> u64 | Per-label tally for one (path, action) pair (0 if never failed). |
`repo`
| Item | What it is |
|---|---|
fn action_category(action : & str) -> & 'static str | Coarse category for a log action, for the /staff/logs tabs (Sprint 0.54 lean — derived from the action string; no stored column yet) |
pub struct Cursor | Keyset cursor over (created_at DESC, id DESC) |
Cursor :: fn encode(& self) -> String | — |
Cursor :: fn decode(s : & str) -> Option <Self> | — |
pub struct AuditFilter | Filters for list_audit_page |
pub struct AuditPage | A page of audit rows + the cursor to fetch the next (older) page. |
pub struct AuditRepo | The single audit write path |
AuditRepo :: async fn record <'e, E>(executor : E, log : & AuditLog) -> Result <(), sqlx::Error> where E : Executor <'e, Database = Postgres>, | Append one audit row. |
AuditRepo :: async fn record_scoped(pool : & PgPool, log : & AuditLog) -> Result <(), sqlx::Error> | RLS-safe best-effort write (Sprint 0.55 US-0.55.8b, consensus Q4(b)) |
pub struct AuditView | One audit row, projected for the read-only /admin/audit view. |
async fn list_audit(pool : & PgPool, actor_id : Option <Uuid>, action : Option <& str>, limit : i64,) -> Result <Vec <AuditView>, sqlx::Error> | Read the audit trail newest-first, optionally filtered by actor id and/or action |
async fn list_audit_page(pool : & PgPool, f : & AuditFilter) -> Result <AuditPage, sqlx::Error> | Paginated, filtered audit read for /staff/logs (Sprint 0.54 T1) |
async fn category_counts(pool : & PgPool, f : & AuditFilter,) -> Result <Vec <(String, i64)>, sqlx::Error> | Count rows per category (for the tab badges), honoring the same actor/action/ date filters but NOT the cursor. |
async fn distinct_actors(pool : & PgPool) -> Result <Vec <(Uuid, String)>, sqlx::Error> | Distinct (actor_id, actor_display) pairs present in the trail — for the audit view's Actor filter. |
async fn distinct_actions(pool : & PgPool) -> Result <Vec <String>, sqlx::Error> | Distinct action strings present in the trail — for the Action filter. |
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
note_audit_write_failure | failures::note_audit_write_failure |
{AuditRepo,AuditView} | repo::{AuditRepo,AuditView} |
Boundary
Reaches into foundation, identity.
Shares tier application with 120 other crates: application-agreements, application-ai, application-analytics, application-approvals, application-assessments, application-auth, application-billing, application-browser-automation, … (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) |
| Location | crates/application/audit-log |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_application["application"] --> n_foundation["foundation"] n_application["application"] --> n_identity["identity"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `application-core` | application | no | always |
| `foundation-audit-log` | foundation | no | always |
| `identity-tenant` | identity | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
async-trait | ^0.1 | — | no | always |
chrono | ^0.4 | serde | no | always |
serde_json | ^1 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
tracing | ^0.1 | — | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio | ^1 | full | no | always |
Build. None.
Depended on by. 6 workspace crates.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_auth["application-auth"] -->|uses| SELF n_application_cli["application-cli"] -->|uses| SELF n_application_cms["application-cms"] -->|uses| SELF n_application_dlp["application-dlp"] -->|uses| SELF n_application_impersonation["application-impersonation"] -->|uses| SELF n_application_rbac["application-rbac"] -->|uses| SELF SELF["application-audit-log"] SELF -->|runtime| n_application_core["application-core"] SELF -->|runtime| n_foundation_audit_log["foundation-audit-log"] SELF -->|runtime| n_identity_tenant["identity-tenant"] 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
| Kind | Name | Source |
|---|---|---|
| lib | application_audit_log | `src/lib.rs` |
| test | pg_forge_audit_log | `tests/pg_forge_audit_log.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
| Property | Evidence |
|---|---|
| async public surface | yes |
| async runtime | none detected |
| database access | yes |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | yes |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
| Variable | Read in |
|---|---|
CARGO_PKG_VERSION | src/lib.rs |
Related capabilities
6 workspace crates depend on this one: application-auth, application-cli, application-cms, application-dlp, application-impersonation, application-rbac.
Verification
| Kind | Count |
|---|---|
| Unit tests | 12 |
| Integration tests | 1 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 1 | 0 | 0 |
failures | 3 | 0 | 3 |
repo | 11 | 0 | 11 |
What the tests establish, by name:
migrate_pending_creates_audit_logs_table—tests/pg_forge_audit_log.rsdistinct_labels_do_not_collide—src/failures.rslabelled_counter_increments_per_failure—src/failures.rstotal_counter_moves_on_failure—src/failures.rstest_module_migrations_non_empty—src/lib.rsaudit_filter_carries_rls_setting—src/repo.rscategory_ai—src/repo.rscategory_auth—src/repo.rscategory_content—src/repo.rscategory_job_and_other—src/repo.rscategory_security—src/repo.rscursor_decode_rejects_garbage—src/repo.rscursor_round_trips—src/repo.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 16 | 24 |
Public modules with a //! block | 2 | 2 |
pie showData
title Public items with rustdoc
"Documented" : 16
"No rustdoc detected" : 8
Metrics
| Metric | Value |
|---|---|
| Rust source files | 3 |
| Source lines | 743 |
| Code lines | 547 |
| Public API items | 24 |
| Public modules | 2 |
| Tests | 13 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 9 |
| Workspace reverse dependencies | 6 |
pie showData
title Public API by kind
"function" : 9
"method" : 9
"struct" : 6
pie showData
title Rust source composition
"Code" : 547
"Blank or comment" : 196
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.