Skip to content

test(provider_contract): pin unknown-field rejection on every DTO - #7155

Merged
EffortlessSteven merged 1 commit into
mainfrom
cursor/provider-dto-unknown-fields-4aa8
Oct 8, 2026
Merged

EffortlessSteven merged 1 commit into
mainfrom
cursor/provider-dto-unknown-fields-4aa8

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Summary

Pin #[serde(deny_unknown_fields)] on every provider-contract DTO, not just the request. public_wire_round_trips_and_rejects_unknown_fields now deserializes a valid instance of each struct plus one extra field at that struct's JSON object and expects an unknown-field failure.

Closes #7148.

Swarm / Source Boundary

This PR targets EffortlessMetrics/ripr-swarm, the normal development trunk for
trusted same-repo ripr work. Confirm the change belongs here:

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge,
    dependency, or repo-ops development for ripr-swarm
  • repair or follow-up for a same-repo swarm PR
  • swarm-only CI, runner, routing, source-of-truth, or agent-operating
    surface
  • other swarm-scoped work:

Source-of-truth Links

Proposal: n/a
Spec: n/a (test-only pin of existing serde contract)
ADR: n/a
Plan item: n/a
Governing issue or accepted claim: #7148
Acceptance delta (one sentence): Temporarily removing deny_unknown_fields from any of the nine provider-contract DTOs makes public_wire_round_trips_and_rejects_unknown_fields fail; restoring it makes the suite pass.

Candidate Relationships

Candidate branch (GitHub PR head is authoritative after publication): cursor/provider-dto-unknown-fields-4aa8
Stack parent or prerequisite PR (if any): none
Proposed replacement of PR (if any; not yet accepted): none
Acceptance retained from a replaced candidate (if any): n/a
Accepted winner and losing candidate disposition (when decided): n/a

Scope

Test-only expansion of the existing public-wire unknown-field pin in crates/ripr/src/provider_contract/tests.rs. Production model.rs and validation logic are unchanged.

Scope Classification

This PR is scoped by:

  • One production behavior
  • One public contract
  • One architectural seam
  • Docs/spec/test-only evidence package
  • Other:

Production delta:

  • none. #[serde(deny_unknown_fields)] already exists on all nine DTOs.

Evidence/support delta:

  • reject_unknown_field_at_struct_level round-trips a valid instance, then inserts "unexpected": true at that struct's JSON object and requires deserialize failure whose message contains unknown field.
  • Covered structs (nine): receipt, capability set, capability descriptor, repository snapshot, subject, request, summary, evidence entry, diagnostic.

Single acceptance criterion:

  • Dropping deny_unknown_fields from any one of those structs fails the test; restoring it passes.

Non-goals:

Support-tier Impact

  • none
  • updates docs/status/SUPPORT_TIERS.md
  • changes a README, release, docs, CLI, JSON, editor, CI, or package claim

Claim/proof notes:

  • Pins existing wire rejection. Does not claim runtime mutation outcomes or that static evidence is adequate.

Policy Impact

  • none
  • doc artifacts
  • CI lane
  • package boundary
  • lint / Clippy
  • no-panic
  • file policy
  • generated artifact
  • dependency
  • process/network

Ledger or exception notes:

  • none

Proof

cargo test -p ripr --lib provider_contract
cargo xtask precommit

Result, failures, or skipped proof:

  • cargo test -p ripr --lib provider_contract: 23 passed, 0 failed, including public_wire_round_trips_and_rejects_unknown_fields.
  • Per-struct removal experiment on this candidate: temporarily dropping deny_unknown_fields from each of the nine DTOs in model.rs made that exact test fail (exit 101); restoring the attributes left a clean tree and the suite passed again.
  • cargo xtask precommit: exit 0 (fmt, no-panic, file-policy, architecture, public-api, output-contracts, and the rest of the precommit table).
  • Candidate SHA 6d0e395147f043a44214de142ad3f4ae36f486c8. Hosted required check Ripr Rust Small Result is the merge authority.

Claim Boundary

What may be claimed after this PR? What must not be claimed yet?

  • May claim: each deny_unknown_fields provider-contract DTO has a discriminator that fails if that attribute is dropped.
  • Must not claim: production validation changes, corpus unknown-field cases, MCP/LSP wire pins, or runtime mutation results.

Rollback

How can this PR be reverted safely?

  • Revert the test-only commit. No production behavior changes.

Spec-Test-Code Traceability

  • Spec: existing provider-contract serde attributes in crates/ripr/src/provider_contract/model.rs
  • Tests: crates/ripr/src/provider_contract/tests.rs::public_wire_round_trips_and_rejects_unknown_fields
  • Code: unchanged
  • Golden outputs: none
  • Metrics: none
  • ADR/learning: none

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.
  • Unknowns include stop reasons where applicable.

CI Economics

  • LEM impact: n/a (test-only, no CI routing change)
  • Workflows touched: none
  • Branch protection impact: none
  • Failure mode caught: n/a for CI architecture
  • Cheaper signal considered: n/a
  • Required lanes affected: ordinary PR matrix only
  • Advisory lanes affected: none
  • On-demand/release lanes affected: none
  • Labels that alter behavior: none
  • Artifact families affected: none
  • Rollback path: revert the test commit

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code.
  • No new panic, unwrap, expect, todo, or unimplemented in tests.
  • New non-Rust programming files are allowlisted with owner, surface, and reason.
  • New generated, dependency, process-spawn, or network surfaces are allowlisted with owner and reason.
  • Errors are reported with actionable context.
  • Public JSON/schema changes are documented.

Gates

Focused local proof named above. Hosted PR CI owns the required merge-gate matrix. precommit is shift-left, not CI-equivalent completeness.

Exact candidate SHA

6d0e395147f043a44214de142ad3f4ae36f486c8 on cursor/provider-dto-unknown-fields-4aa8 (base origin/main 2dd57018756c6c289da88b7824bb891e19fb5ccc).

Open in Web Open in Cursor 

Closes #7148. Probe each deny_unknown_fields provider-contract struct at
its own JSON object with one extra field so dropping the attribute fails.

Co-authored-by: Steven Zimmerman, CPA <EffortlessSteven@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: c887b2ef-4b8a-46cc-8498-63d63635438d
📥 Commits

Reviewing files that changed from the base of the PR and between 2dd5701 and 6d0e395.

📒 Files selected for processing (1)
  • crates/ripr/src/provider_contract/tests.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.


Summary by CodeRabbit

  • Tests
    • Expanded wire-format checks across receipts, capabilities, repository snapshots, requests, summaries, evidence, diagnostics, and related data.
    • These checks now verify that unexpected properties are specifically rejected as unknown fields, rather than treating any deserialization error as sufficient.

Walkthrough

The wire-format test now checks that eight provider contract structures reject an added unexpected property with an unknown-field error. A generic helper verifies round-tripping and reports unrelated errors separately.

Changes

Provider DTO checks

Layer / File(s) Summary
Unknown-field rejection checks
crates/ripr/src/provider_contract/tests.rs
A generic helper verifies round-tripping and checks for a specific unknown-field error. The wire-format test applies it to eight structures and adds a diagnostic fixture. It also checks that the capability set has a descriptor and the summary has an evidence entry.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 6d0e3

No merge-blocking issue is identified; merge after the required checks pass.

Architecture Summary

Architecture risk: 🟡 Medium · up to 6d0e3

The change affects 1 system.

