Skip to content

fix(contractspec): treat a new response enum value as additive - #5095

Merged
Quick104 merged 3 commits into
mainfrom
fix/contract-allow-response-enum-additions
Nov 22, 2026
Merged

Quick104 merged 3 commits into
mainfrom
fix/contract-allow-response-enum-additions

Conversation

@Quick104

@Quick104 Quick104 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

Other clients: Apple N/A (no client-visible change); Android N/A (no client-visible change); Roku N/A (no client-visible change)

The contract rules say a response enum may gain values after the 1.0 lock: AGENTS.md says "New functionality adds fields, enum values, or operations", and docs/architecture/api-contract.md says response enums are additive and clients keep an unknown fallback. The contract checker disagreed. oasdiff rates response-property-enum-value-added as an error, and Policy treats every error as breaking. Before the lock each new response enum value needs an approval entry; main carries 14 of them, all for this rule. Once contracts/api/v2/LOCKED exists, approvals no longer apply, so any PR that adds a response enum value would fail make verify-apiv2-contract with locked contract: ... response-property-enum-value-added, with no way through.

Approach

Diff now builds the oasdiff config with checker.WithSeverityLevels, lowering that one rule to INFO. The finding is still printed, but it is no longer breaking, before or after the lock. I dropped the pre-lock approval requirement for it on purpose: the rules call the change additive in both phases, and an approval that is required now and forbidden later only adds noise to the allowlist.

Request enums stay closed. oasdiff already rates request enum additions as INFO and keeps removals as errors, and this leaves both alone. Response oneOf/anyOf additions also stay breaking. The doc calls discriminated response variants additive, but the spec has no discriminators today, and lowering those rules would also open up non-discriminated unions.

Two changes stay blocked. They were caught before only because every addition was an error. A rename removes one response enum value and adds another, and oasdiff rates the removal alone as INFO, so Diff keeps an addition breaking when the same operation, property, and status also lose a value. A new tag value on one oneOf variant that a sibling already uses lets a response match both variants, so the spec lint now requires named variants to keep at least one shared, required enum tag disjoint. Every oneOf in the spec passes.

The 14 approval entries on main can no longer match a breaking change, so this removes them. api-contract.md now states the checker's behavior for response enum additions.

Validation

  • A new contract test adds a value to a response enum and expects the policy to pass with no approvals, both unlocked and locked. It also expects a request enum value removal and a response enum value rename to fail when locked. A lint test seeds two oneOf variants that share a kind value. It fails on main for the reported reason (unapproved before the lock, locked contract after) and passes on this branch. The rename and variant checks failed on the earlier heads of this PR and pass now.
  • Replaying fix(backup): keep settings the environment sets out of a selective restore #4667's openapi.json change with an empty allowlist and a LOCKED marker: main fails on all 14 enum additions; this branch prints them at info and passes.
  • go test ./internal/contractspec/, make verify-apiv2-contract BASE_REF=origin/main, and make lint-changed pass.

Evidence: https://evidence.siloserver.org/r/silo-server/contract-response-enum-additive/

Risks

An open PR that added an approval for response-property-enum-value-added will fail as a stale approval after this merges, and has to delete that entry. #4621 has 8 such entries. Such PRs already have to drop main's 14 when they rebase.

A rename is matched by operation, property, and response status. oasdiff doesn't name the media type in its findings, so a value removed from one media type and another added to the same property in a second media type would read as a rename and fail. That errs toward blocking, and no current response has enums in more than one media type.

The gate does not check that each native client decodes a response enum with an unknown fallback. That stays a client-side rule, as before.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

Council review

Ran as a follow-up run, with one member at high effort. The plan round was skipped because the fix is mechanical.

Rounds: 2, last reviewed da6630a

Member Round 1 Round 2
Sol (gpt-6.2-sol, high) 7/10 7/10

