From 2349289444784ccb9f9f6bda914ce02695554ade Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:06:31 +0100 Subject: [PATCH 001/141] B1 floor-silent-retired: the builder's finding writer clears floor-silent at its start Builds: design 47 H2 H-A-578 (1), H-A-247 (3) --- .../cmd/mesh-delivery-builder/findings.go | 4 ++++ .../mesh-delivery-builder/cmd/mesh-delivery-builder/main.go | 2 +- .../cmd/mesh-delivery-builder/refused_test.go | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/findings.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/findings.go index ebee9999d..b5f98d2ac 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/findings.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/findings.go @@ -19,6 +19,10 @@ import ( // A-29); its `findings-asked` subject is the seat's, from the generated contract (A-17). type heldWriter = views.HeldWriter[mcseat.Finding, mcseat.FindingCleared, mcseat.FindingsStated, mcseat.FindingsAskedEvent] +// retiredFindingKinds are kinds no code of the builder raises any more, which its writer clears once at its start (design 47 H2 +// H-A-578 (1), H-A-247 (3)): floor-silent went with the version floor. +var retiredFindingKinds = []views.RetiredKind{{Kind: "floor-silent"}} + // findingWriter is the part of the held writer the builder's findings use; Held answers the findings it holds (design 47 G A-38). type findingWriter interface { Write(ctx context.Context, f mcseat.Finding) error diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index d4f7a7e95..ddb57ba36 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -99,7 +99,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro // The builder's findings are raised as they happen, so its one finding writer holds them (design 47 G A-29, §689): it // is started once the state is bound, and what is written before is stated at its start. fw, err := views.NewHeldWriter(views.WriterConfig[mcseat.Finding, mcseat.FindingCleared, mcseat.FindingsStated, mcseat.FindingsAskedEvent]{ - Module: cred.Module, State: calls.State("findings"), Node: cred.Node, Asked: mcseat.SubjectFindingsAsked, JS: js, Conn: conn, Logf: logger.Printf}) + Module: cred.Module, State: calls.State("findings"), Node: cred.Node, Asked: mcseat.SubjectFindingsAsked, Retired: retiredFindingKinds, JS: js, Conn: conn, Logf: logger.Printf}) if err != nil { return err } diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go index c53d57d9b..ee11565bd 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/refused_test.go @@ -566,4 +566,8 @@ func TestTheBuildersFindingsAreObservedByItsCredentialsModule(t *testing.T) { if err != nil || got.Observer != "acme-builder" { t.Fatalf("the finding = %+v, %v; want the observer acme-builder", got, err) } + // H2 H-A-578 (1): floor-silent, which no code of the builder raises any more, is cleared at the writer's start + if !slices.ContainsFunc(retiredFindingKinds, func(r views.RetiredKind) bool { return r.Kind == "floor-silent" && len(r.IDs) == 0 }) || slices.ContainsFunc(retiredFindingKinds, func(r views.RetiredKind) bool { return r.Kind == BuildFailed }) { + t.Error("the writer's retired kinds are not floor-silent alone") + } } From 9d98b2352bbbfd3f1608fd8ca58274babf1c113b Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:06:39 +0100 Subject: [PATCH 002/141] A1 tier-clock: tier-bound counts no time a mover waits for the operator's yes Builds: design 47 H2 H-A-627 (1) (2) (3); row A1 --- .../cmd/mesh-delivery-assigner/pipelines.go | 2 +- .../cmd/mesh-delivery-assigner/tiers.go | 107 +++++++++++++++++- .../cmd/mesh-delivery-assigner/tiers_test.go | 36 +++++- 3 files changed, 136 insertions(+), 9 deletions(-) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines.go index 87d43f3a3..1e301ab9f 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines.go @@ -360,7 +360,7 @@ func (e *pipelineEnds) branchOf(module, placed string) string { // writtenTools is the tool assigner_written: every key of the state written, with its end. func writtenTools(st store) []stdio.Tool { - return []stdio.Tool{{Name: writtenTool, Description: "the pipeline ends the assigner's wants follow: per module and watched branch, the newest version released whose pipeline passed, with its pipeline and rank; per pipeline whose wants are written tier by tier, its tier progress (tier, since, movers); with why, why each want is what it is (as assigner_why).", + return []stdio.Tool{{Name: writtenTool, Description: "the pipeline ends the assigner's wants follow: per module and watched branch, the newest version released whose pipeline passed, with its pipeline and rank; per pipeline whose wants are written tier by tier, its tier progress (tier, since, movers, and clock-from and paused-from: the time tier-bound counts from, and when a pause of the count by an ask of the operator began); with why, why each want is what it is (as assigner_why).", Input: schema(map[string]string{"why": "true: why each want is what it is", "module": "with why: a module's name", "node": "with why: a node's name"}, nil, "why"), Run: func(args map[string]any) (any, error) { if args["why"] == true || args["why"] == "true" { diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers.go index 6422d3ce7..685614f10 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers.go @@ -17,7 +17,9 @@ import ( "git.novox.be/novox/mesh-sdk/go/keys" "git.novox.be/novox/mesh-sdk/go/views" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-assigner/asks" "mesh-delivery-assigner/internal/assign" + "mesh-delivery-assigner/internal/buckets" ) // One pipeline's wants are written tier by tier (design 47 H §751, H-A-10, H-A-56): on a passed pipeline-ended the assigner @@ -55,6 +57,20 @@ type tierProgress struct { Since time.Time `json:"since"` Movers []tierMover `json:"movers"` Source int64 `json:"source,omitempty"` + // ClockFrom is the time tier-bound counts from, in Since's form: Since when the progress starts, moved later by each + // pause; absent reads as Since (design 47 H2 H-A-627). + ClockFrom time.Time `json:"clock-from,omitzero"` + // PausedFrom is the time the standing pause began: a key of the state asks names a mover of the tier that is not running, + // and the count stands still. Absent while the bound counts (H-A-627). + PausedFrom time.Time `json:"paused-from,omitzero"` +} + +// clockFrom is the time tier-bound counts from; Since in a progress kept before the field. +func (t tierProgress) clockFrom() time.Time { + if t.ClockFrom.IsZero() { + return t.Since + } + return t.ClockFrom } // tierKey is the key of pipeline's tier progress; pipeline is the runner's key `.`, its branch escaped. @@ -87,7 +103,8 @@ func (e *pipelineEnds) startTiers(pipeline string, source int64, movers []tierMo for _, m := range movers { first = min(first, m.Tier) } - t = tierProgress{Tier: first, Since: e.clock().UTC(), Source: source} + at := e.clock().UTC() + t = tierProgress{Tier: first, Since: at, ClockFrom: at, Source: source} } moved := false for i := range t.Movers { @@ -169,6 +186,7 @@ func (p *passer) tiers(n assign.Nodes, placedOn func(module, branch string) []st now := p.clock().UTC() bound := p.tierBoundOf() var next time.Time + standing := p.w.read(buckets.Asks()) for _, key := range ks { if !isTierKey(key) { continue @@ -185,13 +203,38 @@ func (p *passer) tiers(n assign.Nodes, placedOn func(module, branch string) []st break } notRunning := p.notRunning(n, placedOn, pipeline, branch, t, t.Tier) - late := !now.Before(t.Since.Add(bound)) + // The count stands still while an ask of the operator names a mover of the tier that is not running (H-A-627): the first + // pass that finds one writes paused-from, the first that finds none moves clock-from later by the time it stood still. + clock := t.clockFrom() + paused := pausedBy(standing, t, notRunning) + if paused && t.PausedFrom.IsZero() && now.Before(clock.Add(bound)) { + t.PausedFrom = now + if now.Before(t.Since) { + t.PausedFrom = t.Since // never earlier than the progress's own start + } + if p.writeTier(key, t, rev, "paused-from") { + p.logf("pipeline %s: tier %d's count of tier-bound stands still: %s", pipeline, t.Tier, pauseNamed(standing, t, notRunning)) + } + continue + } + if !paused && !t.PausedFrom.IsZero() { + held := now.Sub(t.PausedFrom) + t.ClockFrom, t.PausedFrom = clock.Add(held), time.Time{} + if p.writeTier(key, t, rev, "clock-from") { + p.logf("pipeline %s: tier %d's count of tier-bound stood still for %s and goes on; the tier is late at %s", pipeline, t.Tier, held.Round(time.Second), t.ClockFrom.Add(bound).Format(time.RFC3339)) + } + continue + } + if !t.PausedFrom.IsZero() { + break // paused: no lateness, and no timer armed + } + late := !now.Before(clock.Add(bound)) if late { p.tierLate(pipeline, branch, number, t, notRunning) break } if len(notRunning) > 0 { - if d := t.Since.Add(bound); next.IsZero() || d.Before(next) { + if d := clock.Add(bound); next.IsZero() || d.Before(next) { next = d } break @@ -211,7 +254,7 @@ func (p *passer) tiers(n assign.Nodes, placedOn func(module, branch string) []st p.sayPipelineWanted(pipeline, branch, number, t.Source, meshwants.PipelineWantedOutcomeRunning, nil) break } - value, err := json.Marshal(tierProgress{Tier: later, Since: now, Movers: t.Movers, Source: t.Source}) + value, err := json.Marshal(tierProgress{Tier: later, Since: now, ClockFrom: now, Movers: t.Movers, Source: t.Source}) if err == nil { err = p.ends.st.swap(key, value, rev) } @@ -366,3 +409,59 @@ func tierBoundSetting(getenv func(string) string) (time.Duration, error) { // tierBoundUnit is the unit of the setting tier-bound, a minute; the whole test sets a shorter one, so a tier passes its bound // without a test waiting minutes. var tierBoundUnit = time.Minute + +// writeTier swaps the tier progress at key by compare-and-set at rev; false when it was not written (the caller reads it again), +// the failure said but a lost race (what field the write was for names it). +func (p *passer) writeTier(key string, t tierProgress, rev uint64, field string) bool { + value, err := json.Marshal(t) + if err == nil { + err = p.ends.st.swap(key, value, rev) + } + if err != nil && !errors.Is(err, errSwapped) { + p.logf("the tier progress %s is not written (%s): %v", key, field, err) + } + return err == nil +} + +// pausingAsks are the keys of asks (the assigner's state asks, G §717) that pause the count of tier t of its pipeline: a key of +// any kind but assignments that names a mover of the tier by its module, by the mover's fingerprint where the kind's key names +// one (every kind but record, whose key names the composition), and, where it names a machine (every kind but hold), one of +// the machines on which the mover is not running (H-A-627 (1)); sorted. +func pausingAsks(standing map[string][]byte, t tierProgress, notRunning []meshwants.NotRunning) []string { + var out []string + for key := range standing { + k, err := asks.ParseAnyAskKey(key) + if err != nil || k.Kind == asks.AskKindAssignments || k.Module == "" { + continue + } + for _, m := range t.Movers { + if m.Tier != t.Tier || m.Module != k.Module || (k.Kind != asks.AskKindRecord && m.Fp != k.FP) { + continue + } + if k.Kind == asks.AskKindHold || notRunningOn(notRunning, m.Module, k.Node) { + out = append(out, key) + } + } + } + sort.Strings(out) + return out +} + +func notRunningOn(notRunning []meshwants.NotRunning, module, node string) bool { + return slices.ContainsFunc(notRunning, func(nr meshwants.NotRunning) bool { return nr.Module == module && slices.Contains(nr.Machines, node) }) +} + +// pausedBy says whether an ask of the operator pauses tier t's count (pausingAsks). +func pausedBy(standing map[string][]byte, t tierProgress, notRunning []meshwants.NotRunning) bool { + return len(pausingAsks(standing, t, notRunning)) > 0 +} + +// pauseNamed names the ask that pauses the count, for the journal: its key and the movers of the tier it names. +func pauseNamed(standing map[string][]byte, t tierProgress, notRunning []meshwants.NotRunning) string { + var named []string + for _, key := range pausingAsks(standing, t, notRunning) { + k, _ := asks.ParseAnyAskKey(key) + named = append(named, fmt.Sprintf("the ask %s about %s on %s", key, k.Module, k.Node)) + } + return strings.Join(named, "; ") +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers_test.go index 8bdcd70b4..c570ceb8f 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers_test.go @@ -18,6 +18,7 @@ import ( "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/views" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-assigner/asks" "mesh-delivery-assigner/internal/assign" "mesh-delivery-assigner/internal/buckets" ) @@ -32,7 +33,9 @@ func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) { for _, c := range []struct { runs bool pipeline string - }{{true, trunkBranch + ".5"}, {false, trunkBranch + ".5"}, {true, trunkBranch + ".5.again.2"}, {false, trunkBranch + ".5.again.2"}} { + paused bool // H-A-627: the provider's record ask stands in asks from minute 5 to minute 45, and the count stands still + }{{true, trunkBranch + ".5", false}, {false, trunkBranch + ".5", false}, {true, trunkBranch + ".5.again.2", false}, {false, trunkBranch + ".5.again.2", false}, + {true, trunkBranch + ".5", true}, {false, trunkBranch + ".5", true}} { runs, pipeline := c.runs, c.pipeline start := time.Date(2026, 11, 20, 4, 0, 0, 0, time.UTC) now := start @@ -83,12 +86,37 @@ func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) { if !wanted("g14", "db") || !wanted("ace", "db") || wanted("g14", "web") || wanted("ace", "web") { t.Fatalf("%s runs %v: tier 1 alone is not what is wanted first: %v", pipeline, runs, wantsKV.values) } + runAt, lateBefore, lateAt := time.Minute, 29*time.Minute, 30*time.Minute + if c.paused { + runAt, lateBefore, lateAt = 50*time.Minute, 69*time.Minute, 70*time.Minute + akey, err := asks.RecordAskKey("g14", "db", "sha256:"+strings.Repeat("a", 64)) + if err != nil { + t.Fatal(err) + } + now = start.Add(5 * time.Minute) + p.w.put(buckets.Asks(), akey, []byte(`{}`)) + p.wants(context.Background()) + now = start.Add(30 * time.Minute) // past tier-bound had the count not stood still + p.wants(context.Background()) + if len(findings) != 0 || len(said) != 0 { + t.Fatalf("%s: late at minute 30 while its provider's ask stands: %v, %+v", pipeline, findings, said) + } + if prog, _, _ := p.ends.tiersOf(pipeline); prog.PausedFrom.IsZero() || !prog.PausedFrom.Equal(start.Add(5*time.Minute)) { + t.Fatalf("%s: the pause's start is not kept: %+v", pipeline, prog) + } + now = start.Add(45 * time.Minute) + p.w.put(buckets.Asks(), akey, nil) + p.wants(context.Background()) + if prog, _, _ := p.ends.tiersOf(pipeline); !prog.PausedFrom.IsZero() || !prog.ClockFrom.Equal(start.Add(40*time.Minute)) { + t.Fatalf("%s: the pause's end does not move clock-from to minute 40: %+v", pipeline, prog) + } + } if runs { raw, _ := json.Marshal(nodeengine.Running{Node: "g14", Module: "db", Fingerprint: db}) if err := p.w.hearRunning("running.g14.db", raw); err != nil { t.Fatal(err) } - now = start.Add(time.Minute) + now = start.Add(runAt) p.wants(context.Background()) if !wanted("g14", "web") || !wanted("ace", "web") { t.Fatalf("%s: the consumer's want is not written once its provider runs: %v", pipeline, wantsKV.values) @@ -104,12 +132,12 @@ func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) { } continue } - now = start.Add(29 * time.Minute) + now = start.Add(lateBefore) p.wants(context.Background()) if len(findings) != 0 || len(said) != 0 { t.Fatalf("late before tier-bound: %v, %+v", findings, said) } - now = start.Add(30 * time.Minute) + now = start.Add(lateAt) p.wants(context.Background()) p.wants(context.Background()) f, ok := findings["delivery."+assign.KeyID(pipeline)+".tier-late"] From 628d5be5b66df3d1f32b9552767b0c8ce4cad20b Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:06:59 +0100 Subject: [PATCH 003/141] DC1 catalog-forms: the seat mesh-catalog's entry carries consumes, an artifact digests, a revision needs-rules (form 7) Builds: design 47 H2 H-A-580, H-A-605 (4), H-A-621, H-A-682 (1), H-A-698 (3) --- .../go/seats/meshcatalog/contract.go | 22 +++++++++--- .../go/seats/meshcatalog/contract_test.go | 6 ++-- .../seats/mesh-catalog/fixtures/states.json | 14 ++++++-- .../seats/mesh-catalog/seat.json | 36 +++++++++++++++++-- .../ts/seats/meshcatalog/index.d.ts | 15 +++++++- 5 files changed, 81 insertions(+), 12 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go index e22840516..66986138e 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract.go @@ -14,13 +14,13 @@ const Seat = "mesh-catalog" // Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): // a reader of a value of another form says "form N, this reader knows M". -const Form = 6 +const Form = 7 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "6" - generatedFieldsDigest = "ActingRule=8a83ce7e0457 Artifact=78b05c1a9ec3 ArtifactPackage=2a3a660a934d ArtifactRef=a2f06147f4b6 BuildEdge=76f0684e254a CandidatesByGroupValue=9ea8c6c580d2 CandidatesByGroupValuePullsItem=90fb03643258 CandidatesByGroupValuePullsItemFpsValue=4c6783201aa3 CatalogEntry=c0a4ea25d523 CatalogRevision=d1ecaaa484af CatalogRevisionDefinitionsItem=77fcff620d48 CatalogRevisionEvent=710cbc5bfff1 CatalogRevisionsByBranchRevisionValue=17e54f635d35 CatalogRevisionsByCandidateGroupHeadsValue=17e54f635d35 CatalogRevisionsByEntryDigestValue=8755036a3051 DependentsAnswer=7538f2f5e68e Edge=7242732afaef EntryAnswer=805c2ff28e1c EntryInputs=76a7f8690dd2 EntryRef=ff109e5089e1 Fill=80f442916429 FillingEvent=5bd4df78ed84 FingerprintInputs=99a6df7f991f FullEvent=5bd4df78ed84 Head=774b4bf88ba4 InputAnswer=cd41ee65565d InputsByTimeDigestValue=a2f06147f4b6 ManifestsByDigestValue=51b3822b29c6 ModuleAnswer=499a03ce9b27 ModuleAnswerModule=c0f679e09f08 ModulesAnswer=6d119571c69e ModulesAnswerModulesItem=a70f39c60b67 ModulesByModuleValue=fc7530ba893a ModulesByModuleValueInputs2=99a6df7f991f PackagesByModuleValue=2b62574b709f PackagesByModuleValuePackagesItem=a7d30558470d PackagesByPackageSeriesValue=07421d8d3411 PackagesByPackageSeriesValueNewest=aba144994370 PackagesByPackageSeriesValueNewestContents=eca2ccf56913 PackagesByPackageSeriesValueNewestContentsPackagesItem=a7d30558470d PackagesByPackageSeriesValueNumbered=c8ffc628599c PackagesByPackageSeriesValueNumberedContents=0def6c0794ee PackagesByPackageSeriesValueNumberedContentsPackagesItem=a7d30558470d Policy=719e2f460c6f PolicyAnswer=46cdf8430557 PredefinedByListValue=ec8e3febe8ac ProvidesAnswer=7538f2f5e68e RegisterAnswer=46cdf8430557 Registration=ef03d1b2e73f RegistrationAsked=b529a0e1c5ca RegistrationChangedEvent=99a3268edf41 RegistrationHistoryByModuleVersionValue=0999b5bb7dc7 RegistrationHistoryBySourceOwnerNameVersionValue=0999b5bb7dc7 RegistrationsAnswer=8849ef618cf3 RegistrationsByModuleValue=0999b5bb7dc7 RegistrationsBySourceOwnerNameValue=0999b5bb7dc7 RevisionAnswer=258ea5124931 RoomEvent=5bd4df78ed84 SeatDefinitionChangedEvent=e271d24d58f7 SeatDefinitionRemovedEvent=f7d6171111e6 SeatDefinitionsAnswer=0fd6a59fec59 SeatDefinitionsAnswerEntry=d006f68d2be5 SeatDefinitionsAnswerSeatsItem=e271d24d58f7 SeatListAnswer=04477a8044b1 SourceCheck=d1ed7cbbd579 StepStatuses=4f50aa633e61 TakeInEntry=545ec1528499 ToolchainUsed=43b6d42376fb UnwatchAnswer=46cdf8430557 VersionArtifact=438c49a392b0 VersionEdge=b0f80e83f4dc VersionEntry=33f5b00dbda9 VersionReleasedEvent=4ccf1ea90e7f VersionsAnswer=b59e6e057e7b VersionsByModuleVersionValue=e546dfadb913 WatchAnswer=46cdf8430557" + generatedForms = "7" + generatedFieldsDigest = "ActingRule=8a83ce7e0457 Artifact=0223a648b4e5 ArtifactDigestsItem=a7d30558470d ArtifactPackage=2a3a660a934d ArtifactRef=a2f06147f4b6 BuildEdge=76f0684e254a CandidatesByGroupValue=9ea8c6c580d2 CandidatesByGroupValuePullsItem=90fb03643258 CandidatesByGroupValuePullsItemFpsValue=4c6783201aa3 CatalogEntry=4c82dcc1e492 CatalogRevision=178230def2a0 CatalogRevisionDefinitionsItem=77fcff620d48 CatalogRevisionEvent=710cbc5bfff1 CatalogRevisionsByBranchRevisionValue=17e54f635d35 CatalogRevisionsByCandidateGroupHeadsValue=17e54f635d35 CatalogRevisionsByEntryDigestValue=8755036a3051 DependentsAnswer=7538f2f5e68e Edge=7242732afaef EntryAnswer=805c2ff28e1c EntryInputs=76a7f8690dd2 EntryRef=ff109e5089e1 Fill=80f442916429 FillingEvent=5bd4df78ed84 FingerprintInputs=99a6df7f991f FullEvent=5bd4df78ed84 Head=774b4bf88ba4 InputAnswer=cd41ee65565d InputsByTimeDigestValue=a2f06147f4b6 ManifestsByDigestValue=51b3822b29c6 ModuleAnswer=499a03ce9b27 ModuleAnswerModule=c0f679e09f08 ModulesAnswer=6d119571c69e ModulesAnswerModulesItem=a70f39c60b67 ModulesByModuleValue=fc7530ba893a ModulesByModuleValueInputs2=99a6df7f991f PackagesByModuleValue=2b62574b709f PackagesByModuleValuePackagesItem=a7d30558470d PackagesByPackageSeriesValue=07421d8d3411 PackagesByPackageSeriesValueNewest=aba144994370 PackagesByPackageSeriesValueNewestContents=eca2ccf56913 PackagesByPackageSeriesValueNewestContentsPackagesItem=a7d30558470d PackagesByPackageSeriesValueNumbered=c8ffc628599c PackagesByPackageSeriesValueNumberedContents=0def6c0794ee PackagesByPackageSeriesValueNumberedContentsPackagesItem=a7d30558470d Policy=719e2f460c6f PolicyAnswer=46cdf8430557 PredefinedByListValue=ec8e3febe8ac ProvidesAnswer=7538f2f5e68e RegisterAnswer=46cdf8430557 Registration=ef03d1b2e73f RegistrationAsked=b529a0e1c5ca RegistrationChangedEvent=99a3268edf41 RegistrationHistoryByModuleVersionValue=0999b5bb7dc7 RegistrationHistoryBySourceOwnerNameVersionValue=0999b5bb7dc7 RegistrationsAnswer=8849ef618cf3 RegistrationsByModuleValue=0999b5bb7dc7 RegistrationsBySourceOwnerNameValue=0999b5bb7dc7 RevisionAnswer=258ea5124931 RoomEvent=5bd4df78ed84 SeatDefinitionChangedEvent=e271d24d58f7 SeatDefinitionRemovedEvent=f7d6171111e6 SeatDefinitionsAnswer=0fd6a59fec59 SeatDefinitionsAnswerEntry=d006f68d2be5 SeatDefinitionsAnswerSeatsItem=e271d24d58f7 SeatListAnswer=04477a8044b1 SourceCheck=d1ed7cbbd579 StepStatuses=4f50aa633e61 TakeInEntry=545ec1528499 ToolchainUsed=43b6d42376fb UnwatchAnswer=46cdf8430557 VersionArtifact=438c49a392b0 VersionEdge=b0f80e83f4dc VersionEntry=33f5b00dbda9 VersionReleasedEvent=4ccf1ea90e7f VersionsAnswer=b59e6e057e7b VersionsByModuleVersionValue=e546dfadb913 WatchAnswer=46cdf8430557" ) const ( @@ -625,6 +625,14 @@ type ActingRule struct { Step string `json:"step"` } +// ArtifactDigestsItem is a type of the contract. +type ArtifactDigestsItem struct { + // the package's digest, by its files (design 47 H2 H-A-580) + Digest string `json:"digest"` + // the package's Go import path or npm name + Package string `json:"package"` +} + // ArtifactPackage is the package's name read from the revision's own files at the artifact's path (the module of its go.mod, the name of its package.json, the manifest's image name), written at take-in (design 47 G section 676). type ArtifactPackage struct { // go, npm or image @@ -634,6 +642,8 @@ type ArtifactPackage struct { // Artifact is one artifact of a module in the catalog graph entry. type Artifact struct { + // the digest of each package of the artifact, kept by the indexer when it computes the entry, so an importer reads the digest of each package it imports from the entry that publishes it (design 47 H2 H-A-580) + Digests []ArtifactDigestsItem `json:"digests,omitempty"` // the artifact's kind Kind string `json:"kind,omitempty"` // the artifact's language as its manifest says it (go, typescript, ...); a step's build seat is read from it (design 47 G section 323) @@ -670,6 +680,8 @@ type CatalogEntry struct { Class string `json:"class,omitempty"` // the merge commit it was last changed at Commit string `json:"commit"` + // the subjects its accepted manifest consumes, filled by the indexer beside invokes (design 47 H2 H-A-621) + Consumes []string `json:"consumes,omitempty"` // the requirements the manifest's contributes object names as keys, sorted, its local names not carried; each is also in requires (design 47 G section 709) Contributes []string `json:"contributes,omitempty"` // the edges into this module's artifacts, each from the artifact that comes first; the build and the delivery order by these alone @@ -690,7 +702,7 @@ type CatalogEntry struct { // the sha256: digest of the manifest's bytes as the forge answered them, set by the indexer at take-in and never computed again from the manifest whole; the module's value and the manifests key are this digest (design 47 G section 506) ManifestDigest string `json:"manifest-digest,omitempty"` Module string `json:"module"` - // the manifest reads a node-engine must state to compose it, its templates' forms included, as the forge bridge read them at the merge (ADR 0614 §4, ADR 0632 §2) + // the manifest reads a node-engine must state to compose it, its templates' forms included, as the indexer derives them at the take-in (ADR 0614 §4, ADR 0632 §2) Needs []string `json:"needs,omitempty"` // why it has none None string `json:"none,omitempty"` @@ -747,6 +759,8 @@ type CatalogRevision struct { 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"` + // the version of the manifest validator's need rules this revision's entries were derived with, absent read as 0; a take-in derives the rule needs of unmoved entries again only when its own is higher than its base revision's (design 47 H2 H-A-569 (2), H-A-605 (4)) + NeedsRules int64 `json:"needs-rules,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 diff --git a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go index 0a6c75587..646ad9311 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshcatalog/contract_test.go @@ -57,7 +57,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\",\"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\"}", + {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\"}],\"needs-rules\":2,\"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\"}],\"needs-rules\":2,\"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) @@ -69,7 +69,7 @@ func TestFixtures(t *testing.T) { err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, - {name: "a catalog graph entry (xclip)", subject: "", given: "{\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"xclip\",\"version\":\"1\"},\"manifest-digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", wire: "{\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"xclip\",\"version\":\"1\"},\"manifest-digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", + {name: "a catalog graph entry (xclip)", subject: "", given: "{\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"consumes\":[\"node-engine.running.*.*\"],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"xclip\",\"version\":\"1\"},\"manifest-digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", wire: "{\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"consumes\":[\"node-engine.running.*.*\"],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"xclip\",\"version\":\"1\"},\"manifest-digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", decode: func(b []byte) (any, error) { var v CatalogRevisionsByEntryDigestValue err := json.Unmarshal(b, &v) @@ -99,7 +99,7 @@ func TestFixtures(t *testing.T) { err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, - {name: "an entry with its artifacts and the edges into them, per artifact", subject: "", given: "{\"artifacts\":[{\"language\":\"go\",\"ref\":\"mesh-grants:program\"},{\"language\":\"go\",\"ref\":\"mesh-grants:tools\"}],\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"edges\":[{\"from\":\"mesh-grants:program\",\"kind\":6,\"to\":\"node-tools:runtime\",\"why\":\"seat mesh-grants verb grants\"},{\"from\":\"node-tools:runtime\",\"kind\":4,\"to\":\"mesh-grants:tools\",\"why\":\"the tool runner runs the tools\"},{\"from\":\"mesh-sdk:go\",\"kind\":1,\"to\":\"mesh-grants:program\",\"why\":\"git.novox.be/novox/mesh-sdk/go\"},{\"declared\":true,\"from\":\"nats:program\",\"kind\":4,\"to\":\"mesh-grants:program\",\"why\":\"declared in needs\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"mesh-grants\",\"version\":\"1\"},\"module\":\"mesh-grants\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", wire: "{\"artifacts\":[{\"language\":\"go\",\"ref\":\"mesh-grants:program\"},{\"language\":\"go\",\"ref\":\"mesh-grants:tools\"}],\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"edges\":[{\"from\":\"mesh-grants:program\",\"kind\":6,\"to\":\"node-tools:runtime\",\"why\":\"seat mesh-grants verb grants\"},{\"from\":\"node-tools:runtime\",\"kind\":4,\"to\":\"mesh-grants:tools\",\"why\":\"the tool runner runs the tools\"},{\"from\":\"mesh-sdk:go\",\"kind\":1,\"to\":\"mesh-grants:program\",\"why\":\"git.novox.be/novox/mesh-sdk/go\"},{\"declared\":true,\"from\":\"nats:program\",\"kind\":4,\"to\":\"mesh-grants:program\",\"why\":\"declared in needs\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"mesh-grants\",\"version\":\"1\"},\"module\":\"mesh-grants\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", + {name: "an entry with its artifacts and the edges into them, per artifact", subject: "", given: "{\"artifacts\":[{\"digests\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"package\":\"git.novox.be/novox/mesh-sdk/go/keys\"}],\"language\":\"go\",\"ref\":\"mesh-grants:program\"},{\"language\":\"go\",\"ref\":\"mesh-grants:tools\"}],\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"edges\":[{\"from\":\"mesh-grants:program\",\"kind\":6,\"to\":\"node-tools:runtime\",\"why\":\"seat mesh-grants verb grants\"},{\"from\":\"node-tools:runtime\",\"kind\":4,\"to\":\"mesh-grants:tools\",\"why\":\"the tool runner runs the tools\"},{\"from\":\"mesh-sdk:go\",\"kind\":1,\"to\":\"mesh-grants:program\",\"why\":\"git.novox.be/novox/mesh-sdk/go\"},{\"declared\":true,\"from\":\"nats:program\",\"kind\":4,\"to\":\"mesh-grants:program\",\"why\":\"declared in needs\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"mesh-grants\",\"version\":\"1\"},\"module\":\"mesh-grants\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", wire: "{\"artifacts\":[{\"digests\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"package\":\"git.novox.be/novox/mesh-sdk/go/keys\"}],\"language\":\"go\",\"ref\":\"mesh-grants:program\"},{\"language\":\"go\",\"ref\":\"mesh-grants:tools\"}],\"bases\":[\"arch\"],\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"edges\":[{\"from\":\"mesh-grants:program\",\"kind\":6,\"to\":\"node-tools:runtime\",\"why\":\"seat mesh-grants verb grants\"},{\"from\":\"node-tools:runtime\",\"kind\":4,\"to\":\"mesh-grants:tools\",\"why\":\"the tool runner runs the tools\"},{\"from\":\"mesh-sdk:go\",\"kind\":1,\"to\":\"mesh-grants:program\",\"why\":\"git.novox.be/novox/mesh-sdk/go\"},{\"declared\":true,\"from\":\"nats:program\",\"kind\":4,\"to\":\"mesh-grants:program\",\"why\":\"declared in needs\"}],\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"inputs\":{\"from\":{\"bases\":[\"arch\"],\"locks\":{\"go.sum\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\"},\"packages\":[\"git.novox.be/novox/mesh-sdk/go@v0.0.0-20261101000000-f469eb387a30\"],\"tree\":\"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"},\"toolchains\":{\"go\":{\"language\":\"go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}}},\"invokes\":[\"node-files.read\"],\"manifest\":{\"module\":\"mesh-grants\",\"version\":\"1\"},\"module\":\"mesh-grants\",\"packages\":{\"git.novox.be/novox/mesh-sdk/go\":\"v0.0.0-20261101000000-f469eb387a30\"},\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\",\"toolchains\":{\"go\":{\"module\":\"mesh-build-go\",\"recipe\":\"1\",\"version\":\"1.26.0\"}},\"v\":1,\"verdict\":\"accepted\"}", decode: func(b []byte) (any, error) { var v CatalogRevisionsByEntryDigestValue err := json.Unmarshal(b, &v) diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json index 737600b85..53c8ef963 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/fixtures/states.json @@ -213,7 +213,8 @@ "call": "release of mesh-sdk 0.1.27", "call-kind": "release", "module": "mesh-sdk", - "version": "0.1.27" + "version": "0.1.27", + "needs-rules": 2 } }, { @@ -303,6 +304,9 @@ }, "invokes": [ "node-files.read" + ], + "consumes": [ + "node-engine.running.*.*" ] } }, @@ -504,7 +508,13 @@ "artifacts": [ { "ref": "mesh-grants:program", - "language": "go" + "language": "go", + "digests": [ + { + "package": "git.novox.be/novox/mesh-sdk/go/keys", + "digest": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + ] }, { "ref": "mesh-grants:tools", diff --git a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json index 5a46b0b1c..9f22a9a31 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-catalog/seat.json @@ -1691,6 +1691,13 @@ }, "description": "each a seat verb or a module tool it calls" }, + "consumes": { + "type": "array", + "items": { + "type": "string" + }, + "description": "the subjects its accepted manifest consumes, filled by the indexer beside invokes (design 47 H2 H-A-621)" + }, "serves": { "type": "array", "items": { @@ -1710,7 +1717,7 @@ "items": { "type": "string" }, - "description": "the manifest reads a node-engine must state to compose it, its templates' forms included, as the forge bridge read them at the merge (ADR 0614 §4, ADR 0632 §2)" + "description": "the manifest reads a node-engine must state to compose it, its templates' forms included, as the indexer derives them at the take-in (ADR 0614 §4, ADR 0632 §2)" }, "main": { "type": "string", @@ -1989,6 +1996,10 @@ "base": { "type": "integer", "description": "the newest kept revision of its branch below it, which the take-in that wrote it pinned for its pipeline: the base of the validate step's case before (design 47 H-A-147, H-A-151, H-A-154); absent on the branch's first take-in" + }, + "needs-rules": { + "type": "integer", + "description": "the version of the manifest validator's need rules this revision's entries were derived with, absent read as 0; a take-in derives the rule needs of unmoved entries again only when its own is higher than its base revision's (design 47 H2 H-A-569 (2), H-A-605 (4))" } }, "required": [ @@ -2433,6 +2444,27 @@ "ecosystem", "name" ] + }, + "digests": { + "type": "array", + "items": { + "type": "object", + "properties": { + "package": { + "type": "string", + "description": "the package's Go import path or npm name" + }, + "digest": { + "type": "string", + "description": "the package's digest, by its files (design 47 H2 H-A-580)" + } + }, + "required": [ + "package", + "digest" + ] + }, + "description": "the digest of each package of the artifact, kept by the indexer when it computes the entry, so an importer reads the digest of each package it imports from the entry that publishes it (design 47 H2 H-A-580)" } }, "required": [ @@ -2566,5 +2598,5 @@ ] } }, - "form": 6 + "form": 7 } diff --git a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts index 3a2592697..a213095ef 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshcatalog/index.d.ts @@ -171,6 +171,13 @@ export interface ActingRule { "step": string; } +export interface ArtifactDigestsItem { + /** the package's digest, by its files (design 47 H2 H-A-580) */ + "digest": string; + /** the package's Go import path or npm name */ + "package": string; +} + /** the package's name read from the revision's own files at the artifact's path (the module of its go.mod, the name of its package.json, the manifest's image name), written at take-in (design 47 G section 676) */ export interface ArtifactPackage { /** go, npm or image */ @@ -180,6 +187,8 @@ export interface ArtifactPackage { /** one artifact of a module in the catalog graph entry */ export interface Artifact { + /** the digest of each package of the artifact, kept by the indexer when it computes the entry, so an importer reads the digest of each package it imports from the entry that publishes it (design 47 H2 H-A-580) */ + "digests"?: ArtifactDigestsItem[]; /** the artifact's kind */ "kind"?: string; /** the artifact's language as its manifest says it (go, typescript, ...); a step's build seat is read from it (design 47 G section 323) */ @@ -216,6 +225,8 @@ export interface CatalogEntry { "class"?: string; /** the merge commit it was last changed at */ "commit": string; + /** the subjects its accepted manifest consumes, filled by the indexer beside invokes (design 47 H2 H-A-621) */ + "consumes"?: string[]; /** the requirements the manifest's contributes object names as keys, sorted, its local names not carried; each is also in requires (design 47 G section 709) */ "contributes"?: string[]; /** the edges into this module's artifacts, each from the artifact that comes first; the build and the delivery order by these alone */ @@ -236,7 +247,7 @@ export interface CatalogEntry { /** the sha256: digest of the manifest's bytes as the forge answered them, set by the indexer at take-in and never computed again from the manifest whole; the module's value and the manifests key are this digest (design 47 G section 506) */ "manifest-digest"?: string; "module": string; - /** the manifest reads a node-engine must state to compose it, its templates' forms included, as the forge bridge read them at the merge (ADR 0614 §4, ADR 0632 §2) */ + /** the manifest reads a node-engine must state to compose it, its templates' forms included, as the indexer derives them at the take-in (ADR 0614 §4, ADR 0632 §2) */ "needs"?: string[]; /** why it has none */ "none"?: string; @@ -292,6 +303,8 @@ export interface CatalogRevision { "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[]; + /** the version of the manifest validator's need rules this revision's entries were derived with, absent read as 0; a take-in derives the rule needs of unmoved entries again only when its own is higher than its base revision's (design 47 H2 H-A-569 (2), H-A-605 (4)) */ + "needs-rules"?: number; /** 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 */ From 98a9c199c1f492034800a50023dd9dd03caa04ad Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:08:03 +0100 Subject: [PATCH 004/141] DC2 step-runner-delivery-forms: step-ended's revision present exactly when superseded (form 4), mover-added and place-unfinished's all (form 13), record-ended's ends (form 3) Builds: design 47 H2 H-A-574, H-A-594 (4), H-A-609 (3), H-A-617, H-A-644, H-A-645, H-A-650 --- .../go/seats/meshbuilds/contract.go | 6 +- .../go/seats/meshbuilds/contract_test.go | 2 + .../go/seats/meshdelivery/contract.go | 8 ++- .../go/seats/meshdelivery/contract_test.go | 2 +- .../go/seats/meshpipelinerunner/contract.go | 57 ++++++++++++++++-- .../seats/meshpipelinerunner/contract_test.go | 8 +++ .../seats/mesh-builds/fixtures/events.json | 22 +++++++ .../seats/mesh-builds/seat.json | 4 +- .../seats/mesh-delivery/fixtures/events.json | 3 +- .../seats/mesh-delivery/seat.json | 6 +- .../mesh-pipeline-runner/fixtures/events.json | 30 +++++++++- .../mesh-pipeline-runner/fixtures/verbs.json | 16 +++++ .../seats/mesh-pipeline-runner/seat.json | 59 ++++++++++++++++++- .../ts/seats/meshbuilds/index.d.ts | 2 +- .../ts/seats/meshdelivery/index.d.ts | 2 + .../ts/seats/meshpipelinerunner/index.d.ts | 35 ++++++++++- .../ts/seats/meshpipelinerunner/index.js | 9 +++ 17 files changed, 247 insertions(+), 24 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go index 002593838..00032cb0c 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go @@ -13,12 +13,12 @@ const Seat = "mesh-builds" // Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): // a reader of a value of another form says "form N, this reader knows M". -const Form = 3 +const Form = 4 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "3" + generatedForms = "4" generatedFieldsDigest = "AskTakenEvent=6d5d3da7ac39 BuildEntry=3c829a0a3d58 Dependency=90a32b07c563 DropAnswer=7538f2f5e68e PackagePublished=34dd069a6aab PackagePublishedEvent=8e12888c1559 PublishQueueAnswer=0f1326e35e17 PublishQueueAnswerCountsItem=b770db2f0920 PublishQueueAnswerQueueItem=b1eebc09f41e PublishedAnswer=69a801982819 ReservedAnswer=2272a4d6f0f4 ReservedAnswerArtifactsItem=d74eb6e00abb Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 StepAccept=18efeefb6c34 StepEnded=be571d4ff16f StepEndedEvent=207787118dac StepProgressEvent=8215e490ea8d StepRun=dc5893aef7e5 ToolchainAgreed=f3d9ce993734 ToolchainAgreedDigestsItem=1d42893a96b9 ToolchainAgreedEvent=e3502d6f194d VersionReservedEvent=984547d6ad07" ) @@ -198,7 +198,7 @@ type StepEnded struct { Packages map[string]string `json:"packages,omitempty"` Pipeline string `json:"pipeline"` Rerun bool `json:"rerun,omitempty"` - // for a step ended superseded, the module graph revision of the entry that superseded it, 0 when the builder knows none; the runner moves the mover out only for a revision newer than its pipeline's that its view holds (design 47 H2 H-A-561) + // the module graph revision of the entry that superseded the step, present exactly when outcome is superseded and absent otherwise; the runner moves the mover out only for a revision newer than its pipeline's that its view holds (design 47 H2 H-A-574, H-A-650) Revision int64 `json:"revision,omitempty"` // why it failed, could not run or was superseded: the entry not built, the part not heard, the superseding fingerprint Said string `json:"said,omitempty"` diff --git a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract_test.go index f1bf4660f..015ba4fa4 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract_test.go @@ -35,6 +35,8 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v VersionReservedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.version-reserved$")}, {name: "a build step's progress while its build waits for a package", subject: "mesh.seat.mesh-builds.event.step-progress.anchor", given: "{\"ask\":\"a1b2\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-23T02:40:00Z\",\"phase\":\"build\"}", wire: "{\"ask\":\"a1b2\",\"asker\":\"mesh-delivery-pipeline\",\"at\":\"2026-11-23T02:40:00Z\",\"phase\":\"build\"}", decode: func(b []byte) (any, error) { var v StepProgressEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-progress\\.[^.*> ]+$")}, + {name: "the step ended superseded in form 4: revision present exactly when superseded (H-A-574, H-A-650)", subject: "mesh.seat.mesh-builds.event.step-ended.laptop", given: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"form\":4,\"id\":\"m2kx9a1b3c4d6f\",\"node\":\"laptop\",\"outcome\":\"superseded\",\"pipeline\":\"main.12.nats\",\"revision\":14,\"said\":\"nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch\",\"step\":\"build\",\"v\":1}", wire: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"form\":4,\"id\":\"m2kx9a1b3c4d6f\",\"node\":\"laptop\",\"outcome\":\"superseded\",\"pipeline\":\"main.12.nats\",\"revision\":14,\"said\":\"nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch\",\"step\":\"build\",\"v\":1}", + decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-ended\\.[^.*> ]+$")}, {name: "reserved asks a module", subject: "", given: "{\"module\":\"mesh-sdk\"}", wire: "{\"module\":\"mesh-sdk\"}", decode: func(b []byte) (any, error) { var v ReservedInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "reserved asks a package by its name", subject: "", given: "{\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"version\":\"0.1.15\"}", wire: "{\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"version\":\"0.1.15\"}", diff --git a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go index 5ee0a165e..b6fb4877d 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract.go @@ -14,13 +14,13 @@ const Seat = "mesh-delivery" // Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): // a reader of a value of another form says "form N, this reader knows M". -const Form = 2 +const Form = 3 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "2" - generatedFieldsDigest = "DeliveriesAnswer=d6ae3ca4e5da Fill=80f442916429 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 HeadsByRepositoryBranchValue=b32fd594ee25 Owed=a30ee01924cc OwedByRepositoryNumberHeadActValue=f16ff5733d62 OwedEvent=86af3b56de28 RecordEndedEvent=566edb8684e5 RecordEndedEventAwayItem=44ad7d26bd16 RecordOpenedEvent=9cf9afaa25b4 RecoveryAnswer=8c705e17cdf8 RecoveryMergedEvent=014d4d00d2e5 RoomEvent=5bd4df78ed84 ShowAnswer=7538f2f5e68e SourceAnswer=6ae84f05f10d SourceByBranchValue=31aa822718c0 SourceHead=e722e2d9492f SourceMovedEvent=5231909928e9 SourceMovedEventHeadsItem=774b4bf88ba4 StalledAnswer=7538f2f5e68e" + generatedForms = "3" + generatedFieldsDigest = "DeliveriesAnswer=d6ae3ca4e5da Fill=80f442916429 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 HeadsByRepositoryBranchValue=b32fd594ee25 Owed=a30ee01924cc OwedByRepositoryNumberHeadActValue=f16ff5733d62 OwedEvent=86af3b56de28 RecordEndedEvent=c693c67bd78c RecordEndedEventAwayItem=44ad7d26bd16 RecordOpenedEvent=9cf9afaa25b4 RecoveryAnswer=8c705e17cdf8 RecoveryMergedEvent=014d4d00d2e5 RoomEvent=5bd4df78ed84 ShowAnswer=7538f2f5e68e SourceAnswer=6ae84f05f10d SourceByBranchValue=31aa822718c0 SourceHead=e722e2d9492f SourceMovedEvent=5231909928e9 SourceMovedEventHeadsItem=774b4bf88ba4 StalledAnswer=7538f2f5e68e" ) const ( @@ -436,6 +436,8 @@ type RecordEndedEvent struct { Branch string `json:"branch"` // the merge call Call string `json:"call"` + // the record's end count, one higher at each end after the first, as pipeline-ended's end count is (design 47 H2 H-A-597, H-A-617) + Ends int64 `json:"ends,omitempty"` // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). Form int64 `json:"form,omitempty"` // its milestone, . diff --git a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract_test.go index bdf78c409..368f47b9f 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshdelivery/contract_test.go @@ -21,7 +21,7 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v OwedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.owed\\.[^.*> ]+\\.[^.*> ]+$")}, {name: "record-opened is said", subject: "mesh.seat.mesh-delivery.event.record-opened.0123456789abcdef", given: "{\"at\":\"2026-11-20T02:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"milestone\":\"main.1044\",\"record\":\"main.1044\",\"source\":1044}", wire: "{\"at\":\"2026-11-20T02:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"milestone\":\"main.1044\",\"record\":\"main.1044\",\"source\":1044}", decode: func(b []byte) (any, error) { var v RecordOpenedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.record-opened\\.[^.*> ]+$")}, - {name: "record-ended is said", subject: "mesh.seat.mesh-delivery.event.record-ended", given: "{\"at\":\"2026-11-09T21:00:00Z\",\"away\":[{\"node\":\"laptop\",\"since\":\"2026-11-09T18:00:00Z\"}],\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"milestone\":\"main.1044\",\"record\":\"main.1044\",\"source\":1044}", wire: "{\"at\":\"2026-11-09T21:00:00Z\",\"away\":[{\"node\":\"laptop\",\"since\":\"2026-11-09T18:00:00Z\"}],\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"milestone\":\"main.1044\",\"record\":\"main.1044\",\"source\":1044}", + {name: "record-ended is said", subject: "mesh.seat.mesh-delivery.event.record-ended", given: "{\"at\":\"2026-11-09T21:00:00Z\",\"away\":[{\"node\":\"laptop\",\"since\":\"2026-11-09T18:00:00Z\"}],\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"ends\":2,\"milestone\":\"main.1044\",\"record\":\"main.1044\",\"source\":1044}", wire: "{\"at\":\"2026-11-09T21:00:00Z\",\"away\":[{\"node\":\"laptop\",\"since\":\"2026-11-09T18:00:00Z\"}],\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"ends\":2,\"milestone\":\"main.1044\",\"record\":\"main.1044\",\"source\":1044}", decode: func(b []byte) (any, error) { var v RecordEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.record-ended$")}, {name: "filling is said", subject: "mesh.seat.mesh-delivery.event.filling", given: "{\"bytes\":650000000,\"cap\":805306368,\"store\":\"records\"}", wire: "{\"bytes\":650000000,\"cap\":805306368,\"store\":\"records\"}", decode: func(b []byte) (any, error) { var v FillingEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-delivery\\.event\\.filling$")}, diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index 22a9a5c7a..7189ad1d8 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -14,13 +14,13 @@ const Seat = "mesh-pipeline-runner" // Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): // a reader of a value of another form says "form N, this reader knows M". -const Form = 12 +const Form = 13 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "12" - generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverEnded=4b35095f6829 MoverRow=b61f41d131a3 Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=397a8219a855 PipelineStarted=582f8ff3b28d PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=ed94ced4513a Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=48b8cecc529a StandsAnswer=0afa3693bf3b StartAnswer=ed94ced4513a StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=bdaa8bbfbcab StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=21e4ee7a3ef1 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" + generatedForms = "13" + generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverAdded=6966283f6909 MoverAddedEvent=b24ae82030ab MoverEnded=4b35095f6829 MoverRow=b61f41d131a3 Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=397a8219a855 PipelineStarted=582f8ff3b28d PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=ed94ced4513a Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=48b8cecc529a StandsAnswer=0afa3693bf3b StartAnswer=ed94ced4513a StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=bdaa8bbfbcab StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=21e4ee7a3ef1 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" ) const ( @@ -45,6 +45,7 @@ const ( const ( EventPipelineStarted = "pipeline-started" + EventMoverAdded = "mover-added" EventPipelineEnded = "pipeline-ended" EventRunStarted = "run-started" EventStepStarted = "step-started" @@ -106,7 +107,7 @@ func VerbDescription(verb string) string { // Events is every event published on the seat's subject: a new copy each call. func Events() []string { - return []string{EventPipelineStarted, EventPipelineEnded, EventRunStarted, EventStepStarted, EventStepEnded, EventWaitHeld, EventWaitEnded, EventRePinned, EventFilling, EventFull, EventRoom} + return []string{EventPipelineStarted, EventMoverAdded, EventPipelineEnded, EventRunStarted, EventStepStarted, EventStepEnded, EventWaitHeld, EventWaitEnded, EventRePinned, EventFilling, EventFull, EventRoom} } // Family is where the seat's events are kept: the shared events stream, filtered to the seat's subjects. @@ -126,6 +127,17 @@ func SubjectPipelineStarted(branch, revision string) string { // SubjectPipelineStartedAll hears every pipeline-started. const SubjectPipelineStartedAll = "mesh.seat.mesh-pipeline-runner.event.pipeline-started.*.*" +// StreamMoverAdded is the stream mover-added is kept in. +const StreamMoverAdded = "SEAT_mesh-pipeline-runner_mover-added" + +// SubjectMoverAdded is where mover-added is published, on mesh.seat.mesh-pipeline-runner.event.mover-added... +func SubjectMoverAdded(branch, revision string) string { + return "mesh.seat.mesh-pipeline-runner.event.mover-added." + branch + "." + revision +} + +// SubjectMoverAddedAll hears every mover-added. +const SubjectMoverAddedAll = "mesh.seat.mesh-pipeline-runner.event.mover-added.*.*" + // StreamPipelineEnded is the stream pipeline-ended is kept in. const StreamPipelineEnded = "SEAT_mesh-pipeline-runner_pipeline-ended" @@ -717,6 +729,25 @@ const ( MoverUnplacedKeptRevisionUnread = "kept-revision-unread" ) +// MoverAdded is a mover added to a pipeline that waits or runs, or put in a reopened one: said on the pipeline's subject as pipeline-started is, with exactly one of from, caller or take-in; a reader refuses one naming none or two (design 47 H2 H-A-594 (4), H-A-609 (3), H-A-645). +type MoverAdded struct { + // the caller of start, as the runtime proved it + Caller string `json:"caller,omitempty"` + // the mover's fingerprint + Fingerprint string `json:"fingerprint"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` + // the key of the pipeline the mover came from + From string `json:"from,omitempty"` + Module string `json:"module"` + // the key of the pipeline that carries the mover + Pipeline string `json:"pipeline"` + // the catalog graph revision of the pipeline + Revision int64 `json:"revision"` + // the source revision of the take-in whose entries were added to a pipeline already held + TakeIn int64 `json:"take-in,omitempty"` +} + // MoverEnded is one mover at its pipeline's end (design 47 H §746). type MoverEnded struct { // the commit the mover's entry was last changed at, from the pipeline's value (design 47 H-A-119) @@ -1559,8 +1590,10 @@ type PlaceAnswer struct { // PlaceUnfinishedInput is what place-unfinished takes. type PlaceUnfinishedInput struct { - // the unfinished entry's key, . - Key string `json:"key"` + // true to put every key of unfinished at once, one hand act; exactly one of key or all (design 47 H2 H-A-644) + All bool `json:"all,omitempty"` + // the unfinished entry's key, .; exactly one of key or all + Key string `json:"key,omitempty"` // why, written with the caller the runtime proves in the hand-act log Why string `json:"why"` } @@ -1635,6 +1668,9 @@ type TestRunsDropAnswer struct { // PipelineStartedEvent is the body of the event pipeline-started. type PipelineStartedEvent = PipelineStarted +// MoverAddedEvent is the body of the event mover-added. +type MoverAddedEvent = MoverAdded + // PipelineEndedEvent is the body of the event pipeline-ended. type PipelineEndedEvent = PipelineEnded @@ -1881,6 +1917,15 @@ func DecodePipelineStartedEvent(raw []byte) (PipelineStartedEvent, int, error) { return v, formRead(raw), nil } +// DecodeMoverAddedEvent reads a MoverAddedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeMoverAddedEvent(raw []byte) (MoverAddedEvent, int, error) { + var v MoverAddedEvent + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + // DecodePipelineEndedEvent reads a PipelineEndedEvent as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). func DecodePipelineEndedEvent(raw []byte) (PipelineEndedEvent, int, error) { var v PipelineEndedEvent diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go index 7a21c876b..12eb75eee 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go @@ -51,6 +51,10 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.step-ended\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, {name: "a kept mover re-pinned", subject: "mesh.seat.mesh-pipeline-runner.event.re-pinned", given: "{\"mover\":\"mesh-sdk\",\"pipeline\":\"main.3589\",\"revision\":412}", wire: "{\"mover\":\"mesh-sdk\",\"pipeline\":\"main.3589\",\"revision\":412}", decode: func(b []byte) (any, error) { var v RePinnedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.re-pinned$")}, + {name: "a mover added from the pipeline it came from (H-A-594 (4))", subject: "mesh.seat.mesh-pipeline-runner.event.mover-added.main.3589", given: "{\"fingerprint\":\"fp-sdk\",\"from\":\"main.3580\",\"module\":\"mesh-sdk\",\"pipeline\":\"main.3589\",\"revision\":12}", wire: "{\"fingerprint\":\"fp-sdk\",\"from\":\"main.3580\",\"module\":\"mesh-sdk\",\"pipeline\":\"main.3589\",\"revision\":12}", + decode: func(b []byte) (any, error) { var v MoverAddedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.mover-added\\.[^.*> ]+\\.[^.*> ]+$")}, + {name: "a mover added by a take-in whose pipeline key is held (H-A-609 (3))", subject: "mesh.seat.mesh-pipeline-runner.event.mover-added.main.3589", given: "{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"take-in\":3590}", wire: "{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"pipeline\":\"main.3589\",\"revision\":12,\"take-in\":3590}", + decode: func(b []byte) (any, error) { var v MoverAddedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.mover-added\\.[^.*> ]+\\.[^.*> ]+$")}, {name: "a take-in's pipeline kept, its steps naming their mover", subject: "", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"passed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"passed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"artifact\":\"nats:program\",\"ask\":\"m2kx9a1b3c4d5e\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"anchor\",\"outcome\":\"passed\",\"seat\":\"node-build-go\",\"status\":\"required\",\"step\":\"lint\"},{\"artifact\":\"nats:program\",\"carried-from\":\"main.3588\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"carried\",\"status\":\"required\",\"step\":\"unit\",\"tests\":{\"unit\":42}},{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"node\":\"home-server\",\"outcome\":\"failed\",\"seat\":\"node-build-go\",\"status\":\"optional\",\"step\":\"integration\",\"tests\":{\"integration\":3},\"why\":\"TestTheBusWhole failed\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"composition\"},{\"module\":\"nats\",\"outcome\":\"bypassed\",\"status\":\"bypass\",\"step\":\"review\"},{\"module\":\"nats\",\"outcome\":\"passed\",\"status\":\"required\",\"step\":\"approval\"}],\"v\":1}", decode: func(b []byte) (any, error) { var v PipelinesByBranchRevisionValue @@ -135,6 +139,10 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v PlaceInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "end-again asks a running pipeline's end judged once more, with why", subject: "", given: "{\"pipeline\":\"main.20\",\"why\":\"a mover waits on its registration and another failed\"}", wire: "{\"pipeline\":\"main.20\",\"why\":\"a mover waits on its registration and another failed\"}", decode: func(b []byte) (any, error) { var v EndAgainInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "place-unfinished with all, one hand act", subject: "", given: "{\"all\":true,\"why\":\"the unfinished movers of the old pipelines (design 47 H2 H-A-644)\"}", wire: "{\"all\":true,\"why\":\"the unfinished movers of the old pipelines (design 47 H2 H-A-644)\"}", + decode: func(b []byte) (any, error) { var v PlaceUnfinishedInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "place-unfinished with one key", subject: "", given: "{\"key\":\"main.mesh-sdk\",\"why\":\"the mover passed on its own\"}", wire: "{\"key\":\"main.mesh-sdk\",\"why\":\"the mover passed on its own\"}", + decode: func(b []byte) (any, error) { var v PlaceUnfinishedInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { v, err := c.decode([]byte(c.given)) diff --git a/modules/mesh-delivery-contracts/seats/mesh-builds/fixtures/events.json b/modules/mesh-delivery-contracts/seats/mesh-builds/fixtures/events.json index c9d557847..dfb873c53 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-builds/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/mesh-builds/fixtures/events.json @@ -173,5 +173,27 @@ "phase": "build", "at": "2026-11-23T02:40:00Z" } + }, + { + "name": "the step ended superseded in form 4: revision present exactly when superseded (H-A-574, H-A-650)", + "of": "event:step-ended", + "subject": "mesh.seat.mesh-builds.event.step-ended.laptop", + "given": { + "v": 1, + "form": 4, + "id": "m2kx9a1b3c4d6f", + "pipeline": "main.12.nats", + "step": "build", + "node": "laptop", + "outcome": "superseded", + "entries": [ + { + "module": "nats", + "fingerprint": "fp-0123" + } + ], + "said": "nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch", + "revision": 14 + } } ] diff --git a/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json b/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json index ce1bca641..7ef5e9e76 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json @@ -689,7 +689,7 @@ }, "revision": { "type": "integer", - "description": "for a step ended superseded, the module graph revision of the entry that superseded it, 0 when the builder knows none; the runner moves the mover out only for a revision newer than its pipeline's that its view holds (design 47 H2 H-A-561)" + "description": "the module graph revision of the entry that superseded the step, present exactly when outcome is superseded and absent otherwise; the runner moves the mover out only for a revision newer than its pipeline's that its view holds (design 47 H2 H-A-574, H-A-650)" }, "rerun": { "type": "boolean" @@ -791,5 +791,5 @@ ] } }, - "form": 3 + "form": 4 } diff --git a/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/events.json b/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/events.json index 1488efd3a..723cdab38 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/mesh-delivery/fixtures/events.json @@ -44,7 +44,8 @@ "at": "2026-11-09T21:00:00Z", "branch": "main", "source": 1044, - "call": "0123456789abcdef" + "call": "0123456789abcdef", + "ends": 2 } }, { diff --git a/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json b/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json index 08e74ab4e..0f0a7ce86 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-delivery/seat.json @@ -327,6 +327,10 @@ "type": "string", "format": "date-time", "description": "when" + }, + "ends": { + "type": "integer", + "description": "the record's end count, one higher at each end after the first, as pipeline-ended's end count is (design 47 H2 H-A-597, H-A-617)" } }, "required": [ @@ -719,5 +723,5 @@ ] } }, - "form": 2 + "form": 3 } diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json index e7a222b08..e96333b6d 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json @@ -48,7 +48,11 @@ "tier": 1 } ], - "kept": [292, 295, 298], + "kept": [ + 292, + 295, + 298 + ], "at": "2026-11-22T20:00:00Z" } }, @@ -601,5 +605,29 @@ "mover": "mesh-sdk", "revision": 412 } + }, + { + "name": "a mover added from the pipeline it came from (H-A-594 (4))", + "of": "event:mover-added", + "subject": "mesh.seat.mesh-pipeline-runner.event.mover-added.main.3589", + "given": { + "pipeline": "main.3589", + "revision": 12, + "module": "mesh-sdk", + "fingerprint": "fp-sdk", + "from": "main.3580" + } + }, + { + "name": "a mover added by a take-in whose pipeline key is held (H-A-609 (3))", + "of": "event:mover-added", + "subject": "mesh.seat.mesh-pipeline-runner.event.mover-added.main.3589", + "given": { + "pipeline": "main.3589", + "revision": 12, + "module": "nats", + "fingerprint": "fp-0123", + "take-in": 3590 + } } ] diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json index f86884513..816fd5562 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json @@ -341,5 +341,21 @@ "pipeline": "main.20", "why": "a mover waits on its registration and another failed" } + }, + { + "name": "place-unfinished with all, one hand act", + "of": "verb:place-unfinished.input", + "given": { + "all": true, + "why": "the unfinished movers of the old pipelines (design 47 H2 H-A-644)" + } + }, + { + "name": "place-unfinished with one key", + "of": "verb:place-unfinished.input", + "given": { + "key": "main.mesh-sdk", + "why": "the mover passed on its own" + } } ] diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json index 5e4447060..2f4ef049d 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -604,15 +604,18 @@ "properties": { "key": { "type": "string", - "description": "the unfinished entry's key, ." + "description": "the unfinished entry's key, .; exactly one of key or all" }, "why": { "type": "string", "description": "why, written with the caller the runtime proves in the hand-act log" + }, + "all": { + "type": "boolean", + "description": "true to put every key of unfinished at once, one hand act; exactly one of key or all (design 47 H2 H-A-644)" } }, "required": [ - "key", "why" ] }, @@ -767,6 +770,17 @@ "max-mib": 32 } }, + { + "name": "mover-added", + "subject": "mover-added..", + "body": { + "$ref": "#/defs/MoverAdded" + }, + "keep": { + "max-age-days": 90, + "max-mib": 32 + } + }, { "name": "pipeline-ended", "subject": "pipeline-ended..", @@ -2384,7 +2398,46 @@ "module", "outcome" ] + }, + "MoverAdded": { + "type": "object", + "description": "a mover added to a pipeline that waits or runs, or put in a reopened one: said on the pipeline's subject as pipeline-started is, with exactly one of from, caller or take-in; a reader refuses one naming none or two (design 47 H2 H-A-594 (4), H-A-609 (3), H-A-645)", + "properties": { + "pipeline": { + "type": "string", + "description": "the key of the pipeline that carries the mover" + }, + "revision": { + "type": "integer", + "description": "the catalog graph revision of the pipeline" + }, + "module": { + "type": "string" + }, + "fingerprint": { + "type": "string", + "description": "the mover's fingerprint" + }, + "from": { + "type": "string", + "description": "the key of the pipeline the mover came from" + }, + "caller": { + "type": "string", + "description": "the caller of start, as the runtime proved it" + }, + "take-in": { + "type": "integer", + "description": "the source revision of the take-in whose entries were added to a pipeline already held" + } + }, + "required": [ + "pipeline", + "revision", + "module", + "fingerprint" + ] } }, - "form": 12 + "form": 13 } diff --git a/modules/mesh-delivery-contracts/ts/seats/meshbuilds/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshbuilds/index.d.ts index f0ab476e4..4a9e85275 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshbuilds/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshbuilds/index.d.ts @@ -135,7 +135,7 @@ export interface StepEnded { "packages"?: Record; "pipeline": string; "rerun"?: boolean; - /** for a step ended superseded, the module graph revision of the entry that superseded it, 0 when the builder knows none; the runner moves the mover out only for a revision newer than its pipeline's that its view holds (design 47 H2 H-A-561) */ + /** the module graph revision of the entry that superseded the step, present exactly when outcome is superseded and absent otherwise; the runner moves the mover out only for a revision newer than its pipeline's that its view holds (design 47 H2 H-A-574, H-A-650) */ "revision"?: number; /** why it failed, could not run or was superseded: the entry not built, the part not heard, the superseding fingerprint */ "said"?: string; diff --git a/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts index f07a02274..62ad33541 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshdelivery/index.d.ts @@ -269,6 +269,8 @@ export interface RecordEndedEvent { "branch": string; /** the merge call */ "call": string; + /** the record's end count, one higher at each end after the first, as pipeline-ended's end count is (design 47 H2 H-A-597, H-A-617) */ + "ends"?: number; /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ "form"?: number; /** its milestone, . */ diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts index c526c7b30..1f73618f0 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -26,6 +26,7 @@ export declare const verbs: { export declare const events: { readonly pipelineStarted: "pipeline-started"; + readonly moverAdded: "mover-added"; readonly pipelineEnded: "pipeline-ended"; readonly runStarted: "run-started"; readonly stepStarted: "step-started"; @@ -46,6 +47,12 @@ export declare function pipelineStartedSubject(branch: string, revision: string) export declare const pipelineStartedSubjectAll: "mesh.seat.mesh-pipeline-runner.event.pipeline-started.*.*"; +export declare const moverAddedStream: "SEAT_mesh-pipeline-runner_mover-added"; + +export declare function moverAddedSubject(branch: string, revision: string): string; + +export declare const moverAddedSubjectAll: "mesh.seat.mesh-pipeline-runner.event.mover-added.*.*"; + export declare const pipelineEndedStream: "SEAT_mesh-pipeline-runner_pipeline-ended"; export declare function pipelineEndedSubject(branch: string, revision: string): string; @@ -257,6 +264,25 @@ export interface Mover { "widens"?: Widening[]; } +/** a mover added to a pipeline that waits or runs, or put in a reopened one: said on the pipeline's subject as pipeline-started is, with exactly one of from, caller or take-in; a reader refuses one naming none or two (design 47 H2 H-A-594 (4), H-A-609 (3), H-A-645) */ +export interface MoverAdded { + /** the caller of start, as the runtime proved it */ + "caller"?: string; + /** the mover's fingerprint */ + "fingerprint": string; + /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ + "form"?: number; + /** the key of the pipeline the mover came from */ + "from"?: string; + "module": string; + /** the key of the pipeline that carries the mover */ + "pipeline": string; + /** the catalog graph revision of the pipeline */ + "revision": number; + /** the source revision of the take-in whose entries were added to a pipeline already held */ + "take-in"?: number; +} + /** one mover at its pipeline's end (design 47 H §746) */ export interface MoverEnded { /** the commit the mover's entry was last changed at, from the pipeline's value (design 47 H-A-119) */ @@ -928,8 +954,10 @@ export interface PlaceAnswer { /** is what place-unfinished takes. */ export interface PlaceUnfinishedInput { - /** the unfinished entry's key, . */ - "key": string; + /** true to put every key of unfinished at once, one hand act; exactly one of key or all (design 47 H2 H-A-644) */ + "all"?: boolean; + /** the unfinished entry's key, .; exactly one of key or all */ + "key"?: string; /** why, written with the caller the runtime proves in the hand-act log */ "why": string; } @@ -997,6 +1025,9 @@ export interface TestRunsDropAnswer { /** is the body of the event pipeline-started. */ export type PipelineStartedEvent = PipelineStarted; +/** is the body of the event mover-added. */ +export type MoverAddedEvent = MoverAdded; + /** is the body of the event pipeline-ended. */ export type PipelineEndedEvent = PipelineEnded; diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js index 00b626424..83d26fbcc 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js @@ -26,6 +26,7 @@ export const verbs = { export const events = { pipelineStarted: "pipeline-started", + moverAdded: "mover-added", pipelineEnded: "pipeline-ended", runStarted: "run-started", stepStarted: "step-started", @@ -48,6 +49,14 @@ export function pipelineStartedSubject(branch, revision) { export const pipelineStartedSubjectAll = "mesh.seat.mesh-pipeline-runner.event.pipeline-started.*.*"; +export const moverAddedStream = "SEAT_mesh-pipeline-runner_mover-added"; + +export function moverAddedSubject(branch, revision) { + return "mesh.seat.mesh-pipeline-runner.event.mover-added." + branch + "." + revision; +} + +export const moverAddedSubjectAll = "mesh.seat.mesh-pipeline-runner.event.mover-added.*.*"; + export const pipelineEndedStream = "SEAT_mesh-pipeline-runner_pipeline-ended"; export function pipelineEndedSubject(branch, revision) { From 9ebf400457b77d60136a8b70c27db47f5e8eb493 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:08:28 +0100 Subject: [PATCH 005/141] DC3 held-want-words: a held want's words may begin awaits-reads: or awaits-entry: Builds: design 47 H2 H-A-682 (2), H-A-698 (2), H-A-706 (DMC-14) --- .../go/clients/meshwantsclient/wants.go | 18 ++++++++++++++++-- .../go/clients/meshwantsclient/wants_test.go | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go index 21f87b008..362a94532 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go +++ b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants.go @@ -56,6 +56,20 @@ const RevertLive = seat.WantsByWantNodeModuleValueRevertLive // want:version: it awaits its hand placement (design 47 H §772, H-A-73). Beside a put it is the one held want. const HoldAwaitsHandPlacement = "awaits-hand-placement" +// HoldAwaitsReadsPrefix begins the words of a want the assigner holds for a reader capability the node's node-engine does +// not state, followed by the missing capabilities (design 47 H2 H-A-682 (2), H-A-706 (DMC-14)). +const HoldAwaitsReadsPrefix = "awaits-reads:" + +// HoldAwaitsEntryPrefix begins the words of a want the assigner holds until the catalog entry of its fingerprint is read, +// followed by the fingerprint (design 47 H2 H-A-698 (2), H-A-706 (DMC-14)). +const HoldAwaitsEntryPrefix = "awaits-entry:" + +// holdWords says whether words are a held want's other than a put's: awaiting its hand placement, or beginning with one of +// the two prefixes. +func holdWords(words string) bool { + return words == HoldAwaitsHandPlacement || strings.HasPrefix(words, HoldAwaitsReadsPrefix) || strings.HasPrefix(words, HoldAwaitsEntryPrefix) +} + // NodeWord is the last part of a node's own key. const NodeWord = "node" @@ -182,8 +196,8 @@ func checkWant(w Want) error { } return nil } - if w.Hold && !w.Put && w.Words != HoldAwaitsHandPlacement { - return fmt.Errorf("wants: only a put, or a want awaiting its hand placement (%s), holds a want", HoldAwaitsHandPlacement) + if w.Hold && !w.Put && !holdWords(w.Words) { + return fmt.Errorf("wants: only a put, or a want awaiting its hand placement (%s), its reads (%s) or its entry (%s), holds a want", HoldAwaitsHandPlacement, HoldAwaitsReadsPrefix, HoldAwaitsEntryPrefix) } if err := checkFingerprint(w.Fp, "a want's fingerprint"); err != nil { return err diff --git a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go index 9a0d4a17d..da98e58b8 100644 --- a/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go +++ b/modules/mesh-delivery-contracts/go/clients/meshwantsclient/wants_test.go @@ -45,6 +45,9 @@ func TestWantsAreWhatTheEarlierCodecWrote(t *testing.T) { "a placement's build": {Want{Fp: a, Version: "0.1.14"}, `{"v":1,"fp":"` + a + `","version":"0.1.14"}`}, // design 47 H §772, H-A-73: a node whose node-engine reads no want by version is held, awaiting its hand placement. "awaits its hand placement": {Want{Fp: a, Version: "0.1.15", Pipeline: "main.3589", Rank: 1, Hold: true, Words: HoldAwaitsHandPlacement}, `{"v":1,"fp":"` + a + `","version":"0.1.15","pipeline":"main.3589","rank":1,"hold":true,"words":"awaits-hand-placement"}`}, + // design 47 H2 H-A-682 (2), H-A-698 (2), H-A-706 (DMC-14): held for a reader capability the engine does not state, or for an entry not read yet. + "awaits its reads": {Want{Fp: a, Version: "0.1.15", Hold: true, Words: HoldAwaitsReadsPrefix + "directory-contents-owner"}, `{"v":1,"fp":"` + a + `","version":"0.1.15","hold":true,"words":"awaits-reads:directory-contents-owner"}`}, + "awaits its entry": {Want{Fp: a, Version: "0.1.15", Hold: true, Words: HoldAwaitsEntryPrefix + a}, `{"v":1,"fp":"` + a + `","version":"0.1.15","hold":true,"words":"awaits-entry:` + a + `"}`}, } { t.Run(name, func(t *testing.T) { raw, err := EncodeWant(row.w) From 991f93c51b6882a23cd7c3a9d97d850bd724c9f9 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:08:38 +0100 Subject: [PATCH 006/141] B2 revision-wait-said: a step ask's wait for its revision is said wait-held and wait-ended on the builder's waits Builds: design 47 H2 H-A-577 (1) --- .../cmd/mesh-delivery-builder/waits.go | 35 +++++++++++++-- .../cmd/mesh-delivery-builder/waits_test.go | 5 +++ .../internal/build/revisionwait.go | 45 +++++++++++++++++++ .../internal/build/run.go | 4 ++ .../internal/build/step_test.go | 14 ++++++ .../internal/build/waits.go | 29 ++++++++++++ .../internal/build/waits_test.go | 16 ++++++- 7 files changed, 143 insertions(+), 5 deletions(-) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/waits.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/waits.go index e3781b5d9..115444a76 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/waits.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/waits.go @@ -29,7 +29,10 @@ type waitBody struct { How string `json:"how,omitempty"` } -const waitStepBuilding = "building" +const ( + waitStepBuilding = "building" + waitStepBuild = "build" +) // waitsKept keeps the builder's toolchain waits in its old state waits, one key . (design 47 G §672), // and says wait-held and wait-ended on its old stream waits; at its start it says wait-held again for every key. @@ -48,7 +51,20 @@ func newWaitsKept(kv *process.AwaitedBucket, say func(context.Context, string, s } func (w *waitsKept) body(t build.ToolchainWait, how string) waitBody { - return waitBody{Step: waitStepBuilding, On: t.On(), Part: t.Package, Module: t.Module, Fingerprint: t.Fingerprint, Since: t.Since, Bound: w.bound.String(), How: how} + b := waitBody{Step: waitStepBuilding, On: t.On(), Part: t.Package, Module: t.Module, Fingerprint: t.Fingerprint, Since: t.Since, Bound: w.bound.String(), How: how} + if t.IsRevision() { // a step ask's wait for its revision: `step` build, its own bound (design 47 H2 H-A-577 (1)) + b.Step, b.Bound = waitStepBuild, t.Bound + } + return b +} + +// slotOf is the part of a wait's key and subject after `.`: a revision wait keeps its own, so it is told apart +// from that key's toolchain wait. +func slotOf(t build.ToolchainWait) string { + if t.IsRevision() { + return ".revision" + } + return "" } // start reads the state whole and says wait-held again for each key. @@ -76,7 +92,7 @@ func (w *waitsKept) start(ctx context.Context, kv jetstream.KeyValue) { } func (w *waitsKept) said(ctx context.Context, event string, t build.ToolchainWait, how string) { - if err := w.say(ctx, event+"."+t.Module+"."+t.Fingerprint, event+"-"+t.Module+"-"+t.Fingerprint+"-"+t.Since.UTC().Format(time.RFC3339Nano)+how, w.body(t, how)); err != nil { + if err := w.say(ctx, event+"."+t.Module+"."+t.Fingerprint+slotOf(t), event+"-"+t.Module+"-"+t.Fingerprint+slotOf(t)+"-"+t.Since.UTC().Format(time.RFC3339Nano)+how, w.body(t, how)); err != nil { w.logf("saying %s of %s at %s: %v", event, t.Module, t.Fingerprint, err) } } @@ -88,6 +104,7 @@ func (w *waitsKept) Hold(ctx context.Context, t build.ToolchainWait) { w.logf("a wait of %s at %s has no key: %v", t.Module, t.Fingerprint, err) return } + key += slotOf(t) w.mu.Lock() if _, had := w.held[key]; had { w.mu.Unlock() @@ -106,14 +123,24 @@ func (w *waitsKept) Hold(ctx context.Context, t build.ToolchainWait) { // End deletes the wait and says wait-ended with how; it answers whether one was held. func (w *waitsKept) End(ctx context.Context, module, fp, how string) bool { + return w.end(ctx, module, fp, "", how) +} + +// EndRevision ends the revision wait of module's fingerprint, kept under its own key. +func (w *waitsKept) EndRevision(ctx context.Context, module, fp, how string) bool { + return w.end(ctx, module, fp, ".revision", how) +} + +func (w *waitsKept) end(ctx context.Context, module, fp, slot, how string) bool { key, err := builds.BuilderBuildKey(module, fp) if err != nil { return false } + key += slot w.mu.Lock() t, had := w.held[key] // A key queued behind a package ends only when it is published, and a toolchain wait never by that (design 47 G A-192). - if had && (t.Package != "") != (how == build.WaitPublished) { + if had && slot == "" && (t.Package != "") != (how == build.WaitPublished) { had = false } if had { diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/waits_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/waits_test.go index b21a290fb..08c055f1d 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/waits_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/waits_test.go @@ -18,4 +18,9 @@ func TestAWaitBodyNamesItsPart(t *testing.T) { if tc := w.body(build.ToolchainWait{Module: "m", Fingerprint: "src2:f", Language: "go", Version: "go1.26.0"}, ""); tc.Part != "" || tc.On != "toolchain:go@go1.26.0" { t.Errorf("a toolchain wait says %+v", tc) } + // H2 H-A-577 (1): a revision wait says `step` build, `on` revision: and its own bound, under the subject token `.revision` + rev := build.ToolchainWait{Module: "m", Fingerprint: "src2:f", Kind: build.WaitKindRevision, Revision: 7, Bound: "2m0s"} + if rv := w.body(rev, ""); rv.Step != "build" || rv.On != "revision:7" || rv.Bound != "2m0s" || slotOf(rev) != ".revision" || slotOf(build.ToolchainWait{}) != "" { + t.Errorf("a revision wait says %+v, slot %q", rv, slotOf(rev)) + } } diff --git a/modules/mesh-delivery-builder/internal/build/revisionwait.go b/modules/mesh-delivery-builder/internal/build/revisionwait.go index 417f92c43..c3b6f3d9b 100644 --- a/modules/mesh-delivery-builder/internal/build/revisionwait.go +++ b/modules/mesh-delivery-builder/internal/build/revisionwait.go @@ -163,26 +163,71 @@ func (b *Builder) awaitRevision(ctx context.Context, run meshbuilds.StepRun) (ou wait, stop := context.WithTimeout(ctx, bound) // a context's bound, no timer (ADR 0437 §8) defer stop() told := false + var keys []string + // Each entry of the ask is a wait said on the builder's stream waits (design 47 H2 H-A-577 (1)): `wait-held` while the picture + // does not hold the revision, `wait-ended` with how it ended: ran, failed at the bound, released by builder_release. + endWaits := func(how string) { + for _, e := range run.Entries { + if b.Waits != nil { + b.Waits.EndRevision(context.WithoutCancel(ctx), e.Module, e.Fingerprint, how) + } + } + b.mu.Lock() + for _, k := range keys { + delete(b.revisionWaiting, k) + delete(b.revisionReleased, k) + } + b.mu.Unlock() + } for { b.mu.Lock() moved := b.moved + released := false + for _, k := range keys { + released = released || b.revisionReleased[k] + } b.mu.Unlock() if b.holdsRevision(run.Branch, run.Source, run.Entries) { if told { b.logf("%s: revision %d of %s is in the builder's picture: the build goes on", run.Pipeline, run.Source, run.Branch) + endWaits(WaitRan) } return "", "" } + if released { + endWaits(WaitReleased) + b.logf("%s: %s: the wait was released by hand, the step fails, nothing is built", run.Pipeline, notHeld) + return meshbuilds.StepEndedOutcomeFailed, notHeld + ": the wait was released by hand, and a build with no version is never made" + } if !told { b.logf("%s: %s yet: the ask waits for it, at most %s", run.Pipeline, notHeld, bound) told = true + since := b.now() + for _, e := range run.Entries { + if run.Revision <= 0 { + break // an ask naming no revision has no `revision:` to say + } + k, err := builds.BuilderBuildKey(e.Module, e.Fingerprint) + if err != nil { + continue + } + keys = append(keys, k) + b.mu.Lock() + b.revisionWaiting[k] = true + b.mu.Unlock() + if b.Waits != nil { + b.Waits.Hold(ctx, ToolchainWait{Module: e.Module, Fingerprint: e.Fingerprint, Since: since, Kind: WaitKindRevision, Revision: run.Revision, Bound: bound.String()}) + } + } } select { case <-moved: case <-wait.Done(): if ctx.Err() != nil { + endWaits(WaitFailed) return meshbuilds.StepEndedOutcomeCouldNotRun, notHeld + ": the builder stopped before it was" } + endWaits(WaitFailed) b.logf("%s: %s within %s: the step fails, nothing is built", run.Pipeline, notHeld, bound) return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s within %s", notHeld, bound) } diff --git a/modules/mesh-delivery-builder/internal/build/run.go b/modules/mesh-delivery-builder/internal/build/run.go index cb4cd5f2b..805087e4c 100644 --- a/modules/mesh-delivery-builder/internal/build/run.go +++ b/modules/mesh-delivery-builder/internal/build/run.go @@ -165,6 +165,9 @@ type Builder struct { events map[string]bool // released are the keys builder_release is building now, whatever toolchain their fingerprint names (§276, §672). released map[string]bool + // revisionWaiting are the keys whose step ask waits for its revision now, revisionReleased those builder_release ended + // (design 47 H2 H-A-577 (1)). + revisionWaiting, revisionReleased map[string]bool // builds are the ends that withdraw the asks of a key's build in flight, by build key (ADR 0664 §4): a newer fingerprint of // the module takes its older one's build out, and the asker drops that build's asks. builds map[string]context.CancelCauseFunc @@ -205,6 +208,7 @@ func (b *Builder) init() { b.hands, b.events = map[string]*handWatch{}, map[string]bool{} b.builds = map[string]context.CancelCauseFunc{} b.moved = make(chan struct{}) + b.revisionWaiting, b.revisionReleased = map[string]bool{}, map[string]bool{} }) } diff --git a/modules/mesh-delivery-builder/internal/build/step_test.go b/modules/mesh-delivery-builder/internal/build/step_test.go index 4294b85cd..6081f7558 100644 --- a/modules/mesh-delivery-builder/internal/build/step_test.go +++ b/modules/mesh-delivery-builder/internal/build/step_test.go @@ -417,6 +417,8 @@ func aStepAskWaitsForItsRevision(t *testing.T) { held.Store(40) asked := make(chan struct{}, 1) r, res, entry := revisionRig(t, &held, asked) + rw := &memWaits{} + r.b.Waits = rw var keptReads atomic.Int64 // H-A-205, H-A-222: a revision above the newest is read by number once; not answered, it is waited for r.b.KeptRevision = func(context.Context, string, int64) (int64, map[string]string, error) { keptReads.Add(1) @@ -449,6 +451,11 @@ func aStepAskWaitsForItsRevision(t *testing.T) { if end.Outcome != meshbuilds.StepEndedOutcomePassed || len(res.sources) != 1 || res.sources[0].Revision != 41 || keptReads.Load() != 1 { t.Errorf("end = %+v, reserved from %+v, kept revisions read %d; want passed with one version reserved from revision 41, read by number once", end, res.sources, keptReads.Load()) } + // H-A-577 (1): the wait is held `revision:7` while the picture lacks it and ended `ran` once it holds it + if rw.mu.Lock(); !slices.Equal(rw.ons, []string{"revision:7"}) || !slices.Equal(rw.ended, []string{"revision:ran"}) || len(rw.held) != 0 { + t.Errorf("the revision wait: held %v, ended %v, standing %v; want one revision:7 ended ran", rw.ons, rw.ended, rw.held) + } + rw.mu.Unlock() } @@ -643,12 +650,19 @@ func aStepAskPastItsRevisionBoundFails(t *testing.T) { held.Store(40) r, res, _ := revisionRig(t, &held, make(chan struct{}, 1)) r.b.RevisionWait = time.Nanosecond + rw := &memWaits{} + r.b.Waits = rw end := r.b.BuildStep(t.Context(), "a1", meshbuilds.StepRun{Pipeline: "main.7.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Revision: 7, Source: 41, Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}}) r.b.Wait() if _, built := r.st.vals[r.key]; end.Outcome != meshbuilds.StepEndedOutcomeFailed || !strings.Contains(end.Said, "revision 41 of main not in the builder's picture") || built || len(res.sources) != 0 { t.Errorf("end = %+v, built %v, reserved %+v; want failed naming revision 41 of main, nothing built", end, built, res.sources) } + // H-A-577 (1): the wait is held and ended `failed` at its bound + if rw.mu.Lock(); !slices.Equal(rw.ended, []string{"revision:failed"}) || len(rw.held) != 0 { + t.Errorf("the revision wait: ended %v, standing %v; want one ended failed", rw.ended, rw.held) + } + rw.mu.Unlock() // A step ask with no source (a run on request) does not wait (H-A-156). end = r.b.BuildStep(t.Context(), "a1", meshbuilds.StepRun{Pipeline: "run.1.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}}) if strings.Contains(end.Said, "not in the builder's picture") { diff --git a/modules/mesh-delivery-builder/internal/build/waits.go b/modules/mesh-delivery-builder/internal/build/waits.go index e51f0b14d..53dde5899 100644 --- a/modules/mesh-delivery-builder/internal/build/waits.go +++ b/modules/mesh-delivery-builder/internal/build/waits.go @@ -29,6 +29,10 @@ const ( // WaitPublished ends the wait of a key queued behind a package, when the key is claimed (the package is published). WaitPublished = "published" WaitReleased = "released" + // WaitFailed ends a revision wait at its bound (design 47 H2 H-A-577 (1)). + WaitFailed = "failed" + // WaitKindRevision is the Kind of a revision wait. + WaitKindRevision = "revision" ) // ToolchainWait is one wait: the entry's module and fingerprint, and the toolchain it waits for. @@ -41,13 +45,24 @@ type ToolchainWait struct { // Package is the package version a key queued behind it waits for, `@` (ADR 0603 §8; design 47 G A-192): the wait is the // package's, not a toolchain's, and Language and Version are empty. Package string `json:"package,omitempty"` + // Kind is "revision" on a step ask's wait for its revision; Revision is then the module graph revision the ask names (design + // 47 H2 H-A-577 (1)); Bound is that wait's own bound, said as `bound` (the toolchain wait's is the builder's). + Kind string `json:"kind,omitempty"` + Revision int64 `json:"revision,omitempty"` + Bound string `json:"bound,omitempty"` } +// IsRevision says whether the wait is a step ask's wait for its revision, kept under `..revision`. +func (w ToolchainWait) IsRevision() bool { return w.Kind == WaitKindRevision } + // On is what the wait waits for, as the wait's `on` says it. func (w ToolchainWait) On() string { if w.Package != "" { return "package:" + w.Package } + if w.IsRevision() { + return fmt.Sprintf("revision:%d", w.Revision) + } return "toolchain:" + w.Language + "@" + w.Version } @@ -56,6 +71,9 @@ func (w ToolchainWait) On() string { type Waits interface { Hold(ctx context.Context, w ToolchainWait) End(ctx context.Context, module, fp, how string) bool + // EndRevision ends the revision wait of module's fingerprint, saying how (ran, failed or released), and answers whether + // one was held (design 47 H2 H-A-577 (1)). + EndRevision(ctx context.Context, module, fp, how string) bool } // toolchainWait is the toolchain wait of a module's fingerprint, or false when no language of its plan names a version @@ -100,7 +118,18 @@ func (b *Builder) Release(ctx context.Context, module, fp, why, by string) strin if !b.Waits.End(ctx, module, fp, WaitReleased) { b.mu.Lock() delete(b.released, key) + revision := b.revisionWaiting[key] b.mu.Unlock() + // A step ask's wait for its revision ends as its bound does (design 47 H2 H-A-577 (1)): the ask fails, since a build + // with no version is never made (H-A-155). + if revision { + b.mu.Lock() + b.revisionReleased[key] = true + b.mu.Unlock() + b.pictureMoved() + b.logf("%s: the revision wait is released by %s (%s): the ask fails, nothing is built", key, by, why) + return "" + } return fmt.Sprintf("%s holds no toolchain wait: %s builds a failed key again", key, BuildAgainTool) } b.logf("%s: released by %s (%s): built with the running build module", key, by, why) diff --git a/modules/mesh-delivery-builder/internal/build/waits_test.go b/modules/mesh-delivery-builder/internal/build/waits_test.go index 180b24a46..d1ee5795b 100644 --- a/modules/mesh-delivery-builder/internal/build/waits_test.go +++ b/modules/mesh-delivery-builder/internal/build/waits_test.go @@ -13,6 +13,7 @@ type memWaits struct { mu sync.Mutex held map[string]ToolchainWait ended []string + ons []string // what each wait held waited on, in the order held } func (w *memWaits) Hold(_ context.Context, t ToolchainWait) { @@ -21,7 +22,20 @@ func (w *memWaits) Hold(_ context.Context, t ToolchainWait) { if w.held == nil { w.held = map[string]ToolchainWait{} } - w.held[t.Module+"."+t.Fingerprint] = t + w.ons = append(w.ons, t.On()) + w.held[t.Module+"."+t.Fingerprint+map[bool]string{true: ".revision"}[t.IsRevision()]] = t +} + +func (w *memWaits) EndRevision(_ context.Context, module, fp, how string) bool { + w.mu.Lock() + defer w.mu.Unlock() + k := module + "." + fp + ".revision" + if _, ok := w.held[k]; !ok { + return false + } + delete(w.held, k) + w.ended = append(w.ended, "revision:"+how) + return true } func (w *memWaits) End(_ context.Context, module, fp, how string) bool { From c8f9e1b8d349efb809477f603b8e1c8c9b943e36 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:08:45 +0100 Subject: [PATCH 007/141] DC4 merge-pull-unwatched-base: merge-pull merges a member whose base is no watched branch plainly, whatever its repository, noted no delivery Builds: design 47 H2 H-A-704, H-A-717 (DQ-49) --- modules/mesh-delivery-contracts/go/seats/git/contract.go | 8 ++++---- .../mesh-delivery-contracts/go/seats/git/contract_test.go | 4 ++-- .../seats/git/fixtures/states.json | 4 ++-- .../mesh-delivery-contracts/seats/git/fixtures/verbs.json | 4 ++-- modules/mesh-delivery-contracts/seats/git/seat.json | 8 ++++---- modules/mesh-delivery-contracts/ts/seats/git/index.d.ts | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/git/contract.go b/modules/mesh-delivery-contracts/go/seats/git/contract.go index 47326ac0f..69a7b3045 100644 --- a/modules/mesh-delivery-contracts/go/seats/git/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/git/contract.go @@ -86,7 +86,7 @@ func VerbDescription(verb string) string { case VerbNote: return "Append one line to a commit's note under refs/notes/mesh-plan. The line carries the act's id, and an id the note already holds is skipped (held)." case VerbMergePull: - return "Merge one or more pull requests with the forge tools' account, each at the head the caller names: one merge call, a delivery's start and, with two or more members, its group (design 47 H §734, §735, §766; ADR 0682 §1, §2). Every member is judged before any is merged: still the pull request's head, its base a watched branch, no run at the head's build-input fingerprint failed a required step (judged from its own state failed-steps), registrations heard; no branch protection is read. A member whose repository has no watched branch is judged against nothing of the module graph and merged plainly in the order named, starting no delivery: its outcome says merged with the note no delivery (H-A-471). When one member is refused, none is merged. Then it merges them in the order named, writing the call in its state calls before the first merge, and says merge-called once. It answers once, at the call's end, naming the call and each member's outcome; a member already merged is refused already-merged, naming its commit." + return "Merge one or more pull requests with the forge tools' account, each at the head the caller names: one merge call, a delivery's start and, with two or more members, its group (design 47 H §734, §735, §766; ADR 0682 §1, §2). Every member is judged before any is merged: still the pull request's head, no run at the head's build-input fingerprint failed a required step (judged from its own state failed-steps), registrations heard; no branch protection is read. A member whose base is no watched branch, whatever its repository, is judged against nothing of the module graph and merged plainly in the order named, starting no delivery: its outcome says merged with the note no delivery, and merge-called leaves it out (H-A-471, H-A-704). When one member is refused, none is merged. Then it merges them in the order named, writing the call in its state calls before the first merge, and says merge-called once. It answers once, at the call's end, naming the call and each member's outcome; a member already merged is refused already-merged, naming its commit." case VerbTag: return "Write the git tag of a released version, /vMAJOR.MINOR.PATCH for a Go package (design 47 H2 §796), at the commit its build was made from; the builder writes it only on the catalog's version-released (design 47 G section 370). A tag already at that commit is answered performed. An error answer carries error and error-kind." } @@ -229,12 +229,12 @@ type Call struct { // CallMember is one member of a kept call. type CallMember struct { - // the pull request's base, read at judging: a watched branch, but for a member noted as of a repository with no watched branch + // the pull request's base, read at judging: a watched branch, but for a member noted as one whose base is no watched branch Branch string `json:"branch"` // for merged, the merge commit Commit string `json:"commit,omitempty"` Head string `json:"head"` - // for a member merged plainly, its repository having no watched branch: "no delivery: the repository has no watched branch"; it starts no delivery and merge-called leaves it out (design 47 H2 H-A-471) + // for a member merged plainly, its base being no watched branch, whatever its repository: "no delivery: its base is no watched branch"; it starts no delivery and merge-called leaves it out (design 47 H2 H-A-471, H-A-704) Note string `json:"note,omitempty"` Number int64 `json:"number"` Repository string `json:"repository"` @@ -298,7 +298,7 @@ type FailedStep struct { type MemberOutcome struct { // for merged, the merge commit; for a member refused already-merged, its commit Commit string `json:"commit,omitempty"` - // for a member merged plainly, its repository having no watched branch: "no delivery: the repository has no watched branch"; it starts no delivery and merge-called leaves it out (design 47 H2 H-A-471) + // for a member merged plainly, its base being no watched branch, whatever its repository: "no delivery: its base is no watched branch"; it starts no delivery and merge-called leaves it out (design 47 H2 H-A-471, H-A-704) Note string `json:"note,omitempty"` Number int64 `json:"number"` Repository string `json:"repository"` diff --git a/modules/mesh-delivery-contracts/go/seats/git/contract_test.go b/modules/mesh-delivery-contracts/go/seats/git/contract_test.go index 58c4e65b0..d05fd497c 100644 --- a/modules/mesh-delivery-contracts/go/seats/git/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/git/contract_test.go @@ -43,7 +43,7 @@ func TestFixtures(t *testing.T) { }, subjectIs: nil}, {name: "a merge call kept", subject: "", given: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"members\":[{\"branch\":\"main\",\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"branch\":\"main\",\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"judged\"}],\"said\":false}", wire: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"members\":[{\"branch\":\"main\",\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"branch\":\"main\",\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"judged\"}],\"said\":false}", decode: func(b []byte) (any, error) { var v CallsByCallCallValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "a merge call kept with a member merged plainly, its repository having no watched branch", subject: "", given: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"members\":[{\"branch\":\"main\",\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"branch\":\"main\",\"commit\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"note\":\"no delivery: the repository has no watched branch\",\"number\":799,\"repository\":\"novox/hq\",\"state\":\"merged\"}],\"said\":true}", wire: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"members\":[{\"branch\":\"main\",\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"branch\":\"main\",\"commit\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"note\":\"no delivery: the repository has no watched branch\",\"number\":799,\"repository\":\"novox/hq\",\"state\":\"merged\"}],\"said\":true}", + {name: "a merge call kept with a member merged plainly, its base being no watched branch", subject: "", given: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"members\":[{\"branch\":\"main\",\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"branch\":\"main\",\"commit\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"note\":\"no delivery: its base is no watched branch\",\"number\":799,\"repository\":\"novox/hq\",\"state\":\"merged\"}],\"said\":true}", wire: "{\"account\":\"tools-shanks\",\"at\":\"2026-11-20T02:00:00Z\",\"by\":\"lead-47@workstation\",\"members\":[{\"branch\":\"main\",\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"head\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"branch\":\"main\",\"commit\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"note\":\"no delivery: its base is no watched branch\",\"number\":799,\"repository\":\"novox/hq\",\"state\":\"merged\"}],\"said\":true}", decode: func(b []byte) (any, error) { var v CallsByCallCallValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "pull asks", subject: "", given: "{\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\"}", wire: "{\"merge-commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"repository\":\"novox/mesh-sdk\"}", decode: func(b []byte) (any, error) { var v PullInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, @@ -135,7 +135,7 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v MergePullInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "merge-pull answers the call and each member merged", subject: "", given: "{\"call\":\"0123456789abcdef\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"commit\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"merged\"}]}", wire: "{\"call\":\"0123456789abcdef\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"commit\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"merged\"}]}", decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "merge-pull merges a member of a repository with no watched branch plainly, noted no delivery", subject: "", given: "{\"call\":\"0123456789abcdef\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"commit\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"note\":\"no delivery: the repository has no watched branch\",\"number\":799,\"repository\":\"novox/hq\",\"state\":\"merged\"}]}", wire: "{\"call\":\"0123456789abcdef\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"commit\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"note\":\"no delivery: the repository has no watched branch\",\"number\":799,\"repository\":\"novox/hq\",\"state\":\"merged\"}]}", + {name: "merge-pull merges a member whose base is no watched branch plainly, noted no delivery", subject: "", given: "{\"call\":\"0123456789abcdef\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"commit\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"note\":\"no delivery: its base is no watched branch\",\"number\":799,\"repository\":\"novox/hq\",\"state\":\"merged\"}]}", wire: "{\"call\":\"0123456789abcdef\",\"members\":[{\"commit\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"merged\"},{\"commit\":\"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\",\"note\":\"no delivery: its base is no watched branch\",\"number\":799,\"repository\":\"novox/hq\",\"state\":\"merged\"}]}", decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "merge-pull refuses every member when one is refused, naming why", subject: "", given: "{\"call\":\"0123456789abcdef\",\"members\":[{\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"refused\",\"why\":\"the head moved: cccccccccccccccccccccccccccccccccccccccc, not the named aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"},{\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"judged\"}]}", wire: "{\"call\":\"0123456789abcdef\",\"members\":[{\"number\":178,\"repository\":\"novox/mesh-sdk\",\"state\":\"refused\",\"why\":\"the head moved: cccccccccccccccccccccccccccccccccccccccc, not the named aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"},{\"number\":261,\"repository\":\"novox/mesh-delivery\",\"state\":\"judged\"}]}", decode: func(b []byte) (any, error) { var v MergePullAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, diff --git a/modules/mesh-delivery-contracts/seats/git/fixtures/states.json b/modules/mesh-delivery-contracts/seats/git/fixtures/states.json index 25f8e5f0c..f90538277 100644 --- a/modules/mesh-delivery-contracts/seats/git/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/git/fixtures/states.json @@ -44,7 +44,7 @@ } }, { - "name": "a merge call kept with a member merged plainly, its repository having no watched branch", + "name": "a merge call kept with a member merged plainly, its base being no watched branch", "of": "state:calls/call.", "given": { "account": "tools-shanks", @@ -66,7 +66,7 @@ "repository": "novox/hq", "state": "merged", "branch": "main", - "note": "no delivery: the repository has no watched branch" + "note": "no delivery: its base is no watched branch" } ], "said": true diff --git a/modules/mesh-delivery-contracts/seats/git/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/git/fixtures/verbs.json index 5e0c6983d..64cd43af0 100644 --- a/modules/mesh-delivery-contracts/seats/git/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/git/fixtures/verbs.json @@ -515,7 +515,7 @@ } }, { - "name": "merge-pull merges a member of a repository with no watched branch plainly, noted no delivery", + "name": "merge-pull merges a member whose base is no watched branch plainly, noted no delivery", "of": "verb:merge-pull.answer", "why": "a repository of no module is the forge's business alone (design 47 H2 H-A-471)", "given": { @@ -532,7 +532,7 @@ "number": 799, "state": "merged", "commit": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", - "note": "no delivery: the repository has no watched branch" + "note": "no delivery: its base is no watched branch" } ] } diff --git a/modules/mesh-delivery-contracts/seats/git/seat.json b/modules/mesh-delivery-contracts/seats/git/seat.json index d6e621094..3a9195c1b 100644 --- a/modules/mesh-delivery-contracts/seats/git/seat.json +++ b/modules/mesh-delivery-contracts/seats/git/seat.json @@ -834,7 +834,7 @@ }, { "name": "merge-pull", - "description": "Merge one or more pull requests with the forge tools' account, each at the head the caller names: one merge call, a delivery's start and, with two or more members, its group (design 47 H §734, §735, §766; ADR 0682 §1, §2). Every member is judged before any is merged: still the pull request's head, its base a watched branch, no run at the head's build-input fingerprint failed a required step (judged from its own state failed-steps), registrations heard; no branch protection is read. A member whose repository has no watched branch is judged against nothing of the module graph and merged plainly in the order named, starting no delivery: its outcome says merged with the note no delivery (H-A-471). When one member is refused, none is merged. Then it merges them in the order named, writing the call in its state calls before the first merge, and says merge-called once. It answers once, at the call's end, naming the call and each member's outcome; a member already merged is refused already-merged, naming its commit.", + "description": "Merge one or more pull requests with the forge tools' account, each at the head the caller names: one merge call, a delivery's start and, with two or more members, its group (design 47 H §734, §735, §766; ADR 0682 §1, §2). Every member is judged before any is merged: still the pull request's head, no run at the head's build-input fingerprint failed a required step (judged from its own state failed-steps), registrations heard; no branch protection is read. A member whose base is no watched branch, whatever its repository, is judged against nothing of the module graph and merged plainly in the order named, starting no delivery: its outcome says merged with the note no delivery, and merge-called leaves it out (H-A-471, H-A-704). When one member is refused, none is merged. Then it merges them in the order named, writing the call in its state calls before the first merge, and says merge-called once. It answers once, at the call's end, naming the call and each member's outcome; a member already merged is refused already-merged, naming its commit.", "input": { "type": "object", "properties": { @@ -1670,7 +1670,7 @@ }, "note": { "type": "string", - "description": "for a member merged plainly, its repository having no watched branch: \"no delivery: the repository has no watched branch\"; it starts no delivery and merge-called leaves it out (design 47 H2 H-A-471)" + "description": "for a member merged plainly, its base being no watched branch, whatever its repository: \"no delivery: its base is no watched branch\"; it starts no delivery and merge-called leaves it out (design 47 H2 H-A-471, H-A-704)" } }, "required": [ @@ -1726,7 +1726,7 @@ }, "branch": { "type": "string", - "description": "the pull request's base, read at judging: a watched branch, but for a member noted as of a repository with no watched branch" + "description": "the pull request's base, read at judging: a watched branch, but for a member noted as one whose base is no watched branch" }, "head": { "type": "string", @@ -1751,7 +1751,7 @@ }, "note": { "type": "string", - "description": "for a member merged plainly, its repository having no watched branch: \"no delivery: the repository has no watched branch\"; it starts no delivery and merge-called leaves it out (design 47 H2 H-A-471)" + "description": "for a member merged plainly, its base being no watched branch, whatever its repository: \"no delivery: its base is no watched branch\"; it starts no delivery and merge-called leaves it out (design 47 H2 H-A-471, H-A-704)" } }, "required": [ diff --git a/modules/mesh-delivery-contracts/ts/seats/git/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/git/index.d.ts index 4b3578401..d6964cac5 100644 --- a/modules/mesh-delivery-contracts/ts/seats/git/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/git/index.d.ts @@ -92,12 +92,12 @@ export interface Call { /** one member of a kept call */ export interface CallMember { - /** the pull request's base, read at judging: a watched branch, but for a member noted as of a repository with no watched branch */ + /** the pull request's base, read at judging: a watched branch, but for a member noted as one whose base is no watched branch */ "branch": string; /** for merged, the merge commit */ "commit"?: string; "head": string; - /** for a member merged plainly, its repository having no watched branch: "no delivery: the repository has no watched branch"; it starts no delivery and merge-called leaves it out (design 47 H2 H-A-471) */ + /** for a member merged plainly, its base being no watched branch, whatever its repository: "no delivery: its base is no watched branch"; it starts no delivery and merge-called leaves it out (design 47 H2 H-A-471, H-A-704) */ "note"?: string; "number": number; "repository": string; @@ -146,7 +146,7 @@ export interface FailedStep { export interface MemberOutcome { /** for merged, the merge commit; for a member refused already-merged, its commit */ "commit"?: string; - /** for a member merged plainly, its repository having no watched branch: "no delivery: the repository has no watched branch"; it starts no delivery and merge-called leaves it out (design 47 H2 H-A-471) */ + /** for a member merged plainly, its base being no watched branch, whatever its repository: "no delivery: its base is no watched branch"; it starts no delivery and merge-called leaves it out (design 47 H2 H-A-471, H-A-704) */ "note"?: string; "number": number; "repository": string; From 8865d61beca91d0c262eae1068f12639f4c405b8 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:09:01 +0100 Subject: [PATCH 008/141] DC5 published-names-fingerprint: package-published gains the reservation's fingerprint (mesh-builds stays at form 4, one raise per seat) Builds: design 47 H2 H-A-707 (6), H-A-717 (DQ-52) --- .../go/seats/meshbuilds/contract.go | 4 ++- .../go/seats/meshbuilds/contract_test.go | 2 ++ .../seats/mesh-builds/fixtures/events.json | 30 +++++++++++++++++++ .../seats/mesh-builds/seat.json | 4 +++ .../ts/seats/meshbuilds/index.d.ts | 2 ++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go index 00032cb0c..6e5555a49 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract.go @@ -19,7 +19,7 @@ const Form = 4 // whose fields changed while its forms did not (design 47 H2 §780). const ( generatedForms = "4" - generatedFieldsDigest = "AskTakenEvent=6d5d3da7ac39 BuildEntry=3c829a0a3d58 Dependency=90a32b07c563 DropAnswer=7538f2f5e68e PackagePublished=34dd069a6aab PackagePublishedEvent=8e12888c1559 PublishQueueAnswer=0f1326e35e17 PublishQueueAnswerCountsItem=b770db2f0920 PublishQueueAnswerQueueItem=b1eebc09f41e PublishedAnswer=69a801982819 ReservedAnswer=2272a4d6f0f4 ReservedAnswerArtifactsItem=d74eb6e00abb Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 StepAccept=18efeefb6c34 StepEnded=be571d4ff16f StepEndedEvent=207787118dac StepProgressEvent=8215e490ea8d StepRun=dc5893aef7e5 ToolchainAgreed=f3d9ce993734 ToolchainAgreedDigestsItem=1d42893a96b9 ToolchainAgreedEvent=e3502d6f194d VersionReservedEvent=984547d6ad07" + generatedFieldsDigest = "AskTakenEvent=6d5d3da7ac39 BuildEntry=3c829a0a3d58 Dependency=90a32b07c563 DropAnswer=7538f2f5e68e PackagePublished=7e20050c6260 PackagePublishedEvent=8e12888c1559 PublishQueueAnswer=0f1326e35e17 PublishQueueAnswerCountsItem=b770db2f0920 PublishQueueAnswerQueueItem=b1eebc09f41e PublishedAnswer=69a801982819 ReservedAnswer=2272a4d6f0f4 ReservedAnswerArtifactsItem=d74eb6e00abb Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 StepAccept=18efeefb6c34 StepEnded=be571d4ff16f StepEndedEvent=207787118dac StepProgressEvent=8215e490ea8d StepRun=dc5893aef7e5 ToolchainAgreed=f3d9ce993734 ToolchainAgreedDigestsItem=1d42893a96b9 ToolchainAgreedEvent=e3502d6f194d VersionReservedEvent=984547d6ad07" ) const ( @@ -146,6 +146,8 @@ type PackagePublished struct { Dependencies []Dependency `json:"dependencies,omitempty"` // the published artifact's digest Digest string `json:"digest"` + // the fingerprint of the build the reservation holds, so the runner marks every running pipeline of the branch that moves the module at it; absent from a publish whose reservation names none; the builder, the assigner and the indexer read it not and decode it tolerantly (design 47 H2 H-A-707 (6)) + Fingerprint string `json:"fingerprint,omitempty"` // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). Form int64 `json:"form,omitempty"` // the module diff --git a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract_test.go index 015ba4fa4..706c43da9 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshbuilds/contract_test.go @@ -37,6 +37,8 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v StepProgressEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-progress\\.[^.*> ]+$")}, {name: "the step ended superseded in form 4: revision present exactly when superseded (H-A-574, H-A-650)", subject: "mesh.seat.mesh-builds.event.step-ended.laptop", given: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"form\":4,\"id\":\"m2kx9a1b3c4d6f\",\"node\":\"laptop\",\"outcome\":\"superseded\",\"pipeline\":\"main.12.nats\",\"revision\":14,\"said\":\"nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch\",\"step\":\"build\",\"v\":1}", wire: "{\"entries\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\"}],\"form\":4,\"id\":\"m2kx9a1b3c4d6f\",\"node\":\"laptop\",\"outcome\":\"superseded\",\"pipeline\":\"main.12.nats\",\"revision\":14,\"said\":\"nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch\",\"step\":\"build\",\"v\":1}", decode: func(b []byte) (any, error) { var v StepEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.step-ended\\.[^.*> ]+$")}, + {name: "a package published, naming the build's fingerprint (H-A-707 (6))", subject: "mesh.seat.mesh-builds.event.package-published", given: "{\"artifact\":\"mesh-sdk:go\",\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"dependencies\":[{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":1,\"part\":\"mesh-contracts:go-nodeengine\",\"version\":\"0.1.4\"},{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":3,\"part\":\"mesh-build-go:toolchain\",\"version\":\"1.26.0\"}],\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"source\":3589,\"v\":1,\"version\":\"0.1.15\"}", wire: "{\"artifact\":\"mesh-sdk:go\",\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"dependencies\":[{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":1,\"part\":\"mesh-contracts:go-nodeengine\",\"version\":\"0.1.4\"},{\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"kind\":3,\"part\":\"mesh-build-go:toolchain\",\"version\":\"1.26.0\"}],\"digest\":\"sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"source\":3589,\"v\":1,\"version\":\"0.1.15\"}", + decode: func(b []byte) (any, error) { var v PackagePublishedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-builds\\.event\\.package-published$")}, {name: "reserved asks a module", subject: "", given: "{\"module\":\"mesh-sdk\"}", wire: "{\"module\":\"mesh-sdk\"}", decode: func(b []byte) (any, error) { var v ReservedInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "reserved asks a package by its name", subject: "", given: "{\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"version\":\"0.1.15\"}", wire: "{\"name\":\"git.novox.be/novox/mesh-sdk/go\",\"version\":\"0.1.15\"}", diff --git a/modules/mesh-delivery-contracts/seats/mesh-builds/fixtures/events.json b/modules/mesh-delivery-contracts/seats/mesh-builds/fixtures/events.json index dfb873c53..ee7b415b2 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-builds/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/mesh-builds/fixtures/events.json @@ -195,5 +195,35 @@ "said": "nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch", "revision": 14 } + }, + { + "name": "a package published, naming the build's fingerprint (H-A-707 (6))", + "of": "event:package-published", + "subject": "mesh.seat.mesh-builds.event.package-published", + "given": { + "v": 1, + "artifact": "mesh-sdk:go", + "module": "mesh-sdk", + "version": "0.1.15", + "digest": "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", + "branch": "main", + "source": 3589, + "dependencies": [ + { + "kind": 1, + "version": "0.1.4", + "digest": "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", + "part": "mesh-contracts:go-nodeengine" + }, + { + "kind": 3, + "version": "1.26.0", + "digest": "sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef", + "part": "mesh-build-go:toolchain" + } + ], + "at": "2026-11-10T10:00:00Z", + "fingerprint": "fp-sdk" + } } ] diff --git a/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json b/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json index 7ef5e9e76..482f7bf3c 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-builds/seat.json @@ -524,6 +524,10 @@ "type": "integer", "description": "the catalog revision number of that branch the build was made from, the indexer's count (design 47 H-A-218, H-A-220); absent from a reservation made before the field" }, + "fingerprint": { + "type": "string", + "description": "the fingerprint of the build the reservation holds, so the runner marks every running pipeline of the branch that moves the module at it; absent from a publish whose reservation names none; the builder, the assigner and the indexer read it not and decode it tolerantly (design 47 H2 H-A-707 (6))" + }, "dependencies": { "type": "array", "items": { diff --git a/modules/mesh-delivery-contracts/ts/seats/meshbuilds/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshbuilds/index.d.ts index 4a9e85275..138a124e6 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshbuilds/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshbuilds/index.d.ts @@ -83,6 +83,8 @@ export interface PackagePublished { "dependencies"?: Dependency[]; /** the published artifact's digest */ "digest": string; + /** the fingerprint of the build the reservation holds, so the runner marks every running pipeline of the branch that moves the module at it; absent from a publish whose reservation names none; the builder, the assigner and the indexer read it not and decode it tolerantly (design 47 H2 H-A-707 (6)) */ + "fingerprint"?: string; /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ "form"?: number; /** the module */ From f3e68c66464f8e7a4411bcd4c61fb6174e9fa78e Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:09:33 +0100 Subject: [PATCH 009/141] A2 want-of-no-version: want-unversioned, and unplaced and tier-late, cleared from the findings bucket Builds: design 47 H2 H-A-673 (the assigner's part), H-A-706 (DQ-40), H-A-722; row A2 --- .../cmd/mesh-delivery-assigner/pass.go | 104 +++++++++++++++--- .../mesh-delivery-assigner/seat_tools_test.go | 41 +++++++ .../cmd/mesh-delivery-assigner/tiers.go | 33 ++++++ .../cmd/mesh-delivery-assigner/tiers_test.go | 8 ++ .../internal/assign/unlisted.go | 32 ++++++ .../internal/assign/wants.go | 8 +- .../internal/assign/wants_test.go | 22 ++++ 7 files changed, 231 insertions(+), 17 deletions(-) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go index d32129583..5d4daa346 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go @@ -31,6 +31,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" "git.novox.be/novox/mesh-sdk/go/catalogue" + mcc "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient" mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" "mesh-delivery-assigner/internal/assign" @@ -60,8 +61,6 @@ type passer struct { whys map[string]string // findings is the assigner's findings bucket (its said conditions, ADR 0564 §2). findings assign.Findings - // unplaced are the nodes whose unplaced finding this process wrote. - unplaced map[string]bool // listed says whether a module's watched branches list it (catalogViews.listed), for the clear of assignment-unlisted. listed func(module string) bool // answeredAt is, by the id of a backup ask, how many values the have had when its answer was written into the want. @@ -252,6 +251,7 @@ func (p *passer) wants(ctx context.Context) { for name := range wanted { names[name] = true } + unversioned := map[string]unversionedWant{} for name := range names { groups := p.groups(name, nodesOf[name], assignedBranches[name]) for gi, g := range groups { @@ -279,6 +279,9 @@ func (p *passer) wants(ctx context.Context) { p.outsideReview(ctx, name, target.Fp, m.Nodes, bv.nodes, bv.manifests[name].ClaimsSeat(mcseat.Seat), p.movedTo(wanted, bv.nodes)) } out := assign.Wants(m, wantedOf) + for node, fp := range out.Unversioned { + unversioned[assign.UnversionedKey(name, node)] = unversionedWant{module: name, node: node, fp: fp} + } p.sayWhy(ctx, name, m.Nodes, wantWhy{Branch: g.branch, Fp: target.Fp, Version: target.Version, Pipeline: target.Pipeline, Step: whyStep(ok)}, wantedOf, &out) if ok { p.yeses(ctx, name, m, wantedOf, &out) @@ -288,6 +291,7 @@ func (p *passer) wants(ctx context.Context) { } } } + p.unversionedFindings(unversioned, trunk) } // put writes one key of the assigner's own bucket; a write that fails is said and made again at the next pass. @@ -767,17 +771,37 @@ func chosenOf(chosen map[string]catalogue.PersonPolicy, module string) *catalogu return nil } +// findingKeys is the keys the assigner's findings bucket holds now; false when it cannot be read (no bucket, or a read that +// failed, said), so that nothing is written or cleared from what was not read (H-A-722: a finding is cleared from what the bucket +// holds, never from what a process remembers). +func (p *passer) findingKeys(what string) (map[string]bool, bool) { + if p.findings.Keys == nil || p.findings.Put == nil || p.findings.Delete == nil { + return nil, false + } + ks, err := p.findings.Keys() + if err != nil { + p.logf("the findings are not read, so %s is not written or cleared in this pass: %v", what, err) + return nil, false + } + have := make(map[string]bool, len(ks)) + for _, k := range ks { + have[k] = true + } + return have, true +} + // unplacedFindings writes, from the lease write, the finding `machine..unplaced` for each node that runs but no -// assignments names, which gets no want (ADR 0571 §6), and deletes it once the node is placed. +// assignments names, which gets no want (ADR 0571 §6), and deletes it at the pass that finds the node placed or gone: the +// findings' keys are read from the bucket at each pass (H-A-722). func (p *passer) unplacedFindings() { - if p.findings.Put == nil { + have, ok := p.findingKeys("the finding unplaced") + if !ok { return } - now := []string(p.w.unplacedNodes()) is := map[string]bool{} - for _, node := range now { + for _, node := range p.w.unplacedNodes() { is[node] = true - if p.unplaced[node] { + if have[assign.UnplacedKey(node)] { continue } f, err := assign.UnplacedFinding(node, p.clock()) @@ -786,23 +810,71 @@ func (p *passer) unplacedFindings() { } if err != nil { p.logf("the unplaced node %s is not said: %v", node, err) - continue } - if p.unplaced == nil { - p.unplaced = map[string]bool{} - } - p.unplaced[node] = true } - for node := range p.unplaced { - if is[node] { + for key := range have { + node, found := unplacedOfKey(key) + if !found || is[node] { continue } - if err := p.findings.Delete(assign.UnplacedKey(node)); err == nil { - delete(p.unplaced, node) + if err := p.findings.Delete(key); err != nil { + p.logf("the finding %s is not cleared: %v", key, err) } } } +// unplacedOfKey is the node of an unplaced finding's key `machine..unplaced`, or false for another finding's. +func unplacedOfKey(key string) (string, bool) { + rest, ok := strings.CutPrefix(key, mcc.ScopeMachine+".") + if !ok { + return "", false + } + node, ok := strings.CutSuffix(rest, "."+assign.KindUnplaced) + return node, ok && node != "" && assign.UnplacedKey(node) == key +} + +// unversionedWant is a want of no version for which no target is held, as a pass finds it (design 47 H2 H-A-673, H-A-706). +type unversionedWant struct{ module, node, fp string } + +// unversionedFindings writes the finding want-unversioned (id `.`) of each want a pass found with no version and no +// target, naming its fingerprint and why no target is held, and clears, at the pass that finds its cause gone, each one the +// bucket holds that the pass did not find: the want names a version, the module is no longer assigned to the node, or the node +// is gone (H-A-722). Nothing is cleared while the trunk is unread. +func (p *passer) unversionedFindings(found map[string]unversionedWant, trunk map[string]meshcatalog.ModulesByModuleValue) { + have, ok := p.findingKeys("the finding want-unversioned") + if !ok { + return + } + for key, u := range found { + if have[key] { + continue + } + f, err := assign.UnversionedFinding(u.module, u.node, u.fp, "no version of it released on its branch has a passed pipeline whose tier is written, and no placement names a build", p.clock()) + if err == nil { + err = p.findings.Put(f) + } + if err != nil { + p.logf("the finding want-unversioned of %s on %s is not written: %v", u.module, u.node, err) + } + } + if len(trunk) == 0 { + return + } + for key := range have { + if _, _, is := assign.UnversionedOfKey(key); !is { + continue + } + if _, still := found[key]; still { + continue + } + if err := p.findings.Delete(key); err != nil { + p.logf("the finding %s is not cleared: %v", key, err) + continue + } + p.logf("the finding %s is cleared: its want names a version, or its module or its node is gone", key) + } +} + // clearUnlisted clears, in the pass over the assignments, each finding assignment-unlisted whose assignment is gone or whose module // one of its watched branches lists again, so the clear never waits for the next composition step on that machine (H-A-149). func (p *passer) clearUnlisted() { diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools_test.go index 8b18c9f0d..978545b59 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/seat_tools_test.go @@ -17,6 +17,7 @@ import ( "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" + mwc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/catalogkey" "git.novox.be/novox/mesh-sdk/go/keys" @@ -287,6 +288,7 @@ func TestTheSeatsVerbs(t *testing.T) { findings := map[string][]byte{} p := &passer{w: w, logf: func(string, ...any) {}, findings: assign.Findings{ Put: putInto(findings), + Keys: func() ([]string, error) { return slices.Collect(maps.Keys(findings)), nil }, Delete: func(k string) error { delete(findings, k); return nil }}} p.unplacedFindings() if _, ok := findings[assign.UnplacedKey("g14")]; !ok || len(findings) != 1 { @@ -298,6 +300,45 @@ func TestTheSeatsVerbs(t *testing.T) { t.Errorf("placed again: findings %v", findings) } }) + t.Run("H-A-673, H-A-706, H-A-722: want-unversioned is written, and cleared from the bucket by a pass after a restart", func(t *testing.T) { + fp := meshcatalogclient.SourcePrefix2 + strings.Repeat("3", 64) + wantsKV := &memKV{values: map[string][]byte{}} + findings := map[string][]byte{} + pass := func(version string, assigned ...string) *passer { + p := newPasser(kvSet{buckets.Wants(): wantsKV, buckets.Asks(): &memKV{values: map[string][]byte{}}}, time.Now()) + p.publishWants = func(string, any, string) error { return nil } + p.findings = assign.Findings{Put: putInto(findings), Keys: func() ([]string, error) { return slices.Collect(maps.Keys(findings)), nil }, + Delete: func(k string) error { delete(findings, k); return nil }} + digest := strings.Repeat("4", 64) + mod, _ := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: digest, Repository: "novox/web", Commit: strings.Repeat("1", 40), Path: meshcatalogclient.RootPath}) + putModuleRaw(p.w, trunkBranch, "web", mod) + p.w.manifests[digest] = parsed{module: "web", manifest: catalogue.Manifest{Module: "web"}} + placeOn(t, p.w, "g14", assigned...) + raw, _ := mwc.EncodeWant(mwc.Want{Fp: fp, Version: version}) + key, _ := mwc.WantKey("g14", "web") + wantsKV.values[key] = raw + p.w.putEntry(buckets.Wants(), key, raw, 1, time.Now()) + return p + } + key := assign.UnversionedKey("web", "g14") + pass("", "web").wants(context.Background()) + if _, ok := findings[key]; !ok || len(findings) != 1 { + t.Fatalf("a want of no version and no target: findings %v", findings) + } + pass("", "web").wants(context.Background()) // a process that starts again: written once, and it stands + if _, ok := findings[key]; !ok || len(findings) != 1 { + t.Fatalf("a restarted pass changed the finding: %v", findings) + } + pass("1.0.0", "web").wants(context.Background()) // the want names a version now + if len(findings) != 0 { + t.Errorf("the want names a version: findings %v", findings) + } + pass("", "web").wants(context.Background()) + pass("", "other").wants(context.Background()) // the module is no longer assigned to the node + if len(findings) != 0 { + t.Errorf("the module is no longer assigned to the node: findings %v", findings) + } + }) t.Run("1955/L7 (ADR 0571 §4): seat-holders is written from assignments, only the keys a change moves, and answered by assignments seats", func(t *testing.T) { writes := 0 kv := &countingKV{memKV: memKV{values: map[string][]byte{}}, writes: &writes} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers.go index 685614f10..18d32f708 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers.go @@ -187,6 +187,13 @@ func (p *passer) tiers(n assign.Nodes, placedOn func(module, branch string) []st bound := p.tierBoundOf() var next time.Time standing := p.w.read(buckets.Asks()) + followed := map[string]bool{} + for _, key := range ks { + if isTierKey(key) { + followed[assign.KeyID(strings.TrimPrefix(key, tierPrefix))] = true + } + } + defer p.clearTierLate(followed) for _, key := range ks { if !isTierKey(key) { continue @@ -465,3 +472,29 @@ func pauseNamed(standing map[string][]byte, t tierProgress, notRunning []meshwan } return strings.Join(named, "; ") } + +// clearTierLate clears, at the pass that finds its pipeline no longer followed (no tier progress stands for it), each finding +// tier-late the findings bucket holds, read from the bucket, never from what a process said (H-A-722). followed are the +// pipelines' ids as a finding's key holds them. +func (p *passer) clearTierLate(followed map[string]bool) { + have, ok := p.findingKeys("the finding tier-late") + if !ok { + return + } + for key := range have { + rest, is := strings.CutPrefix(key, mcc.ScopeDelivery+".") + if !is { + continue + } + id, is := strings.CutSuffix(rest, "."+kindTierLate) + if !is || followed[id] { + continue + } + if err := p.findings.Delete(key); err != nil { + p.logf("the finding %s is not cleared: %v", key, err) + continue + } + delete(p.said, key+".raised") + p.logf("the finding %s is cleared: its pipeline is no longer followed", key) + } +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers_test.go index c570ceb8f..b1963be50 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tiers_test.go @@ -3,6 +3,8 @@ package main import ( "context" "encoding/json" + "maps" + "slices" "strings" "testing" "time" @@ -45,7 +47,10 @@ func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) { p.say = func(oc.Condition) error { return nil } findings := map[string]mcseat.Finding{} p.findings = assign.Findings{Put: func(f mcseat.Finding) error { findings[views.FindingKey(f.Scope, f.ID, f.Kind)] = f; return nil }, + Keys: func() ([]string, error) { return slices.Collect(maps.Keys(findings)), nil }, Delete: func(key string) error { delete(findings, key); return nil }} + // H-A-722: a tier-late of a pipeline no longer followed, written before a restart, is cleared at the first pass. + findings["delivery.main.3.tier-late"] = mcseat.Finding{Scope: "delivery", ID: "main.3", Kind: kindTierLate} var said []meshwants.PipelineWanted p.publishWants = func(event string, body any, _ string) error { if b, ok := body.(meshwants.PipelineWantedEvent); ok { @@ -83,6 +88,9 @@ func TestAPipelinesWantsAreWrittenTierByTier(t *testing.T) { return ok } p.wants(context.Background()) + if _, old := findings["delivery.main.3.tier-late"]; old { + t.Errorf("%s: a tier-late of a pipeline no longer followed stands after a pass: %v", pipeline, findings) + } if !wanted("g14", "db") || !wanted("ace", "db") || wanted("g14", "web") || wanted("ace", "web") { t.Fatalf("%s runs %v: tier 1 alone is not what is wanted first: %v", pipeline, runs, wantsKV.values) } diff --git a/modules/mesh-delivery-assigner/internal/assign/unlisted.go b/modules/mesh-delivery-assigner/internal/assign/unlisted.go index 11b4f0b84..eebf7b5a3 100644 --- a/modules/mesh-delivery-assigner/internal/assign/unlisted.go +++ b/modules/mesh-delivery-assigner/internal/assign/unlisted.go @@ -44,3 +44,35 @@ func UnlistedFinding(node, module string, at time.Time) (mcseat.Finding, error) "Take it off, or register the module on a watched branch.", Source: "assigner." + KindAssignmentUnlisted}, at) } + +// KindWantUnversioned is a want that names no version, for a module whose target no release gives (design 47 H2 H-A-673, +// H-A-706 on DQ-40): scope delivery, id `.`, severity warning. +const KindWantUnversioned = "want-unversioned" + +// UnversionedKey is its finding's key, `delivery...want-unversioned`. +func UnversionedKey(module, node string) string { + return views.FindingKey(ScopeAssignmentUnlisted, KeyID(module+"."+node), KindWantUnversioned) +} + +// UnversionedOfKey is the module and node of a want-unversioned finding's key, or false for another finding's. +func UnversionedOfKey(key string) (module, node string, ok bool) { + rest, ok := strings.CutPrefix(key, ScopeAssignmentUnlisted+".") + if !ok { + return "", "", false + } + if rest, ok = strings.CutSuffix(rest, "."+KindWantUnversioned); !ok { + return "", "", false + } + module, node, ok = strings.Cut(rest, ".") + return module, node, ok && module != "" && node != "" && !strings.Contains(node, ".") +} + +// UnversionedFinding is the finding of the want of module on node that names fingerprint fp and no version, while no target is +// held (why). +func UnversionedFinding(module, node, fp, why string, at time.Time) (mcseat.Finding, error) { + summary := fmt.Sprintf("the want of %s on %s names %s and no version, and no target is held for it: %s", module, node, short(fp), why) + return encode(Observed{Scope: ScopeAssignmentUnlisted, ID: module + "." + node, Kind: KindWantUnversioned, Machine: node, + Severity: mcseat.FindingSeverityWarning, Summary: summary, Headline: clipHeadline(module + " on " + node + " is wanted with no version"), + Explanation: summary + ". The want stands as written, so the node composes nothing new for it; it clears once the want names a version.", + Source: "assigner." + KindWantUnversioned}, at) +} diff --git a/modules/mesh-delivery-assigner/internal/assign/wants.go b/modules/mesh-delivery-assigner/internal/assign/wants.go index 99fa6f5b7..e7eeef0ae 100644 --- a/modules/mesh-delivery-assigner/internal/assign/wants.go +++ b/modules/mesh-delivery-assigner/internal/assign/wants.go @@ -96,13 +96,16 @@ func (n Nodes) RunsHealthy(node, module, fp string) bool { // Outcome is what one module's pass decides: each node's want to write (only those that change). type Outcome struct { Wants map[string]mwc.Want + // Unversioned is, by node, the fingerprint of a want that names no version and for which Target answers none: the want + // stands as written, and the pass says it with the finding want-unversioned (design 47 H2 H-A-673, H-A-706 on DQ-40). + Unversioned map[string]string } // Wants is the pass of one module m: for each of its nodes, the want naming its Target, starting from the want written before // (wants, by node). A put that owns a node's want writes the put's; a node with no target keeps the want written. A node that // wants m but is no longer among its nodes gets its want written removed, never deleted (ADR 0408 §4). func Wants(m Module, wants map[string]mwc.Want) Outcome { - out := Outcome{Wants: map[string]mwc.Want{}} + out := Outcome{Wants: map[string]mwc.Want{}, Unversioned: map[string]string{}} for _, node := range m.Nodes { before, had := wants[node] p, put := m.Puts[node] @@ -124,6 +127,9 @@ func Wants(m Module, wants map[string]mwc.Want) Outcome { t, ok = m.Target(node) } if !ok || t.Fp == "" { + if had && !before.Removed && !before.Put && before.Version == "" && before.Fp != "" { + out.Unversioned[node] = before.Fp + } continue } next := mwc.Want{Fp: t.Fp, Version: t.Version, Pipeline: t.Pipeline, Rank: t.Rank, Self: m.selfOn(node)} diff --git a/modules/mesh-delivery-assigner/internal/assign/wants_test.go b/modules/mesh-delivery-assigner/internal/assign/wants_test.go index 74c117e72..1d77b9027 100644 --- a/modules/mesh-delivery-assigner/internal/assign/wants_test.go +++ b/modules/mesh-delivery-assigner/internal/assign/wants_test.go @@ -86,6 +86,28 @@ func TestAWantNamesTheNewestPassedVersion(t *testing.T) { } } } + // H-A-673, H-A-706 (DQ-40): a node whose want names no version and for which Target answers none is named in the outcome + // beside the wants, with the fingerprint; one whose want names a version, one with a target (rewritten) and one removed are not. + none := func() Module { + m := released() + m.Target = func(string) (Target, bool) { return Target{}, false } + return m + } + for _, c := range []struct { + name string + module func() Module + before map[string]mwc.Want + named map[string]string + }{ + {"no version and no target", none, map[string]mwc.Want{"ace": {Fp: fOld}, "g14": {Fp: fOld, Version: "1.2.2"}}, map[string]string{"ace": fOld}}, + {"a target rewrites the want", released, map[string]mwc.Want{"ace": {Fp: fOld}}, map[string]string{}}, + {"a removed want", none, map[string]mwc.Want{"ace": {Removed: true}}, map[string]string{}}, + } { + got := Wants(c.module(), c.before).Unversioned + if len(got) != len(c.named) || (len(got) > 0 && got["ace"] != c.named["ace"]) { + t.Errorf("%s: unversioned = %v, want %v", c.name, got, c.named) + } + } } // ADR 0546: a put owns the node's want from its asking until it ends; while it waits the rule writes nothing there, once wanted its From 6dc9164504feb2d483dd900f191413644cca17b2 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:09:56 +0100 Subject: [PATCH 010/141] DC6 runner-reads-bounded: MoverRow carries fingerprint and version, show and stands take a bound and page by a cursor, pipeline-started's movers are StartedMover Builds: design 47 H2 H-A-709 (1) (2) (3), H-A-717 (DQ-52, DQ-57) --- .../go/seats/meshpipelinerunner/contract.go | 60 ++++++++-- .../seats/meshpipelinerunner/contract_test.go | 10 +- .../mesh-pipeline-runner/fixtures/events.json | 3 +- .../mesh-pipeline-runner/fixtures/verbs.json | 77 +++++++++++++ .../seats/mesh-pipeline-runner/seat.json | 103 ++++++++++++++++-- .../ts/seats/meshpipelinerunner/index.d.ts | 50 +++++++-- 6 files changed, 272 insertions(+), 31 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index 7189ad1d8..65238d420 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -20,7 +20,7 @@ const Form = 13 // whose fields changed while its forms did not (design 47 H2 §780). const ( generatedForms = "13" - generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverAdded=6966283f6909 MoverAddedEvent=b24ae82030ab MoverEnded=4b35095f6829 MoverRow=b61f41d131a3 Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=397a8219a855 PipelineStarted=582f8ff3b28d PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=ed94ced4513a Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=48b8cecc529a StandsAnswer=0afa3693bf3b StartAnswer=ed94ced4513a StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=bdaa8bbfbcab StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=21e4ee7a3ef1 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" + generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverAdded=6966283f6909 MoverAddedEvent=b24ae82030ab MoverEnded=4b35095f6829 MoverRow=b7ceefe24722 Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=397a8219a855 PipelineStarted=d5fc3ee236c7 PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=ed94ced4513a Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=8609ff359791 StandsAnswer=e05cecdde456 StartAnswer=ed94ced4513a StartedMover=4450a94e6ca3 StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=bdaa8bbfbcab StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=21e4ee7a3ef1 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" ) const ( @@ -72,11 +72,11 @@ func VerbDescription(verb string) string { case VerbStart: return "A delivering pipeline for a watched branch's head, by hand; written in the hand-act log. With modules, a pipeline at the head keyed ..again. carrying the named modules whose newest entry has no passed pipeline, at the take-in's tiers; a module whose newest entry passed is refused by name. Exactly one of module or modules (design 47 H2 H-A-479)." case VerbShow: - return "One pipeline: naming a mover, its steps alone; with no mover, each mover's row (its module, outcome and failed step), never every step of every mover, or the steps of any mover the step and state filters hold; and its step log, with the stores' fill (design 47 H2 §789, H-A-376). Reads only." + return "One pipeline: naming a mover, its steps alone; with no mover, each mover's row (its module, outcome and failed step), never every step of every mover, or the steps of any mover the step and state filters hold; and its step log, with the stores' fill (design 47 H2 §789, H-A-376). The answer names only the movers its page holds, with each row's fingerprint and version, mover-count and step-count and no unlogged; it answers within bound, capped, total and next, and moved true when the record was written between two pages (design 47 H2 H-A-709 (1), (2)). Reads only." case VerbList: return "The pipelines and runs of a module, a branch or a commit, newest first, of every branch when none is named (design 47 H2 H-A-533): by default one short row per pipeline, the newest 20 (its key, branch, call, source, revision, start, end, outcome, movers' count, its steps counted per outcome and first failed or could-not-run step with its module and why); the whole pipelines, each record with its movers and steps counted, never its steps (show gives those), only with full and a limit (design 47 H2 H-A-376, H-A-467). Reads only." case VerbStands: - return "What stands still, and since when: each step not ended and each wait held. Reads only." + return "What stands still, and since when: each step not ended and each wait held, in the order of their since, then their pipeline, module, step and artifact, within bound; reads only (design 47 H2 H-A-709 (2))." case VerbWhyCarried: return "Where a step's result was carried from, with the kept results it rests on. Reads only." case VerbKept: @@ -768,9 +768,13 @@ type MoverEnded struct { // MoverRow is one mover of a pipeline in show's short form (design 47 H2 H-A-376). type MoverRow struct { Failed *FailedStep `json:"failed,omitempty"` - Module string `json:"module"` + // the mover's build-input fingerprint, which the delivery view's pipeline page reads from the row (design 47 H2 H-A-709 (1)) + Fingerprint string `json:"fingerprint,omitempty"` + Module string `json:"module"` // waiting for a mover with no step placed; running while a required step is open; failed once a required step did not pass; superseded for one a newer pipeline took out Outcome string `json:"outcome"` + // the version released for the mover in this pipeline, absent until one is (design 47 H2 H-A-709 (1)) + Version string `json:"version,omitempty"` } // The values of MoverRow's outcome. @@ -793,7 +797,7 @@ type Pipeline struct { Ended *time.Time `json:"ended,omitempty"` // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). Form int64 `json:"form,omitempty"` - // how many movers the pipeline has, set by list alone (H-A-191) + // how many movers the pipeline has, set by list and by show (H-A-191, design 47 H2 H-A-709 (1)) MoverCount int64 `json:"mover-count,omitempty"` // the modules the pipeline moves, its take-in's entries (design 47 H §746) Movers []Mover `json:"movers"` @@ -811,13 +815,13 @@ type Pipeline struct { // the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) Source int64 `json:"source"` Started *time.Time `json:"started,omitempty"` - // how many steps the pipeline's movers have, set by list alone, which answers the record with its steps empty (H-A-191) + // how many steps the pipeline's movers have, set by list, which answers the record with its steps empty, and by show (H-A-191, design 47 H2 H-A-709 (1)) StepCount int64 `json:"step-count,omitempty"` // every mover's steps, each naming its mover, approval last; in the state pipelines a record's own are empty, each mover's kept under its own key (H-A-187) Steps []StepResult `json:"steps"` // the modules a newer waiting take-in of the same branch took out of the pipeline, written with the movers by compare-and-set; at its placing the runner writes a mover's build-step why from it (design 47 H §748, H-A-107) Superseded []string `json:"superseded,omitempty"` - // the step-log entries of the steps that ended and are not appended to the step log yet, in order; written with the step's end in one write and cleared when appended (design 47 G sections 486, 606); in the state pipelines a record's own are empty, each mover's kept under its own key beside its steps (H-A-189) + // the step-log entries of the steps that ended and are not appended to the step log yet, in order; written with the step's end in one write and cleared when appended (design 47 G sections 486, 606); in the state pipelines a record's own are empty, each mover's kept under its own key beside its steps (H-A-189); show's answer carries none (design 47 H2 H-A-709 (1)) Unlogged []LogEntry `json:"unlogged,omitempty"` // the layout version V int64 `json:"v,omitempty"` @@ -994,8 +998,8 @@ type PipelineStarted struct { Form int64 `json:"form,omitempty"` // every catalog revision the pipeline's movers are kept at, said again in full at each re-pin, so the indexer pins each while the pipeline runs (design 47 H2 H-A-496 and its addendum) Kept []int64 `json:"kept,omitempty"` - // the pipeline's movers - Movers []Mover `json:"movers"` + // the pipeline's movers, each with what its readers read (design 47 H2 H-A-709 (3)) + Movers []StartedMover `json:"movers"` // the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) Pipeline string `json:"pipeline"` // for a pipeline a package's publish started, that publish (A-202) @@ -1049,6 +1053,20 @@ type Shared struct { Run string `json:"run"` } +// StartedMover is one mover of a pipeline-started: what its readers read, the gate's module, fingerprint and version; published, widens, tests, unplaced, revision and over-budget stay in the pipeline's record, read by show (design 47 H2 H-A-709 (3)). +type StartedMover struct { + // the commit the module's entry was last changed at + Commit string `json:"commit"` + // the module's build-input fingerprint at the commit + Fingerprint string `json:"fingerprint"` + Module string `json:"module"` + Repository string `json:"repository"` + // the mover's tier in the pipeline's delivery order, from 1 (ADR 0666 section 14; design 47 H section 746) + Tier int64 `json:"tier,omitempty"` + // the version released for the mover in this pipeline, absent until one is (design 47 H-A-52) + Version string `json:"version,omitempty"` +} + // StepEvent is a step's start or end: the step, its status, its outcome, its fingerprint, its test counts, what a carried result was carried from, and for a rerun that it is one and its proved caller; a bypassed step too. type StepEvent struct { At *time.Time `json:"at,omitempty"` @@ -1338,9 +1356,11 @@ type StartAnswer struct { // ShowInput is what show takes. type ShowInput struct { + // the most bytes the answer holds, 4,096 to 786,432; absent, the runner's setting answer-bound (design 47 H2 H-A-709 (2)) + Bound int64 `json:"bound,omitempty"` // a mover's module: the answer's pipeline then holds that mover's steps alone (H-A-187); with neither mover, step nor state the answer holds each mover's row (design 47 H2 H-A-376) Mover string `json:"mover,omitempty"` - // the cursor the previous page answered, opaque; absent for the first page (design 47 H2 §779, §789) + // the cursor the previous page answered, opaque: the place of the next row or step among those the filters hold and the record's revision; a next the runner cannot read as its own is refused, a page being read again from the start (design 47 H2 H-A-709 (2), H-A-717 (DQ-57)) Next string `json:"next,omitempty"` // the pipeline's key Pipeline string `json:"pipeline"` @@ -1364,12 +1384,14 @@ const ( // ShowAnswer is what show answers. type ShowAnswer struct { - // yes when the answer stopped at 768 KB; the rest is read from next (design 47 H2 §789) + // yes when the answer stopped at bound; the rest is read from next (design 47 H2 H-A-709 (2)) Capped bool `json:"capped,omitempty"` Fill []Fill `json:"fill,omitempty"` // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). Form int64 `json:"form,omitempty"` Log []LogEntry `json:"log,omitempty"` + // yes when a page was asked with a next of another revision of the record: it answers from that place, though rows and steps may have changed between the pages; a reader that needs one whole picture reads again with no next (design 47 H2 H-A-709 (2)) + Moved bool `json:"moved,omitempty"` // each mover's row, when show names no mover, step or state (design 47 H2 H-A-376) Movers []MoverRow `json:"movers,omitempty"` // the cursor of the next page, opaque; empty at the end (design 47 H2 §779) @@ -1404,13 +1426,27 @@ type ListAnswer struct { // StandsInput is what stands takes. type StandsInput struct { + // the most bytes the answer holds, 4,096 to 786,432; absent, the runner's setting answer-bound (design 47 H2 H-A-709 (2)) + Bound int64 `json:"bound,omitempty"` + // only this module's waits, applied while reading + Module string `json:"module,omitempty"` + // the cursor the previous page answered, opaque: the place of the last wait answered, so the next page answers the waits after it; a next the runner cannot read as its own is refused, a page being read again from the start (design 47 H2 H-A-709 (2), H-A-717 (DQ-57)) + Next string `json:"next,omitempty"` + // only this pipeline's waits, applied while reading + Pipeline string `json:"pipeline,omitempty"` } // StandsAnswer is what stands answers. type StandsAnswer struct { + // yes when the answer stopped at bound; the rest is read from next + Capped bool `json:"capped,omitempty"` // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). - Form int64 `json:"form,omitempty"` + Form int64 `json:"form,omitempty"` + // the cursor of the next page, opaque; empty at the end + Next string `json:"next,omitempty"` Stands []Wait `json:"stands"` + // how many waits the filters hold in all + Total int64 `json:"total,omitempty"` } // WhyCarriedInput is what why-carried takes. diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go index 12eb75eee..f14ae4e43 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go @@ -17,7 +17,7 @@ func TestFixtures(t *testing.T) { decode func([]byte) (any, error) subjectIs *regexp.Regexp }{ - {name: "a take-in's pipeline started with its two movers", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-started.main.3589", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"repository\":\"mesh-sdk\",\"tier\":1},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":2}],\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"repository\":\"mesh-sdk\",\"tier\":1},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":2}],\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1}", + {name: "a take-in's pipeline started with its two movers", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-started.main.3589", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"repository\":\"mesh-sdk\",\"tier\":1,\"version\":\"0.1.15\"},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":2}],\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"repository\":\"mesh-sdk\",\"tier\":1,\"version\":\"0.1.15\"},{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":2}],\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1}", decode: func(b []byte) (any, error) { var v PipelineStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-started\\.[^.*> ]+\\.[^.*> ]+$")}, {name: "a pipeline started again at a re-pin, with the three revisions its movers are kept at (H-A-496)", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-started.main.291", given: "{\"at\":\"2026-11-22T20:00:00Z\",\"branch\":\"main\",\"kept\":[292,295,298],\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"pipeline\":\"main.291\",\"revision\":291,\"source\":114,\"v\":1}", wire: "{\"at\":\"2026-11-22T20:00:00Z\",\"branch\":\"main\",\"kept\":[292,295,298],\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"pipeline\":\"main.291\",\"revision\":291,\"source\":114,\"v\":1}", decode: func(b []byte) (any, error) { var v PipelineStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-started\\.[^.*> ]+\\.[^.*> ]+$")}, @@ -143,6 +143,14 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v PlaceUnfinishedInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "place-unfinished with one key", subject: "", given: "{\"key\":\"main.mesh-sdk\",\"why\":\"the mover passed on its own\"}", wire: "{\"key\":\"main.mesh-sdk\",\"why\":\"the mover passed on its own\"}", decode: func(b []byte) (any, error) { var v PlaceUnfinishedInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "show answers a page of movers' rows with their fingerprint and version, moved and capped (H-A-709)", subject: "", given: "{\"capped\":true,\"moved\":true,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"running\",\"version\":\"0.1.9\"},{\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"outcome\":\"passed\"}],\"next\":\"cursor-1\",\"pipeline\":{\"branch\":\"main\",\"mover-count\":129,\"movers\":[],\"outcome\":\"running\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step-count\":516,\"steps\":[],\"v\":1},\"total\":129}", wire: "{\"capped\":true,\"moved\":true,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"running\",\"version\":\"0.1.9\"},{\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"outcome\":\"passed\"}],\"next\":\"cursor-1\",\"pipeline\":{\"branch\":\"main\",\"mover-count\":129,\"movers\":[],\"outcome\":\"running\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step-count\":516,\"steps\":[],\"v\":1},\"total\":129}", + decode: func(b []byte) (any, error) { var v ShowAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "stands answers a page, capped, with the total and the cursor of the next (H-A-709)", subject: "", given: "{\"capped\":true,\"next\":\"cursor-2\",\"stands\":[{\"artifact\":\"nats:program\",\"branch\":\"main\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.3589\",\"revision\":12,\"since\":\"2026-11-10T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}],\"total\":300}", wire: "{\"capped\":true,\"next\":\"cursor-2\",\"stands\":[{\"artifact\":\"nats:program\",\"branch\":\"main\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.3589\",\"revision\":12,\"since\":\"2026-11-10T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}],\"total\":300}", + decode: func(b []byte) (any, error) { var v StandsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "stands asked for one pipeline and module, within a bound (H-A-709)", subject: "", given: "{\"bound\":32768,\"module\":\"nats\",\"next\":\"cursor-2\",\"pipeline\":\"main.3589\"}", wire: "{\"bound\":32768,\"module\":\"nats\",\"next\":\"cursor-2\",\"pipeline\":\"main.3589\"}", + decode: func(b []byte) (any, error) { var v StandsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "show asked within a bound (H-A-709)", subject: "", given: "{\"bound\":65536,\"next\":\"cursor-1\",\"pipeline\":\"main.3589\"}", wire: "{\"bound\":65536,\"next\":\"cursor-1\",\"pipeline\":\"main.3589\"}", + decode: func(b []byte) (any, error) { var v ShowInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { v, err := c.decode([]byte(c.given)) diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json index e96333b6d..ffc143975 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json @@ -16,7 +16,8 @@ "commit": "0123456789abcdef0123456789abcdef01234567", "fingerprint": "fp-sdk", "repository": "mesh-sdk", - "tier": 1 + "tier": 1, + "version": "0.1.15" }, { "module": "nats", diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json index 816fd5562..b3cb40dc0 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json @@ -357,5 +357,82 @@ "key": "main.mesh-sdk", "why": "the mover passed on its own" } + }, + { + "name": "show answers a page of movers' rows with their fingerprint and version, moved and capped (H-A-709)", + "of": "verb:show.answer", + "given": { + "pipeline": { + "pipeline": "main.3589", + "branch": "main", + "revision": 12, + "source": 3589, + "v": 1, + "outcome": "running", + "mover-count": 129, + "step-count": 516, + "movers": [], + "steps": [] + }, + "movers": [ + { + "module": "nats", + "outcome": "running", + "fingerprint": "fp-0123", + "version": "0.1.9" + }, + { + "module": "mesh-sdk", + "outcome": "passed", + "fingerprint": "fp-sdk" + } + ], + "capped": true, + "total": 129, + "next": "cursor-1", + "moved": true + } + }, + { + "name": "stands answers a page, capped, with the total and the cursor of the next (H-A-709)", + "of": "verb:stands.answer", + "given": { + "stands": [ + { + "pipeline": "main.3589", + "module": "nats", + "branch": "main", + "revision": 12, + "source": 3589, + "v": 1, + "step": "unit", + "artifact": "nats:program", + "on": "build node", + "since": "2026-11-10T10:00:00Z" + } + ], + "capped": true, + "total": 300, + "next": "cursor-2" + } + }, + { + "name": "stands asked for one pipeline and module, within a bound (H-A-709)", + "of": "verb:stands.input", + "given": { + "pipeline": "main.3589", + "module": "nats", + "bound": 32768, + "next": "cursor-2" + } + }, + { + "name": "show asked within a bound (H-A-709)", + "of": "verb:show.input", + "given": { + "pipeline": "main.3589", + "bound": 65536, + "next": "cursor-1" + } } ] diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json index 2f4ef049d..9eb333c20 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -93,7 +93,7 @@ }, { "name": "show", - "description": "One pipeline: naming a mover, its steps alone; with no mover, each mover's row (its module, outcome and failed step), never every step of every mover, or the steps of any mover the step and state filters hold; and its step log, with the stores' fill (design 47 H2 §789, H-A-376). Reads only.", + "description": "One pipeline: naming a mover, its steps alone; with no mover, each mover's row (its module, outcome and failed step), never every step of every mover, or the steps of any mover the step and state filters hold; and its step log, with the stores' fill (design 47 H2 §789, H-A-376). The answer names only the movers its page holds, with each row's fingerprint and version, mover-count and step-count and no unlogged; it answers within bound, capped, total and next, and moved true when the record was written between two pages (design 47 H2 H-A-709 (1), (2)). Reads only.", "input": { "type": "object", "properties": { @@ -125,7 +125,13 @@ }, "next": { "type": "string", - "description": "the cursor the previous page answered, opaque; absent for the first page (design 47 H2 §779, §789)" + "description": "the cursor the previous page answered, opaque: the place of the next row or step among those the filters hold and the record's revision; a next the runner cannot read as its own is refused, a page being read again from the start (design 47 H2 H-A-709 (2), H-A-717 (DQ-57))" + }, + "bound": { + "type": "integer", + "minimum": 4096, + "maximum": 786432, + "description": "the most bytes the answer holds, 4,096 to 786,432; absent, the runner's setting answer-bound (design 47 H2 H-A-709 (2))" } }, "required": [ @@ -152,7 +158,7 @@ }, "capped": { "type": "boolean", - "description": "yes when the answer stopped at 768 KB; the rest is read from next (design 47 H2 §789)" + "description": "yes when the answer stopped at bound; the rest is read from next (design 47 H2 H-A-709 (2))" }, "total": { "type": "integer", @@ -168,6 +174,10 @@ "$ref": "#/defs/MoverRow" }, "description": "each mover's row, when show names no mover, step or state (design 47 H2 H-A-376)" + }, + "moved": { + "type": "boolean", + "description": "yes when a page was asked with a next of another revision of the record: it answers from that place, though rows and steps may have changed between the pages; a reader that needs one whole picture reads again with no next (design 47 H2 H-A-709 (2))" } }, "required": [ @@ -231,10 +241,29 @@ }, { "name": "stands", - "description": "What stands still, and since when: each step not ended and each wait held. Reads only.", + "description": "What stands still, and since when: each step not ended and each wait held, in the order of their since, then their pipeline, module, step and artifact, within bound; reads only (design 47 H2 H-A-709 (2)).", "input": { "type": "object", - "properties": {} + "properties": { + "pipeline": { + "type": "string", + "description": "only this pipeline's waits, applied while reading" + }, + "module": { + "type": "string", + "description": "only this module's waits, applied while reading" + }, + "bound": { + "type": "integer", + "minimum": 4096, + "maximum": 786432, + "description": "the most bytes the answer holds, 4,096 to 786,432; absent, the runner's setting answer-bound (design 47 H2 H-A-709 (2))" + }, + "next": { + "type": "string", + "description": "the cursor the previous page answered, opaque: the place of the last wait answered, so the next page answers the waits after it; a next the runner cannot read as its own is refused, a page being read again from the start (design 47 H2 H-A-709 (2), H-A-717 (DQ-57))" + } + } }, "answer": { "type": "object", @@ -244,6 +273,18 @@ "items": { "$ref": "#/defs/Wait" } + }, + "capped": { + "type": "boolean", + "description": "yes when the answer stopped at bound; the rest is read from next" + }, + "total": { + "type": "integer", + "description": "how many waits the filters hold in all" + }, + "next": { + "type": "string", + "description": "the cursor of the next page, opaque; empty at the end" } }, "required": [ @@ -1425,15 +1466,15 @@ "items": { "$ref": "#/defs/LogEntry" }, - "description": "the step-log entries of the steps that ended and are not appended to the step log yet, in order; written with the step's end in one write and cleared when appended (design 47 G sections 486, 606); in the state pipelines a record's own are empty, each mover's kept under its own key beside its steps (H-A-189)" + "description": "the step-log entries of the steps that ended and are not appended to the step log yet, in order; written with the step's end in one write and cleared when appended (design 47 G sections 486, 606); in the state pipelines a record's own are empty, each mover's kept under its own key beside its steps (H-A-189); show's answer carries none (design 47 H2 H-A-709 (1))" }, "mover-count": { "type": "integer", - "description": "how many movers the pipeline has, set by list alone (H-A-191)" + "description": "how many movers the pipeline has, set by list and by show (H-A-191, design 47 H2 H-A-709 (1))" }, "step-count": { "type": "integer", - "description": "how many steps the pipeline's movers have, set by list alone, which answers the record with its steps empty (H-A-191)" + "description": "how many steps the pipeline's movers have, set by list, which answers the record with its steps empty, and by show (H-A-191, design 47 H2 H-A-709 (1))" }, "published": { "$ref": "#/defs/Published", @@ -1679,9 +1720,9 @@ "movers": { "type": "array", "items": { - "$ref": "#/defs/Mover" + "$ref": "#/defs/StartedMover" }, - "description": "the pipeline's movers" + "description": "the pipeline's movers, each with what its readers read (design 47 H2 H-A-709 (3))" }, "run": { "type": "string", @@ -2378,6 +2419,14 @@ "module": { "type": "string" }, + "fingerprint": { + "type": "string", + "description": "the mover's build-input fingerprint, which the delivery view's pipeline page reads from the row (design 47 H2 H-A-709 (1))" + }, + "version": { + "type": "string", + "description": "the version released for the mover in this pipeline, absent until one is (design 47 H2 H-A-709 (1))" + }, "outcome": { "type": "string", "enum": [ @@ -2437,6 +2486,40 @@ "module", "fingerprint" ] + }, + "StartedMover": { + "type": "object", + "description": "one mover of a pipeline-started: what its readers read, the gate's module, fingerprint and version; published, widens, tests, unplaced, revision and over-budget stay in the pipeline's record, read by show (design 47 H2 H-A-709 (3))", + "properties": { + "module": { + "type": "string" + }, + "commit": { + "type": "string", + "description": "the commit the module's entry was last changed at" + }, + "fingerprint": { + "type": "string", + "description": "the module's build-input fingerprint at the commit" + }, + "repository": { + "type": "string" + }, + "tier": { + "type": "integer", + "description": "the mover's tier in the pipeline's delivery order, from 1 (ADR 0666 section 14; design 47 H section 746)" + }, + "version": { + "type": "string", + "description": "the version released for the mover in this pipeline, absent until one is (design 47 H-A-52)" + } + }, + "required": [ + "module", + "commit", + "fingerprint", + "repository" + ] } }, "form": 13 diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts index 1f73618f0..f5989b3bf 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -303,9 +303,13 @@ export interface MoverEnded { /** one mover of a pipeline in show's short form (design 47 H2 H-A-376) */ export interface MoverRow { "failed"?: FailedStep; + /** the mover's build-input fingerprint, which the delivery view's pipeline page reads from the row (design 47 H2 H-A-709 (1)) */ + "fingerprint"?: string; "module": string; /** waiting for a mover with no step placed; running while a required step is open; failed once a required step did not pass; superseded for one a newer pipeline took out */ "outcome": "waiting" | "running" | "passed" | "failed" | "superseded"; + /** the version released for the mover in this pipeline, absent until one is (design 47 H2 H-A-709 (1)) */ + "version"?: string; } /** one pipeline of one take-in, its movers the take-in's entries, as the runner keeps it in its state pipelines by compare-and-set (design 47 H §746) */ @@ -319,7 +323,7 @@ export interface Pipeline { "ended"?: string; /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ "form"?: number; - /** how many movers the pipeline has, set by list alone (H-A-191) */ + /** how many movers the pipeline has, set by list and by show (H-A-191, design 47 H2 H-A-709 (1)) */ "mover-count"?: number; /** the modules the pipeline moves, its take-in's entries (design 47 H §746) */ "movers": Mover[]; @@ -337,13 +341,13 @@ export interface Pipeline { /** the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) */ "source": number; "started"?: string; - /** how many steps the pipeline's movers have, set by list alone, which answers the record with its steps empty (H-A-191) */ + /** how many steps the pipeline's movers have, set by list, which answers the record with its steps empty, and by show (H-A-191, design 47 H2 H-A-709 (1)) */ "step-count"?: number; /** every mover's steps, each naming its mover, approval last; in the state pipelines a record's own are empty, each mover's kept under its own key (H-A-187) */ "steps": StepResult[]; /** the modules a newer waiting take-in of the same branch took out of the pipeline, written with the movers by compare-and-set; at its placing the runner writes a mover's build-step why from it (design 47 H §748, H-A-107) */ "superseded"?: string[]; - /** the step-log entries of the steps that ended and are not appended to the step log yet, in order; written with the step's end in one write and cleared when appended (design 47 G sections 486, 606); in the state pipelines a record's own are empty, each mover's kept under its own key beside its steps (H-A-189) */ + /** the step-log entries of the steps that ended and are not appended to the step log yet, in order; written with the step's end in one write and cleared when appended (design 47 G sections 486, 606); in the state pipelines a record's own are empty, each mover's kept under its own key beside its steps (H-A-189); show's answer carries none (design 47 H2 H-A-709 (1)) */ "unlogged"?: LogEntry[]; /** the layout version */ "v"?: number; @@ -487,8 +491,8 @@ export interface PipelineStarted { "form"?: number; /** every catalog revision the pipeline's movers are kept at, said again in full at each re-pin, so the indexer pins each while the pipeline runs (design 47 H2 H-A-496 and its addendum) */ "kept"?: number[]; - /** the pipeline's movers */ - "movers": Mover[]; + /** the pipeline's movers, each with what its readers read (design 47 H2 H-A-709 (3)) */ + "movers": StartedMover[]; /** the pipeline's key, ., or ..published.. for a pipeline a publish started; a branch escaped as a key's name is (design 47 H §746, §747) */ "pipeline": string; /** for a pipeline a package's publish started, that publish (A-202) */ @@ -542,6 +546,20 @@ export interface Shared { "run": string; } +/** one mover of a pipeline-started: what its readers read, the gate's module, fingerprint and version; published, widens, tests, unplaced, revision and over-budget stay in the pipeline's record, read by show (design 47 H2 H-A-709 (3)) */ +export interface StartedMover { + /** the commit the module's entry was last changed at */ + "commit": string; + /** the module's build-input fingerprint at the commit */ + "fingerprint": string; + "module": string; + "repository": string; + /** the mover's tier in the pipeline's delivery order, from 1 (ADR 0666 section 14; design 47 H section 746) */ + "tier"?: number; + /** the version released for the mover in this pipeline, absent until one is (design 47 H-A-52) */ + "version"?: string; +} + /** a step's start or end: the step, its status, its outcome, its fingerprint, its test counts, what a carried result was carried from, and for a rerun that it is one and its proved caller; a bypassed step too */ export interface StepEvent { "at"?: string; @@ -756,9 +774,11 @@ export interface StartAnswer { /** is what show takes. */ export interface ShowInput { + /** the most bytes the answer holds, 4,096 to 786,432; absent, the runner's setting answer-bound (design 47 H2 H-A-709 (2)) */ + "bound"?: number; /** a mover's module: the answer's pipeline then holds that mover's steps alone (H-A-187); with neither mover, step nor state the answer holds each mover's row (design 47 H2 H-A-376) */ "mover"?: string; - /** the cursor the previous page answered, opaque; absent for the first page (design 47 H2 §779, §789) */ + /** the cursor the previous page answered, opaque: the place of the next row or step among those the filters hold and the record's revision; a next the runner cannot read as its own is refused, a page being read again from the start (design 47 H2 H-A-709 (2), H-A-717 (DQ-57)) */ "next"?: string; /** the pipeline's key */ "pipeline": string; @@ -770,12 +790,14 @@ export interface ShowInput { /** is what show answers. */ export interface ShowAnswer { - /** yes when the answer stopped at 768 KB; the rest is read from next (design 47 H2 §789) */ + /** yes when the answer stopped at bound; the rest is read from next (design 47 H2 H-A-709 (2)) */ "capped"?: boolean; "fill"?: Fill[]; /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ "form"?: number; "log"?: LogEntry[]; + /** yes when a page was asked with a next of another revision of the record: it answers from that place, though rows and steps may have changed between the pages; a reader that needs one whole picture reads again with no next (design 47 H2 H-A-709 (2)) */ + "moved"?: boolean; /** each mover's row, when show names no mover, step or state (design 47 H2 H-A-376) */ "movers"?: MoverRow[]; /** the cursor of the next page, opaque; empty at the end (design 47 H2 §779) */ @@ -810,13 +832,27 @@ export interface ListAnswer { /** is what stands takes. */ export interface StandsInput { + /** the most bytes the answer holds, 4,096 to 786,432; absent, the runner's setting answer-bound (design 47 H2 H-A-709 (2)) */ + "bound"?: number; + /** only this module's waits, applied while reading */ + "module"?: string; + /** the cursor the previous page answered, opaque: the place of the last wait answered, so the next page answers the waits after it; a next the runner cannot read as its own is refused, a page being read again from the start (design 47 H2 H-A-709 (2), H-A-717 (DQ-57)) */ + "next"?: string; + /** only this pipeline's waits, applied while reading */ + "pipeline"?: string; } /** is what stands answers. */ export interface StandsAnswer { + /** yes when the answer stopped at bound; the rest is read from next */ + "capped"?: boolean; /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ "form"?: number; + /** the cursor of the next page, opaque; empty at the end */ + "next"?: string; "stands": Wait[]; + /** how many waits the filters hold in all */ + "total"?: number; } /** is what why-carried takes. */ From dc6669f768e4bf2a8a5637cd4f3fdc5ae326318b Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:10:16 +0100 Subject: [PATCH 011/141] DC2b place-unfinished answers placed and failed with all; mover-added kept as pipeline-started is Builds: design 47 H2 H-A-644, H-A-725, H-A-726 --- .../go/seats/meshpipelinerunner/contract.go | 34 +++++++++--- .../seats/meshpipelinerunner/contract_test.go | 6 +++ .../mesh-pipeline-runner/fixtures/verbs.json | 36 +++++++++++++ .../seats/mesh-pipeline-runner/seat.json | 53 +++++++++++++++++-- .../ts/seats/meshpipelinerunner/index.d.ts | 28 ++++++++-- 5 files changed, 144 insertions(+), 13 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index 65238d420..e5c1449ad 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -20,7 +20,7 @@ const Form = 13 // whose fields changed while its forms did not (design 47 H2 §780). const ( generatedForms = "13" - generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverAdded=6966283f6909 MoverAddedEvent=b24ae82030ab MoverEnded=4b35095f6829 MoverRow=b7ceefe24722 Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=397a8219a855 PipelineStarted=d5fc3ee236c7 PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=ed94ced4513a Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=8609ff359791 StandsAnswer=e05cecdde456 StartAnswer=ed94ced4513a StartedMover=4450a94e6ca3 StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=bdaa8bbfbcab StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=21e4ee7a3ef1 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" + generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverAdded=6966283f6909 MoverAddedEvent=b24ae82030ab MoverEnded=4b35095f6829 MoverRow=b7ceefe24722 Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=397a8219a855 PipelineStarted=d5fc3ee236c7 PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=69998ea62147 PlaceUnfinishedAnswerFailedItem=d9b89913b9bf PlaceUnfinishedAnswerPlacedItem=9ff9288125e5 Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=8609ff359791 StandsAnswer=e05cecdde456 StartAnswer=ed94ced4513a StartedMover=4450a94e6ca3 StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=bdaa8bbfbcab StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=21e4ee7a3ef1 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" ) const ( @@ -94,7 +94,7 @@ func VerbDescription(verb string) string { case VerbPlace: return "A waiting pipeline placed ahead of its turn, its steps asked now; written in the hand-act log (design 47 H §748, H-A-53)." case VerbPlaceUnfinished: - return "A mover kept in the state unfinished put in a pipeline of its own at once, keyed ..unfinished.; written in the hand-act log (design 47 H2 §786, H-A-398)." + return "A mover kept in the state unfinished put in a pipeline of its own at once, keyed ..unfinished.; written in the hand-act log (design 47 H2 §786, H-A-398). With all, each key of unfinished is put in a pipeline of its own; the answer names every pipeline put and every key that could not be (design 47 H2 H-A-725)." case VerbAskAgain: return "A declined approval step asked again (ADR 0666 section 10). Written in the hand-act log." case VerbTestRuns: @@ -1634,14 +1634,36 @@ type PlaceUnfinishedInput struct { Why string `json:"why"` } -// PlaceUnfinishedAnswer is what place-unfinished answers. -type PlaceUnfinishedAnswer struct { - // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). - Form int64 `json:"form,omitempty"` +// PlaceUnfinishedAnswerFailedItem is a type of the contract. +type PlaceUnfinishedAnswerFailedItem struct { + // the unfinished entry's key + Key string `json:"key"` + // why it could not be put + Words string `json:"words"` +} + +// PlaceUnfinishedAnswerPlacedItem is a type of the contract. +type PlaceUnfinishedAnswerPlacedItem struct { + // the unfinished entry's key + Key string `json:"key"` // the key of the pipeline the mover is put in Pipeline string `json:"pipeline"` } +// PlaceUnfinishedAnswer is what place-unfinished answers. +type PlaceUnfinishedAnswer struct { + // one item per key that could not be put with all, empty with key; always present (design 47 H2 H-A-725) + Failed []PlaceUnfinishedAnswerFailedItem `json:"failed"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` + // with key, the key of the pipeline the mover is put in; absent with all + Pipeline string `json:"pipeline,omitempty"` + // one item per key put with all, empty with key; always present (design 47 H2 H-A-725) + Placed []PlaceUnfinishedAnswerPlacedItem `json:"placed"` + // with all and no key in unfinished, that two empty lists are the answer (design 47 H2 H-A-725) + Said string `json:"said,omitempty"` +} + // AskAgainInput is what ask-again takes. type AskAgainInput struct { // the mover's module, so a pipeline of several movers is never ambiguous; a call naming none on a pipeline of one mover is taken as that mover (design 47 H-A-101) diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go index f14ae4e43..9ca12a204 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go @@ -151,6 +151,12 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v StandsInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "show asked within a bound (H-A-709)", subject: "", given: "{\"bound\":65536,\"next\":\"cursor-1\",\"pipeline\":\"main.3589\"}", wire: "{\"bound\":65536,\"next\":\"cursor-1\",\"pipeline\":\"main.3589\"}", decode: func(b []byte) (any, error) { var v ShowInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "place-unfinished with all answers each key put and each that could not be (H-A-725)", subject: "", given: "{\"failed\":[{\"key\":\"main.gitea\",\"words\":\"its entry is not read\"}],\"placed\":[{\"key\":\"main.nats\",\"pipeline\":\"main.3589.unfinished.nats\"}]}", wire: "{\"failed\":[{\"key\":\"main.gitea\",\"words\":\"its entry is not read\"}],\"placed\":[{\"key\":\"main.nats\",\"pipeline\":\"main.3589.unfinished.nats\"}]}", + decode: func(b []byte) (any, error) { var v PlaceUnfinishedAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "place-unfinished with all over no key answers two empty lists and says so (H-A-725)", subject: "", given: "{\"failed\":[],\"placed\":[],\"said\":\"no key in unfinished\"}", wire: "{\"failed\":[],\"placed\":[],\"said\":\"no key in unfinished\"}", + decode: func(b []byte) (any, error) { var v PlaceUnfinishedAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "place-unfinished with one key answers its pipeline", subject: "", given: "{\"failed\":[],\"pipeline\":\"main.3589.unfinished.nats\",\"placed\":[]}", wire: "{\"failed\":[],\"pipeline\":\"main.3589.unfinished.nats\",\"placed\":[]}", + decode: func(b []byte) (any, error) { var v PlaceUnfinishedAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { v, err := c.decode([]byte(c.given)) diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json index b3cb40dc0..27026dee0 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json @@ -434,5 +434,41 @@ "bound": 65536, "next": "cursor-1" } + }, + { + "name": "place-unfinished with all answers each key put and each that could not be (H-A-725)", + "of": "verb:place-unfinished.answer", + "given": { + "placed": [ + { + "key": "main.nats", + "pipeline": "main.3589.unfinished.nats" + } + ], + "failed": [ + { + "key": "main.gitea", + "words": "its entry is not read" + } + ] + } + }, + { + "name": "place-unfinished with all over no key answers two empty lists and says so (H-A-725)", + "of": "verb:place-unfinished.answer", + "given": { + "placed": [], + "failed": [], + "said": "no key in unfinished" + } + }, + { + "name": "place-unfinished with one key answers its pipeline", + "of": "verb:place-unfinished.answer", + "given": { + "pipeline": "main.3589.unfinished.nats", + "placed": [], + "failed": [] + } } ] diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json index 9eb333c20..79e55f56d 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -639,7 +639,7 @@ }, { "name": "place-unfinished", - "description": "A mover kept in the state unfinished put in a pipeline of its own at once, keyed ..unfinished.; written in the hand-act log (design 47 H2 §786, H-A-398).", + "description": "A mover kept in the state unfinished put in a pipeline of its own at once, keyed ..unfinished.; written in the hand-act log (design 47 H2 §786, H-A-398). With all, each key of unfinished is put in a pipeline of its own; the answer names every pipeline put and every key that could not be (design 47 H2 H-A-725).", "input": { "type": "object", "properties": { @@ -665,11 +665,58 @@ "properties": { "pipeline": { "type": "string", - "description": "the key of the pipeline the mover is put in" + "description": "with key, the key of the pipeline the mover is put in; absent with all" + }, + "placed": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string", + "description": "the unfinished entry's key" + }, + "pipeline": { + "type": "string", + "description": "the key of the pipeline the mover is put in" + } + }, + "required": [ + "key", + "pipeline" + ] + }, + "description": "one item per key put with all, empty with key; always present (design 47 H2 H-A-725)" + }, + "failed": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string", + "description": "the unfinished entry's key" + }, + "words": { + "type": "string", + "description": "why it could not be put" + } + }, + "required": [ + "key", + "words" + ] + }, + "description": "one item per key that could not be put with all, empty with key; always present (design 47 H2 H-A-725)" + }, + "said": { + "type": "string", + "description": "with all and no key in unfinished, that two empty lists are the answer (design 47 H2 H-A-725)" } }, "required": [ - "pipeline" + "placed", + "failed" ] }, "class": "act" diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts index f5989b3bf..5a9c9ac10 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -998,14 +998,34 @@ export interface PlaceUnfinishedInput { "why": string; } -/** is what place-unfinished answers. */ -export interface PlaceUnfinishedAnswer { - /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ - "form"?: number; +export interface PlaceUnfinishedAnswerFailedItem { + /** the unfinished entry's key */ + "key": string; + /** why it could not be put */ + "words": string; +} + +export interface PlaceUnfinishedAnswerPlacedItem { + /** the unfinished entry's key */ + "key": string; /** the key of the pipeline the mover is put in */ "pipeline": string; } +/** is what place-unfinished answers. */ +export interface PlaceUnfinishedAnswer { + /** one item per key that could not be put with all, empty with key; always present (design 47 H2 H-A-725) */ + "failed": PlaceUnfinishedAnswerFailedItem[]; + /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ + "form"?: number; + /** with key, the key of the pipeline the mover is put in; absent with all */ + "pipeline"?: string; + /** one item per key put with all, empty with key; always present (design 47 H2 H-A-725) */ + "placed": PlaceUnfinishedAnswerPlacedItem[]; + /** with all and no key in unfinished, that two empty lists are the answer (design 47 H2 H-A-725) */ + "said"?: string; +} + /** is what ask-again takes. */ export interface AskAgainInput { /** the mover's module, so a pipeline of several movers is never ambiguous; a call naming none on a pipeline of one mover is taken as that mover (design 47 H-A-101) */ From 19f8f6b63771f17b7999564bc9432015978b3398 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:10:37 +0100 Subject: [PATCH 012/141] B3 held-at-its-version: a registry's record at V is judged for every artifact, by the fingerprint it keeps or the reserved digest; MarkHeld writes it Builds: design 47 H2 H-A-588 (4), H-A-616, H-A-663 --- .../cmd/mesh-delivery-builder/publishitem.go | 7 +-- .../cmd/mesh-delivery-builder/reserve.go | 3 ++ .../internal/versions/republish.go | 51 +++++++++++++------ .../internal/versions/republish_test.go | 19 +++++++ .../internal/versions/reserve.go | 44 ++++++++++++++++ .../internal/versions/reserve_test.go | 13 +++++ 6 files changed, 119 insertions(+), 18 deletions(-) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/publishitem.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/publishitem.go index ba8fbea96..f9d90dc89 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/publishitem.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/publishitem.go @@ -421,8 +421,9 @@ func registryVersionsVia(call toolCaller) func(context.Context, string, string) } var a struct { // the four registry seats answer versions alike: each version with its digest Versions []struct { - Version string `json:"version"` - Digest string `json:"digest"` + Version string `json:"version"` + Digest string `json:"digest"` + Fingerprint string `json:"fingerprint"` } `json:"versions"` } if err := json.Unmarshal(raw, &a); err != nil { @@ -430,7 +431,7 @@ func registryVersionsVia(call toolCaller) func(context.Context, string, string) } out := make([]versions.HeldVersion, 0, len(a.Versions)) for _, v := range a.Versions { - out = append(out, versions.HeldVersion{Version: v.Version, Digest: v.Digest}) + out = append(out, versions.HeldVersion{Version: v.Version, Digest: v.Digest, Fingerprint: v.Fingerprint}) } return out, nil } diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go index 16d5eff87..813e426a4 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go @@ -573,6 +573,9 @@ func (rv *reservations) ReleasedFor(ctx context.Context, module, fingerprint str // asked for ever. The version's release follows from the catalog as for any published. func (rv *reservations) markHeld(ctx context.Context, v versions.ReservedVersion, held []versions.HeldArtifact) { for _, h := range held { + if v.Published[h.Ref] { + continue // marked already: its package-published was said (design 47 H2 H-A-588 (4): once) + } rv.logf("%s %s: %s holds %s %s with the built digest %s: marked published from its record", v.Module, v.Version, h.Seat, h.Name, h.Version, h.Digest) rv.published(ctx, versions.Outcome{Name: h.Name, Version: h.Version, Digest: h.Digest, Holder: h.Seat}, nil) } diff --git a/modules/mesh-delivery-builder/internal/versions/republish.go b/modules/mesh-delivery-builder/internal/versions/republish.go index d2ab90a8f..c78549e4a 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish.go +++ b/modules/mesh-delivery-builder/internal/versions/republish.go @@ -846,6 +846,8 @@ func (r *Reserver) MarkUnstored(ctx context.Context, module, version, artifact, // HeldVersion is one version a registry seat's verb versions answers of a name, with its digest. type HeldVersion struct { Version, Digest string + // Fingerprint is the fingerprint the holder keeps for the version (design 47 H2 H-A-589 (3)); empty where none is kept. + Fingerprint string } // HeldArtifact is an artifact of a reservation as a registry seat's record holds it at the reservation's version: its reference, @@ -854,32 +856,51 @@ type HeldArtifact struct { Ref, Seat, Name, Version, Digest string } -// Judged is what the registries' record says of a reserved version's missing artifacts (design 47 H H-A-272, H-A-274, H-A-275): -// those held at the version with the built digest (Held), those held at the version with another digest (Elsewhere), and, when an -// artifact is held at neither, the first one lacking (Lacks). All says every missing artifact is held with its built digest. +// Judged is what the registries' record says of a reserved version's artifacts (design 47 H H-A-272, H-A-274, H-A-275; H2 H-A-588 +// (4), H-A-616, H-A-663): those held at the version for the reservation's fingerprint (Held, with the digest the registry holds), +// those held at the version for another fingerprint or with another digest (Elsewhere), and, when an artifact is held at neither, +// the first one lacking (Lacks). All says every artifact is held for the fingerprint. type Judged struct { Held, Elsewhere []HeldArtifact Lacks string All bool } -// Held judges v's missing artifacts against the registries' record (design 47 H H-A-269 (2), H-A-272, H-A-274, H-A-275): each -// artifact's registry seat and name as a publish again sends them, its record read through the seat's verb versions (versionsOf). -// A version with no missing artifact is All. +// heldFor says whether the registry's record h of an artifact at v's version is held for v's fingerprint (design 47 H2 H-A-616, +// H-A-663): a holder that keeps a fingerprint says it, and it is the reservation's or another's; one that keeps none holds it for +// the reservation's fingerprint when its digest is the one the reservation records for the artifact (a kept published is such a +// record), and elsewhere when the reservation records another digest or none. +func heldFor(v ReservedVersion, ref string, h HeldVersion) bool { + if h.Fingerprint != "" { + return h.Fingerprint == v.Fingerprint + } + return v.Artifacts[ref] != "" && h.Digest == v.Artifacts[ref] +} + +// Held judges every artifact of v against the registries' record (design 47 H H-A-269 (2), H-A-272, H-A-274, H-A-275; H2 H-A-588 +// (4), H-A-663: an artifact already marked published counts as held when its registry still answers it): each artifact's registry +// seat and name as a publish again sends them, its record read through the seat's verb versions (versionsOf). An upstream artifact +// is never read. A version with no missing artifact is All. func (r *Republisher) Held(ctx context.Context, v ReservedVersion, versionsOf func(ctx context.Context, seat, name string) ([]HeldVersion, error)) (Judged, error) { - missing := v.Missing() - if len(missing) == 0 { + if len(v.Missing()) == 0 { return Judged{All: true}, nil } e, err := r.Entry(ctx, v.Fingerprint) if err != nil { return Judged{}, fmt.Errorf("the catalog entry %s of %s %s cannot be read: %w", v.Fingerprint, v.Module, v.Version, err) } + refs := make([]string, 0, len(v.Artifacts)) + for ref := range v.Artifacts { + if !slices.Contains(v.Upstream, ref) { + refs = append(refs, ref) + } + } + sort.Strings(refs) var out Judged - for _, ref := range missing { + for _, ref := range refs { seat, name, _, ok := publishTarget(e, v.Module, ref) if !ok { - if out.Lacks == "" { + if out.Lacks == "" && !v.Published[ref] { out.Lacks = ref + ": the catalog entry names no registry seat for it" } continue @@ -888,13 +909,13 @@ func (r *Republisher) Held(ctx context.Context, v ReservedVersion, versionsOf fu if err != nil { return Judged{}, fmt.Errorf("%s's versions of %s cannot be read: %w", seat, name, err) } - at, found := HeldArtifact{}, false + at, found, forF := HeldArtifact{}, false, false for _, h := range held { if strings.TrimPrefix(h.Version, "v") != v.Version { continue } - at, found = HeldArtifact{Ref: ref, Seat: seat, Name: name, Version: h.Version, Digest: h.Digest}, true - if h.Digest == v.Artifacts[ref] { + at, found, forF = HeldArtifact{Ref: ref, Seat: seat, Name: name, Version: h.Version, Digest: h.Digest}, true, heldFor(v, ref, h) + if forF { break } } @@ -903,13 +924,13 @@ func (r *Republisher) Held(ctx context.Context, v ReservedVersion, versionsOf fu if out.Lacks == "" { out.Lacks = fmt.Sprintf("%s holds no %s %s", seat, name, v.Version) } - case at.Digest == v.Artifacts[ref]: + case forF: out.Held = append(out.Held, at) default: out.Elsewhere = append(out.Elsewhere, at) } } - out.All = len(out.Held) == len(missing) + out.All = out.Lacks == "" && len(out.Elsewhere) == 0 && len(out.Held) > 0 return out, nil } diff --git a/modules/mesh-delivery-builder/internal/versions/republish_test.go b/modules/mesh-delivery-builder/internal/versions/republish_test.go index 0f78961f4..b58db0148 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish_test.go +++ b/modules/mesh-delivery-builder/internal/versions/republish_test.go @@ -262,6 +262,11 @@ func TestTheRegistriesRecordSaysWhetherAVersionIsHeld(t *testing.T) { {name: "held in the Go form with the built digest", holds: []HeldVersion{{Version: "v0.1.36", Digest: "sha256:z"}, {Version: "v0.1.37", Digest: "sha256:a"}}, all: true}, {name: "another digest at the version", holds: []HeldVersion{{Version: "0.1.37", Digest: "sha256:b"}}, elsewhere: true}, {name: "the version lacked", holds: []HeldVersion{{Version: "0.1.36", Digest: "sha256:a"}}, lacks: true}, + // H2 H-A-616: no fingerprint kept: held for F when the digest is the reserved one, elsewhere with another + {name: "no fingerprint kept, the reserved digest", holds: []HeldVersion{{Version: "0.1.37", Digest: "sha256:a"}}, all: true}, + // H2 H-A-589 (3): a holder that keeps a fingerprint says whose it is, whatever the digest + {name: "the fingerprint kept is F's", holds: []HeldVersion{{Version: "0.1.37", Digest: "sha256:b", Fingerprint: "fp"}}, all: true}, + {name: "the fingerprint kept is another's", holds: []HeldVersion{{Version: "0.1.37", Digest: "sha256:a", Fingerprint: "other"}}, elsewhere: true}, } { t.Run(c.name, func(t *testing.T) { var seat, name string @@ -283,6 +288,20 @@ func TestTheRegistriesRecordSaysWhetherAVersionIsHeld(t *testing.T) { if j, err := r.Held(ctx, v, nil); err != nil || !j.All { t.Errorf("a version with no missing artifact is judged %+v (%v), want all held without a read", j, err) } + // H2 H-A-663: a kept published counts as held while its registry answers it at the version, and no longer when it does not + v.Published, v.Artifacts = map[string]bool{"m:lib": true, "m:other": true}, map[string]string{"m:lib": "sha256:a", "m:other": "sha256:o"} + v.Upstream = nil + entry.Artifacts = append(entry.Artifacts, meshcatalog.Artifact{Ref: "m:other", Kind: "package", Language: "go", Package: &meshcatalog.ArtifactPackage{Ecosystem: "go", Name: "git.example/o"}}) + v.Published["m:other"] = false + both := func(_ context.Context, _, n string) ([]HeldVersion, error) { + if n == "git.example/o" { + return nil, nil + } + return []HeldVersion{{Version: "0.1.37", Digest: "sha256:a"}}, nil + } + if j, err := r.Held(ctx, v, both); err != nil || j.All || len(j.Held) != 1 || j.Held[0].Ref != "m:lib" || !strings.Contains(j.Lacks, "git.example/o") { + t.Errorf("a kept published its registry answers is judged %+v (%v), want it held and the other lacking", j, err) + } } // queueAt writes a queued version of module m at holder oci directly, as a start finds it. diff --git a/modules/mesh-delivery-builder/internal/versions/reserve.go b/modules/mesh-delivery-builder/internal/versions/reserve.go index a6a3a55e9..377f2273c 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve.go @@ -416,6 +416,50 @@ func allSet(m map[string]string) bool { return true } +// MarkHeld writes on module's reservation of version each artifact a registry holds at the version for the reservation's +// fingerprint, with the held digest, and marks it published when it was not (design 47 H2 H-A-588 (4)), in one compare-and-set. +// It answers the artifacts it newly marked, and false when the reservation stands at another version. +func (r *Reserver) MarkHeld(ctx context.Context, module, version string, held []HeldArtifact) ([]HeldArtifact, bool, error) { + series, _, err := SplitVersion(version) + if err != nil { + return nil, false, err + } + key := ReservedKey(module, series) + for { + cur, rev, found, err := r.get(ctx, key) + if err != nil || !found || cur.Version != version { + return nil, false, err + } + was := cur + was.Artifacts, was.Published, was.PublishedAt = maps.Clone(cur.Artifacts), maps.Clone(cur.Published), maps.Clone(cur.PublishedAt) + var marked []HeldArtifact + changed := false + if cur.Artifacts == nil { + cur.Artifacts = map[string]string{} + } + for _, h := range held { + if cur.Artifacts[h.Ref] != h.Digest { + cur.Artifacts[h.Ref], changed = h.Digest, true + } + if !cur.Published[h.Ref] { + cur.markPublished(h.Ref, r.now()) + marked, changed = append(marked, h), true + } + } + if !changed { + return nil, true, nil + } + raw, _ := json.Marshal(cur) + if _, err := r.Store.Update(ctx, key, raw, rev); errors.Is(err, ErrConflict) { + continue + } else if err != nil { + return nil, false, fmt.Errorf("%s cannot be written: %w", key, err) + } + r.said(r.reindex(ctx, key, was, cur)) + return marked, true, nil + } +} + // DefaultReleasedKept is the setting released-kept unless set (design 47 G A-456b). const DefaultReleasedKept = 16 diff --git a/modules/mesh-delivery-builder/internal/versions/reserve_test.go b/modules/mesh-delivery-builder/internal/versions/reserve_test.go index 46616f5ed..cbb3538ee 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve_test.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve_test.go @@ -174,6 +174,19 @@ func TestReservationIsReadAndMarkedPublished(t *testing.T) { if key, ok := ReservedBoundOf(ReservedBoundKey("m", "1.4")); !ok || key != ReservedKey("m", "1.4") || ReservedBoundFor(key) != ReservedBoundKey("m", "1.4") { t.Errorf("the bound key does not name the reservation back: %q %v", key, ok) } + // Design 47 H2 H-A-588 (4): MarkHeld writes the digest a registry holds on the reservation and marks the artifact published, once. + held := []HeldArtifact{{Ref: "m:b", Digest: "sha256:held"}} + markedHeld, ok, err := r.MarkHeld(ctx, "m", "1.4.3", held) + cur, _, _ = r.At(ctx, ReservedKey("m", "1.4")) + if err != nil || !ok || len(markedHeld) != 1 || cur.Artifacts["m:b"] != "sha256:held" || !cur.Published["m:b"] || cur.Artifacts["m:a"] != "sha256:aa" || cur.PublishedAt["m:b"].IsZero() { + t.Fatalf("marked %v (%v, %v), reservation %+v: want m:b with the held digest, published, m:a as it was", markedHeld, ok, err, cur) + } + if again, ok, err := r.MarkHeld(ctx, "m", "1.4.3", held); err != nil || !ok || len(again) != 0 { + t.Errorf("a second marking marked %v (%v, %v), want none: package-published is said once", again, ok, err) + } + if _, ok, _ := r.MarkHeld(ctx, "m", "1.4.99", held); ok { + t.Error("a reservation at another version was marked") + } } // TestAReleaseIsRecordedByFingerprintBeforeItsReservationGoes: design 47 G A-456a — the version-released of a version records From 25e9d71e1953e74a478659c04341ff5db2fb2486 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:10:42 +0100 Subject: [PATCH 013/141] X1 readme-checks: the README names the check main requires, the checker's mesh/check, and no merge-check.sh Builds: design 47 H2 H-A-676 (DQ-28) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a087d22cb..19b971acf 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Novox Mesh — delivery: the parts that build, check and deliver a change by watching and writing keys on the bus (ADR 0429). -Made by the mesh from the gitea module's config value `repositories` (novox/hq ADR 0428). Main takes no push: a change reaches it by a pull request whose `mesh/repo-check` (this repository's `merge-check.sh`) and `mesh/merge-gate` passed. +Made by the mesh from the gitea module's config value `repositories` (novox/hq ADR 0428). Main takes no push: a change reaches it by a pull request whose `mesh/check`, the checker's verdict, passed (ADR 0447 §1); this repository holds no `merge-check.sh`. From e0f69f73d3aac4dc74300cbae0eece460439b62f Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:10:55 +0100 Subject: [PATCH 014/141] K5 missing-reads-go: graph.MissingReads goes, with its rows Builds: design 47 H2 H-A-639 (DQ-1) --- modules/mesh-delivery-sdk/graph/graph_test.go | 19 ---------- modules/mesh-delivery-sdk/graph/reads.go | 37 ------------------- 2 files changed, 56 deletions(-) delete mode 100644 modules/mesh-delivery-sdk/graph/reads.go diff --git a/modules/mesh-delivery-sdk/graph/graph_test.go b/modules/mesh-delivery-sdk/graph/graph_test.go index 86fedf537..bbe5c7914 100644 --- a/modules/mesh-delivery-sdk/graph/graph_test.go +++ b/modules/mesh-delivery-sdk/graph/graph_test.go @@ -18,25 +18,6 @@ func TestGraphEdges(t *testing.T) { t.Run("a node's value", nodeValues) t.Run("a reader of the seat list waits for its holder", readersOfTheSeatList) t.Run("a verb is served by a running healthy have of the node-engine contract", servedByHaves) - // ADR 0636 §2, issue 1966: a need of a bootstrapped seat is read by every engine whatever its statement names; a seat - // not bootstrapped and a word stay missing, and an engine stating none is read as the baseline. - t.Run("a bootstrapped seat is read by every engine", func(t *testing.T) { - stated := []string{"word:claims", "word:invokes"} - for _, c := range []struct { - name string - needs, stated []string - want []string - }{ - {"mesh-catalog and node-backup", []string{"seat:mesh-catalog", "seat:node-backup", "word:invokes"}, stated, nil}, - {"a seat not bootstrapped", []string{"seat:mesh-catalog", "seat:mesh-vault"}, stated, []string{"seat:mesh-vault"}}, - {"a word", []string{"seat:node-engine", "word:zone"}, stated, []string{"word:zone"}}, - {"the baseline", []string{"seat:mesh-catalog", "form:seat-reach"}, nil, []string{"form:seat-reach"}}, - } { - if got := MissingReads(c.needs, c.stated); !slices.Equal(got, c.want) { - t.Errorf("%s: missing %v, want %v", c.name, got, c.want) - } - } - }) fp := "src2:" + strings.Repeat("b", 64) node := func(repository, path string, edit func(*Node)) Node { n := Node{FP: fp, Repository: repository, Path: path} diff --git a/modules/mesh-delivery-sdk/graph/reads.go b/modules/mesh-delivery-sdk/graph/reads.go deleted file mode 100644 index 1ac59974c..000000000 --- a/modules/mesh-delivery-sdk/graph/reads.go +++ /dev/null @@ -1,37 +0,0 @@ -package graph - -import ( - "slices" - "strings" - "sync" - - "git.novox.be/novox/mesh-sdk/go/catalogue" - "git.novox.be/novox/mesh-sdk/go/seatlist" -) - -// bootstrappedReads are the reader capabilities `seat:` of the bootstrapped seats: the embedded files' own, so -// computed once. -var bootstrappedReads = sync.OnceValue(func() []string { - var out []string - for _, d := range seatlist.Bootstrapped() { - out = append(out, catalogue.ReadSeat+d.Seat) - } - return out -}) - -// MissingReads is catalogue.MissingManifestReads with every need of a bootstrapped seat counted as read (novox/hq ADR 0614 -// §4, ADR 0636 §2): every reader of the seat list holds the bootstrapped seats from its start, before it has read the list, -// so a manifest naming one is read by every node-engine whatever its statement names. Without it an engine whose statement -// was made before its list was in use states no seat, and the node-engine's own build naming mesh-catalog is held on the -// very engine that would state it (issue 1966). The assigner's capability hold and the indexer's hold both judge with it, -// so the rule is one. -func MissingReads(needs, stated []string) []string { - boot := bootstrappedReads() - missing := slices.DeleteFunc(catalogue.MissingManifestReads(needs, stated), func(n string) bool { - return strings.HasPrefix(n, catalogue.ReadSeat) && slices.Contains(boot, n) - }) - if len(missing) == 0 { - return nil - } - return missing -} From 81bf6c7cc97bf04c06b9af4e584abbfefa08f24e Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:11:41 +0100 Subject: [PATCH 015/141] K1 stopping-goes: the kind stopping is read nowhere; PublishFault reads no responders as the transport fault Builds: design 47 H2 H-A-570 (3), H-A-624 (3), H-A-658 --- modules/mesh-delivery-sdk/buildstep/ask_test.go | 8 +++----- modules/mesh-delivery-sdk/buildstep/passing.go | 17 ++++------------- modules/mesh-delivery-sdk/steprun/again_test.go | 15 ++++----------- modules/mesh-delivery-sdk/steprun/publish.go | 6 +++--- 4 files changed, 14 insertions(+), 32 deletions(-) diff --git a/modules/mesh-delivery-sdk/buildstep/ask_test.go b/modules/mesh-delivery-sdk/buildstep/ask_test.go index 1a47f3500..188118cc9 100644 --- a/modules/mesh-delivery-sdk/buildstep/ask_test.go +++ b/modules/mesh-delivery-sdk/buildstep/ask_test.go @@ -561,11 +561,9 @@ func TestPauseCapacityAndComposerKey(t *testing.T) { if !IsPassing(fmt.Errorf("fetch: %w", &Passing{Err: errors.New("s")})) || IsPassing(errors.New("i/o timeout")) { t.Error("a wrapped Passing is a Passing error and a bare error is none") } - // A call a stopping tool runner did not take is passing by its typed fault, wrapped or not; its words alone, and a bare - // "timeout", are not (design 47 H2 H-A-542). - if !IsPassing(kindedFault("stopping")) || !IsPassing(fmt.Errorf("publish: %w", kindedFault("stopping"))) || - IsPassing(kindedFault("away")) || IsPassing(errors.New("the tool runner is stopping")) || IsPassing(errors.New("timeout")) { - t.Error("a stopping tool runner's fault is passing by its kind alone") + // H-A-570 (3): no fault kind makes a passing fault; only a Passing does, by its type, and words and a bare "timeout" are none. + if IsPassing(kindedFault("stopping")) || IsPassing(kindedFault("away")) || IsPassing(errors.New("the tool runner is stopping")) || IsPassing(errors.New("timeout")) { + t.Error("only a Passing is passing") } if Ended(Step{State: StepRunning}) || Ended(Step{State: StepAgain}) || !Ended(Step{State: StepPassed}) || !Ended(Step{State: StepFailed}) { t.Error("Ended: running and again are no end") diff --git a/modules/mesh-delivery-sdk/buildstep/passing.go b/modules/mesh-delivery-sdk/buildstep/passing.go index 4aafd08b0..fc11a9369 100644 --- a/modules/mesh-delivery-sdk/buildstep/passing.go +++ b/modules/mesh-delivery-sdk/buildstep/passing.go @@ -14,21 +14,12 @@ type Passing struct{ Err error } func (p *Passing) Error() string { return p.Err.Error() } func (p *Passing) Unwrap() error { return p.Err } -// IsPassing says err is, or wraps, a Passing, or a call a stopping tool runner did not take (errorKindStopping): the one -// place every step's fault reading counts stopping as passing, by its kind and never by its words (design 47 H2 H-A-542). +// IsPassing says err is, or wraps, a Passing: the one place every step's fault reading counts a fault as passing, by its +// type and never by its words. A call that met no responders is the build module's to wrap, as steprun.PublishFault does +// (design 47 H2 H-A-570 (3), H-A-658). func IsPassing(err error) bool { var p *Passing - return errors.As(err, &p) || stopping(err) -} - -// errorKindStopping is the typed fault a stopping tool runner answers each call it does not take with, mesh-sdk stdio's -// ErrorKindStopping (design 47 H2 H-A-542); this package reaches no bus, so it reads the kind by the error's ErrorKind. -const errorKindStopping = "stopping" - -// stopping says err is, or wraps, an error whose typed fault is stopping (ErrorKind() string). -func stopping(err error) bool { - var kinded interface{ ErrorKind() string } - return errors.As(err, &kinded) && kinded.ErrorKind() == errorKindStopping + return errors.As(err, &p) } // passingWords are the words of a network that did not answer, lower-cased: go's and git's (a lookup, a timeout, a refused or diff --git a/modules/mesh-delivery-sdk/steprun/again_test.go b/modules/mesh-delivery-sdk/steprun/again_test.go index 9e051373a..79b15cbb0 100644 --- a/modules/mesh-delivery-sdk/steprun/again_test.go +++ b/modules/mesh-delivery-sdk/steprun/again_test.go @@ -11,20 +11,12 @@ import ( sdkstep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" ) -// stoppingFault is a call a stopping tool runner did not take, as mesh-sdk's stdio hands it: its typed fault stopping. -type stoppingFault struct{} - -func (stoppingFault) Error() string { - return "registry's publish was not taken: the tool runner is stopping" -} -func (stoppingFault) ErrorKind() string { return "stopping" } - // Design 47 H2 §799: a fetch met by a forge's 401 or a connection fault, and a publish met by no responders or a bundle // that exited, end their run `again` after again-delays' delay, with no seat call; a third run's fault ends the step failed // with the why `fetch: ` or `publish: `. ADR 0664 §1 with the bus's count above the runs that started: an ask // given back twice before its first run (the bus says delivered 3, the step key 1 run began) meets its fault in run 2, -// given again after again-delays' second, 60 s, not 3. A publish met by a stopping tool runner is one too (H-A-542); a -// bare timeout is not. +// given again after again-delays' second, 60 s, not 3. A publish met by a stopping tool runner is met by no responders (H-A-570 (3)), so it +// is one too; a bare timeout is not. func TestAFetchOrAPublishMetAwayIsATransportFault(t *testing.T) { delay, err := AgainDelays("") if err != nil || delay(1) != 15*time.Second || delay(2) != time.Minute || delay(3) != time.Minute { @@ -47,7 +39,8 @@ func TestAFetchOrAPublishMetAwayIsATransportFault(t *testing.T) { {"a publish met by a bundle that exited", "publish: ", PublishFault(errors.New("the bundle exited"))}, {"a fetch of a commit that is not there", "", gitFailure("fetch", "fatal: unknown revision or path not in the working tree")}, {"a publish refused", "", PublishFault(errors.New("refused: the digest differs"))}, - {"a publish met by a stopping tool runner", "publish: ", PublishFault(fmt.Errorf("asked again: %w", stoppingFault{}))}, + {"a publish met by a stopping tool runner, no responders wrapped", "publish: ", PublishFault(fmt.Errorf("asked again: %w", errors.New("nats: no responders available for request")))}, + {"a publish met by a fault kinded stopping, which no code reads", "", PublishFault(errors.New("registry's publish was not taken: the tool runner is stopping"))}, {"a publish met by a bare timeout", "", PublishFault(errors.New("timeout"))}, } { t.Run(tc.name, func(t *testing.T) { diff --git a/modules/mesh-delivery-sdk/steprun/publish.go b/modules/mesh-delivery-sdk/steprun/publish.go index cbe6af466..a5141188a 100644 --- a/modules/mesh-delivery-sdk/steprun/publish.go +++ b/modules/mesh-delivery-sdk/steprun/publish.go @@ -82,8 +82,8 @@ func PublishParts(ctx context.Context, call SeatCall, seat string, in reg.Publis return sent, PublishFault(err) } -// PublishFault is err, or, when a publish met no responders, a registry's bundle that exited or a stopping tool runner (its -// typed fault stopping, which sdkstep.IsPassing counts, design 47 H2 H-A-542), a sdkstep.Passing whose words open with +// PublishFault is err, or, when a publish met no responders (a stopping tool runner's calls meet none, design 47 H2 H-A-570 +// (3)) or a registry's bundle that exited, a sdkstep.Passing whose words open with // "publish: " (design 47 H2 §799, ADR 0664 §1): the run ends `again`, with no seat call to learn why, and a third run's // fault ends the step failed with the why `publish: `. Any other error, a bare "timeout" among them, is returned as // it is. @@ -93,7 +93,7 @@ func PublishFault(err error) error { return err } words := strings.ToLower(err.Error()) - if !sdkstep.IsPassing(err) && !strings.Contains(words, "no responders") && !strings.Contains(words, "bundle exited") { + if !strings.Contains(words, "no responders") && !strings.Contains(words, "bundle exited") { return err } return &sdkstep.Passing{Err: fmt.Errorf("publish: %w", err)} From 14208c808c4c0cc54db056b31e9085689ca2c085 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:12:13 +0100 Subject: [PATCH 016/141] V1 view-rows-carry-fingerprint: the pipeline page names each mover's fingerprint and version from its row Builds: design 47 H2 H-A-709 (1); row V1 (the tiers of PipelineView still read pipeline.movers: question sent to the lead) --- .../internal/view/pipelines_test.go | 13 +++++++++++++ .../internal/view/pipelinespage.go | 11 +++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/modules/mesh-delivery-view/internal/view/pipelines_test.go b/modules/mesh-delivery-view/internal/view/pipelines_test.go index ab9cb2063..52270fa42 100644 --- a/modules/mesh-delivery-view/internal/view/pipelines_test.go +++ b/modules/mesh-delivery-view/internal/view/pipelines_test.go @@ -133,6 +133,12 @@ func TestThePipelinesPage(t *testing.T) { Steps: map[string]int64{"passed": 5, "failed": 1, "could not run": 1, "waiting for a build node": 2}}) runner.setRows(testBranch, seat.PipelineRow{Pipeline: "release.8", Source: 4, Revision: 8, Outcome: seat.PipelineOutcomePassed}, seat.PipelineRow{Pipeline: "release.7", Source: 4, Revision: 7, Outcome: seat.PipelineOutcomeSuperseded}) + // H-A-709 (1): a pipeline of 129 movers whose answer holds none in `movers`, only the rows, each with its fingerprint and version. + big := seat.ShowAnswer{Pipeline: seat.Pipeline{Pipeline: "main.13", Branch: "main", Source: 9, Revision: 13, Outcome: seat.PipelineOutcomePassed}} + for i := range 129 { + big.Movers = append(big.Movers, seat.MoverRow{Module: fmt.Sprintf("m%03d", i), Fingerprint: "src2:" + strings.Repeat(fmt.Sprintf("%x", i%16), 64), Version: fmt.Sprintf("0.1.%d", i), Outcome: seat.MoverRowOutcomePassed}) + } + runner.shows["main.13"] = big p := NewPipelines(runner.call, func() []string { return []string{testBranch} }, 0, nil) m := New(testView) fill(m, sourceE(t, 4)) @@ -188,6 +194,13 @@ func TestThePipelinesPage(t *testing.T) { `wantedapplyingno want written`, `held: connection refusedheld: health failed on n1`, "

TIER 2

", `changes?pipeline=main.12\u0026since=`}}, + {"the terminal view's pipeline of 129 movers names each mover's fingerprint and version from its row", func() string { + a, err := p.Show("main.13", "", "") + if err != nil { + return err.Error() + } + return text(func(b *bytes.Buffer) { PipelineTable(b, PipelineAnswer{ShowAnswer: a}, "") }) + }, []string{"m000 src2:" + strings.Repeat("0", 64) + " 0.1.0 passed", "m128 src2:" + strings.Repeat("0", 64) + " 0.1.128 passed", "m127 src2:" + strings.Repeat("f", 64) + " 0.1.127 passed"}}, {"a stage's worst outcome follows the runner's step words, an unknown one counting as failed", func() string { at := func(o ...string) string { var ss []seat.StepResult diff --git a/modules/mesh-delivery-view/internal/view/pipelinespage.go b/modules/mesh-delivery-view/internal/view/pipelinespage.go index 4353f1e6a..0e070a2d3 100644 --- a/modules/mesh-delivery-view/internal/view/pipelinespage.go +++ b/modules/mesh-delivery-view/internal/view/pipelinespage.go @@ -99,17 +99,12 @@ func failedText(f *seat.FailedStep) string { return s } -// MoverRowsText is one pipeline's mover rows as show without a mover answers them: each row's module, outcome and failed -// step, beside the pipeline's mover of that module's fingerprint and published version. +// MoverRowsText is one pipeline's mover rows as show without a mover answers them: each row's module, its fingerprint and +// version, which the row carries (design 47 H2 H-A-709 (1)), its outcome and failed step. func MoverRowsText(a seat.ShowAnswer) [][]string { - movers := map[string]seat.Mover{} - for _, m := range a.Pipeline.Movers { - movers[m.Module] = m - } var out [][]string for _, r := range a.Movers { - m := movers[r.Module] - out = append(out, []string{r.Module, m.Fingerprint, m.Version, r.Outcome, failedText(r.Failed)}) + out = append(out, []string{r.Module, r.Fingerprint, r.Version, r.Outcome, failedText(r.Failed)}) } return out } From 423d06faac50a71ac3fa0535cf1d35ee73845d02 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:12:15 +0100 Subject: [PATCH 017/141] DC3b validate-verb: the seat mesh-wants gains the verb validate (form 4), the assigner's tool reaching the process Builds: design 47 H2 H-A-684 (1), H-A-702, H-A-727 --- .../go/seats/meshwants/contract.go | 74 ++++++++++++- .../go/seats/meshwants/contract_test.go | 6 ++ .../seats/mesh-wants/fixtures/verbs.json | 32 ++++++ .../seats/mesh-wants/seat.json | 102 +++++++++++++++++- .../ts/seats/meshwants/index.d.ts | 40 +++++++ .../ts/seats/meshwants/index.js | 1 + 6 files changed, 250 insertions(+), 5 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go b/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go index 4e95b05e3..ef6a8c8a0 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshwants/contract.go @@ -14,13 +14,13 @@ const Seat = "mesh-wants" // Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): // a reader of a value of another form says "form N, this reader knows M". -const Form = 3 +const Form = 4 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "3" - generatedFieldsDigest = "Ask=6cb8b82e2fbe AskTakenEvent=6d5d3da7ac39 AsksByAssignmentsProposalValue=0bb5682c7b3b AsksByBackupNodeModuleFingerprintValue=0bb5682c7b3b AsksByHoldModuleFingerprintValue=0bb5682c7b3b AsksByOutsideNodeModuleFingerprintValue=0bb5682c7b3b AsksByRecordNodeModuleDigestValue=0bb5682c7b3b AsksByRestoreNodeModuleFingerprintValue=0bb5682c7b3b AsksByRevertNodeModuleFingerprintValue=0bb5682c7b3b AssignmentEntry=7d2549782eb2 AssignmentRevision=72c8701f7314 AssignmentRevisionCapabilitiesItem=0c89b0717762 AssignmentRevisionEvent=7faff968ce44 AssignmentRevisionsByCandidateGroupHeadsValue=8553b390118d AssignmentRevisionsByEntryDigestValue=4e5ee7a23e5b AssignmentRevisionsByTrunkRevisionValue=8553b390118d BusAnswer=7538f2f5e68e CatalogOf=7a4646fdbea7 Change=28d1f3c5cd32 ChangeAfterItem=30d718c21581 CompositionReader=5a943c1f8ef1 CompositionRun=2a08fc65e2d0 CompositionRunProgram=5a1202df3497 CompositionRunWaits=9cd147ddfc06 CompositionsAnswer=f8bca93c7f9c CompositionsByGroupHeadsValue=9428965fab8f CompositionsDropAnswer=52803700282a Difference=4011cff516b1 DifferenceAnswer=629237aa39f0 DifferenceEvent=49066d0dff6d DifferenceRefusedItem=0e9caa83ace7 DifferencesByNodeModuleValue=a22487ffadfd DropAnswer=7538f2f5e68e Edge=a71709025a08 EntryAnswer=05adebad70d6 Fill=80f442916429 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 Held=15abbd6a1a33 HeldCandidate=04872f6afbfa InputAnswer=cd41ee65565d KeepNowAnswer=9962ab9fc051 NodeEntryRef=3888ae847653 NotRunning=279b628db0ec PipelineWanted=e1e379c21e59 PipelineWantedEvent=59946b31ab7d PolicyChangedEvent=7538f2f5e68e RevisionAnswer=39002c770cbd RoomEvent=5bd4df78ed84 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 StepAccept=18efeefb6c34 StepEnded=edd08ab1a18b StepEndedEvent=207787118dac StepProgressEvent=8215e490ea8d StepRun=b975f402601a UpgradeAnswer=7538f2f5e68e Wait=951500be820c WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 WantedEvent=58cf7a9f646b WantsByHeldModuleFingerprintValue=ff14aa998a5d WantsByWantNodeModuleValue=ab7c6799fd5d WantsByWantNodeNodeValue=a737a2108d53" + generatedForms = "4" + generatedFieldsDigest = "Ask=6cb8b82e2fbe AskTakenEvent=6d5d3da7ac39 AsksByAssignmentsProposalValue=0bb5682c7b3b AsksByBackupNodeModuleFingerprintValue=0bb5682c7b3b AsksByHoldModuleFingerprintValue=0bb5682c7b3b AsksByOutsideNodeModuleFingerprintValue=0bb5682c7b3b AsksByRecordNodeModuleDigestValue=0bb5682c7b3b AsksByRestoreNodeModuleFingerprintValue=0bb5682c7b3b AsksByRevertNodeModuleFingerprintValue=0bb5682c7b3b AssignmentEntry=7d2549782eb2 AssignmentRevision=72c8701f7314 AssignmentRevisionCapabilitiesItem=0c89b0717762 AssignmentRevisionEvent=7faff968ce44 AssignmentRevisionsByCandidateGroupHeadsValue=8553b390118d AssignmentRevisionsByEntryDigestValue=4e5ee7a23e5b AssignmentRevisionsByTrunkRevisionValue=8553b390118d BusAnswer=7538f2f5e68e CatalogOf=7a4646fdbea7 Change=28d1f3c5cd32 ChangeAfterItem=30d718c21581 CompositionReader=5a943c1f8ef1 CompositionRun=2a08fc65e2d0 CompositionRunProgram=5a1202df3497 CompositionRunWaits=9cd147ddfc06 CompositionsAnswer=f8bca93c7f9c CompositionsByGroupHeadsValue=9428965fab8f CompositionsDropAnswer=52803700282a Difference=4011cff516b1 DifferenceAnswer=629237aa39f0 DifferenceEvent=49066d0dff6d DifferenceRefusedItem=0e9caa83ace7 DifferencesByNodeModuleValue=a22487ffadfd DropAnswer=7538f2f5e68e Edge=a71709025a08 EntryAnswer=05adebad70d6 Fill=80f442916429 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 Held=15abbd6a1a33 HeldCandidate=04872f6afbfa InputAnswer=cd41ee65565d KeepNowAnswer=9962ab9fc051 NodeEntryRef=3888ae847653 NotRunning=279b628db0ec PipelineWanted=e1e379c21e59 PipelineWantedEvent=59946b31ab7d PolicyChangedEvent=7538f2f5e68e RevisionAnswer=39002c770cbd RoomEvent=5bd4df78ed84 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 StepAccept=18efeefb6c34 StepEnded=edd08ab1a18b StepEndedEvent=207787118dac StepProgressEvent=8215e490ea8d StepRun=b975f402601a UpgradeAnswer=7538f2f5e68e ValidateAnswer=484ec1cfda14 ValidateAnswerProblemsItem=728518b4dc83 Wait=951500be820c WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 WantedEvent=58cf7a9f646b WantsByHeldModuleFingerprintValue=ff14aa998a5d WantsByWantNodeModuleValue=ab7c6799fd5d WantsByWantNodeNodeValue=a737a2108d53" ) const ( @@ -32,6 +32,7 @@ const ( VerbInput = "input" VerbCompositions = "compositions" VerbCompositionsDrop = "compositions-drop" + VerbValidate = "validate" VerbKeepNow = "keep-now" VerbDrop = "drop" ) @@ -58,7 +59,7 @@ const ( // Verbs is every verb the seat serves, in its definition's order: a new copy each call. func Verbs() []string { - return []string{VerbUpgrade, VerbBus, VerbRevision, VerbEntry, VerbDifference, VerbInput, VerbCompositions, VerbCompositionsDrop, VerbKeepNow, VerbDrop} + return []string{VerbUpgrade, VerbBus, VerbRevision, VerbEntry, VerbDifference, VerbInput, VerbCompositions, VerbCompositionsDrop, VerbValidate, VerbKeepNow, VerbDrop} } // VerbDescription is a verb's description as the seat's definition says it, "" for a verb the seat does not serve or @@ -81,6 +82,8 @@ func VerbDescription(verb string) string { return "Each composition run the assigner keeps (design 47 G §728): its program, input digest, ask, readers, outcome and verdict, and the state's fill against its cap; with candidate or machine, only those." case VerbCompositionsDrop: return "Drop one composition run by hand (design 47 G §728): the act and why are written in the hand-act log first, then the run's ask is dropped, each reader ended could not run naming the drop, and the key deleted." + case VerbValidate: + return "Judge a pipeline's candidate on request, the manifest validator's verdict of its manifests: the act and why are written in the hand-act log first, then the candidate's validate run, keyed .validate, is joined or started with the step's own code, so a validate step asked later joins it and builds no second manifest validator. It answers the run as it stands: running with its start, or its end: passed; failed cycle naming the cycle; failed manifest-refused with every problem per manifest, those counted and those the case before holds too; could-not-run with why. It writes no want and ends no step (design 47 H2 H-A-684 (1), H-A-702, H-A-727)." case VerbKeepNow: return "Keep the assignment graph's revisions now, by hand (design 47 H2 §813 (2); H-A-417): written in the hand-act log first by the module's tool assigner_keep_now, then the keeping runs at once on the pass's newest computed revision; answers the revision kept, or the fault the keeping met." case VerbDrop: @@ -1287,6 +1290,60 @@ type CompositionsDropAnswer struct { Run CompositionRun `json:"run"` } +// ValidateInput is what validate takes. +type ValidateInput struct { + // the candidate's key as mesh-pipeline-runner.show names it: ., or run- for a run on request + Candidate string `json:"candidate,omitempty"` + // narrows the answer to this module's manifest + Module string `json:"module,omitempty"` + // a pipeline's key as the runner names it, a delivering pipeline's or a run on request's + Pipeline string `json:"pipeline"` + // why, written with the caller the runtime proves in the hand-act log + Why string `json:"why"` +} + +// ValidateAnswerProblemsItem is a type of the contract. +type ValidateAnswerProblemsItem struct { + // the case before holds it too, so the candidate does not cause it + Before bool `json:"before"` + Module string `json:"module"` + Problem string `json:"problem"` +} + +// ValidateAnswer is what validate answers. +type ValidateAnswer struct { + // for failed cycle, the artifacts the cycle passes through + Cycle []string `json:"cycle,omitempty"` + // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). + Form int64 `json:"form,omitempty"` + // the run's state: running, or its end + Outcome string `json:"outcome"` + // for failed manifest-refused, every problem per manifest, those counted and those the case before holds too + Problems []ValidateAnswerProblemsItem `json:"problems,omitempty"` + // for failed, which + Reason string `json:"reason,omitempty"` + // the validate run as it stands + Run *CompositionRun `json:"run,omitempty"` + // when the run started, while it runs + Started *time.Time `json:"started,omitempty"` + // for could-not-run, why + Why string `json:"why,omitempty"` +} + +// The values of ValidateAnswer's outcome. +const ( + ValidateAnswerOutcomeRunning = "running" + ValidateAnswerOutcomePassed = "passed" + ValidateAnswerOutcomeFailed = "failed" + ValidateAnswerOutcomeCouldNotRun = "could-not-run" +) + +// The values of ValidateAnswer's reason. +const ( + ValidateAnswerReasonCycle = "cycle" + ValidateAnswerReasonManifestRefused = "manifest-refused" +) + // KeepNowInput is what keep-now takes. type KeepNowInput struct { // why the keeping runs now @@ -1614,6 +1671,15 @@ func DecodeCompositionsDropAnswer(raw []byte) (CompositionsDropAnswer, int, erro return v, formRead(raw), nil } +// DecodeValidateAnswer reads a ValidateAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). +func DecodeValidateAnswer(raw []byte) (ValidateAnswer, int, error) { + var v ValidateAnswer + if err := json.Unmarshal(raw, &v); err != nil { + return v, 0, err + } + return v, formRead(raw), nil +} + // DecodeKeepNowAnswer reads a KeepNowAnswer as another part wrote it: a field this reader does not know is left unread, never refused; the form read is answered, 1 when absent (design 47 H2 §780). func DecodeKeepNowAnswer(raw []byte) (KeepNowAnswer, int, error) { var v KeepNowAnswer diff --git a/modules/mesh-delivery-contracts/go/seats/meshwants/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshwants/contract_test.go index 0dd21ea75..65f7e3ece 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshwants/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshwants/contract_test.go @@ -163,6 +163,12 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v CompositionsDropInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "C1 compositions-drop answers the run it deleted and the readers it ended", subject: "", given: "{\"ended\":[{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d6c\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"composition\"}],\"run\":{\"ask\":\"r1a2b3\",\"candidate\":\"main.12\",\"ended\":\"2026-11-17T10:03:00Z\",\"input\":\"sha256:0123\",\"key\":\"main.12.anchor\",\"machine\":\"anchor\",\"outcome\":\"passed\",\"program\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"directory\":\"cmd/mesh-compose\",\"fingerprint\":\"src2:aaaa\",\"repository\":\"novox/mesh-host\"},\"readers\":[{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d6c\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"composition\"}],\"started\":\"2026-11-17T10:00:00Z\",\"verdict\":{\"blamed\":[],\"composes\":true}}}", wire: "{\"ended\":[{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d6c\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"composition\"}],\"run\":{\"ask\":\"r1a2b3\",\"candidate\":\"main.12\",\"ended\":\"2026-11-17T10:03:00Z\",\"input\":\"sha256:0123\",\"key\":\"main.12.anchor\",\"machine\":\"anchor\",\"outcome\":\"passed\",\"program\":{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"directory\":\"cmd/mesh-compose\",\"fingerprint\":\"src2:aaaa\",\"repository\":\"novox/mesh-host\"},\"readers\":[{\"branch\":\"main\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"id\":\"m2kx9a1b3c4d6c\",\"module\":\"nats\",\"pipeline\":\"main.12.nats\",\"revision\":12,\"step\":\"composition\"}],\"started\":\"2026-11-17T10:00:00Z\",\"verdict\":{\"blamed\":[],\"composes\":true}}}", decode: func(b []byte) (any, error) { var v CompositionsDropAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "validate asked for a pipeline's candidate", subject: "", given: "{\"candidate\":\"main.12\",\"pipeline\":\"main.3589\",\"why\":\"a manifest changed by a fix has no verdict before its merge\"}", wire: "{\"candidate\":\"main.12\",\"pipeline\":\"main.3589\",\"why\":\"a manifest changed by a fix has no verdict before its merge\"}", + decode: func(b []byte) (any, error) { var v ValidateInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "validate answers a failed run naming a problem the case before holds too", subject: "", given: "{\"outcome\":\"failed\",\"problems\":[{\"before\":true,\"module\":\"nats\",\"problem\":\"a state asks more than 64 MiB\"}],\"reason\":\"manifest-refused\"}", wire: "{\"outcome\":\"failed\",\"problems\":[{\"before\":true,\"module\":\"nats\",\"problem\":\"a state asks more than 64 MiB\"}],\"reason\":\"manifest-refused\"}", + decode: func(b []byte) (any, error) { var v ValidateAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "validate answers a run still running", subject: "", given: "{\"outcome\":\"running\",\"started\":\"2026-11-25T17:00:00Z\"}", wire: "{\"outcome\":\"running\",\"started\":\"2026-11-25T17:00:00Z\"}", + decode: func(b []byte) (any, error) { var v ValidateAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { v, err := c.decode([]byte(c.given)) diff --git a/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/verbs.json index 2c09da7a1..81a49b30f 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/mesh-wants/fixtures/verbs.json @@ -296,5 +296,37 @@ } ] } + }, + { + "name": "validate asked for a pipeline's candidate", + "of": "verb:validate.input", + "given": { + "pipeline": "main.3589", + "candidate": "main.12", + "why": "a manifest changed by a fix has no verdict before its merge" + } + }, + { + "name": "validate answers a failed run naming a problem the case before holds too", + "of": "verb:validate.answer", + "given": { + "outcome": "failed", + "reason": "manifest-refused", + "problems": [ + { + "module": "nats", + "problem": "a state asks more than 64 MiB", + "before": true + } + ] + } + }, + { + "name": "validate answers a run still running", + "of": "verb:validate.answer", + "given": { + "outcome": "running", + "started": "2026-11-25T17:00:00Z" + } } ] diff --git a/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json b/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json index a2245fc2f..8bb9622bf 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-wants/seat.json @@ -278,6 +278,106 @@ ] } }, + { + "name": "validate", + "class": "act", + "description": "Judge a pipeline's candidate on request, the manifest validator's verdict of its manifests: the act and why are written in the hand-act log first, then the candidate's validate run, keyed .validate, is joined or started with the step's own code, so a validate step asked later joins it and builds no second manifest validator. It answers the run as it stands: running with its start, or its end: passed; failed cycle naming the cycle; failed manifest-refused with every problem per manifest, those counted and those the case before holds too; could-not-run with why. It writes no want and ends no step (design 47 H2 H-A-684 (1), H-A-702, H-A-727).", + "input": { + "type": "object", + "properties": { + "pipeline": { + "type": "string", + "description": "a pipeline's key as the runner names it, a delivering pipeline's or a run on request's" + }, + "module": { + "type": "string", + "description": "narrows the answer to this module's manifest" + }, + "candidate": { + "type": "string", + "description": "the candidate's key as mesh-pipeline-runner.show names it: ., or run- for a run on request" + }, + "why": { + "type": "string", + "description": "why, written with the caller the runtime proves in the hand-act log" + } + }, + "required": [ + "pipeline", + "why" + ] + }, + "answer": { + "type": "object", + "properties": { + "run": { + "$ref": "#/defs/CompositionRun", + "description": "the validate run as it stands" + }, + "outcome": { + "type": "string", + "enum": [ + "running", + "passed", + "failed", + "could-not-run" + ], + "description": "the run's state: running, or its end" + }, + "started": { + "type": "string", + "format": "date-time", + "description": "when the run started, while it runs" + }, + "reason": { + "type": "string", + "enum": [ + "cycle", + "manifest-refused" + ], + "description": "for failed, which" + }, + "cycle": { + "type": "array", + "items": { + "type": "string" + }, + "description": "for failed cycle, the artifacts the cycle passes through" + }, + "problems": { + "type": "array", + "items": { + "type": "object", + "properties": { + "module": { + "type": "string" + }, + "problem": { + "type": "string" + }, + "before": { + "type": "boolean", + "description": "the case before holds it too, so the candidate does not cause it" + } + }, + "required": [ + "module", + "problem", + "before" + ] + }, + "description": "for failed manifest-refused, every problem per manifest, those counted and those the case before holds too" + }, + "why": { + "type": "string", + "description": "for could-not-run, why" + } + }, + "required": [ + "outcome" + ] + } + }, { "name": "keep-now", "description": "Keep the assignment graph's revisions now, by hand (design 47 H2 §813 (2); H-A-417): written in the hand-act log first by the module's tool assigner_keep_now, then the keeping runs at once on the pass's newest computed revision; answers the revision kept, or the fault the keeping met.", @@ -1910,5 +2010,5 @@ "on": "every" } ], - "form": 3 + "form": 4 } diff --git a/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts index 357099d37..41e5b3bd7 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshwants/index.d.ts @@ -13,6 +13,7 @@ export declare const verbs: { readonly input: "input"; readonly compositions: "compositions"; readonly compositionsDrop: "compositions-drop"; + readonly validate: "validate"; readonly keepNow: "keep-now"; readonly drop: "drop"; }; @@ -685,6 +686,45 @@ export interface CompositionsDropAnswer { "run": CompositionRun; } +/** is what validate takes. */ +export interface ValidateInput { + /** the candidate's key as mesh-pipeline-runner.show names it: ., or run- for a run on request */ + "candidate"?: string; + /** narrows the answer to this module's manifest */ + "module"?: string; + /** a pipeline's key as the runner names it, a delivering pipeline's or a run on request's */ + "pipeline": string; + /** why, written with the caller the runtime proves in the hand-act log */ + "why": string; +} + +export interface ValidateAnswerProblemsItem { + /** the case before holds it too, so the candidate does not cause it */ + "before": boolean; + "module": string; + "problem": string; +} + +/** is what validate answers. */ +export interface ValidateAnswer { + /** for failed cycle, the artifacts the cycle passes through */ + "cycle"?: string[]; + /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ + "form"?: number; + /** the run's state: running, or its end */ + "outcome": "running" | "passed" | "failed" | "could-not-run"; + /** for failed manifest-refused, every problem per manifest, those counted and those the case before holds too */ + "problems"?: ValidateAnswerProblemsItem[]; + /** for failed, which */ + "reason"?: "cycle" | "manifest-refused"; + /** the validate run as it stands */ + "run"?: CompositionRun; + /** when the run started, while it runs */ + "started"?: string; + /** for could-not-run, why */ + "why"?: string; +} + /** is what keep-now takes. */ export interface KeepNowInput { /** why the keeping runs now */ diff --git a/modules/mesh-delivery-contracts/ts/seats/meshwants/index.js b/modules/mesh-delivery-contracts/ts/seats/meshwants/index.js index 94fb35ed8..0fc1c5010 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshwants/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/meshwants/index.js @@ -13,6 +13,7 @@ export const verbs = { input: "input", compositions: "compositions", compositionsDrop: "compositions-drop", + validate: "validate", keepNow: "keep-now", drop: "drop", }; From 354e943d24032f63d9678cc189367812556acbac Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:12:17 +0100 Subject: [PATCH 018/141] B4 held-elsewhere: a build again withdraws a standing number a registry holds for another build and takes the next free one (2), the publish item's end at a refusal for other bytes, waits on the lead's answer. Builds: design 47 H2 H-A-590 (1) (3), H-A-616, H-A-279 --- .../cmd/mesh-delivery-builder/main.go | 5 +- .../cmd/mesh-delivery-builder/reserve.go | 26 +++++++-- .../cmd/mesh-delivery-builder/reserve_test.go | 8 ++- .../internal/versions/republish.go | 17 +++--- .../internal/versions/republish_test.go | 2 +- .../internal/versions/reserve.go | 54 ++++++++++++++----- .../internal/versions/reserve_test.go | 39 +++++++++++++- 7 files changed, 121 insertions(+), 30 deletions(-) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index ddb57ba36..fb0e2447d 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -260,9 +260,10 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro Holders: holders, // a registry seat's holder from the seat-holders view, from the start (design 47 G A-416, A-416a) Started: time.Now()} // a build ended from now on is of the live class (H-A-290 (1)) // A number a registry seat already holds is never reserved (H-A-275): read before reserving, through the seats' verb versions. - reserved.r.HeldNumbers = func(ctx context.Context, module, fp string, refs []string) ([]string, error) { - return republish.HeldNumbers(ctx, module, fp, refs, registryVersionsVia(calls.Call)) + reserved.r.HeldRecords = func(ctx context.Context, module, fp string, refs []string) ([]versions.HeldArtifact, error) { + return republish.HeldRecords(ctx, module, fp, refs, registryVersionsVia(calls.Call)) } + reserved.r.MovedFrom = reserved.movedFrom // A done build whose number a registry holds elsewhere is built again at the next free number (H-A-279), on the builder's context. reserved.rebuild = func(_ context.Context, module, fp, why string) error { res := b.BuildAgain(ctx, module, fp, why, "the builder", buildAgainBound) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go index 813e426a4..aeee35460 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go @@ -608,11 +608,27 @@ func (rv *reservations) movedElsewhere(ctx context.Context, v versions.ReservedV } return err } - var at []string - for _, h := range j.Elsewhere { - at = append(at, fmt.Sprintf("%s holds %s %s at %s, built %s", h.Seat, h.Name, h.Version, h.Digest, v.Artifacts[h.Ref])) - } - why := fmt.Sprintf("%s is withdrawn and the build of %s is built again at the next free number: %s", v.Version, v.Fingerprint, strings.Join(at, "; ")) + why := elsewhereWords(v, j.Elsewhere) rv.heldElsewhere(ctx, v.Module, why) return rv.rebuild(ctx, v.Module, v.Fingerprint, why) } + +// elsewhereWords says what withdrew v's number: each artifact a registry holds there for another build, with the seat, both digests and +// the fingerprint the registry keeps for it when one is kept (design 47 H2 H-A-590 (1), H-A-279). +func elsewhereWords(v versions.ReservedVersion, elsewhere []versions.HeldArtifact) string { + var at []string + for _, h := range elsewhere { + w := fmt.Sprintf("%s holds %s %s at %s, built %s", h.Seat, h.Name, h.Version, h.Digest, v.Artifacts[h.Ref]) + if h.Fingerprint != "" { + w += ", for fingerprint " + h.Fingerprint + } + at = append(at, w) + } + return fmt.Sprintf("%s is withdrawn and the build of %s is built again at the next free number: %s", v.Version, v.Fingerprint, strings.Join(at, "; ")) +} + +// movedFrom is told by the reserver a standing number it withdrew at a build again (design 47 H2 H-A-590 (1)): the finding is raised; +// the reserve itself takes the next number no registry holds. +func (rv *reservations) movedFrom(ctx context.Context, v versions.ReservedVersion, elsewhere []versions.HeldArtifact) { + rv.heldElsewhere(ctx, v.Module, elsewhereWords(v, elsewhere)) +} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go index 456d21c62..4d997e094 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go @@ -742,7 +742,13 @@ func TestARegistrysRecordEndsOrMovesAPublish(t *testing.T) { rv.released = func(_ context.Context, m, v string) { ended = append(ended, m+" "+v) } rv.itemEnded = rv.released // a build withdrawn or superseded ends its publish item too (§793) registry := []string{"0.1.37"} - rv.r.HeldNumbers = func(context.Context, string, string, []string) ([]string, error) { return registry, nil } + rv.r.HeldRecords = func(context.Context, string, string, []string) ([]versions.HeldArtifact, error) { + var out []versions.HeldArtifact + for _, v := range registry { + out = append(out, versions.HeldArtifact{Version: v}) + } + return out, nil + } res, err := rv.Reserve(ctx, "node-tools", "0.1", []string{"node-tools:program"}, versions.Source{Fingerprint: "fp1"}) if err != nil || res.Version != "0.1.0" { t.Fatalf("reserved %q (%v)", res.Version, err) diff --git a/modules/mesh-delivery-builder/internal/versions/republish.go b/modules/mesh-delivery-builder/internal/versions/republish.go index c78549e4a..d712ce062 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish.go +++ b/modules/mesh-delivery-builder/internal/versions/republish.go @@ -854,6 +854,8 @@ type HeldVersion struct { // the seat and the name it is published as, the version and the digest the seat holds. type HeldArtifact struct { Ref, Seat, Name, Version, Digest string + // Fingerprint is the fingerprint the registry keeps for the version, empty where none is kept (design 47 H2 H-A-589 (3)). + Fingerprint string } // Judged is what the registries' record says of a reserved version's artifacts (design 47 H H-A-272, H-A-274, H-A-275; H2 H-A-588 @@ -934,15 +936,16 @@ func (r *Republisher) Held(ctx context.Context, v ReservedVersion, versionsOf fu return out, nil } -// HeldNumbers are the versions (MAJOR.MINOR.PATCH) a registry seat's record holds of any of module's artifacts refs, as the catalog -// entry of fingerprint names their seats and names (design 47 H H-A-275): a number one holds is never reserved. An artifact the -// entry names no registry seat for is read nowhere. -func (r *Republisher) HeldNumbers(ctx context.Context, module, fingerprint string, refs []string, versionsOf func(ctx context.Context, seat, name string) ([]HeldVersion, error)) ([]string, error) { +// HeldRecords are the versions (MAJOR.MINOR.PATCH) a registry seat's record holds of any of module's artifacts refs, as the catalog +// entry of fingerprint names their seats and names (design 47 H H-A-275), one record per artifact and version with the digest and the +// fingerprint the registry keeps (H2 H-A-590 (1)): a number one holds is never reserved. An artifact the entry names no registry seat +// for is read nowhere. +func (r *Republisher) HeldRecords(ctx context.Context, module, fingerprint string, refs []string, versionsOf func(ctx context.Context, seat, name string) ([]HeldVersion, error)) ([]HeldArtifact, error) { e, err := r.Entry(ctx, fingerprint) if err != nil { return nil, fmt.Errorf("the catalog entry %s of %s cannot be read: %w", fingerprint, module, err) } - var out []string + var out []HeldArtifact for _, ref := range refs { seat, name, _, ok := publishTarget(e, module, ref) if !ok { @@ -953,8 +956,8 @@ func (r *Republisher) HeldNumbers(ctx context.Context, module, fingerprint strin return out, fmt.Errorf("%s's versions of %s cannot be read: %w", seat, name, err) } for _, h := range held { - if v := strings.TrimPrefix(h.Version, "v"); v != "" && !slices.Contains(out, v) { - out = append(out, v) + if v := strings.TrimPrefix(h.Version, "v"); v != "" { + out = append(out, HeldArtifact{Ref: ref, Seat: seat, Name: name, Version: v, Digest: h.Digest, Fingerprint: h.Fingerprint}) } } } diff --git a/modules/mesh-delivery-builder/internal/versions/republish_test.go b/modules/mesh-delivery-builder/internal/versions/republish_test.go index b58db0148..c4e60ade1 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish_test.go +++ b/modules/mesh-delivery-builder/internal/versions/republish_test.go @@ -278,7 +278,7 @@ func TestTheRegistriesRecordSaysWhetherAVersionIsHeld(t *testing.T) { if c.lacks && !strings.Contains(j.Lacks, "0.1.37") { t.Errorf("what the registry lacks is said as %q", j.Lacks) } - nums, err := r.HeldNumbers(ctx, "m", "fp", []string{"m:lib"}, versionsOf) + nums, err := r.HeldRecords(ctx, "m", "fp", []string{"m:lib"}, versionsOf) if err != nil || len(nums) != len(c.holds) { t.Errorf("the held numbers are %v (%v), want one per version the seat holds", nums, err) } diff --git a/modules/mesh-delivery-builder/internal/versions/reserve.go b/modules/mesh-delivery-builder/internal/versions/reserve.go index 377f2273c..0ed1bb07d 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve.go @@ -161,28 +161,46 @@ type Reserver struct { // Logf says an index write that failed (H-A-269 (1)): the reservation stands, and Reindex writes its index at the next // start. Nil says nothing. Logf func(string, ...any) - // HeldNumbers are the versions a registry seat's record holds of any of module's artifacts (design 47 H H-A-275), read before a - // number is reserved: a number one holds is skipped. Nil reads none; a read that fails is said and the reserve proceeds. - HeldNumbers func(ctx context.Context, module, fingerprint string, refs []string) ([]string, error) + // HeldRecords are the versions a registry seat's record holds of any of module's artifacts (design 47 H H-A-275), each with the + // digest and the fingerprint the registry keeps, read before a number is reserved: a number one holds is skipped, and a + // standing reservation whose number one holds for another build is withdrawn (design 47 H2 H-A-590 (1)). Nil reads none; a + // read that fails is said and the reserve proceeds. + HeldRecords func(ctx context.Context, module, fingerprint string, refs []string) ([]HeldArtifact, error) // HeldElsewhere is told the numbers of module a reserve skipped because a registry holds them (H-A-275); nil is told none. HeldElsewhere func(ctx context.Context, module string, skipped []string) + // MovedFrom is told a standing reservation a reserve withdrew because a registry holds an artifact at its number for another + // build, with those artifacts (H-A-590 (1), H-A-279); nil is told none. + MovedFrom func(ctx context.Context, v ReservedVersion, elsewhere []HeldArtifact) } -// heldNumbers are the patches of series a registry holds of module's artifacts (H-A-275); a read that fails is said, and none. -func (r *Reserver) heldNumbers(ctx context.Context, module, series, fingerprint string, refs []string) map[int]bool { - if r.HeldNumbers == nil { - return nil +// heldNumbers are the patches of series a registry holds of module's artifacts (H-A-275), and the records they come from; a read +// that fails is said, and none. +func (r *Reserver) heldNumbers(ctx context.Context, module, series, fingerprint string, refs []string) (map[int]bool, []HeldArtifact) { + if r.HeldRecords == nil { + return nil, nil } - vs, err := r.HeldNumbers(ctx, module, fingerprint, refs) + recs, err := r.HeldRecords(ctx, module, fingerprint, refs) if err != nil { r.said(fmt.Errorf("%s: the registries' versions are not read before reserving, so a number they hold is not skipped: %w", module, err)) } out := map[int]bool{} - for _, v := range vs { - if s, p, err := SplitVersion(v); err == nil && s == series { + for _, h := range recs { + if s, p, err := SplitVersion(strings.TrimPrefix(h.Version, "v")); err == nil && s == series { out[p] = true } } + return out, recs +} + +// heldElsewhereAt are the records of recs at v's number held for another build (design 47 H2 H-A-590 (1), H-A-616): the registry +// keeps another fingerprint, or none and the reservation records another digest or none for the artifact. +func heldElsewhereAt(v ReservedVersion, recs []HeldArtifact) []HeldArtifact { + var out []HeldArtifact + for _, h := range recs { + if strings.TrimPrefix(h.Version, "v") == v.Version && !heldFor(v, h.Ref, HeldVersion{Version: h.Version, Digest: h.Digest, Fingerprint: h.Fingerprint}) { + out = append(out, h) + } + } return out } @@ -243,13 +261,22 @@ func (r *Reserver) Reserve(ctx context.Context, module, series string, artifacts } } key := ReservedKey(module, series) - held := r.heldNumbers(ctx, module, series, src.Fingerprint, artifacts) + held, records := r.heldNumbers(ctx, module, series, src.Fingerprint, artifacts) for { cur, rev, found, err := r.get(ctx, key) if err != nil { return ReservedVersion{}, err } withdrawn := found && hasKey(cur.Withdrawn, cur.Version) // a number a registry holds elsewhere (H-A-279) + // A standing reservation of this fingerprint whose number a registry holds for another build, or for none the reservation + // records, is withdrawn now, as the done build's path withdraws it (design 47 H2 H-A-590 (1)); the next number no registry holds + // is taken. A read that did not answer left no record: the standing number is kept. + var elsewhere []HeldArtifact + if found && !withdrawn && cur.Fingerprint == src.Fingerprint && cur.Fingerprint != "" { + if elsewhere = heldElsewhereAt(cur, records); len(elsewhere) > 0 { + withdrawn = true + } + } if found && !withdrawn && cur.Fingerprint == src.Fingerprint && cur.Fingerprint != "" && !slices.Contains(released, cur.Version) { if _, p, err := SplitVersion(cur.Version); err == nil && p > high { return cur, nil // kept until released (H-A-225); one at or below the catalog's highest can never be released @@ -270,7 +297,7 @@ func (r *Reserver) Reserve(ctx context.Context, module, series string, artifacts out.Upstream = slices.Clone(src.Upstream) if found { out.Withdrawn = maps.Clone(cur.Withdrawn) - if cur.Fingerprint != src.Fingerprint { + if cur.Fingerprint != src.Fingerprint || len(elsewhere) > 0 { if out.Withdrawn == nil { out.Withdrawn = map[string]string{} } @@ -301,6 +328,9 @@ func (r *Reserver) Reserve(ctx context.Context, module, series string, artifacts if len(skipped) > 0 && r.HeldElsewhere != nil { r.HeldElsewhere(ctx, module, skipped) } + if len(elsewhere) > 0 && r.MovedFrom != nil { + r.MovedFrom(ctx, cur, elsewhere) + } if found && r.Took != nil { r.Took(ctx, cur, out) } diff --git a/modules/mesh-delivery-builder/internal/versions/reserve_test.go b/modules/mesh-delivery-builder/internal/versions/reserve_test.go index cbb3538ee..b5f516b5b 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve_test.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve_test.go @@ -464,11 +464,15 @@ func TestANumberARegistryHoldsIsNeverReserved(t *testing.T) { var readErr error var skipped []string r := &Reserver{Store: store, ReleasedOf: func(context.Context, string) ([]string, error) { return []string{"0.1.36"}, nil }, - HeldNumbers: func(_ context.Context, module, fp string, refs []string) ([]string, error) { + HeldRecords: func(_ context.Context, module, fp string, refs []string) ([]HeldArtifact, error) { if module != "node-tools" || fp != "fp1" || len(refs) != 1 { t.Errorf("the registries are read for %s %s %v", module, fp, refs) } - return held, readErr + var out []HeldArtifact + for _, v := range held { + out = append(out, HeldArtifact{Ref: "node-tools:program", Version: v}) + } + return out, readErr }, HeldElsewhere: func(_ context.Context, _ string, s []string) { skipped = append(skipped, s...) }} v, err := r.Reserve(ctx, "node-tools", "0.1", []string{"node-tools:program"}, Source{Fingerprint: "fp1", Repository: "o/r", Commit: "c1"}) @@ -500,4 +504,35 @@ func TestANumberARegistryHoldsIsNeverReserved(t *testing.T) { if v, err := r.Reserve(ctx, "node-tools", "0.2", []string{"node-tools:program"}, Source{Fingerprint: "fp1"}); err != nil || v.Version != "0.2.1" { t.Errorf("with the registry down reserved %q (%v), want 0.2.1 (what it answered still skipped)", v.Version, err) } + // H2 H-A-590 (1), H-A-616: a build again of F keeps F's standing number unless a registry holds an artifact at it for another + // build: the registry keeps another fingerprint, or none and another digest; one with the reserved digest, or F's own + // fingerprint, keeps it. + for _, c := range []struct { + name string + held HeldArtifact + wantMoved bool + }{ + {name: "another fingerprint kept", held: HeldArtifact{Digest: "sha256:mine", Fingerprint: "other"}, wantMoved: true}, + {name: "no fingerprint, another digest", held: HeldArtifact{Digest: "sha256:theirs"}, wantMoved: true}, + {name: "no fingerprint, the reserved digest", held: HeldArtifact{Digest: "sha256:mine"}}, + {name: "F's own fingerprint", held: HeldArtifact{Digest: "sha256:mine", Fingerprint: "fp9"}}, + } { + st := &reserveMem{mem: newMem()} + var told []HeldArtifact + rr := &Reserver{Store: st, ReleasedOf: func(context.Context, string) ([]string, error) { return nil, nil }} + first, err := rr.Reserve(ctx, "m", "0.3", []string{"m:a"}, Source{Fingerprint: "fp9"}) + if err != nil { + t.Fatal(err) + } + if _, _, err := rr.Built(ctx, "m", first.Version, map[string]string{"m:a": "sha256:mine"}, nil); err != nil { + t.Fatal(err) + } + c.held.Ref, c.held.Version, c.held.Seat = "m:a", first.Version, SeatArtifacts + rr.HeldRecords = func(context.Context, string, string, []string) ([]HeldArtifact, error) { return []HeldArtifact{c.held}, nil } + rr.MovedFrom = func(_ context.Context, _ ReservedVersion, e []HeldArtifact) { told = e } + again, err := rr.Reserve(ctx, "m", "0.3", []string{"m:a"}, Source{Fingerprint: "fp9", Rebuild: true}) + if err != nil || (again.Version != first.Version) != c.wantMoved || (again.Withdrawn[first.Version] == "fp9") != c.wantMoved || (len(told) == 1) != c.wantMoved { + t.Errorf("%s: the build again reserved %+v (%v), told %v; want the number %s %s", c.name, again, err, told, first.Version, map[bool]string{true: "withdrawn and the next taken", false: "kept"}[c.wantMoved]) + } + } } From 13c9fb430eb49ffdd764bec324ebd74ce351a911 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:12:19 +0100 Subject: [PATCH 019/141] B4: gofmt --- .../mesh-delivery-builder/internal/versions/reserve_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-builder/internal/versions/reserve_test.go b/modules/mesh-delivery-builder/internal/versions/reserve_test.go index b5f516b5b..2b4872e8e 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve_test.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve_test.go @@ -528,7 +528,9 @@ func TestANumberARegistryHoldsIsNeverReserved(t *testing.T) { t.Fatal(err) } c.held.Ref, c.held.Version, c.held.Seat = "m:a", first.Version, SeatArtifacts - rr.HeldRecords = func(context.Context, string, string, []string) ([]HeldArtifact, error) { return []HeldArtifact{c.held}, nil } + rr.HeldRecords = func(context.Context, string, string, []string) ([]HeldArtifact, error) { + return []HeldArtifact{c.held}, nil + } rr.MovedFrom = func(_ context.Context, _ ReservedVersion, e []HeldArtifact) { told = e } again, err := rr.Reserve(ctx, "m", "0.3", []string{"m:a"}, Source{Fingerprint: "fp9", Rebuild: true}) if err != nil || (again.Version != first.Version) != c.wantMoved || (again.Withdrawn[first.Version] == "fp9") != c.wantMoved || (len(told) == 1) != c.wantMoved { From 899d6ac0e36664a69957e4359581e4f2f5383289 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:12:50 +0100 Subject: [PATCH 020/141] K2 again-delays: the default is 15s,90s, whose sum spans the tool runner's restart Builds: design 47 H2 H-A-603 --- modules/mesh-delivery-sdk/steprun/again.go | 5 ++--- modules/mesh-delivery-sdk/steprun/again_test.go | 10 +++++----- modules/mesh-delivery-sdk/steprun/pull_test.go | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/modules/mesh-delivery-sdk/steprun/again.go b/modules/mesh-delivery-sdk/steprun/again.go index 7dbe6e0b3..22c5867ac 100644 --- a/modules/mesh-delivery-sdk/steprun/again.go +++ b/modules/mesh-delivery-sdk/steprun/again.go @@ -8,11 +8,10 @@ import ( // AgainDelaysSetting is the setting each build module declares for the delay it passes with a run's `again` (design 47 // H2 §799): how long the bus waits before it gives an ask again after its first, then its second run ended on a -// transport fault, as Go durations separated by commas. DefaultAgainDelays is its default, so three runs span a -// one-minute absence of a holder. +// transport fault, as Go durations separated by commas. DefaultAgainDelays is its default, so three runs span the tool runner's restart, 105 s (design 47 H2 H-A-603). const ( AgainDelaysSetting = "again-delays" - DefaultAgainDelays = "15s,60s" + DefaultAgainDelays = "15s,90s" ) // AgainDelays reads the setting again-delays into a Puller's Delay (§799): the run-th delay of the list, its last for a diff --git a/modules/mesh-delivery-sdk/steprun/again_test.go b/modules/mesh-delivery-sdk/steprun/again_test.go index 79b15cbb0..52ad99700 100644 --- a/modules/mesh-delivery-sdk/steprun/again_test.go +++ b/modules/mesh-delivery-sdk/steprun/again_test.go @@ -15,11 +15,11 @@ import ( // that exited, end their run `again` after again-delays' delay, with no seat call; a third run's fault ends the step failed // with the why `fetch: ` or `publish: `. ADR 0664 §1 with the bus's count above the runs that started: an ask // given back twice before its first run (the bus says delivered 3, the step key 1 run began) meets its fault in run 2, -// given again after again-delays' second, 60 s, not 3. A publish met by a stopping tool runner is met by no responders (H-A-570 (3)), so it +// given again after again-delays' second, 90 s, not 3. A publish met by a stopping tool runner is met by no responders (H-A-570 (3)), so it // is one too; a bare timeout is not. func TestAFetchOrAPublishMetAwayIsATransportFault(t *testing.T) { delay, err := AgainDelays("") - if err != nil || delay(1) != 15*time.Second || delay(2) != time.Minute || delay(3) != time.Minute { + if err != nil || delay(1) != 15*time.Second || delay(2) != 90*time.Second || delay(3) != 90*time.Second { t.Fatalf("the default again-delays: %v", err) } if own, err := AgainDelays("2s, 5s"); err != nil || own(1) != 2*time.Second || own(2) != 5*time.Second { @@ -53,7 +53,7 @@ func TestAFetchOrAPublishMetAwayIsATransportFault(t *testing.T) { if !sdkstep.IsPassing(tc.err) || !strings.HasPrefix(tc.err.Error(), tc.why) { t.Fatalf("%v: want a transport fault opening with %q", tc.err, tc.why) } - // Its first run ends again after 15 s; its second, delivered three times, again after 60 s; its third ends the step failed. + // Its first run ends again after 15 s; its second, delivered three times, again after 90 s; its third ends the step failed. for _, run := range []struct { prior int delivered uint64 @@ -78,8 +78,8 @@ func TestAFetchOrAPublishMetAwayIsATransportFault(t *testing.T) { if prior == 0 && (s.State != sdkstep.StepAgain || len(delays) != 1 || delays[0] != 15*time.Second) { t.Errorf("the first run: step %+v, delays %v, want again after 15s", s, delays) } - if prior == 1 && (s.State != sdkstep.StepAgain || s.Run != 2 || len(delays) != 1 || delays[0] != time.Minute) { - t.Errorf("the second run, delivered %d times: step %+v, delays %v, want again in run 2 after 60s", run.delivered, s, delays) + if prior == 1 && (s.State != sdkstep.StepAgain || s.Run != 2 || len(delays) != 1 || delays[0] != 90*time.Second) { + t.Errorf("the second run, delivered %d times: step %+v, delays %v, want again in run 2 after 90s", run.delivered, s, delays) } if prior == 2 && (s.State != sdkstep.StepFailed || !strings.HasPrefix(s.Reason, tc.why)) { t.Errorf("the third run: step %+v, want failed with the why %q", s, tc.why) diff --git a/modules/mesh-delivery-sdk/steprun/pull_test.go b/modules/mesh-delivery-sdk/steprun/pull_test.go index 4c7af288c..df75fba3b 100644 --- a/modules/mesh-delivery-sdk/steprun/pull_test.go +++ b/modules/mesh-delivery-sdk/steprun/pull_test.go @@ -569,7 +569,7 @@ func TestAPoisonedAskIsSaidAndRunNoMore(t *testing.T) { ackedOnly bool }{ {"a transport fault in run 1", 1, &sdkstep.Passing{Err: errors.New("lookup proxy: i/o timeout")}, sdkstep.StepAgain, 15 * time.Second, true, false}, - {"a transport fault in run 2", 2, &sdkstep.Passing{Err: errors.New("lookup proxy: i/o timeout")}, sdkstep.StepAgain, time.Minute, true, false}, + {"a transport fault in run 2", 2, &sdkstep.Passing{Err: errors.New("lookup proxy: i/o timeout")}, sdkstep.StepAgain, 90 * time.Second, true, false}, {"a transport fault in the last run", sdkstep.AskRuns, &sdkstep.Passing{Err: errors.New("lookup proxy: i/o timeout")}, sdkstep.StepFailed, 0, true, true}, {"a compile error in run 1", 1, errors.New("undefined: x"), sdkstep.StepFailed, 0, false, true}, } { From 13485c371e4c705c31267f20820e82f85667bc8d Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:13:51 +0100 Subject: [PATCH 021/141] R1 binding-said-again: a created heard again with a day count or an operation more is written again Builds: design 47 H2 H-A-685 (3); row R1 (the field comes with mesh-sdk S4) --- modules/mesh-grants/grants_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/mesh-grants/grants_test.go b/modules/mesh-grants/grants_test.go index b57f323a3..147d1853f 100644 --- a/modules/mesh-grants/grants_test.go +++ b/modules/mesh-grants/grants_test.go @@ -3352,6 +3352,22 @@ func TestGrants(t *testing.T) { if !hear("mesh.seat.mesh-broker.event.created", first) || hear("mesh.seat.mesh-broker.event.created", first) { t.Fatal("created: not kept once") } + // H-A-685 (3): a created heard again with a day count of ended instances more, or one operation more, is another binding and + // is written again, the bindings being compared whole. + days := first + days.EndedDays = 30 + if !hear("mesh.seat.mesh-broker.event.created", days) || hear("mesh.seat.mesh-broker.event.created", days) { + t.Fatal("created with ended-days more: not rewritten once") + } + more := days + more.Types = []catalogue.LedgerType{{Name: "act", Operations: []catalogue.LedgerOperation{{Name: "open"}}}} + if !hear("mesh.seat.mesh-broker.event.created", more) { + t.Fatal("created with a type: not rewritten") + } + more.Types = []catalogue.LedgerType{{Name: "act", Operations: []catalogue.LedgerOperation{{Name: "open"}, {Name: "end"}}}} + if !hear("mesh.seat.mesh-broker.event.created", more) { + t.Fatal("created with one operation more: not rewritten") + } b.assign("b", "mod-x") p.Compose() for _, key := range []string{"a.mod-x", "b.mod-x"} { From 0239cf3ac4513325aca5a0a7d2f18e6e37333bb8 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:13:55 +0100 Subject: [PATCH 022/141] DC6b: the indexer's take-in test names pipeline-started's movers as StartedMover Builds: design 47 H2 H-A-709 (3) --- .../cmd/mesh-delivery-indexer/takein_integration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go index f15db48e4..9650b2a6f 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go @@ -357,7 +357,7 @@ func sayPipeline(t *testing.T, ctx context.Context, js jetstream.JetStream, ende pipeline := b + "." + s if !ended { raw, _ := json.Marshal(meshpipelinerunner.PipelineStarted{V: 1, Pipeline: pipeline, Branch: branch, Source: source, Revision: source, - Movers: []meshpipelinerunner.Mover{{Module: "avahi", Tier: 1}}}) + Movers: []meshpipelinerunner.StartedMover{{Module: "avahi", Tier: 1}}}) if _, err := js.Publish(ctx, meshpipelinerunner.SubjectPipelineStarted(b, s), raw); err != nil { t.Fatal(err) } From de7110032bf29d82a467f0c16a7d216bf52762b7 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:13:55 +0100 Subject: [PATCH 023/141] I14 indexer-tools-comment: the package comment names only what the package serves Builds: design 47 H2 H-A-684 (3) --- .../cmd/mesh-delivery-indexer-tools/main.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go index dfa7d8439..0945d469d 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go @@ -1,7 +1,6 @@ // Command mesh-delivery-indexer-tools serves the indexer's tools (novox/hq issue 1945): the runtime launches it for a // call. A hand act writes one value of the indexer's takeins state and waits for the indexer's answer there. The -// indexer is the other program: it serves no request subject (ADR 0437 §4); indexer_judge asks the same way, and -// indexer_verdicts reads the indexer's verdicts state. The read tools of the indexer's states are +// indexer is the other program: it serves no request subject (ADR 0437 §4). The read tools of the indexer's states are // mesh-delivery-view's (indexer_module, indexer_modules, indexer_candidate, indexer_candidates). package main @@ -28,7 +27,7 @@ import ( // asker writes a takeins value and waits for the indexer's answer to it. type asker func(key string, value []byte) (index.TakeInAsk, error) -// Tools are the indexer's tools. read is the indexer's state of verdicts, which indexer_verdicts reads; counts the old sections' count. +// Tools are the indexer's tools. counts is the old sections' count. func Tools(ask asker, now func() time.Time, counts func() (index.OldSectionsCount, error), acts meshhandactsclient.Recorder) []stdio.Tool { str := func(args map[string]any, k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) } return []stdio.Tool{ From 661203451fc07f33e6ce7e974b431f84910ff460 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:13:55 +0100 Subject: [PATCH 024/141] I13 state-cap-64: a state's max-mib is at most 64 Builds: design 47 H2 H-A-678, H-A-694 --- modules/mesh-delivery-indexer/judge/busstate.go | 8 ++++++-- modules/mesh-delivery-indexer/judge/busstate_test.go | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/mesh-delivery-indexer/judge/busstate.go b/modules/mesh-delivery-indexer/judge/busstate.go index b287c2676..28a0900c5 100644 --- a/modules/mesh-delivery-indexer/judge/busstate.go +++ b/modules/mesh-delivery-indexer/judge/busstate.go @@ -40,6 +40,9 @@ type busTemplate struct { fixed string } +// stateMostMiB is the most a state entry's bucket holds, ADR 0690 §1 (design 47 H2 H-A-678, H-A-694). +const stateMostMiB = 64 + // busTemplates are the six templates of design 25 § 12.1 and the bounds of its table. var busTemplates = map[string]busTemplate{ catalogue.TemplateState: { @@ -50,8 +53,9 @@ var busTemplates = map[string]busTemplate{ catalogue.OptionTimeToLive: {kind: optionInt, least: 1, most: 315360000}, catalogue.OptionLifetimePerKey: {kind: optionFlag}, catalogue.OptionPerMachine: {kind: optionFlag}, - // A-277: a state's cap is an option of its template, read as the old state section reads it. - catalogue.OptionCapMiB: {kind: optionInt, least: catalogue.ObjectsLeastMiB, most: catalogue.ObjectsMostMiB}, + // A-277: a state's cap is an option of its template, read as the old state section reads it; ADR 0690 §1 keeps + // its bucket at 64 MiB at most (design 47 H2 H-A-678, H-A-694). + catalogue.OptionCapMiB: {kind: optionInt, least: catalogue.ObjectsLeastMiB, most: stateMostMiB}, // A-314: the cap of the state's own objects store `-objects`, an integer above zero. catalogue.OptionObjectsCapMiB: {kind: optionInt, least: catalogue.ObjectsLeastMiB, most: catalogue.ObjectsMostMiB}, }, diff --git a/modules/mesh-delivery-indexer/judge/busstate_test.go b/modules/mesh-delivery-indexer/judge/busstate_test.go index 6c526d7b9..973dee8c9 100644 --- a/modules/mesh-delivery-indexer/judge/busstate_test.go +++ b/modules/mesh-delivery-indexer/judge/busstate_test.go @@ -64,7 +64,8 @@ func TestBusStateIsJudgedOnce(t *testing.T) { {"objects without a cap", manifest(`{"name":"x","storage":"object-store","template":"objects"}`), []string{"\"x\"", "\"max-mib\" is missing"}}, {"when full given as an option", manifest(`{"name":"x","storage":"stream","template":"log","options":{"when-full":"drop-oldest"}}`), []string{"\"x\"", "\"when-full\"", "fixed"}}, // A-277: a state's max-mib is an option of its template; an approvals state is §677's (key-ttl, 48 hours, at most 64 MiB). - {"a state capped at 256 MiB", manifest(`{"name":"x","storage":"key-value","template":"state","options":{"max-mib":256}}`), nil}, + {"a state capped at 64 MiB (H-A-678)", manifest(`{"name":"x","storage":"key-value","template":"state","options":{"max-mib":64}}`), nil}, + {"a state capped at 65 MiB (H-A-678, H-A-694)", manifest(`{"name":"x","storage":"key-value","template":"state","options":{"max-mib":65}}`), []string{"\"x\"", "\"max-mib\" is 65"}}, {"a state cap over 8192", manifest(`{"name":"x","storage":"key-value","template":"state","options":{"max-mib":8193}}`), []string{"\"x\"", "\"max-mib\" is 8193"}}, {"an approvals state as §677 declares it", manifest(`{"name":"approvals","storage":"key-value","template":"state","options":{"key-ttl":true,"ttl-seconds":172800,"max-mib":64}}`), nil}, {"an approvals state with the default cap", manifest(`{"name":"approvals","storage":"key-value","template":"state","options":{"key-ttl":true,"ttl-seconds":172800}}`), nil}, From b7dc1dc3e1bfb05950c9ed1070823a56da2c18cf Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:14:05 +0100 Subject: [PATCH 025/141] B5 read-before-the-ask: the registries' record at V is written on the reservation before a build module is asked again; a first not stored starts the build again once Builds: design 47 H2 H-A-588 (3) (4), H-A-662, H-A-664, H-A-666, H-A-703 --- .../cmd/mesh-delivery-builder/main.go | 4 ++ .../cmd/mesh-delivery-builder/reserve.go | 45 +++++++++++++++++++ .../internal/build/numbers.go | 4 ++ .../internal/build/reserve_test.go | 16 +++++++ .../internal/build/run.go | 6 +++ .../internal/versions/republish.go | 11 ++++- .../internal/versions/republish_test.go | 16 +++++++ .../internal/versions/reserve.go | 25 ++++++++--- .../internal/versions/reserve_test.go | 17 +++++++ 9 files changed, 138 insertions(+), 6 deletions(-) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index fb0e2447d..a89f62fba 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -264,6 +264,10 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro return republish.HeldRecords(ctx, module, fp, refs, registryVersionsVia(calls.Call)) } reserved.r.MovedFrom = reserved.movedFrom + republish.Unstored = reserved.unstoredAgain + reserved.judge = func(ctx context.Context, v versions.ReservedVersion) (versions.Judged, error) { + return republish.Held(ctx, v, registryVersionsVia(calls.Call)) + } // A done build whose number a registry holds elsewhere is built again at the next free number (H-A-279), on the builder's context. reserved.rebuild = func(_ context.Context, module, fp, why string) error { res := b.BuildAgain(ctx, module, fp, why, "the builder", buildAgainBound) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go index aeee35460..74751b671 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go @@ -58,6 +58,8 @@ type reservations struct { recordAgain func(ctx context.Context, module, fp, when string) (string, error) // rebuild builds a done key of module at fp again (the build-again path, A-490; H-A-279); nil builds none. rebuild func(ctx context.Context, module, fp, why string) error + // judge reads the registries' record of a reservation's artifacts at its version (the republisher's Held); nil reads none. + judge func(ctx context.Context, v versions.ReservedVersion) (versions.Judged, error) // say says package-published on the seat mesh-builds; nil says none. say func(context.Context, meshbuilds.PackagePublished) error // names is each package's name as its series key names it (for Go, its module path), and sayReserved says version-reserved on @@ -568,6 +570,36 @@ func (rv *reservations) ReleasedFor(ctx context.Context, module, fingerprint str return rv.r.ReleasedFor(ctx, module, fingerprint) } +// MarkRegistryHeld reads the registries' record of v's artifacts and writes the held digest of each artifact a registry holds at v's version +// for the build's fingerprint on the reservation, marked published, and says package-published of each once (design 47 H2 H-A-588 +// (4)); what the registries do not hold loses its recorded digest (H-A-664). A read that does not answer is said and nothing is +// written, so the build goes on. +func (rv *reservations) MarkRegistryHeld(ctx context.Context, v versions.ReservedVersion) { + if rv.judge == nil { + return + } + j, err := rv.judge(ctx, v) + if err != nil { + rv.logf("%s %s: the registries' record of its artifacts is not read before the build module is asked again, so none is marked held: %v", v.Module, v.Version, err) + return + } + marked, _, err := rv.r.MarkHeld(ctx, v.Module, v.Version, j.Held) + if err != nil { + rv.logf("%s %s: what the registries hold is not written on the reservation: %v", v.Module, v.Version, err) + return + } + for _, m := range marked { + var held versions.HeldArtifact + for _, h := range j.Held { + if h.Ref == m.Artifact { + held = h + } + } + rv.logf("%s %s: %s holds %s %s at %s for this build: marked published from its record before the build is asked again", v.Module, v.Version, held.Seat, held.Name, held.Version, held.Digest) + rv.sayPublished(ctx, m, held.Digest) + } +} + // markHeld marks the artifacts the registries' record holds at their version with the built digest published, as their published // heard would, and says package-published of each (design 47 H H-A-274): a published heard and lost never leaves the publish // asked for ever. The version's release follows from the catalog as for any published. @@ -627,6 +659,19 @@ func elsewhereWords(v versions.ReservedVersion, elsewhere []versions.HeldArtifac return fmt.Sprintf("%s is withdrawn and the build of %s is built again at the next free number: %s", v.Version, v.Fingerprint, strings.Join(at, "; ")) } +// unstoredAgain builds a key again whose reservation's first artifact a holder refused as not stored (design 47 H2 H-A-662): the +// build under its standing version completes what the registries lack, as the person's builder_build_again would. A key the +// build again refuses (not a first branch's trunk build, or released) is said and left to the person's tool. +func (rv *reservations) unstoredAgain(ctx context.Context, v versions.ReservedVersion, ref, words string) { + if rv.rebuild == nil { + return + } + why := fmt.Sprintf("%s refused by its holder as not stored (%s): the build of %s is built again under %s", ref, words, v.Fingerprint, v.Version) + if err := rv.rebuild(ctx, v.Module, v.Fingerprint, why); err != nil { + rv.logf("%s %s: the build again is not started: %v; builder_build_again builds it", v.Module, v.Version, err) + } +} + // movedFrom is told by the reserver a standing number it withdrew at a build again (design 47 H2 H-A-590 (1)): the finding is raised; // the reserve itself takes the next number no registry holds. func (rv *reservations) movedFrom(ctx context.Context, v versions.ReservedVersion, elsewhere []versions.HeldArtifact) { diff --git a/modules/mesh-delivery-builder/internal/build/numbers.go b/modules/mesh-delivery-builder/internal/build/numbers.go index 81ab181ab..e96864a3b 100644 --- a/modules/mesh-delivery-builder/internal/build/numbers.go +++ b/modules/mesh-delivery-builder/internal/build/numbers.go @@ -133,6 +133,10 @@ type Reservations interface { // TakenOver is the reservation of module's series that took the series over from the build of fingerprint, whose number // it keeps withdrawn (design 47 H H-A-226), and whether one does (H-A-244). TakenOver(ctx context.Context, module, fingerprint string) (versions.ReservedVersion, bool, error) + // MarkRegistryHeld reads the registries' record of v's artifacts at its version and writes on the reservation the held digest of each + // artifact a registry holds there for the build's fingerprint, marking it published, before a build module is asked for the + // fingerprint again (design 47 H2 H-A-588 (4)). A read that does not answer is said and the build goes on. + MarkRegistryHeld(ctx context.Context, v versions.ReservedVersion) // VersionAt is the version module's artifact is published at from the source revision of branch: its reservation of that // origin with the artifact published, else its release recorded at that source revision (design 47 H2 H-A-547 (3), H-A-551). VersionAt(ctx context.Context, module, artifact, branch string, source int64) (string, bool, error) diff --git a/modules/mesh-delivery-builder/internal/build/reserve_test.go b/modules/mesh-delivery-builder/internal/build/reserve_test.go index 9492e6f48..9648845bc 100644 --- a/modules/mesh-delivery-builder/internal/build/reserve_test.go +++ b/modules/mesh-delivery-builder/internal/build/reserve_test.go @@ -34,6 +34,8 @@ type fakeReservations struct { tookBy map[string]versions.ReservedVersion // by fingerprint, the reservation that took its series over (H-A-244) held map[string]versions.ReservedVersion // by fingerprint, the reservation ReservedFor answers as it stands (H-A-492) lost error // the record of the digests fails, as a store refusing it would + marks []string // the versions MarkRegistryHeld was told, with the asks the build module had by then (H-A-588 (4)) + asked func() int atMu sync.Mutex at map[string]string // by ":@.", the version VersionAt answers (H-A-547 (3)) } @@ -55,6 +57,14 @@ func (f *fakeReservations) publishAt(module, artifact, branch string, source int f.at[fmt.Sprintf("%s:%s@%s.%d", module, artifact, branch, source)] = version } +func (f *fakeReservations) MarkRegistryHeld(_ context.Context, v versions.ReservedVersion) { + n := 0 + if f.asked != nil { + n = f.asked() + } + f.marks = append(f.marks, fmt.Sprintf("%s@%d asks", v.Version, n)) +} + func (f *fakeReservations) TakenOver(_ context.Context, _, fp string) (versions.ReservedVersion, bool, error) { v, ok := f.tookBy[fp] return v, ok, nil @@ -429,6 +439,7 @@ func TestAReservingTrunkBuildNeverEndsDoneWithoutItsVersion(t *testing.T) { } r.b.Reserved = res asked := len(r.asks.Asks()) + res.asked = func() int { return len(r.asks.Asks()) - asked } got := r.b.BuildAgain(context.Background(), "m", fp1, "its publish was refused", "shanks.lead", 2*time.Second) r.b.Wait() if c.refuse != "" { @@ -447,6 +458,10 @@ func TestAReservingTrunkBuildNeverEndsDoneWithoutItsVersion(t *testing.T) { if _, ok := res.built[want]; !ok || len(res.reserved) != 1 { t.Fatalf("built %v after %d reservations; want the digests recorded under the freshly reserved %s so the build's end asks its publish", res.built, len(res.reserved), want) } + // H2 H-A-588 (4): what the registries hold is marked once the version is reserved and before the build module is asked + if len(res.marks) != 1 || res.marks[0] != want+"@0 asks" { + t.Errorf("MarkRegistryHeld was told %v; want %s once, before any ask of the build module", res.marks, want) + } }) } } @@ -457,6 +472,7 @@ type realReserve struct { reservations map[string][]byte } +func (r *realReserve) MarkRegistryHeld(context.Context, versions.ReservedVersion) {} func (r *realReserve) ReleasedFor(context.Context, string, string) (bool, error) { return false, nil } diff --git a/modules/mesh-delivery-builder/internal/build/run.go b/modules/mesh-delivery-builder/internal/build/run.go index 805087e4c..aa9a69ec7 100644 --- a/modules/mesh-delivery-builder/internal/build/run.go +++ b/modules/mesh-delivery-builder/internal/build/run.go @@ -815,6 +815,12 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB reserved, hasReserved = b.reserve(ctx, module, m, plan, b.originOf(key), false) } } + if hasReserved && supersededNow == "" && cl.Build.State != builds.BuildDone { + // Before a build module is asked for the fingerprint again, what a registry holds of it at its version is on the reservation + // and marked published, so a version a failed build left partly published is completed, never built whole again over a + // refusal (design 47 H2 H-A-588 (4), H-A-666: between the reserve and the build). + b.Reserved.MarkRegistryHeld(ctx, reserved) + } var result builds.BuilderBuild if supersededNow != "" { // Ended as the newer entry's take-in withdraws a build in flight: final for this fingerprint. diff --git a/modules/mesh-delivery-builder/internal/versions/republish.go b/modules/mesh-delivery-builder/internal/versions/republish.go index d712ce062..e187976d0 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish.go +++ b/modules/mesh-delivery-builder/internal/versions/republish.go @@ -162,6 +162,9 @@ type Republisher struct { // Started is when this run of the builder started: a version whose build ended at or after it is of the live class, one // that ended before it of the start's (H-A-290 (1)). Zero makes every version live. Started time.Time + // Unstored is told the first artifact of a reservation a holder refused as not stored, with the reservation as it stood: the + // builder builds the key again itself (design 47 H2 H-A-662); nil is told none. + Unstored func(ctx context.Context, v ReservedVersion, ref, words string) // Ended ends the publish item of a version that never publishes, its reservation withdrawn or taken over (H-A-290 (2)); // nil ends none. Ended func(ctx context.Context, module, version string) @@ -748,7 +751,7 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate return SendFate{Ended: "none of its artifacts is left to send: each is published or refused as not stored"} } var failed []string - sent := 0 + sent, again := 0, false for _, ref := range refs { seat, name, kind, ok := publishTarget(e, q.Module, ref) if !ok { @@ -769,6 +772,12 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate r.logf("%s %s: the unstored %s is not kept: %v", q.Module, q.Version, ref, merr) } else if ok { r.say(ctx, v, ref+" "+NotStoredWords+words) + // The first of the reservation's artifacts refused as not stored starts the build again, once per reservation: one + // the kept `unstored` already holds starts none (design 47 H2 H-A-662, H-A-703). + if len(v.Unstored) == 0 && !again && r.Unstored != nil { + again = true + r.Unstored(ctx, v, ref, words) + } } continue } diff --git a/modules/mesh-delivery-builder/internal/versions/republish_test.go b/modules/mesh-delivery-builder/internal/versions/republish_test.go index c4e60ade1..de818237b 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish_test.go +++ b/modules/mesh-delivery-builder/internal/versions/republish_test.go @@ -163,6 +163,22 @@ func TestRepublish(t *testing.T) { t.Errorf("sent %d, said %v: want one try and one saying of not stored", len(b.sent), b.said) } }) + t.Run("the first artifact refused as not stored starts the build again once", func(t *testing.T) { + // design 47 H2 H-A-662, H-A-703: one start per reservation, whatever number of its artifacts are refused + b := newRepublishBed(t) + v := b.reserve(t, "m") + var started []string + b.Unstored = func(_ context.Context, v ReservedVersion, ref, _ string) { + started = append(started, v.Version+" "+ref) + } + b.refuse = "oci-artifact-registry's publish of m/prog: not stored: no blob sha256:aa" + b.holders = map[string][]string{SeatArtifacts: {"oci"}} + b.SendQueued(ctx, b.queueAt(v, PublishClassLive, b.now)) + b.SendQueued(ctx, b.queueAt(v, PublishClassLive, b.now)) + if len(started) != 1 || started[0] != v.Version+" m:prog" { + t.Errorf("the build again was started %v, want once for %s", started, v.Version) + } + }) t.Run("a refusal in other words is said each time", func(t *testing.T) { b := newRepublishBed(t) b.reserve(t, "m") diff --git a/modules/mesh-delivery-builder/internal/versions/reserve.go b/modules/mesh-delivery-builder/internal/versions/reserve.go index 0ed1bb07d..58f7bd3b8 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve.go @@ -447,9 +447,11 @@ func allSet(m map[string]string) bool { } // MarkHeld writes on module's reservation of version each artifact a registry holds at the version for the reservation's -// fingerprint, with the held digest, and marks it published when it was not (design 47 H2 H-A-588 (4)), in one compare-and-set. -// It answers the artifacts it newly marked, and false when the reservation stands at another version. -func (r *Reserver) MarkHeld(ctx context.Context, module, version string, held []HeldArtifact) ([]HeldArtifact, bool, error) { +// fingerprint, with the held digest, and marks it published when it was not, in one compare-and-set; in the same write each +// artifact that is neither held nor marked published loses its recorded digest and the reservation its built-at, since what +// the registries do not hold is built again (design 47 H2 H-A-588 (4), H-A-664; unstored is kept). It answers the artifacts it +// newly marked, and false when the reservation stands at another version. +func (r *Reserver) MarkHeld(ctx context.Context, module, version string, held []HeldArtifact) ([]Marked, bool, error) { series, _, err := SplitVersion(version) if err != nil { return nil, false, err @@ -462,20 +464,30 @@ func (r *Reserver) MarkHeld(ctx context.Context, module, version string, held [] } was := cur was.Artifacts, was.Published, was.PublishedAt = maps.Clone(cur.Artifacts), maps.Clone(cur.Published), maps.Clone(cur.PublishedAt) - var marked []HeldArtifact + var marked []Marked changed := false if cur.Artifacts == nil { cur.Artifacts = map[string]string{} } + isHeld := map[string]bool{} for _, h := range held { + isHeld[h.Ref] = true if cur.Artifacts[h.Ref] != h.Digest { cur.Artifacts[h.Ref], changed = h.Digest, true } if !cur.Published[h.Ref] { cur.markPublished(h.Ref, r.now()) - marked, changed = append(marked, h), true + marked, changed = append(marked, Marked{Artifact: h.Ref}), true } } + for ref, d := range cur.Artifacts { + if d != "" && !isHeld[ref] && !cur.Published[ref] && !slices.Contains(cur.Upstream, ref) { + cur.Artifacts[ref], changed = "", true + } + } + if !cur.BuiltAt.IsZero() && !allSet(cur.Artifacts) { + cur.BuiltAt, changed = time.Time{}, true + } if !changed { return nil, true, nil } @@ -486,6 +498,9 @@ func (r *Reserver) MarkHeld(ctx context.Context, module, version string, held [] return nil, false, fmt.Errorf("%s cannot be written: %w", key, err) } r.said(r.reindex(ctx, key, was, cur)) + for i := range marked { + marked[i].Reserved = cur + } return marked, true, nil } } diff --git a/modules/mesh-delivery-builder/internal/versions/reserve_test.go b/modules/mesh-delivery-builder/internal/versions/reserve_test.go index 2b4872e8e..ee3a764a7 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve_test.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve_test.go @@ -187,6 +187,23 @@ func TestReservationIsReadAndMarkedPublished(t *testing.T) { if _, ok, _ := r.MarkHeld(ctx, "m", "1.4.99", held); ok { t.Error("a reservation at another version was marked") } + // H-A-664: in the same write what no registry holds loses its recorded digest and the reservation its built-at; unstored is kept + nv, err := r.Reserve(ctx, "n", "0.1", []string{"n:a", "n:b"}, Source{Fingerprint: "fpn"}) + if err != nil { + t.Fatal(err) + } + if _, _, err := r.Built(ctx, "n", nv.Version, map[string]string{"n:a": "sha256:a", "n:b": "sha256:b"}, nil); err != nil { + t.Fatal(err) + } + if _, err := r.MarkUnstored(ctx, "n", nv.Version, "n:b", "not stored: no blob"); err != nil { + t.Fatal(err) + } + if _, _, err := r.MarkHeld(ctx, "n", nv.Version, []HeldArtifact{{Ref: "n:a", Digest: "sha256:a"}}); err != nil { + t.Fatal(err) + } + if cur, _, _ = r.At(ctx, ReservedKey("n", "0.1")); cur.Artifacts["n:b"] != "" || cur.Artifacts["n:a"] != "sha256:a" || !cur.BuiltAt.IsZero() || cur.Unstored["n:b"] == "" || !cur.Published["n:a"] { + t.Errorf("after the marking %+v: want n:b's digest and the built-at cleared, n:a held, unstored kept", cur) + } } // TestAReleaseIsRecordedByFingerprintBeforeItsReservationGoes: design 47 G A-456a — the version-released of a version records From a58daa9cf7d827978466d94306001702652b94b7 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:14:30 +0100 Subject: [PATCH 026/141] I16 mesh-fingerprint-refused: a manifest naming MESH_FINGERPRINT in any env is refused Builds: design 47 H2 H-A-710 (1) --- modules/mesh-delivery-indexer/judge/rules.go | 31 +++++++++++++++++++ .../mesh-delivery-indexer/judge/rules_test.go | 5 +++ 2 files changed, 36 insertions(+) diff --git a/modules/mesh-delivery-indexer/judge/rules.go b/modules/mesh-delivery-indexer/judge/rules.go index 626421989..b43ab69b9 100644 --- a/modules/mesh-delivery-indexer/judge/rules.go +++ b/modules/mesh-delivery-indexer/judge/rules.go @@ -2839,6 +2839,8 @@ func parseManifest(raw []byte, predefined catalogue.PredefinedList) (catalogue.M problems = append(problems, ConfigLinesProblems(m)...) // And the node's name, which the node-engine sets in every process's env itself (design 47 G A-342). problems = append(problems, NodeEnvProblems(m)...) + // And the build's fingerprint, which the node-engine hands a service itself (design 47 H2 H-A-710 (1)). + problems = append(problems, FingerprintEnvProblems(m)...) // And what it requires optionally, and the files it delivers only while bound (novox/hq ADR 0330). problems = append(problems, OptionalProblems(m)...) // And which setting keys each mergeable file takes (setting_takes.go, novox/hq ADR 0326). @@ -4205,6 +4207,35 @@ func NodeEnvProblems(m catalogue.Manifest) []string { return problems } +// FingerprintEnv is the variable the node-engine sets to the want's fingerprint in a service's env (design 47 H2 H-A-710 +// (1)): a manifest naming it in any env, a container's, a daemon's or a bundle's, is refused. +const FingerprintEnv = "MESH_FINGERPRINT" + +// FingerprintEnvProblems are the resources and bundles whose env names FingerprintEnv: "MESH_FINGERPRINT is the +// node-engine's to hand". +func FingerprintEnvProblems(m catalogue.Manifest) []string { + var problems []string + say := func(what string) { + problems = append(problems, fmt.Sprintf("%s's %s names %s in its env: %s is the node-engine's to hand (design 47 H2 H-A-710)", + m.Module, what, FingerprintEnv, FingerprintEnv)) + } + for _, r := range m.Resources { + if env, ok := r["env"].(map[string]any); ok { + if _, names := env[FingerprintEnv]; names { + say(fmt.Sprintf("resource %v", r["id"])) + } + } + } + if m.Build != nil { + for _, a := range m.Build.Artifacts { + if _, names := a.Env[FingerprintEnv]; names { + say(fmt.Sprintf("artifact %q", a.Name)) + } + } + } + return problems +} + func filepathDir(p string) string { if i := strings.LastIndex(p, "/"); i > 0 { return p[:i] diff --git a/modules/mesh-delivery-indexer/judge/rules_test.go b/modules/mesh-delivery-indexer/judge/rules_test.go index 4610f9f92..cb1e6aaea 100644 --- a/modules/mesh-delivery-indexer/judge/rules_test.go +++ b/modules/mesh-delivery-indexer/judge/rules_test.go @@ -2529,6 +2529,11 @@ func caseAProcessBusNamesOnlyTheModulesOwn(t *testing.T) { if _, err := ParseManifest([]byte(ownNode)); err == nil || !strings.Contains(err.Error(), "MESH_NODE") { t.Errorf("a process setting MESH_NODE itself: %v; want a refusal naming MESH_NODE", err) } + // Design 47 H2 H-A-710 (1): a resource naming MESH_FINGERPRINT in its env is refused with the node-engine's-to-hand problem. + ownFingerprint := strings.Replace(mailSenderProcessManifest(t, ""), `"user":"mesh-mail-send"}`, `"user":"mesh-mail-send","env":{"MESH_FINGERPRINT":"x"}}`, 1) + if _, err := ParseManifest([]byte(ownFingerprint)); err == nil || !strings.Contains(err.Error(), "MESH_FINGERPRINT is the node-engine's to hand") { + t.Errorf("a process naming MESH_FINGERPRINT itself: %v; want a refusal saying it is the node-engine's to hand", err) + } // Design 47 G A-340: an event the module consumes, its process may hear. consumed := strings.Replace(mailSenderProcessManifest(t, `{"consumes":["billing.paid"]}`), `"resources"`, `"consumes":["billing.paid"],"resources"`, 1) if _, err := ParseManifest([]byte(consumed)); err != nil { From fdfe2db0f354f77369c95a8ec520c5afbbe5a460 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:14:55 +0100 Subject: [PATCH 027/141] R3 grants-first-view-away: a first view not read yet is the fault away naming its owner's verb Builds: design 47 H2 H-A-708 (2); row R3 (withheld itself reads the part's own user list, not a first view: question to the lead) --- modules/mesh-grants/cmd/mesh-grants/tools.go | 2 +- modules/mesh-grants/grants_test.go | 11 ++++++++ .../mesh-grants/internal/grants/firstviews.go | 26 +++++++++++++++---- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/modules/mesh-grants/cmd/mesh-grants/tools.go b/modules/mesh-grants/cmd/mesh-grants/tools.go index fccd67400..7ae2a8da5 100644 --- a/modules/mesh-grants/cmd/mesh-grants/tools.go +++ b/modules/mesh-grants/cmd/mesh-grants/tools.go @@ -107,7 +107,7 @@ func (v *toolViews) of(state string) (map[string]json.RawMessage, bool, error) { after = a.Next } if rev == 0 { - return nil, true, fmt.Errorf("%s by %s: %w", state, fv.Tool, grants.ErrFirstViewNotYet) + return nil, true, fmt.Errorf("%s by %s: %w", state, fv.Tool, grants.NotYet(fv.Tool, "answered empty at revision 0")) } if v.held == nil { v.held = map[string]map[string]json.RawMessage{} diff --git a/modules/mesh-grants/grants_test.go b/modules/mesh-grants/grants_test.go index 147d1853f..ad5640d7b 100644 --- a/modules/mesh-grants/grants_test.go +++ b/modules/mesh-grants/grants_test.go @@ -39,6 +39,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" "git.novox.be/novox/mesh-delivery/modules/mesh-grants/grantsstate" + "git.novox.be/novox/mesh-sdk/go/busretry" "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/keys" "git.novox.be/novox/mesh-sdk/go/membership" @@ -3914,6 +3915,16 @@ func TestGrants(t *testing.T) { return last == state } waitFor(t, refusedOnce.Load) + // H-A-708 (2): a read of a first view not in yet is mesh-sdk's `away` fault naming the owner's verb, still ErrFirstViewNotYet. + for read, f := range fv.Followers { + if f.Tool != grants.AssignerModule+".wants" { + continue + } + var away *busretry.Away + if _, _, err := fv.Get(read, "k"); !errors.As(err, &away) || away.Part != f.Tool || !errors.Is(err, grants.ErrFirstViewNotYet) { + t.Errorf("the first view of %s not in yet is read as %v, not the fault away naming %s", read, err, f.Tool) + } + } p := partOn(b) p.Read, p.Views, p.Say, p.SayFinding = fv, fv, say, say before := p.Compose() diff --git a/modules/mesh-grants/internal/grants/firstviews.go b/modules/mesh-grants/internal/grants/firstviews.go index b42c2702d..bebc7c852 100644 --- a/modules/mesh-grants/internal/grants/firstviews.go +++ b/modules/mesh-grants/internal/grants/firstviews.go @@ -14,6 +14,7 @@ import ( occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient" oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel" + "git.novox.be/novox/mesh-sdk/go/busretry" "git.novox.be/novox/mesh-sdk/go/views" ) @@ -66,6 +67,19 @@ const KeyFirstViews = "first-views" // ErrFirstViewNotYet is a read of a first view not answered above revision 0: the part composes as from a failed read. var ErrFirstViewNotYet = errors.New("not answered above revision 0 yet") +// firstViewAway is ErrFirstViewNotYet as mesh-sdk's `away` fault naming the view's owner verb (design 47 H2 H-A-708 (2)): a +// caller of the part's read is told that a part it depends on did not answer yet, which it reads as a transport fault and asks +// again, never as a refusal. +type firstViewAway struct{ *busretry.Away } + +func (e firstViewAway) Is(target error) bool { return target == ErrFirstViewNotYet } +func (e firstViewAway) Unwrap() error { return e.Away } + +// NotYet is ErrFirstViewNotYet for the first view of the owner's verb tool, saying why in words. +func NotYet(tool, words string) error { + return firstViewAway{&busretry.Away{Part: tool, Words: words}} +} + // Views is the part's reads of the five owners' states through their first views: a Reader and a Watcher for those // states, every other read going to Rest. type Views struct { @@ -184,13 +198,15 @@ func (v *Views) ready(read string) (*views.Follower, bool, error) { if !ok { return nil, false, nil } - select { - case <-f.Ready(): - default: - return f, true, fmt.Errorf("%s by %s: %w", read, f.Tool, ErrFirstViewNotYet) + if err := f.Unread(); err != nil { + var away *busretry.Away + if errors.As(err, &away) { + return f, true, fmt.Errorf("%s by %s: %w", read, f.Tool, NotYet(away.Part, away.Words)) + } + return f, true, err } if s := f.Status(); s.Revision == 0 { - return f, true, fmt.Errorf("%s by %s answered empty at revision 0: %w", read, f.Tool, ErrFirstViewNotYet) + return f, true, fmt.Errorf("%s by %s: %w", read, f.Tool, NotYet(f.Tool, "answered empty at revision 0")) } return f, true, nil } From 1d0b2d3e072016766be7a756a082c7ed0503c424 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:15:05 +0100 Subject: [PATCH 028/141] DC6c mover-row-tier: MoverRow gains tier (same form raise of mesh-pipeline-runner) Builds: design 47 H2 H-A-730, H-A-709 (1) --- .../go/seats/meshpipelinerunner/contract.go | 4 +++- .../go/seats/meshpipelinerunner/contract_test.go | 2 +- .../seats/mesh-pipeline-runner/fixtures/verbs.json | 6 ++++-- .../seats/mesh-pipeline-runner/seat.json | 4 ++++ .../ts/seats/meshpipelinerunner/index.d.ts | 2 ++ 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index e5c1449ad..6bc40ce57 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -20,7 +20,7 @@ const Form = 13 // whose fields changed while its forms did not (design 47 H2 §780). const ( generatedForms = "13" - generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverAdded=6966283f6909 MoverAddedEvent=b24ae82030ab MoverEnded=4b35095f6829 MoverRow=b7ceefe24722 Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=397a8219a855 PipelineStarted=d5fc3ee236c7 PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=69998ea62147 PlaceUnfinishedAnswerFailedItem=d9b89913b9bf PlaceUnfinishedAnswerPlacedItem=9ff9288125e5 Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=8609ff359791 StandsAnswer=e05cecdde456 StartAnswer=ed94ced4513a StartedMover=4450a94e6ca3 StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=bdaa8bbfbcab StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=21e4ee7a3ef1 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" + generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverAdded=6966283f6909 MoverAddedEvent=b24ae82030ab MoverEnded=4b35095f6829 MoverRow=6de094f5329f Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=397a8219a855 PipelineStarted=d5fc3ee236c7 PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=69998ea62147 PlaceUnfinishedAnswerFailedItem=d9b89913b9bf PlaceUnfinishedAnswerPlacedItem=9ff9288125e5 Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=8609ff359791 StandsAnswer=e05cecdde456 StartAnswer=ed94ced4513a StartedMover=4450a94e6ca3 StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=bdaa8bbfbcab StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=21e4ee7a3ef1 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" ) const ( @@ -773,6 +773,8 @@ type MoverRow struct { Module string `json:"module"` // waiting for a mover with no step placed; running while a required step is open; failed once a required step did not pass; superseded for one a newer pipeline took out Outcome string `json:"outcome"` + // the mover's tier in the pipeline's delivery order, from 1, which the delivery view's tiered page groups the movers by (design 47 H2 H-A-730) + Tier int64 `json:"tier,omitempty"` // the version released for the mover in this pipeline, absent until one is (design 47 H2 H-A-709 (1)) Version string `json:"version,omitempty"` } diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go index 9ca12a204..f8989f25f 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go @@ -143,7 +143,7 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v PlaceUnfinishedInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "place-unfinished with one key", subject: "", given: "{\"key\":\"main.mesh-sdk\",\"why\":\"the mover passed on its own\"}", wire: "{\"key\":\"main.mesh-sdk\",\"why\":\"the mover passed on its own\"}", decode: func(b []byte) (any, error) { var v PlaceUnfinishedInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "show answers a page of movers' rows with their fingerprint and version, moved and capped (H-A-709)", subject: "", given: "{\"capped\":true,\"moved\":true,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"running\",\"version\":\"0.1.9\"},{\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"outcome\":\"passed\"}],\"next\":\"cursor-1\",\"pipeline\":{\"branch\":\"main\",\"mover-count\":129,\"movers\":[],\"outcome\":\"running\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step-count\":516,\"steps\":[],\"v\":1},\"total\":129}", wire: "{\"capped\":true,\"moved\":true,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"running\",\"version\":\"0.1.9\"},{\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"outcome\":\"passed\"}],\"next\":\"cursor-1\",\"pipeline\":{\"branch\":\"main\",\"mover-count\":129,\"movers\":[],\"outcome\":\"running\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step-count\":516,\"steps\":[],\"v\":1},\"total\":129}", + {name: "show answers a page of movers' rows with their fingerprint and version, moved and capped (H-A-709)", subject: "", given: "{\"capped\":true,\"moved\":true,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"running\",\"tier\":2,\"version\":\"0.1.9\"},{\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"tier\":1}],\"next\":\"cursor-1\",\"pipeline\":{\"branch\":\"main\",\"mover-count\":129,\"movers\":[],\"outcome\":\"running\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step-count\":516,\"steps\":[],\"v\":1},\"total\":129}", wire: "{\"capped\":true,\"moved\":true,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"running\",\"tier\":2,\"version\":\"0.1.9\"},{\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"tier\":1}],\"next\":\"cursor-1\",\"pipeline\":{\"branch\":\"main\",\"mover-count\":129,\"movers\":[],\"outcome\":\"running\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"step-count\":516,\"steps\":[],\"v\":1},\"total\":129}", decode: func(b []byte) (any, error) { var v ShowAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "stands answers a page, capped, with the total and the cursor of the next (H-A-709)", subject: "", given: "{\"capped\":true,\"next\":\"cursor-2\",\"stands\":[{\"artifact\":\"nats:program\",\"branch\":\"main\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.3589\",\"revision\":12,\"since\":\"2026-11-10T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}],\"total\":300}", wire: "{\"capped\":true,\"next\":\"cursor-2\",\"stands\":[{\"artifact\":\"nats:program\",\"branch\":\"main\",\"module\":\"nats\",\"on\":\"build node\",\"pipeline\":\"main.3589\",\"revision\":12,\"since\":\"2026-11-10T10:00:00Z\",\"source\":3589,\"step\":\"unit\",\"v\":1}],\"total\":300}", decode: func(b []byte) (any, error) { var v StandsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json index 27026dee0..970199d9b 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/verbs.json @@ -379,12 +379,14 @@ "module": "nats", "outcome": "running", "fingerprint": "fp-0123", - "version": "0.1.9" + "version": "0.1.9", + "tier": 2 }, { "module": "mesh-sdk", "outcome": "passed", - "fingerprint": "fp-sdk" + "fingerprint": "fp-sdk", + "tier": 1 } ], "capped": true, diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json index 79e55f56d..6b6f3f8e8 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -2474,6 +2474,10 @@ "type": "string", "description": "the version released for the mover in this pipeline, absent until one is (design 47 H2 H-A-709 (1))" }, + "tier": { + "type": "integer", + "description": "the mover's tier in the pipeline's delivery order, from 1, which the delivery view's tiered page groups the movers by (design 47 H2 H-A-730)" + }, "outcome": { "type": "string", "enum": [ diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts index 5a9c9ac10..aeb039771 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -308,6 +308,8 @@ export interface MoverRow { "module": string; /** waiting for a mover with no step placed; running while a required step is open; failed once a required step did not pass; superseded for one a newer pipeline took out */ "outcome": "waiting" | "running" | "passed" | "failed" | "superseded"; + /** the mover's tier in the pipeline's delivery order, from 1, which the delivery view's tiered page groups the movers by (design 47 H2 H-A-730) */ + "tier"?: number; /** the version released for the mover in this pipeline, absent until one is (design 47 H2 H-A-709 (1)) */ "version"?: string; } From 6af989cece355c827f47ee77e59d43ddd1b298b5 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:15:05 +0100 Subject: [PATCH 029/141] B6 drop-names-its-version: builder_reserved_drop takes the version, refuses another or a building one, and names what it forgot Builds: design 47 H2 H-A-592 (1) (2) (3) --- .../mesh-delivery-builder-tools/reserved.go | 13 ++--- .../cmd/mesh-delivery-builder/main.go | 4 ++ .../mesh-delivery-builder/publishitem_test.go | 14 +++++- .../cmd/mesh-delivery-builder/reasks.go | 2 +- .../cmd/mesh-delivery-builder/reserve.go | 50 ++++++++++++++++--- .../cmd/mesh-delivery-builder/reserve_test.go | 7 +-- .../internal/build/reserve_test.go | 9 ++-- .../internal/build/stuck.go | 12 +++-- .../internal/versions/again.go | 2 +- .../internal/versions/reserve.go | 5 +- 10 files changed, 89 insertions(+), 29 deletions(-) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reserved.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reserved.go index a690371cd..39b3bf871 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reserved.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reserved.go @@ -25,16 +25,17 @@ func reservedTools(rr versions.Reader, ask queueAsker, now func() time.Time, act "module": map[string]any{"type": "string", "description": "only this module's reservations"}}}, Run: func(args map[string]any) (any, error) { return versions.AnswerReserved(rr, str(args, "module")) }}, {Name: versions.ReservedDropTool, Description: versions.ReservedDropDescription, - Input: map[string]any{"type": "object", "required": []string{"module", "series", "why"}, "properties": map[string]any{ - "module": map[string]any{"type": "string", "description": "the module"}, - "series": map[string]any{"type": "string", "description": "its MAJOR.MINOR"}, - "why": map[string]any{"type": "string", "description": "why, in plain words"}}}, + Input: map[string]any{"type": "object", "required": []string{"module", "series", "version", "why"}, "properties": map[string]any{ + "module": map[string]any{"type": "string", "description": "the module"}, + "series": map[string]any{"type": "string", "description": "its MAJOR.MINOR"}, + "version": map[string]any{"type": "string", "description": "the MAJOR.MINOR.PATCH the reservation stands at, as builder_reserved shows it: a newer one is never dropped"}, + "why": map[string]any{"type": "string", "description": "why, in plain words"}}}, Run: func(args map[string]any) (any, error) { - key, value, err := build.NewReservedDrop(str(args, "module"), str(args, "series"), str(args, "why"), stdio.CallerOf(args), now()) + key, value, err := build.NewReservedDrop(str(args, "module"), str(args, "series"), str(args, "version"), str(args, "why"), stdio.CallerOf(args), now()) if err != nil { return nil, err } - if _, err := acts.Record(meshhandactsclient.Request{What: fmt.Sprintf("dropped the reservation of %s %s by hand", str(args, "module"), str(args, "series")), + if _, err := acts.Record(meshhandactsclient.Request{What: fmt.Sprintf("dropped the reservation of %s %s by hand", str(args, "module"), str(args, "version")), Why: str(args, "why"), Cause: versions.ReservedDropTool, Verb: "reserved-drop"}); err != nil { return nil, fmt.Errorf("the hand act was not recorded through mesh-hand-acts, so nothing was dropped: %w", err) } diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index a89f62fba..f4b9fb859 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -247,6 +247,10 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro b.Reserved = reserved // A take-over of a series' reservation by another fingerprint withdraws the older build (H-A-225). reserved.withdraw = b.Withdraw + reserved.looking = func(module, fp string) bool { + key, err := builds.BuilderBuildKey(module, fp) + return err == nil && b.Looking(key) + } reserved.recordAgain = b.RecordAgain // a done build's digests its end did not record are recorded at the start (H-A-492) // The versions' hand acts (builder_publish_again, builder_reserved_drop) come through reasks, as builder_build_again. acts := versions.Acts{DropReserved: reserved.dropped} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/publishitem_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/publishitem_test.go index c516dff68..c37f172ee 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/publishitem_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/publishitem_test.go @@ -352,8 +352,18 @@ func TestThePublishItemsAreWiredToTheReservationsAndTheReAskWatch(t *testing.T) } // A drop deletes the item too. third := done("src2:three") - if _, err := rv.dropped(ctx, "m", "0.1", "op", "never", time.Unix(0, 0)); err != nil { - t.Fatal(err) + // H2 H-A-592 (1): another version than the one standing is refused naming the standing one; so is a drop while its fingerprint builds + if _, err := rv.dropped(ctx, "m", "0.1", "0.1.99", "op", "never", time.Unix(0, 0)); err == nil || !strings.Contains(err.Error(), third.Version) { + t.Errorf("a drop naming another version answered %v, want a refusal naming %s", err, third.Version) + } + rv.looking = func(module, fp string) bool { return module == "m" && fp == "src2:three" } + if _, err := rv.dropped(ctx, "m", "0.1", third.Version, "op", "never", time.Unix(0, 0)); err == nil || !strings.Contains(err.Error(), "building") { + t.Errorf("a drop while the fingerprint builds answered %v, want a refusal", err) + } + rv.looking = nil + answer, err := rv.dropped(ctx, "m", "0.1", third.Version, "op", "never", time.Unix(0, 0)) + if err != nil || !strings.Contains(answer, third.Version) || !strings.Contains(answer, "src2:three") { + t.Fatalf("the drop answered %q (%v), want it to name the version and the fingerprint it forgot", answer, err) } if kv.has(versions.PublishItemKey("m", third.Version)) { t.Errorf("a dropped reservation kept its item") diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go index e3951c9a6..bffe75841 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go @@ -225,7 +225,7 @@ func versionActed(ctx context.Context, acts versions.Acts, kv jetstream.KeyValue if acts.DropReserved == nil { err = errors.New("this builder keeps no reservations") } else { - r.Answer, err = acts.DropReserved(ctx, r.Name, r.FP, r.By, r.Why, r.At) + r.Answer, err = acts.DropReserved(ctx, r.Name, r.FP, r.Version, r.By, r.Why, r.At) } } else if acts.DropOldForm == nil { err = errors.New("this builder keeps no old-form window") diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go index 74751b671..3d4051301 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go @@ -7,6 +7,7 @@ import ( "fmt" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" "slices" + "sort" "strings" "time" @@ -58,6 +59,8 @@ type reservations struct { recordAgain func(ctx context.Context, module, fp, when string) (string, error) // rebuild builds a done key of module at fp again (the build-again path, A-490; H-A-279); nil builds none. rebuild func(ctx context.Context, module, fp, why string) error + // looking says a look of the builder holds the build key of module at fp now (builder_reserved_drop refuses it); nil says none. + looking func(module, fp string) bool // judge reads the registries' record of a reservation's artifacts at its version (the republisher's Held); nil reads none. judge func(ctx context.Context, v versions.ReservedVersion) (versions.Judged, error) // say says package-published on the seat mesh-builds; nil says none. @@ -503,22 +506,55 @@ func (rv *reservations) sayPublished(ctx context.Context, m versions.Marked, dig } } -// dropped is builder_reserved_drop: the reservation is deleted and its bound ended. -func (rv *reservations) dropped(ctx context.Context, module, series, by, why string, at time.Time) (string, error) { - cur, held, _ := rv.r.At(ctx, versions.ReservedKey(module, series)) +// dropped is builder_reserved_drop (design 47 H2 H-A-592): it names its version, and the reservation of the series is deleted whole +// only when it stands at that version and its fingerprint is not building; the publish item and the version-unreleased go with it, +// the bound ends, and the answer names what was forgotten. +func (rv *reservations) dropped(ctx context.Context, module, series, version, by, why string, at time.Time) (string, error) { + cur, held, err := rv.r.At(ctx, versions.ReservedKey(module, series)) + if err != nil { + return "", err + } + if !held { + return "", fmt.Errorf("%s holds no reservation of %s", module, series) + } + if cur.Version != version { + return "", fmt.Errorf("%s's reservation of %s stands at %s, not %s: a reservation a newer build took is never dropped", module, series, cur.Version, version) + } + if rv.looking != nil && rv.looking(module, cur.Fingerprint) { + return "", fmt.Errorf("the build of %s at %s, which holds %s, is building: drop it when that build ends or its ask is dropped (builder_stuck reads it)", module, cur.Fingerprint, version) + } + atRegistries := "the registries' record was not read" + if rv.judge != nil { + if j, jerr := rv.judge(ctx, cur); jerr == nil { + var names []string + for _, h := range append(append([]versions.HeldArtifact{}, j.Held...), j.Elsewhere...) { + names = append(names, h.Seat+" "+h.Name) + } + atRegistries = "the registries keep " + strings.Join(names, ", ") + " at it, a gap the next reserve skips" + if len(names) == 0 { + atRegistries = "no registry holds an artifact at it" + } + } + } ok, err := rv.r.Drop(ctx, module, series) if err != nil { return "", err } - if ok && held && rv.itemEnded != nil { - rv.itemEnded(ctx, module, cur.Version) // its publish item goes with its reservation (A-456b), its items terminated (§793) - } if !ok { return "", fmt.Errorf("%s holds no reservation of %s", module, series) } + if rv.itemEnded != nil { + rv.itemEnded(ctx, module, cur.Version) // its publish item goes with its reservation (A-456b), its items terminated (§793) + } rv.dropBound(ctx, versions.ReservedKey(module, series)) rv.found.clear(ctx, versions.VersionUnreleased, meshconditionsclient.ScopeModule, module) - return fmt.Sprintf("the reservation of %s %s is dropped (%s, %s)", module, series, by, why), nil + withdrawn := make([]string, 0, len(cur.Withdrawn)) + for v := range cur.Withdrawn { + withdrawn = append(withdrawn, v) + } + sort.Strings(withdrawn) + return fmt.Sprintf("the reservation of %s %s is dropped (%s, %s): forgot version %s of fingerprint %s, %d recorded digests, withdrawn numbers %v and its publish item and version-unreleased; %s", + module, series, by, why, cur.Version, cur.Fingerprint, len(cur.Artifacts), withdrawn, atRegistries), nil } // noMark says why a published marked nothing, from the reservations the published read (design 47 H H-A-280: no second read): diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go index 4d997e094..4d8146bdf 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go @@ -143,13 +143,14 @@ func TestTheCatalogsWordsMoveTheReservations(t *testing.T) { if all, _ := rv.r.All(ctx); len(all) != 0 || bounds.keys[boundKey] || len(st.vals) != 0 { t.Errorf("after version-released: reservations %v, bounds %v, findings %v; want none", all, bounds.keys, st.vals) } - if _, err := rv.Reserve(ctx, "m", "1.4", []string{"m:a"}, versions.Source{}); err != nil { + again, err := rv.Reserve(ctx, "m", "1.4", []string{"m:a"}, versions.Source{}) + if err != nil { t.Fatal(err) } - if answer, err := rv.dropped(ctx, "m", "1.4", "op", "never released", time.Unix(0, 0)); err != nil || !strings.Contains(answer, "dropped") { + if answer, err := rv.dropped(ctx, "m", "1.4", again.Version, "op", "never released", time.Unix(0, 0)); err != nil || !strings.Contains(answer, "dropped") { t.Errorf("builder_reserved_drop: %q (%v)", answer, err) } - if _, err := rv.dropped(ctx, "m", "1.4", "op", "again", time.Unix(0, 0)); err == nil { + if _, err := rv.dropped(ctx, "m", "1.4", again.Version, "op", "again", time.Unix(0, 0)); err == nil { t.Error("a reservation that is gone was dropped again") } } diff --git a/modules/mesh-delivery-builder/internal/build/reserve_test.go b/modules/mesh-delivery-builder/internal/build/reserve_test.go index 9648845bc..c41cfc462 100644 --- a/modules/mesh-delivery-builder/internal/build/reserve_test.go +++ b/modules/mesh-delivery-builder/internal/build/reserve_test.go @@ -280,15 +280,16 @@ func (unreadable) Get(context.Context, string) ([]byte, uint64, bool, error) { // reasks, under a key of the reservation (never a build key), refusing a module with no MAJOR.MINOR or no why. func TestADropOfAReservationIsAReasksValueOfItsOwnKey(t *testing.T) { at := time.Unix(0, 0) - key, data, err := NewReservedDrop("m", "1.4", "never released", "op@x", at) + key, data, err := NewReservedDrop("m", "1.4", "1.4.3", "never released", "op@x", at) if err != nil || key != "reserved."+versions.ReservedKey("m", "1.4") { t.Fatalf("key %q (%v)", key, err) } - if r, err := DecodeReAsk(data); err != nil || r.Mode != ModeReservedDrop || r.Name != "m" || r.FP != "1.4" || r.By != "op@x" { + if r, err := DecodeReAsk(data); err != nil || r.Mode != ModeReservedDrop || r.Name != "m" || r.FP != "1.4" || r.Version != "1.4.3" || r.By != "op@x" { t.Errorf("value = %+v (%v)", r, err) } - for name, args := range map[string][3]string{"no module": {"", "1.4", "why"}, "no series": {"m", "1", "why"}, "three numbers": {"m", "1.4.2", "why"}, "no why": {"m", "1.4", " "}} { - if _, _, err := NewReservedDrop(args[0], args[1], args[2], "op", at); err == nil { + for name, args := range map[string][4]string{"no module": {"", "1.4", "1.4.3", "why"}, "no series": {"m", "1", "1.4.3", "why"}, "three numbers": {"m", "1.4.2", "1.4.3", "why"}, "no why": {"m", "1.4", "1.4.3", " "}, + "no version": {"m", "1.4", "", "why"}, "another series": {"m", "1.4", "1.5.3", "why"}} { + if _, _, err := NewReservedDrop(args[0], args[1], args[2], args[3], "op", at); err == nil { t.Errorf("%s: a drop was made", name) } } diff --git a/modules/mesh-delivery-builder/internal/build/stuck.go b/modules/mesh-delivery-builder/internal/build/stuck.go index a2c8173db..e0c6ad061 100644 --- a/modules/mesh-delivery-builder/internal/build/stuck.go +++ b/modules/mesh-delivery-builder/internal/build/stuck.go @@ -129,9 +129,10 @@ func NewOldFormDrop(node, why, by string, at time.Time) (string, []byte, error) const ModeReservedDrop = "reserved-drop" // NewReservedDrop is the value builder_reserved_drop writes: the key `reserved..` (never a build key) -// and the value. -func NewReservedDrop(module, series, why, by string, at time.Time) (string, []byte, error) { - module, series = strings.TrimSpace(module), strings.TrimSpace(series) +// and the value, which names the version to drop (design 47 H2 H-A-592 (1)): a reservation a newer build took after it was read +// is never dropped. +func NewReservedDrop(module, series, version, why, by string, at time.Time) (string, []byte, error) { + module, series, version = strings.TrimSpace(module), strings.TrimSpace(series), strings.TrimSpace(version) if module == "" { return "", nil, errors.New("module is required") } @@ -141,7 +142,10 @@ func NewReservedDrop(module, series, why, by string, at time.Time) (string, []by if strings.TrimSpace(why) == "" { return "", nil, errors.New("say why the reservation is dropped (why)") } - data, err := json.Marshal(ReAsk{V: 1, Why: strings.TrimSpace(why), By: by, At: at.UTC(), Mode: ModeReservedDrop, Name: module, FP: series}) + if s, _, err := versions.SplitVersion(version); err != nil || s != series { + return "", nil, fmt.Errorf("version %q is not a MAJOR.MINOR.PATCH of the series %s (version is required)", version, series) + } + data, err := json.Marshal(ReAsk{V: 1, Why: strings.TrimSpace(why), By: by, At: at.UTC(), Mode: ModeReservedDrop, Name: module, FP: series, Version: version}) return "reserved." + versions.ReservedKey(module, series), data, err } diff --git a/modules/mesh-delivery-builder/internal/versions/again.go b/modules/mesh-delivery-builder/internal/versions/again.go index 3010c1bbe..1788c164f 100644 --- a/modules/mesh-delivery-builder/internal/versions/again.go +++ b/modules/mesh-delivery-builder/internal/versions/again.go @@ -15,7 +15,7 @@ type Acts struct { // its answer, or why not. ReserveDone func(ctx context.Context, module, fp, by, why string, at time.Time) (string, error) // DropReserved drops a module's reservation of one MAJOR.MINOR by hand (builder_reserved_drop): its answer, or why not. - DropReserved func(ctx context.Context, module, series, by, why string, at time.Time) (string, error) + DropReserved func(ctx context.Context, module, series, version, by, why string, at time.Time) (string, error) // PublishDrop terminates one publish item (builder_publish_drop, design 47 H2 §793): the answer, or why not. PublishDrop func(ctx context.Context, module, version, by, why string) (string, error) } diff --git a/modules/mesh-delivery-builder/internal/versions/reserve.go b/modules/mesh-delivery-builder/internal/versions/reserve.go index 58f7bd3b8..d1879318c 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve.go @@ -1217,7 +1217,10 @@ const ( "the version its build reserved at its start, each artifact's digest once built, when the build ended and which artifacts a registry " + "seat said published. With module, that module's only. A key goes when the catalog says version-released for it. Read-only." ReservedDropDescription = "Drop a module's reservation of one MAJOR.MINOR by hand (design 47 G section 369), when its version will never be " + - "released; the next build takes the next after the highest released. A hand act: it is recorded in the hand-act log." + "released; given module, series and the version it stands at (version, as builder_reserved shows it). Refused when the key holds another version " + + "(it names the one that stands) and while the reservation's fingerprint is building. It forgets the key whole (the version, its fingerprint, the " + + "artifacts' recorded digests, its withdrawn numbers), its publish item and its version-unreleased, and the answer names what it forgot; what the " + + "registries hold at the version stays, a gap the next reserve skips. A hand act: it is recorded in the hand-act log." ReserveDoneDescription = "Reserve a version for a done trunk build that reserved none (design 47 G A-455): given module and fp, the next version " + "of the series is reserved for that fingerprint with the digests of the build's artifacts, and its publish is queued as builder_publish_again " + "queues it; builds nothing. For a done key that cannot be built again. Refused when the key is not done, is no first watched branch's, or " + From c04e5e364c67f769f526cc3f52e18771916f742c Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:15:05 +0100 Subject: [PATCH 030/141] DC7 other-bytes: the publish answer of the four registry seats gains other-bytes, each seat one form higher Builds: design 47 H2 H-A-729, H-A-589 (1), H-A-590 (2) --- .../seats/containerimageregistry/contract.go | 16 +++++++++++--- .../containerimageregistry/contract_test.go | 4 ++++ .../go/seats/gopackageregistry/contract.go | 16 +++++++++++--- .../seats/gopackageregistry/contract_test.go | 4 ++++ .../go/seats/npmpackageregistry/contract.go | 16 +++++++++++--- .../seats/npmpackageregistry/contract_test.go | 4 ++++ .../go/seats/ociartifactregistry/contract.go | 16 +++++++++++--- .../ociartifactregistry/contract_test.go | 4 ++++ .../parts/registry.json | 17 +++++++++++++++ .../fixtures/verbs.json | 21 +++++++++++++++++++ .../seats/container-image-registry/seat.json | 7 ++++--- .../go-package-registry/fixtures/verbs.json | 21 +++++++++++++++++++ .../seats/go-package-registry/seat.json | 3 ++- .../npm-package-registry/fixtures/verbs.json | 21 +++++++++++++++++++ .../seats/npm-package-registry/seat.json | 3 ++- .../oci-artifact-registry/fixtures/verbs.json | 21 +++++++++++++++++++ .../seats/oci-artifact-registry/seat.json | 2 +- .../seats/containerimageregistry/index.d.ts | 1 + .../parts/registry.d.ts | 10 +++++++++ .../ts/seats/gopackageregistry/index.d.ts | 1 + .../gopackageregistry/parts/registry.d.ts | 10 +++++++++ .../ts/seats/npmpackageregistry/index.d.ts | 1 + .../npmpackageregistry/parts/registry.d.ts | 10 +++++++++ .../ts/seats/ociartifactregistry/index.d.ts | 1 + .../ociartifactregistry/parts/registry.d.ts | 10 +++++++++ 25 files changed, 222 insertions(+), 18 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract.go b/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract.go index 0b20f1225..8022f6fa2 100644 --- a/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract.go @@ -13,7 +13,7 @@ const Seat = "container-image-registry" // Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): // a reader of a value of another form says "form N, this reader knows M". -const Form = 1 +const Form = 2 // FormRegistry is the form of what the part registry adds. const FormRegistry = 1 @@ -21,8 +21,8 @@ const FormRegistry = 1 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "1 registry:1" - generatedFieldsDigest = "Artifact=79361e4ab1cd HeldEvent=b6d4c12500df Hold=c5a97a2f2d5a HoldAnswer=7d536ccb729f HoldsBySeatNameDigestValue=db093998a869 KeptEvent=ec3ef89ef8a7 ListAnswer=ca49dd7f20ee Listed=b9f1d1232e64 MirrorAnswer=0d59df97b53b NameOfAnswer=cc75a2f37394 Outcome=1e66f7bf6725 PublishAnswer=a0df0b922e1e PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 ReleaseAnswer=d30bd6000a16 ReleasedEvent=b6d4c12500df RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 Repository=740e54e0b3b0 TagsAnswer=fe178191458a TagsAnswerTagsItem=eee02e024d64 VersionsAnswer=47e11ca2aea9 WindowsByCallerValue=23d9294dde92 WindowsByCallerValueDroppedItem=d748f0e58825" + generatedForms = "2 registry:1" + generatedFieldsDigest = "Artifact=79361e4ab1cd HeldEvent=b6d4c12500df Hold=c5a97a2f2d5a HoldAnswer=7d536ccb729f HoldsBySeatNameDigestValue=db093998a869 KeptEvent=ec3ef89ef8a7 ListAnswer=ca49dd7f20ee Listed=b9f1d1232e64 MirrorAnswer=0d59df97b53b NameOfAnswer=cc75a2f37394 Outcome=1e66f7bf6725 PublishAnswer=1923c8239f6c PublishAnswerOtherBytes=06b1c9853343 PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 ReleaseAnswer=d30bd6000a16 ReleasedEvent=b6d4c12500df RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 Repository=740e54e0b3b0 TagsAnswer=fe178191458a TagsAnswerTagsItem=eee02e024d64 VersionsAnswer=47e11ca2aea9 WindowsByCallerValue=23d9294dde92 WindowsByCallerValueDroppedItem=d748f0e58825" ) const ( @@ -329,6 +329,14 @@ const ( PublishInputKindUpstream = "upstream" ) +// PublishAnswerOtherBytes is the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729). +type PublishAnswerOtherBytes struct { + // the digest the holder holds for that name and version + Digest string `json:"digest"` + // the fingerprint the holder keeps for it, absent where it keeps none + Fingerprint string `json:"fingerprint,omitempty"` +} + // PublishAnswer is what publish answers. type PublishAnswer struct { // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). @@ -337,6 +345,8 @@ type PublishAnswer struct { Held bool `json:"held,omitempty"` // the digests of the parts the holder lacks, to send by publish-part Lacks []string `json:"lacks,omitempty"` + // the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) + OtherBytes *PublishAnswerOtherBytes `json:"other-bytes,omitempty"` // the transfer Transfer string `json:"transfer"` } diff --git a/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract_test.go b/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract_test.go index ade124474..394c0c88b 100644 --- a/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract_test.go @@ -57,6 +57,10 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v NameOfInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "name-of answers the copy's reference", subject: "", given: "{\"reference\":\"container-image-registry/upstream/docker.io/library/nats@sha256:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"}", wire: "{\"reference\":\"container-image-registry/upstream/docker.io/library/nats@sha256:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"}", decode: func(b []byte) (any, error) { var v NameOfAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "publish answers other-bytes: the name and version are held with another digest (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", + decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", + decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { v, err := c.decode([]byte(c.given)) diff --git a/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract.go b/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract.go index 6d632d989..6a76fc78f 100644 --- a/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract.go @@ -12,7 +12,7 @@ const Seat = "go-package-registry" // Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): // a reader of a value of another form says "form N, this reader knows M". -const Form = 1 +const Form = 2 // FormRegistry is the form of what the part registry adds. const FormRegistry = 1 @@ -20,8 +20,8 @@ const FormRegistry = 1 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "1 registry:1" - generatedFieldsDigest = "Artifact=79361e4ab1cd KeptEvent=ec3ef89ef8a7 Outcome=1e66f7bf6725 PublishAnswer=a0df0b922e1e PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 VersionsAnswer=47e11ca2aea9" + generatedForms = "2 registry:1" + generatedFieldsDigest = "Artifact=79361e4ab1cd KeptEvent=ec3ef89ef8a7 Outcome=1e66f7bf6725 PublishAnswer=1923c8239f6c PublishAnswerOtherBytes=06b1c9853343 PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 VersionsAnswer=47e11ca2aea9" ) const ( @@ -189,6 +189,14 @@ const ( PublishInputKindUpstream = "upstream" ) +// PublishAnswerOtherBytes is the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729). +type PublishAnswerOtherBytes struct { + // the digest the holder holds for that name and version + Digest string `json:"digest"` + // the fingerprint the holder keeps for it, absent where it keeps none + Fingerprint string `json:"fingerprint,omitempty"` +} + // PublishAnswer is what publish answers. type PublishAnswer struct { // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). @@ -197,6 +205,8 @@ type PublishAnswer struct { Held bool `json:"held,omitempty"` // the digests of the parts the holder lacks, to send by publish-part Lacks []string `json:"lacks,omitempty"` + // the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) + OtherBytes *PublishAnswerOtherBytes `json:"other-bytes,omitempty"` // the transfer Transfer string `json:"transfer"` } diff --git a/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract_test.go b/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract_test.go index e5f69ec1d..f4070dd6f 100644 --- a/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract_test.go @@ -37,6 +37,10 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v VersionsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "a tagged version sharing its digest with another tag is kept, not removed", subject: "", given: "{\"kept\":true,\"reason\":\"shared-digest\",\"removed\":false,\"tags\":[\"0.1.19\"]}", wire: "{\"kept\":true,\"reason\":\"shared-digest\",\"removed\":false,\"tags\":[\"0.1.19\"]}", decode: func(b []byte) (any, error) { var v RemoveAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "publish answers other-bytes: the name and version are held with another digest (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", + decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", + decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { v, err := c.decode([]byte(c.given)) diff --git a/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract.go b/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract.go index 594e71009..6bc9a77e2 100644 --- a/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract.go @@ -12,7 +12,7 @@ const Seat = "npm-package-registry" // Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): // a reader of a value of another form says "form N, this reader knows M". -const Form = 1 +const Form = 2 // FormRegistry is the form of what the part registry adds. const FormRegistry = 1 @@ -20,8 +20,8 @@ const FormRegistry = 1 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "1 registry:1" - generatedFieldsDigest = "Artifact=79361e4ab1cd KeptEvent=ec3ef89ef8a7 Outcome=1e66f7bf6725 PublishAnswer=a0df0b922e1e PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 VersionsAnswer=47e11ca2aea9" + generatedForms = "2 registry:1" + generatedFieldsDigest = "Artifact=79361e4ab1cd KeptEvent=ec3ef89ef8a7 Outcome=1e66f7bf6725 PublishAnswer=1923c8239f6c PublishAnswerOtherBytes=06b1c9853343 PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 VersionsAnswer=47e11ca2aea9" ) const ( @@ -189,6 +189,14 @@ const ( PublishInputKindUpstream = "upstream" ) +// PublishAnswerOtherBytes is the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729). +type PublishAnswerOtherBytes struct { + // the digest the holder holds for that name and version + Digest string `json:"digest"` + // the fingerprint the holder keeps for it, absent where it keeps none + Fingerprint string `json:"fingerprint,omitempty"` +} + // PublishAnswer is what publish answers. type PublishAnswer struct { // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). @@ -197,6 +205,8 @@ type PublishAnswer struct { Held bool `json:"held,omitempty"` // the digests of the parts the holder lacks, to send by publish-part Lacks []string `json:"lacks,omitempty"` + // the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) + OtherBytes *PublishAnswerOtherBytes `json:"other-bytes,omitempty"` // the transfer Transfer string `json:"transfer"` } diff --git a/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract_test.go b/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract_test.go index 3092b370e..eeccc2a3d 100644 --- a/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract_test.go @@ -37,6 +37,10 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v VersionsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "a tagged version sharing its digest with another tag is kept, not removed", subject: "", given: "{\"kept\":true,\"reason\":\"shared-digest\",\"removed\":false,\"tags\":[\"0.1.19\"]}", wire: "{\"kept\":true,\"reason\":\"shared-digest\",\"removed\":false,\"tags\":[\"0.1.19\"]}", decode: func(b []byte) (any, error) { var v RemoveAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "publish answers other-bytes: the name and version are held with another digest (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", + decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", + decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { v, err := c.decode([]byte(c.given)) diff --git a/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract.go b/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract.go index e327ef168..406be5b9c 100644 --- a/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract.go @@ -13,7 +13,7 @@ const Seat = "oci-artifact-registry" // Form is the form of the seat's values, events and answers this contract was generated at (design 47 H2 §780): // a reader of a value of another form says "form N, this reader knows M". -const Form = 2 +const Form = 3 // FormRegistry is the form of what the part registry adds. const FormRegistry = 1 @@ -21,8 +21,8 @@ const FormRegistry = 1 // The forms and the digest of the fields this contract was generated from: the generator's compare fails a definition // whose fields changed while its forms did not (design 47 H2 §780). const ( - generatedForms = "2 registry:1" - generatedFieldsDigest = "Artifact=79361e4ab1cd HeldEvent=b6d4c12500df Hold=c5a97a2f2d5a HoldAnswer=7d536ccb729f HoldsBySeatNameDigestValue=db093998a869 KeptEvent=ec3ef89ef8a7 ListAnswer=ffc9dd135c75 Listed=b9f1d1232e64 Outcome=1e66f7bf6725 PublishAnswer=a0df0b922e1e PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 ReleaseAnswer=d30bd6000a16 ReleasedEvent=b6d4c12500df RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 Repository=740e54e0b3b0 VersionsAnswer=47e11ca2aea9 WindowsByCallerValue=23d9294dde92 WindowsByCallerValueDroppedItem=d748f0e58825" + generatedForms = "3 registry:1" + generatedFieldsDigest = "Artifact=79361e4ab1cd HeldEvent=b6d4c12500df Hold=c5a97a2f2d5a HoldAnswer=7d536ccb729f HoldsBySeatNameDigestValue=db093998a869 KeptEvent=ec3ef89ef8a7 ListAnswer=ffc9dd135c75 Listed=b9f1d1232e64 Outcome=1e66f7bf6725 PublishAnswer=1923c8239f6c PublishAnswerOtherBytes=06b1c9853343 PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 ReleaseAnswer=d30bd6000a16 ReleasedEvent=b6d4c12500df RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 Repository=740e54e0b3b0 VersionsAnswer=47e11ca2aea9 WindowsByCallerValue=23d9294dde92 WindowsByCallerValueDroppedItem=d748f0e58825" ) const ( @@ -320,6 +320,14 @@ const ( PublishInputKindUpstream = "upstream" ) +// PublishAnswerOtherBytes is the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729). +type PublishAnswerOtherBytes struct { + // the digest the holder holds for that name and version + Digest string `json:"digest"` + // the fingerprint the holder keeps for it, absent where it keeps none + Fingerprint string `json:"fingerprint,omitempty"` +} + // PublishAnswer is what publish answers. type PublishAnswer struct { // is the form of what this value carries, left out while it is 1 (design 47 H2 §780). @@ -328,6 +336,8 @@ type PublishAnswer struct { Held bool `json:"held,omitempty"` // the digests of the parts the holder lacks, to send by publish-part Lacks []string `json:"lacks,omitempty"` + // the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) + OtherBytes *PublishAnswerOtherBytes `json:"other-bytes,omitempty"` // the transfer Transfer string `json:"transfer"` } diff --git a/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract_test.go b/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract_test.go index becff93af..e6cb547d3 100644 --- a/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract_test.go @@ -57,6 +57,10 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v ListInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "list answers a capped page with the cursor of the next", subject: "", given: "{\"capped\":true,\"next\":\"c-4183\",\"repositories\":[{\"manifests\":[{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"held\":false,\"index\":false,\"size\":4096}],\"name\":\"mail/files\"}],\"total\":3}", wire: "{\"capped\":true,\"next\":\"c-4183\",\"repositories\":[{\"manifests\":[{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"held\":false,\"index\":false,\"size\":4096}],\"name\":\"mail/files\"}],\"total\":3}", decode: func(b []byte) (any, error) { var v ListAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "publish answers other-bytes: the name and version are held with another digest (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", + decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", + decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { v, err := c.decode([]byte(c.given)) diff --git a/modules/mesh-delivery-contracts/parts/registry.json b/modules/mesh-delivery-contracts/parts/registry.json index 671d4b4d6..6d9b0c560 100644 --- a/modules/mesh-delivery-contracts/parts/registry.json +++ b/modules/mesh-delivery-contracts/parts/registry.json @@ -80,6 +80,23 @@ "held": { "type": "boolean", "description": "the digest is held already: nothing to send; the outcome follows as an event" + }, + "other-bytes": { + "type": "object", + "description": "the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729)", + "properties": { + "digest": { + "type": "string", + "description": "the digest the holder holds for that name and version" + }, + "fingerprint": { + "type": "string", + "description": "the fingerprint the holder keeps for it, absent where it keeps none" + } + }, + "required": [ + "digest" + ] } }, "required": [ diff --git a/modules/mesh-delivery-contracts/seats/container-image-registry/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/container-image-registry/fixtures/verbs.json index 1a5dc697c..e25c4ca38 100644 --- a/modules/mesh-delivery-contracts/seats/container-image-registry/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/container-image-registry/fixtures/verbs.json @@ -160,5 +160,26 @@ "given": { "reference": "container-image-registry/upstream/docker.io/library/nats@sha256:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" } + }, + { + "name": "publish answers other-bytes: the name and version are held with another digest (H-A-729)", + "of": "verb:publish.answer", + "given": { + "transfer": "", + "other-bytes": { + "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + "fingerprint": "src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" + } + } + }, + { + "name": "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", + "of": "verb:publish.answer", + "given": { + "transfer": "", + "other-bytes": { + "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" + } + } } ] diff --git a/modules/mesh-delivery-contracts/seats/container-image-registry/seat.json b/modules/mesh-delivery-contracts/seats/container-image-registry/seat.json index f3340b082..f56c8a38e 100644 --- a/modules/mesh-delivery-contracts/seats/container-image-registry/seat.json +++ b/modules/mesh-delivery-contracts/seats/container-image-registry/seat.json @@ -136,7 +136,7 @@ }, { "name": "hold", - "description": "Keep one untagged bundle, archive or copied base from removal by retention, as the artifact sweep's rules keep it (ADR 0617 \u00a72); never an image of the holder's own. Emits held.", + "description": "Keep one untagged bundle, archive or copied base from removal by retention, as the artifact sweep's rules keep it (ADR 0617 §2); never an image of the holder's own. Emits held.", "input": { "type": "object", "properties": { @@ -218,7 +218,7 @@ }, { "name": "list", - "description": "What the store holds of one repository, or of every repository the seat holds when none is named: every image manifest and index, each with its digest, whether it is an index (and the manifests an index names), the tags naming it, its size and whether it is held. Read from the store itself, so a manifest no tag names is listed too; it reads only (ADR 0632 \u00a73).", + "description": "What the store holds of one repository, or of every repository the seat holds when none is named: every image manifest and index, each with its digest, whether it is an index (and the manifests an index names), the tags naming it, its size and whether it is held. Read from the store itself, so a manifest no tag names is listed too; it reads only (ADR 0632 §3).", "input": { "type": "object", "properties": { @@ -500,5 +500,6 @@ } ] } - ] + ], + "form": 2 } diff --git a/modules/mesh-delivery-contracts/seats/go-package-registry/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/go-package-registry/fixtures/verbs.json index be6a53a30..2a23403bd 100644 --- a/modules/mesh-delivery-contracts/seats/go-package-registry/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/go-package-registry/fixtures/verbs.json @@ -106,5 +106,26 @@ "0.1.19" ] } + }, + { + "name": "publish answers other-bytes: the name and version are held with another digest (H-A-729)", + "of": "verb:publish.answer", + "given": { + "transfer": "", + "other-bytes": { + "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + "fingerprint": "src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" + } + } + }, + { + "name": "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", + "of": "verb:publish.answer", + "given": { + "transfer": "", + "other-bytes": { + "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" + } + } } ] diff --git a/modules/mesh-delivery-contracts/seats/go-package-registry/seat.json b/modules/mesh-delivery-contracts/seats/go-package-registry/seat.json index 9d426368b..4e026d065 100644 --- a/modules/mesh-delivery-contracts/seats/go-package-registry/seat.json +++ b/modules/mesh-delivery-contracts/seats/go-package-registry/seat.json @@ -31,5 +31,6 @@ "description": "form none: the Go module proxy's read side, answered anonymously, with no credential (design 51)" } } - ] + ], + "form": 2 } diff --git a/modules/mesh-delivery-contracts/seats/npm-package-registry/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/npm-package-registry/fixtures/verbs.json index 0b88f08e3..94cf68a84 100644 --- a/modules/mesh-delivery-contracts/seats/npm-package-registry/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/npm-package-registry/fixtures/verbs.json @@ -106,5 +106,26 @@ "0.1.19" ] } + }, + { + "name": "publish answers other-bytes: the name and version are held with another digest (H-A-729)", + "of": "verb:publish.answer", + "given": { + "transfer": "", + "other-bytes": { + "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + "fingerprint": "src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" + } + } + }, + { + "name": "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", + "of": "verb:publish.answer", + "given": { + "transfer": "", + "other-bytes": { + "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" + } + } } ] diff --git a/modules/mesh-delivery-contracts/seats/npm-package-registry/seat.json b/modules/mesh-delivery-contracts/seats/npm-package-registry/seat.json index ae2ab3db3..55d1096eb 100644 --- a/modules/mesh-delivery-contracts/seats/npm-package-registry/seat.json +++ b/modules/mesh-delivery-contracts/seats/npm-package-registry/seat.json @@ -31,5 +31,6 @@ "description": "form none: the npm registry's read side, answered anonymously, with no credential (design 51)" } } - ] + ], + "form": 2 } diff --git a/modules/mesh-delivery-contracts/seats/oci-artifact-registry/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/oci-artifact-registry/fixtures/verbs.json index ea035c6fb..b7c26ec76 100644 --- a/modules/mesh-delivery-contracts/seats/oci-artifact-registry/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/oci-artifact-registry/fixtures/verbs.json @@ -164,5 +164,26 @@ "total": 3, "next": "c-4183" } + }, + { + "name": "publish answers other-bytes: the name and version are held with another digest (H-A-729)", + "of": "verb:publish.answer", + "given": { + "transfer": "", + "other-bytes": { + "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + "fingerprint": "src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" + } + } + }, + { + "name": "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", + "of": "verb:publish.answer", + "given": { + "transfer": "", + "other-bytes": { + "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" + } + } } ] diff --git a/modules/mesh-delivery-contracts/seats/oci-artifact-registry/seat.json b/modules/mesh-delivery-contracts/seats/oci-artifact-registry/seat.json index 4dfaf4549..7f8e9639c 100644 --- a/modules/mesh-delivery-contracts/seats/oci-artifact-registry/seat.json +++ b/modules/mesh-delivery-contracts/seats/oci-artifact-registry/seat.json @@ -397,5 +397,5 @@ ] } ], - "form": 2 + "form": 3 } diff --git a/modules/mesh-delivery-contracts/ts/seats/containerimageregistry/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/containerimageregistry/index.d.ts index d8a639cfe..0796f0cfb 100644 --- a/modules/mesh-delivery-contracts/ts/seats/containerimageregistry/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/containerimageregistry/index.d.ts @@ -64,6 +64,7 @@ export type KeptEvent = registry.KeptEvent; export type Outcome = registry.Outcome; export type Part = registry.Part; export type PublishAnswer = registry.PublishAnswer; +export type PublishAnswerOtherBytes = registry.PublishAnswerOtherBytes; export type PublishInput = registry.PublishInput; export type PublishPartAnswer = registry.PublishPartAnswer; export type PublishPartInput = registry.PublishPartInput; diff --git a/modules/mesh-delivery-contracts/ts/seats/containerimageregistry/parts/registry.d.ts b/modules/mesh-delivery-contracts/ts/seats/containerimageregistry/parts/registry.d.ts index 9899be049..30792b93b 100644 --- a/modules/mesh-delivery-contracts/ts/seats/containerimageregistry/parts/registry.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/containerimageregistry/parts/registry.d.ts @@ -96,6 +96,14 @@ export interface PublishInput { "version"?: string; } +/** the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) */ +export interface PublishAnswerOtherBytes { + /** the digest the holder holds for that name and version */ + "digest": string; + /** the fingerprint the holder keeps for it, absent where it keeps none */ + "fingerprint"?: string; +} + /** is what publish answers. */ export interface PublishAnswer { /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ @@ -104,6 +112,8 @@ export interface PublishAnswer { "held"?: boolean; /** the digests of the parts the holder lacks, to send by publish-part */ "lacks"?: string[]; + /** the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) */ + "other-bytes"?: PublishAnswerOtherBytes; /** the transfer */ "transfer": string; } diff --git a/modules/mesh-delivery-contracts/ts/seats/gopackageregistry/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/gopackageregistry/index.d.ts index 2876e791a..36932c203 100644 --- a/modules/mesh-delivery-contracts/ts/seats/gopackageregistry/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/gopackageregistry/index.d.ts @@ -35,6 +35,7 @@ export type KeptEvent = registry.KeptEvent; export type Outcome = registry.Outcome; export type Part = registry.Part; export type PublishAnswer = registry.PublishAnswer; +export type PublishAnswerOtherBytes = registry.PublishAnswerOtherBytes; export type PublishInput = registry.PublishInput; export type PublishPartAnswer = registry.PublishPartAnswer; export type PublishPartInput = registry.PublishPartInput; diff --git a/modules/mesh-delivery-contracts/ts/seats/gopackageregistry/parts/registry.d.ts b/modules/mesh-delivery-contracts/ts/seats/gopackageregistry/parts/registry.d.ts index 9899be049..30792b93b 100644 --- a/modules/mesh-delivery-contracts/ts/seats/gopackageregistry/parts/registry.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/gopackageregistry/parts/registry.d.ts @@ -96,6 +96,14 @@ export interface PublishInput { "version"?: string; } +/** the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) */ +export interface PublishAnswerOtherBytes { + /** the digest the holder holds for that name and version */ + "digest": string; + /** the fingerprint the holder keeps for it, absent where it keeps none */ + "fingerprint"?: string; +} + /** is what publish answers. */ export interface PublishAnswer { /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ @@ -104,6 +112,8 @@ export interface PublishAnswer { "held"?: boolean; /** the digests of the parts the holder lacks, to send by publish-part */ "lacks"?: string[]; + /** the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) */ + "other-bytes"?: PublishAnswerOtherBytes; /** the transfer */ "transfer": string; } diff --git a/modules/mesh-delivery-contracts/ts/seats/npmpackageregistry/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/npmpackageregistry/index.d.ts index 93ef53029..10f90870f 100644 --- a/modules/mesh-delivery-contracts/ts/seats/npmpackageregistry/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/npmpackageregistry/index.d.ts @@ -35,6 +35,7 @@ export type KeptEvent = registry.KeptEvent; export type Outcome = registry.Outcome; export type Part = registry.Part; export type PublishAnswer = registry.PublishAnswer; +export type PublishAnswerOtherBytes = registry.PublishAnswerOtherBytes; export type PublishInput = registry.PublishInput; export type PublishPartAnswer = registry.PublishPartAnswer; export type PublishPartInput = registry.PublishPartInput; diff --git a/modules/mesh-delivery-contracts/ts/seats/npmpackageregistry/parts/registry.d.ts b/modules/mesh-delivery-contracts/ts/seats/npmpackageregistry/parts/registry.d.ts index 9899be049..30792b93b 100644 --- a/modules/mesh-delivery-contracts/ts/seats/npmpackageregistry/parts/registry.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/npmpackageregistry/parts/registry.d.ts @@ -96,6 +96,14 @@ export interface PublishInput { "version"?: string; } +/** the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) */ +export interface PublishAnswerOtherBytes { + /** the digest the holder holds for that name and version */ + "digest": string; + /** the fingerprint the holder keeps for it, absent where it keeps none */ + "fingerprint"?: string; +} + /** is what publish answers. */ export interface PublishAnswer { /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ @@ -104,6 +112,8 @@ export interface PublishAnswer { "held"?: boolean; /** the digests of the parts the holder lacks, to send by publish-part */ "lacks"?: string[]; + /** the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) */ + "other-bytes"?: PublishAnswerOtherBytes; /** the transfer */ "transfer": string; } diff --git a/modules/mesh-delivery-contracts/ts/seats/ociartifactregistry/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/ociartifactregistry/index.d.ts index 099d9bfa1..6484b0b0d 100644 --- a/modules/mesh-delivery-contracts/ts/seats/ociartifactregistry/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/ociartifactregistry/index.d.ts @@ -61,6 +61,7 @@ export type KeptEvent = registry.KeptEvent; export type Outcome = registry.Outcome; export type Part = registry.Part; export type PublishAnswer = registry.PublishAnswer; +export type PublishAnswerOtherBytes = registry.PublishAnswerOtherBytes; export type PublishInput = registry.PublishInput; export type PublishPartAnswer = registry.PublishPartAnswer; export type PublishPartInput = registry.PublishPartInput; diff --git a/modules/mesh-delivery-contracts/ts/seats/ociartifactregistry/parts/registry.d.ts b/modules/mesh-delivery-contracts/ts/seats/ociartifactregistry/parts/registry.d.ts index 9899be049..30792b93b 100644 --- a/modules/mesh-delivery-contracts/ts/seats/ociartifactregistry/parts/registry.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/ociartifactregistry/parts/registry.d.ts @@ -96,6 +96,14 @@ export interface PublishInput { "version"?: string; } +/** the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) */ +export interface PublishAnswerOtherBytes { + /** the digest the holder holds for that name and version */ + "digest": string; + /** the fingerprint the holder keeps for it, absent where it keeps none */ + "fingerprint"?: string; +} + /** is what publish answers. */ export interface PublishAnswer { /** is the form of what this value carries, left out while it is 1 (design 47 H2 §780). */ @@ -104,6 +112,8 @@ export interface PublishAnswer { "held"?: boolean; /** the digests of the parts the holder lacks, to send by publish-part */ "lacks"?: string[]; + /** the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) */ + "other-bytes"?: PublishAnswerOtherBytes; /** the transfer */ "transfer": string; } From 152af6dd2915916c7d4d92199492e455bdf39212 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:15:26 +0100 Subject: [PATCH 031/141] R2 snapshot-purge-grant: a ledger account's composition names the purge of each ledger's snapshot store and history Builds: design 47 H2 H-A-693, H-A-712 (1), H-A-717 (DQ-47); row R2 --- .../internal/buscompose/buscompose_test.go | 8 +++++++- .../mesh-grants/internal/buscompose/ledger.go | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/mesh-grants/internal/buscompose/buscompose_test.go b/modules/mesh-grants/internal/buscompose/buscompose_test.go index c78a43f1a..c52b5fb52 100644 --- a/modules/mesh-grants/internal/buscompose/buscompose_test.go +++ b/modules/mesh-grants/internal/buscompose/buscompose_test.go @@ -1130,8 +1130,12 @@ func aLedgerIsWrittenByItsLedgerAccountAlone(t *testing.T) { if got := ledgers(assigned("a")); !slices.Equal(got, []string{"ledger.a.m"}) { t.Fatalf("after m left b: ledger accounts %v, want ledger.a.m alone", got) } + // H-A-693, H-A-717 (DQ-47): beside its publishes, the account holds the purge request of each ledger's snapshot store and of + // its history stream, its answer on its own inbox. want := []string{"mesh.ledger.m.audit.history.>", "mesh.ledger.m.audit.snapshot.>", - "mesh.ledger.m.records.history.>", "mesh.ledger.m.records.snapshot.>"} + "mesh.ledger.m.records.history.>", "mesh.ledger.m.records.snapshot.>", + "$JS.API.STREAM.PURGE.m_audit", "$JS.API.STREAM.PURGE.m_audit_snapshot", + "$JS.API.STREAM.PURGE.m_records", "$JS.API.STREAM.PURGE.m_records_snapshot"} raw := []string{"mesh.ledger.m.records.history.decision/0290", "mesh.ledger.m.records.snapshot.decision/0290"} for _, p := range both { perms, err := PermissionsFor(p) @@ -1141,6 +1145,8 @@ func aLedgerIsWrittenByItsLedgerAccountAlone(t *testing.T) { if p.Kind == KindLedger { if !slices.Equal(perms.Publish, want) || len(perms.PublishDeny) != 0 { t.Errorf("%s may publish %v, want %v alone", p.Username(), perms.Publish, want) + } else if !slices.Equal(perms.Subscribe, []string{p.inbox()}) { + t.Errorf("%s hears %v, want its own inbox %s for the purge's answer", p.Username(), perms.Subscribe, p.inbox()) } continue } diff --git a/modules/mesh-grants/internal/buscompose/ledger.go b/modules/mesh-grants/internal/buscompose/ledger.go index c34119e42..4d1ca1f83 100644 --- a/modules/mesh-grants/internal/buscompose/ledger.go +++ b/modules/mesh-grants/internal/buscompose/ledger.go @@ -29,6 +29,20 @@ func LedgerPublishGrants(module string, locals []string) []string { return out } +// LedgerPurgeGrants are the purge requests a module's ledger account is granted, beside its publishes: of each ledger's snapshot +// store `__snapshot` and of its history stream `_`, one subject each; the answer comes on the +// account's own inbox (design 47 H2 H-A-693, H-A-717 (DQ-47): the tool runner's purge of a snapshot, and of a history, are the +// account's own grants). Sorted. +func LedgerPurgeGrants(module string, locals []string) []string { + var out []string + for _, local := range locals { + stream := module + "_" + local + out = append(out, "$JS.API.STREAM.PURGE."+stream, "$JS.API.STREAM.PURGE."+stream+"_snapshot") + } + sort.Strings(out) + return out +} + // writesLedger is a module's ledger account publishing on that module's own ledgers' histories and snapshots, and no other // principal (ADR 0597 §9). func writesLedger(p Principal, pattern string) bool { @@ -53,5 +67,5 @@ func ledgerPermissions(p Principal) (Permissions, error) { if err := CheckWriters(p, pub); err != nil { return Permissions{}, err } - return Permissions{Publish: pub, Subscribe: []string{p.inbox()}}, nil + return Permissions{Publish: append(slices.Clone(pub), LedgerPurgeGrants(p.Module, p.Ledgers)...), Subscribe: []string{p.inbox()}}, nil } From 9f09149362362e6112c41403291d86026d784482 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:15:54 +0100 Subject: [PATCH 032/141] B13 upstream-filled: the republisher's read of the entry fills a reservation's upstream once by compare-and-set Builds: design 47 H2 H-A-656, H-A-486 --- .../internal/versions/republish.go | 27 +++++++++++++++++++ .../internal/versions/republish_test.go | 21 +++++++++++++++ .../internal/versions/reserve.go | 26 ++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/modules/mesh-delivery-builder/internal/versions/republish.go b/modules/mesh-delivery-builder/internal/versions/republish.go index e187976d0..2610d9694 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish.go +++ b/modules/mesh-delivery-builder/internal/versions/republish.go @@ -354,6 +354,7 @@ func (r *Republisher) queue(ctx context.Context, vs []ReservedVersion, holdersOf errs = append(errs, fmt.Errorf("the catalog entry %s of %s %s cannot be read: %w", v.Fingerprint, v.Module, v.Version, err)) continue } + v = r.fillUpstream(ctx, v, e) byHolder := map[string]map[string]string{} for _, ref := range v.Missing() { if _, no := v.Unstored[ref]; no { @@ -735,6 +736,7 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate r.say(ctx, v, words) return SendFate{Failed: words} } + v = r.fillUpstream(ctx, v, e) missing := map[string]bool{} for _, ref := range v.Missing() { missing[ref] = true @@ -793,6 +795,31 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate return SendFate{Sent: true} } +// fillUpstream fills the reservation's `upstream` from the catalog entry at its fingerprint, once, by compare-and-set, so every reader +// of the reservation agrees which of its artifacts a registry never publishes (design 47 H2 H-A-656, amending H-A-486's addendum); +// the reservation as it stands is answered, and a write that fails is said and v answered as it was read. +func (r *Republisher) fillUpstream(ctx context.Context, v ReservedVersion, e meshcatalog.CatalogEntry) ReservedVersion { + if len(v.Upstream) > 0 { + return v + } + var refs []string + for _, a := range e.Artifacts { + if _, in := v.Artifacts[a.Ref]; in && a.Kind == "upstream" { + refs = append(refs, a.Ref) + } + } + if len(refs) == 0 { + return v + } + got, err := r.Reserved.FillUpstream(ctx, v.Module, v.Version, refs) + if err != nil { + r.logf("%s %s: its upstream artifacts %v are not written on the reservation: %v", v.Module, v.Version, refs, err) + v.Upstream = refs + return v + } + return got +} + // publishTarget is the registry seat, the name and the kind module's artifact ref is published as, from its catalog entry; ok is // false when the entry names no registry seat for it. func publishTarget(e meshcatalog.CatalogEntry, module, ref string) (seat, name, kind string, ok bool) { diff --git a/modules/mesh-delivery-builder/internal/versions/republish_test.go b/modules/mesh-delivery-builder/internal/versions/republish_test.go index de818237b..420572730 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish_test.go +++ b/modules/mesh-delivery-builder/internal/versions/republish_test.go @@ -163,6 +163,27 @@ func TestRepublish(t *testing.T) { t.Errorf("sent %d, said %v: want one try and one saying of not stored", len(b.sent), b.said) } }) + t.Run("a reservation with no upstream gets it from the entry once", func(t *testing.T) { + // design 47 H2 H-A-656: the republisher's read of the entry fills the reservation's upstream by compare-and-set, so the + // artifact a registry never publishes is no missing one and no entry "names no registry seat" for it + b := newRepublishBed(t) + v := b.reserve(t, "m") + entry := b.Entry + b.Entry = func(ctx context.Context, fp string) (meshcatalog.CatalogEntry, error) { + e, err := entry(ctx, fp) + e.Artifacts = append(e.Artifacts, meshcatalog.Artifact{Ref: "m:up", Kind: "upstream"}) + return e, err + } + if _, _, err := b.Reserved.Built(ctx, "m", v.Version, map[string]string{"m:up": "sha256:cc"}, nil); err != nil { + t.Fatal(err) + } + b.holders = map[string][]string{SeatArtifacts: {"oci"}} + b.SendQueued(ctx, b.queueAt(v, PublishClassLive, b.now)) + cur, _, _ := b.Reserved.At(ctx, ReservedKey("m", "0.1")) + if !slices.Equal(cur.Upstream, []string{"m:up"}) || slices.Contains(cur.Missing(), "m:up") { + t.Errorf("the reservation's upstream is %v, missing %v; want m:up filled once and not missing", cur.Upstream, cur.Missing()) + } + }) t.Run("the first artifact refused as not stored starts the build again once", func(t *testing.T) { // design 47 H2 H-A-662, H-A-703: one start per reservation, whatever number of its artifacts are refused b := newRepublishBed(t) diff --git a/modules/mesh-delivery-builder/internal/versions/reserve.go b/modules/mesh-delivery-builder/internal/versions/reserve.go index d1879318c..b9d10005c 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve.go @@ -505,6 +505,32 @@ func (r *Reserver) MarkHeld(ctx context.Context, module, version string, held [] } } +// FillUpstream writes the artifacts of kind upstream on module's reservation of version when it names none, once, by +// compare-and-set (design 47 H2 H-A-656); it answers the reservation as it stands (one that names some, or stands at another +// version, is answered unchanged). +func (r *Reserver) FillUpstream(ctx context.Context, module, version string, refs []string) (ReservedVersion, error) { + series, _, err := SplitVersion(version) + if err != nil { + return ReservedVersion{}, err + } + key := ReservedKey(module, series) + for { + cur, rev, found, err := r.get(ctx, key) + if err != nil || !found || cur.Version != version || len(cur.Upstream) > 0 { + return cur, err + } + cur.Upstream = slices.Clone(refs) + sort.Strings(cur.Upstream) + raw, _ := json.Marshal(cur) + if _, err := r.Store.Update(ctx, key, raw, rev); errors.Is(err, ErrConflict) { + continue + } else if err != nil { + return ReservedVersion{}, fmt.Errorf("%s cannot be written: %w", key, err) + } + return cur, nil + } +} + // DefaultReleasedKept is the setting released-kept unless set (design 47 G A-456b). const DefaultReleasedKept = 16 From 9dfc0dc4ccb8e5db8d22ca1df368bda8acfa14a4 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:16:05 +0100 Subject: [PATCH 033/141] F1 held-act-said-again: an act performed, heard again, says its kept outcome once more and calls the forge not at all Builds: design 47 H2 H-A-712 (3), H-A-717 (DQ-48); row F1 --- .../mesh-delivery-forge-bridge/gate_test.go | 30 +++++++++++++++++-- .../integration_test.go | 4 +++ .../cmd/mesh-delivery-forge-bridge/owed.go | 27 ++++++++++++----- 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/gate_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/gate_test.go index b324f7b95..6e263dd80 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/gate_test.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/gate_test.go @@ -168,6 +168,32 @@ func TestWhatIsOwedIsPerformedSaidAndKept(t *testing.T) { } } + // Design 47 H2 H-A-712 (3), DQ-48: an act performed that is heard again says its kept outcome once more as owed.ended, its `at` the + // time it was performed, calls the seat git not at all and writes performed not again. + t.Run("an act performed, heard again", func(t *testing.T) { + f := &seatFake{answers: statusOK} + o, pub, kept := newOwing(f) + first, err := o.heard(context.Background(), seat.Seat, gate("owed is said, a status"), nil) + if err != nil || first.Outcome != forgemsg.OwedPerformed || len(f.calls) != 1 || len(pub.data) != 1 { + t.Fatalf("the first hearing: %+v %v, called %v, said %d", first, err, f.calls, len(pub.data)) + } + performedAt, key := first.At, performedKey(seat.Seat, first.ID) + stored := string(kept[key]) + later := performedAt.Add(time.Hour) + o.now = func() time.Time { return later } + again, err := o.heard(context.Background(), seat.Seat, gate("owed is said, a status"), nil) + if err != nil || again.Outcome != forgemsg.OwedPerformed || len(f.calls) != 1 || len(pub.data) != 2 { + t.Fatalf("heard again: %+v %v, called %v, said %d; want its outcome said once more and the seat git not called", again, err, f.calls, len(pub.data)) + } + e, err := forgemsg.DecodeOwedEnded(pub.data[1]) + if err != nil || e.ID != first.ID || e.Outcome != forgemsg.OwedPerformed || !e.At.Equal(performedAt) { + t.Errorf("said again as %+v %v, want the outcome kept, at %s", e, err, performedAt) + } + if string(kept[key]) != stored { + t.Errorf("performed was written again: %s, was %s", kept[key], stored) + } + }) + // Design 47 H2 §807, §775: an act met by the seat git's away is called again at the kept-call pace, its pull request // read before each try, and performed when the forge answers; one away past owed-away-bound ends could not be // performed, naming every try. @@ -224,8 +250,8 @@ func TestWhatIsOwedIsPerformedSaidAndKept(t *testing.T) { o.hear(context.Background(), seat.Seat, m) again := &fakeMsg{subject: m.subject, data: m.data} o.hear(context.Background(), seat.Seat, again) - if m.acked != 1 || again.acked != 1 || len(f.calls) != 1 || len(pub.data) != 1 { - t.Errorf("an act said twice: acked %d and %d, called %v, said %d; want performed and said once, both acknowledged", + if m.acked != 1 || again.acked != 1 || len(f.calls) != 1 || len(pub.data) != 2 { + t.Errorf("an act said twice: acked %d and %d, called %v, said %d; want performed once, its outcome said twice (H-A-712 (3)), both acknowledged", m.acked, again.acked, f.calls, len(pub.data)) } pub.err = errors.New("no responders") diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/integration_test.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/integration_test.go index 06009b7da..3551102c2 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/integration_test.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/integration_test.go @@ -601,6 +601,10 @@ func TestBridgePerformsWhatIsOwedOnce(t *testing.T) { if e := ended(); e.Outcome != forgemsg.OwedPerformed || e.Of != seat.Seat { t.Errorf("the gate's status: %+v, want performed", e) } + // H-A-712 (3), DMC-17: the act said twice is performed once, and its kept outcome is said once more, before the undecodable one. + if e := ended(); e.Outcome != forgemsg.OwedPerformed || e.Of != seat.Seat { + t.Errorf("the gate's status said again: %+v, want its performed outcome once more", e) + } if _, err := b.js.Publish(b.ctx, subject, []byte("{")); err != nil { t.Fatal(err) } diff --git a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/owed.go b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/owed.go index 8a999ed9f..c7f9e74c3 100644 --- a/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/owed.go +++ b/modules/mesh-delivery-forge-bridge/cmd/mesh-delivery-forge-bridge/owed.go @@ -105,7 +105,12 @@ func (o *owing) heard(ctx context.Context, of string, data []byte, tried func()) return forgemsg.OwedEnded{Of: c.Of, ID: c.ID}, fmt.Errorf("the bridge %s", w) } if o.held(ctx, c.Of, c.ID) { - // said twice, or said again while its outcome was on its way: performed once, the outcome said once + // Said twice, or said again at the gate's start: performed once, nothing done at the forge, and the outcome kept + // here said once more as owed.ended, so the gate ends an act it still holds (design 47 H2 H-A-712 (3), DQ-48). Its + // `at` is the time it was performed, and performed is not written again. + if p, err := o.kept(ctx, c.Of, c.ID); err == nil && p.Ended.ID == c.ID { + return p.Ended, o.say(ctx, p.Ended) + } return forgemsg.OwedEnded{Of: c.Of, ID: c.ID}, nil } return o.perform(ctx, c, tried) @@ -202,12 +207,8 @@ func (o *owing) closed(ctx context.Context, c bridge.OwedCall) (string, error) { // which changes nothing at the forge. func (o *owing) end(ctx context.Context, e forgemsg.OwedEnded, c bridge.OwedCall) (forgemsg.OwedEnded, error) { e.At = o.now().UTC() - data, err := forgemsg.EncodeOwedEnded(e) - if err != nil { - return e, fmt.Errorf("the outcome of the owed %s cannot be said: %w", e.ID, err) - } - if _, err := o.pub.Publish(ctx, forgeSubject(forgemsg.OwedEndedEvent), data); err != nil { - return e, fmt.Errorf("the outcome %s of the owed %s could not be said on the stream forge: %w", e.Outcome, e.ID, err) + if err := o.say(ctx, e); err != nil { + return e, err } if e.ID == "" { return e, nil // an undecodable act with no id is said, and has no key to keep @@ -222,6 +223,18 @@ func (o *owing) end(ctx context.Context, e forgemsg.OwedEnded, c bridge.OwedCall return e, nil } +// say publishes an act's outcome as owed.ended on the stream forge, as it stands (its `at` untouched). +func (o *owing) say(ctx context.Context, e forgemsg.OwedEnded) error { + data, err := forgemsg.EncodeOwedEnded(e) + if err != nil { + return fmt.Errorf("the outcome of the owed %s cannot be said: %w", e.ID, err) + } + if _, err := o.pub.Publish(ctx, forgeSubject(forgemsg.OwedEndedEvent), data); err != nil { + return fmt.Errorf("the outcome %s of the owed %s could not be said on the stream forge: %w", e.Outcome, e.ID, err) + } + return nil +} + // held says whether performed holds an outcome of the act already. One that cannot be read is not held: the act is // performed again, which changes nothing at the forge. func (o *owing) held(ctx context.Context, of, id string) bool { From d8f0d4b1fbaf31a1784a0d5e81842d4318d3c02f Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:16:29 +0100 Subject: [PATCH 034/141] V1 view-rows-carry-fingerprint: the tiered page reads module, tier, fingerprint and version from the rows Builds: design 47 H2 H-A-709 (1), H-A-730; row V1 --- .../mesh-delivery-view/internal/view/pipelines_test.go | 9 ++++----- modules/mesh-delivery-view/internal/view/pipelineview.go | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/mesh-delivery-view/internal/view/pipelines_test.go b/modules/mesh-delivery-view/internal/view/pipelines_test.go index 52270fa42..b89effce1 100644 --- a/modules/mesh-delivery-view/internal/view/pipelines_test.go +++ b/modules/mesh-delivery-view/internal/view/pipelines_test.go @@ -116,11 +116,10 @@ func TestThePipelinesPage(t *testing.T) { taken := t0.Add(160e9) // a build node took the step 2m40s after its ask, and it ran 20s (design 47 H2 H-A-516) runner := &fakeRunner{rows: map[string][]seat.PipelineRow{}, shows: map[string]seat.ShowAnswer{ "main.12": {Pipeline: seat.Pipeline{Pipeline: "main.12", Branch: "main", Source: 9, Revision: 12, Outcome: seat.PipelineOutcomeFailed, - Started: &started, Ended: &ended, Movers: []seat.Mover{{Module: "alpha", Fingerprint: fpA, Version: "0.1.4", Tier: 1}, - {Module: "beta", Fingerprint: fpB, Tier: 2}, {Module: "gamma", Fingerprint: fpNew, Tier: 2}, {Module: "delta", Fingerprint: fpOld}}}, - Movers: []seat.MoverRow{{Module: "alpha", Outcome: seat.MoverRowOutcomePassed}, - {Module: "beta", Outcome: seat.MoverRowOutcomeFailed, Failed: &seat.FailedStep{Step: "unit", Artifact: "beta:program", Outcome: "could not run", Why: "no build node"}}, - {Module: "gamma", Outcome: seat.MoverRowOutcomePassed}, {Module: "delta", Outcome: seat.MoverRowOutcomePassed}}}, + Started: &started, Ended: &ended, Movers: []seat.Mover{{Module: "alpha"}, {Module: "beta"}, {Module: "gamma"}, {Module: "delta"}}}, // the module filter reads these; the page reads only the rows (H-A-709 (1), H-A-730) + Movers: []seat.MoverRow{{Module: "alpha", Fingerprint: fpA, Version: "0.1.4", Tier: 1, Outcome: seat.MoverRowOutcomePassed}, + {Module: "beta", Fingerprint: fpB, Tier: 2, Outcome: seat.MoverRowOutcomeFailed, Failed: &seat.FailedStep{Step: "unit", Artifact: "beta:program", Outcome: "could not run", Why: "no build node"}}, + {Module: "gamma", Fingerprint: fpNew, Tier: 2, Outcome: seat.MoverRowOutcomePassed}, {Module: "delta", Fingerprint: fpOld, Outcome: seat.MoverRowOutcomePassed}}}, "main.12/beta": {Pipeline: seat.Pipeline{Pipeline: "main.12", Branch: "main", Source: 9, Revision: 12, Outcome: seat.PipelineOutcomeFailed, Steps: []seat.StepResult{{Module: "beta", Step: "unit", Artifact: "beta:program", Seat: "node-build-go", Node: "n1", Outcome: "could not run", AskedAt: &started, Started: &started, TakenAt: &taken, Ended: &ended, Why: "no build node"}, {Module: "beta", Step: "lint", Artifact: "beta:program", Seat: "node-build-go", Outcome: "could not run", AskedAt: &started, Ended: &ended}}}}, diff --git a/modules/mesh-delivery-view/internal/view/pipelineview.go b/modules/mesh-delivery-view/internal/view/pipelineview.go index c193bde01..81419f353 100644 --- a/modules/mesh-delivery-view/internal/view/pipelineview.go +++ b/modules/mesh-delivery-view/internal/view/pipelineview.go @@ -249,7 +249,7 @@ func (m *Model) PipelineView(p *Pipelines, a seat.ShowAnswer) (PipelineView, err return PipelineView{}, err } pl := a.Pipeline - v := PipelineView{Pipeline: pl.Pipeline, Branch: pl.Branch, Outcome: pl.Outcome, Why: pl.Why, Movers: len(pl.Movers), Nodes: []string{}, Tiers: []PipelineTier{}} + v := PipelineView{Pipeline: pl.Pipeline, Branch: pl.Branch, Outcome: pl.Outcome, Why: pl.Why, Movers: len(rows), Nodes: []string{}, Tiers: []PipelineTier{}} outcome := map[string]string{} for _, r := range rows { outcome[r.Module] = r.Outcome @@ -279,7 +279,7 @@ func (m *Model) PipelineView(p *Pipelines, a seat.ShowAnswer) (PipelineView, err } } nodes := map[string]bool{} - for _, mv := range pl.Movers { + for _, mv := range rows { for _, n := range placedOn[mv.Module] { nodes[n] = true } @@ -287,7 +287,7 @@ func (m *Model) PipelineView(p *Pipelines, a seat.ShowAnswer) (PipelineView, err v.Nodes = slices.Sorted(maps.Keys(nodes)) now := time.Now() tiers := map[int64][]MoverStage{} - for _, mv := range pl.Movers { + for _, mv := range rows { row := MoverStage{Module: mv.Module, Fingerprint: mv.Fingerprint, Version: mv.Version, Outcome: outcome[mv.Module]} for _, s := range Stages { row.Stages = append(row.Stages, stageCell(steps[s.Step][mv.Module], now)) From b79b3a63007aa4b6e6908ba6c0020231c48a5ead Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:16:49 +0100 Subject: [PATCH 035/141] B15 superseded-names-its-revision: a superseded end with no revision heard is could-not-run, never superseded with a zero Builds: design 47 H2 H-A-650, H-A-561 --- .../internal/build/step.go | 5 +++ .../internal/build/step_test.go | 43 +++++++++++++++++-- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/modules/mesh-delivery-builder/internal/build/step.go b/modules/mesh-delivery-builder/internal/build/step.go index 6b2031979..d8240a309 100644 --- a/modules/mesh-delivery-builder/internal/build/step.go +++ b/modules/mesh-delivery-builder/internal/build/step.go @@ -32,6 +32,11 @@ func (b *Builder) BuildStep(ctx context.Context, ask string, run meshbuilds.Step if d := DroppedOf(ctx); d != nil { outcome, said = meshbuilds.StepEndedOutcomeCouldNotRun, d.Error() } + // A superseded end names the revision of the entry that supersedes it (H-A-561); where the builder heard none, it ends the + // step could-not-run itself, naming that, never superseded with a zero revision (design 47 H2 H-A-650). + if outcome == meshbuilds.StepEndedOutcomeSuperseded && end.Revision <= 0 { + outcome, said = meshbuilds.StepEndedOutcomeCouldNotRun, "superseded by a newer entry, but the builder heard no superseding revision for it to name: "+said + } at := b.now() end.Ended, end.Outcome, end.Said = &at, outcome, said if outcome != meshbuilds.StepEndedOutcomeSuperseded { diff --git a/modules/mesh-delivery-builder/internal/build/step_test.go b/modules/mesh-delivery-builder/internal/build/step_test.go index 6081f7558..3ffced765 100644 --- a/modules/mesh-delivery-builder/internal/build/step_test.go +++ b/modules/mesh-delivery-builder/internal/build/step_test.go @@ -158,7 +158,7 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T) if err != nil { t.Fatal(err) } - r.b.Module(t.Context(), "m", newer) + hearAtRevision(t, r.b, "m", newer, 9) r.b.Wait() } r.b.Reserved = res @@ -182,6 +182,7 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T) }) } t.Run("H-A-508: built now, superseded: a newer entry heard while the build runs ends the step superseded", aNewerEntryWhileTheBuildRunsSupersedesTheStep) + t.Run("H-A-650: a superseded end the builder knows no revision for is could-not-run, never superseded with a zero", aSupersededEndWithNoRevisionIsCouldNotRun) t.Run("H-A-155: an ask waits for the picture to take its revision in, then builds with its version reserved", aStepAskWaitsForItsRevision) t.Run("H-A-155: past the bound the ask fails naming its revision, and nothing is built", aStepAskPastItsRevisionBoundFails) t.Run("H-A-205: an ask of a revision below the picture's newest is read by number and built", anOlderKeptRevisionIsReadByNumber) @@ -495,7 +496,7 @@ func anOlderKeptRevisionIsReadByNumber(t *testing.T) { return 45, map[string]string{"m": fp1}, nil } entryn.Fp = fp2 - rn.b.Entry(context.Background(), Origin{Branch: "main", Source: 46, First: true}, entryn) + rn.b.Entry(context.Background(), Origin{Branch: "main", Source: 46, Revision: 48, First: true}, entryn) rn.b.Wait() if endn := rn.b.BuildStep(t.Context(), "a1", run); endn.Outcome != meshbuilds.StepEndedOutcomeSuperseded || !strings.Contains(endn.Said, "superseded by "+fp2) { t.Errorf("the older ask after the newer entry: end = %+v; want superseded by %s", endn, fp2) @@ -724,7 +725,7 @@ func aNewerEntryWhileTheBuildRunsSupersedesTheStep(t *testing.T) { if err != nil { t.Fatal(err) } - r.b.Module(t.Context(), "m", newer) + hearAtRevision(t, r.b, "m", newer, 9) var end meshbuilds.StepEnded select { case end = <-ended: @@ -739,3 +740,39 @@ func aNewerEntryWhileTheBuildRunsSupersedesTheStep(t *testing.T) { t.Errorf("end = %+v, want superseded by %s", end, fp2) } } + +// hearAtRevision takes a module's value in as the picture hears an entry of catalog revision rev on the first branch, so a step it +// supersedes names that revision (design 47 H H-A-561; H2 H-A-650: none heard is no superseded end). +func hearAtRevision(t *testing.T, b *Builder, module string, value []byte, rev int64) { + t.Helper() + m, err := meshcatalogclient.DecodeModule(value) + if err != nil { + t.Fatal(err) + } + b.init() + b.take(t.Context(), Origin{First: true, Revision: rev}, module, m, nil) + b.Wait() +} + +func aSupersededEndWithNoRevisionIsCouldNotRun(t *testing.T) { + r := newRig(t, goBundle) + r.mf.byDigest[mdigest('a')] = catalogue.Manifest{Module: "m", Version: "0.1", Build: &catalogue.Build{Artifacts: []catalogue.Artifact{goBundle}}} + if v := r.consider(t, "modules/m"); v.State != builds.BuildDone { + t.Fatalf("build = %+v, want done", v) + } + newer, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20", + Fp2: fp2, Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(agreedToolchains)}) + if err != nil { + t.Fatal(err) + } + r.b.Module(t.Context(), "m", newer) // heard with no catalog revision + r.b.Wait() + r.b.Reserved = &fakeReservations{} + r.b.StepEntry = func(context.Context, string) (meshcatalog.CatalogEntry, error) { + return meshcatalog.CatalogEntry{Module: "m", Repository: "novox/m", Commit: "c1", Fp: fp1, ManifestDigest: digestOf(false), Path: "modules/m"}, nil + } + end := r.b.BuildStep(t.Context(), "a1", meshbuilds.StepRun{Pipeline: "main.1.m", Step: meshbuilds.StepRunStepBuild, Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}}) + if end.Outcome != meshbuilds.StepEndedOutcomeCouldNotRun || end.Revision != 0 || !strings.Contains(end.Said, "no superseding revision") { + t.Errorf("end = %+v, want could not run naming that no superseding revision was heard", end) + } +} From c0b3fc41384ee8417a3365d06e574d9fac7854c1 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:17:14 +0100 Subject: [PATCH 036/141] B4 (2): a version a registry holds with other bytes ends the publish item at once, spending no try Builds: design 47 H2 H-A-590 (2), H-A-589 (1), H-A-729, H-A-732 --- .../cmd/mesh-delivery-builder/republish.go | 5 ++++ .../internal/versions/republish.go | 24 +++++++++++++++++++ .../internal/versions/republish_test.go | 16 ++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/republish.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/republish.go index f53a17617..034e6b461 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/republish.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/republish.go @@ -62,6 +62,11 @@ func sendVia(call keptCaller) func(ctx context.Context, p versions.Publish) erro if err := json.Unmarshal(raw, &a); err != nil { return fmt.Errorf("%s answered what is no publish answer: %w", p.Seat, err) } + // A version held with other bytes is answered, never failed (design 47 H2 H-A-729); it is read before the transfer, which is + // absent exactly then (H-A-732). + if a.OtherBytes != nil { + return &versions.OtherBytes{Seat: p.Seat, Name: p.Name, Version: p.Version, Digest: a.OtherBytes.Digest, Fingerprint: a.OtherBytes.Fingerprint} + } if len(a.Lacks) > 0 { return fmt.Errorf("%s%s holds %d of the parts of %s %s", versions.NotStoredWords, p.Seat, len(a.Lacks), p.Name, p.Version) } diff --git a/modules/mesh-delivery-builder/internal/versions/republish.go b/modules/mesh-delivery-builder/internal/versions/republish.go index 2610d9694..ef16d4f81 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish.go +++ b/modules/mesh-delivery-builder/internal/versions/republish.go @@ -137,6 +137,21 @@ type Acted struct { Sequence uint64 `json:"sequence"` } +// OtherBytes is a holder's answer to a publish of a version it holds with other bytes (design 47 H2 H-A-589 (1), H-A-729): the +// digest, and the fingerprint it keeps for the version, empty where none is kept. It is an error of Send, which the publish item +// ends at, never as a refusal asked again: the build again of the fingerprint then takes the next free number (H-A-590 (1)). +type OtherBytes struct { + Seat, Name, Version, Digest, Fingerprint string +} + +func (o *OtherBytes) Error() string { + w := fmt.Sprintf("%s holds %s %s with other bytes: digest %s", o.Seat, o.Name, o.Version, o.Digest) + if o.Fingerprint != "" { + w += ", fingerprint " + o.Fingerprint + } + return w +} + // Publish is one artifact's publish again: what the registry seat's publish takes, without parts. type Publish struct { Seat, Kind, Name, Version, Digest, Fingerprint, Commit, Transfer string @@ -767,6 +782,15 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate sent++ continue } + var other *OtherBytes + if errors.As(err, &other) { + // A version the holder holds with other bytes is never published as it stands (ADR 0605 §4): the item ends at once, spending + // no try; the next build of the fingerprint withdraws the number and takes the next free one (H-A-590 (1), H-A-729). + words := fmt.Sprintf("%s %s: %s; built %s, so the number is held for another build and is not published again", ref, q.Version, other, q.Artifacts[ref]) + r.say(ctx, v, words) + r.end(ctx, q.Module, q.Version, words) + return SendFate{Ended: words} + } r.logf("publish again: %s %s: %s refused by %s: %v", q.Module, q.Version, ref, seat, err) words := err.Error() if strings.Contains(words, strings.TrimSuffix(NotStoredWords, ": ")) { diff --git a/modules/mesh-delivery-builder/internal/versions/republish_test.go b/modules/mesh-delivery-builder/internal/versions/republish_test.go index 420572730..a89f02ca0 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish_test.go +++ b/modules/mesh-delivery-builder/internal/versions/republish_test.go @@ -29,7 +29,8 @@ type republishBed struct { sent []Publish said []string ended []string - refuse string // the words Send fails with, empty for none + refuse string // the words Send fails with, empty for none + other *OtherBytes // the holder's answer of a version held with other bytes (H-A-729) // holders are the registry seats' holders the seat-holders view names (design 47 G A-416). holders map[string][]string // puts are the items the work queue took; window deduplicates by message id; full refuses every put; held keeps the puts @@ -58,6 +59,9 @@ func newRepublishBed(t *testing.T) *republishBed { b.mu.Lock() defer b.mu.Unlock() b.sent = append(b.sent, p) + if b.other != nil { + return b.other + } if b.refuse != "" { return errors.New(b.refuse) } @@ -184,6 +188,16 @@ func TestRepublish(t *testing.T) { t.Errorf("the reservation's upstream is %v, missing %v; want m:up filled once and not missing", cur.Upstream, cur.Missing()) } }) + t.Run("a version held with other bytes ends the item at once, no try spent", func(t *testing.T) { + // design 47 H2 H-A-590 (2), H-A-729: never asked again as it stands; the next build of the fingerprint takes another number + b := newRepublishBed(t) + v := b.reserve(t, "m") + b.other = &OtherBytes{Seat: SeatArtifacts, Name: "m/prog", Version: v.Version, Digest: "sha256:zz", Fingerprint: "src2:other"} + f := b.SendQueued(ctx, b.queueAt(v, PublishClassLive, b.now)) + if f.Ended == "" || f.Failed != "" || f.Sent || len(b.sent) != 1 || fmt.Sprint(b.ended) != "[m "+v.Version+"]" || !strings.Contains(f.Ended, "sha256:zz") { + t.Errorf("%+v, sent %d, ended %v: want the item ended at once naming the other digest, and no failure to try again", f, len(b.sent), b.ended) + } + }) t.Run("the first artifact refused as not stored starts the build again once", func(t *testing.T) { // design 47 H2 H-A-662, H-A-703: one start per reservation, whatever number of its artifacts are refused b := newRepublishBed(t) From 05dcdf4bf55d391bb5e6729d8695a5037a823e35 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:17:53 +0100 Subject: [PATCH 037/141] W3 seed-reads-pages: the watchman's seed reads the runner's stands page by page, a failed page seeds nothing Builds: design 47 H2 H-A-709 (2), H-A-717 (DMC-20); row W3 --- .../integration_test.go | 40 ++++++++++++++++++- .../cmd/mesh-delivery-watchman/main.go | 30 +++++++++----- 2 files changed, 60 insertions(+), 10 deletions(-) diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go index 038160818..7235f3721 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go @@ -3,8 +3,10 @@ package main import ( + "bytes" "context" "encoding/json" + "errors" "fmt" "io" "os" @@ -364,6 +366,26 @@ func TestWatchmanWhole(t *testing.T) { // 1135/AC8 return watch.FindingKey(watch.ScopeDelivery, watch.StepFindingID(seededPipeline+"/"+step+"/"), watch.KindPipelineStands) } until("the seeded composition step with no progress", func() bool { return finding(seeded("composition")) }) + // H-A-709 (2): the step of the stands' second page is seeded as the first page's is. + until("the seeded step of the second page", func() bool { + return finding(watch.FindingKey(watch.ScopeDelivery, watch.StepFindingID(seededPipeline+"/unit/web:program"), watch.KindPipelineStands)) + }) + // A page that fails seeds nothing and is said: the first page answers, the second does not. + { + out := &findingsOut{findings: map[string]bool{}} + w2 := watch.New(watchmanModule, out, time.Now) + var said []string + seedSteps(w2, func(key string, body any) (json.RawMessage, error) { + if in, ok := body.(meshpipelinerunner.StandsInput); ok && in.Next != "" { + return nil, errors.New("no responders") + } + raw, _ := json.Marshal(firstPage) + return raw, nil + }, func(f string, a ...any) { said = append(said, fmt.Sprintf(f, a...)) }) + if len(said) != 1 || !strings.Contains(said[0], "no step is seeded") || strings.Contains(said[0], "open steps the runner holds") { + t.Errorf("a failed second page: said %v; want one line saying no step is seeded", said) + } + } if finding(seeded("approval")) { t.Error("a step waiting on a person raised pipeline-stands") } @@ -695,6 +717,9 @@ const ( testWantsBucket = testAssigner + "_" + meshwants.StateWants ) +// firstPage is the first page of the stand-in runner's stands, which names the next. +var firstPage meshpipelinerunner.StandsAnswer + // seededPipeline is the pipeline the stand-in runner's stands names. const seededPipeline = "main.5.web" @@ -715,7 +740,20 @@ func serveCatalogHalf(t *testing.T, nc *nats.Conn) { stands := meshpipelinerunner.StandsAnswer{Stands: []meshpipelinerunner.Wait{ {Pipeline: seededPipeline, Step: "composition", Ask: "seeded-ask", Module: "web", Branch: "main", Since: time.Now().UTC(), V: 1}, {Pipeline: seededPipeline, Step: "approval", On: meshpipelinerunner.WaitOnPerson, Module: "web", Branch: "main", Since: time.Now().UTC(), V: 1}}} - for subject, handle := range map[string]nats.MsgHandler{"mesh.seat.mesh-pipeline-runner.call.stands": respond(stands), + // H-A-709 (2): the stands answer in two pages: the first names `next`, the second, asked with it, holds one more open step. + second := meshpipelinerunner.StandsAnswer{Stands: []meshpipelinerunner.Wait{ + {Pipeline: seededPipeline, Step: "unit", Artifact: "web:program", Ask: "seeded-ask-2", Module: "web", Branch: "main", Since: time.Now().UTC(), V: 1}}} + firstPage = stands + firstPage.Next = "page-2" + pages := func(m *nats.Msg) { + answer := firstPage + if bytes.Contains(m.Data, []byte(`"next":"page-2"`)) { + answer = second + } + raw, _ := json.Marshal(map[string]any{"result": answer, "node": "n0"}) + _ = m.Respond(raw) + } + for subject, handle := range map[string]nats.MsgHandler{"mesh.seat.mesh-pipeline-runner.call.stands": pages, "mesh.seat.mesh-catalog.call.revision": respond(revision), "mesh.seat.mesh-catalog.call.registrations": respond(registrations), "mesh.seat.mesh-delivery.call.source": respond(map[string]any{"branches": []string{"release"}})} { for _, s := range []string{subject, subject + ".>"} { diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go index 29d258291..be8cc2fd5 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/main.go @@ -542,19 +542,31 @@ func seedTakeIn(w *watch.Watchman, call func(key string, body any) (json.RawMess // standsVerb is the runner's seat verb that answers every step started and not ended (design 47 G §731, A-469p). const standsVerb = "seat:" + meshpipelinerunner.Seat + "." + meshpipelinerunner.VerbStands -// seedSteps asks the runner which steps stand now and keeps each, its clock begun at this start (Watchman.SeedSteps, design 47 G -// §731, §732). A runner that does not answer is said: the steps are then known from the events heard after. +// seedSteps asks the runner which steps stand now, page by page through `next`, and keeps each, its clock begun at this start +// (Watchman.SeedSteps, design 47 G §731, §732; H2 H-A-709 (2)). A page that fails seeds nothing and is said: the steps are then +// known from the events heard after. A runner built before reads one page, whose answer names no `next`. func seedSteps(w *watch.Watchman, call func(key string, body any) (json.RawMessage, error), logf func(string, ...any)) { - raw, err := call(standsVerb, map[string]any{}) - if err == nil { - var a meshpipelinerunner.StandsAnswer - if err = json.Unmarshal(raw, &a); err == nil { - w.SeedSteps(a.Stands) - logf("steps: %d open steps the runner holds are watched from this start (%s)", len(a.Stands), standsVerb) + var stands []meshpipelinerunner.Wait + next, pages := "", 0 + for { + raw, err := call(standsVerb, meshpipelinerunner.StandsInput{Next: next}) + if err != nil { + logf("steps: %s cannot be asked (%v) at its page %d, so no step is seeded and a step open before this start is timed only once an event of it is heard", standsVerb, err, pages+1) return } + var a meshpipelinerunner.StandsAnswer + if err := json.Unmarshal(raw, &a); err != nil { + logf("steps: %s answered what does not read (%v) at its page %d, so no step is seeded and a step open before this start is timed only once an event of it is heard", standsVerb, err, pages+1) + return + } + stands, pages = append(stands, a.Stands...), pages+1 + if a.Next == "" || a.Next == next { + break + } + next = a.Next } - logf("steps: %s cannot be asked (%v), so a step open before this start is timed only once an event of it is heard", standsVerb, err) + w.SeedSteps(stands) + logf("steps: %d open steps the runner holds are watched from this start, read in %d pages (%s)", len(stands), pages, standsVerb) } // takeInHeard hands one take-in event of the indexer to the watchman, by its name relative to the indexer, and acknowledges it; From 34c5cc9079d19b35ecb84bbd9bb67eddba1cffd8 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:18:24 +0100 Subject: [PATCH 038/141] W2 second-end-nothing-new: a second record-ended of a cleared record raises and clears nothing Builds: design 47 H2 H-A-617 (the watchman's part; the code already took it as nothing new, the row proves it); row W2 --- .../integration_test.go | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go index 7235f3721..20275428e 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go @@ -360,6 +360,34 @@ func TestWatchmanWhole(t *testing.T) { // 1135/AC8 sayStep("step-ended", time.Now().UTC()) until("the step's end clears it", func() bool { return !finding(stepFinding) }) + // H-A-617: a record open for over a day raises `record-open` and its end clears it; a second end of it (`ends` 2) raises and + // clears nothing. A later record's finding, heard after the second end on the one stream, shows the second end was taken. + recordSay := func(event, record, call string, ends int) { + t.Helper() + body := fmt.Sprintf(`{"record":%q,"milestone":"main.42","branch":"main","source":42,"call":%q,"ends":%d,"at":%q}`, record, call, ends, + time.Now().UTC().Add(-25*time.Hour).Format(time.RFC3339)) + subject := "mesh.seat.mesh-delivery.event." + event + if event == "record-opened" { + subject += "." + call + } + if _, err := js.Publish(ctx, subject, []byte(body)); err != nil { + t.Fatal(err) + } + } + recordFinding := func(record string) bool { + return finding(watch.FindingKey(watch.ScopeDelivery, record, watch.KindRecordOpen)) + } + recordSay("record-opened", "r-first", "aaaaaaaaaaaaaaaa", 0) + until("the record open for over a day", func() bool { return recordFinding("r-first") }) + recordSay("record-ended", "r-first", "aaaaaaaaaaaaaaaa", 1) + until("the record's end clears it", func() bool { return !recordFinding("r-first") }) + recordSay("record-ended", "r-first", "aaaaaaaaaaaaaaaa", 2) + recordSay("record-opened", "r-second", "bbbbbbbbbbbbbbbb", 0) + until("the next record open for over a day", func() bool { return recordFinding("r-second") }) + if recordFinding("r-first") { + t.Error("a second end of a cleared record raised its finding again") + } + // A step the runner's stands named at the start (seeded through the seat verb) and that no progress follows is // `pipeline-stands`; the approval waiting on a person is owed none. seeded := func(step string) string { From af5a7e58701c353d68344b70f553019b615e8806 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:18:28 +0100 Subject: [PATCH 039/141] I1 needs-in-the-judge: ManifestNeeds and ModuleNeeds move into the manifest validator, read field by field through catalogue.Manifest, a key taken only where ManifestReads names its path Builds: design 47 H2 H-A-568, H-A-622, H-A-639, H-A-640, H-A-669 --- .../internal/index/modules.go | 3 +- .../internal/index/modules_test.go | 4 +- .../internal/index/source.go | 3 +- modules/mesh-delivery-indexer/judge/needs.go | 360 ++++++++++++++++++ .../mesh-delivery-indexer/judge/needs_test.go | 74 ++++ 5 files changed, 439 insertions(+), 5 deletions(-) create mode 100644 modules/mesh-delivery-indexer/judge/needs.go create mode 100644 modules/mesh-delivery-indexer/judge/needs_test.go diff --git a/modules/mesh-delivery-indexer/internal/index/modules.go b/modules/mesh-delivery-indexer/internal/index/modules.go index a8cb0cec2..6dc86e668 100644 --- a/modules/mesh-delivery-indexer/internal/index/modules.go +++ b/modules/mesh-delivery-indexer/internal/index/modules.go @@ -10,7 +10,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" - "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/keys" "mesh-delivery-indexer/internal/fingerprint" @@ -102,7 +101,7 @@ func (ix *Indexer) applyMoving(ctx context.Context, f whole, drop bool, moves ma next := meshcatalog.ModulesByModuleValue{Repository: f.Repository, Commit: f.Merge, Manifest: digests[dir], Path: pathOf(dir)} // The reader capabilities a changed manifest needs are written with it, before the judge's pass names them with its // verdict, so no reader takes a new manifest as needing nothing (ADR 0614 §4). - next.Needs, _ = catalogue.ManifestNeeds([]byte(raw)) + next.Needs, _ = judge.ManifestNeeds([]byte(raw)) if whole, ok := f.Needs[dir]; ok { next.Needs = whole // its templates' text too, read by the forge bridge at the merge (ADR 0632 §2) } diff --git a/modules/mesh-delivery-indexer/internal/index/modules_test.go b/modules/mesh-delivery-indexer/internal/index/modules_test.go index e5748ce63..e44343e77 100644 --- a/modules/mesh-delivery-indexer/internal/index/modules_test.go +++ b/modules/mesh-delivery-indexer/internal/index/modules_test.go @@ -16,8 +16,8 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" - "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/process" + "mesh-delivery-indexer/judge" ) const merge = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" @@ -441,7 +441,7 @@ func TestAMergeAddingAModuleDirectoryWritesItsValueWithNoBuildRecordAnywhere(t * } // ADR 0614 §4: the merge writes the reader capabilities its manifest needs, so no reader takes it as needing nothing // before the judge's pass. - if want, _ := catalogue.ManifestNeeds([]byte(avahi)); len(m.Needs) == 0 || !slices.Equal(m.Needs, want) { + if want, _ := judge.ManifestNeeds([]byte(avahi)); len(m.Needs) == 0 || !slices.Equal(m.Needs, want) { t.Errorf("module needs %v, want %v", m.Needs, want) } } diff --git a/modules/mesh-delivery-indexer/internal/index/source.go b/modules/mesh-delivery-indexer/internal/index/source.go index ea7531504..4006704d9 100644 --- a/modules/mesh-delivery-indexer/internal/index/source.go +++ b/modules/mesh-delivery-indexer/internal/index/source.go @@ -10,6 +10,7 @@ import ( "slices" "git.novox.be/novox/mesh-sdk/go/catalogue" + "mesh-delivery-indexer/judge" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/trunk" ) @@ -66,7 +67,7 @@ func (ix *Indexer) wholeAt(ctx context.Context, repository, head string) (whole, if f.Needs == nil { f.Needs = map[string][]string{} } - f.Needs[dir], _ = catalogue.ModuleNeeds([]byte(read.Manifests[dir]), texts) + f.Needs[dir], _ = judge.ModuleNeeds([]byte(read.Manifests[dir]), texts) } if l := read.Locks[dir]; len(l) > 0 { if f.Locks == nil { diff --git a/modules/mesh-delivery-indexer/judge/needs.go b/modules/mesh-delivery-indexer/judge/needs.go new file mode 100644 index 000000000..950ec5f89 --- /dev/null +++ b/modules/mesh-delivery-indexer/judge/needs.go @@ -0,0 +1,360 @@ +package judge + +import ( + "bytes" + "encoding/json" + "reflect" + "regexp" + "slices" + "sort" + "strings" + + "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" + "git.novox.be/novox/mesh-sdk/go/catalogue" +) + +// The reader capabilities a manifest needs (novox/hq ADR 0614 §4; design 47 H2, H-A-639, H-A-669): a manifest word, a +// form or a seat name of the shared contract a reader of manifests (a node-engine) must read for the manifest. +// ManifestNeeds names them for one manifest, ModuleNeeds for a module whose files take their text from templates. The +// manifest is read field by field through catalogue.Manifest, and a key is a word only where catalogue.ManifestReads() +// names its path; a unit test holds the two equal, so a difference fails. + +// requirementLong is one entry of `requires` in its long form, as catalogue reads it. +type requirementLong struct { + Name string `json:"name"` + Optional bool `json:"optional,omitempty"` + Shares []catalogue.BucketShare `json:"shares,omitempty"` +} + +// topWords are the keys catalogue.Manifest's decoder reads whole beside its fields, no words of the contract beneath. +var topWords = []string{"secrets", "contributes", catalogue.OptionalRequiresKey, catalogue.RequireSharesKey} + +// wireKeys are the keys of a block whose decoder reads its object by keys of its own. +var wireKeys = map[reflect.Type][]string{ + reflect.TypeOf(catalogue.OfferIdentity{}): {"max", "in"}, + reflect.TypeOf(catalogue.DataBackup{}): {"dump", "into"}, + reflect.TypeOf(catalogue.OwnSecret{}): {"path", "taken", "issued-by", "prompt", "owner"}, +} + +var ( + takesConfigKey = regexp.MustCompile(`"` + catalogue.TakesConfigField + `"(\s*):`) + needsSeatReach = regexp.MustCompile(`\$\{seat:[a-z0-9][a-z0-9-]*:reach\}`) +) + +const ( + configJSONToken = "${config-json}" + ifConfigWord = catalogue.ReadWord + "resources." + catalogue.IfConfigField + storeHolderSeat = "container-image-registry" +) + +// ManifestNeeds is every reader capability a manifest's own words, forms and seat names need, sorted. An error is +// only bytes that are no JSON object. +func ManifestNeeds(raw []byte) ([]string, error) { + var top map[string]any + dec := json.NewDecoder(bytes.NewReader(raw)) + dec.UseNumber() + if err := dec.Decode(&top); err != nil { + return nil, err + } + used := map[string]bool{} + textNeeds(raw, used) + if claimsAtMesh(top, storeHolderSeat) { + used[catalogue.ReadForm+catalogue.ReferenceFormSeatReach] = true + } + if runsAs, _ := top["runs-as"].(string); runsAs != "" { + used[nodeengine.ManifestReadWordDirectoryContentsOwner] = true + } + for _, r := range asList(top["resources"]) { + if obj, ok := r.(map[string]any); ok { + if _, has := obj[catalogue.IfConfigField]; has { + used[ifConfigWord] = true + } + } + } + if _, has := top[catalogue.ConfigField]; has || takesConfigKey.Match(raw) { + used[catalogue.ReadForm+"config"] = true + } + words := map[string]bool{} + fields := structFields(reflect.TypeOf(catalogue.Manifest{})) + for _, k := range sortedAnyKeys(top) { + v := top[k] + switch { + case k == catalogue.ConfigField: + // The config form is the settings form's words under another key. + words[catalogue.SettingsField] = true + walkValue(v, fields[catalogue.SettingsField].Type, catalogue.SettingsField, words) + case k == "requires": + words[k] = true + for _, e := range asList(v) { + obj, isObj := e.(map[string]any) + if !isObj { + continue + } + if _, bus := obj["storage"]; bus { + words[catalogue.BusStateField] = true + walkValue(obj, reflect.TypeOf(catalogue.BusStateEntry{}), catalogue.BusStateField, words) + continue + } + walkValue(obj, reflect.TypeOf(requirementLong{}), k, words) + } + case slices.Contains(topWords, k): + words[k] = true + default: + if f, known := fields[k]; known { + words[k] = true + walkValue(v, f.Type, k, words) + } + } + } + read := map[string]bool{} + for _, r := range catalogue.ManifestReads() { + read[r] = true + } + for w := range words { + if read[catalogue.ReadWord+w] { + used[catalogue.ReadWord+w] = true + } + } + for _, s := range seatNamesUsed(top) { + used[catalogue.ReadSeat+s] = true + } + return sortedSet(used), nil +} + +// ModuleNeeds is ManifestNeeds of a module whose files take their text from templates: what the manifest needs and +// what each template's text writes, sorted. A template named and not given is no need. +func ModuleNeeds(raw []byte, templates map[string]string) ([]string, error) { + needs, err := ManifestNeeds(raw) + if err != nil || len(templates) == 0 { + return needs, err + } + used := map[string]bool{} + for _, n := range needs { + used[n] = true + } + for _, text := range templates { + textNeeds([]byte(text), used) + } + return sortedSet(used), nil +} + +// readerWords is every word the validator's field-by-field reading can name, by path, sorted: the words +// catalogue.ManifestReads() must name, so a unit test holds the two equal. +func readerWords() []string { + set := map[string]bool{} + walkType(reflect.TypeOf(catalogue.Manifest{}), "", set, map[reflect.Type]bool{}) + set["requires"] = true + set[strings.TrimPrefix(ifConfigWord, catalogue.ReadWord)] = true // a resource's key, read beside the fields + walkType(reflect.TypeOf(requirementLong{}), "requires", set, map[reflect.Type]bool{}) + for _, w := range topWords { + set[w] = true + } + return sortedSet(set) +} + +// textNeeds adds the reference forms a manifest's or a template's text writes to used. +func textNeeds(text []byte, used map[string]bool) { + for _, f := range referenceFormsRead() { + if bytes.Contains(text, []byte("${"+f+":")) { + used[catalogue.ReadForm+f] = true + } + } + if bytes.Contains(text, []byte(configJSONToken)) { + used[catalogue.ReadForm+"config-json"] = true + } + if needsSeatReach.Match(text) { + used[catalogue.ReadForm+catalogue.ReferenceFormSeatReach] = true + } +} + +// referenceFormsRead are the reference forms a manifest's values may hold, `${:…}`: the forms catalogue.ManifestReads() +// names, but for the two it reads by another rule (a build's artifact reference, and a seat's reach). +func referenceFormsRead() []string { + var out []string + for _, r := range catalogue.ManifestReads() { + f, ok := strings.CutPrefix(r, catalogue.ReadForm) + if !ok || f == catalogue.ReferenceFormSeat || f == catalogue.ReferenceFormSeatReach { + continue + } + out = append(out, f) + } + return out +} + +func claimsAtMesh(top map[string]any, seat string) bool { + for _, c := range asList(top["claims"]) { + obj, _ := c.(map[string]any) + name, _ := obj["name"].(string) + scope, _ := obj["scope"].(string) + if hs, ok := catalogue.SeatNamed(name); ok && hs.Name == seat && (scope == "" || scope == catalogue.ScopeMesh) { + return true + } + } + return false +} + +// seatNamesUsed is each seat of the contract's table the manifest names: in a claim, a use, an invoke of a seat's verb, +// and a bucket's share with a seat. +func seatNamesUsed(top map[string]any) []string { + known := map[string]bool{} + for _, s := range catalogue.Seats() { + known[s.Name] = true + } + set := map[string]bool{} + add := func(name string) { + if known[name] { + set[name] = true + } + } + for _, c := range asList(top["claims"]) { + if obj, ok := c.(map[string]any); ok { + name, _ := obj["name"].(string) + add(name) + } + } + for _, u := range asList(top["uses"]) { + name, _ := u.(string) + add(name) + } + for _, i := range asList(top["invokes"]) { + text, _ := i.(string) + if seat, _, ok := catalogue.SeatInvoke(text); ok { + add(seat) + } + } + for _, r := range asList(top["requires"]) { + obj, _ := r.(map[string]any) + for _, share := range asList(obj["shares"]) { + text, _ := share.(string) + if seat, ok := strings.CutPrefix(text, "seat:"); ok { + add(seat) + } + } + } + return sortedSet(set) +} + +func walkType(t reflect.Type, path string, set map[string]bool, onPath map[reflect.Type]bool) { + t = deref(t) + if keys, custom := wireKeys[t]; custom { + for _, k := range keys { + set[joinWord(path, k)] = true + } + return + } + switch t.Kind() { + case reflect.Struct: + if onPath[t] { + return + } + onPath[t] = true + defer delete(onPath, t) + for name, f := range structFields(t) { + word := joinWord(path, name) + set[word] = true + walkType(f.Type, word, set, onPath) + } + case reflect.Slice, reflect.Array, reflect.Map: + if t.Elem().Kind() == reflect.Uint8 { + return + } + walkType(t.Elem(), path, set, onPath) + } +} + +func walkValue(v any, t reflect.Type, path string, used map[string]bool) { + t = deref(t) + if keys, custom := wireKeys[t]; custom { + obj, _ := v.(map[string]any) + for _, k := range keys { + if _, has := obj[k]; has { + used[joinWord(path, k)] = true + } + } + return + } + switch t.Kind() { + case reflect.Struct: + obj, isObj := v.(map[string]any) + if !isObj { + return + } + fields := structFields(t) + for _, k := range sortedAnyKeys(obj) { + f, known := fields[k] + if !known { + continue + } + word := joinWord(path, k) + used[word] = true + walkValue(obj[k], f.Type, word, used) + } + case reflect.Slice, reflect.Array: + if t.Elem().Kind() == reflect.Uint8 { + return + } + for _, item := range asList(v) { + walkValue(item, t.Elem(), path, used) + } + case reflect.Map: + obj, _ := v.(map[string]any) + for _, k := range sortedAnyKeys(obj) { + walkValue(obj[k], t.Elem(), path, used) + } + } +} + +func structFields(t reflect.Type) map[string]reflect.StructField { + out := map[string]reflect.StructField{} + for i := 0; i < t.NumField(); i++ { + f := t.Field(i) + name, _, _ := strings.Cut(f.Tag.Get("json"), ",") + if name == "-" { + continue + } + if f.Anonymous && name == "" && deref(f.Type).Kind() == reflect.Struct { + for k, inner := range structFields(deref(f.Type)) { + if _, shadowed := out[k]; !shadowed { + out[k] = inner + } + } + continue + } + if !f.IsExported() { + continue + } + if name == "" { + name = f.Name + } + out[name] = f + } + return out +} + +func deref(t reflect.Type) reflect.Type { + for t.Kind() == reflect.Pointer { + t = t.Elem() + } + return t +} + +func joinWord(path, key string) string { + if path == "" { + return key + } + return path + "." + key +} + +func asList(v any) []any { + list, _ := v.([]any) + return list +} + +func sortedSet(set map[string]bool) []string { + out := make([]string, 0, len(set)) + for k := range set { + out = append(out, k) + } + sort.Strings(out) + return out +} diff --git a/modules/mesh-delivery-indexer/judge/needs_test.go b/modules/mesh-delivery-indexer/judge/needs_test.go new file mode 100644 index 000000000..81a7ed76c --- /dev/null +++ b/modules/mesh-delivery-indexer/judge/needs_test.go @@ -0,0 +1,74 @@ +package judge + +import ( + "slices" + "strings" + "testing" + + "git.novox.be/novox/mesh-sdk/go/catalogue" +) + +func TestManifestNeeds(t *testing.T) { + for _, row := range []struct { + why, raw string + templates map[string]string + has, not []string + }{ + {"a module of its own account", `{"module":"g","version":"1","runs-as":"g"}`, nil, + []string{"directory-contents-owner", "word:runs-as"}, nil}, + {"a module with no account of its own", `{"module":"g","version":"1"}`, nil, + []string{"word:module"}, []string{"directory-contents-owner"}}, + {"a word the contract does not know", `{"module":"u","version":"1","newer-word":{"inside":1}}`, nil, + []string{"word:module"}, []string{"word:newer-word"}}, + {"a template naming a seat's reach", `{"module":"z","version":"1","resources":[{"id":"f","type":"file","template":"files/d.json"}]}`, + map[string]string{"files/d.json": `{"x":"${seat:container-image-registry:reach}"}`}, + []string{"form:seat-reach"}, nil}, + {"a template writing the config as json", `{"module":"z","version":"1","resources":[{"id":"f","type":"file","template":"files/c.json"}]}`, + map[string]string{"files/c.json": "${config-json}"}, []string{"form:config-json"}, []string{"form:config-lines"}}, + {"a resource with if-config", `{"module":"z","version":"1","resources":[{"id":"f","type":"file","if-config":"x"}]}`, nil, + []string{"word:resources.if-config"}, nil}, + } { + needs, err := ModuleNeeds([]byte(row.raw), row.templates) + if err != nil { + t.Fatalf("%s: %v", row.why, err) + } + for _, n := range row.has { + if !slices.Contains(needs, n) { + t.Errorf("%s: needs %v, not %s", row.why, needs, n) + } + } + for _, n := range row.not { + if slices.Contains(needs, n) { + t.Errorf("%s: needs %v, naming %s", row.why, needs, n) + } + } + } + if _, err := ManifestNeeds([]byte("[]")); err == nil { + t.Error("bytes that are no JSON object: no error") + } +} + +// The manifest validator's reading of a manifest's keys equals ManifestReads' words (H-A-669): a word one names and the +// other does not fails here. +func TestTheValidatorReadsTheWordsManifestReadsNames(t *testing.T) { + var contract []string + for _, r := range catalogue.ManifestReads() { + if w, ok := strings.CutPrefix(r, catalogue.ReadWord); ok { + contract = append(contract, w) + } + } + if got := readerWords(); !slices.Equal(got, contract) { + t.Errorf("the validator reads %d words, ManifestReads names %d: only in the validator %v, only in ManifestReads %v", + len(got), len(contract), diff(got, contract), diff(contract, got)) + } +} + +func diff(a, b []string) []string { + var out []string + for _, x := range a { + if !slices.Contains(b, x) { + out = append(out, x) + } + } + return out +} From 2eccf99693e4693d6927372c497ffc5136bd512a Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:18:53 +0100 Subject: [PATCH 040/141] P11 started-names-what-is-read: pipeline-started's movers are StartedMover's fields alone Builds: design 47 H2 H-A-709 (3) --- .../internal/pipeline/start.go | 8 ++++++- .../internal/pipeline/start_test.go | 23 ++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start.go b/modules/mesh-delivery-pipeline/internal/pipeline/start.go index e2429dd7d..2f3184172 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start.go @@ -446,8 +446,14 @@ func (s *Starter) create(key string, p seat.Pipeline) error { // started is a pipeline's pipeline-started (§746): its key, branch, source, call, revision and movers, and kept, every // catalog revision its movers are kept at (design 47 H2 H-A-496), so the indexer pins each while the pipeline runs. func started(p seat.Pipeline, at time.Time, kept []int64) seat.PipelineStarted { + // Each mover carries what the readers of pipeline-started read, and no more (design 47 H2 H-A-709 (3)): published, widens, tests, + // unplaced, revision and over-budget stay in the pipeline's record, read by show. + movers := make([]seat.StartedMover, 0, len(p.Movers)) + for _, m := range p.Movers { + movers = append(movers, seat.StartedMover{Module: m.Module, Commit: m.Commit, Fingerprint: m.Fingerprint, Repository: m.Repository, Tier: m.Tier, Version: m.Version}) + } return seat.PipelineStarted{V: 1, At: &at, Pipeline: p.Pipeline, Branch: p.Branch, Source: p.Source, Call: p.Call, - Revision: p.Revision, Movers: p.Movers, Published: p.Published, Run: p.Run, Kept: kept} + Revision: p.Revision, Movers: movers, Published: p.Published, Run: p.Run, Kept: kept} } // keptList is every distinct revision of kept-revisions, in order (H-A-496). diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go index 8746e391b..44440d2c3 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go @@ -1,6 +1,7 @@ package pipeline import ( + "bytes" "encoding/json" "errors" "fmt" @@ -30,7 +31,13 @@ func (c created) Create(key string, value []byte) error { // refused. func TestStarts(t *testing.T) { store := created{} - s := &Starter{Pipelines: store, Say: func(string, any) error { return nil }} + var said []seat.PipelineStarted + s := &Starter{Pipelines: store, Say: func(_ string, body any) error { + if ev, ok := body.(seat.PipelineStarted); ok { + said = append(said, ev) + } + return nil + }} key := Key("main", 41) if ok, err := s.Start(Begin{Branch: "main", Source: 41, Movers: []seat.Mover{{Module: "app", Commit: "c1"}}}); !ok || err != nil { t.Fatalf("start = %v, %v", ok, err) @@ -51,6 +58,20 @@ func TestStarts(t *testing.T) { if _, err := s.Start(Begin{Branch: "main", Source: 6}); err == nil { t.Error("a start with no mover is refused") } + // H2 H-A-709 (3): pipeline-started of 100 movers carries StartedMover's fields alone and stays under 32 KB + many := make([]seat.Mover, 100) + for i := range many { + many[i] = seat.Mover{Module: fmt.Sprintf("module-%03d", i), Commit: strings.Repeat("c", 40), Fingerprint: "src2:" + strings.Repeat("f", 64), Repository: "novox/mesh-delivery", Tier: 3, + Published: []string{"module:artifact", "module:other"}, Widens: []seat.Widening{{}}, OverBudget: true, Unplaced: seat.MoverUnplacedKeptRevisionUnread, Revision: 9} + } + said = nil + if _, err := s.Start(Begin{Branch: "main", Source: 44, Movers: many}); err != nil || len(said) != 1 { + t.Fatalf("100 movers started %d events (%v)", len(said), err) + } + raw, _ := json.Marshal(said[0]) + if len(said[0].Movers) != 100 || len(raw) > 32*1024 || bytes.Contains(raw, []byte("over-budget")) || bytes.Contains(raw, []byte("widens")) || bytes.Contains(raw, []byte("unplaced")) || bytes.Contains(raw, []byte(`"published":["`)) { + t.Errorf("pipeline-started of 100 movers is %d bytes: %.200s; want 100 StartedMovers under 32 KB without published, widens, unplaced or over-budget", len(raw), raw) + } s.Pipelines = failing{} if _, err := s.Start(Begin{Branch: "main", Source: 5, Movers: []seat.Mover{{Module: "app"}}}); err == nil { t.Error("a write the bus refuses is an error") From b0d915f6d0ec0ebedd025a2c0ed553b729a8dd48 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:18:53 +0100 Subject: [PATCH 041/141] P9 show-names-its-page: show names only its page's movers, each row its fingerprint, version and tier, and the record's mover and step counts Builds: design 47 H2 H-A-709 (1), H-A-730 --- .../internal/pipeline/read.go | 26 ++++++++++++++++--- .../internal/pipeline/read_test.go | 17 +++++++++--- .../internal/pipeline/repin_test.go | 2 +- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/read.go b/modules/mesh-delivery-pipeline/internal/pipeline/read.go index 584ed38b4..160796b11 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/read.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/read.go @@ -74,7 +74,9 @@ func (r Reads) Show(in seat.ShowInput) (seat.ShowAnswer, error) { // Naming neither a mover nor a filter, show answers each mover's row, never every step of every mover (design 47 H2 // H-A-376), in pages as the steps are. rows := MoverRows(p) - p.Steps = []seat.StepResult{} + moverCount, stepCount := int64(len(p.Movers)), int64(len(p.Steps)) + p.Steps, p.Movers, p.Unlogged = []seat.StepResult{}, []seat.Mover{}, nil // the page's mover rows name each mover (design 47 H2 H-A-709 (1)) + p.MoverCount, p.StepCount = moverCount, stepCount a := seat.ShowAnswer{Pipeline: p, Fill: fills, Total: int64(len(rows)), Movers: []seat.MoverRow{}} size := sizeOf(a) for i := from; i < len(rows); i++ { @@ -88,17 +90,30 @@ func (r Reads) Show(in seat.ShowInput) (seat.ShowAnswer, error) { } return a, nil } + p0steps := len(p.Steps) held := []seat.StepResult{} for _, s := range p.Steps { if (m == "" || s.Module == m) && (in.Step == "" || s.Step == in.Step) && (in.State == "" || s.Outcome == in.State) { held = append(held, s) } } - p.Steps = []seat.StepResult{} + // The answer names only the movers its page holds: the named mover, or those whose steps the page holds (design 47 H2 H-A-709 (1)). + all := p.Movers + p.Steps, p.Movers, p.Unlogged = []seat.StepResult{}, []seat.Mover{}, nil + p.MoverCount, p.StepCount = int64(len(all)), int64(p0steps) a := seat.ShowAnswer{Pipeline: p, Fill: fills, Total: int64(len(held))} size := sizeOf(a) + named := map[string]bool{} for i := from; i < len(held); i++ { n := sizeOf(held[i]) + 1 + if !named[held[i].Module] { // the mover the page's step belongs to is on the page too + named[held[i].Module] = true + for _, mv := range all { + if mv.Module == held[i].Module { + n += sizeOf(mv) + 1 + } + } + } if size+n > MaxAnswer && len(a.Pipeline.Steps) > 0 { a.Capped, a.Next = true, pageCursor(i) break @@ -106,6 +121,11 @@ func (r Reads) Show(in seat.ShowInput) (seat.ShowAnswer, error) { size += n a.Pipeline.Steps = append(a.Pipeline.Steps, held[i]) } + for _, mv := range all { + if mv.Module == m || slices.ContainsFunc(a.Pipeline.Steps, func(s seat.StepResult) bool { return s.Module == mv.Module }) { + a.Pipeline.Movers = append(a.Pipeline.Movers, mv) + } + } return a, nil } @@ -223,7 +243,7 @@ func MoverRows(p seat.Pipeline) []seat.MoverRow { out := make([]seat.MoverRow, 0, len(p.Movers)) for _, m := range p.Movers { steps := stepsOf(p, m.Module) - row := seat.MoverRow{Module: m.Module, Outcome: seat.MoverRowOutcomePassed, Failed: firstFailed(steps)} + row := seat.MoverRow{Module: m.Module, Outcome: seat.MoverRowOutcomePassed, Failed: firstFailed(steps), Fingerprint: m.Fingerprint, Version: m.Version, Tier: m.Tier} running, failed := false, false for _, s := range steps { switch { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go index 430eeb04d..cb9e3aeb3 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go @@ -46,7 +46,7 @@ func TestReads(t *testing.T) { {Module: "alpha", Step: seat.StepResultStepUnit, Artifact: "alpha:program", Status: "required", Outcome: seat.StepResultOutcomeCarried, CarriedFrom: "main.6.alpha"}, {Module: "alpha", Step: seat.StepResultStepApproval, Status: "required", Outcome: seat.StepResultOutcomeWaiting, On: seat.WaitOnPerson, - Started: &t1}}, Movers: []seat.Mover{{Module: "alpha", Commit: "c7"}}}) + Started: &t1}}, Movers: []seat.Mover{{Module: "alpha", Commit: "c7", Tier: 2}}}) put(t, pipes, "beta.3.alpha", seat.Pipeline{Pipeline: "beta.3.alpha", Branch: "beta", Outcome: seat.PipelineOutcomePassed, Started: &t2, Movers: []seat.Mover{{Module: "alpha", Commit: "b3"}}}) put(t, pipes, "main.7.gamma", seat.Pipeline{Pipeline: "main.7.gamma", Branch: "main", @@ -90,8 +90,10 @@ func TestReads(t *testing.T) { // Design 47 H2 H-A-376: naming no mover, show answers each mover's row and never its steps. {"show naming no mover answers each mover's row", func() (string, error) { a, err := r.Show(seat.ShowInput{Pipeline: "main.7.alpha"}) - return fmt.Sprint(a.Pipeline.Movers[0].Module, " ", len(a.Pipeline.Steps), " ", a.Movers, " ", a.Total), err - }, "alpha 0 [{ alpha running}] 1"}, + // design 47 H2 H-A-709 (1): the answer's pipeline names no mover of its own, the rows do, each with its fingerprint, version and + // tier; mover-count and step-count count the record's + return fmt.Sprint(len(a.Pipeline.Movers), " ", len(a.Pipeline.Steps), " ", a.Movers, " ", a.Total, " ", a.Pipeline.MoverCount, " ", a.Pipeline.StepCount), err + }, "0 0 [{ alpha running 2 }] 1 1 3"}, {"show's row of a mover names its first failed step", func() (string, error) { a, err := r.Show(seat.ShowInput{Pipeline: "gone.2"}) return fmt.Sprint(a.Movers[0].Outcome, " ", *a.Movers[0].Failed), err @@ -124,7 +126,7 @@ func TestReads(t *testing.T) { s = append(s, st.Module+" "+st.Step) } return fmt.Sprintf("%s, %d movers", strings.Join(s, ", "), len(a.Pipeline.Movers)), err - }, "epsilon build, 2 movers"}, + }, "epsilon build, 1 movers"}, {"show refuses a mover the pipeline does not move", func() (string, error) { _, err := r.Show(seat.ShowInput{Pipeline: "next.8", Mover: "alpha"}) return "", err @@ -336,10 +338,17 @@ func TestAPipelineIsReadInParts(t *testing.T) { if raw, _ := json.Marshal(a); err != nil || len(raw) >= 64<<10 || len(a.Pipeline.Steps) != 6 || a.Total != 6 || a.Capped { t.Fatalf("one mover of 129: %d bytes, %d steps, total %d, capped %v, %v", len(raw), len(a.Pipeline.Steps), a.Total, a.Capped, err) } + if len(a.Pipeline.Movers) != 1 || a.Pipeline.Movers[0].Module != "module-0042" || a.Pipeline.MoverCount != 129 || a.Pipeline.StepCount != 129*6 { + t.Fatalf("one mover named: the answer's movers %d, counts %d and %d; want that mover alone and the record's counts", len(a.Pipeline.Movers), a.Pipeline.MoverCount, a.Pipeline.StepCount) + } a, err = r.Show(seat.ShowInput{Pipeline: "main.9", Step: seat.StepResultStepUnit, State: seat.StepResultOutcomeFailed}) if err != nil || a.Total != 13 || len(a.Pipeline.Steps) != 13 || a.Pipeline.Steps[0].Module != "module-0003" { t.Fatalf("the failed unit steps: total %d, %d steps, %v", a.Total, len(a.Pipeline.Steps), err) } + // H2 H-A-709 (1): with step and state the movers are those whose steps the page holds, 13 of 129 + if len(a.Pipeline.Movers) != 13 || a.Pipeline.Movers[0].Module != "module-0003" { + t.Fatalf("the filters' answer names %d movers, want the 13 whose steps the page holds", len(a.Pipeline.Movers)) + } // The steps a filter holds are larger than one answer: they are read in pages, each under 768 KB, every step once. big := Reads{Pipelines: record(1000), Kept: memKept{}} seen, pages, next := 0, 0, "" diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go index 3ac122550..5938011b7 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go @@ -290,7 +290,7 @@ func TestAKeptMoverWaitingOnItsRevisionSaysSo(t *testing.T) { said++ } } - shown, err := Reads{Pipelines: rawKept{store.Raw.(*memRaw)}, Kept: memKept{}}.Show(seat.ShowInput{Pipeline: key}) + shown, err := Reads{Pipelines: rawKept{store.Raw.(*memRaw)}, Kept: memKept{}}.Show(seat.ShowInput{Pipeline: key, Mover: "app"}) // the mover named: the answer holds that mover alone (H-A-709 (1)) if err != nil || said != 1 || shown.Pipeline.Movers[0].Unplaced != seat.MoverUnplacedKeptRevisionUnread || shown.Pipeline.Movers[0].Revision != 11 { t.Fatalf("said %d times, show %+v (%v)", said, shown.Pipeline.Movers, err) } From d4ea1f34456f17bc953eef24fefbf1cd65515233 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:19:06 +0100 Subject: [PATCH 042/141] I2 own-put-needs-runs-as: a manifest invoking seat:mesh-vault.own-put without runs-as is refused, a get is not Builds: design 47 H2 H-A-576, H-A-584, H-A-670 --- modules/mesh-delivery-indexer/go.mod | 1 + modules/mesh-delivery-indexer/judge/rules.go | 19 +++++++++++++++++++ .../mesh-delivery-indexer/judge/rules_test.go | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/modules/mesh-delivery-indexer/go.mod b/modules/mesh-delivery-indexer/go.mod index dcf518af7..fb20e4d9a 100644 --- a/modules/mesh-delivery-indexer/go.mod +++ b/modules/mesh-delivery-indexer/go.mod @@ -49,6 +49,7 @@ require ( ) require git.novox.be/novox/mesh-contracts/go/seats/meshbroker v0.0.0-00010101000000-000000000000 +require git.novox.be/novox/mesh-contracts/identity-and-access/go/seats/meshvault v0.0.0-00010101000000-000000000000 replace git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk => ../mesh-delivery-sdk diff --git a/modules/mesh-delivery-indexer/judge/rules.go b/modules/mesh-delivery-indexer/judge/rules.go index b43ab69b9..29601d23f 100644 --- a/modules/mesh-delivery-indexer/judge/rules.go +++ b/modules/mesh-delivery-indexer/judge/rules.go @@ -11,6 +11,7 @@ import ( errors "errors" fmt "fmt" "git.novox.be/novox/mesh-contracts/go/seats/meshbroker" + "git.novox.be/novox/mesh-contracts/identity-and-access/go/seats/meshvault" catalogue "git.novox.be/novox/mesh-sdk/go/catalogue" math "math" net "net" @@ -2870,6 +2871,7 @@ func parseManifest(raw []byte, predefined catalogue.PredefinedList) (catalogue.M // facts about the catalogue and are checked at registration (CatalogueProblems). problems = append(problems, declaredSeatProblems(m)...) problems = append(problems, RunsAsProblems(m)...) + problems = append(problems, OwnPutProblems(m)...) problems = append(problems, ProcessBusProblems(m)...) problems = append(problems, seatEventProblems(m)...) problems = append(problems, ReadsHolderProblems(m)...) @@ -5284,6 +5286,23 @@ func RunsAsProblems(m catalogue.Manifest) []string { return problems } +// OwnPutProblems is what a manifest naming the vault's own-put is held to (design 47 H2, H-A-576, H-A-584, H-A-670): a +// module that invokes seat:mesh-vault.own-put declares runs-as, since the vault hands an own secret only to the account +// of the module's own. A get without runs-as is no problem here: the vault's refusal at the call is its one check. +func OwnPutProblems(m catalogue.Manifest) []string { + if m.RunsAs != "" { + return nil + } + var problems []string + for _, t := range m.Invokes { + if seat, verb, ok := catalogue.SeatInvoke(t); ok && seat == meshvault.Seat && verb == meshvault.VerbOwnPut { + problems = append(problems, fmt.Sprintf("%s invokes %s of the seat %s and declares no runs-as: the vault puts a module's own "+ + "secret only for the account the module runs as (design 47 H2 §822)", m.Module, verb, seat)) + } + } + return problems +} + // capabilityProblems are the words of a claim outside the vocabulary, and capabilities on a claim of a // seat that is not kinded. func capabilityProblems(module string, c catalogue.Claim, kinded bool) []string { diff --git a/modules/mesh-delivery-indexer/judge/rules_test.go b/modules/mesh-delivery-indexer/judge/rules_test.go index cb1e6aaea..ec6a1a964 100644 --- a/modules/mesh-delivery-indexer/judge/rules_test.go +++ b/modules/mesh-delivery-indexer/judge/rules_test.go @@ -4445,6 +4445,22 @@ func caseRunsAsIsAnAccountOfTheModulesOwn(t *testing.T) { } } +func caseOwnPutNeedsRunsAs(t *testing.T) { + for _, row := range []struct { + why, invoke, runsAs string + refused bool + }{ + {"a get without runs-as", "seat:mesh-vault.get", "", false}, + {"an own-put without runs-as", "seat:mesh-vault.own-put", "", true}, + {"an own-put with runs-as", "seat:mesh-vault.own-put", "shop", false}, + } { + got := OwnPutProblems(catalogue.Manifest{Module: "shop", RunsAs: row.runsAs, Invokes: []string{row.invoke}}) + if (len(got) != 0) != row.refused || (row.refused && !strings.Contains(got[0], "shop") && !strings.Contains(got[0], "own-put")) { + t.Errorf("%s: refused = %v, want %v", row.why, got, row.refused) + } + } +} + func caseRuntimeHealthIsRefusedWithoutAnAccountOfItsOwn(t *testing.T) { _, err := ParseManifest(ownAccountManifest(t, false, map[string]any{"kind": "tool", "tool": "keeper_health"})) if err == nil || !strings.Contains(err.Error(), "runtime-health") || !strings.Contains(err.Error(), "runs-as") { @@ -6535,6 +6551,7 @@ func TestRulesSecrets(t *testing.T) { t.Run("HearingARestrictedStreamNeedsAnAccountOfItsOwn", caseHearingARestrictedStreamNeedsAnAccountOfItsOwn) t.Run("ParseManifestForInputsReadsAValueFallingBackToAPredefinedKey", caseParseManifestForInputsReadsAValueFallingBackToAPredefinedKey) t.Run("RunsAsIsAnAccountOfTheModulesOwn", caseRunsAsIsAnAccountOfTheModulesOwn) + t.Run("OwnPutNeedsRunsAs", caseOwnPutNeedsRunsAs) t.Run("RuntimeHealthIsRefusedWithoutAnAccountOfItsOwn", caseRuntimeHealthIsRefusedWithoutAnAccountOfItsOwn) t.Run("TheBussAccountSaysNothingOnTheBus", caseTheBussAccountSaysNothingOnTheBus) t.Run("TheCatalogueCheckRefusesAnIdentityThatOverflowsWhatItRequires", caseTheCatalogueCheckRefusesAnIdentityThatOverflowsWhatItRequires) From 8f36311d082ca0e11e00fa29613d9400e07e32ad Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:20:00 +0100 Subject: [PATCH 043/141] P1 superseded-needs-its-revision: a superseded end with no revision ends the step could-not-run; a passed-over end says step-started with rerun by the runner Builds: design 47 H2 H-A-601, H-A-577 (3), H-A-583 (2), H-A-650 --- .../internal/pipeline/endopen_test.go | 23 +++++++++++++++---- .../internal/pipeline/steps.go | 12 ++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go index 1c07f6844..8ee35b946 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go @@ -78,7 +78,7 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { bs := stepSeatOf(t, builds.Seat) end := StepEnded{ID: "x1", Node: "n1", Pipeline: "main.117", Module: "a", Commit: "c1", Fingerprint: "src2:a1", Step: "build", Outcome: builds.StepEndedOutcomeSuperseded, Said: "a at src2:a1 is superseded by src2:a2, the newest entry heard on its first branch"} - if _, err := h.OnStepEnded(bs, bs.Prefix+"n1", end); err != nil { + if _, err := h.OnStepEndedRevised(bs, bs.Prefix+"n1", end, nil, nil, 120); err != nil { // the end names its superseding revision (H-A-601) t.Fatal(err) } p, _, _ := h.Store.Get("main.117") @@ -172,8 +172,8 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { h := &Hearer{Store: store, Say: func(string, any) error { return nil }, Now: func() time.Time { return t0 }, Release: func(key string) { released = append(released, key) }, View: newerView} bs := stepSeatOf(t, builds.Seat) - got, err := h.OnStepEnded(bs, bs.Prefix+"n1", StepEnded{ID: "x1", Node: "n1", Pipeline: "main.117", Module: "a", Commit: "c1", Fingerprint: "src2:a1", - Step: "build", Outcome: builds.StepEndedOutcomeSuperseded, Said: "a at src2:a1 is superseded by src2:a2"}) + got, err := h.OnStepEndedRevised(bs, bs.Prefix+"n1", StepEnded{ID: "x1", Node: "n1", Pipeline: "main.117", Module: "a", Commit: "c1", Fingerprint: "src2:a1", + Step: "build", Outcome: builds.StepEndedOutcomeSuperseded, Said: "a at src2:a1 is superseded by src2:a2"}, nil, nil, 120) if err != nil { t.Fatal(err) } @@ -197,7 +197,7 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { view int64 want string // left, again or held }{ - {"an end naming no revision (H-A-508 as before)", 0, 116, "left"}, + {"an end naming no revision (H-A-601: could not run)", 0, 116, "could-not-run"}, {"an older revision's entry", 116, 117, "again"}, {"the same revision's entry, the builder's kept revision (H-A-563)", 117, 117, "left"}, {"a newer revision's entry the view does not hold yet", 120, 118, "held"}, @@ -209,8 +209,12 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { var put []Asked var journal []string var waits []string // the waits said, by event and what they wait on (H-A-563) + var started []seat.StepEvent view := r.view say := func(subject string, body any) error { + if ev, ok := body.(seat.StepEvent); ok && strings.Contains(subject, seat.EventStepStarted) { + started = append(started, ev) + } if w, ok := body.(seat.Wait); ok { ev := seat.EventWaitHeld if strings.Contains(subject, seat.EventWaitEnded) { @@ -220,7 +224,7 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { } return nil } - h := &Hearer{Store: store, Say: say, Now: func() time.Time { return t0 }, + h := &Hearer{Store: store, Say: say, Now: func() time.Time { return t0 }, Name: "mesh-delivery-pipeline", View: func(string) (Half, bool) { return Half{Revision: view, Source: view, Entries: map[string]catalog.CatalogEntry{"a": {Module: "a", Fp: "src2:a2"}}}, true }, @@ -239,6 +243,11 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { return slices.Equal(p.Superseded, []string{"a"}) && p.Steps[0].Outcome == seat.StepResultOutcomeSuperseded && len(put) == 0 } switch r.want { + case "could-not-run": + // H2 H-A-601: no revision, no judging: the step ends could-not-run naming the builder and the words, the mover stays + if s := p.Steps[0]; len(p.Superseded) != 0 || s.Outcome != seat.StepResultOutcomeCouldNotRun || !strings.Contains(s.Why, "a superseded end without its revision") || len(put) != 0 { + t.Errorf("superseded %v, a's build %+v, put %+v; want the step could-not-run with the words, the mover staying", p.Superseded, s, put) + } case "left": if !left(p) { t.Errorf("superseded %v, a's build %+v, put %+v; want a left, its build superseded, nothing asked again", p.Superseded, p.Steps[0], put) @@ -248,6 +257,10 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { len(put) != 1 || put[0].ID != "x1again" || p.Outcome != seat.PipelineOutcomeRunning { t.Errorf("superseded %v, a's build %+v, put %+v, pipeline %s; want nothing left, the build asked again as x1again", p.Superseded, p.Steps[0], put, p.Outcome) } + // H2 H-A-577 (3): the passed-over end is said as a step-started with rerun and the runner as the caller + if len(started) != 1 || !started[0].Result.Rerun || started[0].Result.By != "mesh-delivery-pipeline" || started[0].Result.Ask != "x1again" { + t.Errorf("step-started said %+v, want one rerun by the runner of x1again", started) + } if !slices.ContainsFunc(journal, func(l string) bool { return strings.Contains(l, "passed over") }) { t.Errorf("the passed-over end is not said: %q", journal) } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go index ec3d1201d..cf9476176 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go @@ -379,6 +379,11 @@ func (h *Hearer) OnStepEndedRevised(bs StepSeat, subject string, ev StepEnded, s if err := h.PutAgain(ev.Pipeline, *a); err != nil { h.logf("%s: the build of %s asked again as %s is written and not put, put again at the next start: %v", ev.Pipeline, s.Module, a.ID, err) } + // The passed-over end is said as an event, not only in the journal (design 47 H2 H-A-577 (3)): step-started with rerun + // and the runner as the caller. + if err := h.say(seat.EventStepStarted, p, s); err != nil { + h.logf("%s: the step-started of %s asked again is not said: %v", ev.Pipeline, s.Module, err) + } return p, nil } h.logf("%s: %s's build ended superseded (%s), passed over: %s; %s (H-A-555, H-A-561)", ev.Pipeline, s.Module, ev.Said, passed, why) @@ -399,6 +404,11 @@ func (h *Hearer) OnStepEndedRevised(bs StepSeat, subject string, ev StepEnded, s } return p, nil } + } else if supersededBuild(*s, ev.Outcome) { + // A superseded end naming no revision is no end the runner can judge (design 47 H2 H-A-601, H-A-650): the step ends could-not-run, + // naming the builder, and a rerun asks it again. + h.logf("%s: %s's build ended superseded (%s) with no revision: the step ends could-not-run (H-A-601)", ev.Pipeline, s.Module, ev.Said) + ev.Outcome, ev.Said = nodebuildgo.StepEndedOutcomeCouldNotRun, fmt.Sprintf("the builder on %s ended it superseded: a superseded end without its revision (%s)", node, ev.Said) } s.Outcome, s.Node, s.Why, s.Rerun, s.By, s.Ended = ev.Outcome, node, ev.Said, ev.Rerun, ev.By, &now if len(shared) > 0 { @@ -901,6 +911,8 @@ func (h *Hearer) supersededAgain(p *seat.Pipeline, i int, ev StepEnded, passed s return nil, fmt.Sprintf("its build ended superseded (%s), though %s, and it cannot be asked again: %v", ev.Said, passed, err) } s.Ask, s.AskedAt, s.TakenAt, s.Node = a.ID, &now, nil, "" + // The step asked again is a rerun by the runner itself, said as such by its step-started (design 47 H2 H-A-577 (3)). + s.Rerun, s.By = true, h.Name return a, "" } From 3baef9df5b06e01b464f64ae3e2eb4e298f08714 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:20:01 +0100 Subject: [PATCH 044/141] I11 entry-needs: CatalogEntryOf writes the entry's needs from the module's value, ModuleValueOf reads them back Builds: design 47 H2 H-A-682 (1), H-A-568, H-A-569 (2) --- .../internal/index/catalog_graph.go | 11 ++++++++--- .../internal/index/catalog_graph_test.go | 13 +++++++++++++ .../internal/index/toolchains_test.go | 4 ++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_graph.go b/modules/mesh-delivery-indexer/internal/index/catalog_graph.go index 93ff2d057..203b39ce3 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_graph.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_graph.go @@ -35,6 +35,11 @@ func CatalogEntryOf(module string, cur meshcatalog.ModulesByModuleValue, m catal Commit: cur.Commit, Manifest: manifestWhole(raw), ManifestDigest: meshcatalogclient.EntryManifestDigest(cur.Manifest), Verdict: cur.Verdict, Fp: n.FP, None: n.None, Bases: n.Bases, Packages: maps.Clone(cur.Packages), Provides: n.Provides, Requires: n.Requires, Awaits: n.Awaits, Invokes: n.Invokes, Serves: n.Serves, LeftOut: n.LeftOut, Main: MainOf(m), Contributes: contributesOf(m), Class: m.Class} + // needs are the reader capabilities the module's value names (design 47 H2, H-A-682 (1)): its manifest's words, forms + // and seat names and its templates' forms, sorted, absent when empty. + if len(cur.Needs) > 0 { + e.Needs = slices.Compact(slices.Sorted(slices.Values(cur.Needs))) + } // requires names every requirement as catalogue.Manifest.Wants lists them, optional ones and those only contributes names // included, since contributing to a requirement is requiring it (design 47 G §709, A-229). for _, r := range m.Wants() { @@ -66,11 +71,11 @@ func CatalogEntryOf(module string, cur meshcatalog.ModulesByModuleValue, m catal // ModuleValueOf is the module's value as the indexer computes with it, read back from its catalog graph entry: the // inverse of CatalogEntryOf, by which the indexer's view of the trunk is the newest trunk revision's entries (the lead's -// ruling on milestone 47/G finding 1; ADR 0656 §6: one form of the fact). The old line's fields (the old-form -// fingerprint, the reader needs) are not kept. +// ruling on milestone 47/G finding 1; ADR 0656 §6: one form of the fact), the reader needs included (H-A-682 (1)). The old +// line's old-form fingerprint is not kept. func ModuleValueOf(e meshcatalog.CatalogEntry) meshcatalog.ModulesByModuleValue { v := meshcatalog.ModulesByModuleValue{V: keys.Version, Repository: e.Repository, Path: e.Path, Commit: e.Commit, Manifest: meshcatalogclient.BareManifestDigest(e.ManifestDigest), - Verdict: e.Verdict, Fp2: e.Fp, None2: e.None, Packages: maps.Clone(e.Packages)} + Verdict: e.Verdict, Fp2: e.Fp, None2: e.None, Packages: maps.Clone(e.Packages), Needs: slices.Clone(e.Needs)} if in := e.Inputs; in != nil { v.Toolchains, v.Paths, v.Problems, v.Warnings, v.Unknown = maps.Clone(in.Toolchains), maps.Clone(in.Paths), in.Problems, in.Warnings, in.Unknown if in.From != nil { diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_graph_test.go b/modules/mesh-delivery-indexer/internal/index/catalog_graph_test.go index 69dca5113..f54f70885 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_graph_test.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_graph_test.go @@ -109,6 +109,19 @@ func TestAnEntryNamesWhatItContributesToAndEveryRequirement(t *testing.T) { if e := CatalogEntryOf("kv", meshcatalog.ModulesByModuleValue{}, catalogue.Manifest{}, "", graph.Node{}); e.Contributes != nil || e.Class != "" { t.Errorf("an entry of a manifest contributing nothing and naming no class carries contributes %v, class %q", e.Contributes, e.Class) } + // Design 47 H2 H-A-682 (1): a module whose value names needs carries them sorted on its entry, and the value read back + // from the entry names them; a value with none leaves the entry's needs absent. + needs := []string{"seat:node-engine", "form:dir", "word:runs-as"} + e = CatalogEntryOf("web", meshcatalog.ModulesByModuleValue{Needs: needs}, m, raw, graph.Node{}) + if want := []string{"form:dir", "seat:node-engine", "word:runs-as"}; !reflect.DeepEqual(e.Needs, want) { + t.Errorf("needs = %v, want %v", e.Needs, want) + } + if back := ModuleValueOf(e); !reflect.DeepEqual(back.Needs, e.Needs) { + t.Errorf("the value read back names needs %v, want %v", back.Needs, e.Needs) + } + if e := CatalogEntryOf("web", meshcatalog.ModulesByModuleValue{}, m, raw, graph.Node{}); e.Needs != nil { + t.Errorf("a value with no needs gives the entry needs %v", e.Needs) + } // Design 47 H2 §810, H-A-394 (1): the entry carries its manifest's class, which the gate reads. if e := CatalogEntryOf("kv", meshcatalog.ModulesByModuleValue{}, catalogue.Manifest{Class: catalogue.ClassCore}, "", graph.Node{}); e.Class != catalogue.ClassCore { t.Errorf("the entry of a core manifest carries the class %q, want core", e.Class) diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go index 9ee54972a..0be4f0fde 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains_test.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains_test.go @@ -342,10 +342,10 @@ func TestBasesAreComputedFirstAndNoFingerprintTakesTheBuilder(t *testing.T) { // } // W3.1's inputs (the lead's ruling on finding 1): an entry carries what the next revision is computed from (the // fingerprint's inputs, the toolchains used, the package versions), so the module's value read back from it is the - // value modules held, but for the old line's fields. + // value modules held, but for the old-form fingerprint. for name := range mods.vals { m, _ := moduleOf(t, mods, name) - m.Fp, m.None, m.Needs = "", "", nil + m.Fp, m.None = "", "" if back := ModuleValueOf(entries[name]); !reflect.DeepEqual(back, m) { t.Errorf("%s read back from its entry = %+v, want %+v", name, back, m) } From 7401951a868a303df5077bce995a5cdcce45053f Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:20:17 +0100 Subject: [PATCH 045/141] B20 published-says-fingerprint: a package-published said for a reservation names its fingerprint Builds: design 47 H2 H-A-707 (6) --- modules/mesh-delivery-builder/internal/versions/reserve.go | 2 +- .../mesh-delivery-builder/internal/versions/reserve_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/mesh-delivery-builder/internal/versions/reserve.go b/modules/mesh-delivery-builder/internal/versions/reserve.go index b9d10005c..8a9ca6fa0 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve.go @@ -882,7 +882,7 @@ type Marked struct { func (m Marked) PackagePublished(digest string, at time.Time) meshbuilds.PackagePublished { at = at.UTC() return meshbuilds.PackagePublished{V: 1, Artifact: m.Artifact, At: &at, Branch: m.Reserved.Branch, Source: m.Reserved.Source, Revision: m.Reserved.Revision, Module: m.Reserved.Module, - Version: m.Reserved.Version, Digest: digest, Dependencies: m.Reserved.Dependencies[m.Artifact]} + Version: m.Reserved.Version, Digest: digest, Fingerprint: m.Reserved.Fingerprint, Dependencies: m.Reserved.Dependencies[m.Artifact]} } // Published takes a registry seat's published in, as PublishedRead does, answering the artifacts newly marked and the keys it is diff --git a/modules/mesh-delivery-builder/internal/versions/reserve_test.go b/modules/mesh-delivery-builder/internal/versions/reserve_test.go index ee3a764a7..836d74ca3 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve_test.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve_test.go @@ -112,7 +112,7 @@ func TestReservationIsReadAndMarkedPublished(t *testing.T) { ctx := context.Background() store := &reserveMem{mem: newMem()} r := &Reserver{Store: store, ReleasedOf: func(context.Context, string) ([]string, error) { return []string{"1.4.2"}, nil }} - v, err := r.Reserve(ctx, "m", "1.4", []string{"m:a", "m:b"}, Source{Branch: "main", Revision: 41, CatalogRevision: 44}) + v, err := r.Reserve(ctx, "m", "1.4", []string{"m:a", "m:b"}, Source{Branch: "main", Revision: 41, CatalogRevision: 44, Fingerprint: "src2:f"}) if err != nil || v.Version != "1.4.3" { t.Fatalf("reserved %q (%v), want 1.4.3", v.Version, err) } @@ -146,7 +146,7 @@ func TestReservationIsReadAndMarkedPublished(t *testing.T) { at := time.Unix(100, 0) said := marked[0].PackagePublished("sha256:aa", at) atUTC := at.UTC() - if wantSaid := (meshbuilds.PackagePublished{V: 1, Artifact: "m:a", At: &atUTC, Branch: "main", Source: 41, Revision: 44, Module: "m", Version: "1.4.3", Digest: "sha256:aa", Dependencies: deps}); !reflect.DeepEqual(said, wantSaid) { + if wantSaid := (meshbuilds.PackagePublished{V: 1, Artifact: "m:a", At: &atUTC, Branch: "main", Source: 41, Revision: 44, Module: "m", Version: "1.4.3", Digest: "sha256:aa", Fingerprint: "src2:f", Dependencies: deps}); !reflect.DeepEqual(said, wantSaid) { t.Errorf("package-published = %+v, want %+v", said, wantSaid) } if marked, _, _ := r.Published(ctx, "m-a", "1.4.3", "sha256:other"); len(marked) != 0 { From ca91d4e85bb770055b9854df062367e1a3002b19 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:20:45 +0100 Subject: [PATCH 046/141] I4 consumes-on-entry: an entry's consumes equals its manifest's Builds: design 47 H2 H-A-621 --- .../mesh-delivery-indexer/internal/index/catalog_graph.go | 2 +- .../internal/index/catalog_graph_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_graph.go b/modules/mesh-delivery-indexer/internal/index/catalog_graph.go index 203b39ce3..dd51ae937 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_graph.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_graph.go @@ -33,7 +33,7 @@ const CatalogEntryLayout = 1 func CatalogEntryOf(module string, cur meshcatalog.ModulesByModuleValue, m catalogue.Manifest, raw string, n graph.Node) meshcatalog.CatalogEntry { e := meshcatalog.CatalogEntry{V: CatalogEntryLayout, Module: module, Repository: cur.Repository, Path: cur.Path, Commit: cur.Commit, Manifest: manifestWhole(raw), ManifestDigest: meshcatalogclient.EntryManifestDigest(cur.Manifest), Verdict: cur.Verdict, Fp: n.FP, None: n.None, Bases: n.Bases, - Packages: maps.Clone(cur.Packages), Provides: n.Provides, Requires: n.Requires, Awaits: n.Awaits, Invokes: n.Invokes, + Packages: maps.Clone(cur.Packages), Provides: n.Provides, Requires: n.Requires, Awaits: n.Awaits, Invokes: n.Invokes, Consumes: slices.Clone(m.Consumes), Serves: n.Serves, LeftOut: n.LeftOut, Main: MainOf(m), Contributes: contributesOf(m), Class: m.Class} // needs are the reader capabilities the module's value names (design 47 H2, H-A-682 (1)): its manifest's words, forms // and seat names and its templates' forms, sorted, absent when empty. diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_graph_test.go b/modules/mesh-delivery-indexer/internal/index/catalog_graph_test.go index f54f70885..3f9ab847c 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_graph_test.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_graph_test.go @@ -109,6 +109,14 @@ func TestAnEntryNamesWhatItContributesToAndEveryRequirement(t *testing.T) { if e := CatalogEntryOf("kv", meshcatalog.ModulesByModuleValue{}, catalogue.Manifest{}, "", graph.Node{}); e.Contributes != nil || e.Class != "" { t.Errorf("an entry of a manifest contributing nothing and naming no class carries contributes %v, class %q", e.Contributes, e.Class) } + // Design 47 H2 H-A-621: an entry's consumes equals its manifest's, beside its invokes. + cm := catalogue.Manifest{Consumes: []string{"mesh-delivery.merge-called", "mesh-builds.step-ended"}} + if e := CatalogEntryOf("web", meshcatalog.ModulesByModuleValue{}, cm, "", graph.Node{}); !reflect.DeepEqual(e.Consumes, cm.Consumes) { + t.Errorf("consumes = %v, want %v", e.Consumes, cm.Consumes) + } + if e := CatalogEntryOf("web", meshcatalog.ModulesByModuleValue{}, m, raw, graph.Node{}); e.Consumes != nil { + t.Errorf("a manifest consuming nothing gives the entry consumes %v", e.Consumes) + } // Design 47 H2 H-A-682 (1): a module whose value names needs carries them sorted on its entry, and the value read back // from the entry names them; a value with none leaves the entry's needs absent. needs := []string{"seat:node-engine", "form:dir", "word:runs-as"} From dd78f05b56ad159d39ba453072db084a86423235 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:20:56 +0100 Subject: [PATCH 047/141] P8 publish-reaches-sharing-pipelines: a package-published marks every running pipeline of its branch that moves the module at its fingerprint Builds: design 47 H2 H-A-707 (6) --- .../internal/pipeline/start.go | 44 +++++++++++++++++++ .../internal/pipeline/start_test.go | 13 +++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start.go b/modules/mesh-delivery-pipeline/internal/pipeline/start.go index 2f3184172..3f672fc36 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start.go @@ -1232,6 +1232,24 @@ func (s *Starter) heardPublished(ev builds.PackagePublished, view func(branch st if !ok { return seat.Pipeline{}, false, nil } + p, held, err := s.markPublished(key, ev, view) + if !held { + return p, false, err + } + // The same publish reaches every other running pipeline of the branch that moves the publishing module at the fingerprint it + // names, so a pipeline sharing the build releases its waiting movers too (design 47 H2 H-A-707 (6)). + if ev.Fingerprint != "" { + if serr := s.markSharing(ev, key, view); serr != nil { + s.logf("a package-published of %s at %s did not reach every pipeline sharing the build: %v", ev.Artifact, ev.Fingerprint, serr) + err = errors.Join(err, serr) + } + } + return p, true, err +} + +// markPublished writes ev into the publishing mover's published of the running pipeline key and releases the movers that waited for +// it; it answers that pipeline, read, and whether one is held. +func (s *Starter) markPublished(key string, ev builds.PackagePublished, view func(branch string) (Half, bool)) (seat.Pipeline, bool, error) { for { p, rev, err := s.Store.Get(key) if err != nil { @@ -1255,6 +1273,32 @@ func (s *Starter) heardPublished(ev builds.PackagePublished, view func(branch st } } +// markSharing marks ev in every running pipeline of its branch, but except, whose mover of the publishing module is at the +// fingerprint the publish names (design 47 H2 H-A-707 (6)). +func (s *Starter) markSharing(ev builds.PackagePublished, except string, view func(branch string) (Half, bool)) error { + pkeys, err := s.Store.Keys(keys.EscapeName(ev.Branch) + ".*") + if err != nil { + return fmt.Errorf("the pipelines of %s are not listed: %w", ev.Branch, err) + } + var errs []error + for _, k := range pkeys { + if k == except { + continue + } + p, _, err := s.Store.Get(k) + if err != nil || p.Branch != ev.Branch || p.Run != "" || p.Outcome != seat.PipelineOutcomeRunning { + continue + } + if i := slices.IndexFunc(p.Movers, func(m seat.Mover) bool { return m.Module == ev.Module }); i < 0 || p.Movers[i].Fingerprint != ev.Fingerprint { + continue + } + if _, _, err := s.markPublished(k, ev, view); err != nil { + errs = append(errs, err) + } + } + return errors.Join(errs...) +} + // sourcePipeline is the key of branch's pipeline of the lowest-numbered revision of source, the take-in's (H-A-213 (4), // H-A-218): a pipeline is keyed by its revision, so one of a source is found by the source it names, never by its key. func (s *Starter) sourcePipeline(branch string, source int64) (string, bool) { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go index 44440d2c3..cfd8622aa 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/start_test.go @@ -517,12 +517,16 @@ func testATakeInOfTheOldFormIsRefused(t *testing.T) { // older builder) into its source's lowest-numbered revision, the take-in's. func TestAPublishIsTakenIntoThePipelineOfItsRevision(t *testing.T) { mem := memStore{} - for _, r := range []int64{7, 8} { + for _, r := range []int64{7, 8, 9} { + fp := "src2:a" // the pipelines of revisions 7 and 8 move mesh-sdk at one fingerprint, revision 9's at another (H-A-707 (6)) + if r == 9 { + fp = "src2:b" + } mem[Key("main", r)] = struct { p seat.Pipeline rev uint64 }{seat.Pipeline{Pipeline: Key("main", r), Branch: "main", Source: 4, Revision: r, Outcome: seat.PipelineOutcomeRunning, - Movers: []seat.Mover{{Module: "mesh-sdk"}}}, 1} + Movers: []seat.Mover{{Module: "mesh-sdk", Fingerprint: fp}}}, 1} } s := &Starter{Pipelines: memCreated{mem}, Store: mem, Say: func(string, any) error { return nil }} view := func(string) (Half, bool) { return Half{Revision: 8}, true } @@ -535,6 +539,11 @@ func TestAPublishIsTakenIntoThePipelineOfItsRevision(t *testing.T) { if err := s.Published(ev, view); err != nil || len(published("main.7")) != 1 || len(published("main.8")) != 1 { t.Errorf("a publish naming no revision (%v): main.7 %v, main.8 %v; want main.7's, the source's lowest", err, published("main.7"), published("main.8")) } + // H2 H-A-707 (6): a publish naming the fingerprint reaches every running pipeline of the branch that moves the module at it + ev = builds.PackagePublished{Artifact: "mesh-sdk:py", Module: "mesh-sdk", Branch: "main", Source: 4, Revision: 8, Version: "0.1.18", Fingerprint: "src2:a"} + if err := s.Published(ev, view); err != nil || len(published("main.8")) != 2 || len(published("main.7")) != 2 || len(published("main.9")) != 0 { + t.Errorf("a publish at src2:a (%v): main.8 %v, main.7 %v, main.9 %v; want both pipelines moving it marked and revision 9's not", err, published("main.8"), published("main.7"), published("main.9")) + } } // racingStore is memStore whose first Update is preceded by before, a write another part makes between a read and its write. From b7a3d85514ae25b0b6570aae0d1f26aae4b2ac2a Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:21:33 +0100 Subject: [PATCH 048/141] B14 reserve-done-goes: builder_reserve_done and its mode go whole; a build with no version names builder_build_again Builds: design 47 H2 H-A-661, H-A-665, H-A-706 (DQ-39) --- .../mesh-delivery-builder-tools/reserved.go | 29 +-------- .../mesh-delivery-builder-tools/waits_test.go | 54 --------------- .../cmd/mesh-delivery-builder/main.go | 2 - .../cmd/mesh-delivery-builder/reasks.go | 10 +-- .../cmd/mesh-delivery-builder/reserve.go | 19 ------ .../cmd/mesh-delivery-builder/reserve_test.go | 57 ---------------- .../internal/build/numbers.go | 65 ------------------- .../internal/build/reservedone_test.go | 56 ---------------- .../internal/build/step.go | 4 +- .../internal/build/step_test.go | 5 +- .../internal/build/stuck.go | 18 ----- .../internal/versions/again.go | 3 - .../internal/versions/reserve.go | 6 -- .../mesh-delivery-builder/manifest_test.go | 2 +- modules/mesh-delivery-builder/module.json | 1 - 15 files changed, 9 insertions(+), 322 deletions(-) delete mode 100644 modules/mesh-delivery-builder/internal/build/reservedone_test.go diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reserved.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reserved.go index 39b3bf871..e37488a42 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reserved.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/reserved.go @@ -13,7 +13,7 @@ import ( "mesh-delivery-builder/internal/versions" ) -// reservedTools are builder_reserved, builder_reserved_drop and builder_reserve_done (A-455) (design 47 G section 369), served as tools of the bundle. The drop is a hand act: it is recorded in the hand-act log first, then written to +// reservedTools are builder_reserved and builder_reserved_drop (design 47 G section 369), served as tools of the bundle. The drop is a hand act: it is recorded in the hand-act log first, then written to // reasks for the builder, which owns the reservations, to answer. // // The seat's verb reserved is the builder's process's (design 47 G A-115, A-127), not the bundle's. @@ -52,32 +52,5 @@ func reservedTools(rr versions.Reader, ask queueAsker, now func() time.Time, act } return map[string]any{"key": key, "answer": a.Answer}, nil }}, - {Name: versions.ReserveDoneTool, Description: versions.ReserveDoneDescription, - Input: map[string]any{"type": "object", "required": []string{"module", "fp", "why"}, "properties": map[string]any{ - "module": map[string]any{"type": "string", "description": "the module"}, - "fp": map[string]any{"type": "string", "description": "the fingerprint of its done trunk build"}, - "why": map[string]any{"type": "string", "description": "why, in plain words"}}}, - Run: func(args map[string]any) (any, error) { - key, value, err := build.NewReserveDone(str(args, "module"), str(args, "fp"), str(args, "why"), stdio.CallerOf(args), now()) - if err != nil { - return nil, err - } - if _, err := acts.Record(meshhandactsclient.Request{What: fmt.Sprintf("reserved a version for the done build of %s at %s by hand", str(args, "module"), str(args, "fp")), - Why: str(args, "why"), Cause: versions.ReserveDoneTool, Verb: "reserve-done"}); err != nil { - return nil, fmt.Errorf("the hand act was not recorded through mesh-hand-acts, so nothing was reserved: %w", err) - } - raw, err := ask(key, value) - if err != nil { - return nil, err - } - a, err := build.DecodeReAsk(raw) - if err != nil { - return nil, err - } - if a.Refused { - return nil, errors.New(a.Answer) - } - return map[string]any{"key": key, "answer": a.Answer}, nil - }}, } } diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/waits_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/waits_test.go index a65a854fa..e782acf23 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/waits_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder-tools/waits_test.go @@ -2,7 +2,6 @@ package main import ( "encoding/json" - "errors" "strings" "testing" "time" @@ -45,56 +44,3 @@ func TestWaitsToolsListTheWaitsAndReleaseAfterTheHandAct(t *testing.T) { t.Fatalf("release: %v, %d recorded, asked %+v", err, recorded, asked) } } - -// Design 47 G A-455: builder_reserve_done records the hand act first and only then asks the builder through reasks; the builder's -// answer (the version and its queued publish) is the tool's answer, its refusal the tool's error, and an act that was not -// recorded asks nothing. -func TestReserveDoneRecordsTheHandActFirstAndAnswersTheBuilders(t *testing.T) { - var order []string - var asked []build.ReAsk - reply := func(refuse bool) func(string, []byte) (json.RawMessage, error) { - return func(key string, value []byte) (json.RawMessage, error) { - order = append(order, "asked") - a, _ := build.DecodeReAsk(value) - asked = append(asked, a) - a.Answered, a.Answer, a.Refused = time.Now(), "reserved 0.1.13 for node-tools and queued 1 versions to publish: node-tools@0.1.13", refuse - if refuse { - a.Answer = "the build key is not done" - } - return json.Marshal(a) - } - } - record := func(fail bool) meshhandactsclient.Recorder { - return meshhandactsclient.Recorder{Ask: func(string, any) (json.RawMessage, error) { - order = append(order, "recorded") - if fail { - return nil, errors.New("no responders") - } - return json.RawMessage(`{}`), nil - }} - } - run := func(ask func(string, []byte) (json.RawMessage, error), acts meshhandactsclient.Recorder, args map[string]any) (any, error) { - for _, tl := range reservedTools(versions.Reader{}, ask, time.Now, acts) { - if tl.Name == versions.ReserveDoneTool { - return tl.Run(args) - } - } - t.Fatal("the bundle serves no builder_reserve_done") - return nil, nil - } - args := map[string]any{"module": "node-tools", "fp": "src2:7df8", "why": "its build ended done with no version"} - out, err := run(reply(false), record(false), args) - if err != nil || len(order) != 2 || order[0] != "recorded" || order[1] != "asked" || asked[0].Mode != build.ModeReserveDone || asked[0].Name != "node-tools" || asked[0].FP != "src2:7df8" { - t.Fatalf("answer %v, %v; order %v, asked %+v", out, err, order, asked) - } - if ans := out.(map[string]any)["answer"].(string); !strings.Contains(ans, "reserved 0.1.13") || !strings.Contains(ans, "queued 1 versions") { - t.Errorf("the answer %q names no version and queued publish", ans) - } - if _, err := run(reply(true), record(false), args); err == nil || !strings.Contains(err.Error(), "not done") { - t.Errorf("the builder's refusal is not the tool's error: %v", err) - } - order = nil - if _, err := run(reply(false), record(true), args); err == nil || len(order) != 1 || order[0] != "recorded" { - t.Errorf("an unrecorded act was asked of the builder: %v, %v", err, order) - } -} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index f4b9fb859..8a314ba56 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -326,8 +326,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro acts.PublishDrop = func(ctx context.Context, module, version, by, why string) (string, error) { return pq.drop(ctx, items, module, version, by, why) } - // builder_reserve_done: a done trunk build that reserved none is given a version, and its publish queued as publish again does. - acts.ReserveDone = reserveDoneAct(b.ReserveDone, republish.Republish, logger.Printf) // The operator is asked once a key's event builds are spent (design 47 G §568): the builder's asker on the seat operator-channel. decided := &decisions{subject: oc.SubjectDecided(cred.Module)} retakeActed := awaitedReserved{awaitedState{b: actedKV, bucket: own.acted}} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go index bffe75841..80af595ff 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reasks.go @@ -65,7 +65,7 @@ func reAsked(ctx context.Context, b askAgainer, acts versions.Acts, items *publi released(ctx, b, kv, e, r, logf) return } - if r.Mode == build.ModeRepublish || r.Mode == build.ModePublishDrop || r.Mode == build.ModeOldFormDrop || r.Mode == build.ModeReservedDrop || r.Mode == build.ModeReserveDone { + if r.Mode == build.ModeRepublish || r.Mode == build.ModePublishDrop || r.Mode == build.ModeOldFormDrop || r.Mode == build.ModeReservedDrop { // A version's hand act (design 51 *Tools of the builder*) may build again, so it is answered beside the watch. go versionActed(ctx, acts, kv, e, r, logf) return @@ -196,7 +196,7 @@ func emitBuildEnded(ctx context.Context, js jetstream.JetStream, cred process.Ac return nil } -// versionActed answers a reasks value of builder_publish_again, builder_publish_drop, builder_reserve_done, builder_reserved_drop or builder_old_form's drop, a hand act said in the log. +// versionActed answers a reasks value of builder_publish_again, builder_publish_drop, builder_reserved_drop or builder_old_form's drop, a hand act said in the log. func versionActed(ctx context.Context, acts versions.Acts, kv jetstream.KeyValue, e jetstream.KeyValueEntry, r build.ReAsk, logf func(string, ...any)) { var err error if r.Mode == build.ModeRepublish { @@ -215,12 +215,6 @@ func versionActed(ctx context.Context, acts versions.Acts, kv jetstream.KeyValue } else { r.Answer, err = act(ctx, r.Module, r.Version, r.By, r.Why) } - } else if r.Mode == build.ModeReserveDone { - if acts.ReserveDone == nil { - err = errors.New("this builder keeps no reservations") - } else { - r.Answer, err = acts.ReserveDone(ctx, r.Name, r.FP, r.By, r.Why, r.At) - } } else if r.Mode == build.ModeReservedDrop { if acts.DropReserved == nil { err = errors.New("this builder keeps no reservations") diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go index 3d4051301..b2c65f54c 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve.go @@ -582,25 +582,6 @@ func (rv *reservations) noMark(ctx context.Context, o versions.Outcome, read []v return strings.Join(out, "; ") + " (" + standing + "; a published heard before the build recorded its digests is kept until it does)" } -// reserveDoneAct is builder_reserve_done's act (design 47 G A-455): the next version of the series is reserved for a done trunk build -// that reserved none, and its publish is queued as builder_publish_again queues it. Its answer says the version and the queued -// publishes; a reservation whose publish could not be queued is said so, with the tool that queues it. -func reserveDoneAct(reserve func(ctx context.Context, module, fp string) (versions.ReservedVersion, error), - republish func(ctx context.Context, module, version string) ([]string, error), logf func(string, ...any)) func(ctx context.Context, module, fp, by, why string, at time.Time) (string, error) { - return func(ctx context.Context, module, fp, by, why string, at time.Time) (string, error) { - res, err := reserve(ctx, module, fp) - if err != nil { - return "", err - } - logf("%s at %s: version %s is reserved by hand (%s, %s) for the done build", module, fp, res.Version, by, why) - queued, err := republish(ctx, module, res.Version) - if err != nil { - return "", fmt.Errorf("%s is reserved for %s at %s, but its publish is not queued (builder_publish_again queues it): %w", res.Version, module, fp, err) - } - return fmt.Sprintf("reserved %s for %s at %s and queued %d versions to publish: %s; builder_publish_queue shows them", res.Version, module, fp, len(queued), strings.Join(queued, ", ")), nil - } -} - // ReleasedFor says whether a version was released for the build of fingerprint (design 47 G A-456a). func (rv *reservations) ReleasedFor(ctx context.Context, module, fingerprint string) (bool, error) { return rv.r.ReleasedFor(ctx, module, fingerprint) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go index 4d8146bdf..e7ef9939d 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go @@ -20,7 +20,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" stdio "git.novox.be/novox/mesh-sdk/go" - "mesh-delivery-builder/internal/build" "mesh-delivery-builder/internal/versions" ) @@ -667,62 +666,6 @@ func (e ansEntry) Revision() uint64 { return 1 } func (e ansEntry) Value() []byte { return e.value } func (e ansEntry) Operation() jetstream.KeyValueOp { return jetstream.KeyValuePut } -// TestAReserveDoneIsAnsweredWithTheVersionAndItsQueuedPublish: design 47 G A-455 — the reasks value of builder_reserve_done reaches -// the act, which reserves for the done build and queues the publish as publish again does, and its answer names both; a -// refusal of the reserving queues nothing and is the answer; a publish that cannot be queued says the version is reserved. -func TestAReserveDoneIsAnsweredWithTheVersionAndItsQueuedPublish(t *testing.T) { - ctx := context.Background() - var queued []string - var logged []string - logf := func(f string, a ...any) { logged = append(logged, fmt.Sprintf(f, a...)) } - reserve := func(_ context.Context, module, fp string) (versions.ReservedVersion, error) { - if fp == "refused" { - return versions.ReservedVersion{}, fmt.Errorf("the build key of %s at %s is not done", module, fp) - } - return versions.ReservedVersion{Module: module, Version: "0.1.13", Fingerprint: fp}, nil - } - republish := func(_ context.Context, module, version string) ([]string, error) { - if module == "nope" { - return nil, fmt.Errorf("the queue is full") - } - queued = append(queued, module+"@"+version) - return []string{module + "@" + version}, nil - } - acts := versions.Acts{ReserveDone: reserveDoneAct(reserve, republish, logf)} - for _, c := range []struct { - module, fp, want string - refused bool - }{ - {"node-tools", "src2:7df8", "reserved 0.1.13 for node-tools at src2:7df8 and queued 1 versions to publish: node-tools@0.1.13", false}, - {"node-tools", "refused", "not done", true}, - {"nope", "src2:1", "0.1.13 is reserved for nope at src2:1, but its publish is not queued", true}, - } { - value, err := json.Marshal(build.ReAsk{V: 1, Why: "w", By: "me", Mode: build.ModeReserveDone, Name: c.module, FP: c.fp}) - if err != nil { - t.Fatal(err) - } - kv := &ansKV{wrote: make(chan []byte, 1)} - // reAsked sends a reserve-done to the version acts (b is not asked), and the answer is written back to the key. - reAsked(ctx, nil, acts, nil, kv, ansEntry{key: "reserve-done." + c.module, value: value}, logf) - var wrote []byte - select { - case wrote = <-kv.wrote: - case <-time.After(10 * time.Second): - t.Fatalf("%s at %s: no answer was written to the key", c.module, c.fp) - } - var got build.ReAsk - if err := json.Unmarshal(wrote, &got); err != nil || got.Refused != c.refused || !strings.Contains(got.Answer, c.want) || got.Answered.IsZero() { - t.Errorf("%s at %s: written %s (%v), want refused=%v containing %q", c.module, c.fp, wrote, err, c.refused, c.want) - } - } - if !slices.Equal(queued, []string{"node-tools@0.1.13"}) { - t.Errorf("queued %v, want only node-tools@0.1.13", queued) - } - if !slices.ContainsFunc(logged, func(l string) bool { return strings.Contains(l, "0.1.13 is reserved by hand") }) { - t.Errorf("the reserving by hand is not said in the log: %q", logged) - } -} - // TestARegistrysRecordEndsOrMovesAPublish: design 47 H H-A-274 — the artifacts a registry's record holds with the built digest are // marked published from it and package-published is said, as a heard published would; H-A-275 — a done build whose number a // registry holds at another digest (H-A-279) has its number withdrawn, raises version-held-elsewhere naming both digests, and is diff --git a/modules/mesh-delivery-builder/internal/build/numbers.go b/modules/mesh-delivery-builder/internal/build/numbers.go index e96864a3b..640e62fb4 100644 --- a/modules/mesh-delivery-builder/internal/build/numbers.go +++ b/modules/mesh-delivery-builder/internal/build/numbers.go @@ -2,7 +2,6 @@ package build import ( "context" - "errors" "fmt" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" "git.novox.be/novox/mesh-sdk/go/catalogue" @@ -182,67 +181,3 @@ func (b *Builder) reserve(ctx context.Context, module string, m meshcatalog.Modu b.logf("%s: version %s is reserved for this build", module, res.Version) return res, true } - -// ReserveDone is builder_reserve_done (design 47 G A-455): a done trunk build of the first watched branch that reserved no -// version (its key is done, so a look never reserves for it, and a done key cannot be built again) reserves the next version of -// its series now, with the digests the done key holds, as a build that started would, and its build ends with every digest -// recorded. It answers the reserved version; the caller queues its publish (versions.Republisher). A fingerprint whose key is not -// done, whose entry no watched branch carries now, that is no first branch's, or that holds a reservation already is refused, saying which. -func (b *Builder) ReserveDone(ctx context.Context, module, fp string) (versions.ReservedVersion, error) { - b.init() - if b.Reserved == nil { - return versions.ReservedVersion{}, errors.New("this builder reserves no versions") - } - key, err := builds.BuilderBuildKey(module, fp) - if err != nil { - return versions.ReservedVersion{}, err - } - b.mu.Lock() - var m meshcatalog.ModulesByModuleValue - found := false - for hk, v := range b.heard { - if strings.HasSuffix(hk, "\x00"+module) && v.Fp2 == fp { - m, found = v, true - } - } - trunk, first := b.trunkFP[key], b.origin[key].First - b.mu.Unlock() - switch { - case !found: - return versions.ReservedVersion{}, fmt.Errorf("no watched branch carries an entry of %s at %s now, so there is nothing to reserve it from", module, fp) - case !trunk || !first: - return versions.ReservedVersion{}, fmt.Errorf("%s at %s is not the first watched branch's build: only that one reserves a version (§371)", module, fp) - } - digests := b.doneDigests(ctx, module, fp) - if digests == nil { - return versions.ReservedVersion{}, fmt.Errorf("the build key of %s at %s is not done", module, fp) - } - plan, planErr, _ := b.planOf(ctx, m.Manifest) - switch { - case planErr != nil: - return versions.ReservedVersion{}, fmt.Errorf("the plan of %s at %s cannot be read: %w", module, fp, planErr) - case len(plan.Tasks) == 0 || strings.Count(plan.Series, ".") != 1: - return versions.ReservedVersion{}, fmt.Errorf("%s at %s builds nothing or has no MAJOR.MINOR series (%q): it reserves no version", module, fp, plan.Series) - } - if cur, ok, err := b.Reserved.ReservedFor(ctx, module, fp); err != nil { - return versions.ReservedVersion{}, err - } else if ok { - return versions.ReservedVersion{}, fmt.Errorf("%s at %s holds the reservation of %s already", module, fp, cur.Version) - } - res, ok := b.reserve(ctx, module, m, plan, b.originOf(key), false) - if !ok { - return versions.ReservedVersion{}, fmt.Errorf("no version could be reserved for %s at %s (the builder's journal says why)", module, fp) - } - refs := map[string]string{} - for _, t := range plan.Tasks { - d, have := digests[t.Artifact] - if !have { - return res, fmt.Errorf("%s is reserved for %s at %s, but the done key holds no digest of %s", res.Version, module, fp, t.Artifact) - } - refs[module+":"+t.Artifact] = d - } - if err := b.Reserved.Built(ctx, module, res.Version, refs, nil); err != nil { - return res, fmt.Errorf("%s is reserved for %s at %s, but its digests are not recorded: %w", res.Version, module, fp, err) - } - return res, nil -} diff --git a/modules/mesh-delivery-builder/internal/build/reservedone_test.go b/modules/mesh-delivery-builder/internal/build/reservedone_test.go deleted file mode 100644 index 96e611e8a..000000000 --- a/modules/mesh-delivery-builder/internal/build/reservedone_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package build - -import ( - "context" - "slices" - "strings" - "testing" - "time" - - "git.novox.be/novox/mesh-sdk/go/catalogue" - - "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" -) - -// TestADoneTrunkBuildThatReservedNoneIsGivenAVersionByHand: design 47 G A-455 — builder_reserve_done reserves the series' next -// version for a done key that reserved none, with the digests the key holds; a key not done, a fingerprint no entry carries and -// a build that holds a reservation already are refused; the value it writes is a reasks value of its own key. -func TestADoneTrunkBuildThatReservedNoneIsGivenAVersionByHand(t *testing.T) { - ctx := context.Background() - r := newRig(t, goBundle) - r.mf.byDigest[mdigest('a')] = catalogue.Manifest{Module: "m", Version: "0.1", Build: &catalogue.Build{Artifacts: []catalogue.Artifact{goBundle}}} - res := &fakeReservations{} - r.b.Reserved = res - if _, err := r.b.ReserveDone(ctx, "m", fp1); err == nil { - t.Fatal("a version was reserved for a key that is not built") - } - // The build ran while the builder reserved nothing (as the live key did): done, with no reservation. - r.b.Reserved = nil - if v := r.consider(t, "modules/m"); v.State != builds.BuildDone { - t.Fatalf("build = %+v, want done", v) - } - r.b.Reserved = res - if _, err := r.b.ReserveDone(ctx, "m", "src2:"+strings.Repeat("9", 64)); err == nil || !strings.Contains(err.Error(), "no watched branch carries") { - t.Errorf("a fingerprint no entry carries: %v", err) - } - got, err := r.b.ReserveDone(ctx, "m", fp1) - if err != nil || got.Version != "0.1.5" || !slices.Equal(res.series, []string{"0.1"}) || !slices.Equal(res.reserved[0], []string{"m:tool"}) { - t.Fatalf("reserved %+v (%v) in %v for %v, want 0.1.5 of m:tool in 0.1", got, err, res.series, res.reserved) - } - if res.built["m:tool"] != digest || res.sources[0].Fingerprint != fp1 { - t.Errorf("recorded %v from %+v, want the done key's digest for the entry %s", res.built, res.sources, fp1) - } - if _, err := r.b.ReserveDone(ctx, "m", fp1); err == nil || !strings.Contains(err.Error(), "reservation") { - t.Errorf("a build that holds a reservation was given another: %v", err) - } - at := time.Unix(0, 0) - key, _, err := NewReserveDone("m", fp1, "why", "op", at) - if err != nil || !strings.HasPrefix(key, "reserve-done.") { - t.Errorf("key %q (%v)", key, err) - } - for _, args := range [][3]string{{"", fp1, "why"}, {"m", "", "why"}, {"m", fp1, " "}} { - if _, _, err := NewReserveDone(args[0], args[1], args[2], "op", at); err == nil { - t.Errorf("%q made a value", args) - } - } -} diff --git a/modules/mesh-delivery-builder/internal/build/step.go b/modules/mesh-delivery-builder/internal/build/step.go index d8240a309..7a4613a30 100644 --- a/modules/mesh-delivery-builder/internal/build/step.go +++ b/modules/mesh-delivery-builder/internal/build/step.go @@ -212,7 +212,7 @@ func (b *Builder) buildEntry(ctx context.Context, pipeline string, e meshbuilds. // passedWithItsVersion is the verdict of a build that ended done (design 47 G A-456): a build that reserves a version (a build // of the first watched branch's trunk, with a MAJOR.MINOR series and artifacts) passes only when a version is reserved for its -// fingerprint; one that ended done with none fails loudly, naming builder_reserve_done, so no pipeline says passed for a build +// fingerprint; one that ended done with none fails loudly, naming builder_build_again, so no pipeline says passed for a build // that can never be released, and one whose series another fingerprint took over fails saying it is stale, naming that // fingerprint and its version (design 47 H H-A-244). A build that reserves none (a candidate's, a series of before G) passes as it did. func (b *Builder) passedWithItsVersion(ctx context.Context, entry meshcatalog.CatalogEntry) (outcome, said string) { @@ -257,7 +257,7 @@ func (b *Builder) passedWithItsVersion(ctx context.Context, entry meshcatalog.Ca // H-A-244 (2): the series was taken over by a newer fingerprint, whose number it carries now: the build is stale. return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s: built at %s but its series moved to %s %s: stale", entry.Module, entry.Fp, by.Fingerprint, by.Version) } - return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s: built at %s, but no version is reserved for it; builder_reserve_done reserves one for the done build", entry.Module, entry.Fp) + return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s: built at %s, but no version is reserved for it; builder_build_again builds it again under a reserved one", entry.Module, entry.Fp) } return meshbuilds.StepEndedOutcomePassed, "" } diff --git a/modules/mesh-delivery-builder/internal/build/step_test.go b/modules/mesh-delivery-builder/internal/build/step_test.go index 3ffced765..2c9339156 100644 --- a/modules/mesh-delivery-builder/internal/build/step_test.go +++ b/modules/mesh-delivery-builder/internal/build/step_test.go @@ -121,7 +121,7 @@ func TestAStepAskIsWokenByItsBuildsEnd(t *testing.T) { } // A build step passes a build that reserves a version only when a version is reserved for its fingerprint (design 47 G A-456): -// a trunk build that ended done with none fails naming builder_reserve_done, and passes once one is reserved for it; a build +// a trunk build that ended done with none fails naming builder_build_again, and passes once one is reserved for it; a build // that reserves none (a manifest of before G, version "1") passes as it did. func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T) { for _, c := range []struct { @@ -169,7 +169,8 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T) return meshcatalog.CatalogEntry{Module: "m", Repository: "novox/m", Commit: "c1", Fp: fp1, ManifestDigest: digestOf(c.unreadable), Path: "modules/m"}, nil } end := r.b.BuildStep(t.Context(), "a1", meshbuilds.StepRun{Pipeline: "main.1.m", Step: meshbuilds.StepRunStepBuild, Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}}) - if end.Outcome != c.want || !strings.Contains(end.Said, c.said) || (c.want == meshbuilds.StepEndedOutcomeFailed && strings.Contains(end.Said, "builder_reserve_done") == c.takenOver) { + // H2 H-A-665: the failure words of a build with no version name builder_build_again, the person's tool + if end.Outcome != c.want || !strings.Contains(end.Said, c.said) || (c.want == meshbuilds.StepEndedOutcomeFailed && strings.Contains(end.Said, "builder_build_again") == c.takenOver) { t.Errorf("end = %+v, want %s saying %q", end, c.want, c.said) } // The verdict of a build that ended done, as a build ended now is judged, says the same (H-A-508: the newest entry first). diff --git a/modules/mesh-delivery-builder/internal/build/stuck.go b/modules/mesh-delivery-builder/internal/build/stuck.go index e0c6ad061..422504809 100644 --- a/modules/mesh-delivery-builder/internal/build/stuck.go +++ b/modules/mesh-delivery-builder/internal/build/stuck.go @@ -149,24 +149,6 @@ func NewReservedDrop(module, series, version, why, by string, at time.Time) (str return "reserved." + versions.ReservedKey(module, series), data, err } -// ModeReserveDone is the Mode of a reasks value of builder_reserve_done (design 47 G A-455): Name is the module and FP the -// fingerprint of a done trunk build that reserved no version. -const ModeReserveDone = "reserve-done" - -// NewReserveDone is the value builder_reserve_done writes: the key `reserve-done..` (never a build key) and -// the value. -func NewReserveDone(module, fp, why, by string, at time.Time) (string, []byte, error) { - module, fp = strings.TrimSpace(module), strings.TrimSpace(fp) - if module == "" || fp == "" { - return "", nil, errors.New("module and fp are required") - } - if strings.TrimSpace(why) == "" { - return "", nil, errors.New("say why a version is reserved for the done build (why)") - } - data, err := json.Marshal(ReAsk{V: 1, Why: strings.TrimSpace(why), By: by, At: at.UTC(), Mode: ModeReserveDone, Name: module, FP: fp}) - return "reserve-done." + versions.EscapeToken(module) + "." + versions.EscapeToken(fp), data, err -} - // ModeBuild is the Mode of a reasks value that asks the key to be built again, not its waiting asks to be asked again. const ModeBuild = "build" diff --git a/modules/mesh-delivery-builder/internal/versions/again.go b/modules/mesh-delivery-builder/internal/versions/again.go index 1788c164f..130d90733 100644 --- a/modules/mesh-delivery-builder/internal/versions/again.go +++ b/modules/mesh-delivery-builder/internal/versions/again.go @@ -11,9 +11,6 @@ type Acts struct { Republish func(ctx context.Context, module, version string) ([]string, error) // DropOldForm drops a retired node from the old form's count by hand (builder_old_form): its answer, or why not. DropOldForm func(ctx context.Context, node, by, why string, at time.Time) (string, error) - // ReserveDone reserves the next version for a done trunk build that reserved none and queues its publish (builder_reserve_done): - // its answer, or why not. - ReserveDone func(ctx context.Context, module, fp, by, why string, at time.Time) (string, error) // DropReserved drops a module's reservation of one MAJOR.MINOR by hand (builder_reserved_drop): its answer, or why not. DropReserved func(ctx context.Context, module, series, version, by, why string, at time.Time) (string, error) // PublishDrop terminates one publish item (builder_publish_drop, design 47 H2 §793): the answer, or why not. diff --git a/modules/mesh-delivery-builder/internal/versions/reserve.go b/modules/mesh-delivery-builder/internal/versions/reserve.go index 8a9ca6fa0..06ea0e776 100644 --- a/modules/mesh-delivery-builder/internal/versions/reserve.go +++ b/modules/mesh-delivery-builder/internal/versions/reserve.go @@ -31,8 +31,6 @@ const ( // ReservedTool is builder_reserved, ReservedDropTool builder_reserved_drop. ReservedTool = "builder_reserved" ReservedDropTool = "builder_reserved_drop" - // ReserveDoneTool is builder_reserve_done (design 47 G A-455). - ReserveDoneTool = "builder_reserve_done" // UnreleasedBound is the publish's bound: past it a built reservation with an artifact unpublished is the finding // version-unreleased (§369). UnreleasedBound = 10 * time.Minute @@ -1247,10 +1245,6 @@ const ( "(it names the one that stands) and while the reservation's fingerprint is building. It forgets the key whole (the version, its fingerprint, the " + "artifacts' recorded digests, its withdrawn numbers), its publish item and its version-unreleased, and the answer names what it forgot; what the " + "registries hold at the version stays, a gap the next reserve skips. A hand act: it is recorded in the hand-act log." - ReserveDoneDescription = "Reserve a version for a done trunk build that reserved none (design 47 G A-455): given module and fp, the next version " + - "of the series is reserved for that fingerprint with the digests of the build's artifacts, and its publish is queued as builder_publish_again " + - "queues it; builds nothing. For a done key that cannot be built again. Refused when the key is not done, is no first watched branch's, or " + - "holds a reservation already. A hand act: it is recorded in the hand-act log." // ReservedVerb is the seat mesh-builds' verb served as a tool of the same name. ReservedVerb = meshbuilds.VerbReserved ) diff --git a/modules/mesh-delivery-builder/manifest_test.go b/modules/mesh-delivery-builder/manifest_test.go index e1114fb86..fa7b3472e 100644 --- a/modules/mesh-delivery-builder/manifest_test.go +++ b/modules/mesh-delivery-builder/manifest_test.go @@ -184,7 +184,7 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1 } // 1945: the builder's tools (builder_seat_queue: note 62), served by its tools bundle, and the event it says when it asks an ask again. if want := []string{"build_current", "builder_announce_again", "builder_ask_again", "builder_ask_drop", "builder_asks", "builder_bounds", "builder_build", "builder_build_again", "builder_builds_since", "builder_engine_reads", "builder_first_view_again", "builder_first_views", - "builder_health", "builder_old_form", "builder_publish_again", "builder_publish_queue", "builder_release", "builder_reserve_done", "builder_reserved", "builder_reserved_drop", "builder_seat_list", "builder_seat_list_again", "builder_seat_queue", "builder_stuck", "builder_toolchains", "builder_toolchains_drop", "builder_unbuildable", "builder_versions", "builder_waits"}; !reflect.DeepEqual(sorted(m.Tools), want) { + "builder_health", "builder_old_form", "builder_publish_again", "builder_publish_queue", "builder_release", "builder_reserved", "builder_reserved_drop", "builder_seat_list", "builder_seat_list_again", "builder_seat_queue", "builder_stuck", "builder_toolchains", "builder_toolchains_drop", "builder_unbuildable", "builder_versions", "builder_waits"}; !reflect.DeepEqual(sorted(m.Tools), want) { t.Errorf("tools = %v, want %v", m.Tools, want) } // Design 47 G §672: the toolchain waits' stream, kept 7 days within 16 MiB, and the bound's setting, 60 minutes. diff --git a/modules/mesh-delivery-builder/module.json b/modules/mesh-delivery-builder/module.json index 75156b103..f8f14d69a 100644 --- a/modules/mesh-delivery-builder/module.json +++ b/modules/mesh-delivery-builder/module.json @@ -31,7 +31,6 @@ "builder_reserved", "builder_release", "builder_reserved_drop", - "builder_reserve_done", "builder_seat_queue", "builder_stuck", "builder_toolchains", From 7f67e209e618f6736d19111c800cd98ebf7a0a07 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:21:35 +0100 Subject: [PATCH 049/141] I3 needs-rules: each revision carries judge.NeedsRules, a take-in at a higher number derives the unmoved entries' needs from their manifests again Builds: design 47 H2 H-A-569 (2), H-A-605 (4), H-A-586 --- .../internal/index/catalog_branches_test.go | 36 +++++++++++++++++++ .../internal/index/catalog_revisions.go | 26 +++++++++++++- modules/mesh-delivery-indexer/judge/needs.go | 5 +++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_branches_test.go b/modules/mesh-delivery-indexer/internal/index/catalog_branches_test.go index 66319e487..ab31890f9 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_branches_test.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_branches_test.go @@ -2,10 +2,12 @@ package index import ( "context" + "slices" "testing" "time" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + "mesh-delivery-indexer/judge" ) // Design 47 G A-85, §291, H §743, H-A-32: the indexer keeps a catalog revision per watched branch, . (the @@ -117,3 +119,37 @@ func TestTheRevisionAnswersEveryCaller(t *testing.T) { t.Errorf("an unproven caller answered %+v, %v; want the revision", a, err) } } + +// H-A-569 (2), H-A-605 (4): a take-in whose needs-rules equals its base revision's derives nothing for unmoved entries, and +// one with a higher number derives each from the manifest the entry carries, keeping its fingerprint. +func TestAHigherNeedsRulesDerivesTheUnmovedEntriesNeedsAgain(t *testing.T) { + ctx := context.Background() + ix := &Indexer{Module: testSelf, Revisions: newMemObjects(1 << 20)} + entry := meshcatalog.CatalogEntry{Module: "web", Repository: "novox/w", Commit: "c1", Fp: "src2:aa", + Manifest: map[string]any{"module": "web", "version": "1", "runs-as": "web"}} + if err := ix.KeepBranchEntries(ctx, "main", 1, map[string]meshcatalog.CatalogEntry{"web": entry}, nil); err != nil { + t.Fatal(err) + } + needsOf := func(source int64) ([]string, int64) { + a, err := Revision(ctx, ix.Revisions, nil, meshcatalog.RevisionInput{Branch: "main", Source: source}) + if err != nil || len(a.Entries) != 1 { + t.Fatalf("source %d answered %+v (%v)", source, a, err) + } + if a.Entries[0].Fp != "src2:aa" { + t.Errorf("the entry's fingerprint moved to %q", a.Entries[0].Fp) + } + return a.Entries[0].Needs, a.Revision.NeedsRules + } + if needs, rules := needsOf(1); rules != judge.NeedsRules || !slices.Contains(needs, "directory-contents-owner") { + t.Errorf("the first revision holds needs %v at rules %d, want the runs-as need at rules %d", needs, rules, judge.NeedsRules) + } + // The base was written at the same rules: the needs an entry carries are kept as they are. + kept := entry + kept.Needs = []string{"word:module"} + if err := ix.KeepBranchEntries(ctx, "main", 2, map[string]meshcatalog.CatalogEntry{"web": kept}, nil); err != nil { + t.Fatal(err) + } + if needs, _ := needsOf(2); !slices.Equal(needs, []string{"word:module"}) { + t.Errorf("a take-in at unchanged rules derived needs again: %v", needs) + } +} diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go index b52da26e7..05d812b8a 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go @@ -20,6 +20,7 @@ import ( "git.novox.be/novox/mesh-sdk/go/keys" "git.novox.be/novox/mesh-sdk/go/process" "git.novox.be/novox/mesh-sdk/go/views" + "mesh-delivery-indexer/judge" ) // The indexer's object bucket catalog-revisions (design 47, Two graphs; novox/hq ADR 0619 §2: declared in the old @@ -379,9 +380,12 @@ 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) + if judge.NeedsRules > newest.NeedsRules { + entries = withRuleNeeds(entries, movers) // H-A-605 (4): the rules moved since the base, so each unmoved entry is read again + } at := ix.now().UTC() 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) + NeedsRules: judge.NeedsRules, CallKind: call.Kind, Module: call.Module, Version: call.Version, Repository: call.Repository, At: &at}, entries) if err != nil { return 0, err } @@ -461,6 +465,26 @@ func (ix *Indexer) keepBranchEntries(ctx context.Context, branch string, src int return number, nil } +// withRuleNeeds is entries with each unmoved entry's needs derived again from the manifest the entry carries whole, the +// manifest validator's rules as they stand (design 47 H2, H-A-569 (2), H-A-605 (4)): an entry gains the need a rule names +// now, keeps the ones it had and keeps its fingerprint, which no need moves. A mover's needs were derived at its take-in. +func withRuleNeeds(entries map[string]meshcatalog.CatalogEntry, movers []meshcatalog.TakeInEntry) map[string]meshcatalog.CatalogEntry { + moved := map[string]bool{} + for _, m := range movers { + moved[m.Module] = true + } + out := make(map[string]meshcatalog.CatalogEntry, len(entries)) + for name, e := range entries { + if raw, err := json.Marshal(e.Manifest); !moved[name] && len(e.Manifest) > 0 && err == nil { + if derived, err := judge.ManifestNeeds(raw); err == nil { + e.Needs = slices.Compact(slices.Sorted(slices.Values(append(slices.Clone(e.Needs), derived...)))) + } + } + out[name] = e + } + return out +} + // 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). diff --git a/modules/mesh-delivery-indexer/judge/needs.go b/modules/mesh-delivery-indexer/judge/needs.go index 950ec5f89..dfdb404b7 100644 --- a/modules/mesh-delivery-indexer/judge/needs.go +++ b/modules/mesh-delivery-indexer/judge/needs.go @@ -19,6 +19,11 @@ import ( // manifest is read field by field through catalogue.Manifest, and a key is a word only where catalogue.ManifestReads() // names its path; a unit test holds the two equal, so a difference fails. +// NeedsRules is the version of the validator's need rules (design 47 H2, H-A-569 (2), H-A-605 (4)): raised with every +// change of the rules that derive a need from a manifest. Each catalog revision the indexer writes carries it, and a +// take-in derives the rule needs of unmoved entries again only when its own is higher than its base revision's. +const NeedsRules = 1 + // requirementLong is one entry of `requires` in its long form, as catalogue reads it. type requirementLong struct { Name string `json:"name"` From c87d5fe6ab2ef0ece142b89beeb40225d615c4a9 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:22:12 +0100 Subject: [PATCH 050/141] DC8 wait-bound-and-clock: the seat mesh-pipeline-runner's Wait gains bound and clock-from, in form 13's raise Builds: design 47 H2 H-A-736 (1), H-A-599, H-A-611 --- .../go/seats/meshpipelinerunner/contract.go | 6 +++++- .../go/seats/meshpipelinerunner/contract_test.go | 2 +- .../seats/mesh-pipeline-runner/fixtures/events.json | 4 +++- .../seats/mesh-pipeline-runner/seat.json | 9 +++++++++ .../ts/seats/meshpipelinerunner/index.d.ts | 4 ++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index 6bc40ce57..1d7b491f4 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -20,7 +20,7 @@ const Form = 13 // whose fields changed while its forms did not (design 47 H2 §780). const ( generatedForms = "13" - generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverAdded=6966283f6909 MoverAddedEvent=b24ae82030ab MoverEnded=4b35095f6829 MoverRow=6de094f5329f Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=397a8219a855 PipelineStarted=d5fc3ee236c7 PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=69998ea62147 PlaceUnfinishedAnswerFailedItem=d9b89913b9bf PlaceUnfinishedAnswerPlacedItem=9ff9288125e5 Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=8609ff359791 StandsAnswer=e05cecdde456 StartAnswer=ed94ced4513a StartedMover=4450a94e6ca3 StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=bdaa8bbfbcab StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=21e4ee7a3ef1 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" + generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverAdded=6966283f6909 MoverAddedEvent=b24ae82030ab MoverEnded=4b35095f6829 MoverRow=6de094f5329f Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=397a8219a855 PipelineStarted=d5fc3ee236c7 PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=69998ea62147 PlaceUnfinishedAnswerFailedItem=d9b89913b9bf PlaceUnfinishedAnswerPlacedItem=9ff9288125e5 Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=8609ff359791 StandsAnswer=e05cecdde456 StartAnswer=ed94ced4513a StartedMover=4450a94e6ca3 StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=bdaa8bbfbcab StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=90066504aaa7 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" ) const ( @@ -1244,8 +1244,12 @@ type Wait struct { Artifact string `json:"artifact,omitempty"` // the step's own ask, where it has one (design 47 G §731) Ask string `json:"ask,omitempty"` + // a duration such as 30m: the runner's stalled-bound, which the watchman times the wait by (design 47 H2 H-A-599, H-A-611, H-A-736) + Bound string `json:"bound,omitempty"` // the watched branch, or the branch of a run on request Branch string `json:"branch"` + // the time the bound counts from: when the wait was held (design 47 H2 H-A-599, H-A-736) + ClockFrom *time.Time `json:"clock-from,omitempty"` // the commit the module's entry was last changed at Commit string `json:"commit,omitempty"` // the module's build-input fingerprint at the commit diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go index f8989f25f..9b46e9b0f 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go @@ -29,7 +29,7 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v PipelineEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-ended\\.[^.*> ]+\\.[^.*> ]+$")}, {name: "a pipeline ended failed, naming the step that held it, no version released", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.3589", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"failed\",\"status\":\"required\",\"step\":\"unit\"},{\"module\":\"nats\",\"outcome\":\"not asked\",\"status\":\"required\",\"step\":\"approval\",\"why\":\"unit of nats:program failed\"}],\"tier\":1}],\"outcome\":\"failed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1,\"why\":\"unit of nats:program failed\"}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"steps\":[{\"artifact\":\"nats:program\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"outcome\":\"failed\",\"status\":\"required\",\"step\":\"unit\"},{\"module\":\"nats\",\"outcome\":\"not asked\",\"status\":\"required\",\"step\":\"approval\",\"why\":\"unit of nats:program failed\"}],\"tier\":1}],\"outcome\":\"failed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"v\":1,\"why\":\"unit of nats:program failed\"}", decode: func(b []byte) (any, error) { var v PipelineEndedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.pipeline-ended\\.[^.*> ]+\\.[^.*> ]+$")}, - {name: "a pipeline over pipelines-at-once waits its turn", subject: "mesh.seat.mesh-pipeline-runner.event.wait-held.main.3590", given: "{\"branch\":\"main\",\"on\":\"pipelines-at-once\",\"pipeline\":\"main.3590\",\"revision\":13,\"since\":\"2026-11-10T10:01:00Z\",\"source\":3590,\"step\":\"pipeline\",\"v\":1}", wire: "{\"branch\":\"main\",\"on\":\"pipelines-at-once\",\"pipeline\":\"main.3590\",\"revision\":13,\"since\":\"2026-11-10T10:01:00Z\",\"source\":3590,\"step\":\"pipeline\",\"v\":1}", + {name: "a pipeline over pipelines-at-once waits its turn", subject: "mesh.seat.mesh-pipeline-runner.event.wait-held.main.3590", given: "{\"bound\":\"30m\",\"branch\":\"main\",\"clock-from\":\"2026-11-10T10:01:00Z\",\"on\":\"pipelines-at-once\",\"pipeline\":\"main.3590\",\"revision\":13,\"since\":\"2026-11-10T10:01:00Z\",\"source\":3590,\"step\":\"pipeline\",\"v\":1}", wire: "{\"bound\":\"30m\",\"branch\":\"main\",\"clock-from\":\"2026-11-10T10:01:00Z\",\"on\":\"pipelines-at-once\",\"pipeline\":\"main.3590\",\"revision\":13,\"since\":\"2026-11-10T10:01:00Z\",\"source\":3590,\"step\":\"pipeline\",\"v\":1}", decode: func(b []byte) (any, error) { var v WaitHeldEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.wait-held\\.[^.*> ]+\\.[^.*> ]+$")}, {name: "a run on request started", subject: "mesh.seat.mesh-pipeline-runner.event.run-started.nats.main.0123456789abcdef0123456789abcdef01234567", given: "{\"at\":\"2026-11-10T10:00:00Z\",\"by\":\"fix-1965@workstation\",\"members\":[{\"branch\":\"feature/1966-x\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"nats\"}],\"run\":\"run-m2kx9a\",\"v\":1}", wire: "{\"at\":\"2026-11-10T10:00:00Z\",\"by\":\"fix-1965@workstation\",\"members\":[{\"branch\":\"feature/1966-x\",\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"module\":\"nats\"}],\"run\":\"run-m2kx9a\",\"v\":1}", decode: func(b []byte) (any, error) { var v RunStartedEvent; err := json.Unmarshal(b, &v); return v, err }, subjectIs: regexp.MustCompile("^mesh\\.seat\\.mesh-pipeline-runner\\.event\\.run-started\\.[^.*> ]+\\.[^.*> ]+\\.[^.*> ]+$")}, diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json index ffc143975..358035fd2 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/events.json @@ -364,7 +364,9 @@ "v": 1, "step": "pipeline", "on": "pipelines-at-once", - "since": "2026-11-10T10:01:00Z" + "since": "2026-11-10T10:01:00Z", + "bound": "30m", + "clock-from": "2026-11-10T10:01:00Z" } }, { diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json index 6b6f3f8e8..ec7b3bfbc 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -1992,6 +1992,15 @@ "type": "string", "description": "the step's own ask, where it has one (design 47 G §731)" }, + "bound": { + "type": "string", + "description": "a duration such as 30m: the runner's stalled-bound, which the watchman times the wait by (design 47 H2 H-A-599, H-A-611, H-A-736)" + }, + "clock-from": { + "type": "string", + "format": "date-time", + "description": "the time the bound counts from: when the wait was held (design 47 H2 H-A-599, H-A-736)" + }, "shared": { "type": "array", "items": { diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts index aeb039771..9c26b027e 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -692,8 +692,12 @@ export interface Wait { "artifact"?: string; /** the step's own ask, where it has one (design 47 G §731) */ "ask"?: string; + /** a duration such as 30m: the runner's stalled-bound, which the watchman times the wait by (design 47 H2 H-A-599, H-A-611, H-A-736) */ + "bound"?: string; /** the watched branch, or the branch of a run on request */ "branch": string; + /** the time the bound counts from: when the wait was held (design 47 H2 H-A-599, H-A-736) */ + "clock-from"?: string; /** the commit the module's entry was last changed at */ "commit"?: string; /** the module's build-input fingerprint at the commit */ From 94afdcb6b49136d2eaf265303f7608ca86d931ec Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:22:23 +0100 Subject: [PATCH 051/141] B17 build-holds-its-entry: a build takes the newest entry of its fingerprint and its origin at its start; an older revision's entry never moves the origin back Builds: design 47 H2 H-A-707 (1) (2) --- .../internal/build/run.go | 48 ++++++++++++++----- .../internal/build/step_test.go | 34 +++++++++++++ 2 files changed, 71 insertions(+), 11 deletions(-) diff --git a/modules/mesh-delivery-builder/internal/build/run.go b/modules/mesh-delivery-builder/internal/build/run.go index aa9a69ec7..6981912e5 100644 --- a/modules/mesh-delivery-builder/internal/build/run.go +++ b/modules/mesh-delivery-builder/internal/build/run.go @@ -311,7 +311,11 @@ func (b *Builder) take(ctx context.Context, o Origin, key string, m meshcatalog. if bk, err := builds.BuilderBuildKey(key, m.Fp2); err == nil && m.Fp2 != "" { // A fingerprint a watched branch carries is built from that branch's commit, whoever asked for it first. b.trunkFP[bk] = true - b.origin[bk] = o + // The key's origin is never moved back (design 47 H2 H-A-707 (2)): an entry of an older revision with the same fingerprint + // leaves the origin of the newer one as it was. + if cur, held := b.origin[bk]; !held || !originNewer(cur, o) { + b.origin[bk] = o + } b.edges[bk] = e } b.mu.Unlock() @@ -339,7 +343,7 @@ const withdrawnPrefix = "withdrawn: " // supersededBy is the fingerprint that supersedes fp, a fingerprint of module whose build key is key, when fp is of its // registration's first watched branch and is no longer the newest entry heard on that branch (H-A-489); "" otherwise. A key no -// entry named is of the first branch, as originOf has it. +// entry named is of the first branch, as originLocked has it. func (b *Builder) supersededBy(module, key, fp string) string { b.mu.Lock() defer b.mu.Unlock() @@ -433,17 +437,38 @@ func everyArtifactNamesPaths(e meshcatalog.CatalogEntry) bool { return true } -// originOf is the catalog revision the entry of a build key came from; a key no entry named is of the first branch, as a build -// of the trunk's value was before branches were watched. -func (b *Builder) originOf(key string) Origin { - b.mu.Lock() - defer b.mu.Unlock() +// originLocked is the catalog revision the entry of a build key came from; a key no entry named is of the first branch, as a build +// of the trunk's value was before branches were watched. It is read under the lock the caller holds. +func (b *Builder) originLocked(key string) Origin { if o, ok := b.origin[key]; ok { return o } return Origin{First: true} } +// originNewer says whether the origin cur is of a newer module graph revision than o: known by their revisions, else their sources. +func originNewer(cur, o Origin) bool { + newer, known := newerRevision(cur, o) + return known && newer +} + +// entryAndOrigin is what a build holds from its start (design 47 H2 H-A-707 (1)): the entry its picture holds for the module on the +// branch of the key's origin when that entry is of the key's fingerprint, with the origin it was heard at, else the entry that woke it +// with the key's origin. Taken under one lock, it is read by the build's reservation, pins and revision wait, never the key's origin +// as it stands later. +func (b *Builder) entryAndOrigin(module, key string, woke meshcatalog.ModulesByModuleValue) (meshcatalog.ModulesByModuleValue, Origin) { + b.mu.Lock() + defer b.mu.Unlock() + o := b.originLocked(key) + if h, ok := b.heard[o.Branch+"\x00"+module]; ok && h.Fp2 == woke.Fp2 { + if at, ok := b.heardAt[o.Branch+"\x00"+module]; ok { + return h, at + } + return h, o + } + return woke, o +} + // NodesChanged is Reconsider after a toolchain moved, so a build that waited for the nodes to agree on one may go on. func (b *Builder) NodesChanged(ctx context.Context) { b.Reconsider(ctx) } @@ -704,6 +729,7 @@ func (b *Builder) startOnce(ctx context.Context, key, module string, m meshcatal // building by this builder: it takes it again when it starts (ADR 0478 clause 5). func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesByModuleValue) { key, _ := builds.BuilderBuildKey(module, m.Fp2) + m, origin := b.entryAndOrigin(module, key, m) // the build holds one entry and its origin (design 47 H2 H-A-707 (1)) whyEnded := "" defer func() { b.handEnded(key, whyEnded) }() defer b.unrelease(key) @@ -752,8 +778,8 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB delete(b.events, key) b.mu.Unlock() // Only a build of the registration's first watched branch reserves and releases a version (design 47 G §371). - reserving := trunk && b.originOf(key).First && planErr == nil && !nothing && b.reserves(ctx, module, m, plan) - if trunk && b.originOf(key).First && planErr == nil && !nothing && !reserving { + reserving := trunk && origin.First && planErr == nil && !nothing && b.reserves(ctx, module, m, plan) + if trunk && origin.First && planErr == nil && !nothing && !reserving { // A done build whose digests its end did not record is recorded at the next look (design 47 H2 H-A-492). if _, err := b.RecordAgain(ctx, module, m.Fp2, "at a look"); err != nil { b.logf("%v", err) @@ -807,12 +833,12 @@ func (b *Builder) try(ctx context.Context, module string, m meshcatalog.ModulesB // Reserved as A-490b amended by H-A-225 has it: this fingerprint's standing reservation is kept while it is unreleased // and above the highest the catalog's versions answers, else the next above that highest is taken (A-455); the build's // own publish then runs. - reserved, hasReserved = b.reserve(ctx, module, m, plan, b.originOf(key), true) + reserved, hasReserved = b.reserve(ctx, module, m, plan, origin, true) reserving = true } else if reserving && cl.Build.State != builds.BuildDone { // Looked at again just before it reserves (H-A-489): a newer entry heard since the claim is not taken over. if supersededNow = b.supersededBy(module, key, m.Fp2); supersededNow == "" { - reserved, hasReserved = b.reserve(ctx, module, m, plan, b.originOf(key), false) + reserved, hasReserved = b.reserve(ctx, module, m, plan, origin, false) } } if hasReserved && supersededNow == "" && cl.Build.State != builds.BuildDone { diff --git a/modules/mesh-delivery-builder/internal/build/step_test.go b/modules/mesh-delivery-builder/internal/build/step_test.go index 2c9339156..52ed829f6 100644 --- a/modules/mesh-delivery-builder/internal/build/step_test.go +++ b/modules/mesh-delivery-builder/internal/build/step_test.go @@ -184,6 +184,7 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T) } t.Run("H-A-508: built now, superseded: a newer entry heard while the build runs ends the step superseded", aNewerEntryWhileTheBuildRunsSupersedesTheStep) t.Run("H-A-650: a superseded end the builder knows no revision for is could-not-run, never superseded with a zero", aSupersededEndWithNoRevisionIsCouldNotRun) + t.Run("H-A-707 (1) (2): a build holds the newest entry of its fingerprint and its origin, which an older entry never moves back", aBuildHoldsItsNewestEntryAndOrigin) t.Run("H-A-155: an ask waits for the picture to take its revision in, then builds with its version reserved", aStepAskWaitsForItsRevision) t.Run("H-A-155: past the bound the ask fails naming its revision, and nothing is built", aStepAskPastItsRevisionBoundFails) t.Run("H-A-205: an ask of a revision below the picture's newest is read by number and built", anOlderKeptRevisionIsReadByNumber) @@ -777,3 +778,36 @@ func aSupersededEndWithNoRevisionIsCouldNotRun(t *testing.T) { t.Errorf("end = %+v, want could not run naming that no superseding revision was heard", end) } } + +func aBuildHoldsItsNewestEntryAndOrigin(t *testing.T) { + var held atomic.Int64 + r, _, entry := revisionRig(t, &held, make(chan struct{}, 1)) + key, _ := builds.BuilderBuildKey("m", fp1) + val := func(commit string) meshcatalog.ModulesByModuleValue { + v, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: commit, Fp2: fp1, Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(agreedToolchains)}) + if err != nil { + t.Fatal(err) + } + m, _ := meshcatalogclient.DecodeModule(v) + return m + } + _ = entry + r.b.init() + o511 := Origin{Branch: "main", Source: 155, Revision: 511, First: true} + o510 := Origin{Branch: "main", Source: 154, Revision: 510, First: true} + r.b.take(t.Context(), o511, "m", val("7a74cee83f88e6585a5511c3cc53bdf0f5303d20"), nil) + r.b.Wait() + r.b.take(t.Context(), o510, "m", val("1111111111111111111111111111111111111111"), nil) // the same fingerprint, an older revision's entry + r.b.Wait() + r.b.mu.Lock() + got := r.b.origin[key] + r.b.mu.Unlock() + if got != o511 { + t.Errorf("the key's origin is %+v after an older revision's entry was taken; want revision 511's %+v as it was", got, o511) + } + // a build woken by revision 510's value takes the entry its picture holds, revision 511's, with its origin + m, o := r.b.entryAndOrigin("m", key, val("1111111111111111111111111111111111111111")) + if o != o511 || m.Commit != "7a74cee83f88e6585a5511c3cc53bdf0f5303d20" { + t.Errorf("the build woken by revision 510's value holds %+v at %+v; want revision 511's entry and origin", m.Commit, o) + } +} From cb8046c3558884caf184d669fe3094ed43905ad1 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:22:40 +0100 Subject: [PATCH 052/141] Judge tests: a holder's served verbs are read from the seat's definition, the uplink's decision is read as naming ADR 0117 The kind: a test that lists a seat's verbs or decision by hand breaks when the seat gains one; met at mesh-networking a49d6d0 (node-resolver's uplink-names, node-uplink's decisions). Builds: design 47 H2 issue 1984 (lead answer of 25 Nov, thorough fix) --- .../mesh-delivery-indexer/judge/rules_test.go | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/modules/mesh-delivery-indexer/judge/rules_test.go b/modules/mesh-delivery-indexer/judge/rules_test.go index ec6a1a964..ea89b9c01 100644 --- a/modules/mesh-delivery-indexer/judge/rules_test.go +++ b/modules/mesh-delivery-indexer/judge/rules_test.go @@ -4293,7 +4293,7 @@ func caseOnlyAClaimantDeclaresASeatsPath(t *testing.T) { uplink := catalogue.Manifest{Module: "uplink", Version: "1", Claims: []catalogue.Claim{{Name: "node-uplink", Scope: catalogue.ScopeNode}}, Facts: map[string]catalogue.RosterFile{"resolvers": {Path: catalogue.ResolverFile, Template: "nameserver 10.42.0.1\n"}}} resolver := localResolver() - resolver.Claims[0].Serves = []string{"routes", "route", "unroute"} + resolver.Claims[0].Serves = seatVerbs(catalogue.ResolverSeat) if got := CatalogueProblems(catalogue.Shelf{"uplink": uplink, resolver.Module: resolver}); len(got) != 0 { t.Errorf("the uplink's holder and the resolver's declaring the resolver file were refused: %v", got) } @@ -4409,7 +4409,7 @@ func caseReplay412(t *testing.T) { t.Fatal("no node-hostname seat") } holder := catalogue.Manifest{Module: "names", Version: "1", Claims: []catalogue.Claim{{Name: "node-hostname", Scope: catalogue.ScopeNode, - Serves: []string{"entries", "add", "remove"}}}} + Serves: seatVerbs("node-hostname")}}} err := catalogue.CanHold(holder, seat) if err == nil { t.Fatal("a holder of node-hostname declaring neither /etc/hosts nor /etc/hostname was accepted") @@ -4959,7 +4959,7 @@ func caseTheMeshsOwnSeatsAreStillClaimable(t *testing.T) { // It delivers the bus, so its holder provides the bus — the rule this check now enforces. m := catalogue.Manifest{Module: "nats", Provides: []catalogue.Offer{{Name: "mesh-bus", Scope: catalogue.ScopeMesh, Credential: &catalogue.OfferCredential{Form: catalogue.CredentialFormNone}}}, - Claims: []catalogue.Claim{{Name: "mesh-broker", Scope: catalogue.ScopeMesh, Serves: []string{"snapshot-get", "snapshot-restore", "snapshot-restore-cancel", "snapshot-remove"}}}} + Claims: []catalogue.Claim{{Name: "mesh-broker", Scope: catalogue.ScopeMesh, Serves: seatVerbs("mesh-broker")}}} if got := problemsFor(t, catalogue.Shelf{"nats": m}); got != "" { t.Fatalf("a mesh seat was refused by the derived check: %s", got) } @@ -5308,7 +5308,7 @@ func caseTheUplinkIsANodeSeatThatDeliversNothing(t *testing.T) { if !known { t.Fatalf("the uplink is not a seat; the seats are: %s", seatNames()) } - if seat.Scope != catalogue.ScopeNode || seat.Delivers != "" || seat.Decision != "novox/hq ADR 0117" { + if seat.Scope != catalogue.ScopeNode || seat.Delivers != "" || !strings.Contains(seat.Decision, "ADR 0117") { t.Fatalf("the uplink is %+v, not a node seat delivering nothing by ADR 0117", seat) } // And a manager's module can hold it without providing anything. @@ -5640,7 +5640,7 @@ func hostnameSeat(t *testing.T) catalogue.Seat { func hostnameHolder(resources ...map[string]any) catalogue.Manifest { return catalogue.Manifest{Module: "names", Version: "1", Claims: []catalogue.Claim{{Name: "node-hostname", Scope: catalogue.ScopeNode, - Serves: []string{"entries", "add", "remove"}}}, Resources: resources} + Serves: seatVerbs("node-hostname")}}, Resources: resources} } func mustParse(t *testing.T, raw string) catalogue.Manifest { @@ -6248,6 +6248,20 @@ const mailStream = `[{"name":"mail","events":["mail.*.message.added","mail.*.mes // localResolver is a stand-in holder: it claims the seat and renders the resolver file naming the // machine's own address. What is under test is the controller's rule, not the catalogue's module. +// seatVerbs are the verbs the seat's definition declares, as a holder's claim names them: a verb added to a seat (met at +// mesh-networking a49d6d0, node-resolver's uplink-names) never breaks a test that lists them by hand. +func seatVerbs(seat string) []string { + def, ok := catalogue.SeatNamed(seat) + if !ok { + panic(seat + " is not a seat; the seats are: " + seatNames()) + } + var verbs []string + for _, v := range def.Serves { + verbs = append(verbs, v.Name) + } + return verbs +} + func localResolver() catalogue.Manifest { return catalogue.Manifest{Module: "local-resolver", Version: "1", Claims: []catalogue.Claim{{Name: catalogue.ResolverSeat, Scope: catalogue.ScopeNode}}, From 04d912b5c8e57494fe864c549f0a1e428f263f52 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:23:00 +0100 Subject: [PATCH 053/141] DC7b transfer-optional: the registry seats' publish answer has transfer present exactly when a transfer is opened, absent when other-bytes is present Builds: design 47 H2 H-A-732, H-A-729 --- .../go/seats/containerimageregistry/contract.go | 6 +++--- .../go/seats/containerimageregistry/contract_test.go | 4 ++-- .../go/seats/gopackageregistry/contract.go | 6 +++--- .../go/seats/gopackageregistry/contract_test.go | 4 ++-- .../go/seats/npmpackageregistry/contract.go | 6 +++--- .../go/seats/npmpackageregistry/contract_test.go | 4 ++-- .../go/seats/ociartifactregistry/contract.go | 6 +++--- .../go/seats/ociartifactregistry/contract_test.go | 4 ++-- modules/mesh-delivery-contracts/parts/registry.json | 6 ++---- .../seats/container-image-registry/fixtures/verbs.json | 2 -- .../seats/go-package-registry/fixtures/verbs.json | 2 -- .../seats/npm-package-registry/fixtures/verbs.json | 2 -- .../seats/oci-artifact-registry/fixtures/verbs.json | 2 -- .../ts/seats/containerimageregistry/parts/registry.d.ts | 4 ++-- .../ts/seats/gopackageregistry/parts/registry.d.ts | 4 ++-- .../ts/seats/npmpackageregistry/parts/registry.d.ts | 4 ++-- .../ts/seats/ociartifactregistry/parts/registry.d.ts | 4 ++-- 17 files changed, 30 insertions(+), 40 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract.go b/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract.go index 8022f6fa2..71db04ac7 100644 --- a/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract.go @@ -22,7 +22,7 @@ const FormRegistry = 1 // whose fields changed while its forms did not (design 47 H2 §780). const ( generatedForms = "2 registry:1" - generatedFieldsDigest = "Artifact=79361e4ab1cd HeldEvent=b6d4c12500df Hold=c5a97a2f2d5a HoldAnswer=7d536ccb729f HoldsBySeatNameDigestValue=db093998a869 KeptEvent=ec3ef89ef8a7 ListAnswer=ca49dd7f20ee Listed=b9f1d1232e64 MirrorAnswer=0d59df97b53b NameOfAnswer=cc75a2f37394 Outcome=1e66f7bf6725 PublishAnswer=1923c8239f6c PublishAnswerOtherBytes=06b1c9853343 PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 ReleaseAnswer=d30bd6000a16 ReleasedEvent=b6d4c12500df RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 Repository=740e54e0b3b0 TagsAnswer=fe178191458a TagsAnswerTagsItem=eee02e024d64 VersionsAnswer=47e11ca2aea9 WindowsByCallerValue=23d9294dde92 WindowsByCallerValueDroppedItem=d748f0e58825" + generatedFieldsDigest = "Artifact=79361e4ab1cd HeldEvent=b6d4c12500df Hold=c5a97a2f2d5a HoldAnswer=7d536ccb729f HoldsBySeatNameDigestValue=db093998a869 KeptEvent=ec3ef89ef8a7 ListAnswer=ca49dd7f20ee Listed=b9f1d1232e64 MirrorAnswer=0d59df97b53b NameOfAnswer=cc75a2f37394 Outcome=1e66f7bf6725 PublishAnswer=1ab67aa1750a PublishAnswerOtherBytes=06b1c9853343 PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 ReleaseAnswer=d30bd6000a16 ReleasedEvent=b6d4c12500df RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 Repository=740e54e0b3b0 TagsAnswer=fe178191458a TagsAnswerTagsItem=eee02e024d64 VersionsAnswer=47e11ca2aea9 WindowsByCallerValue=23d9294dde92 WindowsByCallerValueDroppedItem=d748f0e58825" ) const ( @@ -347,8 +347,8 @@ type PublishAnswer struct { Lacks []string `json:"lacks,omitempty"` // the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) OtherBytes *PublishAnswerOtherBytes `json:"other-bytes,omitempty"` - // the transfer - Transfer string `json:"transfer"` + // the transfer the publish opens for its chunks; present whenever a transfer is opened and absent exactly when other-bytes is present, never an empty name (design 47 H2 H-A-732) + Transfer string `json:"transfer,omitempty"` } // PublishPartInput is what publish-part takes. diff --git a/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract_test.go b/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract_test.go index 394c0c88b..137855f7f 100644 --- a/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/containerimageregistry/contract_test.go @@ -57,9 +57,9 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v NameOfInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "name-of answers the copy's reference", subject: "", given: "{\"reference\":\"container-image-registry/upstream/docker.io/library/nats@sha256:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"}", wire: "{\"reference\":\"container-image-registry/upstream/docker.io/library/nats@sha256:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\"}", decode: func(b []byte) (any, error) { var v NameOfAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "publish answers other-bytes: the name and version are held with another digest (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", + {name: "publish answers other-bytes: the name and version are held with another digest (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"}}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"}}", decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", + {name: "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"}}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"}}", decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { diff --git a/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract.go b/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract.go index 6a76fc78f..5f845b54a 100644 --- a/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract.go @@ -21,7 +21,7 @@ const FormRegistry = 1 // whose fields changed while its forms did not (design 47 H2 §780). const ( generatedForms = "2 registry:1" - generatedFieldsDigest = "Artifact=79361e4ab1cd KeptEvent=ec3ef89ef8a7 Outcome=1e66f7bf6725 PublishAnswer=1923c8239f6c PublishAnswerOtherBytes=06b1c9853343 PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 VersionsAnswer=47e11ca2aea9" + generatedFieldsDigest = "Artifact=79361e4ab1cd KeptEvent=ec3ef89ef8a7 Outcome=1e66f7bf6725 PublishAnswer=1ab67aa1750a PublishAnswerOtherBytes=06b1c9853343 PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 VersionsAnswer=47e11ca2aea9" ) const ( @@ -207,8 +207,8 @@ type PublishAnswer struct { Lacks []string `json:"lacks,omitempty"` // the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) OtherBytes *PublishAnswerOtherBytes `json:"other-bytes,omitempty"` - // the transfer - Transfer string `json:"transfer"` + // the transfer the publish opens for its chunks; present whenever a transfer is opened and absent exactly when other-bytes is present, never an empty name (design 47 H2 H-A-732) + Transfer string `json:"transfer,omitempty"` } // PublishPartInput is what publish-part takes. diff --git a/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract_test.go b/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract_test.go index f4070dd6f..bf8f8a014 100644 --- a/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/gopackageregistry/contract_test.go @@ -37,9 +37,9 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v VersionsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "a tagged version sharing its digest with another tag is kept, not removed", subject: "", given: "{\"kept\":true,\"reason\":\"shared-digest\",\"removed\":false,\"tags\":[\"0.1.19\"]}", wire: "{\"kept\":true,\"reason\":\"shared-digest\",\"removed\":false,\"tags\":[\"0.1.19\"]}", decode: func(b []byte) (any, error) { var v RemoveAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "publish answers other-bytes: the name and version are held with another digest (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", + {name: "publish answers other-bytes: the name and version are held with another digest (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"}}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"}}", decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", + {name: "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"}}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"}}", decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { diff --git a/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract.go b/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract.go index 6bc9a77e2..99219ea91 100644 --- a/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract.go @@ -21,7 +21,7 @@ const FormRegistry = 1 // whose fields changed while its forms did not (design 47 H2 §780). const ( generatedForms = "2 registry:1" - generatedFieldsDigest = "Artifact=79361e4ab1cd KeptEvent=ec3ef89ef8a7 Outcome=1e66f7bf6725 PublishAnswer=1923c8239f6c PublishAnswerOtherBytes=06b1c9853343 PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 VersionsAnswer=47e11ca2aea9" + generatedFieldsDigest = "Artifact=79361e4ab1cd KeptEvent=ec3ef89ef8a7 Outcome=1e66f7bf6725 PublishAnswer=1ab67aa1750a PublishAnswerOtherBytes=06b1c9853343 PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 VersionsAnswer=47e11ca2aea9" ) const ( @@ -207,8 +207,8 @@ type PublishAnswer struct { Lacks []string `json:"lacks,omitempty"` // the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) OtherBytes *PublishAnswerOtherBytes `json:"other-bytes,omitempty"` - // the transfer - Transfer string `json:"transfer"` + // the transfer the publish opens for its chunks; present whenever a transfer is opened and absent exactly when other-bytes is present, never an empty name (design 47 H2 H-A-732) + Transfer string `json:"transfer,omitempty"` } // PublishPartInput is what publish-part takes. diff --git a/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract_test.go b/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract_test.go index eeccc2a3d..e6e711118 100644 --- a/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/npmpackageregistry/contract_test.go @@ -37,9 +37,9 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v VersionsAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "a tagged version sharing its digest with another tag is kept, not removed", subject: "", given: "{\"kept\":true,\"reason\":\"shared-digest\",\"removed\":false,\"tags\":[\"0.1.19\"]}", wire: "{\"kept\":true,\"reason\":\"shared-digest\",\"removed\":false,\"tags\":[\"0.1.19\"]}", decode: func(b []byte) (any, error) { var v RemoveAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "publish answers other-bytes: the name and version are held with another digest (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", + {name: "publish answers other-bytes: the name and version are held with another digest (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"}}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"}}", decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", + {name: "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"}}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"}}", decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { diff --git a/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract.go b/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract.go index 406be5b9c..e4317c328 100644 --- a/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract.go @@ -22,7 +22,7 @@ const FormRegistry = 1 // whose fields changed while its forms did not (design 47 H2 §780). const ( generatedForms = "3 registry:1" - generatedFieldsDigest = "Artifact=79361e4ab1cd HeldEvent=b6d4c12500df Hold=c5a97a2f2d5a HoldAnswer=7d536ccb729f HoldsBySeatNameDigestValue=db093998a869 KeptEvent=ec3ef89ef8a7 ListAnswer=ffc9dd135c75 Listed=b9f1d1232e64 Outcome=1e66f7bf6725 PublishAnswer=1923c8239f6c PublishAnswerOtherBytes=06b1c9853343 PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 ReleaseAnswer=d30bd6000a16 ReleasedEvent=b6d4c12500df RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 Repository=740e54e0b3b0 VersionsAnswer=47e11ca2aea9 WindowsByCallerValue=23d9294dde92 WindowsByCallerValueDroppedItem=d748f0e58825" + generatedFieldsDigest = "Artifact=79361e4ab1cd HeldEvent=b6d4c12500df Hold=c5a97a2f2d5a HoldAnswer=7d536ccb729f HoldsBySeatNameDigestValue=db093998a869 KeptEvent=ec3ef89ef8a7 ListAnswer=ffc9dd135c75 Listed=b9f1d1232e64 Outcome=1e66f7bf6725 PublishAnswer=1ab67aa1750a PublishAnswerOtherBytes=06b1c9853343 PublishPartAnswer=aebe3c6c89e9 PublishedEvent=ec3ef89ef8a7 RefusedEvent=ec3ef89ef8a7 ReleaseAnswer=d30bd6000a16 ReleasedEvent=b6d4c12500df RemoveAnswer=bccb5a322d69 RemovedEvent=ec3ef89ef8a7 Repository=740e54e0b3b0 VersionsAnswer=47e11ca2aea9 WindowsByCallerValue=23d9294dde92 WindowsByCallerValueDroppedItem=d748f0e58825" ) const ( @@ -338,8 +338,8 @@ type PublishAnswer struct { Lacks []string `json:"lacks,omitempty"` // the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) OtherBytes *PublishAnswerOtherBytes `json:"other-bytes,omitempty"` - // the transfer - Transfer string `json:"transfer"` + // the transfer the publish opens for its chunks; present whenever a transfer is opened and absent exactly when other-bytes is present, never an empty name (design 47 H2 H-A-732) + Transfer string `json:"transfer,omitempty"` } // PublishPartInput is what publish-part takes. diff --git a/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract_test.go b/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract_test.go index e6cb547d3..b8538f044 100644 --- a/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/ociartifactregistry/contract_test.go @@ -57,9 +57,9 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v ListInput; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "list answers a capped page with the cursor of the next", subject: "", given: "{\"capped\":true,\"next\":\"c-4183\",\"repositories\":[{\"manifests\":[{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"held\":false,\"index\":false,\"size\":4096}],\"name\":\"mail/files\"}],\"total\":3}", wire: "{\"capped\":true,\"next\":\"c-4183\",\"repositories\":[{\"manifests\":[{\"digest\":\"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\"held\":false,\"index\":false,\"size\":4096}],\"name\":\"mail/files\"}],\"total\":3}", decode: func(b []byte) (any, error) { var v ListAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "publish answers other-bytes: the name and version are held with another digest (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"},\"transfer\":\"\"}", + {name: "publish answers other-bytes: the name and version are held with another digest (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"}}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\",\"fingerprint\":\"src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\"}}", decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"},\"transfer\":\"\"}", + {name: "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", subject: "", given: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"}}", wire: "{\"other-bytes\":{\"digest\":\"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\"}}", decode: func(b []byte) (any, error) { var v PublishAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { diff --git a/modules/mesh-delivery-contracts/parts/registry.json b/modules/mesh-delivery-contracts/parts/registry.json index 6d9b0c560..224fd42d3 100644 --- a/modules/mesh-delivery-contracts/parts/registry.json +++ b/modules/mesh-delivery-contracts/parts/registry.json @@ -68,7 +68,7 @@ "properties": { "transfer": { "type": "string", - "description": "the transfer" + "description": "the transfer the publish opens for its chunks; present whenever a transfer is opened and absent exactly when other-bytes is present, never an empty name (design 47 H2 H-A-732)" }, "lacks": { "type": "array", @@ -99,9 +99,7 @@ ] } }, - "required": [ - "transfer" - ] + "required": [] }, "optional": true }, diff --git a/modules/mesh-delivery-contracts/seats/container-image-registry/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/container-image-registry/fixtures/verbs.json index e25c4ca38..5764ffd7d 100644 --- a/modules/mesh-delivery-contracts/seats/container-image-registry/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/container-image-registry/fixtures/verbs.json @@ -165,7 +165,6 @@ "name": "publish answers other-bytes: the name and version are held with another digest (H-A-729)", "of": "verb:publish.answer", "given": { - "transfer": "", "other-bytes": { "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", "fingerprint": "src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" @@ -176,7 +175,6 @@ "name": "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", "of": "verb:publish.answer", "given": { - "transfer": "", "other-bytes": { "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" } diff --git a/modules/mesh-delivery-contracts/seats/go-package-registry/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/go-package-registry/fixtures/verbs.json index 2a23403bd..74546a4e2 100644 --- a/modules/mesh-delivery-contracts/seats/go-package-registry/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/go-package-registry/fixtures/verbs.json @@ -111,7 +111,6 @@ "name": "publish answers other-bytes: the name and version are held with another digest (H-A-729)", "of": "verb:publish.answer", "given": { - "transfer": "", "other-bytes": { "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", "fingerprint": "src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" @@ -122,7 +121,6 @@ "name": "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", "of": "verb:publish.answer", "given": { - "transfer": "", "other-bytes": { "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" } diff --git a/modules/mesh-delivery-contracts/seats/npm-package-registry/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/npm-package-registry/fixtures/verbs.json index 94cf68a84..124327c9e 100644 --- a/modules/mesh-delivery-contracts/seats/npm-package-registry/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/npm-package-registry/fixtures/verbs.json @@ -111,7 +111,6 @@ "name": "publish answers other-bytes: the name and version are held with another digest (H-A-729)", "of": "verb:publish.answer", "given": { - "transfer": "", "other-bytes": { "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", "fingerprint": "src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" @@ -122,7 +121,6 @@ "name": "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", "of": "verb:publish.answer", "given": { - "transfer": "", "other-bytes": { "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" } diff --git a/modules/mesh-delivery-contracts/seats/oci-artifact-registry/fixtures/verbs.json b/modules/mesh-delivery-contracts/seats/oci-artifact-registry/fixtures/verbs.json index b7c26ec76..40328985e 100644 --- a/modules/mesh-delivery-contracts/seats/oci-artifact-registry/fixtures/verbs.json +++ b/modules/mesh-delivery-contracts/seats/oci-artifact-registry/fixtures/verbs.json @@ -169,7 +169,6 @@ "name": "publish answers other-bytes: the name and version are held with another digest (H-A-729)", "of": "verb:publish.answer", "given": { - "transfer": "", "other-bytes": { "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", "fingerprint": "src2:dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd" @@ -180,7 +179,6 @@ "name": "publish answers other-bytes, the holder keeping no fingerprint (H-A-729)", "of": "verb:publish.answer", "given": { - "transfer": "", "other-bytes": { "digest": "sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc" } diff --git a/modules/mesh-delivery-contracts/ts/seats/containerimageregistry/parts/registry.d.ts b/modules/mesh-delivery-contracts/ts/seats/containerimageregistry/parts/registry.d.ts index 30792b93b..109f1be37 100644 --- a/modules/mesh-delivery-contracts/ts/seats/containerimageregistry/parts/registry.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/containerimageregistry/parts/registry.d.ts @@ -114,8 +114,8 @@ export interface PublishAnswer { "lacks"?: string[]; /** the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) */ "other-bytes"?: PublishAnswerOtherBytes; - /** the transfer */ - "transfer": string; + /** the transfer the publish opens for its chunks; present whenever a transfer is opened and absent exactly when other-bytes is present, never an empty name (design 47 H2 H-A-732) */ + "transfer"?: string; } /** is what publish-part takes. */ diff --git a/modules/mesh-delivery-contracts/ts/seats/gopackageregistry/parts/registry.d.ts b/modules/mesh-delivery-contracts/ts/seats/gopackageregistry/parts/registry.d.ts index 30792b93b..109f1be37 100644 --- a/modules/mesh-delivery-contracts/ts/seats/gopackageregistry/parts/registry.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/gopackageregistry/parts/registry.d.ts @@ -114,8 +114,8 @@ export interface PublishAnswer { "lacks"?: string[]; /** the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) */ "other-bytes"?: PublishAnswerOtherBytes; - /** the transfer */ - "transfer": string; + /** the transfer the publish opens for its chunks; present whenever a transfer is opened and absent exactly when other-bytes is present, never an empty name (design 47 H2 H-A-732) */ + "transfer"?: string; } /** is what publish-part takes. */ diff --git a/modules/mesh-delivery-contracts/ts/seats/npmpackageregistry/parts/registry.d.ts b/modules/mesh-delivery-contracts/ts/seats/npmpackageregistry/parts/registry.d.ts index 30792b93b..109f1be37 100644 --- a/modules/mesh-delivery-contracts/ts/seats/npmpackageregistry/parts/registry.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/npmpackageregistry/parts/registry.d.ts @@ -114,8 +114,8 @@ export interface PublishAnswer { "lacks"?: string[]; /** the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) */ "other-bytes"?: PublishAnswerOtherBytes; - /** the transfer */ - "transfer": string; + /** the transfer the publish opens for its chunks; present whenever a transfer is opened and absent exactly when other-bytes is present, never an empty name (design 47 H2 H-A-732) */ + "transfer"?: string; } /** is what publish-part takes. */ diff --git a/modules/mesh-delivery-contracts/ts/seats/ociartifactregistry/parts/registry.d.ts b/modules/mesh-delivery-contracts/ts/seats/ociartifactregistry/parts/registry.d.ts index 30792b93b..109f1be37 100644 --- a/modules/mesh-delivery-contracts/ts/seats/ociartifactregistry/parts/registry.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/ociartifactregistry/parts/registry.d.ts @@ -114,8 +114,8 @@ export interface PublishAnswer { "lacks"?: string[]; /** the holder holds that name and version with another digest: the digest and the fingerprint it keeps for them, answered instead of failing the call (the fingerprint absent where it keeps none); present only in that case, and never with lacks; the holder says both digests and both fingerprints in its journal (design 47 H2 H-A-589 (1), H-A-729) */ "other-bytes"?: PublishAnswerOtherBytes; - /** the transfer */ - "transfer": string; + /** the transfer the publish opens for its chunks; present whenever a transfer is opened and absent exactly when other-bytes is present, never an empty name (design 47 H2 H-A-732) */ + "transfer"?: string; } /** is what publish-part takes. */ From 13eccb33b377e74b49fe3925b6c8e4022acfdef4 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:23:32 +0100 Subject: [PATCH 054/141] I12 ledger-end-rules: ended-days 1 to 3650, an ends-with naming a field of its schema, ended-days and ends-with given together Builds: design 47 H2 H-A-634 (3), H-A-690 --- .../mesh-delivery-indexer/judge/busstate.go | 18 +++++++++++++++++- .../judge/busstate_test.go | 16 ++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-indexer/judge/busstate.go b/modules/mesh-delivery-indexer/judge/busstate.go index 28a0900c5..c90d97693 100644 --- a/modules/mesh-delivery-indexer/judge/busstate.go +++ b/modules/mesh-delivery-indexer/judge/busstate.go @@ -119,7 +119,8 @@ var bareStream = map[string]optionRule{ // ledgerConfiguration is what a ledger's own configuration may give: how long its history is kept (design 25 § 12.1). var ledgerConfiguration = map[string]optionRule{ - catalogue.OptionAgeDays: {kind: optionInt, least: 1, most: 3650}, + catalogue.OptionAgeDays: {kind: optionInt, least: 1, most: 3650}, + catalogue.ConfigEndedDays: {kind: optionInt, least: 1, most: 3650}, } // noAge is how a bare stream says it keeps its messages for good. @@ -433,6 +434,7 @@ func ledgerTypeProblems(at string, e catalogue.BusStateEntry) []string { problems = append(problems, fmt.Sprintf("%s: a ledger names at least one type (novox/hq ADR 0597 §1)", at)) } seen := map[string]bool{} + endsWith := false for _, t := range e.Types { where := fmt.Sprintf("%s: type %q", at, t.Name) switch { @@ -473,6 +475,12 @@ func ledgerTypeProblems(at string, e catalogue.BusStateEntry) []string { } } } + if t.EndsWith != "" { + endsWith = true + if _, ok := t.Schema[t.EndsWith]; !ok { + problems = append(problems, fmt.Sprintf("%s: ends-with names the field %q, which the type's schema does not hold (design 47 H2 H-A-634 (3))", where, t.EndsWith)) + } + } for _, name := range slices.Sorted(maps.Keys(t.Schema)) { of := t.Schema[name].DigestOf if of == "" { @@ -483,6 +491,14 @@ func ledgerTypeProblems(at string, e catalogue.BusStateEntry) []string { } } } + // A ledger gives ended instances a lifetime (ended-days) exactly when a type says what ends an instance (ends-with). + _, endedDays := e.Configuration[catalogue.ConfigEndedDays] + if endedDays && !endsWith { + problems = append(problems, fmt.Sprintf("%s: the configuration gives %s and no type names ends-with, so no instance ends (design 47 H2 H-A-634 (3))", at, catalogue.ConfigEndedDays)) + } + if endsWith && !endedDays { + problems = append(problems, fmt.Sprintf("%s: a type names ends-with and the configuration gives no %s (design 47 H2 H-A-634 (3))", at, catalogue.ConfigEndedDays)) + } return problems } diff --git a/modules/mesh-delivery-indexer/judge/busstate_test.go b/modules/mesh-delivery-indexer/judge/busstate_test.go index 973dee8c9..b59538c17 100644 --- a/modules/mesh-delivery-indexer/judge/busstate_test.go +++ b/modules/mesh-delivery-indexer/judge/busstate_test.go @@ -16,6 +16,15 @@ import ( func TestBusStateIsJudgedOnce(t *testing.T) { const ledger = `{"name":"records","storage":"ledger","template":"ledger","options":{"max-mib":512},"types":[` + `{"name":"decision","schema":{"title":{"type":"text"}},"operations":[{"name":"propose","effect":"set-fields","fields":["title"]}]}]}` + ended := func(ledger, days, endsWith string) string { + if days != "" { + ledger = strings.Replace(ledger, `"options"`, `"configuration":{"ended-days":`+days+`},"options"`, 1) + } + if endsWith != "" { + ledger = strings.Replace(ledger, `"name":"decision",`, `"name":"decision","ends-with":"`+endsWith+`",`, 1) + } + return ledger + } manifest := func(entries string) string { return `{"module":"a","version":"1.0","requires":[` + entries + `]}` } @@ -84,6 +93,13 @@ func TestBusStateIsJudgedOnce(t *testing.T) { {"a bare stream with a wrong when full", manifest(`{"name":"x","storage":"stream","configuration":{"when-full":"crash","max-mib":10,"max-age-days":9}}`), []string{"\"x\"", "\"when-full\"", "\"refuse\" or \"drop-oldest\""}}, {"a ledger effect outside the four", manifest(strings.Replace(ledger, `"set-fields"`, `"upsert"`, 1)), []string{"\"records\"", "effect \"upsert\"", "outside the four"}}, {"a ledger whose history expires", manifest(strings.Replace(ledger, `"options"`, `"configuration":{"max-age-days":30},"options"`, 1)), nil}, + // Design 47 H2 H-A-634 (3), H-A-690: ended-days is 1 to 3650 and goes with a type naming the field that ends an instance. + {"a ledger whose ended instances live 30 days", manifest(ended(ledger, "30", "title")), nil}, + {"ended-days 0", manifest(ended(ledger, "0", "title")), []string{"\"ended-days\""}}, + {"ended-days 3651", manifest(ended(ledger, "3651", "title")), []string{"\"ended-days\""}}, + {"an ends-with naming no field of the schema", manifest(ended(ledger, "30", "nothing")), []string{"ends-with", "\"nothing\""}}, + {"ended-days with no type naming ends-with", manifest(ended(ledger, "30", "")), []string{"ended-days", "no type names ends-with"}}, + {"ends-with with no ended-days", manifest(ended(ledger, "", "title")), []string{"ends-with", "no ended-days"}}, // DLV-I12 (ADR 0595 §8, ADR 0597 §2, §4): each refusal names the module, the entry, the type, the operation or index, and the field. {"a set-entry naming no into", manifest(strings.Replace(ledger, `"effect":"set-fields","fields":["title"]`, `"effect":"set-entry","key":"title"`, 1)), []string{"\"records\"", "type \"decision\"", "operation \"propose\"", "no into"}}, From 336d2abaa8887c8b60f50574a4342623d2aa9540 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:24:26 +0100 Subject: [PATCH 055/141] I6 npm-test-files: the files of an npm package that leave its digest are the indexer's setting npm-test-files, no pattern left in code Builds: design 47 H2 H-A-598, H-A-573 --- .../cmd/mesh-delivery-indexer/main.go | 17 +++++++ .../internal/fingerprint/fingerprint.go | 50 +++++++++++++++---- .../internal/fingerprint/fingerprint_test.go | 19 +++++-- .../internal/index/candidates.go | 3 ++ .../internal/index/packages.go | 2 +- .../internal/index/packages_gone_test.go | 2 +- modules/mesh-delivery-indexer/module.json | 7 +++ 7 files changed, 83 insertions(+), 17 deletions(-) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go index 8799a9df6..4bbc7f045 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -358,6 +358,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro Packages: awaitedStore{b: packages, js: js, name: index.Bucket(cred.Module, index.PackagesState)}, Files: filesVia(calls.Call), GoMod: goModVia(calls.Call), Heard: heardStore, Runs: awaitedStore{b: runs}, Graph: graph, // How long a reservation is kept and how long its gathering waits at most (design 47 H2 §805, H-A-424). + NpmTestFiles: listSetting("npm-test-files", logger.Printf), ReservedKeep: durationSetting("reserved-keep", index.DefaultReservedKeep, logger.Printf), ReservedSettle: durationSetting("reserved-settle", index.DefaultReservedSettle, logger.Printf), // How long a take-in waits on another part before it says so, and before it raises take-in-waiting (H2 §803, H-A-461 (2)). @@ -684,3 +685,19 @@ func durationSetting(key string, def time.Duration, logf func(string, ...any)) t } return d } + +// listSetting is the setting key read as a list of comma-separated words; one that is not given is said and is no words. +func listSetting(key string, logf func(string, ...any)) []string { + v, ok := stdio.Setting(key) + if !ok { + logf("the setting %s is not given: no file of an npm package is left out of its digest but node_modules", key) + return nil + } + var out []string + for _, w := range strings.Split(v, ",") { + if w = strings.TrimSpace(w); w != "" { + out = append(out, w) + } + } + return out +} diff --git a/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint.go b/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint.go index dca0b6c16..8ce61fdbe 100644 --- a/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint.go +++ b/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint.go @@ -386,11 +386,11 @@ func Packages(module string, files map[string]string) (requires string, packages // (design 47 H2 H-A-546 (1)). It refuses a listing with no package.json at that directory. // // Its one package is the npm name, its digest the hex sha256 of the sorted lines " " of every -// file under it but node_modules and the test files of `node --test`'s default patterns, which the Node build module's unit -// step runs (H-A-547): a file named `*.test.*`, `*-test.*`, `*_test.*` or `test.*`, and everything under a directory named -// test. The requirements' digest is the hex sha256 of the lines "package.json " and "package-lock.json " -// (the second absent with no lock file), as H-A-525 has it for go.mod and go.sum. -func NpmPackage(name string, files map[string]string) (requires string, packages []meshcatalog.PackagesByModuleValuePackagesItem, err error) { +// file under it but node_modules and the test files the indexer's setting npm-test-files names (H-A-598), the patterns of +// `node --test`'s defaults which the Node build module's unit step runs (H-A-547) as the setting's default has them. The +// requirements' digest is the hex sha256 of the lines "package.json " and "package-lock.json " (the second +// absent with no lock file), as H-A-525 has it for go.mod and go.sum. +func NpmPackage(name string, files map[string]string, testFiles []string) (requires string, packages []meshcatalog.PackagesByModuleValuePackagesItem, err error) { pj, ok := files["package.json"] if !ok { return "", nil, fmt.Errorf("the npm package %s has no package.json at its directory", name) @@ -402,7 +402,7 @@ func NpmPackage(name string, files map[string]string) (requires string, packages sum := sha256.Sum256([]byte(req)) var lines []string for p, object := range files { - if npmLeftOut(p) { + if npmLeftOut(p, testFiles) { continue } lines = append(lines, p+" "+object) @@ -413,15 +413,43 @@ func NpmPackage(name string, files map[string]string) (requires string, packages } // npmLeftOut is whether a file of an npm package, by its path relative to the package, leaves its digest: under -// node_modules or a directory named test, or a test file by `node --test`'s default patterns (H-A-547). -func npmLeftOut(p string) bool { - dir, file := path.Split(p) +// node_modules, or matching one of the setting npm-test-files' patterns (H-A-547, H-A-598). +func npmLeftOut(p string, testFiles []string) bool { + dir, _ := path.Split(p) for _, e := range strings.Split(strings.TrimSuffix(dir, "/"), "/") { - if e == "node_modules" || e == "test" { + if e == "node_modules" { return true } } - return strings.HasPrefix(file, "test.") || strings.Contains(file, ".test.") || strings.Contains(file, "-test.") || strings.Contains(file, "_test.") + for _, pattern := range testFiles { + if globMatch(strings.Split(pattern, "/"), strings.Split(p, "/")) { + return true + } + } + return false +} + +// globMatch is whether the path's segments match the pattern's: a segment by path.Match, `**` any number of segments +// (none included). +func globMatch(pattern, segments []string) bool { + if len(pattern) == 0 { + return len(segments) == 0 + } + if pattern[0] == "**" { + for i := 0; i <= len(segments); i++ { + if globMatch(pattern[1:], segments[i:]) { + return true + } + } + return false + } + if len(segments) == 0 { + return false + } + if ok, err := path.Match(pattern[0], segments[0]); err != nil || !ok { + return false + } + return globMatch(pattern[1:], segments[1:]) } // ignoredDir is whether the go tool takes no package from dir: an element named testdata, or starting with _ or . diff --git a/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint_test.go b/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint_test.go index cbccd2319..7c3e797f4 100644 --- a/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint_test.go +++ b/modules/mesh-delivery-indexer/internal/fingerprint/fingerprint_test.go @@ -13,6 +13,9 @@ const sdk = "git.novox.be/novox/mesh-sdk/go" // The indexer's one computation (ADR 0593 §2): what moved out of mesh-sdk computes what it computed, the import form // moves only with what a module imports, and a package's digest is its own files. +// npmTestFiles are the setting npm-test-files' default, as the indexer's manifest gives it (H-A-573, H-A-598). +var npmTestFiles = []string{"**/*.test.*", "**/*-test.*", "**/*_test.*", "**/test.*", "**/test/**"} + func TestTheFingerprintComputation(t *testing.T) { t.Run("the moved computation gives the values it gave in mesh-sdk", movedComputationGivesTheValuesItGaveInMeshSDK) t.Run("the import form moves only with what the module imports", importFormMovesOnlyWithWhatTheModuleImports) @@ -222,7 +225,7 @@ func packageDigestIsItsOwnFiles(t *testing.T) { npm := map[string]string{"package.json": "p1", "package-lock.json": "l1", "src/stdio.ts": "a", "dist/stdio.js": "b", "src/stdio.test.ts": "t1", "src/a-test.ts": "t2", "src/a_test.mjs": "t3", "test.js": "t4", "test/x.ts": "t5", "node_modules/x/index.js": "n"} - npmReq, npmPkgs, err := NpmPackage("@novox/mesh-sdk", npm) + npmReq, npmPkgs, err := NpmPackage("@novox/mesh-sdk", npm, npmTestFiles) if err != nil || len(npmPkgs) != 1 || npmPkgs[0].Package != "@novox/mesh-sdk" || npmPkgs[0].Digest == "" || npmReq == "" { t.Fatalf("NpmPackage = %q, %+v, %v; want one package by its npm name", npmReq, npmPkgs, err) } @@ -231,7 +234,7 @@ func packageDigestIsItsOwnFiles(t *testing.T) { moves bool }{{"src/stdio.ts", true}, {"dist/stdio.js", true}, {"package.json", true}, {"src/stdio.test.ts", false}, {"src/a-test.ts", false}, {"src/a_test.mjs", false}, {"test.js", false}, {"test/x.ts", false}, {"node_modules/x/index.js", false}} { - r, ps, _ := NpmPackage("@novox/mesh-sdk", with(npm, c.file, "zz")) + r, ps, _ := NpmPackage("@novox/mesh-sdk", with(npm, c.file, "zz"), npmTestFiles) if moved := ps[0].Digest != npmPkgs[0].Digest; moved != c.moves { t.Errorf("changing %s of the npm package moved its digest %v, want %v", c.file, moved, c.moves) } @@ -239,10 +242,18 @@ func packageDigestIsItsOwnFiles(t *testing.T) { t.Error("a changed package.json left the npm package's requirements' digest") } } - if r2, _, _ := NpmPackage("@novox/mesh-sdk", with(npm, "package-lock.json", "l2")); r2 == npmReq { + // H-A-598: the patterns are the setting's; given one, a file it matches leaves the digest and another file moves it. + one := []string{"**/*.spec.*"} + _, base, _ := NpmPackage("@novox/mesh-sdk", with(npm, "src/a.spec.ts", "s"), one) + _, specMoved, _ := NpmPackage("@novox/mesh-sdk", with(npm, "src/a.spec.ts", "s2"), one) + _, otherMoved, _ := NpmPackage("@novox/mesh-sdk", with(npm, "src/stdio.test.ts", "t9"), one) + if specMoved[0].Digest != base[0].Digest || otherMoved[0].Digest == base[0].Digest { + t.Error("with the setting npm-test-files given one pattern, a file it matches moved the digest or another did not") + } + if r2, _, _ := NpmPackage("@novox/mesh-sdk", with(npm, "package-lock.json", "l2"), npmTestFiles); r2 == npmReq { t.Error("a changed lock file left the npm package's requirements' digest") } - if _, _, err := NpmPackage("@novox/mesh-sdk", map[string]string{"index.js": "x"}); err == nil { + if _, _, err := NpmPackage("@novox/mesh-sdk", map[string]string{"index.js": "x"}, npmTestFiles); err == nil { t.Error("a listing with no package.json was taken as an npm package") } } diff --git a/modules/mesh-delivery-indexer/internal/index/candidates.go b/modules/mesh-delivery-indexer/internal/index/candidates.go index ffa206021..f174f0ab1 100644 --- a/modules/mesh-delivery-indexer/internal/index/candidates.go +++ b/modules/mesh-delivery-indexer/internal/index/candidates.go @@ -186,6 +186,9 @@ type Indexer struct { // first reservation its gathering settles at the latest: the settings reserved-keep and reserved-settle (design 47 H2 // §805, H-A-424); zero takes the default. ReservedKeep, ReservedSettle time.Duration + // NpmTestFiles are the patterns of the files that leave an npm package's digest, the setting npm-test-files (design 47 H2 + // H-A-598); none leaves only node_modules. + NpmTestFiles []string // WaitingLine is how long a take-in waits on another part before it says so and keeps its waiting-on, and WaitingBound // how long before it raises take-in-waiting: the settings take-in-waiting-line and take-in-waiting-bound (design 47 H2 // §803, H-A-461 (2)); zero takes the default. diff --git a/modules/mesh-delivery-indexer/internal/index/packages.go b/modules/mesh-delivery-indexer/internal/index/packages.go index 8774d9950..be90fcc80 100644 --- a/modules/mesh-delivery-indexer/internal/index/packages.go +++ b/modules/mesh-delivery-indexer/internal/index/packages.go @@ -459,7 +459,7 @@ func (ix *Indexer) npmPackagesIn(ctx context.Context, repository, commit string, if _, ok := files["package.json"]; !ok { continue } - requires, pkgs, err := fingerprint.NpmPackage(name, files) + requires, pkgs, err := fingerprint.NpmPackage(name, files, ix.NpmTestFiles) if err != nil { ix.logf("%s at %s: %v; it is not published", repository, commit, err) break diff --git a/modules/mesh-delivery-indexer/internal/index/packages_gone_test.go b/modules/mesh-delivery-indexer/internal/index/packages_gone_test.go index b56415076..6a2ba3356 100644 --- a/modules/mesh-delivery-indexer/internal/index/packages_gone_test.go +++ b/modules/mesh-delivery-indexer/internal/index/packages_gone_test.go @@ -226,7 +226,7 @@ func TestARepositorysPackagesAreThoseInTheMergesTree(t *testing.T) { if err := ix.publish(ctx, "novox/mesh-sdk", merge, held, false, TrunkBranch); err != nil { t.Fatal(err) } - _, want, _ := fingerprint.NpmPackage(npmName, listing) + _, want, _ := fingerprint.NpmPackage(npmName, listing, nil) got, ok := ix.publishedAll(ctx)[npmName] if !ok || got.Repository != "novox/mesh-sdk" || got.Dir != "ts" || got.Commit != merge || !reflect.DeepEqual(got.Packages, want) { t.Fatalf("packages of %s = %+v (%v), want its digest %+v from novox/mesh-sdk at ts; asked %v", npmName, got, ok, want, asked) diff --git a/modules/mesh-delivery-indexer/module.json b/modules/mesh-delivery-indexer/module.json index 035b7ab74..dbedebf97 100644 --- a/modules/mesh-delivery-indexer/module.json +++ b/modules/mesh-delivery-indexer/module.json @@ -116,6 +116,13 @@ "default": "30s", "runtime": true }, + "npm-test-files": { + "type": "string", + "description": "the patterns of the files of an npm package that leave its digest, comma-separated: a segment as path.Match reads it, ** any number of directories; node's own test patterns and everything under a test directory (design 47 H2 H-A-573, H-A-598).", + "trusted": false, + "default": "**/*.test.*,**/*-test.*,**/*_test.*,**/test.*,**/test/**", + "runtime": true + }, "reserved-keep": { "type": "string", "description": "how long the indexer keeps a pipeline's reservation of a package's version in its state heard (reserved..), a Go duration (design 47 H2 §805, H-A-424 (2)).", From df890b8a7c11fcecdf0750ed61b3e689927c9ce4 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:25:38 +0100 Subject: [PATCH 056/141] W1 held-wait-timed: the watchman times a wait on the revision view by its bound from its clock-from, seeded or heard, and its end clears it Builds: design 47 H2 H-A-599, H-A-611, H-A-625 (1), H-A-736 (1) --- .../cmd/mesh-delivery-watchman/consumes.go | 6 +- .../integration_test.go | 39 +++++++++- .../internal/watch/steps.go | 77 ++++++++++++++++++- .../internal/watch/steps_test.go | 33 ++++++++ .../mesh-delivery-watchman/manifest_test.go | 2 +- modules/mesh-delivery-watchman/module.json | 2 + 6 files changed, 152 insertions(+), 7 deletions(-) diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/consumes.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/consumes.go index 7065d307d..55c41ca6e 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/consumes.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/consumes.go @@ -173,7 +173,7 @@ func brokerSubject(subject string) bool { return strings.HasPrefix(subject, "mesh.seat."+meshbroker.Seat+".event.") } -// pipelineSubject hands the runner's `step-started` and `step-ended` and the assigner's `step-progress` to the watchman +// pipelineSubject hands the runner's `step-started`, `step-ended`, `wait-held` and `wait-ended` and the assigner's `step-progress` to the watchman // (watch/pipelines.go, watch/steps.go, design 47 G §732, H §741): each step's clock. It says whether the subject was one of them. func pipelineSubject(w *watch.Watchman, subject string, body []byte) bool { switch { @@ -183,6 +183,10 @@ func pipelineSubject(w *watch.Watchman, subject string, body []byte) bool { case strings.HasPrefix(subject, "mesh.seat."+meshpipelinerunner.Seat+".event."+meshpipelinerunner.EventStepEnded+"."): w.StepEvent(body) w.StepEnded(body) + case strings.HasPrefix(subject, "mesh.seat."+meshpipelinerunner.Seat+".event."+meshpipelinerunner.EventWaitHeld+"."): + w.RunnerWaitHeld(body) + case strings.HasPrefix(subject, "mesh.seat."+meshpipelinerunner.Seat+".event."+meshpipelinerunner.EventWaitEnded+"."): + w.RunnerWaitEnded(body) case strings.HasPrefix(subject, "mesh.seat."+meshwants.Seat+".event."+meshwants.EventStepProgress+"."): w.WantsStepProgress(body) default: diff --git a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go index 20275428e..ba515e89d 100644 --- a/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go +++ b/modules/mesh-delivery-watchman/cmd/mesh-delivery-watchman/integration_test.go @@ -394,6 +394,38 @@ func TestWatchmanWhole(t *testing.T) { // 1135/AC8 return watch.FindingKey(watch.ScopeDelivery, watch.StepFindingID(seededPipeline+"/"+step+"/"), watch.KindPipelineStands) } until("the seeded composition step with no progress", func() bool { return finding(seeded("composition")) }) + until("the seeded step held for the view past its bound", func() bool { return finding(seeded("validate")) }) + // H-A-611: a wait-held on the revision view is timed by its bound from its clock-from and its wait-ended clears it; an + // approval wait held twice as long raises nothing. + { + heldFrom := time.Now().UTC().Add(-2 * time.Minute) + held := func(step, on string) []byte { + b, _ := json.Marshal(meshpipelinerunner.WaitHeldEvent{V: 1, Pipeline: "main.13.web", Branch: "main", Source: 13, Step: step, On: on, Bound: "1m", + ClockFrom: &heldFrom, Since: heldFrom}) + return b + } + viewFinding := watch.FindingKey(watch.ScopeDelivery, watch.StepFindingID("main.13.web/composition/"), watch.KindPipelineStands) + approvalFinding := watch.FindingKey(watch.ScopeDelivery, watch.StepFindingID("main.13.web/approval/"), watch.KindPipelineStands) + for _, e := range []struct { + subject string + body []byte + }{ + {meshpipelinerunner.SubjectWaitHeld("main", "13"), held("approval", meshpipelinerunner.WaitOnPerson)}, + {meshpipelinerunner.SubjectWaitHeld("main", "13"), held("composition", meshpipelinerunner.WaitOnRevisionView)}, + } { + if _, err := js.Publish(ctx, e.subject, e.body); err != nil { + t.Fatal(err) + } + } + until("the step held for the revision view past its bound", func() bool { return finding(viewFinding) }) + if finding(approvalFinding) { + t.Error("an approval wait held past the bound raised pipeline-stands") + } + if _, err := js.Publish(ctx, meshpipelinerunner.SubjectWaitEnded("main", "13"), held("composition", meshpipelinerunner.WaitOnRevisionView)); err != nil { + t.Fatal(err) + } + until("the wait's end clears it", func() bool { return !finding(viewFinding) }) + } // H-A-709 (2): the step of the stands' second page is seeded as the first page's is. until("the seeded step of the second page", func() bool { return finding(watch.FindingKey(watch.ScopeDelivery, watch.StepFindingID(seededPipeline+"/unit/web:program"), watch.KindPipelineStands)) @@ -748,6 +780,9 @@ const ( // firstPage is the first page of the stand-in runner's stands, which names the next. var firstPage meshpipelinerunner.StandsAnswer +// heldSince is when the stand-in runner's step held for the revision view was held: past its bound of ten minutes. +var heldSince = time.Now().UTC().Add(-11 * time.Minute) + // seededPipeline is the pipeline the stand-in runner's stands names. const seededPipeline = "main.5.web" @@ -767,7 +802,9 @@ func serveCatalogHalf(t *testing.T, nc *nats.Conn) { // waiting on the assigner, a test step reading a run, and an approval waiting on a person. stands := meshpipelinerunner.StandsAnswer{Stands: []meshpipelinerunner.Wait{ {Pipeline: seededPipeline, Step: "composition", Ask: "seeded-ask", Module: "web", Branch: "main", Since: time.Now().UTC(), V: 1}, - {Pipeline: seededPipeline, Step: "approval", On: meshpipelinerunner.WaitOnPerson, Module: "web", Branch: "main", Since: time.Now().UTC(), V: 1}}} + {Pipeline: seededPipeline, Step: "approval", On: meshpipelinerunner.WaitOnPerson, Module: "web", Branch: "main", Since: time.Now().UTC(), V: 1}, + // H-A-611: a step held for the view past its wait's bound is raised from the start, as after a restart. + {Pipeline: seededPipeline, Step: "validate", On: meshpipelinerunner.WaitOnRevisionView, Bound: "10m", ClockFrom: &heldSince, Module: "web", Branch: "main", Since: heldSince, V: 1}}} // H-A-709 (2): the stands answer in two pages: the first names `next`, the second, asked with it, holds one more open step. second := meshpipelinerunner.StandsAnswer{Stands: []meshpipelinerunner.Wait{ {Pipeline: seededPipeline, Step: "unit", Artifact: "web:program", Ask: "seeded-ask-2", Module: "web", Branch: "main", Since: time.Now().UTC(), V: 1}}} diff --git a/modules/mesh-delivery-watchman/internal/watch/steps.go b/modules/mesh-delivery-watchman/internal/watch/steps.go index 27c3be1d9..599622142 100644 --- a/modules/mesh-delivery-watchman/internal/watch/steps.go +++ b/modules/mesh-delivery-watchman/internal/watch/steps.go @@ -28,6 +28,9 @@ type openStep struct { // at is when the clock began; owed says whether the step is owed progress. at time.Time owed bool + // bound is the time the step may stand from at before it is raised: the wait's own `bound` for a step held for the revision + // view (design 47 H2 H-A-599, H-A-611); zero: the progress bound. + bound time.Duration } // stepKey is the key an open step is kept under. @@ -63,6 +66,54 @@ func (w *Watchman) StepStarted(body []byte) { } owed := e.Result.Outcome == meshpipelinerunner.StepResultOutcomeRunning || e.Result.Outcome == "" w.openStep(key, e.Pipeline, e.Result.Step, e.Result.Artifact, e.Result.Ask, sharedAsks(e.Result.Shared), at, owed) + // A step held for the revision view that starts says its own clock (H-A-625 (1)): the wait's bound is no more. + w.steps[key].bound = 0 + w.timeStep(key) +} + +// RunnerWaitHeld hears the runner's `wait-held`: a wait with `on` `revision view` is a step held for the runner's view of its +// revision, timed by the wait's `bound` from its `clock-from` (its `since` where it carries none), raising `pipeline-stands` +// past it (design 47 H2 H-A-599, H-A-611, H-A-625 (1)); a wait on a person, for a build node or for a turn is owed no progress +// and left. +func (w *Watchman) RunnerWaitHeld(body []byte) { + var e meshpipelinerunner.WaitHeldEvent + if err := json.Unmarshal(body, &e); err != nil || e.Pipeline == "" || e.Step == "" { + w.say("a wait-held of the runner does not read, left: %v", err) + return + } + if e.On != meshpipelinerunner.WaitOnRevisionView { + return + } + bound, err := time.ParseDuration(e.Bound) + if err != nil || bound <= 0 { + w.say("the step %s of %s waits on the revision view and says no bound (%q), so it is never late", e.Step, e.Pipeline, e.Bound) + return + } + from := e.Since + if e.ClockFrom != nil && !e.ClockFrom.IsZero() { + from = *e.ClockFrom + } + w.mu.Lock() + defer w.mu.Unlock() + key := stepKey(e.Pipeline, e.Step, e.Artifact) + w.openStep(key, e.Pipeline, e.Step, e.Artifact, e.Ask, sharedAsks(e.Shared), from, true) + w.steps[key].bound = bound + w.timeStep(key) +} + +// RunnerWaitEnded hears the runner's `wait-ended`: the step held for the revision view is no more held, and its finding ends. +func (w *Watchman) RunnerWaitEnded(body []byte) { + var e meshpipelinerunner.WaitEndedEvent + if err := json.Unmarshal(body, &e); err != nil || e.Pipeline == "" || e.Step == "" { + w.say("a wait-ended of the runner does not read, left: %v", err) + return + } + if e.On != meshpipelinerunner.WaitOnRevisionView { + return + } + w.mu.Lock() + defer w.mu.Unlock() + w.closeStep(stepKey(e.Pipeline, e.Step, e.Artifact)) } // StepEnded hears the runner's `step-ended`: the step's clock ends and its finding is cleared. @@ -184,14 +235,18 @@ func (w *Watchman) timeStep(key string) { if s.ask != "" { last = ", last heard of its ask " + s.ask } + bound := w.progressBound + if s.bound > 0 { + bound = s.bound + } f := Finding{Scope: ScopeDelivery, ID: id, Kind: KindPipelineStands, Severity: Warning, Source: stepRow, Since: s.at, Summary: fmt.Sprintf("the step %s has said nothing since %s%s", name, stamp(s.at), last), - Said: "no progress in " + w.progressBound.String(), + Said: "no progress in " + bound.String(), Headline: "A pipeline step has stopped saying it lives", Explanation: "The step " + name + " started and has not ended, and neither it nor the run it reads has said its progress for " + - w.progressBound.String() + " or more" + last + ".", + bound.String() + " or more" + last + ".", Needs: "the part that runs it to say its progress, or the step ended (the runner's verbs mesh-pipeline-runner.stands and mesh-pipeline-runner.cancel)"} - if left := w.progressBound - w.now().Sub(s.at); left > 0 { + if left := bound - w.now().Sub(s.at); left > 0 { w.signal(stepRow, id, left, signalDue{Do: dueFind, Finding: f}) return } @@ -212,6 +267,20 @@ func (w *Watchman) SeedSteps(stands []meshpipelinerunner.Wait) { continue } owed := s.On != meshpipelinerunner.WaitOnPerson && s.On != meshpipelinerunner.WaitOnBuildNode && s.Who == "" - w.openStep(key, s.Pipeline, s.Step, s.Artifact, s.Ask, sharedAsks(s.Shared), w.now(), owed) + at := w.now() + var bound time.Duration + if s.On == meshpipelinerunner.WaitOnRevisionView { + // A step held for the view stands from the time it was held, whatever the watchman's start (H-A-599, H-A-611). + if d, err := time.ParseDuration(s.Bound); err == nil && d > 0 { + bound = d + at = s.Since + if s.ClockFrom != nil && !s.ClockFrom.IsZero() { + at = *s.ClockFrom + } + } + } + w.openStep(key, s.Pipeline, s.Step, s.Artifact, s.Ask, sharedAsks(s.Shared), at, owed) + w.steps[key].bound = bound + w.timeStep(key) } } diff --git a/modules/mesh-delivery-watchman/internal/watch/steps_test.go b/modules/mesh-delivery-watchman/internal/watch/steps_test.go index 41320f5a0..3d7793617 100644 --- a/modules/mesh-delivery-watchman/internal/watch/steps_test.go +++ b/modules/mesh-delivery-watchman/internal/watch/steps_test.go @@ -19,6 +19,12 @@ func stepBody(pipeline, step, artifact, ask, outcome string, at time.Time, share return b } +func heldBody(pipeline, step, artifact, on, bound string, from *time.Time) []byte { + b, _ := json.Marshal(meshpipelinerunner.WaitHeldEvent{V: 1, Pipeline: pipeline, Branch: "main", Step: step, Artifact: artifact, On: on, Bound: bound, + ClockFrom: from, Since: time.Now().UTC()}) + return b +} + func wantsProgress(ask string, at time.Time, shared ...string) []byte { var sh []meshwants.Shared for _, a := range shared { @@ -111,6 +117,33 @@ func TestAStepThatReadsARunIsTimed(t *testing.T) { w.WantsStepProgress(wantsProgress("a1", c.t)) // the composition step lives expire(w, c, key("p", "unit", "m:program"), time.Minute) }, []string{finding("p", "unit", "m:program")}}, + // H-A-599, H-A-611, H-A-625 (1), H-A-736 (1): a step held for the revision view is timed by its wait's bound from its + // clock-from, and an approval waiting on a person, held twice as long, raises nothing. + {"a wait on the revision view is timed by its bound from its clock-from, and its end clears the finding", func(w *Watchman, o *fakeOut, c *clock) { + from := c.t.Add(-40 * time.Second) + w.RunnerWaitHeld(heldBody("p", "unit", "m:program", meshpipelinerunner.WaitOnRevisionView, "1m", &from)) + if o.ttls[key("p", "unit", "m:program")] != 20*time.Second || len(o.findings) != 0 { + t.Fatalf("the bound is counted from clock-from: %v %v", o.ttls, o.findings) + } + expire(w, c, key("p", "unit", "m:program"), 20*time.Second) + if _, ok := o.findings[finding("p", "unit", "m:program")]; !ok { + t.Fatalf("not raised past the wait's bound: %v", o.findings) + } + w.RunnerWaitEnded(heldBody("p", "unit", "m:program", meshpipelinerunner.WaitOnRevisionView, "1m", &from)) + }, nil}, + {"a wait on a person is never timed, a seeded wait on the view is timed from its clock-from", func(w *Watchman, o *fakeOut, c *clock) { + from := c.t.Add(-2 * time.Minute) + w.RunnerWaitHeld(heldBody("p", "approval", "", meshpipelinerunner.WaitOnPerson, "1m", &from)) + c.t = c.t.Add(time.Hour) + if len(o.pulses) != 0 || len(o.findings) != 0 { + t.Fatalf("a wait on a person owes nothing: %v %v", o.pulses, o.findings) + } + late := c.t.Add(-2 * time.Minute) + w.SeedSteps([]meshpipelinerunner.Wait{{Pipeline: "p", Step: "unit", Artifact: "m:program", On: meshpipelinerunner.WaitOnRevisionView, Bound: "1m", ClockFrom: &late}}) + if _, ok := o.findings[finding("p", "unit", "m:program")]; !ok { + t.Fatalf("a seeded wait held past its bound is raised at once: %v", o.findings) + } + }, []string{finding("p", "unit", "m:program")}}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { diff --git a/modules/mesh-delivery-watchman/manifest_test.go b/modules/mesh-delivery-watchman/manifest_test.go index 6a0dd971c..22842bd78 100644 --- a/modules/mesh-delivery-watchman/manifest_test.go +++ b/modules/mesh-delivery-watchman/manifest_test.go @@ -143,7 +143,7 @@ func TestManifestStateAndReads(t *testing.T) { // 1135/AC6 t.Errorf("invokes = %v, want %v", m.Invokes, want) } // DLV-M5 its first views, 1585/T20 the indexer's take-in events, and DLV-W1 (ADR 0595 §4): the accepted verdicts and the bus module's created and refused, durably. - if want := []string{"seat:mesh-wants.views.wants", "seat:mesh-module-assigner.views.seat-holders", "mesh-catalog.registration-changed", "mesh-catalog.catalog-revision", "mesh-delivery-indexer.take-in.pending", "mesh-delivery-indexer.take-in.taken", "mesh-delivery.source-moved", "mesh-delivery.filling", "mesh-delivery.full", "mesh-delivery.room", "mesh-delivery.record-opened", "mesh-delivery.record-ended", "mesh-catalog.filling", "mesh-catalog.full", "mesh-catalog.room", "mesh-wants.filling", "mesh-wants.full", "mesh-wants.room", "mesh-grants.filling", "mesh-grants.full", "mesh-grants.room", "node-build-go.ask-taken", "node-build-go.step-progress", "node-build-go.step-ended", "node-build-image.ask-taken", "node-build-image.step-progress", "node-build-image.step-ended", "node-build-node.ask-taken", "node-build-node.step-progress", "node-build-node.step-ended", "mesh-pipeline-runner.step-started", "mesh-pipeline-runner.step-ended", "mesh-wants.step-progress", "mesh-wants.wait-held", "mesh-wants.wait-ended", "node-engine.wait-held", "node-engine.wait-ended", "node-engine.running", "mesh-broker.created", "mesh-broker.refused", "mesh-broker.recreated", "mesh-broker.dropped", "mesh-conditions.findings-asked"}; !reflect.DeepEqual(m.Consumes, want) { + if want := []string{"seat:mesh-wants.views.wants", "seat:mesh-module-assigner.views.seat-holders", "mesh-catalog.registration-changed", "mesh-catalog.catalog-revision", "mesh-delivery-indexer.take-in.pending", "mesh-delivery-indexer.take-in.taken", "mesh-delivery.source-moved", "mesh-delivery.filling", "mesh-delivery.full", "mesh-delivery.room", "mesh-delivery.record-opened", "mesh-delivery.record-ended", "mesh-catalog.filling", "mesh-catalog.full", "mesh-catalog.room", "mesh-wants.filling", "mesh-wants.full", "mesh-wants.room", "mesh-grants.filling", "mesh-grants.full", "mesh-grants.room", "node-build-go.ask-taken", "node-build-go.step-progress", "node-build-go.step-ended", "node-build-image.ask-taken", "node-build-image.step-progress", "node-build-image.step-ended", "node-build-node.ask-taken", "node-build-node.step-progress", "node-build-node.step-ended", "mesh-pipeline-runner.step-started", "mesh-pipeline-runner.step-ended", "mesh-pipeline-runner.wait-held", "mesh-pipeline-runner.wait-ended", "mesh-wants.step-progress", "mesh-wants.wait-held", "mesh-wants.wait-ended", "node-engine.wait-held", "node-engine.wait-ended", "node-engine.running", "mesh-broker.created", "mesh-broker.refused", "mesh-broker.recreated", "mesh-broker.dropped", "mesh-conditions.findings-asked"}; !reflect.DeepEqual(m.Consumes, want) { t.Errorf("consumes = %v, want %v", m.Consumes, want) // design 47 H §741, §764, H-A-49, H-A-91 (2) } // Design 47 H §744, H-A-94 (2): the setting take-in-bound, 60 minutes by default, reaches the process as a file. diff --git a/modules/mesh-delivery-watchman/module.json b/modules/mesh-delivery-watchman/module.json index 0d0318aa0..a89d14201 100644 --- a/modules/mesh-delivery-watchman/module.json +++ b/modules/mesh-delivery-watchman/module.json @@ -63,6 +63,8 @@ "node-build-node.step-ended", "mesh-pipeline-runner.step-started", "mesh-pipeline-runner.step-ended", + "mesh-pipeline-runner.wait-held", + "mesh-pipeline-runner.wait-ended", "mesh-wants.step-progress", "mesh-wants.wait-held", "mesh-wants.wait-ended", From bcf170a003cf9316ea804842f191109ad2246731 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:25:45 +0100 Subject: [PATCH 057/141] I9 dropped-subjects-acked: the hub acknowledges toolchain-agreed and wait-ended with no work and says each subject once Builds: design 47 H2 H-A-578 (2), H-A-651, H-A-706 --- .../cmd/mesh-delivery-indexer/dropped.go | 27 +++++++++++++++++++ .../cmd/mesh-delivery-indexer/main.go | 5 ++++ .../cmd/mesh-delivery-indexer/main_test.go | 18 +++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/dropped.go diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/dropped.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/dropped.go new file mode 100644 index 000000000..fa9d56184 --- /dev/null +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/dropped.go @@ -0,0 +1,27 @@ +package main + +import ( + "sync" + + "github.com/nats-io/nats.go/jetstream" + + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" +) + +// droppedSubjects are the subjects the indexer's manifest no longer consumes while its durable consumer's filter still +// holds them, since the grants part never narrows a filter for a dropped entry (design 47 H2 H-A-578 (2), H-A-651): the +// toolchain agreement of the builder and the end of a want's wait. Listed once, here, beside the hub's handlers. +var droppedSubjects = []string{meshbuilds.SubjectToolchainAgreed, meshwants.SubjectWaitEnded} + +// ackDropped is the hub's handler of a subject no longer consumed: it acknowledges each message at once, with no work, so +// the finding event-unhandled stays clear, and says one journal line for the subject at the first one after the start. +func ackDropped(subject string, logf func(string, ...any)) func(jetstream.Msg) { + var once sync.Once + return func(m jetstream.Msg) { + once.Do(func() { + logf("%s is no longer consumed: its events are acknowledged with no work (design 47 H2 H-A-578 (2))", subject) + }) + _ = m.Ack() + } +} diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go index 4bbc7f045..df3617cd5 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -616,6 +616,11 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro if err := hub.Handle(decidedSubject(cred.Module), func(m jetstream.Msg) { heardDecided(ctx, registry, m, logger.Printf) }); err != nil { return err } + for _, subject := range droppedSubjects { + if err := hub.Handle(subject, ackDropped(subject, logger.Printf)); err != nil { + return err + } + } // The indexer's own room wakes every take-in held on a full catalog store (design 47 H §744, H-A-50). if err := hub.Handle(meshcatalog.SubjectRoom, func(m jetstream.Msg) { _ = m.Ack(); go sources.takeAgain() }); err != nil { return err diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main_test.go index 8ff5d8db6..cec137541 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main_test.go @@ -3,6 +3,8 @@ package main import ( "context" "encoding/json" + "fmt" + "strings" "testing" "time" @@ -113,3 +115,19 @@ func (h *startedHub) StartKept(context.Context, jetstream.JetStream, process.Acc h.kept = true return 1 } + +// H-A-578 (2): an event of a subject the indexer no longer consumes is acknowledged with no work, and the journal says +// the subject once, at the first. +func TestASubjectNoLongerConsumedIsAcknowledgedAndSaidOnce(t *testing.T) { + if len(droppedSubjects) != 2 { + t.Fatalf("the dropped subjects are %v, want the toolchain agreement and the wait's end", droppedSubjects) + } + var said []string + handle := ackDropped(droppedSubjects[0], func(format string, a ...any) { said = append(said, fmt.Sprintf(format, a...)) }) + first, second := &ackedMsg{}, &ackedMsg{} + handle(first) + handle(second) + if first.acked != 1 || second.acked != 1 || len(said) != 1 || !strings.Contains(said[0], droppedSubjects[0]) { + t.Errorf("acked %d and %d, said %q; want both acknowledged and the subject said once", first.acked, second.acked, said) + } +} From 61a6811cd5bd0a432653d055419011547e06101e Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:26:11 +0100 Subject: [PATCH 058/141] R3 grants-withheld-away: grants_withheld asked before its first composition answers away naming that composition Builds: design 47 H2 H-A-708 (2), H-A-736 (2) --- modules/mesh-grants/grants_test.go | 6 ++++-- modules/mesh-grants/internal/grants/part.go | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/mesh-grants/grants_test.go b/modules/mesh-grants/grants_test.go index ad5640d7b..b269dbbae 100644 --- a/modules/mesh-grants/grants_test.go +++ b/modules/mesh-grants/grants_test.go @@ -1334,8 +1334,10 @@ func TestGrants(t *testing.T) { t.Fatalf("withheld by node = %+v", byNode) } p := partOn(newFakeBus()) - if _, err := p.WithheldOn("a"); err == nil { - t.Errorf("withheld before any composition answered no error") + // H-A-736 (2): asked before its first composition, withheld answers `away` naming that composition. + var away *busretry.Away + if _, err := p.WithheldOn("a"); !errors.As(err, &away) || away.Part != "the first composition" { + t.Errorf("withheld before any composition answered %v, not away naming the first composition", err) } raw, _ := json.Marshal(grants.UserListState{V: 1, Withheld: byNode}) if _, err := p.Store.Put(grants.StateUserList, grants.KeyList, raw); err != nil { diff --git a/modules/mesh-grants/internal/grants/part.go b/modules/mesh-grants/internal/grants/part.go index f1317e804..df001953b 100644 --- a/modules/mesh-grants/internal/grants/part.go +++ b/modules/mesh-grants/internal/grants/part.go @@ -19,6 +19,7 @@ import ( "git.novox.be/novox/mesh-contracts/identity-and-access/go/seats/meshgrants" oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel" "git.novox.be/novox/mesh-delivery/modules/mesh-grants/grantsstate" + "git.novox.be/novox/mesh-sdk/go/busretry" "git.novox.be/novox/mesh-sdk/go/membership" "mesh-grants/internal/buscompose" ) @@ -784,7 +785,9 @@ func (p *Part) WithheldOn(node string) (meshgrants.Withheld, error) { // Before the process kept the small key: the list's own, which only a reader that can open it reads. if raw, _, found, err = p.Store.Get(StateUserList, KeyList); err == nil { if !found { - return out, errors.New("nothing composed yet: grants_compose_now composes it") + // A read that cannot answer yet is `away` naming what it waits for, never a word a caller takes as a refusal (design + // 47 H2 H-A-708 (2), H-A-736 (2)). + return out, &busretry.Away{Part: "the first composition", Words: "nothing composed yet: grants_compose_now composes it"} } err = json.Unmarshal(raw, &st) } From d77bff56c4fc022db24298cd128dc73cd65adce5 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:27:21 +0100 Subject: [PATCH 059/141] B16 events-by-key (1): the builder's events go through mesh-sdk's hub by key; its eventWorkers go Builds: design 47 H2 H-A-683 (1), H-A-695, H-A-737 (1) --- .../cmd/mesh-delivery-builder/consumers.go | 14 +++- .../cmd/mesh-delivery-builder/eventtake.go | 83 ++++--------------- .../cmd/mesh-delivery-builder/main.go | 7 +- .../cmd/mesh-delivery-builder/reserve_test.go | 71 +++++----------- 4 files changed, 54 insertions(+), 121 deletions(-) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/consumers.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/consumers.go index 3d21bc606..e13cced52 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/consumers.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/consumers.go @@ -14,6 +14,7 @@ import ( // handlers is where a part of the builder registers its handler of the events it hears: the event hub, or agedHub over it. type handlers interface { Handle(pattern string, handle func(jetstream.Msg)) error + HandleByKey(pattern string, key process.EventKey, handle func(jetstream.Msg)) error } // ledgers are the builder's durable consumers' ledgers, one per consumer as a message's metadata names it (the events consumer @@ -56,7 +57,16 @@ type agedHub struct { } func (a agedHub) Handle(pattern string, handle func(jetstream.Msg)) error { - return a.hub.Handle(pattern, func(m jetstream.Msg) { + return a.hub.Handle(pattern, a.aged(handle)) +} + +// HandleByKey registers handle held by key, each message noted as Handle's are. +func (a agedHub) HandleByKey(pattern string, key process.EventKey, handle func(jetstream.Msg)) error { + return a.hub.HandleByKey(pattern, key, a.aged(handle)) +} + +func (a agedHub) aged(handle func(jetstream.Msg)) func(jetstream.Msg) { + return func(m jetstream.Msg) { led := a.ledgers.of(m) if led == nil { handle(m) @@ -64,7 +74,7 @@ func (a agedHub) Handle(pattern string, handle func(jetstream.Msg)) error { } led.Delivered(m) handle(&agedMsg{Msg: m, ledger: led}) - }) + } } // agedMsg is a message whose acknowledgement or end is noted applied on its consumer's ledger, once. diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/eventtake.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/eventtake.go index 84daae11e..a49ff7ad9 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/eventtake.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/eventtake.go @@ -3,12 +3,12 @@ package main import ( "encoding/json" "errors" - "slices" - "sync" + "strings" "time" "github.com/nats-io/nats.go/jetstream" + "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" stdio "git.novox.be/novox/mesh-sdk/go" @@ -60,78 +60,29 @@ func takeEvent(m jetstream.Msg, takers []eventTaker, rest eventTaker, slow time. } } -// eventWorkers hands each event of the builder's durable to a worker of its key (design 47 H2 H-A-514 addenda): the name the -// event carries (a registry seat's outcome's package name, a version-released's module), one shared worker for the events that -// name none. One key's events are handled in the order heard, the keys side by side, so a slow event of one name delays no -// other name's. A worker ends when its queue is empty. The builder holds no timer (ADR 0437 §8), so the events still waiting in -// a queue are said in progress to the bus each time its worker ends a handling, and none waits out the ack wait behind another. -type eventWorkers struct { - handle func(jetstream.Msg) - keyOf func(jetstream.Msg) string - - mu sync.Mutex - queues map[string]*eventQueue -} - -// eventQueue is one key's events not yet handled, the one handled now first. -type eventQueue struct{ msgs []jetstream.Msg } - -// take queues m on its key's worker, starting the worker when none runs. -func (w *eventWorkers) take(m jetstream.Msg) { - key := w.keyOf(m) - w.mu.Lock() - if w.queues == nil { - w.queues = map[string]*eventQueue{} - } - q, running := w.queues[key] - if !running { - q = &eventQueue{} - w.queues[key] = q - } - q.msgs = append(q.msgs, m) - w.mu.Unlock() - if !running { - go w.run(key, q) - } -} - -// run handles key's events in order until its queue is empty, saying those still waiting in progress after each. -func (w *eventWorkers) run(key string, q *eventQueue) { - for { - w.mu.Lock() - if len(q.msgs) == 0 { - delete(w.queues, key) - w.mu.Unlock() - return - } - m := q.msgs[0] - w.mu.Unlock() - w.handle(m) - w.mu.Lock() - q.msgs = q.msgs[1:] - waiting := slices.Clone(q.msgs) - w.mu.Unlock() - for _, m := range waiting { - _ = m.InProgress() - } - } -} - -// eventKey is the worker key of a builder's event (H-A-514 second addendum): a registry seat's outcome's name, a -// version-released's module, else "" (one worker for the events naming none). -func eventKey(m jetstream.Msg) string { - if _, ok := seatEvents[m.Subject()]; ok { +// eventKey is the key the hub holds a builder's event under (design 47 H2 H-A-683 (1), H-A-737 (1)): a registry seat's outcome's +// name, a version-released's module, the node the subject of the seat node-engine's running and manifest-reads-changed names, +// else "" (the events naming none share one key). One key's events are handled one at a time in the order heard, the keys side by +// side, so a slow handling of one node's event holds back no other node's. +func eventKey(subject string, data []byte) string { + if _, ok := seatEvents[subject]; ok { var o versions.Outcome - if json.Unmarshal(m.Data(), &o) == nil { + if json.Unmarshal(data, &o) == nil { return "name " + o.Name } return "" } - if m.Subject() == meshcatalog.SubjectVersionReleased { + if subject == meshcatalog.SubjectVersionReleased { var ev meshcatalog.VersionReleasedEvent - if json.Unmarshal(m.Data(), &ev) == nil { + if json.Unmarshal(data, &ev) == nil { return "module " + ev.Module } + return "" + } + // mesh.seat.node-engine.event.running.. and mesh.seat.node-engine.event.manifest-reads-changed. + if t := strings.Split(subject, "."); len(t) >= 6 && t[2] == "node-engine" && t[3] == "event" && + (t[4] == nodeengine.EventRunning || t[4] == nodeengine.EventManifestReadsChanged) { + return "node " + t[5] } return "" } diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index 8a314ba56..7b2187842 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -483,9 +483,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro {"the registry seats' outcomes", func(m jetstream.Msg) bool { return seatHeard.heard(ctx, m) }}, } gone := eventTaker{"the artifacts gone", func(m jetstream.Msg) bool { heardGone(ctx, b, m, logger.Printf); return true }} - // Each event goes to a worker of the name it carries, one name's events in order, the names side by side (H-A-514 addenda). - workers := &eventWorkers{keyOf: eventKey, handle: func(m jetstream.Msg) { takeEvent(m, takers, gone, slow, nil, logger.Printf) }} - events := workers.take + // The hub holds each event under its key (eventKey), one key's events in order, the keys side by side (H-A-683 (1), H-A-737 (1)). + events := func(m jetstream.Msg) { takeEvent(m, takers, gone, slow, nil, logger.Printf) } // The seats' events (artifacts-gone, the registry seats' words, the build seats' toolchain-reported, the indexer's take-in.taken and // manifest-reads-changed and the seat mesh-conditions' condition-cleared: seatEventPatterns); the owners' views events and the // catalog half's catalog-revision and registration-changed and the gate's source-moved are the views reader's (a message has @@ -534,7 +533,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro seatGate.Follow(seatlist.ProcessBus(calls.Call, aged), func() { seatsChanged(ctx); b.SayUnbuildable(ctx) }, logger.Printf) half.holders = func() { seatsChanged(ctx) } for _, pattern := range seatEventPatterns { - if err := aged.Handle(pattern, events); err != nil { + if err := aged.HandleByKey(pattern, eventKey, events); err != nil { return err } } diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go index e7ef9939d..45b8e01f8 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/reserve_test.go @@ -7,7 +7,6 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" "slices" "strings" - "sync/atomic" "testing" "time" @@ -19,6 +18,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" stdio "git.novox.be/novox/mesh-sdk/go" + "git.novox.be/novox/mesh-sdk/go/process" "mesh-delivery-builder/internal/versions" ) @@ -875,62 +875,35 @@ func TestAPublishedThatMarksNothingIsSaidFromWhatItRead(t *testing.T) { }) } -// Design 47 H2 H-A-514 addenda: each event goes to the worker of the name it carries, so a slow handling of one name holds -// no other name's events, one name's events are handled in the order heard, and an event waiting in its worker's queue is -// said in progress at each tick, so the bus does not give it again. -func TestEventsAreHandledByAWorkerPerName(t *testing.T) { - pub := func(name, v string) *queuedEvent { - return &queuedEvent{wakeMsg: wakeMsg{subject: gopackageregistry.SubjectPublished, data: []byte(`{"name":"` + name + `","version":"` + v + `","digest":"sha256:aa"}`)}} - } - if got := eventKey(&pub("a", "1").wakeMsg); got != "name a" { - t.Errorf("a published's key is %q, want its name", got) - } - if got := eventKey(&wakeMsg{subject: meshcatalog.SubjectVersionReleased, data: []byte(`{"module":"m","version":"0.1.0"}`)}); got != "module m" { - t.Errorf("a version-released's key is %q, want its module", got) - } - if got := eventKey(&wakeMsg{subject: "mesh.seat.mesh-artifact-sweep.event.artifacts-gone", data: []byte(`{}`)}); got != "" { - t.Errorf("an event naming no name has the key %q, want the shared worker's", got) - } - release := make(chan struct{}) - handled := make(chan string, 4) - w := &eventWorkers{keyOf: eventKey, handle: func(m jetstream.Msg) { - var o versions.Outcome - _ = json.Unmarshal(m.Data(), &o) - if o.Name == "a" && o.Version == "1" { - <-release +// Design 47 H2 H-A-683 (1), H-A-737 (1): the builder gives the hub each pattern's key: a registry seat's outcome by its name, +// version-released by its module, the seat node-engine's running and manifest-reads-changed by the node their subject names; +// the hub holds one key's events in order and the keys side by side (mesh-sdk's tests). +func TestEventsAreHeldByTheKeyTheyName(t *testing.T) { + for _, c := range []struct { + name, subject, body, want string + }{ + {"a registry seat's outcome by its name", gopackageregistry.SubjectPublished, `{"name":"a","version":"1","digest":"sha256:aa"}`, "name a"}, + {"a version-released by its module", meshcatalog.SubjectVersionReleased, `{"module":"m","version":"0.1.0"}`, "module m"}, + {"a running by its node", "mesh.seat.node-engine.event.running.ace.mod", `{}`, "node ace"}, + {"a manifest-reads-changed by its node", "mesh.seat.node-engine.event.manifest-reads-changed.g14", `{}`, "node g14"}, + {"another node's manifest-reads-changed by its node", "mesh.seat.node-engine.event.manifest-reads-changed.ace", `{}`, "node ace"}, + {"another event of the seat node-engine shares", "mesh.seat.node-engine.event.composed.ace", `{}`, ""}, + {"an event naming none shares", "mesh.seat.mesh-artifact-sweep.event.artifacts-gone", `{}`, ""}, + } { + if got := eventKey(c.subject, []byte(c.body)); got != c.want { + t.Errorf("%s: the key is %q, want %q", c.name, got, c.want) } - handled <- o.Name + "@" + o.Version - }} - a1, a2, a3, b1 := pub("a", "1"), pub("a", "2"), pub("a", "3"), pub("b", "1") - w.take(a1) - w.take(a2) - w.take(a3) - w.take(b1) - if got := <-handled; got != "b@1" { - t.Fatalf("handled %s first, want b's event while a's first one is slow", got) - } - close(release) - if got := []string{<-handled, <-handled, <-handled}; !slices.Equal(got, []string{"a@1", "a@2", "a@3"}) { - t.Errorf("a's events handled %v, want in the order heard", got) - } - // a's worker said its waiting events in progress at each end: a2 and a3 after a1, a3 again after a2. - if a1.progressed.Load() != 0 || a2.progressed.Load() != 1 || a3.progressed.Load() != 2 { - t.Errorf("in progress said %d, %d and %d times of a's events, want 0, 1 and 2", a1.progressed.Load(), a2.progressed.Load(), a3.progressed.Load()) } } -// queuedEvent is an event of the builder's durable that counts its in-progress. -type queuedEvent struct { - wakeMsg - progressed atomic.Int32 -} - -func (m *queuedEvent) InProgress() error { m.progressed.Add(1); return nil } - // oneHandler is an event hub with one handler. type oneHandler struct{ handle func(jetstream.Msg) } func (h *oneHandler) Handle(_ string, f func(jetstream.Msg)) error { h.handle = f; return nil } +func (h *oneHandler) HandleByKey(_ string, _ process.EventKey, f func(jetstream.Msg)) error { + h.handle = f + return nil +} // agedTestMsg is a message of the builder's events consumer, with the metadata a ledger reads. type agedTestMsg struct { From 43f2ebc4ba1c694ed9417081fee7eb3c92ece1a3 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:27:43 +0100 Subject: [PATCH 060/141] A3 needs-hold: a want whose entry needs a capability its node's words lack is held awaiting its reads, one whose entry is not read awaiting its entry; assigner_why names the ask The test of the kept ask compares its fields (KeptAsk gains the hook). Builds: design 47 H2 H-A-682 (2) (3) (4), H-A-698 (1) (2), H-A-706 (DMC-14) --- .../compositioninputs_test.go | 2 +- .../cmd/mesh-delivery-assigner/pass.go | 28 +++++++ .../cmd/mesh-delivery-assigner/pass_test.go | 75 +++++++++++++++++++ .../cmd/mesh-delivery-assigner/why.go | 31 ++++++++ .../internal/assign/wants.go | 24 +++++- .../internal/assign/wants_test.go | 28 +++++++ 6 files changed, 186 insertions(+), 2 deletions(-) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs_test.go index 596bcbab5..f53ea4907 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositioninputs_test.go @@ -101,7 +101,7 @@ func TestAStepsInputsAreAskedOfEachMachine(t *testing.T) { t.Errorf("ace: %+v", got[0]) } // Design 47 H2 §775, H-A-405: each machine is asked as a kept call under the step's ask with the node, until compose-ask-bound. - if asks["ace"] != (process.KeptAsk{ID: "step-1.ace", Bound: time.Second}) || asks["g14"].ID != "step-1.g14" { + if asks["ace"].ID != "step-1.ace" || asks["ace"].Bound != time.Second || asks["g14"].ID != "step-1.g14" { t.Errorf("the kept asks %+v", asks) } if !strings.Contains(got[1].Why, "no responders") || !strings.Contains(got[2].Why, "unready") || got[1].Body != nil || got[2].Body != nil { diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go index 5d4daa346..1f6d6233a 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go @@ -264,6 +264,10 @@ func (p *passer) wants(ctx context.Context) { ReadsVersion: func(node string) bool { return slices.Contains(nodes.Reads[node], nodeengine.ManifestReadWordWantVersion) }, + // H-A-682 (2), H-A-698: a want's needs are those of its entry, the node's missing ones the want held for. + MissingNeeds: func(node, fp string) ([]string, bool) { + return p.missingNeeds(ctx, bv.trunk[name], nodes.Reads[node], fp) + }, // H §750, H-A-5, H-A-99: a placement's build is read before the rule and names the want's version. Target: func(node string) (assign.Target, bool) { if build := builds[node][name]; build != "" { @@ -294,6 +298,30 @@ func (p *passer) wants(ctx context.Context) { p.unversionedFindings(unversioned, trunk) } +// missingNeeds reads what a want at fp lacks of its node's words (design 47 H2 H-A-682 (2), H-A-698): the needs of the entry at fp, +// those of the module's held entry when it names fp, else the seat `mesh-catalog`'s `entry` for it, asked once and kept; read is +// false while that ask stands out, is not found or is unanswered, and the answer wakes a pass. The pass never waits on it. +func (p *passer) missingNeeds(ctx context.Context, held meshcatalog.ModulesByModuleValue, words []string, fp string) (missing []string, read bool) { + needs := held.Needs + if held.Fp2 != fp { + if p.entries == nil { + return nil, true + } + e, state := p.entries.Need(ctx, fp) + if state != meshcatalogclient.EntryAnswered { + return nil, false + } + needs = e.Needs + } + for _, need := range needs { + if !slices.Contains(words, need) { + missing = append(missing, need) + } + } + slices.Sort(missing) + return slices.Compact(missing), true +} + // put writes one key of the assigner's own bucket; a write that fails is said and made again at the next pass. func (p *passer) put(ctx context.Context, bucket, key string, encode func() ([]byte, error)) { p.written(ctx, bucket, key, encode) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go index be395846b..6af9f772b 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" mpr "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" + "git.novox.be/novox/mesh-sdk/go/busretry" "git.novox.be/novox/mesh-sdk/go/process" "mesh-delivery-assigner/internal/buckets" "mesh-delivery-assigner/internal/puts" @@ -1038,3 +1039,77 @@ func TestAnActingPartsNewVersionHoldsNoWant(t *testing.T) { t.Errorf("an acting part's version held the want: kept %v, said %v", waits.values, said) } } + +// H-A-682 (2), H-A-698 (1), (2): the needs of a want are those of the module's held entry when it names the fingerprint, else those +// the seat `mesh-catalog`'s `entry` answers; the pass never waits on that ask, the entry is not read while it is out, not found or +// unanswered, and the answer wakes a pass. +func TestAWantsNeedsAreReadFromItsEntryAndNeverWaitedFor(t *testing.T) { + const held, older, gone, lost = "src2:held", "src2:older", "src2:gone", "src2:lost" + words := []string{"want:version", "approval-mark/1"} + answered := make(chan struct{}, 8) + p := &passer{} + p.entries = meshcatalogclient.NewEntries(func(_ string, body any) (json.RawMessage, error) { + switch fp := body.(meshcatalog.EntryInput).Fingerprint; fp { + case gone: + return nil, &busretry.Answered{Words: "no entry"} + case lost: + return nil, errors.New("no responders") + default: + return json.Marshal(meshcatalog.EntryAnswer{Entry: meshcatalog.CatalogEntry{Module: "m", Fp: fp, Needs: []string{"directory-contents-owner", "approval-mark/1"}}}) + } + }) + p.entries.Changed = func(meshcatalogclient.EntryRow) { answered <- struct{}{} } + value := meshcatalog.ModulesByModuleValue{Fp2: held, Needs: []string{"want:version", "zeta", "approval-mark/1"}} + ctx := context.Background() + for _, c := range []struct { + fp string + missing []string + read bool + asked bool + }{ + {held, []string{"zeta"}, true, false}, + {older, nil, false, true}, // asked: not read yet + {older, []string{"directory-contents-owner"}, true, false}, // answered, and kept + {gone, nil, false, true}, + {lost, nil, false, false}, // out and failed in transport: asked again at the next revision, its answer awaited by no pass + } { + missing, read := p.missingNeeds(ctx, value, words, c.fp) + if !slices.Equal(missing, c.missing) || read != c.read { + t.Errorf("%s: missing %v read %v, want %v %v", c.fp, missing, read, c.missing, c.read) + } + if c.asked { + select { + case <-answered: + case <-time.After(10 * time.Second): // a bound on a failure only + t.Fatalf("%s: the ask is never answered", c.fp) + } + } + } + if _, read := p.missingNeeds(ctx, value, words, gone); read { + t.Error("an entry not found is read") + } +} + +// H-A-698 (2): the why of a want held awaiting its entry names the ask: its state, how often it was asked again and its last failure. +func TestTheWhyOfAWantAwaitingItsEntryNamesTheAsk(t *testing.T) { + const fp = "src2:lost" + kv := &memKV{values: map[string][]byte{}} + p := &passer{kvs: map[string]jetstream.KeyValue{writtenBucket(): kv}} + p.entries = meshcatalogclient.NewEntries(func(string, any) (json.RawMessage, error) { return nil, errors.New("no responders") }) + p.entries.Need(context.Background(), fp) + deadline := time.Now().Add(10 * time.Second) // a bound on a failure only + for len(p.entries.Rows()) == 0 || p.entries.Rows()[0].Detail == "" { + if time.Now().After(deadline) { + t.Fatal("the ask never failed") + } + time.Sleep(time.Millisecond) // the ask runs on its own goroutine + } + held := mwc.Want{Fp: fp, Hold: true, Words: mwc.HoldAwaitsEntryPrefix + fp} + p.sayWhy(context.Background(), "m", []string{"ace"}, wantWhy{Branch: "main", Fp: fp, Step: whyPassed}, nil, &assign.Outcome{Wants: map[string]mwc.Want{"ace": held}}) + raw, ok := kv.values[whyKey("ace", "m")] + var got wantWhy + if !ok || json.Unmarshal(raw, &got) != nil || got.Entry == nil || got.Entry.Fingerprint != fp || got.Entry.State != meshcatalogclient.EntryAsked || + !strings.Contains(got.Entry.Detail, "no responders") { + t.Errorf("the why = %s, want the ask of %s named with its state and last failure", raw, fp) + } +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/why.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/why.go index 94d73776d..dcf8a44e7 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/why.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/why.go @@ -7,6 +7,7 @@ import ( "strings" "time" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" mwc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient" stdio "git.novox.be/novox/mesh-sdk/go" @@ -50,6 +51,28 @@ type wantWhy struct { // Before is the want that stood before the pass, After the one the pass wrote (none: it kept Before). Before *mwc.Want `json:"before,omitempty"` After *mwc.Want `json:"after,omitempty"` + // Entry is the ask of the catalog entry a want held awaiting its entry waits on: its state, how often it was asked again and its + // last failure (design 47 H2 H-A-698 (2)). + Entry *entryAsk `json:"entry,omitempty"` +} + +// entryAsk is where the ask of one catalog entry stands. +type entryAsk struct { + Fingerprint string `json:"fingerprint"` + State meshcatalogclient.EntryState `json:"state"` + Asks int `json:"asks"` + Detail string `json:"detail,omitempty"` +} + +// heldWant is the want a why says stands after the pass: the one written, else the one before. +func heldWant(w wantWhy) mwc.Want { + switch { + case w.After != nil: + return *w.After + case w.Before != nil: + return *w.Before + } + return mwc.Want{} } func whyKey(node, module string) string { return whyPrefix + node + "." + module } @@ -74,6 +97,14 @@ func (p *passer) sayWhy(ctx context.Context, module string, nodes []string, w wa one.After = &a } } + if held := heldWant(one); p.entries != nil && strings.HasPrefix(held.Words, mwc.HoldAwaitsEntryPrefix) { + fp := strings.TrimPrefix(held.Words, mwc.HoldAwaitsEntryPrefix) + for _, row := range p.entries.Rows() { + if row.Fingerprint == fp { + one.Entry = &entryAsk{Fingerprint: fp, State: row.State, Asks: row.Asks, Detail: row.Detail} + } + } + } same := one same.At = time.Time{} cmp, _ := json.Marshal(same) diff --git a/modules/mesh-delivery-assigner/internal/assign/wants.go b/modules/mesh-delivery-assigner/internal/assign/wants.go index e7eeef0ae..e9f57f7e2 100644 --- a/modules/mesh-delivery-assigner/internal/assign/wants.go +++ b/modules/mesh-delivery-assigner/internal/assign/wants.go @@ -17,7 +17,7 @@ import ( // A want names the newest released version whose pipeline passed (design 47 H §750): for every node whose assignment places // a module on a watched branch, the want names the version, the pipeline and the mover's rank in it, written tier by tier -// (§751). It is held for nothing else: the rules of ADR 0429 §6 (the build done, not held, the canary and step, every +// (§751). It is held for nothing else than a reader capability its node-engine does not state (ADR 0614 §4, §772 being its first case, H-A-682); the rules of ADR 0429 §6 (the build done, not held, the canary and step, every // provider healthy, the grant, the composition and the reader capabilities, the provisions, the served verbs and the bus // state), the network hold and A-428's exceptions end (H-A-55). A put owns its node's want as before (ADR 0546), and the // operator's yes on a module of policy record is the node-engine's have and the asker's (the pass's yeses). @@ -58,6 +58,10 @@ type Module struct { // node-engine, design 47 H §772, H-A-45); a node whose engine does not is written its want held, awaiting its hand placement // (H-A-73). Nil: every node does. ReadsVersion func(node string) bool + // MissingNeeds says what the want of node at fp lacks of its node-engine's words: the reader capabilities the entry at fp + // needs that the node's words in `engine-reads` do not hold, sorted; read false while the entry's needs are not read yet + // (design 47 H2 H-A-682 (2), H-A-698 (2)). Nil: no want needs more than want:version. + MissingNeeds func(node, fp string) (missing []string, read bool) } func (m Module) selfOn(node string) bool { return m.Self != nil && m.Self(node) } @@ -143,6 +147,19 @@ func Wants(m Module, wants map[string]mwc.Want) Outcome { if m.ReadsVersion != nil && !m.ReadsVersion(node) { // A node-engine that cannot read a want by version is placed by hand when its machine is back (design 47 H §772). next.Hold, next.Words, next.Backup, next.Revert = true, mwc.HoldAwaitsHandPlacement, "", "" + } else if m.MissingNeeds != nil { + // A node-engine whose words lack a reader capability the entry needs reads the want no better (ADR 0614 §4): the want is + // held, saying which, or saying the entry is not read yet (design 47 H2 H-A-682 (2), H-A-698 (2)). + missing, read := m.MissingNeeds(node, t.Fp) + switch { + case !read: + next.Hold, next.Words, next.Backup, next.Revert = true, mwc.HoldAwaitsEntryPrefix+t.Fp, "", "" + case len(missing) > 0: + next.Hold, next.Words, next.Backup, next.Revert = true, mwc.HoldAwaitsReadsPrefix+strings.Join(missing, ","), "", "" + } + } + if !next.Hold && holdWords(next.Words) { + next.Words = "" // the hold ended: its words with it } if !had || !mwc.SameWant(normal(before), normal(next)) { out.Wants[node] = next @@ -156,6 +173,11 @@ func Wants(m Module, wants map[string]mwc.Want) Outcome { return out } +// holdWords says whether words are those of a want the assigner holds for what its node-engine does not read. +func holdWords(words string) bool { + return words == mwc.HoldAwaitsHandPlacement || strings.HasPrefix(words, mwc.HoldAwaitsReadsPrefix) || strings.HasPrefix(words, mwc.HoldAwaitsEntryPrefix) +} + // failed says whether a have's health check failed once the node is done moving: phase running or failed (never removed, held, or // moving). func failed(h nodeengine.HaveByNodeModuleValue) bool { diff --git a/modules/mesh-delivery-assigner/internal/assign/wants_test.go b/modules/mesh-delivery-assigner/internal/assign/wants_test.go index 1d77b9027..c8f2542f9 100644 --- a/modules/mesh-delivery-assigner/internal/assign/wants_test.go +++ b/modules/mesh-delivery-assigner/internal/assign/wants_test.go @@ -69,6 +69,34 @@ func TestAWantNamesTheNewestPassedVersion(t *testing.T) { m.ReadsVersion = func(node string) bool { return node == "ace" } return m }, nil, map[string]mwc.Want{"ace": want, "g14": {Fp: fNew, Version: "1.2.3", Pipeline: "main.12", Rank: 2, Hold: true, Words: mwc.HoldAwaitsHandPlacement}}}, + {"A3a (H-A-682 (2)): a node whose words lack a need of the entry is held, awaiting its reads; one whose words hold it is not", func() Module { + m := released() + m.MissingNeeds = func(node, fp string) ([]string, bool) { + if node == "ace" { + return []string{"directory-contents-owner", "approval-mark/1"}, true + } + return nil, true + } + return m + }, nil, map[string]mwc.Want{"ace": {Fp: fNew, Version: "1.2.3", Pipeline: "main.12", Rank: 2, Hold: true, Words: mwc.HoldAwaitsReadsPrefix + "directory-contents-owner,approval-mark/1"}, "g14": want}}, + {"A3a: a node without want:version keeps awaiting its hand placement, whatever its needs", func() Module { + m := released() + m.ReadsVersion = func(node string) bool { return node == "g14" } + m.MissingNeeds = func(string, string) ([]string, bool) { return []string{"directory-contents-owner"}, true } + return m + }, nil, map[string]mwc.Want{"ace": {Fp: fNew, Version: "1.2.3", Pipeline: "main.12", Rank: 2, Hold: true, Words: mwc.HoldAwaitsHandPlacement}, + "g14": {Fp: fNew, Version: "1.2.3", Pipeline: "main.12", Rank: 2, Hold: true, Words: mwc.HoldAwaitsReadsPrefix + "directory-contents-owner"}}}, + {"A3a: the node's next manifest-reads-changed naming the need writes the want with no hold", func() Module { + m := released() + m.MissingNeeds = func(string, string) ([]string, bool) { return nil, true } + return m + }, map[string]mwc.Want{"ace": {Fp: fNew, Version: "1.2.3", Pipeline: "main.12", Rank: 2, Hold: true, Words: mwc.HoldAwaitsReadsPrefix + "directory-contents-owner"}, "g14": want}, + map[string]mwc.Want{"ace": want}}, + {"A3b (H-A-698 (2)): a want whose entry is not read yet is held awaiting its entry", func() Module { + m := released() + m.MissingNeeds = func(node, fp string) ([]string, bool) { return nil, node != "ace" } + return m + }, wantedOld(), map[string]mwc.Want{"ace": {Fp: fNew, Version: "1.2.3", Pipeline: "main.12", Rank: 2, Hold: true, Words: mwc.HoldAwaitsEntryPrefix + fNew}, "g14": want}}, {"a node no longer assigned is removed", func() Module { m := released() m.Nodes = []string{"ace"} From 3bb8413dbd46fa0d320a86bda129cfedde369f76 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:28:22 +0100 Subject: [PATCH 061/141] K3 answered-digest, K4 kits: a publish answered other-bytes with the publish's own fingerprint is the held digest in the step result and both in the log, else refused; the publish kit's rows follow H-A-738, the reproducible kit The shared publish names the ask's own fingerprint on a publish that names none. The kit's Bed gains HoldWith, PublishWith and Held. Builds: design 47 H2 H-A-589 (4), H-A-589 (5), H-A-591, H-A-593 (2) (3), H-A-738 (1) --- .../containerimageregistryclient/client.go | 6 +- .../clients/gopackageregistryclient/client.go | 6 +- .../npmpackageregistryclient/client.go | 6 +- .../ociartifactregistryclient/client.go | 6 +- modules/mesh-delivery-sdk/parts/parts.go | 16 ++++- .../publishconformance/publishconformance.go | 61 ++++++++++++++---- .../publishconformance_test.go | 34 ++++++++++ modules/mesh-delivery-sdk/steprun/answered.go | 62 +++++++++++++++++++ modules/mesh-delivery-sdk/steprun/askrun.go | 15 ++++- .../steprun/conformance/conformance.go | 44 +++++++++++++ .../steprun/conformance/conformance_test.go | 21 +++++++ modules/mesh-delivery-sdk/steprun/publish.go | 6 ++ .../mesh-delivery-sdk/steprun/publish_test.go | 59 ++++++++++++++++++ 13 files changed, 323 insertions(+), 19 deletions(-) create mode 100644 modules/mesh-delivery-sdk/publishconformance/publishconformance_test.go create mode 100644 modules/mesh-delivery-sdk/steprun/answered.go create mode 100644 modules/mesh-delivery-sdk/steprun/publish_test.go diff --git a/modules/mesh-delivery-contracts/go/clients/containerimageregistryclient/client.go b/modules/mesh-delivery-contracts/go/clients/containerimageregistryclient/client.go index 249d10cee..4e3920d42 100644 --- a/modules/mesh-delivery-contracts/go/clients/containerimageregistryclient/client.go +++ b/modules/mesh-delivery-contracts/go/clients/containerimageregistryclient/client.go @@ -44,7 +44,11 @@ func Publish(ctx context.Context, call Call, in seat.PublishInput, ps []parts.Pa if err := json.Unmarshal(raw, &a); err != nil { return parts.Opened{}, fmt.Errorf("%s's answer to publish: %w", seat.Seat, err) } - return parts.Opened{Held: a.Held, Lacks: a.Lacks}, nil + opened := parts.Opened{Held: a.Held, Lacks: a.Lacks} + if a.OtherBytes != nil { + opened.Other = &parts.Other{Digest: a.OtherBytes.Digest, Fingerprint: a.OtherBytes.Fingerprint} + } + return opened, nil } chunk := func(_ context.Context, part string, sequence int, last bool, data []byte) error { raw, err := call("seat:"+seat.Seat+"."+seat.VerbPublishPart, seat.PublishPartInput{Transfer: in.Transfer, Part: part, diff --git a/modules/mesh-delivery-contracts/go/clients/gopackageregistryclient/client.go b/modules/mesh-delivery-contracts/go/clients/gopackageregistryclient/client.go index 4bbda8c80..de0ca7b64 100644 --- a/modules/mesh-delivery-contracts/go/clients/gopackageregistryclient/client.go +++ b/modules/mesh-delivery-contracts/go/clients/gopackageregistryclient/client.go @@ -44,7 +44,11 @@ func Publish(ctx context.Context, call Call, in seat.PublishInput, ps []parts.Pa if err := json.Unmarshal(raw, &a); err != nil { return parts.Opened{}, fmt.Errorf("%s's answer to publish: %w", seat.Seat, err) } - return parts.Opened{Held: a.Held, Lacks: a.Lacks}, nil + opened := parts.Opened{Held: a.Held, Lacks: a.Lacks} + if a.OtherBytes != nil { + opened.Other = &parts.Other{Digest: a.OtherBytes.Digest, Fingerprint: a.OtherBytes.Fingerprint} + } + return opened, nil } chunk := func(_ context.Context, part string, sequence int, last bool, data []byte) error { raw, err := call("seat:"+seat.Seat+"."+seat.VerbPublishPart, seat.PublishPartInput{Transfer: in.Transfer, Part: part, diff --git a/modules/mesh-delivery-contracts/go/clients/npmpackageregistryclient/client.go b/modules/mesh-delivery-contracts/go/clients/npmpackageregistryclient/client.go index c35810ae6..b1a860b67 100644 --- a/modules/mesh-delivery-contracts/go/clients/npmpackageregistryclient/client.go +++ b/modules/mesh-delivery-contracts/go/clients/npmpackageregistryclient/client.go @@ -44,7 +44,11 @@ func Publish(ctx context.Context, call Call, in seat.PublishInput, ps []parts.Pa if err := json.Unmarshal(raw, &a); err != nil { return parts.Opened{}, fmt.Errorf("%s's answer to publish: %w", seat.Seat, err) } - return parts.Opened{Held: a.Held, Lacks: a.Lacks}, nil + opened := parts.Opened{Held: a.Held, Lacks: a.Lacks} + if a.OtherBytes != nil { + opened.Other = &parts.Other{Digest: a.OtherBytes.Digest, Fingerprint: a.OtherBytes.Fingerprint} + } + return opened, nil } chunk := func(_ context.Context, part string, sequence int, last bool, data []byte) error { raw, err := call("seat:"+seat.Seat+"."+seat.VerbPublishPart, seat.PublishPartInput{Transfer: in.Transfer, Part: part, diff --git a/modules/mesh-delivery-contracts/go/clients/ociartifactregistryclient/client.go b/modules/mesh-delivery-contracts/go/clients/ociartifactregistryclient/client.go index 68e1c6a82..b6ca294ba 100644 --- a/modules/mesh-delivery-contracts/go/clients/ociartifactregistryclient/client.go +++ b/modules/mesh-delivery-contracts/go/clients/ociartifactregistryclient/client.go @@ -44,7 +44,11 @@ func Publish(ctx context.Context, call Call, in seat.PublishInput, ps []parts.Pa if err := json.Unmarshal(raw, &a); err != nil { return parts.Opened{}, fmt.Errorf("%s's answer to publish: %w", seat.Seat, err) } - return parts.Opened{Held: a.Held, Lacks: a.Lacks}, nil + opened := parts.Opened{Held: a.Held, Lacks: a.Lacks} + if a.OtherBytes != nil { + opened.Other = &parts.Other{Digest: a.OtherBytes.Digest, Fingerprint: a.OtherBytes.Fingerprint} + } + return opened, nil } chunk := func(_ context.Context, part string, sequence int, last bool, data []byte) error { raw, err := call("seat:"+seat.Seat+"."+seat.VerbPublishPart, seat.PublishPartInput{Transfer: in.Transfer, Part: part, diff --git a/modules/mesh-delivery-sdk/parts/parts.go b/modules/mesh-delivery-sdk/parts/parts.go index e16c46318..7d13964fd 100644 --- a/modules/mesh-delivery-sdk/parts/parts.go +++ b/modules/mesh-delivery-sdk/parts/parts.go @@ -31,6 +31,15 @@ type Part struct { type Opened struct { Held bool Lacks []string + // Other is the receiver's answer that it holds the name and version with another digest: nothing is sent (design 47 H2 + // H-A-729, H-A-738). + Other *Other +} + +// Other is the digest a receiver holds for a name and version it was offered other bytes for, and the fingerprint it keeps +// for them, empty where it keeps none. +type Other struct { + Digest, Fingerprint string } // Open opens (or opens again) the transfer on the receiver, naming every part: the caller's own call. @@ -45,6 +54,8 @@ type Sent struct { Held bool Parts []string Chunks int + // Other is what the receiver held the name and version as, when it answered other bytes: nothing was sent. + Other *Other } // Send opens the transfer and sends the parts the receiver answers it lacks, each in chunks of at most MaxChunk, in @@ -59,7 +70,10 @@ func Send(ctx context.Context, open Open, chunk Chunk, parts []Part) (Sent, erro if err != nil { return Sent{}, err } - sent := Sent{Held: opened.Held} + sent := Sent{Held: opened.Held, Other: opened.Other} + if opened.Other != nil { + return sent, nil + } for _, d := range opened.Lacks { p, ok := byDigest[d] if !ok { diff --git a/modules/mesh-delivery-sdk/publishconformance/publishconformance.go b/modules/mesh-delivery-sdk/publishconformance/publishconformance.go index 336583202..2d535edbc 100644 --- a/modules/mesh-delivery-sdk/publishconformance/publishconformance.go +++ b/modules/mesh-delivery-sdk/publishconformance/publishconformance.go @@ -2,8 +2,9 @@ // one contract cannot each read it their own way (novox/hq design 47 G A-73, A-417, A-490): a publish with a version, a // digest and no parts is the builder's publish again. A holder holding what the digest names under the name says it published // (it moves nothing, or, where the bytes sit in the artifact store, as distribution's A-417 takes them, tags them); a holder -// that holds none of it, or holds the version under another digest, refuses it as not stored, naming the digest, and says it -// refused (A-490, A-490a). The cases live here beside the build modules' conformance kit (design 47 G §680, A-490a). A +// that holds none of it refuses it as not stored, naming the digest, and says it refused (A-490, A-490a); one that holds the +// version under another digest answers other-bytes with that digest and the fingerprint it keeps, no error and nothing +// stored (design 47 H2 H-A-589 (1), H-A-593 (2), H-A-729, H-A-738 (1)). The cases live here beside the build modules' conformance kit (design 47 G §680, A-490a). A // holder's own test runs Run over its own test bed, for every seat it fills. package publishconformance @@ -21,22 +22,38 @@ const ( Other = "sha256:fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210" ) +// OtherBytes is the answer other-bytes: the digest the holder holds for the name and version and the fingerprint it keeps for +// them, empty where it keeps none. +type OtherBytes struct { + Digest, Fingerprint string +} + // Outcome is what a holder did with a publish: whether the transfer ended with it, how many parts it asked for, the event -// it said on its seat (published or refused) with its reason, and the error it answered. +// it said on its seat (published or refused) with its reason, the error it answered and the other-bytes it answered, nil +// when it did not. type Outcome struct { Ended bool Lacks int Event string Reason string Err error + Other *OtherBytes } // Bed is one holder under test, fresh for a case. type Bed struct { // Hold makes the holder hold the digest under Name at Version, as the builder's reservation of Version would find it. Hold func(digest string) - // Publish sends the publish of name at version with the digest and no parts, and reports what the holder did. + // Publish sends the publish of name at version with the digest and no parts, and no fingerprint, and reports what the + // holder did. Publish func(name, version, digest string) Outcome + // HoldWith is Hold, the holder keeping the fingerprint for the version beside the digest. + HoldWith func(digest, fingerprint string) + // PublishWith is Publish naming a fingerprint. + PublishWith func(name, version, digest, fingerprint string) Outcome + // Held is what the holder holds for name at version now, as its verb versions answers it: the digest and the + // fingerprint kept, each empty where none is held. + Held func(name, version string) (digest, fingerprint string) } // Run runs the cases over beds made by fresh. @@ -60,15 +77,37 @@ func Run(t *testing.T, fresh func(t *testing.T) Bed) { t.Errorf("a digest not held answered %+v; want refused said with the digest in its reason, ended, no part lacked", o) } }) - t.Run("a publish with a digest and no parts is refused as not stored, naming the digest, when the holder holds the version under another digest", func(t *testing.T) { + // H-A-593 (2), H-A-738 (1): a version held under another digest is answered other-bytes, never a refusal and never stored. + for _, c := range []struct { + name string + kept, offers string + }{ + {"with the publish's fingerprint", "src2:aa", "src2:aa"}, + {"with another fingerprint", "src2:bb", "src2:aa"}, + {"with no fingerprint kept", "", "src2:aa"}, + {"with no fingerprint named", "src2:aa", ""}, + } { + t.Run("a publish naming the digest of a version the holder holds under another digest "+c.name+" is answered other-bytes, nothing stored", func(t *testing.T) { + b := fresh(t) + b.HoldWith(Other, c.kept) + o := b.PublishWith(Name, Version, Digest, c.offers) + if o.Err != nil || o.Other == nil || o.Other.Digest != Other || o.Other.Fingerprint != c.kept || o.Lacks != 0 { + t.Fatalf("another digest held answered %+v; want no error and other-bytes with %s and the kept fingerprint %q, no part lacked", o, Other, c.kept) + } + if d, f := b.Held(Name, Version); d != Other || f != c.kept { + t.Errorf("the holder holds %s with the fingerprint %q after it, want %s with %q: nothing stored", d, f, Other, c.kept) + } + }) + } + t.Run("a publish of the digest the holder holds is answered as held, with the fingerprint it keeps", func(t *testing.T) { b := fresh(t) - b.Hold(Other) - o := b.Publish(Name, Version, Digest) - if o.Err == nil || !strings.Contains(o.Err.Error(), "not stored") || !strings.Contains(o.Err.Error(), Digest) { - t.Fatalf("another digest held answered %+v; want the error to say not stored and name %s", o, Digest) + b.HoldWith(Digest, "src2:aa") + o := b.PublishWith(Name, Version, Digest, "src2:bb") + if o.Err != nil || o.Other != nil || o.Event != "published" { + t.Fatalf("the held digest answered %+v; want no error, no other-bytes and published", o) } - if o.Event != "refused" || !strings.Contains(o.Reason, "not stored") || !strings.Contains(o.Reason, Digest) || o.Lacks != 0 || !o.Ended { - t.Errorf("another digest held answered %+v; want refused said as not stored with the digest, ended, no part lacked", o) + if d, f := b.Held(Name, Version); d != Digest || f != "src2:aa" { + t.Errorf("versions answers %s with the fingerprint %q, want %s with src2:aa", d, f, Digest) } }) } diff --git a/modules/mesh-delivery-sdk/publishconformance/publishconformance_test.go b/modules/mesh-delivery-sdk/publishconformance/publishconformance_test.go new file mode 100644 index 000000000..cbb9410d5 --- /dev/null +++ b/modules/mesh-delivery-sdk/publishconformance/publishconformance_test.go @@ -0,0 +1,34 @@ +package publishconformance + +import ( + "errors" + "testing" +) + +// holder is a correct holder of a registry seat in memory: what the kit's cases hold it to (design 47 H2 H-A-593 (2), +// H-A-738 (1)). +type holder struct{ digest, fingerprint string } + +func (h *holder) publish(digest, fingerprint string) Outcome { + switch { + case h.digest == digest: + return Outcome{Ended: true, Event: "published"} + case h.digest != "": + return Outcome{Other: &OtherBytes{Digest: h.digest, Fingerprint: h.fingerprint}} + } + reason := "the digest " + digest + " is not stored" + return Outcome{Ended: true, Event: "refused", Reason: reason, Err: errors.New(reason)} +} + +func TestTheKitHoldsACorrectHolder(t *testing.T) { + Run(t, func(t *testing.T) Bed { + h := &holder{} + return Bed{ + Hold: func(d string) { h.digest, h.fingerprint = d, "" }, + Publish: func(_, _, d string) Outcome { return h.publish(d, "") }, + HoldWith: func(d, f string) { h.digest, h.fingerprint = d, f }, + PublishWith: func(_, _, d, f string) Outcome { return h.publish(d, f) }, + Held: func(_, _ string) (string, string) { return h.digest, h.fingerprint }, + } + }) +} diff --git a/modules/mesh-delivery-sdk/steprun/answered.go b/modules/mesh-delivery-sdk/steprun/answered.go new file mode 100644 index 000000000..bd8195897 --- /dev/null +++ b/modules/mesh-delivery-sdk/steprun/answered.go @@ -0,0 +1,62 @@ +package steprun + +import ( + "context" + "fmt" + "sync" +) + +// **A publish answered with the held digest** (design 47 H2 H-A-589 (4), H-A-738 (1)): a registry holds a name and version +// with another digest than the build made and answers `other-bytes` with that digest and the fingerprint it keeps. The +// shared publish compares that fingerprint with the publish's own (the ask's); equal, the publish is answered as published +// with the held digest, nothing stored, and the ask's publish records the digest the seat answered, which the ask's step +// result names for the artifact (ADR 0605 §9: a done key names what its seat answered) while the step log names both +// digests; other or absent, the publish is refused naming both. + +type publishKey struct{} + +// heldPublish is one artifact's publish of an ask: the fingerprint it publishes under, and the digest its seat answered when that +// is not the digest built. +type heldPublish struct { + mu sync.Mutex + fingerprint string + answered string +} + +// withPublish is ctx for the publish of one artifact of an ask whose fingerprint is fingerprint, and the record the ask +// reads the answered digest from. +func withPublish(ctx context.Context, fingerprint string) (context.Context, *heldPublish) { + a := &heldPublish{fingerprint: fingerprint} + return context.WithValue(ctx, publishKey{}, a), a +} + +func publishOf(ctx context.Context) *heldPublish { + a, _ := ctx.Value(publishKey{}).(*heldPublish) + return a +} + +// Answered is the digest the seat answered for the artifact when it held the version as another digest, empty when it +// answered the digest built. +func (a *heldPublish) Answered() string { + if a == nil { + return "" + } + a.mu.Lock() + defer a.mu.Unlock() + return a.answered +} + +// heldAnswer reads a publish answered `other-bytes` of the digest built: the held digest it is published as, or the refusal. +func heldAnswer(ctx context.Context, seat, name, version, built, heldDigest, heldFingerprint, fingerprint string) error { + if fingerprint == "" || heldFingerprint != fingerprint { + return fmt.Errorf("%s holds %s %s as %s with the fingerprint %q, and the publish names %s with the fingerprint %q: a held version offered with other bytes (ADR 0605 §4)", + seat, name, version, heldDigest, heldFingerprint, built, fingerprint) + } + if a := publishOf(ctx); a != nil { + a.mu.Lock() + a.answered = heldDigest + a.mu.Unlock() + } + Phase(ctx, fmt.Sprintf("%s answered %s %s as published with the held digest %s, built %s: the same fingerprint, nothing stored", seat, name, version, heldDigest, built)) + return nil +} diff --git a/modules/mesh-delivery-sdk/steprun/askrun.go b/modules/mesh-delivery-sdk/steprun/askrun.go index 90d3a6aa4..4c6ed0e00 100644 --- a/modules/mesh-delivery-sdk/steprun/askrun.go +++ b/modules/mesh-delivery-sdk/steprun/askrun.go @@ -254,8 +254,9 @@ func (s AskSteps) build(ctx context.Context, job sdkstep.BuildJob, version strin } } var ( - out any - err error + out any + err error + published *heldPublish ) if a.From != "" { if s.Copy == nil { @@ -285,7 +286,9 @@ func (s AskSteps) build(ctx context.Context, job sdkstep.BuildJob, version strin args["version"] = version } Phase(ctx, "build "+a.Artifact) - out, err = s.Build(ctx, args) + var buildCtx context.Context + buildCtx, published = withPublish(ctx, job.Fp) + out, err = s.Build(buildCtx, args) } if err != nil { // The compare's out-of-step is answered with the failure, so the build's end still names it. @@ -306,6 +309,12 @@ func (s AskSteps) build(ctx context.Context, job sdkstep.BuildJob, version strin if err := json.Unmarshal(r, &built); err != nil || built.Digest == "" { return nil, fmt.Errorf("the build of %s answered no digest: %s", a.Artifact, r) } + // A version its seat held as another digest with the same fingerprint is the held digest, which the done key names + // (H-A-589 (4), H-A-738 (1)). + if held := published.Answered(); held != "" { + Phase(ctx, fmt.Sprintf("%s: built %s, answered %s: the step result names %s", a.Artifact, built.Digest, held, held)) + built.Digest = held + } answer.Artifacts = append(answer.Artifacts, sdkstep.AskBuilt{Artifact: a.Artifact, Digest: built.Digest, Reference: built.Reference}) if built.Kept != "" { answer.Kept = strings.TrimPrefix(built.Kept, "sha256:") diff --git a/modules/mesh-delivery-sdk/steprun/conformance/conformance.go b/modules/mesh-delivery-sdk/steprun/conformance/conformance.go index 17f9d6110..7ac90b532 100644 --- a/modules/mesh-delivery-sdk/steprun/conformance/conformance.go +++ b/modules/mesh-delivery-sdk/steprun/conformance/conformance.go @@ -15,9 +15,13 @@ import ( "errors" "fmt" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/steprun" + "io/fs" + "os" + "path/filepath" "slices" "strings" "testing" + "time" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" ) @@ -324,3 +328,43 @@ func runsCounted(puller func(read func(key string) (json.RawMessage, error)) *st } return nil } + +// Reproducible holds a build module to giving one digest per artifact from two folders (design 47 H2 H-A-591, H-A-593 (3)): +// fill writes the module's files into a folder, build builds its artifacts there and answers each one's digest by name. The +// two folders have different names and the second one's files other times, so a digest that moved with a path or a time +// fails. A catalogue check (failurekit) refuses a build module whose tests do not call it. +func Reproducible(t *testing.T, fill func(dir string) error, build func(dir string) (map[string]string, error)) { + t.Helper() + var digests [2]map[string]string + for i, name := range []string{"first-folder", "a-second-folder-elsewhere"} { + dir := filepath.Join(t.TempDir(), name) + if err := os.MkdirAll(dir, 0o755); err != nil { + t.Fatal(err) + } + if err := fill(dir); err != nil { + t.Fatalf("the module's files are not written into %s: %v", dir, err) + } + if i == 1 { + later := time.Now().Add(-24 * time.Hour) + _ = filepath.WalkDir(dir, func(p string, _ fs.DirEntry, err error) error { + if err == nil { + _ = os.Chtimes(p, later, later) + } + return nil + }) + } + out, err := build(dir) + if err != nil { + t.Fatalf("the build in %s: %v", dir, err) + } + digests[i] = out + } + if len(digests[0]) == 0 { + t.Error("the build gave no artifact, so none is held to one digest") + } + for artifact, first := range digests[0] { + if second, ok := digests[1][artifact]; !ok || second != first { + t.Errorf("the artifact %s has the digest %s built in one folder and %q in another: its bytes depend on where or when it was built", artifact, first, second) + } + } +} diff --git a/modules/mesh-delivery-sdk/steprun/conformance/conformance_test.go b/modules/mesh-delivery-sdk/steprun/conformance/conformance_test.go index d2c4c76a5..9f6253b92 100644 --- a/modules/mesh-delivery-sdk/steprun/conformance/conformance_test.go +++ b/modules/mesh-delivery-sdk/steprun/conformance/conformance_test.go @@ -4,6 +4,8 @@ import ( "context" "encoding/json" "errors" + "os" + "path/filepath" "slices" "strings" "testing" @@ -301,3 +303,22 @@ func TestRunsCountedRefusesAPullerThatDoesNotReadTheStepsState(t *testing.T) { } } } + +// H-A-593 (3): the shared pack gives one digest from two folders; one that writes a folder's name into its bytes does not. +func TestTheSharedPackIsReproducible(t *testing.T) { + fill := func(dir string) error { + if err := os.MkdirAll(filepath.Join(dir, "src"), 0o755); err != nil { + return err + } + for name, body := range map[string]string{"b.txt": "b", "src/a.txt": "a", "a.txt": "a"} { + if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0o644); err != nil { + return err + } + } + return nil + } + Reproducible(t, fill, func(dir string) (map[string]string, error) { + _, digest, err := steprun.Pack(dir) + return map[string]string{"archive": digest}, err + }) +} diff --git a/modules/mesh-delivery-sdk/steprun/publish.go b/modules/mesh-delivery-sdk/steprun/publish.go index a5141188a..7d4617135 100644 --- a/modules/mesh-delivery-sdk/steprun/publish.go +++ b/modules/mesh-delivery-sdk/steprun/publish.go @@ -78,7 +78,13 @@ func SentHow(n int) func(parts.Sent) string { // PublishParts publishes in with ps as its parts on seat, through that seat's client: in's fields are the seat's own // (the four registry seats share the publish verb's input, design 51), the parts are written by the client. func PublishParts(ctx context.Context, call SeatCall, seat string, in reg.PublishInput, ps []parts.Part) (parts.Sent, error) { + if a := publishOf(ctx); a != nil && in.Fingerprint == "" { + in.Fingerprint = a.fingerprint // the ask's own: the holder keeps it for the version (H-A-589 (2)) + } sent, err := publishParts(ctx, call, seat, in, ps) + if err == nil && sent.Other != nil { + err = heldAnswer(ctx, seat, in.Name, in.Version, in.Digest, sent.Other.Digest, sent.Other.Fingerprint, in.Fingerprint) + } return sent, PublishFault(err) } diff --git a/modules/mesh-delivery-sdk/steprun/publish_test.go b/modules/mesh-delivery-sdk/steprun/publish_test.go new file mode 100644 index 000000000..a18424c17 --- /dev/null +++ b/modules/mesh-delivery-sdk/steprun/publish_test.go @@ -0,0 +1,59 @@ +package steprun + +import ( + "context" + "encoding/json" + "fmt" + "strings" + "testing" + + reg "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/containerimageregistry" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/parts" +) + +// Design 47 H2 H-A-589 (4), H-A-738 (1): a publish answered other-bytes carrying the publish's own fingerprint is answered +// as published with the held digest: the ask's record names it, the step log names both digests, and nothing is sent; with +// another or no fingerprint it is refused naming both. +func TestAPublishOfAHeldVersionIsAnsweredWithTheHeldDigest(t *testing.T) { + const built, held = "sha256:aaaa", "sha256:bbbb" + for _, c := range []struct { + name, kept, ask string + answered string + refused bool + }{ + {"the same fingerprint", "src2:f1", "src2:f1", held, false}, + {"another fingerprint", "src2:f2", "src2:f1", "", true}, + {"no kept fingerprint", "", "src2:f1", "", true}, + {"no fingerprint of its own", "src2:f1", "", "", true}, + } { + t.Run(c.name, func(t *testing.T) { + var log []string + ctx := context.WithValue(context.Background(), phaseKey{}, &phases{logf: func(f string, a ...any) { log = append(log, fmt.Sprintf(f, a...)) }}) + ctx, record := withPublish(ctx, c.ask) + calls := 0 + call := func(key string, in any) (json.RawMessage, error) { + calls++ + raw, _ := json.Marshal(in) + if want := c.ask; want != "" && !strings.Contains(string(raw), want) && strings.HasSuffix(key, ".publish") { + t.Errorf("the publish %s names no fingerprint %s of the ask", raw, want) + } + other := map[string]any{"digest": held} + if c.kept != "" { + other["fingerprint"] = c.kept + } + return json.Marshal(map[string]any{"other-bytes": other}) + } + in := reg.PublishInput{Name: "x/y", Kind: reg.PublishInputKindArchive, Version: "0.1.0", Digest: built, Transfer: "t"} + sent, err := PublishParts(ctx, call, GoSeat, in, []parts.Part{{Digest: built, Size: 1, Open: nil}}) + if (err != nil) != c.refused || record.Answered() != c.answered || calls != 1 || sent.Other == nil { + t.Fatalf("answered %q, err %v after %d calls (other %+v), want answered %q and refused %v with the one publish call", record.Answered(), err, calls, sent.Other, c.answered, c.refused) + } + if c.refused && !(strings.Contains(err.Error(), built) && strings.Contains(err.Error(), held)) { + t.Errorf("the refusal %v does not name both digests", err) + } + if !c.refused && !(strings.Contains(strings.Join(log, "\n"), built) && strings.Contains(strings.Join(log, "\n"), held)) { + t.Errorf("the step log %q does not name both digests", log) + } + }) + } +} From b24dd11ff4ded17797b6b3c8624bf5462d25efae Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:31:09 +0100 Subject: [PATCH 062/141] A6 reads-share-a-deadline: every read of a run is a kept call stopping at the run's first read plus reads-bound; callRetry, transient and the fixed bounds go Builds: design 47 H2 H-A-708 (3) --- .../compositionreads.go | 153 +++++++++++------- .../mesh-delivery-assigner/compositionrun.go | 22 +-- .../compositionrun_test.go | 123 +++++++++----- .../cmd/mesh-delivery-assigner/main.go | 25 ++- .../cmd/mesh-delivery-assigner/pass_test.go | 3 + .../cmd/mesh-delivery-assigner/puts.go | 2 + .../mesh-delivery-assigner/validatestep.go | 11 +- .../validatestep_test.go | 4 +- .../mesh-delivery-assigner/manifest_test.go | 3 +- modules/mesh-delivery-assigner/module.json | 17 ++ 10 files changed, 248 insertions(+), 115 deletions(-) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionreads.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionreads.go index c4b20b41e..81291b45a 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionreads.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionreads.go @@ -10,23 +10,59 @@ import ( mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-sdk/go/buscalls" + "git.novox.be/novox/mesh-sdk/go/process" ) // The reads of a composition step (design 47 G §354, A-252, A-261): the entries of one catalog revision are read once and shared by -// every composition step of that revision, since an entry is content-addressed and a revision never changes; a read that times out -// or fails in transport is made again with a growing wait for a bounded time, said in the journal, and only then ends the step as -// could not run. +// every composition step of that revision, since an entry is content-addressed and a revision never changes. Every read of the +// seats mesh-catalog and mesh-builds is a kept call (§775), paced by the form, and all of one run's reads stop at one deadline: its +// first read's time plus the setting reads-bound (design 47 H2 H-A-708 (3)); past it the run ends could not run with every call's +// time and words. const ( - // readsBound is how long a read is made again before the step could not run. - readsBound = 3 * time.Minute - // readsFirstWait and readsMaxWait bound the wait between two tries. - readsFirstWait = time.Second - readsMaxWait = 15 * time.Second + // defaultReadsBound is the setting reads-bound's default, 8 minutes: it spans the six minutes a seat went unanswered on + // 2026-11-23 and stays below the runner's ask-unanswered-bound (10 minutes, counted from the pull), so the step ends with the + // assigner's words. + defaultReadsBound = 8 * time.Minute // readsKept is how many catalog revisions' halves are kept; the oldest read goes first. readsKept = 8 ) +// readsBoundSetting is the setting reads-bound, in minutes, read at the start from the file the manifest declares with the content +// ${config:reads-bound}; its default for a file missing or empty. +func readsBoundSetting(getenv func(string) string) (time.Duration, error) { + minutes, err := settingFile(getenv("MESH_ASSIGNER_READS_BOUND_FILE")) + if err != nil || minutes == 0 { + return defaultReadsBound, err + } + return time.Duration(minutes) * time.Minute, nil +} + +// readsClock is the deadline of one run's reads: it begins at the run's first read. +type readsClock struct { + mu sync.Mutex + first time.Time + last string +} + +type readsClockKey struct{} + +// withReadsClock gives ctx the clock of one run's reads; a ctx that has one keeps it. +func withReadsClock(ctx context.Context) context.Context { + if ctx.Value(readsClockKey{}) != nil { + return ctx + } + return context.WithValue(ctx, readsClockKey{}, &readsClock{}) +} + +// readsClockOf is the clock of the run ctx belongs to, or a clock of its own for a read made outside a run. +func readsClockOf(ctx context.Context) *readsClock { + if c, ok := ctx.Value(readsClockKey{}).(*readsClock); ok { + return c + } + return &readsClock{} +} + // readKey names one revision of one watched branch. type readKey struct { branch string @@ -48,65 +84,68 @@ type compositionReads struct { seats map[string]json.RawMessage // by seat and digest: the definition, raw } -// transient says whether a read's fault is of the transport or a timeout, so that it is worth reading again. -func transient(err error, said string) bool { - text := said +// callRead calls the seat verb key as a kept call that stops at the run's deadline (design 47 H2 H-A-708 (3)); it answers the body +// of a good answer, or the holder's own words of an answer that is none, or the fault naming the holder, its machine and every +// call of the form. +func (r *compositionRun) callRead(ctx context.Context, key string, body any) (json.RawMessage, string, error) { + if err := ctx.Err(); err != nil { + return nil, "", err + } + clock := readsClockOf(ctx) + left, bound, first := r.readsLeft(clock) + if left <= 0 { + clock.mu.Lock() + last := clock.last + clock.mu.Unlock() + return nil, "", fmt.Errorf("%s is not read: the run's reads passed their deadline of %s (the setting reads-bound) counted from its first read at %s%s", + key, bound, first.UTC().Format(time.RFC3339), last) + } + raw, err := r.call(process.KeptAsk{Bound: left}, key, body) if err != nil { - text = err.Error() + " " + said + words := fmt.Errorf("%s%s: %w", key, r.holderWords(key), err) + clock.mu.Lock() + clock.last = "; the last read said: " + words.Error() + clock.mu.Unlock() + return nil, "", words } - text = strings.ToLower(text) - for _, w := range []string{"deadline exceeded", "timeout", "timed out", "no responders", "connection", "i/o", "eof", "broken pipe", "unavailable"} { - if strings.Contains(text, w) { - return true - } + inner, said, ok := buscalls.Unwrap(raw) + if ok { + return inner, "", nil } - return false + return nil, said, nil } -// callRetry calls the seat verb key, again with a growing wait while its fault is transient, for readsBound; it answers the body of -// a good answer, or the last fault. -func (r *compositionRun) callRetry(ctx context.Context, key string, body any) (json.RawMessage, string, error) { - start := r.now() - wait := readsFirstWait - for try := 1; ; try++ { - raw, err := r.call(key, body) - var inner json.RawMessage - var said string - if err == nil { - var ok bool - if inner, said, ok = buscalls.Unwrap(raw); ok { - return inner, "", nil - } - } - if !transient(err, said) { - return nil, said, err - } - if r.now().Sub(start)+wait > readsBound { - return nil, said, err - } - r.logf("composition step: %s is not read (try %d, %v %s), read again in %s", key, try, err, said, wait) - if serr := r.waitFor(ctx, wait); serr != nil { - return nil, said, serr - } - if wait *= 2; wait > readsMaxWait { - wait = readsMaxWait - } +// readsLeft is what stays of the run's reads' deadline, with the deadline's length and its first read's time; the first read +// begins it. +func (r *compositionRun) readsLeft(clock *readsClock) (left, bound time.Duration, first time.Time) { + bound = r.readsBound + if bound <= 0 { + bound = defaultReadsBound } + now := r.now() + clock.mu.Lock() + defer clock.mu.Unlock() + if clock.first.IsZero() { + clock.first = now + } + return bound - now.Sub(clock.first), bound, clock.first } -// waitFor waits d, or until ctx ends. -func (r *compositionRun) waitFor(ctx context.Context, d time.Duration) error { - if r.sleep != nil { - return r.sleep(ctx, d) +// holderWords name the module that holds the seat of key and the machines it runs on, as the seat list names them (design 47 H2 +// H-A-708 (3)); nothing where they are not read. +func (r *compositionRun) holderWords(key string) string { + seat, _, _ := strings.Cut(strings.TrimPrefix(key, "seat:"), ".") + if r.holder == nil || seat == "" { + return "" } - t := time.NewTimer(d) - defer t.Stop() - select { - case <-ctx.Done(): - return ctx.Err() - case <-t.C: - return nil + module, nodes := r.holder(seat) + if module == "" { + return "" } + if len(nodes) == 0 { + return " (its holder " + module + ")" + } + return " (its holder " + module + " on " + strings.Join(nodes, ", ") + ")" } // half is the revision's half, read once for every step of it: a step that finds it being read waits for that read, and a read that diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go index f81b50b8f..05f9b20e9 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go @@ -58,8 +58,12 @@ type compositionRun struct { runs *compositionRuns inputs *compositionInputs keeper *inputKeeper - // call asks a seat verb held once for the mesh (process.Conn.CallKept). - call func(key string, body any) (json.RawMessage, error) + // call asks a seat verb held once for the mesh as a kept call that stops at the ask's bound (process.Conn.CallKeptAsk). + call func(ask process.KeptAsk, key string, body any) (json.RawMessage, error) + // readsBound is the setting reads-bound: the run's reads stop at its first read's time plus it (H-A-708 (3)); zero: its default. + readsBound time.Duration + // holder is the module holding a seat and the machines it runs on, for the words of a read that met a fault; nil: none named. + holder func(seat string) (module string, nodes []string) // callFile asks a seat verb held once for the mesh whose answer comes in chunks, as a kept call (process.Conn.CallFileKept), // answering the verb's answer with the bytes received as its member `file`, base64: the validate step's seat-list (H-A-443). callFile func(ask process.KeptAsk, key string, body any) (json.RawMessage, error) @@ -87,9 +91,8 @@ type compositionRun struct { // own is the assigner's own context: a run's start, and its wait for a package's publish, run on it as the take-up's do, never // on the starting step's, which a supersede or a drop ends while other steps share the run (design 47 H2 H-A-630 (3)). own context.Context - // reads shares the catalog reads among steps (compositionreads.go); sleep waits between two tries of a read (nil: a timer). + // reads shares the catalog reads among steps (compositionreads.go). reads *compositionReads - sleep func(ctx context.Context, d time.Duration) error // ask asks a seat verb on one node, for the run's answer kept as the build seat's object (buildstep.StepEnded.ReadOutput). ask buildstep.AskVerb now func() time.Time @@ -258,6 +261,7 @@ func (p *runPrep) get(ctx context.Context) error { // start composes the machine of the run the step asked under stepAsk started (§718): the node's input of this moment, its request kept once in `inputs`, // the composer program chosen and recorded with the request's digest, and one run ask put. A fault ends the run could not run. func (r *compositionRun) start(ctx context.Context, key string, run meshwants.CompositionRun, prep *runPrep, stepAsk string) { + ctx = withReadsClock(ctx) // all the run's reads stop at one deadline (design 47 H2 H-A-708 (3)) node, ask := run.Machine, run.Ask end := func(said string) { if _, err := r.runs.endRun(key, ask, meshwants.CompositionRunOutcomeCouldNotRun, said, nil); err != nil { @@ -477,7 +481,7 @@ func (r *compositionRun) readRevision(ctx context.Context, run meshwants.StepRun half := mcc.Half{Entries: map[string]meshcatalog.CatalogEntry{}} in := meshcatalog.RevisionInput{Branch: keys.EscapeName(run.Branch), Revision: run.Revision} for { - body, said, err := r.callRetry(ctx, mcc.RevisionVerb, in) + body, said, err := r.callRead(ctx, mcc.RevisionVerb, in) if err != nil { return mcc.Half{}, err } @@ -526,7 +530,7 @@ func (r *compositionRun) seats(ctx context.Context, defs []meshcatalog.CatalogRe // trunkSeats are the definitions of every seat of the trunk's seat list (seat-definitions with no seat names them with their digests). func (r *compositionRun) trunkSeats(ctx context.Context) ([]json.RawMessage, error) { what := "the trunk's seat list is not read" - body, said, err := r.callRetry(ctx, seatDefinitionsKey, meshcatalog.SeatDefinitionsInput{}) + body, said, err := r.callRead(ctx, seatDefinitionsKey, meshcatalog.SeatDefinitionsInput{}) if err != nil || body == nil { return nil, unreadErr(what, err, said) } @@ -554,7 +558,7 @@ func (r *compositionRun) seatAt(ctx context.Context, seat, digest string) (json. return def, nil } what := "the definition of the seat " + seat + " is not read" - body, said, err := r.callRetry(ctx, seatDefinitionsKey, meshcatalog.SeatDefinitionsInput{Seat: seat}) + body, said, err := r.callRead(ctx, seatDefinitionsKey, meshcatalog.SeatDefinitionsInput{Seat: seat}) if err != nil || body == nil { return nil, unreadErr(what, err, said) } @@ -998,7 +1002,7 @@ func (r *compositionRun) takeUpWaits(ctx context.Context) { // publishedOf asks the seat mesh-builds' verb published whether by's build is published, answering the pin it is published at // (vMAJOR.MINOR.PATCH, spec S9) when it is. func (r *compositionRun) publishedOf(ctx context.Context, by packagePublisher) (string, bool, error) { - body, said, err := r.callRetry(ctx, publishedVerbKey, builds.PublishedInput{Module: by.module, Artifact: by.artifact, Fingerprint: by.fingerprint}) + body, said, err := r.callRead(ctx, publishedVerbKey, builds.PublishedInput{Module: by.module, Artifact: by.artifact, Fingerprint: by.fingerprint}) if err != nil || body == nil { return "", false, unreadErr(builds.VerbPublished+" did not answer", err, said) } @@ -1052,7 +1056,7 @@ func (r *compositionRun) programs(ctx context.Context, half mcc.Half) (func(node return b.program, fp, b.pins, nil } what := "the entry of the node-engine's build " + fp + " is not read" - body, said, err := r.callRetry(ctx, entryVerbKey, meshcatalog.EntryInput{Fingerprint: fp}) + body, said, err := r.callRead(ctx, entryVerbKey, meshcatalog.EntryInput{Fingerprint: fp}) if err != nil || body == nil { return buildstep.RunProgram{}, fp, nil, unreadErr(what, err, said) } diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go index 6d4c08a76..cfd090f49 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "git.novox.be/novox/mesh-sdk/go/busretry" "git.novox.be/novox/mesh-sdk/go/process" "github.com/nats-io/nats.go/jetstream" "maps" @@ -201,7 +202,7 @@ func newRunStand(t *testing.T, revisionEngine, trunkEngine, seatDigest string) * s.runs = newCompositionRuns(newRunsMem(), defaultRunSettings, time.Now, t.Logf) s.r = &compositionRun{runs: s.runs, inputs: &compositionInputs{machines: func(string, string) []string { return []string{"ace", "g14", "shanks"} }, callFile: engines, bound: time.Second}, - keeper: keeper, reads: &compositionReads{}, call: call, away: away, own: context.Background(), now: time.Now, logf: t.Logf, + keeper: keeper, reads: &compositionReads{}, call: asKept(call), away: away, own: context.Background(), now: time.Now, logf: t.Logf, trunk: func() (mcc.Half, bool) { return mcc.Half{Entries: map[string]meshcatalog.CatalogEntry{"engine": engine(trunkEngine, commitE1)}}, true }, @@ -663,51 +664,40 @@ func TestTheCompositionStepRunsOneAskPerMachine(t *testing.T) { } } -// Design 47 G §354, A-252: the entries of one catalog revision are read once for every step of it, and a read that times out is -// made again with a growing wait for a bounded time, said in the journal, before the step could not run. -func TestTheCompositionStepReadsTheRevisionOnceAndAgainOnATimeout(t *testing.T) { +// asKept is a fake seat call as the kept call the run makes: the bound and the hook are the call's own, a fake answers at once. +func asKept(call func(key string, body any) (json.RawMessage, error)) func(process.KeptAsk, string, any) (json.RawMessage, error) { + return func(_ process.KeptAsk, key string, body any) (json.RawMessage, error) { return call(key, body) } +} + +// Design 47 G §354, A-252: the entries of one catalog revision are read once for every step of it, and a fault of the holder's own +// answer is not read again. +func TestTheCompositionStepReadsTheRevisionOnce(t *testing.T) { step := meshwants.StepRun{Module: "m", Branch: "main", Revision: 7, Step: meshwants.StepRunStepComposition} for _, tc := range []struct { name string - faults int // consecutive faults of the `revision` read before it answers - fault error // the fault + fault error // the fault of the `revision` read, none: it answers steps int want string // the outcome of the last step revisionCalls int - waits int }{ - {"two steps of one revision read it once", 0, nil, 2, meshwants.StepEndedOutcomeFailed, 2, 0}, - {"a timeout is read again", 3, errors.New("context deadline exceeded"), 1, meshwants.StepEndedOutcomeFailed, 5, 3}, - {"a fault that stays ends could not run", 1000, errors.New("nats: timeout"), 1, meshwants.StepEndedOutcomeCouldNotRun, -1, -1}, - {"a fault of the answer is not read again", 1, errors.New("no such revision"), 1, meshwants.StepEndedOutcomeCouldNotRun, 1, 0}, + {"two steps of one revision read it once", nil, 2, meshwants.StepEndedOutcomeFailed, 2}, + {"a fault of the answer is not read again", errors.New("no such revision"), 1, meshwants.StepEndedOutcomeCouldNotRun, 1}, } { t.Run(tc.name, func(t *testing.T) { s := newRunStand(t, "src2:e1", "src2:e1", "d1") inner := s.r.call var mu sync.Mutex - calls, faults := 0, tc.faults - s.r.call = func(key string, body any) (json.RawMessage, error) { + calls := 0 + s.r.call = func(ask process.KeptAsk, key string, body any) (json.RawMessage, error) { if key == mcc.RevisionVerb { mu.Lock() calls++ - f := faults > 0 - faults-- mu.Unlock() - if f { + if tc.fault != nil { return nil, tc.fault } } - return inner(key, body) - } - clock := time.Unix(1000, 0) - var waits []time.Duration - s.r.now = func() time.Time { mu.Lock(); defer mu.Unlock(); return clock } - s.r.sleep = func(_ context.Context, d time.Duration) error { - mu.Lock() - defer mu.Unlock() - waits = append(waits, d) - clock = clock.Add(d) - return nil + return inner(ask, key, body) } var wg sync.WaitGroup outs := make([]stepOutcome, tc.steps) @@ -721,24 +711,73 @@ func TestTheCompositionStepReadsTheRevisionOnceAndAgainOnATimeout(t *testing.T) t.Fatalf("a step came to %+v, want %s", o, tc.want) } } - if tc.waits == -1 { // never answers: bounded, growing waits - if len(waits) < 3 || waits[0] != readsFirstWait || waits[1] != 2*readsFirstWait || waits[len(waits)-1] != readsMaxWait { - t.Errorf("the waits %v do not grow to %s", waits, readsMaxWait) - } - var total time.Duration - for _, w := range waits { - total += w - } - if total > readsBound { - t.Errorf("read again for %s, bound %s", total, readsBound) - } - if !strings.Contains(outs[0].Said, "catalog revision is not read") || !strings.Contains(outs[0].Said, "timeout") { - t.Errorf("the step said %q", outs[0].Said) + if calls != tc.revisionCalls { + t.Errorf("`revision` asked %d times, want %d", calls, tc.revisionCalls) + } + }) + } +} + +// Design 47 H2 H-A-708 (3), AC-A6: every read of a run is a kept call that stops at one deadline, the run's first read's time plus +// reads-bound (default 8 minutes): two reads each unanswered in turn end the run could not run with the assigner's words before +// the runner's bound of 10 minutes, naming the holder and its machine, the last fault and the calls; a read answered after a +// fault of two minutes composes. +func TestARunsReadsShareOneDeadline(t *testing.T) { + step := meshwants.StepRun{Module: "m", Branch: "main", Revision: 7, Step: meshwants.StepRunStepComposition} + away := &busretry.Away{Part: "the trunk's revision 512", Words: "not read yet since 23:35:40"} + for _, tc := range []struct { + name string + answer func(clock *time.Time, ask process.KeptAsk, key string) error // a fault of the read, none: it answers + want string + bounds []time.Duration // the bound each kept call was given, in order + }{ + {"seat-definitions met by no responders for two minutes and then answered composes", func(clock *time.Time, ask process.KeptAsk, key string) error { + if key == seatDefinitionsKey && clock.Before(time.Unix(1000, 0).Add(2*time.Minute)) { + *clock = clock.Add(2 * time.Minute) // the form met no responders for two minutes, then the holder answered + } + return nil + }, meshwants.StepEndedOutcomeFailed, nil}, + {"two reads each unanswered in turn end the run at the shared deadline", func(clock *time.Time, ask process.KeptAsk, key string) error { + if key == mcc.RevisionVerb || key == seatDefinitionsKey { + *clock = clock.Add(ask.Bound) // the form asks again until the bound it is given + return &busretry.Unanswered{Seat: "mesh-catalog", Verb: "x", Bound: ask.Bound, Tries: []busretry.Try{{At: *clock, Words: away.Error()}}, Last: away} + } + return nil + }, meshwants.StepEndedOutcomeCouldNotRun, []time.Duration{8 * time.Minute}}, + } { + t.Run(tc.name, func(t *testing.T) { + s := newRunStand(t, "src2:e1", "src2:e1", "d1") + inner := s.r.call + clock := time.Unix(1000, 0) + var mu sync.Mutex + var bounds []time.Duration + s.r.now = func() time.Time { mu.Lock(); defer mu.Unlock(); return clock } + s.r.holder = func(seat string) (string, []string) { return "mesh-delivery-indexer", []string{"novox"} } + s.r.call = func(ask process.KeptAsk, key string, body any) (json.RawMessage, error) { + mu.Lock() + bounds = append(bounds, ask.Bound) + err := tc.answer(&clock, ask, key) + mu.Unlock() + if err != nil { + return nil, err } + return inner(ask, key, body) + } + out := s.r.run(context.Background(), "ask-step", step) + if out.Outcome != tc.want { + t.Fatalf("the step came to %+v, want %s", out, tc.want) + } + if tc.bounds == nil { return } - if calls != tc.revisionCalls || len(waits) != tc.waits { - t.Errorf("`revision` asked %d times with %d waits, want %d and %d", calls, len(waits), tc.revisionCalls, tc.waits) + total := clock.Sub(time.Unix(1000, 0)) + if total > 9*time.Minute || bounds[0] != 8*time.Minute { + t.Errorf("the reads took %s with bounds %v, want the first at 8m and all before the runner's 10m", total, bounds) + } + for _, w := range []string{"mesh-delivery-indexer on novox", "not read yet since 23:35:40", "mesh-catalog"} { + if !strings.Contains(out.Said, w) { + t.Errorf("the step said %q, which does not name %q", out.Said, w) + } } }) } diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go index afcd59c68..badc8e979 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go @@ -690,7 +690,11 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber, if err != nil { return err } - run := &compositionRun{runs: runs, inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFileKept, bound: askBound}, keeper: inputs, reads: &compositionReads{}, call: bus.CallKept, callFile: bus.CallFileKept, + readsBound, err := readsBoundSetting(getenv) + if err != nil { + return err + } + run := &compositionRun{runs: runs, inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFileKept, bound: askBound}, keeper: inputs, reads: &compositionReads{}, call: bus.CallKeptAsk, callFile: bus.CallFileKept, readsBound: readsBound, holder: holderOf(bus, w), trunk: trunkOf(iv, w.trunkName), newest: iv.newestOf(), watched: iv.watchedOf, assigned: w.assignedOn, assignment: w.assignmentOf, findings: findings, running: w.runningOf, away: func(machine string) bool { return w.awayNow()[machine] }, put: runAskPublisher(js), own: ctx, ask: bus.CallFile, now: time.Now, logf: logger.Printf} // The seat's work queue (design 47 H2 §777): pulled through its one worker, each ask taken once in the state taken. takenBound, err := askTakenBound() @@ -862,6 +866,25 @@ func hearReadsChanged(ctx context.Context, js jetstream.JetStream, hub *process. }() } +// holderOf names the module holding a seat, asked of the seat that places modules (seatlist.HolderOf), and the machines whose +// assignments place it, for the words of a read that met a fault (design 47 H2 H-A-708 (3)). +func holderOf(bus caller, w *world) func(seat string) (string, []string) { + return func(seat string) (string, []string) { + module, err := seatlist.HolderOf(bus.Call, seat) + if err != nil { + return "", nil + } + var nodes []string + for node, modules := range w.assigned() { + if slices.Contains(modules, module) { + nodes = append(nodes, node) + } + } + slices.Sort(nodes) + return module, nodes + } +} + // entriesOf are the catalog entries the passer asks by fingerprint: the followed branches' own, so each catalog-revision asks // again an entry whose ask failed to reach the holder, at most asks times (the setting entry-asks, 0 its default), and the // assigner's finding writer writes entry-not-found and entry-unanswered of them (design 47 H, H-A-60). Each change wakes a pass. diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go index 6af9f772b..82d216205 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass_test.go @@ -318,6 +318,9 @@ func (b *fakeBus) CallOn(node, key string, body any) (json.RawMessage, error) { return b.Call(node+"/"+key, body) } func (b *fakeBus) CallKept(key string, body any) (json.RawMessage, error) { return b.Call(key, body) } +func (b *fakeBus) CallKeptAsk(_ process.KeptAsk, key string, body any) (json.RawMessage, error) { + return b.Call(key, body) +} func (b *fakeBus) CallFile(key string, body any) (json.RawMessage, error) { return b.Call(key, body) } func (b *fakeBus) CallFileKept(_ process.KeptAsk, key string, body any) (json.RawMessage, error) { return b.Call(key, body) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/puts.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/puts.go index 9bcb29407..d544fc3d0 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/puts.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/puts.go @@ -43,6 +43,8 @@ type caller interface { CallOn(node, key string, body any) (json.RawMessage, error) // CallKept is Call for a kept call, safe to call again (process.Conn.CallKept; ADR 0668). CallKept(key string, body any) (json.RawMessage, error) + // CallKeptAsk is CallKept stopping at its caller's bound and carrying the ask's id and hook (process.Conn.CallKeptAsk; H2 §775). + CallKeptAsk(ask process.KeptAsk, key string, body any) (json.RawMessage, error) // CallFile is Call of a verb marked chunks, its answer read whole (process.Conn.CallFile; design 47 G A-291). CallFile(key string, body any) (json.RawMessage, error) // CallFileKept is CallFile as a kept call carrying its ask's id, until its bound (process.Conn.CallFileKept; H2 §775). diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go index 95166e21a..a35719078 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go @@ -250,6 +250,7 @@ func manifestsOf(half mcc.Half) (map[string]composer.Manifest, error) { // is kept once in `inputs`, its program and input recorded on the run, and one run ask put on the Go build seat. A fault ends // the run could not run. func (r *compositionRun) startValidate(ctx context.Context, key string, run meshwants.CompositionRun, step meshwants.StepRun) { + ctx = withReadsClock(ctx) // all the run's reads stop at one deadline (design 47 H2 H-A-708 (3)) ask := run.Ask end := func(outcome, said string, verdict map[string]any) { if _, err := r.runs.endRun(key, ask, outcome, said, verdict); err != nil { @@ -438,7 +439,7 @@ const seatListKey = "seat:" + meshcatalog.Seat + "." + meshcatalog.VerbSeatList // seat-list hands, asked as a kept call under the run's ask. func (r *compositionRun) validateSeats(ctx context.Context, ask string, defs []meshcatalog.CatalogRevisionDefinitionsItem) ([]json.RawMessage, string, error) { if len(defs) == 0 { - return r.seatList(ask) + return r.seatList(ctx, ask) } sorted := slices.Clone(defs) slices.SortStableFunc(sorted, func(a, b meshcatalog.CatalogRevisionDefinitionsItem) int { return strings.Compare(a.Seat, b.Seat) }) @@ -466,8 +467,12 @@ func seatListDigest(raw []byte) string { // seatList is the trunk's seat list as the verb seat-list hands it (H-A-443): its digest and size, then the object's bytes in // chunks; bytes whose size or sha256 is not the answer's, or that are no JSON array, are refused, so every run of one digest // judges the same bytes. -func (r *compositionRun) seatList(ask string) ([]json.RawMessage, string, error) { +func (r *compositionRun) seatList(ctx context.Context, ask string) ([]json.RawMessage, string, error) { what := "the trunk's seat list is not read through " + seatListKey + left, bound, _ := r.readsLeft(readsClockOf(ctx)) + if left <= 0 { + return nil, "", errors.New(what + ": the run's reads passed their deadline of " + bound.String() + " (the setting reads-bound)") + } if r.callFile == nil { return nil, "", errors.New(what + ": the assigner holds no chunked call") } @@ -475,7 +480,7 @@ func (r *compositionRun) seatList(ask string) ([]json.RawMessage, string, error) if _, err := rand.Read(bits[:]); err != nil { return nil, "", fmt.Errorf("%s: %w", what, err) } - raw, err := r.callFile(process.KeptAsk{ID: ask + "." + meshcatalog.VerbSeatList, Bound: readsBound}, seatListKey, + raw, err := r.callFile(process.KeptAsk{ID: ask + "." + meshcatalog.VerbSeatList, Bound: left}, seatListKey, meshcatalog.SeatListInput{Call: hex.EncodeToString(bits[:])}) if err != nil { return nil, "", fmt.Errorf("%s: %w", what, err) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go index 5deaaae2f..49ec920d0 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go @@ -128,7 +128,7 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) { } return nil } - r := &compositionRun{runs: runs, keeper: keeper, reads: &compositionReads{}, call: call, callFile: callFile, own: context.Background(), now: time.Now, logf: t.Logf, + r := &compositionRun{runs: runs, keeper: keeper, reads: &compositionReads{}, call: asKept(call), callFile: callFile, own: context.Background(), now: time.Now, logf: t.Logf, put: func(_ context.Context, a buildstep.StepAsk) error { body, err := keeper.body(a.Run.Input.Digest) if err != nil { @@ -234,7 +234,7 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) { {"an empty list", listAnswer([]byte(`[]`), seatListDigest([]byte(`[]`)), 2)}, } { listed = row.answer - if seats, digest, err := r.seatList("ask-row"); err == nil || !strings.Contains(err.Error(), seatListKey) { + if seats, digest, err := r.seatList(context.Background(), "ask-row"); err == nil || !strings.Contains(err.Error(), seatListKey) { t.Errorf("%s: the seat list read %s %s, %v; want it refused, naming the verb", row.name, digest, seats, err) } } diff --git a/modules/mesh-delivery-assigner/manifest_test.go b/modules/mesh-delivery-assigner/manifest_test.go index 27672e376..4609a876c 100644 --- a/modules/mesh-delivery-assigner/manifest_test.go +++ b/modules/mesh-delivery-assigner/manifest_test.go @@ -185,7 +185,7 @@ func TestManifest(t *testing.T) { } file, _ := os.ReadFile("module.json") if err := json.Unmarshal(file, &raw); err != nil || raw.Config["outside-wait-minutes"].Default != float64(30) || raw.Config["outside-settle-seconds"].Default != float64(90) || - raw.Config["ask-operator-for"].Default != "take-off,remove-node,stops" || len(raw.Config) != 17 || raw.Config["tier-bound"].Default != float64(30) || raw.Config["entry-asks"].Default != float64(5) || + raw.Config["ask-operator-for"].Default != "take-off,remove-node,stops" || len(raw.Config) != 18 || raw.Config["tier-bound"].Default != float64(30) || raw.Config["entry-asks"].Default != float64(5) || raw.Config["reads-bound"].Default != float64(8) || raw.Config["composition-runs-cap-mib"].Default != float64(16) || raw.Config["composition-runs-kept"].Default != "24h" || raw.Config["composition-step-bound"].Default != "30m" || raw.Config["run-untaken-bound"].Default != "24h" || raw.Config["blame-tries"].Default != float64(20) || // design 47 H2 H-A-628 (3): the bound of a run's wait for a package's publish, the builder's default @@ -210,6 +210,7 @@ func TestManifest(t *testing.T) { {"MESH_ASSIGNER_PASS_STALL_FILE", "${dir:state}/pass-stall-seconds", "pass-stall-seconds"}, // design 47 H2 H-A-635 {"MESH_ASSIGNER_TIER_BOUND_FILE", "${dir:state}/tier-bound", "tier-bound"}, // design 47 H §751 {"MESH_ASSIGNER_ENTRY_ASKS_FILE", "${dir:state}/entry-asks", "entry-asks"}, // design 47 H H-A-60 + {"MESH_ASSIGNER_READS_BOUND_FILE", "${dir:state}/reads-bound", "reads-bound"}, // design 47 H2 H-A-708 (3) } { if !strings.Contains(string(file), `"`+f.env+`": "`+f.path+`"`) || !strings.Contains(string(file), `"path": "`+f.path+`"`) || !strings.Contains(string(file), `"content": "${config:`+f.key+`}"`) { diff --git a/modules/mesh-delivery-assigner/module.json b/modules/mesh-delivery-assigner/module.json index ec9a7447d..869699938 100644 --- a/modules/mesh-delivery-assigner/module.json +++ b/modules/mesh-delivery-assigner/module.json @@ -197,6 +197,14 @@ "trusted": false, "default": 30 }, + "reads-bound": { + "type": "number", + "description": "minutes a composition or validate run's reads of the seats mesh-catalog and mesh-builds may take in all, counted from the run's first read: the reads are kept calls paced by the form, and past it the run ends could not run with every call's time and words. Kept below the runner's ask-unanswered-bound (default 10 minutes, counted from the pull), so the step ends with the assigner's words; one set above it has the runner's bound end the step with its own (design 47 H2 H-A-708 (3)).", + "minimum": 1, + "maximum": 9, + "trusted": false, + "default": 8 + }, "entry-asks": { "type": "number", "description": "how often the assigner asks a catalog entry again, on each catalog-revision and when its link to the bus opens again, after its ask failed to reach the holder of the seat mesh-catalog; one more failure leaves it unanswered, with the finding entry-unanswered (design 47 H, H-A-60).", @@ -346,6 +354,14 @@ "mode": "0600", "content": "${config:tier-bound}" }, + { + "id": "reads-bound", + "type": "file", + "path": "${dir:state}/reads-bound", + "owner": "mesh-delivery-assigner", + "mode": "0600", + "content": "${config:reads-bound}" + }, { "id": "entry-asks", "type": "file", @@ -425,6 +441,7 @@ "MESH_ASSIGNER_ASK_OPERATOR_FOR_FILE": "${dir:state}/ask-operator-for", "MESH_ASSIGNER_TIER_BOUND_FILE": "${dir:state}/tier-bound", "MESH_ASSIGNER_ENTRY_ASKS_FILE": "${dir:state}/entry-asks", + "MESH_ASSIGNER_READS_BOUND_FILE": "${dir:state}/reads-bound", "MESH_ASSIGNER_COMPOSITION_RUNS_CAP_MIB_FILE": "${dir:state}/composition-runs-cap-mib", "MESH_ASSIGNER_COMPOSITION_RUNS_KEPT_FILE": "${dir:state}/composition-runs-kept", "MESH_ASSIGNER_COMPOSITION_STEP_BOUND_FILE": "${dir:state}/composition-step-bound", From d9f733318cabf15a3e84e5a7654bd91d3f7e91ae Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:31:36 +0100 Subject: [PATCH 063/141] B16 events-by-key (2): a retake lists no key; the set of keys failed on a transport fault is filled by the start sweep and kept by every write Builds: design 47 H2 H-A-683 (2), H-A-696 --- .../internal/build/faulted.go | 113 ++++++++++++++++++ .../internal/build/retake.go | 26 ++-- .../internal/build/retake_test.go | 50 ++++++++ .../internal/build/retakeask_test.go | 3 + .../internal/build/run.go | 8 +- 5 files changed, 180 insertions(+), 20 deletions(-) create mode 100644 modules/mesh-delivery-builder/internal/build/faulted.go diff --git a/modules/mesh-delivery-builder/internal/build/faulted.go b/modules/mesh-delivery-builder/internal/build/faulted.go new file mode 100644 index 000000000..20659cb01 --- /dev/null +++ b/modules/mesh-delivery-builder/internal/build/faulted.go @@ -0,0 +1,113 @@ +package build + +import ( + "context" + "sort" + "sync" + + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds" +) + +// Faulted is the set of build keys whose newest revision failed on a transport fault, with the seat and node the fault names +// (design 47 H2 H-A-683 (2), H-A-696): filled by the start sweep (Builder.Sweep) and kept by every write of a build (the store +// Builder.init wraps), held in memory so that an event retakes only the keys whose seat or node it names, and lists no key of the +// bucket. An event heard before the sweep has filled the set waits (WaitFilled) until it has. +type Faulted struct { + mu sync.Mutex + revs map[string]uint64 // the newest revision noted of each key, so that an older read never replaces a newer write + faults map[string]fault + filled chan struct{} + once sync.Once +} + +type fault struct{ seat, node string } + +func newFaulted() *Faulted { + return &Faulted{revs: map[string]uint64{}, faults: map[string]fault{}, filled: make(chan struct{})} +} + +// note keeps what key holds at revision rev: in the set when it failed on a transport fault, else out of it. +func (f *Faulted) note(key string, value []byte, rev uint64) { + var fl fault + in := false + if v, err := builds.DecodeBuilderBuild(value); err == nil && v.State == builds.BuildFailed { + _, seat, node, _, ok := builds.TransportFaultOf(v.Error) + fl, in = fault{seat, node}, ok + } + f.mu.Lock() + defer f.mu.Unlock() + if rev < f.revs[key] { + return + } + f.revs[key] = rev + if in { + f.faults[key] = fl + } else { + delete(f.faults, key) + } +} + +// Fill says the start sweep has read every key, and returns how many keys the set holds. +func (f *Faulted) Fill() int { + f.once.Do(func() { close(f.filled) }) + return f.Len() +} + +// Len is how many keys the set holds. +func (f *Faulted) Len() int { + f.mu.Lock() + defer f.mu.Unlock() + return len(f.faults) +} + +// WaitFilled returns once the start sweep has filled the set, or ctx ends. +func (f *Faulted) WaitFilled(ctx context.Context) error { + select { + case <-f.filled: + return nil + case <-ctx.Done(): + return ctx.Err() + } +} + +// Matching are the keys of the set whose seat and node want says passed, in order. +func (f *Faulted) Matching(want func(seat, node string) bool) []string { + f.mu.Lock() + defer f.mu.Unlock() + var out []string + for k, fl := range f.faults { + if want(fl.seat, fl.node) { + out = append(out, k) + } + } + sort.Strings(out) + return out +} + +// faultNoting is the builds store that notes every write in the set. +type faultNoting struct { + Store + set *Faulted +} + +func (s faultNoting) Create(ctx context.Context, key string, value []byte) (uint64, error) { + rev, err := s.Store.Create(ctx, key, value) + if err == nil { + s.set.note(key, value, rev) + } + return rev, err +} + +func (s faultNoting) Update(ctx context.Context, key string, value []byte, revision uint64) (uint64, error) { + rev, err := s.Store.Update(ctx, key, value, revision) + if err == nil { + s.set.note(key, value, rev) + } + return rev, err +} + +// WaitFaults returns once the start sweep has filled the set of faulted keys, or ctx ends. +func (b *Builder) WaitFaults(ctx context.Context) error { + b.init() + return b.Faults.WaitFilled(ctx) +} diff --git a/modules/mesh-delivery-builder/internal/build/retake.go b/modules/mesh-delivery-builder/internal/build/retake.go index e27865d2d..740769c10 100644 --- a/modules/mesh-delivery-builder/internal/build/retake.go +++ b/modules/mesh-delivery-builder/internal/build/retake.go @@ -104,6 +104,10 @@ func (r *Retaker) Heard(ctx context.Context, subject string, data []byte, seq ui return true, nil } } + // An event heard before the start sweep has filled the set of faulted keys waits for it (H-A-696), held under its node's key. + if err := r.Builder.WaitFaults(ctx); err != nil { + return true, err + } var want func(seat, node string) bool if running { want, err = r.runningWant(ctx, data) @@ -135,7 +139,7 @@ func (r *Retaker) runningWant(ctx context.Context, data []byte) (func(seat, node r.logf("a running that does not read is not acted on: %v", err) return nil, nil } - if ev.Stopped || ev.Fingerprint == "" { + if ev.Stopped || ev.Fingerprint == "" || r.Builder.Faults.Len() == 0 { // no key to retake: no call (H-A-683 (2)) return nil, nil } e, err := r.Entry(ctx, ev.Fingerprint) @@ -167,25 +171,9 @@ func (r *Retaker) returnedWant(data []byte) (func(seat, node string) bool, error return func(_, node string) bool { return node == ev.Node }, nil } -// retakeAll builds again every key failed on a transport fault whose seat and node want says passed. +// retakeAll builds again every key of the set of faulted keys whose seat and node want says passed; it lists no key of the bucket. func (r *Retaker) retakeAll(ctx context.Context, want func(seat, node string) bool) error { - keys, err := r.Builder.Claimer.Store.Keys(ctx) - if err != nil { - return fmt.Errorf("the build keys cannot be listed: %w", err) - } - for _, key := range keys { - raw, _, found, err := r.Builder.Claimer.Store.Get(ctx, key) - if err != nil || !found { - continue - } - v, err := builds.DecodeBuilderBuild(raw) - if err != nil || v.State != builds.BuildFailed { - continue - } - _, seat, node, _, ok := builds.TransportFaultOf(v.Error) - if !ok || !want(seat, node) { - continue - } + for _, key := range r.Builder.Faults.Matching(want) { started, ask, cur, rev, err := r.Builder.Retake(ctx, key) if err != nil { return err diff --git a/modules/mesh-delivery-builder/internal/build/retake_test.go b/modules/mesh-delivery-builder/internal/build/retake_test.go index 3d8ee4a9b..f113f7652 100644 --- a/modules/mesh-delivery-builder/internal/build/retake_test.go +++ b/modules/mesh-delivery-builder/internal/build/retake_test.go @@ -5,7 +5,9 @@ import ( "encoding/json" "fmt" "sync" + "sync/atomic" "testing" + "time" "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" @@ -52,6 +54,9 @@ func TestRetakeOnAnEvent(t *testing.T) { if v := r.consider(t, "modules/m"); !builds.FailedOnTransportFault(v.Error) { t.Fatalf("the key = %+v, want failed on a transport fault", v) } + if err := r.b.Sweep(context.Background()); err != nil { // the start sweep fills the set of faulted keys (H-A-696) + t.Fatal(err) + } var asked []string rt := &Retaker{Builder: r.b, Acted: &actedStore{}, Entry: func(context.Context, string) (meshcatalog.CatalogEntry, error) { @@ -113,6 +118,9 @@ func TestRetakeOnANodeReturned(t *testing.T) { r.consider(t, "modules/m") seed(t, r.st, builds.BuilderBuild{State: builds.BuildFailed, By: "novox.builder", Manifest: mdigest('a'), Error: "transport fault: connection, node-build-go ace, dial tcp: connection refused"}) + if err := r.b.Sweep(context.Background()); err != nil { + t.Fatal(err) + } rt := &Retaker{Builder: r.b, Acted: &actedStore{}} for seq, c := range []struct { node, why string @@ -128,3 +136,45 @@ func TestRetakeOnANodeReturned(t *testing.T) { } } } + +// Design 47 H2 H-A-683 (2), H-A-696: a running heard before the start sweep has filled the set of faulted keys waits for it, then +// retakes the keys its node names; one heard after, with the set empty, reads no entry and starts nothing. +func TestRetakeWaitsForTheStartSweep(t *testing.T) { + r := newRig(t, goBundle) + r.consider(t, "modules/m") + seed(t, r.st, builds.BuilderBuild{State: builds.BuildFailed, By: "novox.builder", Manifest: mdigest('a'), + Error: "transport fault: connection, node-build-go ace, dial tcp: connection refused"}) + var entries atomic.Int32 + rt := &Retaker{Builder: r.b, Acted: &actedStore{}, Entry: func(context.Context, string) (meshcatalog.CatalogEntry, error) { + entries.Add(1) + return meshcatalog.CatalogEntry{Serves: []string{"node-build-go.steps"}}, nil + }} + running, _ := json.Marshal(nodeengine.Running{Module: "mesh-build-go", Node: "ace", Fingerprint: "f1"}) + done := make(chan error, 1) + go func() { + _, err := rt.Heard(context.Background(), "mesh.seat.node-engine.event.running.ace.mesh-build-go", running, 1) + done <- err + }() + select { + case err := <-done: + t.Fatalf("a running heard before the sweep ended returned (%v), want it waiting", err) + case <-time.After(50 * time.Millisecond): + } + if err := r.b.Sweep(context.Background()); err != nil { + t.Fatal(err) + } + if err := <-done; err != nil { + t.Fatal(err) + } + r.b.Wait() + if v := valueOf(t, r.st, r.key); v.State != builds.BuildDone || entries.Load() != 1 { + t.Fatalf("after the sweep: the key = %+v, entries read %d, want built and one entry read", v, entries.Load()) + } + // The set is empty now: another running reads no entry. + if _, err := rt.Heard(context.Background(), "mesh.seat.node-engine.event.running.ace.mesh-build-go", running, 2); err != nil { + t.Fatal(err) + } + if entries.Load() != 1 { + t.Fatalf("a running with the set empty read %d entries, want none more", entries.Load()-1) + } +} diff --git a/modules/mesh-delivery-builder/internal/build/retakeask_test.go b/modules/mesh-delivery-builder/internal/build/retakeask_test.go index b30b3c0fd..e0467d1ce 100644 --- a/modules/mesh-delivery-builder/internal/build/retakeask_test.go +++ b/modules/mesh-delivery-builder/internal/build/retakeask_test.go @@ -54,6 +54,9 @@ func theOperatorAnswers(t *testing.T, option string) { r.consider(t, "modules/m") seed(t, r.st, builds.BuilderBuild{State: builds.BuildFailed, By: "novox.builder", Manifest: mdigest('a'), EventBuilds: 3, Error: "transport fault: connection, node-build-go ace, dial tcp: connection refused"}) + if err := r.b.Sweep(context.Background()); err != nil { + t.Fatal(err) + } var published []oc.Ask acted := &actedStore{} asker := &OperatorAsk{Builder: r.b, Acted: acted, Ctx: context.Background(), Now: askedAt, diff --git a/modules/mesh-delivery-builder/internal/build/run.go b/modules/mesh-delivery-builder/internal/build/run.go index 6981912e5..55a088635 100644 --- a/modules/mesh-delivery-builder/internal/build/run.go +++ b/modules/mesh-delivery-builder/internal/build/run.go @@ -133,7 +133,9 @@ type Builder struct { // its single reference, and its needs. Nil: no node states anything, and the first forms are kept. Forms func() (present, counted map[string][]string) - once sync.Once + once sync.Once + // Faults are the keys whose newest revision failed on a transport fault (H-A-683 (2)), filled by Sweep and kept by every write. + Faults *Faulted sem chan struct{} wg sync.WaitGroup mu sync.Mutex @@ -194,6 +196,8 @@ func (b *Builder) Looking(key string) bool { func (b *Builder) init() { b.once.Do(func() { + b.Faults = newFaulted() + b.Claimer.Store = faultNoting{Store: b.Claimer.Store, set: b.Faults} limit := b.Limit if limit <= 0 { limit = 256 @@ -510,6 +514,7 @@ func (b *Builder) Sweep(ctx context.Context, pictured ...string) error { if err != nil || !found { continue } + b.Faults.note(key, value, rev) cur, err := builds.DecodeBuilderBuild(value) if err != nil { continue @@ -529,6 +534,7 @@ func (b *Builder) Sweep(ctx context.Context, pictured ...string) error { } b.logf("%s: closed, left building by %s for a fingerprint the module no longer has", key, cur.By) } + b.logf("the start sweep read %d keys and put %d in the set of keys failed on a transport fault", len(keys), b.Faults.Fill()) if newly { // A key read before the scan may wait for a package the scan found published (ADR 0500 clause 6). b.Reconsider(ctx) From 0a3eb550eb7dfa958f520dc785ab604aaf63d011 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:32:06 +0100 Subject: [PATCH 064/141] A7 call-unanswered: a read waited five minutes writes the finding call-unanswered of its seat verb, cleared at the answer or when no run waits on it Builds: design 47 H2 H-A-708 (4), H-A-731 --- .../compositionreads.go | 81 ++++++++++++++++++- .../mesh-delivery-assigner/compositionrun.go | 5 ++ .../compositionrun_test.go | 43 ++++++++++ .../mesh-delivery-assigner/validatestep.go | 5 +- .../internal/assign/findings.go | 21 +++++ 5 files changed, 153 insertions(+), 2 deletions(-) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionreads.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionreads.go index 81291b45a..08be1b15c 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionreads.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionreads.go @@ -8,9 +8,12 @@ import ( "sync" "time" + mccond "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient" mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" "git.novox.be/novox/mesh-sdk/go/buscalls" + "git.novox.be/novox/mesh-sdk/go/busretry" "git.novox.be/novox/mesh-sdk/go/process" + "mesh-delivery-assigner/internal/assign" ) // The reads of a composition step (design 47 G §354, A-252, A-261): the entries of one catalog revision are read once and shared by @@ -100,7 +103,10 @@ func (r *compositionRun) callRead(ctx context.Context, key string, body any) (js return nil, "", fmt.Errorf("%s is not read: the run's reads passed their deadline of %s (the setting reads-bound) counted from its first read at %s%s", key, bound, first.UTC().Format(time.RFC3339), last) } - raw, err := r.call(process.KeptAsk{Bound: left}, key, body) + id := readFindingID(key) + r.waiting(id, +1) + raw, err := r.call(process.KeptAsk{Bound: left, Hook: r.readHook}, key, body) + r.waiting(id, -1) if err != nil { words := fmt.Errorf("%s%s: %w", key, r.holderWords(key), err) clock.mu.Lock() @@ -218,3 +224,76 @@ func unreadErr(what string, err error, said string) error { } return fmt.Errorf("%s: %s", what, said) } + +// readFindingID is the id of the finding call-unanswered of a read of key: `.`. +func readFindingID(key string) string { return strings.TrimPrefix(key, "seat:") } + +// readKey is the key of the finding call-unanswered of a read: one per seat verb. +func readFindingKey(id string) string { + return mccond.Key(mccond.ScopeCall, assign.KeyID(id), mccond.KindCallUnanswered) +} + +// readHook is the kept-call form's hook (design 47 H2 H-A-708 (4), H-A-731): told when a read has waited five minutes, it writes the +// finding call-unanswered of its seat verb naming its holder, its machine, the last fault and since when; told of the answer, it +// clears it. +func (r *compositionRun) readHook(w busretry.Waited) { + id := w.Seat + "." + w.Verb + if w.Answered { + r.clearRead(id, true) + return + } + if r.findings.Put == nil { + return + } + holder, nodes := "", []string(nil) + if r.holder != nil { + holder, nodes = r.holder(w.Seat) + } + f := assign.ReadUnanswered(w.Seat, w.Verb, holder, nodes, w.Last, w.Since).Finding(r.now()) + if err := r.findings.Put(f); err != nil { + r.logf("the finding %s is not written: %v", readFindingKey(id), err) + return + } + r.readMu.Lock() + if r.raised == nil { + r.raised = map[string]bool{} + } + r.raised[id] = true + r.readMu.Unlock() +} + +// waiting counts the reads of one seat verb now waiting for an answer; when the last one ends, the finding it raised is cleared: +// no run waits on it any more, and each run's could-not-run says it (design 47 H2 H-A-708 (4)). +func (r *compositionRun) waiting(id string, d int) { + r.readMu.Lock() + if r.inflight == nil { + r.inflight = map[string]int{} + } + r.inflight[id] += d + none := r.inflight[id] <= 0 + if none { + delete(r.inflight, id) + } + r.readMu.Unlock() + if d < 0 && none { + r.clearRead(id, false) + } +} + +// clearRead clears the finding of a read's seat verb when this process raised it; answered says the verb answered. +func (r *compositionRun) clearRead(id string, answered bool) { + r.readMu.Lock() + raised := r.raised[id] + if raised && (answered || r.inflight[id] <= 0) { + delete(r.raised, id) + } else { + raised = false + } + r.readMu.Unlock() + if !raised || r.findings.Delete == nil { + return + } + if err := r.findings.Delete(readFindingKey(id)); err != nil { + r.logf("the finding %s is not cleared: %v", readFindingKey(id), err) + } +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go index 05f9b20e9..4157c3b7f 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go @@ -64,6 +64,11 @@ type compositionRun struct { readsBound time.Duration // holder is the module holding a seat and the machines it runs on, for the words of a read that met a fault; nil: none named. holder func(seat string) (module string, nodes []string) + // readMu guards inflight, the reads now waiting by seat verb, and raised, the seat verbs whose finding call-unanswered this + // process wrote (H-A-708 (4)). + readMu sync.Mutex + inflight map[string]int + raised map[string]bool // callFile asks a seat verb held once for the mesh whose answer comes in chunks, as a kept call (process.Conn.CallFileKept), // answering the verb's answer with the bytes received as its member `file`, base64: the validate step's seat-list (H-A-443). callFile func(ask process.KeptAsk, key string, body any) (json.RawMessage, error) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go index cfd090f49..729aa48b4 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun_test.go @@ -18,6 +18,7 @@ import ( mmac "git.novox.be/novox/mesh-contracts/go/clients/meshmoduleassignerclient" mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner" ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" + mccond "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient" mcseat "git.novox.be/novox/mesh-contracts/health-and-repair/go/seats/meshconditions" mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" @@ -26,6 +27,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" "git.novox.be/novox/mesh-sdk/go/keys" + "git.novox.be/novox/mesh-sdk/go/views" "mesh-delivery-assigner/internal/assign" ) @@ -783,6 +785,47 @@ func TestARunsReadsShareOneDeadline(t *testing.T) { } } +// Design 47 H2 H-A-708 (4), H-A-731, AC-A7: a read that waited five minutes writes the finding call-unanswered, id `.`, +// naming its holder and machine, the last fault and since when; the verb's answer clears it, and so does the end of the last read +// waiting on it past its bound. +func TestAReadUnansweredForFiveMinutesIsTheFindingCallUnanswered(t *testing.T) { + step := meshwants.StepRun{Module: "m", Branch: "main", Revision: 7, Step: meshwants.StepRunStepComposition} + for _, answered := range []bool{true, false} { + s := newRunStand(t, "src2:e1", "src2:e1", "d1") + inner := s.r.call + findings := map[string]mcseat.Finding{} + s.r.findings = assign.Findings{Put: func(f mcseat.Finding) error { findings[views.FindingKey(f.Scope, f.ID, f.Kind)] = f; return nil }, + Delete: func(key string) error { delete(findings, key); return nil }} + s.r.holder = func(string) (string, []string) { return "mesh-delivery-indexer", []string{"novox"} } + since := time.Unix(500, 0) + key := mccond.Key(mccond.ScopeCall, "mesh-catalog.revision", mccond.KindCallUnanswered) + s.r.call = func(ask process.KeptAsk, k string, body any) (json.RawMessage, error) { + if k != mcc.RevisionVerb { + return inner(ask, k, body) + } + ask.Hook(busretry.Waited{Seat: "mesh-catalog", Verb: "revision", Since: since, Last: "away: the trunk's revision 512 not read yet"}) + if f, ok := findings[key]; !ok || !strings.Contains(f.Summary, "mesh-delivery-indexer on novox") || !strings.Contains(f.Summary, "the trunk's revision 512") || + !strings.Contains(f.Summary, since.UTC().Format(time.RFC3339)) { + t.Errorf("at five minutes the findings are %+v", findings) + } + if answered { + ask.Hook(busretry.Waited{Seat: "mesh-catalog", Verb: "revision", Since: since, Answered: true}) + if _, ok := findings[key]; ok { + t.Error("the answer left the finding") + } + return inner(ask, k, body) + } + return nil, &busretry.Unanswered{Seat: "mesh-catalog", Verb: "revision", Bound: ask.Bound} + } + if out := s.r.run(context.Background(), "ask-step", step); answered == (out.Outcome == meshwants.StepEndedOutcomeCouldNotRun) { + t.Errorf("answered %v: the step came to %+v", answered, out) + } + if len(findings) != 0 { + t.Errorf("answered %v: the findings stand after the read: %+v", answered, findings) + } + } +} + // Design 47 G §718, §719, §720: three composition steps of one revision on two machines start two runs, one request and one run // ask per machine, and each step reads both verdicts; the run records its program with the node-engine fingerprint it was chosen // from and the digest of its kept request, which names no module of the asking pipeline; a step of another candidate starts its diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go index a35719078..3cca23537 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go @@ -480,8 +480,11 @@ func (r *compositionRun) seatList(ctx context.Context, ask string) ([]json.RawMe if _, err := rand.Read(bits[:]); err != nil { return nil, "", fmt.Errorf("%s: %w", what, err) } - raw, err := r.callFile(process.KeptAsk{ID: ask + "." + meshcatalog.VerbSeatList, Bound: left}, seatListKey, + id := readFindingID(seatListKey) + r.waiting(id, +1) + raw, err := r.callFile(process.KeptAsk{ID: ask + "." + meshcatalog.VerbSeatList, Bound: left, Hook: r.readHook}, seatListKey, meshcatalog.SeatListInput{Call: hex.EncodeToString(bits[:])}) + r.waiting(id, -1) if err != nil { return nil, "", fmt.Errorf("%s: %w", what, err) } diff --git a/modules/mesh-delivery-assigner/internal/assign/findings.go b/modules/mesh-delivery-assigner/internal/assign/findings.go index 260ba6ea8..a374727e9 100644 --- a/modules/mesh-delivery-assigner/internal/assign/findings.go +++ b/modules/mesh-delivery-assigner/internal/assign/findings.go @@ -75,6 +75,27 @@ func CallUnanswered(id, callee, machine, fault, source string, since time.Time) Source: source} } +// ReadUnanswered is the observation of a seat verb a run's read waited five minutes on (design 47 H2 H-A-708 (4), ADR 0668 §3): id +// `.`, the summary naming its holder, the machines it runs on, the last fault and since when; the id is one finding per +// seat verb. +func ReadUnanswered(seat, verb, holder string, machines []string, fault string, since time.Time) Observed { + who := "its holder is not read" + if holder != "" { + who = "its holder " + holder + if len(machines) > 0 { + who += " on " + strings.Join(machines, ", ") + } + } + callee := seat + "." + verb + return Observed{Scope: mcc.ScopeCall, ID: callee, Kind: mcc.KindCallUnanswered, Severity: mcseat.FindingSeverityWarning, + Summary: fmt.Sprintf("%s is unanswered since %s (%s); the last fault: %s", callee, since.UTC().Format(time.RFC3339), who, fault), + Said: fault, Headline: "A read of a run is not answered", + Explanation: fmt.Sprintf("A composition or validate run's read of %s is asked again at the kept-call pace and has not been answered since %s; %s. "+ + "The last fault: %s.", callee, since.UTC().Format(time.RFC3339), who, fault), + Needs: "the holder of the seat " + seat + " to answer", + Source: "assigner." + mcc.KindCallUnanswered} +} + // FindingOf is a said condition as a finding: from the condition's own key `mesh-delivery-assigner..` (the // subject's id when the key names none), its words unchanged but the resolved ones. raised is false for a clear, whose // finding names only its scope, id and kind. From db3e853cb7024ad6270d487eeadc26bcc623a145 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:32:28 +0100 Subject: [PATCH 065/141] B4 (2) other-bytes by fingerprint: an other-bytes answer for the publish's own fingerprint ends as published with the held digest Builds: design 47 H2 H-A-738 (1) --- .../cmd/mesh-delivery-builder/main.go | 1 + .../internal/versions/republish.go | 26 ++++++++++++++++++- .../internal/versions/republish_test.go | 13 ++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index 7b2187842..180cdffbf 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -269,6 +269,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro } reserved.r.MovedFrom = reserved.movedFrom republish.Unstored = reserved.unstoredAgain + republish.AsHeld = reserved.sayPublished // an artifact held for this very build is published as held (H-A-738 (1)) reserved.judge = func(ctx context.Context, v versions.ReservedVersion) (versions.Judged, error) { return republish.Held(ctx, v, registryVersionsVia(calls.Call)) } diff --git a/modules/mesh-delivery-builder/internal/versions/republish.go b/modules/mesh-delivery-builder/internal/versions/republish.go index ef16d4f81..8fa5fb10e 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish.go +++ b/modules/mesh-delivery-builder/internal/versions/republish.go @@ -180,6 +180,9 @@ type Republisher struct { // Unstored is told the first artifact of a reservation a holder refused as not stored, with the reservation as it stood: the // builder builds the key again itself (design 47 H2 H-A-662); nil is told none. Unstored func(ctx context.Context, v ReservedVersion, ref, words string) + // AsHeld is told each artifact a holder answered `other-bytes` for the publish's own fingerprint, newly marked published with the held + // digest (design 47 H2 H-A-738 (1)): the builder says package-published of it; nil says none. + AsHeld func(ctx context.Context, m Marked, digest string) // Ended ends the publish item of a version that never publishes, its reservation withdrawn or taken over (H-A-290 (2)); // nil ends none. Ended func(ctx context.Context, module, version string) @@ -768,7 +771,7 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate return SendFate{Ended: "none of its artifacts is left to send: each is published or refused as not stored"} } var failed []string - sent, again := 0, false + sent, held, again := 0, 0, false for _, ref := range refs { seat, name, kind, ok := publishTarget(e, q.Module, ref) if !ok { @@ -783,6 +786,25 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate continue } var other *OtherBytes + if errors.As(err, &other) && other.Fingerprint != "" && other.Fingerprint == v.Fingerprint { + // The holder keeps this very build at the version, with the digest of an earlier run of it: the publish is answered as + // published with the held digest, nothing stored (H-A-738 (1)). + marked, _, merr := r.Reserved.MarkHeld(bound, q.Module, v.Version, []HeldArtifact{{Ref: ref, Seat: other.Seat, Name: other.Name, + Version: other.Version, Digest: other.Digest, Fingerprint: other.Fingerprint}}) + if merr != nil { + r.say(ctx, v, ref+": "+merr.Error()) + failed = append(failed, ref+": "+merr.Error()) + continue + } + r.say(ctx, v, fmt.Sprintf("%s %s: %s holds it for this build with the digest %s, built %s: published as held, nothing stored", ref, q.Version, other.Seat, other.Digest, q.Artifacts[ref])) + for _, m := range marked { + if r.AsHeld != nil { + r.AsHeld(ctx, m, other.Digest) + } + } + held++ + continue + } if errors.As(err, &other) { // A version the holder holds with other bytes is never published as it stands (ADR 0605 §4): the item ends at once, spending // no try; the next build of the fingerprint withdraws the number and takes the next free one (H-A-590 (1), H-A-729). @@ -813,6 +835,8 @@ func (r *Republisher) SendQueued(ctx context.Context, q QueuedPublish) SendFate switch { case len(failed) > 0: return SendFate{Failed: strings.Join(failed, "; ")} + case sent == 0 && held > 0: + return SendFate{Ended: "each artifact left is published as the holder holds it for this build"} case sent == 0: return SendFate{Ended: "each artifact left was refused as not stored"} } diff --git a/modules/mesh-delivery-builder/internal/versions/republish_test.go b/modules/mesh-delivery-builder/internal/versions/republish_test.go index a89f02ca0..07bc4e4eb 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish_test.go +++ b/modules/mesh-delivery-builder/internal/versions/republish_test.go @@ -198,6 +198,19 @@ func TestRepublish(t *testing.T) { t.Errorf("%+v, sent %d, ended %v: want the item ended at once naming the other digest, and no failure to try again", f, len(b.sent), b.ended) } }) + t.Run("a version held with other bytes for the publish's own fingerprint ends as published with the held digest", func(t *testing.T) { + // design 47 H2 H-A-738 (1): equal fingerprints answer as published, nothing stored, the held digest on the reservation + b := newRepublishBed(t) + v := b.reserve(t, "m") + var said []string + b.AsHeld = func(_ context.Context, m Marked, digest string) { said = append(said, m.Artifact+" "+digest) } + b.other = &OtherBytes{Seat: SeatArtifacts, Name: "m/prog", Version: v.Version, Digest: "sha256:zz", Fingerprint: v.Fingerprint} + f := b.SendQueued(ctx, b.queueAt(v, PublishClassLive, b.now)) + cur, _, _ := b.Reserved.At(ctx, ReservedKey("m", "0.1")) + if f.Ended == "" || f.Failed != "" || f.Sent || len(b.ended) != 0 || !cur.Published["m:prog"] || cur.Artifacts["m:prog"] != "sha256:zz" || fmt.Sprint(said) != "[m:prog sha256:zz]" { + t.Errorf("%+v, ended %v, published %v, digest %q, said %v: want published with the held digest, said once, no refusal", f, b.ended, cur.Published, cur.Artifacts["m:prog"], said) + } + }) t.Run("the first artifact refused as not stored starts the build again once", func(t *testing.T) { // design 47 H2 H-A-662, H-A-703: one start per reservation, whatever number of its artifacts are refused b := newRepublishBed(t) From 69ed0d95f41ef1ac1e2b43f72b192f24933f2de9 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:32:44 +0100 Subject: [PATCH 066/141] I5 digests-from-the-publisher: a Go package artifact's entry keeps its packages' digests, an importer's fingerprint reads them from the publishing entry, the import form takes no accepted-series override Builds: design 47 H2 H-A-580, H-A-672 (DQ-21), H-A-521, H-A-530 --- .../internal/index/artifacts.go | 29 ++++++++++++++ .../internal/index/imports_test.go | 25 +++++++++++- .../internal/index/importset.go | 39 ++++++++++++++++++- .../internal/index/series.go | 30 ++++++-------- .../internal/index/toolchains.go | 9 +++-- 5 files changed, 105 insertions(+), 27 deletions(-) diff --git a/modules/mesh-delivery-indexer/internal/index/artifacts.go b/modules/mesh-delivery-indexer/internal/index/artifacts.go index 0473a6548..25e2e2831 100644 --- a/modules/mesh-delivery-indexer/internal/index/artifacts.go +++ b/modules/mesh-delivery-indexer/internal/index/artifacts.go @@ -37,6 +37,7 @@ func (ix *Indexer) withArtifacts(ctx context.Context, e meshcatalog.CatalogEntry art := meshcatalog.Artifact{Ref: ArtifactRefOf(e.Module, a.Name), Language: a.Language, Kind: a.Kind} if pkg := ix.packageOf(ctx, e, a); pkg != nil { art.Package = pkg + art.Digests = ix.digestsOf(ctx, pkg) } e.Artifacts = append(e.Artifacts, art) } @@ -82,3 +83,31 @@ func (ix *Indexer) packageOf(ctx context.Context, e meshcatalog.CatalogEntry, a } return &meshcatalog.ArtifactPackage{Ecosystem: ecosystem, Name: name} } + +// digestsOf are the digests of the packages of a package artifact's module, one item per package, kept on the artifact of +// the entry so an importer reads each imported package's digest from the entry that publishes it (design 47 H2 H-A-580): +// those of the packages state's value of a Go module the artifact names, sorted by package; nil for an artifact of +// another ecosystem, or while the state holds none of its module. +func (ix *Indexer) digestsOf(ctx context.Context, pkg *meshcatalog.ArtifactPackage) []meshcatalog.ArtifactDigestsItem { + if pkg.Ecosystem != EcosystemGo || ix.Packages == nil { + return nil + } + key, err := PackagesKey(pkg.Name) + if err != nil { + return nil + } + value, _, found, err := ix.Packages.Get(ctx, key) + if err != nil || !found { + return nil + } + p, err := DecodePublishedPackages(value) + if err != nil { + return nil + } + var out []meshcatalog.ArtifactDigestsItem + for _, d := range p.Packages { + out = append(out, meshcatalog.ArtifactDigestsItem{Package: d.Package, Digest: d.Digest}) + } + slices.SortFunc(out, func(a, b meshcatalog.ArtifactDigestsItem) int { return strings.Compare(a.Package, b.Package) }) + return out +} diff --git a/modules/mesh-delivery-indexer/internal/index/imports_test.go b/modules/mesh-delivery-indexer/internal/index/imports_test.go index 116ef8920..6e6aaa1e2 100644 --- a/modules/mesh-delivery-indexer/internal/index/imports_test.go +++ b/modules/mesh-delivery-indexer/internal/index/imports_test.go @@ -3,6 +3,7 @@ package index import ( "context" "errors" + "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" "strings" "testing" @@ -491,8 +492,10 @@ func anAcceptedSeriesPinsItsNewest(t *testing.T) { return ix.HearImportsReported(ctx, buildEnd(t, "avahi", before.Fp2, meshSDK, meshSDK+"/announce")) }) pinned := step("0.1.15 published from c3", hear("0.1.15", c3)) - if pinned.Fp2 == before.Fp2 || pinned.Packages[meshSDK] != "v0.1.15" { - t.Fatalf("after 0.1.15: fp2 %q (was %q), versions %v; want moved by c3's announce, pinned to v0.1.15", pinned.Fp2, before.Fp2, pinned.Packages) + // The import form takes no accepted-series override (design 47 H2 H-A-672): the series' contents (c3) move nothing, the + // digests are the trunk entry's (c1) and the version is pinned. + if pinned.Fp2 != before.Fp2 || pinned.Packages[meshSDK] != "v0.1.15" { + t.Fatalf("after 0.1.15: fp2 %q (was %q), versions %v; want unmoved by the series' contents, pinned to v0.1.15", pinned.Fp2, before.Fp2, pinned.Packages) } // A publish in a series avahi does not accept pins nothing and moves nothing (H-A-184). if m := step("0.2.0 published from c1", hear("0.2.0", c1)); m.Fp2 != pinned.Fp2 || m.Packages[meshSDK] != "v0.1.15" { @@ -501,6 +504,24 @@ func anAcceptedSeriesPinsItsNewest(t *testing.T) { if m := step("trunk at c2", trunk(c2)); m.Fp2 != pinned.Fp2 || m.Packages[meshSDK] != "v0.1.15" { t.Errorf("a trunk merge moved avahi off its accepted series' newest: %q %v", m.Fp2, m.Packages) } + // A trunk merge that changes announce, a package it imports, moves it: its digest is read from the publisher's entry + // of the revision, whatever series it accepts (design 47 H2 H-A-580, H-A-672). + if m := step("trunk at c3", trunk(c3)); m.Fp2 == pinned.Fp2 || m.Packages[meshSDK] != "v0.1.15" { + t.Errorf("a change of an imported package at the trunk did not move avahi: %q (was %q) %v", m.Fp2, pinned.Fp2, m.Packages) + } + // The publisher's entry keeps the digest of each package of its package artifact (design 47 H2 H-A-580). + held, _ := ix.heldModules(ctx) + raw, man, err := ix.manifestRaw(ctx, held["mesh-sdk"].Manifest) + if err != nil { + t.Fatal(err) + } + digests := 0 + for _, a := range ix.withArtifacts(ctx, CatalogEntryOf("mesh-sdk", held["mesh-sdk"], man, raw, graph.Node{}), man).Artifacts { + digests += len(a.Digests) + } + if digests == 0 { + t.Errorf("the entry of mesh-sdk keeps no digest of its packages") + } // mesh-sdk's module releases 0.3.0: a module's release number is never a package's pin (H-A-183). ix.Versions = newMem() ix.Versions.(*memStore).put(meshcatalog.VersionsByModuleVersionKey("mesh-sdk", "0.3.0"), []byte(`{}`)) diff --git a/modules/mesh-delivery-indexer/internal/index/importset.go b/modules/mesh-delivery-indexer/internal/index/importset.go index 962e484d4..c49337089 100644 --- a/modules/mesh-delivery-indexer/internal/index/importset.go +++ b/modules/mesh-delivery-indexer/internal/index/importset.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "maps" "slices" "strings" @@ -216,13 +217,21 @@ func (ix *Indexer) meshPackages(ctx context.Context, held map[string]meshcatalog // packagesPublishedBy are the packages meshPackages names, each with the repository of the module that publishes it, so a // take-in tells the packages its repository publishes (design 47 H2 H-A-520, H-A-539). func (ix *Indexer) packagesPublishedBy(ctx context.Context, held map[string]meshcatalog.ModulesByModuleValue) (map[string]string, error) { + names, _, err := ix.publishedByEntries(ctx, held) + return names, err +} + +// publishedByEntries are packagesPublishedBy's names, and with them the digests each Go package artifact of those entries +// keeps, by the package's name (an artifact's `digests`, design 47 H2 H-A-580): what an importer's fingerprint reads. +func (ix *Indexer) publishedByEntries(ctx context.Context, held map[string]meshcatalog.ModulesByModuleValue) (map[string]string, map[string][]meshcatalog.ArtifactDigestsItem, error) { if held == nil { var err error if held, err = ix.heldModules(ctx); err != nil { - return nil, err + return nil, nil, err } } names := map[string]string{} + digests := map[string][]meshcatalog.ArtifactDigestsItem{} for name, cur := range held { if cur.Manifest == "" { continue @@ -234,10 +243,36 @@ func (ix *Indexer) packagesPublishedBy(ctx context.Context, held map[string]mesh for _, a := range ix.withArtifacts(ctx, CatalogEntryOf(name, cur, m, raw, graph.Node{}), m).Artifacts { if p := a.Package; p != nil && p.Name != "" && (p.Ecosystem == EcosystemGo || p.Ecosystem == EcosystemNpm) { names[p.Name] = cur.Repository + if len(a.Digests) > 0 { + digests[p.Name] = a.Digests + } } } } - return names, nil + return names, digests, nil +} + +// fromEntries is published with the packages of each module an entry of the revision computed publishes taken at the +// digests that entry keeps (design 47 H2 H-A-580): an importer's fingerprint reads a package's digest from the entry that +// publishes it, so a publisher that moves in the same take-in is read at its new digests; a module no entry keeps digests +// of stays as the state holds it. Nothing of published is changed in place. +func fromEntries(published map[string]meshcatalog.PackagesByModuleValue, digests map[string][]meshcatalog.ArtifactDigestsItem) map[string]meshcatalog.PackagesByModuleValue { + if len(digests) == 0 { + return published + } + out := maps.Clone(published) + for module, items := range digests { + p, ok := out[module] + if !ok { + continue + } + p.Packages = make([]meshcatalog.PackagesByModuleValuePackagesItem, len(items)) + for i, d := range items { + p.Packages[i] = meshcatalog.PackagesByModuleValuePackagesItem{Package: d.Package, Digest: d.Digest} + } + out[module] = p + } + return out } // inTheMesh are the imports a package of names holds, the package itself or a path under it (I9's reading); any other diff --git a/modules/mesh-delivery-indexer/internal/index/series.go b/modules/mesh-delivery-indexer/internal/index/series.go index 00e9a5091..5c54542b0 100644 --- a/modules/mesh-delivery-indexer/internal/index/series.go +++ b/modules/mesh-delivery-indexer/internal/index/series.go @@ -165,15 +165,13 @@ func (ix *Indexer) SeriesAll(ctx context.Context) map[string]SeriesPackage { return out } -// acceptedSeries is the packages state as a module of repository whose manifest is m is fingerprinted against (DLV-I6; -// ADR 0606 §4, ADR 0609 §1; design 32 *A package, its series, and the series its users accept*): each mesh Go module of -// another repository whose package's series the module accepts (Manifest.AcceptedSeries) and a seat published, by that -// series' newest version, its digests read at that version's commit, and pinned to the version itself (Go's form, -// `v0.1.15`). A series with no published version yet, or whose contents the forge did not list, leaves the module's -// latest published commit (the commit form, milestone § 2 item 4). A module of the same repository takes its sibling by -// path, never by a series. With nothing to pin, published is answered as it is. -func acceptedSeries(series map[string]SeriesPackage, m catalogue.Manifest, repository string, published map[string]meshcatalog.PackagesByModuleValue) (map[string]meshcatalog.PackagesByModuleValue, sdkstep.PackageVersions) { - var out map[string]meshcatalog.PackagesByModuleValue +// acceptedSeries are the pins of a module of repository whose manifest is m (DLV-I6; ADR 0606 §4, ADR 0609 §1; design 32 +// *A package, its series, and the series its users accept*): each mesh Go module of another repository whose package's +// series the module accepts (Manifest.AcceptedSeries) and a seat published, pinned to the series' newest version (Go's form, +// `v0.1.15`). The import form takes no accepted-series override of the packages' digests: it reads each digest from the +// entry that publishes the package, whatever series the module accepts (design 47 H2 H-A-672, H-A-580), so only the version +// line takes the pins. A module of the same repository takes its sibling by path, never by a series. +func acceptedSeries(series map[string]SeriesPackage, m catalogue.Manifest, repository string) sdkstep.PackageVersions { var pins sdkstep.PackageVersions for _, key := range slices.Sorted(maps.Keys(series)) { s := series[key] @@ -184,18 +182,12 @@ func acceptedSeries(series map[string]SeriesPackage, m catalogue.Manifest, repos if repo, _, ok := trunk.PackageRepository(s.GoModule); !ok || trunk.SameRepository(repo, repository) { continue } - if out == nil { - out, pins = maps.Clone(published), sdkstep.PackageVersions{} + if pins == nil { + pins = sdkstep.PackageVersions{} } - p := publishedOfContents(*pinned.Contents) - version := "v" + pinned.Version - p.Commit = version - out[s.GoModule], pins[s.GoModule] = p, version + pins[s.GoModule] = "v" + pinned.Version } - if out == nil { - return published, nil - } - return out, pins + return pins } // pinnedVersion is the version of a series its users are pinned to: its newest released one, never a reservation's diff --git a/modules/mesh-delivery-indexer/internal/index/toolchains.go b/modules/mesh-delivery-indexer/internal/index/toolchains.go index fab63fd28..7560e9350 100644 --- a/modules/mesh-delivery-indexer/internal/index/toolchains.go +++ b/modules/mesh-delivery-indexer/internal/index/toolchains.go @@ -236,7 +236,8 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc return fmt.Errorf("no fingerprint is written: %w", err) } // The packages the module graph's entries publish: a reported import set counts only those (design 47 H2 H-A-539, H-A-540). - publishedBy, err := ix.packagesPublishedBy(ctx, held) + publishedBy, entryDigests, err := ix.publishedByEntries(ctx, held) + published = fromEntries(published, entryDigests) // an importer reads the digests of the entry that publishes (H-A-580) mesh, ofRepository := map[string]bool{}, map[string]bool{} for name, repo := range publishedBy { mesh[name] = true @@ -313,7 +314,7 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc toolchains[artifact] = t.tc } var r result - pub, pins := acceptedSeries(series, k.manifest, k.cur.Repository, published) + pins := acceptedSeries(series, k.manifest, k.cur.Repository) switch { case k.contexts: r.none = None2Context @@ -321,11 +322,11 @@ func (ix *Indexer) recomputeLocked(ctx context.Context, overlay map[string]meshc r.none = strings.Join(missing, "; ") case noToolchain != "": r.none = noToolchain - if fp, pkgs, ok := stillComputed(module, kept, k, toolchains, held, pub, pins, series, mesh); ok { + if fp, pkgs, ok := stillComputed(module, kept, k, toolchains, held, published, pins, series, mesh); ok { r = result{fp: fp, tcs: k.held.Toolchains, pkgs: pkgs} } default: - f := formOf(module, k.cur.Repository, &kept, k.reported, mesh, toolchains, k.held, held, pub, pins, ix.logf) + f := formOf(module, k.cur.Repository, &kept, k.reported, mesh, toolchains, k.held, held, published, pins, ix.logf) r.fp, r.none = f.fp, f.none if r.fp != "" { // a pin is a released version, never a commit (H-A-161), and the version line's fingerprint takes it (H-A-167) From c9de0c62453990f77ac9716cd87ec75326e089e6 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:33:49 +0100 Subject: [PATCH 067/141] DC9 step-result-held-at: StepResult gains held-at, when the step was held (same form raise of mesh-pipeline-runner) Builds: design 47 H2 H-A-738 (2), H-A-599 --- .../go/seats/meshpipelinerunner/contract.go | 4 +++- .../go/seats/meshpipelinerunner/contract_test.go | 2 +- .../seats/mesh-pipeline-runner/fixtures/states.json | 3 ++- .../seats/mesh-pipeline-runner/seat.json | 5 +++++ .../ts/seats/meshpipelinerunner/index.d.ts | 2 ++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index 1d7b491f4..5d4766a17 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -20,7 +20,7 @@ const Form = 13 // whose fields changed while its forms did not (design 47 H2 §780). const ( generatedForms = "13" - generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverAdded=6966283f6909 MoverAddedEvent=b24ae82030ab MoverEnded=4b35095f6829 MoverRow=6de094f5329f Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=397a8219a855 PipelineStarted=d5fc3ee236c7 PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=69998ea62147 PlaceUnfinishedAnswerFailedItem=d9b89913b9bf PlaceUnfinishedAnswerPlacedItem=9ff9288125e5 Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=8609ff359791 StandsAnswer=e05cecdde456 StartAnswer=ed94ced4513a StartedMover=4450a94e6ca3 StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=bdaa8bbfbcab StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=90066504aaa7 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" + generatedFieldsDigest = "AcceptAnswer=224df0394653 Accepted=d2b011e5090f AskAgainAnswer=224df0394653 CancelAnswer=a0dcc32b3f57 EndAgainAnswer=a0dcc32b3f57 FailedStep=cd7184342136 Fill=7a76c9ceb157 FillingEvent=5bd4df78ed84 FullEvent=5bd4df78ed84 KeptAnswer=dfe0d48bc169 KeptByLevelDigestValue=f06c90f7da7f KeptResult=af5f81f189b7 ListAnswer=284210b3c054 LogEntry=b059967b2ae4 Member=8a103baec01f Mover=5db376275bcf MoverAdded=6966283f6909 MoverAddedEvent=b24ae82030ab MoverEnded=4b35095f6829 MoverRow=6de094f5329f Pipeline=2663792125bf PipelineEnded=e3f4c58f93c8 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=397a8219a855 PipelineStarted=d5fc3ee236c7 PipelineStartedEvent=eaa401af4117 PipelinesByBranchRevisionAgainNValue=693580eed498 PipelinesByBranchRevisionUnfinishedModuleValue=693580eed498 PipelinesByBranchRevisionValue=693580eed498 PipelinesByBranchRunRunValue=693580eed498 PipelinesByBranchSourcePublishedPackageVersionValue=693580eed498 PipelinesByStepsPipelineMoverValue=94de99db7816 PlaceAnswer=a0dcc32b3f57 PlaceUnfinishedAnswer=69998ea62147 PlaceUnfinishedAnswerFailedItem=d9b89913b9bf PlaceUnfinishedAnswerPlacedItem=9ff9288125e5 Published=d9af3024dacc QueueByQueueNextValue=765a2918a728 QueueByRunningPipelineValue=ed94ced4513a QueueByWaitingSequenceValue=99605298ae13 RePinnedEvent=92fd04bfa6d3 RerunAnswer=9b7efd0df344 ReviewAnswer=f397b8965179 RoomEvent=5bd4df78ed84 RunAnswer=96bd45aa2e62 RunStarted=b280617410c3 RunStartedEvent=0767a9358fa3 Shared=c981cf6aa860 SharedAskedBy=c9b30cc4d0d0 ShowAnswer=8609ff359791 StandsAnswer=e05cecdde456 StartAnswer=ed94ced4513a StartedMover=4450a94e6ca3 StepEndedEvent=799020642c19 StepEvent=64f18c40ed5d StepLogByPipelineValue=ffdde090a101 StepResult=9db5cfcb26bb StepStartedEvent=799020642c19 TestCounts=9c1332427159 TestRun=ca5a87f3b6b8 TestRunPackage=a7d30558470d TestRunReader=c9b30cc4d0d0 TestRunsAnswer=7ab81a45ca33 TestRunsDropAnswer=8ee70b35469d ToolchainUsed=43b6d42376fb Wait=90066504aaa7 WaitEndedEvent=2bf6d38041c0 WaitHeldEvent=2bf6d38041c0 Waiting=ed94ced4513a WhyCarriedAnswer=8e2fcea6479f Widening=e2790a307466" ) const ( @@ -1109,6 +1109,8 @@ type StepResult struct { Ended *time.Time `json:"ended,omitempty"` // the artifact's build-input fingerprint the step ran at Fingerprint string `json:"fingerprint,omitempty"` + // when the step was held, written at the hold and cleared at its end; absent when it holds no wait, so the ended wait, stands and the watchman's seed read the same time (design 47 H2 H-A-738 (2)) + HeldAt *time.Time `json:"held-at,omitempty"` // the mover the step is of (design 47 H-A-35) Module string `json:"module,omitempty"` // the node whose holder ended it diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go index 9b46e9b0f..1ad030227 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go @@ -61,7 +61,7 @@ func TestFixtures(t *testing.T) { err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, - {name: "a running pipeline whose build waits on the revision view for the revision that superseded it (H-A-561, H-A-562)", subject: "", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"form\":12,\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"running\",\"pipeline\":\"main.3590\",\"revision\":13,\"source\":3590,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"revision view\",\"outcome\":\"waiting\",\"revision\":14,\"seat\":\"mesh-builds\",\"status\":\"required\",\"step\":\"build\",\"why\":\"nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch\"}],\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"form\":12,\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"running\",\"pipeline\":\"main.3590\",\"revision\":13,\"source\":3590,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"on\":\"revision view\",\"outcome\":\"waiting\",\"revision\":14,\"seat\":\"mesh-builds\",\"status\":\"required\",\"step\":\"build\",\"why\":\"nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch\"}],\"v\":1}", + {name: "a running pipeline whose build waits on the revision view for the revision that superseded it (H-A-561, H-A-562)", subject: "", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"form\":12,\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"running\",\"pipeline\":\"main.3590\",\"revision\":13,\"source\":3590,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"fingerprint\":\"fp-0123\",\"held-at\":\"2026-11-10T10:00:30Z\",\"module\":\"nats\",\"on\":\"revision view\",\"outcome\":\"waiting\",\"revision\":14,\"seat\":\"mesh-builds\",\"status\":\"required\",\"step\":\"build\",\"why\":\"nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch\"}],\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"form\":12,\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"running\",\"pipeline\":\"main.3590\",\"revision\":13,\"source\":3590,\"started\":\"2026-11-10T10:00:00Z\",\"steps\":[{\"fingerprint\":\"fp-0123\",\"held-at\":\"2026-11-10T10:00:30Z\",\"module\":\"nats\",\"on\":\"revision view\",\"outcome\":\"waiting\",\"revision\":14,\"seat\":\"mesh-builds\",\"status\":\"required\",\"step\":\"build\",\"why\":\"nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch\"}],\"v\":1}", decode: func(b []byte) (any, error) { var v PipelinesByBranchRevisionValue err := json.Unmarshal(b, &v) diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json index 1e21b7505..ecb98df80 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/fixtures/states.json @@ -103,7 +103,8 @@ "why": "nats at fp-0123 is superseded by fp-0456, the newest entry heard on its first branch", "fingerprint": "fp-0123", "seat": "mesh-builds", - "module": "nats" + "module": "nats", + "held-at": "2026-11-10T10:00:30Z" } ], "started": "2026-11-10T10:00:00Z", diff --git a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json index ec7b3bfbc..a68c17d11 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -1327,6 +1327,11 @@ "type": "string", "description": "for a carried result, the pipeline it was carried from" }, + "held-at": { + "type": "string", + "format": "date-time", + "description": "when the step was held, written at the hold and cleared at its end; absent when it holds no wait, so the ended wait, stands and the watchman's seed read the same time (design 47 H2 H-A-738 (2))" + }, "rerun": { "type": "boolean", "description": "the step was asked again by the runner's rerun" diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts index 9c26b027e..8b467b173 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -602,6 +602,8 @@ export interface StepResult { "ended"?: string; /** the artifact's build-input fingerprint the step ran at */ "fingerprint"?: string; + /** when the step was held, written at the hold and cleared at its end; absent when it holds no wait, so the ended wait, stands and the watchman's seed read the same time (design 47 H2 H-A-738 (2)) */ + "held-at"?: string; /** the mover the step is of (design 47 H-A-35) */ "module"?: string; /** the node whose holder ended it */ From c7c65556db6e98483cec32e4d8a778f7289f9d54 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:34:12 +0100 Subject: [PATCH 068/141] K4b reserved-other-bytes: RunReserved's held-under-another-digest row is answered other-bytes, nothing stored Builds: design 47 H2 H-A-738 (1), H-A-729 --- .../publishconformance/publishconformance.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/mesh-delivery-sdk/publishconformance/publishconformance.go b/modules/mesh-delivery-sdk/publishconformance/publishconformance.go index 2d535edbc..26499ef7a 100644 --- a/modules/mesh-delivery-sdk/publishconformance/publishconformance.go +++ b/modules/mesh-delivery-sdk/publishconformance/publishconformance.go @@ -151,7 +151,7 @@ func RunReserved(t *testing.T, fresh func(t *testing.T) ReservedBed) { }{ {name: "reserved, no digest yet: published", reserve: NoDigestYet, ok: true}, {name: "reserved with the digest: published", reserve: SameDigest, ok: true}, - {name: "reserved with no digest yet, the version held under another digest: refused, nothing published", reserve: NoDigestYet, held: true, words: "is published with"}, + {name: "reserved with no digest yet, the version held under another digest: answered other-bytes, nothing stored", reserve: NoDigestYet, held: true}, {name: "reserved for another digest: refused, naming the reservation", reserve: OtherDigest, words: "did not reserve"}, {name: "nothing reserved: refused", words: "did not"}, } { @@ -165,9 +165,10 @@ func RunReserved(t *testing.T, fresh func(t *testing.T) ReservedBed) { } o := b.PublishWhole() if c.held { - // Refused whether it ends with an error or only with the event refused, and never said published. - if o.Event != "refused" || !strings.Contains(o.Reason, c.words) { - t.Fatalf("answered %+v; want refused with %q in its reason, and nothing published", o, c.words) + // A version held under another digest is answered other-bytes, the held digest named: no error, never said + // published and nothing stored; the reader compares its fingerprint (design 47 H2 H-A-729, H-A-738 (1)). + if o.Err != nil || o.Other == nil || o.Other.Digest == "" || o.Event == "published" { + t.Fatalf("answered %+v; want no error and other-bytes naming the held digest, and nothing published", o) } return } From a84db91177f18532898363106964a4a024ab02e7 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:34:13 +0100 Subject: [PATCH 069/141] B7 (1) acted-lifetimes: acted is key-ttl with max-mib 4; marks take the lifetime acted-days (30), the release record none; keys of no form go at the start Builds: design 47 H2 H-A-720 (1) (2) (3) (4) --- .../cmd/mesh-delivery-builder/main.go | 10 ++- .../cmd/mesh-delivery-builder/versions.go | 72 +++++++++++++++++++ .../internal/versions/republish.go | 19 ++++- .../internal/versions/republish_test.go | 20 ++++++ .../mesh-delivery-builder/manifest_test.go | 7 +- modules/mesh-delivery-builder/module.json | 19 ++++- 6 files changed, 141 insertions(+), 6 deletions(-) diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index 180cdffbf..126df5f29 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -294,6 +294,13 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro return err } pq.ackWait = publishSet.PauseMax // a sent item unheard is delivered again after the longest pause (H-A-440 (1)) + actedDays, err := numberFile(getenv("MESH_BUILDER_ACTED_DAYS_FILE"), versions.DefaultActedDays) + if err != nil { + return err + } + if actedDays > 365 { + return fmt.Errorf("the setting acted-days is %d, at most 365", actedDays) + } releasedKept, err := numberFile(getenv("MESH_BUILDER_RELEASED_KEPT_FILE"), versions.DefaultReleasedKept) if err != nil { return err @@ -329,7 +336,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro } // The operator is asked once a key's event builds are spent (design 47 G §568): the builder's asker on the seat operator-channel. decided := &decisions{subject: oc.SubjectDecided(cred.Module)} - retakeActed := awaitedReserved{awaitedState{b: actedKV, bucket: own.acted}} + retakeActed := markLifetime{awaitedReserved{awaitedState{b: actedKV, bucket: own.acted}}, actedDays} + actedKV.Ready(func(kv jetstream.KeyValue) { deleteUnknown(ctx, kv, logger.Printf) }) asker := &operatorask.Asker[oc.Warrant]{Module: cred.Module, Call: calls.Call, Record: calls.Ask, Publish: publishVia(ctx, js), Subscribe: decided.hear(logger.Printf), Contract: operatorask.Contract{Seat: oc.Seat, StateAsks: oc.StateAsks}, AskSubject: oc.AcceptSubjectAsk, DecidedSubject: oc.SubjectDecided} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go index 0ac59ccad..fdb938b7f 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go @@ -123,3 +123,75 @@ func emitSeatEvent(ctx context.Context, js jetstream.JetStream, cred process.Acc _, err = js.PublishMsg(pub, msg, jetstream.WithMsgID(id)) return err } + +// markLifetime writes the marks of the state acted with the bus's per-message lifetime of the setting acted-days, each write giving +// it again (design 47 H2 H-A-720 (1)); the release record and every other key it writes with none (H-A-720 (2)). An update is the +// compare-and-set delete of the revision and the create that carries the lifetime, since the bus gives a lifetime at a create. +type markLifetime struct { + awaitedReserved + days int +} + +func (s markLifetime) life(key string) (time.Duration, bool) { + if mark, _ := versions.ActedFormOf(key); mark { + return time.Duration(s.days) * 24 * time.Hour, true + } + return 0, false +} + +func (s markLifetime) Create(ctx context.Context, key string, value []byte) (uint64, error) { + ttl, ok := s.life(key) + if !ok { + return s.awaitedReserved.Create(ctx, key, value) + } + kv, err := s.kv() + if err != nil { + return 0, err + } + rev, err := kv.Create(ctx, key, value, jetstream.KeyTTL(ttl)) + return rev, versionsConflict(err) +} + +func (s markLifetime) Update(ctx context.Context, key string, value []byte, revision uint64) (uint64, error) { + ttl, ok := s.life(key) + if !ok { + return s.awaitedReserved.Update(ctx, key, value, revision) + } + kv, err := s.kv() + if err != nil { + return 0, err + } + if err := kv.Delete(ctx, key, jetstream.LastRevision(revision)); err != nil { + return 0, versionsConflict(err) + } + rev, err := kv.Create(ctx, key, value, jetstream.KeyTTL(ttl)) + return rev, versionsConflict(err) +} + +// deleteUnknown deletes each key of the state acted of a form the builder does not write (design 47 H2 H-A-720 (3)) and says the +// count once. +func deleteUnknown(ctx context.Context, kv jetstream.KeyValue, logf func(string, ...any)) { + l, err := kv.ListKeys(ctx) + if err != nil { + logf("the keys of the state %s are not listed, so none of no form is deleted: %v", versions.ActedState, err) + return + } + var gone []string + for k := range l.Keys() { + if _, known := versions.ActedFormOf(k); !known { + gone = append(gone, k) + } + } + _ = l.Stop() + n := 0 + for _, k := range gone { + if err := kv.Delete(ctx, k); err != nil { + logf("the key %s of the state %s, of no form the builder writes, is not deleted: %v", k, versions.ActedState, err) + continue + } + n++ + } + if len(gone) > 0 { + logf("the state %s: %d keys of no form the builder writes were deleted at the start", versions.ActedState, n) + } +} diff --git a/modules/mesh-delivery-builder/internal/versions/republish.go b/modules/mesh-delivery-builder/internal/versions/republish.go index 8fa5fb10e..61dd1a9a8 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish.go +++ b/modules/mesh-delivery-builder/internal/versions/republish.go @@ -32,7 +32,7 @@ const ( PublishesLocal = "publishes" // ActedState holds, one key per subject, the last stream sequence the builder acted on; capped at ActedMiB. ActedState = "acted" - ActedMiB = 1 + ActedMiB = 4 // PublishQueueTool is builder_publish_queue. PublishQueueTool = "builder_publish_queue" // QueueFull is what version-unreleased says of a version the work queue's cap refused. @@ -331,6 +331,23 @@ func (r *Republisher) end(ctx context.Context, module, version, why string) { } } +// The forms of the keys of the state acted (design 47 H2 H-A-720): the marks of an event or an ask acted on, each written with the +// lifetime of the setting acted-days, and the release record `released.`, written with none. A key of no form is deleted at +// the start. +const DefaultActedDays = 30 + +var actedMarkForms = []string{EscapeToken("retake:"), EscapeToken("retake-asked:"), EscapeToken("retake-ask:")} + +// ActedFormOf says whether key is a mark (known, with a lifetime) or the release record (known, with none), or of no form. +func ActedFormOf(key string) (mark, known bool) { + for _, f := range actedMarkForms { + if strings.HasPrefix(key, f) { + return true, true + } + } + return false, strings.HasPrefix(key, ReleasedKey("")) +} + // ActedKey is the acted key of a subject. func ActedKey(subject string) string { return EscapeToken(subject) } diff --git a/modules/mesh-delivery-builder/internal/versions/republish_test.go b/modules/mesh-delivery-builder/internal/versions/republish_test.go index 07bc4e4eb..1ecccb084 100644 --- a/modules/mesh-delivery-builder/internal/versions/republish_test.go +++ b/modules/mesh-delivery-builder/internal/versions/republish_test.go @@ -540,3 +540,23 @@ func TestThePublishQueueToolAnswersAtAnySize(t *testing.T) { t.Errorf("a reader with no bulk read answered %d (%v) with %d single reads, want every key read one by one", b.Total, err, gets) } } + +// Design 47 H2 H-A-720: the forms of the keys of the state acted: marks take a lifetime, the release record none, any other key of no +// form is deleted at the start. +func TestActedKeysHaveForms(t *testing.T) { + for _, c := range []struct { + key string + mark, known bool + }{ + {ActedKey("retake:mesh.seat.node-engine.event.running.ace.m"), true, true}, + {ActedKey("retake-asked:m\x00abc"), true, true}, + {ActedKey("retake-ask:ask-1"), true, true}, + {ReleasedKey("m"), false, true}, + {"junk", false, false}, + {ActedKey("publish:x"), false, false}, + } { + if mark, known := ActedFormOf(c.key); mark != c.mark || known != c.known { + t.Errorf("%q: mark %v, known %v, want %v, %v", c.key, mark, known, c.mark, c.known) + } + } +} diff --git a/modules/mesh-delivery-builder/manifest_test.go b/modules/mesh-delivery-builder/manifest_test.go index fa7b3472e..144fae554 100644 --- a/modules/mesh-delivery-builder/manifest_test.go +++ b/modules/mesh-delivery-builder/manifest_test.go @@ -122,7 +122,7 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1 if m.Module != "mesh-delivery-builder" { t.Errorf("module = %q", m.Module) } - if want := []state{{Name: "builds", History: 5, MaxMiB: 128}, {Name: "engine-reads", History: 1, MaxMiB: 8}, {Name: "findings", History: 5, MaxMiB: 32}, {Name: "hearing", History: 1, MaxMiB: 8}, {Name: "instances", History: 1, MaxMiB: 8}, {Name: "old-form", History: 1, MaxMiB: 8}, {Name: "bounds", History: 1, KeyTTL: true, MaxMiB: 16}, {Name: "taken", History: 1, KeyTTL: true, MaxMiB: 8}, {Name: "queues", History: 1, MaxMiB: 8}, {Name: "toolchains-heard", History: 1, MaxMiB: 8}, {Name: "waits", History: 1, MaxMiB: 4}, {Name: "reserved", History: 1, MaxMiB: 8}, {Name: "acted", History: 1, MaxMiB: 1}, {Name: "asked", History: 1, MaxMiB: 8}, {Name: "reasks", History: 1, MaxMiB: 8}, {Name: "first-views", History: 1, MaxMiB: 8}, {Name: "unbuildable", History: 1, MaxMiB: 8}, {Name: "consumers", History: 1, MaxMiB: 8}}; !reflect.DeepEqual(m.State, want) { // builds.BuilderBuildsHistory // caps per H-A-437 over the fills read on novox 2026-11-22 (design 47 H2 §812, §814) + if want := []state{{Name: "builds", History: 5, MaxMiB: 128}, {Name: "engine-reads", History: 1, MaxMiB: 8}, {Name: "findings", History: 5, MaxMiB: 32}, {Name: "hearing", History: 1, MaxMiB: 8}, {Name: "instances", History: 1, MaxMiB: 8}, {Name: "old-form", History: 1, MaxMiB: 8}, {Name: "bounds", History: 1, KeyTTL: true, MaxMiB: 16}, {Name: "taken", History: 1, KeyTTL: true, MaxMiB: 8}, {Name: "queues", History: 1, MaxMiB: 8}, {Name: "toolchains-heard", History: 1, MaxMiB: 8}, {Name: "waits", History: 1, MaxMiB: 4}, {Name: "reserved", History: 1, MaxMiB: 8}, {Name: "acted", History: 1, KeyTTL: true, MaxMiB: 4}, {Name: "asked", History: 1, MaxMiB: 8}, {Name: "reasks", History: 1, MaxMiB: 8}, {Name: "first-views", History: 1, MaxMiB: 8}, {Name: "unbuildable", History: 1, MaxMiB: 8}, {Name: "consumers", History: 1, MaxMiB: 8}}; !reflect.DeepEqual(m.State, want) { // builds.BuilderBuildsHistory // caps per H-A-437 over the fills read on novox 2026-11-22 (design 47 H2 §812, §814) t.Errorf("state = %+v, want %+v", m.State, want) } // 1887/A4c: the builder chooses no node, so it reads neither presence nor have, invokes no build module's tool and @@ -198,7 +198,8 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1 m.Streams[3].Duplicates != 24 || m.Streams[3].MaxDeliveries != 10 || m.Streams[3].MaxAgeDays != 7 || m.Streams[3].MaxMiB != 64 { t.Errorf("streams = %+v, want waits with wait-held.** and wait-ended.**, 7 days, 16 MiB, the builds' stream (build.ended.**, 7 days, kept last per subject: design 47 G A-181) and the findings' stream", m.Streams) } - if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 13 || + if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 14 || m.Config["acted-days"].Default != float64(30) || m.Config["acted-days"].Maximum != 365 || // H-A-720 (1) + // design 47 H2 §775, H-A-381 (2): the kept-call pace and the taken key's bound, read by the process m.Config["kept-call-pace-first"].Default != "1s" || m.Config["kept-call-pace-max"].Default != "30s" || m.Config["ask-taken-bound"].Default != "10m" || !m.Config["kept-call-pace-first"].Runtime || !m.Config["kept-call-pace-max"].Runtime || !m.Config["ask-taken-bound"].Runtime || @@ -267,7 +268,7 @@ func TestManifestProcess(t *testing.T) { // 1607/AC1 t.Errorf("health = %v, want kind unit alone", p["health"]) } env, _ := p["env"].(map[string]any) - if len(env) != 9 || env["MESH_BUILDER_RECORD_BOUND_FILE"] != "${dir:state}/record-bound-seconds" || env["MESH_BUILDER_REVISION_WAIT_FILE"] != "${dir:state}/revision-wait-minutes" || env["MESH_BUILDER_PACKAGE_WAIT_FILE"] != "${dir:state}/package-wait-minutes" || env["MESH_BUILDER_PUBLISH_TRIES_FILE"] != "${dir:state}/publish-tries" || env["MESH_BROKER_FILE"] != "${dir:state}/broker" || env["MESH_BUILDER_TOOLCHAIN_WAIT_FILE"] != "${dir:state}/toolchain-wait-minutes" { + if len(env) != 10 || env["MESH_BUILDER_RECORD_BOUND_FILE"] != "${dir:state}/record-bound-seconds" || env["MESH_BUILDER_REVISION_WAIT_FILE"] != "${dir:state}/revision-wait-minutes" || env["MESH_BUILDER_PACKAGE_WAIT_FILE"] != "${dir:state}/package-wait-minutes" || env["MESH_BUILDER_PUBLISH_TRIES_FILE"] != "${dir:state}/publish-tries" || env["MESH_BROKER_FILE"] != "${dir:state}/broker" || env["MESH_BUILDER_TOOLCHAIN_WAIT_FILE"] != "${dir:state}/toolchain-wait-minutes" { t.Errorf("env = %v, want the broker file and the path of the toolchain wait's file, never the setting itself (design 47 G §672, A-71)", p["env"]) } for k, v := range env { diff --git a/modules/mesh-delivery-builder/module.json b/modules/mesh-delivery-builder/module.json index f8f14d69a..3ee417544 100644 --- a/modules/mesh-delivery-builder/module.json +++ b/modules/mesh-delivery-builder/module.json @@ -135,7 +135,7 @@ { "name": "toolchains-heard", "history": 1, "max-mib": 8 }, { "name": "waits", "history": 1, "max-mib": 4 }, { "name": "reserved", "history": 1, "max-mib": 8 }, - { "name": "acted", "history": 1, "max-mib": 1 }, + { "name": "acted", "history": 1, "key-ttl": true, "max-mib": 4 }, { "name": "asked", "history": 1, "max-mib": 8 }, { "name": "reasks", "history": 1, "max-mib": 8 }, { "name": "first-views", "history": 1, "max-mib": 8 }, @@ -232,6 +232,14 @@ "trusted": false, "default": 30 }, + "acted-days": { + "type": "number", + "description": "how many days a mark of an event or an ask acted on (state acted) is kept after its last write; the mark outlives every delivery of its event by far (design 47 H2 H-A-720).", + "minimum": 1, + "maximum": 365, + "trusted": false, + "default": 30 + }, "released-kept": { "type": "number", "description": "how many of a module's last releases the builder keeps, by fingerprint, to judge a rerun of a released build's step (design 47 G A-456b); the oldest is dropped.", @@ -332,6 +340,14 @@ "mode": "0600", "content": "${config:publish-pause-max}" }, + { + "id": "acted-days", + "type": "file", + "path": "${dir:state}/acted-days", + "owner": "mesh-delivery-builder", + "mode": "0600", + "content": "${config:acted-days}" + }, { "id": "released-kept", "type": "file", @@ -371,6 +387,7 @@ "MESH_BUILDER_PUBLISH_PAUSE_FILE": "${dir:state}/publish-pause", "MESH_BUILDER_PUBLISH_PAUSE_MAX_FILE": "${dir:state}/publish-pause-max", "MESH_BUILDER_PUBLISH_TRIES_FILE": "${dir:state}/publish-tries", + "MESH_BUILDER_ACTED_DAYS_FILE": "${dir:state}/acted-days", "MESH_BUILDER_RELEASED_KEPT_FILE": "${dir:state}/released-kept" }, "user": "mesh-delivery-builder", From 382145eddcec9007f4ce0edbd304f41195e53248 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:35:10 +0100 Subject: [PATCH 070/141] A5 assigner-validate: the tool assigner_validate reads the pipeline's candidate from the runner's show and calls the seat mesh-wants' verb validate, which the process answers, recording the hand act before it joins or starts .validate Builds: design 47 H2 H-A-684 (1) (2), H-A-702, H-A-727, H-A-739 --- .../compositions_tools.go | 17 +- .../compositions_tools_test.go | 4 +- .../cmd/mesh-delivery-assigner/main.go | 2 +- .../cmd/mesh-delivery-assigner/tools.go | 1 + .../mesh-delivery-assigner/validatestep.go | 190 ++++++++++++++++++ .../validatestep_test.go | 106 +++++++++- .../mesh-delivery-assigner/manifest_test.go | 3 +- modules/mesh-delivery-assigner/module.json | 4 +- 8 files changed, 318 insertions(+), 9 deletions(-) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositions_tools.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositions_tools.go index df955f7d9..6804387d2 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositions_tools.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositions_tools.go @@ -104,9 +104,9 @@ func (c *compositionSteps) drop(r *compositionRuns, record func(meshhandactsclie return answer, err } -// compositionVerbs are the process's handlers of the seat mesh-wants' verbs compositions and compositions-drop. -func compositionVerbs(r *compositionRuns, c *compositionSteps, record func(meshhandactsclient.Request) error) map[string]process.SeatHandler { - return map[string]process.SeatHandler{ +// compositionVerbs are the process's handlers of the seat mesh-wants' verbs compositions, compositions-drop and validate. +func compositionVerbs(r *compositionRuns, c *compositionSteps, record func(meshhandactsclient.Request) error, validate *compositionRun) map[string]process.SeatHandler { + verbs := map[string]process.SeatHandler{ meshwants.VerbCompositions: func(_ string, raw json.RawMessage) (any, error) { var in meshwants.CompositionsInput if len(raw) > 0 { @@ -124,6 +124,17 @@ func compositionVerbs(r *compositionRuns, c *compositionSteps, record func(meshh return c.drop(r, record, caller, in) }, } + if validate != nil { + // The seat's verb validate (design 47 H2 H-A-727): the tool assigner_validate reaches the process, which keeps the runs. + verbs[meshwants.VerbValidate] = func(caller string, raw json.RawMessage) (any, error) { + var in meshwants.ValidateInput + if err := json.Unmarshal(raw, &in); err != nil { + return nil, fmt.Errorf("the arguments are not JSON: %w", err) + } + return validate.validateOnRequest(validate.own, record, caller, in) + } + } + return verbs } // compositionsTools are the module's tools of §728's names, each calling its verb (A-469f). diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositions_tools_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositions_tools_test.go index b1688be16..50cc778cf 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositions_tools_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositions_tools_test.go @@ -45,14 +45,14 @@ func TestTheCompositionRunsAreReadAndDroppedByTheirVerbs(t *testing.T) { }) var recorded []meshhandactsclient.Request record := func(q meshhandactsclient.Request) error { recorded = append(recorded, q); return nil } - verbs := compositionVerbs(r, c, record) + verbs := compositionVerbs(r, c, record, nil) out, err := verbs[meshwants.VerbCompositions]("op", json.RawMessage(`{"machine":"n2"}`)) read, _ := out.(meshwants.CompositionsAnswer) if err != nil || len(read.Runs) != 1 || read.Runs[0].Key != runKeyOf("main.3", "n2") || read.Runs[0].Ask != "run-n2" || len(read.Runs[0].Readers) != 3 || read.Fill.Store != "composition-runs" || read.Fill.Cap != 16<<20 || read.Fill.Bytes == 0 { t.Fatalf("compositions = %+v %v", out, err) } - refuse := compositionVerbs(r, c, func(meshhandactsclient.Request) error { return errors.New("no holder") }) + refuse := compositionVerbs(r, c, func(meshhandactsclient.Request) error { return errors.New("no holder") }, nil) if _, err := refuse[meshwants.VerbCompositionsDrop]("op", json.RawMessage(`{"candidate":"main.3","machine":"n2","why":"stuck"}`)); err == nil || !strings.Contains(err.Error(), "nothing was dropped") || len(drops) != 0 { t.Fatalf("a drop not recorded: %v, drops %v", err, drops) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go index badc8e979..5f4ffbed2 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go @@ -724,7 +724,7 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber, _, err := meshhandactsclient.Recorder{Ask: bus.Call}.Record(q) return err } - verbs := compositionVerbs(runs, steps, record) + verbs := compositionVerbs(runs, steps, record, run) maps.Copy(verbs, dropVerb(steps)) // the seat's act drop (§778, H-A-404) if p.graph != nil { maps.Copy(verbs, keepNowVerb(ctx, p)) // the keeping by hand (§813 (2), H-A-417) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tools.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tools.go index 5c12d2548..692dac7b4 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tools.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/tools.go @@ -409,6 +409,7 @@ func serveTools() error { tools = append(tools, wants.tools()...) keeper := &inputKeeper{vals: stateobjects.ForState(buckets.InputsState), now: time.Now, logf: func(string, ...any) {}} tools = append(tools, inputsRead(keeper), inputsDrop(keeper, stdio.Ask)) + tools = append(tools, validateTools(stdio.Ask)...) // judge a pipeline's candidate on request, through the seat mesh-wants' verb validate (H-A-727) tools = append(tools, compositionsTools(stdio.Ask)...) // the composition runs' read and drop, through their verbs (§728) tools = append(tools, viewTools(os.Getenv, keptSource, time.Now)...) // What each node's engine reads, as the assigner uses it: its own state engine-reads (design 47 H-A-104). diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go index 3cca23537..0e77e4a7b 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go @@ -13,13 +13,16 @@ import ( "slices" "strings" + "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + mpr "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" meshwants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" stdio "git.novox.be/novox/mesh-sdk/go" + "git.novox.be/novox/mesh-sdk/go/buscalls" "git.novox.be/novox/mesh-sdk/go/process" "mesh-delivery-assigner/internal/buckets" @@ -512,3 +515,190 @@ func (r *compositionRun) seatList(ctx context.Context, ask string) ([]json.RawMe } return list, a.Digest, nil } + +// validateTool is the tool that judges a pipeline's candidate on request (design 47 H2 H-A-684, H-A-702, H-A-727). +const validateTool = "assigner_validate" + +// showKey is the seat mesh-pipeline-runner's verb show, which names a pipeline's candidate (H-A-684 (1), H-A-739). +const showKey = "seat:" + mpr.Seat + "." + mpr.VerbShow + +// validateVerbKey is the seat mesh-wants' verb validate, answered by the assigner's process, which keeps the runs (H-A-727). +const validateVerbKey = "seat:" + meshwants.Seat + "." + meshwants.VerbValidate + +// validateOnRequest is the process's answer of the seat mesh-wants' verb validate: it reads the pipeline's candidate from the runner's +// `show` (H-A-739), answers at once, starting nothing, a pipeline the runner does not know and a candidate the indexer does not +// hold; for a run that has ended it answers its verdict, narrowed by the module; otherwise it records the hand act through the seat +// mesh-hand-acts with its why (H-A-702) and joins or starts the run `.validate` as the step does (H-A-684 (1), H-A-727), +// and answers the run as it stands. +func (r *compositionRun) validateOnRequest(ctx context.Context, record func(meshhandactsclient.Request) error, caller string, in meshwants.ValidateInput) (meshwants.ValidateAnswer, error) { + why, pipeline := strings.TrimSpace(in.Why), strings.TrimSpace(in.Pipeline) + if pipeline == "" || why == "" { + return meshwants.ValidateAnswer{}, errors.New("name the pipeline and why its candidate is judged") + } + couldNot := func(words string) (meshwants.ValidateAnswer, error) { + return meshwants.ValidateAnswer{Outcome: meshwants.ValidateAnswerOutcomeCouldNotRun, Why: words}, nil + } + body, said, err := r.callRead(withReadsClock(ctx), showKey, mpr.ShowInput{Pipeline: pipeline, Bound: 4096}) + if err != nil { + return couldNot("the runner's show of " + pipeline + " is not read: " + err.Error()) + } + if body == nil { + return couldNot("the runner knows no pipeline " + pipeline + ": " + said) + } + var shown mpr.ShowAnswer + if err := json.Unmarshal(body, &shown); err != nil || shown.Pipeline.Pipeline == "" { + return couldNot("the runner's show of " + pipeline + " names no pipeline") + } + p := shown.Pipeline + step := meshwants.StepRun{Pipeline: pipeline, Branch: p.Branch, Revision: p.Revision, Run: p.Run, Source: p.Source, Module: strings.TrimSpace(in.Module), + Step: meshwants.StepRunStepValidate} + candidate, err := candidateKeyOf(step) + if err != nil { + return couldNot("the pipeline " + pipeline + " names no candidate: " + err.Error()) + } + if in.Candidate != "" && in.Candidate != candidate { + return couldNot(fmt.Sprintf("the candidate %s is not the pipeline %s's, %s", in.Candidate, pipeline, candidate)) + } + if _, err := r.revision(withReadsClock(ctx), step); err != nil { + return couldNot(fmt.Sprintf("the indexer holds no candidate %s of the pipeline %s: %v", candidate, pipeline, err)) + } + key, err := validateKeyOf(step) + if err != nil { + return couldNot(err.Error()) + } + run, _, ok, err := r.runs.read(key) + if err != nil { + return meshwants.ValidateAnswer{}, err + } + if !ok || run.Ended == nil { + if err := record(meshhandactsclient.Request{What: meshwants.VerbValidate + " " + key, Why: why + " (" + caller + ")", Cause: "validate"}); err != nil { + return meshwants.ValidateAnswer{}, fmt.Errorf("the hand act was not recorded, so no run was started: %w", err) + } + now := r.now().UTC() + reader := readerOf("validate."+buildstep.NewID(), step) + reader.Ended = &now // a reader of a hand act owes no step end; the run's later steps join it + j, err := r.runs.joinAt(key, reader, candidate, "", buildstep.NewID()) + if err != nil { + return meshwants.ValidateAnswer{}, fmt.Errorf("the validate run %s is not joined: %w", key, err) + } + if j.started { + go r.startValidate(r.own, key, j.run, step) + } + if run, _, ok, err = r.runs.read(key); err != nil || !ok { + run = j.run + } + } + run.Key = key + return validateAnswerOf(run, step.Module) +} + +// validateAnswerOf is the validate run as it stands: running with its start, or its end: passed, failed `cycle` naming the +// cycle, failed `manifest-refused` with every problem per manifest (those the case before holds too marked), or could not run with +// why; the problems narrowed to module when one is named (H-A-684 (1)). +func validateAnswerOf(run meshwants.CompositionRun, module string) (meshwants.ValidateAnswer, error) { + out := meshwants.ValidateAnswer{Run: &run} + if run.Ended == nil { + out.Outcome, out.Started = meshwants.ValidateAnswerOutcomeRunning, run.Started + return out, nil + } + if run.Outcome != meshwants.CompositionRunOutcomePassed { + out.Outcome, out.Why = meshwants.ValidateAnswerOutcomeCouldNotRun, run.Said + return out, nil + } + var v validateVerdict + if raw, err := json.Marshal(run.Verdict); err != nil || json.Unmarshal(raw, &v) != nil { + out.Outcome, out.Why = meshwants.ValidateAnswerOutcomeCouldNotRun, "the validate run's verdict does not read" + return out, nil + } + if len(v.Cycle) > 0 { + out.Outcome, out.Reason = meshwants.ValidateAnswerOutcomeFailed, meshwants.ValidateAnswerReasonCycle + for _, a := range v.Cycle { + out.Cycle = append(out.Cycle, string(a)) + } + return out, nil + } + counted := false + for _, name := range slices.Sorted(maps.Keys(v.Change.Manifests)) { + read := v.Change.Manifests[name] + if read.Accepted || read.Refused == "" || (module != "" && name != module) { + continue + } + held := map[string]bool{} + for _, p := range strings.Split(v.Before.Manifests[name].Refused, "\n") { + held[p] = true + } + for _, p := range strings.Split(read.Refused, "\n") { + if p != "" { + out.Problems = append(out.Problems, meshwants.ValidateAnswerProblemsItem{Module: name, Problem: p, Before: held[p]}) + counted = counted || !held[p] + } + } + } + out.Outcome = meshwants.ValidateAnswerOutcomePassed + if counted { + out.Outcome, out.Reason = meshwants.ValidateAnswerOutcomeFailed, meshwants.ValidateAnswerReasonManifestRefused + } + return out, nil +} + +// validateTools is the module's tool assigner_validate: it reads the pipeline's candidate from the seat mesh-pipeline-runner's `show` +// (answering a pipeline the runner does not know, starting nothing), then calls the seat mesh-wants' verb validate, which the +// process answers; it writes no state and answers what the verb answers (H-A-727). +func validateTools(ask func(string, any) (json.RawMessage, error)) []stdio.Tool { + return []stdio.Tool{{Name: validateTool, Description: "Judge a manifest on request (design 47 H2 H-A-684, H-A-702): the manifest validator's verdict " + + "on a pipeline's candidate, a delivering pipeline's or a run on request's, the one revision's manifests together. It joins or starts the " + + "validate run `.validate` as the step does, so the pipeline's own validate step joins it, recorded as a hand act with why, " + + "and answers at once the run as it stands: running, passed, failed (cycle, or manifest-refused with every problem per manifest, those " + + "the case before holds too marked) or could-not-run. A pipeline the runner does not know, or a candidate the indexer does not hold, " + + "is answered so and starts nothing; a run on request's later steps run until its cancel.", + Input: schema(map[string]string{"pipeline": "the pipeline's key as the runner names it", "module": "narrows the answer to one module's manifest", "why": "why the candidate is judged, kept in the hand act"}, + []string{"pipeline", "why"}), + Run: func(args map[string]any) (any, error) { + pipeline, why := strings.TrimSpace(arg(args, "pipeline")), strings.TrimSpace(arg(args, "why")) + if pipeline == "" || why == "" { + return nil, errors.New("name the pipeline and why its candidate is judged") + } + body, said, err := unwrapAnswer(ask(showKey, mpr.ShowInput{Pipeline: pipeline, Bound: 4096})) + if err != nil || body == nil { + return meshwants.ValidateAnswer{Outcome: meshwants.ValidateAnswerOutcomeCouldNotRun, Why: "the runner knows no pipeline " + pipeline + ": " + orWords(said, err)}, nil + } + var shown mpr.ShowAnswer + if err := json.Unmarshal(body, &shown); err != nil || shown.Pipeline.Pipeline == "" { + return meshwants.ValidateAnswer{Outcome: meshwants.ValidateAnswerOutcomeCouldNotRun, Why: "the runner's show of " + pipeline + " names no pipeline"}, nil + } + p := shown.Pipeline + candidate, err := candidateKeyOf(meshwants.StepRun{Branch: p.Branch, Revision: p.Revision, Run: p.Run}) + if err != nil { + return meshwants.ValidateAnswer{Outcome: meshwants.ValidateAnswerOutcomeCouldNotRun, Why: "the pipeline " + pipeline + " names no candidate: " + err.Error()}, nil + } + raw, err := ask(validateVerbKey, meshwants.ValidateInput{Pipeline: pipeline, Candidate: candidate, Module: strings.TrimSpace(arg(args, "module")), Why: why}) + if err != nil { + return nil, err + } + var out any + if err := json.Unmarshal(raw, &out); err != nil { + return nil, fmt.Errorf("validate answered what is not JSON: %w", err) + } + return out, nil + }}} +} + +// unwrapAnswer reads a verb's answer as a tool call gave it: the body of a good answer, else the holder's words; err when the call +// failed. +func unwrapAnswer(raw json.RawMessage, err error) (json.RawMessage, string, error) { + if err != nil { + return nil, "", err + } + body, said, ok := buscalls.Unwrap(raw) + if !ok { + return nil, said, nil + } + return body, "", nil +} + +func orWords(said string, err error) string { + if err != nil { + return err.Error() + } + return said +} diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go index 49ec920d0..cab03b100 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go @@ -11,9 +11,11 @@ import ( "testing" "time" + "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds" meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" + mpr "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" meshwants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer" @@ -64,9 +66,24 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) { } return b } + // The runner's show of each pipeline it knows (H-A-739): a delivering pipeline's, a run on request's, and one whose candidate the + // indexer holds not. + shown := map[string]mpr.Pipeline{ + "main.12": {Pipeline: "main.12", Branch: "main", Revision: 12, Source: 12}, + "main.run.r1": {Pipeline: "main.run.r1", Branch: "main", Revision: 7, Run: "r1"}, + "main.50": {Pipeline: "main.50", Branch: "main", Revision: 50, Source: 50}, + } call := func(key string, body any) (json.RawMessage, error) { raw, _ := json.Marshal(body) switch key { + case showKey: + var in mpr.ShowInput + _ = json.Unmarshal(raw, &in) + p, ok := shown[in.Pipeline] + if !ok { + return json.Marshal(map[string]string{"error": "no pipeline " + in.Pipeline}) + } + return json.Marshal(mpr.ShowAnswer{Pipeline: p}) case mcc.RevisionVerb: var in meshcatalog.RevisionInput _ = json.Unmarshal(raw, &in) @@ -276,12 +293,99 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) { key, _ := validateKeyOf(step("web", 14)) run := runs.awaitEach(ctx, []string{key}, nil)[key] mu.Lock() - defer mu.Unlock() if run.Ended == nil || run.Outcome != meshwants.CompositionRunOutcomePassed || len(asks) != 5 || asks[4].Packages["git.novox.be/novox/mesh-sdk/go"] != "v0.1.36" { t.Errorf("the validate run its starting step left ended %v %s %q with %d validator asks, want it put after the publish and passed", run.Ended, run.Outcome, run.Said, len(asks)) } + mu.Unlock() if len(held) < 2 || !strings.HasPrefix(held[len(held)-2], waitOnPublish+"git.novox.be/novox/mesh-sdk/go (") || !strings.HasPrefix(held[len(held)-1], waitOnBuildNode+" (") || !strings.HasSuffix(held[len(held)-1], ".held.put)") { t.Errorf("the validate run's reader was said waiting %v; want mesh-sdk's publish, then a build node again at the put (H-A-632)", held) } + + // H2 H-A-684, H-A-702, H-A-727, H-A-739 (A5): the verb validate, which the tool assigner_validate calls, joins or starts the run. + var acts []meshhandactsclient.Request + record := func(q meshhandactsclient.Request) error { acts = append(acts, q); return nil } + onRequest := func(pipeline, module, why string) meshwants.ValidateAnswer { + t.Helper() + a, err := r.validateOnRequest(ctx, record, "op@shanks", meshwants.ValidateInput{Pipeline: pipeline, Module: module, Why: why}) + if err != nil { + t.Fatalf("validate of %s: %v", pipeline, err) + } + return a + } + if _, err := r.validateOnRequest(ctx, record, "op", meshwants.ValidateInput{Pipeline: "main.12"}); err == nil || len(acts) != 0 { + t.Errorf("a call with no why is not refused (%v), or recorded %d hand acts", err, len(acts)) + } + mu.Lock() + asked := len(asks) + mu.Unlock() + if a := onRequest("main.12", "", "judge the fix before its merge"); a.Outcome != meshwants.ValidateAnswerOutcomeRunning || a.Started == nil || len(acts) != 1 || + !strings.Contains(acts[0].What, "main.12"+validateKeySuffix) || !strings.Contains(acts[0].Why, "judge the fix before its merge (op@shanks)") { + t.Errorf("a pipeline with no validate run answered %+v after %d hand acts %+v", a, len(acts), acts) + } + // The pipeline's own validate step joins that run: no second manifest validator is asked. + if o := r.validate(ctx, "ask-web-12", meshwants.StepRun{Step: meshwants.StepRunStepValidate, Pipeline: "main.12", Branch: "main", Module: "web", Revision: 12, Source: 12}); o.Outcome != meshwants.StepEndedOutcomeFailed || len(asks) != asked+1 { + t.Errorf("the step after the call ended %+v with %d validator asks, want one for the call and the step", o, len(asks)-asked) + } + // On an ended run it starts nothing, records none and answers its verdict, narrowed by the module. + got := onRequest("main.12", "web", "again") + if got.Outcome != meshwants.ValidateAnswerOutcomeFailed || got.Reason != meshwants.ValidateAnswerReasonManifestRefused || len(acts) != 1 || len(asks) != asked+1 || + len(got.Problems) != 2 || got.Problems[0].Module != "web" || got.Problems[0].Before || got.Problems[1].Problem != "an inherited problem" || !got.Problems[1].Before { + t.Errorf("an ended run answered %+v after %d hand acts and %d asks", got, len(acts), len(asks)-asked) + } + // An unknown pipeline and a candidate the indexer does not hold are answered so, and start nothing. + for _, pipeline := range []string{"main.99", "main.50"} { + if a := onRequest(pipeline, "", "why"); a.Outcome != meshwants.ValidateAnswerOutcomeCouldNotRun || a.Why == "" || len(acts) != 1 || len(asks) != asked+1 { + t.Errorf("%s answered %+v after %d hand acts, %d asks", pipeline, a, len(acts), len(asks)-asked) + } + } + // H-A-739: a run on request's candidate (run-r1) is judged at the revision show names, 7. + if a := onRequest("main.run.r1", "", "judge the run's members"); a.Outcome != meshwants.ValidateAnswerOutcomeRunning || len(acts) != 2 { + t.Errorf("a run on request answered %+v after %d hand acts", a, len(acts)) + } + if run, _, ok, _ := runs.read("main.run.r1" + validateKeySuffix); !ok || run.Candidate != "run-r1" { + t.Errorf("the run on request's validate run is %+v (kept %v), want its candidate run-r1", run, ok) + } +} + +// H-A-684 (1), H-A-727, H-A-739: the tool reads the runner's show for the candidate and calls the seat mesh-wants' verb validate with +// it, answering what the verb answers; a pipeline the runner does not know is answered so with no verb called, and a call with no +// why is refused. +func TestTheToolValidateReadsTheCandidateAndCallsTheVerb(t *testing.T) { + var verbs []meshwants.ValidateInput + ask := func(key string, body any) (json.RawMessage, error) { + raw, _ := json.Marshal(body) + switch key { + case showKey: + var in mpr.ShowInput + _ = json.Unmarshal(raw, &in) + if in.Pipeline == "main.12" { + return json.Marshal(mpr.ShowAnswer{Pipeline: mpr.Pipeline{Pipeline: "main.12", Branch: "main", Revision: 12}}) + } + return json.Marshal(map[string]string{"error": "no pipeline " + in.Pipeline}) + case validateVerbKey: + var in meshwants.ValidateInput + _ = json.Unmarshal(raw, &in) + verbs = append(verbs, in) + return json.Marshal(meshwants.ValidateAnswer{Outcome: meshwants.ValidateAnswerOutcomePassed}) + } + return nil, errors.New("no such verb " + key) + } + tool := validateTools(ask)[0] + if d := strings.ToLower(tool.Description); tool.Name != validateTool || !strings.Contains(d, "judge a manifest on request") || !strings.Contains(d, "the manifest validator's verdict") || + !strings.Contains(d, "validate") { + t.Errorf("the tool %s says %q", tool.Name, tool.Description) + } + out, err := tool.Run(map[string]any{"pipeline": "main.12", "module": "web", "why": "before the merge"}) + if b, _ := json.Marshal(out); err != nil || !strings.Contains(string(b), `"outcome":"passed"`) || len(verbs) != 1 || + verbs[0] != (meshwants.ValidateInput{Pipeline: "main.12", Candidate: "main.12", Module: "web", Why: "before the merge"}) { + t.Errorf("a known pipeline answered %s, %v and called the verb with %+v", out, err, verbs) + } + out, err = tool.Run(map[string]any{"pipeline": "main.99", "why": "why"}) + if a, _ := out.(meshwants.ValidateAnswer); err != nil || a.Outcome != meshwants.ValidateAnswerOutcomeCouldNotRun || len(verbs) != 1 { + t.Errorf("an unknown pipeline answered %+v, %v and called the verb %d times", out, err, len(verbs)) + } + if _, err := tool.Run(map[string]any{"pipeline": "main.12"}); err == nil || len(verbs) != 1 { + t.Errorf("a call with no why answered %v and called the verb", err) + } } diff --git a/modules/mesh-delivery-assigner/manifest_test.go b/modules/mesh-delivery-assigner/manifest_test.go index 4609a876c..0bd006b07 100644 --- a/modules/mesh-delivery-assigner/manifest_test.go +++ b/modules/mesh-delivery-assigner/manifest_test.go @@ -116,7 +116,7 @@ func TestManifest(t *testing.T) { // which lists and asks again what each node's engine reads. if !slices.Equal(m.Tools, []string{"assigner_put", "assigner_release", "assigner_puts", "assigner_waits", "assigner_inputs", "assigner_inputs_drop", "assigner_compositions", "assigner_compositions_drop", "assignments", "seat-holders", "wants", "asks", "assigner_read_assignments", "assigner_read_seat_holders", "assigner_read_wants", "assigner_read_findings", "assigner_read_differences", "assigner_read_copies", - "assigner_first_views", "assigner_first_view_again", "assigner_engine_reads", "assigner_seat_list", "assigner_seat_list_again", "assigner_ask_again", "assigner_written", "assigner_why", "assigner_want_drop", "assigner_assignment_drop", "assigner_asks", "assigner_ask_drop", "assigner_keep_now", "assigner_validate_before"}) { + "assigner_first_views", "assigner_first_view_again", "assigner_engine_reads", "assigner_seat_list", "assigner_seat_list_again", "assigner_ask_again", "assigner_written", "assigner_why", "assigner_want_drop", "assigner_assignment_drop", "assigner_asks", "assigner_ask_drop", "assigner_keep_now", "assigner_validate_before", "assigner_validate"}) { t.Errorf("the assigner serves tools %v, want its three put tools, three first views, six read tools, assigner_engine_reads, the seat list's two (ADR 0636 §7) assigner_ask_again (ADR 0668 §5), assigner_why (design 47 G A-439) and assigner_assignment_drop after assigner_want_drop (design 47 H2 H-A-509)", m.Tools) } if m.RunsAs != m.Module || m.SecretsOwner != m.RunsAs { @@ -164,6 +164,7 @@ func TestManifest(t *testing.T) { "seat:mesh-conditions.conditions", // design 47 G §706: the conditions read at each judging of an outside wait "seat:mesh-delivery.source", // §507: the branches the gate keeps a source revision of, before the first registrations "seat:mesh-hand-acts.hand-act", "seat:mesh-hand-acts.hand-acts", "seat:mesh-hand-acts.warranted", // ADR 0565 §9, §11: the seat alone + "seat:mesh-pipeline-runner.show", // design 47 H2 H-A-684 (1), H-A-739: the candidate of the pipeline assigner_validate judges "seat:node-backup.backed-up", "seat:node-backup.now", "seat:node-build-go.accept.check", // A-231 "seat:node-build-go.answer", // A-254, H-A-412: a composition run's answer over the inline bound, read through the build seat's verb answer diff --git a/modules/mesh-delivery-assigner/module.json b/modules/mesh-delivery-assigner/module.json index 869699938..6b982ca94 100644 --- a/modules/mesh-delivery-assigner/module.json +++ b/modules/mesh-delivery-assigner/module.json @@ -81,6 +81,7 @@ "seat:mesh-hand-acts.hand-act", "seat:mesh-hand-acts.hand-acts", "seat:mesh-hand-acts.warranted", + "seat:mesh-pipeline-runner.show", "seat:node-backup.backed-up", "seat:node-backup.now", "seat:node-build-go.answer", @@ -140,7 +141,8 @@ "assigner_asks", "assigner_ask_drop", "assigner_keep_now", - "assigner_validate_before" + "assigner_validate_before", + "assigner_validate" ], "state": [ { "name": "assignments", "history": 64, "max-mib": 8 }, From fd4d28badb3e2f534bbdd2fff8afbc8757cc1433 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:35:18 +0100 Subject: [PATCH 071/141] A5 assigner-validate: the manifest claims the verb validate of the seat mesh-wants Builds: design 47 H2 H-A-727 --- modules/mesh-delivery-assigner/manifest_test.go | 2 +- modules/mesh-delivery-assigner/module.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-assigner/manifest_test.go b/modules/mesh-delivery-assigner/manifest_test.go index 0bd006b07..c3e1abd32 100644 --- a/modules/mesh-delivery-assigner/manifest_test.go +++ b/modules/mesh-delivery-assigner/manifest_test.go @@ -104,7 +104,7 @@ func TestManifest(t *testing.T) { // revision, entry and difference from its revisions kept as objects in the old section, form 1, capped at 512 MiB. if len(m.Claims) != 2 || m.Claims[0].Name != meshmoduleassigner.Seat || m.Claims[0].At() != catalogue.ScopeMesh || !slices.Equal(m.Claims[0].Serves, []string{"assignments", "proposals", "propose", "withdraw", "again", "placement"}) || - m.Claims[1].Name != meshwants.Seat || m.Claims[1].At() != catalogue.ScopeMesh || !slices.Equal(m.Claims[1].Serves, []string{"upgrade", "bus", "revision", "entry", "difference", "input", "compositions", "compositions-drop", "keep-now", "drop"}) { + m.Claims[1].Name != meshwants.Seat || m.Claims[1].At() != catalogue.ScopeMesh || !slices.Equal(m.Claims[1].Serves, []string{"upgrade", "bus", "revision", "entry", "difference", "input", "compositions", "compositions-drop", "validate", "keep-now", "drop"}) { t.Errorf("the assigner claims %+v, want mesh-module-assigner with its five verbs and mesh-wants with its five", m.Claims) } if len(m.Objects) != 1 || m.Objects[0].Name != "assignment-revisions" || m.Objects[0].MaxMiB != 512 || m.Objects[0].Form != 1 { diff --git a/modules/mesh-delivery-assigner/module.json b/modules/mesh-delivery-assigner/module.json index 6b982ca94..78d76c7e9 100644 --- a/modules/mesh-delivery-assigner/module.json +++ b/modules/mesh-delivery-assigner/module.json @@ -29,6 +29,7 @@ "input", "compositions", "compositions-drop", + "validate", "keep-now", "drop" ] From 9b264704f974b3536bb8a0a6fc1be60146478293 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:35:37 +0100 Subject: [PATCH 072/141] P2 held-step-said: the held step keeps held-at; wait-held, wait-ended and stands carry the stalled-bound and clock-from = held-at Builds: design 47 H2 H-A-599, H-A-736 (1), H-A-738 (2) --- .../cmd/mesh-delivery-pipeline-tools/main.go | 2 +- .../cmd/mesh-delivery-pipeline/main.go | 1 + .../internal/pipeline/endopen_test.go | 15 ++++++++-- .../internal/pipeline/read.go | 10 +++++-- .../internal/pipeline/read_test.go | 29 +++++++++++++++++++ .../internal/pipeline/steps.go | 14 +++++++++ .../internal/pipeline/supersede.go | 3 +- 7 files changed, 68 insertions(+), 6 deletions(-) diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main.go index 6404b644a..1adb35a30 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline-tools/main.go @@ -176,7 +176,7 @@ func main() { } fill := StoresFill(func(n string) (*stdio.StateInfo, error) { return stdio.State(n).Info() }, func(n string) (*stdio.LogInfo, error) { return stdio.Log(n).Info() }, time.Now) - r := pipeline.Reads{Pipelines: kept{stdio.State(seat.StatePipelines)}, Kept: kept{stdio.State(seat.StateKept)}, Fill: fill} + r := pipeline.Reads{Pipelines: kept{stdio.State(seat.StatePipelines)}, Kept: kept{stdio.State(seat.StateKept)}, Fill: fill, StalledBound: stalledBound} tools := append(Tools(r), FirstViewTools(os.Getenv(stdio.ServedAs), stdio.State(views.StatusState), meshhandactsclient.Recorder{Ask: stdio.Ask}, time.Now)...) tools = append(tools, UnloggedTools(stdio.State(seat.StatePipelines), stdio.Log(seat.StateStepLog), meshhandactsclient.Recorder{Ask: stdio.Ask}, func(f string, a ...any) { fmt.Fprintf(os.Stderr, "[mesh-delivery-pipeline-tools] "+f+"\n", a...) })...) diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go index e8418b4e8..a7b5812fb 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/main.go @@ -172,6 +172,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro if err != nil { return err } + hearer.StalledBound = stalledBound // the held step's wait is timed by it (H-A-738 (2)) logger.Printf("health: a running pipeline with nothing open and nothing newly placed, or a step whose ask is untaken, is named after %s (%s)", stalledBound, pipeline.StalledBoundSetting) // Its asking half (§22, §24): a pipeline's steps are placed from the module's registration and each build seat is asked // for its step. diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go index 8ee35b946..49ec419e3 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/endopen_test.go @@ -208,6 +208,7 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { Movers: slices.Clone(movers[:2]), Steps: []seat.StepResult{step("a", seat.StepResultOutcomeRunning, "x1"), step("b", seat.StepResultOutcomeRunning, "x2")}}, rev: 1}} var put []Asked var journal []string + var waitBodies []seat.Wait var waits []string // the waits said, by event and what they wait on (H-A-563) var started []seat.StepEvent view := r.view @@ -220,11 +221,12 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { if strings.Contains(subject, seat.EventWaitEnded) { ev = seat.EventWaitEnded } + waitBodies = append(waitBodies, w) waits = append(waits, ev+" "+w.Step+" "+w.On+" "+w.Module) } return nil } - h := &Hearer{Store: store, Say: say, Now: func() time.Time { return t0 }, Name: "mesh-delivery-pipeline", + h := &Hearer{Store: store, Say: say, Now: func() time.Time { return t0 }, Name: "mesh-delivery-pipeline", StalledBound: time.Minute, View: func(string) (Half, bool) { return Half{Revision: view, Source: view, Entries: map[string]catalog.CatalogEntry{"a": {Module: "a", Fp: "src2:a2"}}}, true }, @@ -269,6 +271,9 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { len(put) != 0 || p.Outcome != seat.PipelineOutcomeRunning { t.Fatalf("superseded %v, a's build %+v, put %+v; want the build waiting on the revision view for revision 120, nothing asked", p.Superseded, s, put) } + if s := p.Steps[0]; s.HeldAt == nil || !s.HeldAt.Equal(t0) { + t.Errorf("the held step keeps held-at %v, want %v", s.HeldAt, t0) + } if want := []string{seat.EventWaitHeld + " build revision view a"}; !slices.Equal(waits, want) { t.Errorf("waits said %q, want %q", waits, want) } @@ -281,12 +286,18 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) { if moved := h.RevisionHeld("main"); !slices.Equal(moved, []string{"main.117"}) { t.Errorf("at revision 120 the view moved %v, want main.117", moved) } - if p, _, _ := store.Get("main.117"); !left(p) || p.Steps[0].On != "" || p.Outcome != seat.PipelineOutcomeRunning { + if p, _, _ := store.Get("main.117"); !left(p) || p.Steps[0].On != "" || p.Steps[0].HeldAt != nil || p.Outcome != seat.PipelineOutcomeRunning { t.Errorf("after the view held 120: superseded %v, a's build %+v, pipeline %s; want a left, b still running", p.Superseded, p.Steps[0], p.Outcome) } if want := []string{seat.EventWaitHeld + " build revision view a", seat.EventWaitEnded + " build revision view a"}; !slices.Equal(waits, want) { t.Errorf("waits said %q, want %q", waits, want) } + // H-A-599, H-A-738 (2): each carries the runner's stalled-bound and the time the step was held; none outlives the hold. + for _, w := range waitBodies { + if w.Bound != "1m0s" || w.ClockFrom == nil || !w.ClockFrom.Equal(t0) { + t.Errorf("a wait said with bound %q and clock-from %v, want 1m0s and %v", w.Bound, w.ClockFrom, t0) + } + } } }) } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/read.go b/modules/mesh-delivery-pipeline/internal/pipeline/read.go index 160796b11..4b2479320 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/read.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/read.go @@ -29,6 +29,8 @@ type Reads struct { // Fill is each of the runner's stores' fill now, pipelines, kept and step-log, read through the bundle's calls // (the state's `mesh/state.info`, the object store's and the log's fill; design 47 G §366, §623, A-214); nil says none. Fill func() ([]seat.Fill, error) + // StalledBound is the runner's setting stalled-bound, the bound of a held step's wait (H-A-599, H-A-738 (2)). + StalledBound time.Duration } // fills is the stores' fill, or an error saying it could not be read: an answer never leaves it out unsaid. @@ -345,9 +347,13 @@ func (r Reads) Stands() (seat.StandsAnswer, error) { continue } m, _ := MoverOf(p, s.Module) - out = append(out, seat.Wait{Pipeline: p.Pipeline, Module: m.Module, Branch: p.Branch, Commit: m.Commit, + w := seat.Wait{Pipeline: p.Pipeline, Module: m.Module, Branch: p.Branch, Commit: m.Commit, Run: p.Run, Source: p.Source, Revision: p.Revision, Fingerprint: m.Fingerprint, Step: s.Step, - Artifact: s.Artifact, On: s.On, Since: *s.Started, V: 1, Ask: askOfWait(s), Shared: sharedOfWait(s)}) + Artifact: s.Artifact, On: s.On, Since: *s.Started, V: 1, Ask: askOfWait(s), Shared: sharedOfWait(s)} + if s.On == seat.WaitOnRevisionView && s.HeldAt != nil { // the held step's wait is timed from its hold (H-A-599, H-A-738 (2)) + w.Bound, w.ClockFrom = boundOf(r.StalledBound), s.HeldAt + } + out = append(out, w) } } sort.SliceStable(out, func(i, j int) bool { return out[i].Since.Before(out[j].Since) }) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go index cb9e3aeb3..fb2a9e81c 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/read_test.go @@ -384,3 +384,32 @@ func TestAPipelineIsReadInParts(t *testing.T) { t.Fatalf("words %q", got) } } + +// Design 47 H2 H-A-599, H-A-738 (2): a held step stands with the runner's stalled-bound and the time it was held, so the watchman's +// seed from stands times it as the wait-held did, also after a restart. +func TestStandsNamesTheBoundAndClockOfAHeldStep(t *testing.T) { + f := newRunFixture() + p := f.start(t, 4, 9) + held := time.Date(2026, 11, 25, 12, 0, 0, 0, time.UTC) + pl := f.pipeline(p) + for i := range pl.Steps { + if pl.Steps[i].Step == "unit" && pl.Steps[i].Artifact == "app:program" { + pl.Steps[i].Outcome, pl.Steps[i].On, pl.Steps[i].Revision, pl.Steps[i].HeldAt = seat.StepResultOutcomeWaiting, seat.WaitOnRevisionView, 12, &held + } + } + pipes := memKept{} + put(t, pipes, p.Pipeline, pl) + a, err := Reads{Pipelines: pipes, Kept: memKept{}, StalledBound: time.Minute}.Stands() + if err != nil { + t.Fatal(err) + } + for _, w := range a.Stands { + if w.Artifact == "app:program" && w.Step == "unit" { + if w.Bound != "1m0s" || w.ClockFrom == nil || !w.ClockFrom.Equal(held) { + t.Errorf("the held step stands with bound %q and clock-from %v, want 1m0s and %v", w.Bound, w.ClockFrom, held) + } + return + } + } + t.Error("the held step does not stand") +} diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go index cf9476176..1f78a2d91 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go @@ -157,6 +157,8 @@ type Hearer struct { // Asker publishes an approval step's ask (§37); Name is the runner's own name, the asker a warrant names. Asker Asker Name string + // StalledBound is the runner's setting stalled-bound (§790): the bound of a held step's wait, given at the start (H-A-738 (2)). + StalledBound time.Duration // Where reads the router's record of one of the runner's asks, as operatorchannelclient.Client.Where does: its state and // its warrant (design 47 G A-89, §700). Where func(ask string) (string, *oc.Warrant, error) @@ -391,6 +393,8 @@ func (h *Hearer) OnStepEndedRevised(bs StepSeat, subject string, ev StepEnded, s case superseding > own && !h.viewHolds(p.Branch, superseding): old := s.Ask s.Outcome, s.On, s.Revision, s.Node, s.Why = seat.StepResultOutcomeWaiting, seat.WaitOnRevisionView, superseding, node, ev.Said + held := h.now() + s.HeldAt = &held // when the step was held: the clock of its wait (H-A-599, H-A-738 (2)) if _, err := h.Store.Update(ev.Pipeline, p, rev); errors.Is(err, ErrChanged) { continue } else if err != nil { @@ -411,6 +415,7 @@ func (h *Hearer) OnStepEndedRevised(bs StepSeat, subject string, ev StepEnded, s ev.Outcome, ev.Said = nodebuildgo.StepEndedOutcomeCouldNotRun, fmt.Sprintf("the builder on %s ended it superseded: a superseded end without its revision (%s)", node, ev.Said) } s.Outcome, s.Node, s.Why, s.Rerun, s.By, s.Ended = ev.Outcome, node, ev.Said, ev.Rerun, ev.By, &now + s.HeldAt = nil // the hold ends with the step (H-A-738 (2)) if len(shared) > 0 { s.Shared = shared } @@ -761,6 +766,7 @@ func (h *Hearer) say(event string, p seat.Pipeline, step *seat.StepResult) error w.Module, w.Commit, w.Fingerprint, w.Step, w.Ask = m.Module, m.Commit, m.Fingerprint, step.Step, step.Ask if step.On == seat.WaitOnRevisionView { // a build waiting for the revision that superseded it (H-A-563) w.On = step.On + w.Bound, w.ClockFrom = boundOf(h.StalledBound), step.HeldAt // timed from its hold by the stalled bound (H-A-599, H-A-736 (1)) } } return h.Say(runnerclient.RevisionSubject(event, p.Branch, subjectRevision(p)), w) @@ -1128,3 +1134,11 @@ func sameValidate(p *seat.Pipeline, i int, now time.Time) []int { } return out } + +// boundOf is a bound as a wait names it, a Go duration such as 5m0s; empty for none. +func boundOf(d time.Duration) string { + if d <= 0 { + return "" + } + return d.String() +} diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go b/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go index f2c7858e9..de358ce92 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/supersede.go @@ -214,6 +214,7 @@ func supersedeStep(p *seat.Pipeline, st *seat.StepResult, why string, now time.T drop = append(drop, *st) // its own ask on a build node: the seat's drop cancels it } st.Outcome, st.Why, st.Ended = seat.StepResultOutcomeSuperseded, why, &now + st.HeldAt = nil p.Unlogged = append(p.Unlogged, endEntry(p.Pipeline, *st, now)) return leave, drop } @@ -405,7 +406,7 @@ func (h *Hearer) revisionHeldOne(key string, held int64) bool { waited = append(waited, *st) // its wait-ended is said as it was held (H-A-563) } why := fmt.Sprintf("superseded: its build was superseded and its mover left for the newer revision's pipeline, revision %d now held (H-A-508, H-A-562): %s", held, whys[st.Module]) - st.On, st.Revision = "", 0 + st.On, st.Revision, st.HeldAt = "", 0, nil l, d := supersedeStep(&p, st, why, now) leave, drop = append(leave, l...), append(drop, d...) ended = append(ended, i) From 4f8e850512ea9991c2ef176ebcbef6b002e4b604 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:36:19 +0100 Subject: [PATCH 073/141] A4 engine-need-refused: a mover claiming the seat node-engine whose entry needs a capability no node's words hold is refused manifest-refused, counted as new Builds: design 47 H2 H-A-682 (5) --- .../mesh-delivery-assigner/compositionrun.go | 3 + .../cmd/mesh-delivery-assigner/main.go | 2 +- .../mesh-delivery-assigner/validatestep.go | 75 ++++++++++++++++++- .../validatestep_test.go | 23 ++++++ 4 files changed, 98 insertions(+), 5 deletions(-) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go index 4157c3b7f..c755cbb56 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/compositionrun.go @@ -64,6 +64,9 @@ type compositionRun struct { readsBound time.Duration // holder is the module holding a seat and the machines it runs on, for the words of a read that met a fault; nil: none named. holder func(seat string) (module string, nodes []string) + // engineReads is what each node's engine states it reads (the state engine-reads), for the validate run's refusal of a node-engine + // that needs what none states (design 47 H2 H-A-682 (5)); nil: none is judged. + engineReads *engineReadsKept // readMu guards inflight, the reads now waiting by seat verb, and raised, the seat verbs whose finding call-unanswered this // process wrote (H-A-708 (4)). readMu sync.Mutex diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go index 5f4ffbed2..f14701b46 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main.go @@ -694,7 +694,7 @@ func follow(ctx context.Context, js jetstream.JetStream, nc process.Subscriber, if err != nil { return err } - run := &compositionRun{runs: runs, inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFileKept, bound: askBound}, keeper: inputs, reads: &compositionReads{}, call: bus.CallKeptAsk, callFile: bus.CallFileKept, readsBound: readsBound, holder: holderOf(bus, w), + run := &compositionRun{runs: runs, inputs: &compositionInputs{machines: w.machinesOf, callFile: bus.CallFileKept, bound: askBound}, keeper: inputs, reads: &compositionReads{}, call: bus.CallKeptAsk, callFile: bus.CallFileKept, readsBound: readsBound, holder: holderOf(bus, w), engineReads: reads, trunk: trunkOf(iv, w.trunkName), newest: iv.newestOf(), watched: iv.watchedOf, assigned: w.assignedOn, assignment: w.assignmentOf, findings: findings, running: w.runningOf, away: func(machine string) bool { return w.awayNow()[machine] }, put: runAskPublisher(js), own: ctx, ask: bus.CallFile, now: time.Now, logf: logger.Printf} // The seat's work queue (design 47 H2 §777): pulled through its one worker, each ask taken once in the state taken. takenBound, err := askTakenBound() diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go index 0e77e4a7b..280fdd5ee 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep.go @@ -13,6 +13,7 @@ import ( "slices" "strings" + ne "git.novox.be/novox/mesh-contracts/go/seats/nodeengine" "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient" mcc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient" meshcatalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" @@ -127,7 +128,11 @@ func (r *compositionRun) judgeValidate(ctx context.Context, step meshwants.StepR if half.Revision.Base <= 0 { empty = emptyBeforeWords } - if problems := causedProblems(v.Change, v.Before); len(problems) > 0 { + problems := causedProblems(v.Change, v.Before) + for _, p := range r.engineNeedProblems(half)[step.Module] { // H-A-682 (5): the node-engine's own build is refused, never held + problems = append(problems, step.Module+": "+p) + } + if len(problems) > 0 { said := reasonManifestRefused + ": " + strings.Join(problems, "; ") if empty != "" { said += " (" + empty + ")" @@ -137,6 +142,58 @@ func (r *compositionRun) judgeValidate(ctx context.Context, step meshwants.StepR return stepOutcome{Outcome: meshwants.StepEndedOutcomePassed, Said: empty} } +// engineNeedProblems are, by module, the problems of the revision's entries that claim the seat node-engine and need a reader capability +// that no node's words in the state engine-reads hold: such an engine would be held on every machine and none could state it, so its +// validate run refuses it (design 47 H2 H-A-682 (5)), counted as a new problem. None while no node's words are held. +func (r *compositionRun) engineNeedProblems(half mcc.Half) map[string][]string { + if r.engineReads == nil { + return nil + } + var stated []string + nodes := r.engineReads.nodes() + for _, node := range nodes { + words, _ := r.engineReads.words(node) + stated = append(stated, words...) + } + if len(nodes) == 0 { + return nil + } + out := map[string][]string{} + for module, e := range half.Entries { + if !claimsSeat(e.Manifest, ne.Seat) { + continue + } + for _, need := range e.Needs { + if !slices.Contains(stated, need) { + out[module] = append(out[module], "needs "+need+", which no node-engine states") + } + } + slices.Sort(out[module]) + } + return out +} + +// claimsSeat says whether a manifest, as the catalog entry keeps it, claims the seat. +func claimsSeat(manifest map[string]any, seat string) bool { + raw, err := json.Marshal(manifest) + if err != nil { + return false + } + var m struct { + Claims []struct { + Name string `json:"name"` + } `json:"claims"` + } + if json.Unmarshal(raw, &m) != nil { + return false + } + return slices.ContainsFunc(m.Claims, func(c struct { + Name string `json:"name"` + }) bool { + return c.Name == seat + }) +} + // emptyBeforeWords say, in a validate step's end, that its revision names no base: the branch's first take-in, judged against // an empty case before (H-A-151, H-A-154). const emptyBeforeWords = "the case before is empty: the revision names no base, the branch's first take-in" @@ -559,7 +616,8 @@ func (r *compositionRun) validateOnRequest(ctx context.Context, record func(mesh if in.Candidate != "" && in.Candidate != candidate { return couldNot(fmt.Sprintf("the candidate %s is not the pipeline %s's, %s", in.Candidate, pipeline, candidate)) } - if _, err := r.revision(withReadsClock(ctx), step); err != nil { + half, err := r.revision(withReadsClock(ctx), step) + if err != nil { return couldNot(fmt.Sprintf("the indexer holds no candidate %s of the pipeline %s: %v", candidate, pipeline, err)) } key, err := validateKeyOf(step) @@ -589,13 +647,13 @@ func (r *compositionRun) validateOnRequest(ctx context.Context, record func(mesh } } run.Key = key - return validateAnswerOf(run, step.Module) + return validateAnswerOf(run, step.Module, r.engineNeedProblems(half)) } // validateAnswerOf is the validate run as it stands: running with its start, or its end: passed, failed `cycle` naming the // cycle, failed `manifest-refused` with every problem per manifest (those the case before holds too marked), or could not run with // why; the problems narrowed to module when one is named (H-A-684 (1)). -func validateAnswerOf(run meshwants.CompositionRun, module string) (meshwants.ValidateAnswer, error) { +func validateAnswerOf(run meshwants.CompositionRun, module string, engine map[string][]string) (meshwants.ValidateAnswer, error) { out := meshwants.ValidateAnswer{Run: &run} if run.Ended == nil { out.Outcome, out.Started = meshwants.ValidateAnswerOutcomeRunning, run.Started @@ -634,6 +692,15 @@ func validateAnswerOf(run meshwants.CompositionRun, module string) (meshwants.Va } } } + for _, name := range slices.Sorted(maps.Keys(engine)) { // H-A-682 (5): a node-engine's needs no node-engine states + if module != "" && name != module { + continue + } + for _, p := range engine[name] { + out.Problems = append(out.Problems, meshwants.ValidateAnswerProblemsItem{Module: name, Problem: p}) + counted = true + } + } out.Outcome = meshwants.ValidateAnswerOutcomePassed if counted { out.Outcome, out.Reason = meshwants.ValidateAnswerOutcomeFailed, meshwants.ValidateAnswerReasonManifestRefused diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go index cab03b100..6f761c2e4 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/validatestep_test.go @@ -302,6 +302,29 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) { t.Errorf("the validate run's reader was said waiting %v; want mesh-sdk's publish, then a build node again at the put (H-A-632)", held) } + // H2 H-A-682 (5) (A4): a mover claiming the seat node-engine whose entry needs a capability no node's words hold ends + // manifest-refused naming it, counted as new; one that a node states is not refused for it; the verb's answer lists it. + engine := meshcatalog.CatalogEntry{Module: "engine", Fp: "src2:eng", Needs: []string{"directory-contents-owner"}, ManifestDigest: "d-eng", + Manifest: map[string]any{"module": "engine", "claims": []any{map[string]any{"name": "node-engine"}}}} + revisions[15], revisions[16] = []meshcatalog.CatalogEntry{indexer, engine}, []meshcatalog.CatalogEntry{indexer, engine} + engineStep := func(revision int64) meshwants.StepRun { + return meshwants.StepRun{Step: meshwants.StepRunStepValidate, Pipeline: "main." + string(rune('0'+revision)), Branch: "main", Module: "engine", Revision: revision, Source: revision} + } + r.engineReads = &engineReadsKept{by: map[string]engineWords{"ace": {Words: []string{"want:version"}}}} + if o := r.validate(ctx, "ask-engine", engineStep(15)); o.Outcome != meshwants.StepEndedOutcomeFailed || !strings.HasPrefix(o.Said, reasonManifestRefused+": ") || + !strings.Contains(o.Said, "engine: needs directory-contents-owner, which no node-engine states") { + t.Errorf("a node-engine needing what no node states ended %+v", o) + } + r.engineReads = &engineReadsKept{by: map[string]engineWords{"ace": {Words: []string{"want:version"}}, "g14": {Words: []string{"directory-contents-owner"}}}} + if o := r.validate(ctx, "ask-engine-2", engineStep(16)); strings.Contains(o.Said, "which no node-engine states") { + t.Errorf("a node-engine needing what g14 states ended %+v", o) + } + ended := time.Now() + passed := meshwants.CompositionRun{Started: &ended, Ended: &ended, Outcome: meshwants.CompositionRunOutcomePassed, Verdict: map[string]any{}} + if a, _ := validateAnswerOf(passed, "", map[string][]string{"engine": {"needs directory-contents-owner, which no node-engine states"}}); a.Outcome != meshwants.ValidateAnswerOutcomeFailed || + len(a.Problems) != 1 || a.Problems[0].Before || a.Problems[0].Module != "engine" { + t.Errorf("the verb's answer for a node-engine needing what none states is %+v", a) + } // H2 H-A-684, H-A-702, H-A-727, H-A-739 (A5): the verb validate, which the tool assigner_validate calls, joins or starts the run. var acts []meshhandactsclient.Request record := func(q meshhandactsclient.Request) error { acts = append(acts, q); return nil } From f1f2d352e5cd3b23915a1bf3c931ed9988d99f6f Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:36:32 +0100 Subject: [PATCH 074/141] I7 failed-record: a mover not delivered at a failed or cancelled end, or named in unfinished, pins its entry's revision and that revision's base under failed.., freed when it passes, a newer revision moves it or its module or branch leaves the registrations Builds: design 47 H2 H-A-566, H-A-572 (1) (2), H-A-595, H-A-608, H-A-649 (af09bb9a taken as new code, H-A-565 (2) (3) not) --- .../cmd/mesh-delivery-indexer/main.go | 6 + .../internal/index/pins.go | 241 +++++++++++++++++- .../internal/index/pins_test.go | 81 +++++- 3 files changed, 325 insertions(+), 3 deletions(-) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go index df3617cd5..dedbddff3 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -649,6 +649,12 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro hear(meshcatalog.StreamRegistrationChanged, "a newly watched branch's source revisions are not taken in until the indexer starts again", func(m jetstream.Msg) { _ = m.Ack() sources.refresh() + // A module that left the registrations, or a branch that left its registration, frees its failed record (H-A-572 (2)). + if registered, err := registry.RegisteredFailedRecords(ctx); err != nil { + logger.Printf("the failed records are not freed after a registration changed: %v", err) + } else if err := ix.FreeFailedRecords(ctx, registered); err != nil { + logger.Printf("the failed records are not freed after a registration changed: %v", err) + } }) // The held take-ins are taken in again from the state held at the start, before a branch's consumer gives a later one // (design 47 H, H-A-114, H-A-118); a chain's key a stop left is deleted first (H2 H-A-497 addendum). diff --git a/modules/mesh-delivery-indexer/internal/index/pins.go b/modules/mesh-delivery-indexer/internal/index/pins.go index eb29829b2..48cc0b60a 100644 --- a/modules/mesh-delivery-indexer/internal/index/pins.go +++ b/modules/mesh-delivery-indexer/internal/index/pins.go @@ -22,7 +22,8 @@ import ( // The indexer keeps the records pinning each catalog graph revision and removes a revision only on an event (design 47 G §153, // §178, §189, §215, §216, §579, A-169, A-171): its state pins holds one key per revision, `.` (the watched branch // and the revision's number, the branch escaped as a name is), whose value lists the records that pin it: a take-in's, each -// running pipeline's (design 47 H §743, §749) and each passed pipeline's release until a newer one is the want (H-A-168, H-A-170). +// running pipeline's (design 47 H §743, §749), each passed pipeline's release until a newer one is the want (H-A-168, H-A-170), +// and each failed pipeline's mover that did not pass until it passes or a newer revision moves it (H2 H-A-565, H-A-566). const ( // PinsState is the state's name; PinsCapMiB is its cap in the manifest (about 1,800 keys of about 0.2 KiB). PinsState = "pins" @@ -74,7 +75,9 @@ func pinObject(key string) (string, bool) { // HeardPins applies one event of the seat mesh-pipeline-runner the indexer's durable consumers gave it (design 47 H §749): a // pipeline-started pins the revision it names, and each revision its movers are kept at (design 47 H2 H-A-496), under the -// record `pipeline.`, its pipeline-ended frees it and every other revision the record pins (H-A-147). A body +// record `pipeline.`, its pipeline-ended frees it and every other revision the record pins (H-A-147); a failed +// one first pins them under `failed..` for each mover that did not pass, freed when the mover passes in a +// later pipeline or a pipeline of a newer revision moves it (H-A-565 (1), H-A-566). A body // that is no such event, or names no revision, changes nothing; an error leaves the event unacknowledged, so the bus gives it // again; one applied twice changes nothing. func (ix *Indexer) HeardPins(ctx context.Context, started *runner.PipelineStarted, ended *runner.PipelineEnded) error { @@ -94,6 +97,16 @@ func (ix *Indexer) HeardPins(ctx context.Context, started *runner.PipelineStarte if err := ix.pinKept(ctx, started.Branch, started.Revision, started.Kept, record); err != nil { return err } + // A delivering pipeline of a newer revision that moves a mover a failed pipeline left, carried or at a newer + // fingerprint, frees that mover's failed record from every older revision of the branch: its own pin covers it now + // (design 47 H2 H-A-565 (1), H-A-566). + if started.Run == "" { + for _, m := range started.Movers { + if err := ix.unpinOlder(ctx, started.Branch, started.Revision, FailedRecord(started.Branch, m.Module)); err != nil { + return err + } + } + } // The reservations of the pipeline's revision settle at its start, if they gather (design 47 H2 §805, H-A-424 (1)). if err := ix.Settle(ctx, BranchObject(started.Branch, started.Revision)); err != nil { ix.logf("versions: the reservations of %s are not re-pinned at its pipeline-started: %v", BranchObject(started.Branch, started.Revision), err) @@ -125,6 +138,24 @@ func (ix *Indexer) HeardPins(ctx context.Context, started *runner.PipelineStarte } } record := PipelineRecord(ended.Pipeline) + if ended.Run == "" { + // A mover that passed frees its failed record from every older revision of the branch; a delivering pipeline that + // ended failed keeps its own revision and each kept revision its record pins under failed.. for + // each mover that did not pass, before its own record is freed, so a rerun or a carry still reads them (design 47 + // H2 H-A-565 (1), H-A-566). + for _, m := range ended.Movers { + if ended.Outcome == runner.PipelineEndedOutcomePassed || moverPassed(m) { + if err := ix.unpinOlder(ctx, ended.Branch, ended.Revision, FailedRecord(ended.Branch, m.Module)); err != nil { + return err + } + } + } + if ended.Outcome == runner.PipelineEndedOutcomeFailed || ended.Outcome == runner.PipelineEndedOutcomeCancelled { + if err := ix.pinFailed(ctx, ended, record); err != nil { + return err + } + } + } if err := ix.unpin(ctx, PinKey(ended.Branch, ended.Revision), record); err != nil { return err } @@ -139,6 +170,212 @@ func ReleaseRecord(branch, module string) string { return "release." + keys.EscapeName(branch) + "." + keys.EscapeName(module) } +// FailedRecord is the record a failed pipeline pins its own and its kept revisions under, one per mover that did not pass: +// `failed..`, each name escaped as a key's name is (design 47 H2 H-A-565 (1), H-A-566). +func FailedRecord(branch, module string) string { + return "failed." + keys.EscapeName(branch) + "." + keys.EscapeName(module) +} + +// moverPassed says whether a mover of a pipeline-ended passed: it holds steps and each required one passed, was carried or +// had nothing to run, as the runner counts a step passed. +func moverPassed(m runner.MoverEnded) bool { + if len(m.Steps) == 0 { + return false + } + for _, s := range m.Steps { + if s.Status != runner.StepResultStatusRequired { + continue + } + switch s.Outcome { + case runner.StepResultOutcomePassed, runner.StepResultOutcomeCarried, runner.StepResultOutcomeNothingToRun: + default: + return false + } + } + return true +} + +// movedOut says whether a mover of a pipeline-ended left it for a newer revision: a required step of it is superseded. +func movedOut(m runner.MoverEnded) bool { + return slices.ContainsFunc(m.Steps, func(s runner.StepResult) bool { + return s.Status == runner.StepResultStatusRequired && s.Outcome == runner.StepResultOutcomeSuperseded + }) +} + +// pinFailed pins, for each mover a pipeline-ended that failed or was cancelled did not deliver (a mover with a required +// step that did not pass, and each module its `unfinished` names, not one moved out of it for a newer revision), the revision +// the mover's entry comes from and that revision's `base`, under the mover's failed record: the kept revision the mover's +// entry is at, else the pipeline's own (design 47 H2 H-A-566, H-A-572 (1), H-A-595, H-A-608). At most two revisions per record. +func (ix *Indexer) pinFailed(ctx context.Context, ended *runner.PipelineEnded, record string) error { + var failed []string + fingerprint := map[string]string{} + for _, m := range ended.Movers { + fingerprint[m.Module] = m.Fingerprint + if !moverPassed(m) && !movedOut(m) { + failed = append(failed, m.Module) + } + } + for _, module := range ended.Unfinished { + if !slices.Contains(failed, module) { + failed = append(failed, module) + } + } + if len(failed) == 0 { + return nil + } + slices.Sort(failed) + pinKeys, err := ix.Pins.Keys(ctx) + if err != nil { + return err + } + slices.Sort(pinKeys) + var kept []int64 // the revisions the pipeline's record pins above its own: where its movers are kept + for _, k := range pinKeys { + b, r, ok := ParsePinKey(k) + if !ok || b != ended.Branch || r <= ended.Revision { + continue + } + v, _, found, err := ix.Pins.Get(ctx, k) + if err != nil { + return err + } + var pv PinValue + if found && json.Unmarshal(v, &pv) == nil && slices.Contains(pv.Records, record) { + kept = append(kept, r) + } + } + slices.Reverse(kept) // the newest first + for _, module := range failed { + at := ended.Revision + for _, r := range kept { + if ix.entryAt(ctx, ended.Branch, r, module) == fingerprint[module] && fingerprint[module] != "" { + at = r + break + } + } + revisions := []string{PinKey(ended.Branch, at)} + if base := ix.baseOf(ctx, ended.Branch, at); base > 0 && base != at { + revisions = append(revisions, PinKey(ended.Branch, base)) + } + for _, k := range revisions { + if err := ix.pin(ctx, k, FailedRecord(ended.Branch, module)); err != nil { + // A write the full state refuses is said, and the event is left unacknowledged so the bus gives it again at its + // kept-call pace (H-A-572 (1)). + ix.logf("pins: %s is not written to %s, so %s is heard again: %v", FailedRecord(ended.Branch, module), k, ended.Pipeline, err) + return err + } + } + ix.logf("pins: %s ended %s: %s keeps %s until it passes in a later pipeline or a newer revision moves it (H-A-566, H-A-608)", + ended.Pipeline, ended.Outcome, FailedRecord(ended.Branch, module), strings.Join(revisions, ", ")) + } + return nil +} + +// entryAt is the fingerprint of module's entry in revision r of branch, empty when the revision or the entry is not read. +func (ix *Indexer) entryAt(ctx context.Context, branch string, r int64, module string) string { + _, entries, err := ReadRevision(ctx, ix.Revisions, RevisionObject(meshcatalog.CatalogRevision{Branch: branch, Revision: r})) + if err != nil { + return "" + } + for _, e := range entries { + if e.Module == module { + return e.Fp + } + } + return "" +} + +// baseOf is the revision revision r of branch names as its base (H-A-151), zero when it names none or is not read. +func (ix *Indexer) baseOf(ctx context.Context, branch string, r int64) int64 { + rev, _, err := ReadRevision(ctx, ix.Revisions, RevisionObject(meshcatalog.CatalogRevision{Branch: branch, Revision: r})) + if err != nil { + return 0 + } + return rev.Base +} + +// FreeFailedRecords frees every failed record (`failed..`) from every pin that holds it when no registration +// of its module names its branch any more: the module left the registrations, or, until a change of a module's branch is a +// take-in of that branch's head for that module alone, its branch left the module's registration. registered says the +// registrations as a set of records (design 47 H2 H-A-572 (2), heard on registration-changed, ADR 0666 section 2). +func (ix *Indexer) FreeFailedRecords(ctx context.Context, registered map[string]bool) error { + pinKeys, err := ix.Pins.Keys(ctx) + if err != nil { + return err + } + for _, k := range pinKeys { + v, _, found, err := ix.Pins.Get(ctx, k) + if err != nil { + return err + } + var pv PinValue + if !found || json.Unmarshal(v, &pv) != nil { + continue + } + for _, record := range pv.Records { + if strings.HasPrefix(record, "failed.") && !registered[record] { + if err := ix.unpin(ctx, k, record); err != nil { + return err + } + ix.logf("pins: %s is freed from %s: its module is no longer registered on that branch (H-A-572 (2))", record, k) + } + } + } + return nil +} + +// RegisteredFailedRecords are the failed records every registration of the registry names, one per module and branch. +func (r *Registry) RegisteredFailedRecords(ctx context.Context) (map[string]bool, error) { + all, err := r.Registrations.Keys(ctx) + if err != nil { + return nil, err + } + out := map[string]bool{} + for _, k := range all { + v, _, found, err := r.Registrations.Get(ctx, k) + if err != nil { + return nil, err + } + var reg meshcatalog.Registration + if !found || json.Unmarshal(v, ®) != nil { + continue + } + if reg.Module == "" { + return nil, fmt.Errorf("the registration %s names no module, so no failed record is freed by this read", k) + } + for _, b := range reg.Branches { + out[FailedRecord(b, reg.Module)] = true + } + } + return out, nil +} + +// unpinOlder frees record from every revision of branch older than revision (H-A-566). +func (ix *Indexer) unpinOlder(ctx context.Context, branch string, revision int64, record string) error { + pinKeys, err := ix.Pins.Keys(ctx) + if err != nil { + return err + } + for _, k := range pinKeys { + b, r, ok := ParsePinKey(k) + if !ok || b != branch || r >= revision { + continue + } + v, _, found, err := ix.Pins.Get(ctx, k) + if err != nil { + return err + } + var pv PinValue + if !found || json.Unmarshal(v, &pv) != nil || !slices.Contains(pv.Records, record) { + continue + } + if err := ix.unpin(ctx, k, record); err != nil { + return err + } + } + return nil +} + // HeardPipelineWanted applies one pipeline-wanted of the seat mesh-wants, said when a pipeline's wants are written to the end // (design 47 H §751, H-A-168, H-A-170, H-A-173, H-A-174). Outcome running: a module whose release record the pipeline's own // kept revision holds released its newer version there, and that is the want everywhere, so the module's record is freed from diff --git a/modules/mesh-delivery-indexer/internal/index/pins_test.go b/modules/mesh-delivery-indexer/internal/index/pins_test.go index f8c203b0b..706fe6ebe 100644 --- a/modules/mesh-delivery-indexer/internal/index/pins_test.go +++ b/modules/mesh-delivery-indexer/internal/index/pins_test.go @@ -52,6 +52,58 @@ func TestAPipelinesKeptRevisionsArePinnedUntilItEnds(t *testing.T) { heard(&runner.PipelineStarted{Branch: "main", Pipeline: "main.1", Revision: 1, Kept: []int64{3, 4}}, nil, "main.1", "main.3", "main.4", "main.6") heard(nil, &runner.PipelineEnded{Branch: "main", Pipeline: "main.1", Revision: 1, Outcome: runner.PipelineEndedOutcomeFailed}, "main.6") + + // H-A-565 (1), H-A-566: a failed delivering pipeline keeps its own and its kept revisions under failed.main. for + // each mover that did not pass (app failed, lib never ran; ok passed, gone was superseded); a pipeline of a newer + // revision moving lib frees lib's, app passing in a later pipeline frees app's, and only then the revisions go. + pending = 1 + for source := int64(7); source <= 10; source++ { + e := reader + e.Commit = fmt.Sprintf("c%d", source) + if err := ix.KeepBranchEntries(ctx, "main", source, map[string]meshcatalog.CatalogEntry{"reader": e}, nil); err != nil { + t.Fatal(err) + } + } + pending = 0 + step := func(outcome string) []runner.StepResult { + return []runner.StepResult{{Step: runner.StepResultStepUnit, Status: runner.StepResultStatusRequired, Outcome: outcome}} + } + heard(&runner.PipelineStarted{Branch: "main", Pipeline: "main.7", Revision: 7, Kept: []int64{8}}, nil, "main.10", "main.7", "main.8") + heard(nil, &runner.PipelineEnded{Branch: "main", Pipeline: "main.7", Revision: 7, Outcome: runner.PipelineEndedOutcomeFailed, + Movers: []runner.MoverEnded{{Module: "app", Steps: step(runner.StepResultOutcomeFailed)}, {Module: "lib", Steps: step(runner.StepResultOutcomeNotAsked)}, + {Module: "ok", Steps: step(runner.StepResultOutcomePassed)}, {Module: "gone", Steps: step(runner.StepResultOutcomeSuperseded)}}}, + "main.10", "main.7") + for _, k := range []string{"main.7"} { + if v, _, _, _ := ix.Pins.Get(ctx, k); !slices.Equal(mustRecords(t, v), []string{"failed.main.app", "failed.main.lib"}) { + t.Errorf("the pin of %s holds %s, want app's and lib's failed records", k, v) + } + } + heard(&runner.PipelineStarted{Branch: "main", Pipeline: "main.10", Revision: 10, Movers: []runner.StartedMover{{Module: "lib"}}}, nil, + "main.10", "main.7") + if v, _, _, _ := ix.Pins.Get(ctx, "main.7"); !slices.Equal(mustRecords(t, v), []string{"failed.main.app"}) { + t.Errorf("the pin of main.7 holds %s after main.10 moved lib, want app's failed record alone", v) + } + heard(nil, &runner.PipelineEnded{Branch: "main", Pipeline: "main.10", Revision: 10, Outcome: runner.PipelineEndedOutcomeFailed, + Movers: []runner.MoverEnded{{Module: "app", Steps: step(runner.StepResultOutcomePassed)}, {Module: "lib", Steps: step(runner.StepResultOutcomePassed)}}}, + "main.10") + + // H-A-595, H-A-608: a cancelled end pins as a failed one does, for a mover its `unfinished` names as for one whose step + // failed, so the revision its entry comes from stays after the pipeline's end. + pending = 1 + for source := int64(11); source <= 12; source++ { + e := reader + e.Commit = fmt.Sprintf("c%d", source) + if err := ix.KeepBranchEntries(ctx, "main", source, map[string]meshcatalog.CatalogEntry{"reader": e}, nil); err != nil { + t.Fatal(err) + } + } + pending = 0 + heard(&runner.PipelineStarted{Branch: "main", Pipeline: "main.11", Revision: 11}, nil, "main.11", "main.12") + heard(nil, &runner.PipelineEnded{Branch: "main", Pipeline: "main.11", Revision: 11, Outcome: runner.PipelineEndedOutcomeCancelled, + Unfinished: []string{"carried"}}, "main.11", "main.12") + if v, _, _, _ := ix.Pins.Get(ctx, "main.11"); !slices.Equal(mustRecords(t, v), []string{"failed.main.carried"}) { + t.Errorf("the pin of main.11 holds %s after a cancelled end naming carried unfinished, want its failed record", v) + } } // Design 47 H §749 (G §579, A-169, A-171): the indexer pins a revision on a pipeline-started that names it and frees it on its @@ -227,6 +279,7 @@ func TestATakeInPinsTheBranchsPreviousRevisionForItsPipeline(t *testing.T) { unreleased bool // its mover released no version there, so nothing pins main.5 (H-A-173) then []int64 // sources taken in with no mover after the end released []string + failed []string // main.5's mover did not pass in the failed pipeline: its failed record keeps these (H-A-565 (1), H-A-566) }{ {name: "the previous revision kept and pinned", before: []int64{3, 4}, at: 3, whileRuns: []string{"main.2", "main.3"}, afterTheEnd: []string{"main.3"}, base: 2}, {name: "the newest kept before, whatever its source", before: []int64{2}, at: 2, whileRuns: []string{"main.1", "main.2"}, afterTheEnd: []string{"main.2"}, base: 1}, @@ -237,6 +290,8 @@ func TestATakeInPinsTheBranchsPreviousRevisionForItsPipeline(t *testing.T) { base: 1, passed: true, unreleased: true, then: []int64{6}, afterTheEnd: []string{"main.3"}}, {name: "a failed pipeline's revision goes once no longer current", before: []int64{4}, at: 2, whileRuns: []string{"main.1", "main.2"}, base: 1, then: []int64{6}, afterTheEnd: []string{"main.3"}}, + {name: "a failed pipeline's mover that did not pass keeps its revisions", before: []int64{4}, at: 2, whileRuns: []string{"main.1", "main.2"}, + base: 1, then: []int64{6}, afterTheEnd: []string{"main.1", "main.2", "main.3"}, failed: []string{"main.1", "main.2"}}, } { t.Run(tc.name, func(t *testing.T) { ix := &Indexer{Module: testSelf, Revisions: newMemObjects(1 << 20), Pins: newMem(), Findings: newFindings(), @@ -273,7 +328,11 @@ func TestATakeInPinsTheBranchsPreviousRevisionForItsPipeline(t *testing.T) { } } end := runner.PipelineEnded{Branch: "main", Pipeline: at, Revision: tc.at, Outcome: runner.PipelineEndedOutcomeFailed, - Movers: []runner.MoverEnded{{Module: "reader", Fingerprint: "f", Version: "0.1.5"}}} + Movers: []runner.MoverEnded{{Module: "reader", Fingerprint: "f", Version: "0.1.5", + Steps: []runner.StepResult{{Step: runner.StepResultStepUnit, Status: runner.StepResultStatusRequired, Outcome: runner.StepResultOutcomePassed}}}}} + if tc.failed != nil { + end.Movers[0].Steps[0].Outcome = runner.StepResultOutcomeFailed + } if tc.unreleased { end.Movers[0].Version = "" } @@ -296,6 +355,9 @@ func TestATakeInPinsTheBranchsPreviousRevisionForItsPipeline(t *testing.T) { if slices.Contains(tc.released, k) { want = []string{ReleaseRecord("main", "reader")} } + if slices.Contains(tc.failed, k) { + want = []string{FailedRecord("main", "reader")} + } if v, _, _, _ := ix.Pins.Get(ctx, k); !slices.Equal(append([]string{}, mustRecords(t, v)...), want) { t.Errorf("after the pipeline's end the pin of %s holds %s, want %v", k, v, want) } @@ -304,3 +366,20 @@ func TestATakeInPinsTheBranchsPreviousRevisionForItsPipeline(t *testing.T) { }) } } + +// Design 47 H2 H-A-572 (2): a failed record is freed from every pin when no registration of its module names its branch. +func TestAFailedRecordIsFreedWhenItsModuleLeavesTheRegistrations(t *testing.T) { + ctx := context.Background() + ix := &Indexer{Module: testSelf, Revisions: newMemObjects(1 << 20), Pins: newMem(), Findings: newFindings()} + for _, r := range []string{FailedRecord("main", "gone"), FailedRecord("main", "stays"), PipelineRecord("main.1")} { + if err := ix.pin(ctx, "main.3", r); err != nil { + t.Fatal(err) + } + } + if err := ix.FreeFailedRecords(ctx, map[string]bool{FailedRecord("main", "stays"): true}); err != nil { + t.Fatal(err) + } + if v, _, _, _ := ix.Pins.Get(ctx, "main.3"); !slices.Equal(mustRecords(t, v), []string{FailedRecord("main", "stays"), PipelineRecord("main.1")}) { + t.Errorf("the pin holds %s, want the registered module's failed record and the pipeline's alone", v) + } +} From 5922da0a928b56645d4809939954bcac6baf740f Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:37:22 +0100 Subject: [PATCH 075/141] I8 pin-drop-record: indexer_pin_drop with record drops that one record from every pin holding it, the pins' other records staying Builds: design 47 H2 H-A-572 (3) --- .../cmd/mesh-delivery-indexer/takein.go | 4 ++ .../cmd/mesh-delivery-indexer/takein_test.go | 3 + .../internal/index/pins.go | 70 +++++++++++++++++-- .../internal/index/pins_test.go | 11 +++ .../internal/index/takein.go | 3 + 5 files changed, 87 insertions(+), 4 deletions(-) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go index b86f544c9..94ad1c86a 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein.go @@ -20,6 +20,7 @@ type takerIn interface { DropCandidateGraph(ctx context.Context, group, heads, by, why string) index.TakenIn NamedDrop(ctx context.Context, fingerprint, member, by, why string) index.TakenIn PinDrop(ctx context.Context, key, by, why string) index.TakenIn + PinDropRecord(ctx context.Context, record, by, why string) index.TakenIn DropRunByHand(ctx context.Context, run, by, why string) index.TakenIn RegistryAct(ctx context.Context, a index.TakeInAsk) index.TakenIn // HeldAgain and HeldSkip act on a watched branch's held source-moved (design 47 H §744). @@ -70,6 +71,9 @@ func takenIn(ctx context.Context, ix takerIn, kv jetstream.KeyValue, e jetstream } else if a.NamedFingerprint != "" && a.Drop { asked, r = "drop of a member of a fingerprint's names", ix.NamedDrop(ctx, a.NamedFingerprint, a.NamedMember, a.By, a.Why) a.Module = r.Module + } else if a.PinDropRecord != "" { + asked, r = "drop of a record from the pins of the catalog graph revisions", ix.PinDropRecord(ctx, a.PinDropRecord, a.By, a.Why) + a.Module = r.Module } else if a.PinDrop != "" { asked, r = "drop of a pin of the catalog graph revisions", ix.PinDrop(ctx, a.PinDrop, a.By, a.Why) a.Module = r.Module diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_test.go index 495844ebf..a04fc28e0 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_test.go @@ -39,6 +39,9 @@ func (s *askedBy) NamedDrop(context.Context, string, string, string, string) ind func (s *askedBy) PinDrop(context.Context, string, string, string) index.TakenIn { return s.did("pin-drop") } +func (s *askedBy) PinDropRecord(context.Context, string, string, string) index.TakenIn { + return s.did("pin-drop-record") +} func (s *askedBy) DropRunByHand(context.Context, string, string, string) index.TakenIn { return s.did("run-drop") } diff --git a/modules/mesh-delivery-indexer/internal/index/pins.go b/modules/mesh-delivery-indexer/internal/index/pins.go index 48cc0b60a..c10ba1999 100644 --- a/modules/mesh-delivery-indexer/internal/index/pins.go +++ b/modules/mesh-delivery-indexer/internal/index/pins.go @@ -799,6 +799,48 @@ func (ix *Indexer) PinDrop(ctx context.Context, key, by, why string) TakenIn { return r } +// PinDropRecord drops one record, by its name, from every pin of the state pins that holds it, leaving each pin's other records +// (indexer_pin_drop with record, design 47 H2 H-A-572 (3)); the removal rule then applies. +func (ix *Indexer) PinDropRecord(ctx context.Context, record, by, why string) TakenIn { + r := TakenIn{Module: "pins record " + record} + if ix.Pins == nil { + r.Answer = "the indexer keeps no state " + PinsState + ": nothing dropped" + return r + } + pinKeys, err := ix.Pins.Keys(ctx) + if err != nil { + r.Answer = "the state " + PinsState + " cannot be read: " + err.Error() + return r + } + slices.Sort(pinKeys) + dropped := 0 + for _, k := range pinKeys { + if _, _, ok := ParsePinKey(k); !ok { + continue + } + v, _, found, err := ix.Pins.Get(ctx, k) + if err != nil { + r.Answer = "the pin " + k + " cannot be read, so the drop stops there: " + err.Error() + return r + } + var pv PinValue + if !found || json.Unmarshal(v, &pv) != nil || !slices.Contains(pv.Records, record) { + continue + } + if err := ix.unpin(ctx, k, record); err != nil { + r.Answer = "the record " + record + " could not be dropped from " + k + ": " + err.Error() + ix.logf("%s", r.Answer) + return r + } + dropped++ + } + r.Stored = dropped > 0 + r.Answer = fmt.Sprintf("the record %s is dropped from %d pins by %s (%s)", record, dropped, by, why) + ix.logf("%s", r.Answer) + ix.JudgePins(ctx) + return r +} + // PinnedRevision is one revision of the state pins as indexer_pins lists it. type PinnedRevision struct { Revision string `json:"revision"` @@ -881,14 +923,34 @@ func PinsTools(pins Store, o Objects, ask func(key string, value []byte) (TakeIn "running pipeline (design 47 H §765); the removal rule then applies (a revision no record pins and not current goes). A hand " + "act, recorded through mesh-hand-acts before it is asked. Clears the finding pin-missing of the key. indexer_pins names the keys. " + "With all true and no key, every pin of the state goes, each recorded and asked as one: the clean state's tool, run while no " + - "pipeline runs (design 47 H-A-121, H-A-124); it answers the count dropped and the pipelines they named.", + "pipeline runs (design 47 H-A-121, H-A-124); it answers the count dropped and the pipelines they named. With record " + + "and no key, that one record (`failed..`, as indexer_pins names it) is dropped from every pin that holds it " + + "and the pins' other records stay (design 47 H2 H-A-572 (3)).", Input: map[string]any{"type": "object", "required": []string{"why"}, "properties": map[string]any{ - "key": map[string]any{"type": "string", "description": "the pin's key `.`, as indexer_pins names it"}, - "all": map[string]any{"type": "boolean", "description": "true drops every pin of the state pins, naming no key"}, - "why": map[string]any{"type": "string", "description": "why it is dropped, in plain words"}}}, + "key": map[string]any{"type": "string", "description": "the pin's key `.`, as indexer_pins names it"}, + "all": map[string]any{"type": "boolean", "description": "true drops every pin of the state pins, naming no key"}, + "record": map[string]any{"type": "string", "description": "one record, as indexer_pins names it, dropped from every pin that holds it; the pins' other records stay"}, + "why": map[string]any{"type": "string", "description": "why it is dropped, in plain words"}}}, Run: func(args map[string]any) (any, error) { str := func(k string) string { s, _ := args[k].(string); return strings.TrimSpace(s) } key, why := str("key"), str("why") + if rec := str("record"); rec != "" { + if key != "" || str("all") == "true" || why == "" { + return nil, errors.New("name a record (record) with no key and no all, and say why (why): a drop is a hand act, recorded through mesh-hand-acts") + } + data, err := json.Marshal(TakeInAsk{V: 1, PinDropRecord: rec, Why: why, By: stdio.CallerOf(args), At: now().UTC()}) + if err != nil { + return nil, err + } + if err := record("dropped the record "+rec+" from the pins of the catalog graph revisions by hand", why); err != nil { + return nil, fmt.Errorf("the hand act was not recorded through mesh-hand-acts, so nothing was dropped: %w", err) + } + a, err := ask("pin-drop-record."+keys.EscapeName(rec), data) + if err != nil { + return nil, err + } + return a.Result, nil + } if all, _ := args["all"].(bool); all || str("all") == "true" { if key != "" { return nil, errors.New("the all form drops every pin: name no key with it") diff --git a/modules/mesh-delivery-indexer/internal/index/pins_test.go b/modules/mesh-delivery-indexer/internal/index/pins_test.go index 706fe6ebe..42ef466a8 100644 --- a/modules/mesh-delivery-indexer/internal/index/pins_test.go +++ b/modules/mesh-delivery-indexer/internal/index/pins_test.go @@ -177,6 +177,17 @@ func TestTheIndexerRemovesARevisionOnlyWhenNoRecordPinsItAndItIsNotCurrent(t *te if f := ix.Findings.Held(); len(f) != 1 || f[0].Kind != PinMissingKind { t.Fatalf("findings %v, want one %s", f, PinMissingKind) } + // H-A-572 (3): a record dropped by name leaves its pin's other records. + if err := ix.pin(ctx, "main.3", FailedRecord("main", "x")); err != nil { + t.Fatal(err) + } + before, _, _, _ := ix.Pins.Get(ctx, "main.3") + if r := ix.PinDropRecord(ctx, FailedRecord("main", "x"), "operator", "a hand act"); !r.Stored { + t.Fatalf("the record drop answered %q", r.Answer) + } + if v, _, _, _ := ix.Pins.Get(ctx, "main.3"); len(mustRecords(t, v)) != len(mustRecords(t, before))-1 || slices.Contains(mustRecords(t, v), FailedRecord("main", "x")) { + t.Errorf("the pin holds %s after the record drop, was %s: want the one record gone and the others staying", v, before) + } if r := ix.PinDrop(ctx, "main.1", "operator", "names no running pipeline"); !r.Stored { t.Fatalf("the pin drop answered %q", r.Answer) } diff --git a/modules/mesh-delivery-indexer/internal/index/takein.go b/modules/mesh-delivery-indexer/internal/index/takein.go index 5e7074c31..d6f063142 100644 --- a/modules/mesh-delivery-indexer/internal/index/takein.go +++ b/modules/mesh-delivery-indexer/internal/index/takein.go @@ -45,6 +45,9 @@ type TakeInAsk struct { NamedFingerprint string `json:"named-fingerprint,omitempty" takein:"act"` // PinDrop asks one pin of the state pins, by its key, to be dropped (indexer_pin_drop, design 47 H §765). PinDrop string `json:"pin-drop,omitempty" takein:"act"` + // PinDropRecord asks one record, by its name, to be dropped from every pin that holds it, the pins' other records staying + // (indexer_pin_drop with record, design 47 H2 H-A-572 (3)). + PinDropRecord string `json:"pin-drop-record,omitempty" takein:"act"` // Held names the watched branch whose held source-moved is taken in again now (indexer_take_in_pending) or, with Skip and // HeldSource, ended unwritten (indexer_take_in_skip; design 47 H §744). Held string `json:"held,omitempty" takein:"act"` From 72ef5dc7c4c0609d3d45aaedafc953bf605af6bd Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:38:47 +0100 Subject: [PATCH 076/141] B7 (1): a mark is updated by one publish carrying its lifetime and the expected last sequence of its key Builds: design 47 H2 H-A-720 (1), H-A-741 --- .../acted_integration_test.go | 38 +++++++++++++++++++ .../cmd/mesh-delivery-builder/main.go | 2 +- .../cmd/mesh-delivery-builder/versions.go | 28 +++++++++++--- 3 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 modules/mesh-delivery-builder/cmd/mesh-delivery-builder/acted_integration_test.go diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/acted_integration_test.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/acted_integration_test.go new file mode 100644 index 000000000..d3bfdbd1a --- /dev/null +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/acted_integration_test.go @@ -0,0 +1,38 @@ +//go:build integration + +package main + +import ( + "errors" + "testing" + "time" + + "github.com/nats-io/nats.go/jetstream" + + "mesh-delivery-builder/internal/versions" +) + +// Design 47 H2 H-A-720 (1), H-A-741: a mark is updated by one publish carrying its lifetime and the expected last sequence of its +// key: the update at the right revision succeeds and the key keeps its lifetime; one at a stale revision is a conflict. +func TestAMarkIsUpdatedWithItsLifetimeInOnePublish(t *testing.T) { + b := startBed(t) + kv, err := b.js.CreateKeyValue(b.ctx, jetstream.KeyValueConfig{Bucket: "acted-test", LimitMarkerTTL: time.Minute}) + if err != nil { + t.Fatal(err) + } + key := versions.ActedKey("retake:x") + rev, err := kv.Create(b.ctx, key, []byte("1"), jetstream.KeyTTL(time.Hour)) + if err != nil { + t.Fatal(err) + } + next, err := updateWithLifetime(b.ctx, b.js, "acted-test", key, []byte("2"), rev, 2*time.Hour) + if err != nil || next <= rev { + t.Fatalf("update at the key's revision: %d, %v", next, err) + } + if e, err := kv.Get(b.ctx, key); err != nil || string(e.Value()) != "2" || e.Revision() != next { + t.Fatalf("the key holds %v, %v after the update", e, err) + } + if _, err := updateWithLifetime(b.ctx, b.js, "acted-test", key, []byte("3"), rev, time.Hour); !errors.Is(err, versions.ErrConflict) { + t.Fatalf("update at a stale revision: %v, want a conflict", err) + } +} diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go index 126df5f29..47377f07e 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/main.go @@ -336,7 +336,7 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro } // The operator is asked once a key's event builds are spent (design 47 G §568): the builder's asker on the seat operator-channel. decided := &decisions{subject: oc.SubjectDecided(cred.Module)} - retakeActed := markLifetime{awaitedReserved{awaitedState{b: actedKV, bucket: own.acted}}, actedDays} + retakeActed := markLifetime{awaitedReserved{awaitedState{b: actedKV, bucket: own.acted}}, actedDays, js} actedKV.Ready(func(kv jetstream.KeyValue) { deleteUnknown(ctx, kv, logger.Printf) }) asker := &operatorask.Asker[oc.Warrant]{Module: cred.Module, Call: calls.Call, Record: calls.Ask, Publish: publishVia(ctx, js), Subscribe: decided.hear(logger.Printf), Contract: operatorask.Contract{Seat: oc.Seat, StateAsks: oc.StateAsks}, diff --git a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go index fdb938b7f..29bdbf79d 100644 --- a/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go +++ b/modules/mesh-delivery-builder/cmd/mesh-delivery-builder/versions.go @@ -4,6 +4,8 @@ import ( "context" "encoding/json" "errors" + "fmt" + "strconv" "time" "github.com/nats-io/nats.go" @@ -126,10 +128,11 @@ func emitSeatEvent(ctx context.Context, js jetstream.JetStream, cred process.Acc // markLifetime writes the marks of the state acted with the bus's per-message lifetime of the setting acted-days, each write giving // it again (design 47 H2 H-A-720 (1)); the release record and every other key it writes with none (H-A-720 (2)). An update is the -// compare-and-set delete of the revision and the create that carries the lifetime, since the bus gives a lifetime at a create. +// one publish carrying the lifetime and the expected last sequence of the key (H-A-741). type markLifetime struct { awaitedReserved days int + js jetstream.JetStream } func (s markLifetime) life(key string) (time.Duration, bool) { @@ -161,11 +164,26 @@ func (s markLifetime) Update(ctx context.Context, key string, value []byte, revi if err != nil { return 0, err } - if err := kv.Delete(ctx, key, jetstream.LastRevision(revision)); err != nil { - return 0, versionsConflict(err) + _ = kv + return updateWithLifetime(ctx, s.js, s.bucket, key, value, revision, ttl) +} + +// updateWithLifetime is one publish to the key's subject carrying the per-message lifetime and the expected last sequence of the +// key: the compare-and-set update that gives the lifetime again (design 47 H2 H-A-741). +func updateWithLifetime(ctx context.Context, js jetstream.JetStream, bucket, key string, value []byte, revision uint64, ttl time.Duration) (uint64, error) { + msg := nats.NewMsg("$KV." + bucket + "." + key) + msg.Data = value + msg.Header.Set("Nats-TTL", fmt.Sprintf("%ds", int64(ttl/time.Second))) + msg.Header.Set("Nats-Expected-Last-Subject-Sequence", strconv.FormatUint(revision, 10)) + ack, err := js.PublishMsg(ctx, msg) + if err != nil { + var apiErr *jetstream.APIError + if errors.As(err, &apiErr) && apiErr.ErrorCode == jetstream.JSErrCodeStreamWrongLastSequence { + return 0, versions.ErrConflict + } + return 0, err } - rev, err := kv.Create(ctx, key, value, jetstream.KeyTTL(ttl)) - return rev, versionsConflict(err) + return ack.Sequence, nil } // deleteUnknown deletes each key of the state acted of a form the builder does not write (design 47 H2 H-A-720 (3)) and says the From 1b4d7e5c8d2f73d98822d3953afbb973b83e33f2 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 25 Nov 2026 17:42:54 +0100 Subject: [PATCH 077/141] I15 starting-indexer-answers: the starting indexer answers away while its start's read of the trunk holds the view, and says its start's phases KeptTrunk.Unread and current answer the fault away naming "the trunk's revision " while the start's read holds the view, and never wait behind it; the verb revision asks it first; the tools' watched copies (seat-definitions, config readers) ask WatchedStates.Unread before they read and are watched from the bundle's start. The indexer's start says each step as a phase of mesh-sdk's ProcessReader (BeginPhase, EndPhase), kept at start-phase of the state first-views. Rows: a unit test of the held read, one of the watched copy, and TestIndexerWhole's phases and held-read case. Builds: design 47 H2 H-A-708 (1) (2), H-A-717 DQ-54, H-A-733 (2) --- .../mesh-delivery-indexer-tools/catalog.go | 19 ++++- .../cmd/mesh-delivery-indexer-tools/main.go | 5 ++ .../cmd/mesh-delivery-indexer-tools/views.go | 3 + .../watched_test.go | 54 +++++++++++++++ .../cmd/mesh-delivery-indexer/main.go | 30 ++++++-- .../takein_integration_test.go | 68 +++++++++++++++++- .../internal/index/catalog_revisions.go | 69 ++++++++++++++++--- .../internal/index/kept_trunk_test.go | 65 +++++++++++++++++ .../internal/index/revision_verb.go | 6 ++ 9 files changed, 300 insertions(+), 19 deletions(-) create mode 100644 modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/watched_test.go diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/catalog.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/catalog.go index e6688fb00..c779eaa17 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/catalog.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/catalog.go @@ -72,9 +72,19 @@ type watchedSource struct { state string } -func (s watchedSource) Keys() ([]string, error) { return s.w.Keys(s.state) } +// Each read asks Unread first, so a call made before the copy has its state answers the fault away at once (design 47 H2 +// H-A-708 (2)); the bundle's own start keeps the waiting read (main). +func (s watchedSource) Keys() ([]string, error) { + if err := s.w.Unread(s.state); err != nil { + return nil, err + } + return s.w.Keys(s.state) +} func (s watchedSource) Get(key string) (*views.Entry, bool, error) { + if err := s.w.Unread(s.state); err != nil { + return nil, false, err + } v, ok, err := s.w.Get(s.state, key) if err != nil || !ok { return nil, false, err @@ -82,4 +92,9 @@ func (s watchedSource) Get(key string) (*views.Entry, bool, error) { return &views.Entry{Value: v}, true, nil } -func (s watchedSource) Values() (map[string][]byte, error) { return s.w.Values(s.state) } +func (s watchedSource) Values() (map[string][]byte, error) { + if err := s.w.Unread(s.state); err != nil { + return nil, err + } + return s.w.Values(s.state) +} diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go index 0945d469d..efdbc0bb0 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/main.go @@ -194,6 +194,11 @@ func main() { } follow.Start(context.Background()) watched := stdio.NewWatchedStates() + // The copies the handlers read are watched from the start, beside the answers: a handler asks Unread first and is answered + // the fault away until its state is in (design 47 H2 H-A-708 (2)). + for _, state := range []string{index.SeatDefinitionsState, "manifests"} { + go watched.Follow(state, nil) + } tools = append(tools, catalogTools(trunk.State, kept, watched)...) // The seat mesh-catalog's verb revision, a first view of the catalog half answered in this runtime of its own to exactly // the parts whose entry declares it (novox/hq ADR 0663). diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/views.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/views.go index f7922ec81..1eb2d65cd 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/views.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/views.go @@ -62,6 +62,9 @@ func configReadersTool(watched *stdio.WatchedStates, modules views.Source) stdio } } kept := map[string]meshcatalog.ManifestsByDigestValue{} + if err := watched.Unread("manifests"); err != nil { + return nil, err + } raws, err := watched.Values("manifests") if err != nil { return nil, fmt.Errorf("the manifests state cannot be read: %w", err) diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/watched_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/watched_test.go new file mode 100644 index 000000000..d931f9c26 --- /dev/null +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer-tools/watched_test.go @@ -0,0 +1,54 @@ +package main + +import ( + "errors" + "runtime" + "testing" + "time" + + stdio "git.novox.be/novox/mesh-sdk/go" + "git.novox.be/novox/mesh-sdk/go/busretry" + + "mesh-delivery-indexer/internal/index" +) + +// Design 47 H2 H-A-708 (2): a handler on a watched copy asks Unread first, so the verb seat-definitions, asked before the copy +// has its state (the watch not handing its values yet), answers the fault away at once and answers its values after. +func TestASeatDefinitionsReadIsAnsweredAwayUntilItsStateIsWatched(t *testing.T) { + release := make(chan struct{}) + w := stdio.WatchedStatesOver(func(state string, handle func(stdio.StateChange) error) error { + <-release + return handle(stdio.StateChange{State: state, Key: "git.trunk", Op: stdio.OpPut, Value: []byte(`{"digest":"d"}`), Revision: 1, Current: true}) + }, nil) + src := watchedSource{w, index.SeatDefinitionsState} + var away *busretry.Away + if _, err := src.Keys(); !errors.As(err, &away) { + t.Fatalf("Keys before the copy is asked for = %v, want away", err) + } + go w.Follow(index.SeatDefinitionsState, nil) // the bundle's start asks for the copy + deadline := time.Now().Add(5 * time.Second) + for { + _, err := src.Values() + if errors.As(err, &away) && away.Part == "the state "+index.SeatDefinitionsState { + break // asked for and not handed yet + } + if time.Now().After(deadline) { + t.Fatalf("Values while the watch is held = %v, want away naming the state", err) + } + runtime.Gosched() + } + close(release) + for { + keys, err := src.Keys() + if err == nil { + if len(keys) != 1 || keys[0] != "git.trunk" { + t.Fatalf("Keys after the copy has its state = %v, want its one key", keys) + } + return + } + if time.Now().After(deadline) { + t.Fatalf("Keys still %v after the watch handed its values", err) + } + runtime.Gosched() + } +} diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go index dedbddff3..ceb36376b 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/main.go @@ -18,6 +18,7 @@ import ( "os" "os/signal" "strings" + "sync" "sync/atomic" "syscall" "time" @@ -397,12 +398,34 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro } return ix.SeedModulesFrom(ctx, r.Definitions(), stepsVia(calls.CallKeptWhileOpen, ix.SeedEntryHeld, logger.Printf)) } + // The indexer's one pull of its durable on the shared events stream (process.EventHub): every handler is registered + // before it starts. + hub := process.NewEventHub(logger.Printf) + reader := &views.ProcessReader{Module: cred.Module, Call: calls.Call, Logf: logger.Printf, Hub: hub, + Findings: func() views.WireWriter { return writer }} // Each step of the start says when it begins and how long it took, so a start that does not end is read in the journal // and not guessed (lead-47 2026-11-16: two starts on novox ran 25 minutes at one CPU with no line). + // Each is also the phase the start is in, said in the reader's journal and kept for the first-view tool (design 47 H2 + // H-A-708 (1), H-A-717 DQ-54), and ended only by its own end, so a pass that runs beside the start's (the publish at + // start) never ends another's. + var phaseMu sync.Mutex + phase := "" step := func(name string) func() { began := time.Now() logger.Printf("start: %s", name) - return func() { logger.Printf("start: %s done in %s", name, time.Since(began).Round(time.Millisecond)) } + phaseMu.Lock() + phase = name + phaseMu.Unlock() + reader.BeginPhase(name) + return func() { + logger.Printf("start: %s done in %s", name, time.Since(began).Round(time.Millisecond)) + phaseMu.Lock() + defer phaseMu.Unlock() + if phase == name { + phase = "" + reader.EndPhase() + } + } } // A module of the current trunk graph with no registration is registered once at the start, as a kept trunk revision // registers one entering the graph (design 47 H H-A-262, H-A-264 (1)); said loudly, whatever it answers. @@ -452,11 +475,6 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro buildModules.refresh() // The assignments is the seat mesh-module-assigner's: read through its holder's first view and views family, never its bucket (DLV-F1r). assignmentsErrs := make(chan error) - // The indexer's one pull of its durable on the shared events stream (process.EventHub): every handler is registered - // before it starts. - hub := process.NewEventHub(logger.Printf) - reader := &views.ProcessReader{Module: cred.Module, Call: calls.Call, Logf: logger.Printf, Hub: hub, - Findings: func() views.WireWriter { return writer }} // The holder function (A-302): the seat-holders view of the claimant of mesh-module-assigner in the indexer's own catalog, // followed again at each refresh of the build modules (a seat list change, a catalog revision). seatHolders := &seatHoldersFollow{ctx: ctx, ix: ix, reader: reader, logf: logger.Printf} diff --git a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go index 9650b2a6f..e5b9e6d8b 100644 --- a/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go +++ b/modules/mesh-delivery-indexer/cmd/mesh-delivery-indexer/takein_integration_test.go @@ -26,7 +26,9 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/nodebuildgo" stdio "git.novox.be/novox/mesh-sdk/go" + "git.novox.be/novox/mesh-sdk/go/busretry" "git.novox.be/novox/mesh-sdk/go/keys" + "git.novox.be/novox/mesh-sdk/go/views" "mesh-delivery-indexer/internal/index" ) @@ -412,7 +414,7 @@ func TestIndexerWhole(t *testing.T) { ) var forge *forgeCommits var heard *takeIns - var pins, held, takeinsKV, regs, runs jetstream.KeyValue + var pins, held, takeinsKV, regs, runs, status jetstream.KeyValue js, ctx, candidates, _, restart := startIndexerRun(t, func(context.Context, buildLog) {}, func(ctx context.Context, js jetstream.JetStream) { heard = hearTakeIns(t, js.Conn()) forge = serveCommits(t, js.Conn()) @@ -423,8 +425,8 @@ func TestIndexerWhole(t *testing.T) { for _, b := range []struct { state string kv *jetstream.KeyValue - }{{index.HeldState, &held}, {index.TakeInsState, &takeinsKV}, {index.RunsState, &runs}} { - if *b.kv, err = js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, b.state), History: 1}); err != nil { + }{{index.HeldState, &held}, {index.TakeInsState, &takeinsKV}, {index.RunsState, &runs}, {views.StatusState, &status}} { + if *b.kv, err = js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.Bucket(testIndexer, b.state), History: 64}); err != nil { t.Fatal(err) } } @@ -649,6 +651,66 @@ func TestIndexerWhole(t *testing.T) { if hq := heard.next(t, "delta", 2); len(hq.Entries) != 0 || hq.Revision != 2 { t.Errorf("the move of novox/hq on delta said %+v, want revision 2 with no movers", hq) } + + // Design 47 H2 H-A-708 (1), H-A-717 DQ-54: the start's phases are kept at start-phase of the state first-views, and the + // start's last phase ended is null. + untilKey(t, ctx, status, views.StartPhaseKey, func(v []byte) bool { return string(v) == "null" }) + phases, err := status.History(ctx, views.StartPhaseKey) + if err != nil { + t.Fatal(err) + } + var said []string + for _, e := range phases { + var p *views.StartPhase + if json.Unmarshal(e.Value(), &p) == nil && p != nil { + said = append(said, p.Name) + } + } + for _, want := range []string{"following the assignments", "computing the fingerprints"} { + if !slices.Contains(said, want) { + t.Errorf("the start's phases kept %q, want %q among them", said, want) + } + } + + // Design 47 H2 H-A-708 (2) (AC-I15): while the start's read of the trunk is held, the verb revision, asked of the tools' + // view of the trunk, answers the fault away naming the trunk's revision within seconds, never waiting behind the read. + hold := &holdEntries{Objects: objects, reading: make(chan struct{}), release: make(chan struct{})} + kept := &index.KeptTrunk{} + readEnded := make(chan error, 1) + go func() { readEnded <- kept.Reread(ctx, hold) }() + <-hold.reading + answered := make(chan error, 1) + go func() { + _, err := toolNamed(t, []stdio.Tool{index.RevisionTool(hold, kept)}, meshcatalog.Seat+"."+meshcatalog.VerbRevision).Run(map[string]any{}) + answered <- err + }() + select { + case err := <-answered: + var away *busretry.Away + if !errors.As(err, &away) || !strings.HasPrefix(away.Part, "the trunk's revision ") { + t.Errorf("revision while the start's read is held answered %v, want away naming the trunk's revision", err) + } + case <-time.After(waitBound): + t.Error("revision waited behind the start's read of the trunk") + } + close(hold.release) + if err := <-readEnded; err != nil { + t.Errorf("the held read of the trunk ended with %v", err) + } +} + +// holdEntries is the indexer's objects whose first read of an entry waits until release is closed: a read of the trunk held. +type holdEntries struct { + index.Objects + reading, release chan struct{} + once sync.Once +} + +func (h *holdEntries) Get(ctx context.Context, name string) ([]byte, error) { + if strings.HasPrefix(name, "entry.") { + h.once.Do(func() { close(h.reading); <-h.release }) + } + return h.Objects.Get(ctx, name) } // toolNamed is the tool of that name. diff --git a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go index 05d812b8a..e7f11e026 100644 --- a/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go +++ b/modules/mesh-delivery-indexer/internal/index/catalog_revisions.go @@ -16,6 +16,7 @@ import ( "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog" runner "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner" "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/graph" + "git.novox.be/novox/mesh-sdk/go/busretry" "git.novox.be/novox/mesh-sdk/go/catalogue" "git.novox.be/novox/mesh-sdk/go/keys" "git.novox.be/novox/mesh-sdk/go/process" @@ -223,9 +224,17 @@ func newestOf(ctx context.Context, o Objects, branch string) (meshcatalog.Catalo // while the newest is newer than the one that failed; the same revision failing twice is the read's failure. Progress bounds // the loop. No revision kept is false. func readNewestOf(ctx context.Context, o Objects, branch string) (meshcatalog.CatalogRevision, []meshcatalog.CatalogEntry, bool, error) { + return readNewestOfSaying(ctx, o, branch, nil) +} + +// readNewestOfSaying is readNewestOf telling said the revision each pass found as the newest, before it reads its entries. +func readNewestOfSaying(ctx context.Context, o Objects, branch string, said func(revision int64)) (meshcatalog.CatalogRevision, []meshcatalog.CatalogEntry, bool, error) { var failed int64 for { newest, any, err := newestOf(ctx, o, branch) + if err == nil && any && said != nil { + said(newest.Revision) + } if err == nil && !any { return newest, nil, false, nil } @@ -649,11 +658,16 @@ type KeptTrunk struct { read sync.Mutex // one re-read at a time; a read of the view never holds it mu sync.Mutex started bool - at int64 - mods Store - held Store - rev meshcatalog.CatalogRevision - entries []meshcatalog.CatalogEntry + // reading is whether a read of the trunk runs now, readingRev the revision it reads (0 while the newest is not known + // yet) and readingSince when it began: a call that meets the start's read says them as the fault away (Unread). + reading bool + readingRev int64 + readingSince time.Time + at int64 + mods Store + held Store + rev meshcatalog.CatalogRevision + entries []meshcatalog.CatalogEntry // manifests are the manifests the revision's entries carry whole, as JSON, by their digest as a module's value names it // (A-487c: the verbs module and provides answer them from here, never from the manifests state). manifests map[string]string @@ -668,13 +682,25 @@ func (k *KeptTrunk) Reread(ctx context.Context, o Objects) error { func (k *KeptTrunk) reread(ctx context.Context, o Objects) error { began := time.Now() + k.mu.Lock() + k.reading, k.readingRev, k.readingSince = true, 0, began + k.mu.Unlock() + defer func() { + k.mu.Lock() + k.reading = false + k.mu.Unlock() + }() fail := func(err error) error { if k.Say != nil { k.Say("the view of the trunk is BEHIND, its re-read failed after %s (the view held stays, the next heard catalog-revision reads again): %v", time.Since(began).Round(time.Millisecond), err) } return err } - newest, entries, any, err := readNewestOf(ctx, o, TrunkBranch) + newest, entries, any, err := readNewestOfSaying(ctx, o, TrunkBranch, func(revision int64) { + k.mu.Lock() + k.readingRev = revision + k.mu.Unlock() + }) if err != nil { return fail(err) } @@ -762,13 +788,40 @@ func (t TrunkStates) view() (modules, nodes Store, at int64, err error) { return t.Kept.current(context.Background(), t.Objects) } -// current is the view held; before the start's read it reads the newest revision once. +// Unread is the fault away (busretry.Away, design 47 H2 H-A-708 (2)) naming "the trunk's revision " with "not read yet +// since