diff --git a/go/seats/nodeengine/contract.go b/go/seats/nodeengine/contract.go index 4bd7cdd..ff3feac 100644 --- a/go/seats/nodeengine/contract.go +++ b/go/seats/nodeengine/contract.go @@ -26,6 +26,7 @@ const ( VerbCompose = "compose" VerbComposeCandidate = "compose-candidate" VerbManifestReads = "manifest-reads" + VerbApplyOrder = "apply-order" VerbSeatList = "seat-list" VerbSeatListAgain = "seat-list-again" VerbFirstViews = "first-views" @@ -47,7 +48,7 @@ const ( // Verbs is every verb the seat serves, in its definition's order: a new copy each call. func Verbs() []string { - return []string{VerbHandOver, VerbAccessAct, VerbJudgeDirectories, VerbSetuidSearch, VerbRootFree, VerbActs, VerbPackages, VerbComposition, VerbCompose, VerbComposeCandidate, VerbManifestReads, VerbSeatList, VerbSeatListAgain, VerbFirstViews, VerbFirstViewAgain, VerbEntryAgain, VerbProcessBuilds} + return []string{VerbHandOver, VerbAccessAct, VerbJudgeDirectories, VerbSetuidSearch, VerbRootFree, VerbActs, VerbPackages, VerbComposition, VerbCompose, VerbComposeCandidate, VerbManifestReads, VerbApplyOrder, VerbSeatList, VerbSeatListAgain, VerbFirstViews, VerbFirstViewAgain, VerbEntryAgain, VerbProcessBuilds} } // Events is every event published on the seat's subject: a new copy each call. @@ -705,6 +706,14 @@ type LoginFallback struct { Why string `json:"why"` } +// ManifestReadWord is the word a node-engine states in manifest-reads when it reads a want by version and not by digests (design 47 H 772, H-A-45); the assigner holds a node whose engine does not state it. Other words in manifest-reads are free. +type ManifestReadWord = string + +// The values of ManifestReadWord. +const ( + ManifestReadWordWantVersion = "want:version" +) + // ManifestReadsChanged is what a node-engine says when what it reads changed or its node returned (ADR 0618 §4). type ManifestReadsChanged struct { // when it says it, RFC 3339 @@ -1404,6 +1413,32 @@ type ManifestReadsAnswer struct { V int64 `json:"v"` } +// ApplyOrderInput is what apply-order takes. +type ApplyOrderInput struct { +} + +// ApplyOrderAnswerOrderItem is a type of the contract. +type ApplyOrderAnswerOrderItem struct { + // the module whose want waits to be applied + Module string `json:"module"` + // the want's pipeline (its key); absent for a want in none + Pipeline string `json:"pipeline,omitempty"` + // its place in the order, the first applied being 1 + Position int64 `json:"position"` + // the mover's tier in its pipeline; absent for a want in none + Rank int64 `json:"rank,omitempty"` + // the modules it waits on; empty when it waits for nothing + Waits []string `json:"waits"` + // why it stands there, in one sentence + Why string `json:"why"` +} + +// ApplyOrderAnswer is what apply-order answers. +type ApplyOrderAnswer struct { + // one row per unapplied changed want, in the order it will be applied + Order []ApplyOrderAnswerOrderItem `json:"order"` +} + // SeatListInput is what seat-list takes. type SeatListInput struct { } diff --git a/go/seats/nodeengine/contract_test.go b/go/seats/nodeengine/contract_test.go index 4ebf1aa..58b58e7 100644 --- a/go/seats/nodeengine/contract_test.go +++ b/go/seats/nodeengine/contract_test.go @@ -127,6 +127,8 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v CompositionAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "composition says withheld unknown when the grants part does not answer", subject: "", given: "{\"composition\":{\"key\":\"\"},\"judged\":{\"judgement\":\"\",\"waits_for_yes\":false,\"words\":\"\"},\"module\":\"zsh\",\"node\":\"workstation\",\"started\":false,\"withheld-unknown\":\"withheld unknown: the grants part does not answer\"}", wire: "{\"composition\":{\"key\":\"\"},\"judged\":{\"judgement\":\"\",\"waits_for_yes\":false,\"words\":\"\"},\"module\":\"zsh\",\"node\":\"workstation\",\"started\":false,\"withheld-unknown\":\"withheld unknown: the grants part does not answer\"}", decode: func(b []byte) (any, error) { var v CompositionAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, + {name: "apply-order answers the changed wants in the order they are applied, with why and what each waits on", subject: "", given: "{\"order\":[{\"module\":\"mesh-broker\",\"position\":1,\"waits\":[],\"why\":\"the bus module is applied first\"},{\"module\":\"mesh-delivery-view\",\"pipeline\":\"main.2\",\"position\":2,\"rank\":2,\"waits\":[\"mesh-delivery-indexer\"],\"why\":\"rank 2 of main.2, after rank 1\"}]}", wire: "{\"order\":[{\"module\":\"mesh-broker\",\"position\":1,\"waits\":[],\"why\":\"the bus module is applied first\"},{\"module\":\"mesh-delivery-view\",\"pipeline\":\"main.2\",\"position\":2,\"rank\":2,\"waits\":[\"mesh-delivery-indexer\"],\"why\":\"rank 2 of main.2, after rank 1\"}]}", + decode: func(b []byte) (any, error) { var v ApplyOrderAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, } for _, c := range cases { v, err := c.decode([]byte(c.given)) diff --git a/seats/node-engine/fixtures/verbs.json b/seats/node-engine/fixtures/verbs.json index 94914a3..9deecc3 100644 --- a/seats/node-engine/fixtures/verbs.json +++ b/seats/node-engine/fixtures/verbs.json @@ -259,5 +259,29 @@ }, "withheld-unknown": "withheld unknown: the grants part does not answer" } + }, + { + "name": "apply-order answers the changed wants in the order they are applied, with why and what each waits on", + "of": "verb:apply-order.answer", + "given": { + "order": [ + { + "module": "mesh-broker", + "position": 1, + "why": "the bus module is applied first", + "waits": [] + }, + { + "module": "mesh-delivery-view", + "pipeline": "main.2", + "rank": 2, + "position": 2, + "why": "rank 2 of main.2, after rank 1", + "waits": [ + "mesh-delivery-indexer" + ] + } + ] + } } ] diff --git a/seats/node-engine/seat.json b/seats/node-engine/seat.json index 748fbd0..0752123 100644 --- a/seats/node-engine/seat.json +++ b/seats/node-engine/seat.json @@ -724,6 +724,67 @@ }, "class": "read" }, + { + "name": "apply-order", + "optional": true, + "description": "The order this machine's engine will apply its changed wants in, with why: one row per unapplied changed want, the bus module and the backup holder first, then each pipeline's wants by rank, then the rest by name, its own want last, a reverted module first (design 47 H 771, H-A-46). Read-only. Answered by this machine's engine alone.", + "input": { + "type": "object", + "properties": {} + }, + "answer": { + "type": "object", + "properties": { + "order": { + "type": "array", + "items": { + "type": "object", + "properties": { + "module": { + "type": "string", + "description": "the module whose want waits to be applied" + }, + "pipeline": { + "type": "string", + "description": "the want's pipeline (its key); absent for a want in none" + }, + "rank": { + "type": "integer", + "description": "the mover's tier in its pipeline; absent for a want in none" + }, + "position": { + "type": "integer", + "description": "its place in the order, the first applied being 1" + }, + "why": { + "type": "string", + "description": "why it stands there, in one sentence" + }, + "waits": { + "type": "array", + "items": { + "type": "string" + }, + "description": "the modules it waits on; empty when it waits for nothing" + } + }, + "required": [ + "module", + "position", + "why", + "waits" + ] + }, + "description": "one row per unapplied changed want, in the order it will be applied" + } + }, + "required": [ + "order" + ], + "description": "the order this machine's engine applies its changed wants in" + }, + "class": "read" + }, { "name": "seat-list", "description": "The seat list this engine holds and what it waits for (novox/hq ADR 0636 §7): each seat's source (trunk or bootstrap) and digest, the seats held from the bootstrap alone, the definitions refused, the last error and whether the seat mesh-catalog has answered. Read-only.", @@ -1855,6 +1916,13 @@ ], "description": "the answer of an act the operator is asked" }, + "ManifestReadWord": { + "type": "string", + "enum": [ + "want:version" + ], + "description": "the word a node-engine states in manifest-reads when it reads a want by version and not by digests (design 47 H 772, H-A-45); the assigner holds a node whose engine does not state it. Other words in manifest-reads are free" + }, "ManifestReadsChanged": { "type": "object", "properties": { diff --git a/ts/seats/nodeengine/index.d.ts b/ts/seats/nodeengine/index.d.ts index 3c87dec..4a0f14f 100644 --- a/ts/seats/nodeengine/index.d.ts +++ b/ts/seats/nodeengine/index.d.ts @@ -16,6 +16,7 @@ export declare const verbs: { readonly compose: "compose"; readonly composeCandidate: "compose-candidate"; readonly manifestReads: "manifest-reads"; + readonly applyOrder: "apply-order"; readonly seatList: "seat-list"; readonly seatListAgain: "seat-list-again"; readonly firstViews: "first-views"; @@ -378,6 +379,9 @@ export interface LoginFallback { "why": string; } +/** the word a node-engine states in manifest-reads when it reads a want by version and not by digests (design 47 H 772, H-A-45); the assigner holds a node whose engine does not state it. Other words in manifest-reads are free */ +export type ManifestReadWord = "want:version"; + /** what a node-engine says when what it reads changed or its node returned (ADR 0618 §4) */ export interface ManifestReadsChanged { /** when it says it, RFC 3339 */ @@ -1028,6 +1032,31 @@ export interface ManifestReadsAnswer { "v": number; } +/** is what apply-order takes. */ +export interface ApplyOrderInput { +} + +export interface ApplyOrderAnswerOrderItem { + /** the module whose want waits to be applied */ + "module": string; + /** the want's pipeline (its key); absent for a want in none */ + "pipeline"?: string; + /** its place in the order, the first applied being 1 */ + "position": number; + /** the mover's tier in its pipeline; absent for a want in none */ + "rank"?: number; + /** the modules it waits on; empty when it waits for nothing */ + "waits": string[]; + /** why it stands there, in one sentence */ + "why": string; +} + +/** is what apply-order answers. */ +export interface ApplyOrderAnswer { + /** one row per unapplied changed want, in the order it will be applied */ + "order": ApplyOrderAnswerOrderItem[]; +} + /** is what seat-list takes. */ export interface SeatListInput { } diff --git a/ts/seats/nodeengine/index.js b/ts/seats/nodeengine/index.js index 1ce11bb..f5d9135 100644 --- a/ts/seats/nodeengine/index.js +++ b/ts/seats/nodeengine/index.js @@ -16,6 +16,7 @@ export const verbs = { compose: "compose", composeCandidate: "compose-candidate", manifestReads: "manifest-reads", + applyOrder: "apply-order", seatList: "seat-list", seatListAgain: "seat-list-again", firstViews: "first-views",