fix(audit): forward DomainEvent.timestamp to AuditService.record() #1258

Merged
HAL9000 merged 3 commits from feature/audit-preserve-event-timestamp into master 2026-05-30 04:05:31 +00:00

3 Commits

Author SHA1 Message Date
controller-ci-rerun 43e16a8987 chore: re-trigger CI [controller]
CI / lint (pull_request) Successful in 43s
CI / quality (pull_request) Successful in 38s
CI / build (pull_request) Successful in 40s
CI / helm (pull_request) Successful in 42s
CI / typecheck (pull_request) Successful in 1m43s
CI / push-validation (pull_request) Successful in 42s
CI / security (pull_request) Successful in 1m53s
CI / unit_tests (pull_request) Successful in 6m12s
CI / integration_tests (pull_request) Successful in 6m19s
CI / docker (pull_request) Successful in 1m23s
CI / coverage (pull_request) Successful in 12m17s
CI / status-check (pull_request) Successful in 2s
2026-05-29 22:50:30 -04:00
HAL9000 8ed8750160 fix(audit): forward DomainEvent.timestamp to AuditService.record()
CI / push-validation (pull_request) Successful in 23s
CI / helm (pull_request) Successful in 30s
CI / build (pull_request) Successful in 43s
CI / lint (pull_request) Successful in 55s
CI / quality (pull_request) Successful in 54s
CI / typecheck (pull_request) Successful in 57s
CI / security (pull_request) Successful in 1m28s
CI / integration_tests (pull_request) Successful in 3m4s
CI / unit_tests (pull_request) Successful in 7m30s
CI / docker (pull_request) Failing after 14m0s
CI / coverage (pull_request) Failing after 21m7s
CI / status-check (pull_request) Has been cancelled
AuditService.record() was generating its own timestamp internally,
discarding the original DomainEvent.timestamp. This means audit entries
recorded when an event was audited, not when the domain event actually
occurred, breaking forensic accuracy per §Audit Logging (SEC7).

Changes:
- Add `timestamp: datetime | None = None` keyword parameter to
  AuditService.record(). When provided, uses it as created_at;
  falls back to datetime.now(tz=UTC) for backward compatibility.
  Applied to both the async queue path and the synchronous DB path.
- AuditEventSubscriber._handle_event() now passes timestamp=event.timestamp
  so the original event creation time is preserved in audit entries.
- Add 3 Behave BDD scenarios covering: full pipeline timestamp
  preservation, direct record() with explicit timestamp, and backward
  compatibility (record() without timestamp auto-generates created_at).
- Add preserve_event_timestamp Robot integration test and helper subcommand.
- Add static source check in security_audit.robot verifying the
  timestamp parameter signature exists.

ISSUES CLOSED: #719
2026-05-29 16:36:39 -04:00
controller-ci-rerun 08c17959cf chore: re-trigger CI [controller] 2026-05-29 16:36:39 -04:00