Skip to content

feat(evaluate): refuse a decision from a local policy - #1302

Merged
ToreMerkely merged 2 commits into
mainfrom
7583-refuse-inline-policy-decision
Oct 26, 2026
Merged

ToreMerkely merged 2 commits into
mainfrom
7583-refuse-inline-policy-decision

Conversation

@ToreMerkely

Copy link
Copy Markdown
Contributor

Refuse kosli evaluate policy --control with --path or --policy before any request, naming kosli publish rego-policy and --identifier. Kosli now records a decision only from a published policy, so the server would reject the request anyway. Step 3 of refusing decisions from inline policies.

Part of kosli-dev/server#7583

🤖 Generated with Claude Code

Kosli now refuses to record a decision from an inline policy
(kosli-dev/server#7583): publishing is org-admin only and validates the
policy, so an inline bundle let whoever records a decision also write
the Rego behind it. `kosli evaluate policy --control` with `--path` or
`--policy` now fails before any request, naming
`kosli publish rego-policy` and `--identifier`, rather than sending an
evaluation the server rejects. `--path` without `--control` still
evaluates.

The decision tests now name a published policy with --identifier.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ToreMerkely

Copy link
Copy Markdown
Contributor Author
  • --path without --control is unchanged; evaluate trail(s) --server-side never sends a decision, so nothing else needs the check.
  • The server side is kosli-dev/server#7652. An older CLI meets that server's 400 and prints it, so release order does not matter for correctness; this only gives the guidance earlier.
  • The command is still hidden, so there is no docs page to regenerate.

@ToreMerkely
ToreMerkely enabled auto-merge (squash) October 26, 2026 08:49
@github-actions github-actions Bot added go Pull requests that update go code feat labels Oct 26, 2026
@claude

claude Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @ToreMerkely's task in 51s —— View job


Follow-up review of new commits (d45befc → 116574a)

Scope: git diff d45befc8..116574a8 touches only cmd/kosli/root.go (flag help text) and cmd/kosli/evaluatePolicy_test.go (new test).

Previous finding status:

  • The nit about policyControlFlag help text not mentioning the --identifier constraint — resolved. policyControlFlag in root.go:156 now reads "Only a published policy (--identifier) can record one." The review thread was already marked resolved (author replied confirming the fix in 116574a), so no further action needed there.

New commits review: No new issues found. The added test (TestAControlFromTheEnvironmentIsRefusedWithAPath) correctly exercises the existing refusal path — suite.cmd() already supplies --path, and o.control is populated from KOSLI_CONTROL via the existing flag/env binding, so the check at evaluatePolicy.go:213 (o.control != "" && len(policyRefs) > 0) fires as expected without any production code change. The help-text-only change to root.go carries no logic risk.

0 new inline comments posted.

Comment thread cmd/kosli/evaluatePolicy.go
Only the long help said a decision needs a published policy, so
someone reading the flag list met the constraint only as an error. A
test also locks in that KOSLI_CONTROL from the environment is refused
with --path, as a typed --control is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ToreMerkely

Copy link
Copy Markdown
Contributor Author

On the review's other suggestions:

  • Order of checks: skipped. The published-policy refusal coming before the missing --flow/--trail one is the right order, as the review says.
  • Release note: skipped. The request failed before this change too, only at the server; the command is still hidden, and the feat(evaluate): title reaches the changelog.
  • KOSLI_CONTROL from the environment: fixed in 116574a with TestAControlFromTheEnvironmentIsRefusedWithAPath.

@ToreMerkely
ToreMerkely merged commit 85b55bf into main Oct 26, 2026
22 checks passed
@ToreMerkely
ToreMerkely deleted the 7583-refuse-inline-policy-decision branch October 26, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants