Skip to content

Feature/sma 101 audit log trait noop factory composition root wiring#194

Open
mrnkslv wants to merge 6 commits into
feature/sma-99-audit-log-architecturefrom
feature/sma-101-audit-log-trait-noop-factory-composition-root-wiring
Open

Feature/sma 101 audit log trait noop factory composition root wiring#194
mrnkslv wants to merge 6 commits into
feature/sma-99-audit-log-architecturefrom
feature/sma-101-audit-log-trait-noop-factory-composition-root-wiring

Conversation

@mrnkslv
Copy link
Copy Markdown
Contributor

@mrnkslv mrnkslv commented May 28, 2026

Summary

Define AuditLog async trait, NoopAuditLog, and AuditLogFactory as the foundation for the audit log subsystem. Wire Arc through the composition root so all future producers can depend on the trait without further structural changes.

Changes

  • Add AuditLog async trait (record(&self, event: AuditEvent)) and NoopAuditLog implementation in audit/log.rs
  • Add AuditLogFactory::from_config returning Arc; placeholder returns NoopAuditLog until JsonlAuditLog is implemented
  • Add AuditInitError using thiserror with InvalidPath, DirCreate, FileOpen variants
  • Add AuditLogConfig to AppConfig with #[serde(default)] — existing configs without the field load unchanged
    Wire Arc in service_main_task.rs: initialized after setup_log, passed to ElectionsTask and http_server_task::run
  • Add audit: Arc field to AppState and ElectionsTask
  • Remove standalone audit/config.rs — AuditLogConfig lives in common::app_config alongside other config types
  • Tests: noop_audit_log_record_completes verifies the NoopAuditLog contract;
  • factory_returns_audit_log_that_accepts_events verifies factory behavior without downcasting

Closes SMA-101

@linear
Copy link
Copy Markdown

linear Bot commented May 28, 2026

SMA-101

…-101-audit-log-trait-noop-factory-composition-root-wiring
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces the audit log abstraction and wires a shared Arc<dyn AuditLog> through the node-control service composition root so future audit producers can depend on it.

Changes:

  • Adds AuditLog, NoopAuditLog, AuditLogFactory, and audit initialization error scaffolding.
  • Moves AuditLogConfig into common app config and adds it to AppConfig with serde defaults.
  • Passes the audit log into HTTP AppState and the elections task, updating tests and config constructors.

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/node-control/service/src/audit/log.rs Adds the async audit log trait, noop implementation, and unit test.
src/node-control/service/src/audit/factory.rs Adds factory and initialization error type for audit log creation.
src/node-control/service/src/audit/mod.rs Re-exports audit config, factory, trait, and noop implementation.
src/node-control/service/src/audit/event.rs Updates test import path for AuditLogConfig.
src/node-control/common/src/app_config.rs Adds AuditLogConfig, embeds it in AppConfig, and tests missing-field defaults.
src/node-control/service/src/service_main_task.rs Initializes audit logging and passes it to service tasks.
src/node-control/service/src/task/mod.rs Adds audit dependency to ElectionsTask.
src/node-control/service/src/elections/election_task.rs Accepts the audit log dependency in the elections runner.
src/node-control/service/src/http/http_server_task.rs Adds audit log to HTTP app state and run wiring.
src/node-control/service/src/http/entity_crud_handlers_tests.rs Updates test config/state construction with audit defaults.
src/node-control/service/src/http/config_handlers_tests.rs Updates test config/state construction with audit defaults.
src/node-control/service/src/http/auth_tests.rs Updates test config/state construction with audit defaults.
src/node-control/service/src/task/task_manager.rs Updates test AppConfig construction.
src/node-control/service/src/contracts/contracts_task.rs Updates test AppConfig construction.
src/node-control/service/src/auth/user_store.rs Updates test AppConfig construction.
src/node-control/commands/src/commands/nodectl/config_cmd.rs Includes audit log defaults in generated config.
src/node-control/service/Cargo.toml Adds thiserror dependency for audit init errors.
src/Cargo.lock Locks the new service dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

pub mod participant;

pub use config::AuditLogConfig;
pub use common::app_config::AuditLogConfig;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


let audit = AuditLogFactory::from_config(&app_cfg.audit_log)
.await
.map_err(|e| anyhow::anyhow!("audit log init failed: {e}"))?;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@mrnkslv mrnkslv added run-e2e and removed run-e2e labels May 28, 2026
@mrnkslv mrnkslv requested a review from Keshoid May 28, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants