From c94e8564e6dd20e43560ed0f6a38abd847a70b44 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 03:49:06 +0100 Subject: [PATCH] C-R3: the runner's queue keeps the pipelines running MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The seat mesh-pipeline-runner's state queue gains the key form running., value {pipeline}, written when a pipeline is placed and deleted at its end, its cancel or its approval wait, so pipelines-at-once is judged against the running keys alone. A fixture row reads the new form; the generator refused it before the form was defined. Builds: design 47 H §748; lead answer H-A-96 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy --- .../go/seats/meshpipelinerunner/contract.go | 41 +++++++++++++++++++ .../seats/meshpipelinerunner/contract_test.go | 6 +++ .../mesh-pipeline-runner/fixtures/states.json | 7 ++++ .../seats/mesh-pipeline-runner/seat.json | 18 +++++++- .../ts/seats/meshpipelinerunner/index.d.ts | 12 ++++++ .../ts/seats/meshpipelinerunner/index.js | 17 ++++++++ 6 files changed, 100 insertions(+), 1 deletion(-) diff --git a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go index 96e4131c..a1a2a21f 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract.go @@ -340,6 +340,41 @@ func DecodeQueueByWaitingSequenceValue(raw []byte) (QueueByWaitingSequenceValue, return v, nil } +// QueueByRunningPipelineKey is the key of one value of the state queue under the form "running.". +func QueueByRunningPipelineKey(pipeline string) string { return "running." + pipeline } + +// ParseQueueByRunningPipelineKey reads the parts of a key of the form "running.", in the order of the form; the last result is false for a key of another form. +func ParseQueueByRunningPipelineKey(key string) (string, bool) { + rest := key + if !strings.HasPrefix(rest, "running.") { + return "", false + } + rest = rest[8:] + if rest == "" { + return "", false + } + v1 := rest + rest = "" + if rest != "" { + return "", false + } + return v1, true +} + +// DecodeQueueByRunningPipelineValue reads one value of the state queue under the form "running.", refusing a field QueueByRunningPipelineValue does not know and any text after the value. +func DecodeQueueByRunningPipelineValue(raw []byte) (QueueByRunningPipelineValue, error) { + var v QueueByRunningPipelineValue + dec := json.NewDecoder(bytes.NewReader(raw)) + dec.DisallowUnknownFields() + if err := dec.Decode(&v); err != nil { + return v, err + } + if dec.More() { + return v, errors.New("text after the value") + } + return v, nil +} + // KeptByLevelDigestKey is the key of one value of the state kept under the form ".". func KeptByLevelDigestKey(level, digest string) string { return level + "." + digest } @@ -1259,6 +1294,12 @@ type QueueByQueueNextValue = int64 // QueueByWaitingSequenceValue is one value of the state queue under the key waiting.. type QueueByWaitingSequenceValue = Waiting +// QueueByRunningPipelineValue is one value of the state queue under the key running.. +type QueueByRunningPipelineValue struct { + // the pipeline's key, as the key names it + Pipeline string `json:"pipeline"` +} + // KeptByLevelDigestValue is one value of the state kept under the key .. type KeptByLevelDigestValue = KeptResult 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 d4d39dba..d8012f6e 100644 --- a/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go +++ b/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner/contract_test.go @@ -65,6 +65,12 @@ func TestFixtures(t *testing.T) { err := json.Unmarshal(b, &v) return v, err }, subjectIs: nil}, + {name: "a running pipeline in the queue", subject: "", given: "{\"pipeline\":\"main.3589\"}", wire: "{\"pipeline\":\"main.3589\"}", + decode: func(b []byte) (any, error) { + var v QueueByRunningPipelineValue + err := json.Unmarshal(b, &v) + return v, err + }, subjectIs: nil}, {name: "a pipeline waiting its turn, its seq given", subject: "", given: "{\"branch\":\"main\",\"call\":\"fedcba9876543210\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0124\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"waiting\",\"pipeline\":\"main.3590\",\"revision\":13,\"seq\":2,\"source\":3590,\"steps\":[],\"v\":1}", wire: "{\"branch\":\"main\",\"call\":\"fedcba9876543210\",\"movers\":[{\"commit\":\"0123456789abcdef0123456789abcdef01234567\",\"fingerprint\":\"fp-0124\",\"module\":\"nats\",\"repository\":\"mesh-networking\",\"tier\":1}],\"outcome\":\"waiting\",\"pipeline\":\"main.3590\",\"revision\":13,\"seq\":2,\"source\":3590,\"steps\":[],\"v\":1}", decode: func(b []byte) (any, error) { var v PipelinesByBranchSourceValue 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 18285de8..8a189b70 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 @@ -191,6 +191,13 @@ "pipeline": "main.3590" } }, + { + "name": "a running pipeline in the queue", + "of": "state:queue/running.", + "given": { + "pipeline": "main.3589" + } + }, { "name": "a pipeline waiting its turn, its seq given", "of": "state:pipelines/.", 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 68879ae5..a2ba9896 100644 --- a/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json +++ b/modules/mesh-delivery-contracts/seats/mesh-pipeline-runner/seat.json @@ -755,7 +755,7 @@ "name": "queue", "template": "state", "history": 1, - "description": "the pipelines waiting their turn under pipelines-at-once, the lowest sequence read first by key order (design 47 H §748, H-A-36, H-A-72)", + "description": "the pipelines waiting their turn under pipelines-at-once, the lowest sequence read first by key order, and the pipelines running (design 47 H §748, H-A-36, H-A-72, H-A-96)", "key-forms": [ { "key": "queue.next", @@ -771,6 +771,22 @@ "$ref": "#/defs/Waiting" }, "description": "a waiting pipeline, its sequence 20 digits" + }, + { + "key": "running.", + "value": { + "type": "object", + "properties": { + "pipeline": { + "type": "string", + "description": "the pipeline's key, as the key names it" + } + }, + "required": [ + "pipeline" + ] + }, + "description": "a running pipeline, written by compare-and-set when it is placed and deleted at its end, its cancel or its approval wait; pipelines-at-once is judged against these keys alone (H-A-96)" } ] }, 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 ec8bf096..3fef19f9 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.d.ts @@ -123,6 +123,12 @@ export declare function queueByWaitingSequenceKey(sequence: string): string; /** The parts of a key of the form "waiting.", or undefined for a key of another form. */ export declare function parseQueueByWaitingSequenceKey(_key: string): { sequence: string } | undefined; +/** The key of one value of the state queue under the form "running.". */ +export declare function queueByRunningPipelineKey(pipeline: string): string; + +/** The parts of a key of the form "running.", or undefined for a key of another form. */ +export declare function parseQueueByRunningPipelineKey(_key: string): { pipeline: string } | undefined; + /** The key of one value of the state kept under the form ".". */ export declare function keptByLevelDigestKey(level: string, digest: string): string; @@ -769,6 +775,12 @@ export type QueueByQueueNextValue = number; /** is one value of the state queue under the key waiting.. */ export type QueueByWaitingSequenceValue = Waiting; +/** is one value of the state queue under the key running.. */ +export interface QueueByRunningPipelineValue { + /** the pipeline's key, as the key names it */ + "pipeline": string; +} + /** is one value of the state kept under the key .. */ export type KeptByLevelDigestValue = KeptResult; diff --git a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js index e8e03364..721b6839 100644 --- a/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js +++ b/modules/mesh-delivery-contracts/ts/seats/meshpipelinerunner/index.js @@ -203,6 +203,23 @@ export function parseQueueByWaitingSequenceKey(_key) { return { sequence }; } +/** The key of one value of the state queue under the form "running.". */ +export function queueByRunningPipelineKey(pipeline) { + return "running." + pipeline; +} + +/** The parts of a key of the form "running.", or undefined for a key of another form. */ +export function parseQueueByRunningPipelineKey(_key) { + let _rest = _key; + if (!_rest.startsWith("running.")) return undefined; + _rest = _rest.slice(8); + if (_rest === "") return undefined; + const pipeline = _rest; + _rest = ""; + if (_rest !== "") return undefined; + return { pipeline }; +} + /** The key of one value of the state kept under the form ".". */ export function keptByLevelDigestKey(level, digest) { return level + "." + digest;