Skip to content

Commit 0a91961

Browse files
committed
feat: use core. prefixes for generator metadata keys (#2371)
1 parent 5627050 commit 0a91961

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

hugr-core/src/envelope.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ use crate::import::ImportError;
6565
use crate::{Extension, import::import_package};
6666

6767
/// Key used to store the name of the generator that produced the envelope.
68-
pub const GENERATOR_KEY: &str = "__generator";
68+
pub const GENERATOR_KEY: &str = "core.generator";
69+
/// Key used to store the list of used extensions in the metadata of a HUGR.
70+
pub const USED_EXTENSIONS_KEY: &str = "core.used_extensions";
6971

7072
/// Get the name of the generator from the metadata of the HUGR modules.
7173
/// If multiple modules have different generators, a comma-separated list is returned in
@@ -449,9 +451,6 @@ fn encode_model<'h>(
449451
Ok(())
450452
}
451453

452-
/// Key used to store the list of used extensions in the metadata of a HUGR.
453-
pub const USED_EXTENSIONS_KEY: &str = "__used_extensions";
454-
455454
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
456455
struct UsedExtension {
457456
name: String,

specification/hugr.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -778,23 +778,26 @@ existing metadata, given the node ID.
778778
`Ports` (for port metadata) or `History` (for use by the rewrite
779779
engine)?
780780

781+
Reserved metadata keys used by the HUGR tooling are prefixed with `core.`.
782+
Use of this prefix by external tooling may cause issues.
783+
781784
#### Generator Metadata
782785
Tooling generating HUGR can specify some reserved metadata keys to be used for debugging
783786
purposes.
784787

785-
The key `__generator` when used on the module root node is
788+
The key `core.generator` when used on the module root node is
786789
used to specify the tooling used to generate the module.
787790
The associated value must be an object/dictionary containing the fields `name`
788791
and `version`, each with string values. Extra fields may be used to include
789792
additional data about generating tooling that may be useful for debugging. Example:
790793

791794
```json
792795
{
793-
"__generator": { "name": "my_compiler", "version": "1.0.0" }
796+
"core.generator": { "name": "my_compiler", "version": "1.0.0" }
794797
}
795798
```
796799

797-
The key `__used_extensions` when used on the module root node is
800+
The key `core.used_extensions` when used on the module root node is
798801
used to specify the names and versions of all the extensions used in the module.
799802
Some of these may correspond to extensions packaged with the module, but they
800803
may also be extensions the consuming tooling has pre-loaded. They can be used by the
@@ -803,7 +806,7 @@ must be an array of objects/dictionaries containing the keys `name` and `version
803806
with string values. Example:
804807
```json
805808
{
806-
"__used_extensions": [{ "name": "my_ext", "version": "2.2.3" }]
809+
"core.used_extensions": [{ "name": "my_ext", "version": "2.2.3" }]
807810
}
808811
```
809812

0 commit comments

Comments
 (0)