Skip to content

[$25 BOUNTY] Add stale diagnostic cleanup dry run - #123

Open
Saiaaax wants to merge 3 commits into
jaxassistant55:mainfrom
Saiaaax:bounty68-stale-cleanup
Open

[$25 BOUNTY] Add stale diagnostic cleanup dry run#123
Saiaaax wants to merge 3 commits into
jaxassistant55:mainfrom
Saiaaax:bounty68-stale-cleanup

Conversation

@Saiaaax

@Saiaaax Saiaaax commented Jun 24, 2026

Copy link
Copy Markdown

Summary

Add a --diagnostic-cleanup flag to build.py that lists stale diagnostic artifacts (those not belonging to the current commit) without deleting them. An explicit --force-cleanup flag is required to actually perform the deletion. Current commit artifacts are always preserved.

Closes #68

Changes

  • build.py: Added --diagnostic-cleanup flag (dry-run by default) and --force-cleanup flag for actual deletion
    • New function find_stale_diagnostic_artifacts() scans the diagnostic/ directory for artifacts whose embedded commit ID differs from the current HEAD
    • New function run_diagnostic_cleanup() handles both dry-run listing and force deletion with size reporting
    • Current commit artifacts (including chunked .logd parts) are never removed
    • Updated argparse epilog with cleanup usage examples
  • tools/test_stale_cleanup.py: New test file with 10 test cases covering:
    • Current commit artifacts excluded from stale list
    • Other commit artifacts included in stale list
    • Empty and nonexistent directory handling
    • Non-matching file patterns ignored
    • Dry-run does not delete files
    • Force mode deletes stale but preserves current commit
    • Correct stale count in both modes
    • Chunked .logd parts detected as stale for old commits
    • Current commit chunked parts preserved in force mode
  • docs/OPERATIONS.md: Added "Diagnostic Artifact Cleanup" section documenting:
    • Overview of stale artifact naming conventions
    • Dry-run mode usage and safety guarantees
    • Force mode usage
    • Test running instructions
    • Example session output

Testing

# Dry-run: list stale artifacts without deleting
python3 build.py --diagnostic-cleanup

# Force: actually delete stale artifacts
python3 build.py --diagnostic-cleanup --force-cleanup

# Run the test suite
python3 tools/test_stale_cleanup.py

All 10 tests pass using temporary diagnostic directories (no real files are modified).

Diagnostic Artifacts

  • Diagnostic .logd reference: diagnostic/build-ec966bc5.logd
  • Matching metadata: diagnostic/build-ec966bc5.json

Checklist

  • Relevant modules affected by these changes build locally
  • Tests pass locally
  • Diagnostic build log is committed in this PR
  • Documentation has been updated, if applicable
  • Configuration or schema changes are documented, if applicable
  • No generated build artifacts are committed, except the required diagnostic build log
  • Changes are scoped to the PR purpose and avoid unrelated cleanup
  • Security, privacy, and error-handling implications have been considered

  • I would like to request that my diagnostic build log is removed before merging

Payout address: 0x5253757322092903C2F0a8EfEed592344216CC7E

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.

[$25 BOUNTY] [Python] Add stale diagnostic cleanup dry run

1 participant