98 lines
2.1 KiB
Python
98 lines
2.1 KiB
Python
|
|
"""Manifest data model (ADR-0003).
|
||
|
|
|
||
|
|
Field types are restricted to CBOR-/JSON-compatible primitives (``str``,
|
||
|
|
``int``, ``bool``, ``None``, ``list``, ``dict``) so the canonical CBOR
|
||
|
|
encoding and the JCS JSON projection round-trip losslessly.
|
||
|
|
"""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from dataclasses import dataclass
|
||
|
|
from typing import Any
|
||
|
|
|
||
|
|
MANIFEST_VERSION = 1
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass(frozen=True, slots=True)
|
||
|
|
class FileEntry:
|
||
|
|
"""One stored file in a package."""
|
||
|
|
|
||
|
|
id: str
|
||
|
|
relative_path: str
|
||
|
|
media_type: str
|
||
|
|
size_bytes: int
|
||
|
|
digest_algorithm: str
|
||
|
|
digest_primary_hex: str
|
||
|
|
digest_sha256_hex: str
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass(frozen=True, slots=True)
|
||
|
|
class StorageReceipt:
|
||
|
|
"""A record of where a file's bytes are stored."""
|
||
|
|
|
||
|
|
file_id: str
|
||
|
|
backend_id: str
|
||
|
|
content_address: str
|
||
|
|
retrieval_tier: str
|
||
|
|
status: str
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass(frozen=True, slots=True)
|
||
|
|
class RetentionHold:
|
||
|
|
"""An active hold preventing deletion eligibility."""
|
||
|
|
|
||
|
|
hold_id: str
|
||
|
|
reason: str
|
||
|
|
actor: str
|
||
|
|
applied_at: str
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass(frozen=True, slots=True)
|
||
|
|
class RetentionSummary:
|
||
|
|
"""Retention state summary as of manifest write time."""
|
||
|
|
|
||
|
|
retention_class: str
|
||
|
|
expires_at: str | None
|
||
|
|
active_holds: list[RetentionHold]
|
||
|
|
last_retention_event_sequence: int | None
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass(frozen=True, slots=True)
|
||
|
|
class Package:
|
||
|
|
"""Package-level metadata."""
|
||
|
|
|
||
|
|
id: str
|
||
|
|
name: str
|
||
|
|
producer: str
|
||
|
|
subject: str
|
||
|
|
retention_class: str
|
||
|
|
status: str
|
||
|
|
created_at: str
|
||
|
|
finalized_at: str | None
|
||
|
|
expires_at: str | None
|
||
|
|
metadata: dict[str, Any]
|
||
|
|
metadata_schema_id: str | None
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass(frozen=True, slots=True)
|
||
|
|
class Provenance:
|
||
|
|
"""Provenance fields recorded at ingest time."""
|
||
|
|
|
||
|
|
source_commits: dict[str, str]
|
||
|
|
tool_versions: dict[str, str]
|
||
|
|
environment: dict[str, str]
|
||
|
|
ingest_actor: str
|
||
|
|
ingest_timestamps: dict[str, str]
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass(frozen=True, slots=True)
|
||
|
|
class Manifest:
|
||
|
|
"""The complete v1 manifest payload."""
|
||
|
|
|
||
|
|
manifest_version: int
|
||
|
|
package: Package
|
||
|
|
files: list[FileEntry]
|
||
|
|
storage_receipts: list[StorageReceipt]
|
||
|
|
retention_summary: RetentionSummary
|
||
|
|
provenance: Provenance
|