From ed0b90576740e1709dd2d9189a466c1d801cc1f0 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 23:27:19 +0100 Subject: [PATCH 1/3] H-A-504 addendum contracts: pipeline-ended carries the pipeline's sequence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The assigner had no sequence to write as a want's run: pipeline-ended said no seq, so it took the key's last segment, an again run's number, and refused node-tools 0.1.115 of main.320.again.1 under run "2" of an older pipeline. pipeline-ended gains seq, the record's; the record's seq is now said to be taken for every pipeline. The runner seat's form is 10; the contract is regenerated, with a fixture of an again pipeline's end. Builds: design 47 H2 §813 (1), H-A-504 corrected, H-A-504 addendum --- .../go/seats/meshpipelinerunner/contract.go | 10 ++++---- .../seats/meshpipelinerunner/contract_test.go | 2 ++ .../mesh-pipeline-runner/fixtures/events.json | 24 +++++++++++++++++++ .../seats/mesh-pipeline-runner/seat.json | 8 +++++-- .../ts/seats/meshpipelinerunner/index.d.ts | 4 +++- 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index 7f285c681..ddc60ede8 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 = 9 +const Form = 10 // 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 = "9" - 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=523f8fc0fe41 PipelineEndedEvent=cb44007f7173 PipelineEndedPhases=9d1c33ce4cc4 PipelineEndedPhasesBuild=a08d49692a09 PipelineEndedPhasesComposition=a08d49692a09 PipelineEndedPhasesIntegration=a08d49692a09 PipelineEndedPhasesLint=a08d49692a09 PipelineEndedPhasesUnit=a08d49692a09 PipelineEndedPhasesValidate=a08d49692a09 PipelineRow=f58dbdcaf2d4 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=0dac0e15d017 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 = "10" + 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=f58dbdcaf2d4 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=0dac0e15d017 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 ( @@ -775,7 +775,7 @@ type Pipeline struct { Revision int64 `json:"revision,omitempty"` // the run on request's id, for a pipeline of a run; such a pipeline delivers nothing Run string `json:"run,omitempty"` - // for a pipeline written over pipelines-at-once, its place in the queue: the runner's counter queue.next at its write (design 47 H §748) + // its place in the runner's sequence: the runner's counter queue.next at its write, taken for every pipeline it writes, queued or placed at once, so it grows across the pipelines of a branch (design 47 H §748; H2 §813 (1), H-A-504 addendum) Seq int64 `json:"seq,omitempty"` // the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) Source int64 `json:"source"` @@ -897,6 +897,8 @@ type PipelineEnded struct { Revision int64 `json:"revision,omitempty"` // the run on request's id, for a pipeline of a run; such a pipeline delivers nothing Run string `json:"run,omitempty"` + // the pipeline's sequence, its record's seq: the assigner writes it as the run of the wants the pipeline's pass writes (design 47 H2 §813 (1), H-A-504 addendum) + Seq int64 `json:"seq,omitempty"` // 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"` 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 e37f88c2b..d1394d8e1 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go @@ -21,6 +21,8 @@ func TestFixtures(t *testing.T) { 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\\.[^.*> ]+\\.[^.*> ]+$")}, + {name: "an again pipeline ended passed, with its sequence (H-A-504 addendum)", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.320", given: "{\"branch\":\"main\",\"end-count\":1,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"node-tools\",\"steps\":[],\"tier\":1,\"version\":\"0.1.115\"}],\"outcome\":\"passed\",\"pipeline\":\"main.320.again.1\",\"revision\":320,\"seq\":269,\"source\":119,\"v\":1}", wire: "{\"branch\":\"main\",\"end-count\":1,\"movers\":[{\"fingerprint\":\"fp-0123\",\"module\":\"node-tools\",\"steps\":[],\"tier\":1,\"version\":\"0.1.115\"}],\"outcome\":\"passed\",\"pipeline\":\"main.320.again.1\",\"revision\":320,\"seq\":269,\"source\":119,\"v\":1}", + 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 passed: per mover its version, steps and tier, an optional step failed", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.3589", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\",\"widens\":[{\"name\":\"seat:mesh-wants.input\",\"what\":\"grant\"}]},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"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\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\",\"widens\":[{\"name\":\"seat:mesh-wants.input\",\"what\":\"grant\"}]},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"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\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"v\":1}", 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 of two movers ended with its phases and one mover left unfinished", subject: "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.3589", given: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"form\":2,\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\",\"widens\":[{\"name\":\"seat:mesh-wants.input\",\"what\":\"grant\"}]},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"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\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"phases\":{\"build\":{\"end\":\"2026-11-21T22:02:00Z\",\"start\":\"2026-11-21T22:00:06Z\"},\"composition\":{\"end\":\"2026-11-21T22:06:00Z\",\"start\":\"2026-11-21T22:04:01Z\"},\"ended\":\"2026-11-21T22:06:00Z\",\"placed\":\"2026-11-21T22:00:05Z\",\"taken\":\"2026-11-21T22:00:00Z\",\"unit\":{\"end\":\"2026-11-21T22:04:00Z\",\"start\":\"2026-11-21T22:02:01Z\"}},\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"unfinished\":[\"mesh-delivery-view\"],\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"0123456789abcdef\",\"end-count\":1,\"ended\":\"2026-11-10T10:20:00Z\",\"form\":2,\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-sdk\",\"module\":\"mesh-sdk\",\"steps\":[{\"module\":\"mesh-sdk\",\"outcome\":\"passed\",\"seat\":\"mesh-wants\",\"status\":\"required\",\"step\":\"validate\"}],\"tier\":1,\"version\":\"0.1.21\",\"widens\":[{\"name\":\"seat:mesh-wants.input\",\"what\":\"grant\"}]},{\"fingerprint\":\"fp-0123\",\"module\":\"nats\",\"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\"}],\"tier\":2,\"version\":\"0.1.15\"}],\"outcome\":\"passed\",\"phases\":{\"build\":{\"end\":\"2026-11-21T22:02:00Z\",\"start\":\"2026-11-21T22:00:06Z\"},\"composition\":{\"end\":\"2026-11-21T22:06:00Z\",\"start\":\"2026-11-21T22:04:01Z\"},\"ended\":\"2026-11-21T22:06:00Z\",\"placed\":\"2026-11-21T22:00:05Z\",\"taken\":\"2026-11-21T22:00:00Z\",\"unit\":{\"end\":\"2026-11-21T22:04:00Z\",\"start\":\"2026-11-21T22:02:01Z\"}},\"pipeline\":\"main.3589\",\"revision\":12,\"source\":3589,\"started\":\"2026-11-10T10:00:00Z\",\"unfinished\":[\"mesh-delivery-view\"],\"v\":1}", 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 706214ce4..e7a222b08 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 @@ -52,6 +52,30 @@ "at": "2026-11-22T20:00:00Z" } }, + { + "name": "an again pipeline ended passed, with its sequence (H-A-504 addendum)", + "of": "event:pipeline-ended", + "subject": "mesh.seat.mesh-pipeline-runner.event.pipeline-ended.main.320", + "given": { + "pipeline": "main.320.again.1", + "branch": "main", + "revision": 320, + "seq": 269, + "source": 119, + "end-count": 1, + "v": 1, + "outcome": "passed", + "movers": [ + { + "module": "node-tools", + "fingerprint": "fp-0123", + "steps": [], + "tier": 1, + "version": "0.1.115" + } + ] + } + }, { "name": "a pipeline ended passed: per mover its version, steps and tier, an optional step failed", "of": "event:pipeline-ended", 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 306479ac3..33f62f7f3 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -1357,7 +1357,7 @@ }, "seq": { "type": "integer", - "description": "for a pipeline written over pipelines-at-once, its place in the queue: the runner's counter queue.next at its write (design 47 H §748)" + "description": "its place in the runner's sequence: the runner's counter queue.next at its write, taken for every pipeline it writes, queued or placed at once, so it grows across the pipelines of a branch (design 47 H §748; H2 §813 (1), H-A-504 addendum)" }, "end-count": { "type": "integer", @@ -1455,6 +1455,10 @@ "type": "integer", "description": "the catalog graph revision of the branch the pipeline runs for" }, + "seq": { + "type": "integer", + "description": "the pipeline's sequence, its record's seq: the assigner writes it as the run of the wants the pipeline's pass writes (design 47 H2 §813 (1), H-A-504 addendum)" + }, "end-count": { "type": "integer", "description": "how often the pipeline has ended: 1 at its first end, one higher at each end again after a passing rerun, so the assigner takes a later end of the same source revision (design 47 G sections 29, 325)" @@ -2374,5 +2378,5 @@ ] } }, - "form": 9 + "form": 10 } 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 550917874..28be0c5f7 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -306,7 +306,7 @@ export interface Pipeline { "revision"?: number; /** the run on request's id, for a pipeline of a run; such a pipeline delivers nothing */ "run"?: string; - /** for a pipeline written over pipelines-at-once, its place in the queue: the runner's counter queue.next at its write (design 47 H §748) */ + /** its place in the runner's sequence: the runner's counter queue.next at its write, taken for every pipeline it writes, queued or placed at once, so it grows across the pipelines of a branch (design 47 H §748; H2 §813 (1), H-A-504 addendum) */ "seq"?: number; /** the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) */ "source": number; @@ -417,6 +417,8 @@ export interface PipelineEnded { "revision"?: number; /** the run on request's id, for a pipeline of a run; such a pipeline delivers nothing */ "run"?: string; + /** the pipeline's sequence, its record's seq: the assigner writes it as the run of the wants the pipeline's pass writes (design 47 H2 §813 (1), H-A-504 addendum) */ + "seq"?: number; /** the source revision of the watched branch; the pipeline is keyed by it (ADR 0666 section 9) */ "source": number; "started"?: string; -- 2.54.0 From f6aff0182c9ce712bf34fa53e11fb02437cfa803 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 23:28:41 +0100 Subject: [PATCH 2/3] H-A-504 addendum runner: every pipeline has a sequence, and its end says it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The runner took queue.next only for a pipeline that waited, so most pipelines kept seq 0 and the assigner had no order across pipelines for a want's run. queueStart now takes the next sequence for every pipeline it writes, queued or placed at once, and pipeline-ended carries the record's seq. Builds: design 47 H2 §813 (1), H-A-504 corrected, H-A-504 addendum --- .../queue_integration_test.go | 11 +++++---- .../internal/pipeline/ended_test.go | 7 ++++-- .../internal/pipeline/queue.go | 23 +++++++++++-------- .../internal/pipeline/queue_test.go | 13 ++++++----- .../internal/pipeline/steps.go | 5 ++-- 5 files changed, 35 insertions(+), 24 deletions(-) diff --git a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/queue_integration_test.go b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/queue_integration_test.go index fd539a64b..5fda4dab6 100644 --- a/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/queue_integration_test.go +++ b/modules/mesh-delivery-pipeline/cmd/mesh-delivery-pipeline/queue_integration_test.go @@ -268,13 +268,16 @@ func testTheQueueRunsPipelinesInTurn(t *testing.T) { waitFor(t, ctx, logs, func() bool { return get(key).Outcome == want }) } - // Two take-ins in a row: the first runs, its build asked; the second is written waiting under sequence 1 with no step, - // says pipeline-started and wait-held. + // Two take-ins in a row: the first runs at sequence 1 (every pipeline has one, H-A-504 addendum), its build asked; the + // second is written waiting under sequence 2 with no step, says pipeline-started and wait-held. take(3, "app") outcome("main.3", seat.PipelineOutcomeRunning) + if p := get("main.3"); p.Seq != 1 { + t.Fatalf("main.3 placed at once has seq %d, want 1", p.Seq) + } take(4, "lib") - if p := get("main.4"); p.Outcome != seat.PipelineOutcomeWaiting || p.Seq != 1 || len(p.Steps) != 0 { - t.Fatalf("main.4 = %s seq %d with %d steps, want waiting at 1 with none", p.Outcome, p.Seq, len(p.Steps)) + if p := get("main.4"); p.Outcome != seat.PipelineOutcomeWaiting || p.Seq != 2 || len(p.Steps) != 0 { + t.Fatalf("main.4 = %s seq %d with %d steps, want waiting at 2 with none", p.Outcome, p.Seq, len(p.Steps)) } waitFor(t, ctx, logs, func() bool { return wasSaid("wait-held.main.4") && wasSaid("pipeline-started.main.4") }) if r := running(); !slices.Equal(r, []string{"main.3"}) { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/ended_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/ended_test.go index 9400620e0..1080f9715 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/ended_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/ended_test.go @@ -223,11 +223,11 @@ func TestAReleasedVersionIsTheMoversVersion(t *testing.T) { } } -// Design 47 H2 §785: a pipeline of two movers ends with its taken, placed and ended times and each step kind's span, the +// Design 47 H2 §785: a pipeline of two movers ends with its sequence (H-A-504 addendum) and its taken, placed and ended times and each step kind's span, the // earliest start and the latest end across its movers; a kind none of whose steps started has none. func TestPipelineEndedCarriesEachStepKindsSpan(t *testing.T) { at := func(m int) *time.Time { v := time.Date(2026, 11, 22, 1, m, 0, 0, time.UTC); return &v } - p := seat.Pipeline{Pipeline: "main.7", Started: at(0), Ended: at(30), Outcome: seat.PipelineOutcomePassed, + p := seat.Pipeline{Pipeline: "main.7", Seq: 270, Started: at(0), Ended: at(30), Outcome: seat.PipelineOutcomePassed, Movers: []seat.Mover{{Module: "lib", Tier: 1}, {Module: "app", Tier: 2}}, Steps: []seat.StepResult{ {Module: "lib", Step: seat.StepResultStepBuild, Started: at(2), Ended: at(6)}, @@ -236,6 +236,9 @@ func TestPipelineEndedCarriesEachStepKindsSpan(t *testing.T) { {Module: "app", Step: seat.StepResultStepUnit, Started: at(10)}, {Module: "app", Step: seat.StepResultStepComposition}, }} + if seq := pipelineEnded(p).Seq; seq != 270 { + t.Errorf("pipeline-ended carries seq %d, want the record's 270 (H-A-504 addendum)", seq) + } ph := pipelineEnded(p).Phases if ph == nil || !ph.Taken.Equal(*at(0)) || !ph.Placed.Equal(*at(1)) || !ph.Ended.Equal(*at(30)) { t.Fatalf("phases %+v, want taken 01:00, placed 01:01, ended 01:30", ph) diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/queue.go b/modules/mesh-delivery-pipeline/internal/pipeline/queue.go index 9effe4847..ffa0fae70 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/queue.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/queue.go @@ -117,7 +117,7 @@ func (q *Queue) run(key string) (bool, error) { return true, nil } -// next is the sequence the next waiting pipeline gets: queue.next read and written one higher by compare-and-set, from 1. +// next is the sequence the next pipeline gets, waiting or placed: queue.next read and written one higher by compare-and-set, from 1. func (q *Queue) next() (int64, error) { for { raw, rev, err := q.Store.Get(seat.QueueByQueueNextKey()) @@ -180,23 +180,26 @@ func (s *Starter) sayQueueWait(event string, p seat.Pipeline, at time.Time, how } } -// queueStart judges a start against the bound (§748): under it, it answers true, the pipeline placed and its running key -// written once the pipeline is (ran); over it p gets the next sequence and state waiting, with no step, and its waiting key -// is written first, so a key whose pipeline was never written is dropped at its placing; it answers false and that key. A -// start with no queue is placed. +// queueStart gives p the next sequence of queue.next, whether it waits or is placed at once, so every pipeline's seq grows +// across the pipelines of a branch and the assigner writes it as its wants' run (design 47 H2 §813 (1), H-A-504 addendum); +// then it judges the start against the bound (§748): under it, it answers true, the pipeline placed and its running key +// written once the pipeline is (ran); over it p gets state waiting, with no step, and its waiting key is written first, so a +// key whose pipeline was never written is dropped at its placing; it answers false and that key. A start with no queue is +// placed. func (s *Starter) queueStart(p *seat.Pipeline) (bool, string, error) { if s.Queue == nil { return true, "", nil } - full, err := s.Queue.full() - if err != nil || !full { - return err == nil, "", err - } seq, err := s.Queue.next() if err != nil { return false, "", err } - p.Seq, p.Outcome = seq, seat.PipelineOutcomeWaiting + p.Seq = seq + full, err := s.Queue.full() + if err != nil || !full { + return err == nil, "", err + } + p.Outcome = seat.PipelineOutcomeWaiting return false, sequenceKey(seq), s.Queue.wait(seq, p.Pipeline) } diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/queue_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/queue_test.go index 23b841668..a697a4433 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/queue_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/queue_test.go @@ -116,8 +116,9 @@ func TestThePipelinesWaitTheirTurn(t *testing.T) { take := takeIn(t, s, view) take(4, "app") first := len(asks.ids) - if p, _, _ := mem.Get("main.4"); p.Outcome != seat.PipelineOutcomeRunning || p.Seq != 0 || first == 0 { - t.Fatalf("the first pipeline = %s seq %d with %d asks, want running and asked", p.Outcome, p.Seq, first) + if p, _, _ := mem.Get("main.4"); p.Outcome != seat.PipelineOutcomeRunning || p.Seq != 1 || first == 0 { + // H-A-504 addendum: a pipeline placed at once has its sequence too + t.Fatalf("the first pipeline = %s seq %d with %d asks, want running at 1 and asked", p.Outcome, p.Seq, first) } if _, ok := q["running.main.4"]; !ok { t.Fatalf("the queue = %v, want running.main.4", q) @@ -127,15 +128,15 @@ func TestThePipelinesWaitTheirTurn(t *testing.T) { take(6, "tool") for i, key := range []string{"main.5", "main.6"} { p, _, _ := mem.Get(key) - if p.Outcome != seat.PipelineOutcomeWaiting || p.Seq != int64(i+1) || len(p.Steps) != 0 { - t.Errorf("%s = %s seq %d with %d steps, want waiting at %d with none", key, p.Outcome, p.Seq, len(p.Steps), i+1) + if p.Outcome != seat.PipelineOutcomeWaiting || p.Seq != int64(i+2) || len(p.Steps) != 0 { + t.Errorf("%s = %s seq %d with %d steps, want waiting at %d with none", key, p.Outcome, p.Seq, len(p.Steps), i+2) } } if len(asks.ids) != first { t.Errorf("a waiting pipeline asked %d steps", len(asks.ids)-first) } - if _, ok := q["waiting.00000000000000000001"]; !ok || string(q["queue.next"].v) != "3" { - t.Errorf("the queue = %v, want waiting.<1 in 20 digits> and queue.next 3", q) + if _, ok := q["waiting.00000000000000000002"]; !ok || string(q["queue.next"].v) != "4" { + t.Errorf("the queue = %v, want waiting.<2 in 20 digits> and queue.next 4", q) } if !slices.Contains(*said, "pipeline-started.main.5") || !slices.Contains(*said, "wait-held.main.5") || len(*waits) != 2 || (*waits)[0].Step != seat.WaitStepPipeline || (*waits)[0].On != seat.WaitOnPipelinesAtOnce || (*waits)[0].Pipeline != "main.5" { diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go index 35156c372..23d4ecb90 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/steps.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/steps.go @@ -693,7 +693,8 @@ func stepsOf(p seat.Pipeline, module string) []seat.StepResult { return out } -// pipelineEnded is p's pipeline-ended (design 47 H §746): its key, branch, source, call, revision and outcome, and per +// pipelineEnded is p's pipeline-ended (design 47 H §746): its key, branch, source, call, revision, sequence (H2 §813 (1), +// H-A-504 addendum) and outcome, and per // mover, in the delivery order of its tiers, its module, fingerprint, commit, widens (H-A-119), released version, step results // and tier; and the movers its end left unfinished (design 47 H2 §786). func pipelineEnded(p seat.Pipeline) seat.PipelineEnded { @@ -704,7 +705,7 @@ func pipelineEnded(p seat.Pipeline) seat.PipelineEnded { } sort.SliceStable(movers, func(i, j int) bool { return movers[i].Tier < movers[j].Tier }) return seat.PipelineEnded{V: 1, Pipeline: p.Pipeline, Branch: p.Branch, Source: p.Source, Call: p.Call, Revision: p.Revision, - Run: p.Run, Outcome: p.Outcome, Why: p.Why, Started: p.Started, Ended: p.Ended, EndCount: p.EndCount, Movers: movers, + Seq: p.Seq, Run: p.Run, Outcome: p.Outcome, Why: p.Why, Started: p.Started, Ended: p.Ended, EndCount: p.EndCount, Movers: movers, Phases: phasesOf(p), Unfinished: unfinishedOf(p)} } -- 2.54.0 From b6702196b88945a0d93d5034f8ce9b74e7097188 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 22 Nov 2026 23:35:51 +0100 Subject: [PATCH 3/3] H-A-504 addendum assigner: a want's run is its pipeline's sequence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit runOf took the pipeline key's last segment, an again run's number, so node-tools 0.1.115 of main.320.again.1 (run "1") was refused on every node under run "2" of main.265.again.2, an older pipeline. The assigner now keeps the sequence pipeline-ended says in its end record and the want rule writes it as the want's run; the compare-and-set and the node-engine's compare stay as they are. A pipeline-ended without seq is refused in the journal and keeps nothing; an end kept before this change, without seq, writes no want and says so once, naming the runner's end-again of its pipeline as the recovery. Builds: design 47 H2 §813 (1), H-A-504 corrected, H-A-504 addendum, H-A-504 second addendum --- .../mesh-delivery-assigner/graphkept_test.go | 36 +++++++++++----- .../integration_test.go | 2 +- .../cmd/mesh-delivery-assigner/pass.go | 15 +++---- .../cmd/mesh-delivery-assigner/pipelines.go | 42 ++++++++++++++++-- .../mesh-delivery-assigner/pipelines_test.go | 43 ++++++++++++++----- .../internal/assign/wants.go | 7 +++ 6 files changed, 111 insertions(+), 34 deletions(-) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/graphkept_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/graphkept_test.go index b8078d174..f90e3ef05 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/graphkept_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/graphkept_test.go @@ -96,21 +96,22 @@ func TestTheWantsAreSaidWantedFromTheKeptAssignmentGraphRevision(t *testing.T) { if err := json.Unmarshal(events[len(events)-1].body, &w); err != nil || len(events) != 3 || !w.Removed || w.Fp != fpTest { t.Errorf("a removing want said %+v (%v), %d events", w, err, len(events)) } - // Design 47 H2 §813 (1), H-A-416: a want carries its run, its pipeline's source in decimal, or the newest source held for a - // want of no pipeline; it is written by compare-and-set refusing a lower run, and one that differs only by its run stands. + // Design 47 H2 §813 (1), H-A-504 corrected and its addendum: a want of a pipeline carries its run, the pipeline's sequence the + // want rule set; a want of no pipeline the newest source held. It is written by compare-and-set refusing a lower run, and + // one that differs only by its run stands. t.Run("a want's run", func(t *testing.T) { wkey, _ := mwc.WantKey("g14", "db") stored := func() mwc.Want { w, _ := mwc.DecodeWant(kv.values[wkey]); return w } - p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.2", Pipeline: "main.12", Rank: 1}) - if w := stored(); w.Run != "12" || w.Pipeline != "main.12" { - t.Fatalf("the want of pipeline main.12 is %+v, want run 12", w) + p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.2", Pipeline: "main.12", Rank: 1, Run: "212"}) + if w := stored(); w.Run != "212" || w.Pipeline != "main.12" { + t.Fatalf("the want of pipeline main.12 is %+v, want run 212", w) } puts := kv.puts - p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.1", Pipeline: "main.11", Rank: 1}) - if w := stored(); w.Run != "12" || w.Version != "0.1.2" || kv.puts != puts { + p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.1", Pipeline: "main.11", Rank: 1, Run: "211"}) + if w := stored(); w.Run != "212" || w.Version != "0.1.2" || kv.puts != puts { t.Errorf("a want of a lower run replaced %+v (%d writes)", w, kv.puts-puts) } - p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.2", Pipeline: "main.12", Rank: 1}) + p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.2", Pipeline: "main.12", Rank: 1, Run: "212"}) if kv.puts != puts { t.Error("a want that stands was written again") } @@ -119,10 +120,23 @@ func TestTheWantsAreSaidWantedFromTheKeptAssignmentGraphRevision(t *testing.T) { if w, _ := mwc.DecodeWant(kv.values[skey]); w.Run != "9" { t.Errorf("a put's want is %+v, want the newest source held, 9", w) } - // a placement's build after the delivery of run 12: the newest source held for it is the want's own, never refused + // a placement's build after the delivery of run 212: the newest source held for it is the want's own, never refused p.putWant(ctx, "g14", "db", mwc.Want{Fp: fpTest, Version: "0.1.0"}) - if w := stored(); w.Run != "12" || w.Version != "0.1.0" { - t.Errorf("a placement's want after run 12 is %+v, want it written at run 12", w) + if w := stored(); w.Run != "212" || w.Version != "0.1.0" { + t.Errorf("a placement's want after run 212 is %+v, want it written at run 212", w) + } + // A want written with an again run's number ("2") is replaced by any sequence; a lower sequence is refused. + nkey, _ := mwc.WantKey("novox", "node-tools") + atNovox := func() mwc.Want { w, _ := mwc.DecodeWant(kv.values[nkey]); return w } + p.putWant(ctx, "novox", "node-tools", mwc.Want{Fp: fpTest, Version: "0.1.96", Pipeline: "main.265.again.2", Rank: 1, Run: "2"}) + p.putWant(ctx, "novox", "node-tools", mwc.Want{Fp: fpTest, Version: "0.1.115", Pipeline: "main.320.again.1", Rank: 1, Run: "270"}) + if w := atNovox(); w.Run != "270" || w.Version != "0.1.115" { + t.Errorf("seq 270 after run 2 left %+v, want 0.1.115 at run 270", w) + } + puts = kv.puts + p.putWant(ctx, "novox", "node-tools", mwc.Want{Fp: fpTest, Version: "0.1.114", Pipeline: "main.319", Rank: 1, Run: "269"}) + if w := atNovox(); w.Run != "270" || kv.puts != puts { + t.Errorf("seq 269 after 270 replaced %+v (%d writes)", w, kv.puts-puts) } }) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go index 8358c76d8..0531f2932 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/integration_test.go @@ -599,7 +599,7 @@ func (b *bed) ended(t *testing.T, source int64, outcome string, movers ...moverA if outcome != mpr.PipelineEndedOutcomePassed { step.Outcome = mpr.StepResultOutcomeFailed } - e := mpr.PipelineEnded{V: 1, Pipeline: pipeline, Branch: trunkBranch, Source: source, Outcome: outcome} + e := mpr.PipelineEnded{V: 1, Pipeline: pipeline, Branch: trunkBranch, Source: source, Seq: 200 + source, Outcome: outcome} for _, m := range movers { e.Movers = append(e.Movers, mpr.MoverEnded{Module: m.module, Fingerprint: m.fp, Version: m.version, Tier: m.tier, Steps: []mpr.StepResult{step}}) } 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 fcd40fdf1..6dc77a0fb 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pass.go @@ -312,15 +312,14 @@ func (p *passer) putWant(ctx context.Context, node, module string, want mwc.Want } } -// runOf is the run a want carries (design 47 H2 §813 (1); H-A-355 (1), H-A-416): the source revision of the pipeline that -// released it, `.`, in decimal; for a want of no pipeline (a put, a placement's build, a removal) the newest -// source the assigner holds for it: the trunk's source of its kept assignment graph revision, or the run of the want written -// (held) when that is newer, so a person's put or placement after a delivery is never refused as older; "" when it holds none. +// runOf is the run a want carries (design 47 H2 §813 (1); H-A-355 (1), H-A-504 corrected and its addendum): the sequence of +// the pipeline that released it, as its pipeline-ended said it, set on the want by the want rule; for a want of no pipeline (a +// put, a placement's build, a removal) the newest source the assigner holds for it: the trunk's source of its kept assignment +// graph revision, or the run of the want written (held) when that is newer, so a person's put or placement after a delivery is +// never refused as older; "" when it holds none. func (p *passer) runOf(want mwc.Want, held *mwc.Want) string { - if i := strings.LastIndexByte(want.Pipeline, '.'); i >= 0 { - if n, err := strconv.ParseInt(want.Pipeline[i+1:], 10, 64); err == nil && n > 0 { - return strconv.FormatInt(n, 10) - } + if want.Run != "" { + return want.Run } var newest int64 if p.graph != nil { 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 c1883405f..87d43f3a3 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines.go @@ -44,8 +44,11 @@ const pipelineEndedSubject = "mesh.seat." + mpr.Seat + ".event." + mpr.EventPipe type End struct { Pipeline string `json:"pipeline"` Source int64 `json:"source"` - Fp string `json:"fp"` - Version string `json:"version"` + // Seq is the pipeline's sequence its pipeline-ended said, written as the run of its wants (design 47 H2 §813 (1), H-A-504 + // addendum). + Seq int64 `json:"seq,omitempty"` + Fp string `json:"fp"` + Version string `json:"version"` // Rank is the mover's tier in the pipeline's delivery order, from 1 (§746, §750). Rank int64 `json:"rank"` } @@ -141,6 +144,8 @@ type pipelineEnds struct { // firsts is, by module, the first watched branch of its registration, the branch of a placement that names none (design // 47 G §14). firsts map[string]string + // noSeq is, by module and pipeline, the ends kept without a sequence already said (H-A-504 second addendum). + noSeq map[string]bool // runEnded is told a run on request's pipeline-ended, its group `run-`, to drop the run's candidate (A-235, H-A-58); nil // drops nothing. runEnded func(group string) error @@ -178,6 +183,13 @@ func (e *pipelineEnds) take(p mpr.PipelineEnded) (bool, error) { e.logf("the pipeline-ended of %s is refused, and none of its movers' versions is kept: %v", p.Pipeline, err) return false, nil } + // Its sequence is its wants' run (design 47 H2 §813 (1), H-A-504 addendum): an end without one, of an older runner, is + // refused loudly and writes no want. + if p.Seq <= 0 { + e.logf("the pipeline-ended of %s is refused, and none of its movers' versions is kept: it carries no seq, the run its "+ + "wants would carry (a runner older than H-A-504's addendum); the runner's end-again of %s, once it says seq, keeps them", p.Pipeline, p.Pipeline) + return false, nil + } changed := false var kept []tierMover versioned := map[string]bool{} @@ -219,7 +231,7 @@ func (e *pipelineEnds) take(p mpr.PipelineEnded) (bool, error) { break // an older version, or this one again } } - value, err := json.Marshal(End{Pipeline: p.Pipeline, Source: p.Source, Fp: m.Fingerprint, Version: m.Version, Rank: max(m.Tier, 1)}) + value, err := json.Marshal(End{Pipeline: p.Pipeline, Source: p.Source, Seq: p.Seq, Fp: m.Fingerprint, Version: m.Version, Rank: max(m.Tier, 1)}) if err != nil { return changed, err } @@ -236,6 +248,22 @@ func (e *pipelineEnds) take(p mpr.PipelineEnded) (bool, error) { return changed, nil } +// noSeqOnce says, once per module and pipeline, that the end kept for module from pipeline carries no sequence and writes +// no want, naming the recovery (H-A-504 second addendum). +func (e *pipelineEnds) noSeqOnce(module, pipeline string) { + e.mu.Lock() + if e.noSeq == nil { + e.noSeq = map[string]bool{} + } + said := e.noSeq[module+" "+pipeline] + e.noSeq[module+" "+pipeline] = true + e.mu.Unlock() + if !said && e.logf != nil { + e.logf("no want of %s is written: its end kept from %s carries no seq, the run its want would carry (kept before "+ + "H-A-504's addendum); the runner's end-again of %s, or %s's next pipeline, writes it", module, pipeline, pipeline, module) + } +} + // endOf is the end kept for module on branch: the newest version released there whose pipeline passed. func (e *pipelineEnds) endOf(module, branch string) (End, bool) { if e == nil { @@ -257,7 +285,13 @@ func (e *pipelineEnds) target(module, branch string) (assign.Target, bool) { if !ok || !e.tierWritten(end) { return assign.Target{}, false } - return assign.Target{Fp: end.Fp, Version: end.Version, Pipeline: end.Pipeline, Rank: end.Rank}, true + if end.Seq <= 0 { + // An end kept before pipeline-ended carried its sequence has no run for its wants (design 47 H2 §813 (1), H-A-504 + // second addendum): it writes no want, said once. + e.noSeqOnce(module, end.Pipeline) + return assign.Target{}, false + } + return assign.Target{Fp: end.Fp, Version: end.Version, Pipeline: end.Pipeline, Rank: end.Rank, Seq: end.Seq}, true } // hearPipeline takes a pipeline-ended: a passed one's released versions are kept (take), and a run on request's drops the diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines_test.go index aff50e807..f870a6d70 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/pipelines_test.go @@ -68,9 +68,9 @@ func mover(module, fp, version string, tier int64, outcome string) mpr.MoverEnde Steps: []mpr.StepResult{{Step: "unit", Status: mpr.StepResultStatusRequired, Outcome: outcome, Module: module}}} } -// ended is the pipeline-ended of the take-in of source on branch, its movers given. +// ended is the pipeline-ended of the take-in of source on branch, its movers given, its sequence 200 + source. func ended(branch string, source int64, outcome string, movers ...mpr.MoverEnded) mpr.PipelineEnded { - return mpr.PipelineEnded{V: 1, Branch: branch, Source: source, EndCount: 1, Outcome: outcome, Movers: movers, + return mpr.PipelineEnded{V: 1, Branch: branch, Source: source, Seq: 200 + source, EndCount: 1, Outcome: outcome, Movers: movers, Pipeline: fmt.Sprintf("%s.%d", branch, source)} } @@ -86,28 +86,34 @@ func TestThePassedVersionIsKept(t *testing.T) { want *End // nil: none kept for web on main }{ {"a passed pipeline keeps its version", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "0.1.2", 2, ok))}, - &End{Pipeline: "main.5", Source: 5, Fp: "fp1", Version: "0.1.2", Rank: 2}}, + &End{Pipeline: "main.5", Source: 5, Seq: 205, Fp: "fp1", Version: "0.1.2", Rank: 2}}, {"nothing to run counts as passed", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, nothing))}, - &End{Pipeline: "main.5", Source: 5, Fp: "fp1", Version: "0.1.2", Rank: 1}}, + &End{Pipeline: "main.5", Source: 5, Seq: 205, Fp: "fp1", Version: "0.1.2", Rank: 1}}, {"a failed pipeline keeps nothing, a passed mover in it neither", []mpr.PipelineEnded{ended("main", 5, fail, mover("web", "fp1", "0.1.2", 1, ok), mover("db", "fp9", "0.3.0", 1, failed))}, nil}, {"a mover whose required step failed keeps nothing", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, failed))}, nil}, {"no version released keeps nothing", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "", 1, ok))}, nil}, {"an older end heard after a newer one keeps the newer", []mpr.PipelineEnded{ended("main", 6, pass, mover("web", "fp2", "0.1.3", 1, ok)), - ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, ok))}, &End{Pipeline: "main.6", Source: 6, Fp: "fp2", Version: "0.1.3", Rank: 1}}, + ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, ok))}, &End{Pipeline: "main.6", Source: 6, Seq: 206, Fp: "fp2", Version: "0.1.3", Rank: 1}}, {"a newer version replaces", []mpr.PipelineEnded{ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, ok)), - ended("main", 6, pass, mover("web", "fp2", "0.1.10", 1, ok))}, &End{Pipeline: "main.6", Source: 6, Fp: "fp2", Version: "0.1.10", Rank: 1}}, + ended("main", 6, pass, mover("web", "fp2", "0.1.10", 1, ok))}, &End{Pipeline: "main.6", Source: 6, Seq: 206, Fp: "fp2", Version: "0.1.10", Rank: 1}}, // H-A-485: an again pipeline's end is kept as a take-in's; a key of no form the runner's seat defines is refused, nothing kept. {"an again pipeline keeps its version", []mpr.PipelineEnded{func() mpr.PipelineEnded { p := ended("main", 5, pass, mover("web", "fp1", "0.1.2", 2, ok)) p.Pipeline = "main.5.again.2" return p - }()}, &End{Pipeline: "main.5.again.2", Source: 5, Fp: "fp1", Version: "0.1.2", Rank: 2}}, + }()}, &End{Pipeline: "main.5.again.2", Source: 5, Seq: 205, Fp: "fp1", Version: "0.1.2", Rank: 2}}, {"a key of no form is refused", []mpr.PipelineEnded{func() mpr.PipelineEnded { p := ended("main", 5, pass, mover("web", "fp1", "0.1.2", 2, ok)) p.Pipeline = "main.5.later.2" return p }()}, nil}, + // H-A-504 addendum: an end without its sequence, of an older runner, is refused and keeps nothing. + {"an end without seq keeps nothing", []mpr.PipelineEnded{func() mpr.PipelineEnded { + p := ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, ok)) + p.Seq = 0 + return p + }()}, nil}, {"a run on request keeps nothing", []mpr.PipelineEnded{func() mpr.PipelineEnded { p := ended("main", 5, pass, mover("web", "fp1", "0.1.2", 1, ok)) p.Run = "r1" @@ -206,7 +212,7 @@ func TestAPassWritesTheWantOfThePassedVersion(t *testing.T) { if !passed { continue } - if w, err := mwc.DecodeWant(raw); err != nil || w.Fp != fp || w.Version != "0.1.2" || w.Pipeline != trunkBranch+".5" || w.Rank != 2 { + if w, err := mwc.DecodeWant(raw); err != nil || w.Fp != fp || w.Version != "0.1.2" || w.Pipeline != trunkBranch+".5" || w.Rank != 2 || w.Run != "205" { t.Errorf("%s: the want on %s = %+v (%v)", c.name, node, w, err) } } @@ -235,8 +241,25 @@ func TestARegistrationNamesTheDefaultBranch(t *testing.T) { if woken == 0 || endsKept() != 1 || e.branchOf("web", "") != "beta" || e.branchOf("other", "") != trunkBranch { t.Errorf("ends kept %d, default branch %q: an unwatched branch's end stayed, or the default is wrong", endsKept(), e.branchOf("web", "")) } - if tg, ok := e.target("web", ""); !ok || tg.Fp != "fp2" { - t.Errorf("the default branch's target = %+v %v", tg, ok) + if tg, ok := e.target("web", ""); !ok || tg.Fp != "fp2" || tg.Seq != 205 { + t.Errorf("the default branch's target = %+v %v, want fp2 at seq 205", tg, ok) + } + // H-A-504 second addendum: an end kept without a sequence (before pipeline-ended said it) writes no want, said once. + raw, rev, _ := st.get(endKey("web", "beta")) + var old End + _ = json.Unmarshal(raw, &old) + old.Seq = 0 + raw, _ = json.Marshal(old) + _ = st.swap(endKey("web", "beta"), raw, rev) + var said []string + e.logf = func(f string, a ...any) { said = append(said, fmt.Sprintf(f, a...)) } + for range 2 { + if tg, ok := e.target("web", ""); ok { + t.Errorf("an end kept without seq is the target %+v", tg) + } + } + if len(said) != 1 || !strings.Contains(said[0], "beta.5") || !strings.Contains(said[0], "end-again") { + t.Errorf("an end kept without seq said %q, want once, naming the pipeline and end-again", said) } e.registered(mpcat.Registration{Module: "web"}, true) if endsKept() != 0 { diff --git a/modules/mesh-delivery-assigner/internal/assign/wants.go b/modules/mesh-delivery-assigner/internal/assign/wants.go index 6e4aea7e8..99fa6f5b7 100644 --- a/modules/mesh-delivery-assigner/internal/assign/wants.go +++ b/modules/mesh-delivery-assigner/internal/assign/wants.go @@ -3,6 +3,7 @@ package assign import ( "fmt" "slices" + "strconv" "strings" "git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient" @@ -28,6 +29,9 @@ type Target struct { Version string Pipeline string Rank int64 + // Seq is the pipeline's sequence, the want's run in decimal (design 47 H2 §813 (1), H-A-504 addendum); 0 for a placement's + // build. + Seq int64 } // Module is what the want rule reads of one module: the nodes it is assigned to, the build each node's want names, the puts @@ -123,6 +127,9 @@ func Wants(m Module, wants map[string]mwc.Want) Outcome { continue } next := mwc.Want{Fp: t.Fp, Version: t.Version, Pipeline: t.Pipeline, Rank: t.Rank, Self: m.selfOn(node)} + if t.Seq > 0 { + next.Run = strconv.FormatInt(t.Seq, 10) + } if had && !before.Removed && !before.Put && before.Fp == t.Fp { // The answers the want carries stay while its build does: a failed backup's (ADR 0539 §16), a held revert's, the yes. next.Backup, next.Words, next.Revert, next.Yes, next.Release = before.Backup, before.Words, before.Revert, before.Yes, before.Release -- 2.54.0