Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
# Jules Agent System: Nightly Audit & Ruthless Remediation

**Role:** High-Integrity Systems Auditor & First-Principles Engineer
**Frequency:** Nightly Execution (02:00 UTC)

## 1. Objective: The Audit Trace

You are tasked with a nightly deep-scan of all system logs, transaction traces, and state changes. Your goal is not just to find "failures," but to identify **divergences from first principles** (e.g., "Is this data state logically possible given the laws of the system?").

## 2. Analysis Phase: First-Principles Inquiry

For every error, bottleneck, or inconsistency discovered, you must execute a "Five Whys" interrogation:

* **Identify the Issue:** Define the exact delta between the expected state and the actual state.
* **The Origin Inquiry:** Ask exactly *how* and *why* the system architecture allowed this state to exist. Do not accept "random glitch" as an answer; find the logic gap.
* **Clean-up Motives:** Propose immediate mitigation to restore service or data integrity.

## 3. Execution Phase: Ruthless Solutions

You are authorized to take autonomous action on **all** issues found. You must bypass "band-aid" fixes in favor of **ruthless, proven solutions**:

* **Discard the Fragile:** If a component fails consistently, your suggested action should be a structural rewrite rather than a patch.
* **Atomic Remediation:** Ensure every fix is idempotent and verified against the system's core constraints.
* **No Half-Measures:** If a record is corrupt, quarantine and rebuild from the last known-good state; do not attempt to "guess" missing data.

## 4. Fortification: Preventative Measures

Every remediation must be accompanied by a hard-coded preventative measure. This includes:

* **Constraint Injection:** Adding schema-level or logic-level guards to make the error mathematically impossible to repeat.
* **Automated Regression:** Creating a new trace-point specifically for this failure mode to catch it in real-time before the next nightly audit.

## Implementation Instructions for Jules

1. **Initialize Audit Agent:** Load the trace logs for the previous 24-hour window.
2. **Filter Logic:** Flag any status code > 400 or any latency > 200ms.
3. **Action Loop:**
* **IF** issue found **THEN** execute `FirstPrinciplesAnalysis()`.
* **EXECUTE** `RuthlessCleanup()`.
* **DEPLOY** `PreventativeGuard()`.
4. **Reporting:** Summarize all "Ruthless Actions" taken and list the new constraints added to the system.

## Workflow Integration
* **GCP:** Monitor logs and service health.
* **GITHUB:** Track code changes and potential regressions.
* **SUPABASE:** Verify data integrity and execute cleanup.

To execute this audit manually or test the agent logic, run:
```bash
PYTHONPATH=src python3 scripts/nightly_audit_agent.py --dry-run
```
Comment on lines +1 to +51
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The AGENTS.md file documents a "Nightly Audit & Ruthless Remediation" workflow that does not align with EventRelay's core architecture. EventRelay's single workflow is: YouTube link → context → agents → outputs. This documentation describes a scheduled monitoring agent with no connection to YouTube video processing.

The documentation references "GCP monitoring," "GITHUB tracking," and "SUPABASE verification" as integration points, but these are not part of the YouTube video workflow. The instruction to run this "manually or test the agent logic" further confirms this is a standalone monitoring tool, not an agent dispatched from video event extraction.

Per custom coding guidelines (CodingGuidelineID: 1000000), the project explicitly prohibits alternative workflows and manual triggers that bypass the YouTube link flow. This documentation should either be removed or significantly revised to show how this monitoring capability integrates with the YouTube video processing workflow.

Copilot generated this review using guidance from repository custom instructions.
# AGENTS.md

## Mission
Expand Down
9 changes: 9 additions & 0 deletions scripts/nightly_audit_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
import argparse
import json
import logging
import os

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'os' is not used.

Copilot Autofix

AI 10 days ago

To fix an unused import, the general approach is to delete the import statement for the module that is not referenced anywhere in the file. This removes unnecessary dependencies and slightly improves readability and startup time.

In this case, the best fix is to remove the import os line from scripts/nightly_audit_agent.py. Specifically, delete line 22 (import os) while leaving all other imports intact. No additional methods, imports, or definitions are needed, since the file does not rely on os in the visible code, and we are not changing any existing functionality.

Suggested changeset 1
scripts/nightly_audit_agent.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/scripts/nightly_audit_agent.py b/scripts/nightly_audit_agent.py
--- a/scripts/nightly_audit_agent.py
+++ b/scripts/nightly_audit_agent.py
@@ -19,7 +19,6 @@
 import argparse
 import json
 import logging
