Skip to content

Implement github issue 1014 - #1015

Merged
amirbiron merged 4 commits into
mainfrom
cursor/implement-github-issue-1014-5689
Oct 22, 2025
Merged

amirbiron merged 4 commits into
mainfrom
cursor/implement-github-issue-1014-5689

Conversation

@amirbiron

@amirbiron amirbiron commented Oct 22, 2025 •

Copy link
Copy Markdown
Owner

Docs: עדכון Connection Pooling ו-HTTP Sessions

מיישם את #1014 – יישור תיעוד ה‑ENV והקונפיגורציה לשדרוגי Pooling ולשימוש ב‑HTTP Sessions.

מה שונה

  • ENV: הוספה/הרחבה של פרמטרי Pooling/Timeouts עבור MongoDB, Redis, aiohttp ו‑requests (כולל SAFE_MODE).
  • HTTP Sync: תיעוד המודול http_sync.py ושימוש ב‑requests.Session גלובלי עם HTTPAdapter ו‑Retries.
  • .env: דוגמאות קצרות ל‑Dev/Staging/Prod, כולל הערת Docker (שימוש ב‑service names ולא ב‑localhost).
  • Performance: הנחיות כוונון (tuning) ופרק “בדיקות מהירות” לאחר שינוי ENV.

עמודים שעודכנו

  • docs/environment-variables.rst
  • docs/configuration.rst
  • docs/performance-scaling.rst

דוגמת .env (תמציתי)

# Redis
CACHE_ENABLED=true
REDIS_URL=redis://redis:6379/0
REDIS_MAX_CONNECTIONS=100
REDIS_CONNECT_TIMEOUT=2.0
REDIS_SOCKET_TIMEOUT=3.0
SAFE_MODE=false

MongoDB

MONGODB_URL=mongodb://mongo:27017
DATABASE_NAME=code_keeper_bot
MONGODB_MAX_POOL_SIZE=100
MONGODB_MIN_POOL_SIZE=5
MONGODB_MAX_IDLE_TIME_MS=30000
MONGODB_WAIT_QUEUE_TIMEOUT_MS=5000
MONGODB_SERVER_SELECTION_TIMEOUT_MS=5000
MONGODB_SOCKET_TIMEOUT_MS=30000
MONGODB_CONNECT_TIMEOUT_MS=10000
MONGODB_RETRY_WRITES=true
MONGODB_RETRY_READS=true
MONGODB_APPNAME=CodeBot

aiohttp

AIOHTTP_POOL_LIMIT=100
AIOHTTP_LIMIT_PER_HOST=25
AIOHTTP_TIMEOUT_TOTAL=15

requests (http_sync)

REQUESTS_POOL_CONNECTIONS=20
REQUESTS_POOL_MAXSIZE=100
REQUESTS_TIMEOUT=8
REQUESTS_RETRIES=2
REQUESTS_RETRY_BACKOFF=0.2

מדוע

לספק תיעוד מעודכן, ברור ואחיד לשדרוגי Pooling/Timeouts ולשימוש ב‑Sessions (async/sync), כדי לשפר יציבות וביצועים ולהקל על כוונון לפי סביבה.

תוכנית בדיקות

  1. התקנת תלויות דוקס:
    pip install -r docs/requirements.txt
  2. בנייה מקומית עם אזהרות כשגיאות:
    sphinx-build -b html docs docs/_build/html -W --keep-going
  3. מעבר ידני על העמודים המעודכנים לאימות קישורים, טבלאות וקטעי .env.

קריטריוני מעבר

  • בנייה עוברת ללא אזהרות.
  • עמודי התיעוד נטענים תקין והקישורים פנימיים עובדים.

סיכונים ו-Rollback

  • סיכון נמוך (שינויי תיעוד בלבד). Rollback: החזרת קבצי RST לקודמתם.

קישורים

Open in Cursor Open in Web


Note

