Skip to content

refactor(contract): unify schemas with shared $ref definitions#1109

Closed
nextlevelshit wants to merge 2 commits intomainfrom
994-partial-refactor-contract-schemas
Closed

refactor(contract): unify schemas with shared $ref definitions#1109
nextlevelshit wants to merge 2 commits intomainfrom
994-partial-refactor-contract-schemas

Conversation

@nextlevelshit
Copy link
Copy Markdown
Collaborator

Summary

  • Extract shared schema definitions (finding, issue-reference, pr-reference, severity) into _defs/ directory under .wave/contracts/
  • Refactor existing contract schemas to use $ref pointers to shared definitions, eliminating redundant inline definitions
  • Add JSON Schema $ref resolution support in the contract validation engine (internal/contract/jsonschema.go)
  • Add comprehensive chain tests validating that pipeline step outputs conform to downstream input schemas
  • Fix OpenCode adapter to properly handle schema validation edge cases

Related to #994

Changes

  • .wave/contracts/_defs/*.schema.json — New shared base schemas for findings, issue references, PR references, and severity enums
  • .wave/contracts/*.schema.json — Updated existing schemas to use $ref pointers instead of inline definitions
  • internal/contract/jsonschema.go — Added $ref resolution logic for local file references
  • internal/contract/jsonschema_refs_test.go — Tests for $ref resolution
  • internal/contract/chain_test.go — Cross-pipeline artifact chaining validation tests
  • internal/contract/input_validator.go — Minor validation improvements
  • internal/adapter/opencode.go — Adapter fix for schema handling
  • internal/defaults/pipelines/*.yaml — Pipeline config updates for contract references
  • internal/webui/ — Minor UI fixes (unrelated cleanup in same branch)

Test Plan

  • go test ./internal/contract/... — All contract tests pass including new chain and ref resolution tests
  • Schema validation confirms pipeline outputs chain correctly as inputs to downstream steps

…tions

Create shared _defs/ schemas for severity, finding, PR reference, and issue
reference types. Enhance jsonschema validator to preload _defs/ for cross-file
$ref resolution. Refactor 10 contract schemas to use $ref instead of inline
duplicates. Wire input-side schema_path validation into 4 key pipeline YAMLs.
Add unit tests for $ref resolution and chain integration tests for artifact
compatibility across pipeline steps.
…add missing chain tests

review-findings.schema.json and triage-verdict.schema.json gained minimum:1
and format:uri constraints via $ref to pr-reference that were not present in
the original schemas — a breaking change that could reject previously valid
artifacts. Reverted pr_number/pr_url to original inline definitions.

Added missing chain test coverage for pr-result, gh-pr-comment-result, and
research-report (allOf+$ref pattern) schemas.
@nextlevelshit
Copy link
Copy Markdown
Collaborator Author

Closing as superseded by #1110. The flat schema approach (no $ref pointers, self-contained schemas with vocab fixes and sync test) was accepted and smoke-tested. The _defs/ + $ref resolution path adds complexity that isn't needed now — if cross-schema $ref is wanted later, it can be reintroduced on top of the unified flat schemas.

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.

1 participant