Repository navigation
feat(Conformance): derive declared cardinality for links-only relationships - #418
Merged
Merged
Conversation
…nships (#390) Discovery records the cardinality each relationship endpoint's success schema declares; relationship-self-dereferences holds a links-only relationship's `self` link to the cardinality of the declared relationship endpoint it resolves to, naming that endpoint in the finding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ZgiUeCy5QxSz5oQt2gT1H
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
Closes #390.
spec/links/relationship-self-dereferencesnow checks a links-only relationship'sselflink against the cardinality the api declares for it. Until now it took either cardinality.src/internal/conformance/core.ts):Discovered.linkage(new typeCardinality, moved fromlinks.ts) holds, for eachrelationship-role endpoint, what its success schema's encodeddatadeclares:"one": an identifier object ornull."many": an array."unshown": a schema it cannot read (Schema.Unknown, nodata, a union whose members disagree), and every other role.src/internal/conformance/links.ts): when the relationship object has nodata,relationshipSelfLinksresolves theselflink and drops the base URL from its path. If that path fills a declared relationship endpoint's path (each literal matching exactly,:parammatching any segment), the claim takes that endpoint's cardinality. It falls back to"unshown"(either kind passes) when:articles.commentsRelationship(GET /articles/:id/relationships/comments) declares", andexpectedsays the endpoint's success schema declares the cardinality. Findings based on linkage the relationship shows read word for word as before.relationship-self-matches-linkage) is unchanged.docs/conformance.md: the §3 rule table row, the fallback sentence, the examples paragraph and the test inventory are updated.Verification
Run in order in the worktree, after rebasing onto
origin/trunk(which includes the vite-plus 1.3 / tsgo 0.55 bump):pnpm install --frozen-lockfile: passvp run build: passvp check: pass (0 errors; the warning count is the same as trunk's, 4325)vp run check: pass ("every type gate green")vp run -r test:unit: pass. In the full run on a loaded machine, 2–3test/entry-points.test.tscases timed out (they walkdist/). Run alone, that file passes 25/25, and the blog, github and northwind example suites pass when run separately.vp run docgen: passfallow audit --base origin/trunk: pass ("No issues in 6 changed files")Changeset
.changeset/links-only-cardinality.md, minor: the rule now fails servers it used to pass (a paginated to-many relationship whose relationship endpoint answers one identifier).Notes
src/Conformance.test.ts, one new case:comments(to-many) answering an array and a links-onlyauthor(to-one) answering one identifier pass.detailandexpectedpinned.authordeclared,commentstakes either kind.Schema.Unknownrelationship endpoints take either kind.src/internal/conformance/core.test.ts: a newdescribeat the end of the file pins the cardinality discovery reads forone,optional,manyandpaginated, and for aSchema.Unknownordata-less success.data. Linkage the relationship shows still wins, as the issue specifies.roleOfdoes not classify asrelationship(anything other thanGET /<type>/:id/relationships/<name>) is not consulted.core.tsleavesidempotencyKeyOfand theidempotencyKeyfield alone.Generated by Claude Code