DLV-FB1 sdk: a forge message says a branch was deleted (design 51 *Tagged versions*)

delivery.ForgeBranchDeleted, accepted by checkForgeKind, names the repository and the branch and carries nothing else
(A3's request 2).

Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
2026-11-04 12:02:52 +01:00
parent 63f983897c
commit 46baac8286
3 changed files with 22 additions and 3 deletions
+5
View File
@@ -69,6 +69,11 @@ func TestForgeMergedRefusesBadInputs(t *testing.T) {
// ADR 0565 §2 (issue 1953 D1): the predefined list is one JSON object, said present or absent, never both.
"predefined not an object": {func(f *Forge) { f.Predefined = []byte(`["domain"]`) }, "one JSON object"},
"predefined both": {func(f *Forge) { f.Predefined = []byte(`{}`); f.PredefinedRead = true }, "says the merge holds none"},
// A deleted branch names its branch and carries nothing else (design 51 *Tagged versions*).
"branch-deleted with no branch": {func(f *Forge) { *f = Forge{Kind: ForgeBranchDeleted, Repository: "novox/mesh-sdk"} }, "needs the branch"},
"branch-deleted with a head": {func(f *Forge) {
*f = Forge{Kind: ForgeBranchDeleted, Repository: "novox/mesh-sdk", Branch: "feat/x", Head: "aaaa"}
}, "carries nothing else"},
} {
f := mergedWithInputs()
tc.mut(&f)
+14 -2
View File
@@ -47,6 +47,10 @@ const (
ForgeMerged = "merged"
ForgeRefused = "refused"
ForgeOpen = "open"
// ForgeBranchDeleted says a branch of a repository was deleted on the forge, from the forge's own delete event
// (design 51 *Tagged versions*): the builder removes the tagged versions it asked for that branch. It names the
// repository and the branch and carries nothing else. A reader that does not know the kind ignores it.
ForgeBranchDeleted = "branch-deleted"
)
// OpenPull names an open pull request into the trunk: the repository as `<owner>/<name>` and the number.
@@ -166,10 +170,10 @@ func checkRepository(repository string) error {
func checkForgeKind(kind string) error {
switch kind {
case ForgePull, ForgeMerged, ForgeRefused, ForgeOpen:
case ForgePull, ForgeMerged, ForgeRefused, ForgeOpen, ForgeBranchDeleted:
return nil
}
return fmt.Errorf("delivery: the forge kind %q is not pull, merged, refused or open", kind)
return fmt.Errorf("delivery: the forge kind %q is not pull, merged, refused, open or branch-deleted", kind)
}
// ForgeEvent is the name of a forge message of the given kind: `forge.<owner>.<name>.<kind>`.
@@ -704,6 +708,14 @@ func (f Forge) check() error {
if err := f.checkInputs(func(d string) bool { _, ok := f.Trees[d]; return ok }, "its trees"); err != nil {
return err
}
case ForgeBranchDeleted:
if f.Branch == "" {
return fmt.Errorf("delivery: a branch-deleted message needs the branch")
}
if f.Number != 0 || f.Head != "" || f.Merge != "" || len(f.Dirs) > 0 || len(f.Trees) > 0 || len(f.Manifests) > 0 ||
len(f.Locks) > 0 || len(f.Paths) > 0 || len(f.Packages) > 0 || f.Act != "" {
return fmt.Errorf("delivery: a branch-deleted message names its repository and branch and carries nothing else")
}
case ForgeRefused:
if len(f.Dirs) > 0 || f.DirsKnown {
return fmt.Errorf("delivery: a refused message carries no module directories")
+3 -1
View File
@@ -44,7 +44,7 @@ func TestSourceKeys(t *testing.T) { // 1200/AC1
if err != nil || repo != "novox/mesh-sdk" || kind != ForgeMerged {
t.Fatalf("parse forge event = %q %q %v", repo, kind, err)
}
for _, k := range []string{ForgePull, ForgeMerged, ForgeRefused} {
for _, k := range []string{ForgePull, ForgeMerged, ForgeRefused, ForgeBranchDeleted} {
if _, err := ForgeEvent("a/b", k); err != nil {
t.Errorf("kind %s refused: %v", k, err)
}
@@ -150,6 +150,8 @@ func sampleForges() []Forge {
Trees: map[string]string{"modules/a": "t1"}, Root: "t0"},
{Kind: ForgeRefused, Repository: "novox/mesh-sdk", Act: "novox/mesh-sdk.36.aaaa.view", Words: "403 forbidden"},
{Kind: ForgeOpen, Open: []OpenPull{{Repository: "novox/mesh-sdk", Number: 36}, {Repository: "novox/mesh-control", Number: 7}}},
// A deleted branch, from the forge's delete event (design 51 *Tagged versions*).
{Kind: ForgeBranchDeleted, Repository: "novox/mesh-sdk", Branch: "feat/x"},
}
}