Fixed: a response enum rename passed the locked gate; a oneOf variant tag shared with a sibling passed; an optional enum could stand in for the variant tag (fixed after round 2, not re-reviewed). Answered: a cross-media-type rename match errs toward blocking (see Risks). Neither round posted on the PR; findings came back to the run.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code, oasdiff (via the repository's contract checker), silo-evidence
  • Model(s): claude-opus-5-5 (implementation and code-review verification), claude-sonnet-5-5 (cleanup finder, validation check), gpt-6.2-sol (background review)
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: medium-level code review (three finders, verified by the implementing agent). It tightened the test to name the request-side rule and corrected two doc comments on Change. The background review's two findings are fixed (see Council review). The simplify pass changed nothing. See Council review for the background review.

🤖 Generated with Claude Code

Note

Treat new response enum values as additive in contractspec diff and lint

  • Lowers oasdiff's response-property-enum-value-added rule to INFO severity in additiveRules, so a plain response enum addition no longer requires approval. In diff.go, additions are correlated with removals by operation, path, property, and status via the new enumPropertyKey helper; if the same response property also loses a value, the addition is reported at ERR severity (breaking).
  • Adds a lintVariantTags check in lint.go that reports oneOf schemas whose variants share values for every shared required enum tag. The former nullable-enum traversal is generalized into walkSchema, which visits properties, items, additionalProperties, and oneOf/anyOf/allOf branches.
  • Documents the additive policy in api-contract.md: response enum additions are additive, request enum removals stay breaking.
  • Behavioral Change: response enum additions now pass locked policy without approval; oneOf schemas lacking a disjoint required enum tag now produce a new lint finding. Renames (add+remove on the same property) remain breaking. Adds tests in diff_test.go and lint_test.go.

Macroscope summarized a4a5ccf.

The API contract rules say response enums gain values after the 1.0 lock
and clients keep an unknown fallback, but the oasdiff policy rated
response-property-enum-value-added as an error. Before the lock each such
addition needed an approval entry; once contracts/api/v2/LOCKED exists it
would fail with no override.

Lower that one rule to INFO so it is reported but never breaking. Request
enums stay closed: removing a request value is still breaking, and adding
one was already INFO. The 14 approvals for the rule on main can no longer
match a breaking change, so they go.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 45cd37e9-33df-4040-8a9a-feb814529e5d
Commits

Reviewing files that changed from the base of the PR and between 381d720 and a4a5ccf.

Files selected for processing: 6

  • contracts/api/v2/breaking-approvals.json
  • docs/architecture/api-contract.md
  • internal/contractspec/diff.go
  • internal/contractspec/diff_test.go
  • internal/contractspec/lint.go
  • internal/contractspec/lint_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 22, 2026
@silo-kody

silo-kody Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T02:24:01.630885Z a4a5ccf New commits
🔒 Security Review ✅ Completed 2026-11-22T02:26:15.035404Z a4a5ccf New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-triage silo-triage Bot added api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Nov 22, 2026
Lowering response enum additions to INFO let two changes through that
were caught before only because every addition was an error. A rename
removes one response enum value and adds another, and oasdiff rates the
removal INFO. A new tag value on one oneOf variant that a sibling already
uses makes a response match both.

Diff now keeps an addition breaking when the same operation, property,
and status also lose a value. The spec lint requires the named variants
of a oneOf to keep at least one shared enum tag disjoint.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-triage silo-triage Bot added size/L 200–499 added + deleted lines (all files); change volume, not priority. and removed size/M 50–199 added + deleted lines (all files); change volume, not priority. labels Nov 22, 2026
@silo-kody

silo-kody Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

Comment on lines +430 to +434
for _, value := range v.Properties[name].Enum {
if value != nil && seen[value] {
disjoint = false
}
seen[value] = true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug critical

Object-valued enum entries crash the contract lint

Valid object or array enum values become maps or slices in []any, causing a panic when used as seen keys and aborting contract verification. Compare enum values in a way that supports non-comparable types.

Prompt for LLM
File internal/contractspec/lint.go, lines 430-434:

Object-valued enum entries crash the contract lint

JSON Schema permits object and array enum values, but unmarshaling them into `[]any` produces maps and slices that panic when used as `seen` map keys. A valid contract containing such a shared enum in named variants therefore aborts the contract verification instead of producing lint results.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Comment thread internal/contractspec/lint.go Outdated
Comment on lines +414 to +418
var tags []string
for _, name := range sortedKeys(variants[0].Properties) {
shared := true
for _, v := range variants {
if p := v.Properties[name]; p == nil || len(p.Enum) == 0 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug high

Composed variants bypass the new tag collision check

Variants expressed through allOf or component aliases can hide tag collisions, allowing an ambiguous oneOf to pass the diff and lint gates. Resolve composed and referenced variant properties before checking tags.

Prompt for LLM
File internal/contractspec/lint.go, lines 414-418:

Composed variants bypass the new tag collision check

Named variants expressed through `allOf` or a component alias have no direct `Properties`, so the shared-tag search silently skips them. Adding a tag value already used by another variant can then pass the additive diff and lint gates while creating an ambiguous `oneOf`; resolve composed and referenced variant properties before checking tags.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Comment on lines +430 to +434
for _, value := range v.Properties[name].Enum {
if value != nil && seen[value] {
disjoint = false
}
seen[value] = true

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug high

Nullable tag collisions pass the variant disjointness check

Two nullable variants can both accept null, allowing an ambiguous oneOf to pass linting. Treat null as an ordinary enum value when checking disjointness.

Prompt for LLM
File internal/contractspec/lint.go, lines 430-434:

Nullable tag collisions pass the variant disjointness check

Two nullable variants can both accept a tag value of `null`, but the overlap is ignored and the lint accepts the ambiguous `oneOf`. Treat `null` as an ordinary enum value when checking disjointness.

Suggested code:

if seen[value] {
	 disjoint = false
}

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

Comment on lines +437 to +439
if disjoint {
return
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug high

Optional tags are treated as proof that variants are disjoint

An object omitting an optional tag can satisfy multiple variants even when their tag enums are disjoint. Require the distinguishing tag in every variant before treating its enum values as proof of disjointness.

Prompt for LLM
File internal/contractspec/lint.go, lines 437-439:

Optional tags are treated as proof that variants are disjoint

Disjoint enum values do not distinguish variants when the tag property is optional: an object omitting it can satisfy multiple branches, but the lint returns successfully. Require the distinguishing tag in every variant before treating its enum values as proof of disjointness.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

An optional enum that differs between variants can't tell a response
apart, since the response may omit it. The variant tag lint now considers
only enum members every variant requires.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 merged commit 8b09b14 into main Nov 22, 2026
15 of 17 checks passed
@Quick104
Quick104 deleted the fix/contract-allow-response-enum-additions branch November 22, 2026 03:26
Quick104 added a commit that referenced this pull request Nov 23, 2026
…tive

Main's contract check (#5095) classes a new response enum value as
additive, so the two approvals for the recommended row type match no
change and fail the check as stale.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish size/L 200–499 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant