Skip to content

precompile input#3275

Closed
joejstuart wants to merge 9 commits intoconforma:mainfrom
joejstuart:bypass-conftest
Closed

precompile input#3275
joejstuart wants to merge 9 commits intoconforma:mainfrom
joejstuart:bypass-conftest

Conversation

@joejstuart
Copy link
Copy Markdown
Contributor

No description provided.

@joejstuart joejstuart marked this pull request as draft May 6, 2026 17:24
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 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: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 231d2e86-eee5-42f0-b973-9225dee67a11

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 37 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/evaluator/conftest_evaluator.go 86.17% 34 Missing ⚠️
...ation_snapshot_image/application_snapshot_image.go 80.00% 2 Missing ⚠️
internal/image/validate.go 66.66% 1 Missing ⚠️
Flag Coverage Δ
acceptance 54.90% <82.23%> (-0.26%) ⬇️
generative 17.73% <0.00%> (-0.17%) ⬇️
integration 26.99% <65.63%> (+0.33%) ⬆️
unit 68.99% <75.28%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/image/validate.go 70.80% <66.66%> (ø)
...ation_snapshot_image/application_snapshot_image.go 83.56% <80.00%> (+0.87%) ⬆️
internal/evaluator/conftest_evaluator.go 87.60% <86.17%> (-1.06%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

joejstuart and others added 9 commits May 6, 2026 14:48
… constructor

Extract the policy source download loop, annotation inspection, and rule
collection logic from Evaluate() into a new downloadAndInspectPolicies()
method called once during construction. This makes the data available as
read-only struct fields during Evaluate(), preparing for pre-compilation
of the OPA engine in a subsequent commit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Compile policies once via conftest.LoadWithData() in the constructor and
store the Engine. In Evaluate(), instead of creating a conftestRunner
(which re-compiles everything), query the pre-compiled engine's Compiler
and Store directly via rego.New(). This eliminates both the redundant
compilation inside conftestRunner.Run() and the double LoadWithData call
that existed solely to access the store for validation.

The new evaluateWithEngine/queryNamespace/evalOPAQuery methods replicate
conftest's check() logic but skip addFileInfo() (which mutates the store),
making concurrent evaluation safe. Mock runner injection via context is
preserved for tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add ParsedInput map[string]any field to EvaluationTarget. When set,
evaluateWithEngine uses it directly instead of reading and parsing
input files from disk. Nothing sets ParsedInput yet — that comes in
the next commit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add BuildInput() to ApplicationSnapshotImage that constructs the OPA
input as a map[string]any via JSON marshal/unmarshal (to ensure correct
OPA types) without writing to disk. Update ValidateImage to use
BuildInput and pass the result via EvaluationTarget.ParsedInput,
bypassing the temp-file creation and re-parsing that WriteInputFile
required.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…package

Move downloadAndInspectPolicies and compileEngine from the evaluator
constructor to a lazy sync.Once in evaluateWithEngine. This prevents
double downloads (PreProcessPolicy already pins URLs) and fixes test
failures where mock runners never call Evaluate but constructor tried
to download real policies.

Add memprofile package for opt-in memory profiling (EC_MEMPROFILE=1)
with phase-by-phase snapshots and pprof server.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove the memprofile package and all its call sites. This was useful
for diagnosing the allocation problem but is debug instrumentation
that doesn't belong in production. Go's existing runtime/pprof and
runtime/trace support (via the --trace flag) covers profiling needs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix type assertion from value to pointer receiver (*conftestEvaluator)
  in integration test
- Replace JSON-only parseInputFiles with conftest parser supporting
  JSON, YAML, and other formats
- Add OPA tracing and print hook support to evalOPAQuery so --trace=opa
  produces expected trace/debug output
- Handle multi-document YAML files matching conftest engine.Check behavior
- Change compileEngine error prefix to "load:" matching conftest runner

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These were the old conftest runner wrapper and result conversion
helper that are no longer needed since we query OPA directly via
rego.New() with the pre-compiled engine.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove initCtx from struct; pass live ctx through ensureInitialized
  to avoid stale/cancelled context bugs
- Remove silent os.Stat guard in compileEngine; the Evaluate method
  already branches on runnerKey so tests never reach this path
- Fix receiver inconsistency: change queryNamespace, evalOPAQuery,
  prepareDataDirs, computeSuccesses, isResultIncluded to pointer
  receivers matching the rest of the struct
- Remove dead WriteInputFile method and update tests to use BuildInput
- Remove unused metadataQuery constant (was only used by deleted toRules)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant