Skip to content

feat: add promise check command for review-findings gate - #259

Closed
shano wants to merge 1 commit into
mainfrom
promise-review-check-gate
Closed

feat: add promise check command for review-findings gate#259
shano wants to merge 1 commit into
mainfrom
promise-review-check-gate

Conversation

@shano

@shano shano commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds 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-contained: registers a new promise parent command via its own init(), no changes to root.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 deps
  • go 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)

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.
@jeduardo

Copy link
Copy Markdown
Contributor

@codex review

Comment thread cmd/promise_check.go

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread cmd/promise_check.go
default:
dec := yaml.NewDecoder(bytes.NewReader(data))
dec.KnownFields(true)
if err := dec.Decode(&findings); err != nil {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Comment thread cmd/promise_check.go
Comment thread cmd/promise_check.go

var promiseCmd = &cobra.Command{
Use: "promise",
Short: "Work with Kratix Promises",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Short: "Work with Kratix Promises",
Short: "Utilities to help build and maintain Kratix Promises",

Comment thread cmd/promise_check.go
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())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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")

@shano

shano commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by the standalone kratix-review CLI plugin: https://github.com/syntasso/enterprise-kratix/pull/1356. The review-findings gate now lives there instead of kratix-cli core; #260 has been retargeted to main and stripped of the review-findings-specific code, leaving it as a standalone structural promise check command.

@shano shano closed this Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants