diff --git a/go/clients/nodeengineclient/client_test.go b/go/clients/nodeengineclient/client_test.go index 2c95f97..d4ef6b8 100644 --- a/go/clients/nodeengineclient/client_test.go +++ b/go/clients/nodeengineclient/client_test.go @@ -157,3 +157,24 @@ func TestCandidateKeysOfTheThreeFormsRoundTripAndRefuse(t *testing.T) { t.Errorf("an ask naming a revision: %v", err) } } + +// A-237b: compose-candidate is a verb marked chunks: an ask carries the caller's call token, and an answer names the chunks the +// composition input is sent in; the inline input stays for an ask with no token. +func TestComposeCandidateAskAndAnswerCarryTheChunkedForm(t *testing.T) { + key, _ := RevisionKey("main", 7) + ask, err := EncodeAsk(seat.ComposeCandidateInput{Candidate: key, Input: true, Call: "0123456789abcdef0123456789abcdef"}) + if err != nil { + t.Fatal(err) + } + back, err := DecodeAsk(ask) + if err != nil || back.Call != "0123456789abcdef0123456789abcdef" || !back.Input { + t.Errorf("the ask came back as %+v (%v)", back, err) + } + raw, err := EncodeAnswer(seat.ComposeCandidateAnswer{Node: "n1", Candidate: key, Verdict: Composed, Modules: []seat.Module{}, Own: seat.Module{Module: NodeWord, State: ModuleComposed, Digest: "sha256:" + strings.Repeat("a", 64)}, Chunks: 3}) + if err != nil { + t.Fatal(err) + } + if a, err := DecodeAnswer(raw); err != nil || a.Chunks != 3 || a.Input != nil { + t.Errorf("the answer came back as %+v (%v)", a, err) + } +} diff --git a/go/seats/nodeengine/contract.go b/go/seats/nodeengine/contract.go index 93cb24a..4f86ef3 100644 --- a/go/seats/nodeengine/contract.go +++ b/go/seats/nodeengine/contract.go @@ -1349,6 +1349,8 @@ type ComposeAnswer struct { // ComposeCandidateInput is what compose-candidate takes. type ComposeCandidateInput struct { + // 128 random bits the caller chooses: the subject token of the chunks and acknowledgements the composition input is sent in, whatever its size (design 47 G A-237b); an ask with input and no call is answered inline, as before the checker goes (G-6 section 321) + Call string `json:"call,omitempty"` // the key of the candidate to compose: a check's candidate in the indexer, .; a branch pipeline's catalog graph revision, . (the node-engine reads its entries through mesh-catalog.revision); or a run on request's, run-; built and read by the seat's client (nodeengineclient) Candidate string `json:"candidate"` // also answer the composition input the candidate was composed from, for the sandbox path @@ -1359,7 +1361,9 @@ type ComposeCandidateInput struct { type ComposeCandidateAnswer struct { // the candidate's key Candidate string `json:"candidate"` - // when asked: the composition input it composed from + // when asked with input and a call token: how many chunks of at most 512 KiB carry the composition input, sent on the chunk subject of the call, each acknowledged by the caller (design 47 G A-237b) + Chunks int64 `json:"chunks,omitempty"` + // when asked without a call token: the composition input it composed from, inline, up to what one answer carries (the checker's form, kept until G removes the checker, G-6 section 321) Input map[string]any `json:"input,omitempty"` // every module placed on the node, sorted by name Modules []Module `json:"modules"` diff --git a/seats/node-engine/seat.json b/seats/node-engine/seat.json index c867864..9ba2124 100644 --- a/seats/node-engine/seat.json +++ b/seats/node-engine/seat.json @@ -606,6 +606,10 @@ "input": { "description": "also answer the composition input the candidate was composed from, for the sandbox path", "type": "boolean" + }, + "call": { + "description": "128 random bits the caller chooses: the subject token of the chunks and acknowledgements the composition input is sent in, whatever its size (design 47 G A-237b); an ask with input and no call is answered inline, as before the checker goes (G-6 section 321)", + "type": "string" } }, "required": [ @@ -658,7 +662,12 @@ }, "input": { "type": "object", - "description": "when asked: the composition input it composed from" + "description": "when asked without a call token: the composition input it composed from, inline, up to what one answer carries (the checker's form, kept until G removes the checker, G-6 section 321)" + }, + "chunks": { + "type": "integer", + "minimum": 0, + "description": "when asked with input and a call token: how many chunks of at most 512 KiB carry the composition input, sent on the chunk subject of the call, each acknowledged by the caller (design 47 G A-237b)" } }, "required": [ @@ -671,6 +680,7 @@ "took" ] }, + "chunks": true, "class": "read" }, { diff --git a/ts/seats/nodeengine/index.d.ts b/ts/seats/nodeengine/index.d.ts index b635b61..a9710f1 100644 --- a/ts/seats/nodeengine/index.d.ts +++ b/ts/seats/nodeengine/index.d.ts @@ -981,6 +981,8 @@ export interface ComposeAnswer { /** is what compose-candidate takes. */ export interface ComposeCandidateInput { + /** 128 random bits the caller chooses: the subject token of the chunks and acknowledgements the composition input is sent in, whatever its size (design 47 G A-237b); an ask with input and no call is answered inline, as before the checker goes (G-6 section 321) */ + "call"?: string; /** the key of the candidate to compose: a check's candidate in the indexer, .; a branch pipeline's catalog graph revision, . (the node-engine reads its entries through mesh-catalog.revision); or a run on request's, run-; built and read by the seat's client (nodeengineclient) */ "candidate": string; /** also answer the composition input the candidate was composed from, for the sandbox path */ @@ -991,7 +993,9 @@ export interface ComposeCandidateInput { export interface ComposeCandidateAnswer { /** the candidate's key */ "candidate": string; - /** when asked: the composition input it composed from */ + /** when asked with input and a call token: how many chunks of at most 512 KiB carry the composition input, sent on the chunk subject of the call, each acknowledged by the caller (design 47 G A-237b) */ + "chunks"?: number; + /** when asked without a call token: the composition input it composed from, inline, up to what one answer carries (the checker's form, kept until G removes the checker, G-6 section 321) */ "input"?: Record; /** every module placed on the node, sorted by name */ "modules": Module[];