node-engine seat: compose-candidate is a verb marked chunks; its ask carries a call token and its answer names the chunks (A-237b)
Builds: design 47 G (G-22 lead answers 2) A-237b; A-237, A-249
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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, <group>.<heads hash>; a branch pipeline's catalog graph revision, <branch>.<revision> (the node-engine reads its entries through mesh-catalog.revision); or a run on request's, run-<id>; 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"`
|
||||
|
||||
@@ -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"
|
||||
},
|
||||
{
|
||||
|
||||
Vendored
+5
-1
@@ -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, <group>.<heads hash>; a branch pipeline's catalog graph revision, <branch>.<revision> (the node-engine reads its entries through mesh-catalog.revision); or a run on request's, run-<id>; 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<string, unknown>;
|
||||
/** every module placed on the node, sorted by name */
|
||||
"modules": Module[];
|
||||
|
||||
Reference in New Issue
Block a user