Skip to content

fix: add missing required Gemara schema fields to policy fixtures#707

Merged
sonupreetam merged 1 commit into
complytime:mainfrom
yvonnedevlinrh:fix/696-gemara-schema-fields
Jul 9, 2026
Merged

fix: add missing required Gemara schema fields to policy fixtures#707
sonupreetam merged 1 commit into
complytime:mainfrom
yvonnedevlinrh:fix/696-gemara-schema-fields

Conversation

@yvonnedevlinrh

@yvonnedevlinrh yvonnedevlinrh commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Add required fields per the upstream Gemara CUE schema to mock-oci-registry policy YAML fixtures and inline test YAML in resolver_test.go. These files would fail cue vet -c -d '#Policy' validation. They work at runtime because Go's YAML unmarshalling silently uses zero values for missing fields.

This is the same class of fix applied in PR #695 for acceptance test data.

Changes

Policy YAML fixtures (cmd/mock-oci-registry/testdata/)

Three files updated:

  • test-branch-protection-policy.yaml
  • ampel-branch-protection-policy.yaml
  • test-opa-policy.yaml

Metadata blocks gained:

  • type: Policy — required by #Metadata.type
  • gemara-version: 1.0.0 — required by #Metadata."gemara-version" (consistent with sibling catalogs and governance artifacts)

Evaluation-methods entries (both top-level and within assessment-plans) gained:

  • id: <evaluator>-eval — required by #AcceptedMethod.id
  • mode: Automated — required by #AcceptedMethod.mode

Inline test YAML (internal/policy/resolver_test.go)

Six inline YAML policy fixtures updated with the same fields:

  • TestResolvePolicyGraph_AllThreeLayers (line 114)
  • TestResolvePolicyGraph_MissingOptionalLayers (line 163)
  • TestParsePolicyLayer_MissingAssessmentPlans (line 209, metadata only)
  • TestParsePolicyLayer_SingleAssessmentPlan (line 234)
  • TestParsePolicyLayer_MultiEvaluator (line 271)
  • validPolicyYAML() shared helper (line 698, used by 7+ tests)

Reference

rh-workstation-audit-policy.yaml is already fully compliant and served as the target state model.

Verification

# All unit tests pass
make test-unit

# Validate each policy file against the Gemara CUE schema
cue vet -c -d '#Policy' github.com/gemaraproj/gemara@v1.3.0 \
  cmd/mock-oci-registry/testdata/test-branch-protection-policy.yaml

cue vet -c -d '#Policy' github.com/gemaraproj/gemara@v1.3.0 \
  cmd/mock-oci-registry/testdata/ampel-branch-protection-policy.yaml

cue vet -c -d '#Policy' github.com/gemaraproj/gemara@v1.3.0 \
  cmd/mock-oci-registry/testdata/test-opa-policy.yaml

Related Issues

Closes #696

Add required fields per the upstream Gemara CUE schema to mock-oci-registry
policy YAML fixtures and inline test YAML in resolver_test.go.

Metadata blocks gain:
  - type: Policy
  - gemara-version: 1.0.0

Evaluation-methods entries gain:
  - id: <evaluator>-eval
  - mode: Automated

These fields are required by the Gemara CUE schema (#Metadata.type,
#Metadata."gemara-version", #AcceptedMethod.id, #AcceptedMethod.mode)
but were silently zero-valued by Go's YAML unmarshaller at runtime.

The reference fixture rh-workstation-audit-policy.yaml was already
compliant and served as the target state model.

Closes complytime#696

Assisted-by: OpenCode (claude-opus-4-6)
Signed-off-by: Yvonne Devlin <ydevlin@redhat.com>

@sonupreetam sonupreetam left a comment

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.

LGTM

@sonupreetam sonupreetam enabled auto-merge (squash) July 9, 2026 14:08

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

Clean, well-scoped fixture fix that aligns test data with the upstream Gemara CUE schema. All 4 required fields (type, gemara-version, id, mode) added consistently across 3 YAML fixtures and 6 inline test YAML blocks. Scope matches issue #696 exactly. All CI checks pass.

This review was generated by /review-pr (AI-assisted).

@sonupreetam sonupreetam merged commit f61e943 into complytime:main Jul 9, 2026
28 checks passed
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.

fix: add missing required Gemara schema fields to mock-oci-registry policy fixtures

3 participants