diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-07-23 16:21:20 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-07-23 16:39:34 +0900 |
| commit | 67dbb68818026f3d7a64e9519cf1aac36468b7c9 (patch) | |
| tree | 68f1e731242a9c8ef1912a195c2a6aefc53f6da5 /internal/pkg/pkg.go | |
| parent | 0e689d9983dee9f742c4ed4b2e716fbcb1b84e99 (diff) | |
internal/pkg: implementation revisions
This enables changing the behaviour of an artifact implementation without changing its IR structure. Unfortunately this changes the IR header structure resulting in many rebuilds.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/pkg.go')
| -rw-r--r-- | internal/pkg/pkg.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/pkg/pkg.go b/internal/pkg/pkg.go index 99a54462..ae3a8185 100644 --- a/internal/pkg/pkg.go +++ b/internal/pkg/pkg.go @@ -16,6 +16,7 @@ import ( "io" "io/fs" "maps" + "math" "os" "os/signal" "path/filepath" @@ -520,6 +521,28 @@ type FileArtifact interface { Artifact } +// RevisionArtifact is optionally implemented by an artifact that had undergone +// internal changes affecting its behaviour while retaining its IR structure. +type RevisionArtifact interface { + // Revision returns the revision number of [Artifact]. This value is always + // represented in the IR. An IR stream produced from the same [Kind] with + // differing revision is rejected. + // + // Result must remain identical across multiple invocations. + Revision() uint64 + + Artifact +} + +// GetRevision returns the revision number of an [Artifact]. +func GetRevision(a Artifact) (revision uint64) { + revision = math.MaxUint64 + if r, ok := a.(RevisionArtifact); ok { + revision = r.Revision() + } + return +} + // reportName returns a string describing [Artifact] presented to the user. func reportName(a Artifact, id unique.Handle[ID]) string { r := Encode(id.Value()) |
