Documentation
¶
Overview ¶
Package archive is the cloud seam for long-term archival of agent runs: a create-only object store over Amazon S3 or Google Cloud Storage.
Patchy only ever writes an object once and never deletes one. Retention, legal hold, encryption keys, tiering and expiry all belong to the bucket's own policy (S3 Object Lock, a GCS retention lock, CMK/CMEK, lifecycle rules), so an operator's audit guarantees never depend on patchy behaving.
Every write is conditional on the object not existing (S3 If-None-Match: *, GCS DoesNotExist). A retry that finds an object already there succeeds when the stored sha256 matches the new body and fails with ErrConflict when it does not, so a re-collected run converges instead of either overwriting evidence or erroring forever.
Credentials always come from the platform's default chain (IRSA or EKS Pod Identity, GKE workload identity, ADC), so no key material exists anywhere. The package has no Kubernetes imports: internal/runarchive owns assembling a run's objects and recording where they went.
Index ¶
Constants ¶
const MaxPresignTTL = 7 * 24 * time.Hour
MaxPresignTTL is the longest a presigned URL may live. Both S3 SigV4 and GCS V4 signing cap expiry at seven days.
const MetadataSHA256 = "sha256"
MetadataSHA256 is the user-metadata key every object carries its body's hex sha256 under (x-amz-meta-sha256 on S3, metadata.sha256 on GCS). It is what makes a create-only retry idempotent without re-reading the body.
Variables ¶
var ( // ErrNotFound reports an object that does not exist. ErrNotFound = errors.New("archive: object not found") // ErrConflict reports a create-only write that found a different object // already at the key. It is never retried: the archive is immutable, so // a different body means the caller is not writing what it wrote before. ErrConflict = errors.New("archive: object exists with different content") )
Functions ¶
func Join ¶
Join builds an object key from parts, dropping empty parts and stray slashes so a prefix of "", "audit" or "/audit/" all behave alike.
func RegisterFlags ¶
RegisterFlags declares the store-location flags every binary that reads or writes the archive shares (PATCHY_ARCHIVE_* in the environment).
Types ¶
type Config ¶
type Config struct {
// Provider is s3 or gcs; empty disables archival.
Provider Provider
// Bucket name.
Bucket string
// Prefix every key starts with (no leading or trailing slash needed).
Prefix string
// Region of an S3 bucket; empty uses the SDK default chain.
Region string
// Endpoint overrides the service endpoint, for S3-compatible stores and
// tests. On S3 it also switches to path-style addressing.
Endpoint string
// KMSKey encrypts each write with this key (an S3 KMS key id or ARN, or
// a GCS CryptoKey resource name). Empty leaves the bucket default.
KMSKey string
}
Config locates the bucket and the key prefix runs are archived under. An empty Provider means archival is disabled.
func ConfigFrom ¶
func ConfigFrom(o StringGetter) Config
ConfigFrom reads the flags RegisterFlags declared.
type Location ¶
Location is everything needed to find one object without any patchy configuration: a CLI holding only the run's status can open the store and read the key with the caller's own credentials.
type Store ¶
type Store interface {
// Put writes body at key exactly once. Writing the same bytes again
// succeeds; writing different bytes fails with ErrConflict.
Put(ctx context.Context, key string, body []byte, contentType string) error
// Get opens an object for reading; ErrNotFound when it is absent.
Get(ctx context.Context, key string) (io.ReadCloser, error)
// Presign returns a URL that GETs key without credentials until it
// expires. A non-empty attachment asks the browser to download the
// object under that file name instead of displaying it.
Presign(ctx context.Context, key string, ttl time.Duration,
attachment string) (url string, expires time.Time, err error)
// Close releases the client.
Close() error
}
Store is a create-only object store.
type StringGetter ¶
StringGetter reads a resolved flag value.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package archivetest provides an in-memory archive.Store for tests of the packages that archive runs or serve archived objects.
|
Package archivetest provides an in-memory archive.Store for tests of the packages that archive runs or serve archived objects. |