Skip to content

feat(cli): add --max-total-size flag to audit cleanup - #1819

Merged
SequeI merged 1 commit into
nolabs-ai:mainfrom
christine-at-datadog:add-audit-cleanup-max-total-size
Sep 9, 2026
Merged

SequeI merged 1 commit into
nolabs-ai:mainfrom
christine-at-datadog:add-audit-cleanup-max-total-size

Conversation

@christine-at-datadog

Copy link
Copy Markdown
Contributor

Closes #1818

Summary

Adds a --max-total-size <MB> flag to nono audit cleanup: sorts sessions oldest-first (the same discovery/sort path the command already uses) and removes sessions until the remaining total is under the given size, using the existing per-session disk_size already computed for each SessionInfo. Purely additive — behavior without the flag is unchanged.

Deliberately does not compose with --older-than as an AND filter in the same invocation; a caller wanting size-bounded pruning of recent-but-large sessions should pass --max-total-size alone, since combining it with --older-than would exclude the very sessions the size bound exists to catch. Noted in the flag's help text.

Files changed

  • crates/nono-cli/src/cli.rs — new max_total_size: Option<u64> field on AuditCleanupArgs, plus a unit test (test_audit_cleanup_max_total_size).
  • crates/nono-cli/src/audit_commands.rs — size-based pruning pass in cmd_cleanup, after the existing --keep filtering; respects --dry-run.

Testing

  • New unit test covers: total already under budget (no-op) and total over budget (prunes oldest until under).
  • cargo test, cargo clippy -- -D warnings -D clippy::unwrap_used, and cargo fmt --check all pass locally.

Agent Compliance Check

  • I am not prohibited from contributing under this policy
  • An issue already exists (audit cleanup: add a size-bounded pruning mode (--max-total-size) #1818)
  • I described my intent and approach in the issue discussion
  • I reviewed repository coding and security rules for the affected area
  • I provided required attribution for reused or adapted code (none reused/adapted — new logic only)
  • I did not use forbidden patterns such as unwrap/expect
  • I used NonoError where required
  • I validated and canonicalized all relevant paths
  • This PR matches the approved or disclosed issue scope

This contribution was prepared with the assistance of an AI coding agent (Claude Code), reviewed and submitted by a human maintainer of the downstream project referenced in the linked issue.

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

PR Review Summary

Size

Metric Value
Lines added +108
Lines removed -1
Total changed 109
Classification Medium (50–300 lines)

Affected crates

  • crates/nono-cli — CLI changes. Verify argument parsing, flag documentation, and UX behaviour across supported platforms.

Blast radius — Contained

This PR touches: source code


Updated automatically on each push to this PR.

@nogent-nolabs-ai nogent-nolabs-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nogent code review

1 potential bug identified.

Automated code + security review. CI already covers clippy, rustfmt, tests, cargo-audit and commit-lint.

Comment thread crates/nono-cli/src/tool-sandbox/dynamic_providers.rs Outdated
Comment thread crates/nono-cli/src/audit_commands.rs
Comment thread crates/nono-proxy/src/oauth_capture/mod.rs Outdated
@christine-at-datadog
christine-at-datadog force-pushed the add-audit-cleanup-max-total-size branch from 0a40e85 to b29d96e Compare September 8, 2026 01:21
@christine-at-datadog
christine-at-datadog force-pushed the add-audit-cleanup-max-total-size branch from b29d96e to c125507 Compare September 8, 2026 01:47
@christine-at-datadog
christine-at-datadog force-pushed the add-audit-cleanup-max-total-size branch from c125507 to df8695b Compare September 8, 2026 01:59
@SequeI

SequeI commented Sep 8, 2026

Copy link
Copy Markdown
Member

Hi!

Thanks for the PR, let's also add documentation for this new flag so users are aware of the option, and let me know if the nogent comments have been addressed. Overall looks good though, thanks!

@christine-at-datadog christine-at-datadog changed the title audit cleanup: add --max-total-size flag feat(cli): add --max-total-size flag to audit cleanup Sep 8, 2026
nono audit cleanup only bounds sessions by --keep (count) or
--older-than (age). A user with a handful of very large sessions, or a
burst of same-week sessions from an unbounded retry loop, has no way
to trim the audit tree by disk usage.

Add --max-total-size <MB>, applied the same way as --keep: walk the
already-sorted (newest-first) removable list, accumulate disk_size,
and remove everything past the point the running total exceeds the
budget. The budget accounts for sessions already excluded by --keep
or --older-than, since those stay on disk too — otherwise the actual
remaining total could exceed the configured cap.

Patch-Name: reconcile-add-audit-cleanup-max-total-size

Signed-off-by: Christine Le <christine.le@datadoghq.com>
Signed-off-by: christine.le <christine.le@datadoghq.com>
@christine-at-datadog
christine-at-datadog force-pushed the add-audit-cleanup-max-total-size branch from df8695b to 649b4fd Compare September 8, 2026 18:04

@SequeI SequeI left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, thanks Christine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

audit cleanup: add a size-bounded pruning mode (--max-total-size)

2 participants