Skip to content

Add move and split redirects to the schema - #3000

Merged
ddbeck merged 43 commits into
web-platform-dx:v3.0from
ddbeck:91-redirects
Sep 12, 2025
Merged

Add move and split redirects to the schema#3000
ddbeck merged 43 commits into
web-platform-dx:v3.0from
ddbeck:91-redirects

Conversation

@ddbeck

@ddbeck ddbeck commented May 27, 2025

Copy link
Copy Markdown
Collaborator

Towards #91 and the sequel to #2990.

Because this PR follows #2990, looking at the diff between them might be easier to look at. See: ddbeck/web-features@91-jsonschema-source-of-truth...ddbeck:web-features:91-redirects

This PR does the following:

  • Adds redirects to the JSON Schema
  • Generates (and embellishes) types for the new schema
  • Modifies our scripts to use the new types and support redirects
  • Demonstrates both types of redirects, by splitting single-color-gradients and moving numeric-seperators to numeric-separators (Fix typo in file name #2484)

@ddbeck ddbeck added schema Schema changes, proposals, and bugs major version required This PR requires a minor version semver release (vX+1.0.0) package:web-features feature evolution Issues/PRs for describing changing feature definitions over time (as opposed to support) labels May 27, 2025
@github-actions github-actions Bot added feature definition Creating or defining new features or groups of features. tools and infrastructure Project internal tooling, such as linters, GitHub Actions, or repo settings labels May 27, 2025
@ddbeck
ddbeck requested a review from foolip May 27, 2025 16:31
Comment thread index.ts Outdated
Comment thread features/webcodecs.yml
name: WebCodecs
description: The WebCodecs API provides low-level access to individual video frames and chunks of audio samples, for full control over the way media is processed.
spec: https://w3c.github.io/webcodecs/
caniuse: webcodecs

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we should split it, but the fact that this is in caniuse makes me think we should somehow keep webcodecs as well? With composite features or similar we could.

Do we have any other candidates for splitting where the existing entry is just wrong and has no value to preserve?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is a good point. One thing I haven't done is to write guidelines that say when to move or split a feature—I just put these in to demonstrate the fact that one could do it. I think it would actually be best to back out the YAML files from this PR before merging and land those changes separately, especially to make the release notes more informative.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Which is to say, once I've written the guidelines, webcodecs might not get a split at all.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Alright, making the actual changes separately sounds good!

We do need to make sure we have a real case for splitting however. If we can only come up with "composite" features that we might later want to merge back together, then I'm not sure we should remove the original feature. Do have features that were combined by mistake and should never be considered one?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, I'm not currently seeing a compulsory split, if we're assuming some future composite feature schema.

It's somewhat easier to find historic cases. #1089 is a case where, without a splitting schema, would produce either a) a breaking release (which is basically what we did, in the pre-1.0 era) or b) a useless composite feature that combines something interoperable and something that never will be. In the latter case, caniuse has a corresponding feature, but I don't think we should follow caniuse's lead there.

There are also cases we've already merged that look a little suspect, where we split something by moving keys, tweaking a description, and just kinda pretending we got it right in the first place (e.g., #2491, #2652). I don't wish to bank on always being on the right side of that line.

Which brings me to my last concern: split ought to be the reverse of merged. If we wish to be able to merge freely, then we'll need a safe undo. Otherwise, merges will have the feeling of a semver-major event for maintainers here, even if it doesn't bump the version number.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's use #2776 as the feature to demonstrating split. We'd split that into gradients (2 BCD keys) and conic-gradients (1 BCD key).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I switched to the single color stop feature as our demonstrator in 9b276f0

@ddbeck ddbeck added this to the web-features v3.0 milestone May 29, 2025
jcscottiii added a commit to GoogleChrome/webstatus.dev that referenced this pull request Aug 29, 2025
Currently, v3 cannot let us know if a feature has been partially split out.
This commit removes the split out info from the Regular Feature model.

See comment: web-platform-dx/web-features#3000 (comment)

This allows us to simplify this. We can revisit in v4.
github-merge-queue Bot pushed a commit to GoogleChrome/webstatus.dev that referenced this pull request Aug 30, 2025
* fix: Return correct feature evolution data for moved and split features

The primary changes are:
- The `GetMovedWebFeatureDetailsByOriginalFeatureKey` function has been fixed. It was previously returning the internal database ID of the new feature; it now correctly returns the human-readable feature key, as intended.
- The main feature query has been updated to join against a new `SplitWebFeatures` table. The `GET /v1/features` and `GET /v1/features/{feature_id}` endpoints now include an `evolution` object in the response. This object contains `split_off_info` which lists any features that have been split off from the primary feature.

To support this, the following changes were also made:
- The `openapi.yaml` specification has been updated to include the new `evolution` fields in the `Feature` schema.
- The fake data generation process in `util/cmd/load_fake_data` has been significantly enhanced to create more realistic test data for feature evolution, including scenarios for moved, fully split, and partially split features.
- End-to-end tests and snapshots have been updated to reflect the new data structures and the changes in the underlying test data.start

There needs to be some frontend changes. But that will come in a future PR.

* fix snapshots

* Remove split out info from Regular Feature model

Currently, v3 cannot let us know if a feature has been partially split out.
This commit removes the split out info from the Regular Feature model.

See comment: web-platform-dx/web-features#3000 (comment)

This allows us to simplify this. We can revisit in v4.

* update snapshots
Comment thread types.quicktype.ts
Comment on lines 61 to 69
/**
* A feature data entry
*
* A feature has permanently moved to exactly one other ID
*
* A feature has split into two or more other features
*/
export interface FeatureData {
/**

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Note for other reviewers: Quicktype combines the schema for ordinary features, moved features, and split features into one all-optional mega object type. This is a little useless, so types.ts cleans this up. See that file for further commentary.

Comment thread schemas/data.schema.json
"required": ["name"],
"additionalProperties": false
},
"Release": {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Note to other reviewers: I alphabetized these sort of on accident. This not real change for Release or SnapshotData. Please tell me if you'd rather that I revert this.

Comment thread types.ts
Comment on lines +100 to +102
type FeatureRedirectData = { kind: Exclude<Kind, "feature"> } & Required<
Pick<QuicktypeMonolithicFeatureData, "redirect_target" | "redirect_targets">
>;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Note to other reviewers: Here I define a helper type for any redirect feature (i.e., kind is not "feature" and it has redirect_target and redirect_targets). Then I use this to construct the more specific FeatureMovedData and FeatureSplitData types.

@ddbeck
ddbeck requested a review from foolip September 8, 2025 14:31
@ddbeck
ddbeck marked this pull request as ready for review September 8, 2025 14:31
Comment thread index.ts Outdated
Comment thread assertions.test.ts
Comment on lines +4 to +36
describe("assertValidReference()", function () {
it("throws if target ID is a move", function () {
assert.throws(() => {
assertValidFeatureReference("a", "some-moving-feature", {
"some-moving-feature": { kind: "moved" },
});
});
});

it("throws if target ID is a split", function () {
assert.throws(() => {
assertValidFeatureReference("a", "some-split-feature", {
"some-split-feature": { kind: "split" },
});
});
});

it("throws if target ID is not defined", function () {
assert.throws(() => {
assertValidFeatureReference(
"a",
"this-is-a-completely-invalid-feature",
{},
);
});
});

it("does not throw if target ID is a feature", function () {
assert.doesNotThrow(() => {
assertValidFeatureReference("a", "dom", { dom: { kind: "feature" } });
});
});
});

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@foolip there are now tests for asserting feature references (and a little refactoring to make this easier to do for other things, like snapshots, later), for your consideration.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I consider this excellent!

@ddbeck
ddbeck merged commit 0d40182 into web-platform-dx:v3.0 Sep 12, 2025
3 checks passed
@ddbeck
ddbeck deleted the 91-redirects branch September 12, 2025 10:48
@ddbeck ddbeck mentioned this pull request Sep 12, 2025
ddbeck added a commit that referenced this pull request Sep 17, 2025
* Demonstrate JSON Schema as source of truth for web-features data (#2990)
* Add move and split redirects to the schema (#3000)
* Add guidelines for moving and splitting features (#3180)
* Add consumer docs for moved and split features (#3181)
* Change schema `string | string[]` properties to `string[]` (#3184)
* Fix missing `group` and `snapshot` keys from convenience types

Co-authored-by: James C Scott III <7788930+jcscottiii@users.noreply.github.com>
Co-authored-by: Philip Jägenstedt <philip@foolip.org>
Co-authored-by: Patrick Brosset <patrickbrosset@gmail.com>
Co-authored-by: szepeviktor <952007+szepeviktor@users.noreply.github.com>
Co-authored-by: LeoMcA <755354+LeoMcA@users.noreply.github.com>
Co-authored-by: foolip <498917+foolip@users.noreply.github.com>
@ddbeck ddbeck removed the major version required This PR requires a minor version semver release (vX+1.0.0) label Sep 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature definition Creating or defining new features or groups of features. feature evolution Issues/PRs for describing changing feature definitions over time (as opposed to support) package:web-features schema Schema changes, proposals, and bugs tools and infrastructure Project internal tooling, such as linters, GitHub Actions, or repo settings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants