Skip to content

feat: implement incident history queries and context assembly#7

Merged
itenev merged 2 commits into
mainfrom
feat/incident-history-queries
Jun 7, 2026
Merged

feat: implement incident history queries and context assembly#7
itenev merged 2 commits into
mainfrom
feat/incident-history-queries

Conversation

@itenev

@itenev itenev commented Jun 7, 2026

Copy link
Copy Markdown
Owner
Summary
Implements incident history queries and context assembly for Hermes prompts. This enables the agent to retrieve recent incidents, operator corrections, runbook success rates, and host metric baselines to provide data-driven, context-aware alert analysis.

Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [x] Documentation update

Pre-Review Findings and Resolutions
<!-- Hermes pre-review checklist. Fill this out before requesting human review. -->
- [x] Linting/formatting (ruff check --fix && ruff format) applied before pre-review.
- [x] Any runbook loading/YAML changes include an end-to-end test loading the physical file. (N/A for this PR)
- [x] Design contracts verified (single-writer boundary maintained in DB, no new violations introduced).
- Findings flagged by Hermes: 
  - Unused imports detected during initial file creation (typing.Optional in context.py, json and os in test_context.py).
- Resolutions applied:
  - Removed unused imports and ran ruff format . to ensure clean, compliant code before commit.

Testing
- [x] All existing tests pass (pytest -v --cov=agentic_node_ops --cov=webhook_receiver — 128 tests passed, 89% coverage)
- [x] New tests added for new functionality (6 tests in tests/test_context.py covering DB queries and context builder formatting)
- [x] Manual verification steps (if applicable): N/A (fully covered by unit tests with temporary in-memory SQLite databases)

Checklist
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation (docs/hermes-implementation-plan.md)
- [x] My changes generate no new warnings or errors

loki-hermes-agent[bot] added 2 commits June 7, 2026 13:48
- Add get_runbook_stats() and get_host_baselines() to database.py
- Create context.py with build_hermes_context() for prompt assembly
- Add 6 comprehensive tests for context builder and DB queries
- Update hermes-implementation-plan.md to mark Task 11 complete
- Improves readability for human log viewers when analysis exceeds 100 chars
@itenev
itenev merged commit c8fb2b1 into main Jun 7, 2026
2 checks passed
@itenev
itenev deleted the feat/incident-history-queries branch June 7, 2026 14:43
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.

1 participant