mesh-issues: take every condition key the controller raises, a delivery's with its slash among them (hq issue 475)
mesh/delivery superseded: a newer head of the same pull request
mesh/merge-gate pass: builds mesh-issues → novox; no bus step; every machine composes with the change as it did without (4 of 4 compose)
mesh/repo-check pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-check-typescript.sh (typescript)
mesh/delivery superseded: a newer head of the same pull request
mesh/merge-gate pass: builds mesh-issues → novox; no bus step; every machine composes with the change as it did without (4 of 4 compose)
mesh/repo-check pass: its merge-check.sh passed, each part in its toolchain: merge-check.sh (go), merge-check-typescript.sh (typescript)
The tracker's own pattern refused the slash a delivery's id carries, so no issue could track a delivery's condition and the operator's alert kept saying no issue tracks it. Mirror the controller's key rule instead of a pattern of our own; a router test proves a slashed key is matched and named end to end.
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
@@ -219,13 +220,42 @@ const (
|
||||
var LinkKinds = []string{LinkDuplicates, LinkRelatesTo, LinkDependsOn, LinkPullRequest, LinkDecision, LinkDesign, LinkCondition, LinkDelivery}
|
||||
|
||||
var (
|
||||
pullRequest = regexp.MustCompile(`^[a-z0-9][a-z0-9._-]{0,99}#[1-9][0-9]{0,6}$`)
|
||||
decision = regexp.MustCompile(`^[0-9]{4}$`)
|
||||
conditionKey = regexp.MustCompile(`^[a-z0-9][a-z0-9._:=@-]{0,199}$`)
|
||||
deliveryID = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._:-]{0,99}$`)
|
||||
issueNumber = regexp.MustCompile(`^[1-9][0-9]{0,8}$`)
|
||||
pullRequest = regexp.MustCompile(`^[a-z0-9][a-z0-9._-]{0,99}#[1-9][0-9]{0,6}$`)
|
||||
decision = regexp.MustCompile(`^[0-9]{4}$`)
|
||||
deliveryID = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._:-]{0,99}$`)
|
||||
issueNumber = regexp.MustCompile(`^[1-9][0-9]{0,8}$`)
|
||||
)
|
||||
|
||||
// The controller's rule for a condition's key, mirrored (novox/hq issue 475): mesh-controller's
|
||||
// internal/conditions/condition.go composes every key in `Key` as `<scope>.<id>.<kind>`, the id split on its dots,
|
||||
// each token made of the bus's safe characters `A-Za-z0-9_=/-` (anything else becomes `_`, an empty token `_`),
|
||||
// and `Observation.check` refuses a scope not in its `Scopes`. A delivery's id carries its repository as
|
||||
// owner/name, so its keys hold a slash: the narrower shape this replaced refused every one of them, and no issue
|
||||
// could track a delivery's condition. Mirroring the rule, rather than widening a pattern, keeps the tracker taking
|
||||
// exactly what the controller can raise.
|
||||
var (
|
||||
conditionScopes = []string{"machine", "plan", "call", "build", "merge", "provider", "seat", "bus", "core",
|
||||
"probe", "mesh", "delivery", "module"}
|
||||
conditionKeyToken = regexp.MustCompile(`^[A-Za-z0-9_=/-]+$`)
|
||||
)
|
||||
|
||||
// MostConditionKey is the longest key a link takes: the controller sets no bound, the tracker keeps a link one line.
|
||||
const MostConditionKey = 255
|
||||
|
||||
// isConditionKey says whether k is a key the controller could raise.
|
||||
func isConditionKey(k string) bool {
|
||||
parts := strings.Split(k, ".")
|
||||
if len(k) > MostConditionKey || len(parts) < 3 || !slices.Contains(conditionScopes, parts[0]) {
|
||||
return false
|
||||
}
|
||||
for _, p := range parts {
|
||||
if !conditionKeyToken.MatchString(p) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// checkTarget is a link's target, as its kind takes it, said the one way it is kept.
|
||||
func checkTarget(kind, target string) (string, error) {
|
||||
t := strings.TrimSpace(target)
|
||||
@@ -241,7 +271,8 @@ func checkTarget(kind, target string) (string, error) {
|
||||
case LinkDesign:
|
||||
ok, shape = designPath.MatchString(t), "a design document, such as 03-DESIGN/01-to-be/53-the-issue-tracker.md"
|
||||
case LinkCondition:
|
||||
ok, shape = conditionKey.MatchString(t), "a condition's key as the controller names it"
|
||||
ok, shape = isConditionKey(t), "a condition's key as the controller names it: <scope>.<id>.<kind>, "+
|
||||
"the scope one of "+strings.Join(conditionScopes, ", ")+", each part of letters, digits and _=/-"
|
||||
case LinkDelivery:
|
||||
ok, shape = deliveryID.MatchString(t), "a delivery's id as the controller names it"
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user