Repository navigation
feat(publish): hidden kosli publish rego-policy, publish a versioned Rego policy - #1256
Conversation
The rego-policy publish needs the same backoff wait as evaluations. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rego-policy publish returns 202 Accepted, which Do reported as an error. Only 200, 201 and 202 are accepted: callers read the body as the whole answer, which a 204 (no body) or a 206/207 (part of one) is not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the client for PUT /api/v2/rego-policies/{org}/{identifier},
which stores the next version as pending.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… valid version Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sions apart Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…publishing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o-policy help Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A slash in an identifier was read as a path separator, and "../x" left the org's route. The identifier and org are now escaped, and "", "." and "..", which escaping cannot keep in place, are refused before sending. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rminal Publishing content the newest valid version already holds answers with that version, so the extra read was wasted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server re-runs a publish that loses a race, so a 409 is a refusal. Retrying it as a lock delayed the answer and lost the server's message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep only the fact each comment states that the code cannot show, and drop the comments that restate a test name or what a helper does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Claude finished @jumboduck's task in 2m 8s —— View job Review complete ✅Scope:
Previous findingsBoth of my earlier findings are resolved (threads already marked resolved on GitHub) and neither location was touched by this batch of commits:
New commits in this range
I traced the new logic ( Note: I could not execute |
…alid one With --output json, a rejected or failed version left stdout empty, so a script could not read error.kind or error.message. The exit code is still 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ding message A route without a host left a user on a non-default --host to fill it in. The message and GetVersion now build the URL in one place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ing message The same message format as create rego-policy, so a user on a non-default --host can use the URL as it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review. Triage of the summary points (1 and 2 are answered on their threads):
|
A script reading stdout had no version number to read the version later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Publishing the files and input schema of the newest valid version answers with that version. The table output now says that nothing new was stored, and that --comment was not kept when one was given. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both StillPendingError types rebuilt the URL in Error() and carried a fallback branch that could not run. They now hold the URL itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The docHidden annotation still generates a page, with hidden: true; like evaluate policy, this command gets none until it is unhidden. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each call publishes a version, the first one included, which is what the server API and the help already call it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The version is already stored when the read fails, so the error now says which one, and --output json still prints it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…as dropped A new version keeps the comment it was sent with, so an answer with a different comment is an existing version, pending or not. The comment clause now appears only when the comment really was not kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The JSON output is built from the Version struct, not the server's body as sent, so it holds only the fields Version declares. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A 2xx without a version decoded to 0, and the command read versions/0 and reported whatever came back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implements the CLI side of kosli-dev/server#7079. The server side is merged (kosli-dev/server#7269, #7296, #7307, #7311, #7320).
A new command publishes a versioned Rego policy under an immutable identifier, then waits for the server to validate the new version.
kosli publish rego-policy pr-approved ./policies/pr-approved/ \ --input-schema trail \ --name "Pull request approved" \ --description "Every change reached main through an approved PR" \ --comment "Initial version"What it does
PUT /api/v2/rego-policies/{org}/{identifier}with the bundle, then pollsGET .../versions/{n}until the version leavespending(30 s by default).PATHis a file or a directory, collected by the samepolicyBundle()askosli evaluate policy --policy, so the same directory gives the same files and digest on both paths. The 100-file and 1 MiB caps are refused before sending.valid: printsrego policy 'pr-approved' version 1 is valid (sha256:...), exits 0.rejected: the policy is at fault; prints the kind and message from the evaluator, exits 1.failed: Kosli is at fault; says so and that publishing again retries, exits 1.valid, it is not polled, and the table output says that nothing new was stored (and that--commentwas not kept, when one was given).--input-schema(trail|trails) is required.--nameis needed on the first publish only.--output jsonalways prints the version: witherror.kindanderror.messagefor a rejected or failed one, and as pending when the wait expires; the exit code is unchanged.--dry-runis supported.Decisions worth a reviewer's attention
publish rego-policy, notcreate rego-policyas the issue's designed surface has it. Every call publishes a version, the first one included, which is what the server API ("Publish a version of a rego policy") and the help call it. It adds apublishverb; the CLI's othercreatecommands are create-or-update. The issue and the server docs still saycreate rego-policy.evaluate policy, while the endpoint is behindis-server-side-evaluation-enabled. Thepublishverb has no other subcommand, so it is hidden too. A lifecycle test pins this, including thatkosli docsgenerates no page; unhiding is theHiddenline plus that test.requests.Donow accepts 202 as well as 200 and 201, because the publish returns 202 Accepted. Only those three: every caller reads the body as the whole answer, which a 204, 206 or 207 is not. A side effect: the Bitbucketcase 202("still being indexed, please retry") can now run; before, a 202 was an error."",.and..are refused before sending. Before this,../other/xleft the org's route.DisableConflictRetry): the server re-runs a publish that loses a race itself, so a 409 is a refusal to report.--description ""does not clear a description. Every flag refuses an empty value, ashack/empty-flag-audit/docs/2026-08-13-empty-value-decision.mddecided.PATH. Decisions cite a published version, so its source must be on disk.internal/poll), shared with evaluations. Both packages use one options type,poll.Options, with their own defaults filled byOptions.Or.evaluatestill-pending message changes too: it now gives the full URL with the host, as the new command does, so a user on a non-default--hostcan use it as it is.Not in this PR
audit.py) fails onmainfor threesnapshot s3flags; not touched here. The new command is inspec.jsonandcoverage.json.Testing
internal/poll(6 tests),internal/regopolicies(23 tests), and the command suite (24 tests), all against stubbed servers, because the local test server cannot validate a version.make test_integrationpassed before the last 5 commits (second review fixes and the rename); those have offline tests only.make lint: 0 issues.is-server-side-evaluation-enabled.🤖 Generated with Claude Code