Skip to content

feat: Add AutoEscalation — Elixir port of Opsbox::AutoEscalation#52

Open
Jez-A wants to merge 4 commits intoauto_escalation_adf_builderfrom
auto_escalation_in_zexbox
Open

feat: Add AutoEscalation — Elixir port of Opsbox::AutoEscalation#52
Jez-A wants to merge 4 commits intoauto_escalation_adf_builderfrom
auto_escalation_in_zexbox

Conversation

@Jez-A
Copy link

@Jez-A Jez-A commented Mar 3, 2026

Summary

PR: #53 adds the Jira client used to search, create, add comments, and transition issues and tickets. Can be merged individually.

PR: #54 adds the ADFBuilder which builds Atlassian Document Format (ADF) maps for Jira issue descriptions and comments.

The planned merge order is 53, then 54, then 52 (this PR)

Usage

rescue
  e ->
    Zexbox.AutoEscalation.handle_error(
      error: e,
      stacktrace: __STACKTRACE__,
      action: "checkout",
      priority: "High",
      zigl_team: "Purchase Ops",
      user_context: %{email: user.email},
      additional_context: %{basket_id: basket.id}
    )

Impact

Allows us to connect critical-path exceptions and errors into our medic system seamlessly.

Test plan

  • mix test test/zexbox/auto_escalation_test.exs — 21 tests covering new-ticket path, existing-ticket path, disabled state, search failure fallback, and custom fingerprints
  • mix test — full suite green

🤖 Generated with Claude Code

@Jez-A Jez-A force-pushed the auto_escalation_in_zexbox branch from fdafb20 to 99ee28f Compare March 3, 2026 14:52
@Jez-A Jez-A changed the title feat: Add Zexbox.AutoEscalation — Elixir port of Opsbox::AutoEscalation feat: Add AutoEscalation — Elixir port of Opsbox::AutoEscalation Mar 3, 2026
@Jez-A Jez-A changed the base branch from master to auto_escalation_adf_builder March 3, 2026 14:53
end

defp auto_escalation_enabled? do
Application.get_env(:zexbox, :auto_escalation_enabled, true) == true
Copy link
Author

Choose a reason for hiding this comment

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

This environment variable will need to be added

@Jez-A Jez-A force-pushed the auto_escalation_adf_builder branch from 1217069 to 846cb0b Compare March 3, 2026 15:43
@Jez-A Jez-A force-pushed the auto_escalation_in_zexbox branch from 0551ddc to 5d3d3e9 Compare March 3, 2026 15:43
@Jez-A Jez-A force-pushed the auto_escalation_adf_builder branch from 846cb0b to 698e096 Compare March 3, 2026 17:07
Jez-A and others added 4 commits March 3, 2026 17:07
Adds Zexbox.AutoEscalation, which handles automatic error-to-on-call
escalation via Jira. When an error is rescued, this module:

1. Generates a fingerprint (action::ErrorClass) and searches Jira for an
   open ticket with that fingerprint (exact-match JQL, excludes resolved
   statuses: Done / No Further Action / Ready for Support Approval).
2. If found: adds an ADF comment documenting the new occurrence.
3. If not found: creates a Bug ticket with ADF description, sets the
   fingerprint and ZIGL Team custom fields, then transitions to "To do".

Returns {:ok, ticket_map}, {:error, reason}, or {:disabled, nil}.
Uses the SP project key in :production, SS otherwise.

Usage from a rescue block:

    rescue
      e ->
        Zexbox.AutoEscalation.handle_error(
          error: e,
          stacktrace: __STACKTRACE__,
          action: "checkout",
          priority: "High",
          zigl_team: "Purchase Ops"
        )

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…guments

Mirrors the JiraClient refactor: handle_error/5, generate_fingerprint/2,
and all private helpers now use explicit positional args instead of keyword
lists. JiraClient call sites updated to match the new positional API.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Jez-A Jez-A force-pushed the auto_escalation_in_zexbox branch from 5d3d3e9 to 3615fd1 Compare March 3, 2026 17:08
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