open-policy-agent/opa-idea-plugin

Visual Debugger

GoldbergAlexander opened this issue · 3 comments

What would you like to be added

Visual debugging support like exists with Python in PyCharm or Java in JetBrains.

Why is this needed

This would speed up policy development and document discovery.
Features from a technical implementation are available using the Fregot tool, however, it would be nice to extend this integration into an IDE. Looking at the JetBrains documentation on plugins it seems like "Debuggers" are in the works and I don't know if this level of integration is even supported.

If this is not on the roadmap, I'd be interested in taking this up myself.

Implementation details

That would be awesome @GoldbergAlexander 👍 I know of plenty other language integrations that adds debugging capabilities for their language so it should certainly be doable. What's missing for this type of integration is rather in OPA itself, as there is no way of tapping into this from the outside currently. At the last bi-weekly meeting we talked some about the options in that space, and @tsandall presented some ideas around that. Perhaps you'd like to join in for the next one? Details for how to join can be found in the OPA README. Next meeting is Tuesday the 16th.

We could obviously keep the discussion going here until then too :)

That sounds great — I’ll do a little more research on how that integration works and see if I can dial in. I see what you mean on the repl support in OPA. Fregot (https://github.com/fugue/fregot/tree/master/lib/Fregot) seems to have their own rego implementation, perhaps that could be the base?

Yep, you could use Fregot to implement a debugger extension. I also did a quick experiment to see how much it would take to do this inside OPA using the existing tracing support. The answer is not too much--tracing delivers events when expressions are being executed so the debugger can hook into those and then wait for input, query state, etc. Here's the spike: tsandall/opa@a2cc2db