Skip to content

Add AnalysisEngine and PlatformOps to core library#1062

Draft
mikeagun wants to merge 4 commits intovbpf:mainfrom
mikeagun:analysis-engine
Draft

Add AnalysisEngine and PlatformOps to core library#1062
mikeagun wants to merge 4 commits intovbpf:mainfrom
mikeagun:analysis-engine

Conversation

@mikeagun
Copy link
Copy Markdown
Contributor

@mikeagun mikeagun commented Mar 31, 2026

Add AnalysisEngine — a session-managing wrapper around the PREVAIL pipeline that handles ELF loading, caching, re-analysis on file change, and live access to AnalysisResult for constraint checking and backward slicing.

PlatformOps is an abstract interface that decouples the engine from platform-specific operations (ELF validation, program enumeration, TLS management, verifier options). PrevailPlatformOps is the portable implementation using only PREVAIL's public API.

These live in src/ (the core library) with no JSON or protocol dependencies, so both the CLI and any server frontend can share them.

Depends on #1061 (compute_slice_from_label).

Files changed:

  • src/analysis_engine.hpp / .cpp — engine and session types
  • src/platform_ops.hpp — abstract platform interface

Refactor backward slicing to expose a general-purpose
compute_slice_from_label() method on AnalysisResult that accepts an
arbitrary label and seed relevance. The existing compute_failure_slices()
now delegates to it, iterating error labels and extracting initial
relevance from assertions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Michael Agun <danielagun@microsoft.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 627100fc-070d-43a3-ab3d-e053c82a623f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@mikeagun mikeagun mentioned this pull request Mar 31, 2026
Michael Agun and others added 2 commits April 8, 2026 14:39
Merge per-label relevance instead of overwriting when a label is
revisited from a different successor, preserving registers and stack
offsets from earlier visits.

Only fall back to aggregating all assertion registers when the failing
assertion was not identified. When it was found but has no register
deps, leave the seed empty so compute_slice_from_label enters
conservative mode.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Michael Agun <danielagun@microsoft.com>
Move the analysis engine (session management, caching, re-analysis on
file change) and platform abstraction into the core library so both
prevail CLI and MCP frontends can share it.

Changes from the original src/mcp/ versions:
- Replace prevail_headers.hpp with direct includes
- Add [[nodiscard]] to PlatformOps virtual methods
- Fix option overrides persisting across calls (init from defaults)
- Remove no-op catch (...) { throw; } in analyze()
- Fix stale 'check.exe' reference in PrevailPlatformOps (now 'prevail')

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Michael Agun <danielagun@microsoft.com>
Replace the 3 optional<bool> parameters on analyze() with a pointer to
ebpf_verifier_options_t, giving callers full control over verbosity,
conformance groups, and all other verifier settings. When null, platform
defaults are used.

Remove the VerificationOptions struct (subset of ebpf_verifier_options_t
that is no longer needed). Store the full options in AnalysisSession so
callers can inspect them.

Stop hardcoding verbosity flags in analyze() — each frontend (CLI, MCP)
sets its own verbosity before calling the engine.

Accept ebpf_platform_t by value in PrevailPlatformOps so callers can
configure conformance groups before constructing the ops object.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Michael Agun <danielagun@microsoft.com>
@elazarg
Copy link
Copy Markdown
Collaborator

elazarg commented Apr 17, 2026

Now #1061 is merged; however, I'd postpone this refactor to after most of the 107* design issues are addressed.

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