Skip to content

feat(Conformance): segment-aware rule-id prefixes for only and skip #367

Closed

Description

@thomasfosterau

Problem

Conformance.Options.only and Options.skip (added in #366, for #302) match a rule id by plain string prefix: id.startsWith(prefix). A prefix that is a complete rule id therefore also matches any rule whose id merely continues it, with no / in between. Today that happens once among the rule ids:

  • spec/status/create-location is a prefix of spec/status/create-location-matches-self.

So skip: ["spec/status/create-location"] (meant to leave out the SHOULD-level Location check) also leaves out create-location-matches-self, and only: ["spec/status/create-location"] runs both. A caller cannot name the first rule alone. Each future rule whose id extends an existing one adds another such collision silently.

The owner decided on #366 to keep plain prefixes there, matching only as it shipped, and to make both segment-aware in a follow-up (decision).

Proposal

Match a prefix by path segment, for both only and skip: a prefix matches a rule id when it equals the id, or when the id continues it with /. A prefix that already ends in / ("spec/links/") keeps matching every rule beneath it.

  • "spec/status/create-location" matches that rule alone.
  • "spec/content-negotiation" and "spec/content-negotiation/" both match the whole section.
  • "spec/content-neg" matches nothing.

This narrows what some existing prefixes select, so it is a behaviour change for a caller relying on a partial segment; the changeset should say so.

Done when

  • One shared matcher serves only and skip in src/Conformance.ts (selected), segment-aware as above, with the JSDoc on both options, the README and docs/conformance.md §1.5 updated.
  • A test pins that skip: ["spec/status/create-location"] leaves out that rule and keeps spec/status/create-location-matches-self (and the same for only).
  • The tests that rely on a partial-segment prefix are updated: in src/Conformance.test.ts, "leaves out the skipped rules from what only and tiers select" skips spec/content-negotiation/accept-weight, which today matches accept-weight-is-not-a-parameter and accept-weight-zero-refuses only as a partial segment, and "leaves out the skipped rule ids" uses spec/content-neg.
  • A changeset describes the narrower matching.

Generated by Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions