Skip to content

Add browser-safe playground evaluator - #3630

Draft
dheerajodha wants to merge 6 commits into
conforma:mainfrom
dheerajodha:playground-wasm-poc
Draft

dheerajodha wants to merge 6 commits into
conforma:mainfrom
dheerajodha:playground-wasm-poc

Conversation

@dheerajodha

Copy link
Copy Markdown
Contributor

Summary

  • Add an experimental public pkg/playground evaluator for the browser playground spike.
  • Accept inline Rego, JSON/YAML input, and optional JSON/YAML data without pulling in the CLI command tree.
  • Reuse Conforma rule metadata parsing from internal/opa/rule so playground results stay closer to real Conforma policy metadata.
  • Remove the earlier hack/playground-wasm prototype so this branch only carries the reusable evaluator package.

Scope

This is not full ec validate input parity yet. It intentionally avoids EnterpriseContractPolicy source resolution, include/exclude filtering, OCI/image validation, Sigstore, Rekor, Kubernetes, and remote policy fetching. The goal is to provide the minimal Conforma-owned evaluator package that can compile to js/wasm for EC-2222.

Verification

  • GOCACHE=/private/tmp/ec-gocache-playground go test ./pkg/playground
  • GOOS=js GOARCH=wasm GOCACHE=/private/tmp/ec-gocache-playground go test -c -o /private/tmp/conforma-playground-package.test.wasm ./pkg/playground
  • Dependency scan confirmed the wasm package avoids the CLI-heavy dependency graph.

References EC-2222.

Adds a narrow browser-local playground spike under hack/playground-wasm. The PoC compiles a small Go wrapper to WebAssembly, loads it from a static HTML page, and evaluates pasted Rego against pasted JSON or YAML input with OPA's Go APIs.

This intentionally avoids the full Conforma CLI command path, OCI fetching, Sigstore, Rekor, and remote policy loading. The goal is to prove the in-browser rule authoring loop before deciding how much of ec validate input can be reused for production parity.
References EC-2222.

Extends the browser-local playground spike so pasted Rego can contain multiple modules separated by # file markers and optional JSON/YAML data can be made available under data.

This moves the PoC closer to real Conforma policy shapes where rule modules import helper packages and rely on policy data, while still intentionally avoiding EnterpriseContractPolicy resolution, remote policy fetching, and full ec validate input parity.
EC-2222: Add a Conforma-shaped playground fixture that exercises multiple Rego modules, helper imports, rule data, and structured deny/warn results.

Document current parity boundaries and the next comparison needed against the real ec validate input path.
EC-2222: Add an equivalent local ec validate input fixture for the playground parity sample.

Document the observed comparison: the failing input reports the same two violations and one warning, while the passing input succeeds with three checked rules in the CLI report.
EC-2222: Add a small pkg/playground evaluator in Conforma CLI that accepts inline Rego, inline JSON/YAML input, and optional inline JSON/YAML data for browser playground use.

The package uses OPA directly plus Conforma's rule metadata parser to return Conforma-like violations, warnings, successes, and success-count without pulling in CLI, source-resolution, image, OCI, Sigstore, Rekor, Kubernetes, or Conftest paths.
EC-2222: Remove the old hack/playground-wasm prototype now that the standalone playground repo owns the UI and the CLI branch only needs the reusable pkg/playground evaluator.
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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

@fullsend-ai-review

Copy link
Copy Markdown

<!-- fullsend:risk-assessment -->
Risk Assessment: moderate (2/5)

Details

Nearly all metadata signals are low-risk, but a large blast radius designation elevates the change-size composite to 5; the two new files carry no git history to assess stability, yielding a moderate composite score of 2.

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

High

  • [naming conventions] pkg/playground/evaluator_test.go:17 — Missing //go:build unit build tag. Every test file in the repository carries a build constraint (//go:build unit or //go:build integration). Without this tag the tests run under a plain go test ./... invocation, bypassing the project's test isolation architecture.
    Remediation: Add //go:build unit immediately after the SPDX line and before package playground.

Labels: PR adds new Go package (playground evaluator feature)


Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

@fullsend-ai-review fullsend-ai-review 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.

See the review comment for full details.

//
// SPDX-License-Identifier: Apache-2.0

package playground

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[high] naming conventions

Missing //go:build unit build tag. Every test file in the repository carries a build constraint (//go:build unit or //go:build integration). Without this tag the tests run under a plain go test ./... invocation, bypassing the project's test isolation architecture.

Suggested fix: Add //go:build unit immediately after the SPDX line and before package playground.

@fullsend-ai-review fullsend-ai-review Bot added feature go Pull requests that update Go code labels Oct 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature go Pull requests that update Go code risk/moderate PR risk: moderate size: XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant