Skip to content

Add RFC for component metadata. #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jan 22, 2024

Conversation

jfng
Copy link
Member

@jfng jfng commented Nov 17, 2023

@whitequark whitequark added the meta:nominated Nominated for discussion on the next relevant meeting label Nov 20, 2023
jfng added a commit to jfng/amaranth-rfcs that referenced this pull request Nov 24, 2023
…eeting.

- clarify how Signature subclasses can have multiple annotations.
- add a naming policy for annotations.
- rename lib.annotation to lib.meta.
- remove mention that ComponentMetadata inherits from Annotation.
- expand drawbacks and rationale sections.
- move support for clock and reset signals to a later RFC.
@jfng
Copy link
Member Author

jfng commented Nov 24, 2023

Modified as a follow-up to the 2023-11-20 Amaranth meeting.

jfng added a commit to jfng/amaranth-rfcs that referenced this pull request Nov 24, 2023
…eeting.

- clarify how Signature subclasses can have multiple annotations.
- add a naming policy for annotations.
- rename lib.annotation to lib.meta.
- remove mention that ComponentMetadata inherits from Annotation.
- expand drawbacks and rationale sections.
- move support for clock and reset signals to a later RFC.
@jfng jfng force-pushed the component-metadata branch from 844c121 to 20f369c Compare November 24, 2023 17:40
jfng added a commit to jfng/amaranth-rfcs that referenced this pull request Nov 24, 2023
…eeting.

- clarify how Signature subclasses can have multiple annotations.
- add a naming policy for annotations.
- rename lib.annotation to lib.meta.
- remove mention that ComponentMetadata inherits from Annotation.
- expand drawbacks and rationale sections.
- move support for clock and reset signals to a later RFC.
@jfng jfng force-pushed the component-metadata branch from 20f369c to 0ac0260 Compare November 24, 2023 17:53
@whitequark
Copy link
Member

I propose changing:

Annotation names must be prefixed by a reversed second-level domain name

to:

Annotation names must be prefixed by a reversed domain name

@whitequark
Copy link
Member

I propose changing:

To ensure this, schema URLs must have the following structure: <protocol>://<domain>/schema/<version>/<path>. The version of an annotation schema should match the Python package that implements it.

to:

To ensure this, schema URLs must have the following structure: <protocol>://<domain>/schema/<path>/<version>.json. The version of an annotation schema should match the Python package that implements it.

For these reasons:

  1. Even within the amaranth-lang organization, we do not have synchronized versioning, and it is weird to have version as the first item.
  2. Ideally the schema should be served with the correct MIME type, and adding .json at the end makes things simpler for the case where the web server is provided by a third party (e.g. GitHub pages).

jfng added a commit to jfng/amaranth-rfcs that referenced this pull request Nov 27, 2023
* Remove restriction to second-level domains to allow providers such as
  Github Pages.
* Move the schema version at the end of its URL, as project versions
  may not necessarily be synchronized within an organization.
* Add a .json suffix to schema URLs, to help servers report the correct
  MIME type.
@jfng
Copy link
Member Author

jfng commented Nov 27, 2023

Updated with @whitequark's proposed changes for URLs.

jfng added a commit to jfng/amaranth-rfcs that referenced this pull request Nov 27, 2023
@whitequark
Copy link
Member

The start date is the date of the merge.

@whitequark
Copy link
Member

We have discussed this RFC on the 2023-11-27 weekly meeting. We did not reach unanimous consensus as two reviewees (galibert and Chips4Makers) abstained, without objecting to merging.

This isn't a situation we had before so for now the RFC is not actually merged while we figure out what to do next.

On the text of the RFC:

@whitequark commented that reset values must be strings to avoid exhausting numeric precision in JSON parsers.

@zyp commented that it is unclear why reset values should be represented in two's complement, and that they could be just as well represented in signed decimal, which could be easier to parse.

@whitequark whitequark removed the meta:nominated Nominated for discussion on the next relevant meeting label Nov 27, 2023
@jfng
Copy link
Member Author

jfng commented Nov 28, 2023

I propose changing:

To ensure this, schema URLs must have the following structure: <protocol>://<domain>/schema/<version>/<path>. The version of an annotation schema should match the Python package that implements it.

to:

To ensure this, schema URLs must have the following structure: <protocol>://<domain>/schema/<path>/<version>.json. The version of an annotation schema should match the Python package that implements it.

Would it make sense to enforce package names in schema URLs? The format could become: <protocol>://<domain>/schema/<package>/<version>/<path>.json.

I think this would give better names to files served at those URLs (e.g. "component.json" instead of "4.0.json").

@whitequark
Copy link
Member

How would you determine the package name?

@jfng
Copy link
Member Author

jfng commented Nov 28, 2023

The validator would assume that the string between "/schema/" and the next "/" is the package name. I don't think we need to check that it is actually one, though.

@whitequark
Copy link
Member

Would the package name for something in amaranth.lib.foo be amaranth, amaranth.lib.foo, something else?

@jfng
Copy link
Member Author

jfng commented Nov 28, 2023

Would the package name for something in amaranth.lib.foo be amaranth, amaranth.lib.foo, something else?

It would be amaranth. lib.foo may appear in the rest of the path, if needed. We wouldn't force symmetry between Python module names and URL paths.

