package build import ( "context" "errors" "fmt" ) // **A dropped ask ends its step could-not-run, naming the drop** (design 47 H2 §777, §778; H-A-401, H-A-404; ADR 0664 §4): // the seat mesh-builds' drop ends an ask its caller no longer waits for. A taken ask that runs is cancelled with a Dropped // cause; one not pulled yet is kept in the state taken under DroppedKey, and its pull ends it the same way. Either way the // build step's finish answers it could-not-run with Dropped's words, so no build runs for it after. // The tools of the seat's queue (§777's tools table): AsksTool reads what waits and what is taken, AskDropTool ends one // ask through the seat's verb drop, the hand act recorded first. const ( AsksTool = "builder_asks" AskDropTool = "builder_ask_drop" ) // DroppedPrefix is the key prefix in the state taken of a drop of an ask not pulled yet (H-A-404). const DroppedPrefix = "dropped." // DroppedKey is the key in the state taken of the drop of the ask id. func DroppedKey(id string) string { return DroppedPrefix + id } // Dropped is why a step's context was cancelled by the seat's verb drop, and the value its key keeps: who asked it and why. type Dropped struct { By string `json:"by,omitempty"` Why string `json:"why"` } func (d *Dropped) Error() string { by := d.By if by == "" { by = "its asker" } return fmt.Sprintf("the ask was dropped by %s through the seat mesh-builds' drop: %s", by, d.Why) } // DroppedOf is the drop that cancelled ctx, nil when none did. func DroppedOf(ctx context.Context) *Dropped { var d *Dropped if errors.As(context.Cause(ctx), &d) { return d } return nil }