Skip to content

Conversation

@houseme
Copy link
Contributor

@houseme houseme commented Nov 14, 2025

Type of Change

  • New Feature
  • Bug Fix
  • Documentation
  • Performance Improvement
  • Test/CI
  • Refactor
  • Other:

Related Issues

Summary of Changes

Problem

The audit system currently transitions to AuditSystemState::Starting immediately upon entering the start() method, before validating that any targets exist. This causes a brief state inconsistency when the configuration contains no enabled targets.

Solution

This PR modifies the state machine logic to:

  1. Create targets from configuration first
  2. Check if the target list is empty
  3. Only transition to Starting state if targets exist
  4. Return early with Ok(()) and keep Stopped state when no targets are found

Changes

  • File: crates/audit/src/system.rs
  • Move state transition (*state = AuditSystemState::Starting) after target creation
  • Add early return when targets.is_empty()
  • Add informative log message for zero-target scenario

Testing

  • System remains in Stopped state when no targets configured
  • Normal startup proceeds when valid targets exist
  • State consistency maintained across edge cases

Impact

  • Prevents misleading state transitions
  • Improves observability and debugging
  • No breaking changes to public API

Checklist

  • I have read and followed the CONTRIBUTING.md guidelines
  • Passed make pre-commit
  • Added/updated necessary tests
  • Documentation updated (if needed)
  • CI/CD passed (if applicable)

Impact

  • Breaking change (compatibility)
  • Requires doc/config/deployment update
  • Other impact:

Additional Notes


Thank you for your contribution! Please ensure your PR follows the community standards (CODE_OF_CONDUCT.md) and sign the CLA if this is your first contribution.

Avoid setting AuditSystemState::Starting when target list is empty.
Now checks target availability before state transition, keeping the
system in Stopped state if no enabled targets are found.

- Check targets.is_empty() before setting Starting state
- Return early with Ok(()) when no targets exist
- Maintain consistent state machine behavior
- Prevent transient "Starting" state with no actual targets

Resolves issue where audit system would incorrectly enter Starting
state even when configuration contained no enabled targets.
@github-actions
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
cargo/wildmatch 2.6.1 🟢 4.1
Details
CheckScoreReason
Code-Review⚠️ 2Found 5/21 approved changesets -- score normalized to 2
Binary-Artifacts🟢 10no binaries found in the repo
Maintained🟢 56 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 5
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Packaging⚠️ -1packaging workflow not detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Security-Policy⚠️ 0security policy file not detected
Vulnerabilities🟢 100 existing vulnerabilities detected
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0

Scanned Files

  • Cargo.lock

@houseme houseme merged commit 55e3a1f into main Nov 14, 2025
16 checks passed
@houseme houseme deleted the fix/fix-audit-1114 branch November 14, 2025 12:23
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.

1 participant