Skip to content

feat(brain): bridge Elasticsearch log causes into R3 - #281

Merged
gnanirahulnutakki merged 3 commits into
devfrom
gnanirahulnutakki/feat/e14-elasticsearch-r3-bridge
Jul 19, 2026
Merged

feat(brain): bridge Elasticsearch log causes into R3#281
gnanirahulnutakki merged 3 commits into
devfrom
gnanirahulnutakki/feat/e14-elasticsearch-r3-bridge

Conversation

@gnanirahulnutakki

@gnanirahulnutakki gnanirahulnutakki commented Jul 19, 2026

Copy link
Copy Markdown
Member

Summary

  • bridge the existing bounded Elasticsearch search/ecs-v1 log-cause fact into the deterministic R3 CrashLoop rule
  • revalidate exact source/provenance, Pod attachment, closed payload bounds, caller-declared coverage, staleness, and a SHA-256 identity bound to the retained sanitized aggregate
  • add actual projector-to-graph-to-R3, cross-Pod, adversarial, replay, and text/JSON privacy coverage
  • document the behavior and its nonclaims in README, ROADMAP, the E14 spec, ADR-0008, and the GSTACK journal

Security, reliability, and cost

Raw log messages are classified and discarded by the existing source projector before the brain sees a fact. The bridge retains only exact Pod identity, the closed logs.cause value, last classified event time, source, and staleness. It adds no Elasticsearch client, credential, endpoint/index configuration, query execution, retention, correlation, typed intent, mutation, dispatch, cloud resource, egress, or recurring cost.

Verification

  • make ci — zero lint findings, no reachable vulnerabilities, complete race/policy/alert/performance/E2E/build gate
  • focused race coverage — Elasticsearch 95.7%, brain 88.6%, CLI 62.7%
  • native decoder fuzz — 653,689 post-hardening executions
  • make e2e-isolation — PostgreSQL 18.4 forced RLS plus both 50,000-execution workspace fuzzers
  • make release-check — reproducible four-platform archives, SPDX SBOMs, Homebrew, amd64/arm64 Hub OCI
  • make e2e-kind — Kubernetes 1.36.1 two-cluster suite in 234.972s with clean teardown
  • CodeRabbit — one defense-in-depth scope check fixed; repeated complete review reports zero findings

Closes #280
Parent: #46

Summary by CodeRabbit

  • New Features
    • CrashLoopBackOff investigations can now incorporate validated, sanitized Elasticsearch search/ecs-v1 log-cause evidence (no direct querying).
    • Supports a closed set of causes: panic, missing-config, dependency-failure, preserving last-event timing and staleness.
    • Added a deterministic replay fixture for Elasticsearch log-cause R3.
  • Bug Fixes
    • Fail-closed validation rejects ambiguous, unrelated, invalid, or cross-pod evidence; telemetry coverage is never inferred.
    • Investigation output omits raw logs and discarded sensitive/unapproved metadata.
  • Documentation
    • Updated the E14 investigation brain spec, roadmap, and supporting session/ADR to describe the bridge and CLI limitations.
  • Tests
    • Added projector/CLI coverage, fuzzing, and stricter payload decoding hardening (e.g., invalid UTF-8 rejection).

Revalidate bounded search/ecs-v1 facts at the graph boundary, bind native identity to the retained sanitized Pod aggregate, and preserve staleness and caller-declared coverage without retaining raw logs or adding I/O.

GSTACK-Checkpoint: 2026-07-18/e14-elasticsearch-r3-bridge#1

Signed-off-by: Gnani Rahul Nutakki <gnani.nutakki@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 023873ff-6028-4cc4-b455-5a2e7c4b0e41

📥 Commits

Reviewing files that changed from the base of the PR and between 5cab98c and 84d93a9.

📒 Files selected for processing (1)
  • sessions/2026-07-18-e14-elasticsearch-r3-bridge.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • sessions/2026-07-18-e14-elasticsearch-r3-bridge.md

📝 Walkthrough

Walkthrough

The PR connects sanitized Elasticsearch search/ecs-v1 log-cause facts to R3 through strict provenance, payload, Pod identity, and SHA-256 validation. It preserves normalized cause evidence, declared coverage, and staleness while adding evaluation, replay, CLI, fuzz, and fail-closed test coverage.

Changes

Elasticsearch R3 graph bridge

