feat(scan): support JSON as alternative EvaluationLog output format - #816
Open
yvonnedevlinrh wants to merge 1 commit into
Open
feat(scan): support JSON as alternative EvaluationLog output format#816yvonnedevlinrh wants to merge 1 commit into
yvonnedevlinrh wants to merge 1 commit into
Conversation
Add --log-format yaml|json flag and COMPLYTIME_LOG_FORMAT env var to select the EvaluationLog serialization format. YAML remains the default. JSON output uses 2-space indentation with kebab-case field names matching the upstream go-gemara schema. Implementation: - EvalLogFormatEnvVar, EvalLogFormatYAML, EvalLogFormatJSON constants in internal/complytime/consts.go - Shadow structs in internal/output/evaluator.go gain json: tags alongside existing yaml: tags (kebab-case matching go-gemara) - Write(outDir, logFormat string) branches on format using json.MarshalIndent for the JSON path - scanOptions.logFormat field, flag registration with shell completion, env var override (flag precedence), and validateLogFormat() in cmd/complyctl/cli/scan.go - Tests for JSON output, field names, YAML default, format validation, and env var precedence Includes OpenSpec artifacts in openspec/changes/json-evallog/. Closes complytime#795 Assisted-by: OpenCode (claude-opus-4-6) Signed-off-by: Yvonne Devlin <ydevlin@redhat.com>
yvonnedevlinrh
force-pushed
the
opsx/json-evallog
branch
from
August 14, 2026 15:12
aa6ce01 to
65f2ffa
Compare
yvonnedevlinrh
requested review from
gxmiranda and
hbraswelrh
and removed request for
cdaniels255 and
marcusburghardt
August 14, 2026 15:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
--log-format yaml|jsonflag andCOMPLYTIME_LOG_FORMATenvironment variable tocomplyctl scan, allowing users to select JSON as an alternative EvaluationLog serialization format. YAML remains the default.Closes #795
Motivation
Automation pipelines that consume EvaluationLog output often require JSON for downstream tooling (jq, structured logging, API ingestion). Today, an extra YAML-to-JSON conversion step is needed. This change eliminates that step by producing JSON natively.
Changes
Constants (
internal/complytime/consts.go)EvalLogFormatEnvVar = "COMPLYTIME_LOG_FORMAT"— env var name constantEvalLogFormatYAML = "yaml"/EvalLogFormatJSON = "json"— named format constantsOutput Package (
internal/output/evaluator.go)serializableEvaluationLog,serializableControlEvaluation,serializableAssessmentLog) gainjson:struct tags alongside existingyaml:tags, using kebab-case keys matching upstream go-gemara (e.g.,json:"assessment-logs",json:"steps-executed")Write(outDir, logFormat string)— updated signature; branches onlogFormat:"json"usesjson.MarshalIndentwith 2-space indentation and.jsonextension; otherwise YAML path unchangedencoding/jsonandinternal/complytimeimportsCLI Integration (
cmd/complyctl/cli/scan.go)scanOptions.logFormatfield--log-formatflag (default"yaml") with help text referencing env var["yaml", "json"]COMPLYTIME_LOG_FORMATwhen flag not explicitly set (flag takes precedence)validateLogFormat()— case-sensitive validation rejecting anything other than"yaml"or"json"logFormatplumbed through:scanPolicy()→runScanAndReport()→processScanOutput()→writeScanReports()→eval.Write()Tests
internal/output/evaluator_test.go: 3 new tests — JSON output with structural round-trip validation, JSON kebab-case field names with negative PascalCase/camelCase assertions, YAML default behaviorcmd/complyctl/cli/cli_test.go: 7 new tests — validateLogFormat valid/invalid/constants, env var applied/precedence/invalid/emptyWrite()calls and 2processScanOutput()calls for new signaturesDocumentation
CHANGELOG.md— entry under### AddedAGENTS.md— json-evallog added to Recent ChangesOpenSpec Artifacts
openspec/changes/json-evallog/— proposal, design (5 decisions), spec (4 requirements, 11 scenarios), and tasksVerification
go test -race -coverprofile=coverage.out ./...— all passgolangci-lint run ./...— 0 issuesgo build -mod=vendor ./...— cleanUsage