feat: wire dispatcher to Hermes agent loop (Task 9)#3
Merged
Conversation
added 2 commits
June 7, 2026 01:11
- Create src/agentic_node_ops/database.py: SQLite WAL wrapper, sole writer, implements full schema (incidents, host_fingerprints, operator_corrections, runbook_outcomes, action_proposals) - Create src/agentic_node_ops/processor.py: reads alerts.jsonl from last_read_offset, inserts to SQLite, builds NotificationPayload, dispatches via NotificationDispatcher, updates offset atomically (tempfile + rename) - Add 12 unit tests covering database operations, offset management, payload building, and async processing loop - Update docs/hermes-implementation-plan.md to mark Task 9 complete
- Replace per-cycle asyncio.run() with single persistent event loop (_run_loop_async) to maintain httpx connection pools - Use asyncio.sleep instead of time.sleep for better cancellation handling - Remove redundant import time from run_processor_loop - Add sqlite3.IntegrityError catch to advance offset on UNIQUE constraint violations, preventing infinite retry loops - Update comment to clarify that notification dispatch failures (captured in NotificationResult) do not trigger the offset-rollback path - Add test_process_alerts_async_duplicate_incident to verify duplicate handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wires the dispatcher to the Hermes agent loop (Task 9), and addresses review feedback.
Changes
src/agentic_node_ops/database.py: SQLite WAL wrapper, sole writer, implements full schemasrc/agentic_node_ops/processor.py:alerts.jsonlfromlast_read_offset, inserts to SQLite, buildsNotificationPayload, dispatches viaNotificationDispatcher, updates offset atomicallyasyncio.run()with a single persistent event loop (_run_loop_async) to maintainhttpxconnection poolstime.sleepforasyncio.sleepfor better cancellation handlingsqlite3.IntegrityErrorcatch to advance offset on UNIQUE constraint violations, preventing infinite retry loopsNotificationResult) do not trigger the offset-rollback pathtests/test_database.py&tests/test_processor.py: 13 unit tests covering database operations, offset management, payload building, async processing loop, and duplicate incident handlingdocs/hermes-implementation-plan.md: Updated to mark Task 9 completeTesting
All 43 tests passing.
Checklist