Layer / File(s) Summary
Bridge contract and identity binding
README.md, docs/ROADMAP.md, docs/adr/..., docs/specs/..., internal/connector/elasticsearch/...
Documents the narrow R3 seam and binds projector identities to retained workspace, Pod, cause, aggregate, and event-time fields.
Graph fact validation and projection
internal/brain/graph.go
Routes exact Elasticsearch facts through provenance, payload, bounds, Pod identity, text, and digest validation before producing a Pod-scoped logs.cause observation.
Projection, evaluation, and output validation
internal/brain/graph_elasticsearch_test.go, internal/brain/testdata/replays/*, internal/cli/investigate_test.go
Tests accepted causes, coverage and staleness handling, fail-closed mutations, Pod-local evidence, fuzzed payloads, replay expectations, and sanitized text/JSON output.
Implementation record
sessions/2026-07-18-e14-elasticsearch-r3-bridge.md
Records the bridge design constraints and verification checklist.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ElasticsearchConnector
  participant FromGraphFacts
  participant InvestigationBrain
  ElasticsearchConnector->>FromGraphFacts: provide bounded derived LogSignal fact
  FromGraphFacts->>FromGraphFacts: validate provenance, identity, payload, and Pod scope
  FromGraphFacts->>InvestigationBrain: emit sanitized logs.cause observation
  InvestigationBrain->>InvestigationBrain: evaluate existing R3 CrashLoop rule
Loading

Possibly related PRs

  • ArdurAI/sith#215 — Provides the bounded Elasticsearch log-cause fact pipeline consumed by this bridge.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: bridging Elasticsearch log causes into R3.
Linked Issues check ✅ Passed The summarized code and docs implement the narrow Elasticsearch search/ecs-v1 bridge, validation, sanitization, and tests required by issue #280.
Out of Scope Changes check ✅ Passed The changes stay focused on the Elasticsearch-to-R3 bridge and its supporting tests and documentation, with no clear unrelated additions.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch gnanirahulnutakki/feat/e14-elasticsearch-r3-bridge

Comment @coderabbitai help to get the list of available commands.

@gnanirahulnutakki

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/brain/graph.go`:
- Around line 220-254: Extend the validation in the Elasticsearch log-cause fact
projection to reject any non-empty provenance DeepLink or Collector metadata,
alongside the existing attributes and display checks. Update the validation
block around the entity and fact fields so unexpected provenance metadata
returns the same fail-closed error path.
- Around line 453-459: Update decodeElasticsearchLogCausePayload to validate raw
with utf8.Valid before calling rejectDuplicateGraphJSON, returning the existing
payload-decoding error pattern when the bytes are invalid. Keep duplicate-key
rejection and subsequent decoding unchanged.

In `@sessions/2026-07-18-e14-elasticsearch-r3-bridge.md`:
- Line 101: Update the line beginning “#280, update `#46`” to avoid a malformed
Markdown heading token, using “issue 280” or placing “#280” inline within the
sentence while preserving the existing meaning.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1dd788ad-9a82-4a7d-9990-45968101caa7

📥 Commits

Reviewing files that changed from the base of the PR and between 098b2b8 and 2d1c89e.

📒 Files selected for processing (13)
  • README.md
  • docs/ROADMAP.md
  • docs/adr/0008-deterministic-advisory-brain.md
  • docs/specs/E2-readfed-brain-integrations.md
  • internal/brain/graph.go
  • internal/brain/graph_elasticsearch_test.go
  • internal/brain/testdata/replays/README.md
  • internal/brain/testdata/replays/r3-elasticsearch-log-cause.json
  • internal/cli/investigate_test.go
  • internal/connector/elasticsearch/boundary_test.go
  • internal/connector/elasticsearch/project.go
  • internal/connector/elasticsearch/project_test.go
  • sessions/2026-07-18-e14-elasticsearch-r3-bridge.md

Comment thread internal/brain/graph.go
Comment thread internal/brain/graph.go
Comment thread sessions/2026-07-18-e14-elasticsearch-r3-bridge.md Outdated
Reject unreviewed provenance metadata and malformed UTF-8 before JSON normalization. Add regression coverage and record the hosted-review remediation proof.

GSTACK-Checkpoint: 2026-07-18/e14-elasticsearch-r3-bridge#2

Signed-off-by: Gnani Rahul Nutakki <gnani.nutakki@gmail.com>
@gnanirahulnutakki

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@sessions/2026-07-18-e14-elasticsearch-r3-bridge.md`:
- Around line 115-119: Resolve the conflicting brain coverage values between the
earlier checkpoint and this post-remediation matrix entry. If they represent
different runs, identify each by its checkpoint or commit; otherwise, correct
the value so the verification record contains one unambiguous coverage figure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 93d2fba9-6a77-4329-8cd0-ab22b6fe00d0

📥 Commits

Reviewing files that changed from the base of the PR and between 2d1c89e and 5cab98c.

📒 Files selected for processing (3)
  • internal/brain/graph.go
  • internal/brain/graph_elasticsearch_test.go
  • sessions/2026-07-18-e14-elasticsearch-r3-bridge.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/brain/graph_elasticsearch_test.go
  • internal/brain/graph.go

Comment thread sessions/2026-07-18-e14-elasticsearch-r3-bridge.md
Distinguish original feature-head coverage from the post-remediation run so the verification record is unambiguous.

GSTACK-Checkpoint: 2026-07-18/e14-elasticsearch-r3-bridge#3

Signed-off-by: Gnani Rahul Nutakki <gnani.nutakki@gmail.com>
@gnanirahulnutakki

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@gnanirahulnutakki
gnanirahulnutakki merged commit df28654 into dev Jul 19, 2026
7 checks 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.

1 participant