Spaces:
Sleeping
Sleeping
Download src/modules/artifact_catalog/service.py from dellweb3/VibeCoding: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/src/modules/artifact_catalog/service.py
- Command line
-
hf download hf://spaces/dellweb3/VibeCoding/src/modules/artifact_catalog/service.py
-
curl -L -o service.py https://huggingface.co/spaces/dellweb3/VibeCoding/resolve/main/src/modules/artifact_catalog/service.py
1.03 kB
| """Local immutable evidence objects; production registry remains an adapter boundary.""" | |
| import json | |
| import re | |
| from src.modules.skill.domain.models import canonical, digest, SkillError | |
| class ArtifactCatalog: | |
| def __init__(self, repository): | |
| self.repository = repository | |
| def record(self, tenant, run_id, body): | |
| if not re.fullmatch(r'run-[a-f0-9]{32}', run_id): | |
| raise SkillError('INVALID_RUN_ID', '非法任务标识。') | |
| value = dict(body, run_id=run_id) | |
| key = digest(value) | |
| self.repository.put(tenant, run_id, key, canonical(value)) | |
| return {'digest': key, 'manifest': value} | |
| def read(self, tenant, run_id, key): | |
| value = self.repository.get(tenant, run_id, key) | |
| if value is None: | |
| raise SkillError('ARTIFACT_NOT_FOUND', '证据不存在或不可见。', 404) | |
| body = json.loads(value) | |
| if digest(body) != key: | |
| raise SkillError('ARTIFACT_DIGEST_MISMATCH', '证据损坏。', 409) | |
| return body | |