diff --git a/contracts/go/seats/nodebuildgo/contract.go b/contracts/go/seats/nodebuildgo/contract.go index bec6846f..9247bde7 100644 --- a/contracts/go/seats/nodebuildgo/contract.go +++ b/contracts/go/seats/nodebuildgo/contract.go @@ -497,7 +497,7 @@ type Step struct { Run int64 `json:"run,omitempty"` // when (RFC 3339 time) Started time.Time `json:"started"` - // running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed or refused + // running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed, refused or dropped (ended by the verb drop, its cause the reason) State string `json:"state"` Tool string `json:"tool"` // the layout version diff --git a/contracts/go/seats/nodebuildimage/contract.go b/contracts/go/seats/nodebuildimage/contract.go index 11c36d89..2509a8cd 100644 --- a/contracts/go/seats/nodebuildimage/contract.go +++ b/contracts/go/seats/nodebuildimage/contract.go @@ -497,7 +497,7 @@ type Step struct { Run int64 `json:"run,omitempty"` // when (RFC 3339 time) Started time.Time `json:"started"` - // running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed or refused + // running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed, refused or dropped (ended by the verb drop, its cause the reason) State string `json:"state"` Tool string `json:"tool"` // the layout version diff --git a/contracts/go/seats/nodebuildnode/contract.go b/contracts/go/seats/nodebuildnode/contract.go index 07404adf..e3153eab 100644 --- a/contracts/go/seats/nodebuildnode/contract.go +++ b/contracts/go/seats/nodebuildnode/contract.go @@ -497,7 +497,7 @@ type Step struct { Run int64 `json:"run,omitempty"` // when (RFC 3339 time) Started time.Time `json:"started"` - // running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed or refused + // running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed, refused or dropped (ended by the verb drop, its cause the reason) State string `json:"state"` Tool string `json:"tool"` // the layout version diff --git a/contracts/parts/build-step.json b/contracts/parts/build-step.json index faf2d6a3..b92efdb3 100644 --- a/contracts/parts/build-step.json +++ b/contracts/parts/build-step.json @@ -41,7 +41,7 @@ }, { "name": "drop", - "description": "End an ask this node holds for a caller that no longer waits for it: a step not yet running is refused when it is pulled, one running is cancelled and ends refused, naming who dropped it and why. Writes dropped. in the pauses state; the build module removes the key when it has acted.", + "description": "End an ask this node holds for a caller that no longer waits for it: a step not yet running is ended dropped when the bus gives it, one running is cancelled; both end the step dropped, naming who dropped it and why. Writes dropped. in the pauses state; the build module removes the key when it has acted.", "callers": "the build seats' asker (the builder and the checker)", "input": { "type": "object", @@ -434,7 +434,7 @@ }, "state": { "type": "string", - "description": "running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed or refused" + "description": "running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed, refused or dropped (ended by the verb drop, its cause the reason)" }, "started": { "type": "string", diff --git a/contracts/ts/seats/nodebuildgo/src/parts/build-step.ts b/contracts/ts/seats/nodebuildgo/src/parts/build-step.ts index c3d1c882..9c8f07c7 100644 --- a/contracts/ts/seats/nodebuildgo/src/parts/build-step.ts +++ b/contracts/ts/seats/nodebuildgo/src/parts/build-step.ts @@ -273,7 +273,7 @@ export interface Step { "run"?: number; /** when (RFC 3339 time) */ "started": string; - /** running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed or refused */ + /** running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed, refused or dropped (ended by the verb drop, its cause the reason) */ "state": string; "tool": string; /** the layout version */ diff --git a/contracts/ts/seats/nodebuildimage/src/parts/build-step.ts b/contracts/ts/seats/nodebuildimage/src/parts/build-step.ts index c3d1c882..9c8f07c7 100644 --- a/contracts/ts/seats/nodebuildimage/src/parts/build-step.ts +++ b/contracts/ts/seats/nodebuildimage/src/parts/build-step.ts @@ -273,7 +273,7 @@ export interface Step { "run"?: number; /** when (RFC 3339 time) */ "started": string; - /** running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed or refused */ + /** running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed, refused or dropped (ended by the verb drop, its cause the reason) */ "state": string; "tool": string; /** the layout version */ diff --git a/contracts/ts/seats/nodebuildnode/src/parts/build-step.ts b/contracts/ts/seats/nodebuildnode/src/parts/build-step.ts index c3d1c882..9c8f07c7 100644 --- a/contracts/ts/seats/nodebuildnode/src/parts/build-step.ts +++ b/contracts/ts/seats/nodebuildnode/src/parts/build-step.ts @@ -273,7 +273,7 @@ export interface Step { "run"?: number; /** when (RFC 3339 time) */ "started": string; - /** running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed or refused */ + /** running, again (ended on a transport fault, to be given again by the bus after again-at), passed, failed, refused or dropped (ended by the verb drop, its cause the reason) */ "state": string; "tool": string; /** the layout version */ diff --git a/sdk/buildstep/ask_test.go b/sdk/buildstep/ask_test.go index 876908d9..1c6d3082 100644 --- a/sdk/buildstep/ask_test.go +++ b/sdk/buildstep/ask_test.go @@ -344,6 +344,10 @@ func TestPauseCapacityAndComposerKey(t *testing.T) { if Ended(Step{State: StepRunning}) || Ended(Step{State: StepAgain}) || !Ended(Step{State: StepPassed}) || !Ended(Step{State: StepFailed}) { t.Error("Ended: running and again are no end") } + // Review 1: a step ended by the seat's verb drop is the state dropped, an end that decodes (ADR 0664 §4). + if raw, err := EncodeStep(Step{ID: "mvl0frv18d1990", Tool: "go ask", Node: "ace", State: StepDropped, Reason: "withdrawn"}); err != nil || !Ended(Step{State: StepDropped}) { + t.Errorf("a dropped step: %v (%s)", err, raw) + } if AgainAfter(1) != time.Minute || AgainAfter(2) != 4*time.Minute { t.Errorf("AgainAfter = %v, %v", AgainAfter(1), AgainAfter(2)) } @@ -385,8 +389,7 @@ func TestTheThreeSeatsFixturesFitTheNeutralForms(t *testing.T) { seen++ strict(t, f.Given, &Pause{}) case strings.HasPrefix(f.Of, "state:pauses/dropped."): - seen++ - strict(t, f.Given, &Drop{}) + seen++ // its layout is the generated contracts' Drop, which seatgen checks the fixture against case strings.HasPrefix(f.Of, "state:pauses/capacity."): seen++ strict(t, f.Given, &Capacity{}) diff --git a/sdk/buildstep/passing.go b/sdk/buildstep/passing.go index 535b0bee..0be69a93 100644 --- a/sdk/buildstep/passing.go +++ b/sdk/buildstep/passing.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "strings" - "time" ) // Passing is a fault of the network between a build node and what it reaches (a name lookup, a timeout, a reset @@ -57,17 +56,3 @@ func PassingCause(words string) bool { // TransportFaultWords open the reason of a step that ended failed after its runs met a transport fault (the asker says them, // "a transport fault on 3 runs (nodes): cause"): a reader tells that end from a fault of the source by them (ADR 0664 §3). const TransportFaultWords = "a transport fault on " - -// DropKey is the key of an ask's drop in a build seat's pauses state: "dropped." (the part build-step). -func DropKey(askID string) string { return "dropped." + askID } - -// DroppedPrefix opens every key DropKey makes. -const DroppedPrefix = "dropped." - -// Drop is the value of the key dropped. of a build seat's pauses state: an ask its caller no longer waits for. -type Drop struct { - V int `json:"v,omitempty"` - By string `json:"by,omitempty"` - Why string `json:"why"` - At time.Time `json:"at,omitzero"` -} diff --git a/sdk/buildstep/pause.go b/sdk/buildstep/pause.go index d9da0b87..557825ab 100644 --- a/sdk/buildstep/pause.go +++ b/sdk/buildstep/pause.go @@ -32,6 +32,12 @@ func CapacityKey(node string) (string, error) { return "capacity." + node, nil } +// DropKey is the key of an ask's drop in a build seat's pauses state: "dropped." (the part build-step). +func DropKey(askID string) string { return "dropped." + askID } + +// DroppedPrefix opens every key DropKey makes. +const DroppedPrefix = "dropped." + // Pause is whether a node takes no new ask, and who said so. type Pause struct { V int `json:"v"` diff --git a/sdk/buildstep/steps.go b/sdk/buildstep/steps.go index 1da18405..fc05b1a0 100644 --- a/sdk/buildstep/steps.go +++ b/sdk/buildstep/steps.go @@ -29,6 +29,9 @@ const ( StepPassed = "passed" StepFailed = "failed" StepRefused = "refused" + // StepDropped is a step ended by the seat's verb drop: its asker no longer waited for it (ADR 0664 §4). The cause its + // caller named is its reason. It is an end, and no failure of the source. + StepDropped = "dropped" ) // StepBound is how long an asker waits for one ask's step once a build node took it (30 minutes): past it the asker @@ -58,7 +61,7 @@ type Step struct { Passing bool `json:"passing,omitempty"` } -// Ended says a step's state is an end: passed, failed or refused. A step running, or ended on a transport fault with runs +// Ended says a step's state is an end: passed, failed, refused or dropped. A step running, or ended on a transport fault with runs // left (StepAgain), is not. func Ended(s Step) bool { return s.State != StepRunning && s.State != StepAgain && s.State != "" } @@ -119,9 +122,9 @@ func (s Step) check() error { return fmt.Errorf("buildstep: a step needs its tool") } switch s.State { - case StepRunning, StepAgain, StepPassed, StepFailed, StepRefused: + case StepRunning, StepAgain, StepPassed, StepFailed, StepRefused, StepDropped: default: - return fmt.Errorf("buildstep: the step state %q is not running, again, passed, failed or refused", s.State) + return fmt.Errorf("buildstep: the step state %q is not running, again, passed, failed, refused or dropped", s.State) } if len(s.Result) > 0 && !json.Valid(s.Result) { return fmt.Errorf("buildstep: the step's result is not JSON")