@whitequark
Copy link
Member

Sounds reasonable to me.

@whitequark whitequark added the area:core RFC affecting APIs in amaranth-lang/amaranth label Dec 11, 2023
@whitequark whitequark added the meta:nominated Nominated for discussion on the next relevant meeting label Jan 5, 2024
@stafverhaegen-chipflow
Copy link

In previous IRC discussion I abstained when voting on this RFC. Had today a quick chat with @whitequark on this.
My main worry was about bloat of the metadata and abuse of the data to for example trying to describe scripting things like loops etc. in a data serialization format.
I think these worries are not valid for schema that go through the Amaranth RFC process as these aspects are taken into account during that process. I think it should then be made clear in the RFC and/or documentation that standardized metadata schemas are living under the https://amaranth-lang.org URL and that the RFC process is to be used to propose new Amaranth metadata schemas under this URL.

@anuejn
Copy link

anuejn commented Jan 15, 2024

I also had a couple of questions regarding the schema-urls and asked them on IRC today.
The result of the discussion was, that it would be nice to add an option to the amaranth-cli to also output the schema when building a netlist and a metadata.json when that part is developed.

in @whitequark's words:

we could have an option outputting the schema as well. eg design.v + design.v.json + design.v.json-schema
the .json-schema would be a mapping from URIs to schemas, as a JSON file

jfng added 4 commits January 15, 2024 17:28
…eeting.

- clarify how Signature subclasses can have multiple annotations.
- add a naming policy for annotations.
- rename lib.annotation to lib.meta.
- remove mention that ComponentMetadata inherits from Annotation.
- expand drawbacks and rationale sections.
- move support for clock and reset signals to a later RFC.
* Remove restriction to second-level domains to allow providers such as
  Github Pages.
* Move the schema version at the end of its URL, as project versions
  may not necessarily be synchronized within an organization.
* Add a .json suffix to schema URLs, to help servers report the correct
  MIME type.
@jfng jfng force-pushed the component-metadata branch from d1bd056 to 44d8603 Compare January 15, 2024 16:29
@jfng
Copy link
Member Author

jfng commented Jan 15, 2024

Updated to add:

@jfng
Copy link
Member Author

jfng commented Jan 16, 2024

This RFC was discussed during the 2024-01-15 meeting:

(@wanda-phi) The constraint for $id URLs would require users of Github Pages to have a repository named "schema", because their URLs are formatted as "https://<username>.github.io/<repo>". This is overly restrictive.

(@whitequark) Annotation names should be removed in favor of just using $id URLs:

  • $id can uniquely identify an annotation schema;
  • not having to retrieve the name of an annotation from $id removes the need for constraining the latter and solves the issue with Github Pages (and similar hosting providers).
  • "com.example.foo.serial" isn't much more readable than "https://example.com/schema/foo/0.1/serial.json", and cannot disambiguate between versions of a schema;

(@whitequark) Annotations can originate from mutable objects (such as a SoC memory map) which would be attached to interfaces rather than signatures, which are immutable. To collect annotations from a Component, the Signature.annotations property should be replaced by a Signature.annotations(self, interface) method that returns an iterable of a Annotation instances specific to interface.

jfng added 2 commits January 16, 2024 13:17
…e objects.

In some cases such as SoC memory maps, the contents of an annotation
originates from mutable objects, which cannot be attached to a
signature.
@jfng
Copy link
Member Author

jfng commented Jan 16, 2024

This RFC was discussed during the 2024-01-15 meeting:

(@wanda-phi) The constraint for $id URLs would require users of Github Pages to have a repository named "schema", because their URLs are formatted as "https://<username>.github.io/<repo>". This is overly restrictive.

(@whitequark) Annotation names should be removed in favor of just using $id URLs:

  • $id can uniquely identify an annotation schema;

  • not having to retrieve the name of an annotation from $id removes the need for constraining the latter and solves the issue with Github Pages (and similar hosting providers).

  • "com.example.foo.serial" isn't much more readable than "https://example.com/schema/foo/0.1/serial.json", and cannot disambiguate between versions of a schema;

(@whitequark) Annotations can originate from mutable objects (such as a SoC memory map) which would be attached to interfaces rather than signatures, which are immutable. To collect annotations from a Component, the Signature.annotations property should be replaced by a Signature.annotations(self, interface) method that returns an iterable of a Annotation instances specific to interface.

Updated to address these issues.

@whitequark
Copy link
Member

We have discussed this RFC on the 2024-01-22 weekly meeting. The disposition was to merge, without changes.

@jfng Please create a tracking issue for this RFC in the amaranth-lang/amaranth repo, add it to RFC text, and set starting date to today. I will hit merge then. Thank you for this work!

@whitequark whitequark removed the meta:nominated Nominated for discussion on the next relevant meeting label Jan 22, 2024
@jfng
Copy link
Member Author

jfng commented Jan 22, 2024

Done.

@whitequark whitequark merged commit e019bdb into amaranth-lang:main Jan 22, 2024
@whitequark
Copy link
Member

Thanks!

@jfng jfng deleted the component-metadata branch January 22, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core RFC affecting APIs in amaranth-lang/amaranth
Development

Successfully merging this pull request may close these issues.

4 participants