Spaces:
Running on Zero
Running on Zero
GitHub Actions
fix: llm.chat IndexError (lazy Ollama warm + safe _resolve_backend fallback) + chat self-send returns direct
66a1a95 | # HearthNet Quality Assurance Report | |
| **Date:** June 10, 2026 | |
| **Status:** β Quality Check Scripts Created and Executed | |
| --- | |
| ## Executive Summary | |
| Two new management scripts have been created for the HearthNet project: | |
| 1. **check_quality.py** β Automated quality checking script | |
| 2. **app_manager.bat** β Windows batch menu for app management | |
| Quality checks were executed on the codebase with the following results: | |
| --- | |
| ## Quality Check Results | |
| ### β Ruff Linter & Formatter | |
| - **Status:** 167 issues **fixed**, 92 **remaining** | |
| - **Fixed Issues:** | |
| - Unused imports removed | |
| - Import organization improved | |
| - Code simplifications applied (SIM patterns) | |
| - Trailing whitespace removed | |
| - Module-level import positioning corrected | |
| - **Remaining Issues (Manual Review Needed):** | |
| - 52 unsafe fixes available (use `--unsafe-fixes` if approved) | |
| - Code simplification suggestions (try/except patterns, nested conditionals) | |
| - Variable redefinitions in constants.py | |
| - Module shadowing (hearthnet/types.py) | |
| **Action:** Most auto-fixable issues resolved. Remaining issues require thoughtful review. | |
| --- | |
| ### π Bandit Security Check | |
| - **Status:** β **No critical or high-severity vulnerabilities** | |
| - **Findings Summary:** | |
| - **Low Severity (58 issues):** | |
| - Try/except/pass patterns (non-fatal exception handling) | |
| - Use of assert statements in code (assert shouldn't be used for runtime checks) | |
| - Some subprocess calls need explicit `check=True` parameter | |
| - **Medium Severity (11 issues):** | |
| - Binding to `0.0.0.0` (4 instances) β intentional for peer mesh | |
| - URL opening with urllib (2 instances) β used for probe/config only | |
| - Hugging Face unsafe downloads (5 instances) β requires revision pinning | |
| - Hardcoded SQL expression (1 instance) β marked with nosec, uses computed placeholders | |
| **Recommendation:** Most medium-severity findings are intentional for P2P functionality. Hugging Face downloads should use revision pinning for production. | |
| --- | |
| ### π MyPy Type Checking | |
| - **Status:** β οΈ **27 type errors found** | |
| - **Main Issues:** | |
| - Variable redefinitions in constants.py (embed/rerank) | |
| - Unused type ignore comments (8 instances) | |
| - Type incompatibilities in capability descriptors (str vs tuple[int,int]) | |
| - Assignment type mismatches (set vs list in chat service) | |
| - Missing attribute errors in transport layer | |
| **Action:** Type errors are moderate. Most can be fixed by: | |
| 1. Removing unused `type: ignore` comments | |
| 2. Fixing constant duplicates | |
| 3. Updating capability descriptor type annotations | |
| --- | |
| ## Scripts Created | |
| ### 1. `scripts/check_quality.py` | |
| **Purpose:** Run quality checks with proper error handling | |
| **Checks Executed:** | |
| - Ruff format checking | |
| - Ruff linting | |
| - Bandit security analysis | |
| - MyPy type checking | |
| **Features:** | |
| - Timeout protection (no hanging processes) | |
| - Clear pass/fail summary | |
| - Helpful tips for fixing issues | |
| - Only critical checks (avoids pip audit delays) | |
| **Usage:** | |
| ```bash | |
| python scripts/check_quality.py | |
| ``` | |
| **Time:** ~4-5 minutes for complete run | |
| --- | |
| ### 2. `scripts/app_manager.bat` | |
| **Purpose:** Windows batch menu for application management | |
| **Features:** | |
| - π Start HearthNet (CLI or Gradio UI) | |
| - π Stop running instances | |
| - π¦ Install dependencies | |
| - βοΈ Configuration management | |
| - π Quality checks integration | |
| - π§ͺ Test runner | |
| - π Documentation access | |
| **Menu Options:** | |
| ``` | |
| 1. Start HearthNet (CLI) | |
| 2. Start HearthNet (Gradio Web UI) | |
| 3. Start Multi-Node Demo | |
| 4. Stop HearthNet | |
| 5. Install Dependencies | |
| 6. Install Dev Dependencies | |
| 7. Configure Settings | |
| 8. Run Quality Checks | |
| 9. Run Tests | |
| A. Generate Screenshots | |
| B. Open Logs | |
| C. Open Documentation | |
| 0. Exit | |
| ``` | |
| **Usage:** | |
| ```batch | |
| scripts\app_manager.bat | |
| ``` | |
| --- | |
| ## Issues Found & Status | |
| ### π΄ Critical Issues: 0 | |
| ### π Medium Issues: ~15 | |
| 1. **Constant Duplicates** (constants.py) | |
| - EMBED_MAX_TEXTS, EMBED_MAX_CHARS, RERANK_MAX_DOCS redefined | |
| - **Fix:** Remove duplicate definitions | |
| 2. **HuggingFace Model Downloads** | |
| - Missing revision pinning in 5 locations | |
| - **Fix:** Add `revision` parameter to all `from_pretrained()` calls | |
| 3. **Type Mismatches** | |
| - Capability descriptor version expects tuple[int,int], gets str | |
| - **Fix:** Convert string versions to tuples | |
| ### π‘ Low Issues: ~100+ | |
| - Unused type ignore comments (can remove) | |
| - Try/except/pass patterns (intentional, documented) | |
| - Variable names (minor style issues) | |
| --- | |
| ## Next Steps - Recommended Priority | |
| ### Priority 1 (Complete before merge) | |
| - [ ] Remove duplicate constants | |
| - [ ] Fix type incompatibilities in capability descriptors | |
| - [ ] Remove unused `type: ignore` comments from mypy | |
| ### Priority 2 (Before production deployment) | |
| - [ ] Add revision pinning to all HuggingFace downloads | |
| - [ ] Review and address try/except patterns if stricter error handling needed | |
| - [ ] Update assert statements to proper runtime checks | |
| ### Priority 3 (Nice to have) | |
| - [ ] Apply unsafe ruff fixes (after review) | |
| - [ ] Simplify nested conditionals per SIM patterns | |
| - [ ] Consider linter configuration updates | |
| --- | |
| ## Quality Metrics | |
| | Metric | Value | Status | | |
| |--------|-------|--------| | |
| | Lines of Code | 15,106 | β | | |
| | Ruff Issues Fixed | 167 | β | | |
| | Ruff Issues Remaining | 92 | β οΈ | | |
| | Security Issues (High) | 0 | β | | |
| | Security Issues (Medium) | 11 | β οΈ | | |
| | Type Errors | 27 | β οΈ | | |
| | Tests Passing | TBD | π | | |
| --- | |
| ## Scripts Location | |
| ``` | |
| scripts/ | |
| βββ check_quality.py β Quality check automation | |
| βββ app_manager.bat β Windows app management menu | |
| βββ demo_two_nodes.py β Multi-node demo | |
| βββ gen_screenshots.py β UI screenshot generator | |
| ``` | |
| --- | |
| ## Usage Examples | |
| ### Quick Quality Check | |
| ```bash | |
| cd c:\Users\Chris4K\Projekte\HearthNet | |
| python scripts\check_quality.py | |
| ``` | |
| ### Run via Batch Menu | |
| ```bash | |
| scripts\app_manager.bat | |
| # Then press 8 for Quality Checks | |
| ``` | |
| ### Fix Ruff Issues | |
| ```bash | |
| ruff check hearthnet app.py --fix | |
| ruff format hearthnet app.py | |
| ``` | |
| ### Check Specific Issues | |
| ```bash | |
| bandit -r hearthnet | |
| mypy hearthnet --ignore-missing-imports | |
| ``` | |
| --- | |
| ## Configuration Notes | |
| ### Ruff Configuration | |
| - **Target:** Python 3.12 | |
| - **Line Length:** 100 | |
| - **Excluded:** .git, .venv, .pytest_cache, etc. | |
| - **Format:** Double quotes, LF line endings | |
| ### Bandit Configuration | |
| - **Excluded:** tests, .git, .venv | |
| - **Skipped:** B101 (assert_used in tests is OK) | |
| ### MyPy Configuration | |
| - **Python Version:** 3.12 | |
| - **Option:** `--ignore-missing-imports` (many optional deps) | |
| --- | |
| ## Conclusion | |
| β **Quality infrastructure is now in place** with: | |
| - Automated quality checking | |
| - User-friendly Windows batch menu | |
| - Clear issue reporting | |
| - Actionable recommendations | |
| The codebase has **no critical issues** and is ready for continued development. Priority should be given to fixing the medium-level type issues before major refactoring or feature additions. | |
| --- | |
| *Generated by HearthNet Quality Check System* | |
| *Last Run: June 10, 2026 at 20:15 UTC* | |