Skip to content

Implement project stage four - #1343

Merged
amirbiron merged 21 commits into
mainfrom
cursor/implement-project-stage-four-33a3
Nov 4, 2025
Merged

Implement project stage four#1343
amirbiron merged 21 commits into
mainfrom
cursor/implement-project-stage-four-33a3

Conversation

@amirbiron

@amirbiron amirbiron commented Nov 4, 2025

Copy link
Copy Markdown
Owner

What

  • הוספתי את המודול החדש resilience.py עם ניהול Retry/Circuit Breaker ומשתני ENV ניתנים לכיוון.
  • עטפתי מחדש את http_sync.request ו-http_async.request במדיניות הרזיליינס, כולל עדכוני observability ו-emit אירועים.
  • שדרגתי אינטגרציות (Pastebin, Webhooks, GitHub monitor) ופקודות בוט לעבודה עם ה-API החדש ולתוויות מטריקות.
  • הרחבתי את metrics.py (קשור לשלב 4) עם מטריקות חדשות למדדי resiliency.
  • עדכנתי טסטים קיימים והוספתי כיסוי ל-retry/circuit (סינכרוני ואסינכרוני).

Why

שלב 4 דרש רזיליינס מלא מול שירותים חיצוניים ומטריקות שמאפשרות ניטור. הבנייה מחדש מאחדת את כל הניהול לנקודה אחת ומקטינה רעשים זמניים, לצד היכולת לזהות מוקדים בעייתיים (CB פתוח, כמות retries וכו’).

Docs

  • מומלץ להוסיף עמוד “Outbound Resilience” בתיעוד, עם פירוט ה-ENV, המטריקות החדשות והנחיות הפעלה (ראו הצעת דראפט בהערה המצורפת).

Tests

  • לא הורצו – אין pytest מותקן בסביבה (ניסיון להריץ python3 -m pytest נכשל).

Open in Cursor Open in Web


Note

Adds a resilience layer (retry + circuit breaker) to async/sync HTTP, updates integrations/bot/utils to use it with observability, introduces outbound metrics, aligns required check names (no emojis) across CI/docs, and expands tests.

  • Resilience & HTTP:
    • Add resilience.py with env‑configurable RetryPolicy/CircuitBreaker and helpers (resolve_labels, metrics hooks).
    • Overhaul http_async.py and http_sync.py with resilient request(...) (retries, backoff, circuit breaker, observability events/spans) and session instrumentation.
  • Integrations & Bot:
    • Migrate GitHub monitor, Pastebin, webhooks, bot handlers, and utils.FileUtils.download_file to http_async.request(...) with service/endpoint labels.
    • Make GitHub backoff delay env‑tunable in github_menu_handler.apply_rate_limit_delay.
  • Metrics:
    • Extend metrics.py with outbound request duration, retry counters, and circuit state/success‑rate gauges.
  • CI/CD & Templates/Docs:
    • Normalize required status contexts (remove emojis) and simplify status reporting in .github/workflows/ci.yml/deploy.yml and PR template/docs.
    • Unit test job names changed to Unit Tests (3.11/3.12); add env to minimize backoff during tests.
  • Tests:
    • Update existing tests to new async context API; add retry/circuit behavior tests for async/sync HTTP and adjust stubs to release responses.

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

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

cursor Bot commented Nov 4, 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 Nov 4, 2025

Copy link
Copy Markdown

🧯 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 Nov 4, 2025

Copy link
Copy Markdown

⏱️ Performance report

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

@amirbiron
amirbiron marked this pull request as ready for review November 4, 2025 19:47
Comment thread resilience.py Outdated
cursoragent and others added 2 commits November 4, 2025 19:51
This change defers the import of metrics functions until they are actually needed, improving startup performance and reducing optional dependencies.

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread http_async.py
Co-authored-by: amirbiron <amirbiron@gmail.com>
@github-actions

github-actions Bot commented Nov 4, 2025

Copy link
Copy Markdown

📖 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

Copy link
Copy Markdown
Owner Author

@copilot
@cursoragent

הטסט תקוע לא מתקדם,

ומצאתי:

