feat: add --params flag to kosli evaluate commands#762
Conversation
|
Claude finished @tooky's task in 1m 58s —— View job PR Review: feat: add --params flag to kosli evaluate commands
Static AnalysisAll clean: Review SummaryThis is a well-executed PR. The feature is cleanly scoped, follows established patterns, and the TDD discipline is evident in the commit history. What works well
Minor observations (non-blocking)
No bugs, security issues, or performance concerns found. The PR is ready to merge. |
Extends the Evaluate function signature with variadic params. When provided, creates an inmem store so policies can read data.params. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds tests confirming that when no params are provided the policy's default value applies, and that supplying unused params has no effect. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds --params flag to commonEvaluateOptions, accepting inline JSON or @file.json. Params are passed to OPA as data.params so policies can define configurable thresholds with defaults. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When --show-input is active and --params are provided, the params appear alongside input in the audit result output. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Updates help text and examples for evaluate, evaluate trail, evaluate trails, and evaluate input to document the --params flag. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Changes Evaluate signature from variadic params to an explicit map parameter. Callers pass nil when no params are needed, making the API unambiguous. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
mbevc1
left a comment
There was a problem hiding this comment.
Looks good, perhaps only worth looking at comment 2.
|
Summary
--paramsflag toevaluate trail,evaluate trails, andevaluate input, allowing policy authors to pass configuration data (thresholds, expected counts, etc.) without duplicating policy filesdata.params, using OPA's idiomatic data document — existing policies that don't referencedata.paramsare completely unaffected--params '{"min_approvers": 2}') or file reference (--params @params.json)Motivation
Policies are currently fully static. Thresholds like "zero approvers" or "no critical vulnerabilities" are baked into the
.regofile. If you want the same policy logic with different tolerances — say, 1 approver in staging, 2 in production — you need separate policy files duplicating the logic. That's the kind of duplicationkosli evaluateis meant to eliminate.This was flagged independently by both Alex and Dan as a natural next step.
How it works
Policy authors define defaults and override from
data.params:Design decision:
data.paramsnotinput.paramsOPA's
datadocument is designed for configuration, separate frominput(what you're evaluating). Usingdata.params:evaluate input--show-inputoutput clearly distinguishesinputfromparamsTest plan
@file.json, invalid JSON error,--show-inputincludes paramsgo vetclean🤖 Generated with Claude Code