RN5: a step whose status a policy leaves empty is optional and runs

A step neither the artifact's nor the module's policy names is placed as an optional step
(Status returns optional), no longer no step; a failure of it holds nothing.

Builds: design 47 G §553, §23, §32, §535

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
2026-11-12 05:50:24 +01:00
parent 4b47e88369
commit 8953adad88
5 changed files with 25 additions and 23 deletions
@@ -77,7 +77,7 @@ func TestTheRunnerPlacesAPipelineAsksItsBuildTakesItsEndAndAnswersAReview(t *tes
}
// The seats the runner calls, answered as their holders do.
reg := catalog.Registration{Module: "app", Branches: []string{"main"}, Origin: "o/app", Policy: catalog.Policy{Steps: catalog.StepStatuses{Review: "optional"}}}
reg := catalog.Registration{Module: "app", Branches: []string{"main"}, Origin: "o/app", Policy: catalog.Policy{Steps: catalog.StepStatuses{Review: "optional", Composition: "bypass", Approval: "bypass"}}}
answer := func(subject string, body any) {
if _, err := nc.Subscribe(subject, func(m *nats.Msg) {
raw, _ := json.Marshal(map[string]any{"result": body})
@@ -50,7 +50,7 @@ func AskID(pipeline, artifact, step string) string {
// Place places a pipeline's steps (design 47 G §21, §23, §323; A-91): only the steps the module's registration policy
// names, each artifact's lint, unit and integration steps beside the module's composition, review and approval. A step the
// policy does not name is no step. A `bypass` step is placed bypassed and asked of no one; a build step is placed running,
// policy leaves without a status is `optional` (§553). A `bypass` step is placed bypassed and asked of no one; a build step is placed running,
// asked of the build seat the artifact's language names in the catalog half (§323), or, where no seat names it, ended
// could not run naming the missing seat; the module's steps wait. It returns the steps and the asks to put on the seats'
// work queues, one per running step.
@@ -74,9 +74,6 @@ func Place(p seat.Pipeline, reg catalog.Registration, entries map[string]catalog
}
for _, step := range buildSteps {
status := Status(reg, name, step)
if status == "" {
continue
}
s := seat.StepResult{Step: step, Artifact: a.Ref, Status: status, Fingerprint: p.Fingerprint}
if status == seat.StepResultStatusBypass {
s.Outcome, s.Why = seat.StepResultOutcomeBypassed, "bypassed by the module's policy"
@@ -105,9 +102,6 @@ func Place(p seat.Pipeline, reg catalog.Registration, entries map[string]catalog
}
for _, step := range moduleSteps {
status := Status(reg, "", step)
if status == "" {
continue
}
s := seat.StepResult{Step: step, Status: status, Outcome: seat.StepResultOutcomeWaiting}
if status == seat.StepResultStatusBypass {
s.Outcome, s.Why = seat.StepResultOutcomeBypassed, "bypassed by the module's policy"
@@ -49,7 +49,7 @@ func placeFixture() (catalog.Registration, map[string]catalog.CatalogEntry) {
// The runner's asking half (design 47 G §22, §24, §323; A-91): a pipeline's steps are the ones the policy names, a bypassed
// step asked of no one, an artifact no build seat names ended could not run naming it, and each running step asked of its
// build seat's accepted kind step with the pipeline's commit and fingerprint; a step the policy does not name is no step.
// build seat's accepted kind step with the pipeline's commit and fingerprint; a step the policy leaves without a status is optional (§553).
func TestStartPlacesTheStepsThePolicyNamesAndAsksEachBuildSeat(t *testing.T) {
reg, entries := placeFixture()
store := created{}
@@ -67,16 +67,19 @@ func TestStartPlacesTheStepsThePolicyNamesAndAsksEachBuildSeat(t *testing.T) {
for _, st := range p.Steps {
got = append(got, st.Artifact+" "+st.Step+" "+st.Outcome)
}
want := []string{" build running", "app:program lint running", "app:program unit running", "app:tools lint bypassed", "app:tools unit running",
"app:web lint could not run", "app:web unit could not run", " approval waiting"}
// §553: integration, composition and review are named by no policy, so they are optional steps and run.
want := []string{" build running", "app:program lint running", "app:program unit running", "app:program integration running",
"app:tools lint bypassed", "app:tools unit running", "app:tools integration running",
"app:web lint could not run", "app:web unit could not run", "app:web integration could not run",
" composition running", " review waiting", " approval waiting"}
if strings.Join(got, "|") != strings.Join(want, "|") {
t.Errorf("steps = %q, want %q (integration and composition are named by no policy: no step)", got, want)
t.Errorf("steps = %q, want %q", got, want)
}
if !strings.Contains(p.Steps[5].Why, `"rust"`) {
t.Errorf("the step of an artifact no seat builds says %q, want it to name the language", p.Steps[5].Why)
if !strings.Contains(p.Steps[7].Why, `"rust"`) {
t.Errorf("the step of an artifact no seat builds says %q, want it to name the language", p.Steps[7].Why)
}
if len(asks.asks) != 4 {
t.Fatalf("asked %d steps, want the build and the three running ones", len(asks.asks))
if len(asks.asks) != 7 {
t.Fatalf("asked %d steps, want the build, the five running build steps and the composition", len(asks.asks))
}
// A-99: the build is every pipeline's first step, required whatever the policy names, asked of mesh-builds for the
// module's own entry only.
@@ -92,7 +95,7 @@ func TestStartPlacesTheStepsThePolicyNamesAndAsksEachBuildSeat(t *testing.T) {
t.Errorf("the ask = %+v at %s", a, asks.at[1])
}
// A second start of the revision asks nothing.
if ok, err := s.Start(Begin{Branch: "main", Source: 4, Module: "app", Commit: "c1", Entries: entries}); ok || err != nil || len(asks.asks) != 4 {
if ok, err := s.Start(Begin{Branch: "main", Source: 4, Module: "app", Commit: "c1", Entries: entries}); ok || err != nil || len(asks.asks) != 7 {
t.Errorf("second start = %v, %v, %d asks", ok, err, len(asks.asks))
}
}
@@ -198,9 +201,9 @@ func TestResumeAsksTheStepsPlacedAndNotEnded(t *testing.T) {
asks := &stepAsks{}
s := &Starter{Steps: asks, Name: "the-runner", Registration: func(string) (catalog.Registration, bool) { return reg, true }}
n, err := s.Resume(store, "main", Half{Entries: entries})
// main.4 has the build and three running steps of the fixture; main.5 one fewer, its build ended.
if err != nil || n != 7 || len(asks.asks) != 7 {
t.Fatalf("resume asked %d (%d put), %v; want 7", n, len(asks.asks), err)
// main.4 has the build, five running build steps and the composition of the fixture; main.5 one fewer, its build ended.
if err != nil || n != 13 || len(asks.asks) != 13 {
t.Fatalf("resume asked %d (%d put), %v; want 13", n, len(asks.asks), err)
}
for _, id := range asks.ids {
found := false
@@ -12,14 +12,17 @@ import (
// Status is a step's status for one artifact of a module, read from the module's registration and never from a
// manifest (design 47 G §21, §23): the artifact's own status where its policy names one, else the module's. A step
// neither names is "" and is no step of the pipeline (A-91): Place places none for it.
// whose status neither names is `optional` (§553): it runs and a failure holds nothing.
func Status(reg catalog.Registration, artifact, step string) string {
if a, ok := reg.Policy.Artifacts[artifact]; ok {
if s := statusOf(a, step); s != "" {
return s
}
}
return statusOf(reg.Policy.Steps, step)
if s := statusOf(reg.Policy.Steps, step); s != "" {
return s
}
return seat.StepResultStatusOptional
}
func statusOf(s catalog.StepStatuses, step string) string {
@@ -20,7 +20,9 @@ func TestPolicyAndBuildSeat(t *testing.T) {
{"tools", "unit", "bypass"},
{"tools", "integration", "optional"},
{"tools", "approval", "required"},
{"program", "composition", ""},
// A step whose status the policy leaves empty is optional (design 47 G §553), never no step.
{"program", "composition", "optional"},
{"program", "review", "optional"},
} {
if got := Status(reg, c.artifact, c.step); got != c.want {
t.Errorf("Status(%s, %s) = %q, want %q", c.artifact, c.step, got, c.want)