0s
Run actions/github-script@v7
RequestError [HttpError]: Validation Failed
    at /home/runner/work/_actions/actions/github-script/v7/dist/index.js:9537:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v7/dist/index.js:36187:16), <anonymous>:5:1)
    at async main (/home/runner/work/_actions/actions/github-script/v7/dist/index.js:36285:20) {
  status: 422,
  response: {
    url: 'https://api.github.com/repos/amirbiron/CodeBot/statuses/b0723bdaec78795770acad483b5ea51310bd51a2',
    status: 422,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
      'content-length': '205',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Tue, 04 Nov 2025 20:27:22 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'github.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-accepted-github-permissions': 'statuses=write',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-api-version-selected': '2022-11-28',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': '5C00:25D557:A639C8:2D16D42:690A61AA',
      'x-ratelimit-limit': '5000',
      'x-ratelimit-remaining': '4946',
      'x-ratelimit-reset': '1762291259',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '54',
      'x-xss-protection': '0'
    },
    data: {
      message: 'Validation Failed',
      errors: "Validation failed: Context doesn't accept 4-byte Unicode",
      documentation_url: 'https://docs.github.com/rest/commits/statuses#create-a-commit-status',
      status: '422'
    }
  },
  request: {
    method: 'POST',
    url: 'https://api.github.com/repos/amirbiron/CodeBot/statuses/b0723bdaec78795770acad483b5ea51310bd51a2',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'actions/github-script octokit-core.js/5.0.1 Node.js/20.19.5 (linux; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: '{"state":"pending","context":"🧪 Unit Tests (3.11)","description":"Job queued/running","target_url":"https://github.com/amirbiron/CodeBot/actions/runs/19081098526"}',
    request: {
      agent: [Agent],
      fetch: [Function: proxyFetch],
      hook: [Function: bound bound register]
    }
  }
}
Error: Unhandled error: HttpError: Validation Failed

Copilot AI commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

@amirbiron I've opened a new pull request, #1347, to work on those changes. Once the pull request is ready, I'll request review from you.

@amirbiron

Copy link
Copy Markdown
Owner Author

@cursoragent

הטסט תקוע לא מתקדם,

ומצאתי:

0s
Run actions/github-script@v7
RequestError [HttpError]: Validation Failed
    at /home/runner/work/_actions/actions/github-script/v7/dist/index.js:9537:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v7/dist/index.js:36187:16), <anonymous>:5:1)
    at async main (/home/runner/work/_actions/actions/github-script/v7/dist/index.js:36285:20) {
  status: 422,
  response: {
    url: 'https://api.github.com/repos/amirbiron/CodeBot/statuses/b0723bdaec78795770acad483b5ea51310bd51a2',
    status: 422,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
      'content-length': '205',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Tue, 04 Nov 2025 20:27:22 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'github.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-accepted-github-permissions': 'statuses=write',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-api-version-selected': '2022-11-28',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': '5C00:25D557:A639C8:2D16D42:690A61AA',
      'x-ratelimit-limit': '5000',
      'x-ratelimit-remaining': '4946',
      'x-ratelimit-reset': '1762291259',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '54',
      'x-xss-protection': '0'
    },
    data: {
      message: 'Validation Failed',
      errors: "Validation failed: Context doesn't accept 4-byte Unicode",
      documentation_url: 'https://docs.github.com/rest/commits/statuses#create-a-commit-status',
      status: '422'
    }
  },
  request: {
    method: 'POST',
    url: 'https://api.github.com/repos/amirbiron/CodeBot/statuses/b0723bdaec78795770acad483b5ea51310bd51a2',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'actions/github-script octokit-core.js/5.0.1 Node.js/20.19.5 (linux; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: '{"state":"pending","context":"🧪 Unit Tests (3.11)","description":"Job queued/running","target_url":"https://github.com/amirbiron/CodeBot/actions/runs/19081098526"}',
    request: {
      agent: [Agent],
      fetch: [Function: proxyFetch],
      hook: [Function: bound bound register]
    }
  }
}
Error: Unhandled error: HttpError: Validation Failed

@cursor

cursor Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

נראה שזה נופל על הסטטוס־API של GitHub בגלל שהערך ב־context מכיל אימוג’י (“🧪 Unit Tests (3.11)”). ה־Statuses API לא מקבל תווים ב־4־בייט, ולכן הקריאה מחזירה 422. כדי לפתור:

  • עדכן בקובץ ה־workflow את הערכים של context (וגם description אם צריך) כך שיכילו טקסט ASCII בלבד, למשל Unit Tests (3.11) בלי האימוג’י.
  • הרץ את ה־job מחדש אחרי השינוי; ה־pending status יוגדר בלי השגיאה, והבדיקות יתקדמו כרגיל.

