RG2: the registry's list pages by module and cursor; the sweep reads it page by page

oci-artifact-registry's list filters by name or module while it reads and
answers at most 768 KB a page with capped, total and the cursor next, in
order of the names; container-image-registry's answers whole as its form
says. The registry takes a removal for retention whoever asks it: the
refusal "not the sweep's" and its read of the sweep seat's holder go. The
sweep reads the list from its cursor until no page is left.

Builds: design 47 H2 §813 (7), §811, §779; H-A-350 DMC-10, H-A-399
This commit is contained in:
2026-11-22 00:49:42 +01:00
parent cb5de6fd31
commit 681de09f04
10 changed files with 282 additions and 92 deletions
@@ -22,10 +22,10 @@ import (
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
meshconditions "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions"
reg "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/containerimageregistry"
oci "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/ociartifactregistry"
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/parts"
stdio "git.novox.be/novox/mesh-sdk/go"
"git.novox.be/novox/mesh-sdk/go/busstate"
"git.novox.be/novox/mesh-sdk/go/seatlist"
"git.novox.be/novox/mesh-sdk/go/views"
"distribution/internal/holder"
@@ -314,15 +314,7 @@ func tools(v *holder.Verbs, windows kept[holder.Window], taken *asks) []stdio.To
}
return reg.RemoveAnswer{Removed: got.Removed, Kept: got.Kept, Reason: got.Reason, Tags: got.Tags, Artifact: &reg.Artifact{Name: in.Name, Version: in.Version, Tag: in.Tag, Digest: in.Digest}}, nil
}},
stdio.Tool{Name: seat + "." + holder.VerbList, Description: "What the store holds of one repository, or of every repository the seat holds: each manifest's digest, whether it is an index and the manifests it names, the tags naming it, its size and whether it is held (ADR 0632 §3). Read from the store's own files; changes nothing.",
Input: obj(map[string]any{"name": s("<module>/<artifact>; every repository when not given")}),
Run: func(args map[string]any) (any, error) {
repos, err := v.List(context.Background(), seat, stdio.CallerOf(args), str(args, "name"))
if err != nil {
return nil, err
}
return reg.ListAnswer{Repositories: repos}, nil
}},
listTool(v, seat),
stdio.Tool{Name: seat + "." + holder.VerbHold, Description: "Keep one untagged bundle, archive or copied base from retention (the artifact sweep alone); says held.",
Input: obj(map[string]any{"name": s("name"), "digest": s("sha256:…"), "reason": s("which of the sweep's rules keeps it")}, "name", "digest", "reason"),
Run: func(args map[string]any) (any, error) {
@@ -495,7 +487,7 @@ func main() {
Transfers: boundedTransfers{parts.BusTransfers[holder.Opening](holder.TransfersState)}, Cap: boundedCap(parts.BusCap(holder.IncomingObjects)), Record: recordAct, Idle: boundedArm(parts.BusArm(holder.IdleState))}
files := &holder.Files{Container: or(os.Getenv("MESH_REGISTRY_CONTAINER"), "mesh-registry"), Run: holder.ExecRunner, UID: os.Getuid()}
v := &holder.Verbs{Holder: h, Catalog: store, Holds: kept[holder.Hold]{state: "holds", key: holder.Hold.Key}, Mirrors: mirrors{},
Files: files, SweepHolder: func() (string, error) { return seatlist.HolderOf(stdio.Ask, holder.SweepSeat) }}
Files: files}
go followMirrors(v)
go parts.FollowIdle(holder.IdleState, parts.IDs(h.Transfers), h.Expired, func(id string, dropped bool, err error) {
if err != nil {
@@ -523,3 +515,41 @@ func or(v, d string) string {
}
return v
}
// listTool is the seat's verb list. On oci-artifact-registry it filters by name or module while it reads and pages at 768 KB
// by the cursor next (design 47 H2 §779, §811, §813 (7)); on container-image-registry, whose form takes no cursor, it answers
// whole.
func listTool(v *holder.Verbs, seat string) stdio.Tool {
s := func(d string) map[string]any { return map[string]any{"type": "string", "description": d} }
description := "What the store holds of one repository, or of every repository the seat holds: each manifest's digest, whether it is an index and the manifests it names, the tags naming it, its size and whether it is held (ADR 0632 §3). Read from the store's own files; changes nothing."
props := map[string]any{"name": s("<module>/<artifact>; every repository when not given")}
if seat == holder.ArtifactSeat {
description += " Filtered by name or module while it reads and paged by the cursor next, at most 768 KB a page, capped saying the rest is read from next."
props["module"] = s("only the repositories of this module, <module>/*")
props["next"] = s("the cursor the previous page answered; absent for the first page")
}
return stdio.Tool{Name: seat + "." + holder.VerbList, Description: description, Input: map[string]any{"type": "object", "properties": props},
Run: func(args map[string]any) (any, error) {
if seat != holder.ArtifactSeat {
page, err := v.List(context.Background(), seat, stdio.CallerOf(args), holder.ListQuery{Name: str(args, "name")})
if err != nil {
return nil, err
}
return reg.ListAnswer{Repositories: page.Repositories}, nil
}
in, err := arg[oci.ListInput](args)
if err != nil {
return nil, err
}
page, err := v.List(context.Background(), seat, stdio.CallerOf(args), holder.ListQuery{Name: in.Name, Module: in.Module, Next: in.Next, PageBytes: holder.ListPageBytes})
if err != nil {
return nil, err
}
out := oci.ListAnswer{Form: oci.Form, Repositories: []oci.Repository{}, Capped: page.Capped, Next: page.Next, Total: int64(page.Total)}
raw, _ := json.Marshal(page.Repositories)
if err := json.Unmarshal(raw, &out.Repositories); err != nil {
return nil, err
}
return out, nil
}}
}