From 72986f7a2b13f7cb0823cd514b395e9950b9228e Mon Sep 17 00:00:00 2001 From: Corey Leath Date: Fri, 13 Nov 2026 17:07:07 -0500 Subject: [PATCH 01/12] feat: add versioned runbook incident investigator --- logsight/investigator.py | 180 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 logsight/investigator.py diff --git a/logsight/investigator.py b/logsight/investigator.py new file mode 100644 index 0000000..050ff6b --- /dev/null +++ b/logsight/investigator.py @@ -0,0 +1,180 @@ +"""Version-pinned, retrieval-grounded incident investigation helpers.""" + +from __future__ import annotations + +import hashlib +import re +from collections.abc import Sequence +from dataclasses import dataclass +from pathlib import Path + +_MAX_RUNBOOKS = 100 +_MAX_RUNBOOK_CHARS = 64_000 +_MAX_QUERY_CHARS = 2_000 +_TOKEN = re.compile(r"[a-z0-9][a-z0-9_-]{1,}") +_REVISION = re.compile(r"[A-Za-z0-9._-]{7,64}") + + +@dataclass(frozen=True, slots=True) +class Runbook: + """An approved runbook with explicit version and repository provenance.""" + + identifier: str + title: str + version: str + revision: str + path: str + content: str + digest: str + + +@dataclass(frozen=True, slots=True) +class RunbookCitation: + """A ranked, bounded excerpt suitable for a human incident review.""" + + identifier: str + title: str + version: str + revision: str + path: str + digest: str + score: float + excerpt: str + + +@dataclass(frozen=True, slots=True) +class Investigation: + """Evidence-first investigation outcome with immutable source provenance.""" + + query: str + revision: str + citations: tuple[RunbookCitation, ...] + guidance: str + + +class RunbookRepository: + """Load bounded Markdown runbooks with versioned front matter.""" + + def __init__(self, root: str | Path, *, revision: str) -> None: + self.root = Path(root).resolve() + if not _REVISION.fullmatch(revision): + raise ValueError("runbook revision must be a 7-64 character identifier") + self.revision = revision + + def load(self) -> list[Runbook]: + """Load approved runbooks under the configured root in stable path order.""" + + if not self.root.is_dir(): + raise FileNotFoundError(f"runbook directory was not found: {self.root}") + paths = sorted(self.root.rglob("*.md")) + if len(paths) > _MAX_RUNBOOKS: + raise ValueError(f"runbook directory exceeds {_MAX_RUNBOOKS} documents") + return [self._load_path(path) for path in paths] + + def _load_path(self, path: Path) -> Runbook: + resolved = path.resolve() + try: + relative_path = resolved.relative_to(self.root) + except ValueError as exc: + raise ValueError("runbook path must stay within the configured directory") from exc + content = resolved.read_text(encoding="utf-8") + if len(content) > _MAX_RUNBOOK_CHARS: + raise ValueError(f"runbook exceeds {_MAX_RUNBOOK_CHARS} characters: {relative_path}") + metadata, body = _split_front_matter(content) + identifier = _required_metadata(metadata, "id") + title = _required_metadata(metadata, "title") + version = _required_metadata(metadata, "version") + if not body.strip(): + raise ValueError(f"runbook has no body: {relative_path}") + return Runbook( + identifier=identifier, + title=title, + version=version, + revision=self.revision, + path=relative_path.as_posix(), + content=body.strip(), + digest=hashlib.sha256(content.encode("utf-8")).hexdigest(), + ) + + +class IncidentInvestigator: + """Retrieve approved runbook excerpts without inventing operational actions.""" + + def __init__(self, runbooks: Sequence[Runbook]) -> None: + self.runbooks = tuple(runbooks) + + def investigate( + self, query: str, *, evidence: Sequence[str] = (), limit: int = 3 + ) -> Investigation: + """Rank version-pinned runbooks against an incident query and evidence.""" + + if not query.strip() or len(query) > _MAX_QUERY_CHARS: + raise ValueError("query must be non-empty and within the configured limit") + if not 1 <= limit <= 10: + raise ValueError("limit must be between 1 and 10") + query_tokens = _tokens(" ".join([query, *evidence])) + if not query_tokens: + raise ValueError("query must contain searchable terms") + + ranked: list[tuple[float, Runbook]] = [] + for runbook in self.runbooks: + document_tokens = _tokens(f"{runbook.title} {runbook.content}") + overlap = len(query_tokens & document_tokens) + if overlap: + score = overlap / len(query_tokens) + ranked.append((score, runbook)) + ranked.sort(key=lambda item: (-item[0], item[1].identifier, item[1].path)) + citations = tuple( + _citation(runbook, score, query_tokens) for score, runbook in ranked[:limit] + ) + revision = self.runbooks[0].revision if self.runbooks else "none" + guidance = ( + "Review the cited approved runbook excerpts before acting." + if citations + else "No approved runbook matched the supplied incident evidence." + ) + return Investigation(query=query, revision=revision, citations=citations, guidance=guidance) + + +def _split_front_matter(content: str) -> tuple[dict[str, str], str]: + if not content.startswith("---\n"): + raise ValueError("runbook must begin with YAML-style front matter") + closing = content.find("\n---\n", 4) + if closing < 0: + raise ValueError("runbook front matter is not terminated") + metadata: dict[str, str] = {} + for line in content[4:closing].splitlines(): + key, separator, value = line.partition(":") + if not separator or not key or not value.strip(): + raise ValueError("runbook front matter must contain key: value entries") + metadata[key.strip()] = value.strip() + return metadata, content[closing + 5 :] + + +def _required_metadata(metadata: dict[str, str], key: str) -> str: + value = metadata.get(key, "") + if not value or len(value) > 128: + raise ValueError(f"runbook metadata requires a bounded {key}") + return value + + +def _tokens(value: str) -> set[str]: + return set(_TOKEN.findall(value.lower())) + + +def _citation(runbook: Runbook, score: float, query_tokens: set[str]) -> RunbookCitation: + lines = runbook.content.splitlines() + matching = next( + (line.strip() for line in lines if query_tokens & _tokens(line)), + lines[0].strip(), + ) + return RunbookCitation( + identifier=runbook.identifier, + title=runbook.title, + version=runbook.version, + revision=runbook.revision, + path=runbook.path, + digest=runbook.digest, + score=round(score, 4), + excerpt=matching[:500], + ) From c048a7fc9a65681ff56e29bcf7d3096e81522da9 Mon Sep 17 00:00:00 2001 From: Corey Leath Date: Fri, 13 Nov 2026 17:08:32 -0500 Subject: [PATCH 02/12] feat: add grounded incident investigation CLI --- logsight/cli.py | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/logsight/cli.py b/logsight/cli.py index 3db38c8..a51144d 100644 --- a/logsight/cli.py +++ b/logsight/cli.py @@ -3,6 +3,7 @@ from __future__ import annotations import sys +from pathlib import Path import click from rich.console import Console @@ -10,6 +11,7 @@ from rich.table import Table from logsight.analyzer import AnomalyReport, detect_anomalies, error_rate_spike_details +from logsight.investigator import IncidentInvestigator, RunbookRepository from logsight.parser import parse_file, parse_lines from logsight.reasoning import EvidenceExplanation, explain_report @@ -169,6 +171,67 @@ def stdin_cmd(threshold: float, explain: bool) -> None: _print_explanations(explain_report(report)) +@main.command("investigate") +@click.argument("query") +@click.option( + "--runbooks", + type=click.Path(exists=True, file_okay=False, readable=True, path_type=Path), + default=Path("runbooks"), + show_default=True, + help="Directory containing approved, versioned Markdown runbooks.", +) +@click.option( + "--revision", + envvar="LOGSIGHT_RUNBOOK_REVISION", + required=True, + help="Immutable commit revision for the runbook set.", +) +@click.option( + "--evidence", + multiple=True, + help="Additional incident evidence; repeat this option for each item.", +) +@click.option( + "--limit", + default=3, + type=click.IntRange(1, 10), + show_default=True, + help="Maximum number of grounded runbook citations to return.", +) +def investigate_cmd( + query: str, + runbooks: Path, + revision: str, + evidence: tuple[str, ...], + limit: int, +) -> None: + """Retrieve approved runbook evidence for an incident QUERY.""" + + try: + repository = RunbookRepository(runbooks, revision=revision) + investigation = IncidentInvestigator(repository.load()).investigate( + query, evidence=evidence, limit=limit + ) + except (OSError, ValueError) as exc: + raise click.ClickException(str(exc)) from exc + + console.print("[bold]Investigation provenance[/bold]") + console.print(f" revision : [cyan]{investigation.revision}[/cyan]") + console.print(f" guidance : {investigation.guidance}") + for citation in investigation.citations: + console.print( + f"\n[bold]{escape(citation.title)}[/bold] " + f"({escape(citation.identifier)} v{escape(citation.version)})" + ) + console.print( + f" source : {escape(citation.path)} @ " + f"{escape(citation.revision)}" + ) + console.print(f" digest : {citation.digest}") + console.print(f" score : {citation.score:.4f}") + console.print(f" excerpt : {escape(citation.excerpt)}") + + @main.command("health") def health_cmd() -> None: """Verify that LogSight-AI is installed and operational.""" From b680754a457595e5095f205b23e152bce6912bb2 Mon Sep 17 00:00:00 2001 From: Corey Leath Date: Fri, 13 Nov 2026 17:08:56 -0500 Subject: [PATCH 03/12] test: cover grounded incident investigation --- tests/test_investigator.py | 152 +++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 tests/test_investigator.py diff --git a/tests/test_investigator.py b/tests/test_investigator.py new file mode 100644 index 0000000..02130c4 --- /dev/null +++ b/tests/test_investigator.py @@ -0,0 +1,152 @@ +"""Tests for the version-pinned incident investigator.""" + +from __future__ import annotations + +import pytest + +from logsight.investigator import IncidentInvestigator, RunbookRepository + + +def _write_runbook( + root, + name: str, + *, + identifier: str = "database-timeout", + title: str = "Database timeout response", + version: str = "1.2.0", + body: str = "Confirm database connection saturation before escalating.", +) -> None: + (root / name).write_text( + "\n".join( + [ + "---", + f"id: {identifier}", + f"title: {title}", + f"version: {version}", + "---", + body, + "", + ] + ), + encoding="utf-8", + ) + + +def test_loads_versioned_runbook_with_digest_and_relative_path(tmp_path) -> None: + _write_runbook(tmp_path, "database.md") + + runbook = RunbookRepository(tmp_path, revision="abcdef1").load()[0] + + assert runbook.identifier == "database-timeout" + assert runbook.version == "1.2.0" + assert runbook.revision == "abcdef1" + assert runbook.path == "database.md" + assert len(runbook.digest) == 64 + + +def test_investigation_ranks_grounded_citations_deterministically(tmp_path) -> None: + _write_runbook( + tmp_path, + "queue.md", + identifier="queue-backlog", + title="Queue backlog response", + version="2.0.0", + body="Inspect consumer lag and retain the evidence in the incident timeline.", + ) + _write_runbook(tmp_path, "database.md") + + investigation = IncidentInvestigator( + RunbookRepository(tmp_path, revision="0123456789abcdef").load() + ).investigate( + "database timeout", + evidence=("connection saturation observed",), + limit=2, + ) + + assert investigation.revision == "0123456789abcdef" + assert [citation.identifier for citation in investigation.citations] == [ + "database-timeout" + ] + citation = investigation.citations[0] + assert citation.version == "1.2.0" + assert citation.digest + assert "database connection saturation" in citation.excerpt.lower() + assert investigation.guidance.startswith("Review the cited") + + +def test_investigation_returns_no_ungrounded_guidance_for_no_match(tmp_path) -> None: + _write_runbook(tmp_path, "database.md") + + investigation = IncidentInvestigator( + RunbookRepository(tmp_path, revision="abcdef1").load() + ).investigate("kubernetes deployment") + + assert investigation.citations == () + assert investigation.guidance == "No approved runbook matched the supplied incident evidence." + + +def test_investigation_with_no_runbooks_records_no_revision() -> None: + investigation = IncidentInvestigator(()).investigate("database timeout") + + assert investigation.revision == "none" + assert investigation.citations == () + + +@pytest.mark.parametrize( + ("revision", "message"), + [ + ("short", "7-64"), + ("not allowed!", "7-64"), + ], +) +def test_rejects_invalid_repository_revision(tmp_path, revision: str, message: str) -> None: + with pytest.raises(ValueError, match=message): + RunbookRepository(tmp_path, revision=revision) + + +def test_rejects_missing_runbook_directory(tmp_path) -> None: + with pytest.raises(FileNotFoundError, match="not found"): + RunbookRepository(tmp_path / "missing", revision="abcdef1").load() + + +@pytest.mark.parametrize( + "content", + [ + "not front matter", + "---\nid: database\ntitle: Database\nversion: 1", + "---\nid:\ntitle: Database\nversion: 1\n---\nbody", + "---\nid: database\ntitle: Database\n---\nbody", + "---\nid: database\ntitle: Database\nversion: 1\n---\n", + ], +) +def test_rejects_invalid_or_incomplete_runbooks(tmp_path, content: str) -> None: + (tmp_path / "invalid.md").write_text(content, encoding="utf-8") + + with pytest.raises(ValueError): + RunbookRepository(tmp_path, revision="abcdef1").load() + + +def test_rejects_oversized_runbook(tmp_path) -> None: + _write_runbook(tmp_path, "large.md", body="x" * 64_001) + + with pytest.raises(ValueError, match="exceeds"): + RunbookRepository(tmp_path, revision="abcdef1").load() + + +@pytest.mark.parametrize( + ("query", "limit", "message"), + [ + ("", 1, "non-empty"), + ("x", 1, "searchable"), + ("database", 0, "between"), + ("database", 11, "between"), + ], +) +def test_rejects_invalid_queries_and_limits(tmp_path, query: str, limit: int, message: str) -> None: + _write_runbook(tmp_path, "database.md") + investigator = IncidentInvestigator( + RunbookRepository(tmp_path, revision="abcdef1").load() + ) + + with pytest.raises(ValueError, match=message): + investigator.investigate(query, limit=limit) From 7409b33532cdf6a5b5c1c497c331021645b856e5 Mon Sep 17 00:00:00 2001 From: Corey Leath Date: Fri, 13 Nov 2026 17:09:05 -0500 Subject: [PATCH 04/12] test: exercise investigation command --- tests/test_cli.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/test_cli.py b/tests/test_cli.py index 16c742b..94658c4 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -70,3 +70,57 @@ def test_explain_uses_detector_evidence(self, tmp_path): assert "level=ERROR" in result.output assert "single-signal" in result.output assert "no root cause is inferred" in " ".join(result.output.split()) + + + +class TestInvestigateCommand: + def test_returns_versioned_grounded_citation(self, tmp_path): + runbook = tmp_path / "database.md" + runbook.write_text( + "\\n".join( + [ + "---", + "id: database-timeout", + "title: Database timeout response", + "version: 1.0.0", + "---", + "Confirm database connection saturation before escalating.", + "", + ] + ), + encoding="utf-8", + ) + + result = CliRunner().invoke( + main, + [ + "investigate", + "database timeout", + "--runbooks", + str(tmp_path), + "--revision", + "abcdef1", + ], + ) + + assert result.exit_code == 0 + assert "Investigation provenance" in result.output + assert "database-timeout v1.0.0" in result.output + assert "abcdef1" in result.output + assert "digest" in result.output.lower() + + def test_rejects_invalid_runbook_revision(self, tmp_path): + result = CliRunner().invoke( + main, + [ + "investigate", + "database timeout", + "--runbooks", + str(tmp_path), + "--revision", + "short", + ], + ) + + assert result.exit_code == 1 + assert "7-64 character identifier" in result.output From 043f3e7f45a71c8c476b43ef0ab13e11a68d23f9 Mon Sep 17 00:00:00 2001 From: Corey Leath Date: Fri, 13 Nov 2026 17:09:24 -0500 Subject: [PATCH 05/12] docs: add versioned incident runbook guidance --- runbooks/database-timeout.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 runbooks/database-timeout.md diff --git a/runbooks/database-timeout.md b/runbooks/database-timeout.md new file mode 100644 index 0000000..1ad9ab5 --- /dev/null +++ b/runbooks/database-timeout.md @@ -0,0 +1,11 @@ +--- +id: database-timeout +title: Database timeout response +version: 1.0.0 +--- +# Database timeout response + +1. Confirm the error-rate increase and affected service in the normalized log stream. +2. Correlate the event fingerprint with database connection, latency, and saturation telemetry. +3. Preserve the incident timeline and request owner approval before changing connection-pool or failover settings. +4. Record the runbook version and repository revision used for the decision. From dd0fae126d8d6b0b10f69eafccd8ef11139dd6f1 Mon Sep 17 00:00:00 2001 From: Corey Leath Date: Fri, 13 Nov 2026 17:09:25 -0500 Subject: [PATCH 06/12] docs: add versioned incident runbook guidance --- runbooks/queue-backlog.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 runbooks/queue-backlog.md diff --git a/runbooks/queue-backlog.md b/runbooks/queue-backlog.md new file mode 100644 index 0000000..b256fcd --- /dev/null +++ b/runbooks/queue-backlog.md @@ -0,0 +1,11 @@ +--- +id: queue-backlog +title: Queue backlog response +version: 1.0.0 +--- +# Queue backlog response + +1. Confirm producer rate, consumer lag, and retry volume for the affected topic or queue. +2. Identify the affected consumer group and correlate it with trace and deployment evidence. +3. Preserve offsets and the incident timeline before scaling consumers or replaying work. +4. Record the runbook version and repository revision used for the decision. From cbfed88b6f068758224b7190d9b4f459f3105674 Mon Sep 17 00:00:00 2001 From: Corey Leath Date: Fri, 13 Nov 2026 17:09:27 -0500 Subject: [PATCH 07/12] docs: add versioned incident runbook guidance --- docs/INCIDENT_INVESTIGATOR.md | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 docs/INCIDENT_INVESTIGATOR.md diff --git a/docs/INCIDENT_INVESTIGATOR.md b/docs/INCIDENT_INVESTIGATOR.md new file mode 100644 index 0000000..ded103a --- /dev/null +++ b/docs/INCIDENT_INVESTIGATOR.md @@ -0,0 +1,54 @@ +# Incident investigator + +The incident investigator retrieves evidence from approved local Markdown runbooks. It is deliberately retrieval-grounded: it returns ranked excerpts and provenance, rather than generating root-cause claims or executing remediation. + +## Runbook contract + +Each runbook must be a UTF-8 `.md` file below the selected directory and start with bounded front matter: + +```markdown +--- +id: database-timeout +title: Database timeout response +version: 1.0.0 +--- +# Response steps +... +``` + +At investigation time, operators must provide an immutable source-control revision for the complete runbook set. The result records: + +- runbook ID, version, and relative source path; +- supplied repository commit revision; +- SHA-256 digest of the exact runbook file; +- deterministic relevance score and a bounded matching excerpt. + +This lets an incident record show exactly which approved guidance was retrieved. The command never downloads runbooks, calls a hosted model, modifies infrastructure, or presents its response as an authorization to act. + +## CLI usage + +Pin the runbooks to the revision checked out by your deployment or incident workspace: + +```bash +logsight investigate "database timeout during checkout" \ + --runbooks ./runbooks \ + --revision "$(git rev-parse HEAD)" \ + --evidence "ERROR connection pool timeout" \ + --evidence "trace_id=abc123" +``` + +Alternatively, provide the revision through deployment configuration: + +```bash +export LOGSIGHT_RUNBOOK_REVISION="$(git rev-parse HEAD)" +logsight investigate "queue consumer lag" --runbooks ./runbooks +``` + +Review cited excerpts and the surrounding versioned runbook before any production action. A result with no citations is intentionally inconclusive; it should prompt human triage or authoring of an approved runbook, not an invented recommendation. + +## Promotion controls + +- Store runbooks with code review and immutable release/commit history. +- Require incident responders to include the returned revision and digest in an incident record. +- Review changes to runbook wording as operational changes, including rollback implications. +- Use access-controlled repositories and deployment-owned checkout paths for production runbooks. From 1a92e681734a845b122ded3c30fb89c059c134e0 Mon Sep 17 00:00:00 2001 From: Corey Leath Date: Fri, 13 Nov 2026 17:09:38 -0500 Subject: [PATCH 08/12] docs: document versioned incident investigator --- README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index da752cb..71c48ae 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ flowchart LR - `logsight.onnx_worker.OnnxInferenceWorker` — bounded ONNX Runtime feature-batch worker with model provenance and score validation. - `logsight.redis_control.RedisAdmissionController` — atomic Redis deduplication and per-service rate-limit admission control. - `logsight.distributed.CeleryInferenceDispatcher` — bounded JSON Celery dispatch for asynchronous embedding work. +- `logsight.investigator.IncidentInvestigator` — retrieval-grounded, version-pinned incident runbook investigator with evidence citations. - `logsight.streaming.InMemoryStream` — bounded local async stream for tests and development. - `logsight.streaming.KafkaStream` — optional Kafka/Redpanda producer using `aiokafka`. - `logsight.storage.ClickHouseStore` and `QdrantStore` — HTTP adapters for durable analytical and semantic storage. @@ -94,6 +95,24 @@ pip install -e ".[api,kafka,observability,ai,parsing,redis]" The optional integrations are deliberately separated so a developer can use the original local-first CLI without downloading heavyweight ML or infrastructure clients. +### Incident investigator + +The incident investigator retrieves only approved local Markdown runbooks and returns +deterministically ranked excerpts with the runbook version, supplied immutable repository +revision, source path, and a SHA-256 content digest. It does not call a hosted model, +diagnose a root cause, take remediation actions, or turn an excerpt into an authorization +to act. + +```bash +logsight investigate "database timeout during checkout" \ + --runbooks ./runbooks \ + --revision "$(git rev-parse HEAD)" \ + --evidence "ERROR connection pool timeout" +``` + +See [incident-investigator controls](docs/INCIDENT_INVESTIGATOR.md) for the runbook +format, provenance contract, and production-promotion expectations. + ### Helm deployment The production chart at `charts/logsight-ai` deploys the API with an HPA, PDB, @@ -246,7 +265,7 @@ Pull requests retain the existing formatting, linting, strict typing, unit/integ - [x] OTel Collector deployment and trace-log correlation pipeline - [x] Celery/Ray distributed inference workers - [x] Helm chart with HPA/PDB/network policies -- [ ] RAG incident investigator with versioned runbooks/commits +- [x] RAG incident investigator with versioned runbooks/commits - [ ] Labeled benchmark corpus with precision/recall and alert-burden metrics ## Documentation @@ -256,6 +275,7 @@ Pull requests retain the existing formatting, linting, strict typing, unit/integ - [Collector correlation](docs/OTEL_COLLECTOR.md) - [Celery inference workers](docs/CELERY_WORKERS.md) - [Helm chart](charts/logsight-ai/README.md) +- [Incident investigator](docs/INCIDENT_INVESTIGATOR.md) - [Deployment and rollback checklist](docs/DEPLOYMENT.md) - [Benchmark methodology](docs/BENCHMARKING.md) - [Mathematical foundations](docs/MATHEMATICAL_FOUNDATIONS.md) From f8827d5014554bc659962430d6f1aff059abec97 Mon Sep 17 00:00:00 2001 From: Corey Leath Date: Fri, 13 Nov 2026 17:09:57 -0500 Subject: [PATCH 09/12] fix: construct investigation test runbook lines --- tests/test_cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 94658c4..31d9614 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -77,7 +77,7 @@ class TestInvestigateCommand: def test_returns_versioned_grounded_citation(self, tmp_path): runbook = tmp_path / "database.md" runbook.write_text( - "\\n".join( + "\n".join( [ "---", "id: database-timeout", From a803452aa4d27b97b0d81f270c7b88982d94fb6b Mon Sep 17 00:00:00 2001 From: Corey Leath Date: Fri, 13 Nov 2026 17:11:24 -0500 Subject: [PATCH 10/12] style: format incident investigator output --- logsight/cli.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/logsight/cli.py b/logsight/cli.py index a51144d..fe93291 100644 --- a/logsight/cli.py +++ b/logsight/cli.py @@ -223,10 +223,7 @@ def investigate_cmd( f"\n[bold]{escape(citation.title)}[/bold] " f"({escape(citation.identifier)} v{escape(citation.version)})" ) - console.print( - f" source : {escape(citation.path)} @ " - f"{escape(citation.revision)}" - ) + console.print(f" source : {escape(citation.path)} @ {escape(citation.revision)}") console.print(f" digest : {citation.digest}") console.print(f" score : {citation.score:.4f}") console.print(f" excerpt : {escape(citation.excerpt)}") From e2c47321fd357edf66b322979ea3128115651d84 Mon Sep 17 00:00:00 2001 From: Corey Leath Date: Fri, 13 Nov 2026 17:11:29 -0500 Subject: [PATCH 11/12] style: format investigation CLI tests --- tests/test_cli.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 31d9614..6d6e8bf 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -72,7 +72,6 @@ def test_explain_uses_detector_evidence(self, tmp_path): assert "no root cause is inferred" in " ".join(result.output.split()) - class TestInvestigateCommand: def test_returns_versioned_grounded_citation(self, tmp_path): runbook = tmp_path / "database.md" From 5775efffae6f6ba3a7085ee1a139870c94eacb89 Mon Sep 17 00:00:00 2001 From: Corey Leath Date: Fri, 13 Nov 2026 17:11:36 -0500 Subject: [PATCH 12/12] style: format investigator tests --- tests/test_investigator.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/test_investigator.py b/tests/test_investigator.py index 02130c4..9e71bb5 100644 --- a/tests/test_investigator.py +++ b/tests/test_investigator.py @@ -64,9 +64,7 @@ def test_investigation_ranks_grounded_citations_deterministically(tmp_path) -> N ) assert investigation.revision == "0123456789abcdef" - assert [citation.identifier for citation in investigation.citations] == [ - "database-timeout" - ] + assert [citation.identifier for citation in investigation.citations] == ["database-timeout"] citation = investigation.citations[0] assert citation.version == "1.2.0" assert citation.digest @@ -144,9 +142,7 @@ def test_rejects_oversized_runbook(tmp_path) -> None: ) def test_rejects_invalid_queries_and_limits(tmp_path, query: str, limit: int, message: str) -> None: _write_runbook(tmp_path, "database.md") - investigator = IncidentInvestigator( - RunbookRepository(tmp_path, revision="abcdef1").load() - ) + investigator = IncidentInvestigator(RunbookRepository(tmp_path, revision="abcdef1").load()) with pytest.raises(ValueError, match=message): investigator.investigate(query, limit=limit)