ברגע שה־context נקי מהאימוג’י, הסטטוסים שוב יעבדו.


Open in Cursor Open in Web

Learn more about Cursor Agents

Copilot AI and others added 7 commits November 4, 2025 22:55
…texts (#1347)

* Initial plan

* Fix: Remove emojis from GitHub status context fields

Co-authored-by: amirbiron <215461772+amirbiron@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: amirbiron <215461772+amirbiron@users.noreply.github.com>
This change removes the '🧪' emoji from CI test names in documentation and workflow files.

Co-authored-by: amirbiron <amirbiron@gmail.com>
Co-authored-by: amirbiron <amirbiron@gmail.com>
Fix formatting of push event in CI/CD workflow.
Co-authored-by: amirbiron <amirbiron@gmail.com>
Remove unused imports and dummy classes. Improve test clarity by directly testing session creation.

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

Copy link
Copy Markdown
Owner Author

@cursoragent

תקוע המון זמן ככה:


tests/test_cancel_fallbacks.py::test_reminders_cancel_fallback_returns_end PASSED [ 15%]
tests/test_cancel_fallbacks.py::test_main_upload_cancel_fallback_returns_end PASSED [ 15%]
tests/test_chatops_alerts.py::test_alerts_command_shows_recent PASSED    [ 16%]
tests/test_chatops_backoff_commands.py::test_enable_disable_backoff_admin PASSED [ 16%]
tests/test_chatops_backoff_commands.py::test_enable_backoff_non_admin_blocked PASSED [ 16%]
  • תוכל לבדוק מה הטסט הבא בתור ולהבין למה יש תקיעה?

@cursor

cursor Bot commented Nov 4, 2025

Copy link
Copy Markdown
Contributor

סקרתי את סדר הקבצים בתיקיית tests ובדקתי נקודות בקוד שעלולות לגרום להיתקעות (ריטריי/ביטולים).

  • הטסט הבא בתור: tests/test_chatops_mvp.py (ואחריו tests/test_chatops_system_and_metrics.py, ואז tests/test_chatops_triage_and_errors.py).
  • הסיבה הסבירה לתקיעה כרגע היא לא בטסטים עצמם אלא בצעד ה‑Statuses ב‑GitHub: יש נסיון להגדיר context עם אימוג׳י (כמו “🧪 Unit Tests (3.11)”) שה‑Statuses API לא מקבל, מה שגורם לשגיאת 422 ועוצר את ההתקדמות. עדכן את ה‑workflow לציין context ב‑ASCII בלבד (למשל: Unit Tests (3.11)) והרצת ה‑job תתקדם תקין.
  • אם חוששים מתקיעה בגלל ריטריי אסינכרוני שבולע ביטולים: בקוד הנוכחי ה‑CancelledError לא נבלע אלא נזרק מחדש, כך שביטול טסק יעצור מיד ולא ימשיך בריטריי.
async def _async_sleep_with_backoff(attempt: int, policy: RetryPolicy) -> None:
    delay = compute_backoff_delay(attempt, policy)
    if delay <= 0:
        return
    try:
        await asyncio.sleep(delay)
    except asyncio.CancelledError:
        raise
    except Exception:
        return
  • מומלץ: להסיר אימוג׳י מכל ה‑contexts/description בהגדרת ה‑statuses ב‑workflow ולהריץ מחדש. אם אחרי התיקון עדיין נראה תקוע סביב ה‑16%, נסה להריץ ממוקד -k chatops_mvp כדי לאשר שהקבוצה הזו רצה מהר.

Open in Cursor Open in Web

Learn more about Cursor Agents

@cursor

cursor Bot commented Nov 4, 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

cursoragent and others added 6 commits November 4, 2025 22:51
Co-authored-by: amirbiron <amirbiron@gmail.com>
Co-authored-by: amirbiron <amirbiron@gmail.com>
Co-authored-by: amirbiron <amirbiron@gmail.com>
Co-authored-by: amirbiron <amirbiron@gmail.com>
Co-authored-by: amirbiron <amirbiron@gmail.com>
@amirbiron
amirbiron merged commit 81f234a into main Nov 4, 2025
25 checks passed
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.

3 participants