5 Commits
Author SHA1 Message Date
rays 8537b1b082 refactor: remove unused frontend modules, helpers and a stray script
Remove code that nothing imports or calls:

- web/doctor_chat.js (the ChatPanel class, superseded by the chat
  island; only its import in doctor_ui.js remained), web/doctor_chat.css
  and web/doctor_telemetry.js. ComfyUI still loaded these files as
  extension scripts, but they had no module-level side effects.
- DoctorUI.triggerAIAnalysis and DoctorUI.updatePollInterval;
  DoctorAPI.getHistory, DoctorAPI.verifyApiKey and DoctorAPI.chat;
  renderContentPipeline.
- The first, shadowed PatternLoader.get_pattern_info definition (the
  later one was always the one in effect).
- verify_routes.py, which could not run under package imports and
  replaced sys.modules entries with mocks when imported.

The architecture guide lists only existing frontend modules, enforced by
a new test, and the import-scan skip lists no longer name the script.
2026-10-13 14:45:04 +08:00
rays 3c73c29d75 fix: realign diagnostics, telemetry and metadata contracts with their producers
- Privacy diagnostics: the provider name is None for unknown endpoints
  and when no base URL is set; calling .lower() on it raised and dropped
  every issue of the check, including the warning for privacy_mode=none
  with an unknown remote endpoint.
- Telemetry: the pattern allowlist built a PatternLoader without its
  required directories, so it was always empty and every pattern label
  became __unknown__. It now reads ids from the shared loader through a
  new PatternLoader.get_pattern_ids().
- Error summary: the LLM context builder read the category from a nested
  pattern_match key that the pattern stage never writes; it now reads the
  top-level category (nested key kept as a fallback).
- Sidebar: an error delivered before the sidebar panel existed (it waits
  for UI text) threw on auto-open, and so did the menu toggle. Visibility
  is now applied when the panel is created.
- OpenAPI info.version now matches the package version, and the version
  metadata test enforces it.
- A missing optional patterns/custom directory is logged at debug level
  instead of a warning; missing built-in directories still warn.
2026-10-13 14:28:45 +08:00
rookiestar28 4e3d2120bf fix: testing debt analysis and fix 2026-01-05 21:22:43 +08:00
rookiestar28 1ce8ed6130 feat(f4): add error statistics dashboard with pattern tracking, category breakdown, and resolution rate (14/18 E2E tests passing) 2026-01-04 20:24:48 +08:00
rookiestar28 12d3b8e285 feat(patterns): implement PatternLoader with JSON-based pattern management (STAGE 2)
Integrate PatternLoader into analyzer.py to enable JSON-based error pattern
management with hot-reload capability, while preserving fallback to hardcoded
patterns for reliability.

Features:
- JSON-based pattern definitions with schema validation
- Hot-reload capability without restart
- Priority-based pattern matching (higher priority checked first)
- Multi-directory support (builtin, community, custom)
- Backward compatible with fallback to hardcoded PATTERNS

Implementation:
- pattern_loader.py: Core PatternLoader class (309 lines)
  - load(): Load patterns from JSON files with schema validation
  - match(): Match error against patterns (priority-sorted)
  - reload_if_changed(): Hot-reload on file modification
  - get_stats(): Pattern statistics and categorization
- patterns/schema.json: JSON schema definition
  - Required fields: id, regex, error_key, priority, category
  - Optional fields: has_groups, tags, notes
  - Validation: unique IDs, valid priority range (0-100), valid categories
- patterns/builtin/core.json: Migrated 21 existing patterns
  - Priority distribution: 9 high (80-100), 12 medium (50-79)
  - Category distribution: 7 data_type, 3 memory, 3 workflow, 2 model_loading, etc.
- tests/test_pattern_loader.py: Comprehensive test suite (9 tests)
  - All tests passed ✅

Integration with analyzer.py:
- Updated ErrorAnalyzer.analyze():
  - Try PatternLoader first (JSON patterns)
  - Fallback to hardcoded PATTERNS on any error
  - Ensures error analysis always works
- Added ErrorAnalyzer.reload_patterns():
  - Public API for hot-reload
  - Returns True if patterns reloaded

Test Results:
✅ All 9 unit tests passed
✅ Manual integration test passed
✅ 21 patterns loaded from core.json
✅ Error detection working correctly (CUDA OOM, validation errors)
✅ Hot-reload functionality verified
✅ Zero performance regression (<1ms pattern matching)

Architecture:
- Preserves fallback mechanism (learned from STAGE 1)
- Priority-based sorting prevents false positives
- Schema validation catches errors early
- Graceful error handling (never crashes)

Next Steps:
- STAGE 3: F12 Pattern Expansion (35+ community patterns)
- After STAGE 1+2 stable for 3+ days

References:
- Planning: .planning/STAGE2_F2_INTEGRATION_PLAN.md
- Implementation Record: .planning/STAGE2_IMPLEMENTATION_RECORD.md
- Original F2 Design: .planning/FAILURE-F12_F2_T8_IMPLEMENTATION_PLAN.md
2026-01-03 04:55:18 +08:00