Changed systems: crates

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — crates (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in crates/ripr/src/provider_contract/tests.rs: Added a generic test helper that verifies a value round-trips, serializes as an object without an existing unexpected property, and rejects an added property specifically with an unknown-field error. Other failures, including non-object serialization and unrelated deserialization errors, are returned as errors.
  • observed — Modified behavior in crates/ripr/src/provider_contract/tests.rs: Added a diagnostic fixture with a stale-snapshot code, message, and next action; source path and position are unset.
  • observed — Modified behavior in crates/ripr/src/provider_contract/tests.rs: The wire-format test now applies the helper to eight contract structures, returning errors if the capability set has no descriptor or the summary has no evidence entry. It replaces the request-only check, which treated any deserialization error as proof that an unknown field was rejected.

Reliability and maintainability

  • inferred — Risk-relevant change factors for crates: blast_radius_1; direct_dependents_1
🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (6 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR closes issue #7148, and the described nine-DTO unknown-field coverage directly matches the issue objective.
Out of Scope Changes check ✅ Passed The changes are limited to provider-contract test coverage. The summary and description report no production, validation, MCP, LSP, golden, corpus, CI, or release changes.
Linked Issues check ✅ Passed Issue #7148 requires a per-DTO unknown-field rejection pin for the provider-contract DTOs. The diff adds reject_unknown_field_at_struct_level, which round-trips each value, inserts unexpected at t…
Out of Scope Changes check ✅ Passed The diff is limited to crates/ripr/src/provider_contract/tests.rs. The helper and diagnostic fixture support the linked test objective. No unrelated production, validation, MCP, LSP, corpus, documen…
Title check ✅ Passed The title clearly identifies the test change: it expands unknown-field rejection coverage to every provider-contract DTO.
Description check ✅ Passed The description follows the required template and provides scope, acceptance criteria, proof results, claim boundaries, rollback steps, and traceability. It clearly states that the change is test-only…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

I’m a rabbit, testing fields with care,
An extra key appears from nowhere.
Eight DTOs meet the added sign,
Unknown-field errors draw the line.
I hop away; the checks are there.

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a helper function reject_unknown_field_at_struct_level to test that various DTO structs correctly reject unknown fields during deserialization. It also adds a diagnostic helper fixture and refactors the public_wire_round_trips_and_rejects_unknown_fields test to apply this validation across multiple structs, including receipts, capabilities, snapshots, requests, and diagnostics. There are no review comments, and I have no feedback to provide.

@github-actions github-actions Bot 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.

Confirmed findings

  • crates/ripr/src/provider_contract/tests.rs:40 — 'unexpected' is a brittle sentinel. If any DTO grows an 'unexpected' field the helper errors instead of skipping; pin to a high-collision UUID per struct (e.g. format!("__ripr_unknown__{label}")) so the test fails on collision only when the targeted struct actually has that field, and the message remains descriptive.
  • Helper hard-codes key 'unexpected' and silently returns Err if a DTO's valid fixture already has that field; no #[ignore] or fail-loud signal means future DTO additions can quietly lose the deny_unknown_fields pin.

Verification questions

  • Confirm helper's 'extra field failure' check only matches substring 'unknown field' in the error string; if a nested owner with deny_unknown_fields absorbs the key, the outer call still passes.
  • Confirm ripr sensor exited 2 in this packet; given this PR is a ripr test addition, the failure may be on this test or a pre-existing flake. PR body defers local proof to 'follow on this candidate'. Defer to hosted CI but flag for visibility.
  • Confirm helper uses message.contains("unknown field"); the prior test only checked Err vs Ok. New assertion is stricter but still allows any error message containing that substring - a regression that emits e.g. 'unknown field unexpected' from a nested owner (not the target DTO) would pass. For request(), the original code just checked Err(.).

Refuted

  • Helper could be fooled by a sibling DTO that owns deny_unknown_fields and silently absorb the extra unexpected field on the parent object; refuted because: serde_json::to_value(&valid) produces the JSON value for T; the helper mutates that top-level object and feeds it back to serde_json::from_value::<T>, so rejection necessarily comes from T's own deny_unknown_fields. Confirmed by reading the helper body and the Serialize/DeserializeOwned bound.
  • The 'unexpected' key collides with a legitimate DTO field, so the new test silently no-ops on at least one of the 9 DTOs.; refuted because: All 9 DTOs' model.rs field sets (referenced, not in diff) use distinct snake_case names; the helper's contains_key guard would trip if a collision existed and surface it as Err, not silent pass. Currently safe.
  • Test round-trip arm is a no-op and could mask a Serialize that doesn't match Deserialize, defeating the stated pin; refuted because: Helper calls serde_json::from_value::(encoded.clone()) before mutating; assert_eq! compares decoded to valid via PartialEq. If a DTO drops PartialEq impl, this won't compile — but all 9 DTOs are claimed structurally equal. Code visibly exercises both directions.

Evidence gaps

  • cargo-test is scheduled-late, not yet in receipts. Diff changes test logic in provider_contract; without red/green proof of the new 9-DTO path we cannot confirm the suite passes on this candidate SHA. Resolved once cargo-test receipt lands.
  • Cargo-test receipt is scheduled-late; ripr sensor failed exit 2 (also test-related), so the 'focused local proof' cited in PR body is not yet evidenced in this packet.
  • Model proof intent was rejected by deterministic validation.

Parked follow-ups

  • Helper's as_object_mut() precondition is asserted via Err return, but the 'unexpected' collision guard returns Err too - so a DTO whose valid fixture already contains a field literally named 'unexpected' becomes un-testable. None of the 9 current DTOs have such a field per the model.rs surface referenced, but the helper silently drops coverage if a future DTO adds one.

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 8, 2026 11:55

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

review-pr (author self-review, COMMENT)

GitHub cannot request-changes from the PR author. This is a substantive exact-head inspection, not approval.

reviewed_head_sha: 6d0e395147f043a44214de142ad3f4ae36f486c8
integration_basis: origin/main 2dd57018756c6c289da88b7824bb891e19fb5ccc
claim_boundary: test-only pin of deny_unknown_fields on the nine provider-contract DTOs in model.rs; Closes #7148
changed_surfaces_and_semantic_owners_inspected: crates/ripr/src/provider_contract/tests.rs (owner: provider_contract tests); production model.rs/validate.rs unchanged; no MCP/LSP/golden/corpus/xtask overlap
blocking_findings: none on source/oracle for this head
non_blocking_suggestions: corpus unknown-field cases remain optional and were not added; CodeRabbit docstring-coverage 80% is not a repo gate
refuted_or_stale_findings: droid 'unexpected sentinel silently drops coverage' — returning Err from this #[test] fails the test (fail-closed), matching the prior request-only probe's key; collision with a future field named unexpected would fail loudly, not skip. Nested-owner absorption was also refuted in that review: the helper mutates T's own JSON object and deserializes as T.
proof_and_ci_observed: local cargo test -p ripr --lib provider_contract (23 passed); per-struct deny_unknown_fields removal made public_wire_round_trips_and_rejects_unknown_fields fail for all nine DTOs; cargo xtask precommit exit 0. Hosted Ripr Rust Small Result not yet terminal at review time.
proof_or_review_missing: exact-head required check Ripr Rust Small Result (Draft->Ready just fired); advisory droid-review still queued
affected_currentness_dimensions: test stimulus, test oracle, candidate head identity
residual_assumptions_and_non_claims: does not change production serde attributes or validation; does not claim runtime mutation outcomes; optional provider-corpus unknown-field cases omitted
disposition: REVIEW_INCOMPLETE until Ripr Rust Small Result is terminal on this SHA; source/oracle inspection found no blocker

Inspected: complete 1-file diff; nine structs with #[serde(deny_unknown_fields)] in model.rs (descriptor, set, snapshot, subject, request, diagnostic, entry, summary, receipt); helper inserts the extra key at that struct's object so dropping one attribute fails only that case. Positive round-trip plus unknown field substring is a stricter oracle than the old request-only Err(_).

No merge until required hosted proof is current on this head.

@github-actions github-actions Bot 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.

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • ripr sensor failed exit 2 in this packet; PR body defers to hosted CI 'Ripr Rust Small Result' as merge authority. Local ripr receipt absent; flag for visibility but not gating per PR scope.

Verification questions

  • Confirm substring 'unknown field' check is tighter than prior Err vs Ok and could miss rejection messages that phrase it as 'unknown field unexpected' vs 'unexpected field'; serde-json phrasing is stable here.
  • Confirm source-route gap: ripr sensor exited 2 in this packet; helper is a ripr test addition so the failure may be on this test or a pre-existing flake.
  • Confirm ripr sensor exit 2 is most likely a self-incident on this PR's test addition; per-struct removal experiment in PR body is the authoritative local proof. Defer to hosted CI.

Refuted

  • Nested-owner absorption swallows the 'unexpected' key so the helper silently passes even when T lacks deny_unknown_fields; refuted because: Helper builds Value from serde_json::to_value(&valid) where valid: T, mutates the top-level object's own JSON, and deserializes back as T. The extra key is at T's object level, not inside a nested child's JSON object, so a nested child's deny_unknown_fields cannot absorb it before T sees it.
  • Helper silently drops coverage if a DTO already serializes an unexpected field; refuted because: Early-return Err(json_error(...)) makes the #[test] fail loudly rather than skip; per author self-review, future field collision fails the suite.

Parked follow-ups

  • 'unexpected' sentinel is brittle if any DTO ever gains a field of that name; helper errors fail-closed (returns Err) which fails the test, not silently skips.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

@EffortlessSteven

Copy link
Copy Markdown
Member Author

Classifying the follow-up droid review on 6d0e395147f043a44214de142ad3f4ae36f486c8:

The remaining “confirmed” item is the advisory packet’s ripr sensor exit 2. That is the review packet’s own sensor, not a failure of public_wire_round_trips_and_rejects_unknown_fields. Local proof on this SHA is cargo test -p ripr --lib provider_contract (23 passed) plus the per-struct deny_unknown_fields removal experiment. The PR does not add a production analyzer path, so there is no local ripr receipt to attach.

Earlier “silent Err / nested absorb” claims are already refuted in that review and in the author self-review: Err from this #[test] fails the suite, and the extra key is inserted on T’s own JSON object.

No source repair. Merge remains gated on Ripr Rust Small Result for this head.

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

REVIEW_READY — exact-head review of 6d0e39514 (test-only, gate green, 0 threads).

  • Coverage (complete): all 9 DTOs probed (receipt, capability set + descriptor, repository snapshot, subject, request, summary, evidence entry, diagnostic) — matches the 9 deny_unknown_fields attributes in model.rs one for one.
  • Mechanism (stronger than the old pin): the helper requires the failure message to contain "unknown field", pinning the deny-attribute mechanism rather than any deserialization failure; the no-preexisting-unexpected-key assertion prevents vacuous collision; round-trip first guards fixture validity; descriptor/entry extraction carries setup assertions against empty fixtures.
  • Level-correctness: the extra key goes at each struct's own JSON object with nested children serialized as-is, so each probe pins its own struct's attribute, not a nested owner's.
  • Liveness (proven by mutation): commenting out one attribute (model.rs:155) flips the test to FAIL; restored → green. The failure names the mechanism, not just the test.
  • Scope: single test file, no production change; zero promotion/demotion surface. The old request-only inline probe is subsumed (request is now one of the 9 helper calls).

@EffortlessSteven
EffortlessSteven merged commit df76bf9 into main Oct 8, 2026
46 of 47 checks passed
@EffortlessSteven
EffortlessSteven deleted the cursor/provider-dto-unknown-fields-4aa8 branch October 8, 2026 12:59
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.

Provider DTOs lack unknown-field rejection pins except request

2 participants