Expands docs to cover MongoDB/Redis pooling and timeouts, HTTP client configuration (async/sync), new env vars, and performance-scaling guidance.

  • Docs:
    • docs/configuration.rst:
      • Add sections for databases/cache pooling and timeouts (MONGODB_*, REDIS_*, SAFE_MODE).
      • Document HTTP clients: aiohttp (AIOHTTP_*) and sync http_sync with example and env-based pooling/retries.
      • Clarify Redis TLS note and Docker/Compose service hostnames.
    • docs/environment-variables.rst:
      • Expand reference table with MongoDB pooling/timeouts (MONGODB_MAX_POOL_SIZE, ..., MONGODB_APPNAME).
      • Add Redis and HTTP client knobs: REDIS_MAX_CONNECTIONS, REDIS_CONNECT_TIMEOUT, REDIS_SOCKET_TIMEOUT, SAFE_MODE, AIOHTTP_LIMIT_PER_HOST, REQUESTS_POOL_*, REQUESTS_TIMEOUT, REQUESTS_RETRIES, REQUESTS_RETRY_BACKOFF.
    • docs/performance-scaling.rst:
      • Add tuning guidance for MongoDB/Redis/aiohttp/requests pooling and timeouts.
      • Include post-change benchmarking/metrics checklist and environment-specific recommendations.

Written by Cursor Bugbot for commit bfac883. This will update automatically on new commits. Configure here.

Co-authored-by: amirbiron <amirbiron@gmail.com>
@cursor

cursor Bot commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@github-actions

github-actions Bot commented Oct 22, 2025 •

Copy link
Copy Markdown
Contributor

🧯 Dangerous deletes guard report

Policy: see .cursorrules — dangerous deletions are blocked unless wrapped safely.

Summary:

  • Flagged findings (blocking): 0
    0
  • Excluded matches (not blocking): 15
  • Total matches (all files): 125

Flagged findings (file:line:snippet):
(none)

