precompile input#3275
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
… 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>
2e06065 to
c2e35a4
Compare
No description provided.