Skip to content

feat(config): add AuditConfig and RotationConfig to Config#110

Merged
fohte merged 6 commits intofohte/audit-logfrom
fohte/impl-runok-audit-log-config
Mar 8, 2026
Merged

feat(config): add AuditConfig and RotationConfig to Config#110
fohte merged 6 commits intofohte/audit-logfrom
fohte/impl-runok-audit-log-config

Conversation

@fohte
Copy link
Copy Markdown
Owner

@fohte fohte commented Feb 26, 2026

Why

What

  • Add AuditConfig and RotationConfig to Config to support audit log settings in runok.yml
  • Support field-level override merging for the audit section across config layers

Open with Devin

Add audit log configuration structures to the runok config model.
AuditConfig holds enabled/path/rotation settings with sensible defaults
(enabled=true, path=~/.local/share/runok/, retention_days=7).

Config::merge() supports field-level override merging for audit settings
across global, project, and local override config layers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @fohte, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the application's configuration capabilities by integrating dedicated structures for audit log management. It allows users to define detailed audit settings, including enablement, log file paths, and rotation policies, directly within their runok.yml files. A key aspect of this change is the implementation of a sophisticated merging mechanism that ensures these audit settings can be layered and overridden effectively across different configuration sources, providing flexibility and control over logging behavior.

Highlights

  • New Configuration Structures: Introduced AuditConfig and RotationConfig to manage audit log settings within the application's configuration.
  • Configuration Schema Update: The runok.schema.json has been updated to include the new audit section and its related sub-configurations.
  • Field-Level Merging for Audit Settings: Implemented robust merging logic for audit configurations, allowing field-level overrides across different configuration layers (e.g., global, local, and local override files).
  • Comprehensive Testing: Added extensive unit tests to cover the default behavior, resolution logic, parsing, and various merging scenarios for the new audit and rotation configurations.
Changelog
  • schema/runok.schema.json
    • Added audit property to the root configuration schema.
    • Defined AuditConfig and RotationConfig JSON schemas with their respective properties and descriptions.
  • src/config/loader.rs
    • Added load_merges_audit_across_layers test to verify correct merging of audit configurations from multiple layers.
    • Added load_audit_absent_returns_none test to confirm audit is None when not specified in the configuration.
  • src/config/model.rs
    • Introduced AuditConfig struct with fields for enabled, path, and rotation, including Default implementation and helper methods for resolving values.
    • Added RotationConfig struct with retention_days, Default implementation, and a helper method for resolving retention days.
    • Integrated AuditConfig into the main Config struct.
    • Implemented merge_audit and merge_rotation functions within the Config struct for field-level merging of audit and rotation settings.
    • Updated existing Config tests to account for the new audit field.
    • Added new unit tests for AuditConfig and RotationConfig default values, resolution logic, parsing, and various merge scenarios.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 26, 2026

Codecov Report

❌ Patch coverage is 94.35216% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.61%. Comparing base (78ebad7) to head (88a6283).
⚠️ Report is 2 commits behind head on fohte/audit-log.

Files with missing lines Patch % Lines
src/config/model.rs 93.62% 13 Missing ⚠️
src/config/loader.rs 95.87% 4 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##           fohte/audit-log     #110      +/-   ##
===================================================
+ Coverage            89.89%   90.61%   +0.72%     
===================================================
  Files                   29       29              
  Lines                 6183     6481     +298     
===================================================
+ Hits                  5558     5873     +315     
+ Misses                 625      608      -17     
Flag Coverage Δ
Linux 90.46% <94.35%> (+0.73%) ⬆️
macOS 92.53% <94.35%> (+0.66%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

gemini-code-assist[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

fohte and others added 2 commits February 27, 2026 01:04
The default audit log path did not respect the XDG Base Directory
Specification. Check XDG_DATA_HOME before falling back to
$HOME/.local/share/runok/.

Also remove audit_config_is_enabled_defaults_to_true which was already
covered by the parameterized audit_config_is_enabled rstest.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Audit log configuration should not be overridable by project-level or
local override configs, since there is no use case for per-project
audit settings. The merge now preserves only the base (global) value
and discards any audit section from project/local layers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 6 additional findings in Devin Review.

Open in Devin Review

Comment thread src/config/model.rs Outdated
fohte and others added 2 commits March 8, 2026 13:54
Audit log configuration should not be overridable by project-level or
local override configs. Instead of restricting this at the merge level
(which would also block extends resolution from inheriting audit
settings), enforce the restriction in the loader by stripping the audit
field from project/local configs before merging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously the loader silently stripped audit settings from
project-level and local override configs. Now it emits a warning to
stderr so users know their audit config is being ignored.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Comment thread src/config/loader.rs Outdated
Previously, audit settings were stripped from project/local configs
before extends resolution. This meant a project config using `extends`
to reference a preset containing an `audit` section would still get
that audit config merged in, bypassing the global-only restriction.

Integrate `resolve_extends` into `DefaultConfigLoader::load()` so each
config layer's extends are resolved first, then audit is stripped from
the fully-resolved project/local configs. Also extract `strip_audit`
helper to deduplicate the stripping logic.
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment thread src/config/loader.rs
@fohte fohte merged commit ce05473 into fohte/audit-log Mar 8, 2026
7 checks passed
@fohte fohte deleted the fohte/impl-runok-audit-log-config branch March 8, 2026 10:47
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