1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//! Pieces shared by Card and Eval: producer, attachments, relations, `ext`.
//!
//! # Producer
//!
//! `producer { name, version }` identifies the software that wrote the
//! record. It is informational and is not a facet: two harnesses can produce
//! comparable records, and one harness can produce incomparable ones.
//!
//! # Attachments
//!
//! ```text
//! attachments[] { path, sha256, size, media_type }
//! ```
//!
//! An attachment is a file in object storage, addressed by its sha256. The
//! record refers to it by `path`, a relative, `..`-free, unique-within-record
//! name that other fields (`results[].samples_ref`, `runs[].calls`,
//! `runs[].artifacts[]`) point at. The hub checks that referenced paths
//! exist in `attachments[]` and that every `sha256` has been uploaded and
//! confirmed (see `evalhub_store::objects`); it does not open the file.
//! `media_type` is a hint for display and download, nothing more.
//!
//! Content addressing means two records attaching the same file share one
//! object, and a record cannot be published against an object that does not
//! exist. It also means the record commits to the exact bytes: a different
//! file is a different sha256 and therefore a different record.
//!
//! # Relations
//!
//! ```text
//! relations[] { type, to, attrs }
//! ```
//!
//! `type` is a registry id (`core/uses_eval`, `core/retry_of`, …). `to` is a
//! pinned reference, `{ns}/{name}@{seq}`, which the hub resolves to a
//! `version_id` on ingest; an unresolvable reference is accepted and simply
//! does not earn the `refs_resolved` badge. Targets outside the hub are
//! written `external:https://…` or `hf:org/repo@sha` and stored with no
//! `version_id`. `attrs` is free-form per relation type (for `uses_eval`,
//! which runs of the Eval this Card used).
//!
//! Relations are edges between *versions*. Publishing a new version of a
//! Card does not move its edges; a reader who wants "the latest Card that
//! used this Eval" asks the API with `follow_latest=true`.
//!
//! # `ext`
//!
//! The one open door. `ext` is a map from namespace (`{ns}/{name}`) to an
//! arbitrary JSON object. Namespacing is mandatory so that two producers'
//! extensions cannot collide, and so that a namespace can later register an
//! `ext_schema` to make its keys typed and indexable. Until it does, `ext`
//! values can be searched with `eq` and `exists` only.
use BTreeMap;
use JsonSchema;
use ;
/// Producer-private extensions, keyed by namespace (`{ns}/{name}`). Each value
/// is an arbitrary JSON object owned by that namespace.
pub type Ext = ;
/// Free-form attributes carried by a relation, keyed by attribute name.
pub type Attrs = Map;
/// True when an extension map is empty; used to omit it on output.
pub
/// The software that wrote the record. Informational; not a facet.
/// A file in object storage that the record refers to by `path`.
/// An edge from this version to another record version or an external target.
/// The producer's statement about what it removed before publishing.