Skip to content

fix(perf): evict approve-lock leak, index auth_requests, reuse shared httpx client (#660) - #752

Merged
jaylfc merged 1 commit into
devfrom
fix/audit-safe-cleanups
Jun 10, 2026
Merged

fix(perf): evict approve-lock leak, index auth_requests, reuse shared httpx client (#660)#752
jaylfc merged 1 commit into
devfrom
fix/audit-safe-cleanups

Conversation

@jaylfc

@jaylfc jaylfc commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Three audit safe-cleanups with zero runtime-behavior change:

  • Fix 1 (memory leak): Evict the per-request asyncio.Lock from _approve_locks in a try/finally block after approve_auth_request reaches a terminal decision. Without this the dict grows for the process lifetime (one entry per unique request_id ever approved).
  • Fix 2 (missing indexes): Add idx_auth_requests_status and idx_auth_requests_identity to the auth_requests SCHEMA. list_pending and count_pending_for previously did full-table scans. The IF NOT EXISTS guard means BaseStore.init() applies them idempotently on next startup with no migration step.
  • Fix 3 (connection churn): Replace five per-call async with httpx.AsyncClient(timeout=...) blocks in user_memory routes with request.app.state.http_client (the shared client already owned by the app). Timeout is forwarded on each individual .get/.post call. Affected tests updated to inject mocks via app.state.http_client = mock_client instead of patching the constructor.

[label: perf, audit]

… httpx client (#660)

- Evict per-request lock from _approve_locks after terminal decision so the dict does not grow unbounded over the process lifetime (try/finally pop in approve_auth_request handler).
- Add idx_auth_requests_status and idx_auth_requests_identity indexes to auth_requests SCHEMA so list_pending and count_pending_for queries use indexed scans.
- Replace five inline httpx.AsyncClient context managers in user_memory routes with the shared request.app.state.http_client; pass timeout per-call. Update four affected tests to inject mock via app.state.http_client instead of patching the constructor.
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jaylfc, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 2 minutes. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 49bf28f8-1089-4d14-a564-63e5dfc58c2c

📥 Commits

Reviewing files that changed from the base of the PR and between a338ee8 and 7d5353c.

📒 Files selected for processing (5)
  • tests/test_auth_requests.py
  • tests/test_user_memory.py
  • tinyagentos/auth_requests_store.py
  • tinyagentos/routes/agent_auth_requests.py
  • tinyagentos/routes/user_memory.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/audit-safe-cleanups

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jaylfc

jaylfc commented Jun 10, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@jaylfc
jaylfc merged commit 18373f8 into dev Jun 10, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in TinyAgentOS Roadmap Jun 10, 2026
@jaylfc
jaylfc deleted the fix/audit-safe-cleanups branch June 12, 2026 00:02
jaylfc added a commit that referenced this pull request Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

1 participant