Design 47 H1 (8): a catalog revision's call names its kind, one of three constants
The seat mesh-catalog's CatalogRevision and catalog-revision gain call-kind, an enumeration the seat's schema validates (take-in, release, take-in-again), with module and version for a release and repository for a take-in again, beside call, the words for a person (regenerated by seatgen, additive). The indexer's three writers set them: a take-in's from the gate's call, a re-pin's on a module's release, a take-in again's; no reader parses the words. Builds: design 47 H H-A-213 (3), H-A-214, H-A-215
This commit is contained in:
@@ -717,6 +717,8 @@ type CatalogRevision struct {
|
||||
Branch string `json:"branch,omitempty"`
|
||||
// what made the revision (design 47 H-A-212, H-A-213): a take-in's the gate's call its source revision names, a re-pin's release of <module> <version>, a take-in again's take-in again of <repository>; absent for a candidate's
|
||||
Call string `json:"call,omitempty"`
|
||||
// the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215): a take-in's, a re-pin's on a module's release, a take-in again's; absent for a candidate's
|
||||
CallKind string `json:"call-kind,omitempty"`
|
||||
// the seat definitions it was judged with, each by its digest, read whole through seat-definitions
|
||||
Definitions []CatalogRevisionDefinitionsItem `json:"definitions,omitempty"`
|
||||
// one per module, by name
|
||||
@@ -727,8 +729,12 @@ type CatalogRevision struct {
|
||||
Heads string `json:"heads,omitempty"`
|
||||
// trunk or candidate
|
||||
Kind string `json:"kind"`
|
||||
// for call-kind release, the module released (H-A-215)
|
||||
Module string `json:"module,omitempty"`
|
||||
// the movers of the take-in that wrote it, so a redelivered source-moved whose revision is kept says take-in.taken again from them, recomputing nothing (design 47 H §743, H-A-92); absent for one with no mover
|
||||
Movers []TakeInEntry `json:"movers,omitempty"`
|
||||
// for call-kind take-in-again, the repository taken in again (H-A-215)
|
||||
Repository string `json:"repository,omitempty"`
|
||||
// the catalog graph revision's number, counted by its holder
|
||||
Revision int64 `json:"revision"`
|
||||
// the source revision it was taken in from; for a candidate, the source revision its heads are merged onto
|
||||
@@ -737,8 +743,17 @@ type CatalogRevision struct {
|
||||
Trunk []Head `json:"trunk,omitempty"`
|
||||
// the layout version
|
||||
V int64 `json:"v,omitempty"`
|
||||
// for call-kind release, the version released (H-A-215)
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// The values of CatalogRevision's call-kind.
|
||||
const (
|
||||
CatalogRevisionCallKindTakeIn = "take-in"
|
||||
CatalogRevisionCallKindRelease = "release"
|
||||
CatalogRevisionCallKindTakeInAgain = "take-in-again"
|
||||
)
|
||||
|
||||
// Edge is one edge of the catalog graph between artifact references, B before A (ADR 0666 section 14): kind 1 B published before A builds (a package A imports), 2 B published before A delivers (fetched by reference at its start), 3 B delivered before A builds (its build module and toolchain), 4 B delivered before A delivers (a provision, bus state, a format's reader), 5 B has acted for A's new version (an acting rule), 6 B runs a version that serves A (a verb or a manifest word A uses).
|
||||
type Edge struct {
|
||||
// declared in the artifact entry's needs of A's manifest, where nothing else says it
|
||||
@@ -1305,6 +1320,8 @@ type CatalogRevisionEvent struct {
|
||||
Branch string `json:"branch,omitempty"`
|
||||
// what made the revision, as the revision's call names it (design 47 H-A-212, H-A-213); absent for a candidate's
|
||||
Call string `json:"call,omitempty"`
|
||||
// the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215); absent for a candidate's
|
||||
CallKind string `json:"call-kind,omitempty"`
|
||||
// the modules whose entries differ from the revision before it of the same kind
|
||||
Changed []string `json:"changed,omitempty"`
|
||||
// how many entries it lists
|
||||
@@ -1312,12 +1329,25 @@ type CatalogRevisionEvent struct {
|
||||
Group string `json:"group,omitempty"`
|
||||
Heads string `json:"heads,omitempty"`
|
||||
// trunk or candidate: a candidate's moves no running part
|
||||
Kind string `json:"kind"`
|
||||
Revision int64 `json:"revision"`
|
||||
Source int64 `json:"source"`
|
||||
V int64 `json:"v"`
|
||||
Kind string `json:"kind"`
|
||||
// for call-kind release, the module released (H-A-215)
|
||||
Module string `json:"module,omitempty"`
|
||||
// for call-kind take-in-again, the repository taken in again (H-A-215)
|
||||
Repository string `json:"repository,omitempty"`
|
||||
Revision int64 `json:"revision"`
|
||||
Source int64 `json:"source"`
|
||||
V int64 `json:"v"`
|
||||
// for call-kind release, the version released (H-A-215)
|
||||
Version string `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
// The values of CatalogRevisionEvent's call-kind.
|
||||
const (
|
||||
CatalogRevisionEventCallKindTakeIn = "take-in"
|
||||
CatalogRevisionEventCallKindRelease = "release"
|
||||
CatalogRevisionEventCallKindTakeInAgain = "take-in-again"
|
||||
)
|
||||
|
||||
// FillingEvent is the body of the event filling.
|
||||
type FillingEvent = Fill
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestFixtures(t *testing.T) {
|
||||
decode func([]byte) (any, error)
|
||||
subjectIs *regexp.Regexp
|
||||
}{
|
||||
{name: "a trunk revision kept, on the seat's subject", subject: "mesh.seat.mesh-catalog.event.catalog-revision.main", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"call\":\"release of mesh-sdk 0.1.27\",\"changed\":[\"xclip\"],\"entries\":2,\"kind\":\"trunk\",\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"call\":\"release of mesh-sdk 0.1.27\",\"changed\":[\"xclip\"],\"entries\":2,\"kind\":\"trunk\",\"revision\":12,\"source\":3589,\"v\":1}",
|
||||
{name: "a trunk revision kept, on the seat's subject", subject: "mesh.seat.mesh-catalog.event.catalog-revision.main", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"call\":\"release of mesh-sdk 0.1.27\",\"call-kind\":\"release\",\"changed\":[\"xclip\"],\"entries\":2,\"kind\":\"trunk\",\"module\":\"mesh-sdk\",\"revision\":12,\"source\":3589,\"v\":1,\"version\":\"0.1.27\"}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"call\":\"release of mesh-sdk 0.1.27\",\"call-kind\":\"release\",\"changed\":[\"xclip\"],\"entries\":2,\"kind\":\"trunk\",\"module\":\"mesh-sdk\",\"revision\":12,\"source\":3589,\"v\":1,\"version\":\"0.1.27\"}",
|
||||
decode: func(b []byte) (any, error) { var v CatalogRevisionEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-catalog\\.event\\.catalog-revision\\.[^.*> ]+$")},
|
||||
{name: "a candidate's revision kept", subject: "mesh.seat.mesh-catalog.event.catalog-revision.main", given: "{\"branch\":\"main\",\"entries\":2,\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"kind\":\"candidate\",\"revision\":13,\"source\":3589,\"v\":1}", wire: "{\"branch\":\"main\",\"entries\":2,\"group\":\"feat/47-G\",\"heads\":\"0123456789ab\",\"kind\":\"candidate\",\"revision\":13,\"source\":3589,\"v\":1}",
|
||||
decode: func(b []byte) (any, error) { var v CatalogRevisionEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-catalog\\.event\\.catalog-revision\\.[^.*> ]+$")},
|
||||
@@ -59,7 +59,7 @@ func TestFixtures(t *testing.T) {
|
||||
decode: func(b []byte) (any, error) { var v ModulesAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "the module verb (captured: xclip)", subject: "", given: "{\"module\":{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"manifest\":{\"build\":{\"artifacts\":[{\"binary\":\"xclip-tools\",\"from\":\"cmd/xclip-tools\",\"kind\":\"bundle\",\"language\":\"go\",\"loads\":[\"xclip-tools\"],\"name\":\"tools\",\"system\":\"arch\"}]},\"capabilities\":[\"package-manager\"],\"module\":\"xclip\",\"resources\":[{\"id\":\"package\",\"package\":\"xclip\",\"type\":\"package\"}],\"tools\":[\"xclip_copy\",\"xclip_paste\",\"xclip_targets\",\"xclip_session\"],\"version\":\"1\"},\"module\":\"xclip\",\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\"}}", wire: "{\"module\":{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"manifest\":{\"build\":{\"artifacts\":[{\"binary\":\"xclip-tools\",\"from\":\"cmd/xclip-tools\",\"kind\":\"bundle\",\"language\":\"go\",\"loads\":[\"xclip-tools\"],\"name\":\"tools\",\"system\":\"arch\"}]},\"capabilities\":[\"package-manager\"],\"module\":\"xclip\",\"resources\":[{\"id\":\"package\",\"package\":\"xclip\",\"type\":\"package\"}],\"tools\":[\"xclip_copy\",\"xclip_paste\",\"xclip_targets\",\"xclip_session\"],\"version\":\"1\"},\"module\":\"xclip\",\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\"}}",
|
||||
decode: func(b []byte) (any, error) { var v ModuleAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a watched branch's catalog graph revision", subject: "", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"base\":9,\"branch\":\"main\",\"call\":\"release of mesh-sdk 0.1.27\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"movers\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fingerprint\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"repository\":\"novox/mesh-catalog\"}],\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"base\":9,\"branch\":\"main\",\"call\":\"release of mesh-sdk 0.1.27\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"movers\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fingerprint\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"repository\":\"novox/mesh-catalog\"}],\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}",
|
||||
{name: "a watched branch's catalog graph revision", subject: "", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"base\":9,\"branch\":\"main\",\"call\":\"release of mesh-sdk 0.1.27\",\"call-kind\":\"release\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"module\":\"mesh-sdk\",\"movers\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fingerprint\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"repository\":\"novox/mesh-catalog\"}],\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1,\"version\":\"0.1.27\"}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"base\":9,\"branch\":\"main\",\"call\":\"release of mesh-sdk 0.1.27\",\"call-kind\":\"release\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"module\":\"mesh-sdk\",\"movers\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fingerprint\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"repository\":\"novox/mesh-catalog\"}],\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1,\"version\":\"0.1.27\"}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v CatalogRevisionsByBranchRevisionValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
"kind": "trunk",
|
||||
"source": 3589,
|
||||
"call": "release of mesh-sdk 0.1.27",
|
||||
"call-kind": "release",
|
||||
"module": "mesh-sdk",
|
||||
"version": "0.1.27",
|
||||
"entries": 2,
|
||||
"changed": [
|
||||
"xclip"
|
||||
|
||||
@@ -210,7 +210,10 @@
|
||||
}
|
||||
],
|
||||
"base": 9,
|
||||
"call": "release of mesh-sdk 0.1.27"
|
||||
"call": "release of mesh-sdk 0.1.27",
|
||||
"call-kind": "release",
|
||||
"module": "mesh-sdk",
|
||||
"version": "0.1.27"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -661,6 +661,27 @@
|
||||
"type": "string",
|
||||
"description": "what made the revision, as the revision's call names it (design 47 H-A-212, H-A-213); absent for a candidate's"
|
||||
},
|
||||
"call-kind": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"take-in",
|
||||
"release",
|
||||
"take-in-again"
|
||||
],
|
||||
"description": "the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215); absent for a candidate's"
|
||||
},
|
||||
"module": {
|
||||
"type": "string",
|
||||
"description": "for call-kind release, the module released (H-A-215)"
|
||||
},
|
||||
"version": {
|
||||
"type": "string",
|
||||
"description": "for call-kind release, the version released (H-A-215)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "string",
|
||||
"description": "for call-kind take-in-again, the repository taken in again (H-A-215)"
|
||||
},
|
||||
"group": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -1879,6 +1900,27 @@
|
||||
"type": "string",
|
||||
"description": "what made the revision (design 47 H-A-212, H-A-213): a take-in's the gate's call its source revision names, a re-pin's release of <module> <version>, a take-in again's take-in again of <repository>; absent for a candidate's"
|
||||
},
|
||||
"call-kind": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"take-in",
|
||||
"release",
|
||||
"take-in-again"
|
||||
],
|
||||
"description": "the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215): a take-in's, a re-pin's on a module's release, a take-in again's; absent for a candidate's"
|
||||
},
|
||||
"module": {
|
||||
"type": "string",
|
||||
"description": "for call-kind release, the module released (H-A-215)"
|
||||
},
|
||||
"version": {
|
||||
"type": "string",
|
||||
"description": "for call-kind release, the version released (H-A-215)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "string",
|
||||
"description": "for call-kind take-in-again, the repository taken in again (H-A-215)"
|
||||
},
|
||||
"group": {
|
||||
"type": "string",
|
||||
"description": "a candidate's group"
|
||||
|
||||
@@ -279,6 +279,8 @@ export interface CatalogRevision {
|
||||
"branch"?: string;
|
||||
/** what made the revision (design 47 H-A-212, H-A-213): a take-in's the gate's call its source revision names, a re-pin's release of <module> <version>, a take-in again's take-in again of <repository>; absent for a candidate's */
|
||||
"call"?: string;
|
||||
/** the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215): a take-in's, a re-pin's on a module's release, a take-in again's; absent for a candidate's */
|
||||
"call-kind"?: "take-in" | "release" | "take-in-again";
|
||||
/** the seat definitions it was judged with, each by its digest, read whole through seat-definitions */
|
||||
"definitions"?: CatalogRevisionDefinitionsItem[];
|
||||
/** one per module, by name */
|
||||
@@ -289,8 +291,12 @@ export interface CatalogRevision {
|
||||
"heads"?: string;
|
||||
/** trunk or candidate */
|
||||
"kind": string;
|
||||
/** for call-kind release, the module released (H-A-215) */
|
||||
"module"?: string;
|
||||
/** the movers of the take-in that wrote it, so a redelivered source-moved whose revision is kept says take-in.taken again from them, recomputing nothing (design 47 H §743, H-A-92); absent for one with no mover */
|
||||
"movers"?: TakeInEntry[];
|
||||
/** for call-kind take-in-again, the repository taken in again (H-A-215) */
|
||||
"repository"?: string;
|
||||
/** the catalog graph revision's number, counted by its holder */
|
||||
"revision": number;
|
||||
/** the source revision it was taken in from; for a candidate, the source revision its heads are merged onto */
|
||||
@@ -299,6 +305,8 @@ export interface CatalogRevision {
|
||||
"trunk"?: Head[];
|
||||
/** the layout version */
|
||||
"v"?: number;
|
||||
/** for call-kind release, the version released (H-A-215) */
|
||||
"version"?: string;
|
||||
}
|
||||
|
||||
/** one edge of the catalog graph between artifact references, B before A (ADR 0666 section 14): kind 1 B published before A builds (a package A imports), 2 B published before A delivers (fetched by reference at its start), 3 B delivered before A builds (its build module and toolchain), 4 B delivered before A delivers (a provision, bus state, a format's reader), 5 B has acted for A's new version (an acting rule), 6 B runs a version that serves A (a verb or a manifest word A uses) */
|
||||
@@ -800,6 +808,8 @@ export interface CatalogRevisionEvent {
|
||||
"branch"?: string;
|
||||
/** what made the revision, as the revision's call names it (design 47 H-A-212, H-A-213); absent for a candidate's */
|
||||
"call"?: string;
|
||||
/** the kind of what made the revision, which a reader reads instead of call's words (design 47 H-A-213 (3), H-A-214, H-A-215); absent for a candidate's */
|
||||
"call-kind"?: "take-in" | "release" | "take-in-again";
|
||||
/** the modules whose entries differ from the revision before it of the same kind */
|
||||
"changed"?: string[];
|
||||
/** how many entries it lists */
|
||||
@@ -808,9 +818,15 @@ export interface CatalogRevisionEvent {
|
||||
"heads"?: string;
|
||||
/** trunk or candidate: a candidate's moves no running part */
|
||||
"kind": string;
|
||||
/** for call-kind release, the module released (H-A-215) */
|
||||
"module"?: string;
|
||||
/** for call-kind take-in-again, the repository taken in again (H-A-215) */
|
||||
"repository"?: string;
|
||||
"revision": number;
|
||||
"source": number;
|
||||
"v": number;
|
||||
/** for call-kind release, the version released (H-A-215) */
|
||||
"version"?: string;
|
||||
}
|
||||
|
||||
/** is the body of the event filling. */
|
||||
|
||||
@@ -78,7 +78,7 @@ func TestACatalogRevisionIsKeptPerWatchedBranch(t *testing.T) {
|
||||
t.Errorf("the branch's source 8 answered %+v (%v)", a.Revision, err)
|
||||
}
|
||||
// H-A-213: a re-pin's revision of source 8 answers below the take-in's: source 8 answers revision 2.
|
||||
if _, err := ix.keepBranchEntries(ctx, "feature/x.y", 8, "release of mesh-sdk 0.1.27", tip("c4"), nil); err != nil {
|
||||
if _, err := ix.keepBranchEntries(ctx, "feature/x.y", 8, releaseCall("mesh-sdk", "0.1.27"), tip("c4"), nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if a, err := bySource("feature/x=2ey", 8); err != nil || a.Revision.Revision != 2 || a.Entries[0].Commit != "c3" {
|
||||
|
||||
@@ -348,7 +348,7 @@ func (ix *Indexer) viewEntries(ctx context.Context) (map[string]meshcatalog.Cata
|
||||
// KeepBranchEntries keeps entries as the catalog revision of a watched branch taken in from its source revision src (design
|
||||
// 47 H §743, H-A-32), as keepBranchEntries does with no call.
|
||||
func (ix *Indexer) KeepBranchEntries(ctx context.Context, branch string, src int64, entries map[string]meshcatalog.CatalogEntry, movers []meshcatalog.TakeInEntry) error {
|
||||
_, err := ix.keepBranchEntries(ctx, branch, src, "", entries, movers)
|
||||
_, err := ix.keepBranchEntries(ctx, branch, src, revisionCall{}, entries, movers)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ func (ix *Indexer) KeepBranchEntries(ctx context.Context, branch string, src int
|
||||
// branch, its source and its call. movers are kept on the revision (H-A-92), and the revision pinned for its one pipeline,
|
||||
// pipeline.<branch>.<n>, in the same write when there is one (A-449a, H-A-213 (4)), with the branch's previous revision
|
||||
// (H-A-147). It answers the number it kept; ErrObjectsFull is a store too full to keep it.
|
||||
func (ix *Indexer) keepBranchEntries(ctx context.Context, branch string, src int64, call string, entries map[string]meshcatalog.CatalogEntry, movers []meshcatalog.TakeInEntry) (int64, error) {
|
||||
func (ix *Indexer) keepBranchEntries(ctx context.Context, branch string, src int64, call revisionCall, entries map[string]meshcatalog.CatalogEntry, movers []meshcatalog.TakeInEntry) (int64, error) {
|
||||
if ix.Revisions == nil {
|
||||
return 0, nil
|
||||
}
|
||||
@@ -380,7 +380,8 @@ func (ix *Indexer) keepBranchEntries(ctx context.Context, branch string, src int
|
||||
number := newest.Revision + 1
|
||||
entries = WithEdges(ix.withActs(ctx, entries)) // the acting rules and the edges between artifact references are written here, once, for every reader (A-208)
|
||||
at := ix.now().UTC()
|
||||
rev, objects, err := CatalogRevisionOf(meshcatalog.CatalogRevision{Revision: number, Kind: "trunk", Branch: branch, Source: src, Call: call, At: &at}, entries)
|
||||
rev, objects, err := CatalogRevisionOf(meshcatalog.CatalogRevision{Revision: number, Kind: "trunk", Branch: branch, Source: src, Call: call.Call,
|
||||
CallKind: call.Kind, Module: call.Module, Version: call.Version, Repository: call.Repository, At: &at}, entries)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -444,16 +445,39 @@ func (ix *Indexer) keepBranchEntries(ctx context.Context, branch string, src int
|
||||
if after, capacity, err := ix.Revisions.Fill(ctx); fillErr == nil && err == nil && capacity > 0 && used*5 < capacity*4 && after*5 >= capacity*4 {
|
||||
ix.sayFill(ctx, meshcatalog.EventFilling, fmt.Sprintf("%d", rev.Revision), meshcatalog.Fill{Bytes: after, Cap: capacity})
|
||||
}
|
||||
ix.logf("catalog graph: revision %d of source revision %d kept (%s), %d entries, %d changed", rev.Revision, src, call, len(rev.Entries), len(changed))
|
||||
ix.logf("catalog graph: revision %d of source revision %d kept (%s), %d entries, %d changed", rev.Revision, src, call.Call, len(rev.Entries), len(changed))
|
||||
if ix.SayCatalogRevision != nil {
|
||||
if err := ix.SayCatalogRevision(ctx, meshcatalog.CatalogRevisionEvent{V: CatalogEntryLayout, Revision: rev.Revision, Kind: rev.Kind,
|
||||
Branch: keys.EscapeName(branch), Source: src, Call: call, At: &at, Changed: changed, Entries: int64(len(rev.Entries))}); err != nil {
|
||||
Branch: keys.EscapeName(branch), Source: src, Call: call.Call, CallKind: call.Kind, Module: call.Module, Version: call.Version,
|
||||
Repository: call.Repository, At: &at, Changed: changed, Entries: int64(len(rev.Entries))}); err != nil {
|
||||
ix.logf("catalog graph: revision %d is not said: %v", rev.Revision, err)
|
||||
}
|
||||
}
|
||||
return number, nil
|
||||
}
|
||||
|
||||
// revisionCall is what made a catalog revision (design 47 H-A-213 (3), H-A-215): call, the words for a person; Kind, one of the
|
||||
// seat mesh-catalog's three call kinds, which a reader reads instead of the words; Module and Version for a release, Repository
|
||||
// for a take-in again. The zero value names no call (a revision kept by hand or a test).
|
||||
type revisionCall struct {
|
||||
Call, Kind, Module, Version, Repository string
|
||||
}
|
||||
|
||||
// takeInCall is a take-in's: the gate's call its source revision names.
|
||||
func takeInCall(call string) revisionCall {
|
||||
return revisionCall{Call: call, Kind: meshcatalog.CatalogRevisionCallKindTakeIn}
|
||||
}
|
||||
|
||||
// releaseCall is a re-pin's on the release of module at version (H-A-213 (2)).
|
||||
func releaseCall(module, version string) revisionCall {
|
||||
return revisionCall{Call: ReleaseCall(module, version), Kind: meshcatalog.CatalogRevisionCallKindRelease, Module: module, Version: version}
|
||||
}
|
||||
|
||||
// takeInAgainCall is a take-in again's of repository (H-A-212).
|
||||
func takeInAgainCall(repository string) revisionCall {
|
||||
return revisionCall{Call: TakeInAgainCall(repository), Kind: meshcatalog.CatalogRevisionCallKindTakeInAgain, Repository: repository}
|
||||
}
|
||||
|
||||
// HeldObjectsFull is the reason a pending merge is held while the catalog graph revisions are full (Pending.Held).
|
||||
const HeldObjectsFull = "objects full"
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ func TestAReleaseRepinsAnEntryNamingItsPackageWithNoPin(t *testing.T) {
|
||||
for branch, src := range sources {
|
||||
rev, kept, found, err := readNewestOf(ctx, ix.Revisions, branch)
|
||||
if err != nil || !found || rev.Revision != 2 || rev.Source != src || rev.Call != "release of mesh-sdk 0.1.27" ||
|
||||
rev.CallKind != meshcatalog.CatalogRevisionCallKindRelease || rev.Module != "mesh-sdk" || rev.Version != "0.1.27" || // H-A-215
|
||||
len(rev.Movers) != 1 || rev.Movers[0].Module != "g" || rev.Movers[0].Fingerprint != now.Fp2 {
|
||||
t.Errorf("%s's newest = %+v (%v), want revision 2 of source %d, its call the release, g its mover at %s", branch, rev, err, src, now.Fp2)
|
||||
continue
|
||||
@@ -92,7 +93,8 @@ func TestAReleaseRepinsAnEntryNamingItsPackageWithNoPin(t *testing.T) {
|
||||
t.Errorf("%s's newest holds no entry of g at %s", branch, now.Fp2)
|
||||
}
|
||||
}
|
||||
if len(said) != 2 || said[0].Call != "release of mesh-sdk 0.1.27" || said[1].Call != said[0].Call {
|
||||
if len(said) != 2 || said[0].Call != "release of mesh-sdk 0.1.27" || said[1].Call != said[0].Call ||
|
||||
said[0].CallKind != meshcatalog.CatalogRevisionEventCallKindRelease || said[1].Module != "mesh-sdk" || said[1].Version != "0.1.27" {
|
||||
t.Errorf("said %+v, want catalog-revision of each branch with the release's call", said)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func (ix *Indexer) TakeInAgain(ctx context.Context, repository string) TakenIn {
|
||||
}
|
||||
// The take-in again keeps its revision as a re-pin does: the branch's next, of the same source, its call naming the
|
||||
// repository, its movers every module whose fingerprint moved (design 47 H-A-212, H-A-213).
|
||||
if err := ix.keepRepinned(ctx, ix, TrunkBranch, TakeInAgainCall(repository), nil); err != nil {
|
||||
if err := ix.keepRepinned(ctx, ix, TrunkBranch, takeInAgainCall(repository), nil); err != nil {
|
||||
return refuse("taken in again at %.12s, but its catalog revision is not kept: %v", t.Merge, err)
|
||||
}
|
||||
r.Stored, r.Commit = true, t.Merge
|
||||
|
||||
@@ -88,6 +88,7 @@ func TestATakeInAgainReachesARepositoryWithNoMergeSince(t *testing.T) {
|
||||
}
|
||||
rev, _, found, err := readNewestOf(ctx, ix.Revisions, TrunkBranch)
|
||||
if err != nil || !found || rev.Revision != 2 || rev.Source != 4 || rev.Call != "take-in again of novox/mesh-delivery" ||
|
||||
rev.CallKind != meshcatalog.CatalogRevisionCallKindTakeInAgain || rev.Repository != "novox/mesh-delivery" || // H-A-215
|
||||
len(rev.Movers) != 1 || rev.Movers[0].Module != "g" || rev.Movers[0].Fingerprint != m.Fp2 {
|
||||
t.Errorf("the newest trunk revision = %+v (%v), want revision 2 of source 4 with the take-in again's call and g its mover", rev, err)
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ func (ix *Indexer) takeInSource(ctx context.Context, e meshdelivery.SourceMovedE
|
||||
if e.Start {
|
||||
movers = nil // a branch's first revision moves nothing: its entries are the base later take-ins are held against (§768, H-A-19)
|
||||
}
|
||||
number, err := ix.keepBranchEntries(ctx, e.Branch, e.Source, e.Call, entries, movers)
|
||||
number, err := ix.keepBranchEntries(ctx, e.Branch, e.Source, takeInCall(e.Call), entries, movers)
|
||||
if err != nil {
|
||||
if errors.Is(err, ErrObjectsFull) {
|
||||
ix.heldFull.Store(true) // room is said once the store has room again (RoomAgain), and wakes the take-in (§744)
|
||||
|
||||
@@ -61,7 +61,8 @@ func TestASourceRevisionIsTakenInAsOneRevision(t *testing.T) {
|
||||
t.Fatalf("taken %+v, want revision 1 (the branch's first) of source 7 of main with avahi as its one mover", taken)
|
||||
}
|
||||
rev, _, err := ReadRevision(ctx, objects, "main.1")
|
||||
if err != nil || !reflect.DeepEqual(rev.Movers, taken.Entries) || rev.Source != 7 {
|
||||
if err != nil || !reflect.DeepEqual(rev.Movers, taken.Entries) || rev.Source != 7 ||
|
||||
rev.Call != moved.Call || rev.CallKind != meshcatalog.CatalogRevisionCallKindTakeIn { // H-A-215
|
||||
t.Fatalf("main.1 = %+v (%v), want it kept carrying the movers", rev, err)
|
||||
}
|
||||
if v, _, found, _ := ix.Pins.Get(ctx, PinKey("main", 1)); !found {
|
||||
|
||||
@@ -648,7 +648,7 @@ func (ix *Indexer) Repin(ctx context.Context, module, version string) (int, erro
|
||||
if err != nil {
|
||||
return named, err
|
||||
}
|
||||
if err := ix.keepRepinned(ctx, x, branch, ReleaseCall(module, version), only); err != nil {
|
||||
if err := ix.keepRepinned(ctx, x, branch, releaseCall(module, version), only); err != nil {
|
||||
return named, err
|
||||
}
|
||||
}
|
||||
@@ -680,7 +680,7 @@ func (ix *Indexer) repinned(ctx context.Context, module string) (map[string]bool
|
||||
// keepRepinned keeps x's view, re-pinned for the modules only names (every module for nil), as branch's next catalog revision
|
||||
// of the source of its newest, with call, when a fingerprint of them moved against that newest; its movers are those that
|
||||
// moved (H-A-211, H-A-212, H-A-213). A branch with no revision kept yet keeps none: there is no source to keep it of.
|
||||
func (ix *Indexer) keepRepinned(ctx context.Context, x *Indexer, branch, call string, only map[string]bool) error {
|
||||
func (ix *Indexer) keepRepinned(ctx context.Context, x *Indexer, branch string, call revisionCall, only map[string]bool) error {
|
||||
if ix.Revisions == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -689,7 +689,7 @@ func (ix *Indexer) keepRepinned(ctx context.Context, x *Indexer, branch, call st
|
||||
return fmt.Errorf("the newest catalog revision of %s: %w", branch, err)
|
||||
}
|
||||
if !found {
|
||||
ix.logf("re-pin (%s): %s keeps no revision yet, so none is kept for it", call, branch)
|
||||
ix.logf("re-pin (%s): %s keeps no revision yet, so none is kept for it", call.Call, branch)
|
||||
return nil
|
||||
}
|
||||
entries, err := x.viewEntries(ctx)
|
||||
@@ -713,13 +713,13 @@ func (ix *Indexer) keepRepinned(ctx context.Context, x *Indexer, branch, call st
|
||||
movers = append(movers, meshcatalog.TakeInEntry{Module: e.Module, Commit: e.Commit, Fingerprint: e.Fp, Repository: e.Repository})
|
||||
}
|
||||
if len(movers) == 0 {
|
||||
ix.logf("re-pin (%s): no fingerprint of %s moved, so no revision is kept", call, branch)
|
||||
ix.logf("re-pin (%s): no fingerprint of %s moved, so no revision is kept", call.Call, branch)
|
||||
return nil
|
||||
}
|
||||
number, err := ix.keepBranchEntries(ctx, branch, newest.Source, call, entries, movers)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ix.logf("re-pin (%s): %s kept as revision %d of source %d, %d movers", call, branch, number, newest.Source, len(movers))
|
||||
ix.logf("re-pin (%s): %s kept as revision %d of source %d, %d movers", call.Call, branch, number, newest.Source, len(movers))
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user