47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package contract
|
|
|
|
import "time"
|
|
|
|
const ArchiveSchemaVersion = 1
|
|
|
|
// ArchiveReceipt identifies a durably published archive object. Path is a
|
|
// storage-owned reference, never a client-supplied destination. Checksum is
|
|
// lowercase hex SHA-256 of the final stored bytes; version is the schema.
|
|
type ArchiveReceipt struct {
|
|
Version int `json:"version"`
|
|
Path string `json:"path"`
|
|
Checksum string `json:"checksum"`
|
|
ArchivedAt time.Time `json:"archivedAt"`
|
|
}
|
|
|
|
func (r ArchiveReceipt) Validate() error {
|
|
if r.Version < 1 || r.Path == "" || r.ArchivedAt.IsZero() || len(r.Checksum) != 64 {
|
|
return invalid("incomplete archive receipt")
|
|
}
|
|
for _, c := range r.Checksum {
|
|
if !((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) {
|
|
return invalid("archive checksum must be lowercase SHA-256 hex")
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// RunArchive is summary-only: never embed per-card task/failure records.
|
|
type RunArchive struct {
|
|
Version int `json:"version"`
|
|
Run RunMeta `json:"run"`
|
|
Rounds []RoundStats `json:"rounds"`
|
|
}
|
|
|
|
// ArchiveWork.Version is an opaque concurrency token for registration; it is
|
|
// distinct from the archive schema version. Work discovery must survive restarts.
|
|
type ArchiveWork struct {
|
|
RunID string `json:"runId"`
|
|
Version string `json:"-"`
|
|
}
|
|
|
|
type ArchiveWorkPage struct {
|
|
Items []ArchiveWork `json:"items"`
|
|
NextCursor Cursor `json:"nextCursor"`
|
|
}
|