Implement continuity handoffs and pickup validation

This commit is contained in:
kami
2026-07-26 19:10:18 +04:00
parent 96e94bc2d0
commit 1c889167fa
4 changed files with 261 additions and 6 deletions
+15
View File
@@ -209,6 +209,21 @@ func (s *Store) PutArtifact(b []byte) (string, error) {
return h, nil
}
// Artifact returns a CAS artifact after verifying its content address.
func (s *Store) Artifact(ref string) ([]byte, error) {
if len(ref) != 64 {
return nil, fmt.Errorf("%w: invalid artifact reference", domain.ErrInvalid)
}
b, err := os.ReadFile(filepath.Join(s.cas, ref))
if err != nil {
return nil, err
}
if domain.Hash(b) != ref {
return nil, fmt.Errorf("%w: corrupt artifact", domain.ErrInvalid)
}
return b, nil
}
func (s *Store) Task(id string) (domain.Task, bool) {
s.mu.Lock()
defer s.mu.Unlock()