Skip to content

Conversation

ddbeck
Copy link
Collaborator

@ddbeck ddbeck commented May 27, 2025

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
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
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
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
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
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
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
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
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
@captainbrosset
Copy link
Contributor

Now targeting the v3.0 branch (which was created from main a minute ago, so the conflicts here are the same as they were before).

@ddbeck
Copy link
Collaborator Author

ddbeck commented Aug 29, 2025

When I say partially split out, I mean Feature A still exists but it has been scoped down and now feature B and C are split out of Feature A.

I was writing some e2e tests for webstatus.dev and currently I don't see a way for Feature A to use both "#/definitions/FeatureData" and "#/definitions/FeatureSplitData"

@jcscottiii Good question! The main answer is: partial splits can't happen.

In some cases, we'll error correct a feature silently (e.g., if a few compat keys were assigned erroneously—that wouldn't impact the meaning of the name, description, mapping to caniuse, etc.—then we'll just move those keys to another feature)—we do this already. Otherwise, the feature will have to be fully split (i.e., the original ID is just a pointer to two or more others).

I've given some thoughts to more sophistication around partial splits, but it's something we'd have to consider in a v4.0.0 (along with a notion of aspects of a larger feature and/or composite features).

@jcscottiii
Copy link
Contributor

jcscottiii commented Aug 29, 2025

Sounds good to me!

Background: I was just thinking about adding a banner to the feature detail page on webstatus.dev to let users know that they could reference other features in the event the original feature's scope was downsized. But I couldn't see a way for the current schema to tell me that information directly.

In the meantime, if we really wanted this, we could potentially track the BCD keys for each feature. But that introduces its own challenges, such as determining whether a key's removal was an editorial correction or a true feature split.

Anyway, I'm completely okay leaving this for v4 once we have more usage of this.

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 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
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.

"required": ["name"],
"additionalProperties": false
},
"Release": {
Copy link
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 on lines +100 to +102
type FeatureRedirectData = { kind: Exclude<Kind, "feature"> } & Required<
Pick<QuicktypeMonolithicFeatureData, "redirect_target" | "redirect_targets">
>;
Copy link
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 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
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
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 <[email protected]>
Co-authored-by: Philip Jägenstedt <[email protected]>
Co-authored-by: Patrick Brosset <[email protected]>
Co-authored-by: szepeviktor <[email protected]>
Co-authored-by: LeoMcA <[email protected]>
Co-authored-by: foolip <[email protected]>
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) major version required This PR requires a minor version semver release (vX+1.0.0) 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