Skip to content

Address review comments: fix paths, cleanup gating, align docs, add tests#18

Draft
Copilot wants to merge 4 commits intojules-audit-agent-16337681246389421261from
copilot/sub-pr-2
Draft

Address review comments: fix paths, cleanup gating, align docs, add tests#18
Copilot wants to merge 4 commits intojules-audit-agent-16337681246389421261from
copilot/sub-pr-2

Conversation

Copy link
Contributor

Copilot AI commented Jan 29, 2026

Addresses 9 review comments from PR #2 covering path handling, service instantiation, cleanup logic, documentation alignment, and test coverage.

Code Changes

Path handling - Anchored log_dir and report_dir to project root via Path(__file__).resolve().parent.parent instead of relative paths. Prevents writes to unexpected locations when run from cron or outside repo root.

Service cleanup - Removed unused MetricsService and LoggingService instantiations. These start background asyncio tasks that run unexpectedly during one-shot audit and produce noisy cancellation logs.

Database cleanup gating - Changed from unconditional cleanup on any health issue to gated execution:

# Before: runs for any health check failure
if diagnosis['issue']['type'] == 'health_check':
    results = await run_database_cleanup()

# After: only runs when DB components specifically unhealthy
if diagnosis['issue']['type'] == 'health_check':
    unhealthy_components = diagnosis['issue'].get('components', [])
    db_components = [c for c in unhealthy_components if 'database' in c.lower() or 'db' in c.lower()]
    if db_components:
        results = await run_database_cleanup()

Prevents destructive cleanup operations when external services fail.

Threshold alignment - Updated docstring and filter logic documentation from > 400 to >= 400 to match actual implementation. Changed AGENTS.md from "24-hour window" to "complete log scan" to reflect actual behavior.

Advisory labeling - Prefixed automated recommendation actions with [ADVISORY] marker to distinguish from truly automated operations like DB cleanup.

Documentation Changes

AGENTS.md clarifications:

  • Added "Internal Monitoring Tool (Not Part of Core YouTube-Link Workflow)" header to reconcile with documented product workflow
  • Rewrote "Ruthless Solutions" section to distinguish pre-approved automated actions (log analysis, report generation, safe DB cleanup) from advisory-only recommendations (structural rewrites, schema changes, record repairs)
  • Added implementation note explaining current automation scope

Test Coverage

Added 22 unit tests covering:

  • Path anchoring and absolute path validation
  • Status code filtering (>= 400 threshold, 200/400/500 cases)
  • Database cleanup gating (HTTP errors don't trigger, non-DB health issues don't trigger, DB-specific health issues do trigger)
  • Dry-run mode (verifies no mutations, [DRY RUN] markers present)
  • Advisory labeling (restart/review/optimize actions tagged [ADVISORY])

All tests passing. CodeQL clean.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link

vercel bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
event-relay-web Error Error Jan 29, 2026 5:36pm
v0-uvai Error Error Jan 29, 2026 5:36pm

…lign docs

- Remove duplicate sys.path.append, use sys.path.insert(0, ...)
- Anchor log_dir and report_dir to project root using Path(__file__).resolve()
- Update docstring to match actual status code check (>= 400)
- Remove unused service instantiations (MetricsService, LoggingService)
- Gate database cleanup on actual database component health, not all health issues
- Update AGENTS.md to clarify automated vs advisory actions
- Align AGENTS.md thresholds with implementation (>= 400, complete log scan)
- Add note that agent is internal monitoring tool, not part of core workflow

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
- Test initialization (dry-run, live mode, path anchoring)
- Test log analysis (missing file, various status codes, >= 400 threshold)
- Test database cleanup gating (only triggers for DB health issues)
- Test dry-run mode (skips remediation and fortification)
- Test report generation and saving
- Test advisory labeling for remediations
- All 22 tests passing

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
- Fixed inconsistent indentation (5 spaces instead of 4) in lines 208, 211, 234, 235
- All tests still passing

Co-authored-by: groupthinking <154503486+groupthinking@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement Nightly Audit & Ruthless Remediation Agent Address review comments: fix paths, cleanup gating, align docs, add tests Jan 29, 2026
Copilot AI requested a review from groupthinking January 29, 2026 17:41
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.

2 participants