Skip to content

feat(hogli): add ci:insights adapter (with Mendral concrete class)#60299

Merged
rnegron merged 2 commits into
masterfrom
worktree-mendral-experiment
May 28, 2026
Merged

feat(hogli): add ci:insights adapter (with Mendral concrete class)#60299
rnegron merged 2 commits into
masterfrom
worktree-mendral-experiment

Conversation

@rnegron
Copy link
Copy Markdown
Member

@rnegron rnegron commented May 27, 2026

Problem

Mendral (our CI-insights backend) holds aggregated cross-run intelligence — recurring flakes, occurrence counts, confidence, proposed/merged fixes — that no single CI run can show. Today it lives only in Slack and the web UI, so engineers (and agents) rarely consult it at the moment they're actually debugging a red build.

Changes

  • New hogli ci:insights command — an adapter over the CI-insights backend. Verbs: ci:insights (digest for the current repo + branch, default), search, view [--json], plan (prints the recommended remediation plan; does not apply it). All Mendral-specific knowledge is quarantined in one MendralBackend class. Lives in the hogli-commands extension layer; core untouched.
  • debugging-ci-failures skill gains a "Check existing CI insights first" step (between Classification and Local reproduction) so agents query an existing hypothesis before reproducing from scratch.

How did you test this code?

I'm an agent; I did not perform manual QA beyond the runs below. Automated + live checks I actually ran:

  • test_ci_insights.py — 16 passing (preflight, verb→backend mapping, exit-code propagation, recommended-action selection).
  • hogli ci:insights / search / plan <id> against the live backend; plan correctly selected a proposed recommended action over a merged one; bad id exits non-zero.
  • ruff check/format clean; hogli lint:skills + build:skills pass with no file drift.

Publish to changelog?

No.

🤖 Agent context

Authored with Claude Code

@rnegron rnegron marked this pull request as ready for review May 27, 2026 20:01
@assign-reviewers-posthog assign-reviewers-posthog Bot requested a review from a team May 27, 2026 20:02
@rnegron rnegron added the stamphog Request AI review from stamphog label May 27, 2026
Comment thread tools/hogli-commands/hogli_commands/ci_insights.py
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 27, 2026

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
tools/hogli-commands/hogli_commands/tests/test_ci_insights.py:45-53
The parametrize table covers `view --json` but omits the analogous `search --json` case, leaving the `--json` flag on `search` untested despite the project preference for parameterised tests covering symmetric behaviour.

```suggestion
@pytest.mark.parametrize(
    "argv, expected",
    [
        ([], ("mendral", "here")),
        (["search", "flaky timeout"], ("mendral", "insight", "search", "flaky timeout")),
        (["search", "flaky timeout", "--json"], ("mendral", "insight", "search", "flaky timeout", "--json")),
        (["view", "01ABC"], ("mendral", "insight", "view", "01ABC")),
        (["view", "01ABC", "--json"], ("mendral", "insight", "view", "01ABC", "--json")),
    ],
)
```

### Issue 2 of 2
tools/hogli-commands/hogli_commands/tests/test_ci_insights.py:106
The payload `'{"actions": [null]}'` is valid JSON, so it never reaches the `json.JSONDecodeError` handler — the null entry is silently filtered and the code lands on the "No remediation plan available" path, which is already the focus of `test_plan_errors_when_no_actions`. Keeping it here conflates two distinct failure modes; moving it there as a second parametrize case keeps the intent explicit.

```suggestion
@pytest.mark.parametrize("payload", ["", "not json{"])
```

Reviews (1): Last reviewed commit: "fix(hogli): harden ci:insights edge case..." | Re-trigger Greptile

Comment thread tools/hogli-commands/hogli_commands/tests/test_ci_insights.py
Comment thread tools/hogli-commands/hogli_commands/tests/test_ci_insights.py
Copy link
Copy Markdown

@stamphog stamphog Bot left a comment

Choose a reason for hiding this comment

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

The hex-security-app bot raised a valid, current-head, unresolved argument-injection concern: query and insight_id are passed directly as positional elements in the subprocess.run args list with no -- option terminator, so a value like --config=... or --token=... would be interpreted as a flag by the mendral CLI rather than as a literal argument. The fix is a one-line change (place "--" before each user-supplied positional in search, view, and plan). Per review policy, substantive bot comments with valid concerns that remain unaddressed are a REFUSE.

@stamphog stamphog Bot removed the stamphog Request AI review from stamphog label May 27, 2026
@rnegron rnegron added the stamphog Request AI review from stamphog label May 27, 2026
Copy link
Copy Markdown

@stamphog stamphog Bot left a comment

Choose a reason for hiding this comment

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

The hex-security-app bot flagged argument injection in search, view, and plan — user-supplied query and insight_id are passed as positional args to subprocess.run without a -- terminator, so a value starting with - would be interpreted as a flag by the mendral CLI. The thread was marked resolved but the code was not changed, and the stamphog aggregator top-level review (current head) explicitly calls this out as still unaddressed. The fix is trivial — add "--" before each user-supplied positional — and should be applied before auto-approving.

@stamphog stamphog Bot removed the stamphog Request AI review from stamphog label May 27, 2026


class MendralBackend:
"""The only Mendral-aware code. Swap this class to change providers."""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clever 😏

@rnegron rnegron merged commit a8fe448 into master May 28, 2026
232 checks passed
@rnegron rnegron deleted the worktree-mendral-experiment branch May 28, 2026 13:18
@deployment-status-posthog
Copy link
Copy Markdown

deployment-status-posthog Bot commented May 28, 2026

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-05-28 13:58 UTC Run
prod-us ✅ Deployed 2026-05-28 14:15 UTC Run
prod-eu ✅ Deployed 2026-05-28 14:14 UTC Run

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