From 6eb41a17e18b366f05df92b47c3736ce7147ce2a Mon Sep 17 00:00:00 2001 From: jochen Date: Mon, 16 Nov 2026 14:00:30 +0100 Subject: [PATCH] node-engine: a run's compose-candidate key reads candidates.run- by its group, with no heads compared (A-226c) Builds: design 47 G (G-22 lead answers 2) A-226c; A-226b --- internal/selfcompose/candidate.go | 11 ++++++----- internal/selfcompose/candidate_test.go | 8 +++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/internal/selfcompose/candidate.go b/internal/selfcompose/candidate.go index 2c3dd5ca..ef2c65a5 100644 --- a/internal/selfcompose/candidate.go +++ b/internal/selfcompose/candidate.go @@ -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-` (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-`, 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, `.`); 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)) diff --git a/internal/selfcompose/candidate_test.go b/internal/selfcompose/candidate_test.go index 2dff8f97..c7562103 100644 --- a/internal/selfcompose/candidate_test.go +++ b/internal/selfcompose/candidate_test.go @@ -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- 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)