feat: add promise check command for review-findings gate - #259
Conversation
kratix promise check --review-file <path> validates a review-findings YAML/JSON artifact and exits non-zero if any unresolved critical or high finding remains. Self-registers under a new `promise` parent command via init(), no changes to root.go. No new dependencies (cobra, yaml.v3 already present). Built and tested against infrastructure-discovery tooling that needed a hard pass/fail gate rather than a prose "review carefully" instruction before a generated Promise gets applied.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 960d310366
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| default: | ||
| dec := yaml.NewDecoder(bytes.NewReader(data)) | ||
| dec.KnownFields(true) | ||
| if err := dec.Decode(&findings); err != nil { |
There was a problem hiding this comment.
Reject additional YAML documents
When a review artifact contains multiple YAML documents—for example, a generator appends another findings list after ---—this single Decode reads only the first document. An unresolved critical/high finding in a later document is therefore silently ignored and the gate can exit successfully; decode once more and require io.EOF, or explicitly process every document.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@shano is it possible that the review findings YAML/JSON will contain multiple findings collections or is this a situation we should just decide not to support?
|
|
||
| var promiseCmd = &cobra.Command{ | ||
| Use: "promise", | ||
| Short: "Work with Kratix Promises", |
There was a problem hiding this comment.
| Short: "Work with Kratix Promises", | |
| Short: "Utilities to help build and maintain Kratix Promises", |
| Short: "Check promise review findings", | ||
| Long: "Validate a review-findings artifact and fail if unresolved critical or high findings remain.", | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return checkReviewFindings(reviewFile, cmd.ErrOrStderr()) |
There was a problem hiding this comment.
| return checkReviewFindings(reviewFile, cmd.ErrOrStderr()) | |
| cmd.SilenceUsage = true | |
| return checkReviewFindings(reviewFile, cmd.ErrOrStderr()) |
We should silence the usage message on error here, otherwise cobra will show the usage banner when a validation fails, as below:
$ kratix promise check --review-file review-findings.json
unresolved blocking review findings:
- [high] Pillar: Security: Production access controls have not been reviewed.
- [critical] Lifecycle ownership: No team is assigned to respond to production incidents.
Error: 2 unresolved critical/high review finding(s)
Usage: # <----- this shouldn't appear on validation errors
kratix promise check [flags]
Flags:
-h, --help help for check
--review-file string review findings YAML or JSON file (default "review-findings.yaml")
|
Superseded by the standalone |
Summary
kratix promise check --review-file <path>— validates a review-findings YAML/JSON artifact and exits non-zero if any unresolvedcriticalorhighfinding remains.promiseparent command via its owninit(), no changes toroot.go, no new dependencies (uses cobra + yaml.v3, both already present).Context
Built while developing an AI-assisted infrastructure-discovery tool that drafts Kratix Promises from existing cloud resources. The tool runs an adversarial review pass and writes findings to a
review-findings.yaml({severity, dimension, description, resolved}per finding), but a prose "review carefully before applying" instruction isn't a real gate. This command makes "review passed" a binary, scriptable fact instead of an LLM's self-report.Test plan
go build ./...— clean, no new depsgo test ./cmd/... -run TestCheckReviewFindings— all 8 cases pass (empty list, resolved high, unresolved medium allowed, YAML parsing, unresolved blocking finding fails, missing file, invalid severity, missing resolved field)