Excluded matches (by path pattern)
./Dockerfile:34:    rm -rf /var/lib/apt/lists/*
./Dockerfile:76:    rm -rf /var/lib/apt/lists/*
./webapp/static/js/md_preview.bundle.js.map:4:  "sourcesContent": ["// Markdown-it plugin to render GitHub-style task lists; see\n//\n// https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments\n// https://github.com/blog/1825-t … [truncated]
./README.md:778:find . -name "__pycache__" -exec rm -rf {} +
./docs/DOCUMENTATION_GUIDE.md:453:rm -rf _build
./docs/Makefile:24:	rm -rf $(BUILDDIR)
./node_modules/mermaid/dist/chunks/mermaid.core/chunk-KS23V3DP.mjs.map:4:  "sourcesContent": ["{\n  \"name\": \"mermaid\",\n  \"version\": \"11.12.0\",\n  \"description\": \"Markdown-ish syntax for generating flowcharts, mindmaps, sequence  … [truncated]
./node_modules/mermaid/dist/chunks/mermaid.esm.min/chunk-4HFYJGYH.mjs.map:4:  "sourcesContent": ["{\n  \"name\": \"mermaid\",\n  \"version\": \"11.12.0\",\n  \"description\": \"Markdown-ish syntax for generating flowcharts, mindmaps, sequen … [truncated]
./node_modules/mermaid/dist/chunks/mermaid.esm.min/chunk-4HFYJGYH.mjs:1:var r={name:"mermaid",version:"11.12.0",description:"Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graph … [truncated]
./node_modules/mermaid/dist/chunks/mermaid.esm/chunk-2M32CCKP.mjs.map:4:  "sourcesContent": ["{\n  \"name\": \"mermaid\",\n  \"version\": \"11.12.0\",\n  \"description\": \"Markdown-ish syntax for generating flowcharts, mindmaps, sequence d … [truncated]
./node_modules/mermaid/dist/mermaid.min.js:1524:`,"getStyles"),c1e=RQe});var h1e={};dr(h1e,{diagram:()=>NQe});var NQe,f1e=N(()=>{"use strict";$ge();a1e();l1e();u1e();NQe={parser:Fge,db:n1e,renderer:o1e,styles:c1e}});var m1e,g1e=N(()=>{"use  … [truncated]
./node_modules/mermaid/dist/mermaid.js.map:4:  "sourcesContent": ["/**\n* Default values for dimensions\n*/\nconst defaultIconDimensions = Object.freeze({\n\tleft: 0,\n\ttop: 0,\n\twidth: 16,\n\theight: 16\n});\n/**\n* Default values for tr … [truncated]
./node_modules/mermaid/dist/mermaid.min.js.map:4:  "sourcesContent": ["/**\n* Default values for dimensions\n*/\nconst defaultIconDimensions = Object.freeze({\n\tleft: 0,\n\ttop: 0,\n\twidth: 16,\n\theight: 16\n});\n/**\n* Default values fo … [truncated]
./node_modules/katex/package.json:153:    "build": "rimraf dist/ && mkdirp dist && cp README.md dist && rollup -c --failAfterWarnings && webpack && node update-sri.js package dist/README.md",
./node_modules/katex/src/fonts/Makefile:139:	rm -rf pfa ff otf ttf woff woff2

@github-actions

github-actions Bot commented Oct 22, 2025 •

Copy link
Copy Markdown
Contributor

⏱️ Performance report

(No performance test durations collected. Mark tests with @pytest.mark.performance.)

@codecov

codecov Bot commented Oct 22, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

cursoragent and others added 2 commits October 22, 2025 22:10
מעדכן:
- environment-variables.rst: מוסיף משתני ENV ל-Redis/MongoDB/aiohttp/requests ו-SAFE_MODE
- configuration.rst: מקטעי Pooling/HTTP, שימוש ב-http_sync, ודוגמאות .env לפי סביבה
- performance-scaling.rst: הנחיות tuning ו"בדיקות מהירות" לאחר שינוי ENV

מטרת השינוי: ליישר קו עם השדרוגים האחרונים בניהול חיבורים ו-HTTP Sessions ולספק למפתחים הנחיות ברורות לכוונון וניטור.
@amirbiron
amirbiron marked this pull request as ready for review October 22, 2025 22:14
@github-actions

Copy link
Copy Markdown
Contributor

📖 Documentation Preview

The documentation has been built successfully!

To view locally:

  1. Download the artifacts
  2. Extract the zip file
  3. Open index.html in your browser

@amirbiron
amirbiron merged commit 171d8f6 into main Oct 22, 2025
24 checks passed
amirbiron added a commit that referenced this pull request Sep 16, 2026
…figuration, מספר תלוי-סביבה, ו-.pyc בגיט (#3395)

* chore(git): קובצי .pyc יוצאים מניהול גיט

אחד-עשר קבצי ``__pycache__/*.cpython-313.pyc`` נכנסו לגיט ב-8098b67e
(#3239) למרות ש-``.gitignore`` שורה 2 חוסם את התיקייה. ``git rm --cached``
מוציא אותם מהאינדקס ומשאיר אותם על הדיסק, וה-``.gitignore`` הקיים דואג
שהם לא יחזרו כ-untracked.

נבדק שאין תלות: כל עשרת האזכורים של ``__pycache__`` בריפו הם החרגות בלבד
— ``.ruff.toml``, ``bandit.yaml``, ``.yamllint.yaml``,
``services/code_indexer.py``, ``scripts/audit_config_definitions.py``,
``scripts/find_duplicates.py``, ``github_menu_handler.py``,
``repo_analyzer.py`` ושני טסטים. אף אחד מהם אינו קורא מהתיקייה.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1AYmWhLGtpsr7sSdRZVD3

* test(doc_sections): התת-תהליך רץ עם -B ומחוץ לעץ המקור

``test_doc_sections_pulls_no_heavy_modules`` הריץ
``subprocess.run([sys.executable, "-c", code], cwd=_ROOT)`` — כלומר
תת-תהליך שכותב ``__pycache__`` לתוך ``services/``, וזה טסט שכותב לעץ
המקור. התקדים הנכון כבר קיים בריפו, ב-``tests/test_rst_parser.py``, ושם
ההערה מנמקת את שני הדגלים במפורש.

השורש היה שהייבוא נשען על ה-``cwd``: הוא עבד רק מפני שהתהליך רץ בשורש
הריפו. לכן ``-B`` לבדו לא הספיק — ``sys.path.insert`` עם נתיב מוחלט
מנתק את המדידה מעץ העבודה, ורק אז ``cwd=tmp_path`` אפשרי.

נמדד, ולא הונח. בקרה מבודדת בלי pytest, על ``services/__pycache__`` ריק:
הצורה הישנה כותבת שלושה קבצים (``__init__``, ``backoff_state``,
``doc_sections``), הצורה החדשה כותבת אפס, ותיקיית ה-tmp נשארת ריקה גם היא.

ומה שלא השתנה, כדי שלא ייקרא אחרת: בריצת pytest רגילה הדלתא הייתה אפס
גם קודם, כי האיסוף עצמו מייבא את אותם מודולים וכותב את אותם קבצים.
כלומר זו הפרה של מוסכמה ולא באג נצפה, והערך שלה הוא ביום שבו עץ המקור
יהיה לקריאה בלבד — כלל 8 ב-CLAUDE.md.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1AYmWhLGtpsr7sSdRZVD3

* docs(configuration): הסרת הבלוק הכפול של Pooling ו-HTTP Clients

שלושת הסעיפים "Databases and Cache (Pooling/Timeouts)", "HTTP Clients"
ו-"שימוש ב-http_sync" הופיעו פעמיים בקובץ. שניהם נכנסו ב**קומיט אחד**,
171d8f6 (#1015, 23.10.2025), שהכניס את אותו בלוק פעם אחרי "Environment
variables" ופעם אחרי "Security" — לפניו הכותרות לא היו בקובץ כלל.

המחיר נמדד: מתוך 45 תשובות ``ambiguous_section`` שהכלי ``docs_get_section``
מחזיר על כל 208 קובצי ה-RST, 25 הגיעו מהקובץ הזה לבדו. הכפילות גם חצתה את
נרמול הכותרות — ``normalize_title`` מאחד מקפים, ולכן ``שימוש ב‑http_sync``
עם U+2011 ו-``שימוש ב-http_sync`` עם מקף ASCII התנגשו זה בזה.

**שני העותקים הושוו שורה-שורה לפני המחיקה, והם אינם זהים** — אבל אף
הבדל אינו הבדל בתוכן: פיסוק ב-``REDIS_URL``, ניסוח ב-``.. note::``
("לא להשתמש" מול "אל תשתמשו", גרשיים עבריים מול מרכאה), והמקף בכותרת.
נשאר העותק הראשון **מילה במילה**, כי הוא במקום הנכון מבנית — עם שאר
סעיפי הקונפיגורציה, והוא היחיד שמלווה ב-"שימוש ב-http_async" שאין לו
כפילות. שבע-עשרה מתוך תשע-עשרה השורות שנמחקו קיימות בו כלשונן, והשתיים
הנותרות הן שתי וריאציות הניסוח.

עוגנים — נבדק ולא הונח: ``autosectionlabel`` אינו מופעל ב-``conf.py``,
ולכן לכותרות אין לייבלים אוטומטיים. העוגן המפורש היחיד בקובץ הוא
``.. _config-error-signatures:``, שיושב הרבה מתחת לבלוק שנמחק, ואליו
מפנה ``docs/observability/log-aggregator.rst``. שאר ההפניות הנכנסות הן
``:doc:`` לעמוד כולו.

אימות: הספירה הורצה מחדש על כל 208 הקבצים — הקובץ הזה ירד מ-25 ל-**0**,
והסך הכול מ-45 ל-20 (הנותרים הם ``development/tools.rst`` ו-
``observability/query-performance-profiler.rst``, שלא נגענו בהם). ובנייה
מלאה של Sphinx עם ``-W --keep-going`` עברה באפס אזהרות.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1AYmWhLGtpsr7sSdRZVD3

* docs(mcp): משקל הייבוא של הסורק מתואר, ולא נספר

ה-docstring של ``outline_scanners/__init__.py`` קבע ש-``from services
import rst_parser`` מושך "**ארבעה** מודולים מהריפו", ומנה אותם בשמם —
וסגר ב"מהריפו רק מודולים שרשומים כאן בשמם". שתי הטענות אינן נכונות
בסביבה שבה ``structlog`` מותקן.

נמדד בשתי סביבות באותו עץ:

- **בלי** ``structlog``: 73 מודולים, ומהריפו ארבעה — שרשרת ה-``services``.
- **עם** ``structlog``: 330 מודולים, ומהריפו שבעה — אותם ארבעה ועוד
  ``observability``, ``monitoring`` ו-``monitoring.error_signatures``.

השרשרת: ``services/__init__.py`` מייבא ``state`` מ-``backoff_state``,
ששורה 16 בו **מנסה** לייבא ``observability``; ו-``observability.py``
מייבא ``structlog`` בקשיחות בשורה 22 ומנסה ``monitoring.error_signatures``
בשורה 28. כלומר הזנב הזה תלוי במה שמותקן בסביבה, לא בשורת קוד — וזה
בדיוק המבחן שב-``docs/doc-authoring.rst``: מספר שיכול להשתנות בלי שאף
שורת קוד תשתנה אינו ערך שנאכף.

הניסוח החדש מתאר מה נטען ולמה — חלק קבוע וזנב מותנה — ואינו קובע מספר
ואינו סוגר רשימה. האינווריאנט הנושא נשאר, והוא זה שנמדד בשתי הסביבות:
**אפס מודולים כבדים**. ותוקן גם דיוק שני: הטסט שאוכף את האינווריאנט
מודד את ``services.doc_sections``, לא את ``rst_parser``, וזה נכתב עכשיו
כפער מוצהר במקום להשתמע ככיסוי.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P1AYmWhLGtpsr7sSdRZVD3

---------

Co-authored-by: Claude <noreply@anthropic.com>
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