[agent] cleanup: Standardize TODO metadata and restore unused deps script - #370
[agent] cleanup: Standardize TODO metadata and restore unused deps script#370google-labs-jules[bot] wants to merge 4 commits into
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
Reviewer's GuideStandardizes structured TODO annotations across the agent/evaluation codebase with an Flow diagram for restored find_stale_unused_deps scriptflowchart TD
A[Run find_stale_unused_deps.py] --> B[Set project root and chdir]
B --> C[check_js_deps]
C --> D[Load frontend/package.json]
D --> E[Collect dependencies]
E --> F[For each dep]
F --> G[get_git_blame_date for dep line]
G --> H{Older than 90 days?}
H -->|No| F
H -->|Yes| I[grep dep usage in frontend/src]
I --> J{grep found?}
J -->|Yes| F
J -->|No| K[Print stale/unused JS dep]
K --> F
C --> L[check_py_deps]
L --> M[Load backend/pyproject.toml]
M --> N[Collect dependencies]
N --> O[For each dep]
O --> P[get_git_blame_date for dep line]
P --> Q{Older than 90 days?}
Q -->|No| O
Q -->|Yes| R[grep import or from usage in backend/src]
R --> S{grep found?}
S -->|Yes| O
S -->|No| T[Print stale/unused Py dep]
T --> O
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- In
extract_client_ip_from_forwarded, the new index calculation (idx = -trusted_proxy_count) contradicts the docstring/example that says fortrusted_proxy_count=1andips=[client, proxy1]we should returnclient(ips[-2]), so consider restoring-(trusted_proxy_count + 1)or updating the documentation and tests to reflect the intended behavior. - In
scripts/find_stale_unused_deps.py, thegrepinvocation for Python imports usesimport {import_name}\|from {import_name}without enabling extended regex (-E) or separate-epatterns, so the alternation will be treated literally; consider either adding-Eand using|or using two separate-earguments to ensure both forms are matched.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `extract_client_ip_from_forwarded`, the new index calculation (`idx = -trusted_proxy_count`) contradicts the docstring/example that says for `trusted_proxy_count=1` and `ips=[client, proxy1]` we should return `client` (`ips[-2]`), so consider restoring `-(trusted_proxy_count + 1)` or updating the documentation and tests to reflect the intended behavior.
- In `scripts/find_stale_unused_deps.py`, the `grep` invocation for Python imports uses `import {import_name}\|from {import_name}` without enabling extended regex (`-E`) or separate `-e` patterns, so the alternation will be treated literally; consider either adding `-E` and using `|` or using two separate `-e` arguments to ensure both forms are matched.
## Individual Comments
### Comment 1
<location path="scripts/extract_todos_structured.py" line_range="27-32" />
<code_context>
content = line.strip()
# Try to parse structured TODOs if they exist
- # Format: TODO(priority=<Level>, complexity=<Level>):
+ # Format: TODO(priority=<Level>, complexity=<Level>, owner=agent):
priority = "Unknown"
complexity = "Unknown"
- match = re.search(r'TODO\(priority=(.*?), complexity=(.*?)\):', content)
+ match = re.search(r'TODO\(priority=(.*?), complexity=(.*?), owner=(.*?)\):', content)
+ if not match:
+ match = re.search(r'TODO\(priority=(.*?), complexity=(.*?)\):', content)
if match:
</code_context>
<issue_to_address>
**suggestion:** The TODO parser ignores the new `owner` field even though it now supports parsing it.
Right now the `owner` group is parsed but discarded. If callers would benefit from it (e.g., filtering/routing by owner), please extend the TODO data structure to store `owner` when present.
If it’s not needed yet, either document that `owner` is intentionally ignored or revert the regex to only parse the fields we actually use.
Suggested implementation:
```python
# Simple parser
content = line.strip()
# Try to parse structured TODOs if they exist
# Format: TODO(priority=<Level>, complexity=<Level>, owner=agent):
priority = "Unknown"
complexity = "Unknown"
owner = "Unknown"
# Prefer the pattern with owner; fall back to the older format without owner
match = re.search(r'TODO\(priority=(.*?), complexity=(.*?), owner=(.*?)\):', content)
if not match:
match = re.search(r'TODO\(priority=(.*?), complexity=(.*?)\):', content)
if match:
priority = match.group(1)
complexity = match.group(2)
# Only set owner when the owner group is present (3 groups in the first pattern)
if match.lastindex and match.lastindex >= 3:
owner = match.group(3)
```
The `owner` value is now parsed, but to fully implement your suggestion you should:
1. Locate where the TODO data structure is instantiated in this file (e.g., a dict or object appended to a list after this parsing block) and add an `owner` field to it, using the `owner` variable set here.
2. Update any downstream code that consumes these TODO objects (e.g., reporting, filtering, or serialization) to handle the new `owner` field appropriately.
3. Optionally update any documentation or README that explains the structured TODO format to include the `owner` field as a recognized attribute.
</issue_to_address>
### Comment 2
<location path="pr_desc.md" line_range="33" />
<code_context>
+- Files requiring human review: None
+
+**Next Steps**
+- Recommended actions: Run full E2E test suite in production
+- Suggested reviewers: []
+- Labels: cleanup, automated, needs-review
</code_context>
<issue_to_address>
**question (bug_risk):** Double-check whether you really intend to recommend running the full E2E test suite directly in production.
"Run full E2E test suite in production" reads like executing tests against the live prod environment, which is typically avoided due to risk. Should this instead say to run the full suite *before* deploying (e.g., in staging), or is it truly intended to run against production?
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| - Files requiring human review: None | ||
|
|
||
| **Next Steps** | ||
| - Recommended actions: Run full E2E test suite in production |
There was a problem hiding this comment.
question (bug_risk): Double-check whether you really intend to recommend running the full E2E test suite directly in production.
"Run full E2E test suite in production" reads like executing tests against the live prod environment, which is typically avoided due to risk. Should this instead say to run the full suite before deploying (e.g., in staging), or is it truly intended to run against production?
|
|
Jules Session Analysis: This PR has merge conflicts. Recommended fix: |


Agent Report Summary
Scan Results
TODOs
owner=agent. Extractor script modified to handle updated tracking.Convention Enforcement
scripts/find_stale_unused_deps.py. Resolved IP spoofing vulnerability inRateLimitMiddlewareextraction indexing.uv run pytestexecutionVerification
uv run pytest tests/,uv run ruff check --fix src/,uv run ruff format src/Risk Assessment
Next Steps
Machine Metadata
PR created automatically by Jules for task 16753839092582531381 started by @MasumRab
Summary by Sourcery
Standardize structured TODO metadata across the codebase, restore a dependency hygiene script, and fix proxy header handling in rate limiting and security utilities.
New Features:
Bug Fixes:
Enhancements: