Skip to content

Update spec to include tag history endpoint - #606

Open
jcarter3 wants to merge 10 commits into
opencontainers:mainfrom
jcarter3:tag_history
Open

jcarter3 wants to merge 10 commits into
opencontainers:mainfrom
jcarter3:tag_history

Conversation

@jcarter3

@jcarter3 jcarter3 commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Updates distribution spec to include new endpoint for retrieving the history of a given tag. The response is a json list of descriptors,including the created timestamp and sorted in descending order (newest first).
The list can be paged.

Comment thread spec.md Resolved
@jcarter3
jcarter3 force-pushed the tag_history branch 2 times, most recently from ba1f62d to dd534be Compare May 4, 2026 19:24
@jcarter3 jcarter3 changed the title **WIP** Update spec to include tag history endpoint Update spec to include tag history endpoint May 4, 2026
@jcarter3
jcarter3 marked this pull request as ready for review May 4, 2026 19:25

@mikebrow mikebrow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some thoughts

Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md
When `n` is zero, this endpoint MUST return an empty array.
When `n` is not specified, the registry MAY apply a default limit.

- **`before`** *string (RFC 3339 timestamp)*, OPTIONAL

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a chance to have two results with the exact same time stamp..

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a registry could consider every update of a tag as a delete followed by a create and so the timestamp would be the same.

@northtyphoon northtyphoon Aug 22, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think the history can be more compact for repush case. Actually two created events are better repressing what acutally happened compared to created/deleted/created.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether we could reasonably see two at the same timestamp probably depends on how granular timestamp is -- perhaps we should explicitly recommend (implementor's note?) that timestamps should have finer granularity than just seconds?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can recommend finer granularity, we should also update all the examples we provide to use finer granularity (we've had issues in the past where implementors read the examples and not the prose).

Comment thread extensions/_oci.md Resolved

@sudo-bmitch sudo-bmitch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's some early feedback. I still need to spend some time implementing this before considering approving, and we need a conformance test.

Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Outdated

A successful request MUST return a `200 OK` response code.
If the repository does not exist, the registry MUST return a `404 Not Found` response code.
If the tag has no history or the registry does not implement this extension, the registry MUST return a `404 Not Found` response code.

@yosifkit yosifkit Jul 2, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have a MUST/SHOULD respond with UNSUPPORTED in the error code for "registry does not implement this" case? Or perhaps some other recommended required error codes for the other 404 responses so that users of the API can know which it is. Or maybe the n=0 trick is the correct way to figure out if history is supported?


Related:

If the tag has no history [...] the registry MUST return a 404 Not Found

when n is zero, this endpoint MUST return an empty array

These seem conflicting. Perhaps a clarification is needed?

@yosifkit yosifkit Jul 2, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words, does n=0 override the "repository does not exist" 404 or just the "no history" 404 or "registry does not implement this extension" 404 and what about the pinned digest 404?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, those do some conflicting, good catch.

Currently most http routers on an unknown path would return 404 by default, hence the "return 404 if not supported". If we forced an UNSUPPORTED it'd require registries to explicitly update to say they aren't handling it, vs it being the default

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the appropriate thing to do is return an empty response with 200 OK if there is no history - this seems to make more sense?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Could it have no history? What does that mean? Does that mean nothing was ever tagged as this? Or just that the registry hasn't yet recorded history? But if it has at least the current tagged image and they support the history endpoint, it must have a minimum history of one, right? So, 404 is correct, the tag does not exist as an image, or it would have history. Returning an empty list for every tag that doesn't exist seems odd.

Comment thread extensions/_oci.md Resolved

@sudo-bmitch sudo-bmitch left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding our own annotations to the descriptors has me concerned. E.g. what if someone wants to pull up annotations in their own tag history API and there's a collision, perhaps even a collision with an annotation we haven't specified yet but add in a future release.

I'm playing around with my own implementation and have the following struct for each tag history entry:

type LayoutHistory struct {
	Time       time.Time  `json:"time"`
	Deleted    bool       `json:"deleted,omitempty"`
	Descriptor Descriptor `json:"descriptor"`
}

The descriptor ends up nested one extra layer in the responses, but we can now add other fields. E.g. I was considering if registries could add an audit log to each entry, identifying who (or what) was responsible for each entry.


Edit: A few more thoughts looking over this:

  • I'd want to use the Link header for pagination. It's cleaner from the client side to know when more results are available.
  • With the Link header, that gives flexibility for the server to reject some values of n for being too small or large, imposing it's own limits. Or the server can not support pagination and always return the full history.
  • Do we have guidance for servers implementing garbage collection of history responses? If the server has a hard upper limit on the number of history entries per tag, that makes it easier to not paginate responses.
  • When searching on a tag with a digest, I'd lean towards always returning a 200, and just having an empty list when no matches are found. Treat it like a filter on the history, where a tag could also have a particular digest assigned to it multiple times.
  • Is pushing a new tag value treated as a simultaneous delete of the old value, or can that be implied?

Comment thread extensions/_oci.md Resolved
@tianon

tianon commented Jul 23, 2026

Copy link
Copy Markdown
Member

On today's call we talked about a lot of good reasons why it makes sense for this to be shaped like an OCI index (like #579 + referrers), and on the problem of "what if a registry 'pulls up' annotations?" we discussed having said registry ignore any image annotations that start with org.opencontainers.distrubution. (as explicitly "owned" by the registry), for future possible growth (so that clients can assume they're from the registry, not the image).

@michaelb990 michaelb990 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple comments, but this seems like a cool idea!

for registries implementing this for existing repos, is there a way we should communicate to clients when we started tracking history? it seems like there's a difference between "this is the full history for a given tag" and "this is the history since 2026-08-15 for a given tag".

Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md
A successful request MUST return a `200 OK` response code.
If the registry does not implement this extension, the registry MUST return a `404 Not Found` response code.
The registry MUST NOT return a `404 Not Found` response code for any other condition.
If the repository does not exist or the tag has no history, the registry MUST return a `200 OK` response code with an empty manifest list.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the repository does not exist or the tag has no history

the statement is a bit ambiguous, a tag must have a history, at least created if it ever exits. It's better to reword to something like if the repository or tag never exits

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's definitely possible for a registry to not know when the tags it has were created, but that's a separate thing (it would still have a current value, just not a timestamp).

Comment thread extensions/_oci.md Outdated

The annotations MUST include both of the following:

- **`org.opencontainers.distribution.tag.timestamp`** *string*

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timestamp is a universal concept, suggest remove tag from the annotation name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we're talking about the timestamp that the tag event itself happened, I think .tag. is appropriate here -- this isn't the image timestamp or the timestamp of when the image was first seen by the registry or anything, but specifically the timestamp of this specific tag entry.

Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Outdated

- **`org.opencontainers.distribution.tag.timestamp`** *string*

The RFC 3339 timestamp at which the tag history event occurred. Used as the sort key and as the cursor for time-based pagination.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I noted above, it's 100% valid for a registry to not know this timestamp -- we should provide explicit guidance or relax MUST to SHOULD (maybe only allowing it to be missing if there's only a single entry?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an entry doesn't include a timestamp, things get a bit ugly. I agree there is a world where a registry has stored the digests but not the timestamps, but it seems like a rare one?

Without timestamps, the ordering and paging is broken - we could only return a single list of whatever the registry was willing to return unless we defined a backup sorting (complication). If we have mixed entries (some with, some without timestamps) then the inclusion of a before/after param would immediately remove all the records without a timestamp.

I could see a solution where we acknowledge the record exists, but don't allow for listing. We could hide records without timestamps from the listing call, but if you pass a digest in to see if it was part of history, this call could still return true for entries without timestamps. This seems like gross behavior though, and it'd just be easier to just say registries should track these values going forward, and anything before is lost.

Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md Resolved
Comment thread extensions/_oci.md
When provided, only entries whose history entry timestamp is strictly less than (i.e. older than) `before` will be returned.
This is used for time-based pagination: pass the `org.opencontainers.distribution.tag.timestamp` value of the last entry returned in the previous response to retrieve the next page.

- **`since`** *string (RFC 3339 timestamp)*, OPTIONAL

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One possible option (not saying it's a good one, to be clear) would be to relax some of this to ISO 8601 instead of RFC 3339 -- that's a little bit unprecedented in OCI (except in umoci), but that would allow formats like "YYYY-MM-DD" also (although that makes the exclusive nature of these filters even more apparent, so maybe I'm really just thinking out loud? it's certainly easier to use "by hand" than RFC 3339 is)

Comment thread extensions/_oci.md
Specifies the maximum number of results to return.
The registry MAY return fewer results than requested if fewer historical entries exist.
When `n` is zero, this endpoint MUST return an OCI Index with an empty manifest list and MUST NOT include a `Link` header, useful for determining whether the extension is supported (`200 OK`) or not (`404 Not Found`).
When `n` is not specified, the registry MAY apply a default limit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this limit for a single page of results, or does it span multiple pages? E.g. if n=150, should the registry return two pages of results, one with 100 entries, and the next with 50? Or is this the client requested limit per page that the server could ignore?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this limit is per page of results.
If there are 150 entries, and you pass n=150, but the server has an implementation limit of 100, I'd expect the first response to be an index with 100 entries and a Link header pointing to the next 50

Comment thread extensions/_oci.md Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants