node-engine: a run's compose-candidate key reads candidates.run-<id> by its group, with no heads compared (A-226c)

Builds: design 47 G (G-22 lead answers 2) A-226c; A-226b
This commit is contained in:
2026-11-16 14:00:30 +01:00
parent a1cd4a1a2f
commit 6eb41a17e1
2 changed files with 13 additions and 6 deletions
+6 -5
View File
@@ -149,10 +149,6 @@ func (s *Shadow) composeCandidate(ctx context.Context, c *Composer, ask nodeengi
if err != nil {
return refuse(err.Error())
}
if key.Kind == nec.CandidateRun {
// A run on request's candidate is named by `run-<id>` (A-226b); the node-engine reads none yet.
return refuse("the node-engine reads no run on request's candidate yet: " + ask.Candidate)
}
if !s.ready.Load() {
return unready(errNotReady.Error())
}
@@ -172,6 +168,11 @@ func (s *Shadow) composeCandidate(ctx context.Context, c *Composer, ask nodeengi
}
} else {
group, heads = key.Group, key.HeadsHash
if key.Kind == nec.CandidateRun {
// A run on request's candidate is the indexer's `candidates.run-<id>`, read by its group as a check's is, with no
// heads to compare: the run is asked for by its id alone (A-226c).
group, heads = "run-"+key.Run, ""
}
// The ask names the check (the composition key, `<group>.<heads hash>`); the indexer keys the group's candidate by
// the group alone (buckets.CandidateKey) and holds its heads hash in the value.
ckey, err := buckets.CandidateKey(group)
@@ -189,7 +190,7 @@ func (s *Shadow) composeCandidate(ctx context.Context, c *Composer, ask nodeengi
if err != nil {
return refuse(fmt.Sprintf("the indexer's candidate %s cannot be read: %v", ask.Candidate, err))
}
if cand.Heads != heads {
if key.Kind == nec.CandidateCheck && cand.Heads != heads {
// The group moved to other heads: the check asked is replaced, and this node composes not a candidate it was
// not asked about. No answer (ADR 0593 §9), never a verdict on the wrong heads.
return unready(fmt.Sprintf("the indexer's candidate of the group %s is at heads %s, not %s: the check asked is replaced", group, cand.Heads, heads))
+7 -1
View File
@@ -163,10 +163,16 @@ func TestTheNodeComposesACandidateOnAsk(t *testing.T) {
if m := s.ComposeCandidate(ctx, nodeengine.ComposeCandidateInput{Candidate: noRev}); m.Verdict != nec.Refused || !strings.Contains(m.Refused, "holds no revision 999") {
t.Errorf("a revision the catalog does not hold answered %+v", m)
}
// A-226c: a run's key reads the indexer's candidates.run-<id> by its group, with no heads compared; one it holds none of is refused.
candidateOf("run-r1", digest2)
runKey, _ := nec.RunKey("r1")
if m := s.ComposeCandidate(ctx, nodeengine.ComposeCandidateInput{Candidate: runKey}); m.Verdict != nec.Refused || !strings.Contains(m.Refused, "run on request") {
if m := s.ComposeCandidate(ctx, nodeengine.ComposeCandidateInput{Candidate: runKey}); m.Verdict != nec.Composed || len(m.Modules) != 1 || m.Modules[0].Fp != fpNew || !m.Modules[0].Changed {
t.Errorf("a run's key answered %+v", m)
}
noRun, _ := nec.RunKey("r2")
if m := s.ComposeCandidate(ctx, nodeengine.ComposeCandidateInput{Candidate: noRun}); m.Verdict != nec.Refused || !strings.Contains(m.Refused, "holds no candidate") {
t.Errorf("a run the indexer holds none of answered %+v", m)
}
missing, _ := nec.CompositionKey("novox/x#8", "0123456789ab")
if m := s.ComposeCandidate(ctx, nodeengine.ComposeCandidateInput{Candidate: missing}); !strings.Contains(m.Refused, "holds no candidate") {
t.Errorf("a candidate the indexer does not hold answered %+v", m)