fix(demo): wire AuditSubscriber so events reach the audit log

Tier 1 demo was creating an AuditLog instance but never subscribing it
to the bus, so the verification step always reported '0 events'.
Now we explicitly start the AuditSubscriber and the verifier reports
the actual chain length (4 step events + RotationCompleted = 5).
This commit is contained in:
CarterPerez-dev 2026-04-29 01:22:18 -04:00
parent 51287d3f7d
commit 33cddb57cd
3 changed files with 14 additions and 10 deletions

View File

@ -105,9 +105,9 @@ module CRE::Compliance
private def build_manifest(entries : Array(FileEntry)) : String
{
"framework" => @framework,
"generated" => Time.utc.to_rfc3339,
"files" => entries.map { |e|
"framework" => @framework,
"generated" => Time.utc.to_rfc3339,
"files" => entries.map { |e|
{"name" => e.name, "sha256" => e.sha256_hex, "size" => e.size}
},
}.to_json

View File

@ -23,12 +23,12 @@ module CRE::Compliance
}
PCI_DSS = {
"rotation.completed" => ["8.3.9", "8.6.3"],
"rotation.failed" => ["8.3.9", "10.2.1"],
"policy.violation" => ["8.6.3", "10.2.1"],
"drift.detected" => ["10.2.1", "11.5.2"],
"audit.batch.sealed" => ["10.5.2", "10.5.3"],
"key.rotation.kek" => ["3.7.4"],
"rotation.completed" => ["8.3.9", "8.6.3"],
"rotation.failed" => ["8.3.9", "10.2.1"],
"policy.violation" => ["8.6.3", "10.2.1"],
"drift.detected" => ["10.2.1", "11.5.2"],
"audit.batch.sealed" => ["10.5.2", "10.5.3"],
"key.rotation.kek" => ["3.7.4"],
}
ISO27001 = {

View File

@ -5,6 +5,7 @@
require "../engine/event_bus"
require "../engine/rotation_orchestrator"
require "../engine/subscribers/audit_subscriber"
require "../persistence/sqlite/sqlite_persistence"
require "../rotators/env_file"
require "../audit/audit_log"
@ -51,15 +52,18 @@ module CRE::Demo
io.puts CRE::Tui::Ansi.bold("Step 3 - Rotating (4-step contract):")
bus = CRE::Engine::EventBus.new
ch = bus.subscribe(buffer: 256)
audit_sub = CRE::Engine::Subscribers::AuditSubscriber.new(bus, log)
audit_sub.start
bus.run
rotator = CRE::Rotators::EnvFileRotator.new
orchestrator = CRE::Engine::RotationOrchestrator.new(bus, persist)
state = orchestrator.run(cred, rotator)
sleep 0.05.seconds
sleep 0.15.seconds
drain_steps(ch, io)
audit_sub.stop
bus.stop
io.puts ""