Skip to content

fix: resolve 7 bugs (4 CRITICAL, 3 MAJOR) - #2

Merged
fbailleux2 merged 1 commit into
mainfrom
fix/bug-fixes-2025-03-25
Mar 25, 2026
Merged

fbailleux2 merged 1 commit into
mainfrom
fix/bug-fixes-2025-03-25

Conversation

@fbailleux2

Copy link
Copy Markdown
Owner

Bugs fixed

CRITICAL

# File Bug Fix
1 agent/main.py Race condition on current_app — asyncio loop writes, pynput thread reads without synchronisation threading.Lock-protected _get/_set_current_app() helpers
2 aggregator/api.py Fire-and-forget create_task had no error handler — exceptions silently dropped add_done_callback logs warning if task raises
3 validator/api.py Approve endpoint only blocked re-VALIDATED; any other state (FORBIDDEN, RECOMMENDED…) could be approved Added check: only OBSERVED observations can be approved (REST + FlowFabric webhook)
4 drift_detector.py Empty traces returned drift_score=1.0 — impossible to have 100% drift with no data Return drift_score=0.0 when traces=[]; no baseline = unmeasurable

MAJOR

# File Bug Fix
5 models.py ProcessStep.related_event_types: list[str] — no validation of values Changed to list[EventType]; Pydantic v2 coerces and validates
6 capture_clipboard.py Paste payload contained from_app: None when no prior copy detected None → ""
7 flowfabric.py validated_by: None serialised into webhook payload None → ""

Tests

  • test_empty_traces updated to assert drift_score=0.0 (was testing old wrong behavior)
  • All 275 tests pass, 1 skipped

CRITICAL:
- main.py: replace bare list[str] current_app with threading.Lock-protected
  accessors to eliminate race condition between asyncio loop and pynput thread
- aggregator/api.py: add add_done_callback error handler on fire-and-forget
  observation dispatch tasks so unhandled exceptions are logged
- validator/api.py: enforce OBSERVED→VALIDATED state machine — approve endpoint
  (REST + FlowFabric webhook) now returns 409 if observation is not OBSERVED
- drift_detector.py: return drift_score=0.0 when traces list is empty;
  no observed baseline means drift cannot be measured (was incorrectly 1.0)

MAJOR:
- models.py: ProcessStep.related_event_types changed from list[str] to
  list[EventType] for compile-time type safety; Pydantic v2 coerces strings
- capture_clipboard.py: paste payload from_app now "" instead of None when
  no prior copy was detected, preventing None in serialized payloads
- flowfabric.py: validated_by defaults to "" in payload instead of None

tests: update test_empty_traces to reflect corrected zero-drift semantics
@fbailleux2
fbailleux2 merged commit cf59bfc into main Mar 25, 2026
1 check 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.

2 participants