-import os
 import sys
 import traceback
 from datetime import datetime, timezone, timedelta
EOF
@@ -19,7 +19,6 @@
import argparse
import json
import logging
import os
import sys
import traceback
from datetime import datetime, timezone, timedelta
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

Import of 'os' is not used.

Suggested change
import os

Copilot uses AI. Check for mistakes.
import sys
import traceback

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'traceback' is not used.

Copilot Autofix

AI 10 days ago

To fix an unused import, remove the import statement that brings the unused name into the module namespace. This reduces clutter and avoids misleading readers into thinking the module is used.

In this file, traceback is imported twice: once at line 24 and again at line 31. Since CodeQL highlights the import at line 24 and there is a grouped “Set up path to include src” section starting at line 29, the cleanest fix is to remove the earlier, top-level import traceback at line 24 and keep the second one with the other path/setup-related imports. No other code changes are required.

Concretely, in scripts/nightly_audit_agent.py, delete the import traceback line at 24, leaving the later import traceback at 31 intact so behavior remains unchanged if traceback is actually used elsewhere in the file.

Suggested changeset 1
scripts/nightly_audit_agent.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/scripts/nightly_audit_agent.py b/scripts/nightly_audit_agent.py
--- a/scripts/nightly_audit_agent.py
+++ b/scripts/nightly_audit_agent.py
@@ -21,7 +21,6 @@
 import logging
 import os
 import sys
-import traceback
 from datetime import datetime, timezone, timedelta
 from pathlib import Path
 from typing import Dict, Any, List, Optional
EOF
@@ -21,7 +21,6 @@
import logging
import os
import sys
import traceback
from datetime import datetime, timezone, timedelta
from pathlib import Path
from typing import Dict, Any, List, Optional
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

Import of 'traceback' is not used.

Copilot uses AI. Check for mistakes.
from datetime import datetime, timezone, timedelta
from pathlib import Path
from typing import Dict, Any, List, Optional

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'Optional' is not used.
Import of 'List' is not used.

Copilot Autofix

AI 10 days ago

In general, unused import issues are best fixed by either removing the unused names from the import statement or deleting the redundant import entirely if all names in it are unused or duplicated elsewhere. This keeps the module’s dependency surface minimal and improves readability without changing runtime behavior.

In this file, there are multiple imports from typing. The line at 27 imports Dict, Any, List, Optional, and then lines 32–33 import Path and Dict, Any, List, Optional again, followed by line 35 importing Dict, Any yet again. To avoid over-editing and to preserve existing functionality, the minimal fix that addresses CodeQL’s complaint is to remove the unused names (List and Optional) from the first typing import, leaving only the names that are actually needed there (and are reported as used by the rest of the code). Specifically, in scripts/nightly_audit_agent.py, update line 27 from from typing import Dict, Any, List, Optional to from typing import Dict, Any. This change eliminates the unused List and Optional from that import while keeping the rest of the file behavior unchanged. No additional methods, imports, or definitions are required.

Suggested changeset 1
scripts/nightly_audit_agent.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/scripts/nightly_audit_agent.py b/scripts/nightly_audit_agent.py
--- a/scripts/nightly_audit_agent.py
+++ b/scripts/nightly_audit_agent.py
@@ -24,7 +24,7 @@
 import traceback
 from datetime import datetime, timezone, timedelta
 from pathlib import Path
-from typing import Dict, Any, List, Optional
+from typing import Dict, Any
 
 # Set up path to include src
 import sys
EOF
@@ -24,7 +24,7 @@
import traceback
from datetime import datetime, timezone, timedelta
from pathlib import Path
from typing import Dict, Any, List, Optional
from typing import Dict, Any

# Set up path to include src
import sys
Copilot is powered by AI and may make mistakes. Always verify output.
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

Import of 'List' is not used.
Import of 'Optional' is not used.

Copilot uses AI. Check for mistakes.

# Set up path to include src
import sys
import traceback
from pathlib import Path
Expand All @@ -32,6 +40,7 @@
from youtube_extension.backend.services.metrics_service import MetricsService
from youtube_extension.backend.services.logging_service import get_logging_service
from youtube_extension.backend.services.database_cleanup_service import run_database_cleanup
except ImportError as e:
# Print warning but don't fail immediately, allows dry-run in incomplete envs
# print(f"Warning: Could not import services: {e}")
pass
